aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-10-13 04:52:30 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-13 04:52:30 -0400
commitc493756e2a8a78bcaae30668317890dcfe86e7c3 (patch)
tree8fb40782e79472ed882ff2098d4dd295557278ee /arch
parent0d15504f16f68725e4635aa85411015d1c573b0a (diff)
parent4480f15b3306f43bbb0310d461142b4e897ca45b (diff)
Merge branch 'linus' into oprofile
Conflicts: arch/x86/kernel/apic_32.c include/linux/pci_ids.h
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/kernel/smp.c3
-rw-r--r--arch/arm/Kconfig74
-rw-r--r--arch/arm/Makefile2
-rw-r--r--arch/arm/boot/compressed/Makefile2
-rw-r--r--arch/arm/boot/compressed/head.S3
-rw-r--r--arch/arm/common/Kconfig3
-rw-r--r--arch/arm/common/dmabounce.c287
-rw-r--r--arch/arm/common/gic.c2
-rw-r--r--arch/arm/common/it8152.c14
-rw-r--r--arch/arm/common/locomo.c28
-rw-r--r--arch/arm/common/sa1111.c2
-rw-r--r--arch/arm/common/scoop.c2
-rw-r--r--arch/arm/common/sharpsl_param.c2
-rw-r--r--arch/arm/common/time-acorn.c2
-rw-r--r--arch/arm/common/uengine.c2
-rw-r--r--arch/arm/common/via82c505.c2
-rw-r--r--arch/arm/common/vic.c2
-rw-r--r--arch/arm/configs/afeb9260_defconfig1259
-rw-r--r--arch/arm/configs/at91sam9rlek_defconfig1
-rw-r--r--arch/arm/configs/cm_x300_defconfig1466
-rw-r--r--arch/arm/configs/jornada720_defconfig1057
-rw-r--r--arch/arm/configs/orion5x_defconfig3
-rw-r--r--arch/arm/configs/palmz72_defconfig951
-rw-r--r--arch/arm/configs/viper_defconfig1678
-rw-r--r--arch/arm/configs/xm_x2xx_defconfig (renamed from arch/arm/configs/xm_x270_defconfig)237
-rw-r--r--arch/arm/include/asm/bug.h2
-rw-r--r--arch/arm/include/asm/cacheflush.h90
-rw-r--r--arch/arm/include/asm/cachetype.h52
-rw-r--r--arch/arm/include/asm/cputype.h64
-rw-r--r--arch/arm/include/asm/dma-mapping.h378
-rw-r--r--arch/arm/include/asm/elf.h72
-rw-r--r--arch/arm/include/asm/futex.h124
-rw-r--r--arch/arm/include/asm/io.h5
-rw-r--r--arch/arm/include/asm/irq.h4
-rw-r--r--arch/arm/include/asm/kprobes.h1
-rw-r--r--arch/arm/include/asm/mach/map.h17
-rw-r--r--arch/arm/include/asm/mach/udc_pxa2xx.h3
-rw-r--r--arch/arm/include/asm/mc146818rtc.h2
-rw-r--r--arch/arm/include/asm/memory.h40
-rw-r--r--arch/arm/include/asm/mmu_context.h1
-rw-r--r--arch/arm/include/asm/page.h5
-rw-r--r--arch/arm/include/asm/pgtable.h88
-rw-r--r--arch/arm/include/asm/ptrace.h7
-rw-r--r--arch/arm/include/asm/setup.h11
-rw-r--r--arch/arm/include/asm/sparsemem.h20
-rw-r--r--arch/arm/include/asm/system.h58
-rw-r--r--arch/arm/include/asm/thread_info.h2
-rw-r--r--arch/arm/include/asm/uaccess.h10
-rw-r--r--arch/arm/include/asm/vga.h2
-rw-r--r--arch/arm/kernel/Makefile2
-rw-r--r--arch/arm/kernel/armksyms.c4
-rw-r--r--arch/arm/kernel/bios32.c2
-rw-r--r--arch/arm/kernel/crunch.c2
-rw-r--r--arch/arm/kernel/debug.S5
-rw-r--r--arch/arm/kernel/dma-isa.c3
-rw-r--r--arch/arm/kernel/ecard.c6
-rw-r--r--arch/arm/kernel/elf.c79
-rw-r--r--arch/arm/kernel/entry-armv.S16
-rw-r--r--arch/arm/kernel/entry-common.S25
-rw-r--r--arch/arm/kernel/fiq.c1
-rw-r--r--arch/arm/kernel/head-common.S19
-rw-r--r--arch/arm/kernel/head-nommu.S4
-rw-r--r--arch/arm/kernel/head.S12
-rw-r--r--arch/arm/kernel/init_task.c2
-rw-r--r--arch/arm/kernel/io.c3
-rw-r--r--arch/arm/kernel/irq.c11
-rw-r--r--arch/arm/kernel/kprobes-decode.c4
-rw-r--r--arch/arm/kernel/kprobes.c5
-rw-r--r--arch/arm/kernel/machine_kexec.c2
-rw-r--r--arch/arm/kernel/module.c2
-rw-r--r--arch/arm/kernel/process.c33
-rw-r--r--arch/arm/kernel/ptrace.c10
-rw-r--r--arch/arm/kernel/setup.c279
-rw-r--r--arch/arm/kernel/signal.c2
-rw-r--r--arch/arm/kernel/smp.c1
-rw-r--r--arch/arm/kernel/sys_arm.c3
-rw-r--r--arch/arm/kernel/sys_oabi-compat.c2
-rw-r--r--arch/arm/kernel/time.c2
-rw-r--r--arch/arm/kernel/traps.c18
-rw-r--r--arch/arm/kernel/xscale-cp0.c2
-rw-r--r--arch/arm/lib/ashldi3.S2
-rw-r--r--arch/arm/lib/ashrdi3.S2
-rw-r--r--arch/arm/lib/backtrace.S4
-rw-r--r--arch/arm/lib/changebit.S2
-rw-r--r--arch/arm/lib/clear_user.S3
-rw-r--r--arch/arm/lib/clearbit.S2
-rw-r--r--arch/arm/lib/copy_from_user.S2
-rw-r--r--arch/arm/lib/copy_page.S1
-rw-r--r--arch/arm/lib/copy_to_user.S2
-rw-r--r--arch/arm/lib/csumipv6.S1
-rw-r--r--arch/arm/lib/csumpartial.S1
-rw-r--r--arch/arm/lib/csumpartialcopy.S7
-rw-r--r--arch/arm/lib/csumpartialcopygeneric.S1
-rw-r--r--arch/arm/lib/csumpartialcopyuser.S7
-rw-r--r--arch/arm/lib/delay.S3
-rw-r--r--arch/arm/lib/div64.S1
-rw-r--r--arch/arm/lib/findbit.S8
-rw-r--r--arch/arm/lib/getuser.S14
-rw-r--r--arch/arm/lib/io-readsb.S1
-rw-r--r--arch/arm/lib/io-readsl.S1
-rw-r--r--arch/arm/lib/io-readsw-armv4.S1
-rw-r--r--arch/arm/lib/io-writesb.S1
-rw-r--r--arch/arm/lib/io-writesl.S1
-rw-r--r--arch/arm/lib/io-writesw-armv4.S1
-rw-r--r--arch/arm/lib/lib1funcs.S11
-rw-r--r--arch/arm/lib/lshrdi3.S2
-rw-r--r--arch/arm/lib/memchr.S1
-rw-r--r--arch/arm/lib/memcpy.S1
-rw-r--r--arch/arm/lib/memmove.S1
-rw-r--r--arch/arm/lib/memset.S1
-rw-r--r--arch/arm/lib/memzero.S1
-rw-r--r--arch/arm/lib/muldi3.S2
-rw-r--r--arch/arm/lib/putuser.S18
-rw-r--r--arch/arm/lib/setbit.S2
-rw-r--r--arch/arm/lib/sha1.S3
-rw-r--r--arch/arm/lib/strchr.S1
-rw-r--r--arch/arm/lib/strncpy_from_user.S1
-rw-r--r--arch/arm/lib/strnlen_user.S1
-rw-r--r--arch/arm/lib/strrchr.S1
-rw-r--r--arch/arm/lib/testchangebit.S2
-rw-r--r--arch/arm/lib/testclearbit.S2
-rw-r--r--arch/arm/lib/testsetbit.S2
-rw-r--r--arch/arm/lib/uaccess.S2
-rw-r--r--arch/arm/lib/ucmpdi2.S4
-rw-r--r--arch/arm/mach-at91/Kconfig22
-rw-r--r--arch/arm/mach-at91/Makefile2
-rw-r--r--arch/arm/mach-at91/at91cap9.c6
-rw-r--r--arch/arm/mach-at91/at91cap9_devices.c54
-rw-r--r--arch/arm/mach-at91/at91sam9263.c6
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c53
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c6
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c98
-rw-r--r--arch/arm/mach-at91/at91x40_time.c2
-rw-r--r--arch/arm/mach-at91/board-afeb-9260v1.c210
-rw-r--r--arch/arm/mach-at91/board-cap9adk.c2
-rw-r--r--arch/arm/mach-at91/board-carmeva.c28
-rw-r--r--arch/arm/mach-at91/board-csb337.c12
-rw-r--r--arch/arm/mach-at91/board-csb637.c4
-rw-r--r--arch/arm/mach-at91/board-dk.c4
-rw-r--r--arch/arm/mach-at91/board-ecbat91.c2
-rw-r--r--arch/arm/mach-at91/board-ek.c4
-rw-r--r--arch/arm/mach-at91/board-picotux200.c2
-rw-r--r--arch/arm/mach-at91/board-qil-a9260.c14
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c4
-rw-r--r--arch/arm/mach-at91/board-sam9260ek.c80
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c18
-rw-r--r--arch/arm/mach-at91/board-sam9263ek.c64
-rw-r--r--arch/arm/mach-at91/board-sam9g20ek.c8
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c8
-rw-r--r--arch/arm/mach-at91/board-usb-a9260.c14
-rw-r--r--arch/arm/mach-at91/board-usb-a9263.c14
-rw-r--r--arch/arm/mach-at91/board-yl-9200.c50
-rw-r--r--arch/arm/mach-at91/clock.c3
-rw-r--r--arch/arm/mach-at91/gpio.c5
-rw-r--r--arch/arm/mach-at91/include/mach/at91_pit.h3
-rw-r--r--arch/arm/mach-at91/include/mach/at91_rstc.h3
-rw-r--r--arch/arm/mach-at91/include/mach/at91_rtt.h3
-rw-r--r--arch/arm/mach-at91/include/mach/at91_shdwc.h3
-rw-r--r--arch/arm/mach-at91/include/mach/at91_wdt.h3
-rw-r--r--arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h2
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9260_matrix.h2
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9261_matrix.h2
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9_sdramc.h3
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9_smc.h3
-rw-r--r--arch/arm/mach-at91/include/mach/board.h14
-rw-r--r--arch/arm/mach-at91/include/mach/irqs.h2
-rw-r--r--arch/arm/mach-at91/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-at91/leds.c45
-rw-r--r--arch/arm/mach-at91/pm.c2
-rw-r--r--arch/arm/mach-at91/pm_slowclock.S283
-rw-r--r--arch/arm/mach-clps711x/autcpu12.c2
-rw-r--r--arch/arm/mach-clps711x/cdb89712.c2
-rw-r--r--arch/arm/mach-clps711x/include/mach/system.h2
-rw-r--r--arch/arm/mach-clps711x/irq.c2
-rw-r--r--arch/arm/mach-clps711x/p720t-leds.c2
-rw-r--r--arch/arm/mach-clps711x/p720t.c2
-rw-r--r--arch/arm/mach-clps711x/time.c2
-rw-r--r--arch/arm/mach-clps7500/core.c2
-rw-r--r--arch/arm/mach-clps7500/include/mach/irq.h2
-rw-r--r--arch/arm/mach-clps7500/include/mach/memory.h8
-rw-r--r--arch/arm/mach-clps7500/include/mach/system.h2
-rw-r--r--arch/arm/mach-davinci/Makefile2
-rw-r--r--arch/arm/mach-davinci/board-evm.c341
-rw-r--r--arch/arm/mach-davinci/clock.c2
-rw-r--r--arch/arm/mach-davinci/devices.c48
-rw-r--r--arch/arm/mach-davinci/gpio.c138
-rw-r--r--arch/arm/mach-davinci/id.c3
-rw-r--r--arch/arm/mach-davinci/include/mach/common.h3
-rw-r--r--arch/arm/mach-davinci/include/mach/gpio.h73
-rw-r--r--arch/arm/mach-davinci/include/mach/i2c.h7
-rw-r--r--arch/arm/mach-davinci/include/mach/io.h43
-rw-r--r--arch/arm/mach-davinci/include/mach/system.h2
-rw-r--r--arch/arm/mach-davinci/io.c2
-rw-r--r--arch/arm/mach-davinci/irq.c2
-rw-r--r--arch/arm/mach-davinci/psc.c2
-rw-r--r--arch/arm/mach-davinci/serial.c2
-rw-r--r--arch/arm/mach-davinci/time.c2
-rw-r--r--arch/arm/mach-davinci/usb.c116
-rw-r--r--arch/arm/mach-ebsa110/core.c2
-rw-r--r--arch/arm/mach-ebsa110/io.c2
-rw-r--r--arch/arm/mach-ep93xx/Kconfig14
-rw-r--r--arch/arm/mach-ep93xx/adssphere.c28
-rw-r--r--arch/arm/mach-ep93xx/clock.c2
-rw-r--r--arch/arm/mach-ep93xx/core.c46
-rw-r--r--arch/arm/mach-ep93xx/edb9302.c8
-rw-r--r--arch/arm/mach-ep93xx/edb9302a.c28
-rw-r--r--arch/arm/mach-ep93xx/edb9307.c28
-rw-r--r--arch/arm/mach-ep93xx/edb9312.c8
-rw-r--r--arch/arm/mach-ep93xx/edb9315.c8
-rw-r--r--arch/arm/mach-ep93xx/edb9315a.c28
-rw-r--r--arch/arm/mach-ep93xx/gesbc9312.c29
-rw-r--r--arch/arm/mach-ep93xx/gpio.c6
-rw-r--r--arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h34
-rw-r--r--arch/arm/mach-ep93xx/include/mach/platform.h12
-rw-r--r--arch/arm/mach-ep93xx/include/mach/ts72xx.h2
-rw-r--r--arch/arm/mach-ep93xx/include/mach/uncompress.h21
-rw-r--r--arch/arm/mach-ep93xx/micro9.c34
-rw-r--r--arch/arm/mach-ep93xx/ts72xx.c28
-rw-r--r--arch/arm/mach-footbridge/cats-hw.c2
-rw-r--r--arch/arm/mach-footbridge/common.c2
-rw-r--r--arch/arm/mach-footbridge/dc21285.c2
-rw-r--r--arch/arm/mach-footbridge/dma.c2
-rw-r--r--arch/arm/mach-footbridge/include/mach/memory.h10
-rw-r--r--arch/arm/mach-footbridge/include/mach/system.h2
-rw-r--r--arch/arm/mach-footbridge/isa-irq.c5
-rw-r--r--arch/arm/mach-footbridge/isa-timer.c2
-rw-r--r--arch/arm/mach-footbridge/netwinder-hw.c2
-rw-r--r--arch/arm/mach-footbridge/time.c2
-rw-r--r--arch/arm/mach-h720x/common.c6
-rw-r--r--arch/arm/mach-h720x/cpu-h7202.c4
-rw-r--r--arch/arm/mach-imx/clock.c2
-rw-r--r--arch/arm/mach-imx/include/mach/irqs.h5
-rw-r--r--arch/arm/mach-imx/irq.c38
-rw-r--r--arch/arm/mach-imx/leds-mx1ads.c2
-rw-r--r--arch/arm/mach-imx/time.c2
-rw-r--r--arch/arm/mach-integrator/core.c2
-rw-r--r--arch/arm/mach-integrator/cpu.c2
-rw-r--r--arch/arm/mach-integrator/impd1.c2
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c2
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c5
-rw-r--r--arch/arm/mach-integrator/leds.c2
-rw-r--r--arch/arm/mach-integrator/pci_v3.c2
-rw-r--r--arch/arm/mach-iop13xx/include/mach/memory.h61
-rw-r--r--arch/arm/mach-iop13xx/include/mach/pci.h2
-rw-r--r--arch/arm/mach-iop13xx/io.c2
-rw-r--r--arch/arm/mach-iop13xx/msi.c3
-rw-r--r--arch/arm/mach-iop13xx/setup.c2
-rw-r--r--arch/arm/mach-iop13xx/tpmi.c2
-rw-r--r--arch/arm/mach-iop32x/glantank.c2
-rw-r--r--arch/arm/mach-iop32x/iq31244.c6
-rw-r--r--arch/arm/mach-iop32x/iq80321.c2
-rw-r--r--arch/arm/mach-iop32x/n2100.c2
-rw-r--r--arch/arm/mach-iop33x/iq80331.c2
-rw-r--r--arch/arm/mach-iop33x/iq80332.c2
-rw-r--r--arch/arm/mach-iop33x/uart.c2
-rw-r--r--arch/arm/mach-ixp2000/core.c33
-rw-r--r--arch/arm/mach-ixp2000/enp2611.c8
-rw-r--r--arch/arm/mach-ixp2000/include/mach/ixp2000-regs.h8
-rw-r--r--arch/arm/mach-ixp2000/ixdp2400.c2
-rw-r--r--arch/arm/mach-ixp2000/ixdp2800.c2
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x00.c6
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x01.c6
-rw-r--r--arch/arm/mach-ixp2000/pci.c2
-rw-r--r--arch/arm/mach-ixp23xx/core.c4
-rw-r--r--arch/arm/mach-ixp23xx/ixdp2351.c8
-rw-r--r--arch/arm/mach-ixp23xx/pci.c2
-rw-r--r--arch/arm/mach-ixp4xx/common-pci.c9
-rw-r--r--arch/arm/mach-ixp4xx/common.c2
-rw-r--r--arch/arm/mach-ixp4xx/fsg-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/cpu.h9
-rw-r--r--arch/arm/mach-ixp4xx/ixdp425-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/nas100d-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/nslu2-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/addr-map.c8
-rw-r--r--arch/arm/mach-kirkwood/common.c84
-rw-r--r--arch/arm/mach-kirkwood/common.h7
-rw-r--r--arch/arm/mach-kirkwood/db88f6281-bp-setup.c3
-rw-r--r--arch/arm/mach-kirkwood/include/mach/irqs.h1
-rw-r--r--arch/arm/mach-kirkwood/include/mach/kirkwood.h14
-rw-r--r--arch/arm/mach-kirkwood/include/mach/timex.h1
-rw-r--r--arch/arm/mach-kirkwood/pcie.c6
-rw-r--r--arch/arm/mach-kirkwood/rd88f6192-nas-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/rd88f6281-setup.c3
-rw-r--r--arch/arm/mach-ks8695/cpu.c2
-rw-r--r--arch/arm/mach-ks8695/gpio.c22
-rw-r--r--arch/arm/mach-ks8695/include/mach/memory.h4
-rw-r--r--arch/arm/mach-ks8695/include/mach/regs-gpio.h4
-rw-r--r--arch/arm/mach-ks8695/include/mach/regs-lan.h4
-rw-r--r--arch/arm/mach-ks8695/include/mach/regs-wan.h4
-rw-r--r--arch/arm/mach-ks8695/include/mach/system.h2
-rw-r--r--arch/arm/mach-ks8695/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-ks8695/irq.c2
-rw-r--r--arch/arm/mach-ks8695/pci.c4
-rw-r--r--arch/arm/mach-ks8695/time.c2
-rw-r--r--arch/arm/mach-lh7a40x/Kconfig13
-rw-r--r--arch/arm/mach-lh7a40x/arch-kev7a400.c2
-rw-r--r--arch/arm/mach-lh7a40x/arch-lpd7a40x.c4
-rw-r--r--arch/arm/mach-lh7a40x/common.h1
-rw-r--r--arch/arm/mach-lh7a40x/include/mach/memory.h6
-rw-r--r--arch/arm/mach-lh7a40x/irq-lpd7a40x.c4
-rw-r--r--arch/arm/mach-lh7a40x/ssp-cpld.c2
-rw-r--r--arch/arm/mach-lh7a40x/time.c2
-rw-r--r--arch/arm/mach-loki/addr-map.c2
-rw-r--r--arch/arm/mach-loki/irq.c2
-rw-r--r--arch/arm/mach-loki/lb88rc8480-setup.c2
-rw-r--r--arch/arm/mach-msm/board-halibut.c5
-rw-r--r--arch/arm/mach-msm/common.c2
-rw-r--r--arch/arm/mach-msm/dma.c2
-rw-r--r--arch/arm/mach-msm/io.c2
-rw-r--r--arch/arm/mach-msm/irq.c5
-rw-r--r--arch/arm/mach-msm/timer.c3
-rw-r--r--arch/arm/mach-mv78xx0/addr-map.c2
-rw-r--r--arch/arm/mach-mv78xx0/common.c13
-rw-r--r--arch/arm/mach-mv78xx0/db78x00-bp-setup.c8
-rw-r--r--arch/arm/mach-mv78xx0/include/mach/entry-macro.S18
-rw-r--r--arch/arm/mach-mv78xx0/include/mach/irqs.h7
-rw-r--r--arch/arm/mach-mv78xx0/include/mach/mv78xx0.h2
-rw-r--r--arch/arm/mach-mv78xx0/irq.c1
-rw-r--r--arch/arm/mach-mx2/devices.h15
-rw-r--r--arch/arm/mach-mx2/mx27ads.c12
-rw-r--r--arch/arm/mach-mx2/pcm038.c8
-rw-r--r--arch/arm/mach-mx2/serial.c51
-rw-r--r--arch/arm/mach-mx3/devices.c43
-rw-r--r--arch/arm/mach-mx3/devices.h6
-rw-r--r--arch/arm/mach-mx3/iomux.c6
-rw-r--r--arch/arm/mach-mx3/mm.c2
-rw-r--r--arch/arm/mach-mx3/mx31ads.c120
-rw-r--r--arch/arm/mach-mx3/mx31lite.c6
-rw-r--r--arch/arm/mach-mx3/pcm037.c6
-rw-r--r--arch/arm/mach-netx/generic.c7
-rw-r--r--arch/arm/mach-netx/include/mach/system.h2
-rw-r--r--arch/arm/mach-netx/pfifo.c2
-rw-r--r--arch/arm/mach-netx/time.c2
-rw-r--r--arch/arm/mach-netx/xc.c2
-rw-r--r--arch/arm/mach-ns9xxx/board-a9m9750dev.c5
-rw-r--r--arch/arm/mach-ns9xxx/gpio.c2
-rw-r--r--arch/arm/mach-ns9xxx/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-ns9xxx/irq.c2
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c1
-rw-r--r--arch/arm/mach-omap1/clock.c2
-rw-r--r--arch/arm/mach-omap1/devices.c2
-rw-r--r--arch/arm/mach-omap1/fpga.c6
-rw-r--r--arch/arm/mach-omap1/id.c3
-rw-r--r--arch/arm/mach-omap1/io.c2
-rw-r--r--arch/arm/mach-omap1/irq.c3
-rw-r--r--arch/arm/mach-omap1/leds-h2p2-debug.c2
-rw-r--r--arch/arm/mach-omap1/mailbox.c2
-rw-r--r--arch/arm/mach-omap1/mux.c5
-rw-r--r--arch/arm/mach-omap1/pm.c2
-rw-r--r--arch/arm/mach-omap1/serial.c2
-rw-r--r--arch/arm/mach-omap1/time.c2
-rw-r--r--arch/arm/mach-omap1/timer32k.c2
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c3
-rw-r--r--arch/arm/mach-omap2/board-h4.c3
-rw-r--r--arch/arm/mach-omap2/clock.c5
-rw-r--r--arch/arm/mach-omap2/clock24xx.c3
-rw-r--r--arch/arm/mach-omap2/clock34xx.c2
-rw-r--r--arch/arm/mach-omap2/devices.c2
-rw-r--r--arch/arm/mach-omap2/gpmc.c2
-rw-r--r--arch/arm/mach-omap2/id.c3
-rw-r--r--arch/arm/mach-omap2/io.c2
-rw-r--r--arch/arm/mach-omap2/irq.c2
-rw-r--r--arch/arm/mach-omap2/mailbox.c2
-rw-r--r--arch/arm/mach-omap2/memory.c3
-rw-r--r--arch/arm/mach-omap2/mux.c5
-rw-r--r--arch/arm/mach-omap2/pm.c2
-rw-r--r--arch/arm/mach-omap2/serial.c3
-rw-r--r--arch/arm/mach-orion5x/Kconfig26
-rw-r--r--arch/arm/mach-orion5x/Makefile4
-rw-r--r--arch/arm/mach-orion5x/addr-map.c2
-rw-r--r--arch/arm/mach-orion5x/common.c74
-rw-r--r--arch/arm/mach-orion5x/common.h2
-rw-r--r--arch/arm/mach-orion5x/db88f5281-setup.c2
-rw-r--r--arch/arm/mach-orion5x/dns323-setup.c2
-rw-r--r--arch/arm/mach-orion5x/edmini_v2-setup.c262
-rw-r--r--arch/arm/mach-orion5x/gpio.c2
-rw-r--r--arch/arm/mach-orion5x/include/mach/orion5x.h8
-rw-r--r--arch/arm/mach-orion5x/include/mach/timex.h2
-rw-r--r--arch/arm/mach-orion5x/irq.c4
-rw-r--r--arch/arm/mach-orion5x/kurobox_pro-setup.c4
-rw-r--r--arch/arm/mach-orion5x/lsmini-setup.c279
-rw-r--r--arch/arm/mach-orion5x/mpp.c2
-rw-r--r--arch/arm/mach-orion5x/mss2-setup.c2
-rw-r--r--arch/arm/mach-orion5x/mv2120-setup.c2
-rw-r--r--arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c2
-rw-r--r--arch/arm/mach-orion5x/rd88f5181l-ge-setup.c2
-rw-r--r--arch/arm/mach-orion5x/rd88f5182-setup.c2
-rw-r--r--arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c117
-rw-r--r--arch/arm/mach-orion5x/terastation_pro2-setup.c369
-rw-r--r--arch/arm/mach-orion5x/ts78xx-setup.c3
-rw-r--r--arch/arm/mach-orion5x/tsx09-common.c5
-rw-r--r--arch/arm/mach-orion5x/wnr854t-setup.c2
-rw-r--r--arch/arm/mach-orion5x/wrt350n-v2-setup.c2
-rw-r--r--arch/arm/mach-pnx4008/clock.c2
-rw-r--r--arch/arm/mach-pnx4008/core.c2
-rw-r--r--arch/arm/mach-pnx4008/dma.c2
-rw-r--r--arch/arm/mach-pnx4008/gpio.c2
-rw-r--r--arch/arm/mach-pnx4008/include/mach/system.h2
-rw-r--r--arch/arm/mach-pnx4008/include/mach/timex.h2
-rw-r--r--arch/arm/mach-pnx4008/irq.c2
-rw-r--r--arch/arm/mach-pnx4008/pm.c2
-rw-r--r--arch/arm/mach-pnx4008/serial.c3
-rw-r--r--arch/arm/mach-pnx4008/time.c2
-rw-r--r--arch/arm/mach-pxa/Kconfig94
-rw-r--r--arch/arm/mach-pxa/Makefile37
-rw-r--r--arch/arm/mach-pxa/akita-ioexp.c222
-rw-r--r--arch/arm/mach-pxa/am200epd.c374
-rw-r--r--arch/arm/mach-pxa/cm-x255.c258
-rw-r--r--arch/arm/mach-pxa/cm-x270-pci.h13
-rw-r--r--arch/arm/mach-pxa/cm-x270.c472
-rw-r--r--arch/arm/mach-pxa/cm-x2xx-pci.c (renamed from arch/arm/mach-pxa/cm-x270-pci.c)56
-rw-r--r--arch/arm/mach-pxa/cm-x2xx-pci.h13
-rw-r--r--arch/arm/mach-pxa/cm-x2xx.c531
-rw-r--r--arch/arm/mach-pxa/cm-x300.c465
-rw-r--r--arch/arm/mach-pxa/colibri.c11
-rw-r--r--arch/arm/mach-pxa/corgi.c478
-rw-r--r--arch/arm/mach-pxa/corgi_lcd.c290
-rw-r--r--arch/arm/mach-pxa/corgi_pm.c1
-rw-r--r--arch/arm/mach-pxa/corgi_ssp.c276
-rw-r--r--arch/arm/mach-pxa/cpufreq-pxa2xx.c (renamed from arch/arm/mach-pxa/cpu-pxa.c)2
-rw-r--r--arch/arm/mach-pxa/cpufreq-pxa3xx.c258
-rw-r--r--arch/arm/mach-pxa/devices.h1
-rw-r--r--arch/arm/mach-pxa/e330.c43
-rw-r--r--arch/arm/mach-pxa/e350.c43
-rw-r--r--arch/arm/mach-pxa/e400.c94
-rw-r--r--arch/arm/mach-pxa/e400_lcd.c56
-rw-r--r--arch/arm/mach-pxa/e740.c169
-rw-r--r--arch/arm/mach-pxa/e740_lcd.c123
-rw-r--r--arch/arm/mach-pxa/e750.c (renamed from arch/arm/mach-pxa/e750_lcd.c)67
-rw-r--r--arch/arm/mach-pxa/e800.c (renamed from arch/arm/mach-pxa/e800_lcd.c)79
-rw-r--r--arch/arm/mach-pxa/em-x270.c5
-rw-r--r--arch/arm/mach-pxa/eseries.c157
-rw-r--r--arch/arm/mach-pxa/eseries.h4
-rw-r--r--arch/arm/mach-pxa/eseries_udc.c57
-rw-r--r--arch/arm/mach-pxa/generic.c9
-rw-r--r--arch/arm/mach-pxa/generic.h1
-rw-r--r--arch/arm/mach-pxa/gpio.c4
-rw-r--r--arch/arm/mach-pxa/gumstix.c100
-rw-r--r--arch/arm/mach-pxa/idp.c78
-rw-r--r--arch/arm/mach-pxa/include/mach/akita.h32
-rw-r--r--arch/arm/mach-pxa/include/mach/corgi.h11
-rw-r--r--arch/arm/mach-pxa/include/mach/entry-macro.S4
-rw-r--r--arch/arm/mach-pxa/include/mach/hardware.h81
-rw-r--r--arch/arm/mach-pxa/include/mach/i2c.h9
-rw-r--r--arch/arm/mach-pxa/include/mach/irqs.h19
-rw-r--r--arch/arm/mach-pxa/include/mach/littleton.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/memory.h4
-rw-r--r--arch/arm/mach-pxa/include/mach/mfp-pxa25x.h4
-rw-r--r--arch/arm/mach-pxa/include/mach/mfp-pxa320.h8
-rw-r--r--arch/arm/mach-pxa/include/mach/mfp.h5
-rw-r--r--arch/arm/mach-pxa/include/mach/mioa701.h67
-rw-r--r--arch/arm/mach-pxa/include/mach/ohci.h16
-rw-r--r--arch/arm/mach-pxa/include/mach/palmz72.h80
-rw-r--r--arch/arm/mach-pxa/include/mach/pm.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/poodle.h9
-rw-r--r--arch/arm/mach-pxa/include/mach/pxa-regs.h320
-rw-r--r--arch/arm/mach-pxa/include/mach/pxa3xx-regs.h22
-rw-r--r--arch/arm/mach-pxa/include/mach/reset.h9
-rw-r--r--arch/arm/mach-pxa/include/mach/spitz.h42
-rw-r--r--arch/arm/mach-pxa/include/mach/ssp.h24
-rw-r--r--arch/arm/mach-pxa/include/mach/trizeps4.h84
-rw-r--r--arch/arm/mach-pxa/include/mach/viper.h96
-rw-r--r--arch/arm/mach-pxa/irq.c2
-rw-r--r--arch/arm/mach-pxa/leds-trizeps4.c134
-rw-r--r--arch/arm/mach-pxa/leds.c2
-rw-r--r--arch/arm/mach-pxa/littleton.c205
-rw-r--r--arch/arm/mach-pxa/lpd270.c99
-rw-r--r--arch/arm/mach-pxa/lubbock.c26
-rw-r--r--arch/arm/mach-pxa/magician.c16
-rw-r--r--arch/arm/mach-pxa/mainstone.c15
-rw-r--r--arch/arm/mach-pxa/mfp-pxa2xx.c225
-rw-r--r--arch/arm/mach-pxa/mioa701.c905
-rw-r--r--arch/arm/mach-pxa/mioa701_bootresume.S36
-rw-r--r--arch/arm/mach-pxa/mp900.c100
-rw-r--r--arch/arm/mach-pxa/palmtx.c20
-rw-r--r--arch/arm/mach-pxa/palmz72.c554
-rw-r--r--arch/arm/mach-pxa/pcm027.c32
-rw-r--r--arch/arm/mach-pxa/pcm990-baseboard.c33
-rw-r--r--arch/arm/mach-pxa/pm.c18
-rw-r--r--arch/arm/mach-pxa/poodle.c353
-rw-r--r--arch/arm/mach-pxa/pxa25x.c66
-rw-r--r--arch/arm/mach-pxa/pxa27x.c66
-rw-r--r--arch/arm/mach-pxa/pxa3xx.c45
-rw-r--r--arch/arm/mach-pxa/reset.c11
-rw-r--r--arch/arm/mach-pxa/sharpsl_pm.c16
-rw-r--r--arch/arm/mach-pxa/spitz.c537
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c28
-rw-r--r--arch/arm/mach-pxa/ssp.c2
-rw-r--r--arch/arm/mach-pxa/time.c2
-rw-r--r--arch/arm/mach-pxa/tosa.c2
-rw-r--r--arch/arm/mach-pxa/trizeps4.c551
-rw-r--r--arch/arm/mach-pxa/viper.c951
-rw-r--r--arch/arm/mach-pxa/zylonite.c17
-rw-r--r--arch/arm/mach-pxa/zylonite_pxa300.c12
-rw-r--r--arch/arm/mach-pxa/zylonite_pxa320.c10
-rw-r--r--arch/arm/mach-realview/core.c2
-rw-r--r--arch/arm/mach-realview/core.h2
-rw-r--r--arch/arm/mach-realview/include/mach/system.h2
-rw-r--r--arch/arm/mach-realview/localtimer.c2
-rw-r--r--arch/arm/mach-realview/platsmp.c2
-rw-r--r--arch/arm/mach-realview/realview_eb.c2
-rw-r--r--arch/arm/mach-realview/realview_pb1176.c2
-rw-r--r--arch/arm/mach-realview/realview_pb11mp.c2
-rw-r--r--arch/arm/mach-rpc/dma.c2
-rw-r--r--arch/arm/mach-rpc/include/mach/memory.h8
-rw-r--r--arch/arm/mach-rpc/include/mach/system.h2
-rw-r--r--arch/arm/mach-rpc/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-rpc/irq.c2
-rw-r--r--arch/arm/mach-rpc/riscpc.c2
-rw-r--r--arch/arm/mach-s3c2400/gpio.c2
-rw-r--r--arch/arm/mach-s3c2410/bast-irq.c5
-rw-r--r--arch/arm/mach-s3c2410/clock.c2
-rw-r--r--arch/arm/mach-s3c2410/gpio.c2
-rw-r--r--arch/arm/mach-s3c2410/include/mach/system-reset.h2
-rw-r--r--arch/arm/mach-s3c2410/include/mach/system.h2
-rw-r--r--arch/arm/mach-s3c2410/mach-amlm5900.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-n30.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-otom.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-qt2410.c3
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2410.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-tct_hammer.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-vr1000.c2
-rw-r--r--arch/arm/mach-s3c2410/pm.c2
-rw-r--r--arch/arm/mach-s3c2410/s3c2410.c2
-rw-r--r--arch/arm/mach-s3c2410/usb-simtec.c2
-rw-r--r--arch/arm/mach-s3c2412/clock.c2
-rw-r--r--arch/arm/mach-s3c2412/dma.c2
-rw-r--r--arch/arm/mach-s3c2412/irq.c6
-rw-r--r--arch/arm/mach-s3c2412/mach-smdk2413.c2
-rw-r--r--arch/arm/mach-s3c2412/mach-vstms.c3
-rw-r--r--arch/arm/mach-s3c2412/pm.c2
-rw-r--r--arch/arm/mach-s3c2412/s3c2412.c2
-rw-r--r--arch/arm/mach-s3c2440/clock.c2
-rw-r--r--arch/arm/mach-s3c2440/dsc.c2
-rw-r--r--arch/arm/mach-s3c2440/irq.c9
-rw-r--r--arch/arm/mach-s3c2440/mach-anubis.c3
-rw-r--r--arch/arm/mach-s3c2440/mach-nexcoder.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-osiris.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-rx3715.c3
-rw-r--r--arch/arm/mach-s3c2440/mach-smdk2440.c2
-rw-r--r--arch/arm/mach-s3c2440/s3c2440.c2
-rw-r--r--arch/arm/mach-s3c2442/clock.c2
-rw-r--r--arch/arm/mach-s3c2443/clock.c2
-rw-r--r--arch/arm/mach-s3c2443/dma.c2
-rw-r--r--arch/arm/mach-s3c2443/irq.c7
-rw-r--r--arch/arm/mach-s3c2443/mach-smdk2443.c2
-rw-r--r--arch/arm/mach-s3c2443/s3c2443.c2
-rw-r--r--arch/arm/mach-sa1100/badge4.c44
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1100.c4
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1110.c3
-rw-r--r--arch/arm/mach-sa1100/generic.c14
-rw-r--r--arch/arm/mach-sa1100/include/mach/SA-1100.h16
-rw-r--r--arch/arm/mach-sa1100/include/mach/hardware.h18
-rw-r--r--arch/arm/mach-sa1100/include/mach/memory.h16
-rw-r--r--arch/arm/mach-sa1100/irq.c4
-rw-r--r--arch/arm/mach-sa1100/neponset.c11
-rw-r--r--arch/arm/mach-sa1100/pleb.c13
-rw-r--r--arch/arm/mach-sa1100/simpad.c2
-rw-r--r--arch/arm/mach-sa1100/ssp.c2
-rw-r--r--arch/arm/mach-shark/core.c2
-rw-r--r--arch/arm/mach-shark/include/mach/system.h2
-rw-r--r--arch/arm/mach-shark/irq.c2
-rw-r--r--arch/arm/mach-shark/leds.c2
-rw-r--r--arch/arm/mach-versatile/core.c5
-rw-r--r--arch/arm/mach-versatile/include/mach/system.h2
-rw-r--r--arch/arm/mach-versatile/pci.c2
-rw-r--r--arch/arm/mach-versatile/versatile_ab.c2
-rw-r--r--arch/arm/mach-versatile/versatile_pb.c2
-rw-r--r--arch/arm/mm/Kconfig8
-rw-r--r--arch/arm/mm/Makefile2
-rw-r--r--arch/arm/mm/abort-ev7.S1
-rw-r--r--arch/arm/mm/abort-nommu.S1
-rw-r--r--arch/arm/mm/alignment.c2
-rw-r--r--arch/arm/mm/cache-feroceon-l2.c42
-rw-r--r--arch/arm/mm/cache-l2x0.c2
-rw-r--r--arch/arm/mm/cache-v7.S10
-rw-r--r--arch/arm/mm/cache-xsc3l2.c3
-rw-r--r--arch/arm/mm/copypage-v4mc.c2
-rw-r--r--arch/arm/mm/copypage-v6.c1
-rw-r--r--arch/arm/mm/copypage-xscale.c2
-rw-r--r--arch/arm/mm/dma-mapping.c (renamed from arch/arm/mm/consistent.c)104
-rw-r--r--arch/arm/mm/extable.c2
-rw-r--r--arch/arm/mm/fault-armv.c13
-rw-r--r--arch/arm/mm/fault.c7
-rw-r--r--arch/arm/mm/flush.c1
-rw-r--r--arch/arm/mm/init.c193
-rw-r--r--arch/arm/mm/iomap.c3
-rw-r--r--arch/arm/mm/ioremap.c15
-rw-r--r--arch/arm/mm/mm.h3
-rw-r--r--arch/arm/mm/mmap.c6
-rw-r--r--arch/arm/mm/mmu.c106
-rw-r--r--arch/arm/mm/nommu.c18
-rw-r--r--arch/arm/mm/proc-arm1020.S26
-rw-r--r--arch/arm/mm/proc-arm1020e.S26
-rw-r--r--arch/arm/mm/proc-arm1022.S26
-rw-r--r--arch/arm/mm/proc-arm1026.S26
-rw-r--r--arch/arm/mm/proc-arm6_7.S27
-rw-r--r--arch/arm/mm/proc-arm720.S25
-rw-r--r--arch/arm/mm/proc-arm740.S2
-rw-r--r--arch/arm/mm/proc-arm7tdmi.S2
-rw-r--r--arch/arm/mm/proc-arm920.S28
-rw-r--r--arch/arm/mm/proc-arm922.S26
-rw-r--r--arch/arm/mm/proc-arm925.S26
-rw-r--r--arch/arm/mm/proc-arm926.S26
-rw-r--r--arch/arm/mm/proc-arm940.S2
-rw-r--r--arch/arm/mm/proc-arm946.S2
-rw-r--r--arch/arm/mm/proc-arm9tdmi.S2
-rw-r--r--arch/arm/mm/proc-feroceon.S33
-rw-r--r--arch/arm/mm/proc-macros.S170
-rw-r--r--arch/arm/mm/proc-sa110.S21
-rw-r--r--arch/arm/mm/proc-sa1100.S21
-rw-r--r--arch/arm/mm/proc-v6.S42
-rw-r--r--arch/arm/mm/proc-v7.S39
-rw-r--r--arch/arm/mm/proc-xsc3.S56
-rw-r--r--arch/arm/mm/proc-xscale.S76
-rw-r--r--arch/arm/mm/tlb-v7.S2
-rw-r--r--arch/arm/nwfpe/fpa11_cpdt.c2
-rw-r--r--arch/arm/oprofile/Makefile1
-rw-r--r--arch/arm/oprofile/backtrace.c2
-rw-r--r--arch/arm/oprofile/common.c4
-rw-r--r--arch/arm/oprofile/op_arm_model.h1
-rw-r--r--arch/arm/oprofile/op_model_mpcore.c2
-rw-r--r--arch/arm/oprofile/op_model_v7.c411
-rw-r--r--arch/arm/oprofile/op_model_v7.h103
-rw-r--r--arch/arm/oprofile/op_model_xscale.c2
-rw-r--r--arch/arm/plat-iop/i2c.c2
-rw-r--r--arch/arm/plat-iop/io.c2
-rw-r--r--arch/arm/plat-iop/pci.c2
-rw-r--r--arch/arm/plat-iop/time.c2
-rw-r--r--arch/arm/plat-mxc/Kconfig11
-rw-r--r--arch/arm/plat-mxc/Makefile4
-rw-r--r--arch/arm/plat-mxc/devices.c36
-rw-r--r--arch/arm/plat-mxc/dma-mx1-mx2.c840
-rw-r--r--arch/arm/plat-mxc/include/mach/board-mx31ads.h3
-rw-r--r--arch/arm/plat-mxc/include/mach/clock.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/common.h3
-rw-r--r--arch/arm/plat-mxc/include/mach/dma-mx1-mx2.h89
-rw-r--r--arch/arm/plat-mxc/include/mach/entry-macro.S12
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h24
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx3.h20
-rw-r--r--arch/arm/plat-mxc/include/mach/irqs.h1
-rw-r--r--arch/arm/plat-mxc/include/mach/mx27.h1
-rw-r--r--arch/arm/plat-mxc/include/mach/mx31.h1
-rw-r--r--arch/arm/plat-mxc/include/mach/mxc.h6
-rw-r--r--arch/arm/plat-mxc/irq.c36
-rw-r--r--arch/arm/plat-omap/clock.c3
-rw-r--r--arch/arm/plat-omap/common.c2
-rw-r--r--arch/arm/plat-omap/cpu-omap.c2
-rw-r--r--arch/arm/plat-omap/debug-devices.c2
-rw-r--r--arch/arm/plat-omap/debug-leds.c2
-rw-r--r--arch/arm/plat-omap/devices.c23
-rw-r--r--arch/arm/plat-omap/dmtimer.c2
-rw-r--r--arch/arm/plat-omap/fb.c2
-rw-r--r--arch/arm/plat-omap/gpio.c8
-rw-r--r--arch/arm/plat-omap/include/mach/gpio.h2
-rw-r--r--arch/arm/plat-omap/include/mach/irqs.h2
-rw-r--r--arch/arm/plat-omap/include/mach/mtd-xip.h2
-rw-r--r--arch/arm/plat-omap/mailbox.c2
-rw-r--r--arch/arm/plat-omap/mux.c2
-rw-r--r--arch/arm/plat-omap/ocpi.c2
-rw-r--r--arch/arm/plat-omap/sram.c2
-rw-r--r--arch/arm/plat-omap/usb.c2
-rw-r--r--arch/arm/plat-s3c24xx/clock.c2
-rw-r--r--arch/arm/plat-s3c24xx/common-smdk.c2
-rw-r--r--arch/arm/plat-s3c24xx/cpu.c4
-rw-r--r--arch/arm/plat-s3c24xx/devs.c2
-rw-r--r--arch/arm/plat-s3c24xx/dma.c2
-rw-r--r--arch/arm/plat-s3c24xx/gpio.c2
-rw-r--r--arch/arm/plat-s3c24xx/irq.c26
-rw-r--r--arch/arm/plat-s3c24xx/pm-simtec.c2
-rw-r--r--arch/arm/plat-s3c24xx/pm.c2
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x-clock.c2
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x-irq.c9
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x.c2
-rw-r--r--arch/arm/plat-s3c24xx/time.c2
-rw-r--r--arch/arm/tools/mach-types44
-rw-r--r--arch/arm/vfp/entry.S8
-rw-r--r--arch/arm/vfp/vfphw.S25
-rw-r--r--arch/avr32/boards/atngw100/setup.c19
-rw-r--r--arch/avr32/boards/atstk1000/atstk1002.c23
-rw-r--r--arch/avr32/boards/atstk1000/atstk1003.c15
-rw-r--r--arch/avr32/boards/atstk1000/atstk1004.c18
-rw-r--r--arch/avr32/include/asm/atmel-mci.h32
-rw-r--r--arch/avr32/include/asm/byteorder.h22
-rw-r--r--arch/avr32/include/asm/io.h8
-rw-r--r--arch/avr32/kernel/process.c3
-rw-r--r--arch/avr32/kernel/setup.c19
-rw-r--r--arch/avr32/mach-at32ap/at32ap700x.c460
-rw-r--r--arch/avr32/mach-at32ap/clock.c52
-rw-r--r--arch/avr32/mach-at32ap/clock.h8
-rw-r--r--arch/avr32/mach-at32ap/include/mach/at32ap700x.h128
-rw-r--r--arch/avr32/mach-at32ap/include/mach/board.h2
-rw-r--r--arch/avr32/mach-at32ap/include/mach/io.h3
-rw-r--r--arch/avr32/mach-at32ap/include/mach/portmux.h5
-rw-r--r--arch/avr32/mach-at32ap/pdc.c3
-rw-r--r--arch/avr32/mach-at32ap/pio.c63
-rw-r--r--arch/avr32/oprofile/Makefile2
-rw-r--r--arch/avr32/oprofile/backtrace.c81
-rw-r--r--arch/avr32/oprofile/op_model_avr32.c4
-rw-r--r--arch/cris/arch-v32/kernel/smp.c1
-rw-r--r--arch/ia64/include/asm/dma-mapping.h4
-rw-r--r--arch/ia64/include/asm/sections.h3
-rw-r--r--arch/ia64/include/asm/siginfo.h5
-rw-r--r--arch/ia64/kernel/head.S9
-rw-r--r--arch/ia64/kernel/smpboot.c1
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S8
-rw-r--r--arch/ia64/mm/contig.c2
-rw-r--r--arch/ia64/mm/discontig.c2
-rw-r--r--arch/m32r/kernel/smpboot.c2
-rw-r--r--arch/mips/Kconfig69
-rw-r--r--arch/mips/Makefile122
-rw-r--r--arch/mips/alchemy/Kconfig (renamed from arch/mips/au1000/Kconfig)0
-rw-r--r--arch/mips/alchemy/common/Makefile (renamed from arch/mips/au1000/common/Makefile)0
-rw-r--r--arch/mips/alchemy/common/au1xxx_irqmap.c (renamed from arch/mips/au1000/common/au1xxx_irqmap.c)0
-rw-r--r--arch/mips/alchemy/common/clocks.c (renamed from arch/mips/au1000/common/clocks.c)0
-rw-r--r--arch/mips/alchemy/common/cputable.c (renamed from arch/mips/au1000/common/cputable.c)0
-rw-r--r--arch/mips/alchemy/common/dbdma.c (renamed from arch/mips/au1000/common/dbdma.c)0
-rw-r--r--arch/mips/alchemy/common/dma.c (renamed from arch/mips/au1000/common/dma.c)0
-rw-r--r--arch/mips/alchemy/common/gpio.c (renamed from arch/mips/au1000/common/gpio.c)0
-rw-r--r--arch/mips/alchemy/common/irq.c (renamed from arch/mips/au1000/common/irq.c)0
-rw-r--r--arch/mips/alchemy/common/pci.c (renamed from arch/mips/au1000/common/pci.c)0
-rw-r--r--arch/mips/alchemy/common/platform.c (renamed from arch/mips/au1000/common/platform.c)0
-rw-r--r--arch/mips/alchemy/common/power.c (renamed from arch/mips/au1000/common/power.c)0
-rw-r--r--arch/mips/alchemy/common/prom.c (renamed from arch/mips/au1000/common/prom.c)0
-rw-r--r--arch/mips/alchemy/common/puts.c (renamed from arch/mips/au1000/common/puts.c)0
-rw-r--r--arch/mips/alchemy/common/reset.c (renamed from arch/mips/au1000/common/reset.c)0
-rw-r--r--arch/mips/alchemy/common/setup.c (renamed from arch/mips/au1000/common/setup.c)0
-rw-r--r--arch/mips/alchemy/common/sleeper.S (renamed from arch/mips/au1000/common/sleeper.S)10
-rw-r--r--arch/mips/alchemy/common/time.c (renamed from arch/mips/au1000/common/time.c)0
-rw-r--r--arch/mips/alchemy/db1x00/Makefile (renamed from arch/mips/au1000/db1x00/Makefile)0
-rw-r--r--arch/mips/alchemy/db1x00/board_setup.c (renamed from arch/mips/au1000/db1x00/board_setup.c)0
-rw-r--r--arch/mips/alchemy/db1x00/init.c (renamed from arch/mips/au1000/db1x00/init.c)0
-rw-r--r--arch/mips/alchemy/db1x00/irqmap.c (renamed from arch/mips/au1000/db1x00/irqmap.c)0
-rw-r--r--arch/mips/alchemy/mtx-1/Makefile (renamed from arch/mips/au1000/mtx-1/Makefile)0
-rw-r--r--arch/mips/alchemy/mtx-1/board_setup.c (renamed from arch/mips/au1000/mtx-1/board_setup.c)0
-rw-r--r--arch/mips/alchemy/mtx-1/init.c (renamed from arch/mips/au1000/mtx-1/init.c)0
-rw-r--r--arch/mips/alchemy/mtx-1/irqmap.c (renamed from arch/mips/au1000/mtx-1/irqmap.c)0
-rw-r--r--arch/mips/alchemy/mtx-1/platform.c (renamed from arch/mips/au1000/mtx-1/platform.c)0
-rw-r--r--arch/mips/alchemy/pb1000/Makefile (renamed from arch/mips/au1000/pb1000/Makefile)0
-rw-r--r--arch/mips/alchemy/pb1000/board_setup.c (renamed from arch/mips/au1000/pb1000/board_setup.c)0
-rw-r--r--arch/mips/alchemy/pb1000/init.c (renamed from arch/mips/au1000/pb1000/init.c)0
-rw-r--r--arch/mips/alchemy/pb1000/irqmap.c (renamed from arch/mips/au1000/pb1000/irqmap.c)0
-rw-r--r--arch/mips/alchemy/pb1100/Makefile (renamed from arch/mips/au1000/pb1100/Makefile)0
-rw-r--r--arch/mips/alchemy/pb1100/board_setup.c (renamed from arch/mips/au1000/pb1100/board_setup.c)0
-rw-r--r--arch/mips/alchemy/pb1100/init.c (renamed from arch/mips/au1000/pb1100/init.c)0
-rw-r--r--arch/mips/alchemy/pb1100/irqmap.c (renamed from arch/mips/au1000/pb1100/irqmap.c)0
-rw-r--r--arch/mips/alchemy/pb1200/Makefile (renamed from arch/mips/au1000/pb1200/Makefile)0
-rw-r--r--arch/mips/alchemy/pb1200/board_setup.c (renamed from arch/mips/au1000/pb1200/board_setup.c)0
-rw-r--r--arch/mips/alchemy/pb1200/init.c (renamed from arch/mips/au1000/pb1200/init.c)0
-rw-r--r--arch/mips/alchemy/pb1200/irqmap.c (renamed from arch/mips/au1000/pb1200/irqmap.c)0
-rw-r--r--arch/mips/alchemy/pb1200/platform.c (renamed from arch/mips/au1000/pb1200/platform.c)0
-rw-r--r--arch/mips/alchemy/pb1500/Makefile (renamed from arch/mips/au1000/pb1500/Makefile)0
-rw-r--r--arch/mips/alchemy/pb1500/board_setup.c (renamed from arch/mips/au1000/pb1500/board_setup.c)0
-rw-r--r--arch/mips/alchemy/pb1500/init.c (renamed from arch/mips/au1000/pb1500/init.c)0
-rw-r--r--arch/mips/alchemy/pb1500/irqmap.c (renamed from arch/mips/au1000/pb1500/irqmap.c)0
-rw-r--r--arch/mips/alchemy/pb1550/Makefile (renamed from arch/mips/au1000/pb1550/Makefile)0
-rw-r--r--arch/mips/alchemy/pb1550/board_setup.c (renamed from arch/mips/au1000/pb1550/board_setup.c)0
-rw-r--r--arch/mips/alchemy/pb1550/init.c (renamed from arch/mips/au1000/pb1550/init.c)0
-rw-r--r--arch/mips/alchemy/pb1550/irqmap.c (renamed from arch/mips/au1000/pb1550/irqmap.c)0
-rw-r--r--arch/mips/alchemy/xxs1500/Makefile (renamed from arch/mips/au1000/xxs1500/Makefile)0
-rw-r--r--arch/mips/alchemy/xxs1500/board_setup.c (renamed from arch/mips/au1000/xxs1500/board_setup.c)0
-rw-r--r--arch/mips/alchemy/xxs1500/init.c (renamed from arch/mips/au1000/xxs1500/init.c)0
-rw-r--r--arch/mips/alchemy/xxs1500/irqmap.c (renamed from arch/mips/au1000/xxs1500/irqmap.c)0
-rw-r--r--arch/mips/include/asm/Kbuild3
-rw-r--r--arch/mips/include/asm/a.out.h35
-rw-r--r--arch/mips/include/asm/abi.h25
-rw-r--r--arch/mips/include/asm/addrspace.h154
-rw-r--r--arch/mips/include/asm/asm.h409
-rw-r--r--arch/mips/include/asm/asmmacro-32.h158
-rw-r--r--arch/mips/include/asm/asmmacro-64.h139
-rw-r--r--arch/mips/include/asm/asmmacro.h82
-rw-r--r--arch/mips/include/asm/atomic.h801
-rw-r--r--arch/mips/include/asm/auxvec.h4
-rw-r--r--arch/mips/include/asm/barrier.h155
-rw-r--r--arch/mips/include/asm/bcache.h60
-rw-r--r--arch/mips/include/asm/bitops.h672
-rw-r--r--arch/mips/include/asm/bootinfo.h110
-rw-r--r--arch/mips/include/asm/branch.h38
-rw-r--r--arch/mips/include/asm/break.h34
-rw-r--r--arch/mips/include/asm/bug.h33
-rw-r--r--arch/mips/include/asm/bugs.h53
-rw-r--r--arch/mips/include/asm/byteorder.h76
-rw-r--r--arch/mips/include/asm/cache.h20
-rw-r--r--arch/mips/include/asm/cachectl.h26
-rw-r--r--arch/mips/include/asm/cacheflush.h116
-rw-r--r--arch/mips/include/asm/cacheops.h85
-rw-r--r--arch/mips/include/asm/checksum.h260
-rw-r--r--arch/mips/include/asm/cmp.h18
-rw-r--r--arch/mips/include/asm/cmpxchg.h124
-rw-r--r--arch/mips/include/asm/compat-signal.h119
-rw-r--r--arch/mips/include/asm/compat.h221
-rw-r--r--arch/mips/include/asm/compiler.h19
-rw-r--r--arch/mips/include/asm/cpu-features.h219
-rw-r--r--arch/mips/include/asm/cpu-info.h90
-rw-r--r--arch/mips/include/asm/cpu.h267
-rw-r--r--arch/mips/include/asm/cputime.h6
-rw-r--r--arch/mips/include/asm/current.h23
-rw-r--r--arch/mips/include/asm/debug.h48
-rw-r--r--arch/mips/include/asm/dec/ecc.h55
-rw-r--r--arch/mips/include/asm/dec/interrupts.h126
-rw-r--r--arch/mips/include/asm/dec/ioasic.h38
-rw-r--r--arch/mips/include/asm/dec/ioasic_addrs.h152
-rw-r--r--arch/mips/include/asm/dec/ioasic_ints.h74
-rw-r--r--arch/mips/include/asm/dec/kn01.h90
-rw-r--r--arch/mips/include/asm/dec/kn02.h91
-rw-r--r--arch/mips/include/asm/dec/kn02ba.h67
-rw-r--r--arch/mips/include/asm/dec/kn02ca.h79
-rw-r--r--arch/mips/include/asm/dec/kn02xa.h84
-rw-r--r--arch/mips/include/asm/dec/kn03.h74
-rw-r--r--arch/mips/include/asm/dec/kn05.h76
-rw-r--r--arch/mips/include/asm/dec/kn230.h26
-rw-r--r--arch/mips/include/asm/dec/machtype.h27
-rw-r--r--arch/mips/include/asm/dec/prom.h174
-rw-r--r--arch/mips/include/asm/dec/system.h19
-rw-r--r--arch/mips/include/asm/delay.h112
-rw-r--r--arch/mips/include/asm/device.h7
-rw-r--r--arch/mips/include/asm/div64.h110
-rw-r--r--arch/mips/include/asm/dma-mapping.h81
-rw-r--r--arch/mips/include/asm/dma.h315
-rw-r--r--arch/mips/include/asm/ds1286.h15
-rw-r--r--arch/mips/include/asm/ds1287.h27
-rw-r--r--arch/mips/include/asm/dsp.h85
-rw-r--r--arch/mips/include/asm/edac.h34
-rw-r--r--arch/mips/include/asm/elf.h371
-rw-r--r--arch/mips/include/asm/emergency-restart.h6
-rw-r--r--arch/mips/include/asm/emma2rh/emma2rh.h333
-rw-r--r--arch/mips/include/asm/emma2rh/markeins.h75
-rw-r--r--arch/mips/include/asm/errno.h131
-rw-r--r--arch/mips/include/asm/fb.h19
-rw-r--r--arch/mips/include/asm/fcntl.h61
-rw-r--r--arch/mips/include/asm/fixmap.h118
-rw-r--r--arch/mips/include/asm/floppy.h56
-rw-r--r--arch/mips/include/asm/fpregdef.h99
-rw-r--r--arch/mips/include/asm/fpu.h153
-rw-r--r--arch/mips/include/asm/fpu_emulator.h37
-rw-r--r--arch/mips/include/asm/futex.h203
-rw-r--r--arch/mips/include/asm/fw/arc/hinv.h175
-rw-r--r--arch/mips/include/asm/fw/arc/types.h86
-rw-r--r--arch/mips/include/asm/fw/cfe/cfe_api.h122
-rw-r--r--arch/mips/include/asm/fw/cfe/cfe_error.h80
-rw-r--r--arch/mips/include/asm/gcmpregs.h117
-rw-r--r--arch/mips/include/asm/gic.h487
-rw-r--r--arch/mips/include/asm/gpio.h6
-rw-r--r--arch/mips/include/asm/gt64120.h580
-rw-r--r--arch/mips/include/asm/hardirq.h24
-rw-r--r--arch/mips/include/asm/hazards.h271
-rw-r--r--arch/mips/include/asm/highmem.h67
-rw-r--r--arch/mips/include/asm/hw_irq.h20
-rw-r--r--arch/mips/include/asm/i8253.h21
-rw-r--r--arch/mips/include/asm/i8259.h86
-rw-r--r--arch/mips/include/asm/ide.h13
-rw-r--r--arch/mips/include/asm/inst.h394
-rw-r--r--arch/mips/include/asm/io.h589
-rw-r--r--arch/mips/include/asm/ioctl.h94
-rw-r--r--arch/mips/include/asm/ioctls.h109
-rw-r--r--arch/mips/include/asm/ip32/crime.h158
-rw-r--r--arch/mips/include/asm/ip32/ip32_ints.h114
-rw-r--r--arch/mips/include/asm/ip32/mace.h365
-rw-r--r--arch/mips/include/asm/ipcbuf.h28
-rw-r--r--arch/mips/include/asm/irq.h163
-rw-r--r--arch/mips/include/asm/irq_cpu.h20
-rw-r--r--arch/mips/include/asm/irq_gt641xx.h60
-rw-r--r--arch/mips/include/asm/irq_regs.h21
-rw-r--r--arch/mips/include/asm/irqflags.h283
-rw-r--r--arch/mips/include/asm/isadep.h34
-rw-r--r--arch/mips/include/asm/jazz.h310
-rw-r--r--arch/mips/include/asm/jazzdma.h95
-rw-r--r--arch/mips/include/asm/kdebug.h13
-rw-r--r--arch/mips/include/asm/kexec.h30
-rw-r--r--arch/mips/include/asm/kgdb.h44
-rw-r--r--arch/mips/include/asm/kmap_types.h30
-rw-r--r--arch/mips/include/asm/kspd.h36
-rw-r--r--arch/mips/include/asm/lasat/ds1603.h18
-rw-r--r--arch/mips/include/asm/lasat/eeprom.h17
-rw-r--r--arch/mips/include/asm/lasat/head.h22
-rw-r--r--arch/mips/include/asm/lasat/lasat.h258
-rw-r--r--arch/mips/include/asm/lasat/lasatint.h14
-rw-r--r--arch/mips/include/asm/lasat/picvue.h15
-rw-r--r--arch/mips/include/asm/lasat/serial.h13
-rw-r--r--arch/mips/include/asm/linkage.h10
-rw-r--r--arch/mips/include/asm/local.h221
-rw-r--r--arch/mips/include/asm/m48t35.h27
-rw-r--r--arch/mips/include/asm/m48t37.h35
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1000.h1772
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1000_dma.h458
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1000_gpio.h56
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1100_mmc.h208
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1550_spi.h15
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1xxx.h43
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h386
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1xxx_ide.h194
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1xxx_psc.h505
-rw-r--r--arch/mips/include/asm/mach-au1x00/gpio.h69
-rw-r--r--arch/mips/include/asm/mach-au1x00/ioremap.h42
-rw-r--r--arch/mips/include/asm/mach-au1x00/prom.h13
-rw-r--r--arch/mips/include/asm/mach-au1x00/war.h25
-rw-r--r--arch/mips/include/asm/mach-bcm47xx/bcm47xx.h25
-rw-r--r--arch/mips/include/asm/mach-bcm47xx/gpio.h59
-rw-r--r--arch/mips/include/asm/mach-bcm47xx/war.h25
-rw-r--r--arch/mips/include/asm/mach-cobalt/cobalt.h22
-rw-r--r--arch/mips/include/asm/mach-cobalt/cpu-feature-overrides.h56
-rw-r--r--arch/mips/include/asm/mach-cobalt/irq.h57
-rw-r--r--arch/mips/include/asm/mach-cobalt/mach-gt64120.h27
-rw-r--r--arch/mips/include/asm/mach-cobalt/war.h25
-rw-r--r--arch/mips/include/asm/mach-db1x00/db1200.h230
-rw-r--r--arch/mips/include/asm/mach-db1x00/db1x00.h179
-rw-r--r--arch/mips/include/asm/mach-dec/mc146818rtc.h43
-rw-r--r--arch/mips/include/asm/mach-dec/war.h25
-rw-r--r--arch/mips/include/asm/mach-emma2rh/irq.h15
-rw-r--r--arch/mips/include/asm/mach-emma2rh/war.h25
-rw-r--r--arch/mips/include/asm/mach-excite/cpu-feature-overrides.h48
-rw-r--r--arch/mips/include/asm/mach-excite/excite.h154
-rw-r--r--arch/mips/include/asm/mach-excite/excite_fpga.h80
-rw-r--r--arch/mips/include/asm/mach-excite/excite_nandflash.h7
-rw-r--r--arch/mips/include/asm/mach-excite/rm9k_eth.h23
-rw-r--r--arch/mips/include/asm/mach-excite/rm9k_wdt.h12
-rw-r--r--arch/mips/include/asm/mach-excite/rm9k_xicap.h16
-rw-r--r--arch/mips/include/asm/mach-excite/war.h25
-rw-r--r--arch/mips/include/asm/mach-generic/cpu-feature-overrides.h13
-rw-r--r--arch/mips/include/asm/mach-generic/dma-coherence.h45
-rw-r--r--arch/mips/include/asm/mach-generic/floppy.h139
-rw-r--r--arch/mips/include/asm/mach-generic/gpio.h21
-rw-r--r--arch/mips/include/asm/mach-generic/ide.h167
-rw-r--r--arch/mips/include/asm/mach-generic/ioremap.h34
-rw-r--r--arch/mips/include/asm/mach-generic/irq.h45
-rw-r--r--arch/mips/include/asm/mach-generic/kernel-entry-init.h25
-rw-r--r--arch/mips/include/asm/mach-generic/kmalloc.h13
-rw-r--r--arch/mips/include/asm/mach-generic/mangle-port.h52
-rw-r--r--arch/mips/include/asm/mach-generic/mc146818rtc.h36
-rw-r--r--arch/mips/include/asm/mach-generic/spaces.h85
-rw-r--r--arch/mips/include/asm/mach-generic/topology.h1
-rw-r--r--arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h44
-rw-r--r--arch/mips/include/asm/mach-ip22/ds1286.h18
-rw-r--r--arch/mips/include/asm/mach-ip22/spaces.h27
-rw-r--r--arch/mips/include/asm/mach-ip22/war.h29
-rw-r--r--arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h54
-rw-r--r--arch/mips/include/asm/mach-ip27/dma-coherence.h50
-rw-r--r--arch/mips/include/asm/mach-ip27/irq.h22
-rw-r--r--arch/mips/include/asm/mach-ip27/kernel-entry-init.h59
-rw-r--r--arch/mips/include/asm/mach-ip27/kmalloc.h8
-rw-r--r--arch/mips/include/asm/mach-ip27/mangle-port.h25
-rw-r--r--arch/mips/include/asm/mach-ip27/mmzone.h36
-rw-r--r--arch/mips/include/asm/mach-ip27/spaces.h30
-rw-r--r--arch/mips/include/asm/mach-ip27/topology.h59
-rw-r--r--arch/mips/include/asm/mach-ip27/war.h25
-rw-r--r--arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h50
-rw-r--r--arch/mips/include/asm/mach-ip28/ds1286.h4
-rw-r--r--arch/mips/include/asm/mach-ip28/spaces.h22
-rw-r--r--arch/mips/include/asm/mach-ip28/war.h25
-rw-r--r--arch/mips/include/asm/mach-ip32/cpu-feature-overrides.h50
-rw-r--r--arch/mips/include/asm/mach-ip32/dma-coherence.h72
-rw-r--r--arch/mips/include/asm/mach-ip32/kmalloc.h11
-rw-r--r--arch/mips/include/asm/mach-ip32/mangle-port.h26
-rw-r--r--arch/mips/include/asm/mach-ip32/mc146818rtc.h36
-rw-r--r--arch/mips/include/asm/mach-ip32/war.h25
-rw-r--r--arch/mips/include/asm/mach-jazz/dma-coherence.h40
-rw-r--r--arch/mips/include/asm/mach-jazz/floppy.h135
-rw-r--r--arch/mips/include/asm/mach-jazz/mc146818rtc.h38
-rw-r--r--arch/mips/include/asm/mach-jazz/war.h25
-rw-r--r--arch/mips/include/asm/mach-lasat/irq.h13
-rw-r--r--arch/mips/include/asm/mach-lasat/mach-gt64120.h27
-rw-r--r--arch/mips/include/asm/mach-lasat/war.h25
-rw-r--r--arch/mips/include/asm/mach-lemote/dma-coherence.h42
-rw-r--r--arch/mips/include/asm/mach-lemote/mc146818rtc.h36
-rw-r--r--arch/mips/include/asm/mach-lemote/war.h25
-rw-r--r--arch/mips/include/asm/mach-malta/cpu-feature-overrides.h72
-rw-r--r--arch/mips/include/asm/mach-malta/irq.h9
-rw-r--r--arch/mips/include/asm/mach-malta/kernel-entry-init.h52
-rw-r--r--arch/mips/include/asm/mach-malta/mach-gt64120.h19
-rw-r--r--arch/mips/include/asm/mach-malta/mc146818rtc.h48
-rw-r--r--arch/mips/include/asm/mach-malta/war.h25
-rw-r--r--arch/mips/include/asm/mach-mipssim/cpu-feature-overrides.h65
-rw-r--r--arch/mips/include/asm/mach-mipssim/war.h25
-rw-r--r--arch/mips/include/asm/mach-pb1x00/mc146818rtc.h34
-rw-r--r--arch/mips/include/asm/mach-pb1x00/pb1000.h87
-rw-r--r--arch/mips/include/asm/mach-pb1x00/pb1100.h85
-rw-r--r--arch/mips/include/asm/mach-pb1x00/pb1200.h259
-rw-r--r--arch/mips/include/asm/mach-pb1x00/pb1500.h49
-rw-r--r--arch/mips/include/asm/mach-pb1x00/pb1550.h177
-rw-r--r--arch/mips/include/asm/mach-pnx8550/cm.h43
-rw-r--r--arch/mips/include/asm/mach-pnx8550/glb.h86
-rw-r--r--arch/mips/include/asm/mach-pnx8550/int.h140
-rw-r--r--arch/mips/include/asm/mach-pnx8550/kernel-entry-init.h262
-rw-r--r--arch/mips/include/asm/mach-pnx8550/nand.h121
-rw-r--r--arch/mips/include/asm/mach-pnx8550/pci.h185
-rw-r--r--arch/mips/include/asm/mach-pnx8550/uart.h30
-rw-r--r--arch/mips/include/asm/mach-pnx8550/usb.h32
-rw-r--r--arch/mips/include/asm/mach-pnx8550/war.h25
-rw-r--r--arch/mips/include/asm/mach-rc32434/cpu-feature-overrides.h81
-rw-r--r--arch/mips/include/asm/mach-rc32434/ddr.h141
-rw-r--r--arch/mips/include/asm/mach-rc32434/dma.h103
-rw-r--r--arch/mips/include/asm/mach-rc32434/dma_v.h52
-rw-r--r--arch/mips/include/asm/mach-rc32434/eth.h220
-rw-r--r--arch/mips/include/asm/mach-rc32434/gpio.h88
-rw-r--r--arch/mips/include/asm/mach-rc32434/integ.h59
-rw-r--r--arch/mips/include/asm/mach-rc32434/irq.h33
-rw-r--r--arch/mips/include/asm/mach-rc32434/pci.h481
-rw-r--r--arch/mips/include/asm/mach-rc32434/prom.h40
-rw-r--r--arch/mips/include/asm/mach-rc32434/rb.h84
-rw-r--r--arch/mips/include/asm/mach-rc32434/rc32434.h19
-rw-r--r--arch/mips/include/asm/mach-rc32434/timer.h65
-rw-r--r--arch/mips/include/asm/mach-rc32434/war.h25
-rw-r--r--arch/mips/include/asm/mach-rm/cpu-feature-overrides.h43
-rw-r--r--arch/mips/include/asm/mach-rm/mc146818rtc.h21
-rw-r--r--arch/mips/include/asm/mach-rm/war.h29
-rw-r--r--arch/mips/include/asm/mach-sibyte/cpu-feature-overrides.h47
-rw-r--r--arch/mips/include/asm/mach-sibyte/war.h37
-rw-r--r--arch/mips/include/asm/mach-tx39xx/ioremap.h38
-rw-r--r--arch/mips/include/asm/mach-tx39xx/mangle-port.h23
-rw-r--r--arch/mips/include/asm/mach-tx39xx/war.h25
-rw-r--r--arch/mips/include/asm/mach-tx49xx/cpu-feature-overrides.h23
-rw-r--r--arch/mips/include/asm/mach-tx49xx/ioremap.h43
-rw-r--r--arch/mips/include/asm/mach-tx49xx/kmalloc.h8
-rw-r--r--arch/mips/include/asm/mach-tx49xx/war.h25
-rw-r--r--arch/mips/include/asm/mach-vr41xx/irq.h8
-rw-r--r--arch/mips/include/asm/mach-vr41xx/war.h25
-rw-r--r--arch/mips/include/asm/mach-wrppmc/mach-gt64120.h83
-rw-r--r--arch/mips/include/asm/mach-wrppmc/war.h25
-rw-r--r--arch/mips/include/asm/mach-yosemite/cpu-feature-overrides.h47
-rw-r--r--arch/mips/include/asm/mach-yosemite/war.h25
-rw-r--r--arch/mips/include/asm/mc146818-time.h119
-rw-r--r--arch/mips/include/asm/mc146818rtc.h16
-rw-r--r--arch/mips/include/asm/mips-boards/bonito64.h436
-rw-r--r--arch/mips/include/asm/mips-boards/generic.h104
-rw-r--r--arch/mips/include/asm/mips-boards/launch.h35
-rw-r--r--arch/mips/include/asm/mips-boards/malta.h102
-rw-r--r--arch/mips/include/asm/mips-boards/maltaint.h110
-rw-r--r--arch/mips/include/asm/mips-boards/msc01_pci.h258
-rw-r--r--arch/mips/include/asm/mips-boards/piix4.h80
-rw-r--r--arch/mips/include/asm/mips-boards/prom.h47
-rw-r--r--arch/mips/include/asm/mips-boards/sim.h40
-rw-r--r--arch/mips/include/asm/mips-boards/simint.h31
-rw-r--r--arch/mips/include/asm/mips_mt.h26
-rw-r--r--arch/mips/include/asm/mipsmtregs.h395
-rw-r--r--arch/mips/include/asm/mipsprom.h76
-rw-r--r--arch/mips/include/asm/mipsregs.h1526
-rw-r--r--arch/mips/include/asm/mman.h77
-rw-r--r--arch/mips/include/asm/mmu.h6
-rw-r--r--arch/mips/include/asm/mmu_context.h297
-rw-r--r--arch/mips/include/asm/mmzone.h17
-rw-r--r--arch/mips/include/asm/module.h136
-rw-r--r--arch/mips/include/asm/msc01_ic.h148
-rw-r--r--arch/mips/include/asm/msgbuf.h47
-rw-r--r--arch/mips/include/asm/mutex.h9
-rw-r--r--arch/mips/include/asm/nile4.h310
-rw-r--r--arch/mips/include/asm/paccess.h112
-rw-r--r--arch/mips/include/asm/page.h191
-rw-r--r--arch/mips/include/asm/param.h31
-rw-r--r--arch/mips/include/asm/parport.h15
-rw-r--r--arch/mips/include/asm/pci.h179
-rw-r--r--arch/mips/include/asm/pci/bridge.h854
-rw-r--r--arch/mips/include/asm/percpu.h6
-rw-r--r--arch/mips/include/asm/pgalloc.h143
-rw-r--r--arch/mips/include/asm/pgtable-32.h234
-rw-r--r--arch/mips/include/asm/pgtable-64.h253
-rw-r--r--arch/mips/include/asm/pgtable-bits.h137
-rw-r--r--arch/mips/include/asm/pgtable.h383
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h46
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/msp_cic_int.h151
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/msp_int.h43
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/msp_pci.h205
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/msp_prom.h176
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/msp_regops.h236
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h663
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/msp_slp_int.h141
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/war.h28
-rw-r--r--arch/mips/include/asm/pmon.h46
-rw-r--r--arch/mips/include/asm/poll.h9
-rw-r--r--arch/mips/include/asm/posix_types.h144
-rw-r--r--arch/mips/include/asm/prefetch.h87
-rw-r--r--arch/mips/include/asm/processor.h283
-rw-r--r--arch/mips/include/asm/ptrace.h154
-rw-r--r--arch/mips/include/asm/r4k-timer.h30
-rw-r--r--arch/mips/include/asm/r4kcache.h443
-rw-r--r--arch/mips/include/asm/reboot.h15
-rw-r--r--arch/mips/include/asm/reg.h128
-rw-r--r--arch/mips/include/asm/regdef.h100
-rw-r--r--arch/mips/include/asm/resource.h35
-rw-r--r--arch/mips/include/asm/rm9k-ocd.h56
-rw-r--r--arch/mips/include/asm/rtlx.h65
-rw-r--r--arch/mips/include/asm/scatterlist.h28
-rw-r--r--arch/mips/include/asm/seccomp.h37
-rw-r--r--arch/mips/include/asm/sections.h6
-rw-r--r--arch/mips/include/asm/segment.h6
-rw-r--r--arch/mips/include/asm/sembuf.h22
-rw-r--r--arch/mips/include/asm/serial.h22
-rw-r--r--arch/mips/include/asm/setup.h10
-rw-r--r--arch/mips/include/asm/sgi/gio.h86
-rw-r--r--arch/mips/include/asm/sgi/hpc3.h317
-rw-r--r--arch/mips/include/asm/sgi/ioc.h200
-rw-r--r--arch/mips/include/asm/sgi/ip22.h78
-rw-r--r--arch/mips/include/asm/sgi/mc.h231
-rw-r--r--arch/mips/include/asm/sgi/pi1.h71
-rw-r--r--arch/mips/include/asm/sgi/seeq.h21
-rw-r--r--arch/mips/include/asm/sgi/sgi.h47
-rw-r--r--arch/mips/include/asm/sgi/wd.h20
-rw-r--r--arch/mips/include/asm/sgialib.h124
-rw-r--r--arch/mips/include/asm/sgiarcs.h548
-rw-r--r--arch/mips/include/asm/sgidefs.h44
-rw-r--r--arch/mips/include/asm/shmbuf.h38
-rw-r--r--arch/mips/include/asm/shmparam.h13
-rw-r--r--arch/mips/include/asm/sibyte/bcm1480_int.h312
-rw-r--r--arch/mips/include/asm/sibyte/bcm1480_l2c.h176
-rw-r--r--arch/mips/include/asm/sibyte/bcm1480_mc.h984
-rw-r--r--arch/mips/include/asm/sibyte/bcm1480_regs.h902
-rw-r--r--arch/mips/include/asm/sibyte/bcm1480_scd.h406
-rw-r--r--arch/mips/include/asm/sibyte/bigsur.h49
-rw-r--r--arch/mips/include/asm/sibyte/board.h68
-rw-r--r--arch/mips/include/asm/sibyte/carmel.h58
-rw-r--r--arch/mips/include/asm/sibyte/sb1250.h68
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_defs.h259
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_dma.h594
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_genbus.h474
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_int.h248
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_l2c.h131
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_ldt.h423
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_mac.h656
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_mc.h550
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_regs.h893
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_scd.h654
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_smbus.h204
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_syncser.h146
-rw-r--r--arch/mips/include/asm/sibyte/sb1250_uart.h362
-rw-r--r--arch/mips/include/asm/sibyte/sentosa.h40
-rw-r--r--arch/mips/include/asm/sibyte/swarm.h64
-rw-r--r--arch/mips/include/asm/sigcontext.h100
-rw-r--r--arch/mips/include/asm/siginfo.h130
-rw-r--r--arch/mips/include/asm/signal.h139
-rw-r--r--arch/mips/include/asm/sim.h82
-rw-r--r--arch/mips/include/asm/smp-ops.h57
-rw-r--r--arch/mips/include/asm/smp.h63
-rw-r--r--arch/mips/include/asm/smtc.h71
-rw-r--r--arch/mips/include/asm/smtc_ipi.h128
-rw-r--r--arch/mips/include/asm/smtc_proc.h23
-rw-r--r--arch/mips/include/asm/smvp.h19
-rw-r--r--arch/mips/include/asm/sn/addrs.h430
-rw-r--r--arch/mips/include/asm/sn/agent.h46
-rw-r--r--arch/mips/include/asm/sn/arch.h64
-rw-r--r--arch/mips/include/asm/sn/fru.h44
-rw-r--r--arch/mips/include/asm/sn/gda.h107
-rw-r--r--arch/mips/include/asm/sn/hub.h16
-rw-r--r--arch/mips/include/asm/sn/intr.h129
-rw-r--r--arch/mips/include/asm/sn/io.h59
-rw-r--r--arch/mips/include/asm/sn/ioc3.h663
-rw-r--r--arch/mips/include/asm/sn/klconfig.h898
-rw-r--r--arch/mips/include/asm/sn/kldir.h217
-rw-r--r--arch/mips/include/asm/sn/klkernvars.h29
-rw-r--r--arch/mips/include/asm/sn/launch.h106
-rw-r--r--arch/mips/include/asm/sn/mapped_kernel.h54
-rw-r--r--arch/mips/include/asm/sn/nmi.h125
-rw-r--r--arch/mips/include/asm/sn/sn0/addrs.h288
-rw-r--r--arch/mips/include/asm/sn/sn0/arch.h72
-rw-r--r--arch/mips/include/asm/sn/sn0/hub.h40
-rw-r--r--arch/mips/include/asm/sn/sn0/hubio.h972
-rw-r--r--arch/mips/include/asm/sn/sn0/hubmd.h789
-rw-r--r--arch/mips/include/asm/sn/sn0/hubni.h255
-rw-r--r--arch/mips/include/asm/sn/sn0/hubpi.h409
-rw-r--r--arch/mips/include/asm/sn/sn0/ip27.h85
-rw-r--r--arch/mips/include/asm/sn/sn_private.h19
-rw-r--r--arch/mips/include/asm/sn/types.h26
-rw-r--r--arch/mips/include/asm/sni.h244
-rw-r--r--arch/mips/include/asm/socket.h117
-rw-r--r--arch/mips/include/asm/sockios.h26
-rw-r--r--arch/mips/include/asm/sparsemem.h14
-rw-r--r--arch/mips/include/asm/spinlock.h487
-rw-r--r--arch/mips/include/asm/spinlock_types.h25
-rw-r--r--arch/mips/include/asm/stackframe.h574
-rw-r--r--arch/mips/include/asm/stacktrace.h48
-rw-r--r--arch/mips/include/asm/stat.h132
-rw-r--r--arch/mips/include/asm/statfs.h96
-rw-r--r--arch/mips/include/asm/string.h143
-rw-r--r--arch/mips/include/asm/suspend.h6
-rw-r--r--arch/mips/include/asm/sysmips.h25
-rw-r--r--arch/mips/include/asm/system.h222
-rw-r--r--arch/mips/include/asm/termbits.h226
-rw-r--r--arch/mips/include/asm/termios.h132
-rw-r--r--arch/mips/include/asm/thread_info.h153
-rw-r--r--arch/mips/include/asm/time.h79
-rw-r--r--arch/mips/include/asm/timex.h43
-rw-r--r--arch/mips/include/asm/titan_dep.h231
-rw-r--r--arch/mips/include/asm/tlb.h23
-rw-r--r--arch/mips/include/asm/tlbdebug.h16
-rw-r--r--arch/mips/include/asm/tlbflush.h47
-rw-r--r--arch/mips/include/asm/topology.h17
-rw-r--r--arch/mips/include/asm/traps.h28
-rw-r--r--arch/mips/include/asm/txx9/boards.h13
-rw-r--r--arch/mips/include/asm/txx9/generic.h89
-rw-r--r--arch/mips/include/asm/txx9/jmr3927.h180
-rw-r--r--arch/mips/include/asm/txx9/pci.h39
-rw-r--r--arch/mips/include/asm/txx9/rbtx4927.h92
-rw-r--r--arch/mips/include/asm/txx9/rbtx4938.h145
-rw-r--r--arch/mips/include/asm/txx9/rbtx4939.h133
-rw-r--r--arch/mips/include/asm/txx9/smsc_fdc37m81x.h68
-rw-r--r--arch/mips/include/asm/txx9/spi.h34
-rw-r--r--arch/mips/include/asm/txx9/tx3927.h341
-rw-r--r--arch/mips/include/asm/txx9/tx4927.h269
-rw-r--r--arch/mips/include/asm/txx9/tx4927pcic.h203
-rw-r--r--arch/mips/include/asm/txx9/tx4938.h295
-rw-r--r--arch/mips/include/asm/txx9/tx4939.h545
-rw-r--r--arch/mips/include/asm/txx9irq.h34
-rw-r--r--arch/mips/include/asm/txx9pio.h29
-rw-r--r--arch/mips/include/asm/txx9tmr.h67
-rw-r--r--arch/mips/include/asm/types.h54
-rw-r--r--arch/mips/include/asm/uaccess.h1114
-rw-r--r--arch/mips/include/asm/ucontext.h21
-rw-r--r--arch/mips/include/asm/unaligned.h28
-rw-r--r--arch/mips/include/asm/unistd.h1037
-rw-r--r--arch/mips/include/asm/user.h58
-rw-r--r--arch/mips/include/asm/vga.h47
-rw-r--r--arch/mips/include/asm/vpe.h37
-rw-r--r--arch/mips/include/asm/vr41xx/capcella.h43
-rw-r--r--arch/mips/include/asm/vr41xx/giu.h78
-rw-r--r--arch/mips/include/asm/vr41xx/irq.h101
-rw-r--r--arch/mips/include/asm/vr41xx/mpc30x.h37
-rw-r--r--arch/mips/include/asm/vr41xx/pci.h90
-rw-r--r--arch/mips/include/asm/vr41xx/siu.h58
-rw-r--r--arch/mips/include/asm/vr41xx/tb0219.h42
-rw-r--r--arch/mips/include/asm/vr41xx/tb0226.h43
-rw-r--r--arch/mips/include/asm/vr41xx/tb0287.h43
-rw-r--r--arch/mips/include/asm/vr41xx/vr41xx.h152
-rw-r--r--arch/mips/include/asm/war.h244
-rw-r--r--arch/mips/include/asm/watch.h32
-rw-r--r--arch/mips/include/asm/wbflush.h34
-rw-r--r--arch/mips/include/asm/xor.h1
-rw-r--r--arch/mips/include/asm/xtalk/xtalk.h52
-rw-r--r--arch/mips/include/asm/xtalk/xwidget.h167
-rw-r--r--arch/mips/kernel/Makefile3
-rw-r--r--arch/mips/kernel/cevt-r4k.c173
-rw-r--r--arch/mips/kernel/cevt-smtc.c321
-rw-r--r--arch/mips/kernel/cpu-probe.c12
-rw-r--r--arch/mips/kernel/entry.S10
-rw-r--r--arch/mips/kernel/genex.S8
-rw-r--r--arch/mips/kernel/head.S1
-rw-r--r--arch/mips/kernel/mips-mt-fpaff.c2
-rw-r--r--arch/mips/kernel/proc.c13
-rw-r--r--arch/mips/kernel/process.c19
-rw-r--r--arch/mips/kernel/ptrace.c102
-rw-r--r--arch/mips/kernel/ptrace32.c59
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S2
-rw-r--r--arch/mips/kernel/signal32.c12
-rw-r--r--arch/mips/kernel/smp.c2
-rw-r--r--arch/mips/kernel/smtc.c260
-rw-r--r--arch/mips/kernel/traps.c30
-rw-r--r--arch/mips/kernel/watch.c188
-rw-r--r--arch/mips/lib/csum_partial.S57
-rw-r--r--arch/mips/mti-malta/Makefile2
-rw-r--r--arch/mips/mti-malta/malta-smtc.c9
-rw-r--r--arch/mips/pci/Makefile1
-rw-r--r--arch/mips/pci/pci-tx4938.c2
-rw-r--r--arch/mips/pci/pci-tx4939.c109
-rw-r--r--arch/mips/pmc-sierra/msp71xx/Makefile1
-rw-r--r--arch/mips/pmc-sierra/msp71xx/gpio.c218
-rw-r--r--arch/mips/pmc-sierra/msp71xx/gpio_extended.c148
-rw-r--r--arch/mips/rb532/devices.c22
-rw-r--r--arch/mips/rb532/gpio.c238
-rw-r--r--arch/mips/rb532/irq.c2
-rw-r--r--arch/mips/rb532/prom.c12
-rw-r--r--arch/mips/rb532/serial.c6
-rw-r--r--arch/mips/rb532/setup.c4
-rw-r--r--arch/mips/sibyte/swarm/Makefile3
-rw-r--r--arch/mips/sibyte/swarm/platform.c85
-rw-r--r--arch/mips/txx9/Kconfig24
-rw-r--r--arch/mips/txx9/generic/Makefile2
-rw-r--r--arch/mips/txx9/generic/irq_tx4927.c11
-rw-r--r--arch/mips/txx9/generic/irq_tx4938.c11
-rw-r--r--arch/mips/txx9/generic/irq_tx4939.c215
-rw-r--r--arch/mips/txx9/generic/setup.c431
-rw-r--r--arch/mips/txx9/generic/setup_tx3927.c37
-rw-r--r--arch/mips/txx9/generic/setup_tx4927.c97
-rw-r--r--arch/mips/txx9/generic/setup_tx4938.c122
-rw-r--r--arch/mips/txx9/generic/setup_tx4939.c506
-rw-r--r--arch/mips/txx9/generic/spi_eeprom.c (renamed from arch/mips/txx9/rbtx4938/spi_eeprom.c)28
-rw-r--r--arch/mips/txx9/jmr3927/prom.c1
-rw-r--r--arch/mips/txx9/jmr3927/setup.c25
-rw-r--r--arch/mips/txx9/rbtx4927/irq.c11
-rw-r--r--arch/mips/txx9/rbtx4927/prom.c1
-rw-r--r--arch/mips/txx9/rbtx4927/setup.c25
-rw-r--r--arch/mips/txx9/rbtx4938/Makefile2
-rw-r--r--arch/mips/txx9/rbtx4938/irq.c8
-rw-r--r--arch/mips/txx9/rbtx4938/prom.c3
-rw-r--r--arch/mips/txx9/rbtx4938/setup.c63
-rw-r--r--arch/mips/txx9/rbtx4939/Makefile3
-rw-r--r--arch/mips/txx9/rbtx4939/irq.c96
-rw-r--r--arch/mips/txx9/rbtx4939/prom.c17
-rw-r--r--arch/mips/txx9/rbtx4939/setup.c307
-rw-r--r--arch/mn10300/kernel/irq.c71
-rw-r--r--arch/mn10300/unit-asb2303/unit-init.c2
-rw-r--r--arch/mn10300/unit-asb2305/unit-init.c2
-rw-r--r--arch/powerpc/boot/dts/holly.dts106
-rw-r--r--arch/powerpc/include/asm/dcr-regs.h4
-rw-r--r--arch/powerpc/include/asm/siginfo.h5
-rw-r--r--arch/powerpc/kernel/idle.c6
-rw-r--r--arch/powerpc/kernel/smp.c1
-rw-r--r--arch/powerpc/platforms/82xx/ep8248e.c2
-rw-r--r--arch/powerpc/platforms/fsl_uli1575.c12
-rw-r--r--arch/powerpc/platforms/pasemi/gpio_mdio.c6
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c6
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/s390/include/asm/dasd.h13
-rw-r--r--arch/s390/include/asm/delay.h1
-rw-r--r--arch/s390/include/asm/pgtable.h45
-rw-r--r--arch/s390/include/asm/ptrace.h1
-rw-r--r--arch/s390/include/asm/qdio.h8
-rw-r--r--arch/s390/include/asm/syscall.h80
-rw-r--r--arch/s390/include/asm/thread_info.h2
-rw-r--r--arch/s390/kernel/compat_linux.c8
-rw-r--r--arch/s390/kernel/compat_linux.h1
-rw-r--r--arch/s390/kernel/compat_wrapper.S2
-rw-r--r--arch/s390/kernel/entry.S50
-rw-r--r--arch/s390/kernel/entry64.S42
-rw-r--r--arch/s390/kernel/ptrace.c61
-rw-r--r--arch/s390/kernel/signal.c13
-rw-r--r--arch/s390/kernel/smp.c2
-rw-r--r--arch/s390/kernel/syscalls.S2
-rw-r--r--arch/s390/kernel/time.c4
-rw-r--r--arch/s390/lib/delay.c101
-rw-r--r--arch/s390/mm/extmem.c251
-rw-r--r--arch/sh/kernel/smp.c2
-rw-r--r--arch/sparc/Kconfig26
-rw-r--r--arch/sparc/include/asm/Kbuild2
-rw-r--r--arch/sparc/include/asm/asmmacro.h5
-rw-r--r--arch/sparc/include/asm/bpp.h73
-rw-r--r--arch/sparc/include/asm/bugs.h7
-rw-r--r--arch/sparc/include/asm/cpudata_64.h1
-rw-r--r--arch/sparc/include/asm/dma-mapping_32.h59
-rw-r--r--arch/sparc/include/asm/dma.h141
-rw-r--r--arch/sparc/include/asm/dma_32.h288
-rw-r--r--arch/sparc/include/asm/dma_64.h205
-rw-r--r--arch/sparc/include/asm/ebus.h8
-rw-r--r--arch/sparc/include/asm/ebus_32.h99
-rw-r--r--arch/sparc/include/asm/ebus_64.h95
-rw-r--r--arch/sparc/include/asm/ebus_dma.h35
-rw-r--r--arch/sparc/include/asm/elf_32.h7
-rw-r--r--arch/sparc/include/asm/fhc.h43
-rw-r--r--arch/sparc/include/asm/floppy_32.h16
-rw-r--r--arch/sparc/include/asm/floppy_64.h130
-rw-r--r--arch/sparc/include/asm/gpio.h36
-rw-r--r--arch/sparc/include/asm/io-unit.h4
-rw-r--r--arch/sparc/include/asm/io_32.h19
-rw-r--r--arch/sparc/include/asm/io_64.h22
-rw-r--r--arch/sparc/include/asm/iommu_64.h3
-rw-r--r--arch/sparc/include/asm/irq_64.h1
-rw-r--r--arch/sparc/include/asm/mc146818rtc_64.h10
-rw-r--r--arch/sparc/include/asm/memctrl.h9
-rw-r--r--arch/sparc/include/asm/mostek.h8
-rw-r--r--arch/sparc/include/asm/mostek_32.h171
-rw-r--r--arch/sparc/include/asm/mostek_64.h143
-rw-r--r--arch/sparc/include/asm/obio.h11
-rw-r--r--arch/sparc/include/asm/of_device.h2
-rw-r--r--arch/sparc/include/asm/of_platform.h3
-rw-r--r--arch/sparc/include/asm/oplib_32.h1
-rw-r--r--arch/sparc/include/asm/page_32.h5
-rw-r--r--arch/sparc/include/asm/page_64.h2
-rw-r--r--arch/sparc/include/asm/parport.h4
-rw-r--r--arch/sparc/include/asm/pci_32.h2
-rw-r--r--arch/sparc/include/asm/pgtable_32.h4
-rw-r--r--arch/sparc/include/asm/pgtable_64.h2
-rw-r--r--arch/sparc/include/asm/prom.h12
-rw-r--r--arch/sparc/include/asm/ptrace_64.h3
-rw-r--r--arch/sparc/include/asm/reboot.h6
-rw-r--r--arch/sparc/include/asm/rtc.h26
-rw-r--r--arch/sparc/include/asm/sbus.h8
-rw-r--r--arch/sparc/include/asm/sbus_32.h153
-rw-r--r--arch/sparc/include/asm/sbus_64.h190
-rw-r--r--arch/sparc/include/asm/spinlock_32.h2
-rw-r--r--arch/sparc/include/asm/spinlock_64.h2
-rw-r--r--arch/sparc/include/asm/sstate.h13
-rw-r--r--arch/sparc/include/asm/starfire.h1
-rw-r--r--arch/sparc/include/asm/sun4paddr.h56
-rw-r--r--arch/sparc/include/asm/sun4prom.h83
-rw-r--r--arch/sparc/include/asm/system_32.h9
-rw-r--r--arch/sparc/include/asm/system_64.h6
-rw-r--r--arch/sparc/include/asm/thread_info_32.h4
-rw-r--r--arch/sparc/include/asm/timer_32.h87
-rw-r--r--arch/sparc/include/asm/vac-ops.h7
-rw-r--r--arch/sparc/include/asm/vfc_ioctls.h58
-rw-r--r--arch/sparc/include/asm/visasm.h1
-rw-r--r--arch/sparc/kernel/Makefile4
-rw-r--r--arch/sparc/kernel/apc.c72
-rw-r--r--arch/sparc/kernel/auxio.c6
-rw-r--r--arch/sparc/kernel/devices.c2
-rw-r--r--arch/sparc/kernel/dma.c227
-rw-r--r--arch/sparc/kernel/dma.h14
-rw-r--r--arch/sparc/kernel/ebus.c393
-rw-r--r--arch/sparc/kernel/entry.S94
-rw-r--r--arch/sparc/kernel/head.S28
-rw-r--r--arch/sparc/kernel/idprom.c7
-rw-r--r--arch/sparc/kernel/ioport.c227
-rw-r--r--arch/sparc/kernel/irq.h6
-rw-r--r--arch/sparc/kernel/of_device.c74
-rw-r--r--arch/sparc/kernel/pcic.c15
-rw-r--r--arch/sparc/kernel/pmc.c59
-rw-r--r--arch/sparc/kernel/process.c2
-rw-r--r--arch/sparc/kernel/prom.c7
-rw-r--r--arch/sparc/kernel/setup.c32
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c25
-rw-r--r--arch/sparc/kernel/sun4c_irq.c156
-rw-r--r--arch/sparc/kernel/sun4d_irq.c286
-rw-r--r--arch/sparc/kernel/sun4d_smp.c13
-rw-r--r--arch/sparc/kernel/sun4m_irq.c495
-rw-r--r--arch/sparc/kernel/sun4m_smp.c6
-rw-r--r--arch/sparc/kernel/sun4setup.c75
-rw-r--r--arch/sparc/kernel/sys_sparc.c8
-rw-r--r--arch/sparc/kernel/tick14.c47
-rw-r--r--arch/sparc/kernel/time.c382
-rw-r--r--arch/sparc/kernel/traps.c17
-rw-r--r--arch/sparc/mm/Makefile9
-rw-r--r--arch/sparc/mm/btfixup.c6
-rw-r--r--arch/sparc/mm/fault.c2
-rw-r--r--arch/sparc/mm/init.c14
-rw-r--r--arch/sparc/mm/io-unit.c136
-rw-r--r--arch/sparc/mm/iommu.c113
-rw-r--r--arch/sparc/mm/nosrmmu.c59
-rw-r--r--arch/sparc/mm/srmmu.c1
-rw-r--r--arch/sparc/mm/sun4c.c204
-rw-r--r--arch/sparc/prom/Makefile2
-rw-r--r--arch/sparc/prom/bootstr.c4
-rw-r--r--arch/sparc/prom/console.c3
-rw-r--r--arch/sparc/prom/init.c12
-rw-r--r--arch/sparc/prom/memory.c14
-rw-r--r--arch/sparc/prom/ranges.c1
-rw-r--r--arch/sparc/prom/sun4prom.c161
-rw-r--r--arch/sparc64/Kconfig23
-rw-r--r--arch/sparc64/Makefile2
-rw-r--r--arch/sparc64/kernel/Makefile9
-rw-r--r--arch/sparc64/kernel/auxio.c2
-rw-r--r--arch/sparc64/kernel/central.c617
-rw-r--r--arch/sparc64/kernel/chmc.c817
-rw-r--r--arch/sparc64/kernel/cpu.c208
-rw-r--r--arch/sparc64/kernel/ds.c4
-rw-r--r--arch/sparc64/kernel/ebus.c299
-rw-r--r--arch/sparc64/kernel/entry.h7
-rw-r--r--arch/sparc64/kernel/head.S1
-rw-r--r--arch/sparc64/kernel/hvapi.c3
-rw-r--r--arch/sparc64/kernel/hvcalls.S354
-rw-r--r--arch/sparc64/kernel/irq.c1
-rw-r--r--arch/sparc64/kernel/of_device.c62
-rw-r--r--arch/sparc64/kernel/pci.c172
-rw-r--r--arch/sparc64/kernel/pci_common.c8
-rw-r--r--arch/sparc64/kernel/pci_fire.c254
-rw-r--r--arch/sparc64/kernel/pci_impl.h27
-rw-r--r--arch/sparc64/kernel/pci_msi.c18
-rw-r--r--arch/sparc64/kernel/pci_psycho.c750
-rw-r--r--arch/sparc64/kernel/pci_sabre.c507
-rw-r--r--arch/sparc64/kernel/pci_schizo.c368
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c197
-rw-r--r--arch/sparc64/kernel/pci_sun4v_asm.S99
-rw-r--r--arch/sparc64/kernel/power.c55
-rw-r--r--arch/sparc64/kernel/process.c35
-rw-r--r--arch/sparc64/kernel/prom.c91
-rw-r--r--arch/sparc64/kernel/psycho_common.c470
-rw-r--r--arch/sparc64/kernel/psycho_common.h48
-rw-r--r--arch/sparc64/kernel/ptrace.c38
-rw-r--r--arch/sparc64/kernel/reboot.c53
-rw-r--r--arch/sparc64/kernel/sbus.c166
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c23
-rw-r--r--arch/sparc64/kernel/sstate.c67
-rw-r--r--arch/sparc64/kernel/starfire.c5
-rw-r--r--arch/sparc64/kernel/sys_sparc32.c8
-rw-r--r--arch/sparc64/kernel/syscalls.S20
-rw-r--r--arch/sparc64/kernel/systbls.S2
-rw-r--r--arch/sparc64/kernel/time.c1187
-rw-r--r--arch/sparc64/kernel/traps.c69
-rw-r--r--arch/sparc64/kernel/vio.c8
-rw-r--r--arch/sparc64/kernel/visemul.c12
-rw-r--r--arch/sparc64/mm/fault.c37
-rw-r--r--arch/sparc64/mm/init.c84
-rw-r--r--arch/sparc64/mm/init.h49
-rw-r--r--arch/sparc64/mm/tlb.c2
-rw-r--r--arch/um/Kconfig.char4
-rw-r--r--arch/um/kernel/smp.c1
-rw-r--r--arch/um/sys-x86_64/syscall_table.c4
-rw-r--r--arch/x86/Kconfig174
-rw-r--r--arch/x86/Kconfig.cpu120
-rw-r--r--arch/x86/Kconfig.debug13
-rw-r--r--arch/x86/Makefile_32.cpu5
-rw-r--r--arch/x86/boot/Makefile5
-rw-r--r--arch/x86/boot/compressed/Makefile8
-rw-r--r--arch/x86/boot/compressed/head_32.S5
-rw-r--r--arch/x86/boot/compressed/misc.c12
-rw-r--r--arch/x86/boot/compressed/relocs.c2
-rw-r--r--arch/x86/boot/cpu.c17
-rw-r--r--arch/x86/boot/edd.c7
-rw-r--r--arch/x86/boot/header.S1
-rw-r--r--arch/x86/boot/mkcpustr.c40
-rw-r--r--arch/x86/boot/video-vesa.c2
-rw-r--r--arch/x86/configs/i386_defconfig20
-rw-r--r--arch/x86/configs/x86_64_defconfig30
-rw-r--r--arch/x86/crypto/Makefile2
-rw-r--r--arch/x86/crypto/crc32c-intel.c197
-rw-r--r--arch/x86/ia32/ia32_aout.c11
-rw-r--r--arch/x86/ia32/ia32_signal.c138
-rw-r--r--arch/x86/ia32/sys_ia32.c9
-rw-r--r--arch/x86/kernel/Makefile15
-rw-r--r--arch/x86/kernel/acpi/boot.c41
-rw-r--r--arch/x86/kernel/alternative.c8
-rw-r--r--arch/x86/kernel/amd_iommu.c328
-rw-r--r--arch/x86/kernel/amd_iommu_init.c194
-rw-r--r--arch/x86/kernel/aperture_64.c6
-rw-r--r--arch/x86/kernel/apic_32.c445
-rw-r--r--arch/x86/kernel/apic_64.c626
-rw-r--r--arch/x86/kernel/apm_32.c1
-rw-r--r--arch/x86/kernel/asm-offsets_64.c2
-rw-r--r--arch/x86/kernel/bios_uv.c10
-rw-r--r--arch/x86/kernel/cpu/Makefile34
-rw-r--r--arch/x86/kernel/cpu/addon_cpuid_features.c88
-rw-r--r--arch/x86/kernel/cpu/amd.c548
-rw-r--r--arch/x86/kernel/cpu/amd_64.c224
-rw-r--r--arch/x86/kernel/cpu/centaur.c4
-rw-r--r--arch/x86/kernel/cpu/centaur_64.c6
-rw-r--r--arch/x86/kernel/cpu/cmpxchg.c72
-rw-r--r--arch/x86/kernel/cpu/common.c980
-rw-r--r--arch/x86/kernel/cpu/common_64.c712
-rw-r--r--arch/x86/kernel/cpu/cpu.h19
-rw-r--r--arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c13
-rw-r--r--arch/x86/kernel/cpu/cpufreq/elanfreq.c42
-rw-r--r--arch/x86/kernel/cpu/cpufreq/p4-clockmod.c2
-rw-r--r--arch/x86/kernel/cpu/cpufreq/powernow-k6.c41
-rw-r--r--arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c2
-rw-r--r--arch/x86/kernel/cpu/cyrix.c23
-rw-r--r--arch/x86/kernel/cpu/feature_names.c84
-rw-r--r--arch/x86/kernel/cpu/intel.c365
-rw-r--r--arch/x86/kernel/cpu/intel_64.c95
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c169
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_64.c2
-rw-r--r--arch/x86/kernel/cpu/mkcapflags.pl32
-rw-r--r--arch/x86/kernel/cpu/mtrr/generic.c7
-rw-r--r--arch/x86/kernel/cpu/mtrr/if.c4
-rw-r--r--arch/x86/kernel/cpu/mtrr/main.c276
-rw-r--r--arch/x86/kernel/cpu/perfctr-watchdog.c86
-rw-r--r--arch/x86/kernel/cpu/powerflags.c20
-rw-r--r--arch/x86/kernel/cpu/transmeta.c32
-rw-r--r--arch/x86/kernel/cpu/umc.c3
-rw-r--r--arch/x86/kernel/cpuid.c1
-rw-r--r--arch/x86/kernel/crash_dump_64.c13
-rw-r--r--arch/x86/kernel/doublefault_32.c2
-rw-r--r--arch/x86/kernel/ds.c954
-rw-r--r--arch/x86/kernel/e820.c28
-rw-r--r--arch/x86/kernel/early-quirks.c66
-rw-r--r--arch/x86/kernel/early_printk.c748
-rw-r--r--arch/x86/kernel/efi.c6
-rw-r--r--arch/x86/kernel/entry_64.S4
-rw-r--r--arch/x86/kernel/es7000_32.c (renamed from arch/x86/mach-es7000/es7000plat.c)87
-rw-r--r--arch/x86/kernel/genapic_64.c88
-rw-r--r--arch/x86/kernel/genapic_flat_64.c62
-rw-r--r--arch/x86/kernel/genx2apic_cluster.c159
-rw-r--r--arch/x86/kernel/genx2apic_phys.c154
-rw-r--r--arch/x86/kernel/genx2apic_uv_x.c70
-rw-r--r--arch/x86/kernel/head64.c5
-rw-r--r--arch/x86/kernel/head_32.S34
-rw-r--r--arch/x86/kernel/head_64.S4
-rw-r--r--arch/x86/kernel/i387.c168
-rw-r--r--arch/x86/kernel/i8259.c24
-rw-r--r--arch/x86/kernel/io_apic_32.c47
-rw-r--r--arch/x86/kernel/io_apic_64.c639
-rw-r--r--arch/x86/kernel/ioport.c1
-rw-r--r--arch/x86/kernel/ipi.c3
-rw-r--r--arch/x86/kernel/irq_32.c2
-rw-r--r--arch/x86/kernel/irq_64.c2
-rw-r--r--arch/x86/kernel/irqinit_32.c49
-rw-r--r--arch/x86/kernel/k8.c5
-rw-r--r--arch/x86/kernel/kgdb.c7
-rw-r--r--arch/x86/kernel/kvm.c2
-rw-r--r--arch/x86/kernel/ldt.c10
-rw-r--r--arch/x86/kernel/microcode.c853
-rw-r--r--arch/x86/kernel/microcode_amd.c435
-rw-r--r--arch/x86/kernel/microcode_core.c508
-rw-r--r--arch/x86/kernel/microcode_intel.c480
-rw-r--r--arch/x86/kernel/mpparse.c2
-rw-r--r--arch/x86/kernel/nmi.c11
-rw-r--r--arch/x86/kernel/numaq_32.c7
-rw-r--r--arch/x86/kernel/olpc.c6
-rw-r--r--arch/x86/kernel/paravirt-spinlocks.c37
-rw-r--r--arch/x86/kernel/paravirt.c30
-rw-r--r--arch/x86/kernel/paravirt_patch_32.c2
-rw-r--r--arch/x86/kernel/pci-calgary_64.c18
-rw-r--r--arch/x86/kernel/pci-dma.c179
-rw-r--r--arch/x86/kernel/pci-gart_64.c162
-rw-r--r--arch/x86/kernel/pci-nommu.c10
-rw-r--r--arch/x86/kernel/pcspeaker.c13
-rw-r--r--arch/x86/kernel/process.c4
-rw-r--r--arch/x86/kernel/process_32.c101
-rw-r--r--arch/x86/kernel/process_64.c194
-rw-r--r--arch/x86/kernel/ptrace.c522
-rw-r--r--arch/x86/kernel/reboot.c6
-rw-r--r--arch/x86/kernel/setup.c214
-rw-r--r--arch/x86/kernel/setup_percpu.c9
-rw-r--r--arch/x86/kernel/sigframe.h19
-rw-r--r--arch/x86/kernel/signal_32.c273
-rw-r--r--arch/x86/kernel/signal_64.c362
-rw-r--r--arch/x86/kernel/smp.c6
-rw-r--r--arch/x86/kernel/smpboot.c125
-rw-r--r--arch/x86/kernel/summit_32.c2
-rw-r--r--arch/x86/kernel/sys_i386_32.c2
-rw-r--r--arch/x86/kernel/sys_x86_64.c44
-rw-r--r--arch/x86/kernel/syscall_64.c4
-rw-r--r--arch/x86/kernel/time_32.c1
-rw-r--r--arch/x86/kernel/tlb_32.c8
-rw-r--r--arch/x86/kernel/tls.c1
-rw-r--r--arch/x86/kernel/traps_32.c5
-rw-r--r--arch/x86/kernel/traps_64.c74
-rw-r--r--arch/x86/kernel/tsc.c290
-rw-r--r--arch/x86/kernel/visws_quirks.c16
-rw-r--r--arch/x86/kernel/vm86_32.c1
-rw-r--r--arch/x86/kernel/vmi_32.c16
-rw-r--r--arch/x86/kernel/vmlinux_32.lds.S9
-rw-r--r--arch/x86/kernel/vmlinux_64.lds.S9
-rw-r--r--arch/x86/kernel/xsave.c345
-rw-r--r--arch/x86/kvm/vmx.h15
-rw-r--r--arch/x86/lguest/boot.c38
-rw-r--r--arch/x86/lib/Makefile3
-rw-r--r--arch/x86/lib/msr-on-cpu.c78
-rw-r--r--arch/x86/lib/string_32.c42
-rw-r--r--arch/x86/lib/strstr_32.c6
-rw-r--r--arch/x86/lib/usercopy_32.c7
-rw-r--r--arch/x86/mach-default/setup.c19
-rw-r--r--arch/x86/mach-es7000/Makefile5
-rw-r--r--arch/x86/mach-es7000/es7000.h114
-rw-r--r--arch/x86/mach-generic/Makefile1
-rw-r--r--arch/x86/mach-generic/bigsmp.c9
-rw-r--r--arch/x86/mach-generic/es7000.c13
-rw-r--r--arch/x86/mach-generic/numaq.c12
-rw-r--r--arch/x86/mach-generic/summit.c11
-rw-r--r--arch/x86/mach-voyager/voyager_smp.c2
-rw-r--r--arch/x86/mm/discontig_32.c2
-rw-r--r--arch/x86/mm/dump_pagetables.c4
-rw-r--r--arch/x86/mm/fault.c17
-rw-r--r--arch/x86/mm/init_32.c88
-rw-r--r--arch/x86/mm/init_64.c177
-rw-r--r--arch/x86/mm/ioremap.c58
-rw-r--r--arch/x86/mm/numa_64.c10
-rw-r--r--arch/x86/mm/pageattr-test.c9
-rw-r--r--arch/x86/mm/pageattr.c463
-rw-r--r--arch/x86/mm/pat.c132
-rw-r--r--arch/x86/mm/pgtable.c6
-rw-r--r--arch/x86/mm/pgtable_32.c3
-rw-r--r--arch/x86/pci/acpi.c5
-rw-r--r--arch/x86/pci/amd_bus.c2
-rw-r--r--arch/x86/pci/i386.c3
-rw-r--r--arch/x86/pci/irq.c67
-rw-r--r--arch/x86/pci/mmconfig-shared.c12
-rw-r--r--arch/x86/power/cpu_32.c7
-rw-r--r--arch/x86/power/cpu_64.c7
-rw-r--r--arch/x86/power/hibernate_asm_32.S14
-rw-r--r--arch/x86/xen/Kconfig12
-rw-r--r--arch/x86/xen/Makefile12
-rw-r--r--arch/x86/xen/debugfs.c123
-rw-r--r--arch/x86/xen/debugfs.h10
-rw-r--r--arch/x86/xen/enlighten.c317
-rw-r--r--arch/x86/xen/irq.c143
-rw-r--r--arch/x86/xen/mmu.c314
-rw-r--r--arch/x86/xen/mmu.h3
-rw-r--r--arch/x86/xen/multicalls.c115
-rw-r--r--arch/x86/xen/smp.c245
-rw-r--r--arch/x86/xen/spinlock.c428
-rw-r--r--arch/x86/xen/time.c12
-rw-r--r--arch/x86/xen/xen-asm_32.S2
-rw-r--r--arch/x86/xen/xen-asm_64.S22
-rw-r--r--arch/x86/xen/xen-ops.h8
1662 files changed, 104931 insertions, 23096 deletions
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 83df541650fc..06b6fdab639f 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -149,6 +149,9 @@ smp_callin(void)
149 atomic_inc(&init_mm.mm_count); 149 atomic_inc(&init_mm.mm_count);
150 current->active_mm = &init_mm; 150 current->active_mm = &init_mm;
151 151
152 /* inform the notifiers about the new cpu */
153 notify_cpu_starting(cpuid);
154
152 /* Must have completely accurate bogos. */ 155 /* Must have completely accurate bogos. */
153 local_irq_enable(); 156 local_irq_enable();
154 157
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 70dba1668907..efeed65b4a66 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -148,7 +148,6 @@ config ARCH_MAY_HAVE_PC_FDC
148 148
149config ZONE_DMA 149config ZONE_DMA
150 bool 150 bool
151 default y
152 151
153config GENERIC_ISA_DMA 152config GENERIC_ISA_DMA
154 bool 153 bool
@@ -178,6 +177,11 @@ config OPROFILE_MPCORE
178config OPROFILE_ARM11_CORE 177config OPROFILE_ARM11_CORE
179 bool 178 bool
180 179
180config OPROFILE_ARMV7
181 def_bool y
182 depends on CPU_V7 && !SMP
183 bool
184
181endif 185endif
182 186
183config VECTORS_BASE 187config VECTORS_BASE
@@ -245,6 +249,7 @@ config ARCH_CLPS7500
245 select TIMER_ACORN 249 select TIMER_ACORN
246 select ISA 250 select ISA
247 select NO_IOPORT 251 select NO_IOPORT
252 select ARCH_SPARSEMEM_ENABLE
248 help 253 help
249 Support for the Cirrus Logic PS7500FE system-on-a-chip. 254 Support for the Cirrus Logic PS7500FE system-on-a-chip.
250 255
@@ -306,6 +311,7 @@ config ARCH_IOP13XX
306 select PLAT_IOP 311 select PLAT_IOP
307 select PCI 312 select PCI
308 select ARCH_SUPPORTS_MSI 313 select ARCH_SUPPORTS_MSI
314 select VMSPLIT_1G
309 help 315 help
310 Support for Intel's IOP13XX (XScale) family of processors. 316 Support for Intel's IOP13XX (XScale) family of processors.
311 317
@@ -350,6 +356,7 @@ config ARCH_IXP4XX
350 select GENERIC_GPIO 356 select GENERIC_GPIO
351 select GENERIC_TIME 357 select GENERIC_TIME
352 select GENERIC_CLOCKEVENTS 358 select GENERIC_CLOCKEVENTS
359 select ZONE_DMA if PCI
353 help 360 help
354 Support for Intel's IXP4XX (XScale) family of processors. 361 Support for Intel's IXP4XX (XScale) family of processors.
355 362
@@ -434,7 +441,7 @@ config ARCH_ORION5X
434 help 441 help
435 Support for the following Marvell Orion 5x series SoCs: 442 Support for the following Marvell Orion 5x series SoCs:
436 Orion-1 (5181), Orion-VoIP (5181L), Orion-NAS (5182), 443 Orion-1 (5181), Orion-VoIP (5181L), Orion-NAS (5182),
437 Orion-2 (5281). 444 Orion-2 (5281), Orion-1-90 (6183).
438 445
439config ARCH_PNX4008 446config ARCH_PNX4008
440 bool "Philips Nexperia PNX4008 Mobile" 447 bool "Philips Nexperia PNX4008 Mobile"
@@ -464,6 +471,7 @@ config ARCH_RPC
464 select HAVE_PATA_PLATFORM 471 select HAVE_PATA_PLATFORM
465 select ISA_DMA_API 472 select ISA_DMA_API
466 select NO_IOPORT 473 select NO_IOPORT
474 select ARCH_SPARSEMEM_ENABLE
467 help 475 help
468 On the Acorn Risc-PC, Linux can support the internal IDE disk and 476 On the Acorn Risc-PC, Linux can support the internal IDE disk and
469 CD-ROM interface, serial and parallel port, and the floppy drive. 477 CD-ROM interface, serial and parallel port, and the floppy drive.
@@ -471,9 +479,7 @@ config ARCH_RPC
471config ARCH_SA1100 479config ARCH_SA1100
472 bool "SA1100-based" 480 bool "SA1100-based"
473 select ISA 481 select ISA
474 select ARCH_DISCONTIGMEM_ENABLE
475 select ARCH_SPARSEMEM_ENABLE 482 select ARCH_SPARSEMEM_ENABLE
476 select ARCH_SELECT_MEMORY_MODEL
477 select ARCH_MTD_XIP 483 select ARCH_MTD_XIP
478 select GENERIC_GPIO 484 select GENERIC_GPIO
479 select GENERIC_TIME 485 select GENERIC_TIME
@@ -497,6 +503,7 @@ config ARCH_SHARK
497 bool "Shark" 503 bool "Shark"
498 select ISA 504 select ISA
499 select ISA_DMA 505 select ISA_DMA
506 select ZONE_DMA
500 select PCI 507 select PCI
501 help 508 help
502 Support for the StrongARM based Digital DNARD machine, also known 509 Support for the StrongARM based Digital DNARD machine, also known
@@ -504,6 +511,8 @@ config ARCH_SHARK
504 511
505config ARCH_LH7A40X 512config ARCH_LH7A40X
506 bool "Sharp LH7A40X" 513 bool "Sharp LH7A40X"
514 select ARCH_DISCONTIGMEM_ENABLE if !LH7A40X_CONTIGMEM
515 select ARCH_SPARSEMEM_ENABLE if !LH7A40X_CONTIGMEM
507 help 516 help
508 Say Y here for systems based on one of the Sharp LH7A40X 517 Say Y here for systems based on one of the Sharp LH7A40X
509 System on a Chip processors. These CPUs include an ARM922T 518 System on a Chip processors. These CPUs include an ARM922T
@@ -515,7 +524,9 @@ config ARCH_DAVINCI
515 select GENERIC_TIME 524 select GENERIC_TIME
516 select GENERIC_CLOCKEVENTS 525 select GENERIC_CLOCKEVENTS
517 select GENERIC_GPIO 526 select GENERIC_GPIO
527 select ARCH_REQUIRE_GPIOLIB
518 select HAVE_CLK 528 select HAVE_CLK
529 select ZONE_DMA
519 help 530 help
520 Support for TI's DaVinci platform. 531 Support for TI's DaVinci platform.
521 532
@@ -734,6 +745,29 @@ config SMP
734 745
735 If you don't know what to do here, say N. 746 If you don't know what to do here, say N.
736 747
748choice
749 prompt "Memory split"
750 default VMSPLIT_3G
751 help
752 Select the desired split between kernel and user memory.
753
754 If you are not absolutely sure what you are doing, leave this
755 option alone!
756
757 config VMSPLIT_3G
758 bool "3G/1G user/kernel split"
759 config VMSPLIT_2G
760 bool "2G/2G user/kernel split"
761 config VMSPLIT_1G
762 bool "1G/3G user/kernel split"
763endchoice
764
765config PAGE_OFFSET
766 hex
767 default 0x40000000 if VMSPLIT_1G
768 default 0x80000000 if VMSPLIT_2G
769 default 0xC0000000
770
737config NR_CPUS 771config NR_CPUS
738 int "Maximum number of CPUs (2-32)" 772 int "Maximum number of CPUs (2-32)"
739 range 2 32 773 range 2 32
@@ -815,20 +849,18 @@ config ARCH_FLATMEM_HAS_HOLES
815 default y 849 default y
816 depends on FLATMEM 850 depends on FLATMEM
817 851
852# Discontigmem is deprecated
818config ARCH_DISCONTIGMEM_ENABLE 853config ARCH_DISCONTIGMEM_ENABLE
819 bool 854 bool
820 default (ARCH_LH7A40X && !LH7A40X_CONTIGMEM)
821 help
822 Say Y to support efficient handling of discontiguous physical memory,
823 for architectures which are either NUMA (Non-Uniform Memory Access)
824 or have huge holes in the physical address space for other reasons.
825 See <file:Documentation/vm/numa> for more.
826 855
827config ARCH_SPARSEMEM_ENABLE 856config ARCH_SPARSEMEM_ENABLE
828 bool 857 bool
829 858
859config ARCH_SPARSEMEM_DEFAULT
860 def_bool ARCH_SPARSEMEM_ENABLE
861
830config ARCH_SELECT_MEMORY_MODEL 862config ARCH_SELECT_MEMORY_MODEL
831 bool 863 def_bool ARCH_DISCONTIGMEM_ENABLE && ARCH_SPARSEMEM_ENABLE
832 864
833config NODES_SHIFT 865config NODES_SHIFT
834 int 866 int
@@ -845,7 +877,7 @@ config LEDS
845 ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_NETWINDER || \ 877 ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_NETWINDER || \
846 ARCH_OMAP || ARCH_P720T || ARCH_PXA_IDP || \ 878 ARCH_OMAP || ARCH_P720T || ARCH_PXA_IDP || \
847 ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE || \ 879 ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE || \
848 ARCH_AT91 || MACH_TRIZEPS4 || ARCH_DAVINCI || \ 880 ARCH_AT91 || ARCH_DAVINCI || \
849 ARCH_KS8695 || MACH_RD88F5182 881 ARCH_KS8695 || MACH_RD88F5182
850 help 882 help
851 If you say Y here, the LEDs on your machine will be used 883 If you say Y here, the LEDs on your machine will be used
@@ -1005,9 +1037,9 @@ config ATAGS_PROC
1005 1037
1006endmenu 1038endmenu
1007 1039
1008if (ARCH_SA1100 || ARCH_INTEGRATOR || ARCH_OMAP || ARCH_IMX || ARCH_PXA) 1040menu "CPU Power Management"
1009 1041
1010menu "CPU Frequency scaling" 1042if (ARCH_SA1100 || ARCH_INTEGRATOR || ARCH_OMAP || ARCH_IMX || ARCH_PXA)
1011 1043
1012source "drivers/cpufreq/Kconfig" 1044source "drivers/cpufreq/Kconfig"
1013 1045
@@ -1047,10 +1079,12 @@ config CPU_FREQ_PXA
1047 default y 1079 default y
1048 select CPU_FREQ_DEFAULT_GOV_USERSPACE 1080 select CPU_FREQ_DEFAULT_GOV_USERSPACE
1049 1081
1050endmenu
1051
1052endif 1082endif
1053 1083
1084source "drivers/cpuidle/Kconfig"
1085
1086endmenu
1087
1054menu "Floating point emulation" 1088menu "Floating point emulation"
1055 1089
1056comment "At least one emulation must be selected" 1090comment "At least one emulation must be selected"
@@ -1202,6 +1236,8 @@ source "drivers/power/Kconfig"
1202 1236
1203source "drivers/hwmon/Kconfig" 1237source "drivers/hwmon/Kconfig"
1204 1238
1239source "drivers/thermal/Kconfig"
1240
1205source "drivers/watchdog/Kconfig" 1241source "drivers/watchdog/Kconfig"
1206 1242
1207source "drivers/ssb/Kconfig" 1243source "drivers/ssb/Kconfig"
@@ -1222,6 +1258,10 @@ source "drivers/usb/Kconfig"
1222 1258
1223source "drivers/mmc/Kconfig" 1259source "drivers/mmc/Kconfig"
1224 1260
1261source "drivers/memstick/Kconfig"
1262
1263source "drivers/accessibility/Kconfig"
1264
1225source "drivers/leds/Kconfig" 1265source "drivers/leds/Kconfig"
1226 1266
1227source "drivers/rtc/Kconfig" 1267source "drivers/rtc/Kconfig"
@@ -1230,6 +1270,8 @@ source "drivers/dma/Kconfig"
1230 1270
1231source "drivers/dca/Kconfig" 1271source "drivers/dca/Kconfig"
1232 1272
1273source "drivers/auxdisplay/Kconfig"
1274
1233source "drivers/regulator/Kconfig" 1275source "drivers/regulator/Kconfig"
1234 1276
1235source "drivers/uio/Kconfig" 1277source "drivers/uio/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 703a44fa0f9b..e2274bc0b544 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -47,7 +47,7 @@ comma = ,
47# Note that GCC does not numerically define an architecture version 47# Note that GCC does not numerically define an architecture version
48# macro, but instead defines a whole series of macros which makes 48# macro, but instead defines a whole series of macros which makes
49# testing for a specific architecture or later rather impossible. 49# testing for a specific architecture or later rather impossible.
50arch-$(CONFIG_CPU_32v7) :=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7a,-march=armv5t -Wa$(comma)-march=armv7a) 50arch-$(CONFIG_CPU_32v7) :=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
51arch-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6) 51arch-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)
52# Only override the compiler option if ARMv6. The ARMv6K extensions are 52# Only override the compiler option if ARMv6. The ARMv6K extensions are
53# always available in ARMv7 53# always available in ARMv7
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 94462a097f86..7a03f2007882 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -76,7 +76,7 @@ KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
76endif 76endif
77 77
78EXTRA_CFLAGS := -fpic -fno-builtin 78EXTRA_CFLAGS := -fpic -fno-builtin
79EXTRA_AFLAGS := 79EXTRA_AFLAGS := -Wa,-march=all
80 80
81# Supply ZRELADDR, INITRD_PHYS and PARAMS_PHYS to the decompressor via 81# Supply ZRELADDR, INITRD_PHYS and PARAMS_PHYS to the decompressor via
82# linker symbols. We only define initrd_phys and params_phys if the 82# linker symbols. We only define initrd_phys and params_phys if the
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index d42f89b7760b..84a1e0496a3c 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -421,6 +421,7 @@ __setup_mmu: sub r3, r4, #16384 @ Page directory size
421 add r1, r1, #1048576 421 add r1, r1, #1048576
422 str r1, [r0] 422 str r1, [r0]
423 mov pc, lr 423 mov pc, lr
424ENDPROC(__setup_mmu)
424 425
425__armv4_mmu_cache_on: 426__armv4_mmu_cache_on:
426 mov r12, lr 427 mov r12, lr
@@ -801,7 +802,7 @@ loop1:
801 add r2, r2, #4 @ add 4 (line length offset) 802 add r2, r2, #4 @ add 4 (line length offset)
802 ldr r4, =0x3ff 803 ldr r4, =0x3ff
803 ands r4, r4, r1, lsr #3 @ find maximum number on the way size 804 ands r4, r4, r1, lsr #3 @ find maximum number on the way size
804 .word 0xe16f5f14 @ clz r5, r4 - find bit position of way size increment 805 clz r5, r4 @ find bit position of way size increment
805 ldr r7, =0x7fff 806 ldr r7, =0x7fff
806 ands r7, r7, r1, lsr #13 @ extract max number of the index size 807 ands r7, r7, r1, lsr #13 @ extract max number of the index size
807loop2: 808loop2:
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 3e073467caca..2e32acca02fb 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -12,7 +12,8 @@ config ICST307
12 12
13config SA1111 13config SA1111
14 bool 14 bool
15 select DMABOUNCE 15 select DMABOUNCE if !ARCH_PXA
16 select ZONE_DMA if !ARCH_PXA
16 17
17config DMABOUNCE 18config DMABOUNCE
18 bool 19 bool
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index aecc6c3f908f..f030f0775be7 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -154,9 +154,7 @@ alloc_safe_buffer(struct dmabounce_device_info *device_info, void *ptr,
154#endif 154#endif
155 155
156 write_lock_irqsave(&device_info->lock, flags); 156 write_lock_irqsave(&device_info->lock, flags);
157
158 list_add(&buf->node, &device_info->safe_buffers); 157 list_add(&buf->node, &device_info->safe_buffers);
159
160 write_unlock_irqrestore(&device_info->lock, flags); 158 write_unlock_irqrestore(&device_info->lock, flags);
161 159
162 return buf; 160 return buf;
@@ -205,8 +203,22 @@ free_safe_buffer(struct dmabounce_device_info *device_info, struct safe_buffer *
205 203
206/* ************************************************** */ 204/* ************************************************** */
207 205
208static inline dma_addr_t 206static struct safe_buffer *find_safe_buffer_dev(struct device *dev,
209map_single(struct device *dev, void *ptr, size_t size, 207 dma_addr_t dma_addr, const char *where)
208{
209 if (!dev || !dev->archdata.dmabounce)
210 return NULL;
211 if (dma_mapping_error(dev, dma_addr)) {
212 if (dev)
213 dev_err(dev, "Trying to %s invalid mapping\n", where);
214 else
215 pr_err("unknown device: Trying to %s invalid mapping\n", where);
216 return NULL;
217 }
218 return find_safe_buffer(dev->archdata.dmabounce, dma_addr);
219}
220
221static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size,
210 enum dma_data_direction dir) 222 enum dma_data_direction dir)
211{ 223{
212 struct dmabounce_device_info *device_info = dev->archdata.dmabounce; 224 struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
@@ -270,33 +282,21 @@ map_single(struct device *dev, void *ptr, size_t size,
270 return dma_addr; 282 return dma_addr;
271} 283}
272 284
273static inline void 285static inline void unmap_single(struct device *dev, dma_addr_t dma_addr,
274unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 286 size_t size, enum dma_data_direction dir)
275 enum dma_data_direction dir)
276{ 287{
277 struct dmabounce_device_info *device_info = dev->archdata.dmabounce; 288 struct safe_buffer *buf = find_safe_buffer_dev(dev, dma_addr, "unmap");
278 struct safe_buffer *buf = NULL;
279
280 /*
281 * Trying to unmap an invalid mapping
282 */
283 if (dma_mapping_error(dev, dma_addr)) {
284 dev_err(dev, "Trying to unmap invalid mapping\n");
285 return;
286 }
287
288 if (device_info)
289 buf = find_safe_buffer(device_info, dma_addr);
290 289
291 if (buf) { 290 if (buf) {
292 BUG_ON(buf->size != size); 291 BUG_ON(buf->size != size);
292 BUG_ON(buf->direction != dir);
293 293
294 dev_dbg(dev, 294 dev_dbg(dev,
295 "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", 295 "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
296 __func__, buf->ptr, virt_to_dma(dev, buf->ptr), 296 __func__, buf->ptr, virt_to_dma(dev, buf->ptr),
297 buf->safe, buf->safe_dma_addr); 297 buf->safe, buf->safe_dma_addr);
298 298
299 DO_STATS ( device_info->bounce_count++ ); 299 DO_STATS(dev->archdata.dmabounce->bounce_count++);
300 300
301 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) { 301 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) {
302 void *ptr = buf->ptr; 302 void *ptr = buf->ptr;
@@ -317,74 +317,7 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
317 dmac_clean_range(ptr, ptr + size); 317 dmac_clean_range(ptr, ptr + size);
318 outer_clean_range(__pa(ptr), __pa(ptr) + size); 318 outer_clean_range(__pa(ptr), __pa(ptr) + size);
319 } 319 }
320 free_safe_buffer(device_info, buf); 320 free_safe_buffer(dev->archdata.dmabounce, buf);
321 }
322}
323
324static int sync_single(struct device *dev, dma_addr_t dma_addr, size_t size,
325 enum dma_data_direction dir)
326{
327 struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
328 struct safe_buffer *buf = NULL;
329
330 if (device_info)
331 buf = find_safe_buffer(device_info, dma_addr);
332
333 if (buf) {
334 /*
335 * Both of these checks from original code need to be
336 * commented out b/c some drivers rely on the following:
337 *
338 * 1) Drivers may map a large chunk of memory into DMA space
339 * but only sync a small portion of it. Good example is
340 * allocating a large buffer, mapping it, and then
341 * breaking it up into small descriptors. No point
342 * in syncing the whole buffer if you only have to
343 * touch one descriptor.
344 *
345 * 2) Buffers that are mapped as DMA_BIDIRECTIONAL are
346 * usually only synced in one dir at a time.
347 *
348 * See drivers/net/eepro100.c for examples of both cases.
349 *
350 * -ds
351 *
352 * BUG_ON(buf->size != size);
353 * BUG_ON(buf->direction != dir);
354 */
355
356 dev_dbg(dev,
357 "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
358 __func__, buf->ptr, virt_to_dma(dev, buf->ptr),
359 buf->safe, buf->safe_dma_addr);
360
361 DO_STATS ( device_info->bounce_count++ );
362
363 switch (dir) {
364 case DMA_FROM_DEVICE:
365 dev_dbg(dev,
366 "%s: copy back safe %p to unsafe %p size %d\n",
367 __func__, buf->safe, buf->ptr, size);
368 memcpy(buf->ptr, buf->safe, size);
369 break;
370 case DMA_TO_DEVICE:
371 dev_dbg(dev,
372 "%s: copy out unsafe %p to safe %p, size %d\n",
373 __func__,buf->ptr, buf->safe, size);
374 memcpy(buf->safe, buf->ptr, size);
375 break;
376 case DMA_BIDIRECTIONAL:
377 BUG(); /* is this allowed? what does it mean? */
378 default:
379 BUG();
380 }
381 /*
382 * No need to sync the safe buffer - it was allocated
383 * via the coherent allocators.
384 */
385 return 0;
386 } else {
387 return 1;
388 } 321 }
389} 322}
390 323
@@ -396,21 +329,29 @@ static int sync_single(struct device *dev, dma_addr_t dma_addr, size_t size,
396 * substitute the safe buffer for the unsafe one. 329 * substitute the safe buffer for the unsafe one.
397 * (basically move the buffer from an unsafe area to a safe one) 330 * (basically move the buffer from an unsafe area to a safe one)
398 */ 331 */
399dma_addr_t 332dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
400dma_map_single(struct device *dev, void *ptr, size_t size,
401 enum dma_data_direction dir) 333 enum dma_data_direction dir)
402{ 334{
403 dma_addr_t dma_addr;
404
405 dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", 335 dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n",
406 __func__, ptr, size, dir); 336 __func__, ptr, size, dir);
407 337
408 BUG_ON(dir == DMA_NONE); 338 BUG_ON(!valid_dma_direction(dir));
409 339
410 dma_addr = map_single(dev, ptr, size, dir); 340 return map_single(dev, ptr, size, dir);
341}
342EXPORT_SYMBOL(dma_map_single);
411 343
412 return dma_addr; 344dma_addr_t dma_map_page(struct device *dev, struct page *page,
345 unsigned long offset, size_t size, enum dma_data_direction dir)
346{
347 dev_dbg(dev, "%s(page=%p,off=%#lx,size=%zx,dir=%x)\n",
348 __func__, page, offset, size, dir);
349
350 BUG_ON(!valid_dma_direction(dir));
351
352 return map_single(dev, page_address(page) + offset, size, dir);
413} 353}
354EXPORT_SYMBOL(dma_map_page);
414 355
415/* 356/*
416 * see if a mapped address was really a "safe" buffer and if so, copy 357 * see if a mapped address was really a "safe" buffer and if so, copy
@@ -419,126 +360,76 @@ dma_map_single(struct device *dev, void *ptr, size_t size,
419 * should be) 360 * should be)
420 */ 361 */
421 362
422void 363void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
423dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 364 enum dma_data_direction dir)
424 enum dma_data_direction dir)
425{ 365{
426 dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", 366 dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n",
427 __func__, (void *) dma_addr, size, dir); 367 __func__, (void *) dma_addr, size, dir);
428 368
429 BUG_ON(dir == DMA_NONE);
430
431 unmap_single(dev, dma_addr, size, dir); 369 unmap_single(dev, dma_addr, size, dir);
432} 370}
371EXPORT_SYMBOL(dma_unmap_single);
433 372
434int 373int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr,
435dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 374 unsigned long off, size_t sz, enum dma_data_direction dir)
436 enum dma_data_direction dir)
437{ 375{
438 int i; 376 struct safe_buffer *buf;
439
440 dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n",
441 __func__, sg, nents, dir);
442
443 BUG_ON(dir == DMA_NONE);
444
445 for (i = 0; i < nents; i++, sg++) {
446 struct page *page = sg_page(sg);
447 unsigned int offset = sg->offset;
448 unsigned int length = sg->length;
449 void *ptr = page_address(page) + offset;
450 377
451 sg->dma_address = 378 dev_dbg(dev, "%s(dma=%#x,off=%#lx,sz=%zx,dir=%x)\n",
452 map_single(dev, ptr, length, dir); 379 __func__, addr, off, sz, dir);
453 }
454 380
455 return nents; 381 buf = find_safe_buffer_dev(dev, addr, __func__);
456} 382 if (!buf)
457 383 return 1;
458void
459dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
460 enum dma_data_direction dir)
461{
462 int i;
463 384
464 dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", 385 BUG_ON(buf->direction != dir);
465 __func__, sg, nents, dir);
466 386
467 BUG_ON(dir == DMA_NONE); 387 dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
388 __func__, buf->ptr, virt_to_dma(dev, buf->ptr),
389 buf->safe, buf->safe_dma_addr);
468 390
469 for (i = 0; i < nents; i++, sg++) { 391 DO_STATS(dev->archdata.dmabounce->bounce_count++);
470 dma_addr_t dma_addr = sg->dma_address;
471 unsigned int length = sg->length;
472 392
473 unmap_single(dev, dma_addr, length, dir); 393 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) {
394 dev_dbg(dev, "%s: copy back safe %p to unsafe %p size %d\n",
395 __func__, buf->safe + off, buf->ptr + off, sz);
396 memcpy(buf->ptr + off, buf->safe + off, sz);
474 } 397 }
398 return 0;
475} 399}
400EXPORT_SYMBOL(dmabounce_sync_for_cpu);
476 401
477void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr, 402int dmabounce_sync_for_device(struct device *dev, dma_addr_t addr,
478 unsigned long offset, size_t size, 403 unsigned long off, size_t sz, enum dma_data_direction dir)
479 enum dma_data_direction dir)
480{
481 dev_dbg(dev, "%s(dma=%#x,off=%#lx,size=%zx,dir=%x)\n",
482 __func__, dma_addr, offset, size, dir);
483
484 if (sync_single(dev, dma_addr, offset + size, dir))
485 dma_cache_maint(dma_to_virt(dev, dma_addr) + offset, size, dir);
486}
487EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
488
489void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_addr,
490 unsigned long offset, size_t size,
491 enum dma_data_direction dir)
492{
493 dev_dbg(dev, "%s(dma=%#x,off=%#lx,size=%zx,dir=%x)\n",
494 __func__, dma_addr, offset, size, dir);
495
496 if (sync_single(dev, dma_addr, offset + size, dir))
497 dma_cache_maint(dma_to_virt(dev, dma_addr) + offset, size, dir);
498}
499EXPORT_SYMBOL(dma_sync_single_range_for_device);
500
501void
502dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
503 enum dma_data_direction dir)
504{ 404{
505 int i; 405 struct safe_buffer *buf;
506
507 dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n",
508 __func__, sg, nents, dir);
509
510 BUG_ON(dir == DMA_NONE);
511 406
512 for (i = 0; i < nents; i++, sg++) { 407 dev_dbg(dev, "%s(dma=%#x,off=%#lx,sz=%zx,dir=%x)\n",
513 dma_addr_t dma_addr = sg->dma_address; 408 __func__, addr, off, sz, dir);
514 unsigned int length = sg->length;
515 409
516 sync_single(dev, dma_addr, length, dir); 410 buf = find_safe_buffer_dev(dev, addr, __func__);
517 } 411 if (!buf)
518} 412 return 1;
519
520void
521dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents,
522 enum dma_data_direction dir)
523{
524 int i;
525 413
526 dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", 414 BUG_ON(buf->direction != dir);
527 __func__, sg, nents, dir);
528 415
529 BUG_ON(dir == DMA_NONE); 416 dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
417 __func__, buf->ptr, virt_to_dma(dev, buf->ptr),
418 buf->safe, buf->safe_dma_addr);
530 419
531 for (i = 0; i < nents; i++, sg++) { 420 DO_STATS(dev->archdata.dmabounce->bounce_count++);
532 dma_addr_t dma_addr = sg->dma_address;
533 unsigned int length = sg->length;
534 421
535 sync_single(dev, dma_addr, length, dir); 422 if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) {
423 dev_dbg(dev, "%s: copy out unsafe %p to safe %p, size %d\n",
424 __func__,buf->ptr + off, buf->safe + off, sz);
425 memcpy(buf->safe + off, buf->ptr + off, sz);
536 } 426 }
427 return 0;
537} 428}
429EXPORT_SYMBOL(dmabounce_sync_for_device);
538 430
539static int 431static int dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev,
540dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev, const char *name, 432 const char *name, unsigned long size)
541 unsigned long size)
542{ 433{
543 pool->size = size; 434 pool->size = size;
544 DO_STATS(pool->allocs = 0); 435 DO_STATS(pool->allocs = 0);
@@ -549,9 +440,8 @@ dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev, const char
549 return pool->pool ? 0 : -ENOMEM; 440 return pool->pool ? 0 : -ENOMEM;
550} 441}
551 442
552int 443int dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
553dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size, 444 unsigned long large_buffer_size)
554 unsigned long large_buffer_size)
555{ 445{
556 struct dmabounce_device_info *device_info; 446 struct dmabounce_device_info *device_info;
557 int ret; 447 int ret;
@@ -607,9 +497,9 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
607 kfree(device_info); 497 kfree(device_info);
608 return ret; 498 return ret;
609} 499}
500EXPORT_SYMBOL(dmabounce_register_dev);
610 501
611void 502void dmabounce_unregister_dev(struct device *dev)
612dmabounce_unregister_dev(struct device *dev)
613{ 503{
614 struct dmabounce_device_info *device_info = dev->archdata.dmabounce; 504 struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
615 505
@@ -642,15 +532,6 @@ dmabounce_unregister_dev(struct device *dev)
642 532
643 dev_info(dev, "dmabounce: device unregistered\n"); 533 dev_info(dev, "dmabounce: device unregistered\n");
644} 534}
645
646
647EXPORT_SYMBOL(dma_map_single);
648EXPORT_SYMBOL(dma_unmap_single);
649EXPORT_SYMBOL(dma_map_sg);
650EXPORT_SYMBOL(dma_unmap_sg);
651EXPORT_SYMBOL(dma_sync_sg_for_cpu);
652EXPORT_SYMBOL(dma_sync_sg_for_device);
653EXPORT_SYMBOL(dmabounce_register_dev);
654EXPORT_SYMBOL(dmabounce_unregister_dev); 535EXPORT_SYMBOL(dmabounce_unregister_dev);
655 536
656MODULE_AUTHOR("Christopher Hoover <ch@hpl.hp.com>, Deepak Saxena <dsaxena@plexity.net>"); 537MODULE_AUTHOR("Christopher Hoover <ch@hpl.hp.com>, Deepak Saxena <dsaxena@plexity.net>");
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index 0c89bd35e06f..7fc9860a97d7 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -27,9 +27,9 @@
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/smp.h> 28#include <linux/smp.h>
29#include <linux/cpumask.h> 29#include <linux/cpumask.h>
30#include <linux/io.h>
30 31
31#include <asm/irq.h> 32#include <asm/irq.h>
32#include <asm/io.h>
33#include <asm/mach/irq.h> 33#include <asm/mach/irq.h>
34#include <asm/hardware/gic.h> 34#include <asm/hardware/gic.h>
35 35
diff --git a/arch/arm/common/it8152.c b/arch/arm/common/it8152.c
index 5fe9588db077..2793447621c3 100644
--- a/arch/arm/common/it8152.c
+++ b/arch/arm/common/it8152.c
@@ -66,14 +66,6 @@ static void it8152_unmask_irq(unsigned int irq)
66 } 66 }
67} 67}
68 68
69static inline void it8152_irq(int irq)
70{
71 struct irq_desc *desc;
72
73 desc = irq_desc + irq;
74 desc_handle_irq(irq, desc);
75}
76
77static struct irq_chip it8152_irq_chip = { 69static struct irq_chip it8152_irq_chip = {
78 .name = "it8152", 70 .name = "it8152",
79 .ack = it8152_mask_irq, 71 .ack = it8152_mask_irq,
@@ -128,21 +120,21 @@ void it8152_irq_demux(unsigned int irq, struct irq_desc *desc)
128 bits_pd &= ((1 << IT8152_PD_IRQ_COUNT) - 1); 120 bits_pd &= ((1 << IT8152_PD_IRQ_COUNT) - 1);
129 while (bits_pd) { 121 while (bits_pd) {
130 i = __ffs(bits_pd); 122 i = __ffs(bits_pd);
131 it8152_irq(IT8152_PD_IRQ(i)); 123 generic_handle_irq(IT8152_PD_IRQ(i));
132 bits_pd &= ~(1 << i); 124 bits_pd &= ~(1 << i);
133 } 125 }
134 126
135 bits_lp &= ((1 << IT8152_LP_IRQ_COUNT) - 1); 127 bits_lp &= ((1 << IT8152_LP_IRQ_COUNT) - 1);
136 while (bits_lp) { 128 while (bits_lp) {
137 i = __ffs(bits_lp); 129 i = __ffs(bits_lp);
138 it8152_irq(IT8152_LP_IRQ(i)); 130 generic_handle_irq(IT8152_LP_IRQ(i));
139 bits_lp &= ~(1 << i); 131 bits_lp &= ~(1 << i);
140 } 132 }
141 133
142 bits_ld &= ((1 << IT8152_LD_IRQ_COUNT) - 1); 134 bits_ld &= ((1 << IT8152_LD_IRQ_COUNT) - 1);
143 while (bits_ld) { 135 while (bits_ld) {
144 i = __ffs(bits_ld); 136 i = __ffs(bits_ld);
145 it8152_irq(IT8152_LD_IRQ(i)); 137 generic_handle_irq(IT8152_LD_IRQ(i));
146 bits_ld &= ~(1 << i); 138 bits_ld &= ~(1 << i);
147 } 139 }
148 } 140 }
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index 283051eaf931..7c6b4b99a2df 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -24,9 +24,9 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/mach/irq.h> 31#include <asm/mach/irq.h>
32 32
@@ -169,7 +169,6 @@ static struct locomo_dev_info locomo_devices[] = {
169static void locomo_handler(unsigned int irq, struct irq_desc *desc) 169static void locomo_handler(unsigned int irq, struct irq_desc *desc)
170{ 170{
171 int req, i; 171 int req, i;
172 struct irq_desc *d;
173 void __iomem *mapbase = get_irq_chip_data(irq); 172 void __iomem *mapbase = get_irq_chip_data(irq);
174 173
175 /* Acknowledge the parent IRQ */ 174 /* Acknowledge the parent IRQ */
@@ -181,10 +180,9 @@ static void locomo_handler(unsigned int irq, struct irq_desc *desc)
181 if (req) { 180 if (req) {
182 /* generate the next interrupt(s) */ 181 /* generate the next interrupt(s) */
183 irq = LOCOMO_IRQ_START; 182 irq = LOCOMO_IRQ_START;
184 d = irq_desc + irq; 183 for (i = 0; i <= 3; i++, irq++) {
185 for (i = 0; i <= 3; i++, d++, irq++) {
186 if (req & (0x0100 << i)) { 184 if (req & (0x0100 << i)) {
187 desc_handle_irq(irq, d); 185 generic_handle_irq(irq);
188 } 186 }
189 187
190 } 188 }
@@ -222,12 +220,10 @@ static struct irq_chip locomo_chip = {
222 220
223static void locomo_key_handler(unsigned int irq, struct irq_desc *desc) 221static void locomo_key_handler(unsigned int irq, struct irq_desc *desc)
224{ 222{
225 struct irq_desc *d;
226 void __iomem *mapbase = get_irq_chip_data(irq); 223 void __iomem *mapbase = get_irq_chip_data(irq);
227 224
228 if (locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC) & 0x0001) { 225 if (locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC) & 0x0001) {
229 d = irq_desc + LOCOMO_IRQ_KEY_START; 226 generic_handle_irq(LOCOMO_IRQ_KEY_START);
230 desc_handle_irq(LOCOMO_IRQ_KEY_START, d);
231 } 227 }
232} 228}
233 229
@@ -268,7 +264,6 @@ static struct irq_chip locomo_key_chip = {
268static void locomo_gpio_handler(unsigned int irq, struct irq_desc *desc) 264static void locomo_gpio_handler(unsigned int irq, struct irq_desc *desc)
269{ 265{
270 int req, i; 266 int req, i;
271 struct irq_desc *d;
272 void __iomem *mapbase = get_irq_chip_data(irq); 267 void __iomem *mapbase = get_irq_chip_data(irq);
273 268
274 req = locomo_readl(mapbase + LOCOMO_GIR) & 269 req = locomo_readl(mapbase + LOCOMO_GIR) &
@@ -277,10 +272,9 @@ static void locomo_gpio_handler(unsigned int irq, struct irq_desc *desc)
277 272
278 if (req) { 273 if (req) {
279 irq = LOCOMO_IRQ_GPIO_START; 274 irq = LOCOMO_IRQ_GPIO_START;
280 d = irq_desc + LOCOMO_IRQ_GPIO_START; 275 for (i = 0; i <= 15; i++, irq++) {
281 for (i = 0; i <= 15; i++, irq++, d++) {
282 if (req & (0x0001 << i)) { 276 if (req & (0x0001 << i)) {
283 desc_handle_irq(irq, d); 277 generic_handle_irq(irq);
284 } 278 }
285 } 279 }
286 } 280 }
@@ -361,12 +355,10 @@ static struct irq_chip locomo_gpio_chip = {
361 355
362static void locomo_lt_handler(unsigned int irq, struct irq_desc *desc) 356static void locomo_lt_handler(unsigned int irq, struct irq_desc *desc)
363{ 357{
364 struct irq_desc *d;
365 void __iomem *mapbase = get_irq_chip_data(irq); 358 void __iomem *mapbase = get_irq_chip_data(irq);
366 359
367 if (locomo_readl(mapbase + LOCOMO_LTINT) & 0x0001) { 360 if (locomo_readl(mapbase + LOCOMO_LTINT) & 0x0001) {
368 d = irq_desc + LOCOMO_IRQ_LT_START; 361 generic_handle_irq(LOCOMO_IRQ_LT_START);
369 desc_handle_irq(LOCOMO_IRQ_LT_START, d);
370 } 362 }
371} 363}
372 364
@@ -407,17 +399,15 @@ static struct irq_chip locomo_lt_chip = {
407static void locomo_spi_handler(unsigned int irq, struct irq_desc *desc) 399static void locomo_spi_handler(unsigned int irq, struct irq_desc *desc)
408{ 400{
409 int req, i; 401 int req, i;
410 struct irq_desc *d;
411 void __iomem *mapbase = get_irq_chip_data(irq); 402 void __iomem *mapbase = get_irq_chip_data(irq);
412 403
413 req = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIR) & 0x000F; 404 req = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIR) & 0x000F;
414 if (req) { 405 if (req) {
415 irq = LOCOMO_IRQ_SPI_START; 406 irq = LOCOMO_IRQ_SPI_START;
416 d = irq_desc + irq;
417 407
418 for (i = 0; i <= 3; i++, irq++, d++) { 408 for (i = 0; i <= 3; i++, irq++) {
419 if (req & (0x0001 << i)) { 409 if (req & (0x0001 << i)) {
420 desc_handle_irq(irq, d); 410 generic_handle_irq(irq);
421 } 411 }
422 } 412 }
423 } 413 }
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index ec8a5471bf06..fb86f248aab8 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -25,10 +25,10 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/io.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/mach-types.h> 31#include <asm/mach-types.h>
31#include <asm/io.h>
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <asm/mach/irq.h> 33#include <asm/mach/irq.h>
34#include <asm/sizes.h> 34#include <asm/sizes.h>
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
index ae39553589dd..697c64913990 100644
--- a/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -15,7 +15,7 @@
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <asm/io.h> 18#include <linux/io.h>
19#include <asm/gpio.h> 19#include <asm/gpio.h>
20#include <asm/hardware/scoop.h> 20#include <asm/hardware/scoop.h>
21 21
diff --git a/arch/arm/common/sharpsl_param.c b/arch/arm/common/sharpsl_param.c
index aad4d94ba8f5..d56c932580eb 100644
--- a/arch/arm/common/sharpsl_param.c
+++ b/arch/arm/common/sharpsl_param.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h>
15#include <linux/string.h> 16#include <linux/string.h>
16#include <asm/mach/sharpsl_param.h> 17#include <asm/mach/sharpsl_param.h>
17 18
@@ -36,6 +37,7 @@
36#define PHAD_MAGIC MAGIC_CHG('P','H','A','D') 37#define PHAD_MAGIC MAGIC_CHG('P','H','A','D')
37 38
38struct sharpsl_param_info sharpsl_param; 39struct sharpsl_param_info sharpsl_param;
40EXPORT_SYMBOL(sharpsl_param);
39 41
40void sharpsl_save_param(void) 42void sharpsl_save_param(void)
41{ 43{
diff --git a/arch/arm/common/time-acorn.c b/arch/arm/common/time-acorn.c
index df0983aafe69..deeed561b168 100644
--- a/arch/arm/common/time-acorn.c
+++ b/arch/arm/common/time-acorn.c
@@ -17,9 +17,9 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/irq.h> 19#include <linux/irq.h>
20#include <linux/io.h>
20 21
21#include <mach/hardware.h> 22#include <mach/hardware.h>
22#include <asm/io.h>
23#include <asm/hardware/ioc.h> 23#include <asm/hardware/ioc.h>
24 24
25#include <asm/mach/time.h> 25#include <asm/mach/time.h>
diff --git a/arch/arm/common/uengine.c b/arch/arm/common/uengine.c
index 7ecd3c0ab011..b520e56216a9 100644
--- a/arch/arm/common/uengine.c
+++ b/arch/arm/common/uengine.c
@@ -16,9 +16,9 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/io.h>
19#include <mach/hardware.h> 20#include <mach/hardware.h>
20#include <asm/hardware/uengine.h> 21#include <asm/hardware/uengine.h>
21#include <asm/io.h>
22 22
23#if defined(CONFIG_ARCH_IXP2000) 23#if defined(CONFIG_ARCH_IXP2000)
24#define IXP_UENGINE_CSR_VIRT_BASE IXP2000_UENGINE_CSR_VIRT_BASE 24#define IXP_UENGINE_CSR_VIRT_BASE IXP2000_UENGINE_CSR_VIRT_BASE
diff --git a/arch/arm/common/via82c505.c b/arch/arm/common/via82c505.c
index 79a8206e62ac..8421d39109b3 100644
--- a/arch/arm/common/via82c505.c
+++ b/arch/arm/common/via82c505.c
@@ -4,8 +4,8 @@
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/ioport.h> 6#include <linux/ioport.h>
7#include <linux/io.h>
7 8
8#include <asm/io.h>
9#include <asm/system.h> 9#include <asm/system.h>
10 10
11#include <asm/mach/pci.h> 11#include <asm/mach/pci.h>
diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
index c026fa2214a3..f1e4b8f60cab 100644
--- a/arch/arm/common/vic.c
+++ b/arch/arm/common/vic.c
@@ -20,8 +20,8 @@
20 */ 20 */
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/list.h> 22#include <linux/list.h>
23#include <linux/io.h>
23 24
24#include <asm/io.h>
25#include <asm/mach/irq.h> 25#include <asm/mach/irq.h>
26#include <asm/hardware/vic.h> 26#include <asm/hardware/vic.h>
27 27
diff --git a/arch/arm/configs/afeb9260_defconfig b/arch/arm/configs/afeb9260_defconfig
new file mode 100644
index 000000000000..ce909586a34f
--- /dev/null
+++ b/arch/arm/configs/afeb9260_defconfig
@@ -0,0 +1,1259 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc2
4# Tue Aug 12 22:30:16 2008
5#
6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y
11CONFIG_MMU=y
12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
16CONFIG_LOCKDEP_SUPPORT=y
17CONFIG_TRACE_IRQFLAGS_SUPPORT=y
18CONFIG_HARDIRQS_SW_RESEND=y
19CONFIG_GENERIC_IRQ_PROBE=y
20CONFIG_RWSEM_GENERIC_SPINLOCK=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_GENERIC_HWEIGHT=y
24CONFIG_GENERIC_CALIBRATE_DELAY=y
25CONFIG_ARCH_SUPPORTS_AOUT=y
26CONFIG_ZONE_DMA=y
27CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
28CONFIG_VECTORS_BASE=0xffff0000
29CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
30
31#
32# General setup
33#
34CONFIG_EXPERIMENTAL=y
35CONFIG_BROKEN_ON_SMP=y
36CONFIG_LOCK_KERNEL=y
37CONFIG_INIT_ENV_ARG_LIMIT=32
38CONFIG_LOCALVERSION=""
39# CONFIG_LOCALVERSION_AUTO is not set
40CONFIG_SWAP=y
41CONFIG_SYSVIPC=y
42CONFIG_SYSVIPC_SYSCTL=y
43# CONFIG_POSIX_MQUEUE is not set
44# CONFIG_BSD_PROCESS_ACCT is not set
45# CONFIG_TASKSTATS is not set
46# CONFIG_AUDIT is not set
47# CONFIG_IKCONFIG is not set
48CONFIG_LOG_BUF_SHIFT=14
49# CONFIG_CGROUPS is not set
50# CONFIG_GROUP_SCHED is not set
51CONFIG_SYSFS_DEPRECATED=y
52CONFIG_SYSFS_DEPRECATED_V2=y
53# CONFIG_RELAY is not set
54CONFIG_NAMESPACES=y
55# CONFIG_UTS_NS is not set
56# CONFIG_IPC_NS is not set
57# CONFIG_USER_NS is not set
58# CONFIG_PID_NS is not set
59CONFIG_BLK_DEV_INITRD=y
60CONFIG_INITRAMFS_SOURCE=""
61CONFIG_CC_OPTIMIZE_FOR_SIZE=y
62CONFIG_SYSCTL=y
63# CONFIG_EMBEDDED is not set
64CONFIG_UID16=y
65CONFIG_SYSCTL_SYSCALL=y
66CONFIG_SYSCTL_SYSCALL_CHECK=y
67CONFIG_KALLSYMS=y
68# CONFIG_KALLSYMS_ALL is not set
69# CONFIG_KALLSYMS_EXTRA_PASS is not set
70CONFIG_HOTPLUG=y
71CONFIG_PRINTK=y
72CONFIG_BUG=y
73CONFIG_ELF_CORE=y
74CONFIG_COMPAT_BRK=y
75CONFIG_BASE_FULL=y
76CONFIG_FUTEX=y
77CONFIG_ANON_INODES=y
78CONFIG_EPOLL=y
79CONFIG_SIGNALFD=y
80CONFIG_TIMERFD=y
81CONFIG_EVENTFD=y
82CONFIG_SHMEM=y
83CONFIG_VM_EVENT_COUNTERS=y
84CONFIG_SLAB=y
85# CONFIG_SLUB is not set
86# CONFIG_SLOB is not set
87# CONFIG_PROFILING is not set
88# CONFIG_MARKERS is not set
89CONFIG_HAVE_OPROFILE=y
90# CONFIG_KPROBES is not set
91# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
92# CONFIG_HAVE_IOREMAP_PROT is not set
93CONFIG_HAVE_KPROBES=y
94CONFIG_HAVE_KRETPROBES=y
95# CONFIG_HAVE_ARCH_TRACEHOOK is not set
96# CONFIG_HAVE_DMA_ATTRS is not set
97# CONFIG_USE_GENERIC_SMP_HELPERS is not set
98CONFIG_HAVE_CLK=y
99CONFIG_PROC_PAGE_MONITOR=y
100CONFIG_HAVE_GENERIC_DMA_COHERENT=y
101CONFIG_SLABINFO=y
102CONFIG_RT_MUTEXES=y
103# CONFIG_TINY_SHMEM is not set
104CONFIG_BASE_SMALL=0
105CONFIG_MODULES=y
106# CONFIG_MODULE_FORCE_LOAD is not set
107CONFIG_MODULE_UNLOAD=y
108# CONFIG_MODULE_FORCE_UNLOAD is not set
109# CONFIG_MODVERSIONS is not set
110# CONFIG_MODULE_SRCVERSION_ALL is not set
111CONFIG_KMOD=y
112CONFIG_BLOCK=y
113# CONFIG_LBD is not set
114# CONFIG_BLK_DEV_IO_TRACE is not set
115# CONFIG_LSF is not set
116# CONFIG_BLK_DEV_BSG is not set
117# CONFIG_BLK_DEV_INTEGRITY is not set
118
119#
120# IO Schedulers
121#
122CONFIG_IOSCHED_NOOP=y
123CONFIG_IOSCHED_AS=y
124# CONFIG_IOSCHED_DEADLINE is not set
125# CONFIG_IOSCHED_CFQ is not set
126CONFIG_DEFAULT_AS=y
127# CONFIG_DEFAULT_DEADLINE is not set
128# CONFIG_DEFAULT_CFQ is not set
129# CONFIG_DEFAULT_NOOP is not set
130CONFIG_DEFAULT_IOSCHED="anticipatory"
131CONFIG_CLASSIC_RCU=y
132
133#
134# System Type
135#
136# CONFIG_ARCH_AAEC2000 is not set
137# CONFIG_ARCH_INTEGRATOR is not set
138# CONFIG_ARCH_REALVIEW is not set
139# CONFIG_ARCH_VERSATILE is not set
140CONFIG_ARCH_AT91=y
141# CONFIG_ARCH_CLPS7500 is not set
142# CONFIG_ARCH_CLPS711X is not set
143# CONFIG_ARCH_EBSA110 is not set
144# CONFIG_ARCH_EP93XX is not set
145# CONFIG_ARCH_FOOTBRIDGE is not set
146# CONFIG_ARCH_NETX is not set
147# CONFIG_ARCH_H720X is not set
148# CONFIG_ARCH_IMX is not set
149# CONFIG_ARCH_IOP13XX is not set
150# CONFIG_ARCH_IOP32X is not set
151# CONFIG_ARCH_IOP33X is not set
152# CONFIG_ARCH_IXP23XX is not set
153# CONFIG_ARCH_IXP2000 is not set
154# CONFIG_ARCH_IXP4XX is not set
155# CONFIG_ARCH_L7200 is not set
156# CONFIG_ARCH_KIRKWOOD is not set
157# CONFIG_ARCH_KS8695 is not set
158# CONFIG_ARCH_NS9XXX is not set
159# CONFIG_ARCH_LOKI is not set
160# CONFIG_ARCH_MV78XX0 is not set
161# CONFIG_ARCH_MXC is not set
162# CONFIG_ARCH_ORION5X is not set
163# CONFIG_ARCH_PNX4008 is not set
164# CONFIG_ARCH_PXA is not set
165# CONFIG_ARCH_RPC is not set
166# CONFIG_ARCH_SA1100 is not set
167# CONFIG_ARCH_S3C2410 is not set
168# CONFIG_ARCH_SHARK is not set
169# CONFIG_ARCH_LH7A40X is not set
170# CONFIG_ARCH_DAVINCI is not set
171# CONFIG_ARCH_OMAP is not set
172# CONFIG_ARCH_MSM7X00A is not set
173
174#
175# Boot options
176#
177
178#
179# Power management
180#
181
182#
183# Atmel AT91 System-on-Chip
184#
185# CONFIG_ARCH_AT91RM9200 is not set
186CONFIG_ARCH_AT91SAM9260=y
187# CONFIG_ARCH_AT91SAM9261 is not set
188# CONFIG_ARCH_AT91SAM9263 is not set
189# CONFIG_ARCH_AT91SAM9RL is not set
190# CONFIG_ARCH_AT91SAM9G20 is not set
191# CONFIG_ARCH_AT91CAP9 is not set
192# CONFIG_ARCH_AT91X40 is not set
193CONFIG_AT91_PMC_UNIT=y
194
195#
196# AT91SAM9260 Variants
197#
198# CONFIG_ARCH_AT91SAM9260_SAM9XE is not set
199
200#
201# AT91SAM9260 / AT91SAM9XE Board Type
202#
203# CONFIG_MACH_AT91SAM9260EK is not set
204# CONFIG_MACH_CAM60 is not set
205# CONFIG_MACH_SAM9_L9260 is not set
206CONFIG_MACH_AFEB9260=y
207# CONFIG_MACH_USB_A9260 is not set
208# CONFIG_MACH_QIL_A9260 is not set
209
210#
211# AT91 Board Options
212#
213
214#
215# AT91 Feature Selections
216#
217CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
218CONFIG_AT91_TIMER_HZ=100
219CONFIG_AT91_EARLY_DBGU=y
220# CONFIG_AT91_EARLY_USART0 is not set
221# CONFIG_AT91_EARLY_USART1 is not set
222# CONFIG_AT91_EARLY_USART2 is not set
223# CONFIG_AT91_EARLY_USART3 is not set
224# CONFIG_AT91_EARLY_USART4 is not set
225# CONFIG_AT91_EARLY_USART5 is not set
226
227#
228# Processor Type
229#
230CONFIG_CPU_32=y
231CONFIG_CPU_ARM926T=y
232CONFIG_CPU_32v5=y
233CONFIG_CPU_ABRT_EV5TJ=y
234CONFIG_CPU_PABRT_NOIFAR=y
235CONFIG_CPU_CACHE_VIVT=y
236CONFIG_CPU_COPY_V4WB=y
237CONFIG_CPU_TLB_V4WBI=y
238CONFIG_CPU_CP15=y
239CONFIG_CPU_CP15_MMU=y
240
241#
242# Processor Features
243#
244CONFIG_ARM_THUMB=y
245# CONFIG_CPU_ICACHE_DISABLE is not set
246# CONFIG_CPU_DCACHE_DISABLE is not set
247# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
248# CONFIG_CPU_CACHE_ROUND_ROBIN is not set
249# CONFIG_OUTER_CACHE is not set
250
251#
252# Bus support
253#
254# CONFIG_PCI_SYSCALL is not set
255# CONFIG_ARCH_SUPPORTS_MSI is not set
256# CONFIG_PCCARD is not set
257
258#
259# Kernel Features
260#
261# CONFIG_TICK_ONESHOT is not set
262# CONFIG_NO_HZ is not set
263# CONFIG_HIGH_RES_TIMERS is not set
264CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
265CONFIG_PREEMPT=y
266CONFIG_HZ=100
267CONFIG_AEABI=y
268CONFIG_OABI_COMPAT=y
269# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
270CONFIG_SELECT_MEMORY_MODEL=y
271CONFIG_FLATMEM_MANUAL=y
272# CONFIG_DISCONTIGMEM_MANUAL is not set
273# CONFIG_SPARSEMEM_MANUAL is not set
274CONFIG_FLATMEM=y
275CONFIG_FLAT_NODE_MEM_MAP=y
276# CONFIG_SPARSEMEM_STATIC is not set
277# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
278CONFIG_PAGEFLAGS_EXTENDED=y
279CONFIG_SPLIT_PTLOCK_CPUS=4096
280# CONFIG_RESOURCES_64BIT is not set
281CONFIG_ZONE_DMA_FLAG=1
282CONFIG_BOUNCE=y
283CONFIG_VIRT_TO_BUS=y
284# CONFIG_LEDS is not set
285CONFIG_ALIGNMENT_TRAP=y
286
287#
288# Boot options
289#
290CONFIG_ZBOOT_ROM_TEXT=0x0
291CONFIG_ZBOOT_ROM_BSS=0x0
292CONFIG_CMDLINE="mem=64M console=ttyS0,115200 initrd=0x21100000,3145728 root=/dev/ram0 rw"
293# CONFIG_XIP_KERNEL is not set
294# CONFIG_KEXEC is not set
295
296#
297# Floating point emulation
298#
299
300#
301# At least one emulation must be selected
302#
303CONFIG_FPE_NWFPE=y
304# CONFIG_FPE_NWFPE_XP is not set
305# CONFIG_FPE_FASTFPE is not set
306# CONFIG_VFP is not set
307
308#
309# Userspace binary formats
310#
311CONFIG_BINFMT_ELF=y
312# CONFIG_BINFMT_AOUT is not set
313# CONFIG_BINFMT_MISC is not set
314
315#
316# Power management options
317#
318# CONFIG_PM is not set
319CONFIG_ARCH_SUSPEND_POSSIBLE=y
320CONFIG_NET=y
321
322#
323# Networking options
324#
325CONFIG_PACKET=y
326# CONFIG_PACKET_MMAP is not set
327CONFIG_UNIX=y
328# CONFIG_NET_KEY is not set
329CONFIG_INET=y
330# CONFIG_IP_MULTICAST is not set
331# CONFIG_IP_ADVANCED_ROUTER is not set
332CONFIG_IP_FIB_HASH=y
333CONFIG_IP_PNP=y
334# CONFIG_IP_PNP_DHCP is not set
335CONFIG_IP_PNP_BOOTP=y
336# CONFIG_IP_PNP_RARP is not set
337# CONFIG_NET_IPIP is not set
338# CONFIG_NET_IPGRE is not set
339# CONFIG_ARPD is not set
340# CONFIG_SYN_COOKIES is not set
341# CONFIG_INET_AH is not set
342# CONFIG_INET_ESP is not set
343# CONFIG_INET_IPCOMP is not set
344# CONFIG_INET_XFRM_TUNNEL is not set
345# CONFIG_INET_TUNNEL is not set
346# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
347# CONFIG_INET_XFRM_MODE_TUNNEL is not set
348# CONFIG_INET_XFRM_MODE_BEET is not set
349# CONFIG_INET_LRO is not set
350CONFIG_INET_DIAG=y
351CONFIG_INET_TCP_DIAG=y
352# CONFIG_TCP_CONG_ADVANCED is not set
353CONFIG_TCP_CONG_CUBIC=y
354CONFIG_DEFAULT_TCP_CONG="cubic"
355# CONFIG_TCP_MD5SIG is not set
356# CONFIG_IPV6 is not set
357# CONFIG_NETWORK_SECMARK is not set
358# CONFIG_NETFILTER is not set
359# CONFIG_IP_DCCP is not set
360# CONFIG_IP_SCTP is not set
361# CONFIG_TIPC is not set
362# CONFIG_ATM is not set
363# CONFIG_BRIDGE is not set
364# CONFIG_VLAN_8021Q is not set
365# CONFIG_DECNET is not set
366# CONFIG_LLC2 is not set
367# CONFIG_IPX is not set
368# CONFIG_ATALK is not set
369# CONFIG_X25 is not set
370# CONFIG_LAPB is not set
371# CONFIG_ECONET is not set
372# CONFIG_WAN_ROUTER is not set
373# CONFIG_NET_SCHED is not set
374
375#
376# Network testing
377#
378# CONFIG_NET_PKTGEN is not set
379# CONFIG_HAMRADIO is not set
380# CONFIG_CAN is not set
381# CONFIG_IRDA is not set
382# CONFIG_BT is not set
383# CONFIG_AF_RXRPC is not set
384
385#
386# Wireless
387#
388# CONFIG_CFG80211 is not set
389# CONFIG_WIRELESS_EXT is not set
390# CONFIG_MAC80211 is not set
391# CONFIG_IEEE80211 is not set
392# CONFIG_RFKILL is not set
393# CONFIG_NET_9P is not set
394
395#
396# Device Drivers
397#
398
399#
400# Generic Driver Options
401#
402CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
403CONFIG_STANDALONE=y
404CONFIG_PREVENT_FIRMWARE_BUILD=y
405CONFIG_FW_LOADER=y
406CONFIG_FIRMWARE_IN_KERNEL=y
407CONFIG_EXTRA_FIRMWARE=""
408# CONFIG_DEBUG_DRIVER is not set
409# CONFIG_DEBUG_DEVRES is not set
410# CONFIG_SYS_HYPERVISOR is not set
411# CONFIG_CONNECTOR is not set
412CONFIG_MTD=y
413# CONFIG_MTD_DEBUG is not set
414# CONFIG_MTD_CONCAT is not set
415CONFIG_MTD_PARTITIONS=y
416# CONFIG_MTD_REDBOOT_PARTS is not set
417# CONFIG_MTD_CMDLINE_PARTS is not set
418# CONFIG_MTD_AFS_PARTS is not set
419# CONFIG_MTD_AR7_PARTS is not set
420
421#
422# User Modules And Translation Layers
423#
424CONFIG_MTD_CHAR=y
425CONFIG_MTD_BLKDEVS=y
426CONFIG_MTD_BLOCK=y
427# CONFIG_FTL is not set
428# CONFIG_NFTL is not set
429# CONFIG_INFTL is not set
430# CONFIG_RFD_FTL is not set
431# CONFIG_SSFDC is not set
432# CONFIG_MTD_OOPS is not set
433
434#
435# RAM/ROM/Flash chip drivers
436#
437# CONFIG_MTD_CFI is not set
438# CONFIG_MTD_JEDECPROBE is not set
439CONFIG_MTD_MAP_BANK_WIDTH_1=y
440CONFIG_MTD_MAP_BANK_WIDTH_2=y
441CONFIG_MTD_MAP_BANK_WIDTH_4=y
442# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
443# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
444# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
445CONFIG_MTD_CFI_I1=y
446CONFIG_MTD_CFI_I2=y
447# CONFIG_MTD_CFI_I4 is not set
448# CONFIG_MTD_CFI_I8 is not set
449# CONFIG_MTD_RAM is not set
450# CONFIG_MTD_ROM is not set
451# CONFIG_MTD_ABSENT is not set
452
453#
454# Mapping drivers for chip access
455#
456# CONFIG_MTD_COMPLEX_MAPPINGS is not set
457# CONFIG_MTD_PLATRAM is not set
458
459#
460# Self-contained MTD device drivers
461#
462CONFIG_MTD_DATAFLASH=y
463# CONFIG_MTD_M25P80 is not set
464# CONFIG_MTD_SLRAM is not set
465# CONFIG_MTD_PHRAM is not set
466# CONFIG_MTD_MTDRAM is not set
467# CONFIG_MTD_BLOCK2MTD is not set
468
469#
470# Disk-On-Chip Device Drivers
471#
472# CONFIG_MTD_DOC2000 is not set
473# CONFIG_MTD_DOC2001 is not set
474# CONFIG_MTD_DOC2001PLUS is not set
475CONFIG_MTD_NAND=y
476# CONFIG_MTD_NAND_VERIFY_WRITE is not set
477# CONFIG_MTD_NAND_ECC_SMC is not set
478# CONFIG_MTD_NAND_MUSEUM_IDS is not set
479CONFIG_MTD_NAND_IDS=y
480# CONFIG_MTD_NAND_DISKONCHIP is not set
481CONFIG_MTD_NAND_ATMEL=y
482# CONFIG_MTD_NAND_ATMEL_ECC_HW is not set
483CONFIG_MTD_NAND_ATMEL_ECC_SOFT=y
484# CONFIG_MTD_NAND_ATMEL_ECC_NONE is not set
485# CONFIG_MTD_NAND_NANDSIM is not set
486# CONFIG_MTD_NAND_PLATFORM is not set
487# CONFIG_MTD_ALAUDA is not set
488# CONFIG_MTD_ONENAND is not set
489
490#
491# UBI - Unsorted block images
492#
493# CONFIG_MTD_UBI is not set
494# CONFIG_PARPORT is not set
495CONFIG_BLK_DEV=y
496# CONFIG_BLK_DEV_COW_COMMON is not set
497# CONFIG_BLK_DEV_LOOP is not set
498# CONFIG_BLK_DEV_NBD is not set
499# CONFIG_BLK_DEV_UB is not set
500CONFIG_BLK_DEV_RAM=y
501CONFIG_BLK_DEV_RAM_COUNT=16
502CONFIG_BLK_DEV_RAM_SIZE=8192
503# CONFIG_BLK_DEV_XIP is not set
504# CONFIG_CDROM_PKTCDVD is not set
505# CONFIG_ATA_OVER_ETH is not set
506CONFIG_MISC_DEVICES=y
507# CONFIG_ATMEL_PWM is not set
508# CONFIG_ATMEL_TCLIB is not set
509# CONFIG_EEPROM_93CX6 is not set
510CONFIG_ATMEL_SSC=y
511# CONFIG_ENCLOSURE_SERVICES is not set
512CONFIG_HAVE_IDE=y
513# CONFIG_IDE is not set
514
515#
516# SCSI device support
517#
518# CONFIG_RAID_ATTRS is not set
519CONFIG_SCSI=y
520CONFIG_SCSI_DMA=y
521# CONFIG_SCSI_TGT is not set
522# CONFIG_SCSI_NETLINK is not set
523CONFIG_SCSI_PROC_FS=y
524
525#
526# SCSI support type (disk, tape, CD-ROM)
527#
528CONFIG_BLK_DEV_SD=y
529# CONFIG_CHR_DEV_ST is not set
530# CONFIG_CHR_DEV_OSST is not set
531# CONFIG_BLK_DEV_SR is not set
532# CONFIG_CHR_DEV_SG is not set
533# CONFIG_CHR_DEV_SCH is not set
534
535#
536# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
537#
538CONFIG_SCSI_MULTI_LUN=y
539# CONFIG_SCSI_CONSTANTS is not set
540# CONFIG_SCSI_LOGGING is not set
541# CONFIG_SCSI_SCAN_ASYNC is not set
542CONFIG_SCSI_WAIT_SCAN=m
543
544#
545# SCSI Transports
546#
547# CONFIG_SCSI_SPI_ATTRS is not set
548# CONFIG_SCSI_FC_ATTRS is not set
549# CONFIG_SCSI_ISCSI_ATTRS is not set
550# CONFIG_SCSI_SAS_LIBSAS is not set
551# CONFIG_SCSI_SRP_ATTRS is not set
552CONFIG_SCSI_LOWLEVEL=y
553# CONFIG_ISCSI_TCP is not set
554# CONFIG_SCSI_DEBUG is not set
555# CONFIG_SCSI_DH is not set
556# CONFIG_ATA is not set
557# CONFIG_MD is not set
558CONFIG_NETDEVICES=y
559# CONFIG_DUMMY is not set
560# CONFIG_BONDING is not set
561# CONFIG_MACVLAN is not set
562# CONFIG_EQUALIZER is not set
563# CONFIG_TUN is not set
564# CONFIG_VETH is not set
565CONFIG_PHYLIB=y
566
567#
568# MII PHY device drivers
569#
570# CONFIG_MARVELL_PHY is not set
571# CONFIG_DAVICOM_PHY is not set
572# CONFIG_QSEMI_PHY is not set
573# CONFIG_LXT_PHY is not set
574# CONFIG_CICADA_PHY is not set
575# CONFIG_VITESSE_PHY is not set
576# CONFIG_SMSC_PHY is not set
577# CONFIG_BROADCOM_PHY is not set
578# CONFIG_ICPLUS_PHY is not set
579# CONFIG_REALTEK_PHY is not set
580# CONFIG_FIXED_PHY is not set
581# CONFIG_MDIO_BITBANG is not set
582CONFIG_NET_ETHERNET=y
583CONFIG_MII=y
584CONFIG_MACB=y
585# CONFIG_AX88796 is not set
586# CONFIG_SMC91X is not set
587# CONFIG_DM9000 is not set
588# CONFIG_ENC28J60 is not set
589# CONFIG_IBM_NEW_EMAC_ZMII is not set
590# CONFIG_IBM_NEW_EMAC_RGMII is not set
591# CONFIG_IBM_NEW_EMAC_TAH is not set
592# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
593# CONFIG_B44 is not set
594# CONFIG_NETDEV_1000 is not set
595# CONFIG_NETDEV_10000 is not set
596
597#
598# Wireless LAN
599#
600# CONFIG_WLAN_PRE80211 is not set
601# CONFIG_WLAN_80211 is not set
602# CONFIG_IWLWIFI_LEDS is not set
603
604#
605# USB Network Adapters
606#
607# CONFIG_USB_CATC is not set
608# CONFIG_USB_KAWETH is not set
609# CONFIG_USB_PEGASUS is not set
610# CONFIG_USB_RTL8150 is not set
611# CONFIG_USB_USBNET is not set
612# CONFIG_WAN is not set
613# CONFIG_PPP is not set
614# CONFIG_SLIP is not set
615# CONFIG_NETCONSOLE is not set
616# CONFIG_NETPOLL is not set
617# CONFIG_NET_POLL_CONTROLLER is not set
618# CONFIG_ISDN is not set
619
620#
621# Input device support
622#
623CONFIG_INPUT=y
624# CONFIG_INPUT_FF_MEMLESS is not set
625# CONFIG_INPUT_POLLDEV is not set
626
627#
628# Userland interfaces
629#
630CONFIG_INPUT_MOUSEDEV=y
631# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
632CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
633CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
634# CONFIG_INPUT_JOYDEV is not set
635# CONFIG_INPUT_EVDEV is not set
636# CONFIG_INPUT_EVBUG is not set
637
638#
639# Input Device Drivers
640#
641# CONFIG_INPUT_KEYBOARD is not set
642# CONFIG_INPUT_MOUSE is not set
643# CONFIG_INPUT_JOYSTICK is not set
644# CONFIG_INPUT_TABLET is not set
645# CONFIG_INPUT_TOUCHSCREEN is not set
646# CONFIG_INPUT_MISC is not set
647
648#
649# Hardware I/O ports
650#
651# CONFIG_SERIO is not set
652# CONFIG_GAMEPORT is not set
653
654#
655# Character devices
656#
657CONFIG_VT=y
658CONFIG_CONSOLE_TRANSLATIONS=y
659CONFIG_VT_CONSOLE=y
660CONFIG_HW_CONSOLE=y
661# CONFIG_VT_HW_CONSOLE_BINDING is not set
662CONFIG_DEVKMEM=y
663# CONFIG_SERIAL_NONSTANDARD is not set
664
665#
666# Serial drivers
667#
668# CONFIG_SERIAL_8250 is not set
669
670#
671# Non-8250 serial port support
672#
673CONFIG_SERIAL_ATMEL=y
674CONFIG_SERIAL_ATMEL_CONSOLE=y
675CONFIG_SERIAL_ATMEL_PDC=y
676# CONFIG_SERIAL_ATMEL_TTYAT is not set
677CONFIG_SERIAL_CORE=y
678CONFIG_SERIAL_CORE_CONSOLE=y
679CONFIG_UNIX98_PTYS=y
680CONFIG_LEGACY_PTYS=y
681CONFIG_LEGACY_PTY_COUNT=256
682# CONFIG_IPMI_HANDLER is not set
683# CONFIG_HW_RANDOM is not set
684# CONFIG_NVRAM is not set
685# CONFIG_R3964 is not set
686# CONFIG_RAW_DRIVER is not set
687# CONFIG_TCG_TPM is not set
688CONFIG_I2C=y
689CONFIG_I2C_BOARDINFO=y
690CONFIG_I2C_CHARDEV=y
691CONFIG_I2C_HELPER_AUTO=y
692CONFIG_I2C_ALGOBIT=y
693
694#
695# I2C Hardware Bus support
696#
697
698#
699# I2C system bus drivers (mostly embedded / system-on-chip)
700#
701CONFIG_I2C_GPIO=y
702# CONFIG_I2C_OCORES is not set
703# CONFIG_I2C_SIMTEC is not set
704
705#
706# External I2C/SMBus adapter drivers
707#
708# CONFIG_I2C_PARPORT_LIGHT is not set
709# CONFIG_I2C_TAOS_EVM is not set
710# CONFIG_I2C_TINY_USB is not set
711
712#
713# Other I2C/SMBus bus drivers
714#
715# CONFIG_I2C_PCA_PLATFORM is not set
716# CONFIG_I2C_STUB is not set
717
718#
719# Miscellaneous I2C Chip support
720#
721# CONFIG_DS1682 is not set
722CONFIG_AT24=y
723# CONFIG_SENSORS_EEPROM is not set
724# CONFIG_SENSORS_PCF8574 is not set
725# CONFIG_PCF8575 is not set
726# CONFIG_SENSORS_PCA9539 is not set
727# CONFIG_SENSORS_PCF8591 is not set
728# CONFIG_SENSORS_MAX6875 is not set
729# CONFIG_SENSORS_TSL2550 is not set
730# CONFIG_I2C_DEBUG_CORE is not set
731# CONFIG_I2C_DEBUG_ALGO is not set
732# CONFIG_I2C_DEBUG_BUS is not set
733# CONFIG_I2C_DEBUG_CHIP is not set
734CONFIG_SPI=y
735CONFIG_SPI_DEBUG=y
736CONFIG_SPI_MASTER=y
737
738#
739# SPI Master Controller Drivers
740#
741CONFIG_SPI_ATMEL=y
742# CONFIG_SPI_BITBANG is not set
743
744#
745# SPI Protocol Masters
746#
747# CONFIG_SPI_AT25 is not set
748CONFIG_SPI_SPIDEV=y
749# CONFIG_SPI_TLE62X0 is not set
750# CONFIG_W1 is not set
751# CONFIG_POWER_SUPPLY is not set
752# CONFIG_HWMON is not set
753CONFIG_WATCHDOG=y
754CONFIG_WATCHDOG_NOWAYOUT=y
755
756#
757# Watchdog Device Drivers
758#
759# CONFIG_SOFT_WATCHDOG is not set
760
761#
762# USB-based Watchdog Cards
763#
764# CONFIG_USBPCWATCHDOG is not set
765
766#
767# Sonics Silicon Backplane
768#
769CONFIG_SSB_POSSIBLE=y
770# CONFIG_SSB is not set
771
772#
773# Multifunction device drivers
774#
775# CONFIG_MFD_CORE is not set
776# CONFIG_MFD_SM501 is not set
777# CONFIG_HTC_PASIC3 is not set
778# CONFIG_MFD_TMIO is not set
779# CONFIG_MFD_T7L66XB is not set
780# CONFIG_MFD_TC6387XB is not set
781
782#
783# Multimedia devices
784#
785
786#
787# Multimedia core support
788#
789# CONFIG_VIDEO_DEV is not set
790# CONFIG_DVB_CORE is not set
791# CONFIG_VIDEO_MEDIA is not set
792
793#
794# Multimedia drivers
795#
796# CONFIG_DAB is not set
797
798#
799# Graphics support
800#
801# CONFIG_VGASTATE is not set
802# CONFIG_VIDEO_OUTPUT_CONTROL is not set
803# CONFIG_FB is not set
804# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
805
806#
807# Display device support
808#
809# CONFIG_DISPLAY_SUPPORT is not set
810
811#
812# Console display driver support
813#
814# CONFIG_VGA_CONSOLE is not set
815CONFIG_DUMMY_CONSOLE=y
816# CONFIG_SOUND is not set
817CONFIG_HID_SUPPORT=y
818CONFIG_HID=y
819# CONFIG_HID_DEBUG is not set
820# CONFIG_HIDRAW is not set
821
822#
823# USB Input Devices
824#
825# CONFIG_USB_HID is not set
826
827#
828# USB HID Boot Protocol drivers
829#
830# CONFIG_USB_KBD is not set
831# CONFIG_USB_MOUSE is not set
832CONFIG_USB_SUPPORT=y
833CONFIG_USB_ARCH_HAS_HCD=y
834CONFIG_USB_ARCH_HAS_OHCI=y
835# CONFIG_USB_ARCH_HAS_EHCI is not set
836CONFIG_USB=y
837# CONFIG_USB_DEBUG is not set
838# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
839
840#
841# Miscellaneous USB options
842#
843CONFIG_USB_DEVICEFS=y
844CONFIG_USB_DEVICE_CLASS=y
845# CONFIG_USB_DYNAMIC_MINORS is not set
846# CONFIG_USB_OTG is not set
847
848#
849# USB Host Controller Drivers
850#
851# CONFIG_USB_C67X00_HCD is not set
852# CONFIG_USB_ISP116X_HCD is not set
853# CONFIG_USB_ISP1760_HCD is not set
854CONFIG_USB_OHCI_HCD=y
855# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
856# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
857CONFIG_USB_OHCI_LITTLE_ENDIAN=y
858# CONFIG_USB_SL811_HCD is not set
859# CONFIG_USB_R8A66597_HCD is not set
860
861#
862# USB Device Class drivers
863#
864# CONFIG_USB_ACM is not set
865# CONFIG_USB_PRINTER is not set
866# CONFIG_USB_WDM is not set
867
868#
869# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
870#
871
872#
873# may also be needed; see USB_STORAGE Help for more information
874#
875CONFIG_USB_STORAGE=y
876# CONFIG_USB_STORAGE_DEBUG is not set
877# CONFIG_USB_STORAGE_DATAFAB is not set
878# CONFIG_USB_STORAGE_FREECOM is not set
879# CONFIG_USB_STORAGE_ISD200 is not set
880# CONFIG_USB_STORAGE_DPCM is not set
881# CONFIG_USB_STORAGE_USBAT is not set
882# CONFIG_USB_STORAGE_SDDR09 is not set
883# CONFIG_USB_STORAGE_SDDR55 is not set
884# CONFIG_USB_STORAGE_JUMPSHOT is not set
885# CONFIG_USB_STORAGE_ALAUDA is not set
886# CONFIG_USB_STORAGE_ONETOUCH is not set
887# CONFIG_USB_STORAGE_KARMA is not set
888# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
889# CONFIG_USB_LIBUSUAL is not set
890
891#
892# USB Imaging devices
893#
894# CONFIG_USB_MDC800 is not set
895# CONFIG_USB_MICROTEK is not set
896CONFIG_USB_MON=y
897
898#
899# USB port drivers
900#
901# CONFIG_USB_SERIAL is not set
902
903#
904# USB Miscellaneous drivers
905#
906# CONFIG_USB_EMI62 is not set
907# CONFIG_USB_EMI26 is not set
908# CONFIG_USB_ADUTUX is not set
909# CONFIG_USB_AUERSWALD is not set
910# CONFIG_USB_RIO500 is not set
911# CONFIG_USB_LEGOTOWER is not set
912# CONFIG_USB_LCD is not set
913# CONFIG_USB_BERRY_CHARGE is not set
914# CONFIG_USB_LED is not set
915# CONFIG_USB_CYPRESS_CY7C63 is not set
916# CONFIG_USB_CYTHERM is not set
917# CONFIG_USB_PHIDGET is not set
918# CONFIG_USB_IDMOUSE is not set
919# CONFIG_USB_FTDI_ELAN is not set
920# CONFIG_USB_APPLEDISPLAY is not set
921# CONFIG_USB_LD is not set
922# CONFIG_USB_TRANCEVIBRATOR is not set
923# CONFIG_USB_IOWARRIOR is not set
924# CONFIG_USB_TEST is not set
925# CONFIG_USB_ISIGHTFW is not set
926CONFIG_USB_GADGET=y
927# CONFIG_USB_GADGET_DEBUG is not set
928# CONFIG_USB_GADGET_DEBUG_FILES is not set
929CONFIG_USB_GADGET_SELECTED=y
930# CONFIG_USB_GADGET_AMD5536UDC is not set
931# CONFIG_USB_GADGET_ATMEL_USBA is not set
932# CONFIG_USB_GADGET_FSL_USB2 is not set
933# CONFIG_USB_GADGET_NET2280 is not set
934# CONFIG_USB_GADGET_PXA25X is not set
935# CONFIG_USB_GADGET_M66592 is not set
936# CONFIG_USB_GADGET_PXA27X is not set
937# CONFIG_USB_GADGET_GOKU is not set
938# CONFIG_USB_GADGET_LH7A40X is not set
939# CONFIG_USB_GADGET_OMAP is not set
940# CONFIG_USB_GADGET_S3C2410 is not set
941CONFIG_USB_GADGET_AT91=y
942CONFIG_USB_AT91=y
943# CONFIG_USB_GADGET_DUMMY_HCD is not set
944# CONFIG_USB_GADGET_DUALSPEED is not set
945CONFIG_USB_ZERO=m
946# CONFIG_USB_ETH is not set
947CONFIG_USB_GADGETFS=m
948CONFIG_USB_FILE_STORAGE=m
949# CONFIG_USB_FILE_STORAGE_TEST is not set
950CONFIG_USB_G_SERIAL=m
951# CONFIG_USB_MIDI_GADGET is not set
952# CONFIG_USB_G_PRINTER is not set
953# CONFIG_USB_CDC_COMPOSITE is not set
954# CONFIG_MMC is not set
955# CONFIG_NEW_LEDS is not set
956CONFIG_RTC_LIB=y
957CONFIG_RTC_CLASS=y
958CONFIG_RTC_HCTOSYS=y
959CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
960CONFIG_RTC_DEBUG=y
961
962#
963# RTC interfaces
964#
965CONFIG_RTC_INTF_SYSFS=y
966CONFIG_RTC_INTF_PROC=y
967CONFIG_RTC_INTF_DEV=y
968# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
969# CONFIG_RTC_DRV_TEST is not set
970
971#
972# I2C RTC drivers
973#
974# CONFIG_RTC_DRV_DS1307 is not set
975# CONFIG_RTC_DRV_DS1374 is not set
976# CONFIG_RTC_DRV_DS1672 is not set
977# CONFIG_RTC_DRV_MAX6900 is not set
978# CONFIG_RTC_DRV_RS5C372 is not set
979# CONFIG_RTC_DRV_ISL1208 is not set
980# CONFIG_RTC_DRV_X1205 is not set
981# CONFIG_RTC_DRV_PCF8563 is not set
982# CONFIG_RTC_DRV_PCF8583 is not set
983# CONFIG_RTC_DRV_M41T80 is not set
984# CONFIG_RTC_DRV_S35390A is not set
985CONFIG_RTC_DRV_FM3130=y
986
987#
988# SPI RTC drivers
989#
990# CONFIG_RTC_DRV_M41T94 is not set
991# CONFIG_RTC_DRV_DS1305 is not set
992# CONFIG_RTC_DRV_MAX6902 is not set
993# CONFIG_RTC_DRV_R9701 is not set
994# CONFIG_RTC_DRV_RS5C348 is not set
995
996#
997# Platform RTC drivers
998#
999# CONFIG_RTC_DRV_CMOS is not set
1000# CONFIG_RTC_DRV_DS1511 is not set
1001# CONFIG_RTC_DRV_DS1553 is not set
1002# CONFIG_RTC_DRV_DS1742 is not set
1003# CONFIG_RTC_DRV_STK17TA8 is not set
1004# CONFIG_RTC_DRV_M48T86 is not set
1005# CONFIG_RTC_DRV_M48T59 is not set
1006# CONFIG_RTC_DRV_V3020 is not set
1007
1008#
1009# on-CPU RTC drivers
1010#
1011# CONFIG_RTC_DRV_AT91SAM9 is not set
1012# CONFIG_DMADEVICES is not set
1013
1014#
1015# Voltage and Current regulators
1016#
1017# CONFIG_REGULATOR is not set
1018# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
1019# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
1020# CONFIG_REGULATOR_BQ24022 is not set
1021# CONFIG_UIO is not set
1022
1023#
1024# File systems
1025#
1026CONFIG_EXT2_FS=y
1027# CONFIG_EXT2_FS_XATTR is not set
1028# CONFIG_EXT2_FS_XIP is not set
1029CONFIG_EXT3_FS=y
1030CONFIG_EXT3_FS_XATTR=y
1031# CONFIG_EXT3_FS_POSIX_ACL is not set
1032# CONFIG_EXT3_FS_SECURITY is not set
1033# CONFIG_EXT4DEV_FS is not set
1034CONFIG_JBD=y
1035CONFIG_FS_MBCACHE=y
1036# CONFIG_REISERFS_FS is not set
1037# CONFIG_JFS_FS is not set
1038# CONFIG_FS_POSIX_ACL is not set
1039# CONFIG_XFS_FS is not set
1040# CONFIG_OCFS2_FS is not set
1041CONFIG_DNOTIFY=y
1042CONFIG_INOTIFY=y
1043CONFIG_INOTIFY_USER=y
1044# CONFIG_QUOTA is not set
1045# CONFIG_AUTOFS_FS is not set
1046# CONFIG_AUTOFS4_FS is not set
1047# CONFIG_FUSE_FS is not set
1048
1049#
1050# CD-ROM/DVD Filesystems
1051#
1052# CONFIG_ISO9660_FS is not set
1053# CONFIG_UDF_FS is not set
1054
1055#
1056# DOS/FAT/NT Filesystems
1057#
1058CONFIG_FAT_FS=y
1059# CONFIG_MSDOS_FS is not set
1060CONFIG_VFAT_FS=y
1061CONFIG_FAT_DEFAULT_CODEPAGE=437
1062CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1063# CONFIG_NTFS_FS is not set
1064
1065#
1066# Pseudo filesystems
1067#
1068CONFIG_PROC_FS=y
1069CONFIG_PROC_SYSCTL=y
1070CONFIG_SYSFS=y
1071CONFIG_TMPFS=y
1072# CONFIG_TMPFS_POSIX_ACL is not set
1073# CONFIG_HUGETLB_PAGE is not set
1074# CONFIG_CONFIGFS_FS is not set
1075
1076#
1077# Miscellaneous filesystems
1078#
1079# CONFIG_ADFS_FS is not set
1080# CONFIG_AFFS_FS is not set
1081# CONFIG_HFS_FS is not set
1082# CONFIG_HFSPLUS_FS is not set
1083# CONFIG_BEFS_FS is not set
1084# CONFIG_BFS_FS is not set
1085# CONFIG_EFS_FS is not set
1086CONFIG_JFFS2_FS=y
1087CONFIG_JFFS2_FS_DEBUG=0
1088CONFIG_JFFS2_FS_WRITEBUFFER=y
1089# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1090# CONFIG_JFFS2_SUMMARY is not set
1091# CONFIG_JFFS2_FS_XATTR is not set
1092# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1093CONFIG_JFFS2_ZLIB=y
1094# CONFIG_JFFS2_LZO is not set
1095CONFIG_JFFS2_RTIME=y
1096# CONFIG_JFFS2_RUBIN is not set
1097CONFIG_CRAMFS=y
1098# CONFIG_VXFS_FS is not set
1099# CONFIG_MINIX_FS is not set
1100# CONFIG_OMFS_FS is not set
1101# CONFIG_HPFS_FS is not set
1102# CONFIG_QNX4FS_FS is not set
1103# CONFIG_ROMFS_FS is not set
1104# CONFIG_SYSV_FS is not set
1105# CONFIG_UFS_FS is not set
1106CONFIG_NETWORK_FILESYSTEMS=y
1107CONFIG_NFS_FS=y
1108CONFIG_NFS_V3=y
1109# CONFIG_NFS_V3_ACL is not set
1110# CONFIG_NFS_V4 is not set
1111CONFIG_ROOT_NFS=y
1112# CONFIG_NFSD is not set
1113CONFIG_LOCKD=y
1114CONFIG_LOCKD_V4=y
1115CONFIG_NFS_COMMON=y
1116CONFIG_SUNRPC=y
1117# CONFIG_RPCSEC_GSS_KRB5 is not set
1118# CONFIG_RPCSEC_GSS_SPKM3 is not set
1119# CONFIG_SMB_FS is not set
1120# CONFIG_CIFS is not set
1121# CONFIG_NCP_FS is not set
1122# CONFIG_CODA_FS is not set
1123# CONFIG_AFS_FS is not set
1124
1125#
1126# Partition Types
1127#
1128# CONFIG_PARTITION_ADVANCED is not set
1129CONFIG_MSDOS_PARTITION=y
1130CONFIG_NLS=y
1131CONFIG_NLS_DEFAULT="iso8859-1"
1132CONFIG_NLS_CODEPAGE_437=y
1133# CONFIG_NLS_CODEPAGE_737 is not set
1134# CONFIG_NLS_CODEPAGE_775 is not set
1135CONFIG_NLS_CODEPAGE_850=y
1136# CONFIG_NLS_CODEPAGE_852 is not set
1137# CONFIG_NLS_CODEPAGE_855 is not set
1138# CONFIG_NLS_CODEPAGE_857 is not set
1139# CONFIG_NLS_CODEPAGE_860 is not set
1140# CONFIG_NLS_CODEPAGE_861 is not set
1141# CONFIG_NLS_CODEPAGE_862 is not set
1142# CONFIG_NLS_CODEPAGE_863 is not set
1143# CONFIG_NLS_CODEPAGE_864 is not set
1144# CONFIG_NLS_CODEPAGE_865 is not set
1145# CONFIG_NLS_CODEPAGE_866 is not set
1146# CONFIG_NLS_CODEPAGE_869 is not set
1147# CONFIG_NLS_CODEPAGE_936 is not set
1148# CONFIG_NLS_CODEPAGE_950 is not set
1149# CONFIG_NLS_CODEPAGE_932 is not set
1150# CONFIG_NLS_CODEPAGE_949 is not set
1151# CONFIG_NLS_CODEPAGE_874 is not set
1152# CONFIG_NLS_ISO8859_8 is not set
1153# CONFIG_NLS_CODEPAGE_1250 is not set
1154# CONFIG_NLS_CODEPAGE_1251 is not set
1155# CONFIG_NLS_ASCII is not set
1156CONFIG_NLS_ISO8859_1=y
1157# CONFIG_NLS_ISO8859_2 is not set
1158# CONFIG_NLS_ISO8859_3 is not set
1159# CONFIG_NLS_ISO8859_4 is not set
1160# CONFIG_NLS_ISO8859_5 is not set
1161# CONFIG_NLS_ISO8859_6 is not set
1162# CONFIG_NLS_ISO8859_7 is not set
1163# CONFIG_NLS_ISO8859_9 is not set
1164# CONFIG_NLS_ISO8859_13 is not set
1165# CONFIG_NLS_ISO8859_14 is not set
1166# CONFIG_NLS_ISO8859_15 is not set
1167# CONFIG_NLS_KOI8_R is not set
1168# CONFIG_NLS_KOI8_U is not set
1169# CONFIG_NLS_UTF8 is not set
1170# CONFIG_DLM is not set
1171
1172#
1173# Kernel hacking
1174#
1175# CONFIG_PRINTK_TIME is not set
1176CONFIG_ENABLE_WARN_DEPRECATED=y
1177CONFIG_ENABLE_MUST_CHECK=y
1178CONFIG_FRAME_WARN=1024
1179# CONFIG_MAGIC_SYSRQ is not set
1180# CONFIG_UNUSED_SYMBOLS is not set
1181# CONFIG_DEBUG_FS is not set
1182# CONFIG_HEADERS_CHECK is not set
1183CONFIG_DEBUG_KERNEL=y
1184# CONFIG_DEBUG_SHIRQ is not set
1185CONFIG_DETECT_SOFTLOCKUP=y
1186# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1187CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1188CONFIG_SCHED_DEBUG=y
1189# CONFIG_SCHEDSTATS is not set
1190# CONFIG_TIMER_STATS is not set
1191# CONFIG_DEBUG_OBJECTS is not set
1192# CONFIG_DEBUG_SLAB is not set
1193CONFIG_DEBUG_PREEMPT=y
1194# CONFIG_DEBUG_RT_MUTEXES is not set
1195# CONFIG_RT_MUTEX_TESTER is not set
1196# CONFIG_DEBUG_SPINLOCK is not set
1197# CONFIG_DEBUG_MUTEXES is not set
1198# CONFIG_DEBUG_LOCK_ALLOC is not set
1199# CONFIG_PROVE_LOCKING is not set
1200# CONFIG_LOCK_STAT is not set
1201# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1202# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1203# CONFIG_DEBUG_KOBJECT is not set
1204CONFIG_DEBUG_BUGVERBOSE=y
1205CONFIG_DEBUG_INFO=y
1206# CONFIG_DEBUG_VM is not set
1207# CONFIG_DEBUG_WRITECOUNT is not set
1208CONFIG_DEBUG_MEMORY_INIT=y
1209# CONFIG_DEBUG_LIST is not set
1210# CONFIG_DEBUG_SG is not set
1211CONFIG_FRAME_POINTER=y
1212# CONFIG_BOOT_PRINTK_DELAY is not set
1213# CONFIG_RCU_TORTURE_TEST is not set
1214# CONFIG_BACKTRACE_SELF_TEST is not set
1215# CONFIG_FAULT_INJECTION is not set
1216# CONFIG_LATENCYTOP is not set
1217CONFIG_HAVE_FTRACE=y
1218CONFIG_HAVE_DYNAMIC_FTRACE=y
1219# CONFIG_FTRACE is not set
1220# CONFIG_IRQSOFF_TRACER is not set
1221# CONFIG_PREEMPT_TRACER is not set
1222# CONFIG_SCHED_TRACER is not set
1223# CONFIG_CONTEXT_SWITCH_TRACER is not set
1224# CONFIG_SAMPLES is not set
1225CONFIG_HAVE_ARCH_KGDB=y
1226# CONFIG_KGDB is not set
1227CONFIG_DEBUG_USER=y
1228# CONFIG_DEBUG_ERRORS is not set
1229# CONFIG_DEBUG_STACK_USAGE is not set
1230CONFIG_DEBUG_LL=y
1231# CONFIG_DEBUG_ICEDCC is not set
1232
1233#
1234# Security options
1235#
1236# CONFIG_KEYS is not set
1237# CONFIG_SECURITY is not set
1238# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1239# CONFIG_CRYPTO is not set
1240
1241#
1242# Library routines
1243#
1244CONFIG_BITREVERSE=y
1245# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1246# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1247# CONFIG_CRC_CCITT is not set
1248# CONFIG_CRC16 is not set
1249CONFIG_CRC_T10DIF=y
1250# CONFIG_CRC_ITU_T is not set
1251CONFIG_CRC32=y
1252# CONFIG_CRC7 is not set
1253# CONFIG_LIBCRC32C is not set
1254CONFIG_ZLIB_INFLATE=y
1255CONFIG_ZLIB_DEFLATE=y
1256CONFIG_PLIST=y
1257CONFIG_HAS_IOMEM=y
1258CONFIG_HAS_IOPORT=y
1259CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/at91sam9rlek_defconfig b/arch/arm/configs/at91sam9rlek_defconfig
index 1c76642272a1..811bebbdc784 100644
--- a/arch/arm/configs/at91sam9rlek_defconfig
+++ b/arch/arm/configs/at91sam9rlek_defconfig
@@ -496,6 +496,7 @@ CONFIG_INPUT_TOUCHSCREEN=y
496# CONFIG_TOUCHSCREEN_PENMOUNT is not set 496# CONFIG_TOUCHSCREEN_PENMOUNT is not set
497# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set 497# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
498# CONFIG_TOUCHSCREEN_TOUCHWIN is not set 498# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
499CONFIG_TOUCHSCREEN_ATMEL_TSADCC=y
499# CONFIG_TOUCHSCREEN_UCB1400 is not set 500# CONFIG_TOUCHSCREEN_UCB1400 is not set
500# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set 501# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
501# CONFIG_INPUT_MISC is not set 502# CONFIG_INPUT_MISC is not set
diff --git a/arch/arm/configs/cm_x300_defconfig b/arch/arm/configs/cm_x300_defconfig
new file mode 100644
index 000000000000..46f1c9dc350c
--- /dev/null
+++ b/arch/arm/configs/cm_x300_defconfig
@@ -0,0 +1,1466 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc3
4# Tue Aug 19 11:26:54 2008
5#
6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y
11CONFIG_MMU=y
12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
16CONFIG_LOCKDEP_SUPPORT=y
17CONFIG_TRACE_IRQFLAGS_SUPPORT=y
18CONFIG_HARDIRQS_SW_RESEND=y
19CONFIG_GENERIC_IRQ_PROBE=y
20CONFIG_RWSEM_GENERIC_SPINLOCK=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_GENERIC_HWEIGHT=y
24CONFIG_GENERIC_CALIBRATE_DELAY=y
25CONFIG_ARCH_SUPPORTS_AOUT=y
26CONFIG_ZONE_DMA=y
27CONFIG_ARCH_MTD_XIP=y
28CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
29CONFIG_VECTORS_BASE=0xffff0000
30CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
31
32#
33# General setup
34#
35CONFIG_EXPERIMENTAL=y
36CONFIG_BROKEN_ON_SMP=y
37CONFIG_INIT_ENV_ARG_LIMIT=32
38CONFIG_LOCALVERSION="-cm-x300"
39# CONFIG_LOCALVERSION_AUTO is not set
40CONFIG_SWAP=y
41CONFIG_SYSVIPC=y
42CONFIG_SYSVIPC_SYSCTL=y
43# CONFIG_POSIX_MQUEUE is not set
44# CONFIG_BSD_PROCESS_ACCT is not set
45# CONFIG_TASKSTATS is not set
46# CONFIG_AUDIT is not set
47CONFIG_IKCONFIG=y
48CONFIG_IKCONFIG_PROC=y
49CONFIG_LOG_BUF_SHIFT=18
50# CONFIG_CGROUPS is not set
51CONFIG_GROUP_SCHED=y
52CONFIG_FAIR_GROUP_SCHED=y
53# CONFIG_RT_GROUP_SCHED is not set
54CONFIG_USER_SCHED=y
55# CONFIG_CGROUP_SCHED is not set
56CONFIG_SYSFS_DEPRECATED=y
57CONFIG_SYSFS_DEPRECATED_V2=y
58# CONFIG_RELAY is not set
59CONFIG_NAMESPACES=y
60# CONFIG_UTS_NS is not set
61# CONFIG_IPC_NS is not set
62# CONFIG_USER_NS is not set
63# CONFIG_PID_NS is not set
64CONFIG_BLK_DEV_INITRD=y
65CONFIG_INITRAMFS_SOURCE=""
66# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
67CONFIG_SYSCTL=y
68# CONFIG_EMBEDDED is not set
69CONFIG_UID16=y
70CONFIG_SYSCTL_SYSCALL=y
71CONFIG_KALLSYMS=y
72# CONFIG_KALLSYMS_ALL is not set
73# CONFIG_KALLSYMS_EXTRA_PASS is not set
74CONFIG_HOTPLUG=y
75CONFIG_PRINTK=y
76CONFIG_BUG=y
77CONFIG_ELF_CORE=y
78CONFIG_COMPAT_BRK=y
79CONFIG_BASE_FULL=y
80CONFIG_FUTEX=y
81CONFIG_ANON_INODES=y
82CONFIG_EPOLL=y
83CONFIG_SIGNALFD=y
84CONFIG_TIMERFD=y
85CONFIG_EVENTFD=y
86CONFIG_SHMEM=y
87CONFIG_VM_EVENT_COUNTERS=y
88CONFIG_SLUB_DEBUG=y
89# CONFIG_SLAB is not set
90CONFIG_SLUB=y
91# CONFIG_SLOB is not set
92# CONFIG_PROFILING is not set
93# CONFIG_MARKERS is not set
94CONFIG_HAVE_OPROFILE=y
95# CONFIG_KPROBES is not set
96# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
97# CONFIG_HAVE_IOREMAP_PROT is not set
98CONFIG_HAVE_KPROBES=y
99CONFIG_HAVE_KRETPROBES=y
100# CONFIG_HAVE_ARCH_TRACEHOOK is not set
101# CONFIG_HAVE_DMA_ATTRS is not set
102# CONFIG_USE_GENERIC_SMP_HELPERS is not set
103CONFIG_HAVE_CLK=y
104CONFIG_PROC_PAGE_MONITOR=y
105CONFIG_HAVE_GENERIC_DMA_COHERENT=y
106CONFIG_SLABINFO=y
107CONFIG_RT_MUTEXES=y
108# CONFIG_TINY_SHMEM is not set
109CONFIG_BASE_SMALL=0
110CONFIG_MODULES=y
111# CONFIG_MODULE_FORCE_LOAD is not set
112CONFIG_MODULE_UNLOAD=y
113# CONFIG_MODULE_FORCE_UNLOAD is not set
114# CONFIG_MODVERSIONS is not set
115# CONFIG_MODULE_SRCVERSION_ALL is not set
116CONFIG_KMOD=y
117CONFIG_BLOCK=y
118# CONFIG_LBD is not set
119# CONFIG_BLK_DEV_IO_TRACE is not set
120# CONFIG_LSF is not set
121# CONFIG_BLK_DEV_BSG is not set
122# CONFIG_BLK_DEV_INTEGRITY is not set
123
124#
125# IO Schedulers
126#
127CONFIG_IOSCHED_NOOP=y
128CONFIG_IOSCHED_AS=y
129CONFIG_IOSCHED_DEADLINE=y
130CONFIG_IOSCHED_CFQ=y
131# CONFIG_DEFAULT_AS is not set
132# CONFIG_DEFAULT_DEADLINE is not set
133CONFIG_DEFAULT_CFQ=y
134# CONFIG_DEFAULT_NOOP is not set
135CONFIG_DEFAULT_IOSCHED="cfq"
136CONFIG_CLASSIC_RCU=y
137
138#
139# System Type
140#
141# CONFIG_ARCH_AAEC2000 is not set
142# CONFIG_ARCH_INTEGRATOR is not set
143# CONFIG_ARCH_REALVIEW is not set
144# CONFIG_ARCH_VERSATILE is not set
145# CONFIG_ARCH_AT91 is not set
146# CONFIG_ARCH_CLPS7500 is not set
147# CONFIG_ARCH_CLPS711X is not set
148# CONFIG_ARCH_EBSA110 is not set
149# CONFIG_ARCH_EP93XX is not set
150# CONFIG_ARCH_FOOTBRIDGE is not set
151# CONFIG_ARCH_NETX is not set
152# CONFIG_ARCH_H720X is not set
153# CONFIG_ARCH_IMX is not set
154# CONFIG_ARCH_IOP13XX is not set
155# CONFIG_ARCH_IOP32X is not set
156# CONFIG_ARCH_IOP33X is not set
157# CONFIG_ARCH_IXP23XX is not set
158# CONFIG_ARCH_IXP2000 is not set
159# CONFIG_ARCH_IXP4XX is not set
160# CONFIG_ARCH_L7200 is not set
161# CONFIG_ARCH_KIRKWOOD is not set
162# CONFIG_ARCH_KS8695 is not set
163# CONFIG_ARCH_NS9XXX is not set
164# CONFIG_ARCH_LOKI is not set
165# CONFIG_ARCH_MV78XX0 is not set
166# CONFIG_ARCH_MXC is not set
167# CONFIG_ARCH_ORION5X is not set
168# CONFIG_ARCH_PNX4008 is not set
169CONFIG_ARCH_PXA=y
170# CONFIG_ARCH_RPC is not set
171# CONFIG_ARCH_SA1100 is not set
172# CONFIG_ARCH_S3C2410 is not set
173# CONFIG_ARCH_SHARK is not set
174# CONFIG_ARCH_LH7A40X is not set
175# CONFIG_ARCH_DAVINCI is not set
176# CONFIG_ARCH_OMAP is not set
177# CONFIG_ARCH_MSM7X00A is not set
178
179#
180# Intel PXA2xx/PXA3xx Implementations
181#
182
183#
184# Supported PXA3xx Processor Variants
185#
186CONFIG_CPU_PXA300=y
187# CONFIG_CPU_PXA310 is not set
188# CONFIG_CPU_PXA320 is not set
189# CONFIG_CPU_PXA930 is not set
190# CONFIG_ARCH_GUMSTIX is not set
191# CONFIG_ARCH_LUBBOCK is not set
192# CONFIG_MACH_LOGICPD_PXA270 is not set
193# CONFIG_MACH_MAINSTONE is not set
194# CONFIG_ARCH_PXA_IDP is not set
195# CONFIG_PXA_SHARPSL is not set
196# CONFIG_ARCH_PXA_ESERIES is not set
197# CONFIG_MACH_TRIZEPS4 is not set
198# CONFIG_MACH_EM_X270 is not set
199# CONFIG_MACH_COLIBRI is not set
200# CONFIG_MACH_ZYLONITE is not set
201# CONFIG_MACH_LITTLETON is not set
202# CONFIG_MACH_TAVOREVB is not set
203# CONFIG_MACH_SAAR is not set
204# CONFIG_MACH_ARMCORE is not set
205CONFIG_MACH_CM_X300=y
206# CONFIG_MACH_MAGICIAN is not set
207# CONFIG_MACH_PCM027 is not set
208# CONFIG_ARCH_PXA_PALM is not set
209# CONFIG_PXA_EZX is not set
210CONFIG_PXA3xx=y
211# CONFIG_PXA_PWM is not set
212
213#
214# Boot options
215#
216
217#
218# Power management
219#
220
221#
222# Processor Type
223#
224CONFIG_CPU_32=y
225CONFIG_CPU_XSC3=y
226CONFIG_CPU_32v5=y
227CONFIG_CPU_ABRT_EV5T=y
228CONFIG_CPU_PABRT_NOIFAR=y
229CONFIG_CPU_CACHE_VIVT=y
230CONFIG_CPU_TLB_V4WBI=y
231CONFIG_CPU_CP15=y
232CONFIG_CPU_CP15_MMU=y
233CONFIG_IO_36=y
234
235#
236# Processor Features
237#
238# CONFIG_ARM_THUMB is not set
239# CONFIG_CPU_DCACHE_DISABLE is not set
240# CONFIG_CPU_BPREDICT_DISABLE is not set
241CONFIG_OUTER_CACHE=y
242CONFIG_CACHE_XSC3L2=y
243CONFIG_IWMMXT=y
244
245#
246# Bus support
247#
248# CONFIG_PCI_SYSCALL is not set
249# CONFIG_ARCH_SUPPORTS_MSI is not set
250# CONFIG_PCCARD is not set
251
252#
253# Kernel Features
254#
255CONFIG_TICK_ONESHOT=y
256CONFIG_NO_HZ=y
257# CONFIG_HIGH_RES_TIMERS is not set
258CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
259# CONFIG_PREEMPT is not set
260CONFIG_HZ=100
261CONFIG_AEABI=y
262CONFIG_OABI_COMPAT=y
263# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
264CONFIG_SELECT_MEMORY_MODEL=y
265CONFIG_FLATMEM_MANUAL=y
266# CONFIG_DISCONTIGMEM_MANUAL is not set
267# CONFIG_SPARSEMEM_MANUAL is not set
268CONFIG_FLATMEM=y
269CONFIG_FLAT_NODE_MEM_MAP=y
270# CONFIG_SPARSEMEM_STATIC is not set
271# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
272CONFIG_PAGEFLAGS_EXTENDED=y
273CONFIG_SPLIT_PTLOCK_CPUS=4096
274# CONFIG_RESOURCES_64BIT is not set
275CONFIG_ZONE_DMA_FLAG=1
276CONFIG_BOUNCE=y
277CONFIG_VIRT_TO_BUS=y
278CONFIG_ALIGNMENT_TRAP=y
279
280#
281# Boot options
282#
283CONFIG_ZBOOT_ROM_TEXT=0x0
284CONFIG_ZBOOT_ROM_BSS=0x0
285CONFIG_CMDLINE="root=/dev/mtdblock5 rootfstype=jffs2 console=ttyS2,38400"
286# CONFIG_XIP_KERNEL is not set
287# CONFIG_KEXEC is not set
288
289#
290# CPU Frequency scaling
291#
292CONFIG_CPU_FREQ=y
293CONFIG_CPU_FREQ_TABLE=y
294# CONFIG_CPU_FREQ_DEBUG is not set
295CONFIG_CPU_FREQ_STAT=y
296# CONFIG_CPU_FREQ_STAT_DETAILS is not set
297CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
298# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
299# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
300# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
301# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
302CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
303# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
304CONFIG_CPU_FREQ_GOV_USERSPACE=y
305# CONFIG_CPU_FREQ_GOV_ONDEMAND is not set
306# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
307
308#
309# Floating point emulation
310#
311
312#
313# At least one emulation must be selected
314#
315CONFIG_FPE_NWFPE=y
316# CONFIG_FPE_NWFPE_XP is not set
317# CONFIG_FPE_FASTFPE is not set
318
319#
320# Userspace binary formats
321#
322CONFIG_BINFMT_ELF=y
323# CONFIG_BINFMT_AOUT is not set
324# CONFIG_BINFMT_MISC is not set
325
326#
327# Power management options
328#
329CONFIG_PM=y
330# CONFIG_PM_DEBUG is not set
331CONFIG_PM_SLEEP=y
332CONFIG_SUSPEND=y
333CONFIG_SUSPEND_FREEZER=y
334CONFIG_APM_EMULATION=y
335CONFIG_ARCH_SUSPEND_POSSIBLE=y
336CONFIG_NET=y
337
338#
339# Networking options
340#
341CONFIG_PACKET=y
342# CONFIG_PACKET_MMAP is not set
343CONFIG_UNIX=y
344# CONFIG_NET_KEY is not set
345CONFIG_INET=y
346# CONFIG_IP_MULTICAST is not set
347# CONFIG_IP_ADVANCED_ROUTER is not set
348CONFIG_IP_FIB_HASH=y
349CONFIG_IP_PNP=y
350CONFIG_IP_PNP_DHCP=y
351CONFIG_IP_PNP_BOOTP=y
352CONFIG_IP_PNP_RARP=y
353# CONFIG_NET_IPIP is not set
354# CONFIG_NET_IPGRE is not set
355# CONFIG_ARPD is not set
356# CONFIG_SYN_COOKIES is not set
357# CONFIG_INET_AH is not set
358# CONFIG_INET_ESP is not set
359# CONFIG_INET_IPCOMP is not set
360# CONFIG_INET_XFRM_TUNNEL is not set
361# CONFIG_INET_TUNNEL is not set
362# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
363# CONFIG_INET_XFRM_MODE_TUNNEL is not set
364# CONFIG_INET_XFRM_MODE_BEET is not set
365# CONFIG_INET_LRO is not set
366# CONFIG_INET_DIAG is not set
367# CONFIG_TCP_CONG_ADVANCED is not set
368CONFIG_TCP_CONG_CUBIC=y
369CONFIG_DEFAULT_TCP_CONG="cubic"
370# CONFIG_TCP_MD5SIG is not set
371# CONFIG_IPV6 is not set
372# CONFIG_NETWORK_SECMARK is not set
373# CONFIG_NETFILTER is not set
374# CONFIG_IP_DCCP is not set
375# CONFIG_IP_SCTP is not set
376# CONFIG_TIPC is not set
377# CONFIG_ATM is not set
378# CONFIG_BRIDGE is not set
379# CONFIG_VLAN_8021Q is not set
380# CONFIG_DECNET is not set
381# CONFIG_LLC2 is not set
382# CONFIG_IPX is not set
383# CONFIG_ATALK is not set
384# CONFIG_X25 is not set
385# CONFIG_LAPB is not set
386# CONFIG_ECONET is not set
387# CONFIG_WAN_ROUTER is not set
388# CONFIG_NET_SCHED is not set
389
390#
391# Network testing
392#
393# CONFIG_NET_PKTGEN is not set
394# CONFIG_HAMRADIO is not set
395# CONFIG_CAN is not set
396# CONFIG_IRDA is not set
397CONFIG_BT=m
398CONFIG_BT_L2CAP=m
399CONFIG_BT_SCO=m
400CONFIG_BT_RFCOMM=m
401CONFIG_BT_RFCOMM_TTY=y
402CONFIG_BT_BNEP=m
403CONFIG_BT_BNEP_MC_FILTER=y
404CONFIG_BT_BNEP_PROTO_FILTER=y
405CONFIG_BT_HIDP=m
406
407#
408# Bluetooth device drivers
409#
410CONFIG_BT_HCIUSB=m
411CONFIG_BT_HCIUSB_SCO=y
412# CONFIG_BT_HCIBTSDIO is not set
413# CONFIG_BT_HCIUART is not set
414# CONFIG_BT_HCIBCM203X is not set
415# CONFIG_BT_HCIBPA10X is not set
416# CONFIG_BT_HCIBFUSB is not set
417# CONFIG_BT_HCIVHCI is not set
418# CONFIG_AF_RXRPC is not set
419
420#
421# Wireless
422#
423# CONFIG_CFG80211 is not set
424CONFIG_WIRELESS_EXT=y
425CONFIG_WIRELESS_EXT_SYSFS=y
426# CONFIG_MAC80211 is not set
427CONFIG_IEEE80211=m
428# CONFIG_IEEE80211_DEBUG is not set
429CONFIG_IEEE80211_CRYPT_WEP=m
430CONFIG_IEEE80211_CRYPT_CCMP=m
431CONFIG_IEEE80211_CRYPT_TKIP=m
432# CONFIG_RFKILL is not set
433# CONFIG_NET_9P is not set
434
435#
436# Device Drivers
437#
438
439#
440# Generic Driver Options
441#
442CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
443CONFIG_STANDALONE=y
444CONFIG_PREVENT_FIRMWARE_BUILD=y
445CONFIG_FW_LOADER=y
446CONFIG_FIRMWARE_IN_KERNEL=y
447CONFIG_EXTRA_FIRMWARE=""
448# CONFIG_DEBUG_DRIVER is not set
449# CONFIG_DEBUG_DEVRES is not set
450# CONFIG_SYS_HYPERVISOR is not set
451# CONFIG_CONNECTOR is not set
452CONFIG_MTD=y
453# CONFIG_MTD_DEBUG is not set
454# CONFIG_MTD_CONCAT is not set
455CONFIG_MTD_PARTITIONS=y
456# CONFIG_MTD_REDBOOT_PARTS is not set
457# CONFIG_MTD_CMDLINE_PARTS is not set
458# CONFIG_MTD_AFS_PARTS is not set
459# CONFIG_MTD_AR7_PARTS is not set
460
461#
462# User Modules And Translation Layers
463#
464CONFIG_MTD_CHAR=y
465CONFIG_MTD_BLKDEVS=y
466CONFIG_MTD_BLOCK=y
467# CONFIG_FTL is not set
468# CONFIG_NFTL is not set
469# CONFIG_INFTL is not set
470# CONFIG_RFD_FTL is not set
471# CONFIG_SSFDC is not set
472# CONFIG_MTD_OOPS is not set
473
474#
475# RAM/ROM/Flash chip drivers
476#
477# CONFIG_MTD_CFI is not set
478# CONFIG_MTD_JEDECPROBE is not set
479CONFIG_MTD_MAP_BANK_WIDTH_1=y
480CONFIG_MTD_MAP_BANK_WIDTH_2=y
481CONFIG_MTD_MAP_BANK_WIDTH_4=y
482# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
483# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
484# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
485CONFIG_MTD_CFI_I1=y
486CONFIG_MTD_CFI_I2=y
487# CONFIG_MTD_CFI_I4 is not set
488# CONFIG_MTD_CFI_I8 is not set
489# CONFIG_MTD_RAM is not set
490# CONFIG_MTD_ROM is not set
491# CONFIG_MTD_ABSENT is not set
492
493#
494# Mapping drivers for chip access
495#
496# CONFIG_MTD_COMPLEX_MAPPINGS is not set
497# CONFIG_MTD_SHARP_SL is not set
498# CONFIG_MTD_PLATRAM is not set
499
500#
501# Self-contained MTD device drivers
502#
503# CONFIG_MTD_SLRAM is not set
504# CONFIG_MTD_PHRAM is not set
505# CONFIG_MTD_MTDRAM is not set
506# CONFIG_MTD_BLOCK2MTD is not set
507
508#
509# Disk-On-Chip Device Drivers
510#
511# CONFIG_MTD_DOC2000 is not set
512# CONFIG_MTD_DOC2001 is not set
513# CONFIG_MTD_DOC2001PLUS is not set
514CONFIG_MTD_NAND=y
515# CONFIG_MTD_NAND_VERIFY_WRITE is not set
516# CONFIG_MTD_NAND_ECC_SMC is not set
517# CONFIG_MTD_NAND_MUSEUM_IDS is not set
518# CONFIG_MTD_NAND_H1900 is not set
519CONFIG_MTD_NAND_IDS=y
520# CONFIG_MTD_NAND_DISKONCHIP is not set
521# CONFIG_MTD_NAND_SHARPSL is not set
522CONFIG_MTD_NAND_PXA3xx=y
523# CONFIG_MTD_NAND_NANDSIM is not set
524# CONFIG_MTD_NAND_PLATFORM is not set
525# CONFIG_MTD_ALAUDA is not set
526# CONFIG_MTD_ONENAND is not set
527
528#
529# UBI - Unsorted block images
530#
531# CONFIG_MTD_UBI is not set
532# CONFIG_PARPORT is not set
533CONFIG_BLK_DEV=y
534# CONFIG_BLK_DEV_COW_COMMON is not set
535CONFIG_BLK_DEV_LOOP=y
536# CONFIG_BLK_DEV_CRYPTOLOOP is not set
537# CONFIG_BLK_DEV_NBD is not set
538# CONFIG_BLK_DEV_UB is not set
539CONFIG_BLK_DEV_RAM=y
540CONFIG_BLK_DEV_RAM_COUNT=16
541CONFIG_BLK_DEV_RAM_SIZE=4096
542# CONFIG_BLK_DEV_XIP is not set
543# CONFIG_CDROM_PKTCDVD is not set
544# CONFIG_ATA_OVER_ETH is not set
545# CONFIG_MISC_DEVICES is not set
546CONFIG_HAVE_IDE=y
547# CONFIG_IDE is not set
548
549#
550# SCSI device support
551#
552# CONFIG_RAID_ATTRS is not set
553CONFIG_SCSI=y
554CONFIG_SCSI_DMA=y
555# CONFIG_SCSI_TGT is not set
556# CONFIG_SCSI_NETLINK is not set
557CONFIG_SCSI_PROC_FS=y
558
559#
560# SCSI support type (disk, tape, CD-ROM)
561#
562CONFIG_BLK_DEV_SD=y
563# CONFIG_CHR_DEV_ST is not set
564# CONFIG_CHR_DEV_OSST is not set
565# CONFIG_BLK_DEV_SR is not set
566# CONFIG_CHR_DEV_SG is not set
567# CONFIG_CHR_DEV_SCH is not set
568
569#
570# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
571#
572# CONFIG_SCSI_MULTI_LUN is not set
573# CONFIG_SCSI_CONSTANTS is not set
574# CONFIG_SCSI_LOGGING is not set
575# CONFIG_SCSI_SCAN_ASYNC is not set
576CONFIG_SCSI_WAIT_SCAN=m
577
578#
579# SCSI Transports
580#
581# CONFIG_SCSI_SPI_ATTRS is not set
582# CONFIG_SCSI_FC_ATTRS is not set
583# CONFIG_SCSI_ISCSI_ATTRS is not set
584# CONFIG_SCSI_SAS_LIBSAS is not set
585# CONFIG_SCSI_SRP_ATTRS is not set
586CONFIG_SCSI_LOWLEVEL=y
587# CONFIG_ISCSI_TCP is not set
588# CONFIG_SCSI_DEBUG is not set
589# CONFIG_SCSI_DH is not set
590# CONFIG_ATA is not set
591# CONFIG_MD is not set
592CONFIG_NETDEVICES=y
593# CONFIG_DUMMY is not set
594# CONFIG_BONDING is not set
595# CONFIG_MACVLAN is not set
596# CONFIG_EQUALIZER is not set
597# CONFIG_TUN is not set
598# CONFIG_VETH is not set
599# CONFIG_PHYLIB is not set
600CONFIG_NET_ETHERNET=y
601CONFIG_MII=y
602# CONFIG_AX88796 is not set
603# CONFIG_SMC91X is not set
604CONFIG_DM9000=y
605CONFIG_DM9000_DEBUGLEVEL=0
606CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL=y
607# CONFIG_SMC911X is not set
608# CONFIG_IBM_NEW_EMAC_ZMII is not set
609# CONFIG_IBM_NEW_EMAC_RGMII is not set
610# CONFIG_IBM_NEW_EMAC_TAH is not set
611# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
612# CONFIG_B44 is not set
613# CONFIG_NETDEV_1000 is not set
614# CONFIG_NETDEV_10000 is not set
615
616#
617# Wireless LAN
618#
619# CONFIG_WLAN_PRE80211 is not set
620CONFIG_WLAN_80211=y
621CONFIG_LIBERTAS=m
622# CONFIG_LIBERTAS_USB is not set
623CONFIG_LIBERTAS_SDIO=m
624# CONFIG_LIBERTAS_DEBUG is not set
625# CONFIG_USB_ZD1201 is not set
626# CONFIG_USB_NET_RNDIS_WLAN is not set
627# CONFIG_IWLWIFI_LEDS is not set
628# CONFIG_HOSTAP is not set
629
630#
631# USB Network Adapters
632#
633# CONFIG_USB_CATC is not set
634# CONFIG_USB_KAWETH is not set
635# CONFIG_USB_PEGASUS is not set
636# CONFIG_USB_RTL8150 is not set
637# CONFIG_USB_USBNET is not set
638# CONFIG_WAN is not set
639# CONFIG_PPP is not set
640# CONFIG_SLIP is not set
641# CONFIG_NETCONSOLE is not set
642# CONFIG_NETPOLL is not set
643# CONFIG_NET_POLL_CONTROLLER is not set
644# CONFIG_ISDN is not set
645
646#
647# Input device support
648#
649CONFIG_INPUT=y
650# CONFIG_INPUT_FF_MEMLESS is not set
651# CONFIG_INPUT_POLLDEV is not set
652
653#
654# Userland interfaces
655#
656CONFIG_INPUT_MOUSEDEV=y
657# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
658CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
659CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
660# CONFIG_INPUT_JOYDEV is not set
661CONFIG_INPUT_EVDEV=y
662# CONFIG_INPUT_EVBUG is not set
663
664#
665# Input Device Drivers
666#
667CONFIG_INPUT_KEYBOARD=y
668# CONFIG_KEYBOARD_ATKBD is not set
669# CONFIG_KEYBOARD_SUNKBD is not set
670# CONFIG_KEYBOARD_LKKBD is not set
671# CONFIG_KEYBOARD_XTKBD is not set
672# CONFIG_KEYBOARD_NEWTON is not set
673# CONFIG_KEYBOARD_STOWAWAY is not set
674CONFIG_KEYBOARD_PXA27x=m
675# CONFIG_KEYBOARD_GPIO is not set
676# CONFIG_INPUT_MOUSE is not set
677# CONFIG_INPUT_JOYSTICK is not set
678# CONFIG_INPUT_TABLET is not set
679CONFIG_INPUT_TOUCHSCREEN=y
680# CONFIG_TOUCHSCREEN_FUJITSU is not set
681# CONFIG_TOUCHSCREEN_GUNZE is not set
682# CONFIG_TOUCHSCREEN_ELO is not set
683# CONFIG_TOUCHSCREEN_MTOUCH is not set
684# CONFIG_TOUCHSCREEN_INEXIO is not set
685# CONFIG_TOUCHSCREEN_MK712 is not set
686# CONFIG_TOUCHSCREEN_PENMOUNT is not set
687# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
688# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
689# CONFIG_TOUCHSCREEN_UCB1400 is not set
690# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
691# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
692# CONFIG_INPUT_MISC is not set
693
694#
695# Hardware I/O ports
696#
697# CONFIG_SERIO is not set
698# CONFIG_GAMEPORT is not set
699
700#
701# Character devices
702#
703CONFIG_VT=y
704CONFIG_CONSOLE_TRANSLATIONS=y
705CONFIG_VT_CONSOLE=y
706CONFIG_HW_CONSOLE=y
707# CONFIG_VT_HW_CONSOLE_BINDING is not set
708CONFIG_DEVKMEM=y
709# CONFIG_SERIAL_NONSTANDARD is not set
710
711#
712# Serial drivers
713#
714# CONFIG_SERIAL_8250 is not set
715
716#
717# Non-8250 serial port support
718#
719CONFIG_SERIAL_PXA=y
720CONFIG_SERIAL_PXA_CONSOLE=y
721CONFIG_SERIAL_CORE=y
722CONFIG_SERIAL_CORE_CONSOLE=y
723CONFIG_UNIX98_PTYS=y
724# CONFIG_LEGACY_PTYS is not set
725# CONFIG_IPMI_HANDLER is not set
726# CONFIG_HW_RANDOM is not set
727# CONFIG_NVRAM is not set
728# CONFIG_R3964 is not set
729# CONFIG_RAW_DRIVER is not set
730# CONFIG_TCG_TPM is not set
731CONFIG_I2C=y
732CONFIG_I2C_BOARDINFO=y
733# CONFIG_I2C_CHARDEV is not set
734CONFIG_I2C_HELPER_AUTO=y
735
736#
737# I2C Hardware Bus support
738#
739
740#
741# I2C system bus drivers (mostly embedded / system-on-chip)
742#
743# CONFIG_I2C_GPIO is not set
744# CONFIG_I2C_OCORES is not set
745CONFIG_I2C_PXA=y
746# CONFIG_I2C_PXA_SLAVE is not set
747# CONFIG_I2C_SIMTEC is not set
748
749#
750# External I2C/SMBus adapter drivers
751#
752# CONFIG_I2C_PARPORT_LIGHT is not set
753# CONFIG_I2C_TAOS_EVM is not set
754# CONFIG_I2C_TINY_USB is not set
755
756#
757# Other I2C/SMBus bus drivers
758#
759# CONFIG_I2C_PCA_PLATFORM is not set
760# CONFIG_I2C_STUB is not set
761
762#
763# Miscellaneous I2C Chip support
764#
765# CONFIG_DS1682 is not set
766# CONFIG_AT24 is not set
767# CONFIG_SENSORS_EEPROM is not set
768# CONFIG_SENSORS_PCF8574 is not set
769# CONFIG_PCF8575 is not set
770# CONFIG_SENSORS_PCF8591 is not set
771# CONFIG_TPS65010 is not set
772# CONFIG_SENSORS_MAX6875 is not set
773# CONFIG_SENSORS_TSL2550 is not set
774# CONFIG_I2C_DEBUG_CORE is not set
775# CONFIG_I2C_DEBUG_ALGO is not set
776# CONFIG_I2C_DEBUG_BUS is not set
777# CONFIG_I2C_DEBUG_CHIP is not set
778# CONFIG_SPI is not set
779CONFIG_ARCH_REQUIRE_GPIOLIB=y
780CONFIG_GPIOLIB=y
781# CONFIG_DEBUG_GPIO is not set
782# CONFIG_GPIO_SYSFS is not set
783
784#
785# I2C GPIO expanders:
786#
787# CONFIG_GPIO_MAX732X is not set
788CONFIG_GPIO_PCA953X=y
789# CONFIG_GPIO_PCF857X is not set
790
791#
792# PCI GPIO expanders:
793#
794
795#
796# SPI GPIO expanders:
797#
798# CONFIG_W1 is not set
799# CONFIG_POWER_SUPPLY is not set
800# CONFIG_HWMON is not set
801# CONFIG_WATCHDOG is not set
802
803#
804# Sonics Silicon Backplane
805#
806CONFIG_SSB_POSSIBLE=y
807# CONFIG_SSB is not set
808
809#
810# Multifunction device drivers
811#
812# CONFIG_MFD_CORE is not set
813# CONFIG_MFD_SM501 is not set
814# CONFIG_HTC_EGPIO is not set
815# CONFIG_HTC_PASIC3 is not set
816# CONFIG_MFD_TMIO is not set
817# CONFIG_MFD_T7L66XB is not set
818# CONFIG_MFD_TC6387XB is not set
819# CONFIG_MFD_TC6393XB is not set
820
821#
822# Multimedia devices
823#
824
825#
826# Multimedia core support
827#
828# CONFIG_VIDEO_DEV is not set
829# CONFIG_DVB_CORE is not set
830# CONFIG_VIDEO_MEDIA is not set
831
832#
833# Multimedia drivers
834#
835# CONFIG_DAB is not set
836
837#
838# Graphics support
839#
840# CONFIG_VGASTATE is not set
841# CONFIG_VIDEO_OUTPUT_CONTROL is not set
842CONFIG_FB=y
843# CONFIG_FIRMWARE_EDID is not set
844# CONFIG_FB_DDC is not set
845CONFIG_FB_CFB_FILLRECT=y
846CONFIG_FB_CFB_COPYAREA=y
847CONFIG_FB_CFB_IMAGEBLIT=y
848# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
849# CONFIG_FB_SYS_FILLRECT is not set
850# CONFIG_FB_SYS_COPYAREA is not set
851# CONFIG_FB_SYS_IMAGEBLIT is not set
852# CONFIG_FB_FOREIGN_ENDIAN is not set
853# CONFIG_FB_SYS_FOPS is not set
854# CONFIG_FB_SVGALIB is not set
855# CONFIG_FB_MACMODES is not set
856# CONFIG_FB_BACKLIGHT is not set
857# CONFIG_FB_MODE_HELPERS is not set
858# CONFIG_FB_TILEBLITTING is not set
859
860#
861# Frame buffer hardware drivers
862#
863# CONFIG_FB_S1D13XXX is not set
864CONFIG_FB_PXA=y
865# CONFIG_FB_PXA_SMARTPANEL is not set
866# CONFIG_FB_PXA_PARAMETERS is not set
867# CONFIG_FB_MBX is not set
868# CONFIG_FB_W100 is not set
869# CONFIG_FB_AM200EPD is not set
870# CONFIG_FB_VIRTUAL is not set
871# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
872
873#
874# Display device support
875#
876# CONFIG_DISPLAY_SUPPORT is not set
877
878#
879# Console display driver support
880#
881# CONFIG_VGA_CONSOLE is not set
882CONFIG_DUMMY_CONSOLE=y
883CONFIG_FRAMEBUFFER_CONSOLE=y
884CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
885# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
886CONFIG_FONTS=y
887# CONFIG_FONT_8x8 is not set
888# CONFIG_FONT_8x16 is not set
889CONFIG_FONT_6x11=y
890# CONFIG_FONT_7x14 is not set
891# CONFIG_FONT_PEARL_8x8 is not set
892# CONFIG_FONT_ACORN_8x8 is not set
893# CONFIG_FONT_MINI_4x6 is not set
894# CONFIG_FONT_SUN8x16 is not set
895# CONFIG_FONT_SUN12x22 is not set
896# CONFIG_FONT_10x18 is not set
897CONFIG_LOGO=y
898CONFIG_LOGO_LINUX_MONO=y
899CONFIG_LOGO_LINUX_VGA16=y
900CONFIG_LOGO_LINUX_CLUT224=y
901CONFIG_SOUND=m
902CONFIG_SND=m
903CONFIG_SND_TIMER=m
904CONFIG_SND_PCM=m
905# CONFIG_SND_SEQUENCER is not set
906# CONFIG_SND_MIXER_OSS is not set
907# CONFIG_SND_PCM_OSS is not set
908# CONFIG_SND_DYNAMIC_MINORS is not set
909CONFIG_SND_SUPPORT_OLD_API=y
910CONFIG_SND_VERBOSE_PROCFS=y
911# CONFIG_SND_VERBOSE_PRINTK is not set
912# CONFIG_SND_DEBUG is not set
913CONFIG_SND_DRIVERS=y
914# CONFIG_SND_DUMMY is not set
915# CONFIG_SND_MTPAV is not set
916# CONFIG_SND_SERIAL_U16550 is not set
917# CONFIG_SND_MPU401 is not set
918CONFIG_SND_ARM=y
919# CONFIG_SND_PXA2XX_AC97 is not set
920CONFIG_SND_USB=y
921# CONFIG_SND_USB_AUDIO is not set
922# CONFIG_SND_USB_CAIAQ is not set
923CONFIG_SND_SOC=m
924CONFIG_SND_PXA2XX_SOC=m
925# CONFIG_SOUND_PRIME is not set
926CONFIG_HID_SUPPORT=y
927CONFIG_HID=y
928CONFIG_HID_DEBUG=y
929# CONFIG_HIDRAW is not set
930
931#
932# USB Input Devices
933#
934CONFIG_USB_HID=y
935# CONFIG_USB_HIDINPUT_POWERBOOK is not set
936# CONFIG_HID_FF is not set
937# CONFIG_USB_HIDDEV is not set
938CONFIG_USB_SUPPORT=y
939CONFIG_USB_ARCH_HAS_HCD=y
940CONFIG_USB_ARCH_HAS_OHCI=y
941# CONFIG_USB_ARCH_HAS_EHCI is not set
942CONFIG_USB=y
943# CONFIG_USB_DEBUG is not set
944# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
945
946#
947# Miscellaneous USB options
948#
949CONFIG_USB_DEVICEFS=y
950# CONFIG_USB_DEVICE_CLASS is not set
951# CONFIG_USB_DYNAMIC_MINORS is not set
952# CONFIG_USB_SUSPEND is not set
953# CONFIG_USB_OTG is not set
954CONFIG_USB_MON=y
955
956#
957# USB Host Controller Drivers
958#
959# CONFIG_USB_C67X00_HCD is not set
960# CONFIG_USB_ISP116X_HCD is not set
961# CONFIG_USB_ISP1760_HCD is not set
962CONFIG_USB_OHCI_HCD=y
963# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
964# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
965CONFIG_USB_OHCI_LITTLE_ENDIAN=y
966# CONFIG_USB_SL811_HCD is not set
967# CONFIG_USB_R8A66597_HCD is not set
968# CONFIG_USB_MUSB_HDRC is not set
969
970#
971# USB Device Class drivers
972#
973# CONFIG_USB_ACM is not set
974# CONFIG_USB_PRINTER is not set
975# CONFIG_USB_WDM is not set
976
977#
978# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
979#
980
981#
982# may also be needed; see USB_STORAGE Help for more information
983#
984CONFIG_USB_STORAGE=y
985# CONFIG_USB_STORAGE_DEBUG is not set
986# CONFIG_USB_STORAGE_DATAFAB is not set
987# CONFIG_USB_STORAGE_FREECOM is not set
988# CONFIG_USB_STORAGE_ISD200 is not set
989# CONFIG_USB_STORAGE_DPCM is not set
990# CONFIG_USB_STORAGE_USBAT is not set
991# CONFIG_USB_STORAGE_SDDR09 is not set
992# CONFIG_USB_STORAGE_SDDR55 is not set
993# CONFIG_USB_STORAGE_JUMPSHOT is not set
994# CONFIG_USB_STORAGE_ALAUDA is not set
995# CONFIG_USB_STORAGE_ONETOUCH is not set
996# CONFIG_USB_STORAGE_KARMA is not set
997# CONFIG_USB_STORAGE_SIERRA is not set
998# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
999# CONFIG_USB_LIBUSUAL is not set
1000
1001#
1002# USB Imaging devices
1003#
1004# CONFIG_USB_MDC800 is not set
1005# CONFIG_USB_MICROTEK is not set
1006
1007#
1008# USB port drivers
1009#
1010# CONFIG_USB_SERIAL is not set
1011
1012#
1013# USB Miscellaneous drivers
1014#
1015# CONFIG_USB_EMI62 is not set
1016# CONFIG_USB_EMI26 is not set
1017# CONFIG_USB_ADUTUX is not set
1018# CONFIG_USB_RIO500 is not set
1019# CONFIG_USB_LEGOTOWER is not set
1020# CONFIG_USB_LCD is not set
1021# CONFIG_USB_BERRY_CHARGE is not set
1022# CONFIG_USB_LED is not set
1023# CONFIG_USB_CYPRESS_CY7C63 is not set
1024# CONFIG_USB_CYTHERM is not set
1025# CONFIG_USB_PHIDGET is not set
1026# CONFIG_USB_IDMOUSE is not set
1027# CONFIG_USB_FTDI_ELAN is not set
1028# CONFIG_USB_APPLEDISPLAY is not set
1029# CONFIG_USB_LD is not set
1030# CONFIG_USB_TRANCEVIBRATOR is not set
1031# CONFIG_USB_IOWARRIOR is not set
1032# CONFIG_USB_TEST is not set
1033# CONFIG_USB_ISIGHTFW is not set
1034# CONFIG_USB_GADGET is not set
1035CONFIG_MMC=m
1036# CONFIG_MMC_DEBUG is not set
1037# CONFIG_MMC_UNSAFE_RESUME is not set
1038
1039#
1040# MMC/SD Card Drivers
1041#
1042CONFIG_MMC_BLOCK=m
1043CONFIG_MMC_BLOCK_BOUNCE=y
1044# CONFIG_SDIO_UART is not set
1045# CONFIG_MMC_TEST is not set
1046
1047#
1048# MMC/SD Host Controller Drivers
1049#
1050CONFIG_MMC_PXA=m
1051# CONFIG_MMC_SDHCI is not set
1052CONFIG_NEW_LEDS=y
1053CONFIG_LEDS_CLASS=y
1054
1055#
1056# LED drivers
1057#
1058# CONFIG_LEDS_PCA9532 is not set
1059CONFIG_LEDS_GPIO=y
1060# CONFIG_LEDS_PCA955X is not set
1061
1062#
1063# LED Triggers
1064#
1065CONFIG_LEDS_TRIGGERS=y
1066# CONFIG_LEDS_TRIGGER_TIMER is not set
1067CONFIG_LEDS_TRIGGER_HEARTBEAT=y
1068# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
1069CONFIG_RTC_LIB=y
1070CONFIG_RTC_CLASS=y
1071CONFIG_RTC_HCTOSYS=y
1072CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1073# CONFIG_RTC_DEBUG is not set
1074
1075#
1076# RTC interfaces
1077#
1078CONFIG_RTC_INTF_SYSFS=y
1079CONFIG_RTC_INTF_PROC=y
1080CONFIG_RTC_INTF_DEV=y
1081# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1082# CONFIG_RTC_DRV_TEST is not set
1083
1084#
1085# I2C RTC drivers
1086#
1087# CONFIG_RTC_DRV_DS1307 is not set
1088# CONFIG_RTC_DRV_DS1374 is not set
1089# CONFIG_RTC_DRV_DS1672 is not set
1090# CONFIG_RTC_DRV_MAX6900 is not set
1091# CONFIG_RTC_DRV_RS5C372 is not set
1092# CONFIG_RTC_DRV_ISL1208 is not set
1093# CONFIG_RTC_DRV_X1205 is not set
1094# CONFIG_RTC_DRV_PCF8563 is not set
1095# CONFIG_RTC_DRV_PCF8583 is not set
1096# CONFIG_RTC_DRV_M41T80 is not set
1097# CONFIG_RTC_DRV_S35390A is not set
1098# CONFIG_RTC_DRV_FM3130 is not set
1099
1100#
1101# SPI RTC drivers
1102#
1103
1104#
1105# Platform RTC drivers
1106#
1107# CONFIG_RTC_DRV_CMOS is not set
1108# CONFIG_RTC_DRV_DS1511 is not set
1109# CONFIG_RTC_DRV_DS1553 is not set
1110# CONFIG_RTC_DRV_DS1742 is not set
1111# CONFIG_RTC_DRV_STK17TA8 is not set
1112# CONFIG_RTC_DRV_M48T86 is not set
1113# CONFIG_RTC_DRV_M48T59 is not set
1114# CONFIG_RTC_DRV_V3020 is not set
1115
1116#
1117# on-CPU RTC drivers
1118#
1119CONFIG_RTC_DRV_SA1100=y
1120# CONFIG_DMADEVICES is not set
1121
1122#
1123# Voltage and Current regulators
1124#
1125# CONFIG_REGULATOR is not set
1126# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
1127# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
1128# CONFIG_REGULATOR_BQ24022 is not set
1129# CONFIG_UIO is not set
1130
1131#
1132# File systems
1133#
1134CONFIG_EXT2_FS=y
1135# CONFIG_EXT2_FS_XATTR is not set
1136# CONFIG_EXT2_FS_XIP is not set
1137CONFIG_EXT3_FS=y
1138# CONFIG_EXT3_FS_XATTR is not set
1139# CONFIG_EXT4DEV_FS is not set
1140CONFIG_JBD=y
1141# CONFIG_JBD_DEBUG is not set
1142# CONFIG_REISERFS_FS is not set
1143# CONFIG_JFS_FS is not set
1144CONFIG_FS_POSIX_ACL=y
1145# CONFIG_XFS_FS is not set
1146# CONFIG_OCFS2_FS is not set
1147CONFIG_DNOTIFY=y
1148CONFIG_INOTIFY=y
1149CONFIG_INOTIFY_USER=y
1150# CONFIG_QUOTA is not set
1151# CONFIG_AUTOFS_FS is not set
1152# CONFIG_AUTOFS4_FS is not set
1153# CONFIG_FUSE_FS is not set
1154
1155#
1156# CD-ROM/DVD Filesystems
1157#
1158# CONFIG_ISO9660_FS is not set
1159# CONFIG_UDF_FS is not set
1160
1161#
1162# DOS/FAT/NT Filesystems
1163#
1164CONFIG_FAT_FS=m
1165CONFIG_MSDOS_FS=m
1166CONFIG_VFAT_FS=m
1167CONFIG_FAT_DEFAULT_CODEPAGE=437
1168CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1169# CONFIG_NTFS_FS is not set
1170
1171#
1172# Pseudo filesystems
1173#
1174CONFIG_PROC_FS=y
1175CONFIG_PROC_SYSCTL=y
1176CONFIG_SYSFS=y
1177CONFIG_TMPFS=y
1178# CONFIG_TMPFS_POSIX_ACL is not set
1179# CONFIG_HUGETLB_PAGE is not set
1180# CONFIG_CONFIGFS_FS is not set
1181
1182#
1183# Miscellaneous filesystems
1184#
1185# CONFIG_ADFS_FS is not set
1186# CONFIG_AFFS_FS is not set
1187# CONFIG_HFS_FS is not set
1188# CONFIG_HFSPLUS_FS is not set
1189# CONFIG_BEFS_FS is not set
1190# CONFIG_BFS_FS is not set
1191# CONFIG_EFS_FS is not set
1192CONFIG_JFFS2_FS=y
1193CONFIG_JFFS2_FS_DEBUG=0
1194CONFIG_JFFS2_FS_WRITEBUFFER=y
1195# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1196CONFIG_JFFS2_SUMMARY=y
1197# CONFIG_JFFS2_FS_XATTR is not set
1198# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1199CONFIG_JFFS2_ZLIB=y
1200# CONFIG_JFFS2_LZO is not set
1201CONFIG_JFFS2_RTIME=y
1202# CONFIG_JFFS2_RUBIN is not set
1203# CONFIG_CRAMFS is not set
1204# CONFIG_VXFS_FS is not set
1205# CONFIG_MINIX_FS is not set
1206# CONFIG_OMFS_FS is not set
1207# CONFIG_HPFS_FS is not set
1208# CONFIG_QNX4FS_FS is not set
1209# CONFIG_ROMFS_FS is not set
1210# CONFIG_SYSV_FS is not set
1211# CONFIG_UFS_FS is not set
1212CONFIG_NETWORK_FILESYSTEMS=y
1213CONFIG_NFS_FS=y
1214CONFIG_NFS_V3=y
1215CONFIG_NFS_V3_ACL=y
1216CONFIG_NFS_V4=y
1217CONFIG_ROOT_NFS=y
1218# CONFIG_NFSD is not set
1219CONFIG_LOCKD=y
1220CONFIG_LOCKD_V4=y
1221CONFIG_NFS_ACL_SUPPORT=y
1222CONFIG_NFS_COMMON=y
1223CONFIG_SUNRPC=y
1224CONFIG_SUNRPC_GSS=y
1225CONFIG_RPCSEC_GSS_KRB5=y
1226# CONFIG_RPCSEC_GSS_SPKM3 is not set
1227CONFIG_SMB_FS=m
1228# CONFIG_SMB_NLS_DEFAULT is not set
1229CONFIG_CIFS=m
1230# CONFIG_CIFS_STATS is not set
1231CONFIG_CIFS_WEAK_PW_HASH=y
1232# CONFIG_CIFS_XATTR is not set
1233# CONFIG_CIFS_DEBUG2 is not set
1234# CONFIG_CIFS_EXPERIMENTAL is not set
1235# CONFIG_NCP_FS is not set
1236# CONFIG_CODA_FS is not set
1237# CONFIG_AFS_FS is not set
1238
1239#
1240# Partition Types
1241#
1242CONFIG_PARTITION_ADVANCED=y
1243# CONFIG_ACORN_PARTITION is not set
1244# CONFIG_OSF_PARTITION is not set
1245# CONFIG_AMIGA_PARTITION is not set
1246# CONFIG_ATARI_PARTITION is not set
1247# CONFIG_MAC_PARTITION is not set
1248CONFIG_MSDOS_PARTITION=y
1249# CONFIG_BSD_DISKLABEL is not set
1250# CONFIG_MINIX_SUBPARTITION is not set
1251# CONFIG_SOLARIS_X86_PARTITION is not set
1252# CONFIG_UNIXWARE_DISKLABEL is not set
1253# CONFIG_LDM_PARTITION is not set
1254# CONFIG_SGI_PARTITION is not set
1255# CONFIG_ULTRIX_PARTITION is not set
1256# CONFIG_SUN_PARTITION is not set
1257# CONFIG_KARMA_PARTITION is not set
1258# CONFIG_EFI_PARTITION is not set
1259# CONFIG_SYSV68_PARTITION is not set
1260CONFIG_NLS=m
1261CONFIG_NLS_DEFAULT="iso8859-1"
1262CONFIG_NLS_CODEPAGE_437=m
1263# CONFIG_NLS_CODEPAGE_737 is not set
1264# CONFIG_NLS_CODEPAGE_775 is not set
1265# CONFIG_NLS_CODEPAGE_850 is not set
1266# CONFIG_NLS_CODEPAGE_852 is not set
1267# CONFIG_NLS_CODEPAGE_855 is not set
1268# CONFIG_NLS_CODEPAGE_857 is not set
1269# CONFIG_NLS_CODEPAGE_860 is not set
1270# CONFIG_NLS_CODEPAGE_861 is not set
1271# CONFIG_NLS_CODEPAGE_862 is not set
1272# CONFIG_NLS_CODEPAGE_863 is not set
1273# CONFIG_NLS_CODEPAGE_864 is not set
1274# CONFIG_NLS_CODEPAGE_865 is not set
1275# CONFIG_NLS_CODEPAGE_866 is not set
1276# CONFIG_NLS_CODEPAGE_869 is not set
1277# CONFIG_NLS_CODEPAGE_936 is not set
1278# CONFIG_NLS_CODEPAGE_950 is not set
1279# CONFIG_NLS_CODEPAGE_932 is not set
1280# CONFIG_NLS_CODEPAGE_949 is not set
1281# CONFIG_NLS_CODEPAGE_874 is not set
1282# CONFIG_NLS_ISO8859_8 is not set
1283# CONFIG_NLS_CODEPAGE_1250 is not set
1284# CONFIG_NLS_CODEPAGE_1251 is not set
1285# CONFIG_NLS_ASCII is not set
1286CONFIG_NLS_ISO8859_1=m
1287# CONFIG_NLS_ISO8859_2 is not set
1288# CONFIG_NLS_ISO8859_3 is not set
1289# CONFIG_NLS_ISO8859_4 is not set
1290# CONFIG_NLS_ISO8859_5 is not set
1291# CONFIG_NLS_ISO8859_6 is not set
1292# CONFIG_NLS_ISO8859_7 is not set
1293# CONFIG_NLS_ISO8859_9 is not set
1294# CONFIG_NLS_ISO8859_13 is not set
1295# CONFIG_NLS_ISO8859_14 is not set
1296# CONFIG_NLS_ISO8859_15 is not set
1297# CONFIG_NLS_KOI8_R is not set
1298# CONFIG_NLS_KOI8_U is not set
1299# CONFIG_NLS_UTF8 is not set
1300# CONFIG_DLM is not set
1301
1302#
1303# Kernel hacking
1304#
1305# CONFIG_PRINTK_TIME is not set
1306CONFIG_ENABLE_WARN_DEPRECATED=y
1307CONFIG_ENABLE_MUST_CHECK=y
1308CONFIG_FRAME_WARN=1024
1309# CONFIG_MAGIC_SYSRQ is not set
1310# CONFIG_UNUSED_SYMBOLS is not set
1311CONFIG_DEBUG_FS=y
1312# CONFIG_HEADERS_CHECK is not set
1313CONFIG_DEBUG_KERNEL=y
1314# CONFIG_DEBUG_SHIRQ is not set
1315# CONFIG_DETECT_SOFTLOCKUP is not set
1316# CONFIG_SCHED_DEBUG is not set
1317# CONFIG_SCHEDSTATS is not set
1318# CONFIG_TIMER_STATS is not set
1319# CONFIG_DEBUG_OBJECTS is not set
1320# CONFIG_SLUB_DEBUG_ON is not set
1321# CONFIG_SLUB_STATS is not set
1322# CONFIG_DEBUG_RT_MUTEXES is not set
1323# CONFIG_RT_MUTEX_TESTER is not set
1324# CONFIG_DEBUG_SPINLOCK is not set
1325# CONFIG_DEBUG_MUTEXES is not set
1326# CONFIG_DEBUG_LOCK_ALLOC is not set
1327# CONFIG_PROVE_LOCKING is not set
1328# CONFIG_LOCK_STAT is not set
1329# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1330# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1331# CONFIG_DEBUG_KOBJECT is not set
1332CONFIG_DEBUG_BUGVERBOSE=y
1333# CONFIG_DEBUG_INFO is not set
1334# CONFIG_DEBUG_VM is not set
1335# CONFIG_DEBUG_WRITECOUNT is not set
1336CONFIG_DEBUG_MEMORY_INIT=y
1337# CONFIG_DEBUG_LIST is not set
1338# CONFIG_DEBUG_SG is not set
1339CONFIG_FRAME_POINTER=y
1340# CONFIG_BOOT_PRINTK_DELAY is not set
1341# CONFIG_RCU_TORTURE_TEST is not set
1342# CONFIG_BACKTRACE_SELF_TEST is not set
1343# CONFIG_FAULT_INJECTION is not set
1344# CONFIG_LATENCYTOP is not set
1345CONFIG_SYSCTL_SYSCALL_CHECK=y
1346CONFIG_HAVE_FTRACE=y
1347CONFIG_HAVE_DYNAMIC_FTRACE=y
1348# CONFIG_FTRACE is not set
1349# CONFIG_IRQSOFF_TRACER is not set
1350# CONFIG_SCHED_TRACER is not set
1351# CONFIG_CONTEXT_SWITCH_TRACER is not set
1352# CONFIG_SAMPLES is not set
1353CONFIG_HAVE_ARCH_KGDB=y
1354# CONFIG_KGDB is not set
1355CONFIG_DEBUG_USER=y
1356# CONFIG_DEBUG_ERRORS is not set
1357# CONFIG_DEBUG_STACK_USAGE is not set
1358CONFIG_DEBUG_LL=y
1359# CONFIG_DEBUG_ICEDCC is not set
1360
1361#
1362# Security options
1363#
1364# CONFIG_KEYS is not set
1365# CONFIG_SECURITY is not set
1366# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1367CONFIG_CRYPTO=y
1368
1369#
1370# Crypto core or helper
1371#
1372CONFIG_CRYPTO_ALGAPI=y
1373CONFIG_CRYPTO_BLKCIPHER=y
1374CONFIG_CRYPTO_MANAGER=y
1375# CONFIG_CRYPTO_GF128MUL is not set
1376# CONFIG_CRYPTO_NULL is not set
1377# CONFIG_CRYPTO_CRYPTD is not set
1378# CONFIG_CRYPTO_AUTHENC is not set
1379# CONFIG_CRYPTO_TEST is not set
1380
1381#
1382# Authenticated Encryption with Associated Data
1383#
1384# CONFIG_CRYPTO_CCM is not set
1385# CONFIG_CRYPTO_GCM is not set
1386# CONFIG_CRYPTO_SEQIV is not set
1387
1388#
1389# Block modes
1390#
1391CONFIG_CRYPTO_CBC=y
1392# CONFIG_CRYPTO_CTR is not set
1393# CONFIG_CRYPTO_CTS is not set
1394CONFIG_CRYPTO_ECB=m
1395# CONFIG_CRYPTO_LRW is not set
1396# CONFIG_CRYPTO_PCBC is not set
1397# CONFIG_CRYPTO_XTS is not set
1398
1399#
1400# Hash modes
1401#
1402# CONFIG_CRYPTO_HMAC is not set
1403# CONFIG_CRYPTO_XCBC is not set
1404
1405#
1406# Digest
1407#
1408# CONFIG_CRYPTO_CRC32C is not set
1409# CONFIG_CRYPTO_MD4 is not set
1410CONFIG_CRYPTO_MD5=y
1411CONFIG_CRYPTO_MICHAEL_MIC=m
1412# CONFIG_CRYPTO_RMD128 is not set
1413# CONFIG_CRYPTO_RMD160 is not set
1414# CONFIG_CRYPTO_RMD256 is not set
1415# CONFIG_CRYPTO_RMD320 is not set
1416# CONFIG_CRYPTO_SHA1 is not set
1417# CONFIG_CRYPTO_SHA256 is not set
1418# CONFIG_CRYPTO_SHA512 is not set
1419# CONFIG_CRYPTO_TGR192 is not set
1420# CONFIG_CRYPTO_WP512 is not set
1421
1422#
1423# Ciphers
1424#
1425CONFIG_CRYPTO_AES=m
1426# CONFIG_CRYPTO_ANUBIS is not set
1427CONFIG_CRYPTO_ARC4=m
1428# CONFIG_CRYPTO_BLOWFISH is not set
1429# CONFIG_CRYPTO_CAMELLIA is not set
1430# CONFIG_CRYPTO_CAST5 is not set
1431# CONFIG_CRYPTO_CAST6 is not set
1432CONFIG_CRYPTO_DES=y
1433# CONFIG_CRYPTO_FCRYPT is not set
1434# CONFIG_CRYPTO_KHAZAD is not set
1435# CONFIG_CRYPTO_SALSA20 is not set
1436# CONFIG_CRYPTO_SEED is not set
1437# CONFIG_CRYPTO_SERPENT is not set
1438# CONFIG_CRYPTO_TEA is not set
1439# CONFIG_CRYPTO_TWOFISH is not set
1440
1441#
1442# Compression
1443#
1444# CONFIG_CRYPTO_DEFLATE is not set
1445# CONFIG_CRYPTO_LZO is not set
1446# CONFIG_CRYPTO_HW is not set
1447
1448#
1449# Library routines
1450#
1451CONFIG_BITREVERSE=y
1452# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1453# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1454# CONFIG_CRC_CCITT is not set
1455# CONFIG_CRC16 is not set
1456CONFIG_CRC_T10DIF=y
1457# CONFIG_CRC_ITU_T is not set
1458CONFIG_CRC32=y
1459# CONFIG_CRC7 is not set
1460# CONFIG_LIBCRC32C is not set
1461CONFIG_ZLIB_INFLATE=y
1462CONFIG_ZLIB_DEFLATE=y
1463CONFIG_PLIST=y
1464CONFIG_HAS_IOMEM=y
1465CONFIG_HAS_IOPORT=y
1466CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/jornada720_defconfig b/arch/arm/configs/jornada720_defconfig
index 0c556289a3f4..81fadafae02d 100644
--- a/arch/arm/configs/jornada720_defconfig
+++ b/arch/arm/configs/jornada720_defconfig
@@ -1,84 +1,174 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.12-rc1-bk2 3# Linux kernel version: 2.6.27-rc6
4# Sun Mar 27 23:10:35 2005 4# Tue Sep 16 18:56:58 2008
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y
7CONFIG_MMU=y 11CONFIG_MMU=y
8CONFIG_UID16=y 12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
16CONFIG_LOCKDEP_SUPPORT=y
17CONFIG_TRACE_IRQFLAGS_SUPPORT=y
18CONFIG_HARDIRQS_SW_RESEND=y
19CONFIG_GENERIC_IRQ_PROBE=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 20CONFIG_RWSEM_GENERIC_SPINLOCK=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y 24CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_IOMAP=y 25CONFIG_ARCH_SUPPORTS_AOUT=y
26CONFIG_ZONE_DMA=y
27CONFIG_ARCH_MTD_XIP=y
28CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
29CONFIG_VECTORS_BASE=0xffff0000
30CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
12 31
13# 32#
14# Code maturity level options 33# General setup
15# 34#
16CONFIG_EXPERIMENTAL=y 35CONFIG_EXPERIMENTAL=y
17CONFIG_CLEAN_COMPILE=y
18CONFIG_BROKEN_ON_SMP=y 36CONFIG_BROKEN_ON_SMP=y
19 37CONFIG_INIT_ENV_ARG_LIMIT=32
20#
21# General setup
22#
23CONFIG_LOCALVERSION="" 38CONFIG_LOCALVERSION=""
39CONFIG_LOCALVERSION_AUTO=y
24CONFIG_SWAP=y 40CONFIG_SWAP=y
25CONFIG_SYSVIPC=y 41CONFIG_SYSVIPC=y
42CONFIG_SYSVIPC_SYSCTL=y
26# CONFIG_POSIX_MQUEUE is not set 43# CONFIG_POSIX_MQUEUE is not set
27# CONFIG_BSD_PROCESS_ACCT is not set 44# CONFIG_BSD_PROCESS_ACCT is not set
28CONFIG_SYSCTL=y 45# CONFIG_TASKSTATS is not set
29# CONFIG_AUDIT is not set 46# CONFIG_AUDIT is not set
30CONFIG_HOTPLUG=y
31CONFIG_KOBJECT_UEVENT=y
32# CONFIG_IKCONFIG is not set 47# CONFIG_IKCONFIG is not set
48CONFIG_LOG_BUF_SHIFT=14
49# CONFIG_CGROUPS is not set
50# CONFIG_GROUP_SCHED is not set
51CONFIG_SYSFS_DEPRECATED=y
52CONFIG_SYSFS_DEPRECATED_V2=y
53# CONFIG_RELAY is not set
54CONFIG_NAMESPACES=y
55# CONFIG_UTS_NS is not set
56# CONFIG_IPC_NS is not set
57# CONFIG_USER_NS is not set
58# CONFIG_PID_NS is not set
59# CONFIG_BLK_DEV_INITRD is not set
60CONFIG_CC_OPTIMIZE_FOR_SIZE=y
61CONFIG_SYSCTL=y
33# CONFIG_EMBEDDED is not set 62# CONFIG_EMBEDDED is not set
63CONFIG_UID16=y
64CONFIG_SYSCTL_SYSCALL=y
34CONFIG_KALLSYMS=y 65CONFIG_KALLSYMS=y
35# CONFIG_KALLSYMS_ALL is not set 66# CONFIG_KALLSYMS_ALL is not set
36# CONFIG_KALLSYMS_EXTRA_PASS is not set 67# CONFIG_KALLSYMS_EXTRA_PASS is not set
68CONFIG_HOTPLUG=y
69CONFIG_PRINTK=y
70CONFIG_BUG=y
71CONFIG_ELF_CORE=y
72CONFIG_COMPAT_BRK=y
37CONFIG_BASE_FULL=y 73CONFIG_BASE_FULL=y
38CONFIG_FUTEX=y 74CONFIG_FUTEX=y
75CONFIG_ANON_INODES=y
39CONFIG_EPOLL=y 76CONFIG_EPOLL=y
40CONFIG_CC_OPTIMIZE_FOR_SIZE=y 77CONFIG_SIGNALFD=y
78CONFIG_TIMERFD=y
79CONFIG_EVENTFD=y
41CONFIG_SHMEM=y 80CONFIG_SHMEM=y
42CONFIG_CC_ALIGN_FUNCTIONS=0 81CONFIG_VM_EVENT_COUNTERS=y
43CONFIG_CC_ALIGN_LABELS=0 82CONFIG_SLUB_DEBUG=y
44CONFIG_CC_ALIGN_LOOPS=0 83# CONFIG_SLAB is not set
45CONFIG_CC_ALIGN_JUMPS=0 84CONFIG_SLUB=y
85# CONFIG_SLOB is not set
86# CONFIG_PROFILING is not set
87# CONFIG_MARKERS is not set
88CONFIG_HAVE_OPROFILE=y
89# CONFIG_KPROBES is not set
90# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
91# CONFIG_HAVE_IOREMAP_PROT is not set
92CONFIG_HAVE_KPROBES=y
93CONFIG_HAVE_KRETPROBES=y
94# CONFIG_HAVE_ARCH_TRACEHOOK is not set
95# CONFIG_HAVE_DMA_ATTRS is not set
96# CONFIG_USE_GENERIC_SMP_HELPERS is not set
97CONFIG_HAVE_CLK=y
98CONFIG_PROC_PAGE_MONITOR=y
99CONFIG_HAVE_GENERIC_DMA_COHERENT=y
100CONFIG_SLABINFO=y
101CONFIG_RT_MUTEXES=y
46# CONFIG_TINY_SHMEM is not set 102# CONFIG_TINY_SHMEM is not set
47CONFIG_BASE_SMALL=0 103CONFIG_BASE_SMALL=0
48
49#
50# Loadable module support
51#
52CONFIG_MODULES=y 104CONFIG_MODULES=y
105# CONFIG_MODULE_FORCE_LOAD is not set
53# CONFIG_MODULE_UNLOAD is not set 106# CONFIG_MODULE_UNLOAD is not set
54CONFIG_OBSOLETE_MODPARM=y
55# CONFIG_MODVERSIONS is not set 107# CONFIG_MODVERSIONS is not set
56# CONFIG_MODULE_SRCVERSION_ALL is not set 108# CONFIG_MODULE_SRCVERSION_ALL is not set
57CONFIG_KMOD=y 109CONFIG_KMOD=y
110CONFIG_BLOCK=y
111# CONFIG_LBD is not set
112# CONFIG_BLK_DEV_IO_TRACE is not set
113# CONFIG_LSF is not set
114# CONFIG_BLK_DEV_BSG is not set
115# CONFIG_BLK_DEV_INTEGRITY is not set
116
117#
118# IO Schedulers
119#
120CONFIG_IOSCHED_NOOP=y
121CONFIG_IOSCHED_AS=y
122CONFIG_IOSCHED_DEADLINE=y
123CONFIG_IOSCHED_CFQ=y
124# CONFIG_DEFAULT_AS is not set
125# CONFIG_DEFAULT_DEADLINE is not set
126CONFIG_DEFAULT_CFQ=y
127# CONFIG_DEFAULT_NOOP is not set
128CONFIG_DEFAULT_IOSCHED="cfq"
129CONFIG_CLASSIC_RCU=y
58 130
59# 131#
60# System Type 132# System Type
61# 133#
134# CONFIG_ARCH_AAEC2000 is not set
135# CONFIG_ARCH_INTEGRATOR is not set
136# CONFIG_ARCH_REALVIEW is not set
137# CONFIG_ARCH_VERSATILE is not set
138# CONFIG_ARCH_AT91 is not set
62# CONFIG_ARCH_CLPS7500 is not set 139# CONFIG_ARCH_CLPS7500 is not set
63# CONFIG_ARCH_CLPS711X is not set 140# CONFIG_ARCH_CLPS711X is not set
64# CONFIG_ARCH_CO285 is not set
65# CONFIG_ARCH_EBSA110 is not set 141# CONFIG_ARCH_EBSA110 is not set
142# CONFIG_ARCH_EP93XX is not set
66# CONFIG_ARCH_FOOTBRIDGE is not set 143# CONFIG_ARCH_FOOTBRIDGE is not set
67# CONFIG_ARCH_INTEGRATOR is not set 144# CONFIG_ARCH_NETX is not set
68# CONFIG_ARCH_IOP3XX is not set 145# CONFIG_ARCH_H720X is not set
69# CONFIG_ARCH_IXP4XX is not set 146# CONFIG_ARCH_IMX is not set
147# CONFIG_ARCH_IOP13XX is not set
148# CONFIG_ARCH_IOP32X is not set
149# CONFIG_ARCH_IOP33X is not set
150# CONFIG_ARCH_IXP23XX is not set
70# CONFIG_ARCH_IXP2000 is not set 151# CONFIG_ARCH_IXP2000 is not set
152# CONFIG_ARCH_IXP4XX is not set
71# CONFIG_ARCH_L7200 is not set 153# CONFIG_ARCH_L7200 is not set
154# CONFIG_ARCH_KIRKWOOD is not set
155# CONFIG_ARCH_KS8695 is not set
156# CONFIG_ARCH_NS9XXX is not set
157# CONFIG_ARCH_LOKI is not set
158# CONFIG_ARCH_MV78XX0 is not set
159# CONFIG_ARCH_MXC is not set
160# CONFIG_ARCH_ORION5X is not set
161# CONFIG_ARCH_PNX4008 is not set
72# CONFIG_ARCH_PXA is not set 162# CONFIG_ARCH_PXA is not set
73# CONFIG_ARCH_RPC is not set 163# CONFIG_ARCH_RPC is not set
74CONFIG_ARCH_SA1100=y 164CONFIG_ARCH_SA1100=y
75# CONFIG_ARCH_S3C2410 is not set 165# CONFIG_ARCH_S3C2410 is not set
76# CONFIG_ARCH_SHARK is not set 166# CONFIG_ARCH_SHARK is not set
77# CONFIG_ARCH_LH7A40X is not set 167# CONFIG_ARCH_LH7A40X is not set
168# CONFIG_ARCH_DAVINCI is not set
78# CONFIG_ARCH_OMAP is not set 169# CONFIG_ARCH_OMAP is not set
79# CONFIG_ARCH_VERSATILE is not set 170# CONFIG_ARCH_MSM7X00A is not set
80# CONFIG_ARCH_IMX is not set 171CONFIG_DMABOUNCE=y
81# CONFIG_ARCH_H720X is not set
82 172
83# 173#
84# SA11x0 Implementations 174# SA11x0 Implementations
@@ -91,12 +181,21 @@ CONFIG_ARCH_SA1100=y
91# CONFIG_SA1100_H3800 is not set 181# CONFIG_SA1100_H3800 is not set
92# CONFIG_SA1100_BADGE4 is not set 182# CONFIG_SA1100_BADGE4 is not set
93CONFIG_SA1100_JORNADA720=y 183CONFIG_SA1100_JORNADA720=y
184CONFIG_SA1100_JORNADA720_SSP=y
94# CONFIG_SA1100_HACKKIT is not set 185# CONFIG_SA1100_HACKKIT is not set
95# CONFIG_SA1100_LART is not set 186# CONFIG_SA1100_LART is not set
96# CONFIG_SA1100_PLEB is not set 187# CONFIG_SA1100_PLEB is not set
97# CONFIG_SA1100_SHANNON is not set 188# CONFIG_SA1100_SHANNON is not set
98# CONFIG_SA1100_SIMPAD is not set 189# CONFIG_SA1100_SIMPAD is not set
99# CONFIG_SA1100_SSP is not set 190CONFIG_SA1100_SSP=y
191
192#
193# Boot options
194#
195
196#
197# Power management
198#
100 199
101# 200#
102# Processor Type 201# Processor Type
@@ -105,44 +204,71 @@ CONFIG_CPU_32=y
105CONFIG_CPU_SA1100=y 204CONFIG_CPU_SA1100=y
106CONFIG_CPU_32v4=y 205CONFIG_CPU_32v4=y
107CONFIG_CPU_ABRT_EV4=y 206CONFIG_CPU_ABRT_EV4=y
207CONFIG_CPU_PABRT_NOIFAR=y
108CONFIG_CPU_CACHE_V4WB=y 208CONFIG_CPU_CACHE_V4WB=y
109CONFIG_CPU_CACHE_VIVT=y 209CONFIG_CPU_CACHE_VIVT=y
110CONFIG_CPU_TLB_V4WB=y 210CONFIG_CPU_TLB_V4WB=y
111CONFIG_CPU_MINICACHE=y 211CONFIG_CPU_CP15=y
212CONFIG_CPU_CP15_MMU=y
112 213
113# 214#
114# Processor Features 215# Processor Features
115# 216#
217# CONFIG_CPU_ICACHE_DISABLE is not set
218# CONFIG_CPU_DCACHE_DISABLE is not set
219# CONFIG_OUTER_CACHE is not set
116CONFIG_SA1111=y 220CONFIG_SA1111=y
117CONFIG_DMABOUNCE=y
118CONFIG_FORCE_MAX_ZONEORDER=9 221CONFIG_FORCE_MAX_ZONEORDER=9
119 222
120# 223#
121# Bus support 224# Bus support
122# 225#
123CONFIG_ISA=y 226CONFIG_ISA=y
124 227# CONFIG_PCI_SYSCALL is not set
125# 228# CONFIG_ARCH_SUPPORTS_MSI is not set
126# PCCARD (PCMCIA/CardBus) support
127#
128CONFIG_PCCARD=y 229CONFIG_PCCARD=y
129# CONFIG_PCMCIA_DEBUG is not set 230# CONFIG_PCMCIA_DEBUG is not set
130CONFIG_PCMCIA=y 231CONFIG_PCMCIA=y
232CONFIG_PCMCIA_LOAD_CIS=y
233CONFIG_PCMCIA_IOCTL=y
131 234
132# 235#
133# PC-card bridges 236# PC-card bridges
134# 237#
135CONFIG_I82365=y 238# CONFIG_I82365 is not set
136# CONFIG_TCIC is not set 239# CONFIG_TCIC is not set
137CONFIG_PCMCIA_SA1100=y 240CONFIG_PCMCIA_SA1100=y
138# CONFIG_PCMCIA_SA1111 is not set 241# CONFIG_PCMCIA_SA1111 is not set
139CONFIG_PCCARD_NONSTATIC=y
140 242
141# 243#
142# Kernel Features 244# Kernel Features
143# 245#
246CONFIG_TICK_ONESHOT=y
247# CONFIG_NO_HZ is not set
248# CONFIG_HIGH_RES_TIMERS is not set
249CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
144# CONFIG_PREEMPT is not set 250# CONFIG_PREEMPT is not set
251CONFIG_HZ=100
252# CONFIG_AEABI is not set
253CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
254CONFIG_ARCH_SPARSEMEM_ENABLE=y
255CONFIG_ARCH_SELECT_MEMORY_MODEL=y
256CONFIG_NODES_SHIFT=2
257CONFIG_SELECT_MEMORY_MODEL=y
258# CONFIG_FLATMEM_MANUAL is not set
259CONFIG_DISCONTIGMEM_MANUAL=y
260# CONFIG_SPARSEMEM_MANUAL is not set
145CONFIG_DISCONTIGMEM=y 261CONFIG_DISCONTIGMEM=y
262CONFIG_FLAT_NODE_MEM_MAP=y
263CONFIG_NEED_MULTIPLE_NODES=y
264# CONFIG_SPARSEMEM_STATIC is not set
265# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
266CONFIG_PAGEFLAGS_EXTENDED=y
267CONFIG_SPLIT_PTLOCK_CPUS=4096
268# CONFIG_RESOURCES_64BIT is not set
269CONFIG_ZONE_DMA_FLAG=1
270CONFIG_BOUNCE=y
271CONFIG_VIRT_TO_BUS=y
146# CONFIG_LEDS is not set 272# CONFIG_LEDS is not set
147CONFIG_ALIGNMENT_TRAP=y 273CONFIG_ALIGNMENT_TRAP=y
148 274
@@ -151,8 +277,9 @@ CONFIG_ALIGNMENT_TRAP=y
151# 277#
152CONFIG_ZBOOT_ROM_TEXT=0x0 278CONFIG_ZBOOT_ROM_TEXT=0x0
153CONFIG_ZBOOT_ROM_BSS=0x0 279CONFIG_ZBOOT_ROM_BSS=0x0
154CONFIG_CMDLINE="keepinitrd mem=32M" 280CONFIG_CMDLINE=""
155# CONFIG_XIP_KERNEL is not set 281# CONFIG_XIP_KERNEL is not set
282# CONFIG_KEXEC is not set
156 283
157# 284#
158# CPU Frequency scaling 285# CPU Frequency scaling
@@ -174,7 +301,7 @@ CONFIG_FPE_FASTFPE=y
174# Userspace binary formats 301# Userspace binary formats
175# 302#
176CONFIG_BINFMT_ELF=y 303CONFIG_BINFMT_ELF=y
177CONFIG_BINFMT_AOUT=m 304CONFIG_BINFMT_AOUT=y
178# CONFIG_BINFMT_MISC is not set 305# CONFIG_BINFMT_MISC is not set
179# CONFIG_ARTHUR is not set 306# CONFIG_ARTHUR is not set
180 307
@@ -182,188 +309,12 @@ CONFIG_BINFMT_AOUT=m
182# Power management options 309# Power management options
183# 310#
184CONFIG_PM=y 311CONFIG_PM=y
185# CONFIG_PM_LEGACY is not set 312# CONFIG_PM_DEBUG is not set
186# CONFIG_APM is not set 313CONFIG_PM_SLEEP=y
187 314CONFIG_SUSPEND=y
188# 315CONFIG_SUSPEND_FREEZER=y
189# Device Drivers 316# CONFIG_APM_EMULATION is not set
190# 317CONFIG_ARCH_SUSPEND_POSSIBLE=y
191
192#
193# Generic Driver Options
194#
195CONFIG_STANDALONE=y
196CONFIG_PREVENT_FIRMWARE_BUILD=y
197# CONFIG_FW_LOADER is not set
198# CONFIG_DEBUG_DRIVER is not set
199
200#
201# Memory Technology Devices (MTD)
202#
203CONFIG_MTD=y
204CONFIG_MTD_DEBUG=y
205CONFIG_MTD_DEBUG_VERBOSE=1
206# CONFIG_MTD_CONCAT is not set
207CONFIG_MTD_PARTITIONS=y
208# CONFIG_MTD_REDBOOT_PARTS is not set
209# CONFIG_MTD_CMDLINE_PARTS is not set
210# CONFIG_MTD_AFS_PARTS is not set
211
212#
213# User Modules And Translation Layers
214#
215CONFIG_MTD_CHAR=m
216CONFIG_MTD_BLOCK=y
217# CONFIG_FTL is not set
218# CONFIG_NFTL is not set
219# CONFIG_INFTL is not set
220
221#
222# RAM/ROM/Flash chip drivers
223#
224CONFIG_MTD_CFI=y
225# CONFIG_MTD_JEDECPROBE is not set
226CONFIG_MTD_GEN_PROBE=y
227CONFIG_MTD_CFI_ADV_OPTIONS=y
228CONFIG_MTD_CFI_NOSWAP=y
229# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
230# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
231CONFIG_MTD_CFI_GEOMETRY=y
232CONFIG_MTD_MAP_BANK_WIDTH_1=y
233CONFIG_MTD_MAP_BANK_WIDTH_2=y
234CONFIG_MTD_MAP_BANK_WIDTH_4=y
235# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
236# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
237# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
238CONFIG_MTD_CFI_I1=y
239CONFIG_MTD_CFI_I2=y
240# CONFIG_MTD_CFI_I4 is not set
241# CONFIG_MTD_CFI_I8 is not set
242CONFIG_MTD_CFI_INTELEXT=y
243# CONFIG_MTD_CFI_AMDSTD is not set
244# CONFIG_MTD_CFI_STAA is not set
245CONFIG_MTD_CFI_UTIL=y
246# CONFIG_MTD_RAM is not set
247# CONFIG_MTD_ROM is not set
248# CONFIG_MTD_ABSENT is not set
249# CONFIG_MTD_XIP is not set
250
251#
252# Mapping drivers for chip access
253#
254# CONFIG_MTD_COMPLEX_MAPPINGS is not set
255# CONFIG_MTD_PHYSMAP is not set
256# CONFIG_MTD_ARM_INTEGRATOR is not set
257CONFIG_MTD_SA1100=y
258# CONFIG_MTD_EDB7312 is not set
259
260#
261# Self-contained MTD device drivers
262#
263# CONFIG_MTD_SLRAM is not set
264# CONFIG_MTD_PHRAM is not set
265# CONFIG_MTD_MTDRAM is not set
266# CONFIG_MTD_BLKMTD is not set
267# CONFIG_MTD_BLOCK2MTD is not set
268
269#
270# Disk-On-Chip Device Drivers
271#
272# CONFIG_MTD_DOC2000 is not set
273# CONFIG_MTD_DOC2001 is not set
274# CONFIG_MTD_DOC2001PLUS is not set
275
276#
277# NAND Flash Device Drivers
278#
279# CONFIG_MTD_NAND is not set
280
281#
282# Parallel port support
283#
284# CONFIG_PARPORT is not set
285
286#
287# Plug and Play support
288#
289# CONFIG_PNP is not set
290
291#
292# Block devices
293#
294# CONFIG_BLK_DEV_FD is not set
295# CONFIG_BLK_DEV_XD is not set
296# CONFIG_BLK_DEV_COW_COMMON is not set
297CONFIG_BLK_DEV_LOOP=m
298# CONFIG_BLK_DEV_CRYPTOLOOP is not set
299CONFIG_BLK_DEV_NBD=m
300# CONFIG_BLK_DEV_RAM is not set
301CONFIG_BLK_DEV_RAM_COUNT=16
302CONFIG_INITRAMFS_SOURCE=""
303# CONFIG_CDROM_PKTCDVD is not set
304
305#
306# IO Schedulers
307#
308CONFIG_IOSCHED_NOOP=y
309CONFIG_IOSCHED_AS=y
310CONFIG_IOSCHED_DEADLINE=y
311CONFIG_IOSCHED_CFQ=y
312# CONFIG_ATA_OVER_ETH is not set
313
314#
315# ATA/ATAPI/MFM/RLL support
316#
317CONFIG_IDE=m
318CONFIG_BLK_DEV_IDE=m
319
320#
321# Please see Documentation/ide.txt for help/info on IDE drives
322#
323# CONFIG_BLK_DEV_IDE_SATA is not set
324CONFIG_BLK_DEV_IDEDISK=m
325# CONFIG_IDEDISK_MULTI_MODE is not set
326# CONFIG_BLK_DEV_IDECS is not set
327CONFIG_BLK_DEV_IDECD=m
328# CONFIG_BLK_DEV_IDETAPE is not set
329# CONFIG_BLK_DEV_IDEFLOPPY is not set
330# CONFIG_IDE_TASK_IOCTL is not set
331
332#
333# IDE chipset support/bugfixes
334#
335CONFIG_IDE_GENERIC=m
336# CONFIG_IDE_ARM is not set
337# CONFIG_IDE_CHIPSETS is not set
338# CONFIG_BLK_DEV_IDEDMA is not set
339# CONFIG_IDEDMA_AUTO is not set
340# CONFIG_BLK_DEV_HD is not set
341
342#
343# SCSI device support
344#
345# CONFIG_SCSI is not set
346
347#
348# Multi-device support (RAID and LVM)
349#
350# CONFIG_MD is not set
351
352#
353# Fusion MPT device support
354#
355
356#
357# IEEE 1394 (FireWire) support
358#
359
360#
361# I2O device support
362#
363
364#
365# Networking support
366#
367CONFIG_NET=y 318CONFIG_NET=y
368 319
369# 320#
@@ -371,12 +322,17 @@ CONFIG_NET=y
371# 322#
372CONFIG_PACKET=y 323CONFIG_PACKET=y
373CONFIG_PACKET_MMAP=y 324CONFIG_PACKET_MMAP=y
374# CONFIG_NETLINK_DEV is not set
375CONFIG_UNIX=y 325CONFIG_UNIX=y
326CONFIG_XFRM=y
327# CONFIG_XFRM_USER is not set
328# CONFIG_XFRM_SUB_POLICY is not set
329# CONFIG_XFRM_MIGRATE is not set
330# CONFIG_XFRM_STATISTICS is not set
376# CONFIG_NET_KEY is not set 331# CONFIG_NET_KEY is not set
377CONFIG_INET=y 332CONFIG_INET=y
378CONFIG_IP_MULTICAST=y 333CONFIG_IP_MULTICAST=y
379# CONFIG_IP_ADVANCED_ROUTER is not set 334# CONFIG_IP_ADVANCED_ROUTER is not set
335CONFIG_IP_FIB_HASH=y
380# CONFIG_IP_PNP is not set 336# CONFIG_IP_PNP is not set
381# CONFIG_NET_IPIP is not set 337# CONFIG_NET_IPIP is not set
382# CONFIG_NET_IPGRE is not set 338# CONFIG_NET_IPGRE is not set
@@ -386,31 +342,42 @@ CONFIG_IP_MULTICAST=y
386# CONFIG_INET_AH is not set 342# CONFIG_INET_AH is not set
387# CONFIG_INET_ESP is not set 343# CONFIG_INET_ESP is not set
388# CONFIG_INET_IPCOMP is not set 344# CONFIG_INET_IPCOMP is not set
345# CONFIG_INET_XFRM_TUNNEL is not set
389# CONFIG_INET_TUNNEL is not set 346# CONFIG_INET_TUNNEL is not set
390# CONFIG_IP_TCPDIAG is not set 347CONFIG_INET_XFRM_MODE_TRANSPORT=y
391# CONFIG_IP_TCPDIAG_IPV6 is not set 348CONFIG_INET_XFRM_MODE_TUNNEL=y
392 349CONFIG_INET_XFRM_MODE_BEET=y
393# 350# CONFIG_INET_LRO is not set
394# IP: Virtual Server Configuration 351CONFIG_INET_DIAG=y
395# 352CONFIG_INET_TCP_DIAG=y
353# CONFIG_TCP_CONG_ADVANCED is not set
354CONFIG_TCP_CONG_CUBIC=y
355CONFIG_DEFAULT_TCP_CONG="cubic"
356# CONFIG_TCP_MD5SIG is not set
396# CONFIG_IP_VS is not set 357# CONFIG_IP_VS is not set
397# CONFIG_IPV6 is not set 358# CONFIG_IPV6 is not set
359# CONFIG_NETWORK_SECMARK is not set
398CONFIG_NETFILTER=y 360CONFIG_NETFILTER=y
399# CONFIG_NETFILTER_DEBUG is not set 361# CONFIG_NETFILTER_DEBUG is not set
362CONFIG_NETFILTER_ADVANCED=y
363
364#
365# Core Netfilter Configuration
366#
367# CONFIG_NETFILTER_NETLINK_QUEUE is not set
368# CONFIG_NETFILTER_NETLINK_LOG is not set
369# CONFIG_NF_CONNTRACK is not set
370# CONFIG_NETFILTER_XTABLES is not set
400 371
401# 372#
402# IP: Netfilter Configuration 373# IP: Netfilter Configuration
403# 374#
404# CONFIG_IP_NF_CONNTRACK is not set
405# CONFIG_IP_NF_CONNTRACK_MARK is not set
406# CONFIG_IP_NF_QUEUE is not set 375# CONFIG_IP_NF_QUEUE is not set
407# CONFIG_IP_NF_IPTABLES is not set 376# CONFIG_IP_NF_IPTABLES is not set
408# CONFIG_IP_NF_ARPTABLES is not set 377# CONFIG_IP_NF_ARPTABLES is not set
409 378# CONFIG_IP_DCCP is not set
410#
411# SCTP Configuration (EXPERIMENTAL)
412#
413# CONFIG_IP_SCTP is not set 379# CONFIG_IP_SCTP is not set
380# CONFIG_TIPC is not set
414# CONFIG_ATM is not set 381# CONFIG_ATM is not set
415# CONFIG_BRIDGE is not set 382# CONFIG_BRIDGE is not set
416# CONFIG_VLAN_8021Q is not set 383# CONFIG_VLAN_8021Q is not set
@@ -420,30 +387,22 @@ CONFIG_NETFILTER=y
420# CONFIG_ATALK is not set 387# CONFIG_ATALK is not set
421# CONFIG_X25 is not set 388# CONFIG_X25 is not set
422# CONFIG_LAPB is not set 389# CONFIG_LAPB is not set
423# CONFIG_NET_DIVERT is not set
424# CONFIG_ECONET is not set 390# CONFIG_ECONET is not set
425# CONFIG_WAN_ROUTER is not set 391# CONFIG_WAN_ROUTER is not set
426
427#
428# QoS and/or fair queueing
429#
430# CONFIG_NET_SCHED is not set 392# CONFIG_NET_SCHED is not set
431# CONFIG_NET_CLS_ROUTE is not set
432 393
433# 394#
434# Network testing 395# Network testing
435# 396#
436# CONFIG_NET_PKTGEN is not set 397# CONFIG_NET_PKTGEN is not set
437# CONFIG_NETPOLL is not set
438# CONFIG_NET_POLL_CONTROLLER is not set
439# CONFIG_HAMRADIO is not set 398# CONFIG_HAMRADIO is not set
399# CONFIG_CAN is not set
440CONFIG_IRDA=m 400CONFIG_IRDA=m
441 401
442# 402#
443# IrDA protocols 403# IrDA protocols
444# 404#
445CONFIG_IRLAN=m 405CONFIG_IRLAN=m
446# CONFIG_IRNET is not set
447CONFIG_IRCOMM=m 406CONFIG_IRCOMM=m
448# CONFIG_IRDA_ULTRA is not set 407# CONFIG_IRDA_ULTRA is not set
449 408
@@ -468,89 +427,105 @@ CONFIG_IRCOMM=m
468# 427#
469 428
470# 429#
471# Old SIR device drivers
472#
473# CONFIG_IRPORT_SIR is not set
474
475#
476# Old Serial dongle support
477#
478
479#
480# FIR device drivers 430# FIR device drivers
481# 431#
482# CONFIG_NSC_FIR is not set
483# CONFIG_WINBOND_FIR is not set
484# CONFIG_SMC_IRCC_FIR is not set
485# CONFIG_ALI_FIR is not set
486CONFIG_SA1100_FIR=m 432CONFIG_SA1100_FIR=m
487# CONFIG_BT is not set 433# CONFIG_BT is not set
488CONFIG_NETDEVICES=y 434# CONFIG_AF_RXRPC is not set
489# CONFIG_DUMMY is not set
490# CONFIG_BONDING is not set
491# CONFIG_EQUALIZER is not set
492# CONFIG_TUN is not set
493
494#
495# ARCnet devices
496#
497# CONFIG_ARCNET is not set
498
499#
500# Ethernet (10 or 100Mbit)
501#
502# CONFIG_NET_ETHERNET is not set
503CONFIG_MII=m
504 435
505# 436#
506# Ethernet (1000 Mbit) 437# Wireless
507# 438#
439# CONFIG_CFG80211 is not set
440# CONFIG_WIRELESS_EXT is not set
441# CONFIG_MAC80211 is not set
442# CONFIG_IEEE80211 is not set
443# CONFIG_RFKILL is not set
444# CONFIG_NET_9P is not set
508 445
509# 446#
510# Ethernet (10000 Mbit) 447# Device Drivers
511#
512
513#
514# Token Ring devices
515#
516# CONFIG_TR is not set
517
518#
519# Wireless LAN (non-hamradio)
520# 448#
521CONFIG_NET_RADIO=y
522 449
523# 450#
524# Obsolete Wireless cards support (pre-802.11) 451# Generic Driver Options
525# 452#
526# CONFIG_STRIP is not set 453CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
527CONFIG_ARLAN=m 454CONFIG_STANDALONE=y
528CONFIG_WAVELAN=m 455CONFIG_PREVENT_FIRMWARE_BUILD=y
529CONFIG_PCMCIA_WAVELAN=m 456CONFIG_FW_LOADER=y
530# CONFIG_PCMCIA_NETWAVE is not set 457CONFIG_FIRMWARE_IN_KERNEL=y
458CONFIG_EXTRA_FIRMWARE=""
459# CONFIG_DEBUG_DRIVER is not set
460# CONFIG_DEBUG_DEVRES is not set
461# CONFIG_SYS_HYPERVISOR is not set
462# CONFIG_CONNECTOR is not set
463# CONFIG_MTD is not set
464# CONFIG_PARPORT is not set
465# CONFIG_PNP is not set
466CONFIG_BLK_DEV=y
467# CONFIG_BLK_DEV_COW_COMMON is not set
468CONFIG_BLK_DEV_LOOP=m
469# CONFIG_BLK_DEV_CRYPTOLOOP is not set
470CONFIG_BLK_DEV_NBD=m
471# CONFIG_BLK_DEV_RAM is not set
472# CONFIG_CDROM_PKTCDVD is not set
473# CONFIG_ATA_OVER_ETH is not set
474CONFIG_MISC_DEVICES=y
475# CONFIG_EEPROM_93CX6 is not set
476# CONFIG_ENCLOSURE_SERVICES is not set
477CONFIG_HAVE_IDE=y
478CONFIG_IDE=y
479CONFIG_BLK_DEV_IDE=y
531 480
532# 481#
533# Wireless 802.11 Frequency Hopping cards support 482# Please see Documentation/ide/ide.txt for help/info on IDE drives
534# 483#
535# CONFIG_PCMCIA_RAYCS is not set 484# CONFIG_BLK_DEV_IDE_SATA is not set
485CONFIG_BLK_DEV_IDEDISK=y
486# CONFIG_IDEDISK_MULTI_MODE is not set
487CONFIG_BLK_DEV_IDECS=y
488# CONFIG_BLK_DEV_IDECD is not set
489# CONFIG_BLK_DEV_IDETAPE is not set
490# CONFIG_BLK_DEV_IDEFLOPPY is not set
491# CONFIG_IDE_TASK_IOCTL is not set
492CONFIG_IDE_PROC_FS=y
536 493
537# 494#
538# Wireless 802.11b ISA/PCI cards support 495# IDE chipset support/bugfixes
539# 496#
540CONFIG_HERMES=m 497# CONFIG_BLK_DEV_PLATFORM is not set
541# CONFIG_ATMEL is not set 498# CONFIG_BLK_DEV_IDEDMA is not set
542 499
543# 500#
544# Wireless 802.11b Pcmcia/Cardbus cards support 501# SCSI device support
545# 502#
546CONFIG_PCMCIA_HERMES=m 503# CONFIG_RAID_ATTRS is not set
547CONFIG_AIRO_CS=m 504# CONFIG_SCSI is not set
548# CONFIG_PCMCIA_WL3501 is not set 505# CONFIG_SCSI_DMA is not set
549CONFIG_NET_WIRELESS=y 506# CONFIG_SCSI_NETLINK is not set
507# CONFIG_ATA is not set
508# CONFIG_MD is not set
509CONFIG_NETDEVICES=y
510CONFIG_DUMMY=y
511# CONFIG_BONDING is not set
512# CONFIG_MACVLAN is not set
513# CONFIG_EQUALIZER is not set
514# CONFIG_TUN is not set
515# CONFIG_VETH is not set
516# CONFIG_ARCNET is not set
517# CONFIG_NET_ETHERNET is not set
518CONFIG_MII=m
519# CONFIG_NETDEV_1000 is not set
520# CONFIG_NETDEV_10000 is not set
521# CONFIG_TR is not set
550 522
551# 523#
552# PCMCIA network device support 524# Wireless LAN
553# 525#
526# CONFIG_WLAN_PRE80211 is not set
527# CONFIG_WLAN_80211 is not set
528# CONFIG_IWLWIFI_LEDS is not set
554CONFIG_NET_PCMCIA=y 529CONFIG_NET_PCMCIA=y
555CONFIG_PCMCIA_3C589=m 530CONFIG_PCMCIA_3C589=m
556CONFIG_PCMCIA_3C574=m 531CONFIG_PCMCIA_3C574=m
@@ -560,32 +535,20 @@ CONFIG_PCMCIA_NMCLAN=m
560CONFIG_PCMCIA_SMC91C92=m 535CONFIG_PCMCIA_SMC91C92=m
561CONFIG_PCMCIA_XIRC2PS=m 536CONFIG_PCMCIA_XIRC2PS=m
562CONFIG_PCMCIA_AXNET=m 537CONFIG_PCMCIA_AXNET=m
563
564#
565# Wan interfaces
566#
567# CONFIG_WAN is not set 538# CONFIG_WAN is not set
568CONFIG_PPP=m 539# CONFIG_PPP is not set
569# CONFIG_PPP_MULTILINK is not set
570# CONFIG_PPP_FILTER is not set
571CONFIG_PPP_ASYNC=m
572# CONFIG_PPP_SYNC_TTY is not set
573CONFIG_PPP_DEFLATE=m
574CONFIG_PPP_BSDCOMP=m
575# CONFIG_PPPOE is not set
576# CONFIG_SLIP is not set 540# CONFIG_SLIP is not set
577# CONFIG_SHAPER is not set
578# CONFIG_NETCONSOLE is not set 541# CONFIG_NETCONSOLE is not set
579 542# CONFIG_NETPOLL is not set
580# 543# CONFIG_NET_POLL_CONTROLLER is not set
581# ISDN subsystem
582#
583# CONFIG_ISDN is not set 544# CONFIG_ISDN is not set
584 545
585# 546#
586# Input device support 547# Input device support
587# 548#
588CONFIG_INPUT=y 549CONFIG_INPUT=y
550# CONFIG_INPUT_FF_MEMLESS is not set
551# CONFIG_INPUT_POLLDEV is not set
589 552
590# 553#
591# Userland interfaces 554# Userland interfaces
@@ -595,7 +558,6 @@ CONFIG_INPUT_MOUSEDEV_PSAUX=y
595CONFIG_INPUT_MOUSEDEV_SCREEN_X=640 558CONFIG_INPUT_MOUSEDEV_SCREEN_X=640
596CONFIG_INPUT_MOUSEDEV_SCREEN_Y=240 559CONFIG_INPUT_MOUSEDEV_SCREEN_Y=240
597# CONFIG_INPUT_JOYDEV is not set 560# CONFIG_INPUT_JOYDEV is not set
598# CONFIG_INPUT_TSDEV is not set
599# CONFIG_INPUT_EVDEV is not set 561# CONFIG_INPUT_EVDEV is not set
600# CONFIG_INPUT_EVBUG is not set 562# CONFIG_INPUT_EVBUG is not set
601 563
@@ -603,20 +565,31 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=240
603# Input Device Drivers 565# Input Device Drivers
604# 566#
605CONFIG_INPUT_KEYBOARD=y 567CONFIG_INPUT_KEYBOARD=y
606CONFIG_KEYBOARD_ATKBD=y 568# CONFIG_KEYBOARD_ATKBD is not set
607# CONFIG_KEYBOARD_SUNKBD is not set 569# CONFIG_KEYBOARD_SUNKBD is not set
608# CONFIG_KEYBOARD_LKKBD is not set 570# CONFIG_KEYBOARD_LKKBD is not set
609# CONFIG_KEYBOARD_XTKBD is not set 571# CONFIG_KEYBOARD_XTKBD is not set
610# CONFIG_KEYBOARD_NEWTON is not set 572# CONFIG_KEYBOARD_NEWTON is not set
611CONFIG_INPUT_MOUSE=y 573# CONFIG_KEYBOARD_STOWAWAY is not set
612CONFIG_MOUSE_PS2=y 574CONFIG_KEYBOARD_HP7XX=y
613# CONFIG_MOUSE_SERIAL is not set 575# CONFIG_KEYBOARD_GPIO is not set
614# CONFIG_MOUSE_INPORT is not set 576# CONFIG_INPUT_MOUSE is not set
615# CONFIG_MOUSE_LOGIBM is not set
616# CONFIG_MOUSE_PC110PAD is not set
617# CONFIG_MOUSE_VSXXXAA is not set
618# CONFIG_INPUT_JOYSTICK is not set 577# CONFIG_INPUT_JOYSTICK is not set
619# CONFIG_INPUT_TOUCHSCREEN is not set 578# CONFIG_INPUT_TABLET is not set
579CONFIG_INPUT_TOUCHSCREEN=y
580# CONFIG_TOUCHSCREEN_FUJITSU is not set
581# CONFIG_TOUCHSCREEN_GUNZE is not set
582# CONFIG_TOUCHSCREEN_ELO is not set
583# CONFIG_TOUCHSCREEN_MTOUCH is not set
584# CONFIG_TOUCHSCREEN_INEXIO is not set
585# CONFIG_TOUCHSCREEN_MK712 is not set
586CONFIG_TOUCHSCREEN_HP7XX=y
587# CONFIG_TOUCHSCREEN_HTCPEN is not set
588# CONFIG_TOUCHSCREEN_PENMOUNT is not set
589# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
590# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
591# CONFIG_TOUCHSCREEN_UCB1400 is not set
592# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
620# CONFIG_INPUT_MISC is not set 593# CONFIG_INPUT_MISC is not set
621 594
622# 595#
@@ -625,17 +598,18 @@ CONFIG_MOUSE_PS2=y
625CONFIG_SERIO=y 598CONFIG_SERIO=y
626CONFIG_SERIO_SERPORT=y 599CONFIG_SERIO_SERPORT=y
627# CONFIG_SERIO_SA1111 is not set 600# CONFIG_SERIO_SA1111 is not set
628CONFIG_SERIO_LIBPS2=y
629# CONFIG_SERIO_RAW is not set 601# CONFIG_SERIO_RAW is not set
630# CONFIG_GAMEPORT is not set 602# CONFIG_GAMEPORT is not set
631CONFIG_SOUND_GAMEPORT=y
632 603
633# 604#
634# Character devices 605# Character devices
635# 606#
636CONFIG_VT=y 607CONFIG_VT=y
608CONFIG_CONSOLE_TRANSLATIONS=y
637CONFIG_VT_CONSOLE=y 609CONFIG_VT_CONSOLE=y
638CONFIG_HW_CONSOLE=y 610CONFIG_HW_CONSOLE=y
611# CONFIG_VT_HW_CONSOLE_BINDING is not set
612CONFIG_DEVKMEM=y
639# CONFIG_SERIAL_NONSTANDARD is not set 613# CONFIG_SERIAL_NONSTANDARD is not set
640 614
641# 615#
@@ -652,69 +626,120 @@ CONFIG_SERIAL_CORE=y
652CONFIG_SERIAL_CORE_CONSOLE=y 626CONFIG_SERIAL_CORE_CONSOLE=y
653CONFIG_UNIX98_PTYS=y 627CONFIG_UNIX98_PTYS=y
654CONFIG_LEGACY_PTYS=y 628CONFIG_LEGACY_PTYS=y
655CONFIG_LEGACY_PTY_COUNT=256 629CONFIG_LEGACY_PTY_COUNT=32
630# CONFIG_IPMI_HANDLER is not set
631CONFIG_HW_RANDOM=m
632# CONFIG_NVRAM is not set
633# CONFIG_DTLK is not set
634# CONFIG_R3964 is not set
656 635
657# 636#
658# IPMI 637# PCMCIA character devices
659# 638#
660# CONFIG_IPMI_HANDLER is not set 639# CONFIG_SYNCLINK_CS is not set
640# CONFIG_CARDMAN_4000 is not set
641# CONFIG_CARDMAN_4040 is not set
642# CONFIG_IPWIRELESS is not set
643# CONFIG_RAW_DRIVER is not set
644# CONFIG_TCG_TPM is not set
645CONFIG_DEVPORT=y
646# CONFIG_I2C is not set
647# CONFIG_SPI is not set
648CONFIG_ARCH_REQUIRE_GPIOLIB=y
649CONFIG_GPIOLIB=y
650# CONFIG_DEBUG_GPIO is not set
651# CONFIG_GPIO_SYSFS is not set
661 652
662# 653#
663# Watchdog Cards 654# I2C GPIO expanders:
664# 655#
665# CONFIG_WATCHDOG is not set
666# CONFIG_NVRAM is not set
667# CONFIG_RTC is not set
668# CONFIG_DTLK is not set
669# CONFIG_R3964 is not set
670 656
671# 657#
672# Ftape, the floppy tape device driver 658# PCI GPIO expanders:
673# 659#
674# CONFIG_DRM is not set
675 660
676# 661#
677# PCMCIA character devices 662# SPI GPIO expanders:
678# 663#
679# CONFIG_SYNCLINK_CS is not set 664# CONFIG_W1 is not set
680# CONFIG_RAW_DRIVER is not set 665# CONFIG_POWER_SUPPLY is not set
666# CONFIG_HWMON is not set
667# CONFIG_WATCHDOG is not set
681 668
682# 669#
683# TPM devices 670# Sonics Silicon Backplane
684# 671#
685# CONFIG_TCG_TPM is not set 672CONFIG_SSB_POSSIBLE=y
673# CONFIG_SSB is not set
686 674
687# 675#
688# I2C support 676# Multifunction device drivers
689# 677#
690# CONFIG_I2C is not set 678# CONFIG_MFD_CORE is not set
679# CONFIG_MFD_SM501 is not set
680# CONFIG_HTC_EGPIO is not set
681# CONFIG_HTC_PASIC3 is not set
682# CONFIG_MFD_TMIO is not set
683# CONFIG_MFD_T7L66XB is not set
684# CONFIG_MFD_TC6387XB is not set
685# CONFIG_MFD_TC6393XB is not set
691 686
692# 687#
693# Misc devices 688# Multimedia Capabilities Port drivers
694# 689#
690# CONFIG_MCP_SA11X0 is not set
695 691
696# 692#
697# Multimedia devices 693# Multimedia devices
698# 694#
695
696#
697# Multimedia core support
698#
699# CONFIG_VIDEO_DEV is not set 699# CONFIG_VIDEO_DEV is not set
700# CONFIG_DVB_CORE is not set
701# CONFIG_VIDEO_MEDIA is not set
700 702
701# 703#
702# Digital Video Broadcasting Devices 704# Multimedia drivers
703# 705#
704# CONFIG_DVB is not set 706# CONFIG_DAB is not set
705 707
706# 708#
707# Graphics support 709# Graphics support
708# 710#
711# CONFIG_VGASTATE is not set
712# CONFIG_VIDEO_OUTPUT_CONTROL is not set
709CONFIG_FB=y 713CONFIG_FB=y
710# CONFIG_FB_CFB_FILLRECT is not set 714# CONFIG_FIRMWARE_EDID is not set
711# CONFIG_FB_CFB_COPYAREA is not set 715# CONFIG_FB_DDC is not set
712# CONFIG_FB_CFB_IMAGEBLIT is not set 716CONFIG_FB_CFB_FILLRECT=y
713# CONFIG_FB_SOFT_CURSOR is not set 717CONFIG_FB_CFB_COPYAREA=y
718CONFIG_FB_CFB_IMAGEBLIT=y
719# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
720# CONFIG_FB_SYS_FILLRECT is not set
721# CONFIG_FB_SYS_COPYAREA is not set
722# CONFIG_FB_SYS_IMAGEBLIT is not set
723# CONFIG_FB_FOREIGN_ENDIAN is not set
724# CONFIG_FB_SYS_FOPS is not set
725# CONFIG_FB_SVGALIB is not set
726# CONFIG_FB_MACMODES is not set
727# CONFIG_FB_BACKLIGHT is not set
714# CONFIG_FB_MODE_HELPERS is not set 728# CONFIG_FB_MODE_HELPERS is not set
715# CONFIG_FB_TILEBLITTING is not set 729# CONFIG_FB_TILEBLITTING is not set
730
731#
732# Frame buffer hardware drivers
733#
716# CONFIG_FB_SA1100 is not set 734# CONFIG_FB_SA1100 is not set
735CONFIG_FB_S1D13XXX=y
717# CONFIG_FB_VIRTUAL is not set 736# CONFIG_FB_VIRTUAL is not set
737# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
738
739#
740# Display device support
741#
742# CONFIG_DISPLAY_SUPPORT is not set
718 743
719# 744#
720# Console display driver support 745# Console display driver support
@@ -722,94 +747,110 @@ CONFIG_FB=y
722# CONFIG_VGA_CONSOLE is not set 747# CONFIG_VGA_CONSOLE is not set
723# CONFIG_MDA_CONSOLE is not set 748# CONFIG_MDA_CONSOLE is not set
724CONFIG_DUMMY_CONSOLE=y 749CONFIG_DUMMY_CONSOLE=y
725# CONFIG_FRAMEBUFFER_CONSOLE is not set 750CONFIG_FRAMEBUFFER_CONSOLE=y
726 751CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
727# 752# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
728# Logo configuration 753# CONFIG_FONTS is not set
729# 754CONFIG_FONT_8x8=y
755CONFIG_FONT_8x16=y
730# CONFIG_LOGO is not set 756# CONFIG_LOGO is not set
731# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 757# CONFIG_SOUND is not set
732 758# CONFIG_HID_SUPPORT is not set
733# 759# CONFIG_USB_SUPPORT is not set
734# Sound 760# CONFIG_MMC is not set
735# 761# CONFIG_NEW_LEDS is not set
736CONFIG_SOUND=m 762CONFIG_RTC_LIB=y
763CONFIG_RTC_CLASS=y
764CONFIG_RTC_HCTOSYS=y
765CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
766# CONFIG_RTC_DEBUG is not set
737 767
738# 768#
739# Advanced Linux Sound Architecture 769# RTC interfaces
740# 770#
741# CONFIG_SND is not set 771CONFIG_RTC_INTF_SYSFS=y
772CONFIG_RTC_INTF_PROC=y
773CONFIG_RTC_INTF_DEV=y
774# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
775# CONFIG_RTC_DRV_TEST is not set
742 776
743# 777#
744# Open Sound System 778# SPI RTC drivers
745# 779#
746# CONFIG_SOUND_PRIME is not set
747 780
748# 781#
749# USB support 782# Platform RTC drivers
750# 783#
751CONFIG_USB_ARCH_HAS_HCD=y 784# CONFIG_RTC_DRV_CMOS is not set
752CONFIG_USB_ARCH_HAS_OHCI=y 785# CONFIG_RTC_DRV_DS1511 is not set
753# CONFIG_USB is not set 786# CONFIG_RTC_DRV_DS1553 is not set
787# CONFIG_RTC_DRV_DS1742 is not set
788# CONFIG_RTC_DRV_STK17TA8 is not set
789# CONFIG_RTC_DRV_M48T86 is not set
790# CONFIG_RTC_DRV_M48T59 is not set
791# CONFIG_RTC_DRV_V3020 is not set
754 792
755# 793#
756# USB Gadget Support 794# on-CPU RTC drivers
757# 795#
758# CONFIG_USB_GADGET is not set 796CONFIG_RTC_DRV_SA1100=y
797# CONFIG_DMADEVICES is not set
759 798
760# 799#
761# MMC/SD Card support 800# Voltage and Current regulators
762# 801#
763# CONFIG_MMC is not set 802# CONFIG_REGULATOR is not set
803# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
804# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
805# CONFIG_REGULATOR_BQ24022 is not set
806# CONFIG_UIO is not set
764 807
765# 808#
766# File systems 809# File systems
767# 810#
768CONFIG_EXT2_FS=y 811CONFIG_EXT2_FS=y
769# CONFIG_EXT2_FS_XATTR is not set 812# CONFIG_EXT2_FS_XATTR is not set
813# CONFIG_EXT2_FS_XIP is not set
770# CONFIG_EXT3_FS is not set 814# CONFIG_EXT3_FS is not set
771# CONFIG_JBD is not set 815# CONFIG_EXT4DEV_FS is not set
772# CONFIG_REISERFS_FS is not set 816# CONFIG_REISERFS_FS is not set
773# CONFIG_JFS_FS is not set 817# CONFIG_JFS_FS is not set
774 818# CONFIG_FS_POSIX_ACL is not set
775#
776# XFS support
777#
778# CONFIG_XFS_FS is not set 819# CONFIG_XFS_FS is not set
779# CONFIG_MINIX_FS is not set 820# CONFIG_OCFS2_FS is not set
780# CONFIG_ROMFS_FS is not set
781# CONFIG_QUOTA is not set
782CONFIG_DNOTIFY=y 821CONFIG_DNOTIFY=y
822CONFIG_INOTIFY=y
823CONFIG_INOTIFY_USER=y
824# CONFIG_QUOTA is not set
783# CONFIG_AUTOFS_FS is not set 825# CONFIG_AUTOFS_FS is not set
784# CONFIG_AUTOFS4_FS is not set 826# CONFIG_AUTOFS4_FS is not set
827# CONFIG_FUSE_FS is not set
785 828
786# 829#
787# CD-ROM/DVD Filesystems 830# CD-ROM/DVD Filesystems
788# 831#
789CONFIG_ISO9660_FS=m 832# CONFIG_ISO9660_FS is not set
790# CONFIG_JOLIET is not set
791# CONFIG_ZISOFS is not set
792# CONFIG_UDF_FS is not set 833# CONFIG_UDF_FS is not set
793 834
794# 835#
795# DOS/FAT/NT Filesystems 836# DOS/FAT/NT Filesystems
796# 837#
797# CONFIG_MSDOS_FS is not set 838CONFIG_FAT_FS=y
798# CONFIG_VFAT_FS is not set 839CONFIG_MSDOS_FS=y
840CONFIG_VFAT_FS=y
841CONFIG_FAT_DEFAULT_CODEPAGE=437
842CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
799# CONFIG_NTFS_FS is not set 843# CONFIG_NTFS_FS is not set
800 844
801# 845#
802# Pseudo filesystems 846# Pseudo filesystems
803# 847#
804CONFIG_PROC_FS=y 848CONFIG_PROC_FS=y
849CONFIG_PROC_SYSCTL=y
805CONFIG_SYSFS=y 850CONFIG_SYSFS=y
806CONFIG_DEVFS_FS=y
807CONFIG_DEVFS_MOUNT=y
808CONFIG_DEVFS_DEBUG=y
809# CONFIG_DEVPTS_FS_XATTR is not set
810# CONFIG_TMPFS is not set 851# CONFIG_TMPFS is not set
811# CONFIG_HUGETLB_PAGE is not set 852# CONFIG_HUGETLB_PAGE is not set
812CONFIG_RAMFS=y 853# CONFIG_CONFIGFS_FS is not set
813 854
814# 855#
815# Miscellaneous filesystems 856# Miscellaneous filesystems
@@ -821,75 +862,122 @@ CONFIG_RAMFS=y
821# CONFIG_BEFS_FS is not set 862# CONFIG_BEFS_FS is not set
822# CONFIG_BFS_FS is not set 863# CONFIG_BFS_FS is not set
823# CONFIG_EFS_FS is not set 864# CONFIG_EFS_FS is not set
824# CONFIG_JFFS_FS is not set
825CONFIG_JFFS2_FS=y
826CONFIG_JFFS2_FS_DEBUG=2
827# CONFIG_JFFS2_FS_NAND is not set
828# CONFIG_JFFS2_FS_NOR_ECC is not set
829# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
830CONFIG_JFFS2_ZLIB=y
831CONFIG_JFFS2_RTIME=y
832# CONFIG_JFFS2_RUBIN is not set
833# CONFIG_CRAMFS is not set 865# CONFIG_CRAMFS is not set
834# CONFIG_VXFS_FS is not set 866# CONFIG_VXFS_FS is not set
867# CONFIG_MINIX_FS is not set
868# CONFIG_OMFS_FS is not set
835# CONFIG_HPFS_FS is not set 869# CONFIG_HPFS_FS is not set
836# CONFIG_QNX4FS_FS is not set 870# CONFIG_QNX4FS_FS is not set
871# CONFIG_ROMFS_FS is not set
837# CONFIG_SYSV_FS is not set 872# CONFIG_SYSV_FS is not set
838# CONFIG_UFS_FS is not set 873# CONFIG_UFS_FS is not set
839 874# CONFIG_NETWORK_FILESYSTEMS is not set
840#
841# Network File Systems
842#
843CONFIG_NFS_FS=m
844CONFIG_NFS_V3=y
845# CONFIG_NFS_V4 is not set
846# CONFIG_NFS_DIRECTIO is not set
847# CONFIG_NFSD is not set
848CONFIG_LOCKD=m
849CONFIG_LOCKD_V4=y
850CONFIG_SUNRPC=m
851# CONFIG_RPCSEC_GSS_KRB5 is not set
852# CONFIG_RPCSEC_GSS_SPKM3 is not set
853# CONFIG_SMB_FS is not set
854# CONFIG_CIFS is not set
855# CONFIG_NCP_FS is not set
856# CONFIG_CODA_FS is not set
857# CONFIG_AFS_FS is not set
858 875
859# 876#
860# Partition Types 877# Partition Types
861# 878#
862# CONFIG_PARTITION_ADVANCED is not set 879# CONFIG_PARTITION_ADVANCED is not set
863CONFIG_MSDOS_PARTITION=y 880CONFIG_MSDOS_PARTITION=y
864 881CONFIG_NLS=y
865# 882CONFIG_NLS_DEFAULT="iso8859-1"
866# Native Language Support 883CONFIG_NLS_CODEPAGE_437=m
867# 884CONFIG_NLS_CODEPAGE_737=m
868# CONFIG_NLS is not set 885CONFIG_NLS_CODEPAGE_775=m
869 886CONFIG_NLS_CODEPAGE_850=m
870# 887CONFIG_NLS_CODEPAGE_852=m
871# Profiling support 888CONFIG_NLS_CODEPAGE_855=m
872# 889CONFIG_NLS_CODEPAGE_857=m
873# CONFIG_PROFILING is not set 890CONFIG_NLS_CODEPAGE_860=m
891CONFIG_NLS_CODEPAGE_861=m
892CONFIG_NLS_CODEPAGE_862=m
893CONFIG_NLS_CODEPAGE_863=m
894CONFIG_NLS_CODEPAGE_864=m
895CONFIG_NLS_CODEPAGE_865=m
896CONFIG_NLS_CODEPAGE_866=m
897CONFIG_NLS_CODEPAGE_869=m
898CONFIG_NLS_CODEPAGE_936=m
899CONFIG_NLS_CODEPAGE_950=m
900CONFIG_NLS_CODEPAGE_932=m
901CONFIG_NLS_CODEPAGE_949=m
902CONFIG_NLS_CODEPAGE_874=m
903CONFIG_NLS_ISO8859_8=m
904CONFIG_NLS_CODEPAGE_1250=m
905CONFIG_NLS_CODEPAGE_1251=m
906CONFIG_NLS_ASCII=m
907CONFIG_NLS_ISO8859_1=m
908CONFIG_NLS_ISO8859_2=m
909CONFIG_NLS_ISO8859_3=m
910CONFIG_NLS_ISO8859_4=m
911CONFIG_NLS_ISO8859_5=m
912CONFIG_NLS_ISO8859_6=m
913CONFIG_NLS_ISO8859_7=m
914CONFIG_NLS_ISO8859_9=m
915CONFIG_NLS_ISO8859_13=m
916CONFIG_NLS_ISO8859_14=m
917CONFIG_NLS_ISO8859_15=m
918CONFIG_NLS_KOI8_R=m
919CONFIG_NLS_KOI8_U=m
920CONFIG_NLS_UTF8=m
921# CONFIG_DLM is not set
874 922
875# 923#
876# Kernel hacking 924# Kernel hacking
877# 925#
878# CONFIG_PRINTK_TIME is not set 926# CONFIG_PRINTK_TIME is not set
879CONFIG_DEBUG_KERNEL=y 927CONFIG_ENABLE_WARN_DEPRECATED=y
928CONFIG_ENABLE_MUST_CHECK=y
929CONFIG_FRAME_WARN=1024
880# CONFIG_MAGIC_SYSRQ is not set 930# CONFIG_MAGIC_SYSRQ is not set
881CONFIG_LOG_BUF_SHIFT=14 931# CONFIG_UNUSED_SYMBOLS is not set
932# CONFIG_DEBUG_FS is not set
933# CONFIG_HEADERS_CHECK is not set
934CONFIG_DEBUG_KERNEL=y
935# CONFIG_DEBUG_SHIRQ is not set
936CONFIG_DETECT_SOFTLOCKUP=y
937# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
938CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
939CONFIG_SCHED_DEBUG=y
882# CONFIG_SCHEDSTATS is not set 940# CONFIG_SCHEDSTATS is not set
883CONFIG_DEBUG_SLAB=y 941# CONFIG_TIMER_STATS is not set
942# CONFIG_DEBUG_OBJECTS is not set
943# CONFIG_SLUB_DEBUG_ON is not set
944# CONFIG_SLUB_STATS is not set
945# CONFIG_DEBUG_RT_MUTEXES is not set
946# CONFIG_RT_MUTEX_TESTER is not set
884# CONFIG_DEBUG_SPINLOCK is not set 947# CONFIG_DEBUG_SPINLOCK is not set
948# CONFIG_DEBUG_MUTEXES is not set
949# CONFIG_DEBUG_LOCK_ALLOC is not set
950# CONFIG_PROVE_LOCKING is not set
951# CONFIG_LOCK_STAT is not set
885# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 952# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
953# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
886# CONFIG_DEBUG_KOBJECT is not set 954# CONFIG_DEBUG_KOBJECT is not set
887CONFIG_DEBUG_BUGVERBOSE=y 955CONFIG_DEBUG_BUGVERBOSE=y
888# CONFIG_DEBUG_INFO is not set 956# CONFIG_DEBUG_INFO is not set
889# CONFIG_DEBUG_FS is not set 957# CONFIG_DEBUG_VM is not set
958# CONFIG_DEBUG_WRITECOUNT is not set
959CONFIG_DEBUG_MEMORY_INIT=y
960# CONFIG_DEBUG_LIST is not set
961# CONFIG_DEBUG_SG is not set
890CONFIG_FRAME_POINTER=y 962CONFIG_FRAME_POINTER=y
963# CONFIG_BOOT_PRINTK_DELAY is not set
964# CONFIG_RCU_TORTURE_TEST is not set
965# CONFIG_BACKTRACE_SELF_TEST is not set
966# CONFIG_FAULT_INJECTION is not set
967# CONFIG_LATENCYTOP is not set
968# CONFIG_SYSCTL_SYSCALL_CHECK is not set
969CONFIG_HAVE_FTRACE=y
970CONFIG_HAVE_DYNAMIC_FTRACE=y
971# CONFIG_FTRACE is not set
972# CONFIG_IRQSOFF_TRACER is not set
973# CONFIG_SCHED_TRACER is not set
974# CONFIG_CONTEXT_SWITCH_TRACER is not set
975# CONFIG_SAMPLES is not set
976CONFIG_HAVE_ARCH_KGDB=y
977# CONFIG_KGDB is not set
891# CONFIG_DEBUG_USER is not set 978# CONFIG_DEBUG_USER is not set
892CONFIG_DEBUG_ERRORS=y 979CONFIG_DEBUG_ERRORS=y
980# CONFIG_DEBUG_STACK_USAGE is not set
893CONFIG_DEBUG_LL=y 981CONFIG_DEBUG_LL=y
894# CONFIG_DEBUG_ICEDCC is not set 982# CONFIG_DEBUG_ICEDCC is not set
895 983
@@ -898,21 +986,100 @@ CONFIG_DEBUG_LL=y
898# 986#
899# CONFIG_KEYS is not set 987# CONFIG_KEYS is not set
900# CONFIG_SECURITY is not set 988# CONFIG_SECURITY is not set
989# CONFIG_SECURITY_FILE_CAPABILITIES is not set
990CONFIG_CRYPTO=y
991
992#
993# Crypto core or helper
994#
995# CONFIG_CRYPTO_MANAGER is not set
996# CONFIG_CRYPTO_GF128MUL is not set
997# CONFIG_CRYPTO_NULL is not set
998# CONFIG_CRYPTO_CRYPTD is not set
999# CONFIG_CRYPTO_AUTHENC is not set
1000# CONFIG_CRYPTO_TEST is not set
1001
1002#
1003# Authenticated Encryption with Associated Data
1004#
1005# CONFIG_CRYPTO_CCM is not set
1006# CONFIG_CRYPTO_GCM is not set
1007# CONFIG_CRYPTO_SEQIV is not set
1008
1009#
1010# Block modes
1011#
1012# CONFIG_CRYPTO_CBC is not set
1013# CONFIG_CRYPTO_CTR is not set
1014# CONFIG_CRYPTO_CTS is not set
1015# CONFIG_CRYPTO_ECB is not set
1016# CONFIG_CRYPTO_LRW is not set
1017# CONFIG_CRYPTO_PCBC is not set
1018# CONFIG_CRYPTO_XTS is not set
1019
1020#
1021# Hash modes
1022#
1023# CONFIG_CRYPTO_HMAC is not set
1024# CONFIG_CRYPTO_XCBC is not set
1025
1026#
1027# Digest
1028#
1029# CONFIG_CRYPTO_CRC32C is not set
1030# CONFIG_CRYPTO_MD4 is not set
1031# CONFIG_CRYPTO_MD5 is not set
1032# CONFIG_CRYPTO_MICHAEL_MIC is not set
1033# CONFIG_CRYPTO_RMD128 is not set
1034# CONFIG_CRYPTO_RMD160 is not set
1035# CONFIG_CRYPTO_RMD256 is not set
1036# CONFIG_CRYPTO_RMD320 is not set
1037# CONFIG_CRYPTO_SHA1 is not set
1038# CONFIG_CRYPTO_SHA256 is not set
1039# CONFIG_CRYPTO_SHA512 is not set
1040# CONFIG_CRYPTO_TGR192 is not set
1041# CONFIG_CRYPTO_WP512 is not set
901 1042
902# 1043#
903# Cryptographic options 1044# Ciphers
904# 1045#
905# CONFIG_CRYPTO is not set 1046# CONFIG_CRYPTO_AES is not set
1047# CONFIG_CRYPTO_ANUBIS is not set
1048# CONFIG_CRYPTO_ARC4 is not set
1049# CONFIG_CRYPTO_BLOWFISH is not set
1050# CONFIG_CRYPTO_CAMELLIA is not set
1051# CONFIG_CRYPTO_CAST5 is not set
1052# CONFIG_CRYPTO_CAST6 is not set
1053# CONFIG_CRYPTO_DES is not set
1054# CONFIG_CRYPTO_FCRYPT is not set
1055# CONFIG_CRYPTO_KHAZAD is not set
1056# CONFIG_CRYPTO_SALSA20 is not set
1057# CONFIG_CRYPTO_SEED is not set
1058# CONFIG_CRYPTO_SERPENT is not set
1059# CONFIG_CRYPTO_TEA is not set
1060# CONFIG_CRYPTO_TWOFISH is not set
906 1061
907# 1062#
908# Hardware crypto devices 1063# Compression
909# 1064#
1065# CONFIG_CRYPTO_DEFLATE is not set
1066# CONFIG_CRYPTO_LZO is not set
1067CONFIG_CRYPTO_HW=y
910 1068
911# 1069#
912# Library routines 1070# Library routines
913# 1071#
1072CONFIG_BITREVERSE=y
1073# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1074# CONFIG_GENERIC_FIND_NEXT_BIT is not set
914CONFIG_CRC_CCITT=m 1075CONFIG_CRC_CCITT=m
1076# CONFIG_CRC16 is not set
1077# CONFIG_CRC_T10DIF is not set
1078# CONFIG_CRC_ITU_T is not set
915CONFIG_CRC32=y 1079CONFIG_CRC32=y
1080# CONFIG_CRC7 is not set
916# CONFIG_LIBCRC32C is not set 1081# CONFIG_LIBCRC32C is not set
917CONFIG_ZLIB_INFLATE=y 1082CONFIG_PLIST=y
918CONFIG_ZLIB_DEFLATE=y 1083CONFIG_HAS_IOMEM=y
1084CONFIG_HAS_IOPORT=y
1085CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/orion5x_defconfig b/arch/arm/configs/orion5x_defconfig
index 4017d83c9d2d..b2456ca544c9 100644
--- a/arch/arm/configs/orion5x_defconfig
+++ b/arch/arm/configs/orion5x_defconfig
@@ -176,14 +176,17 @@ CONFIG_MACH_KUROBOX_PRO=y
176CONFIG_MACH_DNS323=y 176CONFIG_MACH_DNS323=y
177CONFIG_MACH_TS209=y 177CONFIG_MACH_TS209=y
178CONFIG_MACH_LINKSTATION_PRO=y 178CONFIG_MACH_LINKSTATION_PRO=y
179CONFIG_MACH_LINKSTATION_MINI=y
179CONFIG_MACH_TS409=y 180CONFIG_MACH_TS409=y
180CONFIG_MACH_WRT350N_V2=y 181CONFIG_MACH_WRT350N_V2=y
181CONFIG_MACH_TS78XX=y 182CONFIG_MACH_TS78XX=y
182CONFIG_MACH_MV2120=y 183CONFIG_MACH_MV2120=y
184CONFIG_MACH_EDMINI_V2=y
183CONFIG_MACH_MSS2=y 185CONFIG_MACH_MSS2=y
184CONFIG_MACH_WNR854T=y 186CONFIG_MACH_WNR854T=y
185CONFIG_MACH_RD88F5181L_GE=y 187CONFIG_MACH_RD88F5181L_GE=y
186CONFIG_MACH_RD88F5181L_FXO=y 188CONFIG_MACH_RD88F5181L_FXO=y
189CONFIG_MACH_RD88F6183AP_GE=y
187 190
188# 191#
189# Boot options 192# Boot options
diff --git a/arch/arm/configs/palmz72_defconfig b/arch/arm/configs/palmz72_defconfig
new file mode 100644
index 000000000000..3245f8f33e0a
--- /dev/null
+++ b/arch/arm/configs/palmz72_defconfig
@@ -0,0 +1,951 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc4
4# Sun Aug 24 02:29:27 2008
5#
6CONFIG_ARM=y
7CONFIG_HAVE_PWM=y
8CONFIG_SYS_SUPPORTS_APM_EMULATION=y
9CONFIG_GENERIC_GPIO=y
10CONFIG_GENERIC_TIME=y
11CONFIG_GENERIC_CLOCKEVENTS=y
12CONFIG_MMU=y
13# CONFIG_NO_IOPORT is not set
14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_STACKTRACE_SUPPORT=y
16CONFIG_HAVE_LATENCYTOP_SUPPORT=y
17CONFIG_LOCKDEP_SUPPORT=y
18CONFIG_TRACE_IRQFLAGS_SUPPORT=y
19CONFIG_HARDIRQS_SW_RESEND=y
20CONFIG_GENERIC_IRQ_PROBE=y
21CONFIG_RWSEM_GENERIC_SPINLOCK=y
22# CONFIG_ARCH_HAS_ILOG2_U32 is not set
23# CONFIG_ARCH_HAS_ILOG2_U64 is not set
24CONFIG_GENERIC_HWEIGHT=y
25CONFIG_GENERIC_CALIBRATE_DELAY=y
26CONFIG_ARCH_SUPPORTS_AOUT=y
27CONFIG_ZONE_DMA=y
28CONFIG_ARCH_MTD_XIP=y
29CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
30CONFIG_VECTORS_BASE=0xffff0000
31CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
32
33#
34# General setup
35#
36CONFIG_EXPERIMENTAL=y
37CONFIG_BROKEN_ON_SMP=y
38CONFIG_LOCK_KERNEL=y
39CONFIG_INIT_ENV_ARG_LIMIT=32
40CONFIG_LOCALVERSION=""
41# CONFIG_LOCALVERSION_AUTO is not set
42CONFIG_SWAP=y
43CONFIG_SYSVIPC=y
44CONFIG_SYSVIPC_SYSCTL=y
45# CONFIG_POSIX_MQUEUE is not set
46# CONFIG_BSD_PROCESS_ACCT is not set
47# CONFIG_TASKSTATS is not set
48# CONFIG_AUDIT is not set
49# CONFIG_IKCONFIG is not set
50CONFIG_LOG_BUF_SHIFT=14
51# CONFIG_CGROUPS is not set
52# CONFIG_GROUP_SCHED is not set
53CONFIG_SYSFS_DEPRECATED=y
54CONFIG_SYSFS_DEPRECATED_V2=y
55# CONFIG_RELAY is not set
56CONFIG_NAMESPACES=y
57# CONFIG_UTS_NS is not set
58# CONFIG_IPC_NS is not set
59# CONFIG_USER_NS is not set
60# CONFIG_PID_NS is not set
61CONFIG_BLK_DEV_INITRD=y
62CONFIG_INITRAMFS_SOURCE=""
63CONFIG_CC_OPTIMIZE_FOR_SIZE=y
64CONFIG_SYSCTL=y
65# CONFIG_EMBEDDED is not set
66CONFIG_UID16=y
67CONFIG_SYSCTL_SYSCALL=y
68CONFIG_KALLSYMS=y
69# CONFIG_KALLSYMS_EXTRA_PASS is not set
70CONFIG_HOTPLUG=y
71CONFIG_PRINTK=y
72CONFIG_BUG=y
73CONFIG_ELF_CORE=y
74CONFIG_COMPAT_BRK=y
75CONFIG_BASE_FULL=y
76CONFIG_FUTEX=y
77CONFIG_ANON_INODES=y
78CONFIG_EPOLL=y
79CONFIG_SIGNALFD=y
80CONFIG_TIMERFD=y
81CONFIG_EVENTFD=y
82CONFIG_SHMEM=y
83CONFIG_VM_EVENT_COUNTERS=y
84CONFIG_SLAB=y
85# CONFIG_SLUB is not set
86# CONFIG_SLOB is not set
87# CONFIG_PROFILING is not set
88# CONFIG_MARKERS is not set
89CONFIG_HAVE_OPROFILE=y
90# CONFIG_KPROBES is not set
91# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
92# CONFIG_HAVE_IOREMAP_PROT is not set
93CONFIG_HAVE_KPROBES=y
94CONFIG_HAVE_KRETPROBES=y
95# CONFIG_HAVE_ARCH_TRACEHOOK is not set
96# CONFIG_HAVE_DMA_ATTRS is not set
97# CONFIG_USE_GENERIC_SMP_HELPERS is not set
98CONFIG_HAVE_CLK=y
99CONFIG_PROC_PAGE_MONITOR=y
100CONFIG_HAVE_GENERIC_DMA_COHERENT=y
101CONFIG_SLABINFO=y
102CONFIG_RT_MUTEXES=y
103# CONFIG_TINY_SHMEM is not set
104CONFIG_BASE_SMALL=0
105CONFIG_MODULES=y
106# CONFIG_MODULE_FORCE_LOAD is not set
107CONFIG_MODULE_UNLOAD=y
108# CONFIG_MODULE_FORCE_UNLOAD is not set
109# CONFIG_MODVERSIONS is not set
110# CONFIG_MODULE_SRCVERSION_ALL is not set
111CONFIG_KMOD=y
112CONFIG_BLOCK=y
113# CONFIG_LBD is not set
114# CONFIG_BLK_DEV_IO_TRACE is not set
115# CONFIG_LSF is not set
116# CONFIG_BLK_DEV_BSG is not set
117# CONFIG_BLK_DEV_INTEGRITY is not set
118
119#
120# IO Schedulers
121#
122CONFIG_IOSCHED_NOOP=y
123CONFIG_IOSCHED_AS=y
124# CONFIG_IOSCHED_DEADLINE is not set
125# CONFIG_IOSCHED_CFQ is not set
126CONFIG_DEFAULT_AS=y
127# CONFIG_DEFAULT_DEADLINE is not set
128# CONFIG_DEFAULT_CFQ is not set
129# CONFIG_DEFAULT_NOOP is not set
130CONFIG_DEFAULT_IOSCHED="anticipatory"
131CONFIG_CLASSIC_RCU=y
132
133#
134# System Type
135#
136# CONFIG_ARCH_AAEC2000 is not set
137# CONFIG_ARCH_INTEGRATOR is not set
138# CONFIG_ARCH_REALVIEW is not set
139# CONFIG_ARCH_VERSATILE is not set
140# CONFIG_ARCH_AT91 is not set
141# CONFIG_ARCH_CLPS7500 is not set
142# CONFIG_ARCH_CLPS711X is not set
143# CONFIG_ARCH_EBSA110 is not set
144# CONFIG_ARCH_EP93XX is not set
145# CONFIG_ARCH_FOOTBRIDGE is not set
146# CONFIG_ARCH_NETX is not set
147# CONFIG_ARCH_H720X is not set
148# CONFIG_ARCH_IMX is not set
149# CONFIG_ARCH_IOP13XX is not set
150# CONFIG_ARCH_IOP32X is not set
151# CONFIG_ARCH_IOP33X is not set
152# CONFIG_ARCH_IXP23XX is not set
153# CONFIG_ARCH_IXP2000 is not set
154# CONFIG_ARCH_IXP4XX is not set
155# CONFIG_ARCH_L7200 is not set
156# CONFIG_ARCH_KIRKWOOD is not set
157# CONFIG_ARCH_KS8695 is not set
158# CONFIG_ARCH_NS9XXX is not set
159# CONFIG_ARCH_LOKI is not set
160# CONFIG_ARCH_MV78XX0 is not set
161# CONFIG_ARCH_MXC is not set
162# CONFIG_ARCH_ORION5X is not set
163# CONFIG_ARCH_PNX4008 is not set
164CONFIG_ARCH_PXA=y
165# CONFIG_ARCH_RPC is not set
166# CONFIG_ARCH_SA1100 is not set
167# CONFIG_ARCH_S3C2410 is not set
168# CONFIG_ARCH_SHARK is not set
169# CONFIG_ARCH_LH7A40X is not set
170# CONFIG_ARCH_DAVINCI is not set
171# CONFIG_ARCH_OMAP is not set
172# CONFIG_ARCH_MSM7X00A is not set
173
174#
175# Intel PXA2xx/PXA3xx Implementations
176#
177# CONFIG_ARCH_GUMSTIX is not set
178# CONFIG_ARCH_LUBBOCK is not set
179# CONFIG_MACH_LOGICPD_PXA270 is not set
180# CONFIG_MACH_MAINSTONE is not set
181# CONFIG_ARCH_PXA_IDP is not set
182# CONFIG_PXA_SHARPSL is not set
183# CONFIG_ARCH_PXA_ESERIES is not set
184# CONFIG_MACH_TRIZEPS4 is not set
185# CONFIG_MACH_EM_X270 is not set
186# CONFIG_MACH_COLIBRI is not set
187# CONFIG_MACH_ZYLONITE is not set
188# CONFIG_MACH_LITTLETON is not set
189# CONFIG_MACH_TAVOREVB is not set
190# CONFIG_MACH_SAAR is not set
191# CONFIG_MACH_ARMCORE is not set
192# CONFIG_MACH_MAGICIAN is not set
193# CONFIG_MACH_PCM027 is not set
194CONFIG_ARCH_PXA_PALM=y
195# CONFIG_MACH_PALMTX is not set
196CONFIG_MACH_PALMZ72=y
197# CONFIG_PXA_EZX is not set
198CONFIG_PXA27x=y
199CONFIG_PXA_PWM=y
200
201#
202# Boot options
203#
204
205#
206# Power management
207#
208
209#
210# Processor Type
211#
212CONFIG_CPU_32=y
213CONFIG_CPU_XSCALE=y
214CONFIG_CPU_32v5=y
215CONFIG_CPU_ABRT_EV5T=y
216CONFIG_CPU_PABRT_NOIFAR=y
217CONFIG_CPU_CACHE_VIVT=y
218CONFIG_CPU_TLB_V4WBI=y
219CONFIG_CPU_CP15=y
220CONFIG_CPU_CP15_MMU=y
221
222#
223# Processor Features
224#
225CONFIG_ARM_THUMB=y
226# CONFIG_CPU_DCACHE_DISABLE is not set
227# CONFIG_OUTER_CACHE is not set
228CONFIG_IWMMXT=y
229CONFIG_XSCALE_PMU=y
230
231#
232# Bus support
233#
234# CONFIG_PCI_SYSCALL is not set
235# CONFIG_ARCH_SUPPORTS_MSI is not set
236# CONFIG_PCCARD is not set
237
238#
239# Kernel Features
240#
241CONFIG_TICK_ONESHOT=y
242# CONFIG_NO_HZ is not set
243# CONFIG_HIGH_RES_TIMERS is not set
244CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
245CONFIG_PREEMPT=y
246CONFIG_HZ=100
247CONFIG_AEABI=y
248CONFIG_OABI_COMPAT=y
249# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
250CONFIG_SELECT_MEMORY_MODEL=y
251CONFIG_FLATMEM_MANUAL=y
252# CONFIG_DISCONTIGMEM_MANUAL is not set
253# CONFIG_SPARSEMEM_MANUAL is not set
254CONFIG_FLATMEM=y
255CONFIG_FLAT_NODE_MEM_MAP=y
256# CONFIG_SPARSEMEM_STATIC is not set
257# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
258CONFIG_PAGEFLAGS_EXTENDED=y
259CONFIG_SPLIT_PTLOCK_CPUS=4096
260# CONFIG_RESOURCES_64BIT is not set
261CONFIG_ZONE_DMA_FLAG=1
262CONFIG_BOUNCE=y
263CONFIG_VIRT_TO_BUS=y
264CONFIG_ALIGNMENT_TRAP=y
265
266#
267# Boot options
268#
269CONFIG_ZBOOT_ROM_TEXT=0x0
270CONFIG_ZBOOT_ROM_BSS=0x0
271CONFIG_CMDLINE="mem=32M console=tty root=/dev/mmcblk0"
272# CONFIG_XIP_KERNEL is not set
273# CONFIG_KEXEC is not set
274
275#
276# CPU Frequency scaling
277#
278# CONFIG_CPU_FREQ is not set
279
280#
281# Floating point emulation
282#
283
284#
285# At least one emulation must be selected
286#
287CONFIG_FPE_NWFPE=y
288# CONFIG_FPE_NWFPE_XP is not set
289# CONFIG_FPE_FASTFPE is not set
290
291#
292# Userspace binary formats
293#
294CONFIG_BINFMT_ELF=y
295# CONFIG_BINFMT_AOUT is not set
296# CONFIG_BINFMT_MISC is not set
297
298#
299# Power management options
300#
301CONFIG_PM=y
302# CONFIG_PM_DEBUG is not set
303CONFIG_PM_SLEEP=y
304CONFIG_SUSPEND=y
305CONFIG_SUSPEND_FREEZER=y
306CONFIG_APM_EMULATION=y
307CONFIG_ARCH_SUSPEND_POSSIBLE=y
308CONFIG_NET=y
309
310#
311# Networking options
312#
313CONFIG_PACKET=y
314# CONFIG_PACKET_MMAP is not set
315CONFIG_UNIX=y
316# CONFIG_NET_KEY is not set
317CONFIG_INET=y
318# CONFIG_IP_MULTICAST is not set
319# CONFIG_IP_ADVANCED_ROUTER is not set
320CONFIG_IP_FIB_HASH=y
321CONFIG_IP_PNP=y
322# CONFIG_IP_PNP_DHCP is not set
323CONFIG_IP_PNP_BOOTP=y
324# CONFIG_IP_PNP_RARP is not set
325# CONFIG_NET_IPIP is not set
326# CONFIG_NET_IPGRE is not set
327# CONFIG_ARPD is not set
328# CONFIG_SYN_COOKIES is not set
329# CONFIG_INET_AH is not set
330# CONFIG_INET_ESP is not set
331# CONFIG_INET_IPCOMP is not set
332# CONFIG_INET_XFRM_TUNNEL is not set
333# CONFIG_INET_TUNNEL is not set
334# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
335# CONFIG_INET_XFRM_MODE_TUNNEL is not set
336# CONFIG_INET_XFRM_MODE_BEET is not set
337# CONFIG_INET_LRO is not set
338CONFIG_INET_DIAG=y
339CONFIG_INET_TCP_DIAG=y
340# CONFIG_TCP_CONG_ADVANCED is not set
341CONFIG_TCP_CONG_CUBIC=y
342CONFIG_DEFAULT_TCP_CONG="cubic"
343# CONFIG_TCP_MD5SIG is not set
344# CONFIG_IPV6 is not set
345# CONFIG_NETWORK_SECMARK is not set
346# CONFIG_NETFILTER is not set
347# CONFIG_IP_DCCP is not set
348# CONFIG_IP_SCTP is not set
349# CONFIG_TIPC is not set
350# CONFIG_ATM is not set
351# CONFIG_BRIDGE is not set
352# CONFIG_VLAN_8021Q is not set
353# CONFIG_DECNET is not set
354# CONFIG_LLC2 is not set
355# CONFIG_IPX is not set
356# CONFIG_ATALK is not set
357# CONFIG_X25 is not set
358# CONFIG_LAPB is not set
359# CONFIG_ECONET is not set
360# CONFIG_WAN_ROUTER is not set
361# CONFIG_NET_SCHED is not set
362
363#
364# Network testing
365#
366# CONFIG_NET_PKTGEN is not set
367# CONFIG_HAMRADIO is not set
368# CONFIG_CAN is not set
369# CONFIG_IRDA is not set
370# CONFIG_BT is not set
371# CONFIG_AF_RXRPC is not set
372
373#
374# Wireless
375#
376# CONFIG_CFG80211 is not set
377# CONFIG_WIRELESS_EXT is not set
378# CONFIG_MAC80211 is not set
379# CONFIG_IEEE80211 is not set
380# CONFIG_RFKILL is not set
381# CONFIG_NET_9P is not set
382
383#
384# Device Drivers
385#
386
387#
388# Generic Driver Options
389#
390CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
391CONFIG_STANDALONE=y
392CONFIG_PREVENT_FIRMWARE_BUILD=y
393CONFIG_FW_LOADER=y
394CONFIG_FIRMWARE_IN_KERNEL=y
395CONFIG_EXTRA_FIRMWARE=""
396# CONFIG_SYS_HYPERVISOR is not set
397# CONFIG_CONNECTOR is not set
398# CONFIG_MTD is not set
399# CONFIG_PARPORT is not set
400CONFIG_BLK_DEV=y
401# CONFIG_BLK_DEV_COW_COMMON is not set
402CONFIG_BLK_DEV_LOOP=y
403# CONFIG_BLK_DEV_CRYPTOLOOP is not set
404# CONFIG_BLK_DEV_NBD is not set
405# CONFIG_BLK_DEV_RAM is not set
406# CONFIG_CDROM_PKTCDVD is not set
407# CONFIG_ATA_OVER_ETH is not set
408# CONFIG_MISC_DEVICES is not set
409CONFIG_HAVE_IDE=y
410# CONFIG_IDE is not set
411
412#
413# SCSI device support
414#
415# CONFIG_RAID_ATTRS is not set
416# CONFIG_SCSI is not set
417# CONFIG_SCSI_DMA is not set
418# CONFIG_SCSI_NETLINK is not set
419# CONFIG_ATA is not set
420# CONFIG_MD is not set
421# CONFIG_NETDEVICES is not set
422# CONFIG_ISDN is not set
423
424#
425# Input device support
426#
427CONFIG_INPUT=y
428# CONFIG_INPUT_FF_MEMLESS is not set
429# CONFIG_INPUT_POLLDEV is not set
430
431#
432# Userland interfaces
433#
434CONFIG_INPUT_MOUSEDEV=y
435# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
436CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
437CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
438# CONFIG_INPUT_JOYDEV is not set
439CONFIG_INPUT_EVDEV=y
440# CONFIG_INPUT_EVBUG is not set
441
442#
443# Input Device Drivers
444#
445CONFIG_INPUT_KEYBOARD=y
446# CONFIG_KEYBOARD_ATKBD is not set
447# CONFIG_KEYBOARD_SUNKBD is not set
448# CONFIG_KEYBOARD_LKKBD is not set
449# CONFIG_KEYBOARD_XTKBD is not set
450# CONFIG_KEYBOARD_NEWTON is not set
451# CONFIG_KEYBOARD_STOWAWAY is not set
452CONFIG_KEYBOARD_PXA27x=y
453# CONFIG_KEYBOARD_GPIO is not set
454# CONFIG_KEYBOARD_MATRIX is not set
455# CONFIG_INPUT_MOUSE is not set
456# CONFIG_INPUT_JOYSTICK is not set
457# CONFIG_INPUT_TABLET is not set
458# CONFIG_INPUT_TOUCHSCREEN is not set
459# CONFIG_INPUT_MISC is not set
460
461#
462# Hardware I/O ports
463#
464# CONFIG_SERIO is not set
465# CONFIG_GAMEPORT is not set
466
467#
468# Character devices
469#
470CONFIG_VT=y
471CONFIG_CONSOLE_TRANSLATIONS=y
472CONFIG_VT_CONSOLE=y
473CONFIG_HW_CONSOLE=y
474# CONFIG_VT_HW_CONSOLE_BINDING is not set
475CONFIG_DEVKMEM=y
476# CONFIG_SERIAL_NONSTANDARD is not set
477
478#
479# Serial drivers
480#
481# CONFIG_SERIAL_8250 is not set
482
483#
484# Non-8250 serial port support
485#
486# CONFIG_SERIAL_PXA is not set
487CONFIG_UNIX98_PTYS=y
488CONFIG_LEGACY_PTYS=y
489CONFIG_LEGACY_PTY_COUNT=256
490# CONFIG_IPMI_HANDLER is not set
491# CONFIG_HW_RANDOM is not set
492# CONFIG_NVRAM is not set
493# CONFIG_R3964 is not set
494# CONFIG_RAW_DRIVER is not set
495# CONFIG_TCG_TPM is not set
496CONFIG_I2C=y
497CONFIG_I2C_BOARDINFO=y
498# CONFIG_I2C_CHARDEV is not set
499CONFIG_I2C_HELPER_AUTO=y
500
501#
502# I2C Hardware Bus support
503#
504
505#
506# I2C system bus drivers (mostly embedded / system-on-chip)
507#
508# CONFIG_I2C_GPIO is not set
509# CONFIG_I2C_OCORES is not set
510CONFIG_I2C_PXA=y
511# CONFIG_I2C_PXA_SLAVE is not set
512# CONFIG_I2C_SIMTEC is not set
513
514#
515# External I2C/SMBus adapter drivers
516#
517# CONFIG_I2C_PARPORT_LIGHT is not set
518# CONFIG_I2C_TAOS_EVM is not set
519
520#
521# Other I2C/SMBus bus drivers
522#
523# CONFIG_I2C_PCA_PLATFORM is not set
524# CONFIG_I2C_STUB is not set
525
526#
527# Miscellaneous I2C Chip support
528#
529# CONFIG_DS1682 is not set
530# CONFIG_AT24 is not set
531# CONFIG_SENSORS_EEPROM is not set
532# CONFIG_SENSORS_PCF8574 is not set
533# CONFIG_PCF8575 is not set
534# CONFIG_SENSORS_PCA9539 is not set
535# CONFIG_SENSORS_PCF8591 is not set
536# CONFIG_TPS65010 is not set
537# CONFIG_SENSORS_MAX6875 is not set
538# CONFIG_SENSORS_TSL2550 is not set
539# CONFIG_I2C_DEBUG_CORE is not set
540# CONFIG_I2C_DEBUG_ALGO is not set
541# CONFIG_I2C_DEBUG_BUS is not set
542# CONFIG_I2C_DEBUG_CHIP is not set
543CONFIG_SPI=y
544CONFIG_SPI_MASTER=y
545
546#
547# SPI Master Controller Drivers
548#
549# CONFIG_SPI_BITBANG is not set
550# CONFIG_SPI_PXA2XX is not set
551
552#
553# SPI Protocol Masters
554#
555# CONFIG_SPI_AT25 is not set
556CONFIG_SPI_SPIDEV=y
557# CONFIG_SPI_TLE62X0 is not set
558CONFIG_ARCH_REQUIRE_GPIOLIB=y
559CONFIG_GPIOLIB=y
560CONFIG_GPIO_SYSFS=y
561
562#
563# I2C GPIO expanders:
564#
565# CONFIG_GPIO_MAX732X is not set
566# CONFIG_GPIO_PCA953X is not set
567# CONFIG_GPIO_PCF857X is not set
568
569#
570# PCI GPIO expanders:
571#
572
573#
574# SPI GPIO expanders:
575#
576# CONFIG_GPIO_MAX7301 is not set
577# CONFIG_GPIO_MCP23S08 is not set
578# CONFIG_W1 is not set
579CONFIG_POWER_SUPPLY=y
580# CONFIG_POWER_SUPPLY_DEBUG is not set
581CONFIG_PDA_POWER=y
582# CONFIG_APM_POWER is not set
583# CONFIG_BATTERY_DS2760 is not set
584# CONFIG_HWMON is not set
585# CONFIG_WATCHDOG is not set
586
587#
588# Sonics Silicon Backplane
589#
590CONFIG_SSB_POSSIBLE=y
591# CONFIG_SSB is not set
592
593#
594# Multifunction device drivers
595#
596# CONFIG_MFD_CORE is not set
597# CONFIG_MFD_SM501 is not set
598# CONFIG_HTC_EGPIO is not set
599# CONFIG_HTC_PASIC3 is not set
600# CONFIG_MFD_TMIO is not set
601# CONFIG_MFD_T7L66XB is not set
602# CONFIG_MFD_TC6387XB is not set
603# CONFIG_MFD_TC6393XB is not set
604
605#
606# Multimedia devices
607#
608
609#
610# Multimedia core support
611#
612# CONFIG_VIDEO_DEV is not set
613# CONFIG_DVB_CORE is not set
614# CONFIG_VIDEO_MEDIA is not set
615
616#
617# Multimedia drivers
618#
619# CONFIG_DAB is not set
620
621#
622# Graphics support
623#
624# CONFIG_VGASTATE is not set
625# CONFIG_VIDEO_OUTPUT_CONTROL is not set
626CONFIG_FB=y
627# CONFIG_FIRMWARE_EDID is not set
628# CONFIG_FB_DDC is not set
629CONFIG_FB_CFB_FILLRECT=y
630CONFIG_FB_CFB_COPYAREA=y
631CONFIG_FB_CFB_IMAGEBLIT=y
632# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
633# CONFIG_FB_SYS_FILLRECT is not set
634# CONFIG_FB_SYS_COPYAREA is not set
635# CONFIG_FB_SYS_IMAGEBLIT is not set
636# CONFIG_FB_FOREIGN_ENDIAN is not set
637# CONFIG_FB_SYS_FOPS is not set
638# CONFIG_FB_SVGALIB is not set
639# CONFIG_FB_MACMODES is not set
640# CONFIG_FB_BACKLIGHT is not set
641# CONFIG_FB_MODE_HELPERS is not set
642# CONFIG_FB_TILEBLITTING is not set
643
644#
645# Frame buffer hardware drivers
646#
647# CONFIG_FB_S1D13XXX is not set
648CONFIG_FB_PXA=y
649# CONFIG_FB_PXA_SMARTPANEL is not set
650# CONFIG_FB_PXA_PARAMETERS is not set
651# CONFIG_FB_MBX is not set
652# CONFIG_FB_W100 is not set
653# CONFIG_FB_AM200EPD is not set
654# CONFIG_FB_VIRTUAL is not set
655CONFIG_BACKLIGHT_LCD_SUPPORT=y
656# CONFIG_LCD_CLASS_DEVICE is not set
657CONFIG_BACKLIGHT_CLASS_DEVICE=y
658# CONFIG_BACKLIGHT_CORGI is not set
659CONFIG_BACKLIGHT_PWM=y
660
661#
662# Display device support
663#
664CONFIG_DISPLAY_SUPPORT=y
665
666#
667# Display hardware drivers
668#
669
670#
671# Console display driver support
672#
673# CONFIG_VGA_CONSOLE is not set
674CONFIG_DUMMY_CONSOLE=y
675CONFIG_FRAMEBUFFER_CONSOLE=y
676# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
677# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
678CONFIG_FONTS=y
679CONFIG_FONT_8x8=y
680# CONFIG_FONT_8x16 is not set
681# CONFIG_FONT_6x11 is not set
682# CONFIG_FONT_7x14 is not set
683# CONFIG_FONT_PEARL_8x8 is not set
684# CONFIG_FONT_ACORN_8x8 is not set
685# CONFIG_FONT_MINI_4x6 is not set
686# CONFIG_FONT_SUN8x16 is not set
687# CONFIG_FONT_SUN12x22 is not set
688# CONFIG_FONT_10x18 is not set
689# CONFIG_LOGO is not set
690# CONFIG_SOUND is not set
691# CONFIG_HID_SUPPORT is not set
692# CONFIG_USB_SUPPORT is not set
693CONFIG_MMC=y
694CONFIG_MMC_DEBUG=y
695# CONFIG_MMC_UNSAFE_RESUME is not set
696
697#
698# MMC/SD Card Drivers
699#
700CONFIG_MMC_BLOCK=y
701CONFIG_MMC_BLOCK_BOUNCE=y
702# CONFIG_SDIO_UART is not set
703# CONFIG_MMC_TEST is not set
704
705#
706# MMC/SD Host Controller Drivers
707#
708CONFIG_MMC_PXA=y
709# CONFIG_MMC_SDHCI is not set
710# CONFIG_MMC_SPI is not set
711# CONFIG_NEW_LEDS is not set
712CONFIG_RTC_LIB=y
713CONFIG_RTC_CLASS=y
714CONFIG_RTC_HCTOSYS=y
715CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
716# CONFIG_RTC_DEBUG is not set
717
718#
719# RTC interfaces
720#
721CONFIG_RTC_INTF_SYSFS=y
722CONFIG_RTC_INTF_PROC=y
723CONFIG_RTC_INTF_DEV=y
724# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
725# CONFIG_RTC_DRV_TEST is not set
726
727#
728# I2C RTC drivers
729#
730# CONFIG_RTC_DRV_DS1307 is not set
731# CONFIG_RTC_DRV_DS1374 is not set
732# CONFIG_RTC_DRV_DS1672 is not set
733# CONFIG_RTC_DRV_MAX6900 is not set
734# CONFIG_RTC_DRV_RS5C372 is not set
735# CONFIG_RTC_DRV_ISL1208 is not set
736# CONFIG_RTC_DRV_X1205 is not set
737# CONFIG_RTC_DRV_PCF8563 is not set
738# CONFIG_RTC_DRV_PCF8583 is not set
739# CONFIG_RTC_DRV_M41T80 is not set
740# CONFIG_RTC_DRV_S35390A is not set
741# CONFIG_RTC_DRV_FM3130 is not set
742
743#
744# SPI RTC drivers
745#
746# CONFIG_RTC_DRV_M41T94 is not set
747# CONFIG_RTC_DRV_DS1305 is not set
748# CONFIG_RTC_DRV_MAX6902 is not set
749# CONFIG_RTC_DRV_R9701 is not set
750# CONFIG_RTC_DRV_RS5C348 is not set
751
752#
753# Platform RTC drivers
754#
755# CONFIG_RTC_DRV_CMOS is not set
756# CONFIG_RTC_DRV_DS1511 is not set
757# CONFIG_RTC_DRV_DS1553 is not set
758# CONFIG_RTC_DRV_DS1742 is not set
759# CONFIG_RTC_DRV_STK17TA8 is not set
760# CONFIG_RTC_DRV_M48T86 is not set
761# CONFIG_RTC_DRV_M48T59 is not set
762# CONFIG_RTC_DRV_V3020 is not set
763
764#
765# on-CPU RTC drivers
766#
767CONFIG_RTC_DRV_SA1100=y
768# CONFIG_DMADEVICES is not set
769
770#
771# Voltage and Current regulators
772#
773# CONFIG_REGULATOR is not set
774# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
775# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
776# CONFIG_REGULATOR_BQ24022 is not set
777# CONFIG_UIO is not set
778
779#
780# File systems
781#
782CONFIG_EXT2_FS=y
783# CONFIG_EXT2_FS_XATTR is not set
784# CONFIG_EXT2_FS_XIP is not set
785CONFIG_EXT3_FS=y
786CONFIG_EXT3_FS_XATTR=y
787# CONFIG_EXT3_FS_POSIX_ACL is not set
788# CONFIG_EXT3_FS_SECURITY is not set
789# CONFIG_EXT4DEV_FS is not set
790CONFIG_JBD=y
791CONFIG_FS_MBCACHE=y
792# CONFIG_REISERFS_FS is not set
793# CONFIG_JFS_FS is not set
794# CONFIG_FS_POSIX_ACL is not set
795# CONFIG_XFS_FS is not set
796# CONFIG_OCFS2_FS is not set
797# CONFIG_DNOTIFY is not set
798# CONFIG_INOTIFY is not set
799# CONFIG_QUOTA is not set
800# CONFIG_AUTOFS_FS is not set
801# CONFIG_AUTOFS4_FS is not set
802# CONFIG_FUSE_FS is not set
803
804#
805# CD-ROM/DVD Filesystems
806#
807# CONFIG_ISO9660_FS is not set
808# CONFIG_UDF_FS is not set
809
810#
811# DOS/FAT/NT Filesystems
812#
813CONFIG_FAT_FS=y
814CONFIG_MSDOS_FS=y
815CONFIG_VFAT_FS=y
816CONFIG_FAT_DEFAULT_CODEPAGE=866
817CONFIG_FAT_DEFAULT_IOCHARSET="utf8"
818# CONFIG_NTFS_FS is not set
819
820#
821# Pseudo filesystems
822#
823CONFIG_PROC_FS=y
824CONFIG_PROC_SYSCTL=y
825CONFIG_SYSFS=y
826CONFIG_TMPFS=y
827# CONFIG_TMPFS_POSIX_ACL is not set
828# CONFIG_HUGETLB_PAGE is not set
829# CONFIG_CONFIGFS_FS is not set
830
831#
832# Miscellaneous filesystems
833#
834# CONFIG_ADFS_FS is not set
835# CONFIG_AFFS_FS is not set
836# CONFIG_HFS_FS is not set
837# CONFIG_HFSPLUS_FS is not set
838# CONFIG_BEFS_FS is not set
839# CONFIG_BFS_FS is not set
840# CONFIG_EFS_FS is not set
841# CONFIG_CRAMFS is not set
842# CONFIG_VXFS_FS is not set
843# CONFIG_MINIX_FS is not set
844# CONFIG_OMFS_FS is not set
845# CONFIG_HPFS_FS is not set
846# CONFIG_QNX4FS_FS is not set
847# CONFIG_ROMFS_FS is not set
848# CONFIG_SYSV_FS is not set
849# CONFIG_UFS_FS is not set
850# CONFIG_NETWORK_FILESYSTEMS is not set
851
852#
853# Partition Types
854#
855# CONFIG_PARTITION_ADVANCED is not set
856CONFIG_MSDOS_PARTITION=y
857CONFIG_NLS=y
858CONFIG_NLS_DEFAULT="utf8"
859# CONFIG_NLS_CODEPAGE_437 is not set
860# CONFIG_NLS_CODEPAGE_737 is not set
861# CONFIG_NLS_CODEPAGE_775 is not set
862# CONFIG_NLS_CODEPAGE_850 is not set
863# CONFIG_NLS_CODEPAGE_852 is not set
864# CONFIG_NLS_CODEPAGE_855 is not set
865# CONFIG_NLS_CODEPAGE_857 is not set
866# CONFIG_NLS_CODEPAGE_860 is not set
867# CONFIG_NLS_CODEPAGE_861 is not set
868# CONFIG_NLS_CODEPAGE_862 is not set
869# CONFIG_NLS_CODEPAGE_863 is not set
870# CONFIG_NLS_CODEPAGE_864 is not set
871# CONFIG_NLS_CODEPAGE_865 is not set
872CONFIG_NLS_CODEPAGE_866=y
873# CONFIG_NLS_CODEPAGE_869 is not set
874# CONFIG_NLS_CODEPAGE_936 is not set
875# CONFIG_NLS_CODEPAGE_950 is not set
876# CONFIG_NLS_CODEPAGE_932 is not set
877# CONFIG_NLS_CODEPAGE_949 is not set
878# CONFIG_NLS_CODEPAGE_874 is not set
879# CONFIG_NLS_ISO8859_8 is not set
880# CONFIG_NLS_CODEPAGE_1250 is not set
881# CONFIG_NLS_CODEPAGE_1251 is not set
882# CONFIG_NLS_ASCII is not set
883# CONFIG_NLS_ISO8859_1 is not set
884# CONFIG_NLS_ISO8859_2 is not set
885# CONFIG_NLS_ISO8859_3 is not set
886# CONFIG_NLS_ISO8859_4 is not set
887# CONFIG_NLS_ISO8859_5 is not set
888# CONFIG_NLS_ISO8859_6 is not set
889# CONFIG_NLS_ISO8859_7 is not set
890# CONFIG_NLS_ISO8859_9 is not set
891# CONFIG_NLS_ISO8859_13 is not set
892# CONFIG_NLS_ISO8859_14 is not set
893# CONFIG_NLS_ISO8859_15 is not set
894# CONFIG_NLS_KOI8_R is not set
895# CONFIG_NLS_KOI8_U is not set
896CONFIG_NLS_UTF8=y
897# CONFIG_DLM is not set
898
899#
900# Kernel hacking
901#
902# CONFIG_PRINTK_TIME is not set
903CONFIG_ENABLE_WARN_DEPRECATED=y
904CONFIG_ENABLE_MUST_CHECK=y
905CONFIG_FRAME_WARN=1024
906# CONFIG_MAGIC_SYSRQ is not set
907# CONFIG_UNUSED_SYMBOLS is not set
908# CONFIG_DEBUG_FS is not set
909# CONFIG_HEADERS_CHECK is not set
910# CONFIG_DEBUG_KERNEL is not set
911CONFIG_DEBUG_BUGVERBOSE=y
912CONFIG_DEBUG_MEMORY_INIT=y
913CONFIG_FRAME_POINTER=y
914# CONFIG_LATENCYTOP is not set
915CONFIG_SYSCTL_SYSCALL_CHECK=y
916CONFIG_HAVE_FTRACE=y
917CONFIG_HAVE_DYNAMIC_FTRACE=y
918# CONFIG_FTRACE is not set
919# CONFIG_IRQSOFF_TRACER is not set
920# CONFIG_PREEMPT_TRACER is not set
921# CONFIG_SCHED_TRACER is not set
922# CONFIG_CONTEXT_SWITCH_TRACER is not set
923# CONFIG_SAMPLES is not set
924CONFIG_HAVE_ARCH_KGDB=y
925CONFIG_DEBUG_USER=y
926
927#
928# Security options
929#
930# CONFIG_KEYS is not set
931# CONFIG_SECURITY is not set
932# CONFIG_SECURITY_FILE_CAPABILITIES is not set
933# CONFIG_CRYPTO is not set
934
935#
936# Library routines
937#
938CONFIG_BITREVERSE=y
939# CONFIG_GENERIC_FIND_FIRST_BIT is not set
940# CONFIG_GENERIC_FIND_NEXT_BIT is not set
941# CONFIG_CRC_CCITT is not set
942# CONFIG_CRC16 is not set
943CONFIG_CRC_T10DIF=y
944# CONFIG_CRC_ITU_T is not set
945CONFIG_CRC32=y
946# CONFIG_CRC7 is not set
947# CONFIG_LIBCRC32C is not set
948CONFIG_PLIST=y
949CONFIG_HAS_IOMEM=y
950CONFIG_HAS_IOPORT=y
951CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/viper_defconfig b/arch/arm/configs/viper_defconfig
new file mode 100644
index 000000000000..d01fecb8673e
--- /dev/null
+++ b/arch/arm/configs/viper_defconfig
@@ -0,0 +1,1678 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc4
4# Thu Aug 21 17:12:07 2008
5#
6CONFIG_ARM=y
7CONFIG_HAVE_PWM=y
8CONFIG_SYS_SUPPORTS_APM_EMULATION=y
9CONFIG_GENERIC_GPIO=y
10CONFIG_GENERIC_TIME=y
11CONFIG_GENERIC_CLOCKEVENTS=y
12CONFIG_MMU=y
13# CONFIG_NO_IOPORT is not set
14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_STACKTRACE_SUPPORT=y
16CONFIG_HAVE_LATENCYTOP_SUPPORT=y
17CONFIG_LOCKDEP_SUPPORT=y
18CONFIG_TRACE_IRQFLAGS_SUPPORT=y
19CONFIG_HARDIRQS_SW_RESEND=y
20CONFIG_GENERIC_IRQ_PROBE=y
21CONFIG_RWSEM_GENERIC_SPINLOCK=y
22# CONFIG_ARCH_HAS_ILOG2_U32 is not set
23# CONFIG_ARCH_HAS_ILOG2_U64 is not set
24CONFIG_GENERIC_HWEIGHT=y
25CONFIG_GENERIC_CALIBRATE_DELAY=y
26CONFIG_ARCH_SUPPORTS_AOUT=y
27CONFIG_ZONE_DMA=y
28CONFIG_ARCH_MTD_XIP=y
29CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
30CONFIG_VECTORS_BASE=0xffff0000
31CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
32
33#
34# General setup
35#
36CONFIG_EXPERIMENTAL=y
37CONFIG_BROKEN_ON_SMP=y
38CONFIG_INIT_ENV_ARG_LIMIT=32
39CONFIG_LOCALVERSION=""
40CONFIG_LOCALVERSION_AUTO=y
41# CONFIG_SWAP is not set
42CONFIG_SYSVIPC=y
43CONFIG_SYSVIPC_SYSCTL=y
44# CONFIG_POSIX_MQUEUE is not set
45# CONFIG_BSD_PROCESS_ACCT is not set
46# CONFIG_TASKSTATS is not set
47# CONFIG_AUDIT is not set
48# CONFIG_IKCONFIG is not set
49CONFIG_LOG_BUF_SHIFT=13
50# CONFIG_CGROUPS is not set
51# CONFIG_GROUP_SCHED is not set
52CONFIG_SYSFS_DEPRECATED=y
53CONFIG_SYSFS_DEPRECATED_V2=y
54# CONFIG_RELAY is not set
55# CONFIG_NAMESPACES is not set
56# CONFIG_BLK_DEV_INITRD is not set
57CONFIG_CC_OPTIMIZE_FOR_SIZE=y
58CONFIG_SYSCTL=y
59CONFIG_EMBEDDED=y
60CONFIG_UID16=y
61CONFIG_SYSCTL_SYSCALL=y
62CONFIG_KALLSYMS=y
63# CONFIG_KALLSYMS_ALL is not set
64# CONFIG_KALLSYMS_EXTRA_PASS is not set
65CONFIG_HOTPLUG=y
66CONFIG_PRINTK=y
67CONFIG_BUG=y
68# CONFIG_ELF_CORE is not set
69CONFIG_COMPAT_BRK=y
70CONFIG_BASE_FULL=y
71CONFIG_FUTEX=y
72CONFIG_ANON_INODES=y
73CONFIG_EPOLL=y
74CONFIG_SIGNALFD=y
75CONFIG_TIMERFD=y
76CONFIG_EVENTFD=y
77# CONFIG_SHMEM is not set
78CONFIG_VM_EVENT_COUNTERS=y
79CONFIG_SLAB=y
80# CONFIG_SLUB is not set
81# CONFIG_SLOB is not set
82# CONFIG_PROFILING is not set
83# CONFIG_MARKERS is not set
84CONFIG_HAVE_OPROFILE=y
85# CONFIG_KPROBES is not set
86# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
87# CONFIG_HAVE_IOREMAP_PROT is not set
88CONFIG_HAVE_KPROBES=y
89CONFIG_HAVE_KRETPROBES=y
90# CONFIG_HAVE_ARCH_TRACEHOOK is not set
91# CONFIG_HAVE_DMA_ATTRS is not set
92# CONFIG_USE_GENERIC_SMP_HELPERS is not set
93CONFIG_HAVE_CLK=y
94CONFIG_PROC_PAGE_MONITOR=y
95CONFIG_HAVE_GENERIC_DMA_COHERENT=y
96CONFIG_SLABINFO=y
97CONFIG_RT_MUTEXES=y
98CONFIG_TINY_SHMEM=y
99CONFIG_BASE_SMALL=0
100CONFIG_MODULES=y
101# CONFIG_MODULE_FORCE_LOAD is not set
102CONFIG_MODULE_UNLOAD=y
103# CONFIG_MODULE_FORCE_UNLOAD is not set
104# CONFIG_MODVERSIONS is not set
105# CONFIG_MODULE_SRCVERSION_ALL is not set
106CONFIG_KMOD=y
107CONFIG_BLOCK=y
108# CONFIG_LBD is not set
109# CONFIG_BLK_DEV_IO_TRACE is not set
110# CONFIG_LSF is not set
111# CONFIG_BLK_DEV_BSG is not set
112# CONFIG_BLK_DEV_INTEGRITY is not set
113
114#
115# IO Schedulers
116#
117CONFIG_IOSCHED_NOOP=y
118# CONFIG_IOSCHED_AS is not set
119CONFIG_IOSCHED_DEADLINE=y
120# CONFIG_IOSCHED_CFQ is not set
121# CONFIG_DEFAULT_AS is not set
122CONFIG_DEFAULT_DEADLINE=y
123# CONFIG_DEFAULT_CFQ is not set
124# CONFIG_DEFAULT_NOOP is not set
125CONFIG_DEFAULT_IOSCHED="deadline"
126CONFIG_CLASSIC_RCU=y
127
128#
129# System Type
130#
131# CONFIG_ARCH_AAEC2000 is not set
132# CONFIG_ARCH_INTEGRATOR is not set
133# CONFIG_ARCH_REALVIEW is not set
134# CONFIG_ARCH_VERSATILE is not set
135# CONFIG_ARCH_AT91 is not set
136# CONFIG_ARCH_CLPS7500 is not set
137# CONFIG_ARCH_CLPS711X is not set
138# CONFIG_ARCH_EBSA110 is not set
139# CONFIG_ARCH_EP93XX is not set
140# CONFIG_ARCH_FOOTBRIDGE is not set
141# CONFIG_ARCH_NETX is not set
142# CONFIG_ARCH_H720X is not set
143# CONFIG_ARCH_IMX is not set
144# CONFIG_ARCH_IOP13XX is not set
145# CONFIG_ARCH_IOP32X is not set
146# CONFIG_ARCH_IOP33X is not set
147# CONFIG_ARCH_IXP23XX is not set
148# CONFIG_ARCH_IXP2000 is not set
149# CONFIG_ARCH_IXP4XX is not set
150# CONFIG_ARCH_L7200 is not set
151# CONFIG_ARCH_KIRKWOOD is not set
152# CONFIG_ARCH_KS8695 is not set
153# CONFIG_ARCH_NS9XXX is not set
154# CONFIG_ARCH_LOKI is not set
155# CONFIG_ARCH_MV78XX0 is not set
156# CONFIG_ARCH_MXC is not set
157# CONFIG_ARCH_ORION5X is not set
158# CONFIG_ARCH_PNX4008 is not set
159CONFIG_ARCH_PXA=y
160# CONFIG_ARCH_RPC is not set
161# CONFIG_ARCH_SA1100 is not set
162# CONFIG_ARCH_S3C2410 is not set
163# CONFIG_ARCH_SHARK is not set
164# CONFIG_ARCH_LH7A40X is not set
165# CONFIG_ARCH_DAVINCI is not set
166# CONFIG_ARCH_OMAP is not set
167# CONFIG_ARCH_MSM7X00A is not set
168
169#
170# Intel PXA2xx/PXA3xx Implementations
171#
172# CONFIG_ARCH_GUMSTIX is not set
173# CONFIG_ARCH_LUBBOCK is not set
174# CONFIG_MACH_LOGICPD_PXA270 is not set
175# CONFIG_MACH_MAINSTONE is not set
176# CONFIG_ARCH_PXA_IDP is not set
177# CONFIG_PXA_SHARPSL is not set
178CONFIG_ARCH_VIPER=y
179# CONFIG_ARCH_PXA_ESERIES is not set
180# CONFIG_MACH_TRIZEPS4 is not set
181# CONFIG_MACH_EM_X270 is not set
182# CONFIG_MACH_COLIBRI is not set
183# CONFIG_MACH_ZYLONITE is not set
184# CONFIG_MACH_LITTLETON is not set
185# CONFIG_MACH_TAVOREVB is not set
186# CONFIG_MACH_SAAR is not set
187# CONFIG_MACH_ARMCORE is not set
188# CONFIG_MACH_MAGICIAN is not set
189# CONFIG_MACH_PCM027 is not set
190# CONFIG_ARCH_PXA_PALM is not set
191# CONFIG_PXA_EZX is not set
192CONFIG_PXA25x=y
193CONFIG_PXA_PWM=m
194CONFIG_PXA_HAVE_ISA_IRQS=y
195
196#
197# Boot options
198#
199
200#
201# Power management
202#
203
204#
205# Processor Type
206#
207CONFIG_CPU_32=y
208CONFIG_CPU_XSCALE=y
209CONFIG_CPU_32v5=y
210CONFIG_CPU_ABRT_EV5T=y
211CONFIG_CPU_PABRT_NOIFAR=y
212CONFIG_CPU_CACHE_VIVT=y
213CONFIG_CPU_TLB_V4WBI=y
214CONFIG_CPU_CP15=y
215CONFIG_CPU_CP15_MMU=y
216
217#
218# Processor Features
219#
220CONFIG_ARM_THUMB=y
221# CONFIG_CPU_DCACHE_DISABLE is not set
222# CONFIG_OUTER_CACHE is not set
223CONFIG_IWMMXT=y
224CONFIG_XSCALE_PMU=y
225
226#
227# Bus support
228#
229CONFIG_ISA=y
230# CONFIG_PCI_SYSCALL is not set
231# CONFIG_ARCH_SUPPORTS_MSI is not set
232CONFIG_PCCARD=m
233# CONFIG_PCMCIA_DEBUG is not set
234CONFIG_PCMCIA=m
235CONFIG_PCMCIA_LOAD_CIS=y
236CONFIG_PCMCIA_IOCTL=y
237
238#
239# PC-card bridges
240#
241# CONFIG_I82365 is not set
242# CONFIG_TCIC is not set
243CONFIG_PCMCIA_PXA2XX=m
244CONFIG_PCMCIA_PROBE=y
245
246#
247# Kernel Features
248#
249CONFIG_TICK_ONESHOT=y
250# CONFIG_NO_HZ is not set
251# CONFIG_HIGH_RES_TIMERS is not set
252CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
253# CONFIG_PREEMPT is not set
254CONFIG_HZ=100
255CONFIG_AEABI=y
256CONFIG_OABI_COMPAT=y
257# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
258CONFIG_SELECT_MEMORY_MODEL=y
259CONFIG_FLATMEM_MANUAL=y
260# CONFIG_DISCONTIGMEM_MANUAL is not set
261# CONFIG_SPARSEMEM_MANUAL is not set
262CONFIG_FLATMEM=y
263CONFIG_FLAT_NODE_MEM_MAP=y
264# CONFIG_SPARSEMEM_STATIC is not set
265# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
266CONFIG_PAGEFLAGS_EXTENDED=y
267CONFIG_SPLIT_PTLOCK_CPUS=4096
268# CONFIG_RESOURCES_64BIT is not set
269CONFIG_ZONE_DMA_FLAG=1
270CONFIG_BOUNCE=y
271CONFIG_VIRT_TO_BUS=y
272CONFIG_ALIGNMENT_TRAP=y
273
274#
275# Boot options
276#
277CONFIG_ZBOOT_ROM_TEXT=0x0
278CONFIG_ZBOOT_ROM_BSS=0x0
279CONFIG_CMDLINE="root=31:02 rootfstype=jffs2 ro console=ttyS0,115200"
280# CONFIG_XIP_KERNEL is not set
281# CONFIG_KEXEC is not set
282
283#
284# CPU Frequency scaling
285#
286CONFIG_CPU_FREQ=y
287CONFIG_CPU_FREQ_TABLE=y
288# CONFIG_CPU_FREQ_DEBUG is not set
289CONFIG_CPU_FREQ_STAT=y
290# CONFIG_CPU_FREQ_STAT_DETAILS is not set
291CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
292# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
293# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
294# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
295# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
296CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
297CONFIG_CPU_FREQ_GOV_POWERSAVE=m
298CONFIG_CPU_FREQ_GOV_USERSPACE=m
299CONFIG_CPU_FREQ_GOV_ONDEMAND=m
300CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
301CONFIG_CPU_FREQ_PXA=y
302
303#
304# Floating point emulation
305#
306
307#
308# At least one emulation must be selected
309#
310# CONFIG_FPE_NWFPE is not set
311CONFIG_FPE_FASTFPE=y
312
313#
314# Userspace binary formats
315#
316CONFIG_BINFMT_ELF=y
317# CONFIG_BINFMT_AOUT is not set
318# CONFIG_BINFMT_MISC is not set
319
320#
321# Power management options
322#
323CONFIG_PM=y
324# CONFIG_PM_DEBUG is not set
325CONFIG_PM_SLEEP=y
326CONFIG_SUSPEND=y
327CONFIG_SUSPEND_FREEZER=y
328# CONFIG_APM_EMULATION is not set
329CONFIG_ARCH_SUSPEND_POSSIBLE=y
330CONFIG_NET=y
331
332#
333# Networking options
334#
335CONFIG_PACKET=y
336# CONFIG_PACKET_MMAP is not set
337CONFIG_UNIX=y
338CONFIG_XFRM=y
339# CONFIG_XFRM_USER is not set
340# CONFIG_XFRM_SUB_POLICY is not set
341# CONFIG_XFRM_MIGRATE is not set
342# CONFIG_XFRM_STATISTICS is not set
343# CONFIG_NET_KEY is not set
344CONFIG_INET=y
345# CONFIG_IP_MULTICAST is not set
346# CONFIG_IP_ADVANCED_ROUTER is not set
347CONFIG_IP_FIB_HASH=y
348CONFIG_IP_PNP=y
349CONFIG_IP_PNP_DHCP=y
350# CONFIG_IP_PNP_BOOTP is not set
351# CONFIG_IP_PNP_RARP is not set
352# CONFIG_NET_IPIP is not set
353# CONFIG_NET_IPGRE is not set
354# CONFIG_ARPD is not set
355CONFIG_SYN_COOKIES=y
356# CONFIG_INET_AH is not set
357# CONFIG_INET_ESP is not set
358# CONFIG_INET_IPCOMP is not set
359# CONFIG_INET_XFRM_TUNNEL is not set
360# CONFIG_INET_TUNNEL is not set
361CONFIG_INET_XFRM_MODE_TRANSPORT=y
362CONFIG_INET_XFRM_MODE_TUNNEL=y
363CONFIG_INET_XFRM_MODE_BEET=y
364# CONFIG_INET_LRO is not set
365CONFIG_INET_DIAG=y
366CONFIG_INET_TCP_DIAG=y
367# CONFIG_TCP_CONG_ADVANCED is not set
368CONFIG_TCP_CONG_CUBIC=y
369CONFIG_DEFAULT_TCP_CONG="cubic"
370# CONFIG_TCP_MD5SIG is not set
371# CONFIG_IPV6 is not set
372# CONFIG_NETWORK_SECMARK is not set
373# CONFIG_NETFILTER is not set
374# CONFIG_IP_DCCP is not set
375# CONFIG_IP_SCTP is not set
376# CONFIG_TIPC is not set
377# CONFIG_ATM is not set
378# CONFIG_BRIDGE is not set
379# CONFIG_VLAN_8021Q is not set
380# CONFIG_DECNET is not set
381# CONFIG_LLC2 is not set
382# CONFIG_IPX is not set
383# CONFIG_ATALK is not set
384# CONFIG_X25 is not set
385# CONFIG_LAPB is not set
386# CONFIG_ECONET is not set
387# CONFIG_WAN_ROUTER is not set
388# CONFIG_NET_SCHED is not set
389
390#
391# Network testing
392#
393# CONFIG_NET_PKTGEN is not set
394# CONFIG_HAMRADIO is not set
395# CONFIG_CAN is not set
396# CONFIG_IRDA is not set
397CONFIG_BT=m
398CONFIG_BT_L2CAP=m
399# CONFIG_BT_SCO is not set
400CONFIG_BT_RFCOMM=m
401CONFIG_BT_RFCOMM_TTY=y
402CONFIG_BT_BNEP=m
403# CONFIG_BT_BNEP_MC_FILTER is not set
404# CONFIG_BT_BNEP_PROTO_FILTER is not set
405# CONFIG_BT_HIDP is not set
406
407#
408# Bluetooth device drivers
409#
410CONFIG_BT_HCIUSB=m
411# CONFIG_BT_HCIUSB_SCO is not set
412# CONFIG_BT_HCIBTUSB is not set
413CONFIG_BT_HCIUART=m
414CONFIG_BT_HCIUART_H4=y
415CONFIG_BT_HCIUART_BCSP=y
416# CONFIG_BT_HCIUART_LL is not set
417# CONFIG_BT_HCIBCM203X is not set
418# CONFIG_BT_HCIBPA10X is not set
419# CONFIG_BT_HCIBFUSB is not set
420# CONFIG_BT_HCIDTL1 is not set
421# CONFIG_BT_HCIBT3C is not set
422# CONFIG_BT_HCIBLUECARD is not set
423# CONFIG_BT_HCIBTUART is not set
424# CONFIG_BT_HCIVHCI is not set
425# CONFIG_AF_RXRPC is not set
426
427#
428# Wireless
429#
430# CONFIG_CFG80211 is not set
431# CONFIG_WIRELESS_EXT is not set
432# CONFIG_MAC80211 is not set
433CONFIG_IEEE80211=m
434# CONFIG_IEEE80211_DEBUG is not set
435CONFIG_IEEE80211_CRYPT_WEP=m
436# CONFIG_IEEE80211_CRYPT_CCMP is not set
437# CONFIG_IEEE80211_CRYPT_TKIP is not set
438# CONFIG_RFKILL is not set
439# CONFIG_NET_9P is not set
440
441#
442# Device Drivers
443#
444
445#
446# Generic Driver Options
447#
448CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
449CONFIG_STANDALONE=y
450CONFIG_PREVENT_FIRMWARE_BUILD=y
451CONFIG_FW_LOADER=m
452CONFIG_FIRMWARE_IN_KERNEL=y
453CONFIG_EXTRA_FIRMWARE=""
454# CONFIG_DEBUG_DRIVER is not set
455# CONFIG_DEBUG_DEVRES is not set
456# CONFIG_SYS_HYPERVISOR is not set
457# CONFIG_CONNECTOR is not set
458CONFIG_MTD=y
459# CONFIG_MTD_DEBUG is not set
460# CONFIG_MTD_CONCAT is not set
461CONFIG_MTD_PARTITIONS=y
462CONFIG_MTD_REDBOOT_PARTS=y
463CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=0
464# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
465# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
466# CONFIG_MTD_CMDLINE_PARTS is not set
467# CONFIG_MTD_AFS_PARTS is not set
468# CONFIG_MTD_AR7_PARTS is not set
469
470#
471# User Modules And Translation Layers
472#
473CONFIG_MTD_CHAR=m
474CONFIG_MTD_BLKDEVS=y
475CONFIG_MTD_BLOCK=y
476# CONFIG_FTL is not set
477# CONFIG_NFTL is not set
478# CONFIG_INFTL is not set
479# CONFIG_RFD_FTL is not set
480# CONFIG_SSFDC is not set
481# CONFIG_MTD_OOPS is not set
482
483#
484# RAM/ROM/Flash chip drivers
485#
486CONFIG_MTD_CFI=y
487CONFIG_MTD_JEDECPROBE=y
488CONFIG_MTD_GEN_PROBE=y
489CONFIG_MTD_CFI_ADV_OPTIONS=y
490CONFIG_MTD_CFI_NOSWAP=y
491# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
492# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
493CONFIG_MTD_CFI_GEOMETRY=y
494CONFIG_MTD_MAP_BANK_WIDTH_1=y
495CONFIG_MTD_MAP_BANK_WIDTH_2=y
496# CONFIG_MTD_MAP_BANK_WIDTH_4 is not set
497# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
498# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
499# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
500CONFIG_MTD_CFI_I1=y
501# CONFIG_MTD_CFI_I2 is not set
502# CONFIG_MTD_CFI_I4 is not set
503# CONFIG_MTD_CFI_I8 is not set
504# CONFIG_MTD_OTP is not set
505CONFIG_MTD_CFI_INTELEXT=y
506CONFIG_MTD_CFI_AMDSTD=y
507# CONFIG_MTD_CFI_STAA is not set
508CONFIG_MTD_CFI_UTIL=y
509CONFIG_MTD_RAM=y
510# CONFIG_MTD_ROM is not set
511# CONFIG_MTD_ABSENT is not set
512# CONFIG_MTD_XIP is not set
513
514#
515# Mapping drivers for chip access
516#
517CONFIG_MTD_COMPLEX_MAPPINGS=y
518CONFIG_MTD_PHYSMAP=y
519CONFIG_MTD_PHYSMAP_START=0x8000000
520CONFIG_MTD_PHYSMAP_LEN=0
521CONFIG_MTD_PHYSMAP_BANKWIDTH=2
522CONFIG_MTD_PXA2XX=y
523# CONFIG_MTD_ARM_INTEGRATOR is not set
524# CONFIG_MTD_IMPA7 is not set
525# CONFIG_MTD_SHARP_SL is not set
526# CONFIG_MTD_PLATRAM is not set
527CONFIG_MTD_SPARSE_RAM=y
528
529#
530# Self-contained MTD device drivers
531#
532# CONFIG_MTD_SLRAM is not set
533# CONFIG_MTD_PHRAM is not set
534# CONFIG_MTD_MTDRAM is not set
535# CONFIG_MTD_BLOCK2MTD is not set
536
537#
538# Disk-On-Chip Device Drivers
539#
540# CONFIG_MTD_DOC2000 is not set
541# CONFIG_MTD_DOC2001 is not set
542# CONFIG_MTD_DOC2001PLUS is not set
543# CONFIG_MTD_NAND is not set
544# CONFIG_MTD_ONENAND is not set
545
546#
547# UBI - Unsorted block images
548#
549# CONFIG_MTD_UBI is not set
550# CONFIG_PARPORT is not set
551# CONFIG_PNP is not set
552CONFIG_BLK_DEV=y
553# CONFIG_BLK_DEV_COW_COMMON is not set
554CONFIG_BLK_DEV_LOOP=m
555# CONFIG_BLK_DEV_CRYPTOLOOP is not set
556# CONFIG_BLK_DEV_NBD is not set
557# CONFIG_BLK_DEV_UB is not set
558# CONFIG_BLK_DEV_RAM is not set
559# CONFIG_CDROM_PKTCDVD is not set
560# CONFIG_ATA_OVER_ETH is not set
561CONFIG_MISC_DEVICES=y
562# CONFIG_EEPROM_93CX6 is not set
563# CONFIG_ENCLOSURE_SERVICES is not set
564CONFIG_HAVE_IDE=y
565# CONFIG_IDE is not set
566
567#
568# SCSI device support
569#
570# CONFIG_RAID_ATTRS is not set
571CONFIG_SCSI=m
572CONFIG_SCSI_DMA=y
573# CONFIG_SCSI_TGT is not set
574# CONFIG_SCSI_NETLINK is not set
575# CONFIG_SCSI_PROC_FS is not set
576
577#
578# SCSI support type (disk, tape, CD-ROM)
579#
580CONFIG_BLK_DEV_SD=m
581# CONFIG_CHR_DEV_ST is not set
582# CONFIG_CHR_DEV_OSST is not set
583# CONFIG_BLK_DEV_SR is not set
584# CONFIG_CHR_DEV_SG is not set
585# CONFIG_CHR_DEV_SCH is not set
586
587#
588# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
589#
590# CONFIG_SCSI_MULTI_LUN is not set
591# CONFIG_SCSI_CONSTANTS is not set
592# CONFIG_SCSI_LOGGING is not set
593# CONFIG_SCSI_SCAN_ASYNC is not set
594CONFIG_SCSI_WAIT_SCAN=m
595
596#
597# SCSI Transports
598#
599# CONFIG_SCSI_SPI_ATTRS is not set
600# CONFIG_SCSI_FC_ATTRS is not set
601# CONFIG_SCSI_ISCSI_ATTRS is not set
602# CONFIG_SCSI_SAS_LIBSAS is not set
603# CONFIG_SCSI_SRP_ATTRS is not set
604CONFIG_SCSI_LOWLEVEL=y
605# CONFIG_ISCSI_TCP is not set
606# CONFIG_SCSI_AHA152X is not set
607# CONFIG_SCSI_AIC7XXX_OLD is not set
608# CONFIG_SCSI_ADVANSYS is not set
609# CONFIG_SCSI_IN2000 is not set
610# CONFIG_SCSI_DTC3280 is not set
611# CONFIG_SCSI_FUTURE_DOMAIN is not set
612# CONFIG_SCSI_GENERIC_NCR5380 is not set
613# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
614# CONFIG_SCSI_NCR53C406A is not set
615# CONFIG_SCSI_PAS16 is not set
616# CONFIG_SCSI_QLOGIC_FAS is not set
617# CONFIG_SCSI_SYM53C416 is not set
618# CONFIG_SCSI_T128 is not set
619# CONFIG_SCSI_DEBUG is not set
620# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set
621# CONFIG_SCSI_DH is not set
622CONFIG_ATA=m
623# CONFIG_ATA_NONSTANDARD is not set
624# CONFIG_SATA_PMP is not set
625CONFIG_ATA_SFF=y
626# CONFIG_SATA_MV is not set
627# CONFIG_PATA_LEGACY is not set
628CONFIG_PATA_PCMCIA=m
629# CONFIG_PATA_QDI is not set
630# CONFIG_PATA_WINBOND_VLB is not set
631# CONFIG_PATA_PLATFORM is not set
632# CONFIG_MD is not set
633CONFIG_NETDEVICES=y
634# CONFIG_DUMMY is not set
635# CONFIG_BONDING is not set
636# CONFIG_MACVLAN is not set
637# CONFIG_EQUALIZER is not set
638# CONFIG_TUN is not set
639# CONFIG_VETH is not set
640# CONFIG_ARCNET is not set
641# CONFIG_PHYLIB is not set
642CONFIG_NET_ETHERNET=y
643CONFIG_MII=y
644# CONFIG_AX88796 is not set
645# CONFIG_NET_VENDOR_3COM is not set
646# CONFIG_NET_VENDOR_SMC is not set
647CONFIG_SMC91X=y
648# CONFIG_DM9000 is not set
649# CONFIG_SMC911X is not set
650# CONFIG_NET_VENDOR_RACAL is not set
651# CONFIG_AT1700 is not set
652# CONFIG_DEPCA is not set
653# CONFIG_HP100 is not set
654# CONFIG_NET_ISA is not set
655# CONFIG_IBM_NEW_EMAC_ZMII is not set
656# CONFIG_IBM_NEW_EMAC_RGMII is not set
657# CONFIG_IBM_NEW_EMAC_TAH is not set
658# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
659# CONFIG_NET_PCI is not set
660# CONFIG_B44 is not set
661# CONFIG_NETDEV_1000 is not set
662# CONFIG_NETDEV_10000 is not set
663# CONFIG_TR is not set
664
665#
666# Wireless LAN
667#
668# CONFIG_WLAN_PRE80211 is not set
669# CONFIG_WLAN_80211 is not set
670# CONFIG_IWLWIFI_LEDS is not set
671
672#
673# USB Network Adapters
674#
675# CONFIG_USB_CATC is not set
676# CONFIG_USB_KAWETH is not set
677CONFIG_USB_PEGASUS=m
678# CONFIG_USB_RTL8150 is not set
679CONFIG_USB_USBNET=m
680CONFIG_USB_NET_AX8817X=m
681CONFIG_USB_NET_CDCETHER=m
682# CONFIG_USB_NET_DM9601 is not set
683# CONFIG_USB_NET_GL620A is not set
684CONFIG_USB_NET_NET1080=m
685# CONFIG_USB_NET_PLUSB is not set
686# CONFIG_USB_NET_MCS7830 is not set
687# CONFIG_USB_NET_RNDIS_HOST is not set
688# CONFIG_USB_NET_CDC_SUBSET is not set
689CONFIG_USB_NET_ZAURUS=m
690CONFIG_NET_PCMCIA=y
691# CONFIG_PCMCIA_3C589 is not set
692# CONFIG_PCMCIA_3C574 is not set
693# CONFIG_PCMCIA_FMVJ18X is not set
694# CONFIG_PCMCIA_PCNET is not set
695# CONFIG_PCMCIA_NMCLAN is not set
696# CONFIG_PCMCIA_SMC91C92 is not set
697# CONFIG_PCMCIA_XIRC2PS is not set
698# CONFIG_PCMCIA_AXNET is not set
699# CONFIG_WAN is not set
700CONFIG_PPP=m
701# CONFIG_PPP_MULTILINK is not set
702# CONFIG_PPP_FILTER is not set
703CONFIG_PPP_ASYNC=m
704# CONFIG_PPP_SYNC_TTY is not set
705CONFIG_PPP_DEFLATE=m
706CONFIG_PPP_BSDCOMP=m
707# CONFIG_PPP_MPPE is not set
708# CONFIG_PPPOE is not set
709# CONFIG_PPPOL2TP is not set
710# CONFIG_SLIP is not set
711CONFIG_SLHC=m
712# CONFIG_NETCONSOLE is not set
713# CONFIG_NETPOLL is not set
714# CONFIG_NET_POLL_CONTROLLER is not set
715# CONFIG_ISDN is not set
716
717#
718# Input device support
719#
720CONFIG_INPUT=y
721# CONFIG_INPUT_FF_MEMLESS is not set
722# CONFIG_INPUT_POLLDEV is not set
723
724#
725# Userland interfaces
726#
727CONFIG_INPUT_MOUSEDEV=m
728# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
729CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
730CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
731# CONFIG_INPUT_JOYDEV is not set
732CONFIG_INPUT_EVDEV=m
733# CONFIG_INPUT_EVBUG is not set
734
735#
736# Input Device Drivers
737#
738# CONFIG_INPUT_KEYBOARD is not set
739# CONFIG_INPUT_MOUSE is not set
740# CONFIG_INPUT_JOYSTICK is not set
741# CONFIG_INPUT_TABLET is not set
742CONFIG_INPUT_TOUCHSCREEN=y
743CONFIG_TOUCHSCREEN_FUJITSU=m
744# CONFIG_TOUCHSCREEN_GUNZE is not set
745CONFIG_TOUCHSCREEN_ELO=m
746CONFIG_TOUCHSCREEN_MTOUCH=m
747CONFIG_TOUCHSCREEN_INEXIO=m
748# CONFIG_TOUCHSCREEN_MK712 is not set
749CONFIG_TOUCHSCREEN_HTCPEN=m
750CONFIG_TOUCHSCREEN_PENMOUNT=m
751CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
752CONFIG_TOUCHSCREEN_TOUCHWIN=m
753# CONFIG_TOUCHSCREEN_UCB1400 is not set
754# CONFIG_TOUCHSCREEN_WM97XX is not set
755# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
756CONFIG_TOUCHSCREEN_TOUCHIT213=m
757CONFIG_INPUT_MISC=y
758# CONFIG_INPUT_ATI_REMOTE is not set
759# CONFIG_INPUT_ATI_REMOTE2 is not set
760# CONFIG_INPUT_KEYSPAN_REMOTE is not set
761# CONFIG_INPUT_POWERMATE is not set
762# CONFIG_INPUT_YEALINK is not set
763CONFIG_INPUT_UINPUT=m
764
765#
766# Hardware I/O ports
767#
768CONFIG_SERIO=y
769CONFIG_SERIO_SERPORT=y
770# CONFIG_SERIO_LIBPS2 is not set
771# CONFIG_SERIO_RAW is not set
772# CONFIG_GAMEPORT is not set
773
774#
775# Character devices
776#
777CONFIG_VT=y
778# CONFIG_CONSOLE_TRANSLATIONS is not set
779# CONFIG_VT_CONSOLE is not set
780CONFIG_HW_CONSOLE=y
781# CONFIG_VT_HW_CONSOLE_BINDING is not set
782CONFIG_DEVKMEM=y
783# CONFIG_SERIAL_NONSTANDARD is not set
784
785#
786# Serial drivers
787#
788CONFIG_SERIAL_8250=m
789# CONFIG_SERIAL_8250_CS is not set
790CONFIG_SERIAL_8250_NR_UARTS=5
791CONFIG_SERIAL_8250_RUNTIME_UARTS=5
792# CONFIG_SERIAL_8250_EXTENDED is not set
793
794#
795# Non-8250 serial port support
796#
797CONFIG_SERIAL_PXA=y
798CONFIG_SERIAL_PXA_CONSOLE=y
799CONFIG_SERIAL_CORE=y
800CONFIG_SERIAL_CORE_CONSOLE=y
801CONFIG_UNIX98_PTYS=y
802# CONFIG_LEGACY_PTYS is not set
803# CONFIG_IPMI_HANDLER is not set
804CONFIG_HW_RANDOM=m
805# CONFIG_NVRAM is not set
806# CONFIG_DTLK is not set
807# CONFIG_R3964 is not set
808
809#
810# PCMCIA character devices
811#
812# CONFIG_SYNCLINK_CS is not set
813# CONFIG_CARDMAN_4000 is not set
814# CONFIG_CARDMAN_4040 is not set
815# CONFIG_IPWIRELESS is not set
816# CONFIG_RAW_DRIVER is not set
817# CONFIG_TCG_TPM is not set
818CONFIG_DEVPORT=y
819CONFIG_I2C=y
820CONFIG_I2C_BOARDINFO=y
821CONFIG_I2C_CHARDEV=y
822# CONFIG_I2C_HELPER_AUTO is not set
823
824#
825# I2C Algorithms
826#
827CONFIG_I2C_ALGOBIT=y
828# CONFIG_I2C_ALGOPCF is not set
829# CONFIG_I2C_ALGOPCA is not set
830
831#
832# I2C Hardware Bus support
833#
834
835#
836# I2C system bus drivers (mostly embedded / system-on-chip)
837#
838CONFIG_I2C_GPIO=y
839# CONFIG_I2C_OCORES is not set
840CONFIG_I2C_PXA=y
841# CONFIG_I2C_PXA_SLAVE is not set
842# CONFIG_I2C_SIMTEC is not set
843
844#
845# External I2C/SMBus adapter drivers
846#
847# CONFIG_I2C_PARPORT_LIGHT is not set
848# CONFIG_I2C_TAOS_EVM is not set
849# CONFIG_I2C_TINY_USB is not set
850
851#
852# Other I2C/SMBus bus drivers
853#
854# CONFIG_I2C_ELEKTOR is not set
855# CONFIG_I2C_PCA_ISA is not set
856# CONFIG_I2C_PCA_PLATFORM is not set
857# CONFIG_I2C_STUB is not set
858
859#
860# Miscellaneous I2C Chip support
861#
862# CONFIG_DS1682 is not set
863# CONFIG_AT24 is not set
864# CONFIG_SENSORS_EEPROM is not set
865# CONFIG_SENSORS_PCF8574 is not set
866# CONFIG_PCF8575 is not set
867# CONFIG_SENSORS_PCA9539 is not set
868# CONFIG_SENSORS_PCF8591 is not set
869# CONFIG_TPS65010 is not set
870# CONFIG_SENSORS_MAX6875 is not set
871# CONFIG_SENSORS_TSL2550 is not set
872# CONFIG_I2C_DEBUG_CORE is not set
873# CONFIG_I2C_DEBUG_ALGO is not set
874# CONFIG_I2C_DEBUG_BUS is not set
875# CONFIG_I2C_DEBUG_CHIP is not set
876# CONFIG_SPI is not set
877CONFIG_ARCH_REQUIRE_GPIOLIB=y
878CONFIG_GPIOLIB=y
879# CONFIG_DEBUG_GPIO is not set
880CONFIG_GPIO_SYSFS=y
881
882#
883# I2C GPIO expanders:
884#
885# CONFIG_GPIO_MAX732X is not set
886# CONFIG_GPIO_PCA953X is not set
887# CONFIG_GPIO_PCF857X is not set
888
889#
890# PCI GPIO expanders:
891#
892
893#
894# SPI GPIO expanders:
895#
896# CONFIG_W1 is not set
897# CONFIG_POWER_SUPPLY is not set
898CONFIG_HWMON=y
899# CONFIG_HWMON_VID is not set
900# CONFIG_SENSORS_AD7414 is not set
901# CONFIG_SENSORS_AD7418 is not set
902# CONFIG_SENSORS_ADM1021 is not set
903# CONFIG_SENSORS_ADM1025 is not set
904# CONFIG_SENSORS_ADM1026 is not set
905# CONFIG_SENSORS_ADM1029 is not set
906# CONFIG_SENSORS_ADM1031 is not set
907# CONFIG_SENSORS_ADM9240 is not set
908# CONFIG_SENSORS_ADT7470 is not set
909# CONFIG_SENSORS_ADT7473 is not set
910# CONFIG_SENSORS_ATXP1 is not set
911# CONFIG_SENSORS_DS1621 is not set
912# CONFIG_SENSORS_F71805F is not set
913# CONFIG_SENSORS_F71882FG is not set
914# CONFIG_SENSORS_F75375S is not set
915# CONFIG_SENSORS_GL518SM is not set
916# CONFIG_SENSORS_GL520SM is not set
917# CONFIG_SENSORS_IT87 is not set
918# CONFIG_SENSORS_LM63 is not set
919# CONFIG_SENSORS_LM75 is not set
920# CONFIG_SENSORS_LM77 is not set
921# CONFIG_SENSORS_LM78 is not set
922# CONFIG_SENSORS_LM80 is not set
923# CONFIG_SENSORS_LM83 is not set
924# CONFIG_SENSORS_LM85 is not set
925# CONFIG_SENSORS_LM87 is not set
926# CONFIG_SENSORS_LM90 is not set
927# CONFIG_SENSORS_LM92 is not set
928# CONFIG_SENSORS_LM93 is not set
929# CONFIG_SENSORS_MAX1619 is not set
930# CONFIG_SENSORS_MAX6650 is not set
931# CONFIG_SENSORS_PC87360 is not set
932# CONFIG_SENSORS_PC87427 is not set
933# CONFIG_SENSORS_DME1737 is not set
934# CONFIG_SENSORS_SMSC47M1 is not set
935# CONFIG_SENSORS_SMSC47M192 is not set
936# CONFIG_SENSORS_SMSC47B397 is not set
937# CONFIG_SENSORS_ADS7828 is not set
938# CONFIG_SENSORS_THMC50 is not set
939# CONFIG_SENSORS_VT1211 is not set
940# CONFIG_SENSORS_W83781D is not set
941# CONFIG_SENSORS_W83791D is not set
942# CONFIG_SENSORS_W83792D is not set
943# CONFIG_SENSORS_W83793 is not set
944# CONFIG_SENSORS_W83L785TS is not set
945# CONFIG_SENSORS_W83L786NG is not set
946# CONFIG_SENSORS_W83627HF is not set
947# CONFIG_SENSORS_W83627EHF is not set
948# CONFIG_HWMON_DEBUG_CHIP is not set
949CONFIG_WATCHDOG=y
950# CONFIG_WATCHDOG_NOWAYOUT is not set
951
952#
953# Watchdog Device Drivers
954#
955# CONFIG_SOFT_WATCHDOG is not set
956# CONFIG_SA1100_WATCHDOG is not set
957
958#
959# ISA-based Watchdog Cards
960#
961# CONFIG_PCWATCHDOG is not set
962# CONFIG_MIXCOMWD is not set
963# CONFIG_WDT is not set
964
965#
966# USB-based Watchdog Cards
967#
968# CONFIG_USBPCWATCHDOG is not set
969
970#
971# Sonics Silicon Backplane
972#
973CONFIG_SSB_POSSIBLE=y
974# CONFIG_SSB is not set
975
976#
977# Multifunction device drivers
978#
979# CONFIG_MFD_CORE is not set
980# CONFIG_MFD_SM501 is not set
981# CONFIG_HTC_EGPIO is not set
982# CONFIG_HTC_PASIC3 is not set
983# CONFIG_MFD_TMIO is not set
984# CONFIG_MFD_T7L66XB is not set
985# CONFIG_MFD_TC6387XB is not set
986# CONFIG_MFD_TC6393XB is not set
987
988#
989# Multimedia devices
990#
991
992#
993# Multimedia core support
994#
995# CONFIG_VIDEO_DEV is not set
996# CONFIG_DVB_CORE is not set
997# CONFIG_VIDEO_MEDIA is not set
998
999#
1000# Multimedia drivers
1001#
1002# CONFIG_DAB is not set
1003
1004#
1005# Graphics support
1006#
1007# CONFIG_VGASTATE is not set
1008# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1009CONFIG_FB=y
1010# CONFIG_FIRMWARE_EDID is not set
1011# CONFIG_FB_DDC is not set
1012CONFIG_FB_CFB_FILLRECT=m
1013CONFIG_FB_CFB_COPYAREA=m
1014CONFIG_FB_CFB_IMAGEBLIT=m
1015# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
1016# CONFIG_FB_SYS_FILLRECT is not set
1017# CONFIG_FB_SYS_COPYAREA is not set
1018# CONFIG_FB_SYS_IMAGEBLIT is not set
1019# CONFIG_FB_FOREIGN_ENDIAN is not set
1020# CONFIG_FB_SYS_FOPS is not set
1021# CONFIG_FB_SVGALIB is not set
1022# CONFIG_FB_MACMODES is not set
1023# CONFIG_FB_BACKLIGHT is not set
1024# CONFIG_FB_MODE_HELPERS is not set
1025# CONFIG_FB_TILEBLITTING is not set
1026
1027#
1028# Frame buffer hardware drivers
1029#
1030# CONFIG_FB_S1D13XXX is not set
1031CONFIG_FB_PXA=m
1032# CONFIG_FB_PXA_SMARTPANEL is not set
1033CONFIG_FB_PXA_PARAMETERS=y
1034# CONFIG_FB_MBX is not set
1035# CONFIG_FB_W100 is not set
1036# CONFIG_FB_AM200EPD is not set
1037# CONFIG_FB_VIRTUAL is not set
1038CONFIG_BACKLIGHT_LCD_SUPPORT=y
1039CONFIG_LCD_CLASS_DEVICE=m
1040# CONFIG_LCD_ILI9320 is not set
1041# CONFIG_LCD_PLATFORM is not set
1042CONFIG_BACKLIGHT_CLASS_DEVICE=m
1043# CONFIG_BACKLIGHT_CORGI is not set
1044CONFIG_BACKLIGHT_PWM=m
1045
1046#
1047# Display device support
1048#
1049# CONFIG_DISPLAY_SUPPORT is not set
1050
1051#
1052# Console display driver support
1053#
1054# CONFIG_VGA_CONSOLE is not set
1055# CONFIG_MDA_CONSOLE is not set
1056CONFIG_DUMMY_CONSOLE=y
1057CONFIG_FRAMEBUFFER_CONSOLE=m
1058# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
1059# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
1060# CONFIG_FONTS is not set
1061CONFIG_FONT_8x8=y
1062CONFIG_FONT_8x16=y
1063CONFIG_LOGO=y
1064CONFIG_LOGO_LINUX_MONO=y
1065CONFIG_LOGO_LINUX_VGA16=y
1066CONFIG_LOGO_LINUX_CLUT224=y
1067CONFIG_SOUND=m
1068CONFIG_SND=m
1069CONFIG_SND_TIMER=m
1070CONFIG_SND_PCM=m
1071# CONFIG_SND_SEQUENCER is not set
1072CONFIG_SND_OSSEMUL=y
1073CONFIG_SND_MIXER_OSS=m
1074CONFIG_SND_PCM_OSS=m
1075CONFIG_SND_PCM_OSS_PLUGINS=y
1076# CONFIG_SND_DYNAMIC_MINORS is not set
1077CONFIG_SND_SUPPORT_OLD_API=y
1078CONFIG_SND_VERBOSE_PROCFS=y
1079# CONFIG_SND_VERBOSE_PRINTK is not set
1080# CONFIG_SND_DEBUG is not set
1081CONFIG_SND_VMASTER=y
1082CONFIG_SND_AC97_CODEC=m
1083CONFIG_SND_DRIVERS=y
1084# CONFIG_SND_DUMMY is not set
1085# CONFIG_SND_MTPAV is not set
1086# CONFIG_SND_SERIAL_U16550 is not set
1087# CONFIG_SND_MPU401 is not set
1088# CONFIG_SND_AC97_POWER_SAVE is not set
1089CONFIG_SND_ARM=y
1090CONFIG_SND_PXA2XX_PCM=m
1091CONFIG_SND_PXA2XX_AC97=m
1092CONFIG_SND_USB=y
1093# CONFIG_SND_USB_AUDIO is not set
1094# CONFIG_SND_USB_CAIAQ is not set
1095CONFIG_SND_PCMCIA=y
1096# CONFIG_SND_VXPOCKET is not set
1097# CONFIG_SND_PDAUDIOCF is not set
1098# CONFIG_SND_SOC is not set
1099# CONFIG_SOUND_PRIME is not set
1100CONFIG_AC97_BUS=m
1101CONFIG_HID_SUPPORT=y
1102CONFIG_HID=y
1103# CONFIG_HID_DEBUG is not set
1104# CONFIG_HIDRAW is not set
1105
1106#
1107# USB Input Devices
1108#
1109CONFIG_USB_HID=m
1110# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1111# CONFIG_HID_FF is not set
1112# CONFIG_USB_HIDDEV is not set
1113
1114#
1115# USB HID Boot Protocol drivers
1116#
1117# CONFIG_USB_KBD is not set
1118# CONFIG_USB_MOUSE is not set
1119CONFIG_USB_SUPPORT=y
1120CONFIG_USB_ARCH_HAS_HCD=y
1121# CONFIG_USB_ARCH_HAS_OHCI is not set
1122# CONFIG_USB_ARCH_HAS_EHCI is not set
1123CONFIG_USB=m
1124# CONFIG_USB_DEBUG is not set
1125# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
1126
1127#
1128# Miscellaneous USB options
1129#
1130CONFIG_USB_DEVICEFS=y
1131CONFIG_USB_DEVICE_CLASS=y
1132# CONFIG_USB_DYNAMIC_MINORS is not set
1133CONFIG_USB_SUSPEND=y
1134# CONFIG_USB_OTG is not set
1135# CONFIG_USB_OTG_WHITELIST is not set
1136# CONFIG_USB_OTG_BLACKLIST_HUB is not set
1137# CONFIG_USB_MON is not set
1138
1139#
1140# USB Host Controller Drivers
1141#
1142# CONFIG_USB_C67X00_HCD is not set
1143CONFIG_USB_ISP116X_HCD=m
1144# CONFIG_USB_ISP1760_HCD is not set
1145CONFIG_USB_SL811_HCD=m
1146# CONFIG_USB_SL811_CS is not set
1147CONFIG_USB_R8A66597_HCD=m
1148# CONFIG_USB_MUSB_HDRC is not set
1149# CONFIG_USB_GADGET_MUSB_HDRC is not set
1150
1151#
1152# USB Device Class drivers
1153#
1154CONFIG_USB_ACM=m
1155# CONFIG_USB_PRINTER is not set
1156# CONFIG_USB_WDM is not set
1157
1158#
1159# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1160#
1161
1162#
1163# may also be needed; see USB_STORAGE Help for more information
1164#
1165CONFIG_USB_STORAGE=m
1166# CONFIG_USB_STORAGE_DEBUG is not set
1167# CONFIG_USB_STORAGE_DATAFAB is not set
1168# CONFIG_USB_STORAGE_FREECOM is not set
1169# CONFIG_USB_STORAGE_ISD200 is not set
1170# CONFIG_USB_STORAGE_DPCM is not set
1171# CONFIG_USB_STORAGE_USBAT is not set
1172# CONFIG_USB_STORAGE_SDDR09 is not set
1173# CONFIG_USB_STORAGE_SDDR55 is not set
1174# CONFIG_USB_STORAGE_JUMPSHOT is not set
1175# CONFIG_USB_STORAGE_ALAUDA is not set
1176# CONFIG_USB_STORAGE_ONETOUCH is not set
1177# CONFIG_USB_STORAGE_KARMA is not set
1178# CONFIG_USB_STORAGE_SIERRA is not set
1179# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
1180# CONFIG_USB_LIBUSUAL is not set
1181
1182#
1183# USB Imaging devices
1184#
1185# CONFIG_USB_MDC800 is not set
1186# CONFIG_USB_MICROTEK is not set
1187
1188#
1189# USB port drivers
1190#
1191CONFIG_USB_SERIAL=m
1192# CONFIG_USB_EZUSB is not set
1193CONFIG_USB_SERIAL_GENERIC=y
1194# CONFIG_USB_SERIAL_AIRCABLE is not set
1195# CONFIG_USB_SERIAL_ARK3116 is not set
1196# CONFIG_USB_SERIAL_BELKIN is not set
1197# CONFIG_USB_SERIAL_CH341 is not set
1198# CONFIG_USB_SERIAL_WHITEHEAT is not set
1199# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
1200# CONFIG_USB_SERIAL_CP2101 is not set
1201# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
1202# CONFIG_USB_SERIAL_EMPEG is not set
1203# CONFIG_USB_SERIAL_FTDI_SIO is not set
1204# CONFIG_USB_SERIAL_FUNSOFT is not set
1205# CONFIG_USB_SERIAL_VISOR is not set
1206# CONFIG_USB_SERIAL_IPAQ is not set
1207# CONFIG_USB_SERIAL_IR is not set
1208# CONFIG_USB_SERIAL_EDGEPORT is not set
1209# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
1210# CONFIG_USB_SERIAL_GARMIN is not set
1211# CONFIG_USB_SERIAL_IPW is not set
1212# CONFIG_USB_SERIAL_IUU is not set
1213# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
1214# CONFIG_USB_SERIAL_KEYSPAN is not set
1215# CONFIG_USB_SERIAL_KLSI is not set
1216# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1217CONFIG_USB_SERIAL_MCT_U232=m
1218# CONFIG_USB_SERIAL_MOS7720 is not set
1219# CONFIG_USB_SERIAL_MOS7840 is not set
1220# CONFIG_USB_SERIAL_MOTOROLA is not set
1221# CONFIG_USB_SERIAL_NAVMAN is not set
1222# CONFIG_USB_SERIAL_PL2303 is not set
1223# CONFIG_USB_SERIAL_OTI6858 is not set
1224# CONFIG_USB_SERIAL_SPCP8X5 is not set
1225# CONFIG_USB_SERIAL_HP4X is not set
1226# CONFIG_USB_SERIAL_SAFE is not set
1227# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
1228# CONFIG_USB_SERIAL_TI is not set
1229# CONFIG_USB_SERIAL_CYBERJACK is not set
1230# CONFIG_USB_SERIAL_XIRCOM is not set
1231# CONFIG_USB_SERIAL_OPTION is not set
1232# CONFIG_USB_SERIAL_OMNINET is not set
1233# CONFIG_USB_SERIAL_DEBUG is not set
1234
1235#
1236# USB Miscellaneous drivers
1237#
1238# CONFIG_USB_EMI62 is not set
1239# CONFIG_USB_EMI26 is not set
1240# CONFIG_USB_ADUTUX is not set
1241# CONFIG_USB_RIO500 is not set
1242# CONFIG_USB_LEGOTOWER is not set
1243# CONFIG_USB_LCD is not set
1244# CONFIG_USB_BERRY_CHARGE is not set
1245# CONFIG_USB_LED is not set
1246# CONFIG_USB_CYPRESS_CY7C63 is not set
1247# CONFIG_USB_CYTHERM is not set
1248# CONFIG_USB_PHIDGET is not set
1249# CONFIG_USB_IDMOUSE is not set
1250# CONFIG_USB_FTDI_ELAN is not set
1251# CONFIG_USB_APPLEDISPLAY is not set
1252# CONFIG_USB_LD is not set
1253# CONFIG_USB_TRANCEVIBRATOR is not set
1254# CONFIG_USB_IOWARRIOR is not set
1255# CONFIG_USB_TEST is not set
1256# CONFIG_USB_ISIGHTFW is not set
1257CONFIG_USB_GADGET=m
1258# CONFIG_USB_GADGET_DEBUG is not set
1259# CONFIG_USB_GADGET_DEBUG_FILES is not set
1260CONFIG_USB_GADGET_SELECTED=y
1261# CONFIG_USB_GADGET_AMD5536UDC is not set
1262# CONFIG_USB_GADGET_ATMEL_USBA is not set
1263# CONFIG_USB_GADGET_FSL_USB2 is not set
1264# CONFIG_USB_GADGET_NET2280 is not set
1265CONFIG_USB_GADGET_PXA25X=y
1266CONFIG_USB_PXA25X=m
1267# CONFIG_USB_PXA25X_SMALL is not set
1268# CONFIG_USB_GADGET_M66592 is not set
1269# CONFIG_USB_GADGET_PXA27X is not set
1270# CONFIG_USB_GADGET_GOKU is not set
1271# CONFIG_USB_GADGET_LH7A40X is not set
1272# CONFIG_USB_GADGET_OMAP is not set
1273# CONFIG_USB_GADGET_S3C2410 is not set
1274# CONFIG_USB_GADGET_AT91 is not set
1275# CONFIG_USB_GADGET_DUMMY_HCD is not set
1276# CONFIG_USB_GADGET_DUALSPEED is not set
1277# CONFIG_USB_ZERO is not set
1278CONFIG_USB_ETH=m
1279CONFIG_USB_ETH_RNDIS=y
1280CONFIG_USB_GADGETFS=m
1281CONFIG_USB_FILE_STORAGE=m
1282# CONFIG_USB_FILE_STORAGE_TEST is not set
1283CONFIG_USB_G_SERIAL=m
1284# CONFIG_USB_MIDI_GADGET is not set
1285CONFIG_USB_G_PRINTER=m
1286# CONFIG_USB_CDC_COMPOSITE is not set
1287# CONFIG_MMC is not set
1288# CONFIG_NEW_LEDS is not set
1289CONFIG_RTC_LIB=y
1290CONFIG_RTC_CLASS=m
1291
1292#
1293# RTC interfaces
1294#
1295CONFIG_RTC_INTF_SYSFS=y
1296CONFIG_RTC_INTF_PROC=y
1297CONFIG_RTC_INTF_DEV=y
1298# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1299# CONFIG_RTC_DRV_TEST is not set
1300
1301#
1302# I2C RTC drivers
1303#
1304CONFIG_RTC_DRV_DS1307=m
1305# CONFIG_RTC_DRV_DS1374 is not set
1306# CONFIG_RTC_DRV_DS1672 is not set
1307# CONFIG_RTC_DRV_MAX6900 is not set
1308# CONFIG_RTC_DRV_RS5C372 is not set
1309# CONFIG_RTC_DRV_ISL1208 is not set
1310# CONFIG_RTC_DRV_X1205 is not set
1311# CONFIG_RTC_DRV_PCF8563 is not set
1312# CONFIG_RTC_DRV_PCF8583 is not set
1313# CONFIG_RTC_DRV_M41T80 is not set
1314# CONFIG_RTC_DRV_S35390A is not set
1315# CONFIG_RTC_DRV_FM3130 is not set
1316
1317#
1318# SPI RTC drivers
1319#
1320
1321#
1322# Platform RTC drivers
1323#
1324# CONFIG_RTC_DRV_CMOS is not set
1325# CONFIG_RTC_DRV_DS1511 is not set
1326# CONFIG_RTC_DRV_DS1553 is not set
1327# CONFIG_RTC_DRV_DS1742 is not set
1328# CONFIG_RTC_DRV_STK17TA8 is not set
1329# CONFIG_RTC_DRV_M48T86 is not set
1330# CONFIG_RTC_DRV_M48T59 is not set
1331# CONFIG_RTC_DRV_V3020 is not set
1332
1333#
1334# on-CPU RTC drivers
1335#
1336CONFIG_RTC_DRV_SA1100=m
1337# CONFIG_DMADEVICES is not set
1338
1339#
1340# Voltage and Current regulators
1341#
1342# CONFIG_REGULATOR is not set
1343# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
1344# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
1345# CONFIG_REGULATOR_BQ24022 is not set
1346# CONFIG_UIO is not set
1347
1348#
1349# File systems
1350#
1351CONFIG_EXT2_FS=m
1352# CONFIG_EXT2_FS_XATTR is not set
1353# CONFIG_EXT2_FS_XIP is not set
1354CONFIG_EXT3_FS=m
1355# CONFIG_EXT3_FS_XATTR is not set
1356# CONFIG_EXT4DEV_FS is not set
1357CONFIG_JBD=m
1358# CONFIG_REISERFS_FS is not set
1359# CONFIG_JFS_FS is not set
1360# CONFIG_FS_POSIX_ACL is not set
1361# CONFIG_XFS_FS is not set
1362# CONFIG_OCFS2_FS is not set
1363# CONFIG_DNOTIFY is not set
1364CONFIG_INOTIFY=y
1365CONFIG_INOTIFY_USER=y
1366# CONFIG_QUOTA is not set
1367# CONFIG_AUTOFS_FS is not set
1368# CONFIG_AUTOFS4_FS is not set
1369# CONFIG_FUSE_FS is not set
1370
1371#
1372# CD-ROM/DVD Filesystems
1373#
1374# CONFIG_ISO9660_FS is not set
1375# CONFIG_UDF_FS is not set
1376
1377#
1378# DOS/FAT/NT Filesystems
1379#
1380CONFIG_FAT_FS=m
1381# CONFIG_MSDOS_FS is not set
1382CONFIG_VFAT_FS=m
1383CONFIG_FAT_DEFAULT_CODEPAGE=437
1384CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1385# CONFIG_NTFS_FS is not set
1386
1387#
1388# Pseudo filesystems
1389#
1390CONFIG_PROC_FS=y
1391CONFIG_PROC_SYSCTL=y
1392CONFIG_SYSFS=y
1393CONFIG_TMPFS=y
1394# CONFIG_TMPFS_POSIX_ACL is not set
1395# CONFIG_HUGETLB_PAGE is not set
1396# CONFIG_CONFIGFS_FS is not set
1397
1398#
1399# Miscellaneous filesystems
1400#
1401# CONFIG_ADFS_FS is not set
1402# CONFIG_AFFS_FS is not set
1403# CONFIG_HFS_FS is not set
1404# CONFIG_HFSPLUS_FS is not set
1405# CONFIG_BEFS_FS is not set
1406# CONFIG_BFS_FS is not set
1407# CONFIG_EFS_FS is not set
1408CONFIG_JFFS2_FS=y
1409CONFIG_JFFS2_FS_DEBUG=0
1410CONFIG_JFFS2_FS_WRITEBUFFER=y
1411# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1412# CONFIG_JFFS2_SUMMARY is not set
1413# CONFIG_JFFS2_FS_XATTR is not set
1414# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1415CONFIG_JFFS2_ZLIB=y
1416# CONFIG_JFFS2_LZO is not set
1417CONFIG_JFFS2_RTIME=y
1418# CONFIG_JFFS2_RUBIN is not set
1419# CONFIG_CRAMFS is not set
1420# CONFIG_VXFS_FS is not set
1421# CONFIG_MINIX_FS is not set
1422# CONFIG_OMFS_FS is not set
1423# CONFIG_HPFS_FS is not set
1424# CONFIG_QNX4FS_FS is not set
1425# CONFIG_ROMFS_FS is not set
1426# CONFIG_SYSV_FS is not set
1427# CONFIG_UFS_FS is not set
1428CONFIG_NETWORK_FILESYSTEMS=y
1429CONFIG_NFS_FS=y
1430CONFIG_NFS_V3=y
1431# CONFIG_NFS_V3_ACL is not set
1432# CONFIG_NFS_V4 is not set
1433CONFIG_ROOT_NFS=y
1434CONFIG_NFSD=m
1435CONFIG_NFSD_V3=y
1436# CONFIG_NFSD_V3_ACL is not set
1437# CONFIG_NFSD_V4 is not set
1438CONFIG_LOCKD=y
1439CONFIG_LOCKD_V4=y
1440CONFIG_EXPORTFS=m
1441CONFIG_NFS_COMMON=y
1442CONFIG_SUNRPC=y
1443# CONFIG_RPCSEC_GSS_KRB5 is not set
1444# CONFIG_RPCSEC_GSS_SPKM3 is not set
1445# CONFIG_SMB_FS is not set
1446# CONFIG_CIFS is not set
1447# CONFIG_NCP_FS is not set
1448# CONFIG_CODA_FS is not set
1449# CONFIG_AFS_FS is not set
1450
1451#
1452# Partition Types
1453#
1454CONFIG_PARTITION_ADVANCED=y
1455# CONFIG_ACORN_PARTITION is not set
1456# CONFIG_OSF_PARTITION is not set
1457# CONFIG_AMIGA_PARTITION is not set
1458# CONFIG_ATARI_PARTITION is not set
1459# CONFIG_MAC_PARTITION is not set
1460CONFIG_MSDOS_PARTITION=y
1461# CONFIG_BSD_DISKLABEL is not set
1462# CONFIG_MINIX_SUBPARTITION is not set
1463# CONFIG_SOLARIS_X86_PARTITION is not set
1464# CONFIG_UNIXWARE_DISKLABEL is not set
1465# CONFIG_LDM_PARTITION is not set
1466# CONFIG_SGI_PARTITION is not set
1467# CONFIG_ULTRIX_PARTITION is not set
1468# CONFIG_SUN_PARTITION is not set
1469# CONFIG_KARMA_PARTITION is not set
1470# CONFIG_EFI_PARTITION is not set
1471# CONFIG_SYSV68_PARTITION is not set
1472CONFIG_NLS=m
1473CONFIG_NLS_DEFAULT="iso8859-1"
1474CONFIG_NLS_CODEPAGE_437=m
1475# CONFIG_NLS_CODEPAGE_737 is not set
1476# CONFIG_NLS_CODEPAGE_775 is not set
1477CONFIG_NLS_CODEPAGE_850=m
1478# CONFIG_NLS_CODEPAGE_852 is not set
1479# CONFIG_NLS_CODEPAGE_855 is not set
1480# CONFIG_NLS_CODEPAGE_857 is not set
1481# CONFIG_NLS_CODEPAGE_860 is not set
1482# CONFIG_NLS_CODEPAGE_861 is not set
1483# CONFIG_NLS_CODEPAGE_862 is not set
1484# CONFIG_NLS_CODEPAGE_863 is not set
1485# CONFIG_NLS_CODEPAGE_864 is not set
1486# CONFIG_NLS_CODEPAGE_865 is not set
1487# CONFIG_NLS_CODEPAGE_866 is not set
1488# CONFIG_NLS_CODEPAGE_869 is not set
1489# CONFIG_NLS_CODEPAGE_936 is not set
1490# CONFIG_NLS_CODEPAGE_950 is not set
1491# CONFIG_NLS_CODEPAGE_932 is not set
1492# CONFIG_NLS_CODEPAGE_949 is not set
1493# CONFIG_NLS_CODEPAGE_874 is not set
1494# CONFIG_NLS_ISO8859_8 is not set
1495# CONFIG_NLS_CODEPAGE_1250 is not set
1496# CONFIG_NLS_CODEPAGE_1251 is not set
1497# CONFIG_NLS_ASCII is not set
1498CONFIG_NLS_ISO8859_1=m
1499# CONFIG_NLS_ISO8859_2 is not set
1500# CONFIG_NLS_ISO8859_3 is not set
1501# CONFIG_NLS_ISO8859_4 is not set
1502# CONFIG_NLS_ISO8859_5 is not set
1503# CONFIG_NLS_ISO8859_6 is not set
1504# CONFIG_NLS_ISO8859_7 is not set
1505# CONFIG_NLS_ISO8859_9 is not set
1506# CONFIG_NLS_ISO8859_13 is not set
1507# CONFIG_NLS_ISO8859_14 is not set
1508CONFIG_NLS_ISO8859_15=m
1509# CONFIG_NLS_KOI8_R is not set
1510# CONFIG_NLS_KOI8_U is not set
1511CONFIG_NLS_UTF8=m
1512# CONFIG_DLM is not set
1513
1514#
1515# Kernel hacking
1516#
1517# CONFIG_PRINTK_TIME is not set
1518CONFIG_ENABLE_WARN_DEPRECATED=y
1519CONFIG_ENABLE_MUST_CHECK=y
1520CONFIG_FRAME_WARN=1024
1521CONFIG_MAGIC_SYSRQ=y
1522# CONFIG_UNUSED_SYMBOLS is not set
1523# CONFIG_DEBUG_FS is not set
1524# CONFIG_HEADERS_CHECK is not set
1525CONFIG_DEBUG_KERNEL=y
1526# CONFIG_DEBUG_SHIRQ is not set
1527CONFIG_DETECT_SOFTLOCKUP=y
1528# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1529CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1530CONFIG_SCHED_DEBUG=y
1531# CONFIG_SCHEDSTATS is not set
1532# CONFIG_TIMER_STATS is not set
1533# CONFIG_DEBUG_OBJECTS is not set
1534# CONFIG_DEBUG_SLAB is not set
1535# CONFIG_DEBUG_RT_MUTEXES is not set
1536# CONFIG_RT_MUTEX_TESTER is not set
1537# CONFIG_DEBUG_SPINLOCK is not set
1538CONFIG_DEBUG_MUTEXES=y
1539# CONFIG_DEBUG_LOCK_ALLOC is not set
1540# CONFIG_PROVE_LOCKING is not set
1541# CONFIG_LOCK_STAT is not set
1542# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1543# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1544# CONFIG_DEBUG_KOBJECT is not set
1545CONFIG_DEBUG_BUGVERBOSE=y
1546# CONFIG_DEBUG_INFO is not set
1547# CONFIG_DEBUG_VM is not set
1548# CONFIG_DEBUG_WRITECOUNT is not set
1549# CONFIG_DEBUG_MEMORY_INIT is not set
1550# CONFIG_DEBUG_LIST is not set
1551# CONFIG_DEBUG_SG is not set
1552CONFIG_FRAME_POINTER=y
1553# CONFIG_BOOT_PRINTK_DELAY is not set
1554# CONFIG_RCU_TORTURE_TEST is not set
1555# CONFIG_BACKTRACE_SELF_TEST is not set
1556# CONFIG_FAULT_INJECTION is not set
1557# CONFIG_LATENCYTOP is not set
1558CONFIG_SYSCTL_SYSCALL_CHECK=y
1559CONFIG_HAVE_FTRACE=y
1560CONFIG_HAVE_DYNAMIC_FTRACE=y
1561# CONFIG_FTRACE is not set
1562# CONFIG_IRQSOFF_TRACER is not set
1563# CONFIG_SCHED_TRACER is not set
1564# CONFIG_CONTEXT_SWITCH_TRACER is not set
1565# CONFIG_SAMPLES is not set
1566CONFIG_HAVE_ARCH_KGDB=y
1567# CONFIG_KGDB is not set
1568# CONFIG_DEBUG_USER is not set
1569CONFIG_DEBUG_ERRORS=y
1570# CONFIG_DEBUG_STACK_USAGE is not set
1571# CONFIG_DEBUG_LL is not set
1572
1573#
1574# Security options
1575#
1576# CONFIG_KEYS is not set
1577# CONFIG_SECURITY is not set
1578# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1579CONFIG_CRYPTO=y
1580
1581#
1582# Crypto core or helper
1583#
1584CONFIG_CRYPTO_ALGAPI=m
1585CONFIG_CRYPTO_BLKCIPHER=m
1586CONFIG_CRYPTO_MANAGER=m
1587# CONFIG_CRYPTO_GF128MUL is not set
1588# CONFIG_CRYPTO_NULL is not set
1589# CONFIG_CRYPTO_CRYPTD is not set
1590# CONFIG_CRYPTO_AUTHENC is not set
1591# CONFIG_CRYPTO_TEST is not set
1592
1593#
1594# Authenticated Encryption with Associated Data
1595#
1596# CONFIG_CRYPTO_CCM is not set
1597# CONFIG_CRYPTO_GCM is not set
1598# CONFIG_CRYPTO_SEQIV is not set
1599
1600#
1601# Block modes
1602#
1603# CONFIG_CRYPTO_CBC is not set
1604# CONFIG_CRYPTO_CTR is not set
1605# CONFIG_CRYPTO_CTS is not set
1606CONFIG_CRYPTO_ECB=m
1607# CONFIG_CRYPTO_LRW is not set
1608# CONFIG_CRYPTO_PCBC is not set
1609# CONFIG_CRYPTO_XTS is not set
1610
1611#
1612# Hash modes
1613#
1614# CONFIG_CRYPTO_HMAC is not set
1615# CONFIG_CRYPTO_XCBC is not set
1616
1617#
1618# Digest
1619#
1620# CONFIG_CRYPTO_CRC32C is not set
1621# CONFIG_CRYPTO_MD4 is not set
1622# CONFIG_CRYPTO_MD5 is not set
1623# CONFIG_CRYPTO_MICHAEL_MIC is not set
1624# CONFIG_CRYPTO_RMD128 is not set
1625# CONFIG_CRYPTO_RMD160 is not set
1626# CONFIG_CRYPTO_RMD256 is not set
1627# CONFIG_CRYPTO_RMD320 is not set
1628# CONFIG_CRYPTO_SHA1 is not set
1629# CONFIG_CRYPTO_SHA256 is not set
1630# CONFIG_CRYPTO_SHA512 is not set
1631# CONFIG_CRYPTO_TGR192 is not set
1632# CONFIG_CRYPTO_WP512 is not set
1633
1634#
1635# Ciphers
1636#
1637# CONFIG_CRYPTO_AES is not set
1638# CONFIG_CRYPTO_ANUBIS is not set
1639CONFIG_CRYPTO_ARC4=m
1640# CONFIG_CRYPTO_BLOWFISH is not set
1641# CONFIG_CRYPTO_CAMELLIA is not set
1642# CONFIG_CRYPTO_CAST5 is not set
1643# CONFIG_CRYPTO_CAST6 is not set
1644# CONFIG_CRYPTO_DES is not set
1645# CONFIG_CRYPTO_FCRYPT is not set
1646# CONFIG_CRYPTO_KHAZAD is not set
1647# CONFIG_CRYPTO_SALSA20 is not set
1648# CONFIG_CRYPTO_SEED is not set
1649# CONFIG_CRYPTO_SERPENT is not set
1650# CONFIG_CRYPTO_TEA is not set
1651# CONFIG_CRYPTO_TWOFISH is not set
1652
1653#
1654# Compression
1655#
1656# CONFIG_CRYPTO_DEFLATE is not set
1657# CONFIG_CRYPTO_LZO is not set
1658CONFIG_CRYPTO_HW=y
1659
1660#
1661# Library routines
1662#
1663CONFIG_BITREVERSE=y
1664# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1665# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1666CONFIG_CRC_CCITT=m
1667# CONFIG_CRC16 is not set
1668CONFIG_CRC_T10DIF=m
1669# CONFIG_CRC_ITU_T is not set
1670CONFIG_CRC32=y
1671# CONFIG_CRC7 is not set
1672# CONFIG_LIBCRC32C is not set
1673CONFIG_ZLIB_INFLATE=y
1674CONFIG_ZLIB_DEFLATE=y
1675CONFIG_PLIST=y
1676CONFIG_HAS_IOMEM=y
1677CONFIG_HAS_IOPORT=y
1678CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/xm_x270_defconfig b/arch/arm/configs/xm_x2xx_defconfig
index aa40d91ce599..f891364deceb 100644
--- a/arch/arm/configs/xm_x270_defconfig
+++ b/arch/arm/configs/xm_x2xx_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25 3# Linux kernel version: 2.6.27-rc8
4# Sun May 11 15:12:52 2008 4# Sun Oct 5 11:05:36 2008
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y 7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -12,6 +12,7 @@ CONFIG_MMU=y
12# CONFIG_NO_IOPORT is not set 12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y 13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y 14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
15CONFIG_LOCKDEP_SUPPORT=y 16CONFIG_LOCKDEP_SUPPORT=y
16CONFIG_TRACE_IRQFLAGS_SUPPORT=y 17CONFIG_TRACE_IRQFLAGS_SUPPORT=y
17CONFIG_HARDIRQS_SW_RESEND=y 18CONFIG_HARDIRQS_SW_RESEND=y
@@ -24,6 +25,7 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
24CONFIG_ARCH_SUPPORTS_AOUT=y 25CONFIG_ARCH_SUPPORTS_AOUT=y
25CONFIG_ZONE_DMA=y 26CONFIG_ZONE_DMA=y
26CONFIG_ARCH_MTD_XIP=y 27CONFIG_ARCH_MTD_XIP=y
28CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
27CONFIG_VECTORS_BASE=0xffff0000 29CONFIG_VECTORS_BASE=0xffff0000
28CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 30CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
29 31
@@ -62,7 +64,6 @@ CONFIG_SYSCTL=y
62CONFIG_EMBEDDED=y 64CONFIG_EMBEDDED=y
63CONFIG_UID16=y 65CONFIG_UID16=y
64CONFIG_SYSCTL_SYSCALL=y 66CONFIG_SYSCTL_SYSCALL=y
65CONFIG_SYSCTL_SYSCALL_CHECK=y
66CONFIG_KALLSYMS=y 67CONFIG_KALLSYMS=y
67# CONFIG_KALLSYMS_ALL is not set 68# CONFIG_KALLSYMS_ALL is not set
68# CONFIG_KALLSYMS_EXTRA_PASS is not set 69# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -88,14 +89,21 @@ CONFIG_SLUB=y
88# CONFIG_MARKERS is not set 89# CONFIG_MARKERS is not set
89CONFIG_HAVE_OPROFILE=y 90CONFIG_HAVE_OPROFILE=y
90# CONFIG_KPROBES is not set 91# CONFIG_KPROBES is not set
92# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
93# CONFIG_HAVE_IOREMAP_PROT is not set
91CONFIG_HAVE_KPROBES=y 94CONFIG_HAVE_KPROBES=y
92CONFIG_HAVE_KRETPROBES=y 95CONFIG_HAVE_KRETPROBES=y
96# CONFIG_HAVE_ARCH_TRACEHOOK is not set
93# CONFIG_HAVE_DMA_ATTRS is not set 97# CONFIG_HAVE_DMA_ATTRS is not set
98# CONFIG_USE_GENERIC_SMP_HELPERS is not set
99CONFIG_HAVE_CLK=y
94# CONFIG_PROC_PAGE_MONITOR is not set 100# CONFIG_PROC_PAGE_MONITOR is not set
101CONFIG_HAVE_GENERIC_DMA_COHERENT=y
95CONFIG_RT_MUTEXES=y 102CONFIG_RT_MUTEXES=y
96# CONFIG_TINY_SHMEM is not set 103# CONFIG_TINY_SHMEM is not set
97CONFIG_BASE_SMALL=0 104CONFIG_BASE_SMALL=0
98CONFIG_MODULES=y 105CONFIG_MODULES=y
106# CONFIG_MODULE_FORCE_LOAD is not set
99CONFIG_MODULE_UNLOAD=y 107CONFIG_MODULE_UNLOAD=y
100# CONFIG_MODULE_FORCE_UNLOAD is not set 108# CONFIG_MODULE_FORCE_UNLOAD is not set
101# CONFIG_MODVERSIONS is not set 109# CONFIG_MODVERSIONS is not set
@@ -106,6 +114,7 @@ CONFIG_BLOCK=y
106# CONFIG_BLK_DEV_IO_TRACE is not set 114# CONFIG_BLK_DEV_IO_TRACE is not set
107# CONFIG_LSF is not set 115# CONFIG_LSF is not set
108# CONFIG_BLK_DEV_BSG is not set 116# CONFIG_BLK_DEV_BSG is not set
117# CONFIG_BLK_DEV_INTEGRITY is not set
109 118
110# 119#
111# IO Schedulers 120# IO Schedulers
@@ -131,7 +140,6 @@ CONFIG_CLASSIC_RCU=y
131# CONFIG_ARCH_AT91 is not set 140# CONFIG_ARCH_AT91 is not set
132# CONFIG_ARCH_CLPS7500 is not set 141# CONFIG_ARCH_CLPS7500 is not set
133# CONFIG_ARCH_CLPS711X is not set 142# CONFIG_ARCH_CLPS711X is not set
134# CONFIG_ARCH_CO285 is not set
135# CONFIG_ARCH_EBSA110 is not set 143# CONFIG_ARCH_EBSA110 is not set
136# CONFIG_ARCH_EP93XX is not set 144# CONFIG_ARCH_EP93XX is not set
137# CONFIG_ARCH_FOOTBRIDGE is not set 145# CONFIG_ARCH_FOOTBRIDGE is not set
@@ -145,8 +153,11 @@ CONFIG_CLASSIC_RCU=y
145# CONFIG_ARCH_IXP2000 is not set 153# CONFIG_ARCH_IXP2000 is not set
146# CONFIG_ARCH_IXP4XX is not set 154# CONFIG_ARCH_IXP4XX is not set
147# CONFIG_ARCH_L7200 is not set 155# CONFIG_ARCH_L7200 is not set
156# CONFIG_ARCH_KIRKWOOD is not set
148# CONFIG_ARCH_KS8695 is not set 157# CONFIG_ARCH_KS8695 is not set
149# CONFIG_ARCH_NS9XXX is not set 158# CONFIG_ARCH_NS9XXX is not set
159# CONFIG_ARCH_LOKI is not set
160# CONFIG_ARCH_MV78XX0 is not set
150# CONFIG_ARCH_MXC is not set 161# CONFIG_ARCH_MXC is not set
151# CONFIG_ARCH_ORION5X is not set 162# CONFIG_ARCH_ORION5X is not set
152# CONFIG_ARCH_PNX4008 is not set 163# CONFIG_ARCH_PNX4008 is not set
@@ -164,26 +175,32 @@ CONFIG_DMABOUNCE=y
164# 175#
165# Intel PXA2xx/PXA3xx Implementations 176# Intel PXA2xx/PXA3xx Implementations
166# 177#
167
168#
169# Select target boards
170#
171# CONFIG_ARCH_GUMSTIX is not set 178# CONFIG_ARCH_GUMSTIX is not set
172# CONFIG_ARCH_LUBBOCK is not set 179# CONFIG_ARCH_LUBBOCK is not set
173# CONFIG_MACH_LOGICPD_PXA270 is not set 180# CONFIG_MACH_LOGICPD_PXA270 is not set
174# CONFIG_MACH_MAINSTONE is not set 181# CONFIG_MACH_MAINSTONE is not set
182# CONFIG_MACH_MP900C is not set
175# CONFIG_ARCH_PXA_IDP is not set 183# CONFIG_ARCH_PXA_IDP is not set
176# CONFIG_PXA_SHARPSL is not set 184# CONFIG_PXA_SHARPSL is not set
185# CONFIG_ARCH_VIPER is not set
177# CONFIG_ARCH_PXA_ESERIES is not set 186# CONFIG_ARCH_PXA_ESERIES is not set
178# CONFIG_MACH_TRIZEPS4 is not set 187# CONFIG_TRIZEPS_PXA is not set
179CONFIG_MACH_EM_X270=y 188CONFIG_MACH_EM_X270=y
180# CONFIG_MACH_COLIBRI is not set 189# CONFIG_MACH_COLIBRI is not set
181# CONFIG_MACH_ZYLONITE is not set 190# CONFIG_MACH_ZYLONITE is not set
182# CONFIG_MACH_LITTLETON is not set 191# CONFIG_MACH_LITTLETON is not set
192# CONFIG_MACH_TAVOREVB is not set
193# CONFIG_MACH_SAAR is not set
183CONFIG_MACH_ARMCORE=y 194CONFIG_MACH_ARMCORE=y
195# CONFIG_MACH_CM_X300 is not set
184# CONFIG_MACH_MAGICIAN is not set 196# CONFIG_MACH_MAGICIAN is not set
197# CONFIG_MACH_MIOA701 is not set
185# CONFIG_MACH_PCM027 is not set 198# CONFIG_MACH_PCM027 is not set
199# CONFIG_ARCH_PXA_PALM is not set
200# CONFIG_PXA_EZX is not set
201CONFIG_PXA25x=y
186CONFIG_PXA27x=y 202CONFIG_PXA27x=y
203CONFIG_PXA_SSP=y
187# CONFIG_PXA_PWM is not set 204# CONFIG_PXA_PWM is not set
188 205
189# 206#
@@ -253,11 +270,17 @@ CONFIG_TICK_ONESHOT=y
253CONFIG_NO_HZ=y 270CONFIG_NO_HZ=y
254# CONFIG_HIGH_RES_TIMERS is not set 271# CONFIG_HIGH_RES_TIMERS is not set
255CONFIG_GENERIC_CLOCKEVENTS_BUILD=y 272CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
273CONFIG_VMSPLIT_3G=y
274# CONFIG_VMSPLIT_2G is not set
275# CONFIG_VMSPLIT_1G is not set
276CONFIG_PAGE_OFFSET=0xC0000000
256# CONFIG_PREEMPT is not set 277# CONFIG_PREEMPT is not set
257CONFIG_HZ=100 278CONFIG_HZ=100
258CONFIG_AEABI=y 279CONFIG_AEABI=y
259CONFIG_OABI_COMPAT=y 280CONFIG_OABI_COMPAT=y
260# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set 281CONFIG_ARCH_FLATMEM_HAS_HOLES=y
282# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
283# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
261CONFIG_SELECT_MEMORY_MODEL=y 284CONFIG_SELECT_MEMORY_MODEL=y
262CONFIG_FLATMEM_MANUAL=y 285CONFIG_FLATMEM_MANUAL=y
263# CONFIG_DISCONTIGMEM_MANUAL is not set 286# CONFIG_DISCONTIGMEM_MANUAL is not set
@@ -284,9 +307,10 @@ CONFIG_CMDLINE="root=1f03 mem=32M"
284# CONFIG_KEXEC is not set 307# CONFIG_KEXEC is not set
285 308
286# 309#
287# CPU Frequency scaling 310# CPU Power Management
288# 311#
289# CONFIG_CPU_FREQ is not set 312# CONFIG_CPU_FREQ is not set
313# CONFIG_CPU_IDLE is not set
290 314
291# 315#
292# Floating point emulation 316# Floating point emulation
@@ -316,10 +340,6 @@ CONFIG_SUSPEND=y
316CONFIG_SUSPEND_FREEZER=y 340CONFIG_SUSPEND_FREEZER=y
317CONFIG_APM_EMULATION=m 341CONFIG_APM_EMULATION=m
318CONFIG_ARCH_SUSPEND_POSSIBLE=y 342CONFIG_ARCH_SUSPEND_POSSIBLE=y
319
320#
321# Networking
322#
323CONFIG_NET=y 343CONFIG_NET=y
324 344
325# 345#
@@ -402,6 +422,7 @@ CONFIG_BT_HIDP=m
402# 422#
403CONFIG_BT_HCIUSB=m 423CONFIG_BT_HCIUSB=m
404CONFIG_BT_HCIUSB_SCO=y 424CONFIG_BT_HCIUSB_SCO=y
425# CONFIG_BT_HCIBTUSB is not set
405# CONFIG_BT_HCIBTSDIO is not set 426# CONFIG_BT_HCIBTSDIO is not set
406# CONFIG_BT_HCIUART is not set 427# CONFIG_BT_HCIUART is not set
407# CONFIG_BT_HCIBCM203X is not set 428# CONFIG_BT_HCIBCM203X is not set
@@ -419,6 +440,7 @@ CONFIG_BT_HCIUSB_SCO=y
419# 440#
420# CONFIG_CFG80211 is not set 441# CONFIG_CFG80211 is not set
421CONFIG_WIRELESS_EXT=y 442CONFIG_WIRELESS_EXT=y
443CONFIG_WIRELESS_EXT_SYSFS=y
422# CONFIG_MAC80211 is not set 444# CONFIG_MAC80211 is not set
423# CONFIG_IEEE80211 is not set 445# CONFIG_IEEE80211 is not set
424# CONFIG_RFKILL is not set 446# CONFIG_RFKILL is not set
@@ -435,6 +457,8 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
435CONFIG_STANDALONE=y 457CONFIG_STANDALONE=y
436CONFIG_PREVENT_FIRMWARE_BUILD=y 458CONFIG_PREVENT_FIRMWARE_BUILD=y
437CONFIG_FW_LOADER=m 459CONFIG_FW_LOADER=m
460CONFIG_FIRMWARE_IN_KERNEL=y
461CONFIG_EXTRA_FIRMWARE=""
438# CONFIG_DEBUG_DRIVER is not set 462# CONFIG_DEBUG_DRIVER is not set
439# CONFIG_DEBUG_DEVRES is not set 463# CONFIG_DEBUG_DEVRES is not set
440# CONFIG_SYS_HYPERVISOR is not set 464# CONFIG_SYS_HYPERVISOR is not set
@@ -527,6 +551,7 @@ CONFIG_MTD_NAND=y
527# CONFIG_MTD_NAND_ECC_SMC is not set 551# CONFIG_MTD_NAND_ECC_SMC is not set
528# CONFIG_MTD_NAND_MUSEUM_IDS is not set 552# CONFIG_MTD_NAND_MUSEUM_IDS is not set
529# CONFIG_MTD_NAND_H1900 is not set 553# CONFIG_MTD_NAND_H1900 is not set
554CONFIG_MTD_NAND_GPIO=m
530CONFIG_MTD_NAND_IDS=y 555CONFIG_MTD_NAND_IDS=y
531# CONFIG_MTD_NAND_DISKONCHIP is not set 556# CONFIG_MTD_NAND_DISKONCHIP is not set
532# CONFIG_MTD_NAND_SHARPSL is not set 557# CONFIG_MTD_NAND_SHARPSL is not set
@@ -636,6 +661,7 @@ CONFIG_SCSI_LOWLEVEL=y
636# CONFIG_SCSI_DEBUG is not set 661# CONFIG_SCSI_DEBUG is not set
637# CONFIG_SCSI_SRP is not set 662# CONFIG_SCSI_SRP is not set
638# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set 663# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set
664# CONFIG_SCSI_DH is not set
639CONFIG_ATA=m 665CONFIG_ATA=m
640# CONFIG_ATA_NONSTANDARD is not set 666# CONFIG_ATA_NONSTANDARD is not set
641# CONFIG_SATA_PMP is not set 667# CONFIG_SATA_PMP is not set
@@ -696,17 +722,21 @@ CONFIG_PATA_PCMCIA=m
696# CONFIG_PATA_VIA is not set 722# CONFIG_PATA_VIA is not set
697# CONFIG_PATA_WINBOND is not set 723# CONFIG_PATA_WINBOND is not set
698# CONFIG_PATA_PLATFORM is not set 724# CONFIG_PATA_PLATFORM is not set
725# CONFIG_PATA_SCH is not set
699# CONFIG_MD is not set 726# CONFIG_MD is not set
700# CONFIG_FUSION is not set 727# CONFIG_FUSION is not set
701 728
702# 729#
703# IEEE 1394 (FireWire) support 730# IEEE 1394 (FireWire) support
704# 731#
732
733#
734# Enable only one of the two stacks, unless you know what you are doing
735#
705# CONFIG_FIREWIRE is not set 736# CONFIG_FIREWIRE is not set
706# CONFIG_IEEE1394 is not set 737# CONFIG_IEEE1394 is not set
707# CONFIG_I2O is not set 738# CONFIG_I2O is not set
708CONFIG_NETDEVICES=y 739CONFIG_NETDEVICES=y
709# CONFIG_NETDEVICES_MULTIQUEUE is not set
710# CONFIG_DUMMY is not set 740# CONFIG_DUMMY is not set
711# CONFIG_BONDING is not set 741# CONFIG_BONDING is not set
712# CONFIG_MACVLAN is not set 742# CONFIG_MACVLAN is not set
@@ -725,6 +755,7 @@ CONFIG_MII=y
725# CONFIG_SMC91X is not set 755# CONFIG_SMC91X is not set
726CONFIG_DM9000=y 756CONFIG_DM9000=y
727CONFIG_DM9000_DEBUGLEVEL=1 757CONFIG_DM9000_DEBUGLEVEL=1
758# CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL is not set
728# CONFIG_SMC911X is not set 759# CONFIG_SMC911X is not set
729# CONFIG_NET_TULIP is not set 760# CONFIG_NET_TULIP is not set
730# CONFIG_HP100 is not set 761# CONFIG_HP100 is not set
@@ -780,7 +811,6 @@ CONFIG_LIBERTAS_SDIO=m
780# CONFIG_PRISM54 is not set 811# CONFIG_PRISM54 is not set
781# CONFIG_USB_ZD1201 is not set 812# CONFIG_USB_ZD1201 is not set
782# CONFIG_USB_NET_RNDIS_WLAN is not set 813# CONFIG_USB_NET_RNDIS_WLAN is not set
783# CONFIG_IWLWIFI is not set
784# CONFIG_IWLWIFI_LEDS is not set 814# CONFIG_IWLWIFI_LEDS is not set
785# CONFIG_HOSTAP is not set 815# CONFIG_HOSTAP is not set
786 816
@@ -853,17 +883,18 @@ CONFIG_INPUT_TOUCHSCREEN=y
853# CONFIG_TOUCHSCREEN_GUNZE is not set 883# CONFIG_TOUCHSCREEN_GUNZE is not set
854# CONFIG_TOUCHSCREEN_ELO is not set 884# CONFIG_TOUCHSCREEN_ELO is not set
855# CONFIG_TOUCHSCREEN_MTOUCH is not set 885# CONFIG_TOUCHSCREEN_MTOUCH is not set
886# CONFIG_TOUCHSCREEN_INEXIO is not set
856# CONFIG_TOUCHSCREEN_MK712 is not set 887# CONFIG_TOUCHSCREEN_MK712 is not set
857# CONFIG_TOUCHSCREEN_PENMOUNT is not set 888# CONFIG_TOUCHSCREEN_PENMOUNT is not set
858# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set 889# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
859# CONFIG_TOUCHSCREEN_TOUCHWIN is not set 890# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
860CONFIG_TOUCHSCREEN_UCB1400=m
861CONFIG_TOUCHSCREEN_WM97XX=m 891CONFIG_TOUCHSCREEN_WM97XX=m
862# CONFIG_TOUCHSCREEN_WM9705 is not set 892# CONFIG_TOUCHSCREEN_WM9705 is not set
863CONFIG_TOUCHSCREEN_WM9712=y 893CONFIG_TOUCHSCREEN_WM9712=y
864# CONFIG_TOUCHSCREEN_WM9713 is not set 894# CONFIG_TOUCHSCREEN_WM9713 is not set
865# CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE is not set 895# CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE is not set
866# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set 896# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
897# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
867# CONFIG_INPUT_MISC is not set 898# CONFIG_INPUT_MISC is not set
868 899
869# 900#
@@ -880,6 +911,7 @@ CONFIG_SERIO_LIBPS2=y
880# Character devices 911# Character devices
881# 912#
882CONFIG_VT=y 913CONFIG_VT=y
914CONFIG_CONSOLE_TRANSLATIONS=y
883CONFIG_VT_CONSOLE=y 915CONFIG_VT_CONSOLE=y
884CONFIG_HW_CONSOLE=y 916CONFIG_HW_CONSOLE=y
885# CONFIG_VT_HW_CONSOLE_BINDING is not set 917# CONFIG_VT_HW_CONSOLE_BINDING is not set
@@ -922,45 +954,66 @@ CONFIG_DEVPORT=y
922CONFIG_I2C=y 954CONFIG_I2C=y
923CONFIG_I2C_BOARDINFO=y 955CONFIG_I2C_BOARDINFO=y
924CONFIG_I2C_CHARDEV=m 956CONFIG_I2C_CHARDEV=m
957CONFIG_I2C_HELPER_AUTO=y
925 958
926# 959#
927# I2C Hardware Bus support 960# I2C Hardware Bus support
928# 961#
962
963#
964# PC SMBus host controller drivers
965#
929# CONFIG_I2C_ALI1535 is not set 966# CONFIG_I2C_ALI1535 is not set
930# CONFIG_I2C_ALI1563 is not set 967# CONFIG_I2C_ALI1563 is not set
931# CONFIG_I2C_ALI15X3 is not set 968# CONFIG_I2C_ALI15X3 is not set
932# CONFIG_I2C_AMD756 is not set 969# CONFIG_I2C_AMD756 is not set
933# CONFIG_I2C_AMD8111 is not set 970# CONFIG_I2C_AMD8111 is not set
934# CONFIG_I2C_GPIO is not set
935# CONFIG_I2C_I801 is not set 971# CONFIG_I2C_I801 is not set
936# CONFIG_I2C_I810 is not set 972# CONFIG_I2C_ISCH is not set
937CONFIG_I2C_PXA=y
938# CONFIG_I2C_PXA_SLAVE is not set
939# CONFIG_I2C_PIIX4 is not set 973# CONFIG_I2C_PIIX4 is not set
940# CONFIG_I2C_NFORCE2 is not set 974# CONFIG_I2C_NFORCE2 is not set
941# CONFIG_I2C_OCORES is not set
942# CONFIG_I2C_PARPORT_LIGHT is not set
943# CONFIG_I2C_PROSAVAGE is not set
944# CONFIG_I2C_SAVAGE4 is not set
945# CONFIG_I2C_SIMTEC is not set
946# CONFIG_I2C_SIS5595 is not set 975# CONFIG_I2C_SIS5595 is not set
947# CONFIG_I2C_SIS630 is not set 976# CONFIG_I2C_SIS630 is not set
948# CONFIG_I2C_SIS96X is not set 977# CONFIG_I2C_SIS96X is not set
949# CONFIG_I2C_TAOS_EVM is not set
950# CONFIG_I2C_STUB is not set
951# CONFIG_I2C_TINY_USB is not set
952# CONFIG_I2C_VIA is not set 978# CONFIG_I2C_VIA is not set
953# CONFIG_I2C_VIAPRO is not set 979# CONFIG_I2C_VIAPRO is not set
980
981#
982# I2C system bus drivers (mostly embedded / system-on-chip)
983#
984# CONFIG_I2C_GPIO is not set
985# CONFIG_I2C_OCORES is not set
986CONFIG_I2C_PXA=y
987# CONFIG_I2C_PXA_SLAVE is not set
988# CONFIG_I2C_SIMTEC is not set
989
990#
991# External I2C/SMBus adapter drivers
992#
993# CONFIG_I2C_PARPORT_LIGHT is not set
994# CONFIG_I2C_TAOS_EVM is not set
995# CONFIG_I2C_TINY_USB is not set
996
997#
998# Graphics adapter I2C/DDC channel drivers
999#
954# CONFIG_I2C_VOODOO3 is not set 1000# CONFIG_I2C_VOODOO3 is not set
1001
1002#
1003# Other I2C/SMBus bus drivers
1004#
955# CONFIG_I2C_PCA_PLATFORM is not set 1005# CONFIG_I2C_PCA_PLATFORM is not set
1006# CONFIG_I2C_STUB is not set
956 1007
957# 1008#
958# Miscellaneous I2C Chip support 1009# Miscellaneous I2C Chip support
959# 1010#
960# CONFIG_DS1682 is not set 1011# CONFIG_DS1682 is not set
1012# CONFIG_AT24 is not set
961# CONFIG_SENSORS_EEPROM is not set 1013# CONFIG_SENSORS_EEPROM is not set
962# CONFIG_SENSORS_PCF8574 is not set 1014# CONFIG_SENSORS_PCF8574 is not set
963# CONFIG_PCF8575 is not set 1015# CONFIG_PCF8575 is not set
1016# CONFIG_SENSORS_PCA9539 is not set
964# CONFIG_SENSORS_PCF8591 is not set 1017# CONFIG_SENSORS_PCF8591 is not set
965# CONFIG_TPS65010 is not set 1018# CONFIG_TPS65010 is not set
966# CONFIG_SENSORS_MAX6875 is not set 1019# CONFIG_SENSORS_MAX6875 is not set
@@ -970,25 +1023,31 @@ CONFIG_I2C_PXA=y
970# CONFIG_I2C_DEBUG_BUS is not set 1023# CONFIG_I2C_DEBUG_BUS is not set
971# CONFIG_I2C_DEBUG_CHIP is not set 1024# CONFIG_I2C_DEBUG_CHIP is not set
972# CONFIG_SPI is not set 1025# CONFIG_SPI is not set
973CONFIG_HAVE_GPIO_LIB=y 1026CONFIG_ARCH_REQUIRE_GPIOLIB=y
974 1027CONFIG_GPIOLIB=y
975#
976# GPIO Support
977#
978# CONFIG_DEBUG_GPIO is not set 1028# CONFIG_DEBUG_GPIO is not set
1029# CONFIG_GPIO_SYSFS is not set
979 1030
980# 1031#
981# I2C GPIO expanders: 1032# I2C GPIO expanders:
982# 1033#
1034# CONFIG_GPIO_MAX732X is not set
983# CONFIG_GPIO_PCA953X is not set 1035# CONFIG_GPIO_PCA953X is not set
984# CONFIG_GPIO_PCF857X is not set 1036# CONFIG_GPIO_PCF857X is not set
985 1037
986# 1038#
1039# PCI GPIO expanders:
1040#
1041# CONFIG_GPIO_BT8XX is not set
1042
1043#
987# SPI GPIO expanders: 1044# SPI GPIO expanders:
988# 1045#
989# CONFIG_W1 is not set 1046# CONFIG_W1 is not set
990# CONFIG_POWER_SUPPLY is not set 1047# CONFIG_POWER_SUPPLY is not set
991# CONFIG_HWMON is not set 1048# CONFIG_HWMON is not set
1049# CONFIG_THERMAL is not set
1050# CONFIG_THERMAL_HWMON is not set
992# CONFIG_WATCHDOG is not set 1051# CONFIG_WATCHDOG is not set
993 1052
994# 1053#
@@ -1000,10 +1059,16 @@ CONFIG_SSB_POSSIBLE=y
1000# 1059#
1001# Multifunction device drivers 1060# Multifunction device drivers
1002# 1061#
1062# CONFIG_MFD_CORE is not set
1003# CONFIG_MFD_SM501 is not set 1063# CONFIG_MFD_SM501 is not set
1004# CONFIG_MFD_ASIC3 is not set 1064# CONFIG_MFD_ASIC3 is not set
1005# CONFIG_HTC_EGPIO is not set 1065# CONFIG_HTC_EGPIO is not set
1006# CONFIG_HTC_PASIC3 is not set 1066# CONFIG_HTC_PASIC3 is not set
1067# CONFIG_UCB1400_CORE is not set
1068# CONFIG_MFD_TMIO is not set
1069# CONFIG_MFD_T7L66XB is not set
1070# CONFIG_MFD_TC6387XB is not set
1071# CONFIG_MFD_TC6393XB is not set
1007 1072
1008# 1073#
1009# Multimedia devices 1074# Multimedia devices
@@ -1014,6 +1079,7 @@ CONFIG_SSB_POSSIBLE=y
1014# 1079#
1015# CONFIG_VIDEO_DEV is not set 1080# CONFIG_VIDEO_DEV is not set
1016# CONFIG_DVB_CORE is not set 1081# CONFIG_DVB_CORE is not set
1082# CONFIG_VIDEO_MEDIA is not set
1017 1083
1018# 1084#
1019# Multimedia drivers 1085# Multimedia drivers
@@ -1038,7 +1104,6 @@ CONFIG_FB_CFB_IMAGEBLIT=y
1038# CONFIG_FB_SYS_IMAGEBLIT is not set 1104# CONFIG_FB_SYS_IMAGEBLIT is not set
1039# CONFIG_FB_FOREIGN_ENDIAN is not set 1105# CONFIG_FB_FOREIGN_ENDIAN is not set
1040# CONFIG_FB_SYS_FOPS is not set 1106# CONFIG_FB_SYS_FOPS is not set
1041CONFIG_FB_DEFERRED_IO=y
1042# CONFIG_FB_SVGALIB is not set 1107# CONFIG_FB_SVGALIB is not set
1043# CONFIG_FB_MACMODES is not set 1108# CONFIG_FB_MACMODES is not set
1044# CONFIG_FB_BACKLIGHT is not set 1109# CONFIG_FB_BACKLIGHT is not set
@@ -1071,12 +1136,14 @@ CONFIG_FB_DEFERRED_IO=y
1071# CONFIG_FB_TRIDENT is not set 1136# CONFIG_FB_TRIDENT is not set
1072# CONFIG_FB_ARK is not set 1137# CONFIG_FB_ARK is not set
1073# CONFIG_FB_PM3 is not set 1138# CONFIG_FB_PM3 is not set
1139# CONFIG_FB_CARMINE is not set
1074CONFIG_FB_PXA=y 1140CONFIG_FB_PXA=y
1075# CONFIG_FB_PXA_SMARTPANEL is not set 1141# CONFIG_FB_PXA_SMARTPANEL is not set
1076CONFIG_FB_PXA_PARAMETERS=y 1142CONFIG_FB_PXA_PARAMETERS=y
1077CONFIG_FB_MBX=m 1143CONFIG_FB_MBX=m
1078# CONFIG_FB_AM200EPD is not set 1144# CONFIG_FB_W100 is not set
1079# CONFIG_FB_VIRTUAL is not set 1145# CONFIG_FB_VIRTUAL is not set
1146# CONFIG_FB_METRONOME is not set
1080# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 1147# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1081 1148
1082# 1149#
@@ -1099,15 +1166,7 @@ CONFIG_LOGO=y
1099CONFIG_LOGO_LINUX_MONO=y 1166CONFIG_LOGO_LINUX_MONO=y
1100CONFIG_LOGO_LINUX_VGA16=y 1167CONFIG_LOGO_LINUX_VGA16=y
1101CONFIG_LOGO_LINUX_CLUT224=y 1168CONFIG_LOGO_LINUX_CLUT224=y
1102
1103#
1104# Sound
1105#
1106CONFIG_SOUND=m 1169CONFIG_SOUND=m
1107
1108#
1109# Advanced Linux Sound Architecture
1110#
1111CONFIG_SND=m 1170CONFIG_SND=m
1112CONFIG_SND_TIMER=m 1171CONFIG_SND_TIMER=m
1113CONFIG_SND_PCM=m 1172CONFIG_SND_PCM=m
@@ -1121,19 +1180,15 @@ CONFIG_SND_SUPPORT_OLD_API=y
1121CONFIG_SND_VERBOSE_PROCFS=y 1180CONFIG_SND_VERBOSE_PROCFS=y
1122# CONFIG_SND_VERBOSE_PRINTK is not set 1181# CONFIG_SND_VERBOSE_PRINTK is not set
1123# CONFIG_SND_DEBUG is not set 1182# CONFIG_SND_DEBUG is not set
1124 1183CONFIG_SND_VMASTER=y
1125#
1126# Generic devices
1127#
1128CONFIG_SND_AC97_CODEC=m 1184CONFIG_SND_AC97_CODEC=m
1185CONFIG_SND_DRIVERS=y
1129# CONFIG_SND_DUMMY is not set 1186# CONFIG_SND_DUMMY is not set
1130# CONFIG_SND_MTPAV is not set 1187# CONFIG_SND_MTPAV is not set
1131# CONFIG_SND_SERIAL_U16550 is not set 1188# CONFIG_SND_SERIAL_U16550 is not set
1132# CONFIG_SND_MPU401 is not set 1189# CONFIG_SND_MPU401 is not set
1133 1190# CONFIG_SND_AC97_POWER_SAVE is not set
1134# 1191CONFIG_SND_PCI=y
1135# PCI devices
1136#
1137# CONFIG_SND_AD1889 is not set 1192# CONFIG_SND_AD1889 is not set
1138# CONFIG_SND_ALS300 is not set 1193# CONFIG_SND_ALS300 is not set
1139# CONFIG_SND_ALI5451 is not set 1194# CONFIG_SND_ALI5451 is not set
@@ -1193,42 +1248,16 @@ CONFIG_SND_AC97_CODEC=m
1193# CONFIG_SND_VIRTUOSO is not set 1248# CONFIG_SND_VIRTUOSO is not set
1194# CONFIG_SND_VX222 is not set 1249# CONFIG_SND_VX222 is not set
1195# CONFIG_SND_YMFPCI is not set 1250# CONFIG_SND_YMFPCI is not set
1196# CONFIG_SND_AC97_POWER_SAVE is not set 1251CONFIG_SND_ARM=y
1197
1198#
1199# ALSA ARM devices
1200#
1201CONFIG_SND_PXA2XX_PCM=m 1252CONFIG_SND_PXA2XX_PCM=m
1202CONFIG_SND_PXA2XX_AC97=m 1253CONFIG_SND_PXA2XX_AC97=m
1203 1254CONFIG_SND_USB=y
1204#
1205# USB devices
1206#
1207# CONFIG_SND_USB_AUDIO is not set 1255# CONFIG_SND_USB_AUDIO is not set
1208# CONFIG_SND_USB_CAIAQ is not set 1256# CONFIG_SND_USB_CAIAQ is not set
1209 1257CONFIG_SND_PCMCIA=y
1210#
1211# PCMCIA devices
1212#
1213# CONFIG_SND_VXPOCKET is not set 1258# CONFIG_SND_VXPOCKET is not set
1214# CONFIG_SND_PDAUDIOCF is not set 1259# CONFIG_SND_PDAUDIOCF is not set
1215
1216#
1217# System on Chip audio support
1218#
1219# CONFIG_SND_SOC is not set 1260# CONFIG_SND_SOC is not set
1220
1221#
1222# ALSA SoC audio for Freescale SOCs
1223#
1224
1225#
1226# SoC Audio for the Texas Instruments OMAP
1227#
1228
1229#
1230# Open Sound System
1231#
1232# CONFIG_SOUND_PRIME is not set 1261# CONFIG_SOUND_PRIME is not set
1233CONFIG_AC97_BUS=m 1262CONFIG_AC97_BUS=m
1234CONFIG_HID_SUPPORT=y 1263CONFIG_HID_SUPPORT=y
@@ -1261,12 +1290,15 @@ CONFIG_USB_DEVICEFS=y
1261# CONFIG_USB_OTG is not set 1290# CONFIG_USB_OTG is not set
1262# CONFIG_USB_OTG_WHITELIST is not set 1291# CONFIG_USB_OTG_WHITELIST is not set
1263# CONFIG_USB_OTG_BLACKLIST_HUB is not set 1292# CONFIG_USB_OTG_BLACKLIST_HUB is not set
1293CONFIG_USB_MON=y
1264 1294
1265# 1295#
1266# USB Host Controller Drivers 1296# USB Host Controller Drivers
1267# 1297#
1298# CONFIG_USB_C67X00_HCD is not set
1268# CONFIG_USB_EHCI_HCD is not set 1299# CONFIG_USB_EHCI_HCD is not set
1269# CONFIG_USB_ISP116X_HCD is not set 1300# CONFIG_USB_ISP116X_HCD is not set
1301# CONFIG_USB_ISP1760_HCD is not set
1270CONFIG_USB_OHCI_HCD=y 1302CONFIG_USB_OHCI_HCD=y
1271# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set 1303# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
1272# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set 1304# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
@@ -1274,12 +1306,14 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1274# CONFIG_USB_UHCI_HCD is not set 1306# CONFIG_USB_UHCI_HCD is not set
1275# CONFIG_USB_SL811_HCD is not set 1307# CONFIG_USB_SL811_HCD is not set
1276# CONFIG_USB_R8A66597_HCD is not set 1308# CONFIG_USB_R8A66597_HCD is not set
1309# CONFIG_USB_MUSB_HDRC is not set
1277 1310
1278# 1311#
1279# USB Device Class drivers 1312# USB Device Class drivers
1280# 1313#
1281# CONFIG_USB_ACM is not set 1314# CONFIG_USB_ACM is not set
1282# CONFIG_USB_PRINTER is not set 1315# CONFIG_USB_PRINTER is not set
1316# CONFIG_USB_WDM is not set
1283 1317
1284# 1318#
1285# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 1319# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
@@ -1309,7 +1343,6 @@ CONFIG_USB_STORAGE=y
1309# 1343#
1310# CONFIG_USB_MDC800 is not set 1344# CONFIG_USB_MDC800 is not set
1311# CONFIG_USB_MICROTEK is not set 1345# CONFIG_USB_MICROTEK is not set
1312CONFIG_USB_MON=y
1313 1346
1314# 1347#
1315# USB port drivers 1348# USB port drivers
@@ -1322,7 +1355,6 @@ CONFIG_USB_MON=y
1322# CONFIG_USB_EMI62 is not set 1355# CONFIG_USB_EMI62 is not set
1323# CONFIG_USB_EMI26 is not set 1356# CONFIG_USB_EMI26 is not set
1324# CONFIG_USB_ADUTUX is not set 1357# CONFIG_USB_ADUTUX is not set
1325# CONFIG_USB_AUERSWALD is not set
1326# CONFIG_USB_RIO500 is not set 1358# CONFIG_USB_RIO500 is not set
1327# CONFIG_USB_LEGOTOWER is not set 1359# CONFIG_USB_LEGOTOWER is not set
1328# CONFIG_USB_LCD is not set 1360# CONFIG_USB_LCD is not set
@@ -1338,6 +1370,7 @@ CONFIG_USB_MON=y
1338# CONFIG_USB_TRANCEVIBRATOR is not set 1370# CONFIG_USB_TRANCEVIBRATOR is not set
1339# CONFIG_USB_IOWARRIOR is not set 1371# CONFIG_USB_IOWARRIOR is not set
1340# CONFIG_USB_TEST is not set 1372# CONFIG_USB_TEST is not set
1373# CONFIG_USB_ISIGHTFW is not set
1341# CONFIG_USB_GADGET is not set 1374# CONFIG_USB_GADGET is not set
1342CONFIG_MMC=m 1375CONFIG_MMC=m
1343# CONFIG_MMC_DEBUG is not set 1376# CONFIG_MMC_DEBUG is not set
@@ -1349,6 +1382,7 @@ CONFIG_MMC=m
1349CONFIG_MMC_BLOCK=m 1382CONFIG_MMC_BLOCK=m
1350CONFIG_MMC_BLOCK_BOUNCE=y 1383CONFIG_MMC_BLOCK_BOUNCE=y
1351# CONFIG_SDIO_UART is not set 1384# CONFIG_SDIO_UART is not set
1385# CONFIG_MMC_TEST is not set
1352 1386
1353# 1387#
1354# MMC/SD Host Controller Drivers 1388# MMC/SD Host Controller Drivers
@@ -1356,14 +1390,19 @@ CONFIG_MMC_BLOCK_BOUNCE=y
1356CONFIG_MMC_PXA=m 1390CONFIG_MMC_PXA=m
1357# CONFIG_MMC_SDHCI is not set 1391# CONFIG_MMC_SDHCI is not set
1358# CONFIG_MMC_TIFM_SD is not set 1392# CONFIG_MMC_TIFM_SD is not set
1393# CONFIG_MMC_SDRICOH_CS is not set
1394# CONFIG_MEMSTICK is not set
1395# CONFIG_ACCESSIBILITY is not set
1359CONFIG_NEW_LEDS=y 1396CONFIG_NEW_LEDS=y
1360CONFIG_LEDS_CLASS=y 1397CONFIG_LEDS_CLASS=y
1361 1398
1362# 1399#
1363# LED drivers 1400# LED drivers
1364# 1401#
1402# CONFIG_LEDS_PCA9532 is not set
1365# CONFIG_LEDS_GPIO is not set 1403# CONFIG_LEDS_GPIO is not set
1366CONFIG_LEDS_CM_X270=y 1404CONFIG_LEDS_CM_X270=y
1405# CONFIG_LEDS_PCA955X is not set
1367 1406
1368# 1407#
1369# LED Triggers 1408# LED Triggers
@@ -1401,6 +1440,7 @@ CONFIG_RTC_INTF_DEV=y
1401# CONFIG_RTC_DRV_PCF8583 is not set 1440# CONFIG_RTC_DRV_PCF8583 is not set
1402# CONFIG_RTC_DRV_M41T80 is not set 1441# CONFIG_RTC_DRV_M41T80 is not set
1403# CONFIG_RTC_DRV_S35390A is not set 1442# CONFIG_RTC_DRV_S35390A is not set
1443# CONFIG_RTC_DRV_FM3130 is not set
1404 1444
1405# 1445#
1406# SPI RTC drivers 1446# SPI RTC drivers
@@ -1422,6 +1462,15 @@ CONFIG_RTC_DRV_V3020=y
1422# on-CPU RTC drivers 1462# on-CPU RTC drivers
1423# 1463#
1424CONFIG_RTC_DRV_SA1100=y 1464CONFIG_RTC_DRV_SA1100=y
1465# CONFIG_DMADEVICES is not set
1466
1467#
1468# Voltage and Current regulators
1469#
1470# CONFIG_REGULATOR is not set
1471# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
1472# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
1473# CONFIG_REGULATOR_BQ24022 is not set
1425# CONFIG_UIO is not set 1474# CONFIG_UIO is not set
1426 1475
1427# 1476#
@@ -1501,6 +1550,7 @@ CONFIG_JFFS2_RTIME=y
1501# CONFIG_CRAMFS is not set 1550# CONFIG_CRAMFS is not set
1502# CONFIG_VXFS_FS is not set 1551# CONFIG_VXFS_FS is not set
1503# CONFIG_MINIX_FS is not set 1552# CONFIG_MINIX_FS is not set
1553# CONFIG_OMFS_FS is not set
1504# CONFIG_HPFS_FS is not set 1554# CONFIG_HPFS_FS is not set
1505# CONFIG_QNX4FS_FS is not set 1555# CONFIG_QNX4FS_FS is not set
1506# CONFIG_ROMFS_FS is not set 1556# CONFIG_ROMFS_FS is not set
@@ -1511,13 +1561,12 @@ CONFIG_NFS_FS=y
1511CONFIG_NFS_V3=y 1561CONFIG_NFS_V3=y
1512# CONFIG_NFS_V3_ACL is not set 1562# CONFIG_NFS_V3_ACL is not set
1513# CONFIG_NFS_V4 is not set 1563# CONFIG_NFS_V4 is not set
1514# CONFIG_NFSD is not set
1515CONFIG_ROOT_NFS=y 1564CONFIG_ROOT_NFS=y
1565# CONFIG_NFSD is not set
1516CONFIG_LOCKD=y 1566CONFIG_LOCKD=y
1517CONFIG_LOCKD_V4=y 1567CONFIG_LOCKD_V4=y
1518CONFIG_NFS_COMMON=y 1568CONFIG_NFS_COMMON=y
1519CONFIG_SUNRPC=y 1569CONFIG_SUNRPC=y
1520# CONFIG_SUNRPC_BIND34 is not set
1521# CONFIG_RPCSEC_GSS_KRB5 is not set 1570# CONFIG_RPCSEC_GSS_KRB5 is not set
1522# CONFIG_RPCSEC_GSS_SPKM3 is not set 1571# CONFIG_RPCSEC_GSS_SPKM3 is not set
1523# CONFIG_SMB_FS is not set 1572# CONFIG_SMB_FS is not set
@@ -1626,6 +1675,7 @@ CONFIG_DEBUG_KERNEL=y
1626# CONFIG_DEBUG_INFO is not set 1675# CONFIG_DEBUG_INFO is not set
1627# CONFIG_DEBUG_VM is not set 1676# CONFIG_DEBUG_VM is not set
1628# CONFIG_DEBUG_WRITECOUNT is not set 1677# CONFIG_DEBUG_WRITECOUNT is not set
1678# CONFIG_DEBUG_MEMORY_INIT is not set
1629# CONFIG_DEBUG_LIST is not set 1679# CONFIG_DEBUG_LIST is not set
1630# CONFIG_DEBUG_SG is not set 1680# CONFIG_DEBUG_SG is not set
1631CONFIG_FRAME_POINTER=y 1681CONFIG_FRAME_POINTER=y
@@ -1633,7 +1683,17 @@ CONFIG_FRAME_POINTER=y
1633# CONFIG_RCU_TORTURE_TEST is not set 1683# CONFIG_RCU_TORTURE_TEST is not set
1634# CONFIG_BACKTRACE_SELF_TEST is not set 1684# CONFIG_BACKTRACE_SELF_TEST is not set
1635# CONFIG_FAULT_INJECTION is not set 1685# CONFIG_FAULT_INJECTION is not set
1686# CONFIG_LATENCYTOP is not set
1687CONFIG_SYSCTL_SYSCALL_CHECK=y
1688CONFIG_HAVE_FTRACE=y
1689CONFIG_HAVE_DYNAMIC_FTRACE=y
1690# CONFIG_FTRACE is not set
1691# CONFIG_IRQSOFF_TRACER is not set
1692# CONFIG_SCHED_TRACER is not set
1693# CONFIG_CONTEXT_SWITCH_TRACER is not set
1636# CONFIG_SAMPLES is not set 1694# CONFIG_SAMPLES is not set
1695CONFIG_HAVE_ARCH_KGDB=y
1696# CONFIG_KGDB is not set
1637CONFIG_DEBUG_USER=y 1697CONFIG_DEBUG_USER=y
1638CONFIG_DEBUG_ERRORS=y 1698CONFIG_DEBUG_ERRORS=y
1639# CONFIG_DEBUG_STACK_USAGE is not set 1699# CONFIG_DEBUG_STACK_USAGE is not set
@@ -1689,6 +1749,10 @@ CONFIG_CRYPTO=y
1689# CONFIG_CRYPTO_MD4 is not set 1749# CONFIG_CRYPTO_MD4 is not set
1690# CONFIG_CRYPTO_MD5 is not set 1750# CONFIG_CRYPTO_MD5 is not set
1691# CONFIG_CRYPTO_MICHAEL_MIC is not set 1751# CONFIG_CRYPTO_MICHAEL_MIC is not set
1752# CONFIG_CRYPTO_RMD128 is not set
1753# CONFIG_CRYPTO_RMD160 is not set
1754# CONFIG_CRYPTO_RMD256 is not set
1755# CONFIG_CRYPTO_RMD320 is not set
1692# CONFIG_CRYPTO_SHA1 is not set 1756# CONFIG_CRYPTO_SHA1 is not set
1693# CONFIG_CRYPTO_SHA256 is not set 1757# CONFIG_CRYPTO_SHA256 is not set
1694# CONFIG_CRYPTO_SHA512 is not set 1758# CONFIG_CRYPTO_SHA512 is not set
@@ -1729,6 +1793,7 @@ CONFIG_BITREVERSE=y
1729# CONFIG_GENERIC_FIND_NEXT_BIT is not set 1793# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1730CONFIG_CRC_CCITT=m 1794CONFIG_CRC_CCITT=m
1731# CONFIG_CRC16 is not set 1795# CONFIG_CRC16 is not set
1796# CONFIG_CRC_T10DIF is not set
1732# CONFIG_CRC_ITU_T is not set 1797# CONFIG_CRC_ITU_T is not set
1733CONFIG_CRC32=y 1798CONFIG_CRC32=y
1734# CONFIG_CRC7 is not set 1799# CONFIG_CRC7 is not set
diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h
index 7b62351f097d..4d88425a4169 100644
--- a/arch/arm/include/asm/bug.h
+++ b/arch/arm/include/asm/bug.h
@@ -12,7 +12,7 @@ extern void __bug(const char *file, int line) __attribute__((noreturn));
12#else 12#else
13 13
14/* this just causes an oops */ 14/* this just causes an oops */
15#define BUG() (*(int *)0 = 0) 15#define BUG() do { *(int *)0 = 0; } while (1)
16 16
17#endif 17#endif
18 18
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index 9073d9c6567e..de6c59f814a1 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -444,94 +444,4 @@ static inline void flush_ioremap_region(unsigned long phys, void __iomem *virt,
444 dmac_inv_range(start, start + size); 444 dmac_inv_range(start, start + size);
445} 445}
446 446
447#define __cacheid_present(val) (val != read_cpuid(CPUID_ID))
448#define __cacheid_type_v7(val) ((val & (7 << 29)) == (4 << 29))
449
450#define __cacheid_vivt_prev7(val) ((val & (15 << 25)) != (14 << 25))
451#define __cacheid_vipt_prev7(val) ((val & (15 << 25)) == (14 << 25))
452#define __cacheid_vipt_nonaliasing_prev7(val) ((val & (15 << 25 | 1 << 23)) == (14 << 25))
453#define __cacheid_vipt_aliasing_prev7(val) ((val & (15 << 25 | 1 << 23)) == (14 << 25 | 1 << 23))
454
455#define __cacheid_vivt(val) (__cacheid_type_v7(val) ? 0 : __cacheid_vivt_prev7(val))
456#define __cacheid_vipt(val) (__cacheid_type_v7(val) ? 1 : __cacheid_vipt_prev7(val))
457#define __cacheid_vipt_nonaliasing(val) (__cacheid_type_v7(val) ? 1 : __cacheid_vipt_nonaliasing_prev7(val))
458#define __cacheid_vipt_aliasing(val) (__cacheid_type_v7(val) ? 0 : __cacheid_vipt_aliasing_prev7(val))
459#define __cacheid_vivt_asid_tagged_instr(val) (__cacheid_type_v7(val) ? ((val & (3 << 14)) == (1 << 14)) : 0)
460
461#if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT)
462/*
463 * VIVT caches only
464 */
465#define cache_is_vivt() 1
466#define cache_is_vipt() 0
467#define cache_is_vipt_nonaliasing() 0
468#define cache_is_vipt_aliasing() 0
469#define icache_is_vivt_asid_tagged() 0
470
471#elif !defined(CONFIG_CPU_CACHE_VIVT) && defined(CONFIG_CPU_CACHE_VIPT)
472/*
473 * VIPT caches only
474 */
475#define cache_is_vivt() 0
476#define cache_is_vipt() 1
477#define cache_is_vipt_nonaliasing() \
478 ({ \
479 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
480 __cacheid_vipt_nonaliasing(__val); \
481 })
482
483#define cache_is_vipt_aliasing() \
484 ({ \
485 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
486 __cacheid_vipt_aliasing(__val); \
487 })
488
489#define icache_is_vivt_asid_tagged() \
490 ({ \
491 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
492 __cacheid_vivt_asid_tagged_instr(__val); \
493 })
494
495#else
496/*
497 * VIVT or VIPT caches. Note that this is unreliable since ARM926
498 * and V6 CPUs satisfy the "(val & (15 << 25)) == (14 << 25)" test.
499 * There's no way to tell from the CacheType register what type (!)
500 * the cache is.
501 */
502#define cache_is_vivt() \
503 ({ \
504 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
505 (!__cacheid_present(__val)) || __cacheid_vivt(__val); \
506 })
507
508#define cache_is_vipt() \
509 ({ \
510 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
511 __cacheid_present(__val) && __cacheid_vipt(__val); \
512 })
513
514#define cache_is_vipt_nonaliasing() \
515 ({ \
516 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
517 __cacheid_present(__val) && \
518 __cacheid_vipt_nonaliasing(__val); \
519 })
520
521#define cache_is_vipt_aliasing() \
522 ({ \
523 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
524 __cacheid_present(__val) && \
525 __cacheid_vipt_aliasing(__val); \
526 })
527
528#define icache_is_vivt_asid_tagged() \
529 ({ \
530 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
531 __cacheid_present(__val) && \
532 __cacheid_vivt_asid_tagged_instr(__val); \
533 })
534
535#endif
536
537#endif 447#endif
diff --git a/arch/arm/include/asm/cachetype.h b/arch/arm/include/asm/cachetype.h
new file mode 100644
index 000000000000..d3a4c2cb9f2f
--- /dev/null
+++ b/arch/arm/include/asm/cachetype.h
@@ -0,0 +1,52 @@
1#ifndef __ASM_ARM_CACHETYPE_H
2#define __ASM_ARM_CACHETYPE_H
3
4#define CACHEID_VIVT (1 << 0)
5#define CACHEID_VIPT_NONALIASING (1 << 1)
6#define CACHEID_VIPT_ALIASING (1 << 2)
7#define CACHEID_VIPT (CACHEID_VIPT_ALIASING|CACHEID_VIPT_NONALIASING)
8#define CACHEID_ASID_TAGGED (1 << 3)
9
10extern unsigned int cacheid;
11
12#define cache_is_vivt() cacheid_is(CACHEID_VIVT)
13#define cache_is_vipt() cacheid_is(CACHEID_VIPT)
14#define cache_is_vipt_nonaliasing() cacheid_is(CACHEID_VIPT_NONALIASING)
15#define cache_is_vipt_aliasing() cacheid_is(CACHEID_VIPT_ALIASING)
16#define icache_is_vivt_asid_tagged() cacheid_is(CACHEID_ASID_TAGGED)
17
18/*
19 * __LINUX_ARM_ARCH__ is the minimum supported CPU architecture
20 * Mask out support which will never be present on newer CPUs.
21 * - v6+ is never VIVT
22 * - v7+ VIPT never aliases
23 */
24#if __LINUX_ARM_ARCH__ >= 7
25#define __CACHEID_ARCH_MIN (CACHEID_VIPT_NONALIASING | CACHEID_ASID_TAGGED)
26#elif __LINUX_ARM_ARCH__ >= 6
27#define __CACHEID_ARCH_MIN (~CACHEID_VIVT)
28#else
29#define __CACHEID_ARCH_MIN (~0)
30#endif
31
32/*
33 * Mask out support which isn't configured
34 */
35#if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT)
36#define __CACHEID_ALWAYS (CACHEID_VIVT)
37#define __CACHEID_NEVER (~CACHEID_VIVT)
38#elif !defined(CONFIG_CPU_CACHE_VIVT) && defined(CONFIG_CPU_CACHE_VIPT)
39#define __CACHEID_ALWAYS (0)
40#define __CACHEID_NEVER (CACHEID_VIVT)
41#else
42#define __CACHEID_ALWAYS (0)
43#define __CACHEID_NEVER (0)
44#endif
45
46static inline unsigned int __attribute__((pure)) cacheid_is(unsigned int mask)
47{
48 return (__CACHEID_ALWAYS & mask) |
49 (~__CACHEID_NEVER & __CACHEID_ARCH_MIN & mask & cacheid);
50}
51
52#endif
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
new file mode 100644
index 000000000000..7b9d27e749b8
--- /dev/null
+++ b/arch/arm/include/asm/cputype.h
@@ -0,0 +1,64 @@
1#ifndef __ASM_ARM_CPUTYPE_H
2#define __ASM_ARM_CPUTYPE_H
3
4#include <linux/stringify.h>
5
6#define CPUID_ID 0
7#define CPUID_CACHETYPE 1
8#define CPUID_TCM 2
9#define CPUID_TLBTYPE 3
10
11#ifdef CONFIG_CPU_CP15
12#define read_cpuid(reg) \
13 ({ \
14 unsigned int __val; \
15 asm("mrc p15, 0, %0, c0, c0, " __stringify(reg) \
16 : "=r" (__val) \
17 : \
18 : "cc"); \
19 __val; \
20 })
21#else
22extern unsigned int processor_id;
23#define read_cpuid(reg) (processor_id)
24#endif
25
26/*
27 * The CPU ID never changes at run time, so we might as well tell the
28 * compiler that it's constant. Use this function to read the CPU ID
29 * rather than directly reading processor_id or read_cpuid() directly.
30 */
31static inline unsigned int __attribute_const__ read_cpuid_id(void)
32{
33 return read_cpuid(CPUID_ID);
34}
35
36static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
37{
38 return read_cpuid(CPUID_CACHETYPE);
39}
40
41/*
42 * Intel's XScale3 core supports some v6 features (supersections, L2)
43 * but advertises itself as v5 as it does not support the v6 ISA. For
44 * this reason, we need a way to explicitly test for this type of CPU.
45 */
46#ifndef CONFIG_CPU_XSC3
47#define cpu_is_xsc3() 0
48#else
49static inline int cpu_is_xsc3(void)
50{
51 if ((read_cpuid_id() & 0xffffe000) == 0x69056000)
52 return 1;
53
54 return 0;
55}
56#endif
57
58#if !defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_CPU_XSC3)
59#define cpu_is_xscale() 0
60#else
61#define cpu_is_xscale() 1
62#endif
63
64#endif
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 7b95d2058395..1cb8602dd9d5 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -104,15 +104,14 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
104 * Dummy noncoherent implementation. We don't provide a dma_cache_sync 104 * Dummy noncoherent implementation. We don't provide a dma_cache_sync
105 * function so drivers using this API are highlighted with build warnings. 105 * function so drivers using this API are highlighted with build warnings.
106 */ 106 */
107static inline void * 107static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
108dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp) 108 dma_addr_t *handle, gfp_t gfp)
109{ 109{
110 return NULL; 110 return NULL;
111} 111}
112 112
113static inline void 113static inline void dma_free_noncoherent(struct device *dev, size_t size,
114dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr, 114 void *cpu_addr, dma_addr_t handle)
115 dma_addr_t handle)
116{ 115{
117} 116}
118 117
@@ -127,8 +126,7 @@ dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr,
127 * return the CPU-viewed address, and sets @handle to be the 126 * return the CPU-viewed address, and sets @handle to be the
128 * device-viewed address. 127 * device-viewed address.
129 */ 128 */
130extern void * 129extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
131dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp);
132 130
133/** 131/**
134 * dma_free_coherent - free memory allocated by dma_alloc_coherent 132 * dma_free_coherent - free memory allocated by dma_alloc_coherent
@@ -143,9 +141,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gf
143 * References to memory and mappings associated with cpu_addr/handle 141 * References to memory and mappings associated with cpu_addr/handle
144 * during and after this call executing are illegal. 142 * during and after this call executing are illegal.
145 */ 143 */
146extern void 144extern void dma_free_coherent(struct device *, size_t, void *, dma_addr_t);
147dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
148 dma_addr_t handle);
149 145
150/** 146/**
151 * dma_mmap_coherent - map a coherent DMA allocation into user space 147 * dma_mmap_coherent - map a coherent DMA allocation into user space
@@ -159,8 +155,8 @@ dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
159 * into user space. The coherent DMA buffer must not be freed by the 155 * into user space. The coherent DMA buffer must not be freed by the
160 * driver until the user space mapping has been released. 156 * driver until the user space mapping has been released.
161 */ 157 */
162int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma, 158int dma_mmap_coherent(struct device *, struct vm_area_struct *,
163 void *cpu_addr, dma_addr_t handle, size_t size); 159 void *, dma_addr_t, size_t);
164 160
165 161
166/** 162/**
@@ -174,14 +170,94 @@ int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
174 * return the CPU-viewed address, and sets @handle to be the 170 * return the CPU-viewed address, and sets @handle to be the
175 * device-viewed address. 171 * device-viewed address.
176 */ 172 */
177extern void * 173extern void *dma_alloc_writecombine(struct device *, size_t, dma_addr_t *,
178dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp); 174 gfp_t);
179 175
180#define dma_free_writecombine(dev,size,cpu_addr,handle) \ 176#define dma_free_writecombine(dev,size,cpu_addr,handle) \
181 dma_free_coherent(dev,size,cpu_addr,handle) 177 dma_free_coherent(dev,size,cpu_addr,handle)
182 178
183int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma, 179int dma_mmap_writecombine(struct device *, struct vm_area_struct *,
184 void *cpu_addr, dma_addr_t handle, size_t size); 180 void *, dma_addr_t, size_t);
181
182
183#ifdef CONFIG_DMABOUNCE
184/*
185 * For SA-1111, IXP425, and ADI systems the dma-mapping functions are "magic"
186 * and utilize bounce buffers as needed to work around limited DMA windows.
187 *
188 * On the SA-1111, a bug limits DMA to only certain regions of RAM.
189 * On the IXP425, the PCI inbound window is 64MB (256MB total RAM)
190 * On some ADI engineering systems, PCI inbound window is 32MB (12MB total RAM)
191 *
192 * The following are helper functions used by the dmabounce subystem
193 *
194 */
195
196/**
197 * dmabounce_register_dev
198 *
199 * @dev: valid struct device pointer
200 * @small_buf_size: size of buffers to use with small buffer pool
201 * @large_buf_size: size of buffers to use with large buffer pool (can be 0)
202 *
203 * This function should be called by low-level platform code to register
204 * a device as requireing DMA buffer bouncing. The function will allocate
205 * appropriate DMA pools for the device.
206 *
207 */
208extern int dmabounce_register_dev(struct device *, unsigned long,
209 unsigned long);
210
211/**
212 * dmabounce_unregister_dev
213 *
214 * @dev: valid struct device pointer
215 *
216 * This function should be called by low-level platform code when device
217 * that was previously registered with dmabounce_register_dev is removed
218 * from the system.
219 *
220 */
221extern void dmabounce_unregister_dev(struct device *);
222
223/**
224 * dma_needs_bounce
225 *
226 * @dev: valid struct device pointer
227 * @dma_handle: dma_handle of unbounced buffer
228 * @size: size of region being mapped
229 *
230 * Platforms that utilize the dmabounce mechanism must implement
231 * this function.
232 *
233 * The dmabounce routines call this function whenever a dma-mapping
234 * is requested to determine whether a given buffer needs to be bounced
235 * or not. The function must return 0 if the buffer is OK for
236 * DMA access and 1 if the buffer needs to be bounced.
237 *
238 */
239extern int dma_needs_bounce(struct device*, dma_addr_t, size_t);
240
241/*
242 * The DMA API, implemented by dmabounce.c. See below for descriptions.
243 */
244extern dma_addr_t dma_map_single(struct device *, void *, size_t,
245 enum dma_data_direction);
246extern dma_addr_t dma_map_page(struct device *, struct page *,
247 unsigned long, size_t, enum dma_data_direction);
248extern void dma_unmap_single(struct device *, dma_addr_t, size_t,
249 enum dma_data_direction);
250
251/*
252 * Private functions
253 */
254int dmabounce_sync_for_cpu(struct device *, dma_addr_t, unsigned long,
255 size_t, enum dma_data_direction);
256int dmabounce_sync_for_device(struct device *, dma_addr_t, unsigned long,
257 size_t, enum dma_data_direction);
258#else
259#define dmabounce_sync_for_cpu(dev,dma,off,sz,dir) (1)
260#define dmabounce_sync_for_device(dev,dma,off,sz,dir) (1)
185 261
186 262
187/** 263/**
@@ -198,19 +274,16 @@ int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma,
198 * can regain ownership by calling dma_unmap_single() or 274 * can regain ownership by calling dma_unmap_single() or
199 * dma_sync_single_for_cpu(). 275 * dma_sync_single_for_cpu().
200 */ 276 */
201#ifndef CONFIG_DMABOUNCE 277static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
202static inline dma_addr_t 278 size_t size, enum dma_data_direction dir)
203dma_map_single(struct device *dev, void *cpu_addr, size_t size,
204 enum dma_data_direction dir)
205{ 279{
280 BUG_ON(!valid_dma_direction(dir));
281
206 if (!arch_is_coherent()) 282 if (!arch_is_coherent())
207 dma_cache_maint(cpu_addr, size, dir); 283 dma_cache_maint(cpu_addr, size, dir);
208 284
209 return virt_to_dma(dev, cpu_addr); 285 return virt_to_dma(dev, cpu_addr);
210} 286}
211#else
212extern dma_addr_t dma_map_single(struct device *,void *, size_t, enum dma_data_direction);
213#endif
214 287
215/** 288/**
216 * dma_map_page - map a portion of a page for streaming DMA 289 * dma_map_page - map a portion of a page for streaming DMA
@@ -224,23 +297,25 @@ extern dma_addr_t dma_map_single(struct device *,void *, size_t, enum dma_data_d
224 * or written back. 297 * or written back.
225 * 298 *
226 * The device owns this memory once this call has completed. The CPU 299 * The device owns this memory once this call has completed. The CPU
227 * can regain ownership by calling dma_unmap_page() or 300 * can regain ownership by calling dma_unmap_page().
228 * dma_sync_single_for_cpu().
229 */ 301 */
230static inline dma_addr_t 302static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
231dma_map_page(struct device *dev, struct page *page, 303 unsigned long offset, size_t size, enum dma_data_direction dir)
232 unsigned long offset, size_t size,
233 enum dma_data_direction dir)
234{ 304{
235 return dma_map_single(dev, page_address(page) + offset, size, dir); 305 BUG_ON(!valid_dma_direction(dir));
306
307 if (!arch_is_coherent())
308 dma_cache_maint(page_address(page) + offset, size, dir);
309
310 return page_to_dma(dev, page) + offset;
236} 311}
237 312
238/** 313/**
239 * dma_unmap_single - unmap a single buffer previously mapped 314 * dma_unmap_single - unmap a single buffer previously mapped
240 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices 315 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
241 * @handle: DMA address of buffer 316 * @handle: DMA address of buffer
242 * @size: size of buffer to map 317 * @size: size of buffer (same as passed to dma_map_single)
243 * @dir: DMA transfer direction 318 * @dir: DMA transfer direction (same as passed to dma_map_single)
244 * 319 *
245 * Unmap a single streaming mode DMA translation. The handle and size 320 * Unmap a single streaming mode DMA translation. The handle and size
246 * must match what was provided in the previous dma_map_single() call. 321 * must match what was provided in the previous dma_map_single() call.
@@ -249,108 +324,34 @@ dma_map_page(struct device *dev, struct page *page,
249 * After this call, reads by the CPU to the buffer are guaranteed to see 324 * After this call, reads by the CPU to the buffer are guaranteed to see
250 * whatever the device wrote there. 325 * whatever the device wrote there.
251 */ 326 */
252#ifndef CONFIG_DMABOUNCE 327static inline void dma_unmap_single(struct device *dev, dma_addr_t handle,
253static inline void 328 size_t size, enum dma_data_direction dir)
254dma_unmap_single(struct device *dev, dma_addr_t handle, size_t size,
255 enum dma_data_direction dir)
256{ 329{
257 /* nothing to do */ 330 /* nothing to do */
258} 331}
259#else 332#endif /* CONFIG_DMABOUNCE */
260extern void dma_unmap_single(struct device *, dma_addr_t, size_t, enum dma_data_direction);
261#endif
262 333
263/** 334/**
264 * dma_unmap_page - unmap a buffer previously mapped through dma_map_page() 335 * dma_unmap_page - unmap a buffer previously mapped through dma_map_page()
265 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices 336 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
266 * @handle: DMA address of buffer 337 * @handle: DMA address of buffer
267 * @size: size of buffer to map 338 * @size: size of buffer (same as passed to dma_map_page)
268 * @dir: DMA transfer direction 339 * @dir: DMA transfer direction (same as passed to dma_map_page)
269 * 340 *
270 * Unmap a single streaming mode DMA translation. The handle and size 341 * Unmap a page streaming mode DMA translation. The handle and size
271 * must match what was provided in the previous dma_map_single() call. 342 * must match what was provided in the previous dma_map_page() call.
272 * All other usages are undefined. 343 * All other usages are undefined.
273 * 344 *
274 * After this call, reads by the CPU to the buffer are guaranteed to see 345 * After this call, reads by the CPU to the buffer are guaranteed to see
275 * whatever the device wrote there. 346 * whatever the device wrote there.
276 */ 347 */
277static inline void 348static inline void dma_unmap_page(struct device *dev, dma_addr_t handle,
278dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size, 349 size_t size, enum dma_data_direction dir)
279 enum dma_data_direction dir)
280{ 350{
281 dma_unmap_single(dev, handle, size, dir); 351 dma_unmap_single(dev, handle, size, dir);
282} 352}
283 353
284/** 354/**
285 * dma_map_sg - map a set of SG buffers for streaming mode DMA
286 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
287 * @sg: list of buffers
288 * @nents: number of buffers to map
289 * @dir: DMA transfer direction
290 *
291 * Map a set of buffers described by scatterlist in streaming
292 * mode for DMA. This is the scatter-gather version of the
293 * above dma_map_single interface. Here the scatter gather list
294 * elements are each tagged with the appropriate dma address
295 * and length. They are obtained via sg_dma_{address,length}(SG).
296 *
297 * NOTE: An implementation may be able to use a smaller number of
298 * DMA address/length pairs than there are SG table elements.
299 * (for example via virtual mapping capabilities)
300 * The routine returns the number of addr/length pairs actually
301 * used, at most nents.
302 *
303 * Device ownership issues as mentioned above for dma_map_single are
304 * the same here.
305 */
306#ifndef CONFIG_DMABOUNCE
307static inline int
308dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
309 enum dma_data_direction dir)
310{
311 int i;
312
313 for (i = 0; i < nents; i++, sg++) {
314 char *virt;
315
316 sg->dma_address = page_to_dma(dev, sg_page(sg)) + sg->offset;
317 virt = sg_virt(sg);
318
319 if (!arch_is_coherent())
320 dma_cache_maint(virt, sg->length, dir);
321 }
322
323 return nents;
324}
325#else
326extern int dma_map_sg(struct device *, struct scatterlist *, int, enum dma_data_direction);
327#endif
328
329/**
330 * dma_unmap_sg - unmap a set of SG buffers mapped by dma_map_sg
331 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
332 * @sg: list of buffers
333 * @nents: number of buffers to map
334 * @dir: DMA transfer direction
335 *
336 * Unmap a set of streaming mode DMA translations.
337 * Again, CPU read rules concerning calls here are the same as for
338 * dma_unmap_single() above.
339 */
340#ifndef CONFIG_DMABOUNCE
341static inline void
342dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
343 enum dma_data_direction dir)
344{
345
346 /* nothing to do */
347}
348#else
349extern void dma_unmap_sg(struct device *, struct scatterlist *, int, enum dma_data_direction);
350#endif
351
352
353/**
354 * dma_sync_single_range_for_cpu 355 * dma_sync_single_range_for_cpu
355 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices 356 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
356 * @handle: DMA address of buffer 357 * @handle: DMA address of buffer
@@ -368,145 +369,52 @@ extern void dma_unmap_sg(struct device *, struct scatterlist *, int, enum dma_da
368 * must first the perform a dma_sync_for_device, and then the 369 * must first the perform a dma_sync_for_device, and then the
369 * device again owns the buffer. 370 * device again owns the buffer.
370 */ 371 */
371#ifndef CONFIG_DMABOUNCE 372static inline void dma_sync_single_range_for_cpu(struct device *dev,
372static inline void 373 dma_addr_t handle, unsigned long offset, size_t size,
373dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t handle, 374 enum dma_data_direction dir)
374 unsigned long offset, size_t size,
375 enum dma_data_direction dir)
376{ 375{
377 if (!arch_is_coherent()) 376 BUG_ON(!valid_dma_direction(dir));
378 dma_cache_maint(dma_to_virt(dev, handle) + offset, size, dir); 377
378 dmabounce_sync_for_cpu(dev, handle, offset, size, dir);
379} 379}
380 380
381static inline void 381static inline void dma_sync_single_range_for_device(struct device *dev,
382dma_sync_single_range_for_device(struct device *dev, dma_addr_t handle, 382 dma_addr_t handle, unsigned long offset, size_t size,
383 unsigned long offset, size_t size, 383 enum dma_data_direction dir)
384 enum dma_data_direction dir)
385{ 384{
385 BUG_ON(!valid_dma_direction(dir));
386
387 if (!dmabounce_sync_for_device(dev, handle, offset, size, dir))
388 return;
389
386 if (!arch_is_coherent()) 390 if (!arch_is_coherent())
387 dma_cache_maint(dma_to_virt(dev, handle) + offset, size, dir); 391 dma_cache_maint(dma_to_virt(dev, handle) + offset, size, dir);
388} 392}
389#else
390extern void dma_sync_single_range_for_cpu(struct device *, dma_addr_t, unsigned long, size_t, enum dma_data_direction);
391extern void dma_sync_single_range_for_device(struct device *, dma_addr_t, unsigned long, size_t, enum dma_data_direction);
392#endif
393 393
394static inline void 394static inline void dma_sync_single_for_cpu(struct device *dev,
395dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, size_t size, 395 dma_addr_t handle, size_t size, enum dma_data_direction dir)
396 enum dma_data_direction dir)
397{ 396{
398 dma_sync_single_range_for_cpu(dev, handle, 0, size, dir); 397 dma_sync_single_range_for_cpu(dev, handle, 0, size, dir);
399} 398}
400 399
401static inline void 400static inline void dma_sync_single_for_device(struct device *dev,
402dma_sync_single_for_device(struct device *dev, dma_addr_t handle, size_t size, 401 dma_addr_t handle, size_t size, enum dma_data_direction dir)
403 enum dma_data_direction dir)
404{ 402{
405 dma_sync_single_range_for_device(dev, handle, 0, size, dir); 403 dma_sync_single_range_for_device(dev, handle, 0, size, dir);
406} 404}
407 405
408
409/**
410 * dma_sync_sg_for_cpu
411 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
412 * @sg: list of buffers
413 * @nents: number of buffers to map
414 * @dir: DMA transfer direction
415 *
416 * Make physical memory consistent for a set of streaming
417 * mode DMA translations after a transfer.
418 *
419 * The same as dma_sync_single_for_* but for a scatter-gather list,
420 * same rules and usage.
421 */
422#ifndef CONFIG_DMABOUNCE
423static inline void
424dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
425 enum dma_data_direction dir)
426{
427 int i;
428
429 for (i = 0; i < nents; i++, sg++) {
430 char *virt = sg_virt(sg);
431 if (!arch_is_coherent())
432 dma_cache_maint(virt, sg->length, dir);
433 }
434}
435
436static inline void
437dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents,
438 enum dma_data_direction dir)
439{
440 int i;
441
442 for (i = 0; i < nents; i++, sg++) {
443 char *virt = sg_virt(sg);
444 if (!arch_is_coherent())
445 dma_cache_maint(virt, sg->length, dir);
446 }
447}
448#else
449extern void dma_sync_sg_for_cpu(struct device*, struct scatterlist*, int, enum dma_data_direction);
450extern void dma_sync_sg_for_device(struct device*, struct scatterlist*, int, enum dma_data_direction);
451#endif
452
453#ifdef CONFIG_DMABOUNCE
454/* 406/*
455 * For SA-1111, IXP425, and ADI systems the dma-mapping functions are "magic" 407 * The scatter list versions of the above methods.
456 * and utilize bounce buffers as needed to work around limited DMA windows.
457 *
458 * On the SA-1111, a bug limits DMA to only certain regions of RAM.
459 * On the IXP425, the PCI inbound window is 64MB (256MB total RAM)
460 * On some ADI engineering systems, PCI inbound window is 32MB (12MB total RAM)
461 *
462 * The following are helper functions used by the dmabounce subystem
463 *
464 */
465
466/**
467 * dmabounce_register_dev
468 *
469 * @dev: valid struct device pointer
470 * @small_buf_size: size of buffers to use with small buffer pool
471 * @large_buf_size: size of buffers to use with large buffer pool (can be 0)
472 *
473 * This function should be called by low-level platform code to register
474 * a device as requireing DMA buffer bouncing. The function will allocate
475 * appropriate DMA pools for the device.
476 *
477 */
478extern int dmabounce_register_dev(struct device *, unsigned long, unsigned long);
479
480/**
481 * dmabounce_unregister_dev
482 *
483 * @dev: valid struct device pointer
484 *
485 * This function should be called by low-level platform code when device
486 * that was previously registered with dmabounce_register_dev is removed
487 * from the system.
488 *
489 */ 408 */
490extern void dmabounce_unregister_dev(struct device *); 409extern int dma_map_sg(struct device *, struct scatterlist *, int,
410 enum dma_data_direction);
411extern void dma_unmap_sg(struct device *, struct scatterlist *, int,
412 enum dma_data_direction);
413extern void dma_sync_sg_for_cpu(struct device *, struct scatterlist *, int,
414 enum dma_data_direction);
415extern void dma_sync_sg_for_device(struct device *, struct scatterlist *, int,
416 enum dma_data_direction);
491 417
492/**
493 * dma_needs_bounce
494 *
495 * @dev: valid struct device pointer
496 * @dma_handle: dma_handle of unbounced buffer
497 * @size: size of region being mapped
498 *
499 * Platforms that utilize the dmabounce mechanism must implement
500 * this function.
501 *
502 * The dmabounce routines call this function whenever a dma-mapping
503 * is requested to determine whether a given buffer needs to be bounced
504 * or not. The function must return 0 if the buffer is OK for
505 * DMA access and 1 if the buffer needs to be bounced.
506 *
507 */
508extern int dma_needs_bounce(struct device*, dma_addr_t, size_t);
509#endif /* CONFIG_DMABOUNCE */
510 418
511#endif /* __KERNEL__ */ 419#endif /* __KERNEL__ */
512#endif 420#endif
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 4ca751627489..5be016980c19 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -3,7 +3,6 @@
3 3
4#include <asm/hwcap.h> 4#include <asm/hwcap.h>
5 5
6#ifndef __ASSEMBLY__
7/* 6/*
8 * ELF register definitions.. 7 * ELF register definitions..
9 */ 8 */
@@ -17,12 +16,34 @@ typedef unsigned long elf_freg_t[3];
17typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 16typedef elf_greg_t elf_gregset_t[ELF_NGREG];
18 17
19typedef struct user_fp elf_fpregset_t; 18typedef struct user_fp elf_fpregset_t;
20#endif
21 19
22#define EM_ARM 40 20#define EM_ARM 40
23#define EF_ARM_APCS26 0x08 21
24#define EF_ARM_SOFT_FLOAT 0x200 22#define EF_ARM_EABI_MASK 0xff000000
25#define EF_ARM_EABI_MASK 0xFF000000 23#define EF_ARM_EABI_UNKNOWN 0x00000000
24#define EF_ARM_EABI_VER1 0x01000000
25#define EF_ARM_EABI_VER2 0x02000000
26#define EF_ARM_EABI_VER3 0x03000000
27#define EF_ARM_EABI_VER4 0x04000000
28#define EF_ARM_EABI_VER5 0x05000000
29
30#define EF_ARM_BE8 0x00800000 /* ABI 4,5 */
31#define EF_ARM_LE8 0x00400000 /* ABI 4,5 */
32#define EF_ARM_MAVERICK_FLOAT 0x00000800 /* ABI 0 */
33#define EF_ARM_VFP_FLOAT 0x00000400 /* ABI 0 */
34#define EF_ARM_SOFT_FLOAT 0x00000200 /* ABI 0 */
35#define EF_ARM_OLD_ABI 0x00000100 /* ABI 0 */
36#define EF_ARM_NEW_ABI 0x00000080 /* ABI 0 */
37#define EF_ARM_ALIGN8 0x00000040 /* ABI 0 */
38#define EF_ARM_PIC 0x00000020 /* ABI 0 */
39#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ABI 2 */
40#define EF_ARM_APCS_FLOAT 0x00000010 /* ABI 0, floats in fp regs */
41#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ABI 2 */
42#define EF_ARM_APCS_26 0x00000008 /* ABI 0 */
43#define EF_ARM_SYMSARESORTED 0x00000004 /* ABI 1,2 */
44#define EF_ARM_INTERWORK 0x00000004 /* ABI 0 */
45#define EF_ARM_HASENTRY 0x00000002 /* All */
46#define EF_ARM_RELEXEC 0x00000001 /* All */
26 47
27#define R_ARM_NONE 0 48#define R_ARM_NONE 0
28#define R_ARM_PC24 1 49#define R_ARM_PC24 1
@@ -41,7 +62,6 @@ typedef struct user_fp elf_fpregset_t;
41#endif 62#endif
42#define ELF_ARCH EM_ARM 63#define ELF_ARCH EM_ARM
43 64
44#ifndef __ASSEMBLY__
45/* 65/*
46 * This yields a string that ld.so will use to load implementation 66 * This yields a string that ld.so will use to load implementation
47 * specific libraries for optimization. This is more specific in 67 * specific libraries for optimization. This is more specific in
@@ -59,25 +79,17 @@ typedef struct user_fp elf_fpregset_t;
59#define ELF_PLATFORM (elf_platform) 79#define ELF_PLATFORM (elf_platform)
60 80
61extern char elf_platform[]; 81extern char elf_platform[];
62#endif
63 82
64/* 83struct elf32_hdr;
65 * This is used to ensure we don't load something for the wrong architecture.
66 */
67#define elf_check_arch(x) ((x)->e_machine == EM_ARM && ELF_PROC_OK(x))
68 84
69/* 85/*
70 * 32-bit code is always OK. Some cpus can do 26-bit, some can't. 86 * This is used to ensure we don't load something for the wrong architecture.
71 */ 87 */
72#define ELF_PROC_OK(x) (ELF_THUMB_OK(x) && ELF_26BIT_OK(x)) 88extern int elf_check_arch(const struct elf32_hdr *);
73 89#define elf_check_arch elf_check_arch
74#define ELF_THUMB_OK(x) \
75 ((elf_hwcap & HWCAP_THUMB && ((x)->e_entry & 1) == 1) || \
76 ((x)->e_entry & 3) == 0)
77 90
78#define ELF_26BIT_OK(x) \ 91extern int arm_elf_read_implies_exec(const struct elf32_hdr *, int);
79 ((elf_hwcap & HWCAP_26BIT && (x)->e_flags & EF_ARM_APCS26) || \ 92#define elf_read_implies_exec(ex,stk) arm_elf_read_implies_exec(&(ex), stk)
80 ((x)->e_flags & EF_ARM_APCS26) == 0)
81 93
82#define USE_ELF_CORE_DUMP 94#define USE_ELF_CORE_DUMP
83#define ELF_EXEC_PAGESIZE 4096 95#define ELF_EXEC_PAGESIZE 4096
@@ -94,23 +106,7 @@ extern char elf_platform[];
94 have no such handler. */ 106 have no such handler. */
95#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0 107#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0
96 108
97/* 109extern void elf_set_personality(const struct elf32_hdr *);
98 * Since the FPA coprocessor uses CP1 and CP2, and iWMMXt uses CP0 110#define SET_PERSONALITY(ex, ibcs2) elf_set_personality(&(ex))
99 * and CP1, we only enable access to the iWMMXt coprocessor if the
100 * binary is EABI or softfloat (and thus, guaranteed not to use
101 * FPA instructions.)
102 */
103#define SET_PERSONALITY(ex, ibcs2) \
104 do { \
105 if ((ex).e_flags & EF_ARM_APCS26) { \
106 set_personality(PER_LINUX); \
107 } else { \
108 set_personality(PER_LINUX_32BIT); \
109 if (elf_hwcap & HWCAP_IWMMXT && (ex).e_flags & (EF_ARM_EABI_MASK | EF_ARM_SOFT_FLOAT)) \
110 set_thread_flag(TIF_USING_IWMMXT); \
111 else \
112 clear_thread_flag(TIF_USING_IWMMXT); \
113 } \
114 } while (0)
115 111
116#endif 112#endif
diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
index 6a332a9f099c..9ee743b95de8 100644
--- a/arch/arm/include/asm/futex.h
+++ b/arch/arm/include/asm/futex.h
@@ -1,6 +1,124 @@
1#ifndef _ASM_FUTEX_H 1#ifndef _ASM_ARM_FUTEX_H
2#define _ASM_FUTEX_H 2#define _ASM_ARM_FUTEX_H
3
4#ifdef __KERNEL__
5
6#ifdef CONFIG_SMP
3 7
4#include <asm-generic/futex.h> 8#include <asm-generic/futex.h>
5 9
6#endif 10#else /* !SMP, we can work around lack of atomic ops by disabling preemption */
11
12#include <linux/futex.h>
13#include <linux/preempt.h>
14#include <linux/uaccess.h>
15#include <asm/errno.h>
16
17#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
18 __asm__ __volatile__( \
19 "1: ldrt %1, [%2]\n" \
20 " " insn "\n" \
21 "2: strt %0, [%2]\n" \
22 " mov %0, #0\n" \
23 "3:\n" \
24 " .section __ex_table,\"a\"\n" \
25 " .align 3\n" \
26 " .long 1b, 4f, 2b, 4f\n" \
27 " .previous\n" \
28 " .section .fixup,\"ax\"\n" \
29 "4: mov %0, %4\n" \
30 " b 3b\n" \
31 " .previous" \
32 : "=&r" (ret), "=&r" (oldval) \
33 : "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
34 : "cc", "memory")
35
36static inline int
37futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
38{
39 int op = (encoded_op >> 28) & 7;
40 int cmp = (encoded_op >> 24) & 15;
41 int oparg = (encoded_op << 8) >> 20;
42 int cmparg = (encoded_op << 20) >> 20;
43 int oldval = 0, ret;
44
45 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
46 oparg = 1 << oparg;
47
48 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
49 return -EFAULT;
50
51 pagefault_disable(); /* implies preempt_disable() */
52
53 switch (op) {
54 case FUTEX_OP_SET:
55 __futex_atomic_op("mov %0, %3", ret, oldval, uaddr, oparg);
56 break;
57 case FUTEX_OP_ADD:
58 __futex_atomic_op("add %0, %1, %3", ret, oldval, uaddr, oparg);
59 break;
60 case FUTEX_OP_OR:
61 __futex_atomic_op("orr %0, %1, %3", ret, oldval, uaddr, oparg);
62 break;
63 case FUTEX_OP_ANDN:
64 __futex_atomic_op("and %0, %1, %3", ret, oldval, uaddr, ~oparg);
65 break;
66 case FUTEX_OP_XOR:
67 __futex_atomic_op("eor %0, %1, %3", ret, oldval, uaddr, oparg);
68 break;
69 default:
70 ret = -ENOSYS;
71 }
72
73 pagefault_enable(); /* subsumes preempt_enable() */
74
75 if (!ret) {
76 switch (cmp) {
77 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
78 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
79 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
80 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
81 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
82 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
83 default: ret = -ENOSYS;
84 }
85 }
86 return ret;
87}
88
89static inline int
90futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
91{
92 int val;
93
94 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
95 return -EFAULT;
96
97 pagefault_disable(); /* implies preempt_disable() */
98
99 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
100 "1: ldrt %0, [%3]\n"
101 " teq %0, %1\n"
102 "2: streqt %2, [%3]\n"
103 "3:\n"
104 " .section __ex_table,\"a\"\n"
105 " .align 3\n"
106 " .long 1b, 4f, 2b, 4f\n"
107 " .previous\n"
108 " .section .fixup,\"ax\"\n"
109 "4: mov %0, %4\n"
110 " b 3b\n"
111 " .previous"
112 : "=&r" (val)
113 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
114 : "cc", "memory");
115
116 pagefault_enable(); /* subsumes preempt_enable() */
117
118 return val;
119}
120
121#endif /* !SMP */
122
123#endif /* __KERNEL__ */
124#endif /* _ASM_ARM_FUTEX_H */
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 71934856fc22..a8094451be57 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -60,10 +60,9 @@ extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
60#define MT_DEVICE 0 60#define MT_DEVICE 0
61#define MT_DEVICE_NONSHARED 1 61#define MT_DEVICE_NONSHARED 1
62#define MT_DEVICE_CACHED 2 62#define MT_DEVICE_CACHED 2
63#define MT_DEVICE_IXP2000 3 63#define MT_DEVICE_WC 3
64#define MT_DEVICE_WC 4
65/* 64/*
66 * types 5 onwards can be found in asm/mach/map.h and are undefined 65 * types 4 onwards can be found in asm/mach/map.h and are undefined
67 * for ioremap 66 * for ioremap
68 */ 67 */
69 68
diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h
index d6786090d02c..a0009aa5d157 100644
--- a/arch/arm/include/asm/irq.h
+++ b/arch/arm/include/asm/irq.h
@@ -22,6 +22,10 @@
22#ifndef __ASSEMBLY__ 22#ifndef __ASSEMBLY__
23struct irqaction; 23struct irqaction;
24extern void migrate_irqs(void); 24extern void migrate_irqs(void);
25
26extern void asm_do_IRQ(unsigned int, struct pt_regs *);
27void init_IRQ(void);
28
25#endif 29#endif
26 30
27#endif 31#endif
diff --git a/arch/arm/include/asm/kprobes.h b/arch/arm/include/asm/kprobes.h
index a5d0d99ad387..bb8a19bd5822 100644
--- a/arch/arm/include/asm/kprobes.h
+++ b/arch/arm/include/asm/kprobes.h
@@ -61,7 +61,6 @@ struct kprobe_ctlblk {
61void arch_remove_kprobe(struct kprobe *); 61void arch_remove_kprobe(struct kprobe *);
62void kretprobe_trampoline(void); 62void kretprobe_trampoline(void);
63 63
64int kprobe_trap_handler(struct pt_regs *regs, unsigned int instr);
65int kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr); 64int kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr);
66int kprobe_exceptions_notify(struct notifier_block *self, 65int kprobe_exceptions_notify(struct notifier_block *self,
67 unsigned long val, void *data); 66 unsigned long val, void *data);
diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
index 9eb936e49cc3..cb1139ac1943 100644
--- a/arch/arm/include/asm/mach/map.h
+++ b/arch/arm/include/asm/mach/map.h
@@ -18,16 +18,13 @@ struct map_desc {
18 unsigned int type; 18 unsigned int type;
19}; 19};
20 20
21/* types 0-4 are defined in asm/io.h */ 21/* types 0-3 are defined in asm/io.h */
22#define MT_CACHECLEAN 5 22#define MT_CACHECLEAN 4
23#define MT_MINICLEAN 6 23#define MT_MINICLEAN 5
24#define MT_LOW_VECTORS 7 24#define MT_LOW_VECTORS 6
25#define MT_HIGH_VECTORS 8 25#define MT_HIGH_VECTORS 7
26#define MT_MEMORY 9 26#define MT_MEMORY 8
27#define MT_ROM 10 27#define MT_ROM 9
28
29#define MT_NONSHARED_DEVICE MT_DEVICE_NONSHARED
30#define MT_IXP2000_DEVICE MT_DEVICE_IXP2000
31 28
32#ifdef CONFIG_MMU 29#ifdef CONFIG_MMU
33extern void iotable_init(struct map_desc *, int); 30extern void iotable_init(struct map_desc *, int);
diff --git a/arch/arm/include/asm/mach/udc_pxa2xx.h b/arch/arm/include/asm/mach/udc_pxa2xx.h
index 270902c353fd..f3eabf1ecec3 100644
--- a/arch/arm/include/asm/mach/udc_pxa2xx.h
+++ b/arch/arm/include/asm/mach/udc_pxa2xx.h
@@ -18,8 +18,7 @@ struct pxa2xx_udc_mach_info {
18 /* Boards following the design guidelines in the developer's manual, 18 /* Boards following the design guidelines in the developer's manual,
19 * with on-chip GPIOs not Lubbock's weird hardware, can have a sane 19 * with on-chip GPIOs not Lubbock's weird hardware, can have a sane
20 * VBUS IRQ and omit the methods above. Store the GPIO number 20 * VBUS IRQ and omit the methods above. Store the GPIO number
21 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits. 21 * here. Note that sometimes the signals go through inverters...
22 * Note that sometimes the signals go through inverters...
23 */ 22 */
24 bool gpio_vbus_inverted; 23 bool gpio_vbus_inverted;
25 u16 gpio_vbus; /* high == vbus present */ 24 u16 gpio_vbus; /* high == vbus present */
diff --git a/arch/arm/include/asm/mc146818rtc.h b/arch/arm/include/asm/mc146818rtc.h
index e1ca48a9e973..6b884d2b0b69 100644
--- a/arch/arm/include/asm/mc146818rtc.h
+++ b/arch/arm/include/asm/mc146818rtc.h
@@ -4,8 +4,8 @@
4#ifndef _ASM_MC146818RTC_H 4#ifndef _ASM_MC146818RTC_H
5#define _ASM_MC146818RTC_H 5#define _ASM_MC146818RTC_H
6 6
7#include <linux/io.h>
7#include <mach/irqs.h> 8#include <mach/irqs.h>
8#include <asm/io.h>
9 9
10#ifndef RTC_PORT 10#ifndef RTC_PORT
11#define RTC_PORT(x) (0x70 + (x)) 11#define RTC_PORT(x) (0x70 + (x))
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index bf7c737c9226..809ff9ab853a 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -13,30 +13,27 @@
13#ifndef __ASM_ARM_MEMORY_H 13#ifndef __ASM_ARM_MEMORY_H
14#define __ASM_ARM_MEMORY_H 14#define __ASM_ARM_MEMORY_H
15 15
16#include <linux/compiler.h>
17#include <linux/const.h>
18#include <mach/memory.h>
19#include <asm/sizes.h>
20
16/* 21/*
17 * Allow for constants defined here to be used from assembly code 22 * Allow for constants defined here to be used from assembly code
18 * by prepending the UL suffix only with actual C code compilation. 23 * by prepending the UL suffix only with actual C code compilation.
19 */ 24 */
20#ifndef __ASSEMBLY__ 25#define UL(x) _AC(x, UL)
21#define UL(x) (x##UL)
22#else
23#define UL(x) (x)
24#endif
25
26#include <linux/compiler.h>
27#include <mach/memory.h>
28#include <asm/sizes.h>
29 26
30#ifdef CONFIG_MMU 27#ifdef CONFIG_MMU
31 28
32#ifndef TASK_SIZE
33/* 29/*
30 * PAGE_OFFSET - the virtual address of the start of the kernel image
34 * TASK_SIZE - the maximum size of a user space task. 31 * TASK_SIZE - the maximum size of a user space task.
35 * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area 32 * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
36 */ 33 */
37#define TASK_SIZE UL(0xbf000000) 34#define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
38#define TASK_UNMAPPED_BASE UL(0x40000000) 35#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
39#endif 36#define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
40 37
41/* 38/*
42 * The maximum size of a 26-bit user space task. 39 * The maximum size of a 26-bit user space task.
@@ -44,13 +41,6 @@
44#define TASK_SIZE_26 UL(0x04000000) 41#define TASK_SIZE_26 UL(0x04000000)
45 42
46/* 43/*
47 * Page offset: 3GB
48 */
49#ifndef PAGE_OFFSET
50#define PAGE_OFFSET UL(0xc0000000)
51#endif
52
53/*
54 * The module space lives between the addresses given by TASK_SIZE 44 * The module space lives between the addresses given by TASK_SIZE
55 * and PAGE_OFFSET - it must be within 32MB of the kernel text. 45 * and PAGE_OFFSET - it must be within 32MB of the kernel text.
56 */ 46 */
@@ -147,17 +137,11 @@
147 137
148#ifndef arch_adjust_zones 138#ifndef arch_adjust_zones
149#define arch_adjust_zones(node,size,holes) do { } while (0) 139#define arch_adjust_zones(node,size,holes) do { } while (0)
140#elif !defined(CONFIG_ZONE_DMA)
141#error "custom arch_adjust_zones() requires CONFIG_ZONE_DMA"
150#endif 142#endif
151 143
152/* 144/*
153 * Amount of memory reserved for the vmalloc() area, and minimum
154 * address for vmalloc mappings.
155 */
156extern unsigned long vmalloc_reserve;
157
158#define VMALLOC_MIN (void *)(VMALLOC_END - vmalloc_reserve)
159
160/*
161 * PFNs are used to describe any physical page; this means 145 * PFNs are used to describe any physical page; this means
162 * PFN 0 == physical address 0. 146 * PFN 0 == physical address 0.
163 * 147 *
diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
index a301e446007f..0559f37c2a27 100644
--- a/arch/arm/include/asm/mmu_context.h
+++ b/arch/arm/include/asm/mmu_context.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
18#include <asm/cachetype.h>
18#include <asm/proc-fns.h> 19#include <asm/proc-fns.h>
19#include <asm-generic/mm_hooks.h> 20#include <asm-generic/mm_hooks.h>
20 21
diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index cf2e2680daaa..bed1c0a00368 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -184,8 +184,9 @@ typedef struct page *pgtable_t;
184 184
185#endif /* !__ASSEMBLY__ */ 185#endif /* !__ASSEMBLY__ */
186 186
187#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ 187#define VM_DATA_DEFAULT_FLAGS \
188 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 188 (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
189 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
189 190
190/* 191/*
191 * With EABI on ARMv5 and above we must have 64-bit aligned slab pointers. 192 * With EABI on ARMv5 and above we must have 64-bit aligned slab pointers.
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index 8e21ef15bd74..110295c5461d 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -164,14 +164,30 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
164#define L_PTE_PRESENT (1 << 0) 164#define L_PTE_PRESENT (1 << 0)
165#define L_PTE_FILE (1 << 1) /* only when !PRESENT */ 165#define L_PTE_FILE (1 << 1) /* only when !PRESENT */
166#define L_PTE_YOUNG (1 << 1) 166#define L_PTE_YOUNG (1 << 1)
167#define L_PTE_BUFFERABLE (1 << 2) /* matches PTE */ 167#define L_PTE_BUFFERABLE (1 << 2) /* obsolete, matches PTE */
168#define L_PTE_CACHEABLE (1 << 3) /* matches PTE */ 168#define L_PTE_CACHEABLE (1 << 3) /* obsolete, matches PTE */
169#define L_PTE_USER (1 << 4) 169#define L_PTE_DIRTY (1 << 6)
170#define L_PTE_WRITE (1 << 5) 170#define L_PTE_WRITE (1 << 7)
171#define L_PTE_EXEC (1 << 6) 171#define L_PTE_USER (1 << 8)
172#define L_PTE_DIRTY (1 << 7) 172#define L_PTE_EXEC (1 << 9)
173#define L_PTE_SHARED (1 << 10) /* shared(v6), coherent(xsc3) */ 173#define L_PTE_SHARED (1 << 10) /* shared(v6), coherent(xsc3) */
174 174
175/*
176 * These are the memory types, defined to be compatible with
177 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
178 */
179#define L_PTE_MT_UNCACHED (0x00 << 2) /* 0000 */
180#define L_PTE_MT_BUFFERABLE (0x01 << 2) /* 0001 */
181#define L_PTE_MT_WRITETHROUGH (0x02 << 2) /* 0010 */
182#define L_PTE_MT_WRITEBACK (0x03 << 2) /* 0011 */
183#define L_PTE_MT_MINICACHE (0x06 << 2) /* 0110 (sa1100, xscale) */
184#define L_PTE_MT_WRITEALLOC (0x07 << 2) /* 0111 */
185#define L_PTE_MT_DEV_SHARED (0x04 << 2) /* 0100 */
186#define L_PTE_MT_DEV_NONSHARED (0x0c << 2) /* 1100 */
187#define L_PTE_MT_DEV_WC (0x09 << 2) /* 1001 */
188#define L_PTE_MT_DEV_CACHED (0x0b << 2) /* 1011 */
189#define L_PTE_MT_MASK (0x0f << 2)
190
175#ifndef __ASSEMBLY__ 191#ifndef __ASSEMBLY__
176 192
177/* 193/*
@@ -180,23 +196,30 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
180 * as well as any architecture dependent bits like global/ASID and SMP 196 * as well as any architecture dependent bits like global/ASID and SMP
181 * shared mapping bits. 197 * shared mapping bits.
182 */ 198 */
183#define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_CACHEABLE | L_PTE_BUFFERABLE 199#define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
184#define _L_PTE_READ L_PTE_USER | L_PTE_EXEC
185 200
186extern pgprot_t pgprot_user; 201extern pgprot_t pgprot_user;
187extern pgprot_t pgprot_kernel; 202extern pgprot_t pgprot_kernel;
188 203
189#define PAGE_NONE pgprot_user 204#define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b))
190#define PAGE_COPY __pgprot(pgprot_val(pgprot_user) | _L_PTE_READ) 205
191#define PAGE_SHARED __pgprot(pgprot_val(pgprot_user) | _L_PTE_READ | \ 206#define PAGE_NONE pgprot_user
192 L_PTE_WRITE) 207#define PAGE_SHARED _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_WRITE)
193#define PAGE_READONLY __pgprot(pgprot_val(pgprot_user) | _L_PTE_READ) 208#define PAGE_SHARED_EXEC _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_WRITE | L_PTE_EXEC)
194#define PAGE_KERNEL pgprot_kernel 209#define PAGE_COPY _MOD_PROT(pgprot_user, L_PTE_USER)
195 210#define PAGE_COPY_EXEC _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_EXEC)
196#define __PAGE_NONE __pgprot(_L_PTE_DEFAULT) 211#define PAGE_READONLY _MOD_PROT(pgprot_user, L_PTE_USER)
197#define __PAGE_COPY __pgprot(_L_PTE_DEFAULT | _L_PTE_READ) 212#define PAGE_READONLY_EXEC _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_EXEC)
198#define __PAGE_SHARED __pgprot(_L_PTE_DEFAULT | _L_PTE_READ | L_PTE_WRITE) 213#define PAGE_KERNEL pgprot_kernel
199#define __PAGE_READONLY __pgprot(_L_PTE_DEFAULT | _L_PTE_READ) 214#define PAGE_KERNEL_EXEC _MOD_PROT(pgprot_kernel, L_PTE_EXEC)
215
216#define __PAGE_NONE __pgprot(_L_PTE_DEFAULT)
217#define __PAGE_SHARED __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_WRITE)
218#define __PAGE_SHARED_EXEC __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_WRITE | L_PTE_EXEC)
219#define __PAGE_COPY __pgprot(_L_PTE_DEFAULT | L_PTE_USER)
220#define __PAGE_COPY_EXEC __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_EXEC)
221#define __PAGE_READONLY __pgprot(_L_PTE_DEFAULT | L_PTE_USER)
222#define __PAGE_READONLY_EXEC __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_EXEC)
200 223
201#endif /* __ASSEMBLY__ */ 224#endif /* __ASSEMBLY__ */
202 225
@@ -212,19 +235,19 @@ extern pgprot_t pgprot_kernel;
212#define __P001 __PAGE_READONLY 235#define __P001 __PAGE_READONLY
213#define __P010 __PAGE_COPY 236#define __P010 __PAGE_COPY
214#define __P011 __PAGE_COPY 237#define __P011 __PAGE_COPY
215#define __P100 __PAGE_READONLY 238#define __P100 __PAGE_READONLY_EXEC
216#define __P101 __PAGE_READONLY 239#define __P101 __PAGE_READONLY_EXEC
217#define __P110 __PAGE_COPY 240#define __P110 __PAGE_COPY_EXEC
218#define __P111 __PAGE_COPY 241#define __P111 __PAGE_COPY_EXEC
219 242
220#define __S000 __PAGE_NONE 243#define __S000 __PAGE_NONE
221#define __S001 __PAGE_READONLY 244#define __S001 __PAGE_READONLY
222#define __S010 __PAGE_SHARED 245#define __S010 __PAGE_SHARED
223#define __S011 __PAGE_SHARED 246#define __S011 __PAGE_SHARED
224#define __S100 __PAGE_READONLY 247#define __S100 __PAGE_READONLY_EXEC
225#define __S101 __PAGE_READONLY 248#define __S101 __PAGE_READONLY_EXEC
226#define __S110 __PAGE_SHARED 249#define __S110 __PAGE_SHARED_EXEC
227#define __S111 __PAGE_SHARED 250#define __S111 __PAGE_SHARED_EXEC
228 251
229#ifndef __ASSEMBLY__ 252#ifndef __ASSEMBLY__
230/* 253/*
@@ -286,8 +309,10 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
286/* 309/*
287 * Mark the prot value as uncacheable and unbufferable. 310 * Mark the prot value as uncacheable and unbufferable.
288 */ 311 */
289#define pgprot_noncached(prot) __pgprot(pgprot_val(prot) & ~(L_PTE_CACHEABLE | L_PTE_BUFFERABLE)) 312#define pgprot_noncached(prot) \
290#define pgprot_writecombine(prot) __pgprot(pgprot_val(prot) & ~L_PTE_CACHEABLE) 313 __pgprot((pgprot_val(prot) & ~L_PTE_MT_MASK) | L_PTE_MT_UNCACHED)
314#define pgprot_writecombine(prot) \
315 __pgprot((pgprot_val(prot) & ~L_PTE_MT_MASK) | L_PTE_MT_BUFFERABLE)
291 316
292#define pmd_none(pmd) (!pmd_val(pmd)) 317#define pmd_none(pmd) (!pmd_val(pmd))
293#define pmd_present(pmd) (pmd_val(pmd)) 318#define pmd_present(pmd) (pmd_val(pmd))
@@ -320,11 +345,6 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
320#define pmd_page(pmd) virt_to_page(__va(pmd_val(pmd))) 345#define pmd_page(pmd) virt_to_page(__va(pmd_val(pmd)))
321 346
322/* 347/*
323 * Permanent address of a page. We never have highmem, so this is trivial.
324 */
325#define pages_to_mb(x) ((x) >> (20 - PAGE_SHIFT))
326
327/*
328 * Conversion functions: convert a page and protection to a page entry, 348 * Conversion functions: convert a page and protection to a page entry,
329 * and a page entry and page directory to the page they refer to. 349 * and a page entry and page directory to the page they refer to.
330 */ 350 */
diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index b415c0e85458..73192618f1c2 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -54,7 +54,6 @@
54#define PSR_C_BIT 0x20000000 54#define PSR_C_BIT 0x20000000
55#define PSR_Z_BIT 0x40000000 55#define PSR_Z_BIT 0x40000000
56#define PSR_N_BIT 0x80000000 56#define PSR_N_BIT 0x80000000
57#define PCMASK 0
58 57
59/* 58/*
60 * Groups of PSR bits 59 * Groups of PSR bits
@@ -139,11 +138,7 @@ static inline int valid_user_regs(struct pt_regs *regs)
139 return 0; 138 return 0;
140} 139}
141 140
142#define pc_pointer(v) \ 141#define instruction_pointer(regs) (regs)->ARM_pc
143 ((v) & ~PCMASK)
144
145#define instruction_pointer(regs) \
146 (pc_pointer((regs)->ARM_pc))
147 142
148#ifdef CONFIG_SMP 143#ifdef CONFIG_SMP
149extern unsigned long profile_pc(struct pt_regs *regs); 144extern unsigned long profile_pc(struct pt_regs *regs);
diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 7bbf105463f1..a65413ba121d 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -209,6 +209,17 @@ struct meminfo {
209 struct membank bank[NR_BANKS]; 209 struct membank bank[NR_BANKS];
210}; 210};
211 211
212#define for_each_nodebank(iter,mi,no) \
213 for (iter = 0; iter < mi->nr_banks; iter++) \
214 if (mi->bank[iter].node == no)
215
216#define bank_pfn_start(bank) __phys_to_pfn((bank)->start)
217#define bank_pfn_end(bank) __phys_to_pfn((bank)->start + (bank)->size)
218#define bank_pfn_size(bank) ((bank)->size >> PAGE_SHIFT)
219#define bank_phys_start(bank) (bank)->start
220#define bank_phys_end(bank) ((bank)->start + (bank)->size)
221#define bank_phys_size(bank) (bank)->size
222
212/* 223/*
213 * Early command line parameters. 224 * Early command line parameters.
214 */ 225 */
diff --git a/arch/arm/include/asm/sparsemem.h b/arch/arm/include/asm/sparsemem.h
index 277158191a0d..00098615c6f0 100644
--- a/arch/arm/include/asm/sparsemem.h
+++ b/arch/arm/include/asm/sparsemem.h
@@ -3,8 +3,22 @@
3 3
4#include <asm/memory.h> 4#include <asm/memory.h>
5 5
6#define MAX_PHYSADDR_BITS 32 6/*
7#define MAX_PHYSMEM_BITS 32 7 * Two definitions are required for sparsemem:
8#define SECTION_SIZE_BITS NODE_MEM_SIZE_BITS 8 *
9 * MAX_PHYSMEM_BITS: The number of physical address bits required
10 * to address the last byte of memory.
11 *
12 * SECTION_SIZE_BITS: The number of physical address bits to cover
13 * the maximum amount of memory in a section.
14 *
15 * Eg, if you have 2 banks of up to 64MB at 0x80000000, 0x84000000,
16 * then MAX_PHYSMEM_BITS is 32, SECTION_SIZE_BITS is 26.
17 *
18 * Define these in your mach/memory.h.
19 */
20#if !defined(SECTION_SIZE_BITS) || !defined(MAX_PHYSMEM_BITS)
21#error Sparsemem is not supported on this platform
22#endif
9 23
10#endif 24#endif
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 514af792a598..7aad78420f18 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -43,11 +43,6 @@
43#define CR_XP (1 << 23) /* Extended page tables */ 43#define CR_XP (1 << 23) /* Extended page tables */
44#define CR_VE (1 << 24) /* Vectored interrupts */ 44#define CR_VE (1 << 24) /* Vectored interrupts */
45 45
46#define CPUID_ID 0
47#define CPUID_CACHETYPE 1
48#define CPUID_TCM 2
49#define CPUID_TLBTYPE 3
50
51/* 46/*
52 * This is used to ensure the compiler did actually allocate the register we 47 * This is used to ensure the compiler did actually allocate the register we
53 * asked it for some inline assembly sequences. Apparently we can't trust 48 * asked it for some inline assembly sequences. Apparently we can't trust
@@ -61,36 +56,8 @@
61#ifndef __ASSEMBLY__ 56#ifndef __ASSEMBLY__
62 57
63#include <linux/linkage.h> 58#include <linux/linkage.h>
64#include <linux/stringify.h>
65#include <linux/irqflags.h> 59#include <linux/irqflags.h>
66 60
67#ifdef CONFIG_CPU_CP15
68#define read_cpuid(reg) \
69 ({ \
70 unsigned int __val; \
71 asm("mrc p15, 0, %0, c0, c0, " __stringify(reg) \
72 : "=r" (__val) \
73 : \
74 : "cc"); \
75 __val; \
76 })
77#else
78extern unsigned int processor_id;
79#define read_cpuid(reg) (processor_id)
80#endif
81
82/*
83 * The CPU ID never changes at run time, so we might as well tell the
84 * compiler that it's constant. Use this function to read the CPU ID
85 * rather than directly reading processor_id or read_cpuid() directly.
86 */
87static inline unsigned int read_cpuid_id(void) __attribute_const__;
88
89static inline unsigned int read_cpuid_id(void)
90{
91 return read_cpuid(CPUID_ID);
92}
93
94#define __exception __attribute__((section(".exception.text"))) 61#define __exception __attribute__((section(".exception.text")))
95 62
96struct thread_info; 63struct thread_info;
@@ -131,31 +98,6 @@ extern void cpu_init(void);
131void arm_machine_restart(char mode); 98void arm_machine_restart(char mode);
132extern void (*arm_pm_restart)(char str); 99extern void (*arm_pm_restart)(char str);
133 100
134/*
135 * Intel's XScale3 core supports some v6 features (supersections, L2)
136 * but advertises itself as v5 as it does not support the v6 ISA. For
137 * this reason, we need a way to explicitly test for this type of CPU.
138 */
139#ifndef CONFIG_CPU_XSC3
140#define cpu_is_xsc3() 0
141#else
142static inline int cpu_is_xsc3(void)
143{
144 extern unsigned int processor_id;
145
146 if ((processor_id & 0xffffe000) == 0x69056000)
147 return 1;
148
149 return 0;
150}
151#endif
152
153#if !defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_CPU_XSC3)
154#define cpu_is_xscale() 0
155#else
156#define cpu_is_xscale() 1
157#endif
158
159#define UDBG_UNDEFINED (1 << 0) 101#define UDBG_UNDEFINED (1 << 0)
160#define UDBG_SYSCALL (1 << 1) 102#define UDBG_SYSCALL (1 << 1)
161#define UDBG_BADABORT (1 << 2) 103#define UDBG_BADABORT (1 << 2)
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index e56fa48e4ae7..68b9ec82a37f 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -98,7 +98,7 @@ static inline struct thread_info *current_thread_info(void)
98} 98}
99 99
100#define thread_saved_pc(tsk) \ 100#define thread_saved_pc(tsk) \
101 ((unsigned long)(pc_pointer(task_thread_info(tsk)->cpu_context.pc))) 101 ((unsigned long)(task_thread_info(tsk)->cpu_context.pc))
102#define thread_saved_fp(tsk) \ 102#define thread_saved_fp(tsk) \
103 ((unsigned long)(task_thread_info(tsk)->cpu_context.fp)) 103 ((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
104 104
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index d0f51ff900b5..e98ec60b3400 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -225,7 +225,7 @@ do { \
225 225
226#define __get_user_asm_byte(x,addr,err) \ 226#define __get_user_asm_byte(x,addr,err) \
227 __asm__ __volatile__( \ 227 __asm__ __volatile__( \
228 "1: ldrbt %1,[%2],#0\n" \ 228 "1: ldrbt %1,[%2]\n" \
229 "2:\n" \ 229 "2:\n" \
230 " .section .fixup,\"ax\"\n" \ 230 " .section .fixup,\"ax\"\n" \
231 " .align 2\n" \ 231 " .align 2\n" \
@@ -261,7 +261,7 @@ do { \
261 261
262#define __get_user_asm_word(x,addr,err) \ 262#define __get_user_asm_word(x,addr,err) \
263 __asm__ __volatile__( \ 263 __asm__ __volatile__( \
264 "1: ldrt %1,[%2],#0\n" \ 264 "1: ldrt %1,[%2]\n" \
265 "2:\n" \ 265 "2:\n" \
266 " .section .fixup,\"ax\"\n" \ 266 " .section .fixup,\"ax\"\n" \
267 " .align 2\n" \ 267 " .align 2\n" \
@@ -306,7 +306,7 @@ do { \
306 306
307#define __put_user_asm_byte(x,__pu_addr,err) \ 307#define __put_user_asm_byte(x,__pu_addr,err) \
308 __asm__ __volatile__( \ 308 __asm__ __volatile__( \
309 "1: strbt %1,[%2],#0\n" \ 309 "1: strbt %1,[%2]\n" \
310 "2:\n" \ 310 "2:\n" \
311 " .section .fixup,\"ax\"\n" \ 311 " .section .fixup,\"ax\"\n" \
312 " .align 2\n" \ 312 " .align 2\n" \
@@ -339,7 +339,7 @@ do { \
339 339
340#define __put_user_asm_word(x,__pu_addr,err) \ 340#define __put_user_asm_word(x,__pu_addr,err) \
341 __asm__ __volatile__( \ 341 __asm__ __volatile__( \
342 "1: strt %1,[%2],#0\n" \ 342 "1: strt %1,[%2]\n" \
343 "2:\n" \ 343 "2:\n" \
344 " .section .fixup,\"ax\"\n" \ 344 " .section .fixup,\"ax\"\n" \
345 " .align 2\n" \ 345 " .align 2\n" \
@@ -365,7 +365,7 @@ do { \
365#define __put_user_asm_dword(x,__pu_addr,err) \ 365#define __put_user_asm_dword(x,__pu_addr,err) \
366 __asm__ __volatile__( \ 366 __asm__ __volatile__( \
367 "1: strt " __reg_oper1 ", [%1], #4\n" \ 367 "1: strt " __reg_oper1 ", [%1], #4\n" \
368 "2: strt " __reg_oper0 ", [%1], #0\n" \ 368 "2: strt " __reg_oper0 ", [%1]\n" \
369 "3:\n" \ 369 "3:\n" \
370 " .section .fixup,\"ax\"\n" \ 370 " .section .fixup,\"ax\"\n" \
371 " .align 2\n" \ 371 " .align 2\n" \
diff --git a/arch/arm/include/asm/vga.h b/arch/arm/include/asm/vga.h
index 6a3cd2a2f670..250a4dd00630 100644
--- a/arch/arm/include/asm/vga.h
+++ b/arch/arm/include/asm/vga.h
@@ -1,8 +1,8 @@
1#ifndef ASMARM_VGA_H 1#ifndef ASMARM_VGA_H
2#define ASMARM_VGA_H 2#define ASMARM_VGA_H
3 3
4#include <linux/io.h>
4#include <mach/hardware.h> 5#include <mach/hardware.h>
5#include <asm/io.h>
6 6
7#define VGA_MAP_MEM(x,s) (PCIMEM_BASE + (x)) 7#define VGA_MAP_MEM(x,s) (PCIMEM_BASE + (x))
8 8
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 1d296fc8494e..4305345987d3 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -10,7 +10,7 @@ endif
10 10
11# Object file lists. 11# Object file lists.
12 12
13obj-y := compat.o entry-armv.o entry-common.o irq.o \ 13obj-y := compat.o elf.o entry-armv.o entry-common.o irq.o \
14 process.o ptrace.o setup.o signal.o \ 14 process.o ptrace.o setup.o signal.o \
15 sys_arm.o stacktrace.o time.o traps.o 15 sys_arm.o stacktrace.o time.o traps.o
16 16
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index cc7b246e9652..2357b1cf1cf9 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -13,11 +13,11 @@
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/in6.h> 14#include <linux/in6.h>
15#include <linux/syscalls.h> 15#include <linux/syscalls.h>
16#include <linux/uaccess.h>
17#include <linux/io.h>
16 18
17#include <asm/checksum.h> 19#include <asm/checksum.h>
18#include <asm/io.h>
19#include <asm/system.h> 20#include <asm/system.h>
20#include <asm/uaccess.h>
21#include <asm/ftrace.h> 21#include <asm/ftrace.h>
22 22
23/* 23/*
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index e5747547b44c..17a59b6e521f 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -10,8 +10,8 @@
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/io.h>
13 14
14#include <asm/io.h>
15#include <asm/mach-types.h> 15#include <asm/mach-types.h>
16#include <asm/mach/pci.h> 16#include <asm/mach/pci.h>
17 17
diff --git a/arch/arm/kernel/crunch.c b/arch/arm/kernel/crunch.c
index 3b6a1c293ee4..99995c2b2312 100644
--- a/arch/arm/kernel/crunch.c
+++ b/arch/arm/kernel/crunch.c
@@ -15,9 +15,9 @@
15#include <linux/signal.h> 15#include <linux/signal.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/io.h>
18#include <mach/ep93xx-regs.h> 19#include <mach/ep93xx-regs.h>
19#include <asm/thread_notify.h> 20#include <asm/thread_notify.h>
20#include <asm/io.h>
21 21
22struct crunch_state *crunch_owner; 22struct crunch_state *crunch_owner;
23 23
diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S
index 9550ff0ddde4..f53c58290543 100644
--- a/arch/arm/kernel/debug.S
+++ b/arch/arm/kernel/debug.S
@@ -89,10 +89,12 @@
89ENTRY(printhex8) 89ENTRY(printhex8)
90 mov r1, #8 90 mov r1, #8
91 b printhex 91 b printhex
92ENDPROC(printhex8)
92 93
93ENTRY(printhex4) 94ENTRY(printhex4)
94 mov r1, #4 95 mov r1, #4
95 b printhex 96 b printhex
97ENDPROC(printhex4)
96 98
97ENTRY(printhex2) 99ENTRY(printhex2)
98 mov r1, #2 100 mov r1, #2
@@ -110,6 +112,7 @@ printhex: adr r2, hexbuf
110 bne 1b 112 bne 1b
111 mov r0, r2 113 mov r0, r2
112 b printascii 114 b printascii
115ENDPROC(printhex2)
113 116
114 .ltorg 117 .ltorg
115 118
@@ -127,11 +130,13 @@ ENTRY(printascii)
127 teqne r1, #0 130 teqne r1, #0
128 bne 1b 131 bne 1b
129 mov pc, lr 132 mov pc, lr
133ENDPROC(printascii)
130 134
131ENTRY(printch) 135ENTRY(printch)
132 addruart r3 136 addruart r3
133 mov r1, r0 137 mov r1, r0
134 mov r0, #0 138 mov r0, #0
135 b 1b 139 b 1b
140ENDPROC(printch)
136 141
137hexbuf: .space 16 142hexbuf: .space 16
diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c
index 2f080a35a2d9..4a3a50495c60 100644
--- a/arch/arm/kernel/dma-isa.c
+++ b/arch/arm/kernel/dma-isa.c
@@ -19,10 +19,9 @@
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/dma-mapping.h> 21#include <linux/dma-mapping.h>
22#include <linux/io.h>
22 23
23#include <asm/dma.h> 24#include <asm/dma.h>
24#include <asm/io.h>
25
26#include <asm/mach/dma.h> 25#include <asm/mach/dma.h>
27 26
28#define ISA_DMA_MODE_READ 0x44 27#define ISA_DMA_MODE_READ 0x44
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
index 7a50575a8d4d..60c079d85355 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/kernel/ecard.c
@@ -587,8 +587,7 @@ ecard_irq_handler(unsigned int irq, struct irq_desc *desc)
587 pending = ecard_default_ops.irqpending(ec); 587 pending = ecard_default_ops.irqpending(ec);
588 588
589 if (pending) { 589 if (pending) {
590 struct irq_desc *d = irq_desc + ec->irq; 590 generic_handle_irq(ec->irq);
591 desc_handle_irq(ec->irq, d);
592 called ++; 591 called ++;
593 } 592 }
594 } 593 }
@@ -622,7 +621,6 @@ ecard_irqexp_handler(unsigned int irq, struct irq_desc *desc)
622 ecard_t *ec = slot_to_ecard(slot); 621 ecard_t *ec = slot_to_ecard(slot);
623 622
624 if (ec->claimed) { 623 if (ec->claimed) {
625 struct irq_desc *d = irq_desc + ec->irq;
626 /* 624 /*
627 * this ugly code is so that we can operate a 625 * this ugly code is so that we can operate a
628 * prioritorising system: 626 * prioritorising system:
@@ -635,7 +633,7 @@ ecard_irqexp_handler(unsigned int irq, struct irq_desc *desc)
635 * Serial cards should go in 0/1, ethernet/scsi in 2/3 633 * Serial cards should go in 0/1, ethernet/scsi in 2/3
636 * otherwise you will lose serial data at high speeds! 634 * otherwise you will lose serial data at high speeds!
637 */ 635 */
638 desc_handle_irq(ec->irq, d); 636 generic_handle_irq(ec->irq);
639 } else { 637 } else {
640 printk(KERN_WARNING "card%d: interrupt from unclaimed " 638 printk(KERN_WARNING "card%d: interrupt from unclaimed "
641 "card???\n", slot); 639 "card???\n", slot);
diff --git a/arch/arm/kernel/elf.c b/arch/arm/kernel/elf.c
new file mode 100644
index 000000000000..513f332f040d
--- /dev/null
+++ b/arch/arm/kernel/elf.c
@@ -0,0 +1,79 @@
1#include <linux/module.h>
2#include <linux/sched.h>
3#include <linux/personality.h>
4#include <linux/binfmts.h>
5#include <linux/elf.h>
6
7int elf_check_arch(const struct elf32_hdr *x)
8{
9 unsigned int eflags;
10
11 /* Make sure it's an ARM executable */
12 if (x->e_machine != EM_ARM)
13 return 0;
14
15 /* Make sure the entry address is reasonable */
16 if (x->e_entry & 1) {
17 if (!(elf_hwcap & HWCAP_THUMB))
18 return 0;
19 } else if (x->e_entry & 3)
20 return 0;
21
22 eflags = x->e_flags;
23 if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN) {
24 /* APCS26 is only allowed if the CPU supports it */
25 if ((eflags & EF_ARM_APCS_26) && !(elf_hwcap & HWCAP_26BIT))
26 return 0;
27
28 /* VFP requires the supporting code */
29 if ((eflags & EF_ARM_VFP_FLOAT) && !(elf_hwcap & HWCAP_VFP))
30 return 0;
31 }
32 return 1;
33}
34EXPORT_SYMBOL(elf_check_arch);
35
36void elf_set_personality(const struct elf32_hdr *x)
37{
38 unsigned int eflags = x->e_flags;
39 unsigned int personality = PER_LINUX_32BIT;
40
41 /*
42 * APCS-26 is only valid for OABI executables
43 */
44 if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN) {
45 if (eflags & EF_ARM_APCS_26)
46 personality = PER_LINUX;
47 }
48
49 set_personality(personality);
50
51 /*
52 * Since the FPA coprocessor uses CP1 and CP2, and iWMMXt uses CP0
53 * and CP1, we only enable access to the iWMMXt coprocessor if the
54 * binary is EABI or softfloat (and thus, guaranteed not to use
55 * FPA instructions.)
56 */
57 if (elf_hwcap & HWCAP_IWMMXT &&
58 eflags & (EF_ARM_EABI_MASK | EF_ARM_SOFT_FLOAT)) {
59 set_thread_flag(TIF_USING_IWMMXT);
60 } else {
61 clear_thread_flag(TIF_USING_IWMMXT);
62 }
63}
64EXPORT_SYMBOL(elf_set_personality);
65
66/*
67 * Set READ_IMPLIES_EXEC if:
68 * - the binary requires an executable stack
69 * - we're running on a CPU which doesn't support NX.
70 */
71int arm_elf_read_implies_exec(const struct elf32_hdr *x, int executable_stack)
72{
73 if (executable_stack != EXSTACK_ENABLE_X)
74 return 1;
75 if (cpu_architecture() <= CPU_ARCH_ARMv6)
76 return 1;
77 return 0;
78}
79EXPORT_SYMBOL(arm_elf_read_implies_exec);
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 617e509d60df..77b047475539 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -76,14 +76,17 @@
76__pabt_invalid: 76__pabt_invalid:
77 inv_entry BAD_PREFETCH 77 inv_entry BAD_PREFETCH
78 b common_invalid 78 b common_invalid
79ENDPROC(__pabt_invalid)
79 80
80__dabt_invalid: 81__dabt_invalid:
81 inv_entry BAD_DATA 82 inv_entry BAD_DATA
82 b common_invalid 83 b common_invalid
84ENDPROC(__dabt_invalid)
83 85
84__irq_invalid: 86__irq_invalid:
85 inv_entry BAD_IRQ 87 inv_entry BAD_IRQ
86 b common_invalid 88 b common_invalid
89ENDPROC(__irq_invalid)
87 90
88__und_invalid: 91__und_invalid:
89 inv_entry BAD_UNDEFINSTR 92 inv_entry BAD_UNDEFINSTR
@@ -107,6 +110,7 @@ common_invalid:
107 110
108 mov r0, sp 111 mov r0, sp
109 b bad_mode 112 b bad_mode
113ENDPROC(__und_invalid)
110 114
111/* 115/*
112 * SVC mode handlers 116 * SVC mode handlers
@@ -192,6 +196,7 @@ __dabt_svc:
192 ldr r0, [sp, #S_PSR] 196 ldr r0, [sp, #S_PSR]
193 msr spsr_cxsf, r0 197 msr spsr_cxsf, r0
194 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr 198 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
199ENDPROC(__dabt_svc)
195 200
196 .align 5 201 .align 5
197__irq_svc: 202__irq_svc:
@@ -223,6 +228,7 @@ __irq_svc:
223 bleq trace_hardirqs_on 228 bleq trace_hardirqs_on
224#endif 229#endif
225 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr 230 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
231ENDPROC(__irq_svc)
226 232
227 .ltorg 233 .ltorg
228 234
@@ -272,6 +278,7 @@ __und_svc:
272 ldr lr, [sp, #S_PSR] @ Get SVC cpsr 278 ldr lr, [sp, #S_PSR] @ Get SVC cpsr
273 msr spsr_cxsf, lr 279 msr spsr_cxsf, lr
274 ldmia sp, {r0 - pc}^ @ Restore SVC registers 280 ldmia sp, {r0 - pc}^ @ Restore SVC registers
281ENDPROC(__und_svc)
275 282
276 .align 5 283 .align 5
277__pabt_svc: 284__pabt_svc:
@@ -313,6 +320,7 @@ __pabt_svc:
313 ldr r0, [sp, #S_PSR] 320 ldr r0, [sp, #S_PSR]
314 msr spsr_cxsf, r0 321 msr spsr_cxsf, r0
315 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr 322 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
323ENDPROC(__pabt_svc)
316 324
317 .align 5 325 .align 5
318.LCcralign: 326.LCcralign:
@@ -412,6 +420,7 @@ __dabt_usr:
412 mov r2, sp 420 mov r2, sp
413 adr lr, ret_from_exception 421 adr lr, ret_from_exception
414 b do_DataAbort 422 b do_DataAbort
423ENDPROC(__dabt_usr)
415 424
416 .align 5 425 .align 5
417__irq_usr: 426__irq_usr:
@@ -441,6 +450,7 @@ __irq_usr:
441 450
442 mov why, #0 451 mov why, #0
443 b ret_to_user 452 b ret_to_user
453ENDPROC(__irq_usr)
444 454
445 .ltorg 455 .ltorg
446 456
@@ -474,6 +484,7 @@ __und_usr:
474#else 484#else
475 b __und_usr_unknown 485 b __und_usr_unknown
476#endif 486#endif
487ENDPROC(__und_usr)
477 488
478 @ 489 @
479 @ fallthrough to call_fpe 490 @ fallthrough to call_fpe
@@ -642,6 +653,7 @@ __und_usr_unknown:
642 mov r0, sp 653 mov r0, sp
643 adr lr, ret_from_exception 654 adr lr, ret_from_exception
644 b do_undefinstr 655 b do_undefinstr
656ENDPROC(__und_usr_unknown)
645 657
646 .align 5 658 .align 5
647__pabt_usr: 659__pabt_usr:
@@ -666,6 +678,8 @@ ENTRY(ret_from_exception)
666 get_thread_info tsk 678 get_thread_info tsk
667 mov why, #0 679 mov why, #0
668 b ret_to_user 680 b ret_to_user
681ENDPROC(__pabt_usr)
682ENDPROC(ret_from_exception)
669 683
670/* 684/*
671 * Register switch for ARMv3 and ARMv4 processors 685 * Register switch for ARMv3 and ARMv4 processors
@@ -702,6 +716,7 @@ ENTRY(__switch_to)
702 bl atomic_notifier_call_chain 716 bl atomic_notifier_call_chain
703 mov r0, r5 717 mov r0, r5
704 ldmia r4, {r4 - sl, fp, sp, pc} @ Load all regs saved previously 718 ldmia r4, {r4 - sl, fp, sp, pc} @ Load all regs saved previously
719ENDPROC(__switch_to)
705 720
706 __INIT 721 __INIT
707 722
@@ -1029,6 +1044,7 @@ vector_\name:
1029 mov r0, sp 1044 mov r0, sp
1030 ldr lr, [pc, lr, lsl #2] 1045 ldr lr, [pc, lr, lsl #2]
1031 movs pc, lr @ branch to handler in SVC mode 1046 movs pc, lr @ branch to handler in SVC mode
1047ENDPROC(vector_\name)
1032 .endm 1048 .endm
1033 1049
1034 .globl __stubs_start 1050 .globl __stubs_start
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 060d7e2e9f64..3aa14dcc5bab 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -77,6 +77,7 @@ no_work_pending:
77 mov r0, r0 77 mov r0, r0
78 add sp, sp, #S_FRAME_SIZE - S_PC 78 add sp, sp, #S_FRAME_SIZE - S_PC
79 movs pc, lr @ return & move spsr_svc into cpsr 79 movs pc, lr @ return & move spsr_svc into cpsr
80ENDPROC(ret_to_user)
80 81
81/* 82/*
82 * This is how we return from a fork. 83 * This is how we return from a fork.
@@ -92,7 +93,7 @@ ENTRY(ret_from_fork)
92 mov r0, #1 @ trace exit [IP = 1] 93 mov r0, #1 @ trace exit [IP = 1]
93 bl syscall_trace 94 bl syscall_trace
94 b ret_slow_syscall 95 b ret_slow_syscall
95 96ENDPROC(ret_from_fork)
96 97
97 .equ NR_syscalls,0 98 .equ NR_syscalls,0
98#define CALL(x) .equ NR_syscalls,NR_syscalls+1 99#define CALL(x) .equ NR_syscalls,NR_syscalls+1
@@ -269,6 +270,7 @@ ENTRY(vector_swi)
269 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back 270 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
270 bcs arm_syscall 271 bcs arm_syscall
271 b sys_ni_syscall @ not private func 272 b sys_ni_syscall @ not private func
273ENDPROC(vector_swi)
272 274
273 /* 275 /*
274 * This is the really slow path. We're going to be doing 276 * This is the really slow path. We're going to be doing
@@ -326,7 +328,6 @@ ENTRY(sys_call_table)
326 */ 328 */
327@ r0 = syscall number 329@ r0 = syscall number
328@ r8 = syscall table 330@ r8 = syscall table
329 .type sys_syscall, #function
330sys_syscall: 331sys_syscall:
331 bic scno, r0, #__NR_OABI_SYSCALL_BASE 332 bic scno, r0, #__NR_OABI_SYSCALL_BASE
332 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE 333 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
@@ -338,53 +339,65 @@ sys_syscall:
338 movlo r3, r4 339 movlo r3, r4
339 ldrlo pc, [tbl, scno, lsl #2] 340 ldrlo pc, [tbl, scno, lsl #2]
340 b sys_ni_syscall 341 b sys_ni_syscall
342ENDPROC(sys_syscall)
341 343
342sys_fork_wrapper: 344sys_fork_wrapper:
343 add r0, sp, #S_OFF 345 add r0, sp, #S_OFF
344 b sys_fork 346 b sys_fork
347ENDPROC(sys_fork_wrapper)
345 348
346sys_vfork_wrapper: 349sys_vfork_wrapper:
347 add r0, sp, #S_OFF 350 add r0, sp, #S_OFF
348 b sys_vfork 351 b sys_vfork
352ENDPROC(sys_vfork_wrapper)
349 353
350sys_execve_wrapper: 354sys_execve_wrapper:
351 add r3, sp, #S_OFF 355 add r3, sp, #S_OFF
352 b sys_execve 356 b sys_execve
357ENDPROC(sys_execve_wrapper)
353 358
354sys_clone_wrapper: 359sys_clone_wrapper:
355 add ip, sp, #S_OFF 360 add ip, sp, #S_OFF
356 str ip, [sp, #4] 361 str ip, [sp, #4]
357 b sys_clone 362 b sys_clone
363ENDPROC(sys_clone_wrapper)
358 364
359sys_sigsuspend_wrapper: 365sys_sigsuspend_wrapper:
360 add r3, sp, #S_OFF 366 add r3, sp, #S_OFF
361 b sys_sigsuspend 367 b sys_sigsuspend
368ENDPROC(sys_sigsuspend_wrapper)
362 369
363sys_rt_sigsuspend_wrapper: 370sys_rt_sigsuspend_wrapper:
364 add r2, sp, #S_OFF 371 add r2, sp, #S_OFF
365 b sys_rt_sigsuspend 372 b sys_rt_sigsuspend
373ENDPROC(sys_rt_sigsuspend_wrapper)
366 374
367sys_sigreturn_wrapper: 375sys_sigreturn_wrapper:
368 add r0, sp, #S_OFF 376 add r0, sp, #S_OFF
369 b sys_sigreturn 377 b sys_sigreturn
378ENDPROC(sys_sigreturn_wrapper)
370 379
371sys_rt_sigreturn_wrapper: 380sys_rt_sigreturn_wrapper:
372 add r0, sp, #S_OFF 381 add r0, sp, #S_OFF
373 b sys_rt_sigreturn 382 b sys_rt_sigreturn
383ENDPROC(sys_rt_sigreturn_wrapper)
374 384
375sys_sigaltstack_wrapper: 385sys_sigaltstack_wrapper:
376 ldr r2, [sp, #S_OFF + S_SP] 386 ldr r2, [sp, #S_OFF + S_SP]
377 b do_sigaltstack 387 b do_sigaltstack
388ENDPROC(sys_sigaltstack_wrapper)
378 389
379sys_statfs64_wrapper: 390sys_statfs64_wrapper:
380 teq r1, #88 391 teq r1, #88
381 moveq r1, #84 392 moveq r1, #84
382 b sys_statfs64 393 b sys_statfs64
394ENDPROC(sys_statfs64_wrapper)
383 395
384sys_fstatfs64_wrapper: 396sys_fstatfs64_wrapper:
385 teq r1, #88 397 teq r1, #88
386 moveq r1, #84 398 moveq r1, #84
387 b sys_fstatfs64 399 b sys_fstatfs64
400ENDPROC(sys_fstatfs64_wrapper)
388 401
389/* 402/*
390 * Note: off_4k (r5) is always units of 4K. If we can't do the requested 403 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
@@ -402,11 +415,14 @@ sys_mmap2:
402 str r5, [sp, #4] 415 str r5, [sp, #4]
403 b do_mmap2 416 b do_mmap2
404#endif 417#endif
418ENDPROC(sys_mmap2)
405 419
406ENTRY(pabort_ifar) 420ENTRY(pabort_ifar)
407 mrc p15, 0, r0, cr6, cr0, 2 421 mrc p15, 0, r0, cr6, cr0, 2
408ENTRY(pabort_noifar) 422ENTRY(pabort_noifar)
409 mov pc, lr 423 mov pc, lr
424ENDPROC(pabort_ifar)
425ENDPROC(pabort_noifar)
410 426
411#ifdef CONFIG_OABI_COMPAT 427#ifdef CONFIG_OABI_COMPAT
412 428
@@ -417,26 +433,31 @@ ENTRY(pabort_noifar)
417sys_oabi_pread64: 433sys_oabi_pread64:
418 stmia sp, {r3, r4} 434 stmia sp, {r3, r4}
419 b sys_pread64 435 b sys_pread64
436ENDPROC(sys_oabi_pread64)
420 437
421sys_oabi_pwrite64: 438sys_oabi_pwrite64:
422 stmia sp, {r3, r4} 439 stmia sp, {r3, r4}
423 b sys_pwrite64 440 b sys_pwrite64
441ENDPROC(sys_oabi_pwrite64)
424 442
425sys_oabi_truncate64: 443sys_oabi_truncate64:
426 mov r3, r2 444 mov r3, r2
427 mov r2, r1 445 mov r2, r1
428 b sys_truncate64 446 b sys_truncate64
447ENDPROC(sys_oabi_truncate64)
429 448
430sys_oabi_ftruncate64: 449sys_oabi_ftruncate64:
431 mov r3, r2 450 mov r3, r2
432 mov r2, r1 451 mov r2, r1
433 b sys_ftruncate64 452 b sys_ftruncate64
453ENDPROC(sys_oabi_ftruncate64)
434 454
435sys_oabi_readahead: 455sys_oabi_readahead:
436 str r3, [sp] 456 str r3, [sp]
437 mov r3, r2 457 mov r3, r2
438 mov r2, r1 458 mov r2, r1
439 b sys_readahead 459 b sys_readahead
460ENDPROC(sys_oabi_readahead)
440 461
441/* 462/*
442 * Let's declare a second syscall table for old ABI binaries 463 * Let's declare a second syscall table for old ABI binaries
diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
index e8e90346f11c..36f81d967979 100644
--- a/arch/arm/kernel/fiq.c
+++ b/arch/arm/kernel/fiq.c
@@ -45,7 +45,6 @@
45#include <asm/fiq.h> 45#include <asm/fiq.h>
46#include <asm/irq.h> 46#include <asm/irq.h>
47#include <asm/system.h> 47#include <asm/system.h>
48#include <asm/uaccess.h>
49 48
50static unsigned long no_fiq_insn; 49static unsigned long no_fiq_insn;
51 50
diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S
index 1c3c6ea5f9e7..bde52df1c668 100644
--- a/arch/arm/kernel/head-common.S
+++ b/arch/arm/kernel/head-common.S
@@ -36,7 +36,6 @@ __switch_data:
36 * r2 = atags pointer 36 * r2 = atags pointer
37 * r9 = processor ID 37 * r9 = processor ID
38 */ 38 */
39 .type __mmap_switched, %function
40__mmap_switched: 39__mmap_switched:
41 adr r3, __switch_data + 4 40 adr r3, __switch_data + 4
42 41
@@ -59,6 +58,7 @@ __mmap_switched:
59 bic r4, r0, #CR_A @ Clear 'A' bit 58 bic r4, r0, #CR_A @ Clear 'A' bit
60 stmia r7, {r0, r4} @ Save control register values 59 stmia r7, {r0, r4} @ Save control register values
61 b start_kernel 60 b start_kernel
61ENDPROC(__mmap_switched)
62 62
63/* 63/*
64 * Exception handling. Something went wrong and we can't proceed. We 64 * Exception handling. Something went wrong and we can't proceed. We
@@ -69,8 +69,6 @@ __mmap_switched:
69 * and hope for the best (useful if bootloader fails to pass a proper 69 * and hope for the best (useful if bootloader fails to pass a proper
70 * machine ID for example). 70 * machine ID for example).
71 */ 71 */
72
73 .type __error_p, %function
74__error_p: 72__error_p:
75#ifdef CONFIG_DEBUG_LL 73#ifdef CONFIG_DEBUG_LL
76 adr r0, str_p1 74 adr r0, str_p1
@@ -84,8 +82,8 @@ str_p1: .asciz "\nError: unrecognized/unsupported processor variant (0x"
84str_p2: .asciz ").\n" 82str_p2: .asciz ").\n"
85 .align 83 .align
86#endif 84#endif
85ENDPROC(__error_p)
87 86
88 .type __error_a, %function
89__error_a: 87__error_a:
90#ifdef CONFIG_DEBUG_LL 88#ifdef CONFIG_DEBUG_LL
91 mov r4, r1 @ preserve machine ID 89 mov r4, r1 @ preserve machine ID
@@ -115,13 +113,14 @@ __error_a:
115 adr r0, str_a3 113 adr r0, str_a3
116 bl printascii 114 bl printascii
117 b __error 115 b __error
116ENDPROC(__error_a)
117
118str_a1: .asciz "\nError: unrecognized/unsupported machine ID (r1 = 0x" 118str_a1: .asciz "\nError: unrecognized/unsupported machine ID (r1 = 0x"
119str_a2: .asciz ").\n\nAvailable machine support:\n\nID (hex)\tNAME\n" 119str_a2: .asciz ").\n\nAvailable machine support:\n\nID (hex)\tNAME\n"
120str_a3: .asciz "\nPlease check your kernel config and/or bootloader.\n" 120str_a3: .asciz "\nPlease check your kernel config and/or bootloader.\n"
121 .align 121 .align
122#endif 122#endif
123 123
124 .type __error, %function
125__error: 124__error:
126#ifdef CONFIG_ARCH_RPC 125#ifdef CONFIG_ARCH_RPC
127/* 126/*
@@ -138,6 +137,7 @@ __error:
138#endif 137#endif
1391: mov r0, r0 1381: mov r0, r0
140 b 1b 139 b 1b
140ENDPROC(__error)
141 141
142 142
143/* 143/*
@@ -153,7 +153,6 @@ __error:
153 * r5 = proc_info pointer in physical address space 153 * r5 = proc_info pointer in physical address space
154 * r9 = cpuid (preserved) 154 * r9 = cpuid (preserved)
155 */ 155 */
156 .type __lookup_processor_type, %function
157__lookup_processor_type: 156__lookup_processor_type:
158 adr r3, 3f 157 adr r3, 3f
159 ldmda r3, {r5 - r7} 158 ldmda r3, {r5 - r7}
@@ -169,6 +168,7 @@ __lookup_processor_type:
169 blo 1b 168 blo 1b
170 mov r5, #0 @ unknown processor 169 mov r5, #0 @ unknown processor
1712: mov pc, lr 1702: mov pc, lr
171ENDPROC(__lookup_processor_type)
172 172
173/* 173/*
174 * This provides a C-API version of the above function. 174 * This provides a C-API version of the above function.
@@ -179,6 +179,7 @@ ENTRY(lookup_processor_type)
179 bl __lookup_processor_type 179 bl __lookup_processor_type
180 mov r0, r5 180 mov r0, r5
181 ldmfd sp!, {r4 - r7, r9, pc} 181 ldmfd sp!, {r4 - r7, r9, pc}
182ENDPROC(lookup_processor_type)
182 183
183/* 184/*
184 * Look in <asm/procinfo.h> and arch/arm/kernel/arch.[ch] for 185 * Look in <asm/procinfo.h> and arch/arm/kernel/arch.[ch] for
@@ -201,7 +202,6 @@ ENTRY(lookup_processor_type)
201 * r3, r4, r6 corrupted 202 * r3, r4, r6 corrupted
202 * r5 = mach_info pointer in physical address space 203 * r5 = mach_info pointer in physical address space
203 */ 204 */
204 .type __lookup_machine_type, %function
205__lookup_machine_type: 205__lookup_machine_type:
206 adr r3, 3b 206 adr r3, 3b
207 ldmia r3, {r4, r5, r6} 207 ldmia r3, {r4, r5, r6}
@@ -216,6 +216,7 @@ __lookup_machine_type:
216 blo 1b 216 blo 1b
217 mov r5, #0 @ unknown machine 217 mov r5, #0 @ unknown machine
2182: mov pc, lr 2182: mov pc, lr
219ENDPROC(__lookup_machine_type)
219 220
220/* 221/*
221 * This provides a C-API version of the above function. 222 * This provides a C-API version of the above function.
@@ -226,6 +227,7 @@ ENTRY(lookup_machine_type)
226 bl __lookup_machine_type 227 bl __lookup_machine_type
227 mov r0, r5 228 mov r0, r5
228 ldmfd sp!, {r4 - r6, pc} 229 ldmfd sp!, {r4 - r6, pc}
230ENDPROC(lookup_machine_type)
229 231
230/* Determine validity of the r2 atags pointer. The heuristic requires 232/* Determine validity of the r2 atags pointer. The heuristic requires
231 * that the pointer be aligned, in the first 16k of physical RAM and 233 * that the pointer be aligned, in the first 16k of physical RAM and
@@ -239,8 +241,6 @@ ENTRY(lookup_machine_type)
239 * r2 either valid atags pointer, or zero 241 * r2 either valid atags pointer, or zero
240 * r5, r6 corrupted 242 * r5, r6 corrupted
241 */ 243 */
242
243 .type __vet_atags, %function
244__vet_atags: 244__vet_atags:
245 tst r2, #0x3 @ aligned? 245 tst r2, #0x3 @ aligned?
246 bne 1f 246 bne 1f
@@ -257,3 +257,4 @@ __vet_atags:
257 257
2581: mov r2, #0 2581: mov r2, #0
259 mov pc, lr 259 mov pc, lr
260ENDPROC(__vet_atags)
diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
index 27329bd32037..cc87e1765ed2 100644
--- a/arch/arm/kernel/head-nommu.S
+++ b/arch/arm/kernel/head-nommu.S
@@ -33,7 +33,6 @@
33 * 33 *
34 */ 34 */
35 .section ".text.head", "ax" 35 .section ".text.head", "ax"
36 .type stext, %function
37ENTRY(stext) 36ENTRY(stext)
38 msr cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode 37 msr cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode
39 @ and irqs disabled 38 @ and irqs disabled
@@ -53,11 +52,11 @@ ENTRY(stext)
53 @ the initialization is done 52 @ the initialization is done
54 adr lr, __after_proc_init @ return (PIC) address 53 adr lr, __after_proc_init @ return (PIC) address
55 add pc, r10, #PROCINFO_INITFUNC 54 add pc, r10, #PROCINFO_INITFUNC
55ENDPROC(stext)
56 56
57/* 57/*
58 * Set the Control Register and Read the process ID. 58 * Set the Control Register and Read the process ID.
59 */ 59 */
60 .type __after_proc_init, %function
61__after_proc_init: 60__after_proc_init:
62#ifdef CONFIG_CPU_CP15 61#ifdef CONFIG_CPU_CP15
63 mrc p15, 0, r0, c1, c0, 0 @ read control reg 62 mrc p15, 0, r0, c1, c0, 0 @ read control reg
@@ -85,6 +84,7 @@ __after_proc_init:
85 84
86 mov pc, r13 @ clear the BSS and jump 85 mov pc, r13 @ clear the BSS and jump
87 @ to start_kernel 86 @ to start_kernel
87ENDPROC(__after_proc_init)
88 .ltorg 88 .ltorg
89 89
90#include "head-common.S" 90#include "head-common.S"
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index bff4c6e90dd5..21e17dc94cb5 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -75,7 +75,6 @@
75 * circumstances, zImage) is for. 75 * circumstances, zImage) is for.
76 */ 76 */
77 .section ".text.head", "ax" 77 .section ".text.head", "ax"
78 .type stext, %function
79ENTRY(stext) 78ENTRY(stext)
80 msr cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode 79 msr cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode
81 @ and irqs disabled 80 @ and irqs disabled
@@ -100,9 +99,9 @@ ENTRY(stext)
100 @ mmu has been enabled 99 @ mmu has been enabled
101 adr lr, __enable_mmu @ return (PIC) address 100 adr lr, __enable_mmu @ return (PIC) address
102 add pc, r10, #PROCINFO_INITFUNC 101 add pc, r10, #PROCINFO_INITFUNC
102ENDPROC(stext)
103 103
104#if defined(CONFIG_SMP) 104#if defined(CONFIG_SMP)
105 .type secondary_startup, #function
106ENTRY(secondary_startup) 105ENTRY(secondary_startup)
107 /* 106 /*
108 * Common entry point for secondary CPUs. 107 * Common entry point for secondary CPUs.
@@ -128,6 +127,7 @@ ENTRY(secondary_startup)
128 adr lr, __enable_mmu @ return address 127 adr lr, __enable_mmu @ return address
129 add pc, r10, #PROCINFO_INITFUNC @ initialise processor 128 add pc, r10, #PROCINFO_INITFUNC @ initialise processor
130 @ (return control reg) 129 @ (return control reg)
130ENDPROC(secondary_startup)
131 131
132 /* 132 /*
133 * r6 = &secondary_data 133 * r6 = &secondary_data
@@ -136,6 +136,7 @@ ENTRY(__secondary_switched)
136 ldr sp, [r7, #4] @ get secondary_data.stack 136 ldr sp, [r7, #4] @ get secondary_data.stack
137 mov fp, #0 137 mov fp, #0
138 b secondary_start_kernel 138 b secondary_start_kernel
139ENDPROC(__secondary_switched)
139 140
140 .type __secondary_data, %object 141 .type __secondary_data, %object
141__secondary_data: 142__secondary_data:
@@ -151,7 +152,6 @@ __secondary_data:
151 * this is just loading the page table pointer and domain access 152 * this is just loading the page table pointer and domain access
152 * registers. 153 * registers.
153 */ 154 */
154 .type __enable_mmu, %function
155__enable_mmu: 155__enable_mmu:
156#ifdef CONFIG_ALIGNMENT_TRAP 156#ifdef CONFIG_ALIGNMENT_TRAP
157 orr r0, r0, #CR_A 157 orr r0, r0, #CR_A
@@ -174,6 +174,7 @@ __enable_mmu:
174 mcr p15, 0, r5, c3, c0, 0 @ load domain access register 174 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
175 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer 175 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
176 b __turn_mmu_on 176 b __turn_mmu_on
177ENDPROC(__enable_mmu)
177 178
178/* 179/*
179 * Enable the MMU. This completely changes the structure of the visible 180 * Enable the MMU. This completely changes the structure of the visible
@@ -187,7 +188,6 @@ __enable_mmu:
187 * other registers depend on the function called upon completion 188 * other registers depend on the function called upon completion
188 */ 189 */
189 .align 5 190 .align 5
190 .type __turn_mmu_on, %function
191__turn_mmu_on: 191__turn_mmu_on:
192 mov r0, r0 192 mov r0, r0
193 mcr p15, 0, r0, c1, c0, 0 @ write control reg 193 mcr p15, 0, r0, c1, c0, 0 @ write control reg
@@ -195,7 +195,7 @@ __turn_mmu_on:
195 mov r3, r3 195 mov r3, r3
196 mov r3, r3 196 mov r3, r3
197 mov pc, r13 197 mov pc, r13
198 198ENDPROC(__turn_mmu_on)
199 199
200 200
201/* 201/*
@@ -211,7 +211,6 @@ __turn_mmu_on:
211 * r0, r3, r6, r7 corrupted 211 * r0, r3, r6, r7 corrupted
212 * r4 = physical page table address 212 * r4 = physical page table address
213 */ 213 */
214 .type __create_page_tables, %function
215__create_page_tables: 214__create_page_tables:
216 pgtbl r4 @ page table address 215 pgtbl r4 @ page table address
217 216
@@ -325,6 +324,7 @@ __create_page_tables:
325#endif 324#endif
326#endif 325#endif
327 mov pc, lr 326 mov pc, lr
327ENDPROC(__create_page_tables)
328 .ltorg 328 .ltorg
329 329
330#include "head-common.S" 330#include "head-common.S"
diff --git a/arch/arm/kernel/init_task.c b/arch/arm/kernel/init_task.c
index 8b8c9d38a761..0bbf80625395 100644
--- a/arch/arm/kernel/init_task.c
+++ b/arch/arm/kernel/init_task.c
@@ -8,8 +8,8 @@
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/init_task.h> 9#include <linux/init_task.h>
10#include <linux/mqueue.h> 10#include <linux/mqueue.h>
11#include <linux/uaccess.h>
11 12
12#include <asm/uaccess.h>
13#include <asm/pgtable.h> 13#include <asm/pgtable.h>
14 14
15static struct fs_struct init_fs = INIT_FS; 15static struct fs_struct init_fs = INIT_FS;
diff --git a/arch/arm/kernel/io.c b/arch/arm/kernel/io.c
index 1f6822dfae74..f4470307edb8 100644
--- a/arch/arm/kernel/io.c
+++ b/arch/arm/kernel/io.c
@@ -1,7 +1,6 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <linux/types.h> 2#include <linux/types.h>
3 3#include <linux/io.h>
4#include <asm/io.h>
5 4
6/* 5/*
7 * Copy data from IO memory space to "real" memory space. 6 * Copy data from IO memory space to "real" memory space.
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index f88efb135b70..2f3eb795fa6e 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -112,18 +112,17 @@ static struct irq_desc bad_irq_desc = {
112asmlinkage void __exception asm_do_IRQ(unsigned int irq, struct pt_regs *regs) 112asmlinkage void __exception asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
113{ 113{
114 struct pt_regs *old_regs = set_irq_regs(regs); 114 struct pt_regs *old_regs = set_irq_regs(regs);
115 struct irq_desc *desc = irq_desc + irq; 115
116 irq_enter();
116 117
117 /* 118 /*
118 * Some hardware gives randomly wrong interrupts. Rather 119 * Some hardware gives randomly wrong interrupts. Rather
119 * than crashing, do something sensible. 120 * than crashing, do something sensible.
120 */ 121 */
121 if (irq >= NR_IRQS) 122 if (irq >= NR_IRQS)
122 desc = &bad_irq_desc; 123 handle_bad_irq(irq, &bad_irq_desc);
123 124 else
124 irq_enter(); 125 generic_handle_irq(irq);
125
126 desc_handle_irq(irq, desc);
127 126
128 /* AT91 specific workaround */ 127 /* AT91 specific workaround */
129 irq_finish(irq); 128 irq_finish(irq);
diff --git a/arch/arm/kernel/kprobes-decode.c b/arch/arm/kernel/kprobes-decode.c
index b4565bb133c1..da1f94906a4e 100644
--- a/arch/arm/kernel/kprobes-decode.c
+++ b/arch/arm/kernel/kprobes-decode.c
@@ -488,7 +488,7 @@ static void __kprobes simulate_ldm1stm1(struct kprobe *p, struct pt_regs *regs)
488 488
489 if (!ubit) 489 if (!ubit)
490 addr -= reg_count; 490 addr -= reg_count;
491 addr += (!pbit ^ !ubit); 491 addr += (!pbit == !ubit);
492 492
493 reg_bit_vector = insn & 0xffff; 493 reg_bit_vector = insn & 0xffff;
494 while (reg_bit_vector) { 494 while (reg_bit_vector) {
@@ -503,7 +503,7 @@ static void __kprobes simulate_ldm1stm1(struct kprobe *p, struct pt_regs *regs)
503 if (wbit) { 503 if (wbit) {
504 if (!ubit) 504 if (!ubit)
505 addr -= reg_count; 505 addr -= reg_count;
506 addr -= (!pbit ^ !ubit); 506 addr -= (!pbit == !ubit);
507 regs->uregs[rn] = (long)addr; 507 regs->uregs[rn] = (long)addr;
508 } 508 }
509} 509}
diff --git a/arch/arm/kernel/kprobes.c b/arch/arm/kernel/kprobes.c
index d28513f14d05..3f9abe0e9aff 100644
--- a/arch/arm/kernel/kprobes.c
+++ b/arch/arm/kernel/kprobes.c
@@ -200,9 +200,12 @@ void __kprobes kprobe_handler(struct pt_regs *regs)
200 } 200 }
201} 201}
202 202
203int kprobe_trap_handler(struct pt_regs *regs, unsigned int instr) 203static int __kprobes kprobe_trap_handler(struct pt_regs *regs, unsigned int instr)
204{ 204{
205 unsigned long flags;
206 local_irq_save(flags);
205 kprobe_handler(regs); 207 kprobe_handler(regs);
208 local_irq_restore(flags);
206 return 0; 209 return 0;
207} 210}
208 211
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index fae5beb3c3d6..440dc62cdc3a 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -6,10 +6,10 @@
6#include <linux/kexec.h> 6#include <linux/kexec.h>
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/reboot.h> 8#include <linux/reboot.h>
9#include <linux/io.h>
9#include <asm/pgtable.h> 10#include <asm/pgtable.h>
10#include <asm/pgalloc.h> 11#include <asm/pgalloc.h>
11#include <asm/mmu_context.h> 12#include <asm/mmu_context.h>
12#include <asm/io.h>
13#include <asm/cacheflush.h> 13#include <asm/cacheflush.h>
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
15 15
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index a68259a0cccd..9203ba7d58ee 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -47,7 +47,7 @@ void *module_alloc(unsigned long size)
47 if (!area) 47 if (!area)
48 return NULL; 48 return NULL;
49 49
50 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL); 50 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC);
51} 51}
52#else /* CONFIG_MMU */ 52#else /* CONFIG_MMU */
53void *module_alloc(unsigned long size) 53void *module_alloc(unsigned long size)
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 3fd882337064..d3ea6fa89521 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -28,12 +28,12 @@
28#include <linux/pm.h> 28#include <linux/pm.h>
29#include <linux/tick.h> 29#include <linux/tick.h>
30#include <linux/utsname.h> 30#include <linux/utsname.h>
31#include <linux/uaccess.h>
31 32
32#include <asm/leds.h> 33#include <asm/leds.h>
33#include <asm/processor.h> 34#include <asm/processor.h>
34#include <asm/system.h> 35#include <asm/system.h>
35#include <asm/thread_notify.h> 36#include <asm/thread_notify.h>
36#include <asm/uaccess.h>
37#include <asm/mach/time.h> 37#include <asm/mach/time.h>
38 38
39static const char *processor_modes[] = { 39static const char *processor_modes[] = {
@@ -267,35 +267,6 @@ void show_regs(struct pt_regs * regs)
267 __backtrace(); 267 __backtrace();
268} 268}
269 269
270void show_fpregs(struct user_fp *regs)
271{
272 int i;
273
274 for (i = 0; i < 8; i++) {
275 unsigned long *p;
276 char type;
277
278 p = (unsigned long *)(regs->fpregs + i);
279
280 switch (regs->ftype[i]) {
281 case 1: type = 'f'; break;
282 case 2: type = 'd'; break;
283 case 3: type = 'e'; break;
284 default: type = '?'; break;
285 }
286 if (regs->init_flag)
287 type = '?';
288
289 printk(" f%d(%c): %08lx %08lx %08lx%c",
290 i, type, p[0], p[1], p[2], i & 1 ? '\n' : ' ');
291 }
292
293
294 printk("FPSR: %08lx FPCR: %08lx\n",
295 (unsigned long)regs->fpsr,
296 (unsigned long)regs->fpcr);
297}
298
299/* 270/*
300 * Free current thread data structures etc.. 271 * Free current thread data structures etc..
301 */ 272 */
@@ -414,7 +385,7 @@ unsigned long get_wchan(struct task_struct *p)
414 do { 385 do {
415 if (fp < stack_start || fp > stack_end) 386 if (fp < stack_start || fp > stack_end)
416 return 0; 387 return 0;
417 lr = pc_pointer (((unsigned long *)fp)[-1]); 388 lr = ((unsigned long *)fp)[-1];
418 if (!in_sched_functions(lr)) 389 if (!in_sched_functions(lr))
419 return lr; 390 return lr;
420 fp = *(unsigned long *) (fp - 12); 391 fp = *(unsigned long *) (fp - 12);
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 4b05dc5c1023..df653ea59250 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -18,8 +18,8 @@
18#include <linux/security.h> 18#include <linux/security.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/signal.h> 20#include <linux/signal.h>
21#include <linux/uaccess.h>
21 22
22#include <asm/uaccess.h>
23#include <asm/pgtable.h> 23#include <asm/pgtable.h>
24#include <asm/system.h> 24#include <asm/system.h>
25#include <asm/traps.h> 25#include <asm/traps.h>
@@ -126,7 +126,7 @@ ptrace_getrn(struct task_struct *child, unsigned long insn)
126 126
127 val = get_user_reg(child, reg); 127 val = get_user_reg(child, reg);
128 if (reg == 15) 128 if (reg == 15)
129 val = pc_pointer(val + 8); 129 val += 8;
130 130
131 return val; 131 return val;
132} 132}
@@ -278,8 +278,7 @@ get_branch_address(struct task_struct *child, unsigned long pc, unsigned long in
278 else 278 else
279 base -= aluop2; 279 base -= aluop2;
280 } 280 }
281 if (read_u32(child, base, &alt) == 0) 281 read_u32(child, base, &alt);
282 alt = pc_pointer(alt);
283 } 282 }
284 break; 283 break;
285 284
@@ -305,8 +304,7 @@ get_branch_address(struct task_struct *child, unsigned long pc, unsigned long in
305 304
306 base = ptrace_getrn(child, insn); 305 base = ptrace_getrn(child, insn);
307 306
308 if (read_u32(child, base + nr_regs, &alt) == 0) 307 read_u32(child, base + nr_regs, &alt);
309 alt = pc_pointer(alt);
310 break; 308 break;
311 } 309 }
312 break; 310 break;
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 2ca7038b67a7..1f1eecca7f55 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -26,11 +26,13 @@
26#include <linux/fs.h> 26#include <linux/fs.h>
27 27
28#include <asm/cpu.h> 28#include <asm/cpu.h>
29#include <asm/cputype.h>
29#include <asm/elf.h> 30#include <asm/elf.h>
30#include <asm/procinfo.h> 31#include <asm/procinfo.h>
31#include <asm/setup.h> 32#include <asm/setup.h>
32#include <asm/mach-types.h> 33#include <asm/mach-types.h>
33#include <asm/cacheflush.h> 34#include <asm/cacheflush.h>
35#include <asm/cachetype.h>
34#include <asm/tlbflush.h> 36#include <asm/tlbflush.h>
35 37
36#include <asm/mach/arch.h> 38#include <asm/mach/arch.h>
@@ -59,13 +61,14 @@ __setup("fpe=", fpe_setup);
59 61
60extern void paging_init(struct meminfo *, struct machine_desc *desc); 62extern void paging_init(struct meminfo *, struct machine_desc *desc);
61extern void reboot_setup(char *str); 63extern void reboot_setup(char *str);
62extern int root_mountflags; 64extern void _text, _etext, __data_start, _edata, _end;
63extern void _stext, _text, _etext, __data_start, _edata, _end;
64 65
65unsigned int processor_id; 66unsigned int processor_id;
66EXPORT_SYMBOL(processor_id); 67EXPORT_SYMBOL(processor_id);
67unsigned int __machine_arch_type; 68unsigned int __machine_arch_type;
68EXPORT_SYMBOL(__machine_arch_type); 69EXPORT_SYMBOL(__machine_arch_type);
70unsigned int cacheid;
71EXPORT_SYMBOL(cacheid);
69 72
70unsigned int __atags_pointer __initdata; 73unsigned int __atags_pointer __initdata;
71 74
@@ -81,8 +84,6 @@ EXPORT_SYMBOL(system_serial_high);
81unsigned int elf_hwcap; 84unsigned int elf_hwcap;
82EXPORT_SYMBOL(elf_hwcap); 85EXPORT_SYMBOL(elf_hwcap);
83 86
84unsigned long __initdata vmalloc_reserve = 128 << 20;
85
86 87
87#ifdef MULTI_CPU 88#ifdef MULTI_CPU
88struct processor processor; 89struct processor processor;
@@ -111,9 +112,6 @@ static struct stack stacks[NR_CPUS];
111char elf_platform[ELF_PLATFORM_SIZE]; 112char elf_platform[ELF_PLATFORM_SIZE];
112EXPORT_SYMBOL(elf_platform); 113EXPORT_SYMBOL(elf_platform);
113 114
114unsigned long phys_initrd_start __initdata = 0;
115unsigned long phys_initrd_size __initdata = 0;
116
117static struct meminfo meminfo __initdata = { 0, }; 115static struct meminfo meminfo __initdata = { 0, };
118static const char *cpu_name; 116static const char *cpu_name;
119static const char *machine_name; 117static const char *machine_name;
@@ -178,63 +176,6 @@ static struct resource io_res[] = {
178#define lp1 io_res[1] 176#define lp1 io_res[1]
179#define lp2 io_res[2] 177#define lp2 io_res[2]
180 178
181static const char *cache_types[16] = {
182 "write-through",
183 "write-back",
184 "write-back",
185 "undefined 3",
186 "undefined 4",
187 "undefined 5",
188 "write-back",
189 "write-back",
190 "undefined 8",
191 "undefined 9",
192 "undefined 10",
193 "undefined 11",
194 "undefined 12",
195 "undefined 13",
196 "write-back",
197 "undefined 15",
198};
199
200static const char *cache_clean[16] = {
201 "not required",
202 "read-block",
203 "cp15 c7 ops",
204 "undefined 3",
205 "undefined 4",
206 "undefined 5",
207 "cp15 c7 ops",
208 "cp15 c7 ops",
209 "undefined 8",
210 "undefined 9",
211 "undefined 10",
212 "undefined 11",
213 "undefined 12",
214 "undefined 13",
215 "cp15 c7 ops",
216 "undefined 15",
217};
218
219static const char *cache_lockdown[16] = {
220 "not supported",
221 "not supported",
222 "not supported",
223 "undefined 3",
224 "undefined 4",
225 "undefined 5",
226 "format A",
227 "format B",
228 "undefined 8",
229 "undefined 9",
230 "undefined 10",
231 "undefined 11",
232 "undefined 12",
233 "undefined 13",
234 "format C",
235 "undefined 15",
236};
237
238static const char *proc_arch[] = { 179static const char *proc_arch[] = {
239 "undefined/unknown", 180 "undefined/unknown",
240 "3", 181 "3",
@@ -255,61 +196,19 @@ static const char *proc_arch[] = {
255 "?(17)", 196 "?(17)",
256}; 197};
257 198
258#define CACHE_TYPE(x) (((x) >> 25) & 15)
259#define CACHE_S(x) ((x) & (1 << 24))
260#define CACHE_DSIZE(x) (((x) >> 12) & 4095) /* only if S=1 */
261#define CACHE_ISIZE(x) ((x) & 4095)
262
263#define CACHE_SIZE(y) (((y) >> 6) & 7)
264#define CACHE_ASSOC(y) (((y) >> 3) & 7)
265#define CACHE_M(y) ((y) & (1 << 2))
266#define CACHE_LINE(y) ((y) & 3)
267
268static inline void dump_cache(const char *prefix, int cpu, unsigned int cache)
269{
270 unsigned int mult = 2 + (CACHE_M(cache) ? 1 : 0);
271
272 printk("CPU%u: %s: %d bytes, associativity %d, %d byte lines, %d sets\n",
273 cpu, prefix,
274 mult << (8 + CACHE_SIZE(cache)),
275 (mult << CACHE_ASSOC(cache)) >> 1,
276 8 << CACHE_LINE(cache),
277 1 << (6 + CACHE_SIZE(cache) - CACHE_ASSOC(cache) -
278 CACHE_LINE(cache)));
279}
280
281static void __init dump_cpu_info(int cpu)
282{
283 unsigned int info = read_cpuid(CPUID_CACHETYPE);
284
285 if (info != processor_id) {
286 printk("CPU%u: D %s %s cache\n", cpu, cache_is_vivt() ? "VIVT" : "VIPT",
287 cache_types[CACHE_TYPE(info)]);
288 if (CACHE_S(info)) {
289 dump_cache("I cache", cpu, CACHE_ISIZE(info));
290 dump_cache("D cache", cpu, CACHE_DSIZE(info));
291 } else {
292 dump_cache("cache", cpu, CACHE_ISIZE(info));
293 }
294 }
295
296 if (arch_is_coherent())
297 printk("Cache coherency enabled\n");
298}
299
300int cpu_architecture(void) 199int cpu_architecture(void)
301{ 200{
302 int cpu_arch; 201 int cpu_arch;
303 202
304 if ((processor_id & 0x0008f000) == 0) { 203 if ((read_cpuid_id() & 0x0008f000) == 0) {
305 cpu_arch = CPU_ARCH_UNKNOWN; 204 cpu_arch = CPU_ARCH_UNKNOWN;
306 } else if ((processor_id & 0x0008f000) == 0x00007000) { 205 } else if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
307 cpu_arch = (processor_id & (1 << 23)) ? CPU_ARCH_ARMv4T : CPU_ARCH_ARMv3; 206 cpu_arch = (read_cpuid_id() & (1 << 23)) ? CPU_ARCH_ARMv4T : CPU_ARCH_ARMv3;
308 } else if ((processor_id & 0x00080000) == 0x00000000) { 207 } else if ((read_cpuid_id() & 0x00080000) == 0x00000000) {
309 cpu_arch = (processor_id >> 16) & 7; 208 cpu_arch = (read_cpuid_id() >> 16) & 7;
310 if (cpu_arch) 209 if (cpu_arch)
311 cpu_arch += CPU_ARCH_ARMv3; 210 cpu_arch += CPU_ARCH_ARMv3;
312 } else if ((processor_id & 0x000f0000) == 0x000f0000) { 211 } else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) {
313 unsigned int mmfr0; 212 unsigned int mmfr0;
314 213
315 /* Revised CPUID format. Read the Memory Model Feature 214 /* Revised CPUID format. Read the Memory Model Feature
@@ -330,6 +229,34 @@ int cpu_architecture(void)
330 return cpu_arch; 229 return cpu_arch;
331} 230}
332 231
232static void __init cacheid_init(void)
233{
234 unsigned int cachetype = read_cpuid_cachetype();
235 unsigned int arch = cpu_architecture();
236
237 if (arch >= CPU_ARCH_ARMv7) {
238 cacheid = CACHEID_VIPT_NONALIASING;
239 if ((cachetype & (3 << 14)) == 1 << 14)
240 cacheid |= CACHEID_ASID_TAGGED;
241 } else if (arch >= CPU_ARCH_ARMv6) {
242 if (cachetype & (1 << 23))
243 cacheid = CACHEID_VIPT_ALIASING;
244 else
245 cacheid = CACHEID_VIPT_NONALIASING;
246 } else {
247 cacheid = CACHEID_VIVT;
248 }
249
250 printk("CPU: %s data cache, %s instruction cache\n",
251 cache_is_vivt() ? "VIVT" :
252 cache_is_vipt_aliasing() ? "VIPT aliasing" :
253 cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown",
254 cache_is_vivt() ? "VIVT" :
255 icache_is_vivt_asid_tagged() ? "VIVT ASID tagged" :
256 cache_is_vipt_aliasing() ? "VIPT aliasing" :
257 cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown");
258}
259
333/* 260/*
334 * These functions re-use the assembly code in head.S, which 261 * These functions re-use the assembly code in head.S, which
335 * already provide the required functionality. 262 * already provide the required functionality.
@@ -346,10 +273,10 @@ static void __init setup_processor(void)
346 * types. The linker builds this table for us from the 273 * types. The linker builds this table for us from the
347 * entries in arch/arm/mm/proc-*.S 274 * entries in arch/arm/mm/proc-*.S
348 */ 275 */
349 list = lookup_processor_type(processor_id); 276 list = lookup_processor_type(read_cpuid_id());
350 if (!list) { 277 if (!list) {
351 printk("CPU configuration botched (ID %08x), unable " 278 printk("CPU configuration botched (ID %08x), unable "
352 "to continue.\n", processor_id); 279 "to continue.\n", read_cpuid_id());
353 while (1); 280 while (1);
354 } 281 }
355 282
@@ -369,7 +296,7 @@ static void __init setup_processor(void)
369#endif 296#endif
370 297
371 printk("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n", 298 printk("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n",
372 cpu_name, processor_id, (int)processor_id & 15, 299 cpu_name, read_cpuid_id(), read_cpuid_id() & 15,
373 proc_arch[cpu_architecture()], cr_alignment); 300 proc_arch[cpu_architecture()], cr_alignment);
374 301
375 sprintf(init_utsname()->machine, "%s%c", list->arch_name, ENDIANNESS); 302 sprintf(init_utsname()->machine, "%s%c", list->arch_name, ENDIANNESS);
@@ -379,14 +306,14 @@ static void __init setup_processor(void)
379 elf_hwcap &= ~HWCAP_THUMB; 306 elf_hwcap &= ~HWCAP_THUMB;
380#endif 307#endif
381 308
309 cacheid_init();
382 cpu_proc_init(); 310 cpu_proc_init();
383} 311}
384 312
385/* 313/*
386 * cpu_init - initialise one CPU. 314 * cpu_init - initialise one CPU.
387 * 315 *
388 * cpu_init dumps the cache information, initialises SMP specific 316 * cpu_init sets up the per-CPU stacks.
389 * information, and sets up the per-CPU stacks.
390 */ 317 */
391void cpu_init(void) 318void cpu_init(void)
392{ 319{
@@ -398,9 +325,6 @@ void cpu_init(void)
398 BUG(); 325 BUG();
399 } 326 }
400 327
401 if (system_state == SYSTEM_BOOTING)
402 dump_cpu_info(cpu);
403
404 /* 328 /*
405 * setup stacks for re-entrant exception handlers 329 * setup stacks for re-entrant exception handlers
406 */ 330 */
@@ -443,20 +367,6 @@ static struct machine_desc * __init setup_machine(unsigned int nr)
443 return list; 367 return list;
444} 368}
445 369
446static void __init early_initrd(char **p)
447{
448 unsigned long start, size;
449
450 start = memparse(*p, p);
451 if (**p == ',') {
452 size = memparse((*p) + 1, p);
453
454 phys_initrd_start = start;
455 phys_initrd_size = size;
456 }
457}
458__early_param("initrd=", early_initrd);
459
460static void __init arm_add_memory(unsigned long start, unsigned long size) 370static void __init arm_add_memory(unsigned long start, unsigned long size)
461{ 371{
462 struct membank *bank; 372 struct membank *bank;
@@ -503,17 +413,6 @@ static void __init early_mem(char **p)
503__early_param("mem=", early_mem); 413__early_param("mem=", early_mem);
504 414
505/* 415/*
506 * vmalloc=size forces the vmalloc area to be exactly 'size'
507 * bytes. This can be used to increase (or decrease) the vmalloc
508 * area - the default is 128m.
509 */
510static void __init early_vmalloc(char **arg)
511{
512 vmalloc_reserve = memparse(*arg, arg);
513}
514__early_param("vmalloc=", early_vmalloc);
515
516/*
517 * Initial parsing of the command line. 416 * Initial parsing of the command line.
518 */ 417 */
519static void __init parse_cmdline(char **cmdline_p, char *from) 418static void __init parse_cmdline(char **cmdline_p, char *from)
@@ -527,12 +426,12 @@ static void __init parse_cmdline(char **cmdline_p, char *from)
527 struct early_params *p; 426 struct early_params *p;
528 427
529 for (p = &__early_begin; p < &__early_end; p++) { 428 for (p = &__early_begin; p < &__early_end; p++) {
530 int len = strlen(p->arg); 429 int arglen = strlen(p->arg);
531 430
532 if (memcmp(from, p->arg, len) == 0) { 431 if (memcmp(from, p->arg, arglen) == 0) {
533 if (to != command_line) 432 if (to != command_line)
534 to -= 1; 433 to -= 1;
535 from += len; 434 from += arglen;
536 p->fn(&from); 435 p->fn(&from);
537 436
538 while (*from != ' ' && *from != '\0') 437 while (*from != ' ' && *from != '\0')
@@ -579,18 +478,13 @@ request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
579 kernel_data.end = virt_to_phys(&_end - 1); 478 kernel_data.end = virt_to_phys(&_end - 1);
580 479
581 for (i = 0; i < mi->nr_banks; i++) { 480 for (i = 0; i < mi->nr_banks; i++) {
582 unsigned long virt_start, virt_end;
583
584 if (mi->bank[i].size == 0) 481 if (mi->bank[i].size == 0)
585 continue; 482 continue;
586 483
587 virt_start = __phys_to_virt(mi->bank[i].start);
588 virt_end = virt_start + mi->bank[i].size - 1;
589
590 res = alloc_bootmem_low(sizeof(*res)); 484 res = alloc_bootmem_low(sizeof(*res));
591 res->name = "System RAM"; 485 res->name = "System RAM";
592 res->start = __virt_to_phys(virt_start); 486 res->start = mi->bank[i].start;
593 res->end = __virt_to_phys(virt_end); 487 res->end = mi->bank[i].start + mi->bank[i].size - 1;
594 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; 488 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
595 489
596 request_resource(&iomem_resource, res); 490 request_resource(&iomem_resource, res);
@@ -694,26 +588,6 @@ static int __init parse_tag_ramdisk(const struct tag *tag)
694 588
695__tagtable(ATAG_RAMDISK, parse_tag_ramdisk); 589__tagtable(ATAG_RAMDISK, parse_tag_ramdisk);
696 590
697static int __init parse_tag_initrd(const struct tag *tag)
698{
699 printk(KERN_WARNING "ATAG_INITRD is deprecated; "
700 "please update your bootloader.\n");
701 phys_initrd_start = __virt_to_phys(tag->u.initrd.start);
702 phys_initrd_size = tag->u.initrd.size;
703 return 0;
704}
705
706__tagtable(ATAG_INITRD, parse_tag_initrd);
707
708static int __init parse_tag_initrd2(const struct tag *tag)
709{
710 phys_initrd_start = tag->u.initrd.start;
711 phys_initrd_size = tag->u.initrd.size;
712 return 0;
713}
714
715__tagtable(ATAG_INITRD2, parse_tag_initrd2);
716
717static int __init parse_tag_serialnr(const struct tag *tag) 591static int __init parse_tag_serialnr(const struct tag *tag)
718{ 592{
719 system_serial_low = tag->u.serialnr.low; 593 system_serial_low = tag->u.serialnr.low;
@@ -901,28 +775,12 @@ static const char *hwcap_str[] = {
901 NULL 775 NULL
902}; 776};
903 777
904static void
905c_show_cache(struct seq_file *m, const char *type, unsigned int cache)
906{
907 unsigned int mult = 2 + (CACHE_M(cache) ? 1 : 0);
908
909 seq_printf(m, "%s size\t\t: %d\n"
910 "%s assoc\t\t: %d\n"
911 "%s line length\t: %d\n"
912 "%s sets\t\t: %d\n",
913 type, mult << (8 + CACHE_SIZE(cache)),
914 type, (mult << CACHE_ASSOC(cache)) >> 1,
915 type, 8 << CACHE_LINE(cache),
916 type, 1 << (6 + CACHE_SIZE(cache) - CACHE_ASSOC(cache) -
917 CACHE_LINE(cache)));
918}
919
920static int c_show(struct seq_file *m, void *v) 778static int c_show(struct seq_file *m, void *v)
921{ 779{
922 int i; 780 int i;
923 781
924 seq_printf(m, "Processor\t: %s rev %d (%s)\n", 782 seq_printf(m, "Processor\t: %s rev %d (%s)\n",
925 cpu_name, (int)processor_id & 15, elf_platform); 783 cpu_name, read_cpuid_id() & 15, elf_platform);
926 784
927#if defined(CONFIG_SMP) 785#if defined(CONFIG_SMP)
928 for_each_online_cpu(i) { 786 for_each_online_cpu(i) {
@@ -949,47 +807,26 @@ static int c_show(struct seq_file *m, void *v)
949 if (elf_hwcap & (1 << i)) 807 if (elf_hwcap & (1 << i))
950 seq_printf(m, "%s ", hwcap_str[i]); 808 seq_printf(m, "%s ", hwcap_str[i]);
951 809
952 seq_printf(m, "\nCPU implementer\t: 0x%02x\n", processor_id >> 24); 810 seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
953 seq_printf(m, "CPU architecture: %s\n", proc_arch[cpu_architecture()]); 811 seq_printf(m, "CPU architecture: %s\n", proc_arch[cpu_architecture()]);
954 812
955 if ((processor_id & 0x0008f000) == 0x00000000) { 813 if ((read_cpuid_id() & 0x0008f000) == 0x00000000) {
956 /* pre-ARM7 */ 814 /* pre-ARM7 */
957 seq_printf(m, "CPU part\t: %07x\n", processor_id >> 4); 815 seq_printf(m, "CPU part\t: %07x\n", read_cpuid_id() >> 4);
958 } else { 816 } else {
959 if ((processor_id & 0x0008f000) == 0x00007000) { 817 if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
960 /* ARM7 */ 818 /* ARM7 */
961 seq_printf(m, "CPU variant\t: 0x%02x\n", 819 seq_printf(m, "CPU variant\t: 0x%02x\n",
962 (processor_id >> 16) & 127); 820 (read_cpuid_id() >> 16) & 127);
963 } else { 821 } else {
964 /* post-ARM7 */ 822 /* post-ARM7 */
965 seq_printf(m, "CPU variant\t: 0x%x\n", 823 seq_printf(m, "CPU variant\t: 0x%x\n",
966 (processor_id >> 20) & 15); 824 (read_cpuid_id() >> 20) & 15);
967 } 825 }
968 seq_printf(m, "CPU part\t: 0x%03x\n", 826 seq_printf(m, "CPU part\t: 0x%03x\n",
969 (processor_id >> 4) & 0xfff); 827 (read_cpuid_id() >> 4) & 0xfff);
970 }
971 seq_printf(m, "CPU revision\t: %d\n", processor_id & 15);
972
973 {
974 unsigned int cache_info = read_cpuid(CPUID_CACHETYPE);
975 if (cache_info != processor_id) {
976 seq_printf(m, "Cache type\t: %s\n"
977 "Cache clean\t: %s\n"
978 "Cache lockdown\t: %s\n"
979 "Cache format\t: %s\n",
980 cache_types[CACHE_TYPE(cache_info)],
981 cache_clean[CACHE_TYPE(cache_info)],
982 cache_lockdown[CACHE_TYPE(cache_info)],
983 CACHE_S(cache_info) ? "Harvard" : "Unified");
984
985 if (CACHE_S(cache_info)) {
986 c_show_cache(m, "I", CACHE_ISIZE(cache_info));
987 c_show_cache(m, "D", CACHE_DSIZE(cache_info));
988 } else {
989 c_show_cache(m, "Cache", CACHE_ISIZE(cache_info));
990 }
991 }
992 } 828 }
829 seq_printf(m, "CPU revision\t: %d\n", read_cpuid_id() & 15);
993 830
994 seq_puts(m, "\n"); 831 seq_puts(m, "\n");
995 832
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index ef2f86a5e78a..80b8b5c7e07a 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -11,11 +11,11 @@
11#include <linux/signal.h> 11#include <linux/signal.h>
12#include <linux/personality.h> 12#include <linux/personality.h>
13#include <linux/freezer.h> 13#include <linux/freezer.h>
14#include <linux/uaccess.h>
14 15
15#include <asm/elf.h> 16#include <asm/elf.h>
16#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
17#include <asm/ucontext.h> 18#include <asm/ucontext.h>
18#include <asm/uaccess.h>
19#include <asm/unistd.h> 19#include <asm/unistd.h>
20 20
21#include "ptrace.h" 21#include "ptrace.h"
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index e9842f6767f9..e42a749a56dd 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -277,6 +277,7 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
277 /* 277 /*
278 * Enable local interrupts. 278 * Enable local interrupts.
279 */ 279 */
280 notify_cpu_starting(cpu);
280 local_irq_enable(); 281 local_irq_enable();
281 local_fiq_enable(); 282 local_fiq_enable();
282 283
diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 0128687ba0f7..b3ec641b5cf8 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -27,8 +27,7 @@
27#include <linux/file.h> 27#include <linux/file.h>
28#include <linux/utsname.h> 28#include <linux/utsname.h>
29#include <linux/ipc.h> 29#include <linux/ipc.h>
30 30#include <linux/uaccess.h>
31#include <asm/uaccess.h>
32 31
33extern unsigned long do_mremap(unsigned long addr, unsigned long old_len, 32extern unsigned long do_mremap(unsigned long addr, unsigned long old_len,
34 unsigned long new_len, unsigned long flags, 33 unsigned long new_len, unsigned long flags,
diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c
index 96ab5f52949c..42623db7f870 100644
--- a/arch/arm/kernel/sys_oabi-compat.c
+++ b/arch/arm/kernel/sys_oabi-compat.c
@@ -82,7 +82,7 @@
82#include <linux/socket.h> 82#include <linux/socket.h>
83#include <linux/net.h> 83#include <linux/net.h>
84#include <linux/ipc.h> 84#include <linux/ipc.h>
85#include <asm/uaccess.h> 85#include <linux/uaccess.h>
86 86
87struct oldabi_stat64 { 87struct oldabi_stat64 {
88 unsigned long long st_dev; 88 unsigned long long st_dev;
diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 368d171754cf..c68b44aa88d2 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -59,7 +59,7 @@ unsigned long profile_pc(struct pt_regs *regs)
59 59
60 if (in_lock_functions(pc)) { 60 if (in_lock_functions(pc)) {
61 fp = regs->ARM_fp; 61 fp = regs->ARM_fp;
62 pc = pc_pointer(((unsigned long *)fp)[-1]); 62 pc = ((unsigned long *)fp)[-1];
63 } 63 }
64 64
65 return pc; 65 return pc;
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 872f1f8fbb57..57e6874d0b80 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -19,15 +19,13 @@
19#include <linux/kallsyms.h> 19#include <linux/kallsyms.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/kprobes.h> 22#include <linux/uaccess.h>
23 23
24#include <asm/atomic.h> 24#include <asm/atomic.h>
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26#include <asm/system.h> 26#include <asm/system.h>
27#include <asm/uaccess.h>
28#include <asm/unistd.h> 27#include <asm/unistd.h>
29#include <asm/traps.h> 28#include <asm/traps.h>
30#include <asm/io.h>
31 29
32#include "ptrace.h" 30#include "ptrace.h"
33#include "signal.h" 31#include "signal.h"
@@ -69,7 +67,8 @@ void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long
69 */ 67 */
70static int verify_stack(unsigned long sp) 68static int verify_stack(unsigned long sp)
71{ 69{
72 if (sp < PAGE_OFFSET || (sp > (unsigned long)high_memory && high_memory != 0)) 70 if (sp < PAGE_OFFSET ||
71 (sp > (unsigned long)high_memory && high_memory != NULL))
73 return -EFAULT; 72 return -EFAULT;
74 73
75 return 0; 74 return 0;
@@ -328,17 +327,6 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
328 get_user(instr, (u32 __user *)pc); 327 get_user(instr, (u32 __user *)pc);
329 } 328 }
330 329
331#ifdef CONFIG_KPROBES
332 /*
333 * It is possible to have recursive kprobes, so we can't call
334 * the kprobe trap handler with the undef_lock held.
335 */
336 if (instr == KPROBE_BREAKPOINT_INSTRUCTION && !user_mode(regs)) {
337 kprobe_trap_handler(regs, instr);
338 return;
339 }
340#endif
341
342 if (call_undef_hook(regs, instr) == 0) 330 if (call_undef_hook(regs, instr) == 0)
343 return; 331 return;
344 332
diff --git a/arch/arm/kernel/xscale-cp0.c b/arch/arm/kernel/xscale-cp0.c
index 180000bfdc8f..17127db906fa 100644
--- a/arch/arm/kernel/xscale-cp0.c
+++ b/arch/arm/kernel/xscale-cp0.c
@@ -14,8 +14,8 @@
14#include <linux/signal.h> 14#include <linux/signal.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/io.h>
17#include <asm/thread_notify.h> 18#include <asm/thread_notify.h>
18#include <asm/io.h>
19 19
20static inline void dsp_save_state(u32 *state) 20static inline void dsp_save_state(u32 *state)
21{ 21{
diff --git a/arch/arm/lib/ashldi3.S b/arch/arm/lib/ashldi3.S
index 55e57a1c2e6d..1154d924080b 100644
--- a/arch/arm/lib/ashldi3.S
+++ b/arch/arm/lib/ashldi3.S
@@ -47,3 +47,5 @@ ENTRY(__aeabi_llsl)
47 mov al, al, lsl r2 47 mov al, al, lsl r2
48 mov pc, lr 48 mov pc, lr
49 49
50ENDPROC(__ashldi3)
51ENDPROC(__aeabi_llsl)
diff --git a/arch/arm/lib/ashrdi3.S b/arch/arm/lib/ashrdi3.S
index 0b31398f89b2..9f8b35572f8c 100644
--- a/arch/arm/lib/ashrdi3.S
+++ b/arch/arm/lib/ashrdi3.S
@@ -47,3 +47,5 @@ ENTRY(__aeabi_lasr)
47 mov ah, ah, asr r2 47 mov ah, ah, asr r2
48 mov pc, lr 48 mov pc, lr
49 49
50ENDPROC(__ashrdi3)
51ENDPROC(__aeabi_lasr)
diff --git a/arch/arm/lib/backtrace.S b/arch/arm/lib/backtrace.S
index 84dc890d2bf3..b0951d0e8b2c 100644
--- a/arch/arm/lib/backtrace.S
+++ b/arch/arm/lib/backtrace.S
@@ -30,6 +30,8 @@ ENTRY(c_backtrace)
30 30
31#if !defined(CONFIG_FRAME_POINTER) || !defined(CONFIG_PRINTK) 31#if !defined(CONFIG_FRAME_POINTER) || !defined(CONFIG_PRINTK)
32 mov pc, lr 32 mov pc, lr
33ENDPROC(__backtrace)
34ENDPROC(c_backtrace)
33#else 35#else
34 stmfd sp!, {r4 - r8, lr} @ Save an extra register so we have a location... 36 stmfd sp!, {r4 - r8, lr} @ Save an extra register so we have a location...
35 movs frame, r0 @ if frame pointer is zero 37 movs frame, r0 @ if frame pointer is zero
@@ -103,6 +105,8 @@ for_each_frame: tst frame, mask @ Check for address exceptions
103 mov r1, frame 105 mov r1, frame
104 bl printk 106 bl printk
105no_frame: ldmfd sp!, {r4 - r8, pc} 107no_frame: ldmfd sp!, {r4 - r8, pc}
108ENDPROC(__backtrace)
109ENDPROC(c_backtrace)
106 110
107 .section __ex_table,"a" 111 .section __ex_table,"a"
108 .align 3 112 .align 3
diff --git a/arch/arm/lib/changebit.S b/arch/arm/lib/changebit.S
index 389567c24090..80f3115cbee2 100644
--- a/arch/arm/lib/changebit.S
+++ b/arch/arm/lib/changebit.S
@@ -19,3 +19,5 @@ ENTRY(_change_bit_be)
19 eor r0, r0, #0x18 @ big endian byte ordering 19 eor r0, r0, #0x18 @ big endian byte ordering
20ENTRY(_change_bit_le) 20ENTRY(_change_bit_le)
21 bitop eor 21 bitop eor
22ENDPROC(_change_bit_be)
23ENDPROC(_change_bit_le)
diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
index ecb28dcdaf7b..4d6bc71231f3 100644
--- a/arch/arm/lib/clear_user.S
+++ b/arch/arm/lib/clear_user.S
@@ -41,9 +41,10 @@ USER( strplt r2, [r0], #4)
41USER( strnebt r2, [r0], #1) 41USER( strnebt r2, [r0], #1)
42USER( strnebt r2, [r0], #1) 42USER( strnebt r2, [r0], #1)
43 tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1 43 tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
44USER( strnebt r2, [r0], #1) 44USER( strnebt r2, [r0])
45 mov r0, #0 45 mov r0, #0
46 ldmfd sp!, {r1, pc} 46 ldmfd sp!, {r1, pc}
47ENDPROC(__clear_user)
47 48
48 .section .fixup,"ax" 49 .section .fixup,"ax"
49 .align 0 50 .align 0
diff --git a/arch/arm/lib/clearbit.S b/arch/arm/lib/clearbit.S
index 347516533025..1a63e43a1df0 100644
--- a/arch/arm/lib/clearbit.S
+++ b/arch/arm/lib/clearbit.S
@@ -20,3 +20,5 @@ ENTRY(_clear_bit_be)
20 eor r0, r0, #0x18 @ big endian byte ordering 20 eor r0, r0, #0x18 @ big endian byte ordering
21ENTRY(_clear_bit_le) 21ENTRY(_clear_bit_le)
22 bitop bic 22 bitop bic
23ENDPROC(_clear_bit_be)
24ENDPROC(_clear_bit_le)
diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
index 6b7363ce749c..56799a165cc4 100644
--- a/arch/arm/lib/copy_from_user.S
+++ b/arch/arm/lib/copy_from_user.S
@@ -87,6 +87,8 @@ ENTRY(__copy_from_user)
87 87
88#include "copy_template.S" 88#include "copy_template.S"
89 89
90ENDPROC(__copy_from_user)
91
90 .section .fixup,"ax" 92 .section .fixup,"ax"
91 .align 0 93 .align 0
92 copy_abort_preamble 94 copy_abort_preamble
diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
index 666c99cc0744..6ae04db1ca4f 100644
--- a/arch/arm/lib/copy_page.S
+++ b/arch/arm/lib/copy_page.S
@@ -44,3 +44,4 @@ ENTRY(copy_page)
44 PLD( ldmeqia r1!, {r3, r4, ip, lr} ) 44 PLD( ldmeqia r1!, {r3, r4, ip, lr} )
45 PLD( beq 2b ) 45 PLD( beq 2b )
46 ldmfd sp!, {r4, pc} @ 3 46 ldmfd sp!, {r4, pc} @ 3
47ENDPROC(copy_page)
diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
index 5224d94688d9..22f968bbdffd 100644
--- a/arch/arm/lib/copy_to_user.S
+++ b/arch/arm/lib/copy_to_user.S
@@ -90,6 +90,8 @@ ENTRY(__copy_to_user)
90 90
91#include "copy_template.S" 91#include "copy_template.S"
92 92
93ENDPROC(__copy_to_user)
94
93 .section .fixup,"ax" 95 .section .fixup,"ax"
94 .align 0 96 .align 0
95 copy_abort_preamble 97 copy_abort_preamble
diff --git a/arch/arm/lib/csumipv6.S b/arch/arm/lib/csumipv6.S
index 9621469beec1..3ac6ef01bc43 100644
--- a/arch/arm/lib/csumipv6.S
+++ b/arch/arm/lib/csumipv6.S
@@ -29,4 +29,5 @@ ENTRY(__csum_ipv6_magic)
29 adcs r0, r0, r2 29 adcs r0, r0, r2
30 adcs r0, r0, #0 30 adcs r0, r0, #0
31 ldmfd sp!, {pc} 31 ldmfd sp!, {pc}
32ENDPROC(__csum_ipv6_magic)
32 33
diff --git a/arch/arm/lib/csumpartial.S b/arch/arm/lib/csumpartial.S
index a78dae5a7b28..31d3cb34740d 100644
--- a/arch/arm/lib/csumpartial.S
+++ b/arch/arm/lib/csumpartial.S
@@ -139,3 +139,4 @@ ENTRY(csum_partial)
139 tst len, #0x1c 139 tst len, #0x1c
140 bne 4b 140 bne 4b
141 b .Lless4 141 b .Lless4
142ENDPROC(csum_partial)
diff --git a/arch/arm/lib/csumpartialcopy.S b/arch/arm/lib/csumpartialcopy.S
index 21effe0dbf97..d03fc71fc88c 100644
--- a/arch/arm/lib/csumpartialcopy.S
+++ b/arch/arm/lib/csumpartialcopy.S
@@ -18,13 +18,11 @@
18 */ 18 */
19 19
20 .macro save_regs 20 .macro save_regs
21 mov ip, sp 21 stmfd sp!, {r1, r4 - r8, lr}
22 stmfd sp!, {r1, r4 - r8, fp, ip, lr, pc}
23 sub fp, ip, #4
24 .endm 22 .endm
25 23
26 .macro load_regs 24 .macro load_regs
27 ldmfd sp, {r1, r4 - r8, fp, sp, pc} 25 ldmfd sp!, {r1, r4 - r8, pc}
28 .endm 26 .endm
29 27
30 .macro load1b, reg1 28 .macro load1b, reg1
@@ -50,5 +48,6 @@
50 .endm 48 .endm
51 49
52#define FN_ENTRY ENTRY(csum_partial_copy_nocheck) 50#define FN_ENTRY ENTRY(csum_partial_copy_nocheck)
51#define FN_EXIT ENDPROC(csum_partial_copy_nocheck)
53 52
54#include "csumpartialcopygeneric.S" 53#include "csumpartialcopygeneric.S"
diff --git a/arch/arm/lib/csumpartialcopygeneric.S b/arch/arm/lib/csumpartialcopygeneric.S
index c50e8f5285d1..d620a5f22a09 100644
--- a/arch/arm/lib/csumpartialcopygeneric.S
+++ b/arch/arm/lib/csumpartialcopygeneric.S
@@ -329,3 +329,4 @@ FN_ENTRY
329 adcs sum, sum, r4, push #24 329 adcs sum, sum, r4, push #24
330 mov r5, r4, get_byte_1 330 mov r5, r4, get_byte_1
331 b .Lexit 331 b .Lexit
332FN_EXIT
diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
index c3b93e22ea25..14677fb4b0c4 100644
--- a/arch/arm/lib/csumpartialcopyuser.S
+++ b/arch/arm/lib/csumpartialcopyuser.S
@@ -18,13 +18,11 @@
18 .text 18 .text
19 19
20 .macro save_regs 20 .macro save_regs
21 mov ip, sp 21 stmfd sp!, {r1, r2, r4 - r8, lr}
22 stmfd sp!, {r1 - r2, r4 - r8, fp, ip, lr, pc}
23 sub fp, ip, #4
24 .endm 22 .endm
25 23
26 .macro load_regs 24 .macro load_regs
27 ldmfd sp, {r1, r2, r4-r8, fp, sp, pc} 25 ldmfd sp!, {r1, r2, r4 - r8, pc}
28 .endm 26 .endm
29 27
30 .macro load1b, reg1 28 .macro load1b, reg1
@@ -82,6 +80,7 @@
82 */ 80 */
83 81
84#define FN_ENTRY ENTRY(csum_partial_copy_from_user) 82#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
83#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
85 84
86#include "csumpartialcopygeneric.S" 85#include "csumpartialcopygeneric.S"
87 86
diff --git a/arch/arm/lib/delay.S b/arch/arm/lib/delay.S
index 930a70259220..8d6a8762ab88 100644
--- a/arch/arm/lib/delay.S
+++ b/arch/arm/lib/delay.S
@@ -60,3 +60,6 @@ ENTRY(__delay)
60#endif 60#endif
61 bhi __delay 61 bhi __delay
62 mov pc, lr 62 mov pc, lr
63ENDPROC(__udelay)
64ENDPROC(__const_udelay)
65ENDPROC(__delay)
diff --git a/arch/arm/lib/div64.S b/arch/arm/lib/div64.S
index 58eef6607629..1425e789ba86 100644
--- a/arch/arm/lib/div64.S
+++ b/arch/arm/lib/div64.S
@@ -198,3 +198,4 @@ ENTRY(__do_div64)
198 mov xh, #0 198 mov xh, #0
199 ldr pc, [sp], #8 199 ldr pc, [sp], #8
200 200
201ENDPROC(__do_div64)
diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S
index a5ca0248aa4e..8c4defc4f3c4 100644
--- a/arch/arm/lib/findbit.S
+++ b/arch/arm/lib/findbit.S
@@ -33,6 +33,7 @@ ENTRY(_find_first_zero_bit_le)
33 blo 1b 33 blo 1b
343: mov r0, r1 @ no free bits 343: mov r0, r1 @ no free bits
35 mov pc, lr 35 mov pc, lr
36ENDPROC(_find_first_zero_bit_le)
36 37
37/* 38/*
38 * Purpose : Find next 'zero' bit 39 * Purpose : Find next 'zero' bit
@@ -50,6 +51,7 @@ ENTRY(_find_next_zero_bit_le)
50 orr r2, r2, #7 @ if zero, then no bits here 51 orr r2, r2, #7 @ if zero, then no bits here
51 add r2, r2, #1 @ align bit pointer 52 add r2, r2, #1 @ align bit pointer
52 b 2b @ loop for next bit 53 b 2b @ loop for next bit
54ENDPROC(_find_next_zero_bit_le)
53 55
54/* 56/*
55 * Purpose : Find a 'one' bit 57 * Purpose : Find a 'one' bit
@@ -67,6 +69,7 @@ ENTRY(_find_first_bit_le)
67 blo 1b 69 blo 1b
683: mov r0, r1 @ no free bits 703: mov r0, r1 @ no free bits
69 mov pc, lr 71 mov pc, lr
72ENDPROC(_find_first_bit_le)
70 73
71/* 74/*
72 * Purpose : Find next 'one' bit 75 * Purpose : Find next 'one' bit
@@ -83,6 +86,7 @@ ENTRY(_find_next_bit_le)
83 orr r2, r2, #7 @ if zero, then no bits here 86 orr r2, r2, #7 @ if zero, then no bits here
84 add r2, r2, #1 @ align bit pointer 87 add r2, r2, #1 @ align bit pointer
85 b 2b @ loop for next bit 88 b 2b @ loop for next bit
89ENDPROC(_find_next_bit_le)
86 90
87#ifdef __ARMEB__ 91#ifdef __ARMEB__
88 92
@@ -99,6 +103,7 @@ ENTRY(_find_first_zero_bit_be)
99 blo 1b 103 blo 1b
1003: mov r0, r1 @ no free bits 1043: mov r0, r1 @ no free bits
101 mov pc, lr 105 mov pc, lr
106ENDPROC(_find_first_zero_bit_be)
102 107
103ENTRY(_find_next_zero_bit_be) 108ENTRY(_find_next_zero_bit_be)
104 teq r1, #0 109 teq r1, #0
@@ -113,6 +118,7 @@ ENTRY(_find_next_zero_bit_be)
113 orr r2, r2, #7 @ if zero, then no bits here 118 orr r2, r2, #7 @ if zero, then no bits here
114 add r2, r2, #1 @ align bit pointer 119 add r2, r2, #1 @ align bit pointer
115 b 2b @ loop for next bit 120 b 2b @ loop for next bit
121ENDPROC(_find_next_zero_bit_be)
116 122
117ENTRY(_find_first_bit_be) 123ENTRY(_find_first_bit_be)
118 teq r1, #0 124 teq r1, #0
@@ -127,6 +133,7 @@ ENTRY(_find_first_bit_be)
127 blo 1b 133 blo 1b
1283: mov r0, r1 @ no free bits 1343: mov r0, r1 @ no free bits
129 mov pc, lr 135 mov pc, lr
136ENDPROC(_find_first_bit_be)
130 137
131ENTRY(_find_next_bit_be) 138ENTRY(_find_next_bit_be)
132 teq r1, #0 139 teq r1, #0
@@ -140,6 +147,7 @@ ENTRY(_find_next_bit_be)
140 orr r2, r2, #7 @ if zero, then no bits here 147 orr r2, r2, #7 @ if zero, then no bits here
141 add r2, r2, #1 @ align bit pointer 148 add r2, r2, #1 @ align bit pointer
142 b 2b @ loop for next bit 149 b 2b @ loop for next bit
150ENDPROC(_find_next_bit_be)
143 151
144#endif 152#endif
145 153
diff --git a/arch/arm/lib/getuser.S b/arch/arm/lib/getuser.S
index 2034d4dbe6ad..6763088b7607 100644
--- a/arch/arm/lib/getuser.S
+++ b/arch/arm/lib/getuser.S
@@ -26,16 +26,16 @@
26 * Note that ADDR_LIMIT is either 0 or 0xc0000000. 26 * Note that ADDR_LIMIT is either 0 or 0xc0000000.
27 * Note also that it is intended that __get_user_bad is not global. 27 * Note also that it is intended that __get_user_bad is not global.
28 */ 28 */
29#include <linux/linkage.h>
29#include <asm/errno.h> 30#include <asm/errno.h>
30 31
31 .global __get_user_1 32ENTRY(__get_user_1)
32__get_user_1:
331: ldrbt r2, [r0] 331: ldrbt r2, [r0]
34 mov r0, #0 34 mov r0, #0
35 mov pc, lr 35 mov pc, lr
36ENDPROC(__get_user_1)
36 37
37 .global __get_user_2 38ENTRY(__get_user_2)
38__get_user_2:
392: ldrbt r2, [r0], #1 392: ldrbt r2, [r0], #1
403: ldrbt r3, [r0] 403: ldrbt r3, [r0]
41#ifndef __ARMEB__ 41#ifndef __ARMEB__
@@ -45,17 +45,19 @@ __get_user_2:
45#endif 45#endif
46 mov r0, #0 46 mov r0, #0
47 mov pc, lr 47 mov pc, lr
48ENDPROC(__get_user_2)
48 49
49 .global __get_user_4 50ENTRY(__get_user_4)
50__get_user_4:
514: ldrt r2, [r0] 514: ldrt r2, [r0]
52 mov r0, #0 52 mov r0, #0
53 mov pc, lr 53 mov pc, lr
54ENDPROC(__get_user_4)
54 55
55__get_user_bad: 56__get_user_bad:
56 mov r2, #0 57 mov r2, #0
57 mov r0, #-EFAULT 58 mov r0, #-EFAULT
58 mov pc, lr 59 mov pc, lr
60ENDPROC(__get_user_bad)
59 61
60.section __ex_table, "a" 62.section __ex_table, "a"
61 .long 1b, __get_user_bad 63 .long 1b, __get_user_bad
diff --git a/arch/arm/lib/io-readsb.S b/arch/arm/lib/io-readsb.S
index fb966ad0276f..9f4238987fe9 100644
--- a/arch/arm/lib/io-readsb.S
+++ b/arch/arm/lib/io-readsb.S
@@ -120,3 +120,4 @@ ENTRY(__raw_readsb)
120 strgtb r3, [r1] 120 strgtb r3, [r1]
121 121
122 ldmfd sp!, {r4 - r6, pc} 122 ldmfd sp!, {r4 - r6, pc}
123ENDPROC(__raw_readsb)
diff --git a/arch/arm/lib/io-readsl.S b/arch/arm/lib/io-readsl.S
index 75a9121cb23f..5fb97e7f9f4b 100644
--- a/arch/arm/lib/io-readsl.S
+++ b/arch/arm/lib/io-readsl.S
@@ -76,3 +76,4 @@ ENTRY(__raw_readsl)
768: mov r3, ip, get_byte_0 768: mov r3, ip, get_byte_0
77 strb r3, [r1, #0] 77 strb r3, [r1, #0]
78 mov pc, lr 78 mov pc, lr
79ENDPROC(__raw_readsl)
diff --git a/arch/arm/lib/io-readsw-armv4.S b/arch/arm/lib/io-readsw-armv4.S
index 4db1c5f0b219..1f393d42593d 100644
--- a/arch/arm/lib/io-readsw-armv4.S
+++ b/arch/arm/lib/io-readsw-armv4.S
@@ -128,3 +128,4 @@ ENTRY(__raw_readsw)
128 _BE_ONLY_( movne ip, ip, lsr #24 ) 128 _BE_ONLY_( movne ip, ip, lsr #24 )
129 strneb ip, [r1] 129 strneb ip, [r1]
130 ldmfd sp!, {r4, pc} 130 ldmfd sp!, {r4, pc}
131ENDPROC(__raw_readsw)
diff --git a/arch/arm/lib/io-writesb.S b/arch/arm/lib/io-writesb.S
index 7eba2b6cc69f..68b92f4acaeb 100644
--- a/arch/arm/lib/io-writesb.S
+++ b/arch/arm/lib/io-writesb.S
@@ -91,3 +91,4 @@ ENTRY(__raw_writesb)
91 strgtb r3, [r0] 91 strgtb r3, [r0]
92 92
93 ldmfd sp!, {r4, r5, pc} 93 ldmfd sp!, {r4, r5, pc}
94ENDPROC(__raw_writesb)
diff --git a/arch/arm/lib/io-writesl.S b/arch/arm/lib/io-writesl.S
index f8f14dd227ca..8d3b7813725c 100644
--- a/arch/arm/lib/io-writesl.S
+++ b/arch/arm/lib/io-writesl.S
@@ -64,3 +64,4 @@ ENTRY(__raw_writesl)
64 str ip, [r0] 64 str ip, [r0]
65 bne 6b 65 bne 6b
66 mov pc, lr 66 mov pc, lr
67ENDPROC(__raw_writesl)
diff --git a/arch/arm/lib/io-writesw-armv4.S b/arch/arm/lib/io-writesw-armv4.S
index c8e85bd653b7..d6585612c86b 100644
--- a/arch/arm/lib/io-writesw-armv4.S
+++ b/arch/arm/lib/io-writesw-armv4.S
@@ -94,3 +94,4 @@ ENTRY(__raw_writesw)
943: movne ip, r3, lsr #8 943: movne ip, r3, lsr #8
95 strneh ip, [r0] 95 strneh ip, [r0]
96 mov pc, lr 96 mov pc, lr
97ENDPROC(__raw_writesw)
diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
index 4e492f4b3f0e..67964bcfc854 100644
--- a/arch/arm/lib/lib1funcs.S
+++ b/arch/arm/lib/lib1funcs.S
@@ -230,6 +230,8 @@ ENTRY(__aeabi_uidiv)
230 mov r0, r0, lsr r2 230 mov r0, r0, lsr r2
231 mov pc, lr 231 mov pc, lr
232 232
233ENDPROC(__udivsi3)
234ENDPROC(__aeabi_uidiv)
233 235
234ENTRY(__umodsi3) 236ENTRY(__umodsi3)
235 237
@@ -245,6 +247,7 @@ ENTRY(__umodsi3)
245 247
246 mov pc, lr 248 mov pc, lr
247 249
250ENDPROC(__umodsi3)
248 251
249ENTRY(__divsi3) 252ENTRY(__divsi3)
250ENTRY(__aeabi_idiv) 253ENTRY(__aeabi_idiv)
@@ -284,6 +287,8 @@ ENTRY(__aeabi_idiv)
284 rsbmi r0, r0, #0 287 rsbmi r0, r0, #0
285 mov pc, lr 288 mov pc, lr
286 289
290ENDPROC(__divsi3)
291ENDPROC(__aeabi_idiv)
287 292
288ENTRY(__modsi3) 293ENTRY(__modsi3)
289 294
@@ -305,6 +310,8 @@ ENTRY(__modsi3)
305 rsbmi r0, r0, #0 310 rsbmi r0, r0, #0
306 mov pc, lr 311 mov pc, lr
307 312
313ENDPROC(__modsi3)
314
308#ifdef CONFIG_AEABI 315#ifdef CONFIG_AEABI
309 316
310ENTRY(__aeabi_uidivmod) 317ENTRY(__aeabi_uidivmod)
@@ -316,6 +323,8 @@ ENTRY(__aeabi_uidivmod)
316 sub r1, r1, r3 323 sub r1, r1, r3
317 mov pc, lr 324 mov pc, lr
318 325
326ENDPROC(__aeabi_uidivmod)
327
319ENTRY(__aeabi_idivmod) 328ENTRY(__aeabi_idivmod)
320 329
321 stmfd sp!, {r0, r1, ip, lr} 330 stmfd sp!, {r0, r1, ip, lr}
@@ -325,6 +334,8 @@ ENTRY(__aeabi_idivmod)
325 sub r1, r1, r3 334 sub r1, r1, r3
326 mov pc, lr 335 mov pc, lr
327 336
337ENDPROC(__aeabi_idivmod)
338
328#endif 339#endif
329 340
330Ldiv0: 341Ldiv0:
diff --git a/arch/arm/lib/lshrdi3.S b/arch/arm/lib/lshrdi3.S
index a86dbdd59cc4..99ea338bf87c 100644
--- a/arch/arm/lib/lshrdi3.S
+++ b/arch/arm/lib/lshrdi3.S
@@ -47,3 +47,5 @@ ENTRY(__aeabi_llsr)
47 mov ah, ah, lsr r2 47 mov ah, ah, lsr r2
48 mov pc, lr 48 mov pc, lr
49 49
50ENDPROC(__lshrdi3)
51ENDPROC(__aeabi_llsr)
diff --git a/arch/arm/lib/memchr.S b/arch/arm/lib/memchr.S
index e7ab1ea8ebaa..1da86991d700 100644
--- a/arch/arm/lib/memchr.S
+++ b/arch/arm/lib/memchr.S
@@ -23,3 +23,4 @@ ENTRY(memchr)
23 sub r0, r0, #1 23 sub r0, r0, #1
242: movne r0, #0 242: movne r0, #0
25 mov pc, lr 25 mov pc, lr
26ENDPROC(memchr)
diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
index 7e71d6708a8d..e0d002641d3f 100644
--- a/arch/arm/lib/memcpy.S
+++ b/arch/arm/lib/memcpy.S
@@ -57,3 +57,4 @@ ENTRY(memcpy)
57 57
58#include "copy_template.S" 58#include "copy_template.S"
59 59
60ENDPROC(memcpy)
diff --git a/arch/arm/lib/memmove.S b/arch/arm/lib/memmove.S
index 2e301b7bd8f1..12549187088c 100644
--- a/arch/arm/lib/memmove.S
+++ b/arch/arm/lib/memmove.S
@@ -196,3 +196,4 @@ ENTRY(memmove)
196 196
19718: backward_copy_shift push=24 pull=8 19718: backward_copy_shift push=24 pull=8
198 198
199ENDPROC(memmove)
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index b477d4ac88ef..761eefa76243 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -124,3 +124,4 @@ ENTRY(memset)
124 tst r2, #1 124 tst r2, #1
125 strneb r1, [r0], #1 125 strneb r1, [r0], #1
126 mov pc, lr 126 mov pc, lr
127ENDPROC(memset)
diff --git a/arch/arm/lib/memzero.S b/arch/arm/lib/memzero.S
index b8f79d80ee9b..3fbdef5f802a 100644
--- a/arch/arm/lib/memzero.S
+++ b/arch/arm/lib/memzero.S
@@ -122,3 +122,4 @@ ENTRY(__memzero)
122 tst r1, #1 @ 1 a byte left over 122 tst r1, #1 @ 1 a byte left over
123 strneb r2, [r0], #1 @ 1 123 strneb r2, [r0], #1 @ 1
124 mov pc, lr @ 1 124 mov pc, lr @ 1
125ENDPROC(__memzero)
diff --git a/arch/arm/lib/muldi3.S b/arch/arm/lib/muldi3.S
index d89c60615794..36c91b4957e2 100644
--- a/arch/arm/lib/muldi3.S
+++ b/arch/arm/lib/muldi3.S
@@ -43,3 +43,5 @@ ENTRY(__aeabi_lmul)
43 adc xh, xh, ip, lsr #16 43 adc xh, xh, ip, lsr #16
44 mov pc, lr 44 mov pc, lr
45 45
46ENDPROC(__muldi3)
47ENDPROC(__aeabi_lmul)
diff --git a/arch/arm/lib/putuser.S b/arch/arm/lib/putuser.S
index 08ec7dffa52e..864f3c1c4f18 100644
--- a/arch/arm/lib/putuser.S
+++ b/arch/arm/lib/putuser.S
@@ -26,16 +26,16 @@
26 * Note that ADDR_LIMIT is either 0 or 0xc0000000 26 * Note that ADDR_LIMIT is either 0 or 0xc0000000
27 * Note also that it is intended that __put_user_bad is not global. 27 * Note also that it is intended that __put_user_bad is not global.
28 */ 28 */
29#include <linux/linkage.h>
29#include <asm/errno.h> 30#include <asm/errno.h>
30 31
31 .global __put_user_1 32ENTRY(__put_user_1)
32__put_user_1:
331: strbt r2, [r0] 331: strbt r2, [r0]
34 mov r0, #0 34 mov r0, #0
35 mov pc, lr 35 mov pc, lr
36ENDPROC(__put_user_1)
36 37
37 .global __put_user_2 38ENTRY(__put_user_2)
38__put_user_2:
39 mov ip, r2, lsr #8 39 mov ip, r2, lsr #8
40#ifndef __ARMEB__ 40#ifndef __ARMEB__
412: strbt r2, [r0], #1 412: strbt r2, [r0], #1
@@ -46,23 +46,25 @@ __put_user_2:
46#endif 46#endif
47 mov r0, #0 47 mov r0, #0
48 mov pc, lr 48 mov pc, lr
49ENDPROC(__put_user_2)
49 50
50 .global __put_user_4 51ENTRY(__put_user_4)
51__put_user_4:
524: strt r2, [r0] 524: strt r2, [r0]
53 mov r0, #0 53 mov r0, #0
54 mov pc, lr 54 mov pc, lr
55ENDPROC(__put_user_4)
55 56
56 .global __put_user_8 57ENTRY(__put_user_8)
57__put_user_8:
585: strt r2, [r0], #4 585: strt r2, [r0], #4
596: strt r3, [r0] 596: strt r3, [r0]
60 mov r0, #0 60 mov r0, #0
61 mov pc, lr 61 mov pc, lr
62ENDPROC(__put_user_8)
62 63
63__put_user_bad: 64__put_user_bad:
64 mov r0, #-EFAULT 65 mov r0, #-EFAULT
65 mov pc, lr 66 mov pc, lr
67ENDPROC(__put_user_bad)
66 68
67.section __ex_table, "a" 69.section __ex_table, "a"
68 .long 1b, __put_user_bad 70 .long 1b, __put_user_bad
diff --git a/arch/arm/lib/setbit.S b/arch/arm/lib/setbit.S
index 83bc23d5b037..1dd7176c4b2b 100644
--- a/arch/arm/lib/setbit.S
+++ b/arch/arm/lib/setbit.S
@@ -20,3 +20,5 @@ ENTRY(_set_bit_be)
20 eor r0, r0, #0x18 @ big endian byte ordering 20 eor r0, r0, #0x18 @ big endian byte ordering
21ENTRY(_set_bit_le) 21ENTRY(_set_bit_le)
22 bitop orr 22 bitop orr
23ENDPROC(_set_bit_be)
24ENDPROC(_set_bit_le)
diff --git a/arch/arm/lib/sha1.S b/arch/arm/lib/sha1.S
index 67c2bf4774b7..a16fb208c841 100644
--- a/arch/arm/lib/sha1.S
+++ b/arch/arm/lib/sha1.S
@@ -185,6 +185,8 @@ ENTRY(sha_transform)
185 185
186 ldmfd sp!, {r4 - r8, pc} 186 ldmfd sp!, {r4 - r8, pc}
187 187
188ENDPROC(sha_transform)
189
188.L_sha_K: 190.L_sha_K:
189 .word 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 191 .word 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6
190 192
@@ -204,3 +206,4 @@ ENTRY(sha_init)
204 stmia r0, {r1, r2, r3, ip, lr} 206 stmia r0, {r1, r2, r3, ip, lr}
205 ldr pc, [sp], #4 207 ldr pc, [sp], #4
206 208
209ENDPROC(sha_init)
diff --git a/arch/arm/lib/strchr.S b/arch/arm/lib/strchr.S
index 9f18d6fdee6a..d8f2a1c1aea4 100644
--- a/arch/arm/lib/strchr.S
+++ b/arch/arm/lib/strchr.S
@@ -24,3 +24,4 @@ ENTRY(strchr)
24 movne r0, #0 24 movne r0, #0
25 subeq r0, r0, #1 25 subeq r0, r0, #1
26 mov pc, lr 26 mov pc, lr
27ENDPROC(strchr)
diff --git a/arch/arm/lib/strncpy_from_user.S b/arch/arm/lib/strncpy_from_user.S
index 36e3741a3772..330373c26dd9 100644
--- a/arch/arm/lib/strncpy_from_user.S
+++ b/arch/arm/lib/strncpy_from_user.S
@@ -31,6 +31,7 @@ USER( ldrplbt r3, [r1], #1)
31 sub r1, r1, #1 @ take NUL character out of count 31 sub r1, r1, #1 @ take NUL character out of count
322: sub r0, r1, ip 322: sub r0, r1, ip
33 mov pc, lr 33 mov pc, lr
34ENDPROC(__strncpy_from_user)
34 35
35 .section .fixup,"ax" 36 .section .fixup,"ax"
36 .align 0 37 .align 0
diff --git a/arch/arm/lib/strnlen_user.S b/arch/arm/lib/strnlen_user.S
index 18d8fa4f925a..90bb9d020836 100644
--- a/arch/arm/lib/strnlen_user.S
+++ b/arch/arm/lib/strnlen_user.S
@@ -31,6 +31,7 @@ USER( ldrbt r3, [r0], #1)
31 add r0, r0, #1 31 add r0, r0, #1
322: sub r0, r0, r2 322: sub r0, r0, r2
33 mov pc, lr 33 mov pc, lr
34ENDPROC(__strnlen_user)
34 35
35 .section .fixup,"ax" 36 .section .fixup,"ax"
36 .align 0 37 .align 0
diff --git a/arch/arm/lib/strrchr.S b/arch/arm/lib/strrchr.S
index 538df220aa48..302f20cd2423 100644
--- a/arch/arm/lib/strrchr.S
+++ b/arch/arm/lib/strrchr.S
@@ -23,3 +23,4 @@ ENTRY(strrchr)
23 bne 1b 23 bne 1b
24 mov r0, r3 24 mov r0, r3
25 mov pc, lr 25 mov pc, lr
26ENDPROC(strrchr)
diff --git a/arch/arm/lib/testchangebit.S b/arch/arm/lib/testchangebit.S
index b25dcd2be53e..5c98dc567f0f 100644
--- a/arch/arm/lib/testchangebit.S
+++ b/arch/arm/lib/testchangebit.S
@@ -16,3 +16,5 @@ ENTRY(_test_and_change_bit_be)
16 eor r0, r0, #0x18 @ big endian byte ordering 16 eor r0, r0, #0x18 @ big endian byte ordering
17ENTRY(_test_and_change_bit_le) 17ENTRY(_test_and_change_bit_le)
18 testop eor, strb 18 testop eor, strb
19ENDPROC(_test_and_change_bit_be)
20ENDPROC(_test_and_change_bit_le)
diff --git a/arch/arm/lib/testclearbit.S b/arch/arm/lib/testclearbit.S
index 2dcc4b16b68e..543d7094d18e 100644
--- a/arch/arm/lib/testclearbit.S
+++ b/arch/arm/lib/testclearbit.S
@@ -16,3 +16,5 @@ ENTRY(_test_and_clear_bit_be)
16 eor r0, r0, #0x18 @ big endian byte ordering 16 eor r0, r0, #0x18 @ big endian byte ordering
17ENTRY(_test_and_clear_bit_le) 17ENTRY(_test_and_clear_bit_le)
18 testop bicne, strneb 18 testop bicne, strneb
19ENDPROC(_test_and_clear_bit_be)
20ENDPROC(_test_and_clear_bit_le)
diff --git a/arch/arm/lib/testsetbit.S b/arch/arm/lib/testsetbit.S
index 9011c969761a..0b3f390401ce 100644
--- a/arch/arm/lib/testsetbit.S
+++ b/arch/arm/lib/testsetbit.S
@@ -16,3 +16,5 @@ ENTRY(_test_and_set_bit_be)
16 eor r0, r0, #0x18 @ big endian byte ordering 16 eor r0, r0, #0x18 @ big endian byte ordering
17ENTRY(_test_and_set_bit_le) 17ENTRY(_test_and_set_bit_le)
18 testop orreq, streqb 18 testop orreq, streqb
19ENDPROC(_test_and_set_bit_be)
20ENDPROC(_test_and_set_bit_le)
diff --git a/arch/arm/lib/uaccess.S b/arch/arm/lib/uaccess.S
index b48bd6d5fd83..ffdd27498cee 100644
--- a/arch/arm/lib/uaccess.S
+++ b/arch/arm/lib/uaccess.S
@@ -277,6 +277,7 @@ USER( strgebt r3, [r0], #1) @ May fault
277 ldrgtb r3, [r1], #0 277 ldrgtb r3, [r1], #0
278USER( strgtbt r3, [r0], #1) @ May fault 278USER( strgtbt r3, [r0], #1) @ May fault
279 b .Lc2u_finished 279 b .Lc2u_finished
280ENDPROC(__copy_to_user)
280 281
281 .section .fixup,"ax" 282 .section .fixup,"ax"
282 .align 0 283 .align 0
@@ -542,6 +543,7 @@ USER( ldrgebt r3, [r1], #1) @ May fault
542USER( ldrgtbt r3, [r1], #1) @ May fault 543USER( ldrgtbt r3, [r1], #1) @ May fault
543 strgtb r3, [r0], #1 544 strgtb r3, [r0], #1
544 b .Lcfu_finished 545 b .Lcfu_finished
546ENDPROC(__copy_from_user)
545 547
546 .section .fixup,"ax" 548 .section .fixup,"ax"
547 .align 0 549 .align 0
diff --git a/arch/arm/lib/ucmpdi2.S b/arch/arm/lib/ucmpdi2.S
index f76de07ac182..f0df6a91db04 100644
--- a/arch/arm/lib/ucmpdi2.S
+++ b/arch/arm/lib/ucmpdi2.S
@@ -33,6 +33,8 @@ ENTRY(__ucmpdi2)
33 movhi r0, #2 33 movhi r0, #2
34 mov pc, lr 34 mov pc, lr
35 35
36ENDPROC(__ucmpdi2)
37
36#ifdef CONFIG_AEABI 38#ifdef CONFIG_AEABI
37 39
38ENTRY(__aeabi_ulcmp) 40ENTRY(__aeabi_ulcmp)
@@ -44,5 +46,7 @@ ENTRY(__aeabi_ulcmp)
44 movhi r0, #1 46 movhi r0, #1
45 mov pc, lr 47 mov pc, lr
46 48
49ENDPROC(__aeabi_ulcmp)
50
47#endif 51#endif
48 52
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index a048b92cb407..5aafb2e2ca7a 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -175,6 +175,15 @@ config MACH_SAM9_L9260
175 Select this if you are using Olimex's SAM9-L9260 board based on the Atmel AT91SAM9260. 175 Select this if you are using Olimex's SAM9-L9260 board based on the Atmel AT91SAM9260.
176 <http://www.olimex.com/dev/sam9-L9260.html> 176 <http://www.olimex.com/dev/sam9-L9260.html>
177 177
178config MACH_AFEB9260
179 bool "Custom afeb9260 board v1"
180 depends on ARCH_AT91SAM9260
181 help
182 Select this if you are using custom afeb9260 board based on
183 open hardware design. Select this for revision 1 of the board.
184 <svn://194.85.238.22/home/users/george/svn/arm9eb>
185 <http://groups.google.com/group/arm9fpga-evolution-board>
186
178config MACH_USB_A9260 187config MACH_USB_A9260
179 bool "CALAO USB-A9260" 188 bool "CALAO USB-A9260"
180 depends on ARCH_AT91SAM9260 189 depends on ARCH_AT91SAM9260
@@ -314,6 +323,19 @@ config AT91_PROGRAMMABLE_CLOCKS
314 Select this if you need to program one or more of the PCK0..PCK3 323 Select this if you need to program one or more of the PCK0..PCK3
315 programmable clock outputs. 324 programmable clock outputs.
316 325
326config AT91_SLOW_CLOCK
327 bool "Suspend-to-RAM disables main oscillator"
328 depends on SUSPEND
329 help
330 Select this if you want Suspend-to-RAM to save the most power
331 possible (without powering off the CPU) by disabling the PLLs
332 and main oscillator so that only the 32 KiHz clock is available.
333
334 When only that slow-clock is available, some peripherals lose
335 functionality. Many can't issue wakeup events unless faster
336 clocks are available. Some lose their operating state and
337 need to be completely re-initialized.
338
317config AT91_TIMER_HZ 339config AT91_TIMER_HZ
318 int "Kernel HZ (jiffies per second)" 340 int "Kernel HZ (jiffies per second)"
319 range 32 1024 341 range 32 1024
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 7d641f97516b..cca612d97ca2 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_MACH_CAM60) += board-cam60.o
39obj-$(CONFIG_MACH_SAM9_L9260) += board-sam9-l9260.o 39obj-$(CONFIG_MACH_SAM9_L9260) += board-sam9-l9260.o
40obj-$(CONFIG_MACH_USB_A9260) += board-usb-a9260.o 40obj-$(CONFIG_MACH_USB_A9260) += board-usb-a9260.o
41obj-$(CONFIG_MACH_QIL_A9260) += board-qil-a9260.o 41obj-$(CONFIG_MACH_QIL_A9260) += board-qil-a9260.o
42obj-$(CONFIG_MACH_AFEB9260) += board-afeb-9260v1.o
42 43
43# AT91SAM9261 board-specific support 44# AT91SAM9261 board-specific support
44obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o 45obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o
@@ -64,6 +65,7 @@ obj-y += leds.o
64 65
65# Power Management 66# Power Management
66obj-$(CONFIG_PM) += pm.o 67obj-$(CONFIG_PM) += pm.o
68obj-$(CONFIG_AT91_SLOW_CLOCK) += pm_slowclock.o
67 69
68ifeq ($(CONFIG_PM_DEBUG),y) 70ifeq ($(CONFIG_PM_DEBUG),y)
69CFLAGS_pm.o += -DDEBUG 71CFLAGS_pm.o += -DDEBUG
diff --git a/arch/arm/mach-at91/at91cap9.c b/arch/arm/mach-at91/at91cap9.c
index 638948c16770..0fc0adaebd58 100644
--- a/arch/arm/mach-at91/at91cap9.c
+++ b/arch/arm/mach-at91/at91cap9.c
@@ -141,8 +141,8 @@ static struct clk tcb_clk = {
141 .pmc_mask = 1 << AT91CAP9_ID_TCB, 141 .pmc_mask = 1 << AT91CAP9_ID_TCB,
142 .type = CLK_TYPE_PERIPHERAL, 142 .type = CLK_TYPE_PERIPHERAL,
143}; 143};
144static struct clk pwmc_clk = { 144static struct clk pwm_clk = {
145 .name = "pwmc_clk", 145 .name = "pwm_clk",
146 .pmc_mask = 1 << AT91CAP9_ID_PWMC, 146 .pmc_mask = 1 << AT91CAP9_ID_PWMC,
147 .type = CLK_TYPE_PERIPHERAL, 147 .type = CLK_TYPE_PERIPHERAL,
148}; 148};
@@ -207,7 +207,7 @@ static struct clk *periph_clocks[] __initdata = {
207 &ssc1_clk, 207 &ssc1_clk,
208 &ac97_clk, 208 &ac97_clk,
209 &tcb_clk, 209 &tcb_clk,
210 &pwmc_clk, 210 &pwm_clk,
211 &macb_clk, 211 &macb_clk,
212 &aestdes_clk, 212 &aestdes_clk,
213 &adc_clk, 213 &adc_clk,
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index abb4aac8fa98..5ebd4273d353 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -719,6 +719,60 @@ static void __init at91_add_device_watchdog(void) {}
719 719
720 720
721/* -------------------------------------------------------------------- 721/* --------------------------------------------------------------------
722 * PWM
723 * --------------------------------------------------------------------*/
724
725#if defined(CONFIG_ATMEL_PWM)
726static u32 pwm_mask;
727
728static struct resource pwm_resources[] = {
729 [0] = {
730 .start = AT91CAP9_BASE_PWMC,
731 .end = AT91CAP9_BASE_PWMC + SZ_16K - 1,
732 .flags = IORESOURCE_MEM,
733 },
734 [1] = {
735 .start = AT91CAP9_ID_PWMC,
736 .end = AT91CAP9_ID_PWMC,
737 .flags = IORESOURCE_IRQ,
738 },
739};
740
741static struct platform_device at91cap9_pwm0_device = {
742 .name = "atmel_pwm",
743 .id = -1,
744 .dev = {
745 .platform_data = &pwm_mask,
746 },
747 .resource = pwm_resources,
748 .num_resources = ARRAY_SIZE(pwm_resources),
749};
750
751void __init at91_add_device_pwm(u32 mask)
752{
753 if (mask & (1 << AT91_PWM0))
754 at91_set_A_periph(AT91_PIN_PB19, 1); /* enable PWM0 */
755
756 if (mask & (1 << AT91_PWM1))
757 at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM1 */
758
759 if (mask & (1 << AT91_PWM2))
760 at91_set_B_periph(AT91_PIN_PC29, 1); /* enable PWM2 */
761
762 if (mask & (1 << AT91_PWM3))
763 at91_set_B_periph(AT91_PIN_PA11, 1); /* enable PWM3 */
764
765 pwm_mask = mask;
766
767 platform_device_register(&at91cap9_pwm0_device);
768}
769#else
770void __init at91_add_device_pwm(u32 mask) {}
771#endif
772
773
774
775/* --------------------------------------------------------------------
722 * AC97 776 * AC97
723 * -------------------------------------------------------------------- */ 777 * -------------------------------------------------------------------- */
724 778
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 80bfab5680e2..ada4b6769107 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -129,8 +129,8 @@ static struct clk tcb_clk = {
129 .pmc_mask = 1 << AT91SAM9263_ID_TCB, 129 .pmc_mask = 1 << AT91SAM9263_ID_TCB,
130 .type = CLK_TYPE_PERIPHERAL, 130 .type = CLK_TYPE_PERIPHERAL,
131}; 131};
132static struct clk pwmc_clk = { 132static struct clk pwm_clk = {
133 .name = "pwmc_clk", 133 .name = "pwm_clk",
134 .pmc_mask = 1 << AT91SAM9263_ID_PWMC, 134 .pmc_mask = 1 << AT91SAM9263_ID_PWMC,
135 .type = CLK_TYPE_PERIPHERAL, 135 .type = CLK_TYPE_PERIPHERAL,
136}; 136};
@@ -187,7 +187,7 @@ static struct clk *periph_clocks[] __initdata = {
187 &ssc1_clk, 187 &ssc1_clk,
188 &ac97_clk, 188 &ac97_clk,
189 &tcb_clk, 189 &tcb_clk,
190 &pwmc_clk, 190 &pwm_clk,
191 &macb_clk, 191 &macb_clk,
192 &twodge_clk, 192 &twodge_clk,
193 &udc_clk, 193 &udc_clk,
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index c93992f55dc9..8b884083f76d 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -886,6 +886,59 @@ static void __init at91_add_device_watchdog(void) {}
886 886
887 887
888/* -------------------------------------------------------------------- 888/* --------------------------------------------------------------------
889 * PWM
890 * --------------------------------------------------------------------*/
891
892#if defined(CONFIG_ATMEL_PWM)
893static u32 pwm_mask;
894
895static struct resource pwm_resources[] = {
896 [0] = {
897 .start = AT91SAM9263_BASE_PWMC,
898 .end = AT91SAM9263_BASE_PWMC + SZ_16K - 1,
899 .flags = IORESOURCE_MEM,
900 },
901 [1] = {
902 .start = AT91SAM9263_ID_PWMC,
903 .end = AT91SAM9263_ID_PWMC,
904 .flags = IORESOURCE_IRQ,
905 },
906};
907
908static struct platform_device at91sam9263_pwm0_device = {
909 .name = "atmel_pwm",
910 .id = -1,
911 .dev = {
912 .platform_data = &pwm_mask,
913 },
914 .resource = pwm_resources,
915 .num_resources = ARRAY_SIZE(pwm_resources),
916};
917
918void __init at91_add_device_pwm(u32 mask)
919{
920 if (mask & (1 << AT91_PWM0))
921 at91_set_B_periph(AT91_PIN_PB7, 1); /* enable PWM0 */
922
923 if (mask & (1 << AT91_PWM1))
924 at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM1 */
925
926 if (mask & (1 << AT91_PWM2))
927 at91_set_B_periph(AT91_PIN_PC29, 1); /* enable PWM2 */
928
929 if (mask & (1 << AT91_PWM3))
930 at91_set_B_periph(AT91_PIN_PB29, 1); /* enable PWM3 */
931
932 pwm_mask = mask;
933
934 platform_device_register(&at91sam9263_pwm0_device);
935}
936#else
937void __init at91_add_device_pwm(u32 mask) {}
938#endif
939
940
941/* --------------------------------------------------------------------
889 * SSC -- Synchronous Serial Controller 942 * SSC -- Synchronous Serial Controller
890 * -------------------------------------------------------------------- */ 943 * -------------------------------------------------------------------- */
891 944
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 556bddf35b45..252e954b49fd 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -131,8 +131,8 @@ static struct clk tc2_clk = {
131 .pmc_mask = 1 << AT91SAM9RL_ID_TC2, 131 .pmc_mask = 1 << AT91SAM9RL_ID_TC2,
132 .type = CLK_TYPE_PERIPHERAL, 132 .type = CLK_TYPE_PERIPHERAL,
133}; 133};
134static struct clk pwmc_clk = { 134static struct clk pwm_clk = {
135 .name = "pwmc_clk", 135 .name = "pwm_clk",
136 .pmc_mask = 1 << AT91SAM9RL_ID_PWMC, 136 .pmc_mask = 1 << AT91SAM9RL_ID_PWMC,
137 .type = CLK_TYPE_PERIPHERAL, 137 .type = CLK_TYPE_PERIPHERAL,
138}; 138};
@@ -180,7 +180,7 @@ static struct clk *periph_clocks[] __initdata = {
180 &tc0_clk, 180 &tc0_clk,
181 &tc1_clk, 181 &tc1_clk,
182 &tc2_clk, 182 &tc2_clk,
183 &pwmc_clk, 183 &pwm_clk,
184 &tsc_clk, 184 &tsc_clk,
185 &dma_clk, 185 &dma_clk,
186 &udphs_clk, 186 &udphs_clk,
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 620886341fb5..87deb1e1b529 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -527,6 +527,51 @@ static void __init at91_add_device_tc(void) { }
527 527
528 528
529/* -------------------------------------------------------------------- 529/* --------------------------------------------------------------------
530 * Touchscreen
531 * -------------------------------------------------------------------- */
532
533#if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE)
534static u64 tsadcc_dmamask = DMA_BIT_MASK(32);
535
536static struct resource tsadcc_resources[] = {
537 [0] = {
538 .start = AT91SAM9RL_BASE_TSC,
539 .end = AT91SAM9RL_BASE_TSC + SZ_16K - 1,
540 .flags = IORESOURCE_MEM,
541 },
542 [1] = {
543 .start = AT91SAM9RL_ID_TSC,
544 .end = AT91SAM9RL_ID_TSC,
545 .flags = IORESOURCE_IRQ,
546 }
547};
548
549static struct platform_device at91sam9rl_tsadcc_device = {
550 .name = "atmel_tsadcc",
551 .id = -1,
552 .dev = {
553 .dma_mask = &tsadcc_dmamask,
554 .coherent_dma_mask = DMA_BIT_MASK(32),
555 },
556 .resource = tsadcc_resources,
557 .num_resources = ARRAY_SIZE(tsadcc_resources),
558};
559
560void __init at91_add_device_tsadcc(void)
561{
562 at91_set_A_periph(AT91_PIN_PA17, 0); /* AD0_XR */
563 at91_set_A_periph(AT91_PIN_PA18, 0); /* AD1_XL */
564 at91_set_A_periph(AT91_PIN_PA19, 0); /* AD2_YT */
565 at91_set_A_periph(AT91_PIN_PA20, 0); /* AD3_TB */
566
567 platform_device_register(&at91sam9rl_tsadcc_device);
568}
569#else
570void __init at91_add_device_tsadcc(void) {}
571#endif
572
573
574/* --------------------------------------------------------------------
530 * RTC 575 * RTC
531 * -------------------------------------------------------------------- */ 576 * -------------------------------------------------------------------- */
532 577
@@ -592,6 +637,59 @@ static void __init at91_add_device_watchdog(void) {}
592 637
593 638
594/* -------------------------------------------------------------------- 639/* --------------------------------------------------------------------
640 * PWM
641 * --------------------------------------------------------------------*/
642
643#if defined(CONFIG_ATMEL_PWM)
644static u32 pwm_mask;
645
646static struct resource pwm_resources[] = {
647 [0] = {
648 .start = AT91SAM9RL_BASE_PWMC,
649 .end = AT91SAM9RL_BASE_PWMC + SZ_16K - 1,
650 .flags = IORESOURCE_MEM,
651 },
652 [1] = {
653 .start = AT91SAM9RL_ID_PWMC,
654 .end = AT91SAM9RL_ID_PWMC,
655 .flags = IORESOURCE_IRQ,
656 },
657};
658
659static struct platform_device at91sam9rl_pwm0_device = {
660 .name = "atmel_pwm",
661 .id = -1,
662 .dev = {
663 .platform_data = &pwm_mask,
664 },
665 .resource = pwm_resources,
666 .num_resources = ARRAY_SIZE(pwm_resources),
667};
668
669void __init at91_add_device_pwm(u32 mask)
670{
671 if (mask & (1 << AT91_PWM0))
672 at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM0 */
673
674 if (mask & (1 << AT91_PWM1))
675 at91_set_B_periph(AT91_PIN_PB9, 1); /* enable PWM1 */
676
677 if (mask & (1 << AT91_PWM2))
678 at91_set_B_periph(AT91_PIN_PD5, 1); /* enable PWM2 */
679
680 if (mask & (1 << AT91_PWM3))
681 at91_set_B_periph(AT91_PIN_PD8, 1); /* enable PWM3 */
682
683 pwm_mask = mask;
684
685 platform_device_register(&at91sam9rl_pwm0_device);
686}
687#else
688void __init at91_add_device_pwm(u32 mask) {}
689#endif
690
691
692/* --------------------------------------------------------------------
595 * SSC -- Synchronous Serial Controller 693 * SSC -- Synchronous Serial Controller
596 * -------------------------------------------------------------------- */ 694 * -------------------------------------------------------------------- */
597 695
diff --git a/arch/arm/mach-at91/at91x40_time.c b/arch/arm/mach-at91/at91x40_time.c
index 869b5e28d195..dfff2895f4b2 100644
--- a/arch/arm/mach-at91/at91x40_time.c
+++ b/arch/arm/mach-at91/at91x40_time.c
@@ -23,8 +23,8 @@
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/time.h> 25#include <linux/time.h>
26#include <linux/io.h>
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/io.h>
28#include <asm/mach/time.h> 28#include <asm/mach/time.h>
29#include <mach/at91_tc.h> 29#include <mach/at91_tc.h>
30 30
diff --git a/arch/arm/mach-at91/board-afeb-9260v1.c b/arch/arm/mach-at91/board-afeb-9260v1.c
new file mode 100644
index 000000000000..9c040c78889a
--- /dev/null
+++ b/arch/arm/mach-at91/board-afeb-9260v1.c
@@ -0,0 +1,210 @@
1/*
2 * linux/arch/arm/mach-at91/board-afeb-9260v1.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2006 Atmel
6 * Copyright (C) 2008 Sergey Lapin
7 *
8 * A custom board designed as open hardware; PCBs and various information
9 * is available at http://groups.google.com/group/arm9fpga-evolution-board/
10 * Subversion repository: svn://194.85.238.22/home/users/george/svn/arm9eb
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27#include <linux/types.h>
28#include <linux/init.h>
29#include <linux/mm.h>
30#include <linux/module.h>
31#include <linux/platform_device.h>
32#include <linux/spi/spi.h>
33#include <linux/clk.h>
34#include <linux/dma-mapping.h>
35
36#include <mach/hardware.h>
37#include <asm/setup.h>
38#include <asm/mach-types.h>
39#include <asm/irq.h>
40
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
43#include <asm/mach/irq.h>
44
45#include <mach/board.h>
46#include <mach/gpio.h>
47
48#include "generic.h"
49
50
51static void __init afeb9260_map_io(void)
52{
53 /* Initialize processor: 18.432 MHz crystal */
54 at91sam9260_initialize(18432000);
55
56 /* DGBU on ttyS0. (Rx & Tx only) */
57 at91_register_uart(0, 0, 0);
58
59 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
60 at91_register_uart(AT91SAM9260_ID_US0, 1,
61 ATMEL_UART_CTS | ATMEL_UART_RTS
62 | ATMEL_UART_DTR | ATMEL_UART_DSR
63 | ATMEL_UART_DCD | ATMEL_UART_RI);
64
65 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
66 at91_register_uart(AT91SAM9260_ID_US1, 2,
67 ATMEL_UART_CTS | ATMEL_UART_RTS);
68
69 /* set serial console to ttyS0 (ie, DBGU) */
70 at91_set_serial_console(0);
71}
72
73static void __init afeb9260_init_irq(void)
74{
75 at91sam9260_init_interrupts(NULL);
76}
77
78
79/*
80 * USB Host port
81 */
82static struct at91_usbh_data __initdata afeb9260_usbh_data = {
83 .ports = 1,
84};
85
86/*
87 * USB Device port
88 */
89static struct at91_udc_data __initdata afeb9260_udc_data = {
90 .vbus_pin = AT91_PIN_PC5,
91 .pullup_pin = 0, /* pull-up driven by UDC */
92};
93
94
95
96/*
97 * SPI devices.
98 */
99static struct spi_board_info afeb9260_spi_devices[] = {
100 { /* DataFlash chip */
101 .modalias = "mtd_dataflash",
102 .chip_select = 1,
103 .max_speed_hz = 15 * 1000 * 1000,
104 .bus_num = 0,
105 },
106};
107
108
109/*
110 * MACB Ethernet device
111 */
112static struct at91_eth_data __initdata afeb9260_macb_data = {
113 .phy_irq_pin = AT91_PIN_PA9,
114 .is_rmii = 0,
115};
116
117
118/*
119 * NAND flash
120 */
121static struct mtd_partition __initdata afeb9260_nand_partition[] = {
122 {
123 .name = "bootloader",
124 .offset = 0,
125 .size = (640 * SZ_1K),
126 },
127 {
128 .name = "kernel",
129 .offset = MTDPART_OFS_NXTBLK,
130 .size = SZ_2M,
131 },
132 {
133 .name = "rootfs",
134 .offset = MTDPART_OFS_NXTBLK,
135 .size = MTDPART_SIZ_FULL,
136 },
137};
138
139static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
140{
141 *num_partitions = ARRAY_SIZE(afeb9260_nand_partition);
142 return afeb9260_nand_partition;
143}
144
145static struct atmel_nand_data __initdata afeb9260_nand_data = {
146 .ale = 21,
147 .cle = 22,
148 .rdy_pin = AT91_PIN_PC13,
149 .enable_pin = AT91_PIN_PC14,
150 .partition_info = nand_partitions,
151 .bus_width_16 = 0,
152};
153
154
155/*
156 * MCI (SD/MMC)
157 */
158static struct at91_mmc_data __initdata afeb9260_mmc_data = {
159 .slot_b = 1,
160 .wire4 = 1,
161};
162
163
164
165static struct i2c_board_info __initdata afeb9260_i2c_devices[] = {
166 {
167 I2C_BOARD_INFO("fm3130", 0x68),
168 I2C_BOARD_INFO("24c64", 0x50),
169 },
170};
171
172static void __init afeb9260_board_init(void)
173{
174 /* Serial */
175 at91_add_device_serial();
176 /* USB Host */
177 at91_add_device_usbh(&afeb9260_usbh_data);
178 /* USB Device */
179 at91_add_device_udc(&afeb9260_udc_data);
180 /* SPI */
181 at91_add_device_spi(afeb9260_spi_devices,
182 ARRAY_SIZE(afeb9260_spi_devices));
183 /* NAND */
184 at91_add_device_nand(&afeb9260_nand_data);
185 /* Ethernet */
186 at91_add_device_eth(&afeb9260_macb_data);
187
188 /* Standard function's pin assignments are not
189 * appropriate for us and generic code provide
190 * no API to configure these pins any other way */
191 at91_set_B_periph(AT91_PIN_PA10, 0); /* ETX2 */
192 at91_set_B_periph(AT91_PIN_PA11, 0); /* ETX3 */
193 /* MMC */
194 at91_add_device_mmc(0, &afeb9260_mmc_data);
195 /* I2C */
196 at91_add_device_i2c(afeb9260_i2c_devices,
197 ARRAY_SIZE(afeb9260_i2c_devices));
198}
199
200MACHINE_START(AFEB9260, "Custom afeb9260 board")
201 /* Maintainer: Sergey Lapin <slapin@ossfans.org> */
202 .phys_io = AT91_BASE_SYS,
203 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
204 .boot_params = AT91_SDRAM_BASE + 0x100,
205 .timer = &at91sam926x_timer,
206 .map_io = afeb9260_map_io,
207 .init_irq = afeb9260_init_irq,
208 .init_machine = afeb9260_board_init,
209MACHINE_END
210
diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c
index 196199552eb6..201b89392dcc 100644
--- a/arch/arm/mach-at91/board-cap9adk.c
+++ b/arch/arm/mach-at91/board-cap9adk.c
@@ -214,7 +214,7 @@ static struct physmap_flash_data cap9adk_nor_data = {
214}; 214};
215 215
216#define NOR_BASE AT91_CHIPSELECT_0 216#define NOR_BASE AT91_CHIPSELECT_0
217#define NOR_SIZE 0x800000 217#define NOR_SIZE SZ_8M
218 218
219static struct resource nor_flash_resources[] = { 219static struct resource nor_flash_resources[] = {
220 { 220 {
diff --git a/arch/arm/mach-at91/board-carmeva.c b/arch/arm/mach-at91/board-carmeva.c
index afa1ff0e9577..db1f9544d2e0 100644
--- a/arch/arm/mach-at91/board-carmeva.c
+++ b/arch/arm/mach-at91/board-carmeva.c
@@ -25,7 +25,6 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27 27
28#include <mach/hardware.h>
29#include <asm/setup.h> 28#include <asm/setup.h>
30#include <asm/mach-types.h> 29#include <asm/mach-types.h>
31#include <asm/irq.h> 30#include <asm/irq.h>
@@ -34,6 +33,7 @@
34#include <asm/mach/map.h> 33#include <asm/mach/map.h>
35#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
36 35
36#include <mach/hardware.h>
37#include <mach/board.h> 37#include <mach/board.h>
38#include <mach/gpio.h> 38#include <mach/gpio.h>
39 39
@@ -114,6 +114,30 @@ static struct spi_board_info carmeva_spi_devices[] = {
114 }, 114 },
115}; 115};
116 116
117static struct gpio_led carmeva_leds[] = {
118 { /* "user led 1", LED9 */
119 .name = "led9",
120 .gpio = AT91_PIN_PA21,
121 .active_low = 1,
122 .default_trigger = "heartbeat",
123 },
124 { /* "user led 2", LED10 */
125 .name = "led10",
126 .gpio = AT91_PIN_PA25,
127 .active_low = 1,
128 },
129 { /* "user led 3", LED11 */
130 .name = "led11",
131 .gpio = AT91_PIN_PA26,
132 .active_low = 1,
133 },
134 { /* "user led 4", LED12 */
135 .name = "led12",
136 .gpio = AT91_PIN_PA18,
137 .active_low = 1,
138 }
139};
140
117static void __init carmeva_board_init(void) 141static void __init carmeva_board_init(void)
118{ 142{
119 /* Serial */ 143 /* Serial */
@@ -132,6 +156,8 @@ static void __init carmeva_board_init(void)
132// at91_add_device_cf(&carmeva_cf_data); 156// at91_add_device_cf(&carmeva_cf_data);
133 /* MMC */ 157 /* MMC */
134 at91_add_device_mmc(0, &carmeva_mmc_data); 158 at91_add_device_mmc(0, &carmeva_mmc_data);
159 /* LEDs */
160 at91_gpio_leds(carmeva_leds, ARRAY_SIZE(carmeva_leds));
135} 161}
136 162
137MACHINE_START(CARMEVA, "Carmeva") 163MACHINE_START(CARMEVA, "Carmeva")
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index cb7c9a8fa487..fea2529ebcf9 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -28,7 +28,6 @@
28#include <linux/input.h> 28#include <linux/input.h>
29#include <linux/gpio_keys.h> 29#include <linux/gpio_keys.h>
30 30
31#include <mach/hardware.h>
32#include <asm/setup.h> 31#include <asm/setup.h>
33#include <asm/mach-types.h> 32#include <asm/mach-types.h>
34#include <asm/irq.h> 33#include <asm/irq.h>
@@ -37,6 +36,7 @@
37#include <asm/mach/map.h> 36#include <asm/mach/map.h>
38#include <asm/mach/irq.h> 37#include <asm/mach/irq.h>
39 38
39#include <mach/hardware.h>
40#include <mach/board.h> 40#include <mach/board.h>
41#include <mach/gpio.h> 41#include <mach/gpio.h>
42 42
@@ -114,7 +114,7 @@ static struct spi_board_info csb337_spi_devices[] = {
114}; 114};
115 115
116#define CSB_FLASH_BASE AT91_CHIPSELECT_0 116#define CSB_FLASH_BASE AT91_CHIPSELECT_0
117#define CSB_FLASH_SIZE 0x800000 117#define CSB_FLASH_SIZE SZ_8M
118 118
119static struct mtd_partition csb_flash_partitions[] = { 119static struct mtd_partition csb_flash_partitions[] = {
120 { 120 {
@@ -193,11 +193,11 @@ static struct platform_device csb300_button_device = {
193 193
194static void __init csb300_add_device_buttons(void) 194static void __init csb300_add_device_buttons(void)
195{ 195{
196 at91_set_gpio_input(AT91_PIN_PB29, 0); /* sw0 */ 196 at91_set_gpio_input(AT91_PIN_PB29, 1); /* sw0 */
197 at91_set_deglitch(AT91_PIN_PB29, 1); 197 at91_set_deglitch(AT91_PIN_PB29, 1);
198 at91_set_gpio_input(AT91_PIN_PB28, 0); /* sw1 */ 198 at91_set_gpio_input(AT91_PIN_PB28, 1); /* sw1 */
199 at91_set_deglitch(AT91_PIN_PB28, 1); 199 at91_set_deglitch(AT91_PIN_PB28, 1);
200 at91_set_gpio_input(AT91_PIN_PA21, 0); /* sw2 */ 200 at91_set_gpio_input(AT91_PIN_PA21, 1); /* sw2 */
201 at91_set_deglitch(AT91_PIN_PA21, 1); 201 at91_set_deglitch(AT91_PIN_PA21, 1);
202 202
203 platform_device_register(&csb300_button_device); 203 platform_device_register(&csb300_button_device);
@@ -224,7 +224,7 @@ static struct gpio_led csb_leds[] = {
224 .gpio = AT91_PIN_PB0, 224 .gpio = AT91_PIN_PB0,
225 .active_low = 1, 225 .active_low = 1,
226 .default_trigger = "ide-disk", 226 .default_trigger = "ide-disk",
227 }, 227 }
228}; 228};
229 229
230 230
diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c
index 8db8bd8babd9..cfa3f04b2205 100644
--- a/arch/arm/mach-at91/board-csb637.c
+++ b/arch/arm/mach-at91/board-csb637.c
@@ -25,7 +25,6 @@
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/mtd/physmap.h> 26#include <linux/mtd/physmap.h>
27 27
28#include <mach/hardware.h>
29#include <asm/setup.h> 28#include <asm/setup.h>
30#include <asm/mach-types.h> 29#include <asm/mach-types.h>
31#include <asm/irq.h> 30#include <asm/irq.h>
@@ -34,6 +33,7 @@
34#include <asm/mach/map.h> 33#include <asm/mach/map.h>
35#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
36 35
36#include <mach/hardware.h>
37#include <mach/board.h> 37#include <mach/board.h>
38#include <mach/gpio.h> 38#include <mach/gpio.h>
39 39
@@ -72,7 +72,7 @@ static struct at91_udc_data __initdata csb637_udc_data = {
72}; 72};
73 73
74#define CSB_FLASH_BASE AT91_CHIPSELECT_0 74#define CSB_FLASH_BASE AT91_CHIPSELECT_0
75#define CSB_FLASH_SIZE 0x1000000 75#define CSB_FLASH_SIZE SZ_16M
76 76
77static struct mtd_partition csb_flash_partitions[] = { 77static struct mtd_partition csb_flash_partitions[] = {
78 { 78 {
diff --git a/arch/arm/mach-at91/board-dk.c b/arch/arm/mach-at91/board-dk.c
index 43e1aa7ecef7..0fd0f5bc77ea 100644
--- a/arch/arm/mach-at91/board-dk.c
+++ b/arch/arm/mach-at91/board-dk.c
@@ -29,7 +29,6 @@
29#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
30#include <linux/mtd/physmap.h> 30#include <linux/mtd/physmap.h>
31 31
32#include <mach/hardware.h>
33#include <asm/setup.h> 32#include <asm/setup.h>
34#include <asm/mach-types.h> 33#include <asm/mach-types.h>
35#include <asm/irq.h> 34#include <asm/irq.h>
@@ -38,6 +37,7 @@
38#include <asm/mach/map.h> 37#include <asm/mach/map.h>
39#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
40 39
40#include <mach/hardware.h>
41#include <mach/board.h> 41#include <mach/board.h>
42#include <mach/gpio.h> 42#include <mach/gpio.h>
43#include <mach/at91rm9200_mc.h> 43#include <mach/at91rm9200_mc.h>
@@ -157,7 +157,7 @@ static struct atmel_nand_data __initdata dk_nand_data = {
157}; 157};
158 158
159#define DK_FLASH_BASE AT91_CHIPSELECT_0 159#define DK_FLASH_BASE AT91_CHIPSELECT_0
160#define DK_FLASH_SIZE 0x200000 160#define DK_FLASH_SIZE SZ_2M
161 161
162static struct physmap_flash_data dk_flash_data = { 162static struct physmap_flash_data dk_flash_data = {
163 .width = 2, 163 .width = 2,
diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c
index bfeee8a2af28..1d69908617f0 100644
--- a/arch/arm/mach-at91/board-ecbat91.c
+++ b/arch/arm/mach-at91/board-ecbat91.c
@@ -86,7 +86,7 @@ static struct mtd_partition __initdata my_flash0_partitions[] =
86 { /* 0x8400 */ 86 { /* 0x8400 */
87 .name = "Darrell-loader", 87 .name = "Darrell-loader",
88 .offset = 0, 88 .offset = 0,
89 .size = 12* 1056, 89 .size = 12 * 1056,
90 }, 90 },
91 { 91 {
92 .name = "U-boot", 92 .name = "U-boot",
diff --git a/arch/arm/mach-at91/board-ek.c b/arch/arm/mach-at91/board-ek.c
index 60626e7a3490..4cdfaac8e590 100644
--- a/arch/arm/mach-at91/board-ek.c
+++ b/arch/arm/mach-at91/board-ek.c
@@ -29,7 +29,6 @@
29#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
30#include <linux/mtd/physmap.h> 30#include <linux/mtd/physmap.h>
31 31
32#include <mach/hardware.h>
33#include <asm/setup.h> 32#include <asm/setup.h>
34#include <asm/mach-types.h> 33#include <asm/mach-types.h>
35#include <asm/irq.h> 34#include <asm/irq.h>
@@ -38,6 +37,7 @@
38#include <asm/mach/map.h> 37#include <asm/mach/map.h>
39#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
40 39
40#include <mach/hardware.h>
41#include <mach/board.h> 41#include <mach/board.h>
42#include <mach/gpio.h> 42#include <mach/gpio.h>
43#include <mach/at91rm9200_mc.h> 43#include <mach/at91rm9200_mc.h>
@@ -116,7 +116,7 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = {
116}; 116};
117 117
118#define EK_FLASH_BASE AT91_CHIPSELECT_0 118#define EK_FLASH_BASE AT91_CHIPSELECT_0
119#define EK_FLASH_SIZE 0x200000 119#define EK_FLASH_SIZE SZ_2M
120 120
121static struct physmap_flash_data ek_flash_data = { 121static struct physmap_flash_data ek_flash_data = {
122 .width = 2, 122 .width = 2,
diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c
index dbc912d633c7..859727e7ea30 100644
--- a/arch/arm/mach-at91/board-picotux200.c
+++ b/arch/arm/mach-at91/board-picotux200.c
@@ -105,7 +105,7 @@ static struct at91_mmc_data __initdata picotux200_mmc_data = {
105// }; 105// };
106 106
107#define PICOTUX200_FLASH_BASE AT91_CHIPSELECT_0 107#define PICOTUX200_FLASH_BASE AT91_CHIPSELECT_0
108#define PICOTUX200_FLASH_SIZE 0x400000 108#define PICOTUX200_FLASH_SIZE SZ_4M
109 109
110static struct physmap_flash_data picotux200_flash_data = { 110static struct physmap_flash_data picotux200_flash_data = {
111 .width = 2, 111 .width = 2,
diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c
index 4c28413426c2..cfb4571a2e27 100644
--- a/arch/arm/mach-at91/board-qil-a9260.c
+++ b/arch/arm/mach-at91/board-qil-a9260.c
@@ -30,7 +30,6 @@
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/clk.h> 31#include <linux/clk.h>
32 32
33#include <mach/hardware.h>
34#include <asm/setup.h> 33#include <asm/setup.h>
35#include <asm/mach-types.h> 34#include <asm/mach-types.h>
36#include <asm/irq.h> 35#include <asm/irq.h>
@@ -39,6 +38,7 @@
39#include <asm/mach/map.h> 38#include <asm/mach/map.h>
40#include <asm/mach/irq.h> 39#include <asm/mach/irq.h>
41 40
41#include <mach/hardware.h>
42#include <mach/board.h> 42#include <mach/board.h>
43#include <mach/gpio.h> 43#include <mach/gpio.h>
44#include <mach/at91_shdwc.h> 44#include <mach/at91_shdwc.h>
@@ -119,18 +119,18 @@ static struct at91_eth_data __initdata ek_macb_data = {
119static struct mtd_partition __initdata ek_nand_partition[] = { 119static struct mtd_partition __initdata ek_nand_partition[] = {
120 { 120 {
121 .name = "Uboot & Kernel", 121 .name = "Uboot & Kernel",
122 .offset = 0x00000000, 122 .offset = 0,
123 .size = 16 * 1024 * 1024, 123 .size = SZ_16M,
124 }, 124 },
125 { 125 {
126 .name = "Root FS", 126 .name = "Root FS",
127 .offset = 0x01000000, 127 .offset = MTDPART_OFS_NXTBLK,
128 .size = 120 * 1024 * 1024, 128 .size = 120 * SZ_1M,
129 }, 129 },
130 { 130 {
131 .name = "FS", 131 .name = "FS",
132 .offset = 0x08800000, 132 .offset = MTDPART_OFS_NXTBLK,
133 .size = 120 * 1024 * 1024, 133 .size = 120 * SZ_1M,
134 }, 134 },
135}; 135};
136 136
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index e4910cb26c16..99bb4cc23a09 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -126,11 +126,11 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
126 { 126 {
127 .name = "Bootloader Area", 127 .name = "Bootloader Area",
128 .offset = 0, 128 .offset = 0,
129 .size = 10 * 1024 * 1024, 129 .size = 10 * SZ_1M,
130 }, 130 },
131 { 131 {
132 .name = "User Area", 132 .name = "User Area",
133 .offset = 10 * 1024 * 1024, 133 .offset = MTDPART_OFS_NXTBLK,
134 .size = MTDPART_SIZ_FULL, 134 .size = MTDPART_SIZ_FULL,
135 }, 135 },
136}; 136};
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index cb20e70b3b06..b49eb6e4918a 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -27,8 +27,10 @@
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/spi/at73c213.h> 28#include <linux/spi/at73c213.h>
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/i2c/at24.h>
31#include <linux/gpio_keys.h>
32#include <linux/input.h>
30 33
31#include <mach/hardware.h>
32#include <asm/setup.h> 34#include <asm/setup.h>
33#include <asm/mach-types.h> 35#include <asm/mach-types.h>
34#include <asm/irq.h> 36#include <asm/irq.h>
@@ -37,6 +39,7 @@
37#include <asm/mach/map.h> 39#include <asm/mach/map.h>
38#include <asm/mach/irq.h> 40#include <asm/mach/irq.h>
39 41
42#include <mach/hardware.h>
40#include <mach/board.h> 43#include <mach/board.h>
41#include <mach/gpio.h> 44#include <mach/gpio.h>
42 45
@@ -163,11 +166,11 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
163 { 166 {
164 .name = "Partition 1", 167 .name = "Partition 1",
165 .offset = 0, 168 .offset = 0,
166 .size = 256 * 1024, 169 .size = SZ_256K,
167 }, 170 },
168 { 171 {
169 .name = "Partition 2", 172 .name = "Partition 2",
170 .offset = 256 * 1024, 173 .offset = MTDPART_OFS_NXTBLK,
171 .size = MTDPART_SIZ_FULL, 174 .size = MTDPART_SIZ_FULL,
172 }, 175 },
173}; 176};
@@ -222,6 +225,73 @@ static struct gpio_led ek_leds[] = {
222 } 225 }
223}; 226};
224 227
228/*
229 * I2C devices
230 */
231static struct at24_platform_data at24c512 = {
232 .byte_len = SZ_512K / 8,
233 .page_size = 128,
234 .flags = AT24_FLAG_ADDR16,
235};
236
237static struct i2c_board_info __initdata ek_i2c_devices[] = {
238 {
239 I2C_BOARD_INFO("24c512", 0x50),
240 .platform_data = &at24c512,
241 },
242 /* more devices can be added using expansion connectors */
243};
244
245
246/*
247 * GPIO Buttons
248 */
249#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
250static struct gpio_keys_button ek_buttons[] = {
251 {
252 .gpio = AT91_PIN_PA30,
253 .code = BTN_3,
254 .desc = "Button 3",
255 .active_low = 1,
256 .wakeup = 1,
257 },
258 {
259 .gpio = AT91_PIN_PA31,
260 .code = BTN_4,
261 .desc = "Button 4",
262 .active_low = 1,
263 .wakeup = 1,
264 }
265};
266
267static struct gpio_keys_platform_data ek_button_data = {
268 .buttons = ek_buttons,
269 .nbuttons = ARRAY_SIZE(ek_buttons),
270};
271
272static struct platform_device ek_button_device = {
273 .name = "gpio-keys",
274 .id = -1,
275 .num_resources = 0,
276 .dev = {
277 .platform_data = &ek_button_data,
278 }
279};
280
281static void __init ek_add_device_buttons(void)
282{
283 at91_set_gpio_input(AT91_PIN_PA30, 1); /* btn3 */
284 at91_set_deglitch(AT91_PIN_PA30, 1);
285 at91_set_gpio_input(AT91_PIN_PA31, 1); /* btn4 */
286 at91_set_deglitch(AT91_PIN_PA31, 1);
287
288 platform_device_register(&ek_button_device);
289}
290#else
291static void __init ek_add_device_buttons(void) {}
292#endif
293
294
225static void __init ek_board_init(void) 295static void __init ek_board_init(void)
226{ 296{
227 /* Serial */ 297 /* Serial */
@@ -239,12 +309,14 @@ static void __init ek_board_init(void)
239 /* MMC */ 309 /* MMC */
240 at91_add_device_mmc(0, &ek_mmc_data); 310 at91_add_device_mmc(0, &ek_mmc_data);
241 /* I2C */ 311 /* I2C */
242 at91_add_device_i2c(NULL, 0); 312 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
243 /* SSC (to AT73C213) */ 313 /* SSC (to AT73C213) */
244 at73c213_set_clk(&at73c213_data); 314 at73c213_set_clk(&at73c213_data);
245 at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX); 315 at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
246 /* LEDs */ 316 /* LEDs */
247 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); 317 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
318 /* Push Buttons */
319 ek_add_device_buttons();
248} 320}
249 321
250MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK") 322MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 1a9963b811c7..4977409d4fc6 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -35,7 +35,6 @@
35 35
36#include <video/atmel_lcdc.h> 36#include <video/atmel_lcdc.h>
37 37
38#include <mach/hardware.h>
39#include <asm/setup.h> 38#include <asm/setup.h>
40#include <asm/mach-types.h> 39#include <asm/mach-types.h>
41#include <asm/irq.h> 40#include <asm/irq.h>
@@ -44,6 +43,7 @@
44#include <asm/mach/map.h> 43#include <asm/mach/map.h>
45#include <asm/mach/irq.h> 44#include <asm/mach/irq.h>
46 45
46#include <mach/hardware.h>
47#include <mach/board.h> 47#include <mach/board.h>
48#include <mach/gpio.h> 48#include <mach/gpio.h>
49#include <mach/at91sam9_smc.h> 49#include <mach/at91sam9_smc.h>
@@ -168,11 +168,11 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
168 { 168 {
169 .name = "Partition 1", 169 .name = "Partition 1",
170 .offset = 0, 170 .offset = 0,
171 .size = 256 * 1024, 171 .size = SZ_256K,
172 }, 172 },
173 { 173 {
174 .name = "Partition 2", 174 .name = "Partition 2",
175 .offset = 256 * 1024 , 175 .offset = MTDPART_OFS_NXTBLK,
176 .size = MTDPART_SIZ_FULL, 176 .size = MTDPART_SIZ_FULL,
177 }, 177 },
178}; 178};
@@ -435,24 +435,28 @@ static struct gpio_keys_button ek_buttons[] = {
435 .code = BTN_0, 435 .code = BTN_0,
436 .desc = "Button 0", 436 .desc = "Button 0",
437 .active_low = 1, 437 .active_low = 1,
438 .wakeup = 1,
438 }, 439 },
439 { 440 {
440 .gpio = AT91_PIN_PA26, 441 .gpio = AT91_PIN_PA26,
441 .code = BTN_1, 442 .code = BTN_1,
442 .desc = "Button 1", 443 .desc = "Button 1",
443 .active_low = 1, 444 .active_low = 1,
445 .wakeup = 1,
444 }, 446 },
445 { 447 {
446 .gpio = AT91_PIN_PA25, 448 .gpio = AT91_PIN_PA25,
447 .code = BTN_2, 449 .code = BTN_2,
448 .desc = "Button 2", 450 .desc = "Button 2",
449 .active_low = 1, 451 .active_low = 1,
452 .wakeup = 1,
450 }, 453 },
451 { 454 {
452 .gpio = AT91_PIN_PA24, 455 .gpio = AT91_PIN_PA24,
453 .code = BTN_3, 456 .code = BTN_3,
454 .desc = "Button 3", 457 .desc = "Button 3",
455 .active_low = 1, 458 .active_low = 1,
459 .wakeup = 1,
456 } 460 }
457}; 461};
458 462
@@ -472,13 +476,13 @@ static struct platform_device ek_button_device = {
472 476
473static void __init ek_add_device_buttons(void) 477static void __init ek_add_device_buttons(void)
474{ 478{
475 at91_set_gpio_input(AT91_PIN_PA27, 0); /* btn0 */ 479 at91_set_gpio_input(AT91_PIN_PA27, 1); /* btn0 */
476 at91_set_deglitch(AT91_PIN_PA27, 1); 480 at91_set_deglitch(AT91_PIN_PA27, 1);
477 at91_set_gpio_input(AT91_PIN_PA26, 0); /* btn1 */ 481 at91_set_gpio_input(AT91_PIN_PA26, 1); /* btn1 */
478 at91_set_deglitch(AT91_PIN_PA26, 1); 482 at91_set_deglitch(AT91_PIN_PA26, 1);
479 at91_set_gpio_input(AT91_PIN_PA25, 0); /* btn2 */ 483 at91_set_gpio_input(AT91_PIN_PA25, 1); /* btn2 */
480 at91_set_deglitch(AT91_PIN_PA25, 1); 484 at91_set_deglitch(AT91_PIN_PA25, 1);
481 at91_set_gpio_input(AT91_PIN_PA24, 0); /* btn3 */ 485 at91_set_gpio_input(AT91_PIN_PA24, 1); /* btn3 */
482 at91_set_deglitch(AT91_PIN_PA24, 1); 486 at91_set_deglitch(AT91_PIN_PA24, 1);
483 487
484 platform_device_register(&ek_button_device); 488 platform_device_register(&ek_button_device);
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index b1d11960a735..8354015c6a23 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -26,13 +26,14 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/spi/ads7846.h> 28#include <linux/spi/ads7846.h>
29#include <linux/i2c/at24.h>
29#include <linux/fb.h> 30#include <linux/fb.h>
30#include <linux/gpio_keys.h> 31#include <linux/gpio_keys.h>
31#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/leds.h>
32 34
33#include <video/atmel_lcdc.h> 35#include <video/atmel_lcdc.h>
34 36
35#include <mach/hardware.h>
36#include <asm/setup.h> 37#include <asm/setup.h>
37#include <asm/mach-types.h> 38#include <asm/mach-types.h>
38#include <asm/irq.h> 39#include <asm/irq.h>
@@ -41,6 +42,7 @@
41#include <asm/mach/map.h> 42#include <asm/mach/map.h>
42#include <asm/mach/irq.h> 43#include <asm/mach/irq.h>
43 44
45#include <mach/hardware.h>
44#include <mach/board.h> 46#include <mach/board.h>
45#include <mach/gpio.h> 47#include <mach/gpio.h>
46#include <mach/at91sam9_smc.h> 48#include <mach/at91sam9_smc.h>
@@ -172,11 +174,11 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
172 { 174 {
173 .name = "Partition 1", 175 .name = "Partition 1",
174 .offset = 0, 176 .offset = 0,
175 .size = 64 * 1024 * 1024, 177 .size = SZ_64M,
176 }, 178 },
177 { 179 {
178 .name = "Partition 2", 180 .name = "Partition 2",
179 .offset = 64 * 1024 * 1024, 181 .offset = MTDPART_OFS_NXTBLK,
180 .size = MTDPART_SIZ_FULL, 182 .size = MTDPART_SIZ_FULL,
181 }, 183 },
182}; 184};
@@ -203,12 +205,30 @@ static struct atmel_nand_data __initdata ek_nand_data = {
203 205
204 206
205/* 207/*
208 * I2C devices
209 */
210static struct at24_platform_data at24c512 = {
211 .byte_len = SZ_512K / 8,
212 .page_size = 128,
213 .flags = AT24_FLAG_ADDR16,
214};
215
216
217static struct i2c_board_info __initdata ek_i2c_devices[] = {
218 {
219 I2C_BOARD_INFO("24c512", 0x50),
220 .platform_data = &at24c512,
221 },
222 /* more devices can be added using expansion connectors */
223};
224
225/*
206 * LCD Controller 226 * LCD Controller
207 */ 227 */
208#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) 228#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
209static struct fb_videomode at91_tft_vga_modes[] = { 229static struct fb_videomode at91_tft_vga_modes[] = {
210 { 230 {
211 .name = "TX09D50VM1CCA @ 60", 231 .name = "TX09D50VM1CCA @ 60",
212 .refresh = 60, 232 .refresh = 60,
213 .xres = 240, .yres = 320, 233 .xres = 240, .yres = 320,
214 .pixclock = KHZ2PICOS(4965), 234 .pixclock = KHZ2PICOS(4965),
@@ -224,7 +244,7 @@ static struct fb_videomode at91_tft_vga_modes[] = {
224 244
225static struct fb_monspecs at91fb_default_monspecs = { 245static struct fb_monspecs at91fb_default_monspecs = {
226 .manufacturer = "HIT", 246 .manufacturer = "HIT",
227 .monitor = "TX09D70VM1CCA", 247 .monitor = "TX09D70VM1CCA",
228 248
229 .modedb = at91_tft_vga_modes, 249 .modedb = at91_tft_vga_modes,
230 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes), 250 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
@@ -235,7 +255,7 @@ static struct fb_monspecs at91fb_default_monspecs = {
235}; 255};
236 256
237#define AT91SAM9263_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \ 257#define AT91SAM9263_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
238 | ATMEL_LCDC_DISTYPE_TFT \ 258 | ATMEL_LCDC_DISTYPE_TFT \
239 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) 259 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
240 260
241static void at91_lcdc_power_control(int on) 261static void at91_lcdc_power_control(int on)
@@ -277,7 +297,7 @@ static struct gpio_keys_button ek_buttons[] = {
277 .active_low = 1, 297 .active_low = 1,
278 .desc = "right_click", 298 .desc = "right_click",
279 .wakeup = 1, 299 .wakeup = 1,
280 }, 300 }
281}; 301};
282 302
283static struct gpio_keys_platform_data ek_button_data = { 303static struct gpio_keys_platform_data ek_button_data = {
@@ -296,9 +316,9 @@ static struct platform_device ek_button_device = {
296 316
297static void __init ek_add_device_buttons(void) 317static void __init ek_add_device_buttons(void)
298{ 318{
299 at91_set_GPIO_periph(AT91_PIN_PC5, 0); /* left button */ 319 at91_set_GPIO_periph(AT91_PIN_PC5, 1); /* left button */
300 at91_set_deglitch(AT91_PIN_PC5, 1); 320 at91_set_deglitch(AT91_PIN_PC5, 1);
301 at91_set_GPIO_periph(AT91_PIN_PC4, 0); /* right button */ 321 at91_set_GPIO_periph(AT91_PIN_PC4, 1); /* right button */
302 at91_set_deglitch(AT91_PIN_PC4, 1); 322 at91_set_deglitch(AT91_PIN_PC4, 1);
303 323
304 platform_device_register(&ek_button_device); 324 platform_device_register(&ek_button_device);
@@ -320,25 +340,32 @@ static struct atmel_ac97_data ek_ac97_data = {
320 * LEDs ... these could all be PWM-driven, for variable brightness 340 * LEDs ... these could all be PWM-driven, for variable brightness
321 */ 341 */
322static struct gpio_led ek_leds[] = { 342static struct gpio_led ek_leds[] = {
323 { /* "left" led, green, userled1, pwm1 */ 343 { /* "right" led, green, userled2 (could be driven by pwm2) */
324 .name = "ds1",
325 .gpio = AT91_PIN_PB8,
326 .active_low = 1,
327 .default_trigger = "mmc0",
328 },
329 { /* "right" led, green, userled2, pwm2 */
330 .name = "ds2", 344 .name = "ds2",
331 .gpio = AT91_PIN_PC29, 345 .gpio = AT91_PIN_PC29,
332 .active_low = 1, 346 .active_low = 1,
333 .default_trigger = "nand-disk", 347 .default_trigger = "nand-disk",
334 }, 348 },
335 { /* "power" led, yellow, pwm0 */ 349 { /* "power" led, yellow (could be driven by pwm0) */
336 .name = "ds3", 350 .name = "ds3",
337 .gpio = AT91_PIN_PB7, 351 .gpio = AT91_PIN_PB7,
338 .default_trigger = "heartbeat", 352 .default_trigger = "heartbeat",
339 } 353 }
340}; 354};
341 355
356/*
357 * PWM Leds
358 */
359static struct gpio_led ek_pwm_led[] = {
360 /* For now only DS1 is PWM-driven (by pwm1) */
361 {
362 .name = "ds1",
363 .gpio = 1, /* is PWM channel number */
364 .active_low = 1,
365 .default_trigger = "none",
366 }
367};
368
342 369
343static void __init ek_board_init(void) 370static void __init ek_board_init(void)
344{ 371{
@@ -360,7 +387,7 @@ static void __init ek_board_init(void)
360 /* NAND */ 387 /* NAND */
361 at91_add_device_nand(&ek_nand_data); 388 at91_add_device_nand(&ek_nand_data);
362 /* I2C */ 389 /* I2C */
363 at91_add_device_i2c(NULL, 0); 390 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
364 /* LCD Controller */ 391 /* LCD Controller */
365 at91_add_device_lcdc(&ek_lcdc_data); 392 at91_add_device_lcdc(&ek_lcdc_data);
366 /* Push Buttons */ 393 /* Push Buttons */
@@ -369,6 +396,7 @@ static void __init ek_board_init(void)
369 at91_add_device_ac97(&ek_ac97_data); 396 at91_add_device_ac97(&ek_ac97_data);
370 /* LEDs */ 397 /* LEDs */
371 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); 398 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
399 at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));
372} 400}
373 401
374MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK") 402MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index d4eba5c0ce02..b588ead14d68 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -122,16 +122,16 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
122 { 122 {
123 .name = "Bootstrap", 123 .name = "Bootstrap",
124 .offset = 0, 124 .offset = 0,
125 .size = 4 * 1024 * 1024, 125 .size = 4 * SZ_1M,
126 }, 126 },
127 { 127 {
128 .name = "Partition 1", 128 .name = "Partition 1",
129 .offset = 4 * 1024 * 1024, 129 .offset = MTDPART_OFS_NXTBLK,
130 .size = 60 * 1024 * 1024, 130 .size = 60 * SZ_1M,
131 }, 131 },
132 { 132 {
133 .name = "Partition 2", 133 .name = "Partition 2",
134 .offset = 64 * 1024 * 1024, 134 .offset = MTDPART_OFS_NXTBLK,
135 .size = MTDPART_SIZ_FULL, 135 .size = MTDPART_SIZ_FULL,
136 }, 136 },
137}; 137};
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index c6dce49c388c..270851864308 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -18,7 +18,6 @@
18 18
19#include <video/atmel_lcdc.h> 19#include <video/atmel_lcdc.h>
20 20
21#include <mach/hardware.h>
22#include <asm/setup.h> 21#include <asm/setup.h>
23#include <asm/mach-types.h> 22#include <asm/mach-types.h>
24#include <asm/irq.h> 23#include <asm/irq.h>
@@ -27,6 +26,7 @@
27#include <asm/mach/map.h> 26#include <asm/mach/map.h>
28#include <asm/mach/irq.h> 27#include <asm/mach/irq.h>
29 28
29#include <mach/hardware.h>
30#include <mach/board.h> 30#include <mach/board.h>
31#include <mach/gpio.h> 31#include <mach/gpio.h>
32#include <mach/at91sam9_smc.h> 32#include <mach/at91sam9_smc.h>
@@ -81,11 +81,11 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
81 { 81 {
82 .name = "Partition 1", 82 .name = "Partition 1",
83 .offset = 0, 83 .offset = 0,
84 .size = 256 * 1024, 84 .size = SZ_256K,
85 }, 85 },
86 { 86 {
87 .name = "Partition 2", 87 .name = "Partition 2",
88 .offset = 256 * 1024 , 88 .offset = MTDPART_OFS_NXTBLK,
89 .size = MTDPART_SIZ_FULL, 89 .size = MTDPART_SIZ_FULL,
90 }, 90 },
91}; 91};
@@ -195,6 +195,8 @@ static void __init ek_board_init(void)
195 at91_add_device_mmc(0, &ek_mmc_data); 195 at91_add_device_mmc(0, &ek_mmc_data);
196 /* LCD Controller */ 196 /* LCD Controller */
197 at91_add_device_lcdc(&ek_lcdc_data); 197 at91_add_device_lcdc(&ek_lcdc_data);
198 /* Touch Screen Controller */
199 at91_add_device_tsadcc();
198} 200}
199 201
200MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK") 202MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
diff --git a/arch/arm/mach-at91/board-usb-a9260.c b/arch/arm/mach-at91/board-usb-a9260.c
index f9d0b65da40b..7c350357333a 100644
--- a/arch/arm/mach-at91/board-usb-a9260.c
+++ b/arch/arm/mach-at91/board-usb-a9260.c
@@ -30,7 +30,6 @@
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/clk.h> 31#include <linux/clk.h>
32 32
33#include <mach/hardware.h>
34#include <asm/setup.h> 33#include <asm/setup.h>
35#include <asm/mach-types.h> 34#include <asm/mach-types.h>
36#include <asm/irq.h> 35#include <asm/irq.h>
@@ -39,6 +38,7 @@
39#include <asm/mach/map.h> 38#include <asm/mach/map.h>
40#include <asm/mach/irq.h> 39#include <asm/mach/irq.h>
41 40
41#include <mach/hardware.h>
42#include <mach/board.h> 42#include <mach/board.h>
43#include <mach/gpio.h> 43#include <mach/gpio.h>
44#include <mach/at91_shdwc.h> 44#include <mach/at91_shdwc.h>
@@ -93,18 +93,18 @@ static struct at91_eth_data __initdata ek_macb_data = {
93static struct mtd_partition __initdata ek_nand_partition[] = { 93static struct mtd_partition __initdata ek_nand_partition[] = {
94 { 94 {
95 .name = "Uboot & Kernel", 95 .name = "Uboot & Kernel",
96 .offset = 0x00000000, 96 .offset = 0,
97 .size = 16 * 1024 * 1024, 97 .size = SZ_16M,
98 }, 98 },
99 { 99 {
100 .name = "Root FS", 100 .name = "Root FS",
101 .offset = 0x01000000, 101 .offset = MTDPART_OFS_NXTBLK,
102 .size = 120 * 1024 * 1024, 102 .size = 120 * SZ_1M,
103 }, 103 },
104 { 104 {
105 .name = "FS", 105 .name = "FS",
106 .offset = 0x08800000, 106 .offset = MTDPART_OFS_NXTBLK,
107 .size = 120 * 1024 * 1024, 107 .size = 120 * SZ_1M,
108 } 108 }
109}; 109};
110 110
diff --git a/arch/arm/mach-at91/board-usb-a9263.c b/arch/arm/mach-at91/board-usb-a9263.c
index 673e5c27214d..391b566c4571 100644
--- a/arch/arm/mach-at91/board-usb-a9263.c
+++ b/arch/arm/mach-at91/board-usb-a9263.c
@@ -29,7 +29,6 @@
29#include <linux/gpio_keys.h> 29#include <linux/gpio_keys.h>
30#include <linux/input.h> 30#include <linux/input.h>
31 31
32#include <mach/hardware.h>
33#include <asm/setup.h> 32#include <asm/setup.h>
34#include <asm/mach-types.h> 33#include <asm/mach-types.h>
35#include <asm/irq.h> 34#include <asm/irq.h>
@@ -38,6 +37,7 @@
38#include <asm/mach/map.h> 37#include <asm/mach/map.h>
39#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
40 39
40#include <mach/hardware.h>
41#include <mach/board.h> 41#include <mach/board.h>
42#include <mach/gpio.h> 42#include <mach/gpio.h>
43#include <mach/at91_shdwc.h> 43#include <mach/at91_shdwc.h>
@@ -106,18 +106,18 @@ static struct at91_eth_data __initdata ek_macb_data = {
106static struct mtd_partition __initdata ek_nand_partition[] = { 106static struct mtd_partition __initdata ek_nand_partition[] = {
107 { 107 {
108 .name = "Linux Kernel", 108 .name = "Linux Kernel",
109 .offset = 0x00000000, 109 .offset = 0,
110 .size = 16 * 1024 * 1024, 110 .size = SZ_16M,
111 }, 111 },
112 { 112 {
113 .name = "Root FS", 113 .name = "Root FS",
114 .offset = 0x01000000, 114 .offset = MTDPART_OFS_NXTBLK,
115 .size = 120 * 1024 * 1024, 115 .size = 120 * SZ_1M,
116 }, 116 },
117 { 117 {
118 .name = "FS", 118 .name = "FS",
119 .offset = 0x08800000, 119 .offset = MTDPART_OFS_NXTBLK,
120 .size = 120 * 1024 * 1024, 120 .size = 120 * SZ_1M,
121 } 121 }
122}; 122};
123 123
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index 36b380aad006..e22bf051f835 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -33,7 +33,6 @@
33#include <linux/gpio_keys.h> 33#include <linux/gpio_keys.h>
34#include <linux/input.h> 34#include <linux/input.h>
35 35
36#include <mach/hardware.h>
37#include <asm/setup.h> 36#include <asm/setup.h>
38#include <asm/mach-types.h> 37#include <asm/mach-types.h>
39#include <asm/irq.h> 38#include <asm/irq.h>
@@ -42,6 +41,7 @@
42#include <asm/mach/map.h> 41#include <asm/mach/map.h>
43#include <asm/mach/irq.h> 42#include <asm/mach/irq.h>
44 43
44#include <mach/hardware.h>
45#include <mach/board.h> 45#include <mach/board.h>
46#include <mach/gpio.h> 46#include <mach/gpio.h>
47#include <mach/at91rm9200_mc.h> 47#include <mach/at91rm9200_mc.h>
@@ -150,27 +150,27 @@ static struct mtd_partition __initdata yl9200_nand_partition[] = {
150 { 150 {
151 .name = "AT91 NAND partition 1, boot", 151 .name = "AT91 NAND partition 1, boot",
152 .offset = 0, 152 .offset = 0,
153 .size = 1 * SZ_256K 153 .size = SZ_256K
154 }, 154 },
155 { 155 {
156 .name = "AT91 NAND partition 2, kernel", 156 .name = "AT91 NAND partition 2, kernel",
157 .offset = 1 * SZ_256K, 157 .offset = MTDPART_OFS_NXTBLK,
158 .size = 2 * SZ_1M - 1 * SZ_256K 158 .size = (2 * SZ_1M) - SZ_256K
159 }, 159 },
160 { 160 {
161 .name = "AT91 NAND partition 3, filesystem", 161 .name = "AT91 NAND partition 3, filesystem",
162 .offset = 2 * SZ_1M, 162 .offset = MTDPART_OFS_NXTBLK,
163 .size = 14 * SZ_1M 163 .size = 14 * SZ_1M
164 }, 164 },
165 { 165 {
166 .name = "AT91 NAND partition 4, storage", 166 .name = "AT91 NAND partition 4, storage",
167 .offset = 16 * SZ_1M, 167 .offset = MTDPART_OFS_NXTBLK,
168 .size = 16 * SZ_1M 168 .size = SZ_16M
169 }, 169 },
170 { 170 {
171 .name = "AT91 NAND partition 5, ext-fs", 171 .name = "AT91 NAND partition 5, ext-fs",
172 .offset = 32 * SZ_1M, 172 .offset = MTDPART_OFS_NXTBLK,
173 .size = 32 * SZ_1M 173 .size = SZ_32M
174 } 174 }
175}; 175};
176 176
@@ -193,24 +193,24 @@ static struct atmel_nand_data __initdata yl9200_nand_data = {
193 * NOR Flash 193 * NOR Flash
194 */ 194 */
195#define YL9200_FLASH_BASE AT91_CHIPSELECT_0 195#define YL9200_FLASH_BASE AT91_CHIPSELECT_0
196#define YL9200_FLASH_SIZE 0x1000000 196#define YL9200_FLASH_SIZE SZ_16M
197 197
198static struct mtd_partition yl9200_flash_partitions[] = { 198static struct mtd_partition yl9200_flash_partitions[] = {
199 { 199 {
200 .name = "Bootloader", 200 .name = "Bootloader",
201 .size = 0x00040000,
202 .offset = 0, 201 .offset = 0,
202 .size = SZ_256K,
203 .mask_flags = MTD_WRITEABLE, /* force read-only */ 203 .mask_flags = MTD_WRITEABLE, /* force read-only */
204 }, 204 },
205 { 205 {
206 .name = "Kernel", 206 .name = "Kernel",
207 .size = 0x001C0000, 207 .offset = MTDPART_OFS_NXTBLK,
208 .offset = 0x00040000, 208 .size = (2 * SZ_1M) - SZ_256K
209 }, 209 },
210 { 210 {
211 .name = "Filesystem", 211 .name = "Filesystem",
212 .size = MTDPART_SIZ_FULL, 212 .offset = MTDPART_OFS_NXTBLK,
213 .offset = 0x00200000 213 .size = MTDPART_SIZ_FULL
214 } 214 }
215}; 215};
216 216
@@ -390,10 +390,6 @@ static struct spi_board_info yl9200_spi_devices[] = {
390#if defined(CONFIG_FB_S1D135XX) || defined(CONFIG_FB_S1D13XXX_MODULE) 390#if defined(CONFIG_FB_S1D135XX) || defined(CONFIG_FB_S1D13XXX_MODULE)
391#include <video/s1d13xxxfb.h> 391#include <video/s1d13xxxfb.h>
392 392
393#define AT91_FB_REG_BASE 0x80000000L
394#define AT91_FB_REG_SIZE 0x200
395#define AT91_FB_VMEM_BASE 0x80200000L
396#define AT91_FB_VMEM_SIZE 0x200000L
397 393
398static void __init yl9200_init_video(void) 394static void __init yl9200_init_video(void)
399{ 395{
@@ -516,29 +512,33 @@ static struct s1d13xxxfb_regval yl9200_s1dfb_initregs[] =
516 {S1DREG_COM_DISP_MODE, 0x01}, /* Display Mode Register, LCD only*/ 512 {S1DREG_COM_DISP_MODE, 0x01}, /* Display Mode Register, LCD only*/
517}; 513};
518 514
519static u64 s1dfb_dmamask = DMA_BIT_MASK(32);
520
521static struct s1d13xxxfb_pdata yl9200_s1dfb_pdata = { 515static struct s1d13xxxfb_pdata yl9200_s1dfb_pdata = {
522 .initregs = yl9200_s1dfb_initregs, 516 .initregs = yl9200_s1dfb_initregs,
523 .initregssize = ARRAY_SIZE(yl9200_s1dfb_initregs), 517 .initregssize = ARRAY_SIZE(yl9200_s1dfb_initregs),
524 .platform_init_video = yl9200_init_video, 518 .platform_init_video = yl9200_init_video,
525}; 519};
526 520
521#define YL9200_FB_REG_BASE AT91_CHIPSELECT_7
522#define YL9200_FB_VMEM_BASE YL9200_FB_REG_BASE + SZ_2M
523#define YL9200_FB_VMEM_SIZE SZ_2M
524
527static struct resource yl9200_s1dfb_resource[] = { 525static struct resource yl9200_s1dfb_resource[] = {
528 [0] = { /* video mem */ 526 [0] = { /* video mem */
529 .name = "s1d13xxxfb memory", 527 .name = "s1d13xxxfb memory",
530 .start = AT91_FB_VMEM_BASE, 528 .start = YL9200_FB_VMEM_BASE,
531 .end = AT91_FB_VMEM_BASE + AT91_FB_VMEM_SIZE -1, 529 .end = YL9200_FB_VMEM_BASE + YL9200_FB_VMEM_SIZE -1,
532 .flags = IORESOURCE_MEM, 530 .flags = IORESOURCE_MEM,
533 }, 531 },
534 [1] = { /* video registers */ 532 [1] = { /* video registers */
535 .name = "s1d13xxxfb registers", 533 .name = "s1d13xxxfb registers",
536 .start = AT91_FB_REG_BASE, 534 .start = YL9200_FB_REG_BASE,
537 .end = AT91_FB_REG_BASE + AT91_FB_REG_SIZE -1, 535 .end = YL9200_FB_REG_BASE + SZ_512 -1,
538 .flags = IORESOURCE_MEM, 536 .flags = IORESOURCE_MEM,
539 }, 537 },
540}; 538};
541 539
540static u64 s1dfb_dmamask = DMA_BIT_MASK(32);
541
542static struct platform_device yl9200_s1dfb_device = { 542static struct platform_device yl9200_s1dfb_device = {
543 .name = "s1d13806fb", 543 .name = "s1d13806fb",
544 .id = -1, 544 .id = -1,
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index f5c2847161f5..e4345106ee57 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -22,8 +22,7 @@
22#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/clk.h> 24#include <linux/clk.h>
25 25#include <linux/io.h>
26#include <asm/io.h>
27 26
28#include <mach/hardware.h> 27#include <mach/hardware.h>
29#include <mach/at91_pmc.h> 28#include <mach/at91_pmc.h>
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index 8392d5b517f1..7e5ebb5bdd17 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -18,8 +18,8 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/io.h>
21 22
22#include <asm/io.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <mach/at91_pio.h> 24#include <mach/at91_pio.h>
25#include <mach/gpio.h> 25#include <mach/gpio.h>
@@ -404,7 +404,6 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
404 } 404 }
405 405
406 pin = bank->chipbase; 406 pin = bank->chipbase;
407 gpio = &irq_desc[pin];
408 407
409 while (isr) { 408 while (isr) {
410 if (isr & 1) { 409 if (isr & 1) {
@@ -417,7 +416,7 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
417 gpio_irq_mask(pin); 416 gpio_irq_mask(pin);
418 } 417 }
419 else 418 else
420 desc_handle_irq(pin, gpio); 419 generic_handle_irq(pin);
421 } 420 }
422 pin++; 421 pin++;
423 gpio++; 422 gpio++;
diff --git a/arch/arm/mach-at91/include/mach/at91_pit.h b/arch/arm/mach-at91/include/mach/at91_pit.h
index 0448ac36eadb..974d0bd05b5b 100644
--- a/arch/arm/mach-at91/include/mach/at91_pit.h
+++ b/arch/arm/mach-at91/include/mach/at91_pit.h
@@ -1,6 +1,9 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91_pit.h 2 * arch/arm/mach-at91/include/mach/at91_pit.h
3 * 3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
4 * Periodic Interval Timer (PIT) - System peripherals regsters. 7 * Periodic Interval Timer (PIT) - System peripherals regsters.
5 * Based on AT91SAM9261 datasheet revision D. 8 * Based on AT91SAM9261 datasheet revision D.
6 * 9 *
diff --git a/arch/arm/mach-at91/include/mach/at91_rstc.h b/arch/arm/mach-at91/include/mach/at91_rstc.h
index 7cd1b39aaa43..cbd2bf052c1f 100644
--- a/arch/arm/mach-at91/include/mach/at91_rstc.h
+++ b/arch/arm/mach-at91/include/mach/at91_rstc.h
@@ -1,6 +1,9 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91_rstc.h 2 * arch/arm/mach-at91/include/mach/at91_rstc.h
3 * 3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
4 * Reset Controller (RSTC) - System peripherals regsters. 7 * Reset Controller (RSTC) - System peripherals regsters.
5 * Based on AT91SAM9261 datasheet revision D. 8 * Based on AT91SAM9261 datasheet revision D.
6 * 9 *
diff --git a/arch/arm/mach-at91/include/mach/at91_rtt.h b/arch/arm/mach-at91/include/mach/at91_rtt.h
index 71782e5d2159..7ec75de8bbb6 100644
--- a/arch/arm/mach-at91/include/mach/at91_rtt.h
+++ b/arch/arm/mach-at91/include/mach/at91_rtt.h
@@ -1,6 +1,9 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91_rtt.h 2 * arch/arm/mach-at91/include/mach/at91_rtt.h
3 * 3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
4 * Real-time Timer (RTT) - System peripherals regsters. 7 * Real-time Timer (RTT) - System peripherals regsters.
5 * Based on AT91SAM9261 datasheet revision D. 8 * Based on AT91SAM9261 datasheet revision D.
6 * 9 *
diff --git a/arch/arm/mach-at91/include/mach/at91_shdwc.h b/arch/arm/mach-at91/include/mach/at91_shdwc.h
index 60be5ae624f1..c4ce07e8a8fa 100644
--- a/arch/arm/mach-at91/include/mach/at91_shdwc.h
+++ b/arch/arm/mach-at91/include/mach/at91_shdwc.h
@@ -1,6 +1,9 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91_shdwc.h 2 * arch/arm/mach-at91/include/mach/at91_shdwc.h
3 * 3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
4 * Shutdown Controller (SHDWC) - System peripherals regsters. 7 * Shutdown Controller (SHDWC) - System peripherals regsters.
5 * Based on AT91SAM9261 datasheet revision D. 8 * Based on AT91SAM9261 datasheet revision D.
6 * 9 *
diff --git a/arch/arm/mach-at91/include/mach/at91_wdt.h b/arch/arm/mach-at91/include/mach/at91_wdt.h
index 973b4526a98e..fecc2e9f0ca8 100644
--- a/arch/arm/mach-at91/include/mach/at91_wdt.h
+++ b/arch/arm/mach-at91/include/mach/at91_wdt.h
@@ -1,6 +1,9 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91_wdt.h 2 * arch/arm/mach-at91/include/mach/at91_wdt.h
3 * 3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
4 * Watchdog Timer (WDT) - System peripherals regsters. 7 * Watchdog Timer (WDT) - System peripherals regsters.
5 * Based on AT91SAM9261 datasheet revision D. 8 * Based on AT91SAM9261 datasheet revision D.
6 * 9 *
diff --git a/arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h b/arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h
index bca878f3bd87..1499b1cbffdd 100644
--- a/arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h
+++ b/arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h
@@ -1,6 +1,8 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h 2 * arch/arm/mach-at91/include/mach/at91cap9_ddrsdr.h
3 * 3 *
4 * (C) 2008 Andrew Victor
5 *
4 * DDR/SDR Controller (DDRSDRC) - System peripherals registers. 6 * DDR/SDR Controller (DDRSDRC) - System peripherals registers.
5 * Based on AT91CAP9 datasheet revision B. 7 * Based on AT91CAP9 datasheet revision B.
6 * 8 *
diff --git a/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
index f027de5df956..020f02ed921a 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
@@ -1,6 +1,8 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91sam9260_matrix.h 2 * arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
3 * 3 *
4 * Copyright (C) 2007 Atmel Corporation.
5 *
4 * Memory Controllers (MATRIX, EBI) - System peripherals registers. 6 * Memory Controllers (MATRIX, EBI) - System peripherals registers.
5 * Based on AT91SAM9260 datasheet revision B. 7 * Based on AT91SAM9260 datasheet revision B.
6 * 8 *
diff --git a/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
index db62b1f18300..69c6501915d9 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
@@ -1,6 +1,8 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91sam9261_matrix.h 2 * arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
3 * 3 *
4 * Copyright (C) 2007 Atmel Corporation.
5 *
4 * Memory Controllers (MATRIX, EBI) - System peripherals registers. 6 * Memory Controllers (MATRIX, EBI) - System peripherals registers.
5 * Based on AT91SAM9261 datasheet revision D. 7 * Based on AT91SAM9261 datasheet revision D.
6 * 8 *
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
index 1921181c63ca..b7260389f7ca 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
@@ -1,6 +1,9 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91sam9_sdramc.h 2 * arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
3 * 3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
4 * SDRAM Controllers (SDRAMC) - System peripherals registers. 7 * SDRAM Controllers (SDRAMC) - System peripherals registers.
5 * Based on AT91SAM9261 datasheet revision D. 8 * Based on AT91SAM9261 datasheet revision D.
6 * 9 *
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_smc.h b/arch/arm/mach-at91/include/mach/at91sam9_smc.h
index ec6ad1338b5a..57de6207e57e 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_smc.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_smc.h
@@ -1,6 +1,9 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/at91sam9_smc.h 2 * arch/arm/mach-at91/include/mach/at91sam9_smc.h
3 * 3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
4 * Static Memory Controllers (SMC) - System peripherals registers. 7 * Static Memory Controllers (SMC) - System peripherals registers.
5 * Based on AT91SAM9261 datasheet revision D. 8 * Based on AT91SAM9261 datasheet revision D.
6 * 9 *
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index acd60f2a0724..fb51f0e0a83f 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -133,6 +133,16 @@ struct atmel_uart_data {
133extern void __init at91_add_device_serial(void); 133extern void __init at91_add_device_serial(void);
134 134
135/* 135/*
136 * PWM
137 */
138#define AT91_PWM0 0
139#define AT91_PWM1 1
140#define AT91_PWM2 2
141#define AT91_PWM3 3
142
143extern void __init at91_add_device_pwm(u32 mask);
144
145/*
136 * SSC -- accessed through ssc_request(id). Drivers don't bind to SSC 146 * SSC -- accessed through ssc_request(id). Drivers don't bind to SSC
137 * platform devices. Their SSC ID is part of their configuration data, 147 * platform devices. Their SSC ID is part of their configuration data,
138 * along with information about which SSC signals they should use. 148 * along with information about which SSC signals they should use.
@@ -162,9 +172,13 @@ extern void __init at91_add_device_ac97(struct atmel_ac97_data *data);
162 /* ISI */ 172 /* ISI */
163extern void __init at91_add_device_isi(void); 173extern void __init at91_add_device_isi(void);
164 174
175 /* Touchscreen Controller */
176extern void __init at91_add_device_tsadcc(void);
177
165 /* LEDs */ 178 /* LEDs */
166extern void __init at91_init_leds(u8 cpu_led, u8 timer_led); 179extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
167extern void __init at91_gpio_leds(struct gpio_led *leds, int nr); 180extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
181extern void __init at91_pwm_leds(struct gpio_led *leds, int nr);
168 182
169/* FIXME: this needs a better location, but gets stuff building again */ 183/* FIXME: this needs a better location, but gets stuff building again */
170extern int at91_suspend_entering_slow_clock(void); 184extern int at91_suspend_entering_slow_clock(void);
diff --git a/arch/arm/mach-at91/include/mach/irqs.h b/arch/arm/mach-at91/include/mach/irqs.h
index bda29ccbcd94..36bd55f3fc6e 100644
--- a/arch/arm/mach-at91/include/mach/irqs.h
+++ b/arch/arm/mach-at91/include/mach/irqs.h
@@ -21,7 +21,7 @@
21#ifndef __ASM_ARCH_IRQS_H 21#ifndef __ASM_ARCH_IRQS_H
22#define __ASM_ARCH_IRQS_H 22#define __ASM_ARCH_IRQS_H
23 23
24#include <asm/io.h> 24#include <linux/io.h>
25#include <mach/at91_aic.h> 25#include <mach/at91_aic.h>
26 26
27#define NR_AIC_IRQS 32 27#define NR_AIC_IRQS 32
diff --git a/arch/arm/mach-at91/include/mach/uncompress.h b/arch/arm/mach-at91/include/mach/uncompress.h
index 0410d548e9b1..18bdcdeb474f 100644
--- a/arch/arm/mach-at91/include/mach/uncompress.h
+++ b/arch/arm/mach-at91/include/mach/uncompress.h
@@ -21,7 +21,7 @@
21#ifndef __ASM_ARCH_UNCOMPRESS_H 21#ifndef __ASM_ARCH_UNCOMPRESS_H
22#define __ASM_ARCH_UNCOMPRESS_H 22#define __ASM_ARCH_UNCOMPRESS_H
23 23
24#include <asm/io.h> 24#include <linux/io.h>
25#include <linux/atmel_serial.h> 25#include <linux/atmel_serial.h>
26 26
27#if defined(CONFIG_AT91_EARLY_DBGU) 27#if defined(CONFIG_AT91_EARLY_DBGU)
diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c
index fec03c59ff94..0415a839e1ad 100644
--- a/arch/arm/mach-at91/leds.c
+++ b/arch/arm/mach-at91/leds.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h>
15 16
16#include <mach/board.h> 17#include <mach/board.h>
17#include <mach/gpio.h> 18#include <mach/gpio.h>
@@ -21,15 +22,13 @@
21 22
22#if defined(CONFIG_NEW_LEDS) 23#if defined(CONFIG_NEW_LEDS)
23 24
24#include <linux/platform_device.h>
25
26/* 25/*
27 * New cross-platform LED support. 26 * New cross-platform LED support.
28 */ 27 */
29 28
30static struct gpio_led_platform_data led_data; 29static struct gpio_led_platform_data led_data;
31 30
32static struct platform_device at91_leds = { 31static struct platform_device at91_gpio_leds_device = {
33 .name = "leds-gpio", 32 .name = "leds-gpio",
34 .id = -1, 33 .id = -1,
35 .dev.platform_data = &led_data, 34 .dev.platform_data = &led_data,
@@ -47,7 +46,7 @@ void __init at91_gpio_leds(struct gpio_led *leds, int nr)
47 46
48 led_data.leds = leds; 47 led_data.leds = leds;
49 led_data.num_leds = nr; 48 led_data.num_leds = nr;
50 platform_device_register(&at91_leds); 49 platform_device_register(&at91_gpio_leds_device);
51} 50}
52 51
53#else 52#else
@@ -57,6 +56,44 @@ void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
57 56
58/* ------------------------------------------------------------------------- */ 57/* ------------------------------------------------------------------------- */
59 58
59#if defined (CONFIG_LEDS_ATMEL_PWM)
60
61/*
62 * PWM Leds
63 */
64
65static struct gpio_led_platform_data pwm_led_data;
66
67static struct platform_device at91_pwm_leds_device = {
68 .name = "leds-atmel-pwm",
69 .id = -1,
70 .dev.platform_data = &pwm_led_data,
71};
72
73void __init at91_pwm_leds(struct gpio_led *leds, int nr)
74{
75 int i;
76 u32 pwm_mask = 0;
77
78 if (!nr)
79 return;
80
81 for (i = 0; i < nr; i++)
82 pwm_mask |= (1 << leds[i].gpio);
83
84 pwm_led_data.leds = leds;
85 pwm_led_data.num_leds = nr;
86
87 at91_add_device_pwm(pwm_mask);
88 platform_device_register(&at91_pwm_leds_device);
89}
90#else
91void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
92#endif
93
94
95/* ------------------------------------------------------------------------- */
96
60#if defined(CONFIG_LEDS) 97#if defined(CONFIG_LEDS)
61 98
62#include <asm/leds.h> 99#include <asm/leds.h>
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index ec2fe4ca1e27..9bb4f043aa22 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -17,8 +17,8 @@
17#include <linux/sysfs.h> 17#include <linux/sysfs.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/io.h>
20 21
21#include <asm/io.h>
22#include <asm/irq.h> 22#include <asm/irq.h>
23#include <asm/atomic.h> 23#include <asm/atomic.h>
24#include <asm/mach/time.h> 24#include <asm/mach/time.h>
diff --git a/arch/arm/mach-at91/pm_slowclock.S b/arch/arm/mach-at91/pm_slowclock.S
new file mode 100644
index 000000000000..987fab3d846a
--- /dev/null
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -0,0 +1,283 @@
1/*
2 * arch/arm/mach-at91/pm_slow_clock.S
3 *
4 * Copyright (C) 2006 Savin Zlobec
5 *
6 * AT91SAM9 support:
7 * Copyright (C) 2007 Anti Sullin <anti.sullin@artecdesign.ee
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/linkage.h>
16#include <mach/hardware.h>
17#include <mach/at91_pmc.h>
18
19#ifdef CONFIG_ARCH_AT91RM9200
20#include <mach/at91rm9200_mc.h>
21#elif defined(CONFIG_ARCH_AT91CAP9)
22#include <mach/at91cap9_ddrsdr.h>
23#else
24#include <mach/at91sam9_sdramc.h>
25#endif
26
27
28#ifdef CONFIG_ARCH_AT91SAM9263
29/*
30 * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
31 * handle those cases both here and in the Suspend-To-RAM support.
32 */
33#define AT91_SDRAMC AT91_SDRAMC0
34#warning Assuming EB1 SDRAM controller is *NOT* used
35#endif
36
37/*
38 * When SLOWDOWN_MASTER_CLOCK is defined we will also slow down the Master
39 * clock during suspend by adjusting its prescalar and divisor.
40 * NOTE: This hasn't been shown to be stable on SAM9s; and on the RM9200 there
41 * are errata regarding adjusting the prescalar and divisor.
42 */
43#undef SLOWDOWN_MASTER_CLOCK
44
45#define MCKRDY_TIMEOUT 1000
46#define MOSCRDY_TIMEOUT 1000
47#define PLLALOCK_TIMEOUT 1000
48#define PLLBLOCK_TIMEOUT 1000
49
50
51/*
52 * Wait until master clock is ready (after switching master clock source)
53 */
54 .macro wait_mckrdy
55 mov r4, #MCKRDY_TIMEOUT
561: sub r4, r4, #1
57 cmp r4, #0
58 beq 2f
59 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
60 tst r3, #AT91_PMC_MCKRDY
61 beq 1b
622:
63 .endm
64
65/*
66 * Wait until master oscillator has stabilized.
67 */
68 .macro wait_moscrdy
69 mov r4, #MOSCRDY_TIMEOUT
701: sub r4, r4, #1
71 cmp r4, #0
72 beq 2f
73 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
74 tst r3, #AT91_PMC_MOSCS
75 beq 1b
762:
77 .endm
78
79/*
80 * Wait until PLLA has locked.
81 */
82 .macro wait_pllalock
83 mov r4, #PLLALOCK_TIMEOUT
841: sub r4, r4, #1
85 cmp r4, #0
86 beq 2f
87 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
88 tst r3, #AT91_PMC_LOCKA
89 beq 1b
902:
91 .endm
92
93/*
94 * Wait until PLLB has locked.
95 */
96 .macro wait_pllblock
97 mov r4, #PLLBLOCK_TIMEOUT
981: sub r4, r4, #1
99 cmp r4, #0
100 beq 2f
101 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
102 tst r3, #AT91_PMC_LOCKB
103 beq 1b
1042:
105 .endm
106
107 .text
108
109ENTRY(at91_slow_clock)
110 /* Save registers on stack */
111 stmfd sp!, {r0 - r12, lr}
112
113 /*
114 * Register usage:
115 * R1 = Base address of AT91_PMC
116 * R2 = Base address of AT91_SDRAMC (or AT91_SYS on AT91RM9200)
117 * R3 = temporary register
118 * R4 = temporary register
119 */
120 ldr r1, .at91_va_base_pmc
121 ldr r2, .at91_va_base_sdramc
122
123 /* Drain write buffer */
124 mcr p15, 0, r0, c7, c10, 4
125
126#ifdef CONFIG_ARCH_AT91RM9200
127 /* Put SDRAM in self-refresh mode */
128 mov r3, #1
129 str r3, [r2, #AT91_SDRAMC_SRR]
130#elif defined(CONFIG_ARCH_AT91CAP9)
131 /* Enable SDRAM self-refresh mode */
132 ldr r3, [r2, #AT91_DDRSDRC_LPR - AT91_DDRSDRC]
133 str r3, .saved_sam9_lpr
134
135 mov r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH
136 str r3, [r2, #AT91_DDRSDRC_LPR - AT91_DDRSDRC]
137#else
138 /* Enable SDRAM self-refresh mode */
139 ldr r3, [r2, #AT91_SDRAMC_LPR - AT91_SDRAMC]
140 str r3, .saved_sam9_lpr
141
142 mov r3, #AT91_SDRAMC_LPCB_SELF_REFRESH
143 str r3, [r2, #AT91_SDRAMC_LPR - AT91_SDRAMC]
144#endif
145
146 /* Save Master clock setting */
147 ldr r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
148 str r3, .saved_mckr
149
150 /*
151 * Set the Master clock source to slow clock
152 */
153 bic r3, r3, #AT91_PMC_CSS
154 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
155
156 wait_mckrdy
157
158#ifdef SLOWDOWN_MASTER_CLOCK
159 /*
160 * Set the Master Clock PRES and MDIV fields.
161 *
162 * See AT91RM9200 errata #27 and #28 for details.
163 */
164 mov r3, #0
165 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
166
167 wait_mckrdy
168#endif
169
170 /* Save PLLA setting and disable it */
171 ldr r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
172 str r3, .saved_pllar
173
174 mov r3, #AT91_PMC_PLLCOUNT
175 orr r3, r3, #(1 << 29) /* bit 29 always set */
176 str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
177
178 wait_pllalock
179
180 /* Save PLLB setting and disable it */
181 ldr r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
182 str r3, .saved_pllbr
183
184 mov r3, #AT91_PMC_PLLCOUNT
185 str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
186
187 wait_pllblock
188
189 /* Turn off the main oscillator */
190 ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
191 bic r3, r3, #AT91_PMC_MOSCEN
192 str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
193
194 /* Wait for interrupt */
195 mcr p15, 0, r0, c7, c0, 4
196
197 /* Turn on the main oscillator */
198 ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
199 orr r3, r3, #AT91_PMC_MOSCEN
200 str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
201
202 wait_moscrdy
203
204 /* Restore PLLB setting */
205 ldr r3, .saved_pllbr
206 str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
207
208 wait_pllblock
209
210 /* Restore PLLA setting */
211 ldr r3, .saved_pllar
212 str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
213
214 wait_pllalock
215
216#ifdef SLOWDOWN_MASTER_CLOCK
217 /*
218 * First set PRES if it was not 0,
219 * than set CSS and MDIV fields.
220 *
221 * See AT91RM9200 errata #27 and #28 for details.
222 */
223 ldr r3, .saved_mckr
224 tst r3, #AT91_PMC_PRES
225 beq 2f
226 and r3, r3, #AT91_PMC_PRES
227 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
228
229 wait_mckrdy
230#endif
231
232 /*
233 * Restore master clock setting
234 */
2352: ldr r3, .saved_mckr
236 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
237
238 wait_mckrdy
239
240#ifdef CONFIG_ARCH_AT91RM9200
241 /* Do nothing - self-refresh is automatically disabled. */
242#elif defined(CONFIG_ARCH_AT91CAP9)
243 /* Restore LPR on AT91CAP9 */
244 ldr r3, .saved_sam9_lpr
245 str r3, [r2, #AT91_DDRSDRC_LPR - AT91_DDRSDRC]
246#else
247 /* Restore LPR on AT91SAM9 */
248 ldr r3, .saved_sam9_lpr
249 str r3, [r2, #AT91_SDRAMC_LPR - AT91_SDRAMC]
250#endif
251
252 /* Restore registers, and return */
253 ldmfd sp!, {r0 - r12, pc}
254
255
256.saved_mckr:
257 .word 0
258
259.saved_pllar:
260 .word 0
261
262.saved_pllbr:
263 .word 0
264
265.saved_sam9_lpr:
266 .word 0
267
268.at91_va_base_pmc:
269 .word AT91_VA_BASE_SYS + AT91_PMC
270
271#ifdef CONFIG_ARCH_AT91RM9200
272.at91_va_base_sdramc:
273 .word AT91_VA_BASE_SYS
274#elif defined(CONFIG_ARCH_AT91CAP9)
275.at91_va_base_sdramc:
276 .word AT91_VA_BASE_SYS + AT91_DDRSDRC
277#else
278.at91_va_base_sdramc:
279 .word AT91_VA_BASE_SYS + AT91_SDRAMC
280#endif
281
282ENTRY(at91_slow_clock_sz)
283 .word .-at91_slow_clock
diff --git a/arch/arm/mach-clps711x/autcpu12.c b/arch/arm/mach-clps711x/autcpu12.c
index 474616dcd7a6..5f18eccdc725 100644
--- a/arch/arm/mach-clps711x/autcpu12.c
+++ b/arch/arm/mach-clps711x/autcpu12.c
@@ -22,10 +22,10 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/io.h>
25 26
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/sizes.h> 28#include <asm/sizes.h>
28#include <asm/io.h>
29#include <asm/setup.h> 29#include <asm/setup.h>
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
diff --git a/arch/arm/mach-clps711x/cdb89712.c b/arch/arm/mach-clps711x/cdb89712.c
index aa02aa5a01f4..71a80b5b8ad6 100644
--- a/arch/arm/mach-clps711x/cdb89712.c
+++ b/arch/arm/mach-clps711x/cdb89712.c
@@ -22,9 +22,9 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/io.h>
25 26
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/io.h>
28#include <asm/pgtable.h> 28#include <asm/pgtable.h>
29#include <asm/page.h> 29#include <asm/page.h>
30#include <asm/setup.h> 30#include <asm/setup.h>
diff --git a/arch/arm/mach-clps711x/include/mach/system.h b/arch/arm/mach-clps711x/include/mach/system.h
index a8eade40317f..24e96159e3e7 100644
--- a/arch/arm/mach-clps711x/include/mach/system.h
+++ b/arch/arm/mach-clps711x/include/mach/system.h
@@ -20,9 +20,9 @@
20#ifndef __ASM_ARCH_SYSTEM_H 20#ifndef __ASM_ARCH_SYSTEM_H
21#define __ASM_ARCH_SYSTEM_H 21#define __ASM_ARCH_SYSTEM_H
22 22
23#include <linux/io.h>
23#include <mach/hardware.h> 24#include <mach/hardware.h>
24#include <asm/hardware/clps7111.h> 25#include <asm/hardware/clps7111.h>
25#include <asm/io.h>
26 26
27static inline void arch_idle(void) 27static inline void arch_idle(void)
28{ 28{
diff --git a/arch/arm/mach-clps711x/irq.c b/arch/arm/mach-clps711x/irq.c
index 38623cfcac5a..9a12d8562284 100644
--- a/arch/arm/mach-clps711x/irq.c
+++ b/arch/arm/mach-clps711x/irq.c
@@ -19,10 +19,10 @@
19 */ 19 */
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/io.h>
22 23
23#include <asm/mach/irq.h> 24#include <asm/mach/irq.h>
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/io.h>
26#include <asm/irq.h> 26#include <asm/irq.h>
27 27
28#include <asm/hardware/clps7111.h> 28#include <asm/hardware/clps7111.h>
diff --git a/arch/arm/mach-clps711x/p720t-leds.c b/arch/arm/mach-clps711x/p720t-leds.c
index 262c3c361453..15121446efc8 100644
--- a/arch/arm/mach-clps711x/p720t-leds.c
+++ b/arch/arm/mach-clps711x/p720t-leds.c
@@ -21,9 +21,9 @@
21 */ 21 */
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/io.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/io.h>
27#include <asm/leds.h> 27#include <asm/leds.h>
28#include <asm/system.h> 28#include <asm/system.h>
29#include <asm/mach-types.h> 29#include <asm/mach-types.h>
diff --git a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c
index f51f97d4f212..0d94a30fd6fc 100644
--- a/arch/arm/mach-clps711x/p720t.c
+++ b/arch/arm/mach-clps711x/p720t.c
@@ -22,9 +22,9 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/io.h>
25 26
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/io.h>
28#include <asm/pgtable.h> 28#include <asm/pgtable.h>
29#include <asm/page.h> 29#include <asm/page.h>
30#include <asm/setup.h> 30#include <asm/setup.h>
diff --git a/arch/arm/mach-clps711x/time.c b/arch/arm/mach-clps711x/time.c
index ef1fcd17189e..d581ef0bcd24 100644
--- a/arch/arm/mach-clps711x/time.c
+++ b/arch/arm/mach-clps711x/time.c
@@ -21,11 +21,11 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/irq.h> 22#include <linux/irq.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/io.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/irq.h> 27#include <asm/irq.h>
27#include <asm/leds.h> 28#include <asm/leds.h>
28#include <asm/io.h>
29#include <asm/hardware/clps7111.h> 29#include <asm/hardware/clps7111.h>
30 30
31#include <asm/mach/time.h> 31#include <asm/mach/time.h>
diff --git a/arch/arm/mach-clps7500/core.c b/arch/arm/mach-clps7500/core.c
index cc1b82179e83..c3a33b8a5aac 100644
--- a/arch/arm/mach-clps7500/core.c
+++ b/arch/arm/mach-clps7500/core.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/serial_8250.h> 17#include <linux/serial_8250.h>
18#include <linux/io.h>
18 19
19#include <asm/mach/arch.h> 20#include <asm/mach/arch.h>
20#include <asm/mach/map.h> 21#include <asm/mach/map.h>
@@ -23,7 +24,6 @@
23 24
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/hardware/iomd.h> 26#include <asm/hardware/iomd.h>
26#include <asm/io.h>
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/mach-types.h> 28#include <asm/mach-types.h>
29 29
diff --git a/arch/arm/mach-clps7500/include/mach/irq.h b/arch/arm/mach-clps7500/include/mach/irq.h
index e8da3c58df76..d02fcf28ee05 100644
--- a/arch/arm/mach-clps7500/include/mach/irq.h
+++ b/arch/arm/mach-clps7500/include/mach/irq.h
@@ -10,8 +10,8 @@
10 * 11-08-1999 PJB Created ARM7500 version, derived from RiscPC code 10 * 11-08-1999 PJB Created ARM7500 version, derived from RiscPC code
11 */ 11 */
12 12
13#include <linux/io.h>
13#include <asm/hardware/iomd.h> 14#include <asm/hardware/iomd.h>
14#include <asm/io.h>
15 15
16static inline int fixup_irq(unsigned int irq) 16static inline int fixup_irq(unsigned int irq)
17{ 17{
diff --git a/arch/arm/mach-clps7500/include/mach/memory.h b/arch/arm/mach-clps7500/include/mach/memory.h
index 3326aa99d3ec..87b32db470c8 100644
--- a/arch/arm/mach-clps7500/include/mach/memory.h
+++ b/arch/arm/mach-clps7500/include/mach/memory.h
@@ -32,4 +32,12 @@
32#define FLUSH_BASE_PHYS 0x00000000 32#define FLUSH_BASE_PHYS 0x00000000
33#define FLUSH_BASE 0xdf000000 33#define FLUSH_BASE 0xdf000000
34 34
35/*
36 * Sparsemem support. Each section is a maximum of 64MB. The sections
37 * are offset by 128MB and can cover 128MB, so that gives us a maximum
38 * of 29 physmem bits.
39 */
40#define MAX_PHYSMEM_BITS 29
41#define SECTION_SIZE_BITS 26
42
35#endif 43#endif
diff --git a/arch/arm/mach-clps7500/include/mach/system.h b/arch/arm/mach-clps7500/include/mach/system.h
index 624fc2830ae0..6d325fbe8b08 100644
--- a/arch/arm/mach-clps7500/include/mach/system.h
+++ b/arch/arm/mach-clps7500/include/mach/system.h
@@ -6,8 +6,8 @@
6#ifndef __ASM_ARCH_SYSTEM_H 6#ifndef __ASM_ARCH_SYSTEM_H
7#define __ASM_ARCH_SYSTEM_H 7#define __ASM_ARCH_SYSTEM_H
8 8
9#include <linux/io.h>
9#include <asm/hardware/iomd.h> 10#include <asm/hardware/iomd.h>
10#include <asm/io.h>
11 11
12static inline void arch_idle(void) 12static inline void arch_idle(void)
13{ 13{
diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index 99ac2e55774d..4dc458597f40 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -5,7 +5,7 @@
5 5
6# Common objects 6# Common objects
7obj-y := time.o irq.o clock.o serial.o io.o id.o psc.o \ 7obj-y := time.o irq.o clock.o serial.o io.o id.o psc.o \
8 gpio.o mux.o 8 gpio.o mux.o devices.o usb.o
9 9
10# Board specific 10# Board specific
11obj-$(CONFIG_MACH_DAVINCI_EVM) += board-evm.o 11obj-$(CONFIG_MACH_DAVINCI_EVM) += board-evm.o
diff --git a/arch/arm/mach-davinci/board-evm.c b/arch/arm/mach-davinci/board-evm.c
index 134355787814..a957d239a683 100644
--- a/arch/arm/mach-davinci/board-evm.c
+++ b/arch/arm/mach-davinci/board-evm.c
@@ -13,20 +13,28 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/gpio.h>
17#include <linux/leds.h>
18
19#include <linux/i2c.h>
20#include <linux/i2c/pcf857x.h>
21#include <linux/i2c/at24.h>
22
16#include <linux/mtd/mtd.h> 23#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h> 24#include <linux/mtd/partitions.h>
18#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
26#include <linux/io.h>
19 27
20#include <asm/setup.h> 28#include <asm/setup.h>
21#include <asm/io.h>
22#include <asm/mach-types.h> 29#include <asm/mach-types.h>
23#include <mach/hardware.h>
24 30
25#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
26#include <asm/mach/map.h> 32#include <asm/mach/map.h>
27#include <asm/mach/flash.h> 33#include <asm/mach/flash.h>
28 34
35#include <mach/hardware.h>
29#include <mach/common.h> 36#include <mach/common.h>
37#include <mach/i2c.h>
30 38
31/* other misc. init functions */ 39/* other misc. init functions */
32void __init davinci_psc_init(void); 40void __init davinci_psc_init(void);
@@ -34,10 +42,10 @@ void __init davinci_irq_init(void);
34void __init davinci_map_common_io(void); 42void __init davinci_map_common_io(void);
35void __init davinci_init_common_hw(void); 43void __init davinci_init_common_hw(void);
36 44
37/* NOR Flash base address set to CS0 by default */ 45#if defined(CONFIG_MTD_PHYSMAP) || \
38#define NOR_FLASH_PHYS 0x02000000 46 defined(CONFIG_MTD_PHYSMAP_MODULE)
39 47
40static struct mtd_partition davinci_evm_partitions[] = { 48static struct mtd_partition davinci_evm_norflash_partitions[] = {
41 /* bootloader (U-Boot, etc) in first 4 sectors */ 49 /* bootloader (U-Boot, etc) in first 4 sectors */
42 { 50 {
43 .name = "bootloader", 51 .name = "bootloader",
@@ -68,32 +76,323 @@ static struct mtd_partition davinci_evm_partitions[] = {
68 } 76 }
69}; 77};
70 78
71static struct physmap_flash_data davinci_evm_flash_data = { 79static struct physmap_flash_data davinci_evm_norflash_data = {
72 .width = 2, 80 .width = 2,
73 .parts = davinci_evm_partitions, 81 .parts = davinci_evm_norflash_partitions,
74 .nr_parts = ARRAY_SIZE(davinci_evm_partitions), 82 .nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions),
75}; 83};
76 84
77/* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF 85/* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF
78 * limits addresses to 16M, so using addresses past 16M will wrap */ 86 * limits addresses to 16M, so using addresses past 16M will wrap */
79static struct resource davinci_evm_flash_resource = { 87static struct resource davinci_evm_norflash_resource = {
80 .start = NOR_FLASH_PHYS, 88 .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
81 .end = NOR_FLASH_PHYS + SZ_16M - 1, 89 .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
82 .flags = IORESOURCE_MEM, 90 .flags = IORESOURCE_MEM,
83}; 91};
84 92
85static struct platform_device davinci_evm_flash_device = { 93static struct platform_device davinci_evm_norflash_device = {
86 .name = "physmap-flash", 94 .name = "physmap-flash",
87 .id = 0, 95 .id = 0,
88 .dev = { 96 .dev = {
89 .platform_data = &davinci_evm_flash_data, 97 .platform_data = &davinci_evm_norflash_data,
90 }, 98 },
91 .num_resources = 1, 99 .num_resources = 1,
92 .resource = &davinci_evm_flash_resource, 100 .resource = &davinci_evm_norflash_resource,
101};
102
103#endif
104
105#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
106 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
107
108static struct resource ide_resources[] = {
109 {
110 .start = DAVINCI_CFC_ATA_BASE,
111 .end = DAVINCI_CFC_ATA_BASE + 0x7ff,
112 .flags = IORESOURCE_MEM,
113 },
114 {
115 .start = IRQ_IDE,
116 .end = IRQ_IDE,
117 .flags = IORESOURCE_IRQ,
118 },
119};
120
121static u64 ide_dma_mask = DMA_32BIT_MASK;
122
123static struct platform_device ide_dev = {
124 .name = "palm_bk3710",
125 .id = -1,
126 .resource = ide_resources,
127 .num_resources = ARRAY_SIZE(ide_resources),
128 .dev = {
129 .dma_mask = &ide_dma_mask,
130 .coherent_dma_mask = DMA_32BIT_MASK,
131 },
132};
133
134#endif
135
136/*----------------------------------------------------------------------*/
137
138/*
139 * I2C GPIO expanders
140 */
141
142#define PCF_Uxx_BASE(x) (DAVINCI_N_GPIO + ((x) * 8))
143
144
145/* U2 -- LEDs */
146
147static struct gpio_led evm_leds[] = {
148 { .name = "DS8", .active_low = 1,
149 .default_trigger = "heartbeat", },
150 { .name = "DS7", .active_low = 1, },
151 { .name = "DS6", .active_low = 1, },
152 { .name = "DS5", .active_low = 1, },
153 { .name = "DS4", .active_low = 1, },
154 { .name = "DS3", .active_low = 1, },
155 { .name = "DS2", .active_low = 1,
156 .default_trigger = "mmc0", },
157 { .name = "DS1", .active_low = 1,
158 .default_trigger = "ide-disk", },
159};
160
161static const struct gpio_led_platform_data evm_led_data = {
162 .num_leds = ARRAY_SIZE(evm_leds),
163 .leds = evm_leds,
164};
165
166static struct platform_device *evm_led_dev;
167
168static int
169evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
170{
171 struct gpio_led *leds = evm_leds;
172 int status;
173
174 while (ngpio--) {
175 leds->gpio = gpio++;
176 leds++;
177 }
178
179 /* what an extremely annoying way to be forced to handle
180 * device unregistration ...
181 */
182 evm_led_dev = platform_device_alloc("leds-gpio", 0);
183 platform_device_add_data(evm_led_dev,
184 &evm_led_data, sizeof evm_led_data);
185
186 evm_led_dev->dev.parent = &client->dev;
187 status = platform_device_add(evm_led_dev);
188 if (status < 0) {
189 platform_device_put(evm_led_dev);
190 evm_led_dev = NULL;
191 }
192 return status;
193}
194
195static int
196evm_led_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
197{
198 if (evm_led_dev) {
199 platform_device_unregister(evm_led_dev);
200 evm_led_dev = NULL;
201 }
202 return 0;
203}
204
205static struct pcf857x_platform_data pcf_data_u2 = {
206 .gpio_base = PCF_Uxx_BASE(0),
207 .setup = evm_led_setup,
208 .teardown = evm_led_teardown,
209};
210
211
212/* U18 - A/V clock generator and user switch */
213
214static int sw_gpio;
215
216static ssize_t
217sw_show(struct device *d, struct device_attribute *a, char *buf)
218{
219 char *s = gpio_get_value_cansleep(sw_gpio) ? "on\n" : "off\n";
220
221 strcpy(buf, s);
222 return strlen(s);
223}
224
225static DEVICE_ATTR(user_sw, S_IRUGO, sw_show, NULL);
226
227static int
228evm_u18_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
229{
230 int status;
231
232 /* export dip switch option */
233 sw_gpio = gpio + 7;
234 status = gpio_request(sw_gpio, "user_sw");
235 if (status == 0)
236 status = gpio_direction_input(sw_gpio);
237 if (status == 0)
238 status = device_create_file(&client->dev, &dev_attr_user_sw);
239 else
240 gpio_free(sw_gpio);
241 if (status != 0)
242 sw_gpio = -EINVAL;
243
244 /* audio PLL: 48 kHz (vs 44.1 or 32), single rate (vs double) */
245 gpio_request(gpio + 3, "pll_fs2");
246 gpio_direction_output(gpio + 3, 0);
247
248 gpio_request(gpio + 2, "pll_fs1");
249 gpio_direction_output(gpio + 2, 0);
250
251 gpio_request(gpio + 1, "pll_sr");
252 gpio_direction_output(gpio + 1, 0);
253
254 return 0;
255}
256
257static int
258evm_u18_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
259{
260 gpio_free(gpio + 1);
261 gpio_free(gpio + 2);
262 gpio_free(gpio + 3);
263
264 if (sw_gpio > 0) {
265 device_remove_file(&client->dev, &dev_attr_user_sw);
266 gpio_free(sw_gpio);
267 }
268 return 0;
269}
270
271static struct pcf857x_platform_data pcf_data_u18 = {
272 .gpio_base = PCF_Uxx_BASE(1),
273 .n_latch = (1 << 3) | (1 << 2) | (1 << 1),
274 .setup = evm_u18_setup,
275 .teardown = evm_u18_teardown,
93}; 276};
94 277
278
279/* U35 - various I/O signals used to manage USB, CF, ATA, etc */
280
281static int
282evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
283{
284 /* p0 = nDRV_VBUS (initial: don't supply it) */
285 gpio_request(gpio + 0, "nDRV_VBUS");
286 gpio_direction_output(gpio + 0, 1);
287
288 /* p1 = VDDIMX_EN */
289 gpio_request(gpio + 1, "VDDIMX_EN");
290 gpio_direction_output(gpio + 1, 1);
291
292 /* p2 = VLYNQ_EN */
293 gpio_request(gpio + 2, "VLYNQ_EN");
294 gpio_direction_output(gpio + 2, 1);
295
296 /* p3 = n3V3_CF_RESET (initial: stay in reset) */
297 gpio_request(gpio + 3, "nCF_RESET");
298 gpio_direction_output(gpio + 3, 0);
299
300 /* (p4 unused) */
301
302 /* p5 = 1V8_WLAN_RESET (initial: stay in reset) */
303 gpio_request(gpio + 5, "WLAN_RESET");
304 gpio_direction_output(gpio + 5, 1);
305
306 /* p6 = nATA_SEL (initial: select) */
307 gpio_request(gpio + 6, "nATA_SEL");
308 gpio_direction_output(gpio + 6, 0);
309
310 /* p7 = nCF_SEL (initial: deselect) */
311 gpio_request(gpio + 7, "nCF_SEL");
312 gpio_direction_output(gpio + 7, 1);
313
314 return 0;
315}
316
317static int
318evm_u35_teardown(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
319{
320 gpio_free(gpio + 7);
321 gpio_free(gpio + 6);
322 gpio_free(gpio + 5);
323 gpio_free(gpio + 3);
324 gpio_free(gpio + 2);
325 gpio_free(gpio + 1);
326 gpio_free(gpio + 0);
327 return 0;
328}
329
330static struct pcf857x_platform_data pcf_data_u35 = {
331 .gpio_base = PCF_Uxx_BASE(2),
332 .setup = evm_u35_setup,
333 .teardown = evm_u35_teardown,
334};
335
336/*----------------------------------------------------------------------*/
337
338/* Most of this EEPROM is unused, but U-Boot uses some data:
339 * - 0x7f00, 6 bytes Ethernet Address
340 * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL)
341 * - ... newer boards may have more
342 */
343static struct at24_platform_data eeprom_info = {
344 .byte_len = (256*1024) / 8,
345 .page_size = 64,
346 .flags = AT24_FLAG_ADDR16,
347};
348
349static struct i2c_board_info __initdata i2c_info[] = {
350 {
351 I2C_BOARD_INFO("pcf8574", 0x38),
352 .platform_data = &pcf_data_u2,
353 },
354 {
355 I2C_BOARD_INFO("pcf8574", 0x39),
356 .platform_data = &pcf_data_u18,
357 },
358 {
359 I2C_BOARD_INFO("pcf8574", 0x3a),
360 .platform_data = &pcf_data_u35,
361 },
362 {
363 I2C_BOARD_INFO("24c256", 0x50),
364 .platform_data = &eeprom_info,
365 },
366 /* ALSO:
367 * - tvl320aic33 audio codec (0x1b)
368 * - msp430 microcontroller (0x23)
369 * - tvp5146 video decoder (0x5d)
370 */
371};
372
373/* The msp430 uses a slow bitbanged I2C implementation (ergo 20 KHz),
374 * which requires 100 usec of idle bus after i2c writes sent to it.
375 */
376static struct davinci_i2c_platform_data i2c_pdata = {
377 .bus_freq = 20 /* kHz */,
378 .bus_delay = 100 /* usec */,
379};
380
381static void __init evm_init_i2c(void)
382{
383 davinci_init_i2c(&i2c_pdata);
384 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
385}
386
95static struct platform_device *davinci_evm_devices[] __initdata = { 387static struct platform_device *davinci_evm_devices[] __initdata = {
96 &davinci_evm_flash_device, 388#if defined(CONFIG_MTD_PHYSMAP) || \
389 defined(CONFIG_MTD_PHYSMAP_MODULE)
390 &davinci_evm_norflash_device,
391#endif
392#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
393 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
394 &ide_dev,
395#endif
97}; 396};
98 397
99static void __init 398static void __init
@@ -106,13 +405,21 @@ static __init void davinci_evm_init(void)
106{ 405{
107 davinci_psc_init(); 406 davinci_psc_init();
108 407
109#if defined(CONFIG_BLK_DEV_DAVINCI) || defined(CONFIG_BLK_DEV_DAVINCI_MODULE) 408#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
409 defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
410#if defined(CONFIG_MTD_PHYSMAP) || \
411 defined(CONFIG_MTD_PHYSMAP_MODULE)
110 printk(KERN_WARNING "WARNING: both IDE and NOR flash are enabled, " 412 printk(KERN_WARNING "WARNING: both IDE and NOR flash are enabled, "
111 "but share pins.\n\t Disable IDE for NOR support.\n"); 413 "but share pins.\n\t Disable IDE for NOR support.\n");
112#endif 414#endif
415#endif
113 416
114 platform_add_devices(davinci_evm_devices, 417 platform_add_devices(davinci_evm_devices,
115 ARRAY_SIZE(davinci_evm_devices)); 418 ARRAY_SIZE(davinci_evm_devices));
419 evm_init_i2c();
420
421 /* irlml6401 sustains over 3A, switches 5V in under 8 msec */
422 setup_usb(500, 8);
116} 423}
117 424
118static __init void davinci_evm_irq_init(void) 425static __init void davinci_evm_irq_init(void)
@@ -124,7 +431,7 @@ static __init void davinci_evm_irq_init(void)
124MACHINE_START(DAVINCI_EVM, "DaVinci EVM") 431MACHINE_START(DAVINCI_EVM, "DaVinci EVM")
125 /* Maintainer: MontaVista Software <source@mvista.com> */ 432 /* Maintainer: MontaVista Software <source@mvista.com> */
126 .phys_io = IO_PHYS, 433 .phys_io = IO_PHYS,
127 .io_pg_offst = (io_p2v(IO_PHYS) >> 18) & 0xfffc, 434 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
128 .boot_params = (DAVINCI_DDR_BASE + 0x100), 435 .boot_params = (DAVINCI_DDR_BASE + 0x100),
129 .map_io = davinci_evm_map_io, 436 .map_io = davinci_evm_map_io,
130 .init_irq = davinci_evm_irq_init, 437 .init_irq = davinci_evm_irq_init,
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index d46c69b55aaa..28f6dbc95bd7 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -16,9 +16,9 @@
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/io.h>
19 20
20#include <mach/hardware.h> 21#include <mach/hardware.h>
21#include <asm/io.h>
22 22
23#include <mach/psc.h> 23#include <mach/psc.h>
24#include "clock.h" 24#include "clock.h"
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
new file mode 100644
index 000000000000..3d4b1de8f898
--- /dev/null
+++ b/arch/arm/mach-davinci/devices.c
@@ -0,0 +1,48 @@
1/*
2 * mach-davinci/devices.c
3 *
4 * DaVinci platform device setup/initialization
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/dma-mapping.h>
17#include <linux/io.h>
18
19#include <asm/mach/map.h>
20
21#include <mach/hardware.h>
22#include <mach/i2c.h>
23
24static struct resource i2c_resources[] = {
25 {
26 .start = DAVINCI_I2C_BASE,
27 .end = DAVINCI_I2C_BASE + 0x40,
28 .flags = IORESOURCE_MEM,
29 },
30 {
31 .start = IRQ_I2C,
32 .flags = IORESOURCE_IRQ,
33 },
34};
35
36static struct platform_device davinci_i2c_device = {
37 .name = "i2c_davinci",
38 .id = 1,
39 .num_resources = ARRAY_SIZE(i2c_resources),
40 .resource = i2c_resources,
41};
42
43void __init davinci_init_i2c(struct davinci_i2c_platform_data *pdata)
44{
45 davinci_i2c_device.dev.platform_data = pdata;
46 (void) platform_device_register(&davinci_i2c_device);
47}
48
diff --git a/arch/arm/mach-davinci/gpio.c b/arch/arm/mach-davinci/gpio.c
index c9cb4f09b18f..b49e9d092aab 100644
--- a/arch/arm/mach-davinci/gpio.c
+++ b/arch/arm/mach-davinci/gpio.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * TI DaVinci GPIO Support 2 * TI DaVinci GPIO Support
3 * 3 *
4 * Copyright (c) 2006 David Brownell 4 * Copyright (c) 2006-2007 David Brownell
5 * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com> 5 * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -26,47 +26,45 @@
26 26
27#include <asm/mach/irq.h> 27#include <asm/mach/irq.h>
28 28
29static DEFINE_SPINLOCK(gpio_lock);
30static DECLARE_BITMAP(gpio_in_use, DAVINCI_N_GPIO);
31 29
32int gpio_request(unsigned gpio, const char *tag) 30static DEFINE_SPINLOCK(gpio_lock);
33{
34 if (gpio >= DAVINCI_N_GPIO)
35 return -EINVAL;
36 31
37 if (test_and_set_bit(gpio, gpio_in_use)) 32struct davinci_gpio {
38 return -EBUSY; 33 struct gpio_chip chip;
34 struct gpio_controller *__iomem regs;
35};
39 36
40 return 0; 37static struct davinci_gpio chips[DIV_ROUND_UP(DAVINCI_N_GPIO, 32)];
41}
42EXPORT_SYMBOL(gpio_request);
43 38
44void gpio_free(unsigned gpio)
45{
46 if (gpio >= DAVINCI_N_GPIO)
47 return;
48
49 clear_bit(gpio, gpio_in_use);
50}
51EXPORT_SYMBOL(gpio_free);
52 39
53/* create a non-inlined version */ 40/* create a non-inlined version */
54static struct gpio_controller *__iomem gpio2controller(unsigned gpio) 41static struct gpio_controller *__iomem __init gpio2controller(unsigned gpio)
55{ 42{
56 return __gpio_to_controller(gpio); 43 return __gpio_to_controller(gpio);
57} 44}
58 45
46
47/*--------------------------------------------------------------------------*/
48
59/* 49/*
60 * Assuming the pin is muxed as a gpio output, set its output value. 50 * board setup code *MUST* set PINMUX0 and PINMUX1 as
51 * needed, and enable the GPIO clock.
61 */ 52 */
62void __gpio_set(unsigned gpio, int value) 53
54static int davinci_direction_in(struct gpio_chip *chip, unsigned offset)
63{ 55{
64 struct gpio_controller *__iomem g = gpio2controller(gpio); 56 struct davinci_gpio *d = container_of(chip, struct davinci_gpio, chip);
57 struct gpio_controller *__iomem g = d->regs;
58 u32 temp;
65 59
66 __raw_writel(__gpio_mask(gpio), value ? &g->set_data : &g->clr_data); 60 spin_lock(&gpio_lock);
67} 61 temp = __raw_readl(&g->dir);
68EXPORT_SYMBOL(__gpio_set); 62 temp |= (1 << offset);
63 __raw_writel(temp, &g->dir);
64 spin_unlock(&gpio_lock);
69 65
66 return 0;
67}
70 68
71/* 69/*
72 * Read the pin's value (works even if it's set up as output); 70 * Read the pin's value (works even if it's set up as output);
@@ -75,61 +73,72 @@ EXPORT_SYMBOL(__gpio_set);
75 * Note that changes are synched to the GPIO clock, so reading values back 73 * Note that changes are synched to the GPIO clock, so reading values back
76 * right after you've set them may give old values. 74 * right after you've set them may give old values.
77 */ 75 */
78int __gpio_get(unsigned gpio) 76static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset)
79{ 77{
80 struct gpio_controller *__iomem g = gpio2controller(gpio); 78 struct davinci_gpio *d = container_of(chip, struct davinci_gpio, chip);
79 struct gpio_controller *__iomem g = d->regs;
81 80
82 return !!(__gpio_mask(gpio) & __raw_readl(&g->in_data)); 81 return (1 << offset) & __raw_readl(&g->in_data);
83} 82}
84EXPORT_SYMBOL(__gpio_get);
85 83
86 84static int
87/*--------------------------------------------------------------------------*/ 85davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value)
88
89/*
90 * board setup code *MUST* set PINMUX0 and PINMUX1 as
91 * needed, and enable the GPIO clock.
92 */
93
94int gpio_direction_input(unsigned gpio)
95{ 86{
96 struct gpio_controller *__iomem g = gpio2controller(gpio); 87 struct davinci_gpio *d = container_of(chip, struct davinci_gpio, chip);
88 struct gpio_controller *__iomem g = d->regs;
97 u32 temp; 89 u32 temp;
98 u32 mask; 90 u32 mask = 1 << offset;
99
100 if (!g)
101 return -EINVAL;
102 91
103 spin_lock(&gpio_lock); 92 spin_lock(&gpio_lock);
104 mask = __gpio_mask(gpio);
105 temp = __raw_readl(&g->dir); 93 temp = __raw_readl(&g->dir);
106 temp |= mask; 94 temp &= ~mask;
95 __raw_writel(mask, value ? &g->set_data : &g->clr_data);
107 __raw_writel(temp, &g->dir); 96 __raw_writel(temp, &g->dir);
108 spin_unlock(&gpio_lock); 97 spin_unlock(&gpio_lock);
109 return 0; 98 return 0;
110} 99}
111EXPORT_SYMBOL(gpio_direction_input);
112 100
113int gpio_direction_output(unsigned gpio, int value) 101/*
102 * Assuming the pin is muxed as a gpio output, set its output value.
103 */
104static void
105davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
114{ 106{
115 struct gpio_controller *__iomem g = gpio2controller(gpio); 107 struct davinci_gpio *d = container_of(chip, struct davinci_gpio, chip);
116 u32 temp; 108 struct gpio_controller *__iomem g = d->regs;
117 u32 mask;
118 109
119 if (!g) 110 __raw_writel((1 << offset), value ? &g->set_data : &g->clr_data);
120 return -EINVAL; 111}
112
113static int __init davinci_gpio_setup(void)
114{
115 int i, base;
116
117 for (i = 0, base = 0;
118 i < ARRAY_SIZE(chips);
119 i++, base += 32) {
120 chips[i].chip.label = "DaVinci";
121
122 chips[i].chip.direction_input = davinci_direction_in;
123 chips[i].chip.get = davinci_gpio_get;
124 chips[i].chip.direction_output = davinci_direction_out;
125 chips[i].chip.set = davinci_gpio_set;
126
127 chips[i].chip.base = base;
128 chips[i].chip.ngpio = DAVINCI_N_GPIO - base;
129 if (chips[i].chip.ngpio > 32)
130 chips[i].chip.ngpio = 32;
131
132 chips[i].regs = gpio2controller(base);
133
134 gpiochip_add(&chips[i].chip);
135 }
121 136
122 spin_lock(&gpio_lock);
123 mask = __gpio_mask(gpio);
124 temp = __raw_readl(&g->dir);
125 temp &= ~mask;
126 __raw_writel(mask, value ? &g->set_data : &g->clr_data);
127 __raw_writel(temp, &g->dir);
128 spin_unlock(&gpio_lock);
129 return 0; 137 return 0;
130} 138}
131EXPORT_SYMBOL(gpio_direction_output); 139pure_initcall(davinci_gpio_setup);
132 140
141/*--------------------------------------------------------------------------*/
133/* 142/*
134 * We expect irqs will normally be set up as input pins, but they can also be 143 * We expect irqs will normally be set up as input pins, but they can also be
135 * used as output pins ... which is convenient for testing. 144 * used as output pins ... which is convenient for testing.
@@ -201,7 +210,6 @@ gpio_irq_handler(unsigned irq, struct irq_desc *desc)
201 desc->chip->ack(irq); 210 desc->chip->ack(irq);
202 while (1) { 211 while (1) {
203 u32 status; 212 u32 status;
204 struct irq_desc *gpio;
205 int n; 213 int n;
206 int res; 214 int res;
207 215
@@ -215,12 +223,10 @@ gpio_irq_handler(unsigned irq, struct irq_desc *desc)
215 223
216 /* now demux them to the right lowlevel handler */ 224 /* now demux them to the right lowlevel handler */
217 n = (int)get_irq_data(irq); 225 n = (int)get_irq_data(irq);
218 gpio = &irq_desc[n];
219 while (status) { 226 while (status) {
220 res = ffs(status); 227 res = ffs(status);
221 n += res; 228 n += res;
222 gpio += res; 229 generic_handle_irq(n - 1);
223 desc_handle_irq(n - 1, gpio - 1);
224 status >>= res; 230 status >>= res;
225 } 231 }
226 } 232 }
diff --git a/arch/arm/mach-davinci/id.c b/arch/arm/mach-davinci/id.c
index 70608f76aed8..bf067d604918 100644
--- a/arch/arm/mach-davinci/id.c
+++ b/arch/arm/mach-davinci/id.c
@@ -13,8 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16 16#include <linux/io.h>
17#include <asm/io.h>
18 17
19#define JTAG_ID_BASE 0x01c40028 18#define JTAG_ID_BASE 0x01c40028
20 19
diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h
index a97dfbb15e57..4b522e5c70ec 100644
--- a/arch/arm/mach-davinci/include/mach/common.h
+++ b/arch/arm/mach-davinci/include/mach/common.h
@@ -16,4 +16,7 @@ struct sys_timer;
16 16
17extern struct sys_timer davinci_timer; 17extern struct sys_timer davinci_timer;
18 18
19/* parameters describe VBUS sourcing for host mode */
20extern void setup_usb(unsigned mA, unsigned potpgt_msec);
21
19#endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */ 22#endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */
diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h
index ec151ccf1e8f..b3a2961f0f46 100644
--- a/arch/arm/mach-davinci/include/mach/gpio.h
+++ b/arch/arm/mach-davinci/include/mach/gpio.h
@@ -14,6 +14,7 @@
14#define __DAVINCI_GPIO_H 14#define __DAVINCI_GPIO_H
15 15
16#include <linux/io.h> 16#include <linux/io.h>
17#include <asm-generic/gpio.h>
17#include <mach/hardware.h> 18#include <mach/hardware.h>
18 19
19/* 20/*
@@ -27,13 +28,16 @@
27 * need to pay attention to PINMUX0 and PINMUX1 to be sure those pins are 28 * need to pay attention to PINMUX0 and PINMUX1 to be sure those pins are
28 * used as gpios, not with other peripherals. 29 * used as gpios, not with other peripherals.
29 * 30 *
30 * GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation, and maybe 31 * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation,
31 * for later updates, code should write GPIO(N) or: 32 * and maybe for later updates, code should write GPIO(N) or:
32 * - GPIOV18(N) for 1.8V pins, N in 0..53; same as GPIO(0)..GPIO(53) 33 * - GPIOV18(N) for 1.8V pins, N in 0..53; same as GPIO(0)..GPIO(53)
33 * - GPIOV33(N) for 3.3V pins, N in 0..17; same as GPIO(54)..GPIO(70) 34 * - GPIOV33(N) for 3.3V pins, N in 0..17; same as GPIO(54)..GPIO(70)
34 * 35 *
35 * For GPIO IRQs use gpio_to_irq(GPIO(N)) or gpio_to_irq(GPIOV33(N)) etc 36 * For GPIO IRQs use gpio_to_irq(GPIO(N)) or gpio_to_irq(GPIOV33(N)) etc
36 * for now, that's != GPIO(N) 37 * for now, that's != GPIO(N)
38 *
39 * GPIOs can also be on external chips, numbered after the ones built-in
40 * to the DaVinci chip. For now, they won't be usable as IRQ sources.
37 */ 41 */
38#define GPIO(X) (X) /* 0 <= X <= 70 */ 42#define GPIO(X) (X) /* 0 <= X <= 70 */
39#define GPIOV18(X) (X) /* 1.8V i/o; 0 <= X <= 53 */ 43#define GPIOV18(X) (X) /* 1.8V i/o; 0 <= X <= 53 */
@@ -67,11 +71,11 @@ __gpio_to_controller(unsigned gpio)
67 void *__iomem ptr; 71 void *__iomem ptr;
68 72
69 if (gpio < 32) 73 if (gpio < 32)
70 ptr = (void *__iomem)IO_ADDRESS(DAVINCI_GPIO_BASE + 0x10); 74 ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x10);
71 else if (gpio < 64) 75 else if (gpio < 64)
72 ptr = (void *__iomem)IO_ADDRESS(DAVINCI_GPIO_BASE + 0x38); 76 ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x38);
73 else if (gpio < DAVINCI_N_GPIO) 77 else if (gpio < DAVINCI_N_GPIO)
74 ptr = (void *__iomem)IO_ADDRESS(DAVINCI_GPIO_BASE + 0x60); 78 ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x60);
75 else 79 else
76 ptr = NULL; 80 ptr = NULL;
77 return ptr; 81 return ptr;
@@ -83,25 +87,17 @@ static inline u32 __gpio_mask(unsigned gpio)
83} 87}
84 88
85/* The get/set/clear functions will inline when called with constant 89/* The get/set/clear functions will inline when called with constant
86 * parameters, for low-overhead bitbanging. Illegal constant parameters 90 * parameters referencing built-in GPIOs, for low-overhead bitbanging.
87 * cause link-time errors.
88 * 91 *
89 * Otherwise, calls with variable parameters use outlined functions. 92 * Otherwise, calls with variable parameters or referencing external
93 * GPIOs (e.g. on GPIO expander chips) use outlined functions.
90 */ 94 */
91extern int __error_inval_gpio(void);
92
93extern void __gpio_set(unsigned gpio, int value);
94extern int __gpio_get(unsigned gpio);
95
96static inline void gpio_set_value(unsigned gpio, int value) 95static inline void gpio_set_value(unsigned gpio, int value)
97{ 96{
98 if (__builtin_constant_p(value)) { 97 if (__builtin_constant_p(value) && gpio < DAVINCI_N_GPIO) {
99 struct gpio_controller *__iomem g; 98 struct gpio_controller *__iomem g;
100 u32 mask; 99 u32 mask;
101 100
102 if (gpio >= DAVINCI_N_GPIO)
103 __error_inval_gpio();
104
105 g = __gpio_to_controller(gpio); 101 g = __gpio_to_controller(gpio);
106 mask = __gpio_mask(gpio); 102 mask = __gpio_mask(gpio);
107 if (value) 103 if (value)
@@ -111,48 +107,47 @@ static inline void gpio_set_value(unsigned gpio, int value)
111 return; 107 return;
112 } 108 }
113 109
114 __gpio_set(gpio, value); 110 __gpio_set_value(gpio, value);
115} 111}
116 112
117/* Returns zero or nonzero; works for gpios configured as inputs OR 113/* Returns zero or nonzero; works for gpios configured as inputs OR
118 * as outputs. 114 * as outputs, at least for built-in GPIOs.
119 * 115 *
120 * NOTE: changes in reported values are synchronized to the GPIO clock. 116 * NOTE: for built-in GPIOs, changes in reported values are synchronized
121 * This is most easily seen after calling gpio_set_value() and then immediatly 117 * to the GPIO clock. This is easily seen after calling gpio_set_value()
122 * gpio_get_value(), where the gpio_get_value() would return the old value 118 * and then immediately gpio_get_value(), where the gpio_get_value() will
123 * until the GPIO clock ticks and the new value gets latched. 119 * return the old value until the GPIO clock ticks and the new value gets
120 * latched.
124 */ 121 */
125
126static inline int gpio_get_value(unsigned gpio) 122static inline int gpio_get_value(unsigned gpio)
127{ 123{
128 struct gpio_controller *__iomem g; 124 struct gpio_controller *__iomem g;
129
130 if (!__builtin_constant_p(gpio))
131 return __gpio_get(gpio);
132 125
133 if (gpio >= DAVINCI_N_GPIO) 126 if (!__builtin_constant_p(gpio) || gpio >= DAVINCI_N_GPIO)
134 return __error_inval_gpio(); 127 return __gpio_get_value(gpio);
135 128
136 g = __gpio_to_controller(gpio); 129 g = __gpio_to_controller(gpio);
137 return !!(__gpio_mask(gpio) & __raw_readl(&g->in_data)); 130 return __gpio_mask(gpio) & __raw_readl(&g->in_data);
138} 131}
139 132
140/* powerup default direction is IN */ 133static inline int gpio_cansleep(unsigned gpio)
141extern int gpio_direction_input(unsigned gpio); 134{
142extern int gpio_direction_output(unsigned gpio, int value); 135 if (__builtin_constant_p(gpio) && gpio < DAVINCI_N_GPIO)
143 136 return 0;
144#include <asm-generic/gpio.h> /* cansleep wrappers */ 137 else
145 138 return __gpio_cansleep(gpio);
146extern int gpio_request(unsigned gpio, const char *tag); 139}
147extern void gpio_free(unsigned gpio);
148 140
149static inline int gpio_to_irq(unsigned gpio) 141static inline int gpio_to_irq(unsigned gpio)
150{ 142{
143 if (gpio >= DAVINCI_N_GPIO)
144 return -EINVAL;
151 return DAVINCI_N_AINTC_IRQ + gpio; 145 return DAVINCI_N_AINTC_IRQ + gpio;
152} 146}
153 147
154static inline int irq_to_gpio(unsigned irq) 148static inline int irq_to_gpio(unsigned irq)
155{ 149{
150 /* caller guarantees gpio_to_irq() succeeded */
156 return irq - DAVINCI_N_AINTC_IRQ; 151 return irq - DAVINCI_N_AINTC_IRQ;
157} 152}
158 153
diff --git a/arch/arm/mach-davinci/include/mach/i2c.h b/arch/arm/mach-davinci/include/mach/i2c.h
index e2f54168abd1..c248e9b7e825 100644
--- a/arch/arm/mach-davinci/include/mach/i2c.h
+++ b/arch/arm/mach-davinci/include/mach/i2c.h
@@ -14,8 +14,11 @@
14 14
15/* All frequencies are expressed in kHz */ 15/* All frequencies are expressed in kHz */
16struct davinci_i2c_platform_data { 16struct davinci_i2c_platform_data {
17 unsigned int bus_freq; /* standard bus frequency */ 17 unsigned int bus_freq; /* standard bus frequency (kHz) */
18 unsigned int bus_delay; /* transaction delay */ 18 unsigned int bus_delay; /* post-transaction delay (usec) */
19}; 19};
20 20
21/* for board setup code */
22void davinci_init_i2c(struct davinci_i2c_platform_data *);
23
21#endif /* __ASM_ARCH_I2C_H */ 24#endif /* __ASM_ARCH_I2C_H */
diff --git a/arch/arm/mach-davinci/include/mach/io.h b/arch/arm/mach-davinci/include/mach/io.h
index e7accb910864..b78ee9140496 100644
--- a/arch/arm/mach-davinci/include/mach/io.h
+++ b/arch/arm/mach-davinci/include/mach/io.h
@@ -22,9 +22,8 @@
22#define IO_OFFSET 0xfd000000 /* Virtual IO = 0xfec00000 */ 22#define IO_OFFSET 0xfd000000 /* Virtual IO = 0xfec00000 */
23#define IO_SIZE 0x00400000 23#define IO_SIZE 0x00400000
24#define IO_VIRT (IO_PHYS + IO_OFFSET) 24#define IO_VIRT (IO_PHYS + IO_OFFSET)
25#define io_p2v(pa) ((pa) + IO_OFFSET)
26#define io_v2p(va) ((va) - IO_OFFSET) 25#define io_v2p(va) ((va) - IO_OFFSET)
27#define IO_ADDRESS(x) io_p2v(x) 26#define __IO_ADDRESS(x) ((x) + IO_OFFSET)
28 27
29/* 28/*
30 * We don't actually have real ISA nor PCI buses, but there is so many 29 * We don't actually have real ISA nor PCI buses, but there is so many
@@ -35,7 +34,12 @@
35#define __mem_pci(a) (a) 34#define __mem_pci(a) (a)
36#define __mem_isa(a) (a) 35#define __mem_isa(a) (a)
37 36
38#ifndef __ASSEMBLER__ 37#define IO_ADDRESS(pa) IOMEM(__IO_ADDRESS(pa))
38
39#ifdef __ASSEMBLER__
40#define IOMEM(x) x
41#else
42#define IOMEM(x) ((void __force __iomem *)(x))
39 43
40/* 44/*
41 * Functions to access the DaVinci IO region 45 * Functions to access the DaVinci IO region
@@ -46,34 +50,13 @@
46 * - DO NOT use hardcoded virtual addresses to allow changing the 50 * - DO NOT use hardcoded virtual addresses to allow changing the
47 * IO address space again if needed 51 * IO address space again if needed
48 */ 52 */
49#define davinci_readb(a) (*(volatile unsigned char *)IO_ADDRESS(a)) 53#define davinci_readb(a) __raw_readb(IO_ADDRESS(a))
50#define davinci_readw(a) (*(volatile unsigned short *)IO_ADDRESS(a)) 54#define davinci_readw(a) __raw_readw(IO_ADDRESS(a))
51#define davinci_readl(a) (*(volatile unsigned int *)IO_ADDRESS(a)) 55#define davinci_readl(a) __raw_readl(IO_ADDRESS(a))
52
53#define davinci_writeb(v,a) (*(volatile unsigned char *)IO_ADDRESS(a) = (v))
54#define davinci_writew(v,a) (*(volatile unsigned short *)IO_ADDRESS(a) = (v))
55#define davinci_writel(v,a) (*(volatile unsigned int *)IO_ADDRESS(a) = (v))
56
57/* 16 bit uses LDRH/STRH, base +/- offset_8 */
58typedef struct { volatile u16 offset[256]; } __regbase16;
59#define __REGV16(vaddr) ((__regbase16 *)((vaddr)&~0xff)) \
60 ->offset[((vaddr)&0xff)>>1]
61#define __REG16(paddr) __REGV16(io_p2v(paddr))
62
63/* 8/32 bit uses LDR/STR, base +/- offset_12 */
64typedef struct { volatile u8 offset[4096]; } __regbase8;
65#define __REGV8(vaddr) ((__regbase8 *)((vaddr)&~4095)) \
66 ->offset[((vaddr)&4095)>>0]
67#define __REG8(paddr) __REGV8(io_p2v(paddr))
68
69typedef struct { volatile u32 offset[4096]; } __regbase32;
70#define __REGV32(vaddr) ((__regbase32 *)((vaddr)&~4095)) \
71 ->offset[((vaddr)&4095)>>2]
72
73#define __REG(paddr) __REGV32(io_p2v(paddr))
74#else
75 56
76#define __REG(x) (*((volatile unsigned long *)io_p2v(x))) 57#define davinci_writeb(v, a) __raw_writeb(v, IO_ADDRESS(a))
58#define davinci_writew(v, a) __raw_writew(v, IO_ADDRESS(a))
59#define davinci_writel(v, a) __raw_writel(v, IO_ADDRESS(a))
77 60
78#endif /* __ASSEMBLER__ */ 61#endif /* __ASSEMBLER__ */
79#endif /* __ASM_ARCH_IO_H */ 62#endif /* __ASM_ARCH_IO_H */
diff --git a/arch/arm/mach-davinci/include/mach/system.h b/arch/arm/mach-davinci/include/mach/system.h
index 84ff77aeb738..17ca41dc2c53 100644
--- a/arch/arm/mach-davinci/include/mach/system.h
+++ b/arch/arm/mach-davinci/include/mach/system.h
@@ -11,7 +11,7 @@
11#ifndef __ASM_ARCH_SYSTEM_H 11#ifndef __ASM_ARCH_SYSTEM_H
12#define __ASM_ARCH_SYSTEM_H 12#define __ASM_ARCH_SYSTEM_H
13 13
14#include <asm/io.h> 14#include <linux/io.h>
15#include <mach/hardware.h> 15#include <mach/hardware.h>
16 16
17extern void davinci_watchdog_reset(void); 17extern void davinci_watchdog_reset(void);
diff --git a/arch/arm/mach-davinci/io.c b/arch/arm/mach-davinci/io.c
index 5bb66b61c1a3..299515f70b8b 100644
--- a/arch/arm/mach-davinci/io.c
+++ b/arch/arm/mach-davinci/io.c
@@ -11,9 +11,9 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/io.h>
14 15
15#include <asm/tlb.h> 16#include <asm/tlb.h>
16#include <asm/io.h>
17#include <asm/memory.h> 17#include <asm/memory.h>
18 18
19#include <asm/mach/map.h> 19#include <asm/mach/map.h>
diff --git a/arch/arm/mach-davinci/irq.c b/arch/arm/mach-davinci/irq.c
index 12ca9f29f847..38021af8359a 100644
--- a/arch/arm/mach-davinci/irq.c
+++ b/arch/arm/mach-davinci/irq.c
@@ -22,9 +22,9 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/io.h>
25 26
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/io.h>
28#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
29 29
30#define IRQ_BIT(irq) ((irq) & 0x1f) 30#define IRQ_BIT(irq) ((irq) & 0x1f)
diff --git a/arch/arm/mach-davinci/psc.c b/arch/arm/mach-davinci/psc.c
index aa2fc375a325..58754f066d5b 100644
--- a/arch/arm/mach-davinci/psc.c
+++ b/arch/arm/mach-davinci/psc.c
@@ -21,8 +21,8 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/io.h>
24 25
25#include <asm/io.h>
26#include <mach/hardware.h> 26#include <mach/hardware.h>
27#include <mach/psc.h> 27#include <mach/psc.h>
28#include <mach/mux.h> 28#include <mach/mux.h>
diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c
index caf101e2cc62..3010f9971255 100644
--- a/arch/arm/mach-davinci/serial.c
+++ b/arch/arm/mach-davinci/serial.c
@@ -26,8 +26,8 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/io.h>
29 30
30#include <asm/io.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <mach/hardware.h> 32#include <mach/hardware.h>
33#include <mach/serial.h> 33#include <mach/serial.h>
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index 206e80d41717..3b9a296b5c4b 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -15,8 +15,8 @@
15#include <linux/clocksource.h> 15#include <linux/clocksource.h>
16#include <linux/clockchips.h> 16#include <linux/clockchips.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/io.h>
18 19
19#include <asm/io.h>
20#include <mach/hardware.h> 20#include <mach/hardware.h>
21#include <asm/system.h> 21#include <asm/system.h>
22#include <asm/irq.h> 22#include <asm/irq.h>
diff --git a/arch/arm/mach-davinci/usb.c b/arch/arm/mach-davinci/usb.c
new file mode 100644
index 000000000000..fe182a85159c
--- /dev/null
+++ b/arch/arm/mach-davinci/usb.c
@@ -0,0 +1,116 @@
1/*
2 * USB
3 */
4#include <linux/kernel.h>
5#include <linux/module.h>
6#include <linux/init.h>
7#include <linux/platform_device.h>
8#include <linux/dma-mapping.h>
9
10#include <linux/usb/musb.h>
11#include <linux/usb/otg.h>
12
13#include <mach/common.h>
14#include <mach/hardware.h>
15
16#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
17static struct musb_hdrc_eps_bits musb_eps[] = {
18 { "ep1_tx", 8, },
19 { "ep1_rx", 8, },
20 { "ep2_tx", 8, },
21 { "ep2_rx", 8, },
22 { "ep3_tx", 5, },
23 { "ep3_rx", 5, },
24 { "ep4_tx", 5, },
25 { "ep4_rx", 5, },
26};
27
28static struct musb_hdrc_config musb_config = {
29 .multipoint = true,
30 .dyn_fifo = true,
31 .soft_con = true,
32 .dma = true,
33
34 .num_eps = 5,
35 .dma_channels = 8,
36 .ram_bits = 10,
37 .eps_bits = musb_eps,
38};
39
40static struct musb_hdrc_platform_data usb_data = {
41#if defined(CONFIG_USB_MUSB_OTG)
42 /* OTG requires a Mini-AB connector */
43 .mode = MUSB_OTG,
44#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
45 .mode = MUSB_PERIPHERAL,
46#elif defined(CONFIG_USB_MUSB_HOST)
47 .mode = MUSB_HOST,
48#endif
49 .config = &musb_config,
50};
51
52static struct resource usb_resources[] = {
53 {
54 /* physical address */
55 .start = DAVINCI_USB_OTG_BASE,
56 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
57 .flags = IORESOURCE_MEM,
58 },
59 {
60 .start = IRQ_USBINT,
61 .flags = IORESOURCE_IRQ,
62 },
63};
64
65static u64 usb_dmamask = DMA_32BIT_MASK;
66
67static struct platform_device usb_dev = {
68 .name = "musb_hdrc",
69 .id = -1,
70 .dev = {
71 .platform_data = &usb_data,
72 .dma_mask = &usb_dmamask,
73 .coherent_dma_mask = DMA_32BIT_MASK,
74 },
75 .resource = usb_resources,
76 .num_resources = ARRAY_SIZE(usb_resources),
77};
78
79#ifdef CONFIG_USB_MUSB_OTG
80
81static struct otg_transceiver *xceiv;
82
83struct otg_transceiver *otg_get_transceiver(void)
84{
85 if (xceiv)
86 get_device(xceiv->dev);
87 return xceiv;
88}
89EXPORT_SYMBOL(otg_get_transceiver);
90
91int otg_set_transceiver(struct otg_transceiver *x)
92{
93 if (xceiv && x)
94 return -EBUSY;
95 xceiv = x;
96 return 0;
97}
98EXPORT_SYMBOL(otg_set_transceiver);
99
100#endif
101
102void __init setup_usb(unsigned mA, unsigned potpgt_msec)
103{
104 usb_data.power = mA / 2;
105 usb_data.potpgt = potpgt_msec / 2;
106 platform_device_register(&usb_dev);
107}
108
109#else
110
111void __init setup_usb(unsigned mA, unsigned potpgt_msec)
112{
113}
114
115#endif /* CONFIG_USB_MUSB_HDRC */
116
diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c
index 65cc7c271917..c7bc7fbb11a6 100644
--- a/arch/arm/mach-ebsa110/core.c
+++ b/arch/arm/mach-ebsa110/core.c
@@ -14,10 +14,10 @@
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/serial_8250.h> 15#include <linux/serial_8250.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/io.h>
17 18
18#include <mach/hardware.h> 19#include <mach/hardware.h>
19#include <asm/irq.h> 20#include <asm/irq.h>
20#include <asm/io.h>
21#include <asm/setup.h> 21#include <asm/setup.h>
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
23#include <asm/pgtable.h> 23#include <asm/pgtable.h>
diff --git a/arch/arm/mach-ebsa110/io.c b/arch/arm/mach-ebsa110/io.c
index 53748f5462e9..c52e3047a7eb 100644
--- a/arch/arm/mach-ebsa110/io.c
+++ b/arch/arm/mach-ebsa110/io.c
@@ -23,9 +23,9 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/io.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/page.h> 29#include <asm/page.h>
30 30
31static void __iomem *__isamem_convert_addr(const volatile void __iomem *addr) 31static void __iomem *__isamem_convert_addr(const volatile void __iomem *addr)
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
index ea8549bfbef2..5a1b8c05c958 100644
--- a/arch/arm/mach-ep93xx/Kconfig
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -88,6 +88,20 @@ config MACH_TS72XX
88 Say 'Y' here if you want your kernel to support the 88 Say 'Y' here if you want your kernel to support the
89 Technologic Systems TS-72xx board. 89 Technologic Systems TS-72xx board.
90 90
91choice
92 prompt "Select a UART for early kernel messages"
93
94config EP93XX_EARLY_UART1
95 bool "UART1"
96
97config EP93XX_EARLY_UART2
98 bool "UART2"
99
100config EP93XX_EARLY_UART3
101 bool "UART3"
102
103endchoice
104
91endmenu 105endmenu
92 106
93endif 107endif
diff --git a/arch/arm/mach-ep93xx/adssphere.c b/arch/arm/mach-ep93xx/adssphere.c
index aa1fb352fb8f..561db73ec1ae 100644
--- a/arch/arm/mach-ep93xx/adssphere.c
+++ b/arch/arm/mach-ep93xx/adssphere.c
@@ -18,7 +18,7 @@
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -47,36 +47,12 @@ static struct ep93xx_eth_data adssphere_eth_data = {
47 .phy_id = 1, 47 .phy_id = 1,
48}; 48};
49 49
50static struct resource adssphere_eth_resource[] = {
51 {
52 .start = EP93XX_ETHERNET_PHYS_BASE,
53 .end = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
54 .flags = IORESOURCE_MEM,
55 }, {
56 .start = IRQ_EP93XX_ETHERNET,
57 .end = IRQ_EP93XX_ETHERNET,
58 .flags = IORESOURCE_IRQ,
59 }
60};
61
62static struct platform_device adssphere_eth_device = {
63 .name = "ep93xx-eth",
64 .id = -1,
65 .dev = {
66 .platform_data = &adssphere_eth_data,
67 },
68 .num_resources = 2,
69 .resource = adssphere_eth_resource,
70};
71
72static void __init adssphere_init_machine(void) 50static void __init adssphere_init_machine(void)
73{ 51{
74 ep93xx_init_devices(); 52 ep93xx_init_devices();
75 platform_device_register(&adssphere_flash); 53 platform_device_register(&adssphere_flash);
76 54
77 memcpy(adssphere_eth_data.dev_addr, 55 ep93xx_register_eth(&adssphere_eth_data, 1);
78 (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
79 platform_device_register(&adssphere_eth_device);
80} 56}
81 57
82MACHINE_START(ADSSPHERE, "ADS Sphere board") 58MACHINE_START(ADSSPHERE, "ADS Sphere board")
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 6062e47f2043..8c9f2491dccc 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -15,9 +15,9 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/io.h>
18#include <asm/div64.h> 19#include <asm/div64.h>
19#include <mach/hardware.h> 20#include <mach/hardware.h>
20#include <asm/io.h>
21 21
22struct clk { 22struct clk {
23 char *name; 23 char *name;
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index f99f43669392..de53f0be71b9 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -32,6 +32,7 @@
32#include <linux/termios.h> 32#include <linux/termios.h>
33#include <linux/amba/bus.h> 33#include <linux/amba/bus.h>
34#include <linux/amba/serial.h> 34#include <linux/amba/serial.h>
35#include <linux/io.h>
35 36
36#include <asm/types.h> 37#include <asm/types.h>
37#include <asm/setup.h> 38#include <asm/setup.h>
@@ -41,7 +42,6 @@
41#include <asm/system.h> 42#include <asm/system.h>
42#include <asm/tlbflush.h> 43#include <asm/tlbflush.h>
43#include <asm/pgtable.h> 44#include <asm/pgtable.h>
44#include <asm/io.h>
45 45
46#include <asm/mach/map.h> 46#include <asm/mach/map.h>
47#include <asm/mach/time.h> 47#include <asm/mach/time.h>
@@ -157,7 +157,7 @@ static unsigned char gpio_int_type2[3];
157static const u8 int_type1_register_offset[3] = { 0x90, 0xac, 0x4c }; 157static const u8 int_type1_register_offset[3] = { 0x90, 0xac, 0x4c };
158static const u8 int_type2_register_offset[3] = { 0x94, 0xb0, 0x50 }; 158static const u8 int_type2_register_offset[3] = { 0x94, 0xb0, 0x50 };
159static const u8 eoi_register_offset[3] = { 0x98, 0xb4, 0x54 }; 159static const u8 eoi_register_offset[3] = { 0x98, 0xb4, 0x54 };
160static const u8 int_en_register_offset[3] = { 0x9c, 0xb8, 0x5c }; 160static const u8 int_en_register_offset[3] = { 0x9c, 0xb8, 0x58 };
161 161
162void ep93xx_gpio_update_int_params(unsigned port) 162void ep93xx_gpio_update_int_params(unsigned port)
163{ 163{
@@ -192,8 +192,7 @@ static void ep93xx_gpio_ab_irq_handler(unsigned int irq, struct irq_desc *desc)
192 for (i = 0; i < 8; i++) { 192 for (i = 0; i < 8; i++) {
193 if (status & (1 << i)) { 193 if (status & (1 << i)) {
194 int gpio_irq = gpio_to_irq(EP93XX_GPIO_LINE_A(0)) + i; 194 int gpio_irq = gpio_to_irq(EP93XX_GPIO_LINE_A(0)) + i;
195 desc = irq_desc + gpio_irq; 195 generic_handle_irq(gpio_irq);
196 desc_handle_irq(gpio_irq, desc);
197 } 196 }
198 } 197 }
199 198
@@ -202,7 +201,7 @@ static void ep93xx_gpio_ab_irq_handler(unsigned int irq, struct irq_desc *desc)
202 if (status & (1 << i)) { 201 if (status & (1 << i)) {
203 int gpio_irq = gpio_to_irq(EP93XX_GPIO_LINE_B(0)) + i; 202 int gpio_irq = gpio_to_irq(EP93XX_GPIO_LINE_B(0)) + i;
204 desc = irq_desc + gpio_irq; 203 desc = irq_desc + gpio_irq;
205 desc_handle_irq(gpio_irq, desc); 204 generic_handle_irq(gpio_irq);
206 } 205 }
207 } 206 }
208} 207}
@@ -217,7 +216,7 @@ static void ep93xx_gpio_f_irq_handler(unsigned int irq, struct irq_desc *desc)
217 int port_f_idx = ((irq + 1) & 7) ^ 4; /* {19..22,47..50} -> {0..7} */ 216 int port_f_idx = ((irq + 1) & 7) ^ 4; /* {19..22,47..50} -> {0..7} */
218 int gpio_irq = gpio_to_irq(EP93XX_GPIO_LINE_F(0)) + port_f_idx; 217 int gpio_irq = gpio_to_irq(EP93XX_GPIO_LINE_F(0)) + port_f_idx;
219 218
220 desc_handle_irq(gpio_irq, irq_desc + gpio_irq); 219 generic_handle_irq(gpio_irq);
221} 220}
222 221
223static void ep93xx_gpio_irq_ack(unsigned int irq) 222static void ep93xx_gpio_irq_ack(unsigned int irq)
@@ -461,6 +460,41 @@ static struct platform_device ep93xx_ohci_device = {
461 .resource = ep93xx_ohci_resources, 460 .resource = ep93xx_ohci_resources,
462}; 461};
463 462
463static struct ep93xx_eth_data ep93xx_eth_data;
464
465static struct resource ep93xx_eth_resource[] = {
466 {
467 .start = EP93XX_ETHERNET_PHYS_BASE,
468 .end = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
469 .flags = IORESOURCE_MEM,
470 }, {
471 .start = IRQ_EP93XX_ETHERNET,
472 .end = IRQ_EP93XX_ETHERNET,
473 .flags = IORESOURCE_IRQ,
474 }
475};
476
477static struct platform_device ep93xx_eth_device = {
478 .name = "ep93xx-eth",
479 .id = -1,
480 .dev = {
481 .platform_data = &ep93xx_eth_data,
482 },
483 .num_resources = ARRAY_SIZE(ep93xx_eth_resource),
484 .resource = ep93xx_eth_resource,
485};
486
487void __init ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr)
488{
489 if (copy_addr) {
490 memcpy(data->dev_addr,
491 (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
492 }
493
494 ep93xx_eth_data = *data;
495 platform_device_register(&ep93xx_eth_device);
496}
497
464extern void ep93xx_gpio_init(void); 498extern void ep93xx_gpio_init(void);
465 499
466void __init ep93xx_init_devices(void) 500void __init ep93xx_init_devices(void)
diff --git a/arch/arm/mach-ep93xx/edb9302.c b/arch/arm/mach-ep93xx/edb9302.c
index 97550c0ad7b0..e4add5bdccfd 100644
--- a/arch/arm/mach-ep93xx/edb9302.c
+++ b/arch/arm/mach-ep93xx/edb9302.c
@@ -18,7 +18,7 @@
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -43,10 +43,16 @@ static struct platform_device edb9302_flash = {
43 .resource = &edb9302_flash_resource, 43 .resource = &edb9302_flash_resource,
44}; 44};
45 45
46static struct ep93xx_eth_data edb9302_eth_data = {
47 .phy_id = 1,
48};
49
46static void __init edb9302_init_machine(void) 50static void __init edb9302_init_machine(void)
47{ 51{
48 ep93xx_init_devices(); 52 ep93xx_init_devices();
49 platform_device_register(&edb9302_flash); 53 platform_device_register(&edb9302_flash);
54
55 ep93xx_register_eth(&edb9302_eth_data, 1);
50} 56}
51 57
52MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board") 58MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
diff --git a/arch/arm/mach-ep93xx/edb9302a.c b/arch/arm/mach-ep93xx/edb9302a.c
index 99b01d44bf1c..02c4405afed7 100644
--- a/arch/arm/mach-ep93xx/edb9302a.c
+++ b/arch/arm/mach-ep93xx/edb9302a.c
@@ -18,7 +18,7 @@
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -47,36 +47,12 @@ static struct ep93xx_eth_data edb9302a_eth_data = {
47 .phy_id = 1, 47 .phy_id = 1,
48}; 48};
49 49
50static struct resource edb9302a_eth_resource[] = {
51 {
52 .start = EP93XX_ETHERNET_PHYS_BASE,
53 .end = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
54 .flags = IORESOURCE_MEM,
55 }, {
56 .start = IRQ_EP93XX_ETHERNET,
57 .end = IRQ_EP93XX_ETHERNET,
58 .flags = IORESOURCE_IRQ,
59 }
60};
61
62static struct platform_device edb9302a_eth_device = {
63 .name = "ep93xx-eth",
64 .id = -1,
65 .dev = {
66 .platform_data = &edb9302a_eth_data,
67 },
68 .num_resources = 2,
69 .resource = edb9302a_eth_resource,
70};
71
72static void __init edb9302a_init_machine(void) 50static void __init edb9302a_init_machine(void)
73{ 51{
74 ep93xx_init_devices(); 52 ep93xx_init_devices();
75 platform_device_register(&edb9302a_flash); 53 platform_device_register(&edb9302a_flash);
76 54
77 memcpy(edb9302a_eth_data.dev_addr, 55 ep93xx_register_eth(&edb9302a_eth_data, 1);
78 (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
79 platform_device_register(&edb9302a_eth_device);
80} 56}
81 57
82MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board") 58MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
diff --git a/arch/arm/mach-ep93xx/edb9307.c b/arch/arm/mach-ep93xx/edb9307.c
index 9fb72d01a36c..040edbd2ea05 100644
--- a/arch/arm/mach-ep93xx/edb9307.c
+++ b/arch/arm/mach-ep93xx/edb9307.c
@@ -18,7 +18,7 @@
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -47,36 +47,12 @@ static struct ep93xx_eth_data edb9307_eth_data = {
47 .phy_id = 1, 47 .phy_id = 1,
48}; 48};
49 49
50static struct resource edb9307_eth_resource[] = {
51 {
52 .start = EP93XX_ETHERNET_PHYS_BASE,
53 .end = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
54 .flags = IORESOURCE_MEM,
55 }, {
56 .start = IRQ_EP93XX_ETHERNET,
57 .end = IRQ_EP93XX_ETHERNET,
58 .flags = IORESOURCE_IRQ,
59 }
60};
61
62static struct platform_device edb9307_eth_device = {
63 .name = "ep93xx-eth",
64 .id = -1,
65 .dev = {
66 .platform_data = &edb9307_eth_data,
67 },
68 .num_resources = 2,
69 .resource = edb9307_eth_resource,
70};
71
72static void __init edb9307_init_machine(void) 50static void __init edb9307_init_machine(void)
73{ 51{
74 ep93xx_init_devices(); 52 ep93xx_init_devices();
75 platform_device_register(&edb9307_flash); 53 platform_device_register(&edb9307_flash);
76 54
77 memcpy(edb9307_eth_data.dev_addr, 55 ep93xx_register_eth(&edb9307_eth_data, 1);
78 (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
79 platform_device_register(&edb9307_eth_device);
80} 56}
81 57
82MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board") 58MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
diff --git a/arch/arm/mach-ep93xx/edb9312.c b/arch/arm/mach-ep93xx/edb9312.c
index 87267a574f5e..6853e302bc3a 100644
--- a/arch/arm/mach-ep93xx/edb9312.c
+++ b/arch/arm/mach-ep93xx/edb9312.c
@@ -19,7 +19,7 @@
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/mtd/physmap.h> 20#include <linux/mtd/physmap.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <asm/io.h> 22#include <linux/io.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <asm/mach-types.h> 24#include <asm/mach-types.h>
25#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
@@ -44,10 +44,16 @@ static struct platform_device edb9312_flash = {
44 .resource = &edb9312_flash_resource, 44 .resource = &edb9312_flash_resource,
45}; 45};
46 46
47static struct ep93xx_eth_data edb9312_eth_data = {
48 .phy_id = 1,
49};
50
47static void __init edb9312_init_machine(void) 51static void __init edb9312_init_machine(void)
48{ 52{
49 ep93xx_init_devices(); 53 ep93xx_init_devices();
50 platform_device_register(&edb9312_flash); 54 platform_device_register(&edb9312_flash);
55
56 ep93xx_register_eth(&edb9312_eth_data, 1);
51} 57}
52 58
53MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board") 59MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
diff --git a/arch/arm/mach-ep93xx/edb9315.c b/arch/arm/mach-ep93xx/edb9315.c
index 7e373950be4d..9469b350d253 100644
--- a/arch/arm/mach-ep93xx/edb9315.c
+++ b/arch/arm/mach-ep93xx/edb9315.c
@@ -18,7 +18,7 @@
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -43,10 +43,16 @@ static struct platform_device edb9315_flash = {
43 .resource = &edb9315_flash_resource, 43 .resource = &edb9315_flash_resource,
44}; 44};
45 45
46static struct ep93xx_eth_data edb9315_eth_data = {
47 .phy_id = 1,
48};
49
46static void __init edb9315_init_machine(void) 50static void __init edb9315_init_machine(void)
47{ 51{
48 ep93xx_init_devices(); 52 ep93xx_init_devices();
49 platform_device_register(&edb9315_flash); 53 platform_device_register(&edb9315_flash);
54
55 ep93xx_register_eth(&edb9315_eth_data, 1);
50} 56}
51 57
52MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board") 58MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
diff --git a/arch/arm/mach-ep93xx/edb9315a.c b/arch/arm/mach-ep93xx/edb9315a.c
index 08a7c9bfb689..584457ce7c80 100644
--- a/arch/arm/mach-ep93xx/edb9315a.c
+++ b/arch/arm/mach-ep93xx/edb9315a.c
@@ -18,7 +18,7 @@
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -47,36 +47,12 @@ static struct ep93xx_eth_data edb9315a_eth_data = {
47 .phy_id = 1, 47 .phy_id = 1,
48}; 48};
49 49
50static struct resource edb9315a_eth_resource[] = {
51 {
52 .start = EP93XX_ETHERNET_PHYS_BASE,
53 .end = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
54 .flags = IORESOURCE_MEM,
55 }, {
56 .start = IRQ_EP93XX_ETHERNET,
57 .end = IRQ_EP93XX_ETHERNET,
58 .flags = IORESOURCE_IRQ,
59 }
60};
61
62static struct platform_device edb9315a_eth_device = {
63 .name = "ep93xx-eth",
64 .id = -1,
65 .dev = {
66 .platform_data = &edb9315a_eth_data,
67 },
68 .num_resources = 2,
69 .resource = edb9315a_eth_resource,
70};
71
72static void __init edb9315a_init_machine(void) 50static void __init edb9315a_init_machine(void)
73{ 51{
74 ep93xx_init_devices(); 52 ep93xx_init_devices();
75 platform_device_register(&edb9315a_flash); 53 platform_device_register(&edb9315a_flash);
76 54
77 memcpy(edb9315a_eth_data.dev_addr, 55 ep93xx_register_eth(&edb9315a_eth_data, 1);
78 (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
79 platform_device_register(&edb9315a_eth_device);
80} 56}
81 57
82MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board") 58MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
diff --git a/arch/arm/mach-ep93xx/gesbc9312.c b/arch/arm/mach-ep93xx/gesbc9312.c
index 9b41ec1f089e..035b24e31b64 100644
--- a/arch/arm/mach-ep93xx/gesbc9312.c
+++ b/arch/arm/mach-ep93xx/gesbc9312.c
@@ -18,7 +18,7 @@
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -44,36 +44,15 @@ static struct platform_device gesbc9312_flash = {
44}; 44};
45 45
46static struct ep93xx_eth_data gesbc9312_eth_data = { 46static struct ep93xx_eth_data gesbc9312_eth_data = {
47 .phy_id = 1, 47 .phy_id = 1,
48};
49
50static struct resource gesbc9312_eth_resource[] = {
51 {
52 .start = EP93XX_ETHERNET_PHYS_BASE,
53 .end = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
54 .flags = IORESOURCE_MEM,
55 }, {
56 .start = IRQ_EP93XX_ETHERNET,
57 .end = IRQ_EP93XX_ETHERNET,
58 .flags = IORESOURCE_IRQ,
59 }
60};
61
62static struct platform_device gesbc9312_eth_device = {
63 .name = "ep93xx-eth",
64 .id = -1,
65 .dev = {
66 .platform_data = &gesbc9312_eth_data,
67 },
68 .num_resources = 2,
69 .resource = gesbc9312_eth_resource,
70}; 48};
71 49
72static void __init gesbc9312_init_machine(void) 50static void __init gesbc9312_init_machine(void)
73{ 51{
74 ep93xx_init_devices(); 52 ep93xx_init_devices();
75 platform_device_register(&gesbc9312_flash); 53 platform_device_register(&gesbc9312_flash);
76 platform_device_register(&gesbc9312_eth_device); 54
55 ep93xx_register_eth(&gesbc9312_eth_data, 0);
77} 56}
78 57
79MACHINE_START(GESBC9312, "Glomation GESBC-9312-sx") 58MACHINE_START(GESBC9312, "Glomation GESBC-9312-sx")
diff --git a/arch/arm/mach-ep93xx/gpio.c b/arch/arm/mach-ep93xx/gpio.c
index 0f3fb87ca4be..482cf3d2fbcd 100644
--- a/arch/arm/mach-ep93xx/gpio.c
+++ b/arch/arm/mach-ep93xx/gpio.c
@@ -16,9 +16,9 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/seq_file.h> 18#include <linux/seq_file.h>
19#include <linux/io.h>
19 20
20#include <mach/ep93xx-regs.h> 21#include <mach/ep93xx-regs.h>
21#include <asm/io.h>
22#include <asm/gpio.h> 22#include <asm/gpio.h>
23 23
24struct ep93xx_gpio_chip { 24struct ep93xx_gpio_chip {
@@ -141,10 +141,10 @@ static void ep93xx_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
141static struct ep93xx_gpio_chip ep93xx_gpio_banks[] = { 141static struct ep93xx_gpio_chip ep93xx_gpio_banks[] = {
142 EP93XX_GPIO_BANK("A", 0x00, 0x10, 0), 142 EP93XX_GPIO_BANK("A", 0x00, 0x10, 0),
143 EP93XX_GPIO_BANK("B", 0x04, 0x14, 8), 143 EP93XX_GPIO_BANK("B", 0x04, 0x14, 8),
144 EP93XX_GPIO_BANK("C", 0x30, 0x34, 40), 144 EP93XX_GPIO_BANK("C", 0x08, 0x18, 40),
145 EP93XX_GPIO_BANK("D", 0x0c, 0x1c, 24), 145 EP93XX_GPIO_BANK("D", 0x0c, 0x1c, 24),
146 EP93XX_GPIO_BANK("E", 0x20, 0x24, 32), 146 EP93XX_GPIO_BANK("E", 0x20, 0x24, 32),
147 EP93XX_GPIO_BANK("F", 0x08, 0x18, 16), 147 EP93XX_GPIO_BANK("F", 0x30, 0x34, 16),
148 EP93XX_GPIO_BANK("G", 0x38, 0x3c, 48), 148 EP93XX_GPIO_BANK("G", 0x38, 0x3c, 48),
149 EP93XX_GPIO_BANK("H", 0x40, 0x44, 56), 149 EP93XX_GPIO_BANK("H", 0x40, 0x44, 56),
150}; 150};
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
index 9f4458c8e070..22d6c9a6e4ca 100644
--- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
@@ -6,6 +6,40 @@
6#define __ASM_ARCH_EP93XX_REGS_H 6#define __ASM_ARCH_EP93XX_REGS_H
7 7
8/* 8/*
9 * EP93xx Physical Memory Map:
10 *
11 * The ASDO pin is sampled at system reset to select a synchronous or
12 * asynchronous boot configuration. When ASDO is "1" (i.e. pulled-up)
13 * the synchronous boot mode is selected. When ASDO is "0" (i.e
14 * pulled-down) the asynchronous boot mode is selected.
15 *
16 * In synchronous boot mode nSDCE3 is decoded starting at physical address
17 * 0x00000000 and nCS0 is decoded starting at 0xf0000000. For asynchronous
18 * boot mode they are swapped with nCS0 decoded at 0x00000000 ann nSDCE3
19 * decoded at 0xf0000000.
20 *
21 * There is known errata for the EP93xx dealing with External Memory
22 * Configurations. Please refer to "AN273: EP93xx Silicon Rev E Design
23 * Guidelines" for more information. This document can be found at:
24 *
25 * http://www.cirrus.com/en/pubs/appNote/AN273REV4.pdf
26 */
27
28#define EP93XX_CS0_PHYS_BASE_ASYNC 0x00000000 /* ASDO Pin = 0 */
29#define EP93XX_SDCE3_PHYS_BASE_SYNC 0x00000000 /* ASDO Pin = 1 */
30#define EP93XX_CS1_PHYS_BASE 0x10000000
31#define EP93XX_CS2_PHYS_BASE 0x20000000
32#define EP93XX_CS3_PHYS_BASE 0x30000000
33#define EP93XX_PCMCIA_PHYS_BASE 0x40000000
34#define EP93XX_CS6_PHYS_BASE 0x60000000
35#define EP93XX_CS7_PHYS_BASE 0x70000000
36#define EP93XX_SDCE0_PHYS_BASE 0xc0000000
37#define EP93XX_SDCE1_PHYS_BASE 0xd0000000
38#define EP93XX_SDCE2_PHYS_BASE 0xe0000000
39#define EP93XX_SDCE3_PHYS_BASE_ASYNC 0xf0000000 /* ASDO Pin = 0 */
40#define EP93XX_CS0_PHYS_BASE_SYNC 0xf0000000 /* ASDO Pin = 1 */
41
42/*
9 * EP93xx linux memory map: 43 * EP93xx linux memory map:
10 * 44 *
11 * virt phys size 45 * virt phys size
diff --git a/arch/arm/mach-ep93xx/include/mach/platform.h b/arch/arm/mach-ep93xx/include/mach/platform.h
index b5c182473f5d..db2489d3bda7 100644
--- a/arch/arm/mach-ep93xx/include/mach/platform.h
+++ b/arch/arm/mach-ep93xx/include/mach/platform.h
@@ -4,17 +4,17 @@
4 4
5#ifndef __ASSEMBLY__ 5#ifndef __ASSEMBLY__
6 6
7void ep93xx_map_io(void);
8void ep93xx_init_irq(void);
9void ep93xx_init_time(unsigned long);
10void ep93xx_init_devices(void);
11extern struct sys_timer ep93xx_timer;
12
13struct ep93xx_eth_data 7struct ep93xx_eth_data
14{ 8{
15 unsigned char dev_addr[6]; 9 unsigned char dev_addr[6];
16 unsigned char phy_id; 10 unsigned char phy_id;
17}; 11};
18 12
13void ep93xx_map_io(void);
14void ep93xx_init_irq(void);
15void ep93xx_init_time(unsigned long);
16void ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr);
17void ep93xx_init_devices(void);
18extern struct sys_timer ep93xx_timer;
19 19
20#endif 20#endif
diff --git a/arch/arm/mach-ep93xx/include/mach/ts72xx.h b/arch/arm/mach-ep93xx/include/mach/ts72xx.h
index 30b318aa1a1f..34ddec081c40 100644
--- a/arch/arm/mach-ep93xx/include/mach/ts72xx.h
+++ b/arch/arm/mach-ep93xx/include/mach/ts72xx.h
@@ -70,7 +70,7 @@
70 70
71 71
72#ifndef __ASSEMBLY__ 72#ifndef __ASSEMBLY__
73#include <asm/io.h> 73#include <linux/io.h>
74 74
75static inline int board_is_ts7200(void) 75static inline int board_is_ts7200(void)
76{ 76{
diff --git a/arch/arm/mach-ep93xx/include/mach/uncompress.h b/arch/arm/mach-ep93xx/include/mach/uncompress.h
index 1fd2f17de325..16026c2b1c8c 100644
--- a/arch/arm/mach-ep93xx/include/mach/uncompress.h
+++ b/arch/arm/mach-ep93xx/include/mach/uncompress.h
@@ -31,10 +31,19 @@ static void __raw_writel(unsigned int value, unsigned int ptr)
31 *((volatile unsigned int *)ptr) = value; 31 *((volatile unsigned int *)ptr) = value;
32} 32}
33 33
34 34#if defined(CONFIG_EP93XX_EARLY_UART1)
35#define PHYS_UART1_DATA 0x808c0000 35#define UART_BASE EP93XX_UART1_PHYS_BASE
36#define PHYS_UART1_FLAG 0x808c0018 36#elif defined(CONFIG_EP93XX_EARLY_UART2)
37#define UART1_FLAG_TXFF 0x20 37#define UART_BASE EP93XX_UART2_PHYS_BASE
38#elif defined(CONFIG_EP93XX_EARLY_UART3)
39#define UART_BASE EP93XX_UART3_PHYS_BASE
40#else
41#define UART_BASE EP93XX_UART1_PHYS_BASE
42#endif
43
44#define PHYS_UART_DATA (UART_BASE + 0x00)
45#define PHYS_UART_FLAG (UART_BASE + 0x18)
46#define UART_FLAG_TXFF 0x20
38 47
39static inline void putc(int c) 48static inline void putc(int c)
40{ 49{
@@ -42,11 +51,11 @@ static inline void putc(int c)
42 51
43 for (i = 0; i < 1000; i++) { 52 for (i = 0; i < 1000; i++) {
44 /* Transmit fifo not full? */ 53 /* Transmit fifo not full? */
45 if (!(__raw_readb(PHYS_UART1_FLAG) & UART1_FLAG_TXFF)) 54 if (!(__raw_readb(PHYS_UART_FLAG) & UART_FLAG_TXFF))
46 break; 55 break;
47 } 56 }
48 57
49 __raw_writeb(c, PHYS_UART1_DATA); 58 __raw_writeb(c, PHYS_UART_DATA);
50} 59}
51 60
52static inline void flush(void) 61static inline void flush(void)
diff --git a/arch/arm/mach-ep93xx/micro9.c b/arch/arm/mach-ep93xx/micro9.c
index de047a5c8112..c2197236b632 100644
--- a/arch/arm/mach-ep93xx/micro9.c
+++ b/arch/arm/mach-ep93xx/micro9.c
@@ -16,10 +16,9 @@
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19 19#include <linux/io.h>
20#include <linux/mtd/physmap.h> 20#include <linux/mtd/physmap.h>
21 21
22#include <asm/io.h>
23#include <mach/hardware.h> 22#include <mach/hardware.h>
24 23
25#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -29,38 +28,9 @@ static struct ep93xx_eth_data micro9_eth_data = {
29 .phy_id = 0x1f, 28 .phy_id = 0x1f,
30}; 29};
31 30
32static struct resource micro9_eth_resource[] = {
33 {
34 .start = EP93XX_ETHERNET_PHYS_BASE,
35 .end = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
36 .flags = IORESOURCE_MEM,
37 }, {
38 .start = IRQ_EP93XX_ETHERNET,
39 .end = IRQ_EP93XX_ETHERNET,
40 .flags = IORESOURCE_IRQ,
41 }
42};
43
44static struct platform_device micro9_eth_device = {
45 .name = "ep93xx-eth",
46 .id = -1,
47 .dev = {
48 .platform_data = &micro9_eth_data,
49 },
50 .num_resources = ARRAY_SIZE(micro9_eth_resource),
51 .resource = micro9_eth_resource,
52};
53
54static void __init micro9_eth_init(void)
55{
56 memcpy(micro9_eth_data.dev_addr,
57 (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
58 platform_device_register(&micro9_eth_device);
59}
60
61static void __init micro9_init(void) 31static void __init micro9_init(void)
62{ 32{
63 micro9_eth_init(); 33 ep93xx_register_eth(&micro9_eth_data, 1);
64} 34}
65 35
66/* 36/*
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index c3cbff126d0c..b4aa4c054276 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -19,7 +19,7 @@
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/m48t86.h> 21#include <linux/m48t86.h>
22#include <asm/io.h> 22#include <linux/io.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <asm/mach-types.h> 24#include <asm/mach-types.h>
25#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
@@ -161,28 +161,6 @@ static struct ep93xx_eth_data ts72xx_eth_data = {
161 .phy_id = 1, 161 .phy_id = 1,
162}; 162};
163 163
164static struct resource ts72xx_eth_resource[] = {
165 {
166 .start = EP93XX_ETHERNET_PHYS_BASE,
167 .end = EP93XX_ETHERNET_PHYS_BASE + 0xffff,
168 .flags = IORESOURCE_MEM,
169 }, {
170 .start = IRQ_EP93XX_ETHERNET,
171 .end = IRQ_EP93XX_ETHERNET,
172 .flags = IORESOURCE_IRQ,
173 }
174};
175
176static struct platform_device ts72xx_eth_device = {
177 .name = "ep93xx-eth",
178 .id = -1,
179 .dev = {
180 .platform_data = &ts72xx_eth_data,
181 },
182 .num_resources = 2,
183 .resource = ts72xx_eth_resource,
184};
185
186static void __init ts72xx_init_machine(void) 164static void __init ts72xx_init_machine(void)
187{ 165{
188 ep93xx_init_devices(); 166 ep93xx_init_devices();
@@ -190,9 +168,7 @@ static void __init ts72xx_init_machine(void)
190 platform_device_register(&ts72xx_flash); 168 platform_device_register(&ts72xx_flash);
191 platform_device_register(&ts72xx_rtc_device); 169 platform_device_register(&ts72xx_rtc_device);
192 170
193 memcpy(ts72xx_eth_data.dev_addr, 171 ep93xx_register_eth(&ts72xx_eth_data, 1);
194 (void *)(EP93XX_ETHERNET_BASE + 0x50), 6);
195 platform_device_register(&ts72xx_eth_device);
196} 172}
197 173
198MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC") 174MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
diff --git a/arch/arm/mach-footbridge/cats-hw.c b/arch/arm/mach-footbridge/cats-hw.c
index c261472208cb..6a5b437ab86f 100644
--- a/arch/arm/mach-footbridge/cats-hw.c
+++ b/arch/arm/mach-footbridge/cats-hw.c
@@ -9,9 +9,9 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/screen_info.h> 11#include <linux/screen_info.h>
12#include <linux/io.h>
12 13
13#include <asm/hardware/dec21285.h> 14#include <asm/hardware/dec21285.h>
14#include <asm/io.h>
15#include <asm/mach-types.h> 15#include <asm/mach-types.h>
16#include <asm/setup.h> 16#include <asm/setup.h>
17 17
diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
index b08ab507c052..818014e09f4a 100644
--- a/arch/arm/mach-footbridge/common.c
+++ b/arch/arm/mach-footbridge/common.c
@@ -13,11 +13,11 @@
13#include <linux/ioport.h> 13#include <linux/ioport.h>
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/io.h>
16 17
17#include <asm/pgtable.h> 18#include <asm/pgtable.h>
18#include <asm/page.h> 19#include <asm/page.h>
19#include <asm/irq.h> 20#include <asm/irq.h>
20#include <asm/io.h>
21#include <asm/mach-types.h> 21#include <asm/mach-types.h>
22#include <asm/setup.h> 22#include <asm/setup.h>
23#include <asm/hardware/dec21285.h> 23#include <asm/hardware/dec21285.h>
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index d0dc51e81338..d4c1e526f59c 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -16,8 +16,8 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/ioport.h> 17#include <linux/ioport.h>
18#include <linux/irq.h> 18#include <linux/irq.h>
19#include <linux/io.h>
19 20
20#include <asm/io.h>
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/system.h> 22#include <asm/system.h>
23#include <asm/mach/pci.h> 23#include <asm/mach/pci.h>
diff --git a/arch/arm/mach-footbridge/dma.c b/arch/arm/mach-footbridge/dma.c
index 1f9b09b8ed88..b653e9cfa3f7 100644
--- a/arch/arm/mach-footbridge/dma.c
+++ b/arch/arm/mach-footbridge/dma.c
@@ -11,9 +11,9 @@
11 * ISA DMA controllers. 11 * ISA DMA controllers.
12 */ 12 */
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/io.h>
14 15
15#include <asm/dma.h> 16#include <asm/dma.h>
16#include <asm/io.h>
17#include <asm/scatterlist.h> 17#include <asm/scatterlist.h>
18 18
19#include <asm/mach/dma.h> 19#include <asm/mach/dma.h>
diff --git a/arch/arm/mach-footbridge/include/mach/memory.h b/arch/arm/mach-footbridge/include/mach/memory.h
index e9cae99dd1f9..6ae2f1a07ab9 100644
--- a/arch/arm/mach-footbridge/include/mach/memory.h
+++ b/arch/arm/mach-footbridge/include/mach/memory.h
@@ -42,10 +42,6 @@ extern unsigned long __bus_to_virt(unsigned long);
42 42
43#endif 43#endif
44 44
45/* Task size and page offset at 3GB */
46#define TASK_SIZE UL(0xbf000000)
47#define PAGE_OFFSET UL(0xc0000000)
48
49/* 45/*
50 * Cache flushing area. 46 * Cache flushing area.
51 */ 47 */
@@ -56,12 +52,6 @@ extern unsigned long __bus_to_virt(unsigned long);
56 */ 52 */
57#define PHYS_OFFSET UL(0x00000000) 53#define PHYS_OFFSET UL(0x00000000)
58 54
59/*
60 * This decides where the kernel will search for a free chunk of vm
61 * space during mmap's.
62 */
63#define TASK_UNMAPPED_BASE ((TASK_SIZE + 0x01000000) / 3)
64
65#define FLUSH_BASE_PHYS 0x50000000 55#define FLUSH_BASE_PHYS 0x50000000
66 56
67#endif 57#endif
diff --git a/arch/arm/mach-footbridge/include/mach/system.h b/arch/arm/mach-footbridge/include/mach/system.h
index 01c9f407f498..2db7f36bd6ca 100644
--- a/arch/arm/mach-footbridge/include/mach/system.h
+++ b/arch/arm/mach-footbridge/include/mach/system.h
@@ -7,8 +7,8 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#include <linux/io.h>
10#include <asm/hardware/dec21285.h> 11#include <asm/hardware/dec21285.h>
11#include <asm/io.h>
12#include <mach/hardware.h> 12#include <mach/hardware.h>
13#include <asm/leds.h> 13#include <asm/leds.h>
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
diff --git a/arch/arm/mach-footbridge/isa-irq.c b/arch/arm/mach-footbridge/isa-irq.c
index 7132e522c366..54fec9ae28b9 100644
--- a/arch/arm/mach-footbridge/isa-irq.c
+++ b/arch/arm/mach-footbridge/isa-irq.c
@@ -18,13 +18,13 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/io.h>
21 22
22#include <asm/mach/irq.h> 23#include <asm/mach/irq.h>
23 24
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/hardware/dec21285.h> 26#include <asm/hardware/dec21285.h>
26#include <asm/irq.h> 27#include <asm/irq.h>
27#include <asm/io.h>
28#include <asm/mach-types.h> 28#include <asm/mach-types.h>
29 29
30static void isa_mask_pic_lo_irq(unsigned int irq) 30static void isa_mask_pic_lo_irq(unsigned int irq)
@@ -94,8 +94,7 @@ isa_irq_handler(unsigned int irq, struct irq_desc *desc)
94 return; 94 return;
95 } 95 }
96 96
97 desc = irq_desc + isa_irq; 97 generic_handle_irq(isa_irq);
98 desc_handle_irq(isa_irq, desc);
99} 98}
100 99
101static struct irqaction irq_cascade = { 100static struct irqaction irq_cascade = {
diff --git a/arch/arm/mach-footbridge/isa-timer.c b/arch/arm/mach-footbridge/isa-timer.c
index a764e01d3573..0c8390082fa8 100644
--- a/arch/arm/mach-footbridge/isa-timer.c
+++ b/arch/arm/mach-footbridge/isa-timer.c
@@ -7,8 +7,8 @@
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/interrupt.h> 8#include <linux/interrupt.h>
9#include <linux/irq.h> 9#include <linux/irq.h>
10#include <linux/io.h>
10 11
11#include <asm/io.h>
12#include <asm/irq.h> 12#include <asm/irq.h>
13 13
14#include <asm/mach/time.h> 14#include <asm/mach/time.h>
diff --git a/arch/arm/mach-footbridge/netwinder-hw.c b/arch/arm/mach-footbridge/netwinder-hw.c
index a1f381c64a30..00b0ddcac283 100644
--- a/arch/arm/mach-footbridge/netwinder-hw.c
+++ b/arch/arm/mach-footbridge/netwinder-hw.c
@@ -10,9 +10,9 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/delay.h> 11#include <linux/delay.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/io.h>
13 14
14#include <asm/hardware/dec21285.h> 15#include <asm/hardware/dec21285.h>
15#include <asm/io.h>
16#include <asm/leds.h> 16#include <asm/leds.h>
17#include <asm/mach-types.h> 17#include <asm/mach-types.h>
18#include <asm/setup.h> 18#include <asm/setup.h>
diff --git a/arch/arm/mach-footbridge/time.c b/arch/arm/mach-footbridge/time.c
index 004819ea85c8..cd1b54ff9fe2 100644
--- a/arch/arm/mach-footbridge/time.c
+++ b/arch/arm/mach-footbridge/time.c
@@ -22,9 +22,9 @@
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/mc146818rtc.h> 23#include <linux/mc146818rtc.h>
24#include <linux/bcd.h> 24#include <linux/bcd.h>
25#include <linux/io.h>
25 26
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/io.h>
28 28
29#include <asm/mach/time.h> 29#include <asm/mach/time.h>
30#include "common.h" 30#include "common.h"
diff --git a/arch/arm/mach-h720x/common.c b/arch/arm/mach-h720x/common.c
index b5f9741ae13c..7a2614828217 100644
--- a/arch/arm/mach-h720x/common.c
+++ b/arch/arm/mach-h720x/common.c
@@ -18,11 +18,11 @@
18#include <linux/mman.h> 18#include <linux/mman.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/io.h>
21 22
22#include <asm/page.h> 23#include <asm/page.h>
23#include <asm/pgtable.h> 24#include <asm/pgtable.h>
24#include <asm/dma.h> 25#include <asm/dma.h>
25#include <asm/io.h>
26#include <mach/hardware.h> 26#include <mach/hardware.h>
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
@@ -104,14 +104,12 @@ h720x_gpio_handler(unsigned int mask, unsigned int irq,
104 struct irq_desc *desc) 104 struct irq_desc *desc)
105{ 105{
106 IRQDBG("%s irq: %d\n", __func__, irq); 106 IRQDBG("%s irq: %d\n", __func__, irq);
107 desc = irq_desc + irq;
108 while (mask) { 107 while (mask) {
109 if (mask & 1) { 108 if (mask & 1) {
110 IRQDBG("handling irq %d\n", irq); 109 IRQDBG("handling irq %d\n", irq);
111 desc_handle_irq(irq, desc); 110 generic_handle_irq(irq);
112 } 111 }
113 irq++; 112 irq++;
114 desc++;
115 mask >>= 1; 113 mask >>= 1;
116 } 114 }
117} 115}
diff --git a/arch/arm/mach-h720x/cpu-h7202.c b/arch/arm/mach-h720x/cpu-h7202.c
index 53e1f62f2e79..fd33a19c813a 100644
--- a/arch/arm/mach-h720x/cpu-h7202.c
+++ b/arch/arm/mach-h720x/cpu-h7202.c
@@ -120,12 +120,10 @@ h7202_timerx_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
120 120
121 mask >>= 1; 121 mask >>= 1;
122 irq = IRQ_TIMER1; 122 irq = IRQ_TIMER1;
123 desc = irq_desc + irq;
124 while (mask) { 123 while (mask) {
125 if (mask & 1) 124 if (mask & 1)
126 desc_handle_irq(irq, desc); 125 generic_handle_irq(irq);
127 irq++; 126 irq++;
128 desc++;
129 mask >>= 1; 127 mask >>= 1;
130 } 128 }
131} 129}
diff --git a/arch/arm/mach-imx/clock.c b/arch/arm/mach-imx/clock.c
index 4b4230db3765..7ec60fc91565 100644
--- a/arch/arm/mach-imx/clock.c
+++ b/arch/arm/mach-imx/clock.c
@@ -21,8 +21,8 @@
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/math64.h> 22#include <linux/math64.h>
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/io.h>
24 25
25#include <asm/io.h>
26#include <mach/imx-regs.h> 26#include <mach/imx-regs.h>
27 27
28/* 28/*
diff --git a/arch/arm/mach-imx/include/mach/irqs.h b/arch/arm/mach-imx/include/mach/irqs.h
index eb8d5bd05d56..67812c5ac1f9 100644
--- a/arch/arm/mach-imx/include/mach/irqs.h
+++ b/arch/arm/mach-imx/include/mach/irqs.h
@@ -111,6 +111,11 @@
111/* decode irq number to use with IMR(x), ISR(x) and friends */ 111/* decode irq number to use with IMR(x), ISR(x) and friends */
112#define IRQ_TO_REG(irq) ((irq - IMX_IRQS) >> 5) 112#define IRQ_TO_REG(irq) ((irq - IMX_IRQS) >> 5)
113 113
114/* all normal IRQs can be FIQs */
115#define FIQ_START 0
116/* switch betwean IRQ and FIQ */
117extern int imx_set_irq_fiq(unsigned int irq, unsigned int type);
118
114#define NR_IRQS (IRQ_GPIOD(32) + 1) 119#define NR_IRQS (IRQ_GPIOD(32) + 1)
115#define IRQ_GPIO(x) 120#define IRQ_GPIO(x)
116#endif 121#endif
diff --git a/arch/arm/mach-imx/irq.c b/arch/arm/mach-imx/irq.c
index 798f221eb3b7..531b95deadc0 100644
--- a/arch/arm/mach-imx/irq.c
+++ b/arch/arm/mach-imx/irq.c
@@ -26,20 +26,17 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/io.h>
29 30
30#include <mach/hardware.h> 31#include <mach/hardware.h>
31#include <asm/irq.h> 32#include <asm/irq.h>
32#include <asm/io.h>
33 33
34#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
35 35
36/* 36/*
37 * 37 *
38 * We simply use the ENABLE DISABLE registers inside of the IMX 38 * We simply use the ENABLE DISABLE registers inside of the IMX
39 * to turn on/off specific interrupts. FIXME- We should 39 * to turn on/off specific interrupts.
40 * also add support for the accelerated interrupt controller
41 * by putting offets to irq jump code in the appropriate
42 * places.
43 * 40 *
44 */ 41 */
45 42
@@ -102,6 +99,28 @@ imx_unmask_irq(unsigned int irq)
102 __raw_writel(irq, IMX_AITC_INTENNUM); 99 __raw_writel(irq, IMX_AITC_INTENNUM);
103} 100}
104 101
102#ifdef CONFIG_FIQ
103int imx_set_irq_fiq(unsigned int irq, unsigned int type)
104{
105 unsigned int irqt;
106
107 if (irq >= IMX_IRQS)
108 return -EINVAL;
109
110 if (irq < IMX_IRQS / 2) {
111 irqt = __raw_readl(IMX_AITC_INTTYPEL) & ~(1 << irq);
112 __raw_writel(irqt | (!!type << irq), IMX_AITC_INTTYPEL);
113 } else {
114 irq -= IMX_IRQS / 2;
115 irqt = __raw_readl(IMX_AITC_INTTYPEH) & ~(1 << irq);
116 __raw_writel(irqt | (!!type << irq), IMX_AITC_INTTYPEH);
117 }
118
119 return 0;
120}
121EXPORT_SYMBOL(imx_set_irq_fiq);
122#endif /* CONFIG_FIQ */
123
105static int 124static int
106imx_gpio_irq_type(unsigned int _irq, unsigned int type) 125imx_gpio_irq_type(unsigned int _irq, unsigned int type)
107{ 126{
@@ -182,14 +201,12 @@ static void
182imx_gpio_handler(unsigned int mask, unsigned int irq, 201imx_gpio_handler(unsigned int mask, unsigned int irq,
183 struct irq_desc *desc) 202 struct irq_desc *desc)
184{ 203{
185 desc = irq_desc + irq;
186 while (mask) { 204 while (mask) {
187 if (mask & 1) { 205 if (mask & 1) {
188 DEBUG_IRQ("handling irq %d\n", irq); 206 DEBUG_IRQ("handling irq %d\n", irq);
189 desc_handle_irq(irq, desc); 207 generic_handle_irq(irq);
190 } 208 }
191 irq++; 209 irq++;
192 desc++;
193 mask >>= 1; 210 mask >>= 1;
194 } 211 }
195} 212}
@@ -286,4 +303,9 @@ imx_init_irq(void)
286 303
287 /* Release masking of interrupts according to priority */ 304 /* Release masking of interrupts according to priority */
288 __raw_writel(-1, IMX_AITC_NIMASK); 305 __raw_writel(-1, IMX_AITC_NIMASK);
306
307#ifdef CONFIG_FIQ
308 /* Initialize FIQ */
309 init_FIQ();
310#endif
289} 311}
diff --git a/arch/arm/mach-imx/leds-mx1ads.c b/arch/arm/mach-imx/leds-mx1ads.c
index af81621f689b..1d48f2762cbc 100644
--- a/arch/arm/mach-imx/leds-mx1ads.c
+++ b/arch/arm/mach-imx/leds-mx1ads.c
@@ -13,9 +13,9 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/io.h>
16#include <mach/hardware.h> 17#include <mach/hardware.h>
17#include <asm/system.h> 18#include <asm/system.h>
18#include <asm/io.h>
19#include <asm/leds.h> 19#include <asm/leds.h>
20#include "leds.h" 20#include "leds.h"
21 21
diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
index 08be3875c59e..a11765f5f23b 100644
--- a/arch/arm/mach-imx/time.c
+++ b/arch/arm/mach-imx/time.c
@@ -18,9 +18,9 @@
18#include <linux/clocksource.h> 18#include <linux/clocksource.h>
19#include <linux/clockchips.h> 19#include <linux/clockchips.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/io.h>
21 22
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <asm/io.h>
24#include <asm/leds.h> 24#include <asm/leds.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/mach/time.h> 26#include <asm/mach/time.h>
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 8bacf6d4d097..595b7392ee4e 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -19,10 +19,10 @@
19#include <linux/termios.h> 19#include <linux/termios.h>
20#include <linux/amba/bus.h> 20#include <linux/amba/bus.h>
21#include <linux/amba/serial.h> 21#include <linux/amba/serial.h>
22#include <linux/io.h>
22 23
23#include <mach/hardware.h> 24#include <mach/hardware.h>
24#include <asm/irq.h> 25#include <asm/irq.h>
25#include <asm/io.h>
26#include <asm/hardware/arm_timer.h> 26#include <asm/hardware/arm_timer.h>
27#include <mach/cm.h> 27#include <mach/cm.h>
28#include <asm/system.h> 28#include <asm/system.h>
diff --git a/arch/arm/mach-integrator/cpu.c b/arch/arm/mach-integrator/cpu.c
index 7c49d55e6b27..e4f72d202cc0 100644
--- a/arch/arm/mach-integrator/cpu.c
+++ b/arch/arm/mach-integrator/cpu.c
@@ -17,9 +17,9 @@
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/io.h>
20 21
21#include <mach/hardware.h> 22#include <mach/hardware.h>
22#include <asm/io.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/hardware/icst525.h> 24#include <asm/hardware/icst525.h>
25 25
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index 3c8383dbe9e6..172299a78302 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -20,8 +20,8 @@
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/amba/bus.h> 21#include <linux/amba/bus.h>
22#include <linux/amba/clcd.h> 22#include <linux/amba/clcd.h>
23#include <linux/io.h>
23 24
24#include <asm/io.h>
25#include <asm/hardware/icst525.h> 25#include <asm/hardware/icst525.h>
26#include <mach/lm.h> 26#include <mach/lm.h>
27#include <mach/impd1.h> 27#include <mach/impd1.h>
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index 6e472b5f8f26..8138a7e24562 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -27,9 +27,9 @@
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/amba/bus.h> 28#include <linux/amba/bus.h>
29#include <linux/amba/kmi.h> 29#include <linux/amba/kmi.h>
30#include <linux/io.h>
30 31
31#include <mach/hardware.h> 32#include <mach/hardware.h>
32#include <asm/io.h>
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <asm/setup.h> 34#include <asm/setup.h>
35#include <asm/param.h> /* HZ */ 35#include <asm/param.h> /* HZ */
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 6b99e9c258bd..88026ccd5ac9 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -19,9 +19,9 @@
19#include <linux/amba/bus.h> 19#include <linux/amba/bus.h>
20#include <linux/amba/kmi.h> 20#include <linux/amba/kmi.h>
21#include <linux/amba/clcd.h> 21#include <linux/amba/clcd.h>
22#include <linux/io.h>
22 23
23#include <mach/hardware.h> 24#include <mach/hardware.h>
24#include <asm/io.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/setup.h> 26#include <asm/setup.h>
27#include <asm/mach-types.h> 27#include <asm/mach-types.h>
@@ -217,8 +217,7 @@ sic_handle_irq(unsigned int irq, struct irq_desc *desc)
217 217
218 irq += IRQ_SIC_START; 218 irq += IRQ_SIC_START;
219 219
220 desc = irq_desc + irq; 220 generic_handle_irq(irq);
221 desc_handle_irq(irq, desc);
222 } while (status); 221 } while (status);
223} 222}
224 223
diff --git a/arch/arm/mach-integrator/leds.c b/arch/arm/mach-integrator/leds.c
index 7bc6881434ec..8dcc823f4135 100644
--- a/arch/arm/mach-integrator/leds.c
+++ b/arch/arm/mach-integrator/leds.c
@@ -24,9 +24,9 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/smp.h> 25#include <linux/smp.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/io.h>
30#include <asm/leds.h> 30#include <asm/leds.h>
31#include <asm/system.h> 31#include <asm/system.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c
index 9f2b1ea8fb20..f1d72b225450 100644
--- a/arch/arm/mach-integrator/pci_v3.c
+++ b/arch/arm/mach-integrator/pci_v3.c
@@ -27,9 +27,9 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/io.h>
30 31
31#include <mach/hardware.h> 32#include <mach/hardware.h>
32#include <asm/io.h>
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <asm/system.h> 34#include <asm/system.h>
35#include <asm/mach/pci.h> 35#include <asm/mach/pci.h>
diff --git a/arch/arm/mach-iop13xx/include/mach/memory.h b/arch/arm/mach-iop13xx/include/mach/memory.h
index e8b59d8f1bb9..b82602d529bf 100644
--- a/arch/arm/mach-iop13xx/include/mach/memory.h
+++ b/arch/arm/mach-iop13xx/include/mach/memory.h
@@ -7,9 +7,6 @@
7 * Physical DRAM offset. 7 * Physical DRAM offset.
8 */ 8 */
9#define PHYS_OFFSET UL(0x00000000) 9#define PHYS_OFFSET UL(0x00000000)
10#define TASK_SIZE UL(0x3f000000)
11#define PAGE_OFFSET UL(0x40000000)
12#define TASK_UNMAPPED_BASE ((TASK_SIZE + 0x01000000) / 3)
13 10
14#ifndef __ASSEMBLY__ 11#ifndef __ASSEMBLY__
15 12
@@ -29,32 +26,52 @@
29 26
30/* RAM has 1:1 mapping on the PCIe/x Busses */ 27/* RAM has 1:1 mapping on the PCIe/x Busses */
31#define __virt_to_bus(x) (__virt_to_phys(x)) 28#define __virt_to_bus(x) (__virt_to_phys(x))
32#define __bus_to_virt(x) (__phys_to_virt(x)) 29#define __bus_to_virt(x) (__phys_to_virt(x))
33 30
34#define virt_to_lbus(x) \ 31static inline dma_addr_t __virt_to_lbus(unsigned long x)
35(( ((void*)(x) >= (void*)IOP13XX_PMMR_V_START) && \ 32{
36((void*)(x) < (void*)IOP13XX_PMMR_V_END) ) ? \ 33 return x + IOP13XX_PMMR_PHYS_MEM_BASE - IOP13XX_PMMR_VIRT_MEM_BASE;
37((x) - IOP13XX_PMMR_VIRT_MEM_BASE + IOP13XX_PMMR_PHYS_MEM_BASE) : \ 34}
38((x) - PAGE_OFFSET + PHYS_OFFSET))
39 35
40#define lbus_to_virt(x) \ 36static inline unsigned long __lbus_to_virt(dma_addr_t x)
41(( ((x) >= IOP13XX_PMMR_P_START) && ((x) < IOP13XX_PMMR_P_END) ) ? \ 37{
42((x) - IOP13XX_PMMR_PHYS_MEM_BASE + IOP13XX_PMMR_VIRT_MEM_BASE ) : \ 38 return x + IOP13XX_PMMR_VIRT_MEM_BASE - IOP13XX_PMMR_PHYS_MEM_BASE;
43((x) - PHYS_OFFSET + PAGE_OFFSET)) 39}
40
41#define __is_lbus_dma(a) \
42 ((a) >= IOP13XX_PMMR_P_START && (a) < IOP13XX_PMMR_P_END)
43
44#define __is_lbus_virt(a) \
45 ((a) >= IOP13XX_PMMR_V_START && (a) < IOP13XX_PMMR_V_END)
44 46
45/* Device is an lbus device if it is on the platform bus of the IOP13XX */ 47/* Device is an lbus device if it is on the platform bus of the IOP13XX */
46#define is_lbus_device(dev) (dev &&\ 48#define is_lbus_device(dev) \
47 (strncmp(dev->bus->name, "platform", 8) == 0)) 49 (dev && strncmp(dev->bus->name, "platform", 8) == 0)
48 50
49#define __arch_page_to_dma(dev, page) \ 51#define __arch_dma_to_virt(dev, addr) \
50({is_lbus_device(dev) ? (dma_addr_t)virt_to_lbus(page_address(page)) : \ 52 ({ \
51(dma_addr_t)__virt_to_bus(page_address(page));}) 53 unsigned long __virt; \
54 dma_addr_t __dma = addr; \
55 if (is_lbus_device(dev) && __is_lbus_dma(__dma)) \
56 __virt = __lbus_to_virt(__dma); \
57 else \
58 __virt = __bus_to_virt(__dma); \
59 (void *)__virt; \
60 })
52 61
53#define __arch_dma_to_virt(dev, addr) \ 62#define __arch_virt_to_dma(dev, addr) \
54({is_lbus_device(dev) ? lbus_to_virt(addr) : __bus_to_virt(addr);}) 63 ({ \
64 unsigned long __virt = (unsigned long)addr; \
65 dma_addr_t __dma; \
66 if (is_lbus_device(dev) && __is_lbus_virt(__virt)) \
67 __dma = __virt_to_lbus(__virt); \
68 else \
69 __dma = __virt_to_bus(__virt); \
70 __dma; \
71 })
55 72
56#define __arch_virt_to_dma(dev, addr) \ 73#define __arch_page_to_dma(dev, page) \
57({is_lbus_device(dev) ? virt_to_lbus(addr) : __virt_to_bus(addr);}) 74 __arch_virt_to_dma(dev, page_address(page))
58 75
59#endif /* CONFIG_ARCH_IOP13XX */ 76#endif /* CONFIG_ARCH_IOP13XX */
60#endif /* !ASSEMBLY */ 77#endif /* !ASSEMBLY */
diff --git a/arch/arm/mach-iop13xx/include/mach/pci.h b/arch/arm/mach-iop13xx/include/mach/pci.h
index 17b5515af8b1..59f42b535572 100644
--- a/arch/arm/mach-iop13xx/include/mach/pci.h
+++ b/arch/arm/mach-iop13xx/include/mach/pci.h
@@ -1,7 +1,7 @@
1#ifndef _IOP13XX_PCI_H_ 1#ifndef _IOP13XX_PCI_H_
2#define _IOP13XX_PCI_H_ 2#define _IOP13XX_PCI_H_
3#include <linux/io.h>
3#include <mach/irqs.h> 4#include <mach/irqs.h>
4#include <asm/io.h>
5 5
6struct pci_sys_data; 6struct pci_sys_data;
7struct hw_pci; 7struct hw_pci;
diff --git a/arch/arm/mach-iop13xx/io.c b/arch/arm/mach-iop13xx/io.c
index 26cfa318142c..529580997814 100644
--- a/arch/arm/mach-iop13xx/io.c
+++ b/arch/arm/mach-iop13xx/io.c
@@ -18,8 +18,8 @@
18 */ 18 */
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/io.h>
21#include <mach/hardware.h> 22#include <mach/hardware.h>
22#include <asm/io.h>
23 23
24void * __iomem __iop13xx_io(unsigned long io_addr) 24void * __iomem __iop13xx_io(unsigned long io_addr)
25{ 25{
diff --git a/arch/arm/mach-iop13xx/msi.c b/arch/arm/mach-iop13xx/msi.c
index 63ef1124ca5c..f34b0ed80630 100644
--- a/arch/arm/mach-iop13xx/msi.c
+++ b/arch/arm/mach-iop13xx/msi.c
@@ -110,8 +110,7 @@ static void iop13xx_msi_handler(unsigned int irq, struct irq_desc *desc)
110 do { 110 do {
111 j = find_first_bit(&status, 32); 111 j = find_first_bit(&status, 32);
112 (write_imipr[i])(1 << j); /* write back to clear bit */ 112 (write_imipr[i])(1 << j); /* write back to clear bit */
113 desc = irq_desc + IRQ_IOP13XX_MSI_0 + j + (32*i); 113 generic_handle_irq(IRQ_IOP13XX_MSI_0 + j + (32*i));
114 desc_handle_irq(IRQ_IOP13XX_MSI_0 + j + (32*i), desc);
115 status = (read_imipr[i])(); 114 status = (read_imipr[i])();
116 } while (status); 115 } while (status);
117 } 116 }
diff --git a/arch/arm/mach-iop13xx/setup.c b/arch/arm/mach-iop13xx/setup.c
index b17ccc8cb471..cfd4d2e6dacd 100644
--- a/arch/arm/mach-iop13xx/setup.c
+++ b/arch/arm/mach-iop13xx/setup.c
@@ -18,13 +18,13 @@
18 */ 18 */
19 19
20#include <linux/serial_8250.h> 20#include <linux/serial_8250.h>
21#include <linux/io.h>
21#ifdef CONFIG_MTD_PHYSMAP 22#ifdef CONFIG_MTD_PHYSMAP
22#include <linux/mtd/physmap.h> 23#include <linux/mtd/physmap.h>
23#endif 24#endif
24#include <asm/mach/map.h> 25#include <asm/mach/map.h>
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/irq.h> 27#include <asm/irq.h>
27#include <asm/io.h>
28#include <asm/hardware/iop_adma.h> 28#include <asm/hardware/iop_adma.h>
29 29
30#define IOP13XX_UART_XTAL 33334000 30#define IOP13XX_UART_XTAL 33334000
diff --git a/arch/arm/mach-iop13xx/tpmi.c b/arch/arm/mach-iop13xx/tpmi.c
index 2476347ea62f..c6af1e1bee32 100644
--- a/arch/arm/mach-iop13xx/tpmi.c
+++ b/arch/arm/mach-iop13xx/tpmi.c
@@ -21,7 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
24#include <asm/io.h> 24#include <linux/io.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/sizes.h> 26#include <asm/sizes.h>
27 27
diff --git a/arch/arm/mach-iop32x/glantank.c b/arch/arm/mach-iop32x/glantank.c
index 45d61276d233..a9c2dfdb2507 100644
--- a/arch/arm/mach-iop32x/glantank.c
+++ b/arch/arm/mach-iop32x/glantank.c
@@ -25,8 +25,8 @@
25#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/io.h>
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32#include <asm/mach/map.h> 32#include <asm/mach/map.h>
diff --git a/arch/arm/mach-iop32x/iq31244.c b/arch/arm/mach-iop32x/iq31244.c
index 082818aaa205..dd1cd9904518 100644
--- a/arch/arm/mach-iop32x/iq31244.c
+++ b/arch/arm/mach-iop32x/iq31244.c
@@ -26,8 +26,9 @@
26#include <linux/serial_8250.h> 26#include <linux/serial_8250.h>
27#include <linux/mtd/physmap.h> 27#include <linux/mtd/physmap.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/io.h>
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/io.h> 31#include <asm/cputype.h>
31#include <asm/irq.h> 32#include <asm/irq.h>
32#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
33#include <asm/mach/map.h> 34#include <asm/mach/map.h>
@@ -49,8 +50,7 @@ static int force_ep80219;
49 50
50static int is_80219(void) 51static int is_80219(void)
51{ 52{
52 extern int processor_id; 53 return !!((read_cpuid_id() & 0xffffffe0) == 0x69052e20);
53 return !!((processor_id & 0xffffffe0) == 0x69052e20);
54} 54}
55 55
56static int is_ep80219(void) 56static int is_ep80219(void)
diff --git a/arch/arm/mach-iop32x/iq80321.c b/arch/arm/mach-iop32x/iq80321.c
index d735539808b4..fbe27798759d 100644
--- a/arch/arm/mach-iop32x/iq80321.c
+++ b/arch/arm/mach-iop32x/iq80321.c
@@ -23,8 +23,8 @@
23#include <linux/serial_8250.h> 23#include <linux/serial_8250.h>
24#include <linux/mtd/physmap.h> 24#include <linux/mtd/physmap.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/io.h>
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/io.h>
28#include <asm/irq.h> 28#include <asm/irq.h>
29#include <asm/mach/arch.h> 29#include <asm/mach/arch.h>
30#include <asm/mach/map.h> 30#include <asm/mach/map.h>
diff --git a/arch/arm/mach-iop32x/n2100.c b/arch/arm/mach-iop32x/n2100.c
index 3173f9c5835d..d2e427899729 100644
--- a/arch/arm/mach-iop32x/n2100.c
+++ b/arch/arm/mach-iop32x/n2100.c
@@ -30,8 +30,8 @@
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/reboot.h> 32#include <linux/reboot.h>
33#include <linux/io.h>
33#include <mach/hardware.h> 34#include <mach/hardware.h>
34#include <asm/io.h>
35#include <asm/irq.h> 35#include <asm/irq.h>
36#include <asm/mach/arch.h> 36#include <asm/mach/arch.h>
37#include <asm/mach/map.h> 37#include <asm/mach/map.h>
diff --git a/arch/arm/mach-iop33x/iq80331.c b/arch/arm/mach-iop33x/iq80331.c
index c7d99f9fafed..d51e10cddf20 100644
--- a/arch/arm/mach-iop33x/iq80331.c
+++ b/arch/arm/mach-iop33x/iq80331.c
@@ -22,8 +22,8 @@
22#include <linux/serial_8250.h> 22#include <linux/serial_8250.h>
23#include <linux/mtd/physmap.h> 23#include <linux/mtd/physmap.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/io.h>
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/io.h>
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/mach/arch.h> 28#include <asm/mach/arch.h>
29#include <asm/mach/map.h> 29#include <asm/mach/map.h>
diff --git a/arch/arm/mach-iop33x/iq80332.c b/arch/arm/mach-iop33x/iq80332.c
index af616c5f4fb2..92fb44cdbcad 100644
--- a/arch/arm/mach-iop33x/iq80332.c
+++ b/arch/arm/mach-iop33x/iq80332.c
@@ -22,8 +22,8 @@
22#include <linux/serial_8250.h> 22#include <linux/serial_8250.h>
23#include <linux/mtd/physmap.h> 23#include <linux/mtd/physmap.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/io.h>
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/io.h>
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/mach/arch.h> 28#include <asm/mach/arch.h>
29#include <asm/mach/map.h> 29#include <asm/mach/map.h>
diff --git a/arch/arm/mach-iop33x/uart.c b/arch/arm/mach-iop33x/uart.c
index 8c21870fa808..cdae24e46eea 100644
--- a/arch/arm/mach-iop33x/uart.c
+++ b/arch/arm/mach-iop33x/uart.c
@@ -17,7 +17,7 @@
17#include <linux/serial.h> 17#include <linux/serial.h>
18#include <linux/tty.h> 18#include <linux/tty.h>
19#include <linux/serial_8250.h> 19#include <linux/serial_8250.h>
20#include <asm/io.h> 20#include <linux/io.h>
21#include <asm/pgtable.h> 21#include <asm/pgtable.h>
22#include <asm/page.h> 22#include <asm/page.h>
23#include <asm/mach/map.h> 23#include <asm/mach/map.h>
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
index a6a4f93085fd..babb22597163 100644
--- a/arch/arm/mach-ixp2000/core.c
+++ b/arch/arm/mach-ixp2000/core.c
@@ -84,64 +84,57 @@ static struct map_desc ixp2000_io_desc[] __initdata = {
84 .virtual = IXP2000_CAP_VIRT_BASE, 84 .virtual = IXP2000_CAP_VIRT_BASE,
85 .pfn = __phys_to_pfn(IXP2000_CAP_PHYS_BASE), 85 .pfn = __phys_to_pfn(IXP2000_CAP_PHYS_BASE),
86 .length = IXP2000_CAP_SIZE, 86 .length = IXP2000_CAP_SIZE,
87 .type = MT_DEVICE_IXP2000, 87 .type = MT_DEVICE,
88 }, { 88 }, {
89 .virtual = IXP2000_INTCTL_VIRT_BASE, 89 .virtual = IXP2000_INTCTL_VIRT_BASE,
90 .pfn = __phys_to_pfn(IXP2000_INTCTL_PHYS_BASE), 90 .pfn = __phys_to_pfn(IXP2000_INTCTL_PHYS_BASE),
91 .length = IXP2000_INTCTL_SIZE, 91 .length = IXP2000_INTCTL_SIZE,
92 .type = MT_DEVICE_IXP2000, 92 .type = MT_DEVICE,
93 }, { 93 }, {
94 .virtual = IXP2000_PCI_CREG_VIRT_BASE, 94 .virtual = IXP2000_PCI_CREG_VIRT_BASE,
95 .pfn = __phys_to_pfn(IXP2000_PCI_CREG_PHYS_BASE), 95 .pfn = __phys_to_pfn(IXP2000_PCI_CREG_PHYS_BASE),
96 .length = IXP2000_PCI_CREG_SIZE, 96 .length = IXP2000_PCI_CREG_SIZE,
97 .type = MT_DEVICE_IXP2000, 97 .type = MT_DEVICE,
98 }, { 98 }, {
99 .virtual = IXP2000_PCI_CSR_VIRT_BASE, 99 .virtual = IXP2000_PCI_CSR_VIRT_BASE,
100 .pfn = __phys_to_pfn(IXP2000_PCI_CSR_PHYS_BASE), 100 .pfn = __phys_to_pfn(IXP2000_PCI_CSR_PHYS_BASE),
101 .length = IXP2000_PCI_CSR_SIZE, 101 .length = IXP2000_PCI_CSR_SIZE,
102 .type = MT_DEVICE_IXP2000, 102 .type = MT_DEVICE,
103 }, { 103 }, {
104 .virtual = IXP2000_MSF_VIRT_BASE, 104 .virtual = IXP2000_MSF_VIRT_BASE,
105 .pfn = __phys_to_pfn(IXP2000_MSF_PHYS_BASE), 105 .pfn = __phys_to_pfn(IXP2000_MSF_PHYS_BASE),
106 .length = IXP2000_MSF_SIZE, 106 .length = IXP2000_MSF_SIZE,
107 .type = MT_DEVICE_IXP2000, 107 .type = MT_DEVICE,
108 }, { 108 }, {
109 .virtual = IXP2000_SCRATCH_RING_VIRT_BASE, 109 .virtual = IXP2000_SCRATCH_RING_VIRT_BASE,
110 .pfn = __phys_to_pfn(IXP2000_SCRATCH_RING_PHYS_BASE), 110 .pfn = __phys_to_pfn(IXP2000_SCRATCH_RING_PHYS_BASE),
111 .length = IXP2000_SCRATCH_RING_SIZE, 111 .length = IXP2000_SCRATCH_RING_SIZE,
112 .type = MT_DEVICE_IXP2000, 112 .type = MT_DEVICE,
113 }, { 113 }, {
114 .virtual = IXP2000_SRAM0_VIRT_BASE, 114 .virtual = IXP2000_SRAM0_VIRT_BASE,
115 .pfn = __phys_to_pfn(IXP2000_SRAM0_PHYS_BASE), 115 .pfn = __phys_to_pfn(IXP2000_SRAM0_PHYS_BASE),
116 .length = IXP2000_SRAM0_SIZE, 116 .length = IXP2000_SRAM0_SIZE,
117 .type = MT_DEVICE_IXP2000, 117 .type = MT_DEVICE,
118 }, { 118 }, {
119 .virtual = IXP2000_PCI_IO_VIRT_BASE, 119 .virtual = IXP2000_PCI_IO_VIRT_BASE,
120 .pfn = __phys_to_pfn(IXP2000_PCI_IO_PHYS_BASE), 120 .pfn = __phys_to_pfn(IXP2000_PCI_IO_PHYS_BASE),
121 .length = IXP2000_PCI_IO_SIZE, 121 .length = IXP2000_PCI_IO_SIZE,
122 .type = MT_DEVICE_IXP2000, 122 .type = MT_DEVICE,
123 }, { 123 }, {
124 .virtual = IXP2000_PCI_CFG0_VIRT_BASE, 124 .virtual = IXP2000_PCI_CFG0_VIRT_BASE,
125 .pfn = __phys_to_pfn(IXP2000_PCI_CFG0_PHYS_BASE), 125 .pfn = __phys_to_pfn(IXP2000_PCI_CFG0_PHYS_BASE),
126 .length = IXP2000_PCI_CFG0_SIZE, 126 .length = IXP2000_PCI_CFG0_SIZE,
127 .type = MT_DEVICE_IXP2000, 127 .type = MT_DEVICE,
128 }, { 128 }, {
129 .virtual = IXP2000_PCI_CFG1_VIRT_BASE, 129 .virtual = IXP2000_PCI_CFG1_VIRT_BASE,
130 .pfn = __phys_to_pfn(IXP2000_PCI_CFG1_PHYS_BASE), 130 .pfn = __phys_to_pfn(IXP2000_PCI_CFG1_PHYS_BASE),
131 .length = IXP2000_PCI_CFG1_SIZE, 131 .length = IXP2000_PCI_CFG1_SIZE,
132 .type = MT_DEVICE_IXP2000, 132 .type = MT_DEVICE,
133 } 133 }
134}; 134};
135 135
136void __init ixp2000_map_io(void) 136void __init ixp2000_map_io(void)
137{ 137{
138 /*
139 * On IXP2400 CPUs we need to use MT_DEVICE_IXP2000 so that
140 * XCB=101 (to avoid triggering erratum #66), and given that
141 * this mode speeds up I/O accesses and we have write buffer
142 * flushes in the right places anyway, it doesn't hurt to use
143 * XCB=101 for all IXP2000s.
144 */
145 iotable_init(ixp2000_io_desc, ARRAY_SIZE(ixp2000_io_desc)); 138 iotable_init(ixp2000_io_desc, ARRAY_SIZE(ixp2000_io_desc));
146 139
147 /* Set slowport to 8-bit mode. */ 140 /* Set slowport to 8-bit mode. */
@@ -311,8 +304,7 @@ static void ixp2000_GPIO_irq_handler(unsigned int irq, struct irq_desc *desc)
311 304
312 for (i = 0; i <= 7; i++) { 305 for (i = 0; i <= 7; i++) {
313 if (status & (1<<i)) { 306 if (status & (1<<i)) {
314 desc = irq_desc + i + IRQ_IXP2000_GPIO0; 307 generic_handle_irq(i + IRQ_IXP2000_GPIO0);
315 desc_handle_irq(i + IRQ_IXP2000_GPIO0, desc);
316 } 308 }
317 } 309 }
318} 310}
@@ -404,8 +396,7 @@ static void ixp2000_err_irq_handler(unsigned int irq, struct irq_desc *desc)
404 396
405 for(i = 31; i >= 0; i--) { 397 for(i = 31; i >= 0; i--) {
406 if(status & (1 << i)) { 398 if(status & (1 << i)) {
407 desc = irq_desc + IRQ_IXP2000_DRAM0_MIN_ERR + i; 399 generic_handle_irq(IRQ_IXP2000_DRAM0_MIN_ERR + i);
408 desc_handle_irq(IRQ_IXP2000_DRAM0_MIN_ERR + i, desc);
409 } 400 }
410 } 401 }
411} 402}
diff --git a/arch/arm/mach-ixp2000/enp2611.c b/arch/arm/mach-ixp2000/enp2611.c
index c62ed655c1a7..c84dfac13882 100644
--- a/arch/arm/mach-ixp2000/enp2611.c
+++ b/arch/arm/mach-ixp2000/enp2611.c
@@ -32,8 +32,8 @@
32#include <linux/tty.h> 32#include <linux/tty.h>
33#include <linux/serial_core.h> 33#include <linux/serial_core.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/io.h>
35 36
36#include <asm/io.h>
37#include <asm/irq.h> 37#include <asm/irq.h>
38#include <asm/pgtable.h> 38#include <asm/pgtable.h>
39#include <asm/page.h> 39#include <asm/page.h>
@@ -70,17 +70,17 @@ static struct map_desc enp2611_io_desc[] __initdata = {
70 .virtual = ENP2611_CALEB_VIRT_BASE, 70 .virtual = ENP2611_CALEB_VIRT_BASE,
71 .pfn = __phys_to_pfn(ENP2611_CALEB_PHYS_BASE), 71 .pfn = __phys_to_pfn(ENP2611_CALEB_PHYS_BASE),
72 .length = ENP2611_CALEB_SIZE, 72 .length = ENP2611_CALEB_SIZE,
73 .type = MT_DEVICE_IXP2000, 73 .type = MT_DEVICE,
74 }, { 74 }, {
75 .virtual = ENP2611_PM3386_0_VIRT_BASE, 75 .virtual = ENP2611_PM3386_0_VIRT_BASE,
76 .pfn = __phys_to_pfn(ENP2611_PM3386_0_PHYS_BASE), 76 .pfn = __phys_to_pfn(ENP2611_PM3386_0_PHYS_BASE),
77 .length = ENP2611_PM3386_0_SIZE, 77 .length = ENP2611_PM3386_0_SIZE,
78 .type = MT_DEVICE_IXP2000, 78 .type = MT_DEVICE,
79 }, { 79 }, {
80 .virtual = ENP2611_PM3386_1_VIRT_BASE, 80 .virtual = ENP2611_PM3386_1_VIRT_BASE,
81 .pfn = __phys_to_pfn(ENP2611_PM3386_1_PHYS_BASE), 81 .pfn = __phys_to_pfn(ENP2611_PM3386_1_PHYS_BASE),
82 .length = ENP2611_PM3386_1_SIZE, 82 .length = ENP2611_PM3386_1_SIZE,
83 .type = MT_DEVICE_IXP2000, 83 .type = MT_DEVICE,
84 } 84 }
85}; 85};
86 86
diff --git a/arch/arm/mach-ixp2000/include/mach/ixp2000-regs.h b/arch/arm/mach-ixp2000/include/mach/ixp2000-regs.h
index 19d80379a3e3..822f63f2f4a2 100644
--- a/arch/arm/mach-ixp2000/include/mach/ixp2000-regs.h
+++ b/arch/arm/mach-ixp2000/include/mach/ixp2000-regs.h
@@ -41,13 +41,7 @@
41 * Most of the registers are clumped in 4K regions spread throughout 41 * Most of the registers are clumped in 4K regions spread throughout
42 * the 0xc0000000 -> 0xc0100000 address range, but we just map in 42 * the 0xc0000000 -> 0xc0100000 address range, but we just map in
43 * the whole range using a single 1 MB section instead of small 43 * the whole range using a single 1 MB section instead of small
44 * 4K pages. This has two advantages for us: 44 * 4K pages.
45 *
46 * 1) We use only one TLB entry for large number of on-chip I/O devices.
47 *
48 * 2) We can easily set the Section attributes to XCB=101 on the IXP2400
49 * as required per erratum #66. We accomplish this by using a
50 * new MT_IXP2000_DEVICE memory type with the bits set as required.
51 * 45 *
52 * CAP stands for CSR Access Proxy. 46 * CAP stands for CSR Access Proxy.
53 * 47 *
diff --git a/arch/arm/mach-ixp2000/ixdp2400.c b/arch/arm/mach-ixp2000/ixdp2400.c
index c673b9ef9f69..4467c4224d73 100644
--- a/arch/arm/mach-ixp2000/ixdp2400.c
+++ b/arch/arm/mach-ixp2000/ixdp2400.c
@@ -25,8 +25,8 @@
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/io.h>
28 29
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/pgtable.h> 31#include <asm/pgtable.h>
32#include <asm/page.h> 32#include <asm/page.h>
diff --git a/arch/arm/mach-ixp2000/ixdp2800.c b/arch/arm/mach-ixp2000/ixdp2800.c
index 6715b50829a6..94f68ba9ea50 100644
--- a/arch/arm/mach-ixp2000/ixdp2800.c
+++ b/arch/arm/mach-ixp2000/ixdp2800.c
@@ -25,8 +25,8 @@
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/io.h>
28 29
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/pgtable.h> 31#include <asm/pgtable.h>
32#include <asm/page.h> 32#include <asm/page.h>
diff --git a/arch/arm/mach-ixp2000/ixdp2x00.c b/arch/arm/mach-ixp2000/ixdp2x00.c
index 5a781fd9757a..b0653a87159a 100644
--- a/arch/arm/mach-ixp2000/ixdp2x00.c
+++ b/arch/arm/mach-ixp2000/ixdp2x00.c
@@ -25,8 +25,8 @@
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/io.h>
28 29
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/pgtable.h> 31#include <asm/pgtable.h>
32#include <asm/page.h> 32#include <asm/page.h>
@@ -129,10 +129,8 @@ static void ixdp2x00_irq_handler(unsigned int irq, struct irq_desc *desc)
129 129
130 for(i = 0; i < board_irq_count; i++) { 130 for(i = 0; i < board_irq_count; i++) {
131 if(ex_interrupt & (1 << i)) { 131 if(ex_interrupt & (1 << i)) {
132 struct irq_desc *cpld_desc;
133 int cpld_irq = IXP2000_BOARD_IRQ(0) + i; 132 int cpld_irq = IXP2000_BOARD_IRQ(0) + i;
134 cpld_desc = irq_desc + cpld_irq; 133 generic_handle_irq(cpld_irq);
135 desc_handle_irq(cpld_irq, cpld_desc);
136 } 134 }
137 } 135 }
138 136
diff --git a/arch/arm/mach-ixp2000/ixdp2x01.c b/arch/arm/mach-ixp2000/ixdp2x01.c
index 78a2341dee2c..4a12327a09a3 100644
--- a/arch/arm/mach-ixp2000/ixdp2x01.c
+++ b/arch/arm/mach-ixp2000/ixdp2x01.c
@@ -30,8 +30,8 @@
30#include <linux/serial_core.h> 30#include <linux/serial_core.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/serial_8250.h> 32#include <linux/serial_8250.h>
33#include <linux/io.h>
33 34
34#include <asm/io.h>
35#include <asm/irq.h> 35#include <asm/irq.h>
36#include <asm/pgtable.h> 36#include <asm/pgtable.h>
37#include <asm/page.h> 37#include <asm/page.h>
@@ -79,10 +79,8 @@ static void ixdp2x01_irq_handler(unsigned int irq, struct irq_desc *desc)
79 79
80 for (i = 0; i < IXP2000_BOARD_IRQS; i++) { 80 for (i = 0; i < IXP2000_BOARD_IRQS; i++) {
81 if (ex_interrupt & (1 << i)) { 81 if (ex_interrupt & (1 << i)) {
82 struct irq_desc *cpld_desc;
83 int cpld_irq = IXP2000_BOARD_IRQ(0) + i; 82 int cpld_irq = IXP2000_BOARD_IRQ(0) + i;
84 cpld_desc = irq_desc + cpld_irq; 83 generic_handle_irq(cpld_irq);
85 desc_handle_irq(cpld_irq, cpld_desc);
86 } 84 }
87 } 85 }
88 86
diff --git a/arch/arm/mach-ixp2000/pci.c b/arch/arm/mach-ixp2000/pci.c
index 03d916fbe531..60e9fd08ab80 100644
--- a/arch/arm/mach-ixp2000/pci.c
+++ b/arch/arm/mach-ixp2000/pci.c
@@ -24,8 +24,8 @@
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/io.h>
27 28
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/system.h> 30#include <asm/system.h>
31#include <mach/hardware.h> 31#include <mach/hardware.h>
diff --git a/arch/arm/mach-ixp23xx/core.c b/arch/arm/mach-ixp23xx/core.c
index 68b4ac5b2481..aa4c4420ff3d 100644
--- a/arch/arm/mach-ixp23xx/core.c
+++ b/arch/arm/mach-ixp23xx/core.c
@@ -253,7 +253,6 @@ static void pci_handler(unsigned int irq, struct irq_desc *desc)
253{ 253{
254 u32 pci_interrupt; 254 u32 pci_interrupt;
255 unsigned int irqno; 255 unsigned int irqno;
256 struct irq_desc *int_desc;
257 256
258 pci_interrupt = *IXP23XX_PCI_XSCALE_INT_STATUS; 257 pci_interrupt = *IXP23XX_PCI_XSCALE_INT_STATUS;
259 258
@@ -268,8 +267,7 @@ static void pci_handler(unsigned int irq, struct irq_desc *desc)
268 BUG(); 267 BUG();
269 } 268 }
270 269
271 int_desc = irq_desc + irqno; 270 generic_handle_irq(irqno);
272 desc_handle_irq(irqno, int_desc);
273 271
274 desc->chip->unmask(irq); 272 desc->chip->unmask(irq);
275} 273}
diff --git a/arch/arm/mach-ixp23xx/ixdp2351.c b/arch/arm/mach-ixp23xx/ixdp2351.c
index b6e0bfa44df9..f1b124a709ab 100644
--- a/arch/arm/mach-ixp23xx/ixdp2351.c
+++ b/arch/arm/mach-ixp23xx/ixdp2351.c
@@ -68,11 +68,9 @@ static void ixdp2351_inta_handler(unsigned int irq, struct irq_desc *desc)
68 68
69 for (i = 0; i < IXDP2351_INTA_IRQ_NUM; i++) { 69 for (i = 0; i < IXDP2351_INTA_IRQ_NUM; i++) {
70 if (ex_interrupt & (1 << i)) { 70 if (ex_interrupt & (1 << i)) {
71 struct irq_desc *cpld_desc;
72 int cpld_irq = 71 int cpld_irq =
73 IXP23XX_MACH_IRQ(IXDP2351_INTA_IRQ_BASE + i); 72 IXP23XX_MACH_IRQ(IXDP2351_INTA_IRQ_BASE + i);
74 cpld_desc = irq_desc + cpld_irq; 73 generic_handle_irq(cpld_irq);
75 desc_handle_irq(cpld_irq, cpld_desc);
76 } 74 }
77 } 75 }
78 76
@@ -105,11 +103,9 @@ static void ixdp2351_intb_handler(unsigned int irq, struct irq_desc *desc)
105 103
106 for (i = 0; i < IXDP2351_INTB_IRQ_NUM; i++) { 104 for (i = 0; i < IXDP2351_INTB_IRQ_NUM; i++) {
107 if (ex_interrupt & (1 << i)) { 105 if (ex_interrupt & (1 << i)) {
108 struct irq_desc *cpld_desc;
109 int cpld_irq = 106 int cpld_irq =
110 IXP23XX_MACH_IRQ(IXDP2351_INTB_IRQ_BASE + i); 107 IXP23XX_MACH_IRQ(IXDP2351_INTB_IRQ_BASE + i);
111 cpld_desc = irq_desc + cpld_irq; 108 generic_handle_irq(cpld_irq);
112 desc_handle_irq(cpld_irq, cpld_desc);
113 } 109 }
114 } 110 }
115 111
diff --git a/arch/arm/mach-ixp23xx/pci.c b/arch/arm/mach-ixp23xx/pci.c
index 701d60aa0efd..59022becb134 100644
--- a/arch/arm/mach-ixp23xx/pci.c
+++ b/arch/arm/mach-ixp23xx/pci.c
@@ -25,8 +25,8 @@
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/io.h>
28 29
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/sizes.h> 31#include <asm/sizes.h>
32#include <asm/system.h> 32#include <asm/system.h>
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 192538a04575..d816c51320c7 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -25,9 +25,10 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/io.h>
28#include <asm/dma-mapping.h> 29#include <asm/dma-mapping.h>
29 30
30#include <asm/io.h> 31#include <asm/cputype.h>
31#include <asm/irq.h> 32#include <asm/irq.h>
32#include <asm/sizes.h> 33#include <asm/sizes.h>
33#include <asm/system.h> 34#include <asm/system.h>
@@ -366,15 +367,13 @@ void __init ixp4xx_adjust_zones(int node, unsigned long *zone_size,
366 367
367void __init ixp4xx_pci_preinit(void) 368void __init ixp4xx_pci_preinit(void)
368{ 369{
369 unsigned long processor_id; 370 unsigned long cpuid = read_cpuid_id();
370
371 asm("mrc p15, 0, %0, cr0, cr0, 0;" : "=r"(processor_id) :);
372 371
373 /* 372 /*
374 * Determine which PCI read method to use. 373 * Determine which PCI read method to use.
375 * Rev 0 IXP425 requires workaround. 374 * Rev 0 IXP425 requires workaround.
376 */ 375 */
377 if (!(processor_id & 0xf) && cpu_is_ixp42x()) { 376 if (!(cpuid & 0xf) && cpu_is_ixp42x()) {
378 printk("PCI: IXP42x A0 silicon detected - " 377 printk("PCI: IXP42x A0 silicon detected - "
379 "PCI Non-Prefetch Workaround Enabled\n"); 378 "PCI Non-Prefetch Workaround Enabled\n");
380 ixp4xx_pci_read = ixp4xx_pci_read_errata; 379 ixp4xx_pci_read = ixp4xx_pci_read_errata;
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 58bd2842a6f1..7766f469456b 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -28,11 +28,11 @@
28#include <linux/timex.h> 28#include <linux/timex.h>
29#include <linux/clocksource.h> 29#include <linux/clocksource.h>
30#include <linux/clockchips.h> 30#include <linux/clockchips.h>
31#include <linux/io.h>
31 32
32#include <mach/udc.h> 33#include <mach/udc.h>
33#include <mach/hardware.h> 34#include <mach/hardware.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <asm/io.h>
36#include <asm/pgtable.h> 36#include <asm/pgtable.h>
37#include <asm/page.h> 37#include <asm/page.h>
38#include <asm/irq.h> 38#include <asm/irq.h>
diff --git a/arch/arm/mach-ixp4xx/fsg-setup.c b/arch/arm/mach-ixp4xx/fsg-setup.c
index 501dfdcc39fe..e7c6386782ed 100644
--- a/arch/arm/mach-ixp4xx/fsg-setup.c
+++ b/arch/arm/mach-ixp4xx/fsg-setup.c
@@ -23,11 +23,11 @@
23#include <linux/reboot.h> 23#include <linux/reboot.h>
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/i2c-gpio.h> 25#include <linux/i2c-gpio.h>
26#include <linux/io.h>
26 27
27#include <asm/mach-types.h> 28#include <asm/mach-types.h>
28#include <asm/mach/arch.h> 29#include <asm/mach/arch.h>
29#include <asm/mach/flash.h> 30#include <asm/mach/flash.h>
30#include <asm/io.h>
31#include <asm/gpio.h> 31#include <asm/gpio.h>
32 32
33static struct flash_platform_data fsg_flash_data = { 33static struct flash_platform_data fsg_flash_data = {
diff --git a/arch/arm/mach-ixp4xx/include/mach/cpu.h b/arch/arm/mach-ixp4xx/include/mach/cpu.h
index ff8aa2393bf9..51bd69c46d94 100644
--- a/arch/arm/mach-ixp4xx/include/mach/cpu.h
+++ b/arch/arm/mach-ixp4xx/include/mach/cpu.h
@@ -14,18 +14,19 @@
14#ifndef __ASM_ARCH_CPU_H__ 14#ifndef __ASM_ARCH_CPU_H__
15#define __ASM_ARCH_CPU_H__ 15#define __ASM_ARCH_CPU_H__
16 16
17extern unsigned int processor_id; 17#include <asm/cputype.h>
18
18/* Processor id value in CP15 Register 0 */ 19/* Processor id value in CP15 Register 0 */
19#define IXP425_PROCESSOR_ID_VALUE 0x690541c0 20#define IXP425_PROCESSOR_ID_VALUE 0x690541c0
20#define IXP435_PROCESSOR_ID_VALUE 0x69054040 21#define IXP435_PROCESSOR_ID_VALUE 0x69054040
21#define IXP465_PROCESSOR_ID_VALUE 0x69054200 22#define IXP465_PROCESSOR_ID_VALUE 0x69054200
22#define IXP4XX_PROCESSOR_ID_MASK 0xfffffff0 23#define IXP4XX_PROCESSOR_ID_MASK 0xfffffff0
23 24
24#define cpu_is_ixp42x() ((processor_id & IXP4XX_PROCESSOR_ID_MASK) == \ 25#define cpu_is_ixp42x() ((read_cpuid_id() & IXP4XX_PROCESSOR_ID_MASK) == \
25 IXP425_PROCESSOR_ID_VALUE) 26 IXP425_PROCESSOR_ID_VALUE)
26#define cpu_is_ixp43x() ((processor_id & IXP4XX_PROCESSOR_ID_MASK) == \ 27#define cpu_is_ixp43x() ((read_cpuid_id() & IXP4XX_PROCESSOR_ID_MASK) == \
27 IXP435_PROCESSOR_ID_VALUE) 28 IXP435_PROCESSOR_ID_VALUE)
28#define cpu_is_ixp46x() ((processor_id & IXP4XX_PROCESSOR_ID_MASK) == \ 29#define cpu_is_ixp46x() ((read_cpuid_id() & IXP4XX_PROCESSOR_ID_MASK) == \
29 IXP465_PROCESSOR_ID_VALUE) 30 IXP465_PROCESSOR_ID_VALUE)
30 31
31static inline u32 ixp4xx_read_feature_bits(void) 32static inline u32 ixp4xx_read_feature_bits(void)
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index 9b2d2ec14c80..f4a0c1bc1331 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -20,6 +20,7 @@
20#include <linux/mtd/mtd.h> 20#include <linux/mtd/mtd.h>
21#include <linux/mtd/nand.h> 21#include <linux/mtd/nand.h>
22#include <linux/mtd/partitions.h> 22#include <linux/mtd/partitions.h>
23#include <linux/delay.h>
23 24
24#include <asm/types.h> 25#include <asm/types.h>
25#include <asm/setup.h> 26#include <asm/setup.h>
@@ -29,7 +30,6 @@
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
31#include <asm/mach/flash.h> 32#include <asm/mach/flash.h>
32#include <asm/delay.h>
33 33
34static struct flash_platform_data ixdp425_flash_data = { 34static struct flash_platform_data ixdp425_flash_data = {
35 .map_name = "cfi_probe", 35 .map_name = "cfi_probe",
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
index 84b5e62a9c0a..0acd95ecf27e 100644
--- a/arch/arm/mach-ixp4xx/nas100d-setup.c
+++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
@@ -28,11 +28,11 @@
28#include <linux/reboot.h> 28#include <linux/reboot.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/i2c-gpio.h> 30#include <linux/i2c-gpio.h>
31#include <linux/io.h>
31 32
32#include <asm/mach-types.h> 33#include <asm/mach-types.h>
33#include <asm/mach/arch.h> 34#include <asm/mach/arch.h>
34#include <asm/mach/flash.h> 35#include <asm/mach/flash.h>
35#include <asm/io.h>
36#include <asm/gpio.h> 36#include <asm/gpio.h>
37 37
38static struct flash_platform_data nas100d_flash_data = { 38static struct flash_platform_data nas100d_flash_data = {
diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c
index a48a6655b887..bc9d920ae54f 100644
--- a/arch/arm/mach-ixp4xx/nslu2-setup.c
+++ b/arch/arm/mach-ixp4xx/nslu2-setup.c
@@ -25,12 +25,12 @@
25#include <linux/reboot.h> 25#include <linux/reboot.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/i2c-gpio.h> 27#include <linux/i2c-gpio.h>
28#include <linux/io.h>
28 29
29#include <asm/mach-types.h> 30#include <asm/mach-types.h>
30#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
31#include <asm/mach/flash.h> 32#include <asm/mach/flash.h>
32#include <asm/mach/time.h> 33#include <asm/mach/time.h>
33#include <asm/io.h>
34#include <asm/gpio.h> 34#include <asm/gpio.h>
35 35
36static struct flash_platform_data nslu2_flash_data = { 36static struct flash_platform_data nslu2_flash_data = {
diff --git a/arch/arm/mach-kirkwood/addr-map.c b/arch/arm/mach-kirkwood/addr-map.c
index c79f492072f9..5db4f0bbe5ee 100644
--- a/arch/arm/mach-kirkwood/addr-map.c
+++ b/arch/arm/mach-kirkwood/addr-map.c
@@ -48,6 +48,7 @@
48 48
49 49
50struct mbus_dram_target_info kirkwood_mbus_dram_info; 50struct mbus_dram_target_info kirkwood_mbus_dram_info;
51static int __initdata win_alloc_count;
51 52
52static int __init cpu_win_can_remap(int win) 53static int __init cpu_win_can_remap(int win)
53{ 54{
@@ -111,6 +112,8 @@ void __init kirkwood_setup_cpu_mbus(void)
111 setup_cpu_win(2, KIRKWOOD_NAND_MEM_PHYS_BASE, KIRKWOOD_NAND_MEM_SIZE, 112 setup_cpu_win(2, KIRKWOOD_NAND_MEM_PHYS_BASE, KIRKWOOD_NAND_MEM_SIZE,
112 TARGET_DEV_BUS, ATTR_DEV_NAND, -1); 113 TARGET_DEV_BUS, ATTR_DEV_NAND, -1);
113 114
115 win_alloc_count = 3;
116
114 /* 117 /*
115 * Setup MBUS dram target info. 118 * Setup MBUS dram target info.
116 */ 119 */
@@ -137,3 +140,8 @@ void __init kirkwood_setup_cpu_mbus(void)
137 } 140 }
138 kirkwood_mbus_dram_info.num_cs = cs; 141 kirkwood_mbus_dram_info.num_cs = cs;
139} 142}
143
144void __init kirkwood_setup_sram_win(u32 base, u32 size)
145{
146 setup_cpu_win(win_alloc_count++, base, size, 0x03, 0x00, -1);
147}
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index 189f16f3619d..85cad05d8c5b 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -98,7 +98,6 @@ void __init kirkwood_ehci_init(void)
98 * GE00 98 * GE00
99 ****************************************************************************/ 99 ****************************************************************************/
100struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = { 100struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
101 .t_clk = KIRKWOOD_TCLK,
102 .dram = &kirkwood_mbus_dram_info, 101 .dram = &kirkwood_mbus_dram_info,
103}; 102};
104 103
@@ -108,6 +107,11 @@ static struct resource kirkwood_ge00_shared_resources[] = {
108 .start = GE00_PHYS_BASE + 0x2000, 107 .start = GE00_PHYS_BASE + 0x2000,
109 .end = GE00_PHYS_BASE + 0x3fff, 108 .end = GE00_PHYS_BASE + 0x3fff,
110 .flags = IORESOURCE_MEM, 109 .flags = IORESOURCE_MEM,
110 }, {
111 .name = "ge00 err irq",
112 .start = IRQ_KIRKWOOD_GE00_ERR,
113 .end = IRQ_KIRKWOOD_GE00_ERR,
114 .flags = IORESOURCE_IRQ,
111 }, 115 },
112}; 116};
113 117
@@ -117,7 +121,7 @@ static struct platform_device kirkwood_ge00_shared = {
117 .dev = { 121 .dev = {
118 .platform_data = &kirkwood_ge00_shared_data, 122 .platform_data = &kirkwood_ge00_shared_data,
119 }, 123 },
120 .num_resources = 1, 124 .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
121 .resource = kirkwood_ge00_shared_resources, 125 .resource = kirkwood_ge00_shared_resources,
122}; 126};
123 127
@@ -201,7 +205,6 @@ void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
201 * SPI 205 * SPI
202 ****************************************************************************/ 206 ****************************************************************************/
203static struct orion_spi_info kirkwood_spi_plat_data = { 207static struct orion_spi_info kirkwood_spi_plat_data = {
204 .tclk = KIRKWOOD_TCLK,
205}; 208};
206 209
207static struct resource kirkwood_spi_resources[] = { 210static struct resource kirkwood_spi_resources[] = {
@@ -239,7 +242,7 @@ static struct plat_serial8250_port kirkwood_uart0_data[] = {
239 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, 242 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
240 .iotype = UPIO_MEM, 243 .iotype = UPIO_MEM,
241 .regshift = 2, 244 .regshift = 2,
242 .uartclk = KIRKWOOD_TCLK, 245 .uartclk = 0,
243 }, { 246 }, {
244 }, 247 },
245}; 248};
@@ -283,7 +286,7 @@ static struct plat_serial8250_port kirkwood_uart1_data[] = {
283 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, 286 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
284 .iotype = UPIO_MEM, 287 .iotype = UPIO_MEM,
285 .regshift = 2, 288 .regshift = 2,
286 .uartclk = KIRKWOOD_TCLK, 289 .uartclk = 0,
287 }, { 290 }, {
288 }, 291 },
289}; 292};
@@ -525,9 +528,23 @@ void __init kirkwood_xor1_init(void)
525/***************************************************************************** 528/*****************************************************************************
526 * Time handling 529 * Time handling
527 ****************************************************************************/ 530 ****************************************************************************/
531int kirkwood_tclk;
532
533int __init kirkwood_find_tclk(void)
534{
535 u32 dev, rev;
536
537 kirkwood_pcie_id(&dev, &rev);
538 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
539 return 200000000;
540
541 return 166666667;
542}
543
528static void kirkwood_timer_init(void) 544static void kirkwood_timer_init(void)
529{ 545{
530 orion_time_init(IRQ_KIRKWOOD_BRIDGE, KIRKWOOD_TCLK); 546 kirkwood_tclk = kirkwood_find_tclk();
547 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
531} 548}
532 549
533struct sys_timer kirkwood_timer = { 550struct sys_timer kirkwood_timer = {
@@ -538,33 +555,62 @@ struct sys_timer kirkwood_timer = {
538/***************************************************************************** 555/*****************************************************************************
539 * General 556 * General
540 ****************************************************************************/ 557 ****************************************************************************/
558/*
559 * Identify device ID and revision.
560 */
541static char * __init kirkwood_id(void) 561static char * __init kirkwood_id(void)
542{ 562{
543 switch (readl(DEVICE_ID) & 0x3) { 563 u32 dev, rev;
544 case 0: 564
545 return "88F6180"; 565 kirkwood_pcie_id(&dev, &rev);
546 case 1: 566
547 return "88F6192"; 567 if (dev == MV88F6281_DEV_ID) {
548 case 2: 568 if (rev == MV88F6281_REV_Z0)
549 return "88F6281"; 569 return "MV88F6281-Z0";
570 else if (rev == MV88F6281_REV_A0)
571 return "MV88F6281-A0";
572 else
573 return "MV88F6281-Rev-Unsupported";
574 } else if (dev == MV88F6192_DEV_ID) {
575 if (rev == MV88F6192_REV_Z0)
576 return "MV88F6192-Z0";
577 else if (rev == MV88F6192_REV_A0)
578 return "MV88F6192-A0";
579 else
580 return "MV88F6192-Rev-Unsupported";
581 } else if (dev == MV88F6180_DEV_ID) {
582 if (rev == MV88F6180_REV_A0)
583 return "MV88F6180-Rev-A0";
584 else
585 return "MV88F6180-Rev-Unsupported";
586 } else {
587 return "Device-Unknown";
550 } 588 }
551
552 return "unknown 88F6000 variant";
553} 589}
554 590
555static int __init is_l2_writethrough(void) 591static void __init kirkwood_l2_init(void)
556{ 592{
557 return !!(readl(L2_CONFIG_REG) & L2_WRITETHROUGH); 593#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
594 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
595 feroceon_l2_init(1);
596#else
597 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
598 feroceon_l2_init(0);
599#endif
558} 600}
559 601
560void __init kirkwood_init(void) 602void __init kirkwood_init(void)
561{ 603{
562 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n", 604 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
563 kirkwood_id(), KIRKWOOD_TCLK); 605 kirkwood_id(), kirkwood_tclk);
606 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
607 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
608 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
609 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
564 610
565 kirkwood_setup_cpu_mbus(); 611 kirkwood_setup_cpu_mbus();
566 612
567#ifdef CONFIG_CACHE_FEROCEON_L2 613#ifdef CONFIG_CACHE_FEROCEON_L2
568 feroceon_l2_init(is_l2_writethrough()); 614 kirkwood_l2_init();
569#endif 615#endif
570} 616}
diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h
index 69cd113af03a..8fa0f6a27635 100644
--- a/arch/arm/mach-kirkwood/common.h
+++ b/arch/arm/mach-kirkwood/common.h
@@ -23,10 +23,9 @@ void kirkwood_init_irq(void);
23 23
24extern struct mbus_dram_target_info kirkwood_mbus_dram_info; 24extern struct mbus_dram_target_info kirkwood_mbus_dram_info;
25void kirkwood_setup_cpu_mbus(void); 25void kirkwood_setup_cpu_mbus(void);
26void kirkwood_setup_pcie_io_win(int window, u32 base, u32 size, 26void kirkwood_setup_sram_win(u32 base, u32 size);
27 int maj, int min); 27
28void kirkwood_setup_pcie_mem_win(int window, u32 base, u32 size, 28void kirkwood_pcie_id(u32 *dev, u32 *rev);
29 int maj, int min);
30 29
31void kirkwood_ehci_init(void); 30void kirkwood_ehci_init(void);
32void kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data); 31void kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data);
diff --git a/arch/arm/mach-kirkwood/db88f6281-bp-setup.c b/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
index 610fb24d8ae2..a14c2948c62a 100644
--- a/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
+++ b/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
@@ -25,7 +25,7 @@
25#include "common.h" 25#include "common.h"
26 26
27static struct mv643xx_eth_platform_data db88f6281_ge00_data = { 27static struct mv643xx_eth_platform_data db88f6281_ge00_data = {
28 .phy_addr = 8, 28 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
29}; 29};
30 30
31static struct mv_sata_platform_data db88f6281_sata_data = { 31static struct mv_sata_platform_data db88f6281_sata_data = {
@@ -44,7 +44,6 @@ static void __init db88f6281_init(void)
44 kirkwood_rtc_init(); 44 kirkwood_rtc_init();
45 kirkwood_sata_init(&db88f6281_sata_data); 45 kirkwood_sata_init(&db88f6281_sata_data);
46 kirkwood_uart0_init(); 46 kirkwood_uart0_init();
47 kirkwood_uart1_init();
48} 47}
49 48
50static int __init db88f6281_pci_init(void) 49static int __init db88f6281_pci_init(void)
diff --git a/arch/arm/mach-kirkwood/include/mach/irqs.h b/arch/arm/mach-kirkwood/include/mach/irqs.h
index 6fd05838c72d..ffab89f21c11 100644
--- a/arch/arm/mach-kirkwood/include/mach/irqs.h
+++ b/arch/arm/mach-kirkwood/include/mach/irqs.h
@@ -50,6 +50,7 @@
50#define IRQ_KIRKWOOD_GPIO_HIGH_0_7 39 50#define IRQ_KIRKWOOD_GPIO_HIGH_0_7 39
51#define IRQ_KIRKWOOD_GPIO_HIGH_8_15 40 51#define IRQ_KIRKWOOD_GPIO_HIGH_8_15 40
52#define IRQ_KIRKWOOD_GPIO_HIGH_16_23 41 52#define IRQ_KIRKWOOD_GPIO_HIGH_16_23 41
53#define IRQ_KIRKWOOD_GE00_ERR 46
53 54
54/* 55/*
55 * KIRKWOOD General Purpose Pins 56 * KIRKWOOD General Purpose Pins
diff --git a/arch/arm/mach-kirkwood/include/mach/kirkwood.h b/arch/arm/mach-kirkwood/include/mach/kirkwood.h
index 5c69992295e8..eae42406fd86 100644
--- a/arch/arm/mach-kirkwood/include/mach/kirkwood.h
+++ b/arch/arm/mach-kirkwood/include/mach/kirkwood.h
@@ -68,6 +68,20 @@
68#define L2_WRITETHROUGH 0x00000010 68#define L2_WRITETHROUGH 0x00000010
69 69
70/* 70/*
71 * Supported devices and revisions.
72 */
73#define MV88F6281_DEV_ID 0x6281
74#define MV88F6281_REV_Z0 0
75#define MV88F6281_REV_A0 2
76
77#define MV88F6192_DEV_ID 0x6192
78#define MV88F6192_REV_Z0 0
79#define MV88F6192_REV_A0 2
80
81#define MV88F6180_DEV_ID 0x6180
82#define MV88F6180_REV_A0 2
83
84/*
71 * Register Map 85 * Register Map
72 */ 86 */
73#define DDR_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE | 0x00000) 87#define DDR_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE | 0x00000)
diff --git a/arch/arm/mach-kirkwood/include/mach/timex.h b/arch/arm/mach-kirkwood/include/mach/timex.h
index f77ef4a32c5f..c923cd169b9c 100644
--- a/arch/arm/mach-kirkwood/include/mach/timex.h
+++ b/arch/arm/mach-kirkwood/include/mach/timex.h
@@ -8,4 +8,3 @@
8 8
9#define CLOCK_TICK_RATE (100 * HZ) 9#define CLOCK_TICK_RATE (100 * HZ)
10 10
11#define KIRKWOOD_TCLK 166666667
diff --git a/arch/arm/mach-kirkwood/pcie.c b/arch/arm/mach-kirkwood/pcie.c
index 2195fa31f6b7..f6b08f207c89 100644
--- a/arch/arm/mach-kirkwood/pcie.c
+++ b/arch/arm/mach-kirkwood/pcie.c
@@ -18,6 +18,12 @@
18 18
19#define PCIE_BASE ((void __iomem *)PCIE_VIRT_BASE) 19#define PCIE_BASE ((void __iomem *)PCIE_VIRT_BASE)
20 20
21void __init kirkwood_pcie_id(u32 *dev, u32 *rev)
22{
23 *dev = orion_pcie_dev_id(PCIE_BASE);
24 *rev = orion_pcie_rev(PCIE_BASE);
25}
26
21static int pcie_valid_config(int bus, int dev) 27static int pcie_valid_config(int bus, int dev)
22{ 28{
23 /* 29 /*
diff --git a/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c b/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
index a3012d445971..b1d1a87a6821 100644
--- a/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
+++ b/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
@@ -30,7 +30,7 @@
30#define RD88F6192_GPIO_USB_VBUS 10 30#define RD88F6192_GPIO_USB_VBUS 10
31 31
32static struct mv643xx_eth_platform_data rd88f6192_ge00_data = { 32static struct mv643xx_eth_platform_data rd88f6192_ge00_data = {
33 .phy_addr = 8, 33 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
34}; 34};
35 35
36static struct mv_sata_platform_data rd88f6192_sata_data = { 36static struct mv_sata_platform_data rd88f6192_sata_data = {
diff --git a/arch/arm/mach-kirkwood/rd88f6281-setup.c b/arch/arm/mach-kirkwood/rd88f6281-setup.c
index d96487a0f18b..f785093e433f 100644
--- a/arch/arm/mach-kirkwood/rd88f6281-setup.c
+++ b/arch/arm/mach-kirkwood/rd88f6281-setup.c
@@ -69,7 +69,7 @@ static struct platform_device rd88f6281_nand_flash = {
69}; 69};
70 70
71static struct mv643xx_eth_platform_data rd88f6281_ge00_data = { 71static struct mv643xx_eth_platform_data rd88f6281_ge00_data = {
72 .phy_addr = -1, 72 .phy_addr = MV643XX_ETH_PHY_NONE,
73 .speed = SPEED_1000, 73 .speed = SPEED_1000,
74 .duplex = DUPLEX_FULL, 74 .duplex = DUPLEX_FULL,
75}; 75};
@@ -90,7 +90,6 @@ static void __init rd88f6281_init(void)
90 kirkwood_rtc_init(); 90 kirkwood_rtc_init();
91 kirkwood_sata_init(&rd88f6281_sata_data); 91 kirkwood_sata_init(&rd88f6281_sata_data);
92 kirkwood_uart0_init(); 92 kirkwood_uart0_init();
93 kirkwood_uart1_init();
94 93
95 platform_device_register(&rd88f6281_nand_flash); 94 platform_device_register(&rd88f6281_nand_flash);
96} 95}
diff --git a/arch/arm/mach-ks8695/cpu.c b/arch/arm/mach-ks8695/cpu.c
index c6c08e800233..7f3f24053a00 100644
--- a/arch/arm/mach-ks8695/cpu.c
+++ b/arch/arm/mach-ks8695/cpu.c
@@ -24,9 +24,9 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/io.h>
30#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
31#include <asm/mach/map.h> 31#include <asm/mach/map.h>
32 32
diff --git a/arch/arm/mach-ks8695/gpio.c b/arch/arm/mach-ks8695/gpio.c
index 3624e65cd89b..9aecf0c4b8b1 100644
--- a/arch/arm/mach-ks8695/gpio.c
+++ b/arch/arm/mach-ks8695/gpio.c
@@ -23,8 +23,8 @@
23#include <linux/debugfs.h> 23#include <linux/debugfs.h>
24#include <linux/seq_file.h> 24#include <linux/seq_file.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/io.h>
26 27
27#include <asm/io.h>
28#include <mach/hardware.h> 28#include <mach/hardware.h>
29#include <asm/mach/irq.h> 29#include <asm/mach/irq.h>
30 30
@@ -72,7 +72,7 @@ int __init_or_module ks8695_gpio_interrupt(unsigned int pin, unsigned int type)
72 72
73 /* set pin as input */ 73 /* set pin as input */
74 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPM); 74 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPM);
75 x &= ~IOPM_(pin); 75 x &= ~IOPM(pin);
76 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPM); 76 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPM);
77 77
78 local_irq_restore(flags); 78 local_irq_restore(flags);
@@ -108,7 +108,7 @@ int __init_or_module gpio_direction_input(unsigned int pin)
108 108
109 /* set pin as input */ 109 /* set pin as input */
110 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPM); 110 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPM);
111 x &= ~IOPM_(pin); 111 x &= ~IOPM(pin);
112 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPM); 112 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPM);
113 113
114 local_irq_restore(flags); 114 local_irq_restore(flags);
@@ -136,14 +136,14 @@ int __init_or_module gpio_direction_output(unsigned int pin, unsigned int state)
136 /* set line state */ 136 /* set line state */
137 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD); 137 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
138 if (state) 138 if (state)
139 x |= (1 << pin); 139 x |= IOPD(pin);
140 else 140 else
141 x &= ~(1 << pin); 141 x &= ~IOPD(pin);
142 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPD); 142 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPD);
143 143
144 /* set pin as output */ 144 /* set pin as output */
145 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPM); 145 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPM);
146 x |= IOPM_(pin); 146 x |= IOPM(pin);
147 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPM); 147 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPM);
148 148
149 local_irq_restore(flags); 149 local_irq_restore(flags);
@@ -168,9 +168,9 @@ void gpio_set_value(unsigned int pin, unsigned int state)
168 /* set output line state */ 168 /* set output line state */
169 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD); 169 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
170 if (state) 170 if (state)
171 x |= (1 << pin); 171 x |= IOPD(pin);
172 else 172 else
173 x &= ~(1 << pin); 173 x &= ~IOPD(pin);
174 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPD); 174 __raw_writel(x, KS8695_GPIO_VA + KS8695_IOPD);
175 175
176 local_irq_restore(flags); 176 local_irq_restore(flags);
@@ -189,7 +189,7 @@ int gpio_get_value(unsigned int pin)
189 return -EINVAL; 189 return -EINVAL;
190 190
191 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD); 191 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
192 return (x & (1 << pin)) != 0; 192 return (x & IOPD(pin)) != 0;
193} 193}
194EXPORT_SYMBOL(gpio_get_value); 194EXPORT_SYMBOL(gpio_get_value);
195 195
@@ -240,7 +240,7 @@ static int ks8695_gpio_show(struct seq_file *s, void *unused)
240 for (i = KS8695_GPIO_0; i <= KS8695_GPIO_15 ; i++) { 240 for (i = KS8695_GPIO_0; i <= KS8695_GPIO_15 ; i++) {
241 seq_printf(s, "%i:\t", i); 241 seq_printf(s, "%i:\t", i);
242 242
243 seq_printf(s, "%s\t", (mode & IOPM_(i)) ? "Output" : "Input"); 243 seq_printf(s, "%s\t", (mode & IOPM(i)) ? "Output" : "Input");
244 244
245 if (i <= KS8695_GPIO_3) { 245 if (i <= KS8695_GPIO_3) {
246 if (ctrl & enable[i]) { 246 if (ctrl & enable[i]) {
@@ -273,7 +273,7 @@ static int ks8695_gpio_show(struct seq_file *s, void *unused)
273 273
274 seq_printf(s, "\t"); 274 seq_printf(s, "\t");
275 275
276 seq_printf(s, "%i\n", (data & IOPD_(i)) ? 1 : 0); 276 seq_printf(s, "%i\n", (data & IOPD(i)) ? 1 : 0);
277 } 277 }
278 return 0; 278 return 0;
279} 279}
diff --git a/arch/arm/mach-ks8695/include/mach/memory.h b/arch/arm/mach-ks8695/include/mach/memory.h
index dadbe66cb75c..8fbc4c76c38b 100644
--- a/arch/arm/mach-ks8695/include/mach/memory.h
+++ b/arch/arm/mach-ks8695/include/mach/memory.h
@@ -31,8 +31,8 @@
31/* Platform-bus mapping */ 31/* Platform-bus mapping */
32extern struct bus_type platform_bus_type; 32extern struct bus_type platform_bus_type;
33#define is_lbus_device(dev) (dev && dev->bus == &platform_bus_type) 33#define is_lbus_device(dev) (dev && dev->bus == &platform_bus_type)
34#define __arch_dma_to_virt(dev, x) ({ is_lbus_device(dev) ? \ 34#define __arch_dma_to_virt(dev, x) ({ (void *) (is_lbus_device(dev) ? \
35 __phys_to_virt(x) : __bus_to_virt(x); }) 35 __phys_to_virt(x) : __bus_to_virt(x)); })
36#define __arch_virt_to_dma(dev, x) ({ is_lbus_device(dev) ? \ 36#define __arch_virt_to_dma(dev, x) ({ is_lbus_device(dev) ? \
37 (dma_addr_t)__virt_to_phys(x) : (dma_addr_t)__virt_to_bus(x); }) 37 (dma_addr_t)__virt_to_phys(x) : (dma_addr_t)__virt_to_bus(x); })
38#define __arch_page_to_dma(dev, x) __arch_virt_to_dma(dev, page_address(x)) 38#define __arch_page_to_dma(dev, x) __arch_virt_to_dma(dev, page_address(x))
diff --git a/arch/arm/mach-ks8695/include/mach/regs-gpio.h b/arch/arm/mach-ks8695/include/mach/regs-gpio.h
index 0df6fe61d1ce..90614a7d0548 100644
--- a/arch/arm/mach-ks8695/include/mach/regs-gpio.h
+++ b/arch/arm/mach-ks8695/include/mach/regs-gpio.h
@@ -24,7 +24,7 @@
24 24
25 25
26/* Port Mode Register */ 26/* Port Mode Register */
27#define IOPM_(x) (1 << (x)) /* Mode for GPIO Pin x */ 27#define IOPM(x) (1 << (x)) /* Mode for GPIO Pin x */
28 28
29/* Port Control Register */ 29/* Port Control Register */
30#define IOPC_IOTIM1EN (1 << 17) /* GPIO Pin for Timer1 Enable */ 30#define IOPC_IOTIM1EN (1 << 17) /* GPIO Pin for Timer1 Enable */
@@ -50,6 +50,6 @@
50#define IOPC_TM_EDGE (6) /* Both Edge Detection */ 50#define IOPC_TM_EDGE (6) /* Both Edge Detection */
51 51
52/* Port Data Register */ 52/* Port Data Register */
53#define IOPD_(x) (1 << (x)) /* Signal Level of GPIO Pin x */ 53#define IOPD(x) (1 << (x)) /* Signal Level of GPIO Pin x */
54 54
55#endif 55#endif
diff --git a/arch/arm/mach-ks8695/include/mach/regs-lan.h b/arch/arm/mach-ks8695/include/mach/regs-lan.h
index 9ef409901e76..82c5f3791afb 100644
--- a/arch/arm/mach-ks8695/include/mach/regs-lan.h
+++ b/arch/arm/mach-ks8695/include/mach/regs-lan.h
@@ -29,8 +29,8 @@
29#define KS8695_LRDLB (0x14) /* Receive Descriptor List Base Address */ 29#define KS8695_LRDLB (0x14) /* Receive Descriptor List Base Address */
30#define KS8695_LMAL (0x18) /* MAC Station Address Low */ 30#define KS8695_LMAL (0x18) /* MAC Station Address Low */
31#define KS8695_LMAH (0x1c) /* MAC Station Address High */ 31#define KS8695_LMAH (0x1c) /* MAC Station Address High */
32#define KS8695_LMAAL_(n) (0x80 + ((n)*8)) /* MAC Additional Station Address (0..15) Low */ 32#define KS8695_LMAAL(n) (0x80 + ((n)*8)) /* MAC Additional Station Address (0..15) Low */
33#define KS8695_LMAAH_(n) (0x84 + ((n)*8)) /* MAC Additional Station Address (0..15) High */ 33#define KS8695_LMAAH(n) (0x84 + ((n)*8)) /* MAC Additional Station Address (0..15) High */
34 34
35 35
36/* DMA Transmit Control Register */ 36/* DMA Transmit Control Register */
diff --git a/arch/arm/mach-ks8695/include/mach/regs-wan.h b/arch/arm/mach-ks8695/include/mach/regs-wan.h
index eb494ec6e956..c475bed22b8e 100644
--- a/arch/arm/mach-ks8695/include/mach/regs-wan.h
+++ b/arch/arm/mach-ks8695/include/mach/regs-wan.h
@@ -29,8 +29,8 @@
29#define KS8695_WRDLB (0x14) /* Receive Descriptor List Base Address */ 29#define KS8695_WRDLB (0x14) /* Receive Descriptor List Base Address */
30#define KS8695_WMAL (0x18) /* MAC Station Address Low */ 30#define KS8695_WMAL (0x18) /* MAC Station Address Low */
31#define KS8695_WMAH (0x1c) /* MAC Station Address High */ 31#define KS8695_WMAH (0x1c) /* MAC Station Address High */
32#define KS8695_WMAAL_(n) (0x80 + ((n)*8)) /* MAC Additional Station Address (0..15) Low */ 32#define KS8695_WMAAL(n) (0x80 + ((n)*8)) /* MAC Additional Station Address (0..15) Low */
33#define KS8695_WMAAH_(n) (0x84 + ((n)*8)) /* MAC Additional Station Address (0..15) High */ 33#define KS8695_WMAAH(n) (0x84 + ((n)*8)) /* MAC Additional Station Address (0..15) High */
34 34
35 35
36/* DMA Transmit Control Register */ 36/* DMA Transmit Control Register */
diff --git a/arch/arm/mach-ks8695/include/mach/system.h b/arch/arm/mach-ks8695/include/mach/system.h
index 2a6f91869056..5a9b032bdbeb 100644
--- a/arch/arm/mach-ks8695/include/mach/system.h
+++ b/arch/arm/mach-ks8695/include/mach/system.h
@@ -14,7 +14,7 @@
14#ifndef __ASM_ARCH_SYSTEM_H 14#ifndef __ASM_ARCH_SYSTEM_H
15#define __ASM_ARCH_SYSTEM_H 15#define __ASM_ARCH_SYSTEM_H
16 16
17#include <asm/io.h> 17#include <linux/io.h>
18#include <mach/regs-timer.h> 18#include <mach/regs-timer.h>
19 19
20static void arch_idle(void) 20static void arch_idle(void)
diff --git a/arch/arm/mach-ks8695/include/mach/uncompress.h b/arch/arm/mach-ks8695/include/mach/uncompress.h
index 0eee37a69075..9495cb4d701a 100644
--- a/arch/arm/mach-ks8695/include/mach/uncompress.h
+++ b/arch/arm/mach-ks8695/include/mach/uncompress.h
@@ -14,7 +14,7 @@
14#ifndef __ASM_ARCH_UNCOMPRESS_H 14#ifndef __ASM_ARCH_UNCOMPRESS_H
15#define __ASM_ARCH_UNCOMPRESS_H 15#define __ASM_ARCH_UNCOMPRESS_H
16 16
17#include <asm/io.h> 17#include <linux/io.h>
18#include <mach/regs-uart.h> 18#include <mach/regs-uart.h>
19 19
20static void putc(char c) 20static void putc(char c)
diff --git a/arch/arm/mach-ks8695/irq.c b/arch/arm/mach-ks8695/irq.c
index e5e71f4dbb84..e375c1d53f81 100644
--- a/arch/arm/mach-ks8695/irq.c
+++ b/arch/arm/mach-ks8695/irq.c
@@ -24,10 +24,10 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/io.h>
31 31
32#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
33 33
diff --git a/arch/arm/mach-ks8695/pci.c b/arch/arm/mach-ks8695/pci.c
index 1746c67af176..f5ebcc0fcab9 100644
--- a/arch/arm/mach-ks8695/pci.c
+++ b/arch/arm/mach-ks8695/pci.c
@@ -27,8 +27,8 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/irq.h> 28#include <linux/irq.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/io.h>
30 31
31#include <asm/io.h>
32#include <asm/signal.h> 32#include <asm/signal.h>
33#include <asm/mach/pci.h> 33#include <asm/mach/pci.h>
34#include <mach/hardware.h> 34#include <mach/hardware.h>
@@ -141,7 +141,7 @@ static struct pci_ops ks8695_pci_ops = {
141 .write = ks8695_pci_writeconfig, 141 .write = ks8695_pci_writeconfig,
142}; 142};
143 143
144static struct pci_bus *ks8695_pci_scan_bus(int nr, struct pci_sys_data *sys) 144static struct pci_bus* __init ks8695_pci_scan_bus(int nr, struct pci_sys_data *sys)
145{ 145{
146 return pci_scan_bus(sys->busnr, &ks8695_pci_ops, sys); 146 return pci_scan_bus(sys->busnr, &ks8695_pci_ops, sys);
147} 147}
diff --git a/arch/arm/mach-ks8695/time.c b/arch/arm/mach-ks8695/time.c
index 940888dffc16..69c072c2c0f9 100644
--- a/arch/arm/mach-ks8695/time.c
+++ b/arch/arm/mach-ks8695/time.c
@@ -24,8 +24,8 @@
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/io.h>
27 28
28#include <asm/io.h>
29#include <asm/mach/time.h> 29#include <asm/mach/time.h>
30 30
31#include <mach/regs-timer.h> 31#include <mach/regs-timer.h>
diff --git a/arch/arm/mach-lh7a40x/Kconfig b/arch/arm/mach-lh7a40x/Kconfig
index 6f4c6a1798c1..9be7466e346c 100644
--- a/arch/arm/mach-lh7a40x/Kconfig
+++ b/arch/arm/mach-lh7a40x/Kconfig
@@ -40,23 +40,22 @@ config LPD7A40X_CPLD_SSP
40 bool 40 bool
41 41
42config LH7A40X_CONTIGMEM 42config LH7A40X_CONTIGMEM
43 bool "Disable NUMA Support" 43 bool "Disable NUMA/SparseMEM Support"
44 depends on ARCH_LH7A40X
45 help 44 help
46 Say Y here if your bootloader sets the SROMLL bit(s) in 45 Say Y here if your bootloader sets the SROMLL bit(s) in
47 the SDRAM controller, organizing memory as a contiguous 46 the SDRAM controller, organizing memory as a contiguous
48 array. This option will disable CONFIG_DISCONTIGMEM and 47 array. This option will disable sparse memory support
49 force the kernel to manage all memory in one node. 48 and force the kernel to manage all memory in one node.
50 49
51 Setting this option incorrectly may prevent the kernel from 50 Setting this option incorrectly may prevent the kernel
52 booting. It is OK to leave it N. 51 from booting. It is OK to leave it N.
53 52
54 For more information, consult 53 For more information, consult
55 <file:Documentation/arm/Sharp-LH/SDRAM>. 54 <file:Documentation/arm/Sharp-LH/SDRAM>.
56 55
57config LH7A40X_ONE_BANK_PER_NODE 56config LH7A40X_ONE_BANK_PER_NODE
58 bool "Optimize NUMA Node Tables for Size" 57 bool "Optimize NUMA Node Tables for Size"
59 depends on ARCH_LH7A40X && !LH7A40X_CONTIGMEM 58 depends on !LH7A40X_CONTIGMEM
60 help 59 help
61 Say Y here to produce compact memory node tables. By 60 Say Y here to produce compact memory node tables. By
62 default pairs of adjacent physical RAM banks are managed 61 default pairs of adjacent physical RAM banks are managed
diff --git a/arch/arm/mach-lh7a40x/arch-kev7a400.c b/arch/arm/mach-lh7a40x/arch-kev7a400.c
index 551b97261826..3d7bd50b9095 100644
--- a/arch/arm/mach-lh7a40x/arch-kev7a400.c
+++ b/arch/arm/mach-lh7a40x/arch-kev7a400.c
@@ -77,7 +77,7 @@ static void kev7a400_cpld_handler (unsigned int irq, struct irq_desc *desc)
77 irq = IRQ_KEV7A400_CPLD; 77 irq = IRQ_KEV7A400_CPLD;
78 for (; mask; mask >>= 1, ++irq) 78 for (; mask; mask >>= 1, ++irq)
79 if (mask & 1) 79 if (mask & 1)
80 desc_handle_irq(irq, desc); 80 generic_handle_irq(irq);
81} 81}
82 82
83void __init lh7a40x_init_board_irq (void) 83void __init lh7a40x_init_board_irq (void)
diff --git a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
index e373fb8e2699..cb15e5d32120 100644
--- a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
+++ b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
@@ -214,11 +214,11 @@ static void lpd7a40x_cpld_handler (unsigned int irq, struct irq_desc *desc)
214 desc->chip->ack (irq); 214 desc->chip->ack (irq);
215 215
216 if ((mask & (1<<0)) == 0) /* WLAN */ 216 if ((mask & (1<<0)) == 0) /* WLAN */
217 IRQ_DISPATCH (IRQ_LPD7A40X_ETH_INT); 217 generic_handle_irq(IRQ_LPD7A40X_ETH_INT);
218 218
219#if defined (IRQ_TOUCH) 219#if defined (IRQ_TOUCH)
220 if ((mask & (1<<1)) == 0) /* Touch */ 220 if ((mask & (1<<1)) == 0) /* Touch */
221 IRQ_DISPATCH (IRQ_TOUCH); 221 generic_handle_irq(IRQ_TOUCH);
222#endif 222#endif
223 223
224 desc->chip->unmask (irq); /* Level-triggered need this */ 224 desc->chip->unmask (irq); /* Level-triggered need this */
diff --git a/arch/arm/mach-lh7a40x/common.h b/arch/arm/mach-lh7a40x/common.h
index 0ca20c6c83b7..6ed3f6b6db76 100644
--- a/arch/arm/mach-lh7a40x/common.h
+++ b/arch/arm/mach-lh7a40x/common.h
@@ -15,4 +15,3 @@ extern void lh7a404_init_irq (void);
15extern void lh7a40x_clcd_init (void); 15extern void lh7a40x_clcd_init (void);
16extern void lh7a40x_init_board_irq (void); 16extern void lh7a40x_init_board_irq (void);
17 17
18#define IRQ_DISPATCH(irq) desc_handle_irq((irq),(irq_desc + irq))
diff --git a/arch/arm/mach-lh7a40x/include/mach/memory.h b/arch/arm/mach-lh7a40x/include/mach/memory.h
index f7107b4c197a..1da14ff66c93 100644
--- a/arch/arm/mach-lh7a40x/include/mach/memory.h
+++ b/arch/arm/mach-lh7a40x/include/mach/memory.h
@@ -73,4 +73,10 @@
73 73
74#endif 74#endif
75 75
76/*
77 * Sparsemem version of the above
78 */
79#define MAX_PHYSMEM_BITS 32
80#define SECTION_SIZE_BITS 24
81
76#endif 82#endif
diff --git a/arch/arm/mach-lh7a40x/irq-lpd7a40x.c b/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
index 0d5063ebda10..fd033bb4342f 100644
--- a/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
+++ b/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
@@ -63,10 +63,10 @@ static void lh7a40x_cpld_handler (unsigned int irq, struct irq_desc *desc)
63 desc->chip->ack (irq); 63 desc->chip->ack (irq);
64 64
65 if ((mask & 0x1) == 0) /* WLAN */ 65 if ((mask & 0x1) == 0) /* WLAN */
66 IRQ_DISPATCH (IRQ_LPD7A40X_ETH_INT); 66 generic_handle_irq(IRQ_LPD7A40X_ETH_INT);
67 67
68 if ((mask & 0x2) == 0) /* Touch */ 68 if ((mask & 0x2) == 0) /* Touch */
69 IRQ_DISPATCH (IRQ_LPD7A400_TS); 69 generic_handle_irq(IRQ_LPD7A400_TS);
70 70
71 desc->chip->unmask (irq); /* Level-triggered need this */ 71 desc->chip->unmask (irq); /* Level-triggered need this */
72} 72}
diff --git a/arch/arm/mach-lh7a40x/ssp-cpld.c b/arch/arm/mach-lh7a40x/ssp-cpld.c
index 51fbef9601b9..2901d49d1484 100644
--- a/arch/arm/mach-lh7a40x/ssp-cpld.c
+++ b/arch/arm/mach-lh7a40x/ssp-cpld.c
@@ -43,8 +43,8 @@
43#include <linux/init.h> 43#include <linux/init.h>
44#include <linux/delay.h> 44#include <linux/delay.h>
45#include <linux/spinlock.h> 45#include <linux/spinlock.h>
46#include <linux/io.h>
46 47
47#include <asm/io.h>
48#include <asm/irq.h> 48#include <asm/irq.h>
49#include <mach/hardware.h> 49#include <mach/hardware.h>
50 50
diff --git a/arch/arm/mach-lh7a40x/time.c b/arch/arm/mach-lh7a40x/time.c
index 7fe9e06cf662..4601e425bae3 100644
--- a/arch/arm/mach-lh7a40x/time.c
+++ b/arch/arm/mach-lh7a40x/time.c
@@ -13,9 +13,9 @@
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/time.h> 15#include <linux/time.h>
16#include <linux/io.h>
16 17
17#include <mach/hardware.h> 18#include <mach/hardware.h>
18#include <asm/io.h>
19#include <asm/irq.h> 19#include <asm/irq.h>
20#include <asm/leds.h> 20#include <asm/leds.h>
21 21
diff --git a/arch/arm/mach-loki/addr-map.c b/arch/arm/mach-loki/addr-map.c
index 70ca56bb6f33..0332d8f5c18c 100644
--- a/arch/arm/mach-loki/addr-map.c
+++ b/arch/arm/mach-loki/addr-map.c
@@ -11,8 +11,8 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/mbus.h> 13#include <linux/mbus.h>
14#include <linux/io.h>
14#include <mach/hardware.h> 15#include <mach/hardware.h>
15#include <asm/io.h>
16#include "common.h" 16#include "common.h"
17 17
18/* 18/*
diff --git a/arch/arm/mach-loki/irq.c b/arch/arm/mach-loki/irq.c
index 5a487930cb2f..e1f97338d5b7 100644
--- a/arch/arm/mach-loki/irq.c
+++ b/arch/arm/mach-loki/irq.c
@@ -11,7 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <asm/io.h> 14#include <linux/io.h>
15#include <plat/irq.h> 15#include <plat/irq.h>
16#include "common.h" 16#include "common.h"
17 17
diff --git a/arch/arm/mach-loki/lb88rc8480-setup.c b/arch/arm/mach-loki/lb88rc8480-setup.c
index 2cc9ac9b488f..85f9c1296aa0 100644
--- a/arch/arm/mach-loki/lb88rc8480-setup.c
+++ b/arch/arm/mach-loki/lb88rc8480-setup.c
@@ -67,7 +67,7 @@ static struct platform_device lb88rc8480_boot_flash = {
67}; 67};
68 68
69static struct mv643xx_eth_platform_data lb88rc8480_ge0_data = { 69static struct mv643xx_eth_platform_data lb88rc8480_ge0_data = {
70 .phy_addr = 1, 70 .phy_addr = MV643XX_ETH_PHY_ADDR(1),
71 .mac_addr = { 0x00, 0x50, 0x43, 0x11, 0x22, 0x33 }, 71 .mac_addr = { 0x00, 0x50, 0x43, 0x11, 0x22, 0x33 },
72}; 72};
73 73
diff --git a/arch/arm/mach-msm/board-halibut.c b/arch/arm/mach-msm/board-halibut.c
index 995afc4ade4b..a24259133e07 100644
--- a/arch/arm/mach-msm/board-halibut.c
+++ b/arch/arm/mach-msm/board-halibut.c
@@ -18,6 +18,8 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/io.h>
22#include <linux/delay.h>
21 23
22#include <mach/hardware.h> 24#include <mach/hardware.h>
23#include <asm/mach-types.h> 25#include <asm/mach-types.h>
@@ -28,9 +30,6 @@
28#include <mach/board.h> 30#include <mach/board.h>
29#include <mach/msm_iomap.h> 31#include <mach/msm_iomap.h>
30 32
31#include <asm/io.h>
32#include <asm/delay.h>
33
34#include <linux/mtd/nand.h> 33#include <linux/mtd/nand.h>
35#include <linux/mtd/partitions.h> 34#include <linux/mtd/partitions.h>
36 35
diff --git a/arch/arm/mach-msm/common.c b/arch/arm/mach-msm/common.c
index 3a511368a5d8..604f8ade9587 100644
--- a/arch/arm/mach-msm/common.c
+++ b/arch/arm/mach-msm/common.c
@@ -19,9 +19,9 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/io.h>
22 23
23#include <asm/mach/flash.h> 24#include <asm/mach/flash.h>
24#include <asm/io.h>
25 25
26#include <asm/setup.h> 26#include <asm/setup.h>
27 27
diff --git a/arch/arm/mach-msm/dma.c b/arch/arm/mach-msm/dma.c
index 9de08265d974..0c8f252637e1 100644
--- a/arch/arm/mach-msm/dma.c
+++ b/arch/arm/mach-msm/dma.c
@@ -13,7 +13,7 @@
13 * 13 *
14 */ 14 */
15 15
16#include <asm/io.h> 16#include <linux/io.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <mach/dma.h> 18#include <mach/dma.h>
19 19
diff --git a/arch/arm/mach-msm/io.c b/arch/arm/mach-msm/io.c
index 5976200de99b..7999e4ba8e20 100644
--- a/arch/arm/mach-msm/io.c
+++ b/arch/arm/mach-msm/io.c
@@ -18,9 +18,9 @@
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/io.h>
21 22
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <asm/io.h>
24#include <asm/page.h> 24#include <asm/page.h>
25#include <mach/msm_iomap.h> 25#include <mach/msm_iomap.h>
26#include <asm/mach/map.h> 26#include <asm/mach/map.h>
diff --git a/arch/arm/mach-msm/irq.c b/arch/arm/mach-msm/irq.c
index 66901baf8c8e..04b8d182ff8a 100644
--- a/arch/arm/mach-msm/irq.c
+++ b/arch/arm/mach-msm/irq.c
@@ -19,11 +19,10 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/ptrace.h> 20#include <linux/ptrace.h>
21#include <linux/timer.h> 21#include <linux/timer.h>
22
23#include <linux/irq.h> 22#include <linux/irq.h>
24#include <mach/hardware.h> 23#include <linux/io.h>
25 24
26#include <asm/io.h> 25#include <mach/hardware.h>
27 26
28#include <mach/msm_iomap.h> 27#include <mach/msm_iomap.h>
29 28
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index 9f02d7dca985..2bffe9b7e9fe 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -20,12 +20,11 @@
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/clockchips.h> 21#include <linux/clockchips.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/io.h>
23 24
24#include <asm/mach/time.h> 25#include <asm/mach/time.h>
25#include <mach/msm_iomap.h> 26#include <mach/msm_iomap.h>
26 27
27#include <asm/io.h>
28
29#define MSM_DGT_BASE (MSM_GPT_BASE + 0x10) 28#define MSM_DGT_BASE (MSM_GPT_BASE + 0x10)
30#define MSM_DGT_SHIFT (5) 29#define MSM_DGT_SHIFT (5)
31 30
diff --git a/arch/arm/mach-mv78xx0/addr-map.c b/arch/arm/mach-mv78xx0/addr-map.c
index 4004b672a2eb..311d5b0e9bc7 100644
--- a/arch/arm/mach-mv78xx0/addr-map.c
+++ b/arch/arm/mach-mv78xx0/addr-map.c
@@ -11,7 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/mbus.h> 13#include <linux/mbus.h>
14#include <asm/io.h> 14#include <linux/io.h>
15#include "common.h" 15#include "common.h"
16 16
17/* 17/*
diff --git a/arch/arm/mach-mv78xx0/common.c b/arch/arm/mach-mv78xx0/common.c
index 953a26c469cb..238a2f8c2d52 100644
--- a/arch/arm/mach-mv78xx0/common.c
+++ b/arch/arm/mach-mv78xx0/common.c
@@ -285,6 +285,11 @@ static struct resource mv78xx0_ge00_shared_resources[] = {
285 .start = GE00_PHYS_BASE + 0x2000, 285 .start = GE00_PHYS_BASE + 0x2000,
286 .end = GE00_PHYS_BASE + 0x3fff, 286 .end = GE00_PHYS_BASE + 0x3fff,
287 .flags = IORESOURCE_MEM, 287 .flags = IORESOURCE_MEM,
288 }, {
289 .name = "ge err irq",
290 .start = IRQ_MV78XX0_GE_ERR,
291 .end = IRQ_MV78XX0_GE_ERR,
292 .flags = IORESOURCE_IRQ,
288 }, 293 },
289}; 294};
290 295
@@ -294,7 +299,7 @@ static struct platform_device mv78xx0_ge00_shared = {
294 .dev = { 299 .dev = {
295 .platform_data = &mv78xx0_ge00_shared_data, 300 .platform_data = &mv78xx0_ge00_shared_data,
296 }, 301 },
297 .num_resources = 1, 302 .num_resources = ARRAY_SIZE(mv78xx0_ge00_shared_resources),
298 .resource = mv78xx0_ge00_shared_resources, 303 .resource = mv78xx0_ge00_shared_resources,
299}; 304};
300 305
@@ -330,6 +335,7 @@ void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
330struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = { 335struct mv643xx_eth_shared_platform_data mv78xx0_ge01_shared_data = {
331 .t_clk = 0, 336 .t_clk = 0,
332 .dram = &mv78xx0_mbus_dram_info, 337 .dram = &mv78xx0_mbus_dram_info,
338 .shared_smi = &mv78xx0_ge00_shared,
333}; 339};
334 340
335static struct resource mv78xx0_ge01_shared_resources[] = { 341static struct resource mv78xx0_ge01_shared_resources[] = {
@@ -370,7 +376,6 @@ static struct platform_device mv78xx0_ge01 = {
370void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data) 376void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
371{ 377{
372 eth_data->shared = &mv78xx0_ge01_shared; 378 eth_data->shared = &mv78xx0_ge01_shared;
373 eth_data->shared_smi = &mv78xx0_ge00_shared;
374 mv78xx0_ge01.dev.platform_data = eth_data; 379 mv78xx0_ge01.dev.platform_data = eth_data;
375 380
376 platform_device_register(&mv78xx0_ge01_shared); 381 platform_device_register(&mv78xx0_ge01_shared);
@@ -384,6 +389,7 @@ void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
384struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = { 389struct mv643xx_eth_shared_platform_data mv78xx0_ge10_shared_data = {
385 .t_clk = 0, 390 .t_clk = 0,
386 .dram = &mv78xx0_mbus_dram_info, 391 .dram = &mv78xx0_mbus_dram_info,
392 .shared_smi = &mv78xx0_ge00_shared,
387}; 393};
388 394
389static struct resource mv78xx0_ge10_shared_resources[] = { 395static struct resource mv78xx0_ge10_shared_resources[] = {
@@ -424,7 +430,6 @@ static struct platform_device mv78xx0_ge10 = {
424void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data) 430void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
425{ 431{
426 eth_data->shared = &mv78xx0_ge10_shared; 432 eth_data->shared = &mv78xx0_ge10_shared;
427 eth_data->shared_smi = &mv78xx0_ge00_shared;
428 mv78xx0_ge10.dev.platform_data = eth_data; 433 mv78xx0_ge10.dev.platform_data = eth_data;
429 434
430 platform_device_register(&mv78xx0_ge10_shared); 435 platform_device_register(&mv78xx0_ge10_shared);
@@ -438,6 +443,7 @@ void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
438struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = { 443struct mv643xx_eth_shared_platform_data mv78xx0_ge11_shared_data = {
439 .t_clk = 0, 444 .t_clk = 0,
440 .dram = &mv78xx0_mbus_dram_info, 445 .dram = &mv78xx0_mbus_dram_info,
446 .shared_smi = &mv78xx0_ge00_shared,
441}; 447};
442 448
443static struct resource mv78xx0_ge11_shared_resources[] = { 449static struct resource mv78xx0_ge11_shared_resources[] = {
@@ -478,7 +484,6 @@ static struct platform_device mv78xx0_ge11 = {
478void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data) 484void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
479{ 485{
480 eth_data->shared = &mv78xx0_ge11_shared; 486 eth_data->shared = &mv78xx0_ge11_shared;
481 eth_data->shared_smi = &mv78xx0_ge00_shared;
482 mv78xx0_ge11.dev.platform_data = eth_data; 487 mv78xx0_ge11.dev.platform_data = eth_data;
483 488
484 platform_device_register(&mv78xx0_ge11_shared); 489 platform_device_register(&mv78xx0_ge11_shared);
diff --git a/arch/arm/mach-mv78xx0/db78x00-bp-setup.c b/arch/arm/mach-mv78xx0/db78x00-bp-setup.c
index a2d0c9783604..49f434c39eb7 100644
--- a/arch/arm/mach-mv78xx0/db78x00-bp-setup.c
+++ b/arch/arm/mach-mv78xx0/db78x00-bp-setup.c
@@ -19,19 +19,19 @@
19#include "common.h" 19#include "common.h"
20 20
21static struct mv643xx_eth_platform_data db78x00_ge00_data = { 21static struct mv643xx_eth_platform_data db78x00_ge00_data = {
22 .phy_addr = 8, 22 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
23}; 23};
24 24
25static struct mv643xx_eth_platform_data db78x00_ge01_data = { 25static struct mv643xx_eth_platform_data db78x00_ge01_data = {
26 .phy_addr = 9, 26 .phy_addr = MV643XX_ETH_PHY_ADDR(9),
27}; 27};
28 28
29static struct mv643xx_eth_platform_data db78x00_ge10_data = { 29static struct mv643xx_eth_platform_data db78x00_ge10_data = {
30 .phy_addr = -1, 30 .phy_addr = MV643XX_ETH_PHY_NONE,
31}; 31};
32 32
33static struct mv643xx_eth_platform_data db78x00_ge11_data = { 33static struct mv643xx_eth_platform_data db78x00_ge11_data = {
34 .phy_addr = -1, 34 .phy_addr = MV643XX_ETH_PHY_NONE,
35}; 35};
36 36
37static struct mv_sata_platform_data db78x00_sata_data = { 37static struct mv_sata_platform_data db78x00_sata_data = {
diff --git a/arch/arm/mach-mv78xx0/include/mach/entry-macro.S b/arch/arm/mach-mv78xx0/include/mach/entry-macro.S
index ed4a46bcd3b0..fbfb2693ce6c 100644
--- a/arch/arm/mach-mv78xx0/include/mach/entry-macro.S
+++ b/arch/arm/mach-mv78xx0/include/mach/entry-macro.S
@@ -26,14 +26,22 @@
26 ldr \tmp, [\base, #IRQ_MASK_LOW_OFF] 26 ldr \tmp, [\base, #IRQ_MASK_LOW_OFF]
27 mov \irqnr, #31 27 mov \irqnr, #31
28 ands \irqstat, \irqstat, \tmp 28 ands \irqstat, \irqstat, \tmp
29 bne 1001f
29 30
30 @ if no low interrupts set, check high interrupts 31 @ if no low interrupts set, check high interrupts
31 ldreq \irqstat, [\base, #IRQ_CAUSE_HIGH_OFF] 32 ldr \irqstat, [\base, #IRQ_CAUSE_HIGH_OFF]
32 ldreq \tmp, [\base, #IRQ_MASK_HIGH_OFF] 33 ldr \tmp, [\base, #IRQ_MASK_HIGH_OFF]
33 moveq \irqnr, #63 34 mov \irqnr, #63
34 andeqs \irqstat, \irqstat, \tmp 35 ands \irqstat, \irqstat, \tmp
36 bne 1001f
37
38 @ if no high interrupts set, check error interrupts
39 ldr \irqstat, [\base, #IRQ_CAUSE_ERR_OFF]
40 ldr \tmp, [\base, #IRQ_MASK_ERR_OFF]
41 mov \irqnr, #95
42 ands \irqstat, \irqstat, \tmp
35 43
36 @ find first active interrupt source 44 @ find first active interrupt source
37 clzne \irqstat, \irqstat 451001: clzne \irqstat, \irqstat
38 subne \irqnr, \irqnr, \irqstat 46 subne \irqnr, \irqnr, \irqstat
39 .endm 47 .endm
diff --git a/arch/arm/mach-mv78xx0/include/mach/irqs.h b/arch/arm/mach-mv78xx0/include/mach/irqs.h
index 995d7fb8d06f..bebc330281ec 100644
--- a/arch/arm/mach-mv78xx0/include/mach/irqs.h
+++ b/arch/arm/mach-mv78xx0/include/mach/irqs.h
@@ -80,9 +80,14 @@
80#define IRQ_MV78XX0_DB_OUT 61 80#define IRQ_MV78XX0_DB_OUT 61
81 81
82/* 82/*
83 * MV78xx0 Error Interrupt Controller
84 */
85#define IRQ_MV78XX0_GE_ERR 70
86
87/*
83 * MV78XX0 General Purpose Pins 88 * MV78XX0 General Purpose Pins
84 */ 89 */
85#define IRQ_MV78XX0_GPIO_START 64 90#define IRQ_MV78XX0_GPIO_START 96
86#define NR_GPIO_IRQS GPIO_MAX 91#define NR_GPIO_IRQS GPIO_MAX
87 92
88#define NR_IRQS (IRQ_MV78XX0_GPIO_START + NR_GPIO_IRQS) 93#define NR_IRQS (IRQ_MV78XX0_GPIO_START + NR_GPIO_IRQS)
diff --git a/arch/arm/mach-mv78xx0/include/mach/mv78xx0.h b/arch/arm/mach-mv78xx0/include/mach/mv78xx0.h
index ad664178d6e1..ee9c5593ee92 100644
--- a/arch/arm/mach-mv78xx0/include/mach/mv78xx0.h
+++ b/arch/arm/mach-mv78xx0/include/mach/mv78xx0.h
@@ -71,8 +71,10 @@
71#define BRIDGE_INT_TIMER1 0x0004 71#define BRIDGE_INT_TIMER1 0x0004
72#define BRIDGE_INT_TIMER1_CLR (~0x0004) 72#define BRIDGE_INT_TIMER1_CLR (~0x0004)
73#define IRQ_VIRT_BASE (BRIDGE_VIRT_BASE | 0x0200) 73#define IRQ_VIRT_BASE (BRIDGE_VIRT_BASE | 0x0200)
74#define IRQ_CAUSE_ERR_OFF 0x0000
74#define IRQ_CAUSE_LOW_OFF 0x0004 75#define IRQ_CAUSE_LOW_OFF 0x0004
75#define IRQ_CAUSE_HIGH_OFF 0x0008 76#define IRQ_CAUSE_HIGH_OFF 0x0008
77#define IRQ_MASK_ERR_OFF 0x000c
76#define IRQ_MASK_LOW_OFF 0x0010 78#define IRQ_MASK_LOW_OFF 0x0010
77#define IRQ_MASK_HIGH_OFF 0x0014 79#define IRQ_MASK_HIGH_OFF 0x0014
78#define TIMER_VIRT_BASE (BRIDGE_VIRT_BASE | 0x0300) 80#define TIMER_VIRT_BASE (BRIDGE_VIRT_BASE | 0x0300)
diff --git a/arch/arm/mach-mv78xx0/irq.c b/arch/arm/mach-mv78xx0/irq.c
index 28248d37b999..503e5d195ae5 100644
--- a/arch/arm/mach-mv78xx0/irq.c
+++ b/arch/arm/mach-mv78xx0/irq.c
@@ -19,4 +19,5 @@ void __init mv78xx0_init_irq(void)
19{ 19{
20 orion_irq_init(0, (void __iomem *)(IRQ_VIRT_BASE + IRQ_MASK_LOW_OFF)); 20 orion_irq_init(0, (void __iomem *)(IRQ_VIRT_BASE + IRQ_MASK_LOW_OFF));
21 orion_irq_init(32, (void __iomem *)(IRQ_VIRT_BASE + IRQ_MASK_HIGH_OFF)); 21 orion_irq_init(32, (void __iomem *)(IRQ_VIRT_BASE + IRQ_MASK_HIGH_OFF));
22 orion_irq_init(64, (void __iomem *)(IRQ_VIRT_BASE + IRQ_MASK_ERR_OFF));
22} 23}
diff --git a/arch/arm/mach-mx2/devices.h b/arch/arm/mach-mx2/devices.h
new file mode 100644
index 000000000000..c77a4b8f73b4
--- /dev/null
+++ b/arch/arm/mach-mx2/devices.h
@@ -0,0 +1,15 @@
1
2extern struct platform_device mxc_gpt1;
3extern struct platform_device mxc_gpt2;
4extern struct platform_device mxc_gpt3;
5extern struct platform_device mxc_gpt4;
6extern struct platform_device mxc_gpt5;
7extern struct platform_device mxc_wdt;
8extern struct platform_device mxc_irda_device;
9extern struct platform_device mxc_uart_device0;
10extern struct platform_device mxc_uart_device1;
11extern struct platform_device mxc_uart_device2;
12extern struct platform_device mxc_uart_device3;
13extern struct platform_device mxc_uart_device4;
14extern struct platform_device mxc_uart_device5;
15
diff --git a/arch/arm/mach-mx2/mx27ads.c b/arch/arm/mach-mx2/mx27ads.c
index 4ce56ef4d8d3..56e22d3ca075 100644
--- a/arch/arm/mach-mx2/mx27ads.c
+++ b/arch/arm/mach-mx2/mx27ads.c
@@ -34,6 +34,8 @@
34#include <mach/iomux-mx1-mx2.h> 34#include <mach/iomux-mx1-mx2.h>
35#include <mach/board-mx27ads.h> 35#include <mach/board-mx27ads.h>
36 36
37#include "devices.h"
38
37/* ADS's NOR flash */ 39/* ADS's NOR flash */
38static struct physmap_flash_data mx27ads_flash_data = { 40static struct physmap_flash_data mx27ads_flash_data = {
39 .width = 2, 41 .width = 2,
@@ -251,12 +253,14 @@ static struct imxuart_platform_data uart_pdata[] = {
251 253
252static void __init mx27ads_board_init(void) 254static void __init mx27ads_board_init(void)
253{ 255{
254 int i;
255
256 gpio_fec_active(); 256 gpio_fec_active();
257 257
258 for (i = 0; i < 6; i++) 258 mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
259 imx_init_uart(i, &uart_pdata[i]); 259 mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
260 mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
261 mxc_register_device(&mxc_uart_device3, &uart_pdata[3]);
262 mxc_register_device(&mxc_uart_device4, &uart_pdata[4]);
263 mxc_register_device(&mxc_uart_device5, &uart_pdata[5]);
260 264
261 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 265 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
262} 266}
diff --git a/arch/arm/mach-mx2/pcm038.c b/arch/arm/mach-mx2/pcm038.c
index 1028f453cfc8..7f55746e2591 100644
--- a/arch/arm/mach-mx2/pcm038.c
+++ b/arch/arm/mach-mx2/pcm038.c
@@ -28,6 +28,8 @@
28#include <mach/imx-uart.h> 28#include <mach/imx-uart.h>
29#include <mach/board-pcm038.h> 29#include <mach/board-pcm038.h>
30 30
31#include "devices.h"
32
31/* 33/*
32 * Phytec's phyCORE-i.MX27 comes with 32MiB flash, 34 * Phytec's phyCORE-i.MX27 comes with 32MiB flash,
33 * 16 bit width 35 * 16 bit width
@@ -170,11 +172,11 @@ static struct platform_device *platform_devices[] __initdata = {
170 172
171static void __init pcm038_init(void) 173static void __init pcm038_init(void)
172{ 174{
173 int i;
174 gpio_fec_active(); 175 gpio_fec_active();
175 176
176 for (i = 0; i < 3; i++) 177 mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
177 imx_init_uart(i, &uart_pdata[i]); 178 mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
179 mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
178 180
179 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 181 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
180 182
diff --git a/arch/arm/mach-mx2/serial.c b/arch/arm/mach-mx2/serial.c
index e31fd44f7941..16debc296dad 100644
--- a/arch/arm/mach-mx2/serial.c
+++ b/arch/arm/mach-mx2/serial.c
@@ -35,7 +35,7 @@ static struct resource uart0[] = {
35 }, 35 },
36}; 36};
37 37
38static struct platform_device mxc_uart_device0 = { 38struct platform_device mxc_uart_device0 = {
39 .name = "imx-uart", 39 .name = "imx-uart",
40 .id = 0, 40 .id = 0,
41 .resource = uart0, 41 .resource = uart0,
@@ -54,7 +54,7 @@ static struct resource uart1[] = {
54 }, 54 },
55}; 55};
56 56
57static struct platform_device mxc_uart_device1 = { 57struct platform_device mxc_uart_device1 = {
58 .name = "imx-uart", 58 .name = "imx-uart",
59 .id = 1, 59 .id = 1,
60 .resource = uart1, 60 .resource = uart1,
@@ -73,7 +73,7 @@ static struct resource uart2[] = {
73 }, 73 },
74}; 74};
75 75
76static struct platform_device mxc_uart_device2 = { 76struct platform_device mxc_uart_device2 = {
77 .name = "imx-uart", 77 .name = "imx-uart",
78 .id = 2, 78 .id = 2,
79 .resource = uart2, 79 .resource = uart2,
@@ -92,7 +92,7 @@ static struct resource uart3[] = {
92 }, 92 },
93}; 93};
94 94
95static struct platform_device mxc_uart_device3 = { 95struct platform_device mxc_uart_device3 = {
96 .name = "imx-uart", 96 .name = "imx-uart",
97 .id = 3, 97 .id = 3,
98 .resource = uart3, 98 .resource = uart3,
@@ -111,7 +111,7 @@ static struct resource uart4[] = {
111 }, 111 },
112}; 112};
113 113
114static struct platform_device mxc_uart_device4 = { 114struct platform_device mxc_uart_device4 = {
115 .name = "imx-uart", 115 .name = "imx-uart",
116 .id = 4, 116 .id = 4,
117 .resource = uart4, 117 .resource = uart4,
@@ -130,48 +130,9 @@ static struct resource uart5[] = {
130 }, 130 },
131}; 131};
132 132
133static struct platform_device mxc_uart_device5 = { 133struct platform_device mxc_uart_device5 = {
134 .name = "imx-uart", 134 .name = "imx-uart",
135 .id = 5, 135 .id = 5,
136 .resource = uart5, 136 .resource = uart5,
137 .num_resources = ARRAY_SIZE(uart5), 137 .num_resources = ARRAY_SIZE(uart5),
138}; 138};
139
140/*
141 * Register only those UARTs that physically exists
142 */
143int __init imx_init_uart(int uart_no, struct imxuart_platform_data *pdata)
144{
145 switch (uart_no) {
146 case 0:
147 mxc_uart_device0.dev.platform_data = pdata;
148 platform_device_register(&mxc_uart_device0);
149 break;
150 case 1:
151 mxc_uart_device1.dev.platform_data = pdata;
152 platform_device_register(&mxc_uart_device1);
153 break;
154#ifndef CONFIG_MXC_IRDA
155 case 2:
156 mxc_uart_device2.dev.platform_data = pdata;
157 platform_device_register(&mxc_uart_device2);
158 break;
159#endif
160 case 3:
161 mxc_uart_device3.dev.platform_data = pdata;
162 platform_device_register(&mxc_uart_device3);
163 break;
164 case 4:
165 mxc_uart_device4.dev.platform_data = pdata;
166 platform_device_register(&mxc_uart_device4);
167 break;
168 case 5:
169 mxc_uart_device5.dev.platform_data = pdata;
170 platform_device_register(&mxc_uart_device5);
171 break;
172 default:
173 return -ENODEV;
174 }
175
176 return 0;
177}
diff --git a/arch/arm/mach-mx3/devices.c b/arch/arm/mach-mx3/devices.c
index e08c6a8ac56b..a6bdcc07f3c9 100644
--- a/arch/arm/mach-mx3/devices.c
+++ b/arch/arm/mach-mx3/devices.c
@@ -36,7 +36,7 @@ static struct resource uart0[] = {
36 }, 36 },
37}; 37};
38 38
39static struct platform_device mxc_uart_device0 = { 39struct platform_device mxc_uart_device0 = {
40 .name = "imx-uart", 40 .name = "imx-uart",
41 .id = 0, 41 .id = 0,
42 .resource = uart0, 42 .resource = uart0,
@@ -55,7 +55,7 @@ static struct resource uart1[] = {
55 }, 55 },
56}; 56};
57 57
58static struct platform_device mxc_uart_device1 = { 58struct platform_device mxc_uart_device1 = {
59 .name = "imx-uart", 59 .name = "imx-uart",
60 .id = 1, 60 .id = 1,
61 .resource = uart1, 61 .resource = uart1,
@@ -74,7 +74,7 @@ static struct resource uart2[] = {
74 }, 74 },
75}; 75};
76 76
77static struct platform_device mxc_uart_device2 = { 77struct platform_device mxc_uart_device2 = {
78 .name = "imx-uart", 78 .name = "imx-uart",
79 .id = 2, 79 .id = 2,
80 .resource = uart2, 80 .resource = uart2,
@@ -93,7 +93,7 @@ static struct resource uart3[] = {
93 }, 93 },
94}; 94};
95 95
96static struct platform_device mxc_uart_device3 = { 96struct platform_device mxc_uart_device3 = {
97 .name = "imx-uart", 97 .name = "imx-uart",
98 .id = 3, 98 .id = 3,
99 .resource = uart3, 99 .resource = uart3,
@@ -112,46 +112,13 @@ static struct resource uart4[] = {
112 }, 112 },
113}; 113};
114 114
115static struct platform_device mxc_uart_device4 = { 115struct platform_device mxc_uart_device4 = {
116 .name = "imx-uart", 116 .name = "imx-uart",
117 .id = 4, 117 .id = 4,
118 .resource = uart4, 118 .resource = uart4,
119 .num_resources = ARRAY_SIZE(uart4), 119 .num_resources = ARRAY_SIZE(uart4),
120}; 120};
121 121
122/*
123 * Register only those UARTs that physically exist
124 */
125int __init imx_init_uart(int uart_no, struct imxuart_platform_data *pdata)
126{
127 switch (uart_no) {
128 case 0:
129 mxc_uart_device0.dev.platform_data = pdata;
130 platform_device_register(&mxc_uart_device0);
131 break;
132 case 1:
133 mxc_uart_device1.dev.platform_data = pdata;
134 platform_device_register(&mxc_uart_device1);
135 break;
136 case 2:
137 mxc_uart_device2.dev.platform_data = pdata;
138 platform_device_register(&mxc_uart_device2);
139 break;
140 case 3:
141 mxc_uart_device3.dev.platform_data = pdata;
142 platform_device_register(&mxc_uart_device3);
143 break;
144 case 4:
145 mxc_uart_device4.dev.platform_data = pdata;
146 platform_device_register(&mxc_uart_device4);
147 break;
148 default:
149 return -ENODEV;
150 }
151
152 return 0;
153}
154
155/* GPIO port description */ 122/* GPIO port description */
156static struct mxc_gpio_port imx_gpio_ports[] = { 123static struct mxc_gpio_port imx_gpio_ports[] = {
157 [0] = { 124 [0] = {
diff --git a/arch/arm/mach-mx3/devices.h b/arch/arm/mach-mx3/devices.h
new file mode 100644
index 000000000000..4dc03f9e6001
--- /dev/null
+++ b/arch/arm/mach-mx3/devices.h
@@ -0,0 +1,6 @@
1
2extern struct platform_device mxc_uart_device0;
3extern struct platform_device mxc_uart_device1;
4extern struct platform_device mxc_uart_device2;
5extern struct platform_device mxc_uart_device3;
6extern struct platform_device mxc_uart_device4;
diff --git a/arch/arm/mach-mx3/iomux.c b/arch/arm/mach-mx3/iomux.c
index 3dda1fe23cbf..6e664be8cc13 100644
--- a/arch/arm/mach-mx3/iomux.c
+++ b/arch/arm/mach-mx3/iomux.c
@@ -43,7 +43,8 @@ static DEFINE_SPINLOCK(gpio_mux_lock);
43 */ 43 */
44int mxc_iomux_mode(unsigned int pin_mode) 44int mxc_iomux_mode(unsigned int pin_mode)
45{ 45{
46 u32 reg, field, l, mode, ret = 0; 46 u32 field, l, mode, ret = 0;
47 void __iomem *reg;
47 48
48 reg = IOMUXSW_MUX_CTL + (pin_mode & IOMUX_REG_MASK); 49 reg = IOMUXSW_MUX_CTL + (pin_mode & IOMUX_REG_MASK);
49 field = pin_mode & 0x3; 50 field = pin_mode & 0x3;
@@ -70,7 +71,8 @@ EXPORT_SYMBOL(mxc_iomux_mode);
70 */ 71 */
71void mxc_iomux_set_pad(enum iomux_pins pin, u32 config) 72void mxc_iomux_set_pad(enum iomux_pins pin, u32 config)
72{ 73{
73 u32 reg, field, l; 74 u32 field, l;
75 void __iomem *reg;
74 76
75 reg = IOMUXSW_PAD_CTL + (pin + 2) / 3; 77 reg = IOMUXSW_PAD_CTL + (pin + 2) / 3;
76 field = (pin + 2) % 3; 78 field = (pin + 2) % 3;
diff --git a/arch/arm/mach-mx3/mm.c b/arch/arm/mach-mx3/mm.c
index 30d842bd4d64..0589b5cd33c7 100644
--- a/arch/arm/mach-mx3/mm.c
+++ b/arch/arm/mach-mx3/mm.c
@@ -49,7 +49,7 @@ static struct map_desc mxc_io_desc[] __initdata = {
49 .virtual = AVIC_BASE_ADDR_VIRT, 49 .virtual = AVIC_BASE_ADDR_VIRT,
50 .pfn = __phys_to_pfn(AVIC_BASE_ADDR), 50 .pfn = __phys_to_pfn(AVIC_BASE_ADDR),
51 .length = AVIC_SIZE, 51 .length = AVIC_SIZE,
52 .type = MT_NONSHARED_DEVICE 52 .type = MT_DEVICE_NONSHARED
53 }, 53 },
54}; 54};
55 55
diff --git a/arch/arm/mach-mx3/mx31ads.c b/arch/arm/mach-mx3/mx31ads.c
index 60fb4e0d5acd..1be4a390c63f 100644
--- a/arch/arm/mach-mx3/mx31ads.c
+++ b/arch/arm/mach-mx3/mx31ads.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/serial_8250.h> 24#include <linux/serial_8250.h>
25#include <linux/irq.h>
25 26
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/mach-types.h> 28#include <asm/mach-types.h>
@@ -31,6 +32,8 @@
31#include <asm/mach/map.h> 32#include <asm/mach/map.h>
32#include <mach/common.h> 33#include <mach/common.h>
33#include <mach/board-mx31ads.h> 34#include <mach/board-mx31ads.h>
35#include <mach/imx-uart.h>
36#include <mach/iomux-mx3.h>
34 37
35/*! 38/*!
36 * @file mx31ads.c 39 * @file mx31ads.c
@@ -84,6 +87,108 @@ static inline int mxc_init_extuart(void)
84} 87}
85#endif 88#endif
86 89
90#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
91static struct imxuart_platform_data uart_pdata = {
92 .flags = IMXUART_HAVE_RTSCTS,
93};
94
95static inline void mxc_init_imx_uart(void)
96{
97 mxc_iomux_mode(MX31_PIN_CTS1__CTS1);
98 mxc_iomux_mode(MX31_PIN_RTS1__RTS1);
99 mxc_iomux_mode(MX31_PIN_TXD1__TXD1);
100 mxc_iomux_mode(MX31_PIN_RXD1__RXD1);
101
102 mxc_register_device(&mxc_uart_device0, &uart_pdata);
103}
104#else /* !SERIAL_IMX */
105static inline void mxc_init_imx_uart(void)
106{
107}
108#endif /* !SERIAL_IMX */
109
110static void mx31ads_expio_irq_handler(u32 irq, struct irq_desc *desc)
111{
112 u32 imr_val;
113 u32 int_valid;
114 u32 expio_irq;
115
116 imr_val = __raw_readw(PBC_INTMASK_SET_REG);
117 int_valid = __raw_readw(PBC_INTSTATUS_REG) & imr_val;
118
119 expio_irq = MXC_EXP_IO_BASE;
120 for (; int_valid != 0; int_valid >>= 1, expio_irq++) {
121 if ((int_valid & 1) == 0)
122 continue;
123
124 generic_handle_irq(expio_irq);
125 }
126}
127
128/*
129 * Disable an expio pin's interrupt by setting the bit in the imr.
130 * @param irq an expio virtual irq number
131 */
132static void expio_mask_irq(u32 irq)
133{
134 u32 expio = MXC_IRQ_TO_EXPIO(irq);
135 /* mask the interrupt */
136 __raw_writew(1 << expio, PBC_INTMASK_CLEAR_REG);
137 __raw_readw(PBC_INTMASK_CLEAR_REG);
138}
139
140/*
141 * Acknowledge an expanded io pin's interrupt by clearing the bit in the isr.
142 * @param irq an expanded io virtual irq number
143 */
144static void expio_ack_irq(u32 irq)
145{
146 u32 expio = MXC_IRQ_TO_EXPIO(irq);
147 /* clear the interrupt status */
148 __raw_writew(1 << expio, PBC_INTSTATUS_REG);
149}
150
151/*
152 * Enable a expio pin's interrupt by clearing the bit in the imr.
153 * @param irq a expio virtual irq number
154 */
155static void expio_unmask_irq(u32 irq)
156{
157 u32 expio = MXC_IRQ_TO_EXPIO(irq);
158 /* unmask the interrupt */
159 __raw_writew(1 << expio, PBC_INTMASK_SET_REG);
160}
161
162static struct irq_chip expio_irq_chip = {
163 .ack = expio_ack_irq,
164 .mask = expio_mask_irq,
165 .unmask = expio_unmask_irq,
166};
167
168static void __init mx31ads_init_expio(void)
169{
170 int i;
171
172 printk(KERN_INFO "MX31ADS EXPIO(CPLD) hardware\n");
173
174 /*
175 * Configure INT line as GPIO input
176 */
177 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_4, IOMUX_CONFIG_GPIO));
178
179 /* disable the interrupt and clear the status */
180 __raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG);
181 __raw_writew(0xFFFF, PBC_INTSTATUS_REG);
182 for (i = MXC_EXP_IO_BASE; i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES);
183 i++) {
184 set_irq_chip(i, &expio_irq_chip);
185 set_irq_handler(i, handle_level_irq);
186 set_irq_flags(i, IRQF_VALID);
187 }
188 set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_HIGH);
189 set_irq_chained_handler(EXPIO_PARENT_INT, mx31ads_expio_irq_handler);
190}
191
87/*! 192/*!
88 * This structure defines static mappings for the i.MX31ADS board. 193 * This structure defines static mappings for the i.MX31ADS board.
89 */ 194 */
@@ -92,17 +197,17 @@ static struct map_desc mx31ads_io_desc[] __initdata = {
92 .virtual = AIPS1_BASE_ADDR_VIRT, 197 .virtual = AIPS1_BASE_ADDR_VIRT,
93 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR), 198 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
94 .length = AIPS1_SIZE, 199 .length = AIPS1_SIZE,
95 .type = MT_NONSHARED_DEVICE 200 .type = MT_DEVICE_NONSHARED
96 }, { 201 }, {
97 .virtual = SPBA0_BASE_ADDR_VIRT, 202 .virtual = SPBA0_BASE_ADDR_VIRT,
98 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR), 203 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR),
99 .length = SPBA0_SIZE, 204 .length = SPBA0_SIZE,
100 .type = MT_NONSHARED_DEVICE 205 .type = MT_DEVICE_NONSHARED
101 }, { 206 }, {
102 .virtual = AIPS2_BASE_ADDR_VIRT, 207 .virtual = AIPS2_BASE_ADDR_VIRT,
103 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR), 208 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
104 .length = AIPS2_SIZE, 209 .length = AIPS2_SIZE,
105 .type = MT_NONSHARED_DEVICE 210 .type = MT_DEVICE_NONSHARED
106 }, { 211 }, {
107 .virtual = CS4_BASE_ADDR_VIRT, 212 .virtual = CS4_BASE_ADDR_VIRT,
108 .pfn = __phys_to_pfn(CS4_BASE_ADDR), 213 .pfn = __phys_to_pfn(CS4_BASE_ADDR),
@@ -120,12 +225,19 @@ void __init mx31ads_map_io(void)
120 iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc)); 225 iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc));
121} 226}
122 227
228void __init mx31ads_init_irq(void)
229{
230 mxc_init_irq();
231 mx31ads_init_expio();
232}
233
123/*! 234/*!
124 * Board specific initialization. 235 * Board specific initialization.
125 */ 236 */
126static void __init mxc_board_init(void) 237static void __init mxc_board_init(void)
127{ 238{
128 mxc_init_extuart(); 239 mxc_init_extuart();
240 mxc_init_imx_uart();
129} 241}
130 242
131static void __init mx31ads_timer_init(void) 243static void __init mx31ads_timer_init(void)
@@ -148,7 +260,7 @@ MACHINE_START(MX31ADS, "Freescale MX31ADS")
148 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, 260 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
149 .boot_params = PHYS_OFFSET + 0x100, 261 .boot_params = PHYS_OFFSET + 0x100,
150 .map_io = mx31ads_map_io, 262 .map_io = mx31ads_map_io,
151 .init_irq = mxc_init_irq, 263 .init_irq = mx31ads_init_irq,
152 .init_machine = mxc_board_init, 264 .init_machine = mxc_board_init,
153 .timer = &mx31ads_timer, 265 .timer = &mx31ads_timer,
154MACHINE_END 266MACHINE_END
diff --git a/arch/arm/mach-mx3/mx31lite.c b/arch/arm/mach-mx3/mx31lite.c
index d363a6e79f80..c43440070143 100644
--- a/arch/arm/mach-mx3/mx31lite.c
+++ b/arch/arm/mach-mx3/mx31lite.c
@@ -45,17 +45,17 @@ static struct map_desc mx31lite_io_desc[] __initdata = {
45 .virtual = AIPS1_BASE_ADDR_VIRT, 45 .virtual = AIPS1_BASE_ADDR_VIRT,
46 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR), 46 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
47 .length = AIPS1_SIZE, 47 .length = AIPS1_SIZE,
48 .type = MT_NONSHARED_DEVICE 48 .type = MT_DEVICE_NONSHARED
49 }, { 49 }, {
50 .virtual = SPBA0_BASE_ADDR_VIRT, 50 .virtual = SPBA0_BASE_ADDR_VIRT,
51 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR), 51 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR),
52 .length = SPBA0_SIZE, 52 .length = SPBA0_SIZE,
53 .type = MT_NONSHARED_DEVICE 53 .type = MT_DEVICE_NONSHARED
54 }, { 54 }, {
55 .virtual = AIPS2_BASE_ADDR_VIRT, 55 .virtual = AIPS2_BASE_ADDR_VIRT,
56 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR), 56 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
57 .length = AIPS2_SIZE, 57 .length = AIPS2_SIZE,
58 .type = MT_NONSHARED_DEVICE 58 .type = MT_DEVICE_NONSHARED
59 }, { 59 }, {
60 .virtual = CS4_BASE_ADDR_VIRT, 60 .virtual = CS4_BASE_ADDR_VIRT,
61 .pfn = __phys_to_pfn(CS4_BASE_ADDR), 61 .pfn = __phys_to_pfn(CS4_BASE_ADDR),
diff --git a/arch/arm/mach-mx3/pcm037.c b/arch/arm/mach-mx3/pcm037.c
index df8582a6231b..11fda95c86a5 100644
--- a/arch/arm/mach-mx3/pcm037.c
+++ b/arch/arm/mach-mx3/pcm037.c
@@ -33,6 +33,8 @@
33#include <mach/iomux-mx3.h> 33#include <mach/iomux-mx3.h>
34#include <mach/board-pcm037.h> 34#include <mach/board-pcm037.h>
35 35
36#include "devices.h"
37
36static struct physmap_flash_data pcm037_flash_data = { 38static struct physmap_flash_data pcm037_flash_data = {
37 .width = 2, 39 .width = 2,
38}; 40};
@@ -73,12 +75,12 @@ static void __init mxc_board_init(void)
73 mxc_iomux_mode(MX31_PIN_TXD1__TXD1); 75 mxc_iomux_mode(MX31_PIN_TXD1__TXD1);
74 mxc_iomux_mode(MX31_PIN_RXD1__RXD1); 76 mxc_iomux_mode(MX31_PIN_RXD1__RXD1);
75 77
76 imx_init_uart(0, &uart_pdata); 78 mxc_register_device(&mxc_uart_device0, &uart_pdata);
77 79
78 mxc_iomux_mode(MX31_PIN_CSPI3_MOSI__RXD3); 80 mxc_iomux_mode(MX31_PIN_CSPI3_MOSI__RXD3);
79 mxc_iomux_mode(MX31_PIN_CSPI3_MISO__TXD3); 81 mxc_iomux_mode(MX31_PIN_CSPI3_MISO__TXD3);
80 82
81 imx_init_uart(2, &uart_pdata); 83 mxc_register_device(&mxc_uart_device2, &uart_pdata);
82} 84}
83 85
84/* 86/*
diff --git a/arch/arm/mach-netx/generic.c b/arch/arm/mach-netx/generic.c
index 1b40483ea753..79df60c20e70 100644
--- a/arch/arm/mach-netx/generic.c
+++ b/arch/arm/mach-netx/generic.c
@@ -22,10 +22,10 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/io.h>
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/mach/map.h> 27#include <asm/mach/map.h>
27#include <asm/hardware/vic.h> 28#include <asm/hardware/vic.h>
28#include <asm/io.h>
29#include <mach/netx-regs.h> 29#include <mach/netx-regs.h>
30#include <asm/mach/irq.h> 30#include <asm/mach/irq.h>
31 31
@@ -77,15 +77,12 @@ netx_hif_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
77 stat = ((readl(NETX_DPMAS_INT_EN) & 77 stat = ((readl(NETX_DPMAS_INT_EN) &
78 readl(NETX_DPMAS_INT_STAT)) >> 24) & 0x1f; 78 readl(NETX_DPMAS_INT_STAT)) >> 24) & 0x1f;
79 79
80 desc = irq_desc + NETX_IRQ_HIF_CHAINED(0);
81
82 while (stat) { 80 while (stat) {
83 if (stat & 1) { 81 if (stat & 1) {
84 DEBUG_IRQ("handling irq %d\n", irq); 82 DEBUG_IRQ("handling irq %d\n", irq);
85 desc_handle_irq(irq, desc); 83 generic_handle_irq(irq);
86 } 84 }
87 irq++; 85 irq++;
88 desc++;
89 stat >>= 1; 86 stat >>= 1;
90 } 87 }
91} 88}
diff --git a/arch/arm/mach-netx/include/mach/system.h b/arch/arm/mach-netx/include/mach/system.h
index 27d8ef8e8e29..6c1023b8a9ab 100644
--- a/arch/arm/mach-netx/include/mach/system.h
+++ b/arch/arm/mach-netx/include/mach/system.h
@@ -19,7 +19,7 @@
19#ifndef __ASM_ARCH_SYSTEM_H 19#ifndef __ASM_ARCH_SYSTEM_H
20#define __ASM_ARCH_SYSTEM_H 20#define __ASM_ARCH_SYSTEM_H
21 21
22#include <asm/io.h> 22#include <linux/io.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include "netx-regs.h" 24#include "netx-regs.h"
25 25
diff --git a/arch/arm/mach-netx/pfifo.c b/arch/arm/mach-netx/pfifo.c
index 19ae0a72bea3..03984943e16d 100644
--- a/arch/arm/mach-netx/pfifo.c
+++ b/arch/arm/mach-netx/pfifo.c
@@ -20,8 +20,8 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/io.h>
23 24
24#include <asm/io.h>
25#include <mach/hardware.h> 25#include <mach/hardware.h>
26#include <mach/netx-regs.h> 26#include <mach/netx-regs.h>
27#include <mach/pfifo.h> 27#include <mach/pfifo.h>
diff --git a/arch/arm/mach-netx/time.c b/arch/arm/mach-netx/time.c
index ac8e5bfed691..7c540c1f01fa 100644
--- a/arch/arm/mach-netx/time.c
+++ b/arch/arm/mach-netx/time.c
@@ -21,9 +21,9 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/irq.h> 22#include <linux/irq.h>
23#include <linux/clocksource.h> 23#include <linux/clocksource.h>
24#include <linux/io.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/io.h>
27#include <asm/mach/time.h> 27#include <asm/mach/time.h>
28#include <mach/netx-regs.h> 28#include <mach/netx-regs.h>
29 29
diff --git a/arch/arm/mach-netx/xc.c b/arch/arm/mach-netx/xc.c
index 04c34e82fe6d..32eabf5dfa4f 100644
--- a/arch/arm/mach-netx/xc.c
+++ b/arch/arm/mach-netx/xc.c
@@ -21,8 +21,8 @@
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/firmware.h> 22#include <linux/firmware.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/io.h>
24 25
25#include <asm/io.h>
26#include <mach/hardware.h> 26#include <mach/hardware.h>
27#include <mach/netx-regs.h> 27#include <mach/netx-regs.h>
28 28
diff --git a/arch/arm/mach-ns9xxx/board-a9m9750dev.c b/arch/arm/mach-ns9xxx/board-a9m9750dev.c
index a22a608a7aba..b45bb3b802f1 100644
--- a/arch/arm/mach-ns9xxx/board-a9m9750dev.c
+++ b/arch/arm/mach-ns9xxx/board-a9m9750dev.c
@@ -86,13 +86,10 @@ static void a9m9750dev_fpga_demux_handler(unsigned int irq,
86 86
87 while (stat != 0) { 87 while (stat != 0) {
88 int irqno = fls(stat) - 1; 88 int irqno = fls(stat) - 1;
89 struct irq_desc *fpgadesc;
90 89
91 stat &= ~(1 << irqno); 90 stat &= ~(1 << irqno);
92 91
93 fpgadesc = irq_desc + FPGA_IRQ(irqno); 92 generic_handle_irq(FPGA_IRQ(irqno));
94
95 desc_handle_irq(FPGA_IRQ(irqno), fpgadesc);
96 } 93 }
97 94
98 desc->chip->unmask(irq); 95 desc->chip->unmask(irq);
diff --git a/arch/arm/mach-ns9xxx/gpio.c b/arch/arm/mach-ns9xxx/gpio.c
index 804c30075960..5241e6a286cc 100644
--- a/arch/arm/mach-ns9xxx/gpio.c
+++ b/arch/arm/mach-ns9xxx/gpio.c
@@ -12,13 +12,13 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/bitops.h>
15 16
16#include <mach/gpio.h> 17#include <mach/gpio.h>
17#include <mach/processor.h> 18#include <mach/processor.h>
18#include <mach/processor-ns9360.h> 19#include <mach/processor-ns9360.h>
19#include <asm/bug.h> 20#include <asm/bug.h>
20#include <asm/types.h> 21#include <asm/types.h>
21#include <asm/bitops.h>
22 22
23#include "gpio-ns9360.h" 23#include "gpio-ns9360.h"
24 24
diff --git a/arch/arm/mach-ns9xxx/include/mach/uncompress.h b/arch/arm/mach-ns9xxx/include/mach/uncompress.h
index 5dbc3c5167c8..1b12d324b087 100644
--- a/arch/arm/mach-ns9xxx/include/mach/uncompress.h
+++ b/arch/arm/mach-ns9xxx/include/mach/uncompress.h
@@ -11,7 +11,7 @@
11#ifndef __ASM_ARCH_UNCOMPRESS_H 11#ifndef __ASM_ARCH_UNCOMPRESS_H
12#define __ASM_ARCH_UNCOMPRESS_H 12#define __ASM_ARCH_UNCOMPRESS_H
13 13
14#include <asm/io.h> 14#include <linux/io.h>
15 15
16#define __REG(x) ((void __iomem __force *)(x)) 16#define __REG(x) ((void __iomem __force *)(x))
17 17
diff --git a/arch/arm/mach-ns9xxx/irq.c b/arch/arm/mach-ns9xxx/irq.c
index 38260d5f849b..22e0eb6e9ec4 100644
--- a/arch/arm/mach-ns9xxx/irq.c
+++ b/arch/arm/mach-ns9xxx/irq.c
@@ -10,7 +10,7 @@
10 */ 10 */
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/kernel_stat.h> 12#include <linux/kernel_stat.h>
13#include <asm/io.h> 13#include <linux/io.h>
14#include <asm/mach/irq.h> 14#include <asm/mach/irq.h>
15#include <mach/regs-sys-common.h> 15#include <mach/regs-sys-common.h>
16#include <mach/irqs.h> 16#include <mach/irqs.h>
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index 213b48787102..45a01311669a 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -21,6 +21,7 @@
21#include <linux/reboot.h> 21#include <linux/reboot.h>
22#include <linux/serial_8250.h> 22#include <linux/serial_8250.h>
23#include <linux/serial_reg.h> 23#include <linux/serial_reg.h>
24#include <linux/irq.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/mach-types.h> 27#include <asm/mach-types.h>
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index 5965cf09f8c4..478c2c9a22cb 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -17,8 +17,8 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/io.h>
20 21
21#include <asm/io.h>
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
23 23
24#include <mach/cpu.h> 24#include <mach/cpu.h>
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index ab708d4c597e..99982d3380c9 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -13,9 +13,9 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h>
16 17
17#include <mach/hardware.h> 18#include <mach/hardware.h>
18#include <asm/io.h>
19#include <asm/mach/map.h> 19#include <asm/mach/map.h>
20 20
21#include <mach/tc.h> 21#include <mach/tc.h>
diff --git a/arch/arm/mach-omap1/fpga.c b/arch/arm/mach-omap1/fpga.c
index 4449d86095f6..04995381aa5c 100644
--- a/arch/arm/mach-omap1/fpga.c
+++ b/arch/arm/mach-omap1/fpga.c
@@ -21,9 +21,9 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/io.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/io.h>
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
29 29
@@ -86,7 +86,6 @@ static void fpga_mask_ack_irq(unsigned int irq)
86 86
87void innovator_fpga_IRQ_demux(unsigned int irq, struct irq_desc *desc) 87void innovator_fpga_IRQ_demux(unsigned int irq, struct irq_desc *desc)
88{ 88{
89 struct irq_desc *d;
90 u32 stat; 89 u32 stat;
91 int fpga_irq; 90 int fpga_irq;
92 91
@@ -99,8 +98,7 @@ void innovator_fpga_IRQ_demux(unsigned int irq, struct irq_desc *desc)
99 (fpga_irq < OMAP_FPGA_IRQ_END) && stat; 98 (fpga_irq < OMAP_FPGA_IRQ_END) && stat;
100 fpga_irq++, stat >>= 1) { 99 fpga_irq++, stat >>= 1) {
101 if (stat & 1) { 100 if (stat & 1) {
102 d = irq_desc + fpga_irq; 101 generic_handle_irq(fpga_irq);
103 desc_handle_irq(fpga_irq, d);
104 } 102 }
105 } 103 }
106} 104}
diff --git a/arch/arm/mach-omap1/id.c b/arch/arm/mach-omap1/id.c
index da13c3e82850..13083d7e692d 100644
--- a/arch/arm/mach-omap1/id.c
+++ b/arch/arm/mach-omap1/id.c
@@ -14,8 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h> 16#include <linux/init.h>
17 17#include <linux/io.h>
18#include <asm/io.h>
19 18
20#define OMAP_DIE_ID_0 0xfffe1800 19#define OMAP_DIE_ID_0 0xfffe1800
21#define OMAP_DIE_ID_1 0xfffe1804 20#define OMAP_DIE_ID_1 0xfffe1804
diff --git a/arch/arm/mach-omap1/io.c b/arch/arm/mach-omap1/io.c
index 2b9750b200ce..b3bd8ca85118 100644
--- a/arch/arm/mach-omap1/io.c
+++ b/arch/arm/mach-omap1/io.c
@@ -11,10 +11,10 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/io.h>
14 15
15#include <asm/tlb.h> 16#include <asm/tlb.h>
16#include <asm/mach/map.h> 17#include <asm/mach/map.h>
17#include <asm/io.h>
18#include <mach/mux.h> 18#include <mach/mux.h>
19#include <mach/tc.h> 19#include <mach/tc.h>
20 20
diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c
index 0ec6c1ec4250..9ad5197075ff 100644
--- a/arch/arm/mach-omap1/irq.c
+++ b/arch/arm/mach-omap1/irq.c
@@ -40,6 +40,7 @@
40#include <linux/module.h> 40#include <linux/module.h>
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/io.h>
43 44
44#include <mach/hardware.h> 45#include <mach/hardware.h>
45#include <asm/irq.h> 46#include <asm/irq.h>
@@ -47,8 +48,6 @@
47#include <mach/gpio.h> 48#include <mach/gpio.h>
48#include <mach/cpu.h> 49#include <mach/cpu.h>
49 50
50#include <asm/io.h>
51
52#define IRQ_BANK(irq) ((irq) >> 5) 51#define IRQ_BANK(irq) ((irq) >> 5)
53#define IRQ_BIT(irq) ((irq) & 0x1f) 52#define IRQ_BIT(irq) ((irq) & 0x1f)
54 53
diff --git a/arch/arm/mach-omap1/leds-h2p2-debug.c b/arch/arm/mach-omap1/leds-h2p2-debug.c
index 610f51f18741..71fe2cc7f7cf 100644
--- a/arch/arm/mach-omap1/leds-h2p2-debug.c
+++ b/arch/arm/mach-omap1/leds-h2p2-debug.c
@@ -12,8 +12,8 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel_stat.h> 13#include <linux/kernel_stat.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/io.h>
15 16
16#include <asm/io.h>
17#include <mach/hardware.h> 17#include <mach/hardware.h>
18#include <asm/leds.h> 18#include <asm/leds.h>
19#include <asm/system.h> 19#include <asm/system.h>
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index af44eab1ed24..59abbf331a96 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -13,9 +13,9 @@
13#include <linux/resource.h> 13#include <linux/resource.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h>
16#include <mach/mailbox.h> 17#include <mach/mailbox.h>
17#include <mach/irqs.h> 18#include <mach/irqs.h>
18#include <asm/io.h>
19 19
20#define MAILBOX_ARM2DSP1 0x00 20#define MAILBOX_ARM2DSP1 0x00
21#define MAILBOX_ARM2DSP1b 0x04 21#define MAILBOX_ARM2DSP1b 0x04
diff --git a/arch/arm/mach-omap1/mux.c b/arch/arm/mach-omap1/mux.c
index 898516e362e7..062c905c2ba6 100644
--- a/arch/arm/mach-omap1/mux.c
+++ b/arch/arm/mach-omap1/mux.c
@@ -24,10 +24,11 @@
24 */ 24 */
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <asm/system.h> 27#include <linux/io.h>
28#include <asm/io.h>
29#include <linux/spinlock.h> 28#include <linux/spinlock.h>
30 29
30#include <asm/system.h>
31
31#include <mach/mux.h> 32#include <mach/mux.h>
32 33
33#ifdef CONFIG_OMAP_MUX 34#ifdef CONFIG_OMAP_MUX
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 63c4ea18b1ca..770d256c790b 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -41,8 +41,8 @@
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/sysfs.h> 42#include <linux/sysfs.h>
43#include <linux/module.h> 43#include <linux/module.h>
44#include <linux/io.h>
44 45
45#include <asm/io.h>
46#include <asm/irq.h> 46#include <asm/irq.h>
47#include <asm/atomic.h> 47#include <asm/atomic.h>
48#include <asm/mach/time.h> 48#include <asm/mach/time.h>
diff --git a/arch/arm/mach-omap1/serial.c b/arch/arm/mach-omap1/serial.c
index 0e25a996bb4c..aefc967fc003 100644
--- a/arch/arm/mach-omap1/serial.c
+++ b/arch/arm/mach-omap1/serial.c
@@ -18,8 +18,8 @@
18#include <linux/serial_8250.h> 18#include <linux/serial_8250.h>
19#include <linux/serial_reg.h> 19#include <linux/serial_reg.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/io.h>
21 22
22#include <asm/io.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24 24
25#include <mach/board.h> 25#include <mach/board.h>
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index e54708595ecf..2cf7e32bd293 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -43,10 +43,10 @@
43#include <linux/err.h> 43#include <linux/err.h>
44#include <linux/clocksource.h> 44#include <linux/clocksource.h>
45#include <linux/clockchips.h> 45#include <linux/clockchips.h>
46#include <linux/io.h>
46 47
47#include <asm/system.h> 48#include <asm/system.h>
48#include <mach/hardware.h> 49#include <mach/hardware.h>
49#include <asm/io.h>
50#include <asm/leds.h> 50#include <asm/leds.h>
51#include <asm/irq.h> 51#include <asm/irq.h>
52#include <asm/mach/irq.h> 52#include <asm/mach/irq.h>
diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
index e67760189d14..705367ece174 100644
--- a/arch/arm/mach-omap1/timer32k.c
+++ b/arch/arm/mach-omap1/timer32k.c
@@ -44,10 +44,10 @@
44#include <linux/clk.h> 44#include <linux/clk.h>
45#include <linux/clocksource.h> 45#include <linux/clocksource.h>
46#include <linux/clockchips.h> 46#include <linux/clockchips.h>
47#include <linux/io.h>
47 48
48#include <asm/system.h> 49#include <asm/system.h>
49#include <mach/hardware.h> 50#include <mach/hardware.h>
50#include <asm/io.h>
51#include <asm/leds.h> 51#include <asm/leds.h>
52#include <asm/irq.h> 52#include <asm/irq.h>
53#include <asm/mach/irq.h> 53#include <asm/mach/irq.h>
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index b72ca13b3acb..24688efaa445 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -21,6 +21,7 @@
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/io.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/mach-types.h> 27#include <asm/mach-types.h>
@@ -34,8 +35,6 @@
34#include <mach/common.h> 35#include <mach/common.h>
35#include <mach/gpmc.h> 36#include <mach/gpmc.h>
36 37
37#include <asm/io.h>
38
39 38
40#define SDP2430_FLASH_CS 0 39#define SDP2430_FLASH_CS 0
41#define SDP2430_SMC91X_CS 5 40#define SDP2430_SMC91X_CS 5
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 9e2624ca70a2..d4e3b6fc4705 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -21,6 +21,7 @@
21#include <linux/input.h> 21#include <linux/input.h>
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/io.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/mach-types.h> 27#include <asm/mach-types.h>
@@ -41,8 +42,6 @@
41#include <mach/dma.h> 42#include <mach/dma.h>
42#include <mach/gpmc.h> 43#include <mach/gpmc.h>
43 44
44#include <asm/io.h>
45
46#define H4_FLASH_CS 0 45#define H4_FLASH_CS 0
47#define H4_SMC91X_CS 1 46#define H4_SMC91X_CS 1
48 47
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 1d891e4a6933..97cde3d3611d 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -21,9 +21,8 @@
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <asm/bitops.h> 24#include <linux/io.h>
25 25#include <linux/bitops.h>
26#include <asm/io.h>
27 26
28#include <mach/clock.h> 27#include <mach/clock.h>
29#include <mach/sram.h> 28#include <mach/sram.h>
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 295e671e9cfd..d382eb0184ac 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -24,14 +24,13 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27
28#include <linux/io.h> 27#include <linux/io.h>
29#include <linux/cpufreq.h> 28#include <linux/cpufreq.h>
29#include <linux/bitops.h>
30 30
31#include <mach/clock.h> 31#include <mach/clock.h>
32#include <mach/sram.h> 32#include <mach/sram.h>
33#include <asm/div64.h> 33#include <asm/div64.h>
34#include <asm/bitops.h>
35 34
36#include "memory.h" 35#include "memory.h"
37#include "clock.h" 36#include "clock.h"
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index 3ff74952f835..e5b475f21081 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -25,11 +25,11 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/limits.h> 27#include <linux/limits.h>
28#include <linux/bitops.h>
28 29
29#include <mach/clock.h> 30#include <mach/clock.h>
30#include <mach/sram.h> 31#include <mach/sram.h>
31#include <asm/div64.h> 32#include <asm/div64.h>
32#include <asm/bitops.h>
33 33
34#include "memory.h" 34#include "memory.h"
35#include "clock.h" 35#include "clock.h"
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 7a7f02559075..2ee954a0bc7c 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -13,9 +13,9 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h>
16 17
17#include <mach/hardware.h> 18#include <mach/hardware.h>
18#include <asm/io.h>
19#include <asm/mach-types.h> 19#include <asm/mach-types.h>
20#include <asm/mach/map.h> 20#include <asm/mach/map.h>
21 21
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index f51d69bc457d..af1081a0b27c 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -15,8 +15,8 @@
15#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/ioport.h> 16#include <linux/ioport.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/io.h>
18 19
19#include <asm/io.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <mach/gpmc.h> 21#include <mach/gpmc.h>
22 22
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index a5d4526ac4d6..209177c7f22f 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -14,8 +14,9 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/io.h>
17 18
18#include <asm/io.h> 19#include <asm/cputype.h>
19 20
20#include <mach/control.h> 21#include <mach/control.h>
21#include <mach/cpu.h> 22#include <mach/cpu.h>
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 987351f07d7b..7c3d6289c05f 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -15,9 +15,9 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/io.h>
18 19
19#include <asm/tlb.h> 20#include <asm/tlb.h>
20#include <asm/io.h>
21 21
22#include <asm/mach/map.h> 22#include <asm/mach/map.h>
23 23
diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index 9ef15b31d8fc..196a9565a8dc 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -13,10 +13,10 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/io.h>
16#include <mach/hardware.h> 17#include <mach/hardware.h>
17#include <asm/mach/irq.h> 18#include <asm/mach/irq.h>
18#include <asm/irq.h> 19#include <asm/irq.h>
19#include <asm/io.h>
20 20
21#define INTC_REVISION 0x0000 21#define INTC_REVISION 0x0000
22#define INTC_SYSCONFIG 0x0010 22#define INTC_SYSCONFIG 0x0010
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index a480b96948e4..32b7af3c610b 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -14,9 +14,9 @@
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/io.h>
17#include <mach/mailbox.h> 18#include <mach/mailbox.h>
18#include <mach/irqs.h> 19#include <mach/irqs.h>
19#include <asm/io.h>
20 20
21#define MAILBOX_REVISION 0x00 21#define MAILBOX_REVISION 0x00
22#define MAILBOX_SYSCONFIG 0x10 22#define MAILBOX_SYSCONFIG 0x10
diff --git a/arch/arm/mach-omap2/memory.c b/arch/arm/mach-omap2/memory.c
index 6b49cc9cbdcb..ab1462b02e6e 100644
--- a/arch/arm/mach-omap2/memory.c
+++ b/arch/arm/mach-omap2/memory.c
@@ -21,8 +21,7 @@
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24 24#include <linux/io.h>
25#include <asm/io.h>
26 25
27#include <mach/common.h> 26#include <mach/common.h>
28#include <mach/clock.h> 27#include <mach/clock.h>
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 443d07fef7f3..6b7d672058b9 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -25,10 +25,11 @@
25 */ 25 */
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <asm/system.h> 28#include <linux/io.h>
29#include <asm/io.h>
30#include <linux/spinlock.h> 29#include <linux/spinlock.h>
31 30
31#include <asm/system.h>
32
32#include <mach/control.h> 33#include <mach/control.h>
33#include <mach/mux.h> 34#include <mach/mux.h>
34 35
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 8671e1079ab5..55361c16c9d9 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -24,8 +24,8 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/io.h>
27 28
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/atomic.h> 30#include <asm/atomic.h>
31#include <asm/mach/time.h> 31#include <asm/mach/time.h>
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index adc8a26a8fb0..7d9444adc5df 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -17,8 +17,7 @@
17#include <linux/serial_8250.h> 17#include <linux/serial_8250.h>
18#include <linux/serial_reg.h> 18#include <linux/serial_reg.h>
19#include <linux/clk.h> 19#include <linux/clk.h>
20 20#include <linux/io.h>
21#include <asm/io.h>
22 21
23#include <mach/common.h> 22#include <mach/common.h>
24#include <mach/board.h> 23#include <mach/board.h>
diff --git a/arch/arm/mach-orion5x/Kconfig b/arch/arm/mach-orion5x/Kconfig
index ddcd41b15d17..f59a8d0e0824 100644
--- a/arch/arm/mach-orion5x/Kconfig
+++ b/arch/arm/mach-orion5x/Kconfig
@@ -36,6 +36,12 @@ config MACH_TS209
36 Say 'Y' here if you want your kernel to support the 36 Say 'Y' here if you want your kernel to support the
37 QNAP TS-109/TS-209 platform. 37 QNAP TS-109/TS-209 platform.
38 38
39config MACH_TERASTATION_PRO2
40 bool "Buffalo Terastation Pro II/Live"
41 help
42 Say 'Y' here if you want your kernel to support the
43 Buffalo Terastation Pro II/Live platform.
44
39config MACH_LINKSTATION_PRO 45config MACH_LINKSTATION_PRO
40 bool "Buffalo Linkstation Pro/Live" 46 bool "Buffalo Linkstation Pro/Live"
41 select I2C_BOARDINFO 47 select I2C_BOARDINFO
@@ -44,6 +50,13 @@ config MACH_LINKSTATION_PRO
44 Buffalo Linkstation Pro/Live platform. Both v1 and 50 Buffalo Linkstation Pro/Live platform. Both v1 and
45 v2 devices are supported. 51 v2 devices are supported.
46 52
53config MACH_LINKSTATION_MINI
54 bool "Buffalo Linkstation Mini"
55 select I2C_BOARDINFO
56 help
57 Say 'Y' here if you want your kernel to support the
58 Buffalo Linkstation Mini platform.
59
47config MACH_TS409 60config MACH_TS409
48 bool "QNAP TS-409" 61 bool "QNAP TS-409"
49 help 62 help
@@ -68,6 +81,13 @@ config MACH_MV2120
68 Say 'Y' here if you want your kernel to support the 81 Say 'Y' here if you want your kernel to support the
69 HP Media Vault mv2120 or mv5100. 82 HP Media Vault mv2120 or mv5100.
70 83
84config MACH_EDMINI_V2
85 bool "LaCie Ethernet Disk mini V2"
86 select I2C_BOARDINFO
87 help
88 Say 'Y' here if you want your kernel to support the
89 LaCie Ethernet Disk mini V2.
90
71config MACH_MSS2 91config MACH_MSS2
72 bool "Maxtor Shared Storage II" 92 bool "Maxtor Shared Storage II"
73 help 93 help
@@ -92,6 +112,12 @@ config MACH_RD88F5181L_FXO
92 Say 'Y' here if you want your kernel to support the 112 Say 'Y' here if you want your kernel to support the
93 Marvell Orion-VoIP FXO (88F5181L) RD. 113 Marvell Orion-VoIP FXO (88F5181L) RD.
94 114
115config MACH_RD88F6183AP_GE
116 bool "Marvell Orion-1-90 AP GE Reference Design"
117 help
118 Say 'Y' here if you want your kernel to support the
119 Marvell Orion-1-90 (88F6183) AP GE RD.
120
95endmenu 121endmenu
96 122
97endif 123endif
diff --git a/arch/arm/mach-orion5x/Makefile b/arch/arm/mach-orion5x/Makefile
index fcc48a8864f3..3d4a1bc12355 100644
--- a/arch/arm/mach-orion5x/Makefile
+++ b/arch/arm/mach-orion5x/Makefile
@@ -2,14 +2,18 @@ obj-y += common.o addr-map.o pci.o gpio.o irq.o mpp.o
2obj-$(CONFIG_MACH_DB88F5281) += db88f5281-setup.o 2obj-$(CONFIG_MACH_DB88F5281) += db88f5281-setup.o
3obj-$(CONFIG_MACH_RD88F5182) += rd88f5182-setup.o 3obj-$(CONFIG_MACH_RD88F5182) += rd88f5182-setup.o
4obj-$(CONFIG_MACH_KUROBOX_PRO) += kurobox_pro-setup.o 4obj-$(CONFIG_MACH_KUROBOX_PRO) += kurobox_pro-setup.o
5obj-$(CONFIG_MACH_TERASTATION_PRO2) += terastation_pro2-setup.o
5obj-$(CONFIG_MACH_LINKSTATION_PRO) += kurobox_pro-setup.o 6obj-$(CONFIG_MACH_LINKSTATION_PRO) += kurobox_pro-setup.o
7obj-$(CONFIG_MACH_LINKSTATION_MINI) += lsmini-setup.o
6obj-$(CONFIG_MACH_DNS323) += dns323-setup.o 8obj-$(CONFIG_MACH_DNS323) += dns323-setup.o
7obj-$(CONFIG_MACH_TS209) += ts209-setup.o tsx09-common.o 9obj-$(CONFIG_MACH_TS209) += ts209-setup.o tsx09-common.o
8obj-$(CONFIG_MACH_TS409) += ts409-setup.o tsx09-common.o 10obj-$(CONFIG_MACH_TS409) += ts409-setup.o tsx09-common.o
9obj-$(CONFIG_MACH_WRT350N_V2) += wrt350n-v2-setup.o 11obj-$(CONFIG_MACH_WRT350N_V2) += wrt350n-v2-setup.o
10obj-$(CONFIG_MACH_TS78XX) += ts78xx-setup.o 12obj-$(CONFIG_MACH_TS78XX) += ts78xx-setup.o
11obj-$(CONFIG_MACH_MV2120) += mv2120-setup.o 13obj-$(CONFIG_MACH_MV2120) += mv2120-setup.o
14obj-$(CONFIG_MACH_EDMINI_V2) += edmini_v2-setup.o
12obj-$(CONFIG_MACH_MSS2) += mss2-setup.o 15obj-$(CONFIG_MACH_MSS2) += mss2-setup.o
13obj-$(CONFIG_MACH_WNR854T) += wnr854t-setup.o 16obj-$(CONFIG_MACH_WNR854T) += wnr854t-setup.o
14obj-$(CONFIG_MACH_RD88F5181L_GE) += rd88f5181l-ge-setup.o 17obj-$(CONFIG_MACH_RD88F5181L_GE) += rd88f5181l-ge-setup.o
15obj-$(CONFIG_MACH_RD88F5181L_FXO) += rd88f5181l-fxo-setup.o 18obj-$(CONFIG_MACH_RD88F5181L_FXO) += rd88f5181l-fxo-setup.o
19obj-$(CONFIG_MACH_RD88F6183AP_GE) += rd88f6183ap-ge-setup.o
diff --git a/arch/arm/mach-orion5x/addr-map.c b/arch/arm/mach-orion5x/addr-map.c
index bea37972120a..719957e05d9e 100644
--- a/arch/arm/mach-orion5x/addr-map.c
+++ b/arch/arm/mach-orion5x/addr-map.c
@@ -13,8 +13,8 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/mbus.h> 15#include <linux/mbus.h>
16#include <linux/io.h>
16#include <mach/hardware.h> 17#include <mach/hardware.h>
17#include <asm/io.h>
18#include "common.h" 18#include "common.h"
19 19
20/* 20/*
diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c
index 7b11e552bc5a..9625ef5975d0 100644
--- a/arch/arm/mach-orion5x/common.c
+++ b/arch/arm/mach-orion5x/common.c
@@ -18,6 +18,7 @@
18#include <linux/mv643xx_eth.h> 18#include <linux/mv643xx_eth.h>
19#include <linux/mv643xx_i2c.h> 19#include <linux/mv643xx_i2c.h>
20#include <linux/ata_platform.h> 20#include <linux/ata_platform.h>
21#include <linux/spi/orion_spi.h>
21#include <asm/page.h> 22#include <asm/page.h>
22#include <asm/setup.h> 23#include <asm/setup.h>
23#include <asm/timex.h> 24#include <asm/timex.h>
@@ -146,7 +147,6 @@ void __init orion5x_ehci1_init(void)
146 ****************************************************************************/ 147 ****************************************************************************/
147struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = { 148struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
148 .dram = &orion5x_mbus_dram_info, 149 .dram = &orion5x_mbus_dram_info,
149 .t_clk = ORION5X_TCLK,
150}; 150};
151 151
152static struct resource orion5x_eth_shared_resources[] = { 152static struct resource orion5x_eth_shared_resources[] = {
@@ -154,6 +154,10 @@ static struct resource orion5x_eth_shared_resources[] = {
154 .start = ORION5X_ETH_PHYS_BASE + 0x2000, 154 .start = ORION5X_ETH_PHYS_BASE + 0x2000,
155 .end = ORION5X_ETH_PHYS_BASE + 0x3fff, 155 .end = ORION5X_ETH_PHYS_BASE + 0x3fff,
156 .flags = IORESOURCE_MEM, 156 .flags = IORESOURCE_MEM,
157 }, {
158 .start = IRQ_ORION5X_ETH_ERR,
159 .end = IRQ_ORION5X_ETH_ERR,
160 .flags = IORESOURCE_IRQ,
157 }, 161 },
158}; 162};
159 163
@@ -163,7 +167,7 @@ static struct platform_device orion5x_eth_shared = {
163 .dev = { 167 .dev = {
164 .platform_data = &orion5x_eth_shared_data, 168 .platform_data = &orion5x_eth_shared_data,
165 }, 169 },
166 .num_resources = 1, 170 .num_resources = ARRAY_SIZE(orion5x_eth_shared_resources),
167 .resource = orion5x_eth_shared_resources, 171 .resource = orion5x_eth_shared_resources,
168}; 172};
169 173
@@ -268,6 +272,38 @@ void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
268 272
269 273
270/***************************************************************************** 274/*****************************************************************************
275 * SPI
276 ****************************************************************************/
277static struct orion_spi_info orion5x_spi_plat_data = {
278 .tclk = 0,
279};
280
281static struct resource orion5x_spi_resources[] = {
282 {
283 .name = "spi base",
284 .start = SPI_PHYS_BASE,
285 .end = SPI_PHYS_BASE + 0x1f,
286 .flags = IORESOURCE_MEM,
287 },
288};
289
290static struct platform_device orion5x_spi = {
291 .name = "orion_spi",
292 .id = 0,
293 .dev = {
294 .platform_data = &orion5x_spi_plat_data,
295 },
296 .num_resources = ARRAY_SIZE(orion5x_spi_resources),
297 .resource = orion5x_spi_resources,
298};
299
300void __init orion5x_spi_init()
301{
302 platform_device_register(&orion5x_spi);
303}
304
305
306/*****************************************************************************
271 * UART0 307 * UART0
272 ****************************************************************************/ 308 ****************************************************************************/
273static struct plat_serial8250_port orion5x_uart0_data[] = { 309static struct plat_serial8250_port orion5x_uart0_data[] = {
@@ -278,7 +314,7 @@ static struct plat_serial8250_port orion5x_uart0_data[] = {
278 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, 314 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
279 .iotype = UPIO_MEM, 315 .iotype = UPIO_MEM,
280 .regshift = 2, 316 .regshift = 2,
281 .uartclk = ORION5X_TCLK, 317 .uartclk = 0,
282 }, { 318 }, {
283 }, 319 },
284}; 320};
@@ -322,7 +358,7 @@ static struct plat_serial8250_port orion5x_uart1_data[] = {
322 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, 358 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
323 .iotype = UPIO_MEM, 359 .iotype = UPIO_MEM,
324 .regshift = 2, 360 .regshift = 2,
325 .uartclk = ORION5X_TCLK, 361 .uartclk = 0,
326 }, { 362 }, {
327 }, 363 },
328}; 364};
@@ -455,9 +491,24 @@ void __init orion5x_xor_init(void)
455/***************************************************************************** 491/*****************************************************************************
456 * Time handling 492 * Time handling
457 ****************************************************************************/ 493 ****************************************************************************/
494int orion5x_tclk;
495
496int __init orion5x_find_tclk(void)
497{
498 u32 dev, rev;
499
500 orion5x_pcie_id(&dev, &rev);
501 if (dev == MV88F6183_DEV_ID &&
502 (readl(MPP_RESET_SAMPLE) & 0x00000200) == 0)
503 return 133333333;
504
505 return 166666667;
506}
507
458static void orion5x_timer_init(void) 508static void orion5x_timer_init(void)
459{ 509{
460 orion_time_init(IRQ_ORION5X_BRIDGE, ORION5X_TCLK); 510 orion5x_tclk = orion5x_find_tclk();
511 orion_time_init(IRQ_ORION5X_BRIDGE, orion5x_tclk);
461} 512}
462 513
463struct sys_timer orion5x_timer = { 514struct sys_timer orion5x_timer = {
@@ -499,6 +550,12 @@ static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name)
499 } else { 550 } else {
500 *dev_name = "MV88F5181(L)-Rev-Unsupported"; 551 *dev_name = "MV88F5181(L)-Rev-Unsupported";
501 } 552 }
553 } else if (*dev == MV88F6183_DEV_ID) {
554 if (*rev == MV88F6183_REV_B0) {
555 *dev_name = "MV88F6183-Rev-B0";
556 } else {
557 *dev_name = "MV88F6183-Rev-Unsupported";
558 }
502 } else { 559 } else {
503 *dev_name = "Device-Unknown"; 560 *dev_name = "Device-Unknown";
504 } 561 }
@@ -510,7 +567,12 @@ void __init orion5x_init(void)
510 u32 dev, rev; 567 u32 dev, rev;
511 568
512 orion5x_id(&dev, &rev, &dev_name); 569 orion5x_id(&dev, &rev, &dev_name);
513 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, ORION5X_TCLK); 570 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, orion5x_tclk);
571
572 orion5x_eth_shared_data.t_clk = orion5x_tclk;
573 orion5x_spi_plat_data.tclk = orion5x_tclk;
574 orion5x_uart0_data[0].uartclk = orion5x_tclk;
575 orion5x_uart1_data[0].uartclk = orion5x_tclk;
514 576
515 /* 577 /*
516 * Setup Orion address map 578 * Setup Orion address map
diff --git a/arch/arm/mach-orion5x/common.h b/arch/arm/mach-orion5x/common.h
index 0bd195551a27..1f8b2da676a5 100644
--- a/arch/arm/mach-orion5x/common.h
+++ b/arch/arm/mach-orion5x/common.h
@@ -10,6 +10,7 @@ struct mv_sata_platform_data;
10void orion5x_map_io(void); 10void orion5x_map_io(void);
11void orion5x_init_irq(void); 11void orion5x_init_irq(void);
12void orion5x_init(void); 12void orion5x_init(void);
13extern int orion5x_tclk;
13extern struct sys_timer orion5x_timer; 14extern struct sys_timer orion5x_timer;
14 15
15/* 16/*
@@ -30,6 +31,7 @@ void orion5x_ehci1_init(void);
30void orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data); 31void orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data);
31void orion5x_i2c_init(void); 32void orion5x_i2c_init(void);
32void orion5x_sata_init(struct mv_sata_platform_data *sata_data); 33void orion5x_sata_init(struct mv_sata_platform_data *sata_data);
34void orion5x_spi_init(void);
33void orion5x_uart0_init(void); 35void orion5x_uart0_init(void);
34void orion5x_uart1_init(void); 36void orion5x_uart1_init(void);
35void orion5x_xor_init(void); 37void orion5x_xor_init(void);
diff --git a/arch/arm/mach-orion5x/db88f5281-setup.c b/arch/arm/mach-orion5x/db88f5281-setup.c
index ff13e9060b18..d318bea2af91 100644
--- a/arch/arm/mach-orion5x/db88f5281-setup.c
+++ b/arch/arm/mach-orion5x/db88f5281-setup.c
@@ -285,7 +285,7 @@ subsys_initcall(db88f5281_pci_init);
285 * Ethernet 285 * Ethernet
286 ****************************************************************************/ 286 ****************************************************************************/
287static struct mv643xx_eth_platform_data db88f5281_eth_data = { 287static struct mv643xx_eth_platform_data db88f5281_eth_data = {
288 .phy_addr = 8, 288 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
289}; 289};
290 290
291/***************************************************************************** 291/*****************************************************************************
diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c
index b38c65ccfb15..3e66098340a5 100644
--- a/arch/arm/mach-orion5x/dns323-setup.c
+++ b/arch/arm/mach-orion5x/dns323-setup.c
@@ -79,7 +79,7 @@ subsys_initcall(dns323_pci_init);
79 */ 79 */
80 80
81static struct mv643xx_eth_platform_data dns323_eth_data = { 81static struct mv643xx_eth_platform_data dns323_eth_data = {
82 .phy_addr = 8, 82 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
83}; 83};
84 84
85/**************************************************************************** 85/****************************************************************************
diff --git a/arch/arm/mach-orion5x/edmini_v2-setup.c b/arch/arm/mach-orion5x/edmini_v2-setup.c
new file mode 100644
index 000000000000..b24ee0c2cd61
--- /dev/null
+++ b/arch/arm/mach-orion5x/edmini_v2-setup.c
@@ -0,0 +1,262 @@
1/*
2 * arch/arm/mach-orion5x/edmini_v2-setup.c
3 *
4 * LaCie Ethernet Disk mini V2 Setup
5 *
6 * Copyright (C) 2008 Christopher Moore <moore@free.fr>
7 * Copyright (C) 2008 Albert Aribaud <albert.aribaud@free.fr>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14/*
15 * TODO: add Orion USB device port init when kernel.org support is added.
16 * TODO: add flash write support: see below.
17 * TODO: add power-off support.
18 * TODO: add I2C EEPROM support.
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/platform_device.h>
24#include <linux/pci.h>
25#include <linux/irq.h>
26#include <linux/mtd/physmap.h>
27#include <linux/mv643xx_eth.h>
28#include <linux/leds.h>
29#include <linux/gpio_keys.h>
30#include <linux/input.h>
31#include <linux/i2c.h>
32#include <linux/ata_platform.h>
33#include <linux/gpio.h>
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/pci.h>
37#include <mach/orion5x.h>
38#include "common.h"
39#include "mpp.h"
40
41/*****************************************************************************
42 * EDMINI_V2 Info
43 ****************************************************************************/
44
45/*
46 * 512KB NOR flash Device bus boot chip select
47 */
48
49#define EDMINI_V2_NOR_BOOT_BASE 0xfff80000
50#define EDMINI_V2_NOR_BOOT_SIZE SZ_512K
51
52/*****************************************************************************
53 * 512KB NOR Flash on BOOT Device
54 ****************************************************************************/
55
56/*
57 * Currently the MTD code does not recognize the MX29LV400CBCT as a bottom
58 * -type device. This could cause risks of accidentally erasing critical
59 * flash sectors. We thus define a single, write-protected partition covering
60 * the whole flash.
61 * TODO: once the flash part TOP/BOTTOM detection issue is sorted out in the MTD
62 * code, break this into at least three partitions: 'u-boot code', 'u-boot
63 * environment' and 'whatever is left'.
64 */
65
66static struct mtd_partition edmini_v2_partitions[] = {
67 {
68 .name = "Full512kb",
69 .size = 0x00080000,
70 .offset = 0x00000000,
71 .mask_flags = MTD_WRITEABLE,
72 },
73};
74
75static struct physmap_flash_data edmini_v2_nor_flash_data = {
76 .width = 1,
77 .parts = edmini_v2_partitions,
78 .nr_parts = ARRAY_SIZE(edmini_v2_partitions),
79};
80
81static struct resource edmini_v2_nor_flash_resource = {
82 .flags = IORESOURCE_MEM,
83 .start = EDMINI_V2_NOR_BOOT_BASE,
84 .end = EDMINI_V2_NOR_BOOT_BASE
85 + EDMINI_V2_NOR_BOOT_SIZE - 1,
86};
87
88static struct platform_device edmini_v2_nor_flash = {
89 .name = "physmap-flash",
90 .id = 0,
91 .dev = {
92 .platform_data = &edmini_v2_nor_flash_data,
93 },
94 .num_resources = 1,
95 .resource = &edmini_v2_nor_flash_resource,
96};
97
98/*****************************************************************************
99 * Ethernet
100 ****************************************************************************/
101
102static struct mv643xx_eth_platform_data edmini_v2_eth_data = {
103 .phy_addr = 8,
104};
105
106/*****************************************************************************
107 * RTC 5C372a on I2C bus
108 ****************************************************************************/
109
110#define EDMINIV2_RTC_GPIO 3
111
112static struct i2c_board_info __initdata edmini_v2_i2c_rtc = {
113 I2C_BOARD_INFO("rs5c372a", 0x32),
114 .irq = 0,
115};
116
117/*****************************************************************************
118 * Sata
119 ****************************************************************************/
120
121static struct mv_sata_platform_data edmini_v2_sata_data = {
122 .n_ports = 2,
123};
124
125/*****************************************************************************
126 * GPIO LED (simple - doesn't use hardware blinking support)
127 ****************************************************************************/
128
129#define EDMINI_V2_GPIO_LED_POWER 16
130
131static struct gpio_led edmini_v2_leds[] = {
132 {
133 .name = "power:blue",
134 .gpio = EDMINI_V2_GPIO_LED_POWER,
135 .active_low = 1,
136 },
137};
138
139static struct gpio_led_platform_data edmini_v2_led_data = {
140 .num_leds = ARRAY_SIZE(edmini_v2_leds),
141 .leds = edmini_v2_leds,
142};
143
144static struct platform_device edmini_v2_gpio_leds = {
145 .name = "leds-gpio",
146 .id = -1,
147 .dev = {
148 .platform_data = &edmini_v2_led_data,
149 },
150};
151
152/****************************************************************************
153 * GPIO key
154 ****************************************************************************/
155
156#define EDMINI_V2_GPIO_KEY_POWER 18
157
158static struct gpio_keys_button edmini_v2_buttons[] = {
159 {
160 .code = KEY_POWER,
161 .gpio = EDMINI_V2_GPIO_KEY_POWER,
162 .desc = "Power Button",
163 .active_low = 0,
164 },
165};
166
167static struct gpio_keys_platform_data edmini_v2_button_data = {
168 .buttons = edmini_v2_buttons,
169 .nbuttons = ARRAY_SIZE(edmini_v2_buttons),
170};
171
172static struct platform_device edmini_v2_gpio_buttons = {
173 .name = "gpio-keys",
174 .id = -1,
175 .dev = {
176 .platform_data = &edmini_v2_button_data,
177 },
178};
179
180/*****************************************************************************
181 * General Setup
182 ****************************************************************************/
183static struct orion5x_mpp_mode edminiv2_mpp_modes[] __initdata = {
184 { 0, MPP_UNUSED },
185 { 1, MPP_UNUSED },
186 { 2, MPP_UNUSED },
187 { 3, MPP_GPIO }, /* RTC interrupt */
188 { 4, MPP_UNUSED },
189 { 5, MPP_UNUSED },
190 { 6, MPP_UNUSED },
191 { 7, MPP_UNUSED },
192 { 8, MPP_UNUSED },
193 { 9, MPP_UNUSED },
194 { 10, MPP_UNUSED },
195 { 11, MPP_UNUSED },
196 { 12, MPP_SATA_LED }, /* SATA 0 presence */
197 { 13, MPP_SATA_LED }, /* SATA 1 presence */
198 { 14, MPP_SATA_LED }, /* SATA 0 active */
199 { 15, MPP_SATA_LED }, /* SATA 1 active */
200 /* 16: Power LED control (0 = On, 1 = Off) */
201 { 16, MPP_GPIO },
202 /* 17: Power LED control select (0 = CPLD, 1 = GPIO16) */
203 { 17, MPP_GPIO },
204 /* 18: Power button status (0 = Released, 1 = Pressed) */
205 { 18, MPP_GPIO },
206 { 19, MPP_UNUSED },
207 { -1 }
208};
209
210static void __init edmini_v2_init(void)
211{
212 /*
213 * Setup basic Orion functions. Need to be called early.
214 */
215 orion5x_init();
216
217 orion5x_mpp_conf(edminiv2_mpp_modes);
218
219 /*
220 * Configure peripherals.
221 */
222 orion5x_ehci0_init();
223 orion5x_eth_init(&edmini_v2_eth_data);
224 orion5x_i2c_init();
225 orion5x_sata_init(&edmini_v2_sata_data);
226 orion5x_uart0_init();
227
228 orion5x_setup_dev_boot_win(EDMINI_V2_NOR_BOOT_BASE,
229 EDMINI_V2_NOR_BOOT_SIZE);
230 platform_device_register(&edmini_v2_nor_flash);
231 platform_device_register(&edmini_v2_gpio_leds);
232 platform_device_register(&edmini_v2_gpio_buttons);
233
234 pr_notice("edmini_v2: USB device port, flash write and power-off "
235 "are not yet supported.\n");
236
237 /* Get RTC IRQ and register the chip */
238 if (gpio_request(EDMINIV2_RTC_GPIO, "rtc") == 0) {
239 if (gpio_direction_input(EDMINIV2_RTC_GPIO) == 0)
240 edmini_v2_i2c_rtc.irq = gpio_to_irq(EDMINIV2_RTC_GPIO);
241 else
242 gpio_free(EDMINIV2_RTC_GPIO);
243 }
244
245 if (edmini_v2_i2c_rtc.irq == 0)
246 pr_warning("edmini_v2: failed to get RTC IRQ\n");
247
248 i2c_register_board_info(0, &edmini_v2_i2c_rtc, 1);
249}
250
251/* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */
252MACHINE_START(EDMINI_V2, "LaCie Ethernet Disk mini V2")
253 /* Maintainer: Christopher Moore <moore@free.fr> */
254 .phys_io = ORION5X_REGS_PHYS_BASE,
255 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
256 .boot_params = 0x00000100,
257 .init_machine = edmini_v2_init,
258 .map_io = orion5x_map_io,
259 .init_irq = orion5x_init_irq,
260 .timer = &orion5x_timer,
261 .fixup = tag_fixup_mem32,
262MACHINE_END
diff --git a/arch/arm/mach-orion5x/gpio.c b/arch/arm/mach-orion5x/gpio.c
index cd8a16f67d2b..fc419868e39f 100644
--- a/arch/arm/mach-orion5x/gpio.c
+++ b/arch/arm/mach-orion5x/gpio.c
@@ -15,8 +15,8 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/spinlock.h> 16#include <linux/spinlock.h>
17#include <linux/bitops.h> 17#include <linux/bitops.h>
18#include <linux/io.h>
18#include <asm/gpio.h> 19#include <asm/gpio.h>
19#include <asm/io.h>
20#include <mach/orion5x.h> 20#include <mach/orion5x.h>
21#include "common.h" 21#include "common.h"
22 22
diff --git a/arch/arm/mach-orion5x/include/mach/orion5x.h b/arch/arm/mach-orion5x/include/mach/orion5x.h
index 61eb74a88862..9f5ce1ce5840 100644
--- a/arch/arm/mach-orion5x/include/mach/orion5x.h
+++ b/arch/arm/mach-orion5x/include/mach/orion5x.h
@@ -2,7 +2,7 @@
2 * arch/arm/mach-orion5x/include/mach/orion5x.h 2 * arch/arm/mach-orion5x/include/mach/orion5x.h
3 * 3 *
4 * Generic definitions of Orion SoC flavors: 4 * Generic definitions of Orion SoC flavors:
5 * Orion-1, Orion-VoIP, Orion-NAS, and Orion-2. 5 * Orion-1, Orion-VoIP, Orion-NAS, Orion-2, and Orion-1-90.
6 * 6 *
7 * Maintainer: Tzachi Perelstein <tzachi@marvell.com> 7 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
8 * 8 *
@@ -76,6 +76,9 @@
76#define MV88F5281_REV_D0 4 76#define MV88F5281_REV_D0 4
77#define MV88F5281_REV_D1 5 77#define MV88F5281_REV_D1 5
78#define MV88F5281_REV_D2 6 78#define MV88F5281_REV_D2 6
79/* Orion-1-90 (88F6183) */
80#define MV88F6183_DEV_ID 0x6183
81#define MV88F6183_REV_B0 3
79 82
80/******************************************************************************* 83/*******************************************************************************
81 * Orion Registers Map 84 * Orion Registers Map
@@ -86,6 +89,7 @@
86#define ORION5X_DEV_BUS_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0x10000) 89#define ORION5X_DEV_BUS_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0x10000)
87#define ORION5X_DEV_BUS_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x10000) 90#define ORION5X_DEV_BUS_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x10000)
88#define ORION5X_DEV_BUS_REG(x) (ORION5X_DEV_BUS_VIRT_BASE | (x)) 91#define ORION5X_DEV_BUS_REG(x) (ORION5X_DEV_BUS_VIRT_BASE | (x))
92#define SPI_PHYS_BASE (ORION5X_DEV_BUS_PHYS_BASE | 0x0600)
89#define I2C_PHYS_BASE (ORION5X_DEV_BUS_PHYS_BASE | 0x1000) 93#define I2C_PHYS_BASE (ORION5X_DEV_BUS_PHYS_BASE | 0x1000)
90#define UART0_PHYS_BASE (ORION5X_DEV_BUS_PHYS_BASE | 0x2000) 94#define UART0_PHYS_BASE (ORION5X_DEV_BUS_PHYS_BASE | 0x2000)
91#define UART0_VIRT_BASE (ORION5X_DEV_BUS_VIRT_BASE | 0x2000) 95#define UART0_VIRT_BASE (ORION5X_DEV_BUS_VIRT_BASE | 0x2000)
@@ -153,9 +157,11 @@
153#define CPU_CONF ORION5X_BRIDGE_REG(0x100) 157#define CPU_CONF ORION5X_BRIDGE_REG(0x100)
154#define CPU_CTRL ORION5X_BRIDGE_REG(0x104) 158#define CPU_CTRL ORION5X_BRIDGE_REG(0x104)
155#define CPU_RESET_MASK ORION5X_BRIDGE_REG(0x108) 159#define CPU_RESET_MASK ORION5X_BRIDGE_REG(0x108)
160#define WDT_RESET 0x0002
156#define CPU_SOFT_RESET ORION5X_BRIDGE_REG(0x10c) 161#define CPU_SOFT_RESET ORION5X_BRIDGE_REG(0x10c)
157#define POWER_MNG_CTRL_REG ORION5X_BRIDGE_REG(0x11C) 162#define POWER_MNG_CTRL_REG ORION5X_BRIDGE_REG(0x11C)
158#define BRIDGE_CAUSE ORION5X_BRIDGE_REG(0x110) 163#define BRIDGE_CAUSE ORION5X_BRIDGE_REG(0x110)
164#define WDT_INT_REQ 0x0008
159#define BRIDGE_MASK ORION5X_BRIDGE_REG(0x114) 165#define BRIDGE_MASK ORION5X_BRIDGE_REG(0x114)
160#define BRIDGE_INT_TIMER0 0x0002 166#define BRIDGE_INT_TIMER0 0x0002
161#define BRIDGE_INT_TIMER1 0x0004 167#define BRIDGE_INT_TIMER1 0x0004
diff --git a/arch/arm/mach-orion5x/include/mach/timex.h b/arch/arm/mach-orion5x/include/mach/timex.h
index e82e44db7629..4c69820e0810 100644
--- a/arch/arm/mach-orion5x/include/mach/timex.h
+++ b/arch/arm/mach-orion5x/include/mach/timex.h
@@ -9,5 +9,3 @@
9 */ 9 */
10 10
11#define CLOCK_TICK_RATE (100 * HZ) 11#define CLOCK_TICK_RATE (100 * HZ)
12
13#define ORION5X_TCLK 166666667
diff --git a/arch/arm/mach-orion5x/irq.c b/arch/arm/mach-orion5x/irq.c
index 2545ff9e5830..632a36f5cf14 100644
--- a/arch/arm/mach-orion5x/irq.c
+++ b/arch/arm/mach-orion5x/irq.c
@@ -13,8 +13,8 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/io.h>
16#include <asm/gpio.h> 17#include <asm/gpio.h>
17#include <asm/io.h>
18#include <mach/orion5x.h> 18#include <mach/orion5x.h>
19#include <plat/irq.h> 19#include <plat/irq.h>
20#include "common.h" 20#include "common.h"
@@ -162,7 +162,7 @@ static void orion5x_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
162 polarity ^= 1 << pin; 162 polarity ^= 1 << pin;
163 writel(polarity, GPIO_IN_POL); 163 writel(polarity, GPIO_IN_POL);
164 } 164 }
165 desc_handle_irq(irq, desc); 165 generic_handle_irq(irq);
166 } 166 }
167 } 167 }
168} 168}
diff --git a/arch/arm/mach-orion5x/kurobox_pro-setup.c b/arch/arm/mach-orion5x/kurobox_pro-setup.c
index e321ec331839..dfbb68df7b09 100644
--- a/arch/arm/mach-orion5x/kurobox_pro-setup.c
+++ b/arch/arm/mach-orion5x/kurobox_pro-setup.c
@@ -161,7 +161,7 @@ subsys_initcall(kurobox_pro_pci_init);
161 ****************************************************************************/ 161 ****************************************************************************/
162 162
163static struct mv643xx_eth_platform_data kurobox_pro_eth_data = { 163static struct mv643xx_eth_platform_data kurobox_pro_eth_data = {
164 .phy_addr = 8, 164 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
165}; 165};
166 166
167/***************************************************************************** 167/*****************************************************************************
@@ -293,7 +293,7 @@ static void kurobox_pro_power_off(void)
293 const unsigned char shutdownwait[] = {0x00, 0x0c}; 293 const unsigned char shutdownwait[] = {0x00, 0x0c};
294 const unsigned char poweroff[] = {0x00, 0x06}; 294 const unsigned char poweroff[] = {0x00, 0x06};
295 /* 38400 baud divisor */ 295 /* 38400 baud divisor */
296 const unsigned divisor = ((ORION5X_TCLK + (8 * 38400)) / (16 * 38400)); 296 const unsigned divisor = ((orion5x_tclk + (8 * 38400)) / (16 * 38400));
297 297
298 pr_info("%s: triggering power-off...\n", __func__); 298 pr_info("%s: triggering power-off...\n", __func__);
299 299
diff --git a/arch/arm/mach-orion5x/lsmini-setup.c b/arch/arm/mach-orion5x/lsmini-setup.c
new file mode 100644
index 000000000000..e0c43b8beb72
--- /dev/null
+++ b/arch/arm/mach-orion5x/lsmini-setup.c
@@ -0,0 +1,279 @@
1/*
2 * arch/arm/mach-orion5x/lsmini-setup.c
3 *
4 * Maintainer: Alexey Kopytko <alexey@kopytko.ru>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/pci.h>
15#include <linux/mtd/physmap.h>
16#include <linux/mv643xx_eth.h>
17#include <linux/leds.h>
18#include <linux/gpio_keys.h>
19#include <linux/input.h>
20#include <linux/i2c.h>
21#include <linux/ata_platform.h>
22#include <asm/mach-types.h>
23#include <linux/gpio.h>
24#include <asm/mach/arch.h>
25#include "common.h"
26#include "mpp.h"
27#include "include/mach/system.h"
28
29/*****************************************************************************
30 * Linkstation Mini Info
31 ****************************************************************************/
32
33/*
34 * 256K NOR flash Device bus boot chip select
35 */
36
37#define LSMINI_NOR_BOOT_BASE 0xf4000000
38#define LSMINI_NOR_BOOT_SIZE SZ_256K
39
40/*****************************************************************************
41 * 256KB NOR Flash on BOOT Device
42 ****************************************************************************/
43
44static struct physmap_flash_data lsmini_nor_flash_data = {
45 .width = 1,
46};
47
48static struct resource lsmini_nor_flash_resource = {
49 .flags = IORESOURCE_MEM,
50 .start = LSMINI_NOR_BOOT_BASE,
51 .end = LSMINI_NOR_BOOT_BASE + LSMINI_NOR_BOOT_SIZE - 1,
52};
53
54static struct platform_device lsmini_nor_flash = {
55 .name = "physmap-flash",
56 .id = 0,
57 .dev = {
58 .platform_data = &lsmini_nor_flash_data,
59 },
60 .num_resources = 1,
61 .resource = &lsmini_nor_flash_resource,
62};
63
64/*****************************************************************************
65 * Ethernet
66 ****************************************************************************/
67
68static struct mv643xx_eth_platform_data lsmini_eth_data = {
69 .phy_addr = 8,
70};
71
72/*****************************************************************************
73 * RTC 5C372a on I2C bus
74 ****************************************************************************/
75
76static struct i2c_board_info __initdata lsmini_i2c_rtc = {
77 I2C_BOARD_INFO("rs5c372a", 0x32),
78};
79
80/*****************************************************************************
81 * LEDs attached to GPIO
82 ****************************************************************************/
83
84#define LSMINI_GPIO_LED_ALARM 2
85#define LSMINI_GPIO_LED_INFO 3
86#define LSMINI_GPIO_LED_FUNC 9
87#define LSMINI_GPIO_LED_PWR 14
88
89static struct gpio_led lsmini_led_pins[] = {
90 {
91 .name = "alarm:red",
92 .gpio = LSMINI_GPIO_LED_ALARM,
93 .active_low = 1,
94 }, {
95 .name = "info:amber",
96 .gpio = LSMINI_GPIO_LED_INFO,
97 .active_low = 1,
98 }, {
99 .name = "func:blue:top",
100 .gpio = LSMINI_GPIO_LED_FUNC,
101 .active_low = 1,
102 }, {
103 .name = "power:blue:bottom",
104 .gpio = LSMINI_GPIO_LED_PWR,
105 },
106};
107
108static struct gpio_led_platform_data lsmini_led_data = {
109 .leds = lsmini_led_pins,
110 .num_leds = ARRAY_SIZE(lsmini_led_pins),
111};
112
113static struct platform_device lsmini_leds = {
114 .name = "leds-gpio",
115 .id = -1,
116 .dev = {
117 .platform_data = &lsmini_led_data,
118 },
119};
120
121/****************************************************************************
122 * GPIO Attached Keys
123 ****************************************************************************/
124
125#define LSMINI_GPIO_KEY_FUNC 15
126#define LSMINI_GPIO_KEY_POWER 18
127#define LSMINI_GPIO_KEY_AUTOPOWER 17
128
129#define LSMINI_SW_POWER 0x00
130#define LSMINI_SW_AUTOPOWER 0x01
131
132static struct gpio_keys_button lsmini_buttons[] = {
133 {
134 .code = KEY_OPTION,
135 .gpio = LSMINI_GPIO_KEY_FUNC,
136 .desc = "Function Button",
137 .active_low = 1,
138 }, {
139 .type = EV_SW,
140 .code = LSMINI_SW_POWER,
141 .gpio = LSMINI_GPIO_KEY_POWER,
142 .desc = "Power-on Switch",
143 .active_low = 1,
144 }, {
145 .type = EV_SW,
146 .code = LSMINI_SW_AUTOPOWER,
147 .gpio = LSMINI_GPIO_KEY_AUTOPOWER,
148 .desc = "Power-auto Switch",
149 .active_low = 1,
150 },
151};
152
153static struct gpio_keys_platform_data lsmini_button_data = {
154 .buttons = lsmini_buttons,
155 .nbuttons = ARRAY_SIZE(lsmini_buttons),
156};
157
158static struct platform_device lsmini_button_device = {
159 .name = "gpio-keys",
160 .id = -1,
161 .num_resources = 0,
162 .dev = {
163 .platform_data = &lsmini_button_data,
164 },
165};
166
167
168/*****************************************************************************
169 * SATA
170 ****************************************************************************/
171static struct mv_sata_platform_data lsmini_sata_data = {
172 .n_ports = 2,
173};
174
175
176/*****************************************************************************
177 * Linkstation Mini specific power off method: reboot
178 ****************************************************************************/
179/*
180 * On the Linkstation Mini, the shutdown process is following:
181 * - Userland monitors key events until the power switch goes to off position
182 * - The board reboots
183 * - U-boot starts and goes into an idle mode waiting for the user
184 * to move the switch to ON position
185 */
186
187static void lsmini_power_off(void)
188{
189 arch_reset(0);
190}
191
192
193/*****************************************************************************
194 * General Setup
195 ****************************************************************************/
196
197#define LSMINI_GPIO_USB_POWER 16
198#define LSMINI_GPIO_AUTO_POWER 17
199#define LSMINI_GPIO_POWER 18
200
201#define LSMINI_GPIO_HDD_POWER0 1
202#define LSMINI_GPIO_HDD_POWER1 19
203
204static struct orion5x_mpp_mode lsmini_mpp_modes[] __initdata = {
205 { 0, MPP_UNUSED }, /* LED_RESERVE1 (unused) */
206 { 1, MPP_GPIO }, /* HDD_PWR */
207 { 2, MPP_GPIO }, /* LED_ALARM */
208 { 3, MPP_GPIO }, /* LED_INFO */
209 { 4, MPP_UNUSED },
210 { 5, MPP_UNUSED },
211 { 6, MPP_UNUSED },
212 { 7, MPP_UNUSED },
213 { 8, MPP_UNUSED },
214 { 9, MPP_GPIO }, /* LED_FUNC */
215 { 10, MPP_UNUSED },
216 { 11, MPP_UNUSED }, /* LED_ETH (dummy) */
217 { 12, MPP_UNUSED },
218 { 13, MPP_UNUSED },
219 { 14, MPP_GPIO }, /* LED_PWR */
220 { 15, MPP_GPIO }, /* FUNC */
221 { 16, MPP_GPIO }, /* USB_PWR */
222 { 17, MPP_GPIO }, /* AUTO_POWER */
223 { 18, MPP_GPIO }, /* POWER */
224 { 19, MPP_GPIO }, /* HDD_PWR1 */
225 { -1 },
226};
227
228static void __init lsmini_init(void)
229{
230 /*
231 * Setup basic Orion functions. Need to be called early.
232 */
233 orion5x_init();
234
235 orion5x_mpp_conf(lsmini_mpp_modes);
236
237 /*
238 * Configure peripherals.
239 */
240 orion5x_ehci0_init();
241 orion5x_ehci1_init();
242 orion5x_eth_init(&lsmini_eth_data);
243 orion5x_i2c_init();
244 orion5x_sata_init(&lsmini_sata_data);
245 orion5x_uart0_init();
246 orion5x_xor_init();
247
248 orion5x_setup_dev_boot_win(LSMINI_NOR_BOOT_BASE,
249 LSMINI_NOR_BOOT_SIZE);
250 platform_device_register(&lsmini_nor_flash);
251
252 platform_device_register(&lsmini_button_device);
253
254 platform_device_register(&lsmini_leds);
255
256 i2c_register_board_info(0, &lsmini_i2c_rtc, 1);
257
258 /* enable USB power */
259 gpio_set_value(LSMINI_GPIO_USB_POWER, 1);
260
261 /* register power-off method */
262 pm_power_off = lsmini_power_off;
263
264 pr_info("%s: finished\n", __func__);
265}
266
267#ifdef CONFIG_MACH_LINKSTATION_MINI
268MACHINE_START(LINKSTATION_MINI, "Buffalo Linkstation Mini")
269 /* Maintainer: Alexey Kopytko <alexey@kopytko.ru> */
270 .phys_io = ORION5X_REGS_PHYS_BASE,
271 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
272 .boot_params = 0x00000100,
273 .init_machine = lsmini_init,
274 .map_io = orion5x_map_io,
275 .init_irq = orion5x_init_irq,
276 .timer = &orion5x_timer,
277 .fixup = tag_fixup_mem32,
278MACHINE_END
279#endif
diff --git a/arch/arm/mach-orion5x/mpp.c b/arch/arm/mach-orion5x/mpp.c
index c04ab0e16ea1..640ea2a3fc6c 100644
--- a/arch/arm/mach-orion5x/mpp.c
+++ b/arch/arm/mach-orion5x/mpp.c
@@ -11,8 +11,8 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/mbus.h> 13#include <linux/mbus.h>
14#include <linux/io.h>
14#include <mach/hardware.h> 15#include <mach/hardware.h>
15#include <asm/io.h>
16#include "common.h" 16#include "common.h"
17#include "mpp.h" 17#include "mpp.h"
18 18
diff --git a/arch/arm/mach-orion5x/mss2-setup.c b/arch/arm/mach-orion5x/mss2-setup.c
index 53ff1893b883..68acca98e638 100644
--- a/arch/arm/mach-orion5x/mss2-setup.c
+++ b/arch/arm/mach-orion5x/mss2-setup.c
@@ -109,7 +109,7 @@ subsys_initcall(mss2_pci_init);
109 ****************************************************************************/ 109 ****************************************************************************/
110 110
111static struct mv643xx_eth_platform_data mss2_eth_data = { 111static struct mv643xx_eth_platform_data mss2_eth_data = {
112 .phy_addr = 8, 112 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
113}; 113};
114 114
115/***************************************************************************** 115/*****************************************************************************
diff --git a/arch/arm/mach-orion5x/mv2120-setup.c b/arch/arm/mach-orion5x/mv2120-setup.c
index 978d4d599396..97c9ccb2ac60 100644
--- a/arch/arm/mach-orion5x/mv2120-setup.c
+++ b/arch/arm/mach-orion5x/mv2120-setup.c
@@ -39,7 +39,7 @@
39 * Ethernet 39 * Ethernet
40 ****************************************************************************/ 40 ****************************************************************************/
41static struct mv643xx_eth_platform_data mv2120_eth_data = { 41static struct mv643xx_eth_platform_data mv2120_eth_data = {
42 .phy_addr = 8, 42 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
43}; 43};
44 44
45static struct mv_sata_platform_data mv2120_sata_data = { 45static struct mv_sata_platform_data mv2120_sata_data = {
diff --git a/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c b/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
index e72fe1e065e8..500cdadaf09c 100644
--- a/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
@@ -88,7 +88,7 @@ static struct orion5x_mpp_mode rd88f5181l_fxo_mpp_modes[] __initdata = {
88}; 88};
89 89
90static struct mv643xx_eth_platform_data rd88f5181l_fxo_eth_data = { 90static struct mv643xx_eth_platform_data rd88f5181l_fxo_eth_data = {
91 .phy_addr = -1, 91 .phy_addr = MV643XX_ETH_PHY_NONE,
92 .speed = SPEED_1000, 92 .speed = SPEED_1000,
93 .duplex = DUPLEX_FULL, 93 .duplex = DUPLEX_FULL,
94}; 94};
diff --git a/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c b/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
index a1fe3257320d..ebde81416499 100644
--- a/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
@@ -89,7 +89,7 @@ static struct orion5x_mpp_mode rd88f5181l_ge_mpp_modes[] __initdata = {
89}; 89};
90 90
91static struct mv643xx_eth_platform_data rd88f5181l_ge_eth_data = { 91static struct mv643xx_eth_platform_data rd88f5181l_ge_eth_data = {
92 .phy_addr = -1, 92 .phy_addr = MV643XX_ETH_PHY_NONE,
93 .speed = SPEED_1000, 93 .speed = SPEED_1000,
94 .duplex = DUPLEX_FULL, 94 .duplex = DUPLEX_FULL,
95}; 95};
diff --git a/arch/arm/mach-orion5x/rd88f5182-setup.c b/arch/arm/mach-orion5x/rd88f5182-setup.c
index 4c3bcd76ac85..a04f9e4b633a 100644
--- a/arch/arm/mach-orion5x/rd88f5182-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5182-setup.c
@@ -221,7 +221,7 @@ subsys_initcall(rd88f5182_pci_init);
221 ****************************************************************************/ 221 ****************************************************************************/
222 222
223static struct mv643xx_eth_platform_data rd88f5182_eth_data = { 223static struct mv643xx_eth_platform_data rd88f5182_eth_data = {
224 .phy_addr = 8, 224 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
225}; 225};
226 226
227/***************************************************************************** 227/*****************************************************************************
diff --git a/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c b/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
new file mode 100644
index 000000000000..40e049539091
--- /dev/null
+++ b/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
@@ -0,0 +1,117 @@
1/*
2 * arch/arm/mach-orion5x/rd88f6183-ap-ge-setup.c
3 *
4 * Marvell Orion-1-90 AP GE Reference Design Setup
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/pci.h>
15#include <linux/irq.h>
16#include <linux/mtd/physmap.h>
17#include <linux/mv643xx_eth.h>
18#include <linux/spi/spi.h>
19#include <linux/spi/orion_spi.h>
20#include <linux/spi/flash.h>
21#include <linux/ethtool.h>
22#include <asm/mach-types.h>
23#include <asm/gpio.h>
24#include <asm/leds.h>
25#include <asm/mach/arch.h>
26#include <asm/mach/pci.h>
27#include <mach/orion5x.h>
28#include "common.h"
29#include "mpp.h"
30
31static struct mv643xx_eth_platform_data rd88f6183ap_ge_eth_data = {
32 .phy_addr = -1,
33 .speed = SPEED_1000,
34 .duplex = DUPLEX_FULL,
35};
36
37static struct mtd_partition rd88f6183ap_ge_partitions[] = {
38 {
39 .name = "kernel",
40 .offset = 0x00000000,
41 .size = 0x00200000,
42 }, {
43 .name = "rootfs",
44 .offset = 0x00200000,
45 .size = 0x00500000,
46 }, {
47 .name = "nvram",
48 .offset = 0x00700000,
49 .size = 0x00080000,
50 },
51};
52
53static struct flash_platform_data rd88f6183ap_ge_spi_slave_data = {
54 .type = "m25p64",
55 .nr_parts = ARRAY_SIZE(rd88f6183ap_ge_partitions),
56 .parts = rd88f6183ap_ge_partitions,
57};
58
59static struct spi_board_info __initdata rd88f6183ap_ge_spi_slave_info[] = {
60 {
61 .modalias = "m25p80",
62 .platform_data = &rd88f6183ap_ge_spi_slave_data,
63 .irq = NO_IRQ,
64 .max_speed_hz = 20000000,
65 .bus_num = 0,
66 .chip_select = 0,
67 },
68};
69
70static void __init rd88f6183ap_ge_init(void)
71{
72 /*
73 * Setup basic Orion functions. Need to be called early.
74 */
75 orion5x_init();
76
77 /*
78 * Configure peripherals.
79 */
80 orion5x_ehci0_init();
81 orion5x_eth_init(&rd88f6183ap_ge_eth_data);
82 spi_register_board_info(rd88f6183ap_ge_spi_slave_info,
83 ARRAY_SIZE(rd88f6183ap_ge_spi_slave_info));
84 orion5x_spi_init();
85 orion5x_uart0_init();
86}
87
88static struct hw_pci rd88f6183ap_ge_pci __initdata = {
89 .nr_controllers = 2,
90 .swizzle = pci_std_swizzle,
91 .setup = orion5x_pci_sys_setup,
92 .scan = orion5x_pci_sys_scan_bus,
93 .map_irq = orion5x_pci_map_irq,
94};
95
96static int __init rd88f6183ap_ge_pci_init(void)
97{
98 if (machine_is_rd88f6183ap_ge()) {
99 orion5x_pci_disable();
100 pci_common_init(&rd88f6183ap_ge_pci);
101 }
102
103 return 0;
104}
105subsys_initcall(rd88f6183ap_ge_pci_init);
106
107MACHINE_START(RD88F6183AP_GE, "Marvell Orion-1-90 AP GE Reference Design")
108 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
109 .phys_io = ORION5X_REGS_PHYS_BASE,
110 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
111 .boot_params = 0x00000100,
112 .init_machine = rd88f6183ap_ge_init,
113 .map_io = orion5x_map_io,
114 .init_irq = orion5x_init_irq,
115 .timer = &orion5x_timer,
116 .fixup = tag_fixup_mem32,
117MACHINE_END
diff --git a/arch/arm/mach-orion5x/terastation_pro2-setup.c b/arch/arm/mach-orion5x/terastation_pro2-setup.c
new file mode 100644
index 000000000000..0b101d7d41c2
--- /dev/null
+++ b/arch/arm/mach-orion5x/terastation_pro2-setup.c
@@ -0,0 +1,369 @@
1/*
2 * Buffalo Terastation Pro II/Live Board Setup
3 *
4 * Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/pci.h>
16#include <linux/irq.h>
17#include <linux/delay.h>
18#include <linux/mtd/physmap.h>
19#include <linux/mv643xx_eth.h>
20#include <linux/i2c.h>
21#include <linux/serial_reg.h>
22#include <asm/mach-types.h>
23#include <asm/gpio.h>
24#include <asm/mach/arch.h>
25#include <asm/mach/pci.h>
26#include <mach/orion5x.h>
27#include "common.h"
28#include "mpp.h"
29
30/*****************************************************************************
31 * Terastation Pro 2/Live Info
32 ****************************************************************************/
33
34/*
35 * Terastation Pro 2 hardware :
36 * - Marvell 88F5281-D0
37 * - Marvell 88SX6042 SATA controller (PCI)
38 * - Marvell 88E1118 Gigabit Ethernet PHY
39 * - 256KB NOR flash
40 * - 128MB of DDR RAM
41 * - PCIe port (not equipped)
42 */
43
44/*
45 * 256K NOR flash Device bus boot chip select
46 */
47
48#define TSP2_NOR_BOOT_BASE 0xf4000000
49#define TSP2_NOR_BOOT_SIZE SZ_256K
50
51/*****************************************************************************
52 * 256KB NOR Flash on BOOT Device
53 ****************************************************************************/
54
55static struct physmap_flash_data tsp2_nor_flash_data = {
56 .width = 1,
57};
58
59static struct resource tsp2_nor_flash_resource = {
60 .flags = IORESOURCE_MEM,
61 .start = TSP2_NOR_BOOT_BASE,
62 .end = TSP2_NOR_BOOT_BASE + TSP2_NOR_BOOT_SIZE - 1,
63};
64
65static struct platform_device tsp2_nor_flash = {
66 .name = "physmap-flash",
67 .id = 0,
68 .dev = {
69 .platform_data = &tsp2_nor_flash_data,
70 },
71 .num_resources = 1,
72 .resource = &tsp2_nor_flash_resource,
73};
74
75/*****************************************************************************
76 * PCI
77 ****************************************************************************/
78#define TSP2_PCI_SLOT0_OFFS 7
79#define TSP2_PCI_SLOT0_IRQ_PIN 11
80
81void __init tsp2_pci_preinit(void)
82{
83 int pin;
84
85 /*
86 * Configure PCI GPIO IRQ pins
87 */
88 pin = TSP2_PCI_SLOT0_IRQ_PIN;
89 if (gpio_request(pin, "PCI Int1") == 0) {
90 if (gpio_direction_input(pin) == 0) {
91 set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
92 } else {
93 printk(KERN_ERR "tsp2_pci_preinit failed "
94 "to set_irq_type pin %d\n", pin);
95 gpio_free(pin);
96 }
97 } else {
98 printk(KERN_ERR "tsp2_pci_preinit failed to "
99 "gpio_request %d\n", pin);
100 }
101}
102
103static int __init tsp2_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
104{
105 int irq;
106
107 /*
108 * Check for devices with hard-wired IRQs.
109 */
110 irq = orion5x_pci_map_irq(dev, slot, pin);
111 if (irq != -1)
112 return irq;
113
114 /*
115 * PCI IRQs are connected via GPIOs.
116 */
117 if (slot == TSP2_PCI_SLOT0_OFFS)
118 return gpio_to_irq(TSP2_PCI_SLOT0_IRQ_PIN);
119
120 return -1;
121}
122
123static struct hw_pci tsp2_pci __initdata = {
124 .nr_controllers = 2,
125 .preinit = tsp2_pci_preinit,
126 .swizzle = pci_std_swizzle,
127 .setup = orion5x_pci_sys_setup,
128 .scan = orion5x_pci_sys_scan_bus,
129 .map_irq = tsp2_pci_map_irq,
130};
131
132static int __init tsp2_pci_init(void)
133{
134 if (machine_is_terastation_pro2())
135 pci_common_init(&tsp2_pci);
136
137 return 0;
138}
139
140subsys_initcall(tsp2_pci_init);
141
142/*****************************************************************************
143 * Ethernet
144 ****************************************************************************/
145
146static struct mv643xx_eth_platform_data tsp2_eth_data = {
147 .phy_addr = 0,
148};
149
150/*****************************************************************************
151 * RTC 5C372a on I2C bus
152 ****************************************************************************/
153
154#define TSP2_RTC_GPIO 9
155
156static struct i2c_board_info __initdata tsp2_i2c_rtc = {
157 I2C_BOARD_INFO("rs5c372a", 0x32),
158};
159
160/*****************************************************************************
161 * Terastation Pro II specific power off method via UART1-attached
162 * microcontroller
163 ****************************************************************************/
164
165#define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
166
167static int tsp2_miconread(unsigned char *buf, int count)
168{
169 int i;
170 int timeout;
171
172 for (i = 0; i < count; i++) {
173 timeout = 10;
174
175 while (!(readl(UART1_REG(LSR)) & UART_LSR_DR)) {
176 if (--timeout == 0)
177 break;
178 udelay(1000);
179 }
180
181 if (timeout == 0)
182 break;
183 buf[i] = readl(UART1_REG(RX));
184 }
185
186 /* return read bytes */
187 return i;
188}
189
190static int tsp2_miconwrite(const unsigned char *buf, int count)
191{
192 int i = 0;
193
194 while (count--) {
195 while (!(readl(UART1_REG(LSR)) & UART_LSR_THRE))
196 barrier();
197 writel(buf[i++], UART1_REG(TX));
198 }
199
200 return 0;
201}
202
203static int tsp2_miconsend(const unsigned char *data, int count)
204{
205 int i;
206 unsigned char checksum = 0;
207 unsigned char recv_buf[40];
208 unsigned char send_buf[40];
209 unsigned char correct_ack[3];
210 int retry = 2;
211
212 /* Generate checksum */
213 for (i = 0; i < count; i++)
214 checksum -= data[i];
215
216 do {
217 /* Send data */
218 tsp2_miconwrite(data, count);
219
220 /* send checksum */
221 tsp2_miconwrite(&checksum, 1);
222
223 if (tsp2_miconread(recv_buf, sizeof(recv_buf)) <= 3) {
224 printk(KERN_ERR ">%s: receive failed.\n", __func__);
225
226 /* send preamble to clear the receive buffer */
227 memset(&send_buf, 0xff, sizeof(send_buf));
228 tsp2_miconwrite(send_buf, sizeof(send_buf));
229
230 /* make dummy reads */
231 mdelay(100);
232 tsp2_miconread(recv_buf, sizeof(recv_buf));
233 } else {
234 /* Generate expected ack */
235 correct_ack[0] = 0x01;
236 correct_ack[1] = data[1];
237 correct_ack[2] = 0x00;
238
239 /* checksum Check */
240 if ((recv_buf[0] + recv_buf[1] + recv_buf[2] +
241 recv_buf[3]) & 0xFF) {
242 printk(KERN_ERR ">%s: Checksum Error : "
243 "Received data[%02x, %02x, %02x, %02x]"
244 "\n", __func__, recv_buf[0],
245 recv_buf[1], recv_buf[2], recv_buf[3]);
246 } else {
247 /* Check Received Data */
248 if (correct_ack[0] == recv_buf[0] &&
249 correct_ack[1] == recv_buf[1] &&
250 correct_ack[2] == recv_buf[2]) {
251 /* Interval for next command */
252 mdelay(10);
253
254 /* Receive ACK */
255 return 0;
256 }
257 }
258 /* Received NAK or illegal Data */
259 printk(KERN_ERR ">%s: Error : NAK or Illegal Data "
260 "Received\n", __func__);
261 }
262 } while (retry--);
263
264 /* Interval for next command */
265 mdelay(10);
266
267 return -1;
268}
269
270static void tsp2_power_off(void)
271{
272 const unsigned char watchdogkill[] = {0x01, 0x35, 0x00};
273 const unsigned char shutdownwait[] = {0x00, 0x0c};
274 const unsigned char poweroff[] = {0x00, 0x06};
275 /* 38400 baud divisor */
276 const unsigned divisor = ((orion5x_tclk + (8 * 38400)) / (16 * 38400));
277
278 pr_info("%s: triggering power-off...\n", __func__);
279
280 /* hijack uart1 and reset into sane state (38400,8n1,even parity) */
281 writel(0x83, UART1_REG(LCR));
282 writel(divisor & 0xff, UART1_REG(DLL));
283 writel((divisor >> 8) & 0xff, UART1_REG(DLM));
284 writel(0x1b, UART1_REG(LCR));
285 writel(0x00, UART1_REG(IER));
286 writel(0x07, UART1_REG(FCR));
287 writel(0x00, UART1_REG(MCR));
288
289 /* Send the commands to shutdown the Terastation Pro II */
290 tsp2_miconsend(watchdogkill, sizeof(watchdogkill)) ;
291 tsp2_miconsend(shutdownwait, sizeof(shutdownwait)) ;
292 tsp2_miconsend(poweroff, sizeof(poweroff));
293}
294
295/*****************************************************************************
296 * General Setup
297 ****************************************************************************/
298static struct orion5x_mpp_mode tsp2_mpp_modes[] __initdata = {
299 { 0, MPP_PCIE_RST_OUTn },
300 { 1, MPP_UNUSED },
301 { 2, MPP_UNUSED },
302 { 3, MPP_UNUSED },
303 { 4, MPP_NAND }, /* BOOT NAND Flash REn */
304 { 5, MPP_NAND }, /* BOOT NAND Flash WEn */
305 { 6, MPP_NAND }, /* BOOT NAND Flash HREn[0] */
306 { 7, MPP_NAND }, /* BOOT NAND Flash WEn[0] */
307 { 8, MPP_GPIO }, /* MICON int */
308 { 9, MPP_GPIO }, /* RTC int */
309 { 10, MPP_UNUSED },
310 { 11, MPP_GPIO }, /* PCI Int A */
311 { 12, MPP_UNUSED },
312 { 13, MPP_GPIO }, /* UPS on UART0 enable */
313 { 14, MPP_GPIO }, /* UPS low battery detection */
314 { 15, MPP_UNUSED },
315 { 16, MPP_UART }, /* UART1 RXD */
316 { 17, MPP_UART }, /* UART1 TXD */
317 { 18, MPP_UART }, /* UART1 CTSn */
318 { 19, MPP_UART }, /* UART1 RTSn */
319 { -1 },
320};
321
322static void __init tsp2_init(void)
323{
324 /*
325 * Setup basic Orion functions. Need to be called early.
326 */
327 orion5x_init();
328
329 orion5x_mpp_conf(tsp2_mpp_modes);
330
331 /*
332 * Configure peripherals.
333 */
334 orion5x_setup_dev_boot_win(TSP2_NOR_BOOT_BASE,
335 TSP2_NOR_BOOT_SIZE);
336 platform_device_register(&tsp2_nor_flash);
337
338 orion5x_ehci0_init();
339 orion5x_eth_init(&tsp2_eth_data);
340 orion5x_i2c_init();
341 orion5x_uart0_init();
342 orion5x_uart1_init();
343
344 /* Get RTC IRQ and register the chip */
345 if (gpio_request(TSP2_RTC_GPIO, "rtc") == 0) {
346 if (gpio_direction_input(TSP2_RTC_GPIO) == 0)
347 tsp2_i2c_rtc.irq = gpio_to_irq(TSP2_RTC_GPIO);
348 else
349 gpio_free(TSP2_RTC_GPIO);
350 }
351 if (tsp2_i2c_rtc.irq == 0)
352 pr_warning("tsp2_init: failed to get RTC IRQ\n");
353 i2c_register_board_info(0, &tsp2_i2c_rtc, 1);
354
355 /* register Terastation Pro II specific power-off method */
356 pm_power_off = tsp2_power_off;
357}
358
359MACHINE_START(TERASTATION_PRO2, "Buffalo Terastation Pro II/Live")
360 /* Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com> */
361 .phys_io = ORION5X_REGS_PHYS_BASE,
362 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
363 .boot_params = 0x00000100,
364 .init_machine = tsp2_init,
365 .map_io = orion5x_map_io,
366 .init_irq = orion5x_init_irq,
367 .timer = &orion5x_timer,
368 .fixup = tag_fixup_mem32,
369MACHINE_END
diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c
index ae0a5dccd2a1..1368e9fd1a06 100644
--- a/arch/arm/mach-orion5x/ts78xx-setup.c
+++ b/arch/arm/mach-orion5x/ts78xx-setup.c
@@ -103,8 +103,7 @@ static struct platform_device ts78xx_nor_boot_flash = {
103 * Ethernet 103 * Ethernet
104 ****************************************************************************/ 104 ****************************************************************************/
105static struct mv643xx_eth_platform_data ts78xx_eth_data = { 105static struct mv643xx_eth_platform_data ts78xx_eth_data = {
106 .phy_addr = 0, 106 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
107 .force_phy_addr = 1,
108}; 107};
109 108
110/***************************************************************************** 109/*****************************************************************************
diff --git a/arch/arm/mach-orion5x/tsx09-common.c b/arch/arm/mach-orion5x/tsx09-common.c
index 83feac3147a6..c9abb8fbfa70 100644
--- a/arch/arm/mach-orion5x/tsx09-common.c
+++ b/arch/arm/mach-orion5x/tsx09-common.c
@@ -16,6 +16,7 @@
16#include <linux/timex.h> 16#include <linux/timex.h>
17#include <linux/serial_reg.h> 17#include <linux/serial_reg.h>
18#include "tsx09-common.h" 18#include "tsx09-common.h"
19#include "common.h"
19 20
20/***************************************************************************** 21/*****************************************************************************
21 * QNAP TS-x09 specific power off method via UART1-attached PIC 22 * QNAP TS-x09 specific power off method via UART1-attached PIC
@@ -26,7 +27,7 @@
26void qnap_tsx09_power_off(void) 27void qnap_tsx09_power_off(void)
27{ 28{
28 /* 19200 baud divisor */ 29 /* 19200 baud divisor */
29 const unsigned divisor = ((ORION5X_TCLK + (8 * 19200)) / (16 * 19200)); 30 const unsigned divisor = ((orion5x_tclk + (8 * 19200)) / (16 * 19200));
30 31
31 pr_info("%s: triggering power-off...\n", __func__); 32 pr_info("%s: triggering power-off...\n", __func__);
32 33
@@ -48,7 +49,7 @@ void qnap_tsx09_power_off(void)
48 ****************************************************************************/ 49 ****************************************************************************/
49 50
50struct mv643xx_eth_platform_data qnap_tsx09_eth_data = { 51struct mv643xx_eth_platform_data qnap_tsx09_eth_data = {
51 .phy_addr = 8, 52 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
52}; 53};
53 54
54static int __init qnap_tsx09_parse_hex_nibble(char n) 55static int __init qnap_tsx09_parse_hex_nibble(char n)
diff --git a/arch/arm/mach-orion5x/wnr854t-setup.c b/arch/arm/mach-orion5x/wnr854t-setup.c
index b6bc43e07eed..7ddc22c2bb54 100644
--- a/arch/arm/mach-orion5x/wnr854t-setup.c
+++ b/arch/arm/mach-orion5x/wnr854t-setup.c
@@ -92,7 +92,7 @@ static struct platform_device wnr854t_nor_flash = {
92}; 92};
93 93
94static struct mv643xx_eth_platform_data wnr854t_eth_data = { 94static struct mv643xx_eth_platform_data wnr854t_eth_data = {
95 .phy_addr = -1, 95 .phy_addr = MV643XX_ETH_PHY_NONE,
96 .speed = SPEED_1000, 96 .speed = SPEED_1000,
97 .duplex = DUPLEX_FULL, 97 .duplex = DUPLEX_FULL,
98}; 98};
diff --git a/arch/arm/mach-orion5x/wrt350n-v2-setup.c b/arch/arm/mach-orion5x/wrt350n-v2-setup.c
index b10da17b3fbd..9a4fd5256462 100644
--- a/arch/arm/mach-orion5x/wrt350n-v2-setup.c
+++ b/arch/arm/mach-orion5x/wrt350n-v2-setup.c
@@ -100,7 +100,7 @@ static struct platform_device wrt350n_v2_nor_flash = {
100}; 100};
101 101
102static struct mv643xx_eth_platform_data wrt350n_v2_eth_data = { 102static struct mv643xx_eth_platform_data wrt350n_v2_eth_data = {
103 .phy_addr = -1, 103 .phy_addr = MV643XX_ETH_PHY_NONE,
104 .speed = SPEED_1000, 104 .speed = SPEED_1000,
105 .duplex = DUPLEX_FULL, 105 .duplex = DUPLEX_FULL,
106}; 106};
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c
index 24d036a24a72..898c0e88acbc 100644
--- a/arch/arm/mach-pnx4008/clock.c
+++ b/arch/arm/mach-pnx4008/clock.c
@@ -20,9 +20,9 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/io.h>
23 24
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/io.h>
26 26
27#include <mach/clock.h> 27#include <mach/clock.h>
28#include "clock.h" 28#include "clock.h"
diff --git a/arch/arm/mach-pnx4008/core.c b/arch/arm/mach-pnx4008/core.c
index 3ba46ede9bbd..45734bb880a8 100644
--- a/arch/arm/mach-pnx4008/core.c
+++ b/arch/arm/mach-pnx4008/core.c
@@ -25,9 +25,9 @@
25#include <linux/serial_8250.h> 25#include <linux/serial_8250.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/io.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/io.h>
31#include <asm/setup.h> 31#include <asm/setup.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33#include <asm/pgtable.h> 33#include <asm/pgtable.h>
diff --git a/arch/arm/mach-pnx4008/dma.c b/arch/arm/mach-pnx4008/dma.c
index 833c56be7344..ac2f70eddb9e 100644
--- a/arch/arm/mach-pnx4008/dma.c
+++ b/arch/arm/mach-pnx4008/dma.c
@@ -21,12 +21,12 @@
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/dma-mapping.h> 22#include <linux/dma-mapping.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/io.h>
24 25
25#include <asm/system.h> 26#include <asm/system.h>
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/dma.h> 28#include <asm/dma.h>
28#include <asm/dma-mapping.h> 29#include <asm/dma-mapping.h>
29#include <asm/io.h>
30#include <asm/mach/dma.h> 30#include <asm/mach/dma.h>
31#include <mach/clock.h> 31#include <mach/clock.h>
32 32
diff --git a/arch/arm/mach-pnx4008/gpio.c b/arch/arm/mach-pnx4008/gpio.c
index fb51f7279e95..015cc21d5f55 100644
--- a/arch/arm/mach-pnx4008/gpio.c
+++ b/arch/arm/mach-pnx4008/gpio.c
@@ -17,7 +17,7 @@
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <asm/io.h> 20#include <linux/io.h>
21#include <mach/platform.h> 21#include <mach/platform.h>
22#include <mach/gpio.h> 22#include <mach/gpio.h>
23 23
diff --git a/arch/arm/mach-pnx4008/include/mach/system.h b/arch/arm/mach-pnx4008/include/mach/system.h
index 8985a4622b8c..e12e7abfcbcf 100644
--- a/arch/arm/mach-pnx4008/include/mach/system.h
+++ b/arch/arm/mach-pnx4008/include/mach/system.h
@@ -21,8 +21,8 @@
21#ifndef __ASM_ARCH_SYSTEM_H 21#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H 22#define __ASM_ARCH_SYSTEM_H
23 23
24#include <linux/io.h>
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/io.h>
26#include <mach/platform.h> 26#include <mach/platform.h>
27 27
28static void arch_idle(void) 28static void arch_idle(void)
diff --git a/arch/arm/mach-pnx4008/include/mach/timex.h b/arch/arm/mach-pnx4008/include/mach/timex.h
index 956fbd8e977c..5ff0196c0f16 100644
--- a/arch/arm/mach-pnx4008/include/mach/timex.h
+++ b/arch/arm/mach-pnx4008/include/mach/timex.h
@@ -14,8 +14,8 @@
14#ifndef __PNX4008_TIMEX_H 14#ifndef __PNX4008_TIMEX_H
15#define __PNX4008_TIMEX_H 15#define __PNX4008_TIMEX_H
16 16
17#include <linux/io.h>
17#include <mach/hardware.h> 18#include <mach/hardware.h>
18#include <asm/io.h>
19 19
20#define CLOCK_TICK_RATE 1000000 20#define CLOCK_TICK_RATE 1000000
21 21
diff --git a/arch/arm/mach-pnx4008/irq.c b/arch/arm/mach-pnx4008/irq.c
index 5c4f55af5d4b..a9ce02b4bf17 100644
--- a/arch/arm/mach-pnx4008/irq.c
+++ b/arch/arm/mach-pnx4008/irq.c
@@ -23,8 +23,8 @@
23#include <linux/ioport.h> 23#include <linux/ioport.h>
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/irq.h> 25#include <linux/irq.h>
26#include <linux/io.h>
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <asm/io.h>
28#include <asm/setup.h> 28#include <asm/setup.h>
29#include <asm/pgtable.h> 29#include <asm/pgtable.h>
30#include <asm/page.h> 30#include <asm/page.h>
diff --git a/arch/arm/mach-pnx4008/pm.c b/arch/arm/mach-pnx4008/pm.c
index f970906d8848..b3d8d53e32ef 100644
--- a/arch/arm/mach-pnx4008/pm.c
+++ b/arch/arm/mach-pnx4008/pm.c
@@ -18,8 +18,8 @@
18#include <linux/suspend.h> 18#include <linux/suspend.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/io.h>
21 22
22#include <asm/io.h>
23#include <asm/cacheflush.h> 23#include <asm/cacheflush.h>
24#include <mach/pm.h> 24#include <mach/pm.h>
25#include <mach/clock.h> 25#include <mach/clock.h>
diff --git a/arch/arm/mach-pnx4008/serial.c b/arch/arm/mach-pnx4008/serial.c
index 9be84bbb30e8..f40961e51914 100644
--- a/arch/arm/mach-pnx4008/serial.c
+++ b/arch/arm/mach-pnx4008/serial.c
@@ -12,8 +12,7 @@
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/types.h> 14#include <linux/types.h>
15 15#include <linux/io.h>
16#include <asm/io.h>
17 16
18#include <mach/platform.h> 17#include <mach/platform.h>
19#include <mach/hardware.h> 18#include <mach/hardware.h>
diff --git a/arch/arm/mach-pnx4008/time.c b/arch/arm/mach-pnx4008/time.c
index 180975244f96..fc0ba183fe12 100644
--- a/arch/arm/mach-pnx4008/time.c
+++ b/arch/arm/mach-pnx4008/time.c
@@ -22,10 +22,10 @@
22#include <linux/time.h> 22#include <linux/time.h>
23#include <linux/timex.h> 23#include <linux/timex.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/io.h>
25 26
26#include <asm/system.h> 27#include <asm/system.h>
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/leds.h> 29#include <asm/leds.h>
30#include <asm/mach/time.h> 30#include <asm/mach/time.h>
31#include <asm/errno.h> 31#include <asm/errno.h>
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index e8ee7ec9ff6d..f27f6b3d6e6f 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -38,16 +38,23 @@ config ARCH_LUBBOCK
38 bool "Intel DBPXA250 Development Platform" 38 bool "Intel DBPXA250 Development Platform"
39 select PXA25x 39 select PXA25x
40 select SA1111 40 select SA1111
41 select PXA_HAVE_BOARD_IRQS
41 42
42config MACH_LOGICPD_PXA270 43config MACH_LOGICPD_PXA270
43 bool "LogicPD PXA270 Card Engine Development Platform" 44 bool "LogicPD PXA270 Card Engine Development Platform"
44 select PXA27x 45 select PXA27x
45 select HAVE_PWM 46 select HAVE_PWM
47 select PXA_HAVE_BOARD_IRQS
46 48
47config MACH_MAINSTONE 49config MACH_MAINSTONE
48 bool "Intel HCDDBBVA0 Development Platform" 50 bool "Intel HCDDBBVA0 Development Platform"
49 select PXA27x 51 select PXA27x
50 select HAVE_PWM 52 select HAVE_PWM
53 select PXA_HAVE_BOARD_IRQS
54
55config MACH_MP900C
56 bool "Nec Mobilepro 900/c"
57 select PXA25x
51 58
52config ARCH_PXA_IDP 59config ARCH_PXA_IDP
53 bool "Accelent Xscale IDP" 60 bool "Accelent Xscale IDP"
@@ -114,10 +121,21 @@ config MACH_TOSA
114 bool "Enable Sharp SL-6000x (Tosa) Support" 121 bool "Enable Sharp SL-6000x (Tosa) Support"
115 depends on PXA_SHARPSL 122 depends on PXA_SHARPSL
116 select PXA25x 123 select PXA25x
124 select PXA_HAVE_BOARD_IRQS
125
126config ARCH_VIPER
127 bool "Arcom/Eurotech VIPER SBC"
128 select PXA25x
129 select ISA
130 select I2C_GPIO
131 select HAVE_PWM
132 select PXA_HAVE_BOARD_IRQS
133 select PXA_HAVE_ISA_IRQS
117 134
118config ARCH_PXA_ESERIES 135config ARCH_PXA_ESERIES
119 bool "PXA based Toshiba e-series PDAs" 136 bool "PXA based Toshiba e-series PDAs"
120 select PXA25x 137 select PXA25x
138 select PXA_HAVE_BOARD_IRQS
121 139
122config MACH_E330 140config MACH_E330
123 bool "Toshiba e330" 141 bool "Toshiba e330"
@@ -170,13 +188,41 @@ config MACH_E800
170 Say Y here if you intend to run this kernel on a Toshiba 188 Say Y here if you intend to run this kernel on a Toshiba
171 e800 family PDA. 189 e800 family PDA.
172 190
191config TRIZEPS_PXA
192 bool "PXA based Keith und Koep Trizeps DIMM-Modules"
193
173config MACH_TRIZEPS4 194config MACH_TRIZEPS4
174 bool "Keith und Koep Trizeps4 DIMM-Module" 195 bool "Keith und Koep Trizeps4 DIMM-Module"
196 depends on TRIZEPS_PXA
197 select TRIZEPS_PCMCIA
175 select PXA27x 198 select PXA27x
176 199
177config MACH_TRIZEPS4_CONXS 200config MACH_TRIZEPS4WL
201 bool "Keith und Koep Trizeps4-WL DIMM-Module"
202 depends on TRIZEPS_PXA
203 select TRIZEPS_PCMCIA
204 select PXA27x
205 select PXA_SSP
206
207choice
208 prompt "Select base board for Trizeps module"
209 depends on TRIZEPS_PXA
210
211config MACH_TRIZEPS_CONXS
178 bool "ConXS Eval Board" 212 bool "ConXS Eval Board"
179 depends on MACH_TRIZEPS4 213
214config MACH_TRIZEPS_UCONXS
215 bool "uConXS Eval Board"
216
217config MACH_TRIZEPS_ANY
218 bool "another Board"
219
220endchoice
221
222config TRIZEPS_PCMCIA
223 bool
224 help
225 Enable PCMCIA support for Trizeps modules
180 226
181config MACH_EM_X270 227config MACH_EM_X270
182 bool "CompuLab EM-x270 platform" 228 bool "CompuLab EM-x270 platform"
@@ -189,6 +235,7 @@ config MACH_COLIBRI
189config MACH_ZYLONITE 235config MACH_ZYLONITE
190 bool "PXA3xx Development Platform (aka Zylonite)" 236 bool "PXA3xx Development Platform (aka Zylonite)"
191 select PXA3xx 237 select PXA3xx
238 select PXA_SSP
192 select HAVE_PWM 239 select HAVE_PWM
193 240
194config MACH_LITTLETON 241config MACH_LITTLETON
@@ -207,20 +254,42 @@ config MACH_SAAR
207 select PXA930 254 select PXA930
208 255
209config MACH_ARMCORE 256config MACH_ARMCORE
210 bool "CompuLab CM-X270 modules" 257 bool "CompuLab CM-X255/CM-X270 modules"
211 select PXA27x 258 select PXA27x
212 select IWMMXT 259 select IWMMXT
260 select ZONE_DMA if PCI
261 select PXA25x
262 select PXA_SSP
263
264config MACH_CM_X300
265 bool "CompuLab CM-X300 modules"
266 select PXA3xx
267 select CPU_PXA300
213 268
214config MACH_MAGICIAN 269config MACH_MAGICIAN
215 bool "Enable HTC Magician Support" 270 bool "Enable HTC Magician Support"
216 select PXA27x 271 select PXA27x
217 select IWMMXT 272 select IWMMXT
273 select PXA_HAVE_BOARD_IRQS
274
275config MACH_MIOA701
276 bool "Mitac Mio A701 Support"
277 select PXA27x
278 select IWMMXT
279 select LEDS_GPIO
280 select HAVE_PWM
281 select GPIO_SYSFS
282 help
283 Say Y here if you intend to run this kernel on a
284 MIO A701. Currently there is only basic support
285 for this PDA.
218 286
219config MACH_PCM027 287config MACH_PCM027
220 bool "Phytec phyCORE-PXA270 CPU module (PCM-027)" 288 bool "Phytec phyCORE-PXA270 CPU module (PCM-027)"
221 select PXA27x 289 select PXA27x
222 select IWMMXT 290 select IWMMXT
223 select PXA_SSP 291 select PXA_SSP
292 select PXA_HAVE_BOARD_IRQS
224 293
225config ARCH_PXA_PALM 294config ARCH_PXA_PALM
226 bool "PXA based Palm PDAs" 295 bool "PXA based Palm PDAs"
@@ -236,6 +305,16 @@ config MACH_PALMTX
236 Say Y here if you intend to run this kernel on a Palm T|X 305 Say Y here if you intend to run this kernel on a Palm T|X
237 handheld computer. 306 handheld computer.
238 307
308config MACH_PALMZ72
309 bool "Palm Zire 72"
310 default y
311 depends on ARCH_PXA_PALM
312 select PXA27x
313 select IWMMXT
314 help
315 Say Y here if you intend to run this kernel on Palm Zire 72
316 handheld computer.
317
239config MACH_PCM990_BASEBOARD 318config MACH_PCM990_BASEBOARD
240 bool "PHYTEC PCM-990 development board" 319 bool "PHYTEC PCM-990 development board"
241 select HAVE_PWM 320 select HAVE_PWM
@@ -256,6 +335,9 @@ config PCM990_DISPLAY_NONE
256 335
257endchoice 336endchoice
258 337
338config MACH_AM200EPD
339 depends on MACH_GUMSTIX_F
340 bool "Enable AM200EPD board support"
259 341
260config PXA_EZX 342config PXA_EZX
261 bool "Motorola EZX Platform" 343 bool "Motorola EZX Platform"
@@ -343,4 +425,10 @@ config TOSA_BT
343 This is a simple driver that is able to control 425 This is a simple driver that is able to control
344 the state of built in bluetooth chip on tosa. 426 the state of built in bluetooth chip on tosa.
345 427
428config PXA_HAVE_BOARD_IRQS
429 bool
430
431config PXA_HAVE_ISA_IRQS
432 bool
433
346endif 434endif
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 99ecbe7f8506..d31c9979cfa3 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -6,7 +6,12 @@
6obj-y += clock.o devices.o generic.o irq.o dma.o \ 6obj-y += clock.o devices.o generic.o irq.o dma.o \
7 time.o gpio.o reset.o 7 time.o gpio.o reset.o
8obj-$(CONFIG_PM) += pm.o sleep.o standby.o 8obj-$(CONFIG_PM) += pm.o sleep.o standby.o
9obj-$(CONFIG_CPU_FREQ) += cpu-pxa.o 9
10ifeq ($(CONFIG_CPU_FREQ),y)
11obj-$(CONFIG_PXA25x) += cpufreq-pxa2xx.o
12obj-$(CONFIG_PXA27x) += cpufreq-pxa2xx.o
13obj-$(CONFIG_PXA3xx) += cpufreq-pxa3xx.o
14endif
10 15
11# Generic drivers that other drivers may depend upon 16# Generic drivers that other drivers may depend upon
12obj-$(CONFIG_PXA_SSP) += ssp.o 17obj-$(CONFIG_PXA_SSP) += ssp.o
@@ -22,27 +27,33 @@ obj-$(CONFIG_CPU_PXA930) += pxa930.o
22 27
23# Specific board support 28# Specific board support
24obj-$(CONFIG_ARCH_GUMSTIX) += gumstix.o 29obj-$(CONFIG_ARCH_GUMSTIX) += gumstix.o
30obj-$(CONFIG_MACH_AM200EPD) += am200epd.o
25obj-$(CONFIG_ARCH_LUBBOCK) += lubbock.o 31obj-$(CONFIG_ARCH_LUBBOCK) += lubbock.o
26obj-$(CONFIG_MACH_LOGICPD_PXA270) += lpd270.o 32obj-$(CONFIG_MACH_LOGICPD_PXA270) += lpd270.o
27obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o 33obj-$(CONFIG_MACH_MAINSTONE) += mainstone.o
34obj-$(CONFIG_MACH_MP900C) += mp900.o
28obj-$(CONFIG_ARCH_PXA_IDP) += idp.o 35obj-$(CONFIG_ARCH_PXA_IDP) += idp.o
29obj-$(CONFIG_MACH_TRIZEPS4) += trizeps4.o 36obj-$(CONFIG_MACH_TRIZEPS4) += trizeps4.o
30obj-$(CONFIG_MACH_COLIBRI) += colibri.o 37obj-$(CONFIG_MACH_COLIBRI) += colibri.o
31obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o corgi_pm.o 38obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o sharpsl_pm.o corgi_pm.o
32obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o spitz_pm.o 39obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o sharpsl_pm.o spitz_pm.o
33obj-$(CONFIG_MACH_AKITA) += akita-ioexp.o 40obj-$(CONFIG_MACH_POODLE) += poodle.o
34obj-$(CONFIG_MACH_POODLE) += poodle.o corgi_ssp.o
35obj-$(CONFIG_MACH_PCM027) += pcm027.o 41obj-$(CONFIG_MACH_PCM027) += pcm027.o
36obj-$(CONFIG_MACH_PCM990_BASEBOARD) += pcm990-baseboard.o 42obj-$(CONFIG_MACH_PCM990_BASEBOARD) += pcm990-baseboard.o
37obj-$(CONFIG_MACH_TOSA) += tosa.o 43obj-$(CONFIG_MACH_TOSA) += tosa.o
38obj-$(CONFIG_MACH_EM_X270) += em-x270.o 44obj-$(CONFIG_MACH_EM_X270) += em-x270.o
39obj-$(CONFIG_MACH_MAGICIAN) += magician.o 45obj-$(CONFIG_MACH_MAGICIAN) += magician.o
40obj-$(CONFIG_ARCH_PXA_ESERIES) += eseries.o eseries_udc.o 46obj-$(CONFIG_MACH_MIOA701) += mioa701.o mioa701_bootresume.o
41obj-$(CONFIG_MACH_E740) += e740_lcd.o 47obj-$(CONFIG_ARCH_PXA_ESERIES) += eseries.o
42obj-$(CONFIG_MACH_E750) += e750_lcd.o 48obj-$(CONFIG_MACH_E330) += e330.o
43obj-$(CONFIG_MACH_E400) += e400_lcd.o 49obj-$(CONFIG_MACH_E350) += e350.o
44obj-$(CONFIG_MACH_E800) += e800_lcd.o 50obj-$(CONFIG_MACH_E740) += e740.o
51obj-$(CONFIG_MACH_E750) += e750.o
52obj-$(CONFIG_MACH_E400) += e400.o
53obj-$(CONFIG_MACH_E800) += e800.o
45obj-$(CONFIG_MACH_PALMTX) += palmtx.o 54obj-$(CONFIG_MACH_PALMTX) += palmtx.o
55obj-$(CONFIG_MACH_PALMZ72) += palmz72.o
56obj-$(CONFIG_ARCH_VIPER) += viper.o
46 57
47ifeq ($(CONFIG_MACH_ZYLONITE),y) 58ifeq ($(CONFIG_MACH_ZYLONITE),y)
48 obj-y += zylonite.o 59 obj-y += zylonite.o
@@ -53,7 +64,8 @@ obj-$(CONFIG_MACH_LITTLETON) += littleton.o
53obj-$(CONFIG_MACH_TAVOREVB) += tavorevb.o 64obj-$(CONFIG_MACH_TAVOREVB) += tavorevb.o
54obj-$(CONFIG_MACH_SAAR) += saar.o 65obj-$(CONFIG_MACH_SAAR) += saar.o
55 66
56obj-$(CONFIG_MACH_ARMCORE) += cm-x270.o 67obj-$(CONFIG_MACH_ARMCORE) += cm-x2xx.o cm-x255.o cm-x270.o
68obj-$(CONFIG_MACH_CM_X300) += cm-x300.o
57obj-$(CONFIG_PXA_EZX) += ezx.o 69obj-$(CONFIG_PXA_EZX) += ezx.o
58 70
59# Support for blinky lights 71# Support for blinky lights
@@ -61,12 +73,11 @@ led-y := leds.o
61led-$(CONFIG_ARCH_LUBBOCK) += leds-lubbock.o 73led-$(CONFIG_ARCH_LUBBOCK) += leds-lubbock.o
62led-$(CONFIG_MACH_MAINSTONE) += leds-mainstone.o 74led-$(CONFIG_MACH_MAINSTONE) += leds-mainstone.o
63led-$(CONFIG_ARCH_PXA_IDP) += leds-idp.o 75led-$(CONFIG_ARCH_PXA_IDP) += leds-idp.o
64led-$(CONFIG_MACH_TRIZEPS4) += leds-trizeps4.o
65 76
66obj-$(CONFIG_LEDS) += $(led-y) 77obj-$(CONFIG_LEDS) += $(led-y)
67 78
68ifeq ($(CONFIG_PCI),y) 79ifeq ($(CONFIG_PCI),y)
69obj-$(CONFIG_MACH_ARMCORE) += cm-x270-pci.o 80obj-$(CONFIG_MACH_ARMCORE) += cm-x2xx-pci.o
70endif 81endif
71 82
72obj-$(CONFIG_TOSA_BT) += tosa-bt.o 83obj-$(CONFIG_TOSA_BT) += tosa-bt.o
diff --git a/arch/arm/mach-pxa/akita-ioexp.c b/arch/arm/mach-pxa/akita-ioexp.c
deleted file mode 100644
index 5c67b188a3ba..000000000000
--- a/arch/arm/mach-pxa/akita-ioexp.c
+++ /dev/null
@@ -1,222 +0,0 @@
1/*
2 * Support for the Extra GPIOs on the Sharp SL-C1000 (Akita)
3 * (uses a Maxim MAX7310 8 Port IO Expander)
4 *
5 * Copyright 2005 Openedhand Ltd.
6 *
7 * Author: Richard Purdie <richard@openedhand.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/module.h>
19#include <linux/i2c.h>
20#include <linux/slab.h>
21#include <linux/workqueue.h>
22#include <mach/akita.h>
23
24/* MAX7310 Regiser Map */
25#define MAX7310_INPUT 0x00
26#define MAX7310_OUTPUT 0x01
27#define MAX7310_POLINV 0x02
28#define MAX7310_IODIR 0x03 /* 1 = Input, 0 = Output */
29#define MAX7310_TIMEOUT 0x04
30
31/* Addresses to scan */
32static const unsigned short normal_i2c[] = { 0x18, I2C_CLIENT_END };
33
34/* I2C Magic */
35I2C_CLIENT_INSMOD;
36
37static int max7310_write(struct i2c_client *client, int address, int data);
38static struct i2c_client max7310_template;
39static void akita_ioexp_work(struct work_struct *private_);
40
41static struct device *akita_ioexp_device;
42static unsigned char ioexp_output_value = AKITA_IOEXP_IO_OUT;
43DECLARE_WORK(akita_ioexp, akita_ioexp_work);
44
45
46/*
47 * MAX7310 Access
48 */
49static int max7310_config(struct device *dev, int iomode, int polarity)
50{
51 int ret;
52 struct i2c_client *client = to_i2c_client(dev);
53
54 ret = max7310_write(client, MAX7310_POLINV, polarity);
55 if (ret < 0)
56 return ret;
57 ret = max7310_write(client, MAX7310_IODIR, iomode);
58 return ret;
59}
60
61static int max7310_set_ouputs(struct device *dev, int outputs)
62{
63 struct i2c_client *client = to_i2c_client(dev);
64
65 return max7310_write(client, MAX7310_OUTPUT, outputs);
66}
67
68/*
69 * I2C Functions
70 */
71static int max7310_write(struct i2c_client *client, int address, int value)
72{
73 u8 data[2];
74
75 data[0] = address & 0xff;
76 data[1] = value & 0xff;
77
78 if (i2c_master_send(client, data, 2) == 2)
79 return 0;
80 return -1;
81}
82
83static int max7310_detect(struct i2c_adapter *adapter, int address, int kind)
84{
85 struct i2c_client *new_client;
86 int err;
87
88 if (!(new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
89 return -ENOMEM;
90
91 max7310_template.adapter = adapter;
92 max7310_template.addr = address;
93
94 memcpy(new_client, &max7310_template, sizeof(struct i2c_client));
95
96 if ((err = i2c_attach_client(new_client))) {
97 kfree(new_client);
98 return err;
99 }
100
101 max7310_config(&new_client->dev, AKITA_IOEXP_IO_DIR, 0);
102 akita_ioexp_device = &new_client->dev;
103 schedule_work(&akita_ioexp);
104
105 return 0;
106}
107
108static int max7310_attach_adapter(struct i2c_adapter *adapter)
109{
110 return i2c_probe(adapter, &addr_data, max7310_detect);
111}
112
113static int max7310_detach_client(struct i2c_client *client)
114{
115 int err;
116
117 akita_ioexp_device = NULL;
118
119 if ((err = i2c_detach_client(client)))
120 return err;
121
122 kfree(client);
123 return 0;
124}
125
126static struct i2c_driver max7310_i2c_driver = {
127 .driver = {
128 .name = "akita-max7310",
129 },
130 .id = I2C_DRIVERID_AKITAIOEXP,
131 .attach_adapter = max7310_attach_adapter,
132 .detach_client = max7310_detach_client,
133};
134
135static struct i2c_client max7310_template = {
136 name: "akita-max7310",
137 driver: &max7310_i2c_driver,
138};
139
140void akita_set_ioexp(struct device *dev, unsigned char bit)
141{
142 ioexp_output_value |= bit;
143
144 if (akita_ioexp_device)
145 schedule_work(&akita_ioexp);
146 return;
147}
148
149void akita_reset_ioexp(struct device *dev, unsigned char bit)
150{
151 ioexp_output_value &= ~bit;
152
153 if (akita_ioexp_device)
154 schedule_work(&akita_ioexp);
155 return;
156}
157
158EXPORT_SYMBOL(akita_set_ioexp);
159EXPORT_SYMBOL(akita_reset_ioexp);
160
161static void akita_ioexp_work(struct work_struct *private_)
162{
163 if (akita_ioexp_device)
164 max7310_set_ouputs(akita_ioexp_device, ioexp_output_value);
165}
166
167
168#ifdef CONFIG_PM
169static int akita_ioexp_suspend(struct platform_device *pdev, pm_message_t state)
170{
171 flush_scheduled_work();
172 return 0;
173}
174
175static int akita_ioexp_resume(struct platform_device *pdev)
176{
177 schedule_work(&akita_ioexp);
178 return 0;
179}
180#else
181#define akita_ioexp_suspend NULL
182#define akita_ioexp_resume NULL
183#endif
184
185static int __init akita_ioexp_probe(struct platform_device *pdev)
186{
187 return i2c_add_driver(&max7310_i2c_driver);
188}
189
190static int akita_ioexp_remove(struct platform_device *pdev)
191{
192 i2c_del_driver(&max7310_i2c_driver);
193 return 0;
194}
195
196static struct platform_driver akita_ioexp_driver = {
197 .probe = akita_ioexp_probe,
198 .remove = akita_ioexp_remove,
199 .suspend = akita_ioexp_suspend,
200 .resume = akita_ioexp_resume,
201 .driver = {
202 .name = "akita-ioexp",
203 },
204};
205
206static int __init akita_ioexp_init(void)
207{
208 return platform_driver_register(&akita_ioexp_driver);
209}
210
211static void __exit akita_ioexp_exit(void)
212{
213 platform_driver_unregister(&akita_ioexp_driver);
214}
215
216MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
217MODULE_DESCRIPTION("Akita IO-Expander driver");
218MODULE_LICENSE("GPL");
219
220fs_initcall(akita_ioexp_init);
221module_exit(akita_ioexp_exit);
222
diff --git a/arch/arm/mach-pxa/am200epd.c b/arch/arm/mach-pxa/am200epd.c
new file mode 100644
index 000000000000..b965085a37b9
--- /dev/null
+++ b/arch/arm/mach-pxa/am200epd.c
@@ -0,0 +1,374 @@
1/*
2 * am200epd.c -- Platform device for AM200 EPD kit
3 *
4 * Copyright (C) 2008, Jaya Kumar
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
8 * more details.
9 *
10 * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
11 *
12 * This work was made possible by help and equipment support from E-Ink
13 * Corporation. http://support.eink.com/community
14 *
15 * This driver is written to be used with the Metronome display controller.
16 * on the AM200 EPD prototype kit/development kit with an E-Ink 800x600
17 * Vizplex EPD on a Gumstix board using the Lyre interface board.
18 *
19 */
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/errno.h>
24#include <linux/string.h>
25#include <linux/delay.h>
26#include <linux/interrupt.h>
27#include <linux/fb.h>
28#include <linux/init.h>
29#include <linux/platform_device.h>
30#include <linux/irq.h>
31#include <linux/gpio.h>
32
33#include <mach/pxafb.h>
34
35#include <video/metronomefb.h>
36
37static unsigned int panel_type = 6;
38static struct platform_device *am200_device;
39static struct metronome_board am200_board;
40
41static struct pxafb_mode_info am200_fb_mode_9inch7 = {
42 .pixclock = 40000,
43 .xres = 1200,
44 .yres = 842,
45 .bpp = 16,
46 .hsync_len = 2,
47 .left_margin = 2,
48 .right_margin = 2,
49 .vsync_len = 1,
50 .upper_margin = 2,
51 .lower_margin = 25,
52 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
53};
54
55static struct pxafb_mode_info am200_fb_mode_8inch = {
56 .pixclock = 40000,
57 .xres = 1088,
58 .yres = 791,
59 .bpp = 16,
60 .hsync_len = 28,
61 .left_margin = 8,
62 .right_margin = 30,
63 .vsync_len = 8,
64 .upper_margin = 10,
65 .lower_margin = 8,
66 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
67};
68
69static struct pxafb_mode_info am200_fb_mode_6inch = {
70 .pixclock = 40189,
71 .xres = 832,
72 .yres = 622,
73 .bpp = 16,
74 .hsync_len = 28,
75 .left_margin = 34,
76 .right_margin = 34,
77 .vsync_len = 25,
78 .upper_margin = 0,
79 .lower_margin = 2,
80 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
81};
82
83static struct pxafb_mach_info am200_fb_info = {
84 .modes = &am200_fb_mode_6inch,
85 .num_modes = 1,
86 .lcd_conn = LCD_TYPE_COLOR_TFT | LCD_PCLK_EDGE_FALL |
87 LCD_AC_BIAS_FREQ(24),
88};
89
90/* register offsets for gpio control */
91#define LED_GPIO_PIN 51
92#define STDBY_GPIO_PIN 48
93#define RST_GPIO_PIN 49
94#define RDY_GPIO_PIN 32
95#define ERR_GPIO_PIN 17
96#define PCBPWR_GPIO_PIN 16
97static int gpios[] = { LED_GPIO_PIN , STDBY_GPIO_PIN , RST_GPIO_PIN,
98 RDY_GPIO_PIN, ERR_GPIO_PIN, PCBPWR_GPIO_PIN };
99static char *gpio_names[] = { "LED" , "STDBY" , "RST", "RDY", "ERR", "PCBPWR" };
100
101static int am200_init_gpio_regs(struct metronomefb_par *par)
102{
103 int i;
104 int err;
105
106 for (i = 0; i < ARRAY_SIZE(gpios); i++) {
107 err = gpio_request(gpios[i], gpio_names[i]);
108 if (err) {
109 dev_err(&am200_device->dev, "failed requesting "
110 "gpio %s, err=%d\n", gpio_names[i], err);
111 goto err_req_gpio;
112 }
113 }
114
115 gpio_direction_output(LED_GPIO_PIN, 0);
116 gpio_direction_output(STDBY_GPIO_PIN, 0);
117 gpio_direction_output(RST_GPIO_PIN, 0);
118
119 gpio_direction_input(RDY_GPIO_PIN);
120 gpio_direction_input(ERR_GPIO_PIN);
121
122 gpio_direction_output(PCBPWR_GPIO_PIN, 0);
123
124 return 0;
125
126err_req_gpio:
127 while (i > 0)
128 gpio_free(gpios[i--]);
129
130 return err;
131}
132
133static void am200_cleanup(struct metronomefb_par *par)
134{
135 int i;
136
137 free_irq(IRQ_GPIO(RDY_GPIO_PIN), par);
138
139 for (i = 0; i < ARRAY_SIZE(gpios); i++)
140 gpio_free(gpios[i]);
141}
142
143static int am200_share_video_mem(struct fb_info *info)
144{
145 /* rough check if this is our desired fb and not something else */
146 if ((info->var.xres != am200_fb_info.modes->xres)
147 || (info->var.yres != am200_fb_info.modes->yres))
148 return 0;
149
150 /* we've now been notified that we have our new fb */
151 am200_board.metromem = info->screen_base;
152 am200_board.host_fbinfo = info;
153
154 /* try to refcount host drv since we are the consumer after this */
155 if (!try_module_get(info->fbops->owner))
156 return -ENODEV;
157
158 return 0;
159}
160
161static int am200_unshare_video_mem(struct fb_info *info)
162{
163 dev_dbg(&am200_device->dev, "ENTER %s\n", __func__);
164
165 if (info != am200_board.host_fbinfo)
166 return 0;
167
168 module_put(am200_board.host_fbinfo->fbops->owner);
169 return 0;
170}
171
172static int am200_fb_notifier_callback(struct notifier_block *self,
173 unsigned long event, void *data)
174{
175 struct fb_event *evdata = data;
176 struct fb_info *info = evdata->info;
177
178 dev_dbg(&am200_device->dev, "ENTER %s\n", __func__);
179
180 if (event == FB_EVENT_FB_REGISTERED)
181 return am200_share_video_mem(info);
182 else if (event == FB_EVENT_FB_UNREGISTERED)
183 return am200_unshare_video_mem(info);
184
185 return 0;
186}
187
188static struct notifier_block am200_fb_notif = {
189 .notifier_call = am200_fb_notifier_callback,
190};
191
192/* this gets called as part of our init. these steps must be done now so
193 * that we can use set_pxa_fb_info */
194static void __init am200_presetup_fb(void)
195{
196 int fw;
197 int fh;
198 int padding_size;
199 int totalsize;
200
201 switch (panel_type) {
202 case 6:
203 am200_fb_info.modes = &am200_fb_mode_6inch;
204 break;
205 case 8:
206 am200_fb_info.modes = &am200_fb_mode_8inch;
207 break;
208 case 97:
209 am200_fb_info.modes = &am200_fb_mode_9inch7;
210 break;
211 default:
212 dev_err(&am200_device->dev, "invalid panel_type selection,"
213 " setting to 6\n");
214 am200_fb_info.modes = &am200_fb_mode_6inch;
215 break;
216 }
217
218 /* the frame buffer is divided as follows:
219 command | CRC | padding
220 16kb waveform data | CRC | padding
221 image data | CRC
222 */
223
224 fw = am200_fb_info.modes->xres;
225 fh = am200_fb_info.modes->yres;
226
227 /* waveform must be 16k + 2 for checksum */
228 am200_board.wfm_size = roundup(16*1024 + 2, fw);
229
230 padding_size = PAGE_SIZE + (4 * fw);
231
232 /* total is 1 cmd , 1 wfm, padding and image */
233 totalsize = fw + am200_board.wfm_size + padding_size + (fw*fh);
234
235 /* save this off because we're manipulating fw after this and
236 * we'll need it when we're ready to setup the framebuffer */
237 am200_board.fw = fw;
238 am200_board.fh = fh;
239
240 /* the reason we do this adjustment is because we want to acquire
241 * more framebuffer memory without imposing custom awareness on the
242 * underlying pxafb driver */
243 am200_fb_info.modes->yres = DIV_ROUND_UP(totalsize, fw);
244
245 /* we divide since we told the LCD controller we're 16bpp */
246 am200_fb_info.modes->xres /= 2;
247
248 set_pxa_fb_info(&am200_fb_info);
249
250}
251
252/* this gets called by metronomefb as part of its init, in our case, we
253 * have already completed initial framebuffer init in presetup_fb so we
254 * can just setup the fb access pointers */
255static int am200_setup_fb(struct metronomefb_par *par)
256{
257 int fw;
258 int fh;
259
260 fw = am200_board.fw;
261 fh = am200_board.fh;
262
263 /* metromem was set up by the notifier in share_video_mem so now
264 * we can use its value to calculate the other entries */
265 par->metromem_cmd = (struct metromem_cmd *) am200_board.metromem;
266 par->metromem_wfm = am200_board.metromem + fw;
267 par->metromem_img = par->metromem_wfm + am200_board.wfm_size;
268 par->metromem_img_csum = (u16 *) (par->metromem_img + (fw * fh));
269 par->metromem_dma = am200_board.host_fbinfo->fix.smem_start;
270
271 return 0;
272}
273
274static int am200_get_panel_type(void)
275{
276 return panel_type;
277}
278
279static irqreturn_t am200_handle_irq(int irq, void *dev_id)
280{
281 struct metronomefb_par *par = dev_id;
282
283 wake_up_interruptible(&par->waitq);
284 return IRQ_HANDLED;
285}
286
287static int am200_setup_irq(struct fb_info *info)
288{
289 int ret;
290
291 ret = request_irq(IRQ_GPIO(RDY_GPIO_PIN), am200_handle_irq,
292 IRQF_DISABLED|IRQF_TRIGGER_FALLING,
293 "AM200", info->par);
294 if (ret)
295 dev_err(&am200_device->dev, "request_irq failed: %d\n", ret);
296
297 return ret;
298}
299
300static void am200_set_rst(struct metronomefb_par *par, int state)
301{
302 gpio_set_value(RST_GPIO_PIN, state);
303}
304
305static void am200_set_stdby(struct metronomefb_par *par, int state)
306{
307 gpio_set_value(STDBY_GPIO_PIN, state);
308}
309
310static int am200_wait_event(struct metronomefb_par *par)
311{
312 return wait_event_timeout(par->waitq, gpio_get_value(RDY_GPIO_PIN), HZ);
313}
314
315static int am200_wait_event_intr(struct metronomefb_par *par)
316{
317 return wait_event_interruptible_timeout(par->waitq,
318 gpio_get_value(RDY_GPIO_PIN), HZ);
319}
320
321static struct metronome_board am200_board = {
322 .owner = THIS_MODULE,
323 .setup_irq = am200_setup_irq,
324 .setup_io = am200_init_gpio_regs,
325 .setup_fb = am200_setup_fb,
326 .set_rst = am200_set_rst,
327 .set_stdby = am200_set_stdby,
328 .met_wait_event = am200_wait_event,
329 .met_wait_event_intr = am200_wait_event_intr,
330 .get_panel_type = am200_get_panel_type,
331 .cleanup = am200_cleanup,
332};
333
334static int __init am200_init(void)
335{
336 int ret;
337
338 /* before anything else, we request notification for any fb
339 * creation events */
340 fb_register_client(&am200_fb_notif);
341
342 /* request our platform independent driver */
343 request_module("metronomefb");
344
345 am200_device = platform_device_alloc("metronomefb", -1);
346 if (!am200_device)
347 return -ENOMEM;
348
349 /* the am200_board that will be seen by metronomefb is a copy */
350 platform_device_add_data(am200_device, &am200_board,
351 sizeof(am200_board));
352
353 /* this _add binds metronomefb to am200. metronomefb refcounts am200 */
354 ret = platform_device_add(am200_device);
355
356 if (ret) {
357 platform_device_put(am200_device);
358 fb_unregister_client(&am200_fb_notif);
359 return ret;
360 }
361
362 am200_presetup_fb();
363
364 return 0;
365}
366
367module_param(panel_type, uint, 0);
368MODULE_PARM_DESC(panel_type, "Select the panel type: 6, 8, 97");
369
370module_init(am200_init);
371
372MODULE_DESCRIPTION("board driver for am200 metronome epd kit");
373MODULE_AUTHOR("Jaya Kumar");
374MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-pxa/cm-x255.c b/arch/arm/mach-pxa/cm-x255.c
new file mode 100644
index 000000000000..83a4cdf08176
--- /dev/null
+++ b/arch/arm/mach-pxa/cm-x255.c
@@ -0,0 +1,258 @@
1/*
2 * linux/arch/arm/mach-pxa/cm-x255.c
3 *
4 * Copyright (C) 2007, 2008 CompuLab, Ltd.
5 * Mike Rapoport <mike@compulab.co.il>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/platform_device.h>
13#include <linux/irq.h>
14#include <linux/gpio.h>
15#include <linux/mtd/partitions.h>
16#include <linux/mtd/physmap.h>
17#include <linux/mtd/nand-gpio.h>
18
19#include <linux/spi/spi.h>
20
21#include <asm/mach/arch.h>
22#include <asm/mach-types.h>
23#include <asm/mach/map.h>
24
25#include <mach/pxa2xx-regs.h>
26#include <mach/mfp-pxa25x.h>
27#include <mach/pxa2xx_spi.h>
28#include <mach/bitfield.h>
29
30#include "generic.h"
31
32#define GPIO_NAND_CS (5)
33#define GPIO_NAND_ALE (4)
34#define GPIO_NAND_CLE (3)
35#define GPIO_NAND_RB (10)
36
37static unsigned long cmx255_pin_config[] = {
38 /* AC'97 */
39 GPIO28_AC97_BITCLK,
40 GPIO29_AC97_SDATA_IN_0,
41 GPIO30_AC97_SDATA_OUT,
42 GPIO31_AC97_SYNC,
43
44 /* BTUART */
45 GPIO42_BTUART_RXD,
46 GPIO43_BTUART_TXD,
47 GPIO44_BTUART_CTS,
48 GPIO45_BTUART_RTS,
49
50 /* STUART */
51 GPIO46_STUART_RXD,
52 GPIO47_STUART_TXD,
53
54 /* LCD */
55 GPIO58_LCD_LDD_0,
56 GPIO59_LCD_LDD_1,
57 GPIO60_LCD_LDD_2,
58 GPIO61_LCD_LDD_3,
59 GPIO62_LCD_LDD_4,
60 GPIO63_LCD_LDD_5,
61 GPIO64_LCD_LDD_6,
62 GPIO65_LCD_LDD_7,
63 GPIO66_LCD_LDD_8,
64 GPIO67_LCD_LDD_9,
65 GPIO68_LCD_LDD_10,
66 GPIO69_LCD_LDD_11,
67 GPIO70_LCD_LDD_12,
68 GPIO71_LCD_LDD_13,
69 GPIO72_LCD_LDD_14,
70 GPIO73_LCD_LDD_15,
71 GPIO74_LCD_FCLK,
72 GPIO75_LCD_LCLK,
73 GPIO76_LCD_PCLK,
74 GPIO77_LCD_BIAS,
75
76 /* SSP1 */
77 GPIO23_SSP1_SCLK,
78 GPIO24_SSP1_SFRM,
79 GPIO25_SSP1_TXD,
80 GPIO26_SSP1_RXD,
81
82 /* SSP2 */
83 GPIO81_SSP2_CLK_OUT,
84 GPIO82_SSP2_FRM_OUT,
85 GPIO83_SSP2_TXD,
86 GPIO84_SSP2_RXD,
87
88 /* PC Card */
89 GPIO48_nPOE,
90 GPIO49_nPWE,
91 GPIO50_nPIOR,
92 GPIO51_nPIOW,
93 GPIO52_nPCE_1,
94 GPIO53_nPCE_2,
95 GPIO54_nPSKTSEL,
96 GPIO55_nPREG,
97 GPIO56_nPWAIT,
98 GPIO57_nIOIS16,
99
100 /* SDRAM and local bus */
101 GPIO15_nCS_1,
102 GPIO78_nCS_2,
103 GPIO79_nCS_3,
104 GPIO80_nCS_4,
105 GPIO33_nCS_5,
106 GPIO18_RDY,
107
108 /* GPIO */
109 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH,
110 GPIO9_GPIO, /* PC card reset */
111
112 /* NAND controls */
113 GPIO5_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
114 GPIO4_GPIO | MFP_LPM_DRIVE_LOW, /* NAND ALE */
115 GPIO3_GPIO | MFP_LPM_DRIVE_LOW, /* NAND CLE */
116 GPIO10_GPIO, /* NAND Ready/Busy */
117
118 /* interrupts */
119 GPIO22_GPIO, /* DM9000 interrupt */
120};
121
122#if defined(CONFIG_SPI_PXA2XX)
123static struct pxa2xx_spi_master pxa_ssp_master_info = {
124 .num_chipselect = 1,
125};
126
127static struct spi_board_info spi_board_info[] __initdata = {
128 [0] = {
129 .modalias = "rtc-max6902",
130 .max_speed_hz = 1000000,
131 .bus_num = 1,
132 .chip_select = 0,
133 },
134};
135
136static void __init cmx255_init_rtc(void)
137{
138 pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
139 spi_register_board_info(ARRAY_AND_SIZE(spi_board_info));
140}
141#else
142static inline void cmx255_init_rtc(void) {}
143#endif
144
145#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
146static struct mtd_partition cmx255_nor_partitions[] = {
147 {
148 .name = "ARMmon",
149 .size = 0x00030000,
150 .offset = 0,
151 .mask_flags = MTD_WRITEABLE /* force read-only */
152 } , {
153 .name = "ARMmon setup block",
154 .size = 0x00010000,
155 .offset = MTDPART_OFS_APPEND,
156 .mask_flags = MTD_WRITEABLE /* force read-only */
157 } , {
158 .name = "kernel",
159 .size = 0x00160000,
160 .offset = MTDPART_OFS_APPEND,
161 } , {
162 .name = "ramdisk",
163 .size = MTDPART_SIZ_FULL,
164 .offset = MTDPART_OFS_APPEND
165 }
166};
167
168static struct physmap_flash_data cmx255_nor_flash_data[] = {
169 {
170 .width = 2, /* bankwidth in bytes */
171 .parts = cmx255_nor_partitions,
172 .nr_parts = ARRAY_SIZE(cmx255_nor_partitions)
173 }
174};
175
176static struct resource cmx255_nor_resource = {
177 .start = PXA_CS0_PHYS,
178 .end = PXA_CS0_PHYS + SZ_8M - 1,
179 .flags = IORESOURCE_MEM,
180};
181
182static struct platform_device cmx255_nor = {
183 .name = "physmap-flash",
184 .id = -1,
185 .dev = {
186 .platform_data = cmx255_nor_flash_data,
187 },
188 .resource = &cmx255_nor_resource,
189 .num_resources = 1,
190};
191
192static void __init cmx255_init_nor(void)
193{
194 platform_device_register(&cmx255_nor);
195}
196#else
197static inline void cmx255_init_nor(void) {}
198#endif
199
200#if defined(CONFIG_MTD_NAND_GPIO) || defined(CONFIG_MTD_NAND_GPIO_MODULE)
201static struct resource cmx255_nand_resource[] = {
202 [0] = {
203 .start = PXA_CS1_PHYS,
204 .end = PXA_CS1_PHYS + 11,
205 .flags = IORESOURCE_MEM,
206 },
207 [1] = {
208 .start = PXA_CS5_PHYS,
209 .end = PXA_CS5_PHYS + 3,
210 .flags = IORESOURCE_MEM,
211 },
212};
213
214static struct mtd_partition cmx255_nand_parts[] = {
215 [0] = {
216 .name = "cmx255-nand",
217 .size = MTDPART_SIZ_FULL,
218 .offset = 0,
219 },
220};
221
222static struct gpio_nand_platdata cmx255_nand_platdata = {
223 .gpio_nce = GPIO_NAND_CS,
224 .gpio_cle = GPIO_NAND_CLE,
225 .gpio_ale = GPIO_NAND_ALE,
226 .gpio_rdy = GPIO_NAND_RB,
227 .gpio_nwp = -1,
228 .parts = cmx255_nand_parts,
229 .num_parts = ARRAY_SIZE(cmx255_nand_parts),
230 .chip_delay = 25,
231};
232
233static struct platform_device cmx255_nand = {
234 .name = "gpio-nand",
235 .num_resources = ARRAY_SIZE(cmx255_nand_resource),
236 .resource = cmx255_nand_resource,
237 .id = -1,
238 .dev = {
239 .platform_data = &cmx255_nand_platdata,
240 }
241};
242
243static void __init cmx255_init_nand(void)
244{
245 platform_device_register(&cmx255_nand);
246}
247#else
248static inline void cmx255_init_nand(void) {}
249#endif
250
251void __init cmx255_init(void)
252{
253 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx255_pin_config));
254
255 cmx255_init_rtc();
256 cmx255_init_nor();
257 cmx255_init_nand();
258}
diff --git a/arch/arm/mach-pxa/cm-x270-pci.h b/arch/arm/mach-pxa/cm-x270-pci.h
deleted file mode 100644
index 48f532f4cb51..000000000000
--- a/arch/arm/mach-pxa/cm-x270-pci.h
+++ /dev/null
@@ -1,13 +0,0 @@
1extern void __cmx270_pci_init_irq(int irq_gpio);
2extern void __cmx270_pci_suspend(void);
3extern void __cmx270_pci_resume(void);
4
5#ifdef CONFIG_PCI
6#define cmx270_pci_init_irq(x) __cmx270_pci_init_irq(x)
7#define cmx270_pci_suspend(x) __cmx270_pci_suspend(x)
8#define cmx270_pci_resume(x) __cmx270_pci_resume(x)
9#else
10#define cmx270_pci_init_irq(x) do {} while (0)
11#define cmx270_pci_suspend(x) do {} while (0)
12#define cmx270_pci_resume(x) do {} while (0)
13#endif
diff --git a/arch/arm/mach-pxa/cm-x270.c b/arch/arm/mach-pxa/cm-x270.c
index af003a269534..a82dad1a8cc8 100644
--- a/arch/arm/mach-pxa/cm-x270.c
+++ b/arch/arm/mach-pxa/cm-x270.c
@@ -14,46 +14,22 @@
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16 16
17#include <linux/dm9000.h>
18#include <linux/rtc-v3020.h> 17#include <linux/rtc-v3020.h>
19#include <video/mbxfb.h> 18#include <video/mbxfb.h>
20#include <linux/leds.h>
21 19
22#include <asm/mach/arch.h>
23#include <asm/mach-types.h>
24#include <asm/mach/map.h>
25
26#include <mach/pxa2xx-regs.h>
27#include <mach/mfp-pxa27x.h> 20#include <mach/mfp-pxa27x.h>
28#include <mach/pxa-regs.h>
29#include <mach/audio.h>
30#include <mach/pxafb.h>
31#include <mach/ohci.h> 21#include <mach/ohci.h>
32#include <mach/mmc.h> 22#include <mach/mmc.h>
33#include <mach/bitfield.h>
34
35#include <asm/hardware/it8152.h>
36 23
37#include "generic.h" 24#include "generic.h"
38#include "cm-x270-pci.h"
39
40/* virtual addresses for statically mapped regions */
41#define CMX270_VIRT_BASE (0xe8000000)
42#define CMX270_IT8152_VIRT (CMX270_VIRT_BASE)
43 25
26/* physical address if local-bus attached devices */
44#define RTC_PHYS_BASE (PXA_CS1_PHYS + (5 << 22)) 27#define RTC_PHYS_BASE (PXA_CS1_PHYS + (5 << 22))
45#define DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
46 28
47/* GPIO IRQ usage */ 29/* GPIO IRQ usage */
48#define GPIO10_ETHIRQ (10)
49#define GPIO22_IT8152_IRQ (22)
50#define GPIO83_MMC_IRQ (83) 30#define GPIO83_MMC_IRQ (83)
51#define GPIO95_GFXIRQ (95)
52 31
53#define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
54#define CMX270_IT8152_IRQ IRQ_GPIO(GPIO22_IT8152_IRQ)
55#define CMX270_MMC_IRQ IRQ_GPIO(GPIO83_MMC_IRQ) 32#define CMX270_MMC_IRQ IRQ_GPIO(GPIO83_MMC_IRQ)
56#define CMX270_GFXIRQ IRQ_GPIO(GPIO95_GFXIRQ)
57 33
58/* MMC power enable */ 34/* MMC power enable */
59#define GPIO105_MMC_POWER (105) 35#define GPIO105_MMC_POWER (105)
@@ -157,62 +133,6 @@ static unsigned long cmx270_pin_config[] = {
157 GPIO83_GPIO, /* MMC card detect */ 133 GPIO83_GPIO, /* MMC card detect */
158}; 134};
159 135
160#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
161static struct resource cmx270_dm9000_resource[] = {
162 [0] = {
163 .start = DM9000_PHYS_BASE,
164 .end = DM9000_PHYS_BASE + 4,
165 .flags = IORESOURCE_MEM,
166 },
167 [1] = {
168 .start = DM9000_PHYS_BASE + 8,
169 .end = DM9000_PHYS_BASE + 8 + 500,
170 .flags = IORESOURCE_MEM,
171 },
172 [2] = {
173 .start = CMX270_ETHIRQ,
174 .end = CMX270_ETHIRQ,
175 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
176 }
177};
178
179static struct dm9000_plat_data cmx270_dm9000_platdata = {
180 .flags = DM9000_PLATF_32BITONLY,
181};
182
183static struct platform_device cmx270_dm9000_device = {
184 .name = "dm9000",
185 .id = 0,
186 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
187 .resource = cmx270_dm9000_resource,
188 .dev = {
189 .platform_data = &cmx270_dm9000_platdata,
190 }
191};
192
193static void __init cmx270_init_dm9000(void)
194{
195 platform_device_register(&cmx270_dm9000_device);
196}
197#else
198static inline void cmx270_init_dm9000(void) {}
199#endif
200
201/* UCB1400 touchscreen controller */
202#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
203static struct platform_device cmx270_ts_device = {
204 .name = "ucb1400_ts",
205 .id = -1,
206};
207
208static void __init cmx270_init_touchscreen(void)
209{
210 platform_device_register(&cmx270_ts_device);
211}
212#else
213static inline void cmx270_init_touchscreen(void) {}
214#endif
215
216/* V3020 RTC */ 136/* V3020 RTC */
217#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE) 137#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
218static struct resource cmx270_v3020_resource[] = { 138static struct resource cmx270_v3020_resource[] = {
@@ -242,45 +162,7 @@ static void __init cmx270_init_rtc(void)
242 platform_device_register(&cmx270_rtc_device); 162 platform_device_register(&cmx270_rtc_device);
243} 163}
244#else 164#else
245static inline void cmx270_init_rtc(void) {} 165static inline void cmx2xx_init_rtc(void) {}
246#endif
247
248/* CM-X270 LEDs */
249#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
250static struct gpio_led cmx270_leds[] = {
251 [0] = {
252 .name = "cm-x270:red",
253 .default_trigger = "nand-disk",
254 .gpio = 93,
255 .active_low = 1,
256 },
257 [1] = {
258 .name = "cm-x270:green",
259 .default_trigger = "heartbeat",
260 .gpio = 94,
261 .active_low = 1,
262 },
263};
264
265static struct gpio_led_platform_data cmx270_gpio_led_pdata = {
266 .num_leds = ARRAY_SIZE(cmx270_leds),
267 .leds = cmx270_leds,
268};
269
270static struct platform_device cmx270_led_device = {
271 .name = "leds-gpio",
272 .id = -1,
273 .dev = {
274 .platform_data = &cmx270_gpio_led_pdata,
275 },
276};
277
278static void __init cmx270_init_leds(void)
279{
280 platform_device_register(&cmx270_led_device);
281}
282#else
283static inline void cmx270_init_leds(void) {}
284#endif 166#endif
285 167
286/* 2700G graphics */ 168/* 2700G graphics */
@@ -373,238 +255,11 @@ static void __init cmx270_init_2700G(void)
373static inline void cmx270_init_2700G(void) {} 255static inline void cmx270_init_2700G(void) {}
374#endif 256#endif
375 257
376#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
377/*
378 Display definitions
379 keep these for backwards compatibility, although symbolic names (as
380 e.g. in lpd270.c) looks better
381*/
382#define MTYPE_STN320x240 0
383#define MTYPE_TFT640x480 1
384#define MTYPE_CRT640x480 2
385#define MTYPE_CRT800x600 3
386#define MTYPE_TFT320x240 6
387#define MTYPE_STN640x480 7
388
389static struct pxafb_mode_info generic_stn_320x240_mode = {
390 .pixclock = 76923,
391 .bpp = 8,
392 .xres = 320,
393 .yres = 240,
394 .hsync_len = 3,
395 .vsync_len = 2,
396 .left_margin = 3,
397 .upper_margin = 0,
398 .right_margin = 3,
399 .lower_margin = 0,
400 .sync = (FB_SYNC_HOR_HIGH_ACT |
401 FB_SYNC_VERT_HIGH_ACT),
402 .cmap_greyscale = 0,
403};
404
405static struct pxafb_mach_info generic_stn_320x240 = {
406 .modes = &generic_stn_320x240_mode,
407 .num_modes = 1,
408 .lccr0 = 0,
409 .lccr3 = (LCCR3_PixClkDiv(0x03) |
410 LCCR3_Acb(0xff) |
411 LCCR3_PCP),
412 .cmap_inverse = 0,
413 .cmap_static = 0,
414};
415
416static struct pxafb_mode_info generic_tft_640x480_mode = {
417 .pixclock = 38461,
418 .bpp = 8,
419 .xres = 640,
420 .yres = 480,
421 .hsync_len = 60,
422 .vsync_len = 2,
423 .left_margin = 70,
424 .upper_margin = 10,
425 .right_margin = 70,
426 .lower_margin = 5,
427 .sync = 0,
428 .cmap_greyscale = 0,
429};
430
431static struct pxafb_mach_info generic_tft_640x480 = {
432 .modes = &generic_tft_640x480_mode,
433 .num_modes = 1,
434 .lccr0 = (LCCR0_PAS),
435 .lccr3 = (LCCR3_PixClkDiv(0x01) |
436 LCCR3_Acb(0xff) |
437 LCCR3_PCP),
438 .cmap_inverse = 0,
439 .cmap_static = 0,
440};
441
442static struct pxafb_mode_info generic_crt_640x480_mode = {
443 .pixclock = 38461,
444 .bpp = 8,
445 .xres = 640,
446 .yres = 480,
447 .hsync_len = 63,
448 .vsync_len = 2,
449 .left_margin = 81,
450 .upper_margin = 33,
451 .right_margin = 16,
452 .lower_margin = 10,
453 .sync = (FB_SYNC_HOR_HIGH_ACT |
454 FB_SYNC_VERT_HIGH_ACT),
455 .cmap_greyscale = 0,
456};
457
458static struct pxafb_mach_info generic_crt_640x480 = {
459 .modes = &generic_crt_640x480_mode,
460 .num_modes = 1,
461 .lccr0 = (LCCR0_PAS),
462 .lccr3 = (LCCR3_PixClkDiv(0x01) |
463 LCCR3_Acb(0xff)),
464 .cmap_inverse = 0,
465 .cmap_static = 0,
466};
467
468static struct pxafb_mode_info generic_crt_800x600_mode = {
469 .pixclock = 28846,
470 .bpp = 8,
471 .xres = 800,
472 .yres = 600,
473 .hsync_len = 63,
474 .vsync_len = 2,
475 .left_margin = 26,
476 .upper_margin = 21,
477 .right_margin = 26,
478 .lower_margin = 11,
479 .sync = (FB_SYNC_HOR_HIGH_ACT |
480 FB_SYNC_VERT_HIGH_ACT),
481 .cmap_greyscale = 0,
482};
483
484static struct pxafb_mach_info generic_crt_800x600 = {
485 .modes = &generic_crt_800x600_mode,
486 .num_modes = 1,
487 .lccr0 = (LCCR0_PAS),
488 .lccr3 = (LCCR3_PixClkDiv(0x02) |
489 LCCR3_Acb(0xff)),
490 .cmap_inverse = 0,
491 .cmap_static = 0,
492};
493
494static struct pxafb_mode_info generic_tft_320x240_mode = {
495 .pixclock = 134615,
496 .bpp = 16,
497 .xres = 320,
498 .yres = 240,
499 .hsync_len = 63,
500 .vsync_len = 7,
501 .left_margin = 75,
502 .upper_margin = 0,
503 .right_margin = 15,
504 .lower_margin = 15,
505 .sync = 0,
506 .cmap_greyscale = 0,
507};
508
509static struct pxafb_mach_info generic_tft_320x240 = {
510 .modes = &generic_tft_320x240_mode,
511 .num_modes = 1,
512 .lccr0 = (LCCR0_PAS),
513 .lccr3 = (LCCR3_PixClkDiv(0x06) |
514 LCCR3_Acb(0xff) |
515 LCCR3_PCP),
516 .cmap_inverse = 0,
517 .cmap_static = 0,
518};
519
520static struct pxafb_mode_info generic_stn_640x480_mode = {
521 .pixclock = 57692,
522 .bpp = 8,
523 .xres = 640,
524 .yres = 480,
525 .hsync_len = 4,
526 .vsync_len = 2,
527 .left_margin = 10,
528 .upper_margin = 5,
529 .right_margin = 10,
530 .lower_margin = 5,
531 .sync = (FB_SYNC_HOR_HIGH_ACT |
532 FB_SYNC_VERT_HIGH_ACT),
533 .cmap_greyscale = 0,
534};
535
536static struct pxafb_mach_info generic_stn_640x480 = {
537 .modes = &generic_stn_640x480_mode,
538 .num_modes = 1,
539 .lccr0 = 0,
540 .lccr3 = (LCCR3_PixClkDiv(0x02) |
541 LCCR3_Acb(0xff)),
542 .cmap_inverse = 0,
543 .cmap_static = 0,
544};
545
546static struct pxafb_mach_info *cmx270_display = &generic_crt_640x480;
547
548static int __init cmx270_set_display(char *str)
549{
550 int disp_type = simple_strtol(str, NULL, 0);
551 switch (disp_type) {
552 case MTYPE_STN320x240:
553 cmx270_display = &generic_stn_320x240;
554 break;
555 case MTYPE_TFT640x480:
556 cmx270_display = &generic_tft_640x480;
557 break;
558 case MTYPE_CRT640x480:
559 cmx270_display = &generic_crt_640x480;
560 break;
561 case MTYPE_CRT800x600:
562 cmx270_display = &generic_crt_800x600;
563 break;
564 case MTYPE_TFT320x240:
565 cmx270_display = &generic_tft_320x240;
566 break;
567 case MTYPE_STN640x480:
568 cmx270_display = &generic_stn_640x480;
569 break;
570 default: /* fallback to CRT 640x480 */
571 cmx270_display = &generic_crt_640x480;
572 break;
573 }
574 return 1;
575}
576
577/*
578 This should be done really early to get proper configuration for
579 frame buffer.
580 Indeed, pxafb parameters can be used istead, but CM-X270 bootloader
581 has limitied line length for kernel command line, and also it will
582 break compatibitlty with proprietary releases already in field.
583*/
584__setup("monitor=", cmx270_set_display);
585
586static void __init cmx270_init_display(void)
587{
588 set_pxa_fb_info(cmx270_display);
589}
590#else
591static inline void cmx270_init_display(void) {}
592#endif
593
594/* PXA27x OHCI controller setup */ 258/* PXA27x OHCI controller setup */
595#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 259#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
596static int cmx270_ohci_init(struct device *dev)
597{
598 /* Set the Power Control Polarity Low */
599 UHCHR = (UHCHR | UHCHR_PCPL) &
600 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE);
601
602 return 0;
603}
604
605static struct pxaohci_platform_data cmx270_ohci_platform_data = { 260static struct pxaohci_platform_data cmx270_ohci_platform_data = {
606 .port_mode = PMM_PERPORT_MODE, 261 .port_mode = PMM_PERPORT_MODE,
607 .init = cmx270_ohci_init, 262 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
608}; 263};
609 264
610static void __init cmx270_init_ohci(void) 265static void __init cmx270_init_ohci(void)
@@ -676,131 +331,12 @@ static void __init cmx270_init_mmc(void)
676static inline void cmx270_init_mmc(void) {} 331static inline void cmx270_init_mmc(void) {}
677#endif 332#endif
678 333
679#ifdef CONFIG_PM 334void __init cmx270_init(void)
680static unsigned long sleep_save_msc[10];
681
682static int cmx270_suspend(struct sys_device *dev, pm_message_t state)
683{
684 cmx270_pci_suspend();
685
686 /* save MSC registers */
687 sleep_save_msc[0] = MSC0;
688 sleep_save_msc[1] = MSC1;
689 sleep_save_msc[2] = MSC2;
690
691 /* setup power saving mode registers */
692 PCFR = 0x0;
693 PSLR = 0xff400000;
694 PMCR = 0x00000005;
695 PWER = 0x80000000;
696 PFER = 0x00000000;
697 PRER = 0x00000000;
698 PGSR0 = 0xC0018800;
699 PGSR1 = 0x004F0002;
700 PGSR2 = 0x6021C000;
701 PGSR3 = 0x00020000;
702
703 return 0;
704}
705
706static int cmx270_resume(struct sys_device *dev)
707{
708 cmx270_pci_resume();
709
710 /* restore MSC registers */
711 MSC0 = sleep_save_msc[0];
712 MSC1 = sleep_save_msc[1];
713 MSC2 = sleep_save_msc[2];
714
715 return 0;
716}
717
718static struct sysdev_class cmx270_pm_sysclass = {
719 .name = "pm",
720 .resume = cmx270_resume,
721 .suspend = cmx270_suspend,
722};
723
724static struct sys_device cmx270_pm_device = {
725 .cls = &cmx270_pm_sysclass,
726};
727
728static int __init cmx270_pm_init(void)
729{
730 int error;
731 error = sysdev_class_register(&cmx270_pm_sysclass);
732 if (error == 0)
733 error = sysdev_register(&cmx270_pm_device);
734 return error;
735}
736#else
737static int __init cmx270_pm_init(void) { return 0; }
738#endif
739
740#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
741static void __init cmx270_init_ac97(void)
742{
743 pxa_set_ac97_info(NULL);
744}
745#else
746static inline void cmx270_init_ac97(void) {}
747#endif
748
749static void __init cmx270_init(void)
750{ 335{
751 cmx270_pm_init();
752
753 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config)); 336 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config));
754 337
755 cmx270_init_dm9000();
756 cmx270_init_rtc(); 338 cmx270_init_rtc();
757 cmx270_init_display();
758 cmx270_init_mmc(); 339 cmx270_init_mmc();
759 cmx270_init_ohci(); 340 cmx270_init_ohci();
760 cmx270_init_ac97();
761 cmx270_init_touchscreen();
762 cmx270_init_leds();
763 cmx270_init_2700G(); 341 cmx270_init_2700G();
764} 342}
765
766static void __init cmx270_init_irq(void)
767{
768 pxa27x_init_irq();
769
770 cmx270_pci_init_irq(GPIO22_IT8152_IRQ);
771}
772
773#ifdef CONFIG_PCI
774/* Map PCI companion statically */
775static struct map_desc cmx270_io_desc[] __initdata = {
776 [0] = { /* PCI bridge */
777 .virtual = CMX270_IT8152_VIRT,
778 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
779 .length = SZ_64M,
780 .type = MT_DEVICE
781 },
782};
783
784static void __init cmx270_map_io(void)
785{
786 pxa_map_io();
787 iotable_init(cmx270_io_desc, ARRAY_SIZE(cmx270_io_desc));
788
789 it8152_base_address = CMX270_IT8152_VIRT;
790}
791#else
792static void __init cmx270_map_io(void)
793{
794 pxa_map_io();
795}
796#endif
797
798MACHINE_START(ARMCORE, "Compulab CM-x270")
799 .boot_params = 0xa0000100,
800 .phys_io = 0x40000000,
801 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
802 .map_io = cmx270_map_io,
803 .init_irq = cmx270_init_irq,
804 .timer = &pxa_timer,
805 .init_machine = cmx270_init,
806MACHINE_END
diff --git a/arch/arm/mach-pxa/cm-x270-pci.c b/arch/arm/mach-pxa/cm-x2xx-pci.c
index 2d5bcea1e520..3156b25f6e9d 100644
--- a/arch/arm/mach-pxa/cm-x270-pci.c
+++ b/arch/arm/mach-pxa/cm-x2xx-pci.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/arm/mach-pxa/cm-x270-pci.c 2 * linux/arch/arm/mach-pxa/cm-x2xx-pci.c
3 * 3 *
4 * PCI bios-type initialisation for PCI machines 4 * PCI bios-type initialisation for PCI machines
5 * 5 *
@@ -28,7 +28,7 @@
28#include <asm/hardware/it8152.h> 28#include <asm/hardware/it8152.h>
29 29
30unsigned long it8152_base_address; 30unsigned long it8152_base_address;
31static int cmx270_it8152_irq_gpio; 31static int cmx2xx_it8152_irq_gpio;
32 32
33/* 33/*
34 * Only first 64MB of memory can be accessed via PCI. 34 * Only first 64MB of memory can be accessed via PCI.
@@ -36,13 +36,13 @@ static int cmx270_it8152_irq_gpio;
36 * This is really ugly and we need a better way of specifying 36 * This is really ugly and we need a better way of specifying
37 * DMA-capable regions of memory. 37 * DMA-capable regions of memory.
38 */ 38 */
39void __init cmx270_pci_adjust_zones(int node, unsigned long *zone_size, 39void __init cmx2xx_pci_adjust_zones(int node, unsigned long *zone_size,
40 unsigned long *zhole_size) 40 unsigned long *zhole_size)
41{ 41{
42 unsigned int sz = SZ_64M >> PAGE_SHIFT; 42 unsigned int sz = SZ_64M >> PAGE_SHIFT;
43 43
44 if (machine_is_armcore()) { 44 if (machine_is_armcore()) {
45 pr_info("Adjusting zones for CM-X270\n"); 45 pr_info("Adjusting zones for CM-X2XX\n");
46 46
47 /* 47 /*
48 * Only adjust if > 64M on current system 48 * Only adjust if > 64M on current system
@@ -57,29 +57,29 @@ void __init cmx270_pci_adjust_zones(int node, unsigned long *zone_size,
57 } 57 }
58} 58}
59 59
60static void cmx270_it8152_irq_demux(unsigned int irq, struct irq_desc *desc) 60static void cmx2xx_it8152_irq_demux(unsigned int irq, struct irq_desc *desc)
61{ 61{
62 /* clear our parent irq */ 62 /* clear our parent irq */
63 GEDR(cmx270_it8152_irq_gpio) = GPIO_bit(cmx270_it8152_irq_gpio); 63 GEDR(cmx2xx_it8152_irq_gpio) = GPIO_bit(cmx2xx_it8152_irq_gpio);
64 64
65 it8152_irq_demux(irq, desc); 65 it8152_irq_demux(irq, desc);
66} 66}
67 67
68void __cmx270_pci_init_irq(int irq_gpio) 68void __cmx2xx_pci_init_irq(int irq_gpio)
69{ 69{
70 it8152_init_irq(); 70 it8152_init_irq();
71 71
72 cmx270_it8152_irq_gpio = irq_gpio; 72 cmx2xx_it8152_irq_gpio = irq_gpio;
73 73
74 set_irq_type(gpio_to_irq(irq_gpio), IRQ_TYPE_EDGE_RISING); 74 set_irq_type(gpio_to_irq(irq_gpio), IRQ_TYPE_EDGE_RISING);
75 75
76 set_irq_chained_handler(gpio_to_irq(irq_gpio), cmx270_it8152_irq_demux); 76 set_irq_chained_handler(gpio_to_irq(irq_gpio), cmx2xx_it8152_irq_demux);
77} 77}
78 78
79#ifdef CONFIG_PM 79#ifdef CONFIG_PM
80static unsigned long sleep_save_ite[10]; 80static unsigned long sleep_save_ite[10];
81 81
82void __cmx270_pci_suspend(void) 82void __cmx2xx_pci_suspend(void)
83{ 83{
84 /* save ITE state */ 84 /* save ITE state */
85 sleep_save_ite[0] = __raw_readl(IT8152_INTC_PDCNIMR); 85 sleep_save_ite[0] = __raw_readl(IT8152_INTC_PDCNIMR);
@@ -91,7 +91,7 @@ void __cmx270_pci_suspend(void)
91 __raw_writel((0), IT8152_INTC_LPCNIRR); 91 __raw_writel((0), IT8152_INTC_LPCNIRR);
92} 92}
93 93
94void __cmx270_pci_resume(void) 94void __cmx2xx_pci_resume(void)
95{ 95{
96 /* restore IT8152 state */ 96 /* restore IT8152 state */
97 __raw_writel((sleep_save_ite[0]), IT8152_INTC_PDCNIMR); 97 __raw_writel((sleep_save_ite[0]), IT8152_INTC_PDCNIMR);
@@ -99,12 +99,12 @@ void __cmx270_pci_resume(void)
99 __raw_writel((sleep_save_ite[2]), IT8152_INTC_LPNIAR); 99 __raw_writel((sleep_save_ite[2]), IT8152_INTC_LPNIAR);
100} 100}
101#else 101#else
102void cmx270_pci_suspend(void) {} 102void cmx2xx_pci_suspend(void) {}
103void cmx270_pci_resume(void) {} 103void cmx2xx_pci_resume(void) {}
104#endif 104#endif
105 105
106/* PCI IRQ mapping*/ 106/* PCI IRQ mapping*/
107static int __init cmx270_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) 107static int __init cmx2xx_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
108{ 108{
109 int irq; 109 int irq;
110 110
@@ -116,14 +116,14 @@ static int __init cmx270_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
116 116
117 /* 117 /*
118 Here comes the ugly part. The routing is baseboard specific, 118 Here comes the ugly part. The routing is baseboard specific,
119 but defining a platform for each possible base of CM-X270 is 119 but defining a platform for each possible base of CM-X2XX is
120 unrealistic. Here we keep mapping for ATXBase and SB-X270. 120 unrealistic. Here we keep mapping for ATXBase and SB-X2XX.
121 */ 121 */
122 /* ATXBASE PCI slot */ 122 /* ATXBASE PCI slot */
123 if (slot == 7) 123 if (slot == 7)
124 return IT8152_PCI_INTA; 124 return IT8152_PCI_INTA;
125 125
126 /* ATXBase/SB-x270 CardBus */ 126 /* ATXBase/SB-X2XX CardBus */
127 if (slot == 8 || slot == 0) 127 if (slot == 8 || slot == 0)
128 return IT8152_PCI_INTB; 128 return IT8152_PCI_INTB;
129 129
@@ -131,7 +131,11 @@ static int __init cmx270_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
131 if (slot == 9) 131 if (slot == 9)
132 return IT8152_PCI_INTA; 132 return IT8152_PCI_INTA;
133 133
134 /* SB-x270 Ethernet */ 134 /* CM-x255 Onboard Ethernet */
135 if (slot == 15)
136 return IT8152_PCI_INTC;
137
138 /* SB-x2xx Ethernet */
135 if (slot == 16) 139 if (slot == 16)
136 return IT8152_PCI_INTA; 140 return IT8152_PCI_INTA;
137 141
@@ -144,9 +148,9 @@ static int __init cmx270_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
144 return(0); 148 return(0);
145} 149}
146 150
147static void cmx270_pci_preinit(void) 151static void cmx2xx_pci_preinit(void)
148{ 152{
149 pr_info("Initializing CM-X270 PCI subsystem\n"); 153 pr_info("Initializing CM-X2XX PCI subsystem\n");
150 154
151 __raw_writel(0x800, IT8152_PCI_CFG_ADDR); 155 __raw_writel(0x800, IT8152_PCI_CFG_ADDR);
152 if (__raw_readl(IT8152_PCI_CFG_DATA) == 0x81521283) { 156 if (__raw_readl(IT8152_PCI_CFG_DATA) == 0x81521283) {
@@ -200,21 +204,21 @@ static void cmx270_pci_preinit(void)
200 } 204 }
201} 205}
202 206
203static struct hw_pci cmx270_pci __initdata = { 207static struct hw_pci cmx2xx_pci __initdata = {
204 .swizzle = pci_std_swizzle, 208 .swizzle = pci_std_swizzle,
205 .map_irq = cmx270_pci_map_irq, 209 .map_irq = cmx2xx_pci_map_irq,
206 .nr_controllers = 1, 210 .nr_controllers = 1,
207 .setup = it8152_pci_setup, 211 .setup = it8152_pci_setup,
208 .scan = it8152_pci_scan_bus, 212 .scan = it8152_pci_scan_bus,
209 .preinit = cmx270_pci_preinit, 213 .preinit = cmx2xx_pci_preinit,
210}; 214};
211 215
212static int __init cmx270_init_pci(void) 216static int __init cmx2xx_init_pci(void)
213{ 217{
214 if (machine_is_armcore()) 218 if (machine_is_armcore())
215 pci_common_init(&cmx270_pci); 219 pci_common_init(&cmx2xx_pci);
216 220
217 return 0; 221 return 0;
218} 222}
219 223
220subsys_initcall(cmx270_init_pci); 224subsys_initcall(cmx2xx_init_pci);
diff --git a/arch/arm/mach-pxa/cm-x2xx-pci.h b/arch/arm/mach-pxa/cm-x2xx-pci.h
new file mode 100644
index 000000000000..e24aad2e3ad7
--- /dev/null
+++ b/arch/arm/mach-pxa/cm-x2xx-pci.h
@@ -0,0 +1,13 @@
1extern void __cmx2xx_pci_init_irq(int irq_gpio);
2extern void __cmx2xx_pci_suspend(void);
3extern void __cmx2xx_pci_resume(void);
4
5#ifdef CONFIG_PCI
6#define cmx2xx_pci_init_irq(x) __cmx2xx_pci_init_irq(x)
7#define cmx2xx_pci_suspend(x) __cmx2xx_pci_suspend(x)
8#define cmx2xx_pci_resume(x) __cmx2xx_pci_resume(x)
9#else
10#define cmx2xx_pci_init_irq(x) do {} while (0)
11#define cmx2xx_pci_suspend(x) do {} while (0)
12#define cmx2xx_pci_resume(x) do {} while (0)
13#endif
diff --git a/arch/arm/mach-pxa/cm-x2xx.c b/arch/arm/mach-pxa/cm-x2xx.c
new file mode 100644
index 000000000000..0b3ce3b6d896
--- /dev/null
+++ b/arch/arm/mach-pxa/cm-x2xx.c
@@ -0,0 +1,531 @@
1/*
2 * linux/arch/arm/mach-pxa/cm-x2xx.c
3 *
4 * Copyright (C) 2008 CompuLab, Ltd.
5 * Mike Rapoport <mike@compulab.co.il>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/platform_device.h>
13#include <linux/sysdev.h>
14#include <linux/irq.h>
15#include <linux/gpio.h>
16
17#include <linux/dm9000.h>
18#include <linux/leds.h>
19
20#include <asm/mach/arch.h>
21#include <asm/mach-types.h>
22#include <asm/mach/map.h>
23
24#include <mach/pxa2xx-regs.h>
25#include <mach/mfp-pxa27x.h>
26#include <mach/pxa-regs.h>
27#include <mach/audio.h>
28#include <mach/pxafb.h>
29
30#include <asm/hardware/it8152.h>
31
32#include "generic.h"
33#include "cm-x2xx-pci.h"
34
35extern void cmx255_init(void);
36extern void cmx270_init(void);
37
38/* virtual addresses for statically mapped regions */
39#define CMX2XX_VIRT_BASE (0xe8000000)
40#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
41
42/* physical address if local-bus attached devices */
43#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
44#define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
45
46/* leds */
47#define CMX255_GPIO_RED (27)
48#define CMX255_GPIO_GREEN (32)
49#define CMX270_GPIO_RED (93)
50#define CMX270_GPIO_GREEN (94)
51
52/* GPIO IRQ usage */
53#define GPIO22_ETHIRQ (22)
54#define GPIO10_ETHIRQ (10)
55#define CMX255_GPIO_IT8152_IRQ (0)
56#define CMX270_GPIO_IT8152_IRQ (22)
57
58#define CMX255_ETHIRQ IRQ_GPIO(GPIO22_ETHIRQ)
59#define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
60
61#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
62static struct resource cmx255_dm9000_resource[] = {
63 [0] = {
64 .start = CMX255_DM9000_PHYS_BASE,
65 .end = CMX255_DM9000_PHYS_BASE + 3,
66 .flags = IORESOURCE_MEM,
67 },
68 [1] = {
69 .start = CMX255_DM9000_PHYS_BASE + 4,
70 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
71 .flags = IORESOURCE_MEM,
72 },
73 [2] = {
74 .start = CMX255_ETHIRQ,
75 .end = CMX255_ETHIRQ,
76 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
77 }
78};
79
80static struct resource cmx270_dm9000_resource[] = {
81 [0] = {
82 .start = CMX270_DM9000_PHYS_BASE,
83 .end = CMX270_DM9000_PHYS_BASE + 3,
84 .flags = IORESOURCE_MEM,
85 },
86 [1] = {
87 .start = CMX270_DM9000_PHYS_BASE + 8,
88 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
89 .flags = IORESOURCE_MEM,
90 },
91 [2] = {
92 .start = CMX270_ETHIRQ,
93 .end = CMX270_ETHIRQ,
94 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
95 }
96};
97
98static struct dm9000_plat_data cmx270_dm9000_platdata = {
99 .flags = DM9000_PLATF_32BITONLY,
100};
101
102static struct platform_device cmx2xx_dm9000_device = {
103 .name = "dm9000",
104 .id = 0,
105 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
106 .dev = {
107 .platform_data = &cmx270_dm9000_platdata,
108 }
109};
110
111static void __init cmx2xx_init_dm9000(void)
112{
113 if (cpu_is_pxa25x())
114 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
115 else
116 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
117 platform_device_register(&cmx2xx_dm9000_device);
118}
119#else
120static inline void cmx2xx_init_dm9000(void) {}
121#endif
122
123/* UCB1400 touchscreen controller */
124#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
125static struct platform_device cmx2xx_ts_device = {
126 .name = "ucb1400_ts",
127 .id = -1,
128};
129
130static void __init cmx2xx_init_touchscreen(void)
131{
132 platform_device_register(&cmx2xx_ts_device);
133}
134#else
135static inline void cmx2xx_init_touchscreen(void) {}
136#endif
137
138/* CM-X270 LEDs */
139#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
140static struct gpio_led cmx2xx_leds[] = {
141 [0] = {
142 .name = "cm-x2xx:red",
143 .default_trigger = "nand-disk",
144 .active_low = 1,
145 },
146 [1] = {
147 .name = "cm-x2xx:green",
148 .default_trigger = "heartbeat",
149 .active_low = 1,
150 },
151};
152
153static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
154 .num_leds = ARRAY_SIZE(cmx2xx_leds),
155 .leds = cmx2xx_leds,
156};
157
158static struct platform_device cmx2xx_led_device = {
159 .name = "leds-gpio",
160 .id = -1,
161 .dev = {
162 .platform_data = &cmx2xx_gpio_led_pdata,
163 },
164};
165
166static void __init cmx2xx_init_leds(void)
167{
168 if (cpu_is_pxa25x()) {
169 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
170 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
171 } else {
172 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
173 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
174 }
175 platform_device_register(&cmx2xx_led_device);
176}
177#else
178static inline void cmx2xx_init_leds(void) {}
179#endif
180
181#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
182/*
183 Display definitions
184 keep these for backwards compatibility, although symbolic names (as
185 e.g. in lpd270.c) looks better
186*/
187#define MTYPE_STN320x240 0
188#define MTYPE_TFT640x480 1
189#define MTYPE_CRT640x480 2
190#define MTYPE_CRT800x600 3
191#define MTYPE_TFT320x240 6
192#define MTYPE_STN640x480 7
193
194static struct pxafb_mode_info generic_stn_320x240_mode = {
195 .pixclock = 76923,
196 .bpp = 8,
197 .xres = 320,
198 .yres = 240,
199 .hsync_len = 3,
200 .vsync_len = 2,
201 .left_margin = 3,
202 .upper_margin = 0,
203 .right_margin = 3,
204 .lower_margin = 0,
205 .sync = (FB_SYNC_HOR_HIGH_ACT |
206 FB_SYNC_VERT_HIGH_ACT),
207 .cmap_greyscale = 0,
208};
209
210static struct pxafb_mach_info generic_stn_320x240 = {
211 .modes = &generic_stn_320x240_mode,
212 .num_modes = 1,
213 .lccr0 = 0,
214 .lccr3 = (LCCR3_PixClkDiv(0x03) |
215 LCCR3_Acb(0xff) |
216 LCCR3_PCP),
217 .cmap_inverse = 0,
218 .cmap_static = 0,
219};
220
221static struct pxafb_mode_info generic_tft_640x480_mode = {
222 .pixclock = 38461,
223 .bpp = 8,
224 .xres = 640,
225 .yres = 480,
226 .hsync_len = 60,
227 .vsync_len = 2,
228 .left_margin = 70,
229 .upper_margin = 10,
230 .right_margin = 70,
231 .lower_margin = 5,
232 .sync = 0,
233 .cmap_greyscale = 0,
234};
235
236static struct pxafb_mach_info generic_tft_640x480 = {
237 .modes = &generic_tft_640x480_mode,
238 .num_modes = 1,
239 .lccr0 = (LCCR0_PAS),
240 .lccr3 = (LCCR3_PixClkDiv(0x01) |
241 LCCR3_Acb(0xff) |
242 LCCR3_PCP),
243 .cmap_inverse = 0,
244 .cmap_static = 0,
245};
246
247static struct pxafb_mode_info generic_crt_640x480_mode = {
248 .pixclock = 38461,
249 .bpp = 8,
250 .xres = 640,
251 .yres = 480,
252 .hsync_len = 63,
253 .vsync_len = 2,
254 .left_margin = 81,
255 .upper_margin = 33,
256 .right_margin = 16,
257 .lower_margin = 10,
258 .sync = (FB_SYNC_HOR_HIGH_ACT |
259 FB_SYNC_VERT_HIGH_ACT),
260 .cmap_greyscale = 0,
261};
262
263static struct pxafb_mach_info generic_crt_640x480 = {
264 .modes = &generic_crt_640x480_mode,
265 .num_modes = 1,
266 .lccr0 = (LCCR0_PAS),
267 .lccr3 = (LCCR3_PixClkDiv(0x01) |
268 LCCR3_Acb(0xff)),
269 .cmap_inverse = 0,
270 .cmap_static = 0,
271};
272
273static struct pxafb_mode_info generic_crt_800x600_mode = {
274 .pixclock = 28846,
275 .bpp = 8,
276 .xres = 800,
277 .yres = 600,
278 .hsync_len = 63,
279 .vsync_len = 2,
280 .left_margin = 26,
281 .upper_margin = 21,
282 .right_margin = 26,
283 .lower_margin = 11,
284 .sync = (FB_SYNC_HOR_HIGH_ACT |
285 FB_SYNC_VERT_HIGH_ACT),
286 .cmap_greyscale = 0,
287};
288
289static struct pxafb_mach_info generic_crt_800x600 = {
290 .modes = &generic_crt_800x600_mode,
291 .num_modes = 1,
292 .lccr0 = (LCCR0_PAS),
293 .lccr3 = (LCCR3_PixClkDiv(0x02) |
294 LCCR3_Acb(0xff)),
295 .cmap_inverse = 0,
296 .cmap_static = 0,
297};
298
299static struct pxafb_mode_info generic_tft_320x240_mode = {
300 .pixclock = 134615,
301 .bpp = 16,
302 .xres = 320,
303 .yres = 240,
304 .hsync_len = 63,
305 .vsync_len = 7,
306 .left_margin = 75,
307 .upper_margin = 0,
308 .right_margin = 15,
309 .lower_margin = 15,
310 .sync = 0,
311 .cmap_greyscale = 0,
312};
313
314static struct pxafb_mach_info generic_tft_320x240 = {
315 .modes = &generic_tft_320x240_mode,
316 .num_modes = 1,
317 .lccr0 = (LCCR0_PAS),
318 .lccr3 = (LCCR3_PixClkDiv(0x06) |
319 LCCR3_Acb(0xff) |
320 LCCR3_PCP),
321 .cmap_inverse = 0,
322 .cmap_static = 0,
323};
324
325static struct pxafb_mode_info generic_stn_640x480_mode = {
326 .pixclock = 57692,
327 .bpp = 8,
328 .xres = 640,
329 .yres = 480,
330 .hsync_len = 4,
331 .vsync_len = 2,
332 .left_margin = 10,
333 .upper_margin = 5,
334 .right_margin = 10,
335 .lower_margin = 5,
336 .sync = (FB_SYNC_HOR_HIGH_ACT |
337 FB_SYNC_VERT_HIGH_ACT),
338 .cmap_greyscale = 0,
339};
340
341static struct pxafb_mach_info generic_stn_640x480 = {
342 .modes = &generic_stn_640x480_mode,
343 .num_modes = 1,
344 .lccr0 = 0,
345 .lccr3 = (LCCR3_PixClkDiv(0x02) |
346 LCCR3_Acb(0xff)),
347 .cmap_inverse = 0,
348 .cmap_static = 0,
349};
350
351static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
352
353static int __init cmx2xx_set_display(char *str)
354{
355 int disp_type = simple_strtol(str, NULL, 0);
356 switch (disp_type) {
357 case MTYPE_STN320x240:
358 cmx2xx_display = &generic_stn_320x240;
359 break;
360 case MTYPE_TFT640x480:
361 cmx2xx_display = &generic_tft_640x480;
362 break;
363 case MTYPE_CRT640x480:
364 cmx2xx_display = &generic_crt_640x480;
365 break;
366 case MTYPE_CRT800x600:
367 cmx2xx_display = &generic_crt_800x600;
368 break;
369 case MTYPE_TFT320x240:
370 cmx2xx_display = &generic_tft_320x240;
371 break;
372 case MTYPE_STN640x480:
373 cmx2xx_display = &generic_stn_640x480;
374 break;
375 default: /* fallback to CRT 640x480 */
376 cmx2xx_display = &generic_crt_640x480;
377 break;
378 }
379 return 1;
380}
381
382/*
383 This should be done really early to get proper configuration for
384 frame buffer.
385 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
386 has limitied line length for kernel command line, and also it will
387 break compatibitlty with proprietary releases already in field.
388*/
389__setup("monitor=", cmx2xx_set_display);
390
391static void __init cmx2xx_init_display(void)
392{
393 set_pxa_fb_info(cmx2xx_display);
394}
395#else
396static inline void cmx2xx_init_display(void) {}
397#endif
398
399#ifdef CONFIG_PM
400static unsigned long sleep_save_msc[10];
401
402static int cmx2xx_suspend(struct sys_device *dev, pm_message_t state)
403{
404 cmx2xx_pci_suspend();
405
406 /* save MSC registers */
407 sleep_save_msc[0] = MSC0;
408 sleep_save_msc[1] = MSC1;
409 sleep_save_msc[2] = MSC2;
410
411 /* setup power saving mode registers */
412 PCFR = 0x0;
413 PSLR = 0xff400000;
414 PMCR = 0x00000005;
415 PWER = 0x80000000;
416 PFER = 0x00000000;
417 PRER = 0x00000000;
418 PGSR0 = 0xC0018800;
419 PGSR1 = 0x004F0002;
420 PGSR2 = 0x6021C000;
421 PGSR3 = 0x00020000;
422
423 return 0;
424}
425
426static int cmx2xx_resume(struct sys_device *dev)
427{
428 cmx2xx_pci_resume();
429
430 /* restore MSC registers */
431 MSC0 = sleep_save_msc[0];
432 MSC1 = sleep_save_msc[1];
433 MSC2 = sleep_save_msc[2];
434
435 return 0;
436}
437
438static struct sysdev_class cmx2xx_pm_sysclass = {
439 .name = "pm",
440 .resume = cmx2xx_resume,
441 .suspend = cmx2xx_suspend,
442};
443
444static struct sys_device cmx2xx_pm_device = {
445 .cls = &cmx2xx_pm_sysclass,
446};
447
448static int __init cmx2xx_pm_init(void)
449{
450 int error;
451 error = sysdev_class_register(&cmx2xx_pm_sysclass);
452 if (error == 0)
453 error = sysdev_register(&cmx2xx_pm_device);
454 return error;
455}
456#else
457static int __init cmx2xx_pm_init(void) { return 0; }
458#endif
459
460#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
461static void __init cmx2xx_init_ac97(void)
462{
463 pxa_set_ac97_info(NULL);
464}
465#else
466static inline void cmx2xx_init_ac97(void) {}
467#endif
468
469static void __init cmx2xx_init(void)
470{
471 cmx2xx_pm_init();
472
473 if (cpu_is_pxa25x())
474 cmx255_init();
475 else
476 cmx270_init();
477
478 cmx2xx_init_dm9000();
479 cmx2xx_init_display();
480 cmx2xx_init_ac97();
481 cmx2xx_init_touchscreen();
482 cmx2xx_init_leds();
483}
484
485static void __init cmx2xx_init_irq(void)
486{
487 pxa27x_init_irq();
488
489 if (cpu_is_pxa25x()) {
490 pxa25x_init_irq();
491 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
492 } else {
493 pxa27x_init_irq();
494 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
495 }
496}
497
498#ifdef CONFIG_PCI
499/* Map PCI companion statically */
500static struct map_desc cmx2xx_io_desc[] __initdata = {
501 [0] = { /* PCI bridge */
502 .virtual = CMX2XX_IT8152_VIRT,
503 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
504 .length = SZ_64M,
505 .type = MT_DEVICE
506 },
507};
508
509static void __init cmx2xx_map_io(void)
510{
511 pxa_map_io();
512 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
513
514 it8152_base_address = CMX2XX_IT8152_VIRT;
515}
516#else
517static void __init cmx2xx_map_io(void)
518{
519 pxa_map_io();
520}
521#endif
522
523MACHINE_START(ARMCORE, "Compulab CM-X2XX")
524 .boot_params = 0xa0000100,
525 .phys_io = 0x40000000,
526 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
527 .map_io = cmx2xx_map_io,
528 .init_irq = cmx2xx_init_irq,
529 .timer = &pxa_timer,
530 .init_machine = cmx2xx_init,
531MACHINE_END
diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c
new file mode 100644
index 000000000000..deb46cd144bf
--- /dev/null
+++ b/arch/arm/mach-pxa/cm-x300.c
@@ -0,0 +1,465 @@
1/*
2 * linux/arch/arm/mach-pxa/cm-x300.c
3 *
4 * Support for the CompuLab CM-X300 modules
5 *
6 * Copyright (C) 2008 CompuLab Ltd.
7 *
8 * Mike Rapoport <mike@compulab.co.il>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/module.h>
16#include <linux/kernel.h>
17#include <linux/interrupt.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20
21#include <linux/gpio.h>
22#include <linux/dm9000.h>
23#include <linux/leds.h>
24
25#include <linux/i2c.h>
26#include <linux/i2c/pca953x.h>
27
28#include <asm/mach-types.h>
29#include <asm/mach/arch.h>
30
31#include <mach/mfp-pxa300.h>
32
33#include <mach/hardware.h>
34#include <mach/gpio.h>
35#include <mach/pxafb.h>
36#include <mach/mmc.h>
37#include <mach/ohci.h>
38#include <mach/i2c.h>
39#include <mach/pxa3xx_nand.h>
40
41#include <asm/mach/map.h>
42
43#include "generic.h"
44
45#define CM_X300_ETH_PHYS 0x08000010
46
47#define GPIO82_MMC2_IRQ (82)
48#define GPIO85_MMC2_WP (85)
49
50#define CM_X300_MMC2_IRQ IRQ_GPIO(GPIO82_MMC2_IRQ)
51
52static mfp_cfg_t cm_x300_mfp_cfg[] __initdata = {
53 /* LCD */
54 GPIO54_LCD_LDD_0,
55 GPIO55_LCD_LDD_1,
56 GPIO56_LCD_LDD_2,
57 GPIO57_LCD_LDD_3,
58 GPIO58_LCD_LDD_4,
59 GPIO59_LCD_LDD_5,
60 GPIO60_LCD_LDD_6,
61 GPIO61_LCD_LDD_7,
62 GPIO62_LCD_LDD_8,
63 GPIO63_LCD_LDD_9,
64 GPIO64_LCD_LDD_10,
65 GPIO65_LCD_LDD_11,
66 GPIO66_LCD_LDD_12,
67 GPIO67_LCD_LDD_13,
68 GPIO68_LCD_LDD_14,
69 GPIO69_LCD_LDD_15,
70 GPIO72_LCD_FCLK,
71 GPIO73_LCD_LCLK,
72 GPIO74_LCD_PCLK,
73 GPIO75_LCD_BIAS,
74
75 /* BTUART */
76 GPIO111_UART2_RTS,
77 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
78 GPIO113_UART2_TXD,
79 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
80
81 /* STUART */
82 GPIO109_UART3_TXD,
83 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
84
85 /* AC97 */
86 GPIO23_AC97_nACRESET,
87 GPIO24_AC97_SYSCLK,
88 GPIO29_AC97_BITCLK,
89 GPIO25_AC97_SDATA_IN_0,
90 GPIO27_AC97_SDATA_OUT,
91 GPIO28_AC97_SYNC,
92
93 /* Keypad */
94 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
95 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
96 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
97 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
98 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
99 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
100 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
101 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
102 GPIO121_KP_MKOUT_0,
103 GPIO122_KP_MKOUT_1,
104 GPIO123_KP_MKOUT_2,
105 GPIO124_KP_MKOUT_3,
106 GPIO125_KP_MKOUT_4,
107 GPIO4_2_KP_MKOUT_5,
108
109 /* MMC1 */
110 GPIO3_MMC1_DAT0,
111 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
112 GPIO5_MMC1_DAT2,
113 GPIO6_MMC1_DAT3,
114 GPIO7_MMC1_CLK,
115 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
116
117 /* MMC2 */
118 GPIO9_MMC2_DAT0,
119 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
120 GPIO11_MMC2_DAT2,
121 GPIO12_MMC2_DAT3,
122 GPIO13_MMC2_CLK,
123 GPIO14_MMC2_CMD,
124
125 /* FFUART */
126 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
127 GPIO31_UART1_TXD,
128 GPIO32_UART1_CTS,
129 GPIO37_UART1_RTS,
130 GPIO33_UART1_DCD,
131 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
132 GPIO35_UART1_RI,
133 GPIO36_UART1_DTR,
134
135 /* GPIOs */
136 GPIO79_GPIO, /* LED */
137 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
138 GPIO85_GPIO, /* MMC WP */
139 GPIO99_GPIO, /* Ethernet IRQ */
140};
141
142#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
143static struct resource dm9000_resources[] = {
144 [0] = {
145 .start = CM_X300_ETH_PHYS,
146 .end = CM_X300_ETH_PHYS + 0x3,
147 .flags = IORESOURCE_MEM,
148 },
149 [1] = {
150 .start = CM_X300_ETH_PHYS + 0x4,
151 .end = CM_X300_ETH_PHYS + 0x4 + 500,
152 .flags = IORESOURCE_MEM,
153 },
154 [2] = {
155 .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
156 .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
157 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
158 }
159};
160
161static struct dm9000_plat_data cm_x300_dm9000_platdata = {
162 .flags = DM9000_PLATF_16BITONLY,
163};
164
165static struct platform_device dm9000_device = {
166 .name = "dm9000",
167 .id = 0,
168 .num_resources = ARRAY_SIZE(dm9000_resources),
169 .resource = dm9000_resources,
170 .dev = {
171 .platform_data = &cm_x300_dm9000_platdata,
172 }
173
174};
175
176static void __init cm_x300_init_dm9000(void)
177{
178 platform_device_register(&dm9000_device);
179}
180#else
181static inline void cm_x300_init_dm9000(void) {}
182#endif
183
184#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
185static struct pxafb_mode_info cm_x300_lcd_modes[] = {
186 [0] = {
187 .pixclock = 38000,
188 .bpp = 16,
189 .xres = 480,
190 .yres = 640,
191 .hsync_len = 8,
192 .vsync_len = 2,
193 .left_margin = 8,
194 .upper_margin = 0,
195 .right_margin = 24,
196 .lower_margin = 4,
197 .cmap_greyscale = 0,
198 },
199 [1] = {
200 .pixclock = 153800,
201 .bpp = 16,
202 .xres = 240,
203 .yres = 320,
204 .hsync_len = 8,
205 .vsync_len = 2,
206 .left_margin = 8,
207 .upper_margin = 2,
208 .right_margin = 88,
209 .lower_margin = 2,
210 .cmap_greyscale = 0,
211 },
212};
213
214static struct pxafb_mach_info cm_x300_lcd = {
215 .modes = cm_x300_lcd_modes,
216 .num_modes = 2,
217 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
218};
219
220static void __init cm_x300_init_lcd(void)
221{
222 set_pxa_fb_info(&cm_x300_lcd);
223}
224#else
225static inline void cm_x300_init_lcd(void) {}
226#endif
227
228#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
229static struct mtd_partition cm_x300_nand_partitions[] = {
230 [0] = {
231 .name = "OBM",
232 .offset = 0,
233 .size = SZ_256K,
234 .mask_flags = MTD_WRITEABLE, /* force read-only */
235 },
236 [1] = {
237 .name = "U-Boot",
238 .offset = MTDPART_OFS_APPEND,
239 .size = SZ_256K,
240 .mask_flags = MTD_WRITEABLE, /* force read-only */
241 },
242 [2] = {
243 .name = "Environment",
244 .offset = MTDPART_OFS_APPEND,
245 .size = SZ_256K,
246 },
247 [3] = {
248 .name = "reserved",
249 .offset = MTDPART_OFS_APPEND,
250 .size = SZ_256K + SZ_1M,
251 .mask_flags = MTD_WRITEABLE, /* force read-only */
252 },
253 [4] = {
254 .name = "kernel",
255 .offset = MTDPART_OFS_APPEND,
256 .size = SZ_4M,
257 },
258 [5] = {
259 .name = "fs",
260 .offset = MTDPART_OFS_APPEND,
261 .size = MTDPART_SIZ_FULL,
262 },
263};
264
265static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
266 .enable_arbiter = 1,
267 .parts = cm_x300_nand_partitions,
268 .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
269};
270
271static void __init cm_x300_init_nand(void)
272{
273 pxa3xx_set_nand_info(&cm_x300_nand_info);
274}
275#else
276static inline void cm_x300_init_nand(void) {}
277#endif
278
279#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
280/* The first MMC slot of CM-X300 is hardwired to Libertas card and has
281 no detection/ro pins */
282static int cm_x300_mci_init(struct device *dev,
283 irq_handler_t cm_x300_detect_int,
284 void *data)
285{
286 return 0;
287}
288
289static void cm_x300_mci_exit(struct device *dev, void *data)
290{
291}
292
293static struct pxamci_platform_data cm_x300_mci_platform_data = {
294 .detect_delay = 20,
295 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
296 .init = cm_x300_mci_init,
297 .exit = cm_x300_mci_exit,
298};
299
300static int cm_x300_mci2_ro(struct device *dev)
301{
302 return gpio_get_value(GPIO85_MMC2_WP);
303}
304
305static int cm_x300_mci2_init(struct device *dev,
306 irq_handler_t cm_x300_detect_int,
307 void *data)
308{
309 int err;
310
311 /*
312 * setup GPIO for CM-X300 MMC controller
313 */
314 err = gpio_request(GPIO82_MMC2_IRQ, "mmc card detect");
315 if (err)
316 goto err_request_cd;
317 gpio_direction_input(GPIO82_MMC2_IRQ);
318
319 err = gpio_request(GPIO85_MMC2_WP, "mmc write protect");
320 if (err)
321 goto err_request_wp;
322 gpio_direction_input(GPIO85_MMC2_WP);
323
324 err = request_irq(CM_X300_MMC2_IRQ, cm_x300_detect_int,
325 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
326 "MMC card detect", data);
327 if (err) {
328 printk(KERN_ERR "%s: MMC/SD/SDIO: "
329 "can't request card detect IRQ\n", __func__);
330 goto err_request_irq;
331 }
332
333 return 0;
334
335err_request_irq:
336 gpio_free(GPIO85_MMC2_WP);
337err_request_wp:
338 gpio_free(GPIO82_MMC2_IRQ);
339err_request_cd:
340 return err;
341}
342
343static void cm_x300_mci2_exit(struct device *dev, void *data)
344{
345 free_irq(CM_X300_MMC2_IRQ, data);
346 gpio_free(GPIO82_MMC2_IRQ);
347 gpio_free(GPIO85_MMC2_WP);
348}
349
350static struct pxamci_platform_data cm_x300_mci2_platform_data = {
351 .detect_delay = 20,
352 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
353 .init = cm_x300_mci2_init,
354 .exit = cm_x300_mci2_exit,
355 .get_ro = cm_x300_mci2_ro,
356};
357
358static void __init cm_x300_init_mmc(void)
359{
360 pxa_set_mci_info(&cm_x300_mci_platform_data);
361 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
362}
363#else
364static inline void cm_x300_init_mmc(void) {}
365#endif
366
367#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
368static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
369 .port_mode = PMM_PERPORT_MODE,
370 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
371};
372
373static void __init cm_x300_init_ohci(void)
374{
375 pxa_set_ohci_info(&cm_x300_ohci_platform_data);
376}
377#else
378static inline void cm_x300_init_ohci(void) {}
379#endif
380
381#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
382static struct gpio_led cm_x300_leds[] = {
383 [0] = {
384 .name = "cm-x300:green",
385 .default_trigger = "heartbeat",
386 .gpio = 79,
387 .active_low = 1,
388 },
389};
390
391static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
392 .num_leds = ARRAY_SIZE(cm_x300_leds),
393 .leds = cm_x300_leds,
394};
395
396static struct platform_device cm_x300_led_device = {
397 .name = "leds-gpio",
398 .id = -1,
399 .dev = {
400 .platform_data = &cm_x300_gpio_led_pdata,
401 },
402};
403
404static void __init cm_x300_init_leds(void)
405{
406 platform_device_register(&cm_x300_led_device);
407}
408#else
409static inline void cm_x300_init_leds(void) {}
410#endif
411
412#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
413/* PCA9555 */
414static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
415 .gpio_base = 128,
416};
417
418static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
419 .gpio_base = 144,
420};
421
422static struct i2c_board_info cm_x300_gpio_ext_info[] = {
423 [0] = {
424 I2C_BOARD_INFO("pca9555", 0x24),
425 .platform_data = &cm_x300_gpio_ext_pdata_0,
426 },
427 [1] = {
428 I2C_BOARD_INFO("pca9555", 0x25),
429 .platform_data = &cm_x300_gpio_ext_pdata_1,
430 },
431};
432
433static void __init cm_x300_init_i2c(void)
434{
435 pxa_set_i2c_info(NULL);
436 i2c_register_board_info(0, cm_x300_gpio_ext_info,
437 ARRAY_SIZE(cm_x300_gpio_ext_info));
438}
439#else
440static inline void cm_x300_init_i2c(void) {}
441#endif
442
443static void __init cm_x300_init(void)
444{
445 /* board-processor specific GPIO initialization */
446 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_mfp_cfg));
447
448 cm_x300_init_dm9000();
449 cm_x300_init_lcd();
450 cm_x300_init_ohci();
451 cm_x300_init_mmc();
452 cm_x300_init_nand();
453 cm_x300_init_leds();
454 cm_x300_init_i2c();
455}
456
457MACHINE_START(CM_X300, "CM-X300 module")
458 .phys_io = 0x40000000,
459 .boot_params = 0xa0000100,
460 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
461 .map_io = pxa_map_io,
462 .init_irq = pxa3xx_init_irq,
463 .timer = &pxa_timer,
464 .init_machine = cm_x300_init,
465MACHINE_END
diff --git a/arch/arm/mach-pxa/colibri.c b/arch/arm/mach-pxa/colibri.c
index abce13c846c5..e8473624427e 100644
--- a/arch/arm/mach-pxa/colibri.c
+++ b/arch/arm/mach-pxa/colibri.c
@@ -29,12 +29,17 @@
29#include <asm/mach/irq.h> 29#include <asm/mach/irq.h>
30#include <asm/mach/flash.h> 30#include <asm/mach/flash.h>
31#include <mach/pxa-regs.h> 31#include <mach/pxa-regs.h>
32#include <mach/pxa2xx-gpio.h> 32#include <mach/mfp-pxa27x.h>
33#include <mach/colibri.h> 33#include <mach/colibri.h>
34 34
35#include "generic.h" 35#include "generic.h"
36#include "devices.h" 36#include "devices.h"
37 37
38static unsigned long colibri_pin_config[] __initdata = {
39 GPIO78_nCS_2, /* Ethernet CS */
40 GPIO114_GPIO, /* Ethernet IRQ */
41};
42
38/* 43/*
39 * Flash 44 * Flash
40 */ 45 */
@@ -116,9 +121,7 @@ static struct platform_device *colibri_devices[] __initdata = {
116 121
117static void __init colibri_init(void) 122static void __init colibri_init(void)
118{ 123{
119 /* DM9000 LAN */ 124 pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pin_config));
120 pxa_gpio_mode(GPIO78_nCS_2_MD);
121 pxa_gpio_mode(GPIO_DM9000 | GPIO_IN);
122 125
123 platform_add_devices(colibri_devices, ARRAY_SIZE(colibri_devices)); 126 platform_add_devices(colibri_devices, ARRAY_SIZE(colibri_devices));
124} 127}
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index e703a8d209e2..65558d6aa220 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -20,7 +20,12 @@
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/mmc/host.h> 21#include <linux/mmc/host.h>
22#include <linux/pm.h> 22#include <linux/pm.h>
23#include <linux/gpio.h>
23#include <linux/backlight.h> 24#include <linux/backlight.h>
25#include <linux/io.h>
26#include <linux/spi/spi.h>
27#include <linux/spi/ads7846.h>
28#include <linux/spi/corgi_lcd.h>
24#include <video/w100fb.h> 29#include <video/w100fb.h>
25 30
26#include <asm/setup.h> 31#include <asm/setup.h>
@@ -28,7 +33,6 @@
28#include <asm/mach-types.h> 33#include <asm/mach-types.h>
29#include <mach/hardware.h> 34#include <mach/hardware.h>
30#include <asm/irq.h> 35#include <asm/irq.h>
31#include <asm/io.h>
32#include <asm/system.h> 36#include <asm/system.h>
33 37
34#include <asm/mach/arch.h> 38#include <asm/mach/arch.h>
@@ -37,11 +41,12 @@
37 41
38#include <mach/pxa-regs.h> 42#include <mach/pxa-regs.h>
39#include <mach/pxa2xx-regs.h> 43#include <mach/pxa2xx-regs.h>
40#include <mach/pxa2xx-gpio.h> 44#include <mach/mfp-pxa25x.h>
41#include <mach/i2c.h> 45#include <mach/i2c.h>
42#include <mach/irda.h> 46#include <mach/irda.h>
43#include <mach/mmc.h> 47#include <mach/mmc.h>
44#include <mach/udc.h> 48#include <mach/udc.h>
49#include <mach/pxa2xx_spi.h>
45#include <mach/corgi.h> 50#include <mach/corgi.h>
46#include <mach/sharpsl.h> 51#include <mach/sharpsl.h>
47 52
@@ -52,6 +57,61 @@
52#include "devices.h" 57#include "devices.h"
53#include "sharpsl.h" 58#include "sharpsl.h"
54 59
60static unsigned long corgi_pin_config[] __initdata = {
61 /* Static Memory I/O */
62 GPIO78_nCS_2, /* w100fb */
63 GPIO80_nCS_4, /* scoop */
64
65 /* SSP1 */
66 GPIO23_SSP1_SCLK,
67 GPIO25_SSP1_TXD,
68 GPIO26_SSP1_RXD,
69 GPIO24_GPIO, /* CORGI_GPIO_ADS7846_CS - SFRM as chip select */
70
71 /* I2S */
72 GPIO28_I2S_BITCLK_OUT,
73 GPIO29_I2S_SDATA_IN,
74 GPIO30_I2S_SDATA_OUT,
75 GPIO31_I2S_SYNC,
76 GPIO32_I2S_SYSCLK,
77
78 /* Infra-Red */
79 GPIO47_FICP_TXD,
80 GPIO46_FICP_RXD,
81
82 /* FFUART */
83 GPIO40_FFUART_DTR,
84 GPIO41_FFUART_RTS,
85 GPIO39_FFUART_TXD,
86 GPIO37_FFUART_DSR,
87 GPIO34_FFUART_RXD,
88 GPIO35_FFUART_CTS,
89
90 /* PC Card */
91 GPIO48_nPOE,
92 GPIO49_nPWE,
93 GPIO50_nPIOR,
94 GPIO51_nPIOW,
95 GPIO52_nPCE_1,
96 GPIO53_nPCE_2,
97 GPIO54_nPSKTSEL,
98 GPIO55_nPREG,
99 GPIO56_nPWAIT,
100 GPIO57_nIOIS16,
101
102 /* MMC */
103 GPIO6_MMC_CLK,
104 GPIO8_MMC_CS0,
105
106 /* GPIO */
107 GPIO9_GPIO, /* CORGI_GPIO_nSD_DETECT */
108 GPIO7_GPIO, /* CORGI_GPIO_nSD_WP */
109 GPIO33_GPIO, /* CORGI_GPIO_SD_PWR */
110 GPIO22_GPIO, /* CORGI_GPIO_IR_ON */
111 GPIO44_GPIO, /* CORGI_GPIO_HSYNC */
112
113 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
114};
55 115
56/* 116/*
57 * Corgi SCOOP Device 117 * Corgi SCOOP Device
@@ -67,6 +127,7 @@ static struct resource corgi_scoop_resources[] = {
67static struct scoop_config corgi_scoop_setup = { 127static struct scoop_config corgi_scoop_setup = {
68 .io_dir = CORGI_SCOOP_IO_DIR, 128 .io_dir = CORGI_SCOOP_IO_DIR,
69 .io_out = CORGI_SCOOP_IO_OUT, 129 .io_out = CORGI_SCOOP_IO_OUT,
130 .gpio_base = CORGI_SCOOP_GPIO_BASE,
70}; 131};
71 132
72struct platform_device corgiscoop_device = { 133struct platform_device corgiscoop_device = {
@@ -79,27 +140,6 @@ struct platform_device corgiscoop_device = {
79 .resource = corgi_scoop_resources, 140 .resource = corgi_scoop_resources,
80}; 141};
81 142
82static void corgi_pcmcia_init(void)
83{
84 /* Setup default state of GPIO outputs
85 before we enable them as outputs. */
86 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
87 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
88 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
89 GPIO_bit(GPIO53_nPCE_2);
90
91 pxa_gpio_mode(GPIO48_nPOE_MD);
92 pxa_gpio_mode(GPIO49_nPWE_MD);
93 pxa_gpio_mode(GPIO50_nPIOR_MD);
94 pxa_gpio_mode(GPIO51_nPIOW_MD);
95 pxa_gpio_mode(GPIO55_nPREG_MD);
96 pxa_gpio_mode(GPIO56_nPWAIT_MD);
97 pxa_gpio_mode(GPIO57_nIOIS16_MD);
98 pxa_gpio_mode(GPIO52_nPCE_1_MD);
99 pxa_gpio_mode(GPIO53_nPCE_2_MD);
100 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
101}
102
103static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = { 143static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
104{ 144{
105 .dev = &corgiscoop_device.dev, 145 .dev = &corgiscoop_device.dev,
@@ -112,58 +152,10 @@ static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
112static struct scoop_pcmcia_config corgi_pcmcia_config = { 152static struct scoop_pcmcia_config corgi_pcmcia_config = {
113 .devs = &corgi_pcmcia_scoop[0], 153 .devs = &corgi_pcmcia_scoop[0],
114 .num_devs = 1, 154 .num_devs = 1,
115 .pcmcia_init = corgi_pcmcia_init,
116}; 155};
117 156
118EXPORT_SYMBOL(corgiscoop_device); 157EXPORT_SYMBOL(corgiscoop_device);
119 158
120
121/*
122 * Corgi SSP Device
123 *
124 * Set the parent as the scoop device because a lot of SSP devices
125 * also use scoop functions and this makes the power up/down order
126 * work correctly.
127 */
128struct platform_device corgissp_device = {
129 .name = "corgi-ssp",
130 .dev = {
131 .parent = &corgiscoop_device.dev,
132 },
133 .id = -1,
134};
135
136struct corgissp_machinfo corgi_ssp_machinfo = {
137 .port = 1,
138 .cs_lcdcon = CORGI_GPIO_LCDCON_CS,
139 .cs_ads7846 = CORGI_GPIO_ADS7846_CS,
140 .cs_max1111 = CORGI_GPIO_MAX1111_CS,
141 .clk_lcdcon = 76,
142 .clk_ads7846 = 2,
143 .clk_max1111 = 8,
144};
145
146
147/*
148 * LCD/Framebuffer
149 */
150static void w100_lcdtg_suspend(struct w100fb_par *par)
151{
152 corgi_lcdtg_suspend();
153}
154
155static void w100_lcdtg_init(struct w100fb_par *par)
156{
157 corgi_lcdtg_hw_init(par->xres);
158}
159
160
161static struct w100_tg_info corgi_lcdtg_info = {
162 .change = w100_lcdtg_init,
163 .suspend = w100_lcdtg_suspend,
164 .resume = w100_lcdtg_init,
165};
166
167static struct w100_mem_info corgi_fb_mem = { 159static struct w100_mem_info corgi_fb_mem = {
168 .ext_cntl = 0x00040003, 160 .ext_cntl = 0x00040003,
169 .sdram_mode_reg = 0x00650021, 161 .sdram_mode_reg = 0x00650021,
@@ -242,7 +234,6 @@ static struct w100_mode corgi_fb_modes[] = {
242}; 234};
243 235
244static struct w100fb_mach_info corgi_fb_info = { 236static struct w100fb_mach_info corgi_fb_info = {
245 .tg = &corgi_lcdtg_info,
246 .init_mode = INIT_MODE_ROTATED, 237 .init_mode = INIT_MODE_ROTATED,
247 .mem = &corgi_fb_mem, 238 .mem = &corgi_fb_mem,
248 .regs = &corgi_fb_regs, 239 .regs = &corgi_fb_regs,
@@ -268,60 +259,10 @@ static struct platform_device corgifb_device = {
268 .resource = corgi_fb_resources, 259 .resource = corgi_fb_resources,
269 .dev = { 260 .dev = {
270 .platform_data = &corgi_fb_info, 261 .platform_data = &corgi_fb_info,
271 .parent = &corgissp_device.dev,
272 }, 262 },
273 263
274}; 264};
275 265
276
277/*
278 * Corgi Backlight Device
279 */
280static void corgi_bl_kick_battery(void)
281{
282 void (*kick_batt)(void);
283
284 kick_batt = symbol_get(sharpsl_battery_kick);
285 if (kick_batt) {
286 kick_batt();
287 symbol_put(sharpsl_battery_kick);
288 }
289}
290
291static void corgi_bl_set_intensity(int intensity)
292{
293 if (intensity > 0x10)
294 intensity += 0x10;
295
296 /* Bits 0-4 are accessed via the SSP interface */
297 corgi_ssp_blduty_set(intensity & 0x1f);
298
299 /* Bit 5 is via SCOOP */
300 if (intensity & 0x0020)
301 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
302 else
303 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
304}
305
306static struct generic_bl_info corgi_bl_machinfo = {
307 .name = "corgi-bl",
308 .max_intensity = 0x2f,
309 .default_intensity = 0x1f,
310 .limit_mask = 0x0b,
311 .set_bl_intensity = corgi_bl_set_intensity,
312 .kick_battery = corgi_bl_kick_battery,
313};
314
315static struct platform_device corgibl_device = {
316 .name = "generic-bl",
317 .dev = {
318 .parent = &corgifb_device.dev,
319 .platform_data = &corgi_bl_machinfo,
320 },
321 .id = -1,
322};
323
324
325/* 266/*
326 * Corgi Keyboard Device 267 * Corgi Keyboard Device
327 */ 268 */
@@ -330,75 +271,35 @@ static struct platform_device corgikbd_device = {
330 .id = -1, 271 .id = -1,
331}; 272};
332 273
333
334/* 274/*
335 * Corgi LEDs 275 * Corgi LEDs
336 */ 276 */
337static struct platform_device corgiled_device = { 277static struct gpio_led corgi_gpio_leds[] = {
338 .name = "corgi-led", 278 {
339 .id = -1, 279 .name = "corgi:amber:charge",
340}; 280 .default_trigger = "sharpsl-charge",
341 281 .gpio = CORGI_GPIO_LED_ORANGE,
342 282 },
343/* 283 {
344 * Corgi Touch Screen Device 284 .name = "corgi:green:mail",
345 */ 285 .default_trigger = "nand-disk",
346static unsigned long (*get_hsync_invperiod)(struct device *dev); 286 .gpio = CORGI_GPIO_LED_GREEN,
347
348static void inline sharpsl_wait_sync(int gpio)
349{
350 while((GPLR(gpio) & GPIO_bit(gpio)) == 0);
351 while((GPLR(gpio) & GPIO_bit(gpio)) != 0);
352}
353
354static unsigned long corgi_get_hsync_invperiod(void)
355{
356 if (!get_hsync_invperiod)
357 get_hsync_invperiod = symbol_get(w100fb_get_hsynclen);
358 if (!get_hsync_invperiod)
359 return 0;
360
361 return get_hsync_invperiod(&corgifb_device.dev);
362}
363
364static void corgi_put_hsync(void)
365{
366 if (get_hsync_invperiod)
367 symbol_put(w100fb_get_hsynclen);
368 get_hsync_invperiod = NULL;
369}
370
371static void corgi_wait_hsync(void)
372{
373 sharpsl_wait_sync(CORGI_GPIO_HSYNC);
374}
375
376static struct resource corgits_resources[] = {
377 [0] = {
378 .start = CORGI_IRQ_GPIO_TP_INT,
379 .end = CORGI_IRQ_GPIO_TP_INT,
380 .flags = IORESOURCE_IRQ,
381 }, 287 },
382}; 288};
383 289
384static struct corgits_machinfo corgi_ts_machinfo = { 290static struct gpio_led_platform_data corgi_gpio_leds_info = {
385 .get_hsync_invperiod = corgi_get_hsync_invperiod, 291 .leds = corgi_gpio_leds,
386 .put_hsync = corgi_put_hsync, 292 .num_leds = ARRAY_SIZE(corgi_gpio_leds),
387 .wait_hsync = corgi_wait_hsync,
388}; 293};
389 294
390static struct platform_device corgits_device = { 295static struct platform_device corgiled_device = {
391 .name = "corgi-ts", 296 .name = "leds-gpio",
297 .id = -1,
392 .dev = { 298 .dev = {
393 .parent = &corgissp_device.dev, 299 .platform_data = &corgi_gpio_leds_info,
394 .platform_data = &corgi_ts_machinfo,
395 }, 300 },
396 .id = -1,
397 .num_resources = ARRAY_SIZE(corgits_resources),
398 .resource = corgits_resources,
399}; 301};
400 302
401
402/* 303/*
403 * MMC/SD Device 304 * MMC/SD Device
404 * 305 *
@@ -411,20 +312,42 @@ static int corgi_mci_init(struct device *dev, irq_handler_t corgi_detect_int, vo
411{ 312{
412 int err; 313 int err;
413 314
414 /* setup GPIO for PXA25x MMC controller */ 315 err = gpio_request(CORGI_GPIO_nSD_DETECT, "nSD_DETECT");
415 pxa_gpio_mode(GPIO6_MMCCLK_MD); 316 if (err)
416 pxa_gpio_mode(GPIO8_MMCCS0_MD); 317 goto err_out;
417 pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN);
418 pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT);
419 318
420 corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250); 319 err = gpio_request(CORGI_GPIO_nSD_WP, "nSD_WP");
320 if (err)
321 goto err_free_1;
421 322
422 err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int, 323 err = gpio_request(CORGI_GPIO_SD_PWR, "SD_PWR");
423 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
424 "MMC card detect", data);
425 if (err) 324 if (err)
426 printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); 325 goto err_free_2;
427 326
327 gpio_direction_input(CORGI_GPIO_nSD_DETECT);
328 gpio_direction_input(CORGI_GPIO_nSD_WP);
329 gpio_direction_output(CORGI_GPIO_SD_PWR, 0);
330
331 corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250);
332
333 err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int,
334 IRQF_DISABLED | IRQF_TRIGGER_RISING |
335 IRQF_TRIGGER_FALLING,
336 "MMC card detect", data);
337 if (err) {
338 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
339 __func__);
340 goto err_free_3;
341 }
342 return 0;
343
344err_free_3:
345 gpio_free(CORGI_GPIO_SD_PWR);
346err_free_2:
347 gpio_free(CORGI_GPIO_nSD_WP);
348err_free_1:
349 gpio_free(CORGI_GPIO_nSD_DETECT);
350err_out:
428 return err; 351 return err;
429} 352}
430 353
@@ -432,20 +355,20 @@ static void corgi_mci_setpower(struct device *dev, unsigned int vdd)
432{ 355{
433 struct pxamci_platform_data* p_d = dev->platform_data; 356 struct pxamci_platform_data* p_d = dev->platform_data;
434 357
435 if (( 1 << vdd) & p_d->ocr_mask) 358 gpio_set_value(CORGI_GPIO_SD_PWR, ((1 << vdd) & p_d->ocr_mask));
436 GPSR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
437 else
438 GPCR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
439} 359}
440 360
441static int corgi_mci_get_ro(struct device *dev) 361static int corgi_mci_get_ro(struct device *dev)
442{ 362{
443 return GPLR(CORGI_GPIO_nSD_WP) & GPIO_bit(CORGI_GPIO_nSD_WP); 363 return gpio_get_value(CORGI_GPIO_nSD_WP);
444} 364}
445 365
446static void corgi_mci_exit(struct device *dev, void *data) 366static void corgi_mci_exit(struct device *dev, void *data)
447{ 367{
448 free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data); 368 free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data);
369 gpio_free(CORGI_GPIO_SD_PWR);
370 gpio_free(CORGI_GPIO_nSD_WP);
371 gpio_free(CORGI_GPIO_nSD_DETECT);
449} 372}
450 373
451static struct pxamci_platform_data corgi_mci_platform_data = { 374static struct pxamci_platform_data corgi_mci_platform_data = {
@@ -462,16 +385,32 @@ static struct pxamci_platform_data corgi_mci_platform_data = {
462 */ 385 */
463static void corgi_irda_transceiver_mode(struct device *dev, int mode) 386static void corgi_irda_transceiver_mode(struct device *dev, int mode)
464{ 387{
465 if (mode & IR_OFF) 388 gpio_set_value(CORGI_GPIO_IR_ON, mode & IR_OFF);
466 GPSR(CORGI_GPIO_IR_ON) = GPIO_bit(CORGI_GPIO_IR_ON);
467 else
468 GPCR(CORGI_GPIO_IR_ON) = GPIO_bit(CORGI_GPIO_IR_ON);
469 pxa2xx_transceiver_mode(dev, mode); 389 pxa2xx_transceiver_mode(dev, mode);
470} 390}
471 391
392static int corgi_irda_startup(struct device *dev)
393{
394 int err;
395
396 err = gpio_request(CORGI_GPIO_IR_ON, "IR_ON");
397 if (err)
398 return err;
399
400 gpio_direction_output(CORGI_GPIO_IR_ON, 1);
401 return 0;
402}
403
404static void corgi_irda_shutdown(struct device *dev)
405{
406 gpio_free(CORGI_GPIO_IR_ON);
407}
408
472static struct pxaficp_platform_data corgi_ficp_platform_data = { 409static struct pxaficp_platform_data corgi_ficp_platform_data = {
473 .transceiver_cap = IR_SIRMODE | IR_OFF, 410 .transceiver_cap = IR_SIRMODE | IR_OFF,
474 .transceiver_mode = corgi_irda_transceiver_mode, 411 .transceiver_mode = corgi_irda_transceiver_mode,
412 .startup = corgi_irda_startup,
413 .shutdown = corgi_irda_shutdown,
475}; 414};
476 415
477 416
@@ -483,14 +422,129 @@ static struct pxa2xx_udc_mach_info udc_info __initdata = {
483 .gpio_pullup = CORGI_GPIO_USB_PULLUP, 422 .gpio_pullup = CORGI_GPIO_USB_PULLUP,
484}; 423};
485 424
425#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MASTER)
426static struct pxa2xx_spi_master corgi_spi_info = {
427 .num_chipselect = 3,
428};
429
430static struct ads7846_platform_data corgi_ads7846_info = {
431 .model = 7846,
432 .vref_delay_usecs = 100,
433 .x_plate_ohms = 419,
434 .y_plate_ohms = 486,
435 .gpio_pendown = CORGI_GPIO_TP_INT,
436};
437
438static void corgi_ads7846_cs(u32 command)
439{
440 gpio_set_value(CORGI_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
441}
442
443static struct pxa2xx_spi_chip corgi_ads7846_chip = {
444 .cs_control = corgi_ads7846_cs,
445};
446
447static void corgi_bl_kick_battery(void)
448{
449 void (*kick_batt)(void);
450
451 kick_batt = symbol_get(sharpsl_battery_kick);
452 if (kick_batt) {
453 kick_batt();
454 symbol_put(sharpsl_battery_kick);
455 }
456}
457
458static struct corgi_lcd_platform_data corgi_lcdcon_info = {
459 .init_mode = CORGI_LCD_MODE_VGA,
460 .max_intensity = 0x2f,
461 .default_intensity = 0x1f,
462 .limit_mask = 0x0b,
463 .gpio_backlight_cont = CORGI_GPIO_BACKLIGHT_CONT,
464 .gpio_backlight_on = -1,
465 .kick_battery = corgi_bl_kick_battery,
466};
467
468static void corgi_lcdcon_cs(u32 command)
469{
470 gpio_set_value(CORGI_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
471}
472
473static struct pxa2xx_spi_chip corgi_lcdcon_chip = {
474 .cs_control = corgi_lcdcon_cs,
475};
476
477static void corgi_max1111_cs(u32 command)
478{
479 gpio_set_value(CORGI_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
480}
481
482static struct pxa2xx_spi_chip corgi_max1111_chip = {
483 .cs_control = corgi_max1111_cs,
484};
485
486static struct spi_board_info corgi_spi_devices[] = {
487 {
488 .modalias = "ads7846",
489 .max_speed_hz = 1200000,
490 .bus_num = 1,
491 .chip_select = 0,
492 .platform_data = &corgi_ads7846_info,
493 .controller_data= &corgi_ads7846_chip,
494 .irq = gpio_to_irq(CORGI_GPIO_TP_INT),
495 }, {
496 .modalias = "corgi-lcd",
497 .max_speed_hz = 50000,
498 .bus_num = 1,
499 .chip_select = 1,
500 .platform_data = &corgi_lcdcon_info,
501 .controller_data= &corgi_lcdcon_chip,
502 }, {
503 .modalias = "max1111",
504 .max_speed_hz = 450000,
505 .bus_num = 1,
506 .chip_select = 2,
507 .controller_data= &corgi_max1111_chip,
508 },
509};
510
511static void __init corgi_init_spi(void)
512{
513 int err;
514
515 err = gpio_request(CORGI_GPIO_ADS7846_CS, "ADS7846_CS");
516 if (err)
517 return;
518
519 err = gpio_request(CORGI_GPIO_LCDCON_CS, "LCDCON_CS");
520 if (err)
521 goto err_free_1;
522
523 err = gpio_request(CORGI_GPIO_MAX1111_CS, "MAX1111_CS");
524 if (err)
525 goto err_free_2;
526
527 gpio_direction_output(CORGI_GPIO_ADS7846_CS, 1);
528 gpio_direction_output(CORGI_GPIO_LCDCON_CS, 1);
529 gpio_direction_output(CORGI_GPIO_MAX1111_CS, 1);
530
531 pxa2xx_set_spi_info(1, &corgi_spi_info);
532 spi_register_board_info(ARRAY_AND_SIZE(corgi_spi_devices));
533 return;
534
535err_free_2:
536 gpio_free(CORGI_GPIO_LCDCON_CS);
537err_free_1:
538 gpio_free(CORGI_GPIO_ADS7846_CS);
539}
540#else
541static inline void corgi_init_spi(void) {}
542#endif
486 543
487static struct platform_device *devices[] __initdata = { 544static struct platform_device *devices[] __initdata = {
488 &corgiscoop_device, 545 &corgiscoop_device,
489 &corgissp_device,
490 &corgifb_device, 546 &corgifb_device,
491 &corgikbd_device, 547 &corgikbd_device,
492 &corgibl_device,
493 &corgits_device,
494 &corgiled_device, 548 &corgiled_device,
495}; 549};
496 550
@@ -498,7 +552,8 @@ static void corgi_poweroff(void)
498{ 552{
499 if (!machine_is_corgi()) 553 if (!machine_is_corgi())
500 /* Green LED off tells the bootloader to halt */ 554 /* Green LED off tells the bootloader to halt */
501 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); 555 gpio_set_value(CORGI_GPIO_LED_GREEN, 0);
556
502 arm_machine_restart('h'); 557 arm_machine_restart('h');
503} 558}
504 559
@@ -506,7 +561,8 @@ static void corgi_restart(char mode)
506{ 561{
507 if (!machine_is_corgi()) 562 if (!machine_is_corgi())
508 /* Green LED on tells the bootloader to reboot */ 563 /* Green LED on tells the bootloader to reboot */
509 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); 564 gpio_set_value(CORGI_GPIO_LED_GREEN, 1);
565
510 arm_machine_restart('h'); 566 arm_machine_restart('h');
511} 567}
512 568
@@ -515,20 +571,12 @@ static void __init corgi_init(void)
515 pm_power_off = corgi_poweroff; 571 pm_power_off = corgi_poweroff;
516 arm_pm_restart = corgi_restart; 572 arm_pm_restart = corgi_restart;
517 573
518 /* setup sleep mode values */
519 PWER = 0x00000002;
520 PFER = 0x00000000;
521 PRER = 0x00000002;
522 PGSR0 = 0x0158C000;
523 PGSR1 = 0x00FF0080;
524 PGSR2 = 0x0001C004;
525 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ 574 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
526 PCFR |= PCFR_OPDE; 575 PCFR |= PCFR_OPDE;
527 576
528 corgi_ssp_set_machinfo(&corgi_ssp_machinfo); 577 pxa2xx_mfp_config(ARRAY_AND_SIZE(corgi_pin_config));
529 578
530 pxa_gpio_mode(CORGI_GPIO_IR_ON | GPIO_OUT); 579 corgi_init_spi();
531 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
532 580
533 pxa_set_udc_info(&udc_info); 581 pxa_set_udc_info(&udc_info);
534 pxa_set_mci_info(&corgi_mci_platform_data); 582 pxa_set_mci_info(&corgi_mci_platform_data);
diff --git a/arch/arm/mach-pxa/corgi_lcd.c b/arch/arm/mach-pxa/corgi_lcd.c
deleted file mode 100644
index 311baf149b07..000000000000
--- a/arch/arm/mach-pxa/corgi_lcd.c
+++ /dev/null
@@ -1,290 +0,0 @@
1/*
2 * linux/arch/arm/mach-pxa/corgi_lcd.c
3 *
4 * Corgi/Spitz LCD Specific Code
5 *
6 * Copyright (C) 2005 Richard Purdie
7 *
8 * Connectivity:
9 * Corgi - LCD to ATI Imageon w100 (Wallaby)
10 * Spitz - LCD to PXA Framebuffer
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 */
17
18#include <linux/delay.h>
19#include <linux/kernel.h>
20#include <linux/platform_device.h>
21#include <linux/module.h>
22#include <linux/string.h>
23#include <mach/akita.h>
24#include <mach/corgi.h>
25#include <mach/hardware.h>
26#include <mach/pxa-regs.h>
27#include <mach/sharpsl.h>
28#include <mach/spitz.h>
29#include <asm/hardware/scoop.h>
30#include <asm/mach/sharpsl_param.h>
31#include "generic.h"
32
33/* Register Addresses */
34#define RESCTL_ADRS 0x00
35#define PHACTRL_ADRS 0x01
36#define DUTYCTRL_ADRS 0x02
37#define POWERREG0_ADRS 0x03
38#define POWERREG1_ADRS 0x04
39#define GPOR3_ADRS 0x05
40#define PICTRL_ADRS 0x06
41#define POLCTRL_ADRS 0x07
42
43/* Register Bit Definitions */
44#define RESCTL_QVGA 0x01
45#define RESCTL_VGA 0x00
46
47#define POWER1_VW_ON 0x01 /* VW Supply FET ON */
48#define POWER1_GVSS_ON 0x02 /* GVSS(-8V) Power Supply ON */
49#define POWER1_VDD_ON 0x04 /* VDD(8V),SVSS(-4V) Power Supply ON */
50
51#define POWER1_VW_OFF 0x00 /* VW Supply FET OFF */
52#define POWER1_GVSS_OFF 0x00 /* GVSS(-8V) Power Supply OFF */
53#define POWER1_VDD_OFF 0x00 /* VDD(8V),SVSS(-4V) Power Supply OFF */
54
55#define POWER0_COM_DCLK 0x01 /* COM Voltage DC Bias DAC Serial Data Clock */
56#define POWER0_COM_DOUT 0x02 /* COM Voltage DC Bias DAC Serial Data Out */
57#define POWER0_DAC_ON 0x04 /* DAC Power Supply ON */
58#define POWER0_COM_ON 0x08 /* COM Power Supply ON */
59#define POWER0_VCC5_ON 0x10 /* VCC5 Power Supply ON */
60
61#define POWER0_DAC_OFF 0x00 /* DAC Power Supply OFF */
62#define POWER0_COM_OFF 0x00 /* COM Power Supply OFF */
63#define POWER0_VCC5_OFF 0x00 /* VCC5 Power Supply OFF */
64
65#define PICTRL_INIT_STATE 0x01
66#define PICTRL_INIOFF 0x02
67#define PICTRL_POWER_DOWN 0x04
68#define PICTRL_COM_SIGNAL_OFF 0x08
69#define PICTRL_DAC_SIGNAL_OFF 0x10
70
71#define POLCTRL_SYNC_POL_FALL 0x01
72#define POLCTRL_EN_POL_FALL 0x02
73#define POLCTRL_DATA_POL_FALL 0x04
74#define POLCTRL_SYNC_ACT_H 0x08
75#define POLCTRL_EN_ACT_L 0x10
76
77#define POLCTRL_SYNC_POL_RISE 0x00
78#define POLCTRL_EN_POL_RISE 0x00
79#define POLCTRL_DATA_POL_RISE 0x00
80#define POLCTRL_SYNC_ACT_L 0x00
81#define POLCTRL_EN_ACT_H 0x00
82
83#define PHACTRL_PHASE_MANUAL 0x01
84#define DEFAULT_PHAD_QVGA (9)
85#define DEFAULT_COMADJ (125)
86
87/*
88 * This is only a psuedo I2C interface. We can't use the standard kernel
89 * routines as the interface is write only. We just assume the data is acked...
90 */
91static void lcdtg_ssp_i2c_send(u8 data)
92{
93 corgi_ssp_lcdtg_send(POWERREG0_ADRS, data);
94 udelay(10);
95}
96
97static void lcdtg_i2c_send_bit(u8 data)
98{
99 lcdtg_ssp_i2c_send(data);
100 lcdtg_ssp_i2c_send(data | POWER0_COM_DCLK);
101 lcdtg_ssp_i2c_send(data);
102}
103
104static void lcdtg_i2c_send_start(u8 base)
105{
106 lcdtg_ssp_i2c_send(base | POWER0_COM_DCLK | POWER0_COM_DOUT);
107 lcdtg_ssp_i2c_send(base | POWER0_COM_DCLK);
108 lcdtg_ssp_i2c_send(base);
109}
110
111static void lcdtg_i2c_send_stop(u8 base)
112{
113 lcdtg_ssp_i2c_send(base);
114 lcdtg_ssp_i2c_send(base | POWER0_COM_DCLK);
115 lcdtg_ssp_i2c_send(base | POWER0_COM_DCLK | POWER0_COM_DOUT);
116}
117
118static void lcdtg_i2c_send_byte(u8 base, u8 data)
119{
120 int i;
121 for (i = 0; i < 8; i++) {
122 if (data & 0x80)
123 lcdtg_i2c_send_bit(base | POWER0_COM_DOUT);
124 else
125 lcdtg_i2c_send_bit(base);
126 data <<= 1;
127 }
128}
129
130static void lcdtg_i2c_wait_ack(u8 base)
131{
132 lcdtg_i2c_send_bit(base);
133}
134
135static void lcdtg_set_common_voltage(u8 base_data, u8 data)
136{
137 /* Set Common Voltage to M62332FP via I2C */
138 lcdtg_i2c_send_start(base_data);
139 lcdtg_i2c_send_byte(base_data, 0x9c);
140 lcdtg_i2c_wait_ack(base_data);
141 lcdtg_i2c_send_byte(base_data, 0x00);
142 lcdtg_i2c_wait_ack(base_data);
143 lcdtg_i2c_send_byte(base_data, data);
144 lcdtg_i2c_wait_ack(base_data);
145 lcdtg_i2c_send_stop(base_data);
146}
147
148/* Set Phase Adjust */
149static void lcdtg_set_phadadj(int mode)
150{
151 int adj;
152 switch(mode) {
153 case 480:
154 case 640:
155 /* Setting for VGA */
156 adj = sharpsl_param.phadadj;
157 if (adj < 0) {
158 adj = PHACTRL_PHASE_MANUAL;
159 } else {
160 adj = ((adj & 0x0f) << 1) | PHACTRL_PHASE_MANUAL;
161 }
162 break;
163 case 240:
164 case 320:
165 default:
166 /* Setting for QVGA */
167 adj = (DEFAULT_PHAD_QVGA << 1) | PHACTRL_PHASE_MANUAL;
168 break;
169 }
170
171 corgi_ssp_lcdtg_send(PHACTRL_ADRS, adj);
172}
173
174static int lcd_inited;
175
176void corgi_lcdtg_hw_init(int mode)
177{
178 if (!lcd_inited) {
179 int comadj;
180
181 /* Initialize Internal Logic & Port */
182 corgi_ssp_lcdtg_send(PICTRL_ADRS, PICTRL_POWER_DOWN | PICTRL_INIOFF | PICTRL_INIT_STATE
183 | PICTRL_COM_SIGNAL_OFF | PICTRL_DAC_SIGNAL_OFF);
184
185 corgi_ssp_lcdtg_send(POWERREG0_ADRS, POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_OFF
186 | POWER0_COM_OFF | POWER0_VCC5_OFF);
187
188 corgi_ssp_lcdtg_send(POWERREG1_ADRS, POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF);
189
190 /* VDD(+8V), SVSS(-4V) ON */
191 corgi_ssp_lcdtg_send(POWERREG1_ADRS, POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON);
192 mdelay(3);
193
194 /* DAC ON */
195 corgi_ssp_lcdtg_send(POWERREG0_ADRS, POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON
196 | POWER0_COM_OFF | POWER0_VCC5_OFF);
197
198 /* INIB = H, INI = L */
199 /* PICTL[0] = H , PICTL[1] = PICTL[2] = PICTL[4] = L */
200 corgi_ssp_lcdtg_send(PICTRL_ADRS, PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF);
201
202 /* Set Common Voltage */
203 comadj = sharpsl_param.comadj;
204 if (comadj < 0)
205 comadj = DEFAULT_COMADJ;
206 lcdtg_set_common_voltage((POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_OFF), comadj);
207
208 /* VCC5 ON, DAC ON */
209 corgi_ssp_lcdtg_send(POWERREG0_ADRS, POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON |
210 POWER0_COM_OFF | POWER0_VCC5_ON);
211
212 /* GVSS(-8V) ON, VDD ON */
213 corgi_ssp_lcdtg_send(POWERREG1_ADRS, POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON);
214 mdelay(2);
215
216 /* COM SIGNAL ON (PICTL[3] = L) */
217 corgi_ssp_lcdtg_send(PICTRL_ADRS, PICTRL_INIT_STATE);
218
219 /* COM ON, DAC ON, VCC5_ON */
220 corgi_ssp_lcdtg_send(POWERREG0_ADRS, POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON
221 | POWER0_COM_ON | POWER0_VCC5_ON);
222
223 /* VW ON, GVSS ON, VDD ON */
224 corgi_ssp_lcdtg_send(POWERREG1_ADRS, POWER1_VW_ON | POWER1_GVSS_ON | POWER1_VDD_ON);
225
226 /* Signals output enable */
227 corgi_ssp_lcdtg_send(PICTRL_ADRS, 0);
228
229 /* Set Phase Adjust */
230 lcdtg_set_phadadj(mode);
231
232 /* Initialize for Input Signals from ATI */
233 corgi_ssp_lcdtg_send(POLCTRL_ADRS, POLCTRL_SYNC_POL_RISE | POLCTRL_EN_POL_RISE
234 | POLCTRL_DATA_POL_RISE | POLCTRL_SYNC_ACT_L | POLCTRL_EN_ACT_H);
235 udelay(1000);
236
237 lcd_inited=1;
238 } else {
239 lcdtg_set_phadadj(mode);
240 }
241
242 switch(mode) {
243 case 480:
244 case 640:
245 /* Set Lcd Resolution (VGA) */
246 corgi_ssp_lcdtg_send(RESCTL_ADRS, RESCTL_VGA);
247 break;
248 case 240:
249 case 320:
250 default:
251 /* Set Lcd Resolution (QVGA) */
252 corgi_ssp_lcdtg_send(RESCTL_ADRS, RESCTL_QVGA);
253 break;
254 }
255}
256
257void corgi_lcdtg_suspend(void)
258{
259 /* 60Hz x 2 frame = 16.7msec x 2 = 33.4 msec */
260 mdelay(34);
261
262 /* (1)VW OFF */
263 corgi_ssp_lcdtg_send(POWERREG1_ADRS, POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON);
264
265 /* (2)COM OFF */
266 corgi_ssp_lcdtg_send(PICTRL_ADRS, PICTRL_COM_SIGNAL_OFF);
267 corgi_ssp_lcdtg_send(POWERREG0_ADRS, POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_ON);
268
269 /* (3)Set Common Voltage Bias 0V */
270 lcdtg_set_common_voltage(POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_ON, 0);
271
272 /* (4)GVSS OFF */
273 corgi_ssp_lcdtg_send(POWERREG1_ADRS, POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON);
274
275 /* (5)VCC5 OFF */
276 corgi_ssp_lcdtg_send(POWERREG0_ADRS, POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_OFF);
277
278 /* (6)Set PDWN, INIOFF, DACOFF */
279 corgi_ssp_lcdtg_send(PICTRL_ADRS, PICTRL_INIOFF | PICTRL_DAC_SIGNAL_OFF |
280 PICTRL_POWER_DOWN | PICTRL_COM_SIGNAL_OFF);
281
282 /* (7)DAC OFF */
283 corgi_ssp_lcdtg_send(POWERREG0_ADRS, POWER0_DAC_OFF | POWER0_COM_OFF | POWER0_VCC5_OFF);
284
285 /* (8)VDD OFF */
286 corgi_ssp_lcdtg_send(POWERREG1_ADRS, POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF);
287
288 lcd_inited = 0;
289}
290
diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c
index 35bbfccd2df3..eb7d6c94aa42 100644
--- a/arch/arm/mach-pxa/corgi_pm.c
+++ b/arch/arm/mach-pxa/corgi_pm.c
@@ -21,7 +21,6 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <asm/hardware/scoop.h>
25 24
26#include <mach/sharpsl.h> 25#include <mach/sharpsl.h>
27#include <mach/corgi.h> 26#include <mach/corgi.h>
diff --git a/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c
deleted file mode 100644
index 8e2f2215c4ba..000000000000
--- a/arch/arm/mach-pxa/corgi_ssp.c
+++ /dev/null
@@ -1,276 +0,0 @@
1/*
2 * SSP control code for Sharp Corgi devices
3 *
4 * Copyright (c) 2004-2005 Richard Purdie
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/sched.h>
16#include <linux/slab.h>
17#include <linux/delay.h>
18#include <linux/platform_device.h>
19#include <mach/hardware.h>
20#include <asm/mach-types.h>
21
22#include <mach/ssp.h>
23#include <mach/pxa-regs.h>
24#include <mach/pxa2xx-gpio.h>
25#include <mach/regs-ssp.h>
26#include "sharpsl.h"
27
28static DEFINE_SPINLOCK(corgi_ssp_lock);
29static struct ssp_dev corgi_ssp_dev;
30static struct ssp_state corgi_ssp_state;
31static struct corgissp_machinfo *ssp_machinfo;
32
33/*
34 * There are three devices connected to the SSP interface:
35 * 1. A touchscreen controller (TI ADS7846 compatible)
36 * 2. An LCD controller (with some Backlight functionality)
37 * 3. A battery monitoring IC (Maxim MAX1111)
38 *
39 * Each device uses a different speed/mode of communication.
40 *
41 * The touchscreen is very sensitive and the most frequently used
42 * so the port is left configured for this.
43 *
44 * Devices are selected using Chip Selects on GPIOs.
45 */
46
47/*
48 * ADS7846 Routines
49 */
50unsigned long corgi_ssp_ads7846_putget(ulong data)
51{
52 unsigned long flag;
53 u32 ret = 0;
54
55 spin_lock_irqsave(&corgi_ssp_lock, flag);
56 if (ssp_machinfo->cs_ads7846 >= 0)
57 GPCR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846);
58
59 ssp_write_word(&corgi_ssp_dev,data);
60 ssp_read_word(&corgi_ssp_dev, &ret);
61
62 if (ssp_machinfo->cs_ads7846 >= 0)
63 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846);
64 spin_unlock_irqrestore(&corgi_ssp_lock, flag);
65
66 return ret;
67}
68
69/*
70 * NOTE: These functions should always be called in interrupt context
71 * and use the _lock and _unlock functions. They are very time sensitive.
72 */
73void corgi_ssp_ads7846_lock(void)
74{
75 spin_lock(&corgi_ssp_lock);
76 if (ssp_machinfo->cs_ads7846 >= 0)
77 GPCR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846);
78}
79
80void corgi_ssp_ads7846_unlock(void)
81{
82 if (ssp_machinfo->cs_ads7846 >= 0)
83 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846);
84 spin_unlock(&corgi_ssp_lock);
85}
86
87void corgi_ssp_ads7846_put(ulong data)
88{
89 ssp_write_word(&corgi_ssp_dev,data);
90}
91
92unsigned long corgi_ssp_ads7846_get(void)
93{
94 u32 ret = 0;
95 ssp_read_word(&corgi_ssp_dev, &ret);
96 return ret;
97}
98
99EXPORT_SYMBOL(corgi_ssp_ads7846_putget);
100EXPORT_SYMBOL(corgi_ssp_ads7846_lock);
101EXPORT_SYMBOL(corgi_ssp_ads7846_unlock);
102EXPORT_SYMBOL(corgi_ssp_ads7846_put);
103EXPORT_SYMBOL(corgi_ssp_ads7846_get);
104
105
106/*
107 * LCD/Backlight Routines
108 */
109unsigned long corgi_ssp_dac_put(ulong data)
110{
111 unsigned long flag, sscr1 = SSCR1_SPH;
112 u32 tmp;
113
114 spin_lock_irqsave(&corgi_ssp_lock, flag);
115
116 if (machine_is_spitz() || machine_is_akita() || machine_is_borzoi())
117 sscr1 = 0;
118
119 ssp_disable(&corgi_ssp_dev);
120 ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), sscr1, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_lcdcon));
121 ssp_enable(&corgi_ssp_dev);
122
123 if (ssp_machinfo->cs_lcdcon >= 0)
124 GPCR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon);
125 ssp_write_word(&corgi_ssp_dev,data);
126 /* Read null data back from device to prevent SSP overflow */
127 ssp_read_word(&corgi_ssp_dev, &tmp);
128 if (ssp_machinfo->cs_lcdcon >= 0)
129 GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon);
130
131 ssp_disable(&corgi_ssp_dev);
132 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846));
133 ssp_enable(&corgi_ssp_dev);
134
135 spin_unlock_irqrestore(&corgi_ssp_lock, flag);
136
137 return 0;
138}
139
140void corgi_ssp_lcdtg_send(u8 adrs, u8 data)
141{
142 corgi_ssp_dac_put(((adrs & 0x07) << 5) | (data & 0x1f));
143}
144
145void corgi_ssp_blduty_set(int duty)
146{
147 corgi_ssp_lcdtg_send(0x02,duty);
148}
149
150EXPORT_SYMBOL(corgi_ssp_lcdtg_send);
151EXPORT_SYMBOL(corgi_ssp_blduty_set);
152
153/*
154 * Max1111 Routines
155 */
156int corgi_ssp_max1111_get(ulong data)
157{
158 unsigned long flag;
159 long voltage = 0, voltage1 = 0, voltage2 = 0;
160
161 spin_lock_irqsave(&corgi_ssp_lock, flag);
162 if (ssp_machinfo->cs_max1111 >= 0)
163 GPCR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111);
164 ssp_disable(&corgi_ssp_dev);
165 ssp_config(&corgi_ssp_dev, (SSCR0_Motorola | (SSCR0_DSS & 0x07 )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_max1111));
166 ssp_enable(&corgi_ssp_dev);
167
168 udelay(1);
169
170 /* TB1/RB1 */
171 ssp_write_word(&corgi_ssp_dev,data);
172 ssp_read_word(&corgi_ssp_dev, (u32*)&voltage1); /* null read */
173
174 /* TB12/RB2 */
175 ssp_write_word(&corgi_ssp_dev,0);
176 ssp_read_word(&corgi_ssp_dev, (u32*)&voltage1);
177
178 /* TB13/RB3*/
179 ssp_write_word(&corgi_ssp_dev,0);
180 ssp_read_word(&corgi_ssp_dev, (u32*)&voltage2);
181
182 ssp_disable(&corgi_ssp_dev);
183 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846));
184 ssp_enable(&corgi_ssp_dev);
185 if (ssp_machinfo->cs_max1111 >= 0)
186 GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111);
187 spin_unlock_irqrestore(&corgi_ssp_lock, flag);
188
189 if (voltage1 & 0xc0 || voltage2 & 0x3f)
190 voltage = -1;
191 else
192 voltage = ((voltage1 << 2) & 0xfc) | ((voltage2 >> 6) & 0x03);
193
194 return voltage;
195}
196
197EXPORT_SYMBOL(corgi_ssp_max1111_get);
198
199/*
200 * Support Routines
201 */
202
203void __init corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo)
204{
205 ssp_machinfo = machinfo;
206}
207
208static int __init corgi_ssp_probe(struct platform_device *dev)
209{
210 int ret;
211
212 /* Chip Select - Disable All */
213 if (ssp_machinfo->cs_lcdcon >= 0)
214 pxa_gpio_mode(ssp_machinfo->cs_lcdcon | GPIO_OUT | GPIO_DFLT_HIGH);
215 if (ssp_machinfo->cs_max1111 >= 0)
216 pxa_gpio_mode(ssp_machinfo->cs_max1111 | GPIO_OUT | GPIO_DFLT_HIGH);
217 if (ssp_machinfo->cs_ads7846 >= 0)
218 pxa_gpio_mode(ssp_machinfo->cs_ads7846 | GPIO_OUT | GPIO_DFLT_HIGH);
219
220 ret = ssp_init(&corgi_ssp_dev, ssp_machinfo->port, 0);
221
222 if (ret)
223 printk(KERN_ERR "Unable to register SSP handler!\n");
224 else {
225 ssp_disable(&corgi_ssp_dev);
226 ssp_config(&corgi_ssp_dev, (SSCR0_National | (SSCR0_DSS & 0x0b )), 0, 0, SSCR0_SerClkDiv(ssp_machinfo->clk_ads7846));
227 ssp_enable(&corgi_ssp_dev);
228 }
229
230 return ret;
231}
232
233static int corgi_ssp_remove(struct platform_device *dev)
234{
235 ssp_exit(&corgi_ssp_dev);
236 return 0;
237}
238
239static int corgi_ssp_suspend(struct platform_device *dev, pm_message_t state)
240{
241 ssp_flush(&corgi_ssp_dev);
242 ssp_save_state(&corgi_ssp_dev,&corgi_ssp_state);
243
244 return 0;
245}
246
247static int corgi_ssp_resume(struct platform_device *dev)
248{
249 if (ssp_machinfo->cs_lcdcon >= 0)
250 GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); /* High - Disable LCD Control/Timing Gen */
251 if (ssp_machinfo->cs_max1111 >= 0)
252 GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); /* High - Disable MAX1111*/
253 if (ssp_machinfo->cs_ads7846 >= 0)
254 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); /* High - Disable ADS7846*/
255 ssp_restore_state(&corgi_ssp_dev,&corgi_ssp_state);
256 ssp_enable(&corgi_ssp_dev);
257
258 return 0;
259}
260
261static struct platform_driver corgissp_driver = {
262 .probe = corgi_ssp_probe,
263 .remove = corgi_ssp_remove,
264 .suspend = corgi_ssp_suspend,
265 .resume = corgi_ssp_resume,
266 .driver = {
267 .name = "corgi-ssp",
268 },
269};
270
271int __init corgi_ssp_init(void)
272{
273 return platform_driver_register(&corgissp_driver);
274}
275
276arch_initcall(corgi_ssp_init);
diff --git a/arch/arm/mach-pxa/cpu-pxa.c b/arch/arm/mach-pxa/cpufreq-pxa2xx.c
index 6f5569bac131..d82528e74bd0 100644
--- a/arch/arm/mach-pxa/cpu-pxa.c
+++ b/arch/arm/mach-pxa/cpufreq-pxa2xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/arm/mach-pxa/cpu-pxa.c 2 * linux/arch/arm/mach-pxa/cpufreq-pxa2xx.c
3 * 3 *
4 * Copyright (C) 2002,2003 Intrinsyc Software 4 * Copyright (C) 2002,2003 Intrinsyc Software
5 * 5 *
diff --git a/arch/arm/mach-pxa/cpufreq-pxa3xx.c b/arch/arm/mach-pxa/cpufreq-pxa3xx.c
new file mode 100644
index 000000000000..1ea0c9c0adaf
--- /dev/null
+++ b/arch/arm/mach-pxa/cpufreq-pxa3xx.c
@@ -0,0 +1,258 @@
1/*
2 * linux/arch/arm/mach-pxa/cpufreq-pxa3xx.c
3 *
4 * Copyright (C) 2008 Marvell International Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/sched.h>
15#include <linux/init.h>
16#include <linux/cpufreq.h>
17
18#include <mach/hardware.h>
19#include <mach/pxa-regs.h>
20#include <mach/pxa3xx-regs.h>
21
22#include "generic.h"
23
24#define HSS_104M (0)
25#define HSS_156M (1)
26#define HSS_208M (2)
27#define HSS_312M (3)
28
29#define SMCFS_78M (0)
30#define SMCFS_104M (2)
31#define SMCFS_208M (5)
32
33#define SFLFS_104M (0)
34#define SFLFS_156M (1)
35#define SFLFS_208M (2)
36#define SFLFS_312M (3)
37
38#define XSPCLK_156M (0)
39#define XSPCLK_NONE (3)
40
41#define DMCFS_26M (0)
42#define DMCFS_260M (3)
43
44struct pxa3xx_freq_info {
45 unsigned int cpufreq_mhz;
46 unsigned int core_xl : 5;
47 unsigned int core_xn : 3;
48 unsigned int hss : 2;
49 unsigned int dmcfs : 2;
50 unsigned int smcfs : 3;
51 unsigned int sflfs : 2;
52 unsigned int df_clkdiv : 3;
53
54 int vcc_core; /* in mV */
55 int vcc_sram; /* in mV */
56};
57
58#define OP(cpufreq, _xl, _xn, _hss, _dmc, _smc, _sfl, _dfi, vcore, vsram) \
59{ \
60 .cpufreq_mhz = cpufreq, \
61 .core_xl = _xl, \
62 .core_xn = _xn, \
63 .hss = HSS_##_hss##M, \
64 .dmcfs = DMCFS_##_dmc##M, \
65 .smcfs = SMCFS_##_smc##M, \
66 .sflfs = SFLFS_##_sfl##M, \
67 .df_clkdiv = _dfi, \
68 .vcc_core = vcore, \
69 .vcc_sram = vsram, \
70}
71
72static struct pxa3xx_freq_info pxa300_freqs[] = {
73 /* CPU XL XN HSS DMEM SMEM SRAM DFI VCC_CORE VCC_SRAM */
74 OP(104, 8, 1, 104, 260, 78, 104, 3, 1000, 1100), /* 104MHz */
75 OP(208, 16, 1, 104, 260, 104, 156, 2, 1000, 1100), /* 208MHz */
76 OP(416, 16, 2, 156, 260, 104, 208, 2, 1100, 1200), /* 416MHz */
77 OP(624, 24, 2, 208, 260, 208, 312, 3, 1375, 1400), /* 624MHz */
78};
79
80static struct pxa3xx_freq_info pxa320_freqs[] = {
81 /* CPU XL XN HSS DMEM SMEM SRAM DFI VCC_CORE VCC_SRAM */
82 OP(104, 8, 1, 104, 260, 78, 104, 3, 1000, 1100), /* 104MHz */
83 OP(208, 16, 1, 104, 260, 104, 156, 2, 1000, 1100), /* 208MHz */
84 OP(416, 16, 2, 156, 260, 104, 208, 2, 1100, 1200), /* 416MHz */
85 OP(624, 24, 2, 208, 260, 208, 312, 3, 1375, 1400), /* 624MHz */
86 OP(806, 31, 2, 208, 260, 208, 312, 3, 1400, 1400), /* 806MHz */
87};
88
89static unsigned int pxa3xx_freqs_num;
90static struct pxa3xx_freq_info *pxa3xx_freqs;
91static struct cpufreq_frequency_table *pxa3xx_freqs_table;
92
93static int setup_freqs_table(struct cpufreq_policy *policy,
94 struct pxa3xx_freq_info *freqs, int num)
95{
96 struct cpufreq_frequency_table *table;
97 int i;
98
99 table = kzalloc((num + 1) * sizeof(*table), GFP_KERNEL);
100 if (table == NULL)
101 return -ENOMEM;
102
103 for (i = 0; i < num; i++) {
104 table[i].index = i;
105 table[i].frequency = freqs[i].cpufreq_mhz * 1000;
106 }
107 table[num].frequency = i;
108 table[num].frequency = CPUFREQ_TABLE_END;
109
110 pxa3xx_freqs = freqs;
111 pxa3xx_freqs_num = num;
112 pxa3xx_freqs_table = table;
113
114 return cpufreq_frequency_table_cpuinfo(policy, table);
115}
116
117static void __update_core_freq(struct pxa3xx_freq_info *info)
118{
119 uint32_t mask = ACCR_XN_MASK | ACCR_XL_MASK;
120 uint32_t accr = ACCR;
121 uint32_t xclkcfg;
122
123 accr &= ~(ACCR_XN_MASK | ACCR_XL_MASK | ACCR_XSPCLK_MASK);
124 accr |= ACCR_XN(info->core_xn) | ACCR_XL(info->core_xl);
125
126 /* No clock until core PLL is re-locked */
127 accr |= ACCR_XSPCLK(XSPCLK_NONE);
128
129 xclkcfg = (info->core_xn == 2) ? 0x3 : 0x2; /* turbo bit */
130
131 ACCR = accr;
132 __asm__("mcr p14, 0, %0, c6, c0, 0\n" : : "r"(xclkcfg));
133
134 while ((ACSR & mask) != (accr & mask))
135 cpu_relax();
136}
137
138static void __update_bus_freq(struct pxa3xx_freq_info *info)
139{
140 uint32_t mask;
141 uint32_t accr = ACCR;
142
143 mask = ACCR_SMCFS_MASK | ACCR_SFLFS_MASK | ACCR_HSS_MASK |
144 ACCR_DMCFS_MASK;
145
146 accr &= ~mask;
147 accr |= ACCR_SMCFS(info->smcfs) | ACCR_SFLFS(info->sflfs) |
148 ACCR_HSS(info->hss) | ACCR_DMCFS(info->dmcfs);
149
150 ACCR = accr;
151
152 while ((ACSR & mask) != (accr & mask))
153 cpu_relax();
154}
155
156static int pxa3xx_cpufreq_verify(struct cpufreq_policy *policy)
157{
158 return cpufreq_frequency_table_verify(policy, pxa3xx_freqs_table);
159}
160
161static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)
162{
163 return get_clk_frequency_khz(0);
164}
165
166static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy,
167 unsigned int target_freq,
168 unsigned int relation)
169{
170 struct pxa3xx_freq_info *next;
171 struct cpufreq_freqs freqs;
172 unsigned long flags;
173 int idx;
174
175 if (policy->cpu != 0)
176 return -EINVAL;
177
178 /* Lookup the next frequency */
179 if (cpufreq_frequency_table_target(policy, pxa3xx_freqs_table,
180 target_freq, relation, &idx))
181 return -EINVAL;
182
183 next = &pxa3xx_freqs[idx];
184
185 freqs.old = policy->cur;
186 freqs.new = next->cpufreq_mhz * 1000;
187 freqs.cpu = policy->cpu;
188
189 pr_debug("CPU frequency from %d MHz to %d MHz%s\n",
190 freqs.old / 1000, freqs.new / 1000,
191 (freqs.old == freqs.new) ? " (skipped)" : "");
192
193 if (freqs.old == target_freq)
194 return 0;
195
196 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
197
198 local_irq_save(flags);
199 __update_core_freq(next);
200 __update_bus_freq(next);
201 local_irq_restore(flags);
202
203 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
204
205 return 0;
206}
207
208static __init int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)
209{
210 int ret = -EINVAL;
211
212 /* set default policy and cpuinfo */
213 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
214 policy->cpuinfo.min_freq = 104000;
215 policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000;
216 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
217 policy->cur = policy->min = policy->max = get_clk_frequency_khz(0);
218
219 if (cpu_is_pxa300() || cpu_is_pxa310())
220 ret = setup_freqs_table(policy, ARRAY_AND_SIZE(pxa300_freqs));
221
222 if (cpu_is_pxa320())
223 ret = setup_freqs_table(policy, ARRAY_AND_SIZE(pxa320_freqs));
224
225 if (ret) {
226 pr_err("failed to setup frequency table\n");
227 return ret;
228 }
229
230 pr_info("CPUFREQ support for PXA3xx initialized\n");
231 return 0;
232}
233
234static struct cpufreq_driver pxa3xx_cpufreq_driver = {
235 .verify = pxa3xx_cpufreq_verify,
236 .target = pxa3xx_cpufreq_set,
237 .init = pxa3xx_cpufreq_init,
238 .get = pxa3xx_cpufreq_get,
239 .name = "pxa3xx-cpufreq",
240};
241
242static int __init cpufreq_init(void)
243{
244 if (cpu_is_pxa3xx())
245 return cpufreq_register_driver(&pxa3xx_cpufreq_driver);
246
247 return 0;
248}
249module_init(cpufreq_init);
250
251static void __exit cpufreq_exit(void)
252{
253 cpufreq_unregister_driver(&pxa3xx_cpufreq_driver);
254}
255module_exit(cpufreq_exit);
256
257MODULE_DESCRIPTION("CPU frequency scaling driver for PXA3xx");
258MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-pxa/devices.h b/arch/arm/mach-pxa/devices.h
index 887c738f5911..bb04af4b0aa3 100644
--- a/arch/arm/mach-pxa/devices.h
+++ b/arch/arm/mach-pxa/devices.h
@@ -32,5 +32,6 @@ extern struct platform_device pxa27x_device_pwm0;
32extern struct platform_device pxa27x_device_pwm1; 32extern struct platform_device pxa27x_device_pwm1;
33 33
34extern struct platform_device pxa3xx_device_nand; 34extern struct platform_device pxa3xx_device_nand;
35extern struct platform_device pxa3xx_device_i2c_power;
35 36
36void __init pxa_register_device(struct platform_device *dev, void *data); 37void __init pxa_register_device(struct platform_device *dev, void *data);
diff --git a/arch/arm/mach-pxa/e330.c b/arch/arm/mach-pxa/e330.c
new file mode 100644
index 000000000000..d488eded2058
--- /dev/null
+++ b/arch/arm/mach-pxa/e330.c
@@ -0,0 +1,43 @@
1/*
2 * Hardware definitions for the Toshiba eseries PDAs
3 *
4 * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
5 *
6 * This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15
16#include <asm/setup.h>
17#include <asm/mach/arch.h>
18#include <asm/mach-types.h>
19
20#include <mach/mfp-pxa25x.h>
21#include <mach/hardware.h>
22#include <mach/udc.h>
23
24#include "generic.h"
25#include "eseries.h"
26
27static void __init e330_init(void)
28{
29 pxa_set_udc_info(&e7xx_udc_mach_info);
30}
31
32MACHINE_START(E330, "Toshiba e330")
33 /* Maintainer: Ian Molton (spyro@f2s.com) */
34 .phys_io = 0x40000000,
35 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
36 .boot_params = 0xa0000100,
37 .map_io = pxa_map_io,
38 .init_irq = pxa25x_init_irq,
39 .fixup = eseries_fixup,
40 .init_machine = e330_init,
41 .timer = &pxa_timer,
42MACHINE_END
43
diff --git a/arch/arm/mach-pxa/e350.c b/arch/arm/mach-pxa/e350.c
new file mode 100644
index 000000000000..8ecbc5479828
--- /dev/null
+++ b/arch/arm/mach-pxa/e350.c
@@ -0,0 +1,43 @@
1/*
2 * Hardware definitions for the Toshiba eseries PDAs
3 *
4 * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
5 *
6 * This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15
16#include <asm/setup.h>
17#include <asm/mach/arch.h>
18#include <asm/mach-types.h>
19
20#include <mach/mfp-pxa25x.h>
21#include <mach/hardware.h>
22#include <mach/udc.h>
23
24#include "generic.h"
25#include "eseries.h"
26
27static void __init e350_init(void)
28{
29 pxa_set_udc_info(&e7xx_udc_mach_info);
30}
31
32MACHINE_START(E350, "Toshiba e350")
33 /* Maintainer: Ian Molton (spyro@f2s.com) */
34 .phys_io = 0x40000000,
35 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
36 .boot_params = 0xa0000100,
37 .map_io = pxa_map_io,
38 .init_irq = pxa25x_init_irq,
39 .fixup = eseries_fixup,
40 .init_machine = e350_init,
41 .timer = &pxa_timer,
42MACHINE_END
43
diff --git a/arch/arm/mach-pxa/e400.c b/arch/arm/mach-pxa/e400.c
new file mode 100644
index 000000000000..544bbaa20621
--- /dev/null
+++ b/arch/arm/mach-pxa/e400.c
@@ -0,0 +1,94 @@
1/*
2 * Hardware definitions for the Toshiba eseries PDAs
3 *
4 * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
5 *
6 * This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15
16#include <asm/setup.h>
17#include <asm/mach/arch.h>
18#include <asm/mach-types.h>
19
20#include <mach/pxa-regs.h>
21#include <mach/mfp-pxa25x.h>
22#include <mach/hardware.h>
23
24#include <mach/pxafb.h>
25#include <mach/udc.h>
26
27#include "generic.h"
28#include "eseries.h"
29
30/* ------------------------ E400 LCD definitions ------------------------ */
31
32static struct pxafb_mode_info e400_pxafb_mode_info = {
33 .pixclock = 140703,
34 .xres = 240,
35 .yres = 320,
36 .bpp = 16,
37 .hsync_len = 4,
38 .left_margin = 28,
39 .right_margin = 8,
40 .vsync_len = 3,
41 .upper_margin = 5,
42 .lower_margin = 6,
43 .sync = 0,
44};
45
46static struct pxafb_mach_info e400_pxafb_mach_info = {
47 .modes = &e400_pxafb_mode_info,
48 .num_modes = 1,
49 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
50 .lccr3 = 0,
51 .pxafb_backlight_power = NULL,
52};
53
54/* ------------------------ E400 MFP config ----------------------------- */
55
56static unsigned long e400_pin_config[] __initdata = {
57 /* Chip selects */
58 GPIO15_nCS_1, /* CS1 - Flash */
59 GPIO80_nCS_4, /* CS4 - TMIO */
60
61 /* Clocks */
62 GPIO12_32KHz,
63
64 /* BTUART */
65 GPIO42_BTUART_RXD,
66 GPIO43_BTUART_TXD,
67 GPIO44_BTUART_CTS,
68 GPIO45_GPIO, /* Used by TMIO for #SUSPEND */
69
70 /* wakeup */
71 GPIO0_GPIO | WAKEUP_ON_EDGE_RISE,
72};
73
74/* ---------------------------------------------------------------------- */
75
76static void __init e400_init(void)
77{
78 pxa2xx_mfp_config(ARRAY_AND_SIZE(e400_pin_config));
79 set_pxa_fb_info(&e400_pxafb_mach_info);
80 pxa_set_udc_info(&e7xx_udc_mach_info);
81}
82
83MACHINE_START(E400, "Toshiba e400")
84 /* Maintainer: Ian Molton (spyro@f2s.com) */
85 .phys_io = 0x40000000,
86 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
87 .boot_params = 0xa0000100,
88 .map_io = pxa_map_io,
89 .init_irq = pxa25x_init_irq,
90 .fixup = eseries_fixup,
91 .init_machine = e400_init,
92 .timer = &pxa_timer,
93MACHINE_END
94
diff --git a/arch/arm/mach-pxa/e400_lcd.c b/arch/arm/mach-pxa/e400_lcd.c
deleted file mode 100644
index 263884165f57..000000000000
--- a/arch/arm/mach-pxa/e400_lcd.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * e400_lcd.c
3 *
4 * (c) 2005 Ian Molton <spyro@f2s.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/module.h>
15
16#include <asm/mach-types.h>
17#include <mach/pxa-regs.h>
18#include <mach/pxafb.h>
19
20static struct pxafb_mode_info e400_pxafb_mode_info = {
21 .pixclock = 140703,
22 .xres = 240,
23 .yres = 320,
24 .bpp = 16,
25 .hsync_len = 4,
26 .left_margin = 28,
27 .right_margin = 8,
28 .vsync_len = 3,
29 .upper_margin = 5,
30 .lower_margin = 6,
31 .sync = 0,
32};
33
34static struct pxafb_mach_info e400_pxafb_mach_info = {
35 .modes = &e400_pxafb_mode_info,
36 .num_modes = 1,
37 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
38 .lccr3 = 0,
39 .pxafb_backlight_power = NULL,
40};
41
42static int __init e400_lcd_init(void)
43{
44 if (!machine_is_e400())
45 return -ENODEV;
46
47 set_pxa_fb_info(&e400_pxafb_mach_info);
48 return 0;
49}
50
51module_init(e400_lcd_init);
52
53MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
54MODULE_DESCRIPTION("e400 lcd driver");
55MODULE_LICENSE("GPLv2");
56
diff --git a/arch/arm/mach-pxa/e740.c b/arch/arm/mach-pxa/e740.c
new file mode 100644
index 000000000000..c57a15b37f0d
--- /dev/null
+++ b/arch/arm/mach-pxa/e740.c
@@ -0,0 +1,169 @@
1/*
2 * Hardware definitions for the Toshiba eseries PDAs
3 *
4 * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
5 *
6 * This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/device.h>
16#include <linux/platform_device.h>
17#include <linux/fb.h>
18
19#include <video/w100fb.h>
20
21#include <asm/setup.h>
22#include <asm/mach/arch.h>
23#include <asm/mach-types.h>
24
25#include <mach/mfp-pxa25x.h>
26#include <mach/hardware.h>
27#include <mach/udc.h>
28
29#include "generic.h"
30#include "eseries.h"
31
32
33/* ------------------------ e740 video support --------------------------- */
34
35static struct w100_gen_regs e740_lcd_regs = {
36 .lcd_format = 0x00008023,
37 .lcdd_cntl1 = 0x0f000000,
38 .lcdd_cntl2 = 0x0003ffff,
39 .genlcd_cntl1 = 0x00ffff03,
40 .genlcd_cntl2 = 0x003c0f03,
41 .genlcd_cntl3 = 0x000143aa,
42};
43
44static struct w100_mode e740_lcd_mode = {
45 .xres = 240,
46 .yres = 320,
47 .left_margin = 20,
48 .right_margin = 28,
49 .upper_margin = 9,
50 .lower_margin = 8,
51 .crtc_ss = 0x80140013,
52 .crtc_ls = 0x81150110,
53 .crtc_gs = 0x80050005,
54 .crtc_vpos_gs = 0x000a0009,
55 .crtc_rev = 0x0040010a,
56 .crtc_dclk = 0xa906000a,
57 .crtc_gclk = 0x80050108,
58 .crtc_goe = 0x80050108,
59 .pll_freq = 57,
60 .pixclk_divider = 4,
61 .pixclk_divider_rotated = 4,
62 .pixclk_src = CLK_SRC_XTAL,
63 .sysclk_divider = 1,
64 .sysclk_src = CLK_SRC_PLL,
65 .crtc_ps1_active = 0x41060010,
66};
67
68static struct w100_gpio_regs e740_w100_gpio_info = {
69 .init_data1 = 0x21002103,
70 .gpio_dir1 = 0xffffdeff,
71 .gpio_oe1 = 0x03c00643,
72 .init_data2 = 0x003f003f,
73 .gpio_dir2 = 0xffffffff,
74 .gpio_oe2 = 0x000000ff,
75};
76
77static struct w100fb_mach_info e740_fb_info = {
78 .modelist = &e740_lcd_mode,
79 .num_modes = 1,
80 .regs = &e740_lcd_regs,
81 .gpio = &e740_w100_gpio_info,
82 .xtal_freq = 14318000,
83 .xtal_dbl = 1,
84};
85
86static struct resource e740_fb_resources[] = {
87 [0] = {
88 .start = 0x0c000000,
89 .end = 0x0cffffff,
90 .flags = IORESOURCE_MEM,
91 },
92};
93
94static struct platform_device e740_fb_device = {
95 .name = "w100fb",
96 .id = -1,
97 .dev = {
98 .platform_data = &e740_fb_info,
99 },
100 .num_resources = ARRAY_SIZE(e740_fb_resources),
101 .resource = e740_fb_resources,
102};
103
104/* --------------------------- MFP Pin config -------------------------- */
105
106static unsigned long e740_pin_config[] __initdata = {
107 /* Chip selects */
108 GPIO15_nCS_1, /* CS1 - Flash */
109 GPIO79_nCS_3, /* CS3 - IMAGEON */
110 GPIO80_nCS_4, /* CS4 - TMIO */
111
112 /* Clocks */
113 GPIO12_32KHz,
114
115 /* BTUART */
116 GPIO42_BTUART_RXD,
117 GPIO43_BTUART_TXD,
118 GPIO44_BTUART_CTS,
119 GPIO45_GPIO, /* Used by TMIO for #SUSPEND */
120
121 /* PC Card */
122 GPIO8_GPIO, /* CD0 */
123 GPIO44_GPIO, /* CD1 */
124 GPIO11_GPIO, /* IRQ0 */
125 GPIO6_GPIO, /* IRQ1 */
126 GPIO27_GPIO, /* RST0 */
127 GPIO24_GPIO, /* RST1 */
128 GPIO20_GPIO, /* PWR0 */
129 GPIO23_GPIO, /* PWR1 */
130 GPIO48_nPOE,
131 GPIO49_nPWE,
132 GPIO50_nPIOR,
133 GPIO51_nPIOW,
134 GPIO52_nPCE_1,
135 GPIO53_nPCE_2,
136 GPIO54_nPSKTSEL,
137 GPIO55_nPREG,
138 GPIO56_nPWAIT,
139 GPIO57_nIOIS16,
140
141 /* wakeup */
142 GPIO0_GPIO | WAKEUP_ON_EDGE_RISE,
143};
144
145/* ----------------------------------------------------------------------- */
146
147static struct platform_device *devices[] __initdata = {
148 &e740_fb_device,
149};
150
151static void __init e740_init(void)
152{
153 pxa2xx_mfp_config(ARRAY_AND_SIZE(e740_pin_config));
154 platform_add_devices(devices, ARRAY_SIZE(devices));
155 pxa_set_udc_info(&e7xx_udc_mach_info);
156}
157
158MACHINE_START(E740, "Toshiba e740")
159 /* Maintainer: Ian Molton (spyro@f2s.com) */
160 .phys_io = 0x40000000,
161 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
162 .boot_params = 0xa0000100,
163 .map_io = pxa_map_io,
164 .init_irq = pxa25x_init_irq,
165 .fixup = eseries_fixup,
166 .init_machine = e740_init,
167 .timer = &pxa_timer,
168MACHINE_END
169
diff --git a/arch/arm/mach-pxa/e740_lcd.c b/arch/arm/mach-pxa/e740_lcd.c
deleted file mode 100644
index 26bd599af178..000000000000
--- a/arch/arm/mach-pxa/e740_lcd.c
+++ /dev/null
@@ -1,123 +0,0 @@
1/* e740_lcd.c
2 *
3 * This file contains the definitions for the LCD timings and functions
4 * to control the LCD power / frontlighting via the w100fb driver.
5 *
6 * (c) 2005 Ian Molton <spyro@f2s.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/device.h>
16#include <linux/fb.h>
17#include <linux/err.h>
18#include <linux/platform_device.h>
19
20#include <asm/mach-types.h>
21
22#include <video/w100fb.h>
23
24/*
25**potential** shutdown routine - to be investigated
26devmem2 0x0c010528 w 0xff3fff00
27devmem2 0x0c010190 w 0x7FFF8000
28devmem2 0x0c0101b0 w 0x00FF0000
29devmem2 0x0c01008c w 0x00000000
30devmem2 0x0c010080 w 0x000000bf
31devmem2 0x0c010098 w 0x00000015
32devmem2 0x0c010088 w 0x4b000204
33devmem2 0x0c010098 w 0x0000001d
34*/
35
36static struct w100_gen_regs e740_lcd_regs = {
37 .lcd_format = 0x00008023,
38 .lcdd_cntl1 = 0x0f000000,
39 .lcdd_cntl2 = 0x0003ffff,
40 .genlcd_cntl1 = 0x00ffff03,
41 .genlcd_cntl2 = 0x003c0f03,
42 .genlcd_cntl3 = 0x000143aa,
43};
44
45static struct w100_mode e740_lcd_mode = {
46 .xres = 240,
47 .yres = 320,
48 .left_margin = 20,
49 .right_margin = 28,
50 .upper_margin = 9,
51 .lower_margin = 8,
52 .crtc_ss = 0x80140013,
53 .crtc_ls = 0x81150110,
54 .crtc_gs = 0x80050005,
55 .crtc_vpos_gs = 0x000a0009,
56 .crtc_rev = 0x0040010a,
57 .crtc_dclk = 0xa906000a,
58 .crtc_gclk = 0x80050108,
59 .crtc_goe = 0x80050108,
60 .pll_freq = 57,
61 .pixclk_divider = 4,
62 .pixclk_divider_rotated = 4,
63 .pixclk_src = CLK_SRC_XTAL,
64 .sysclk_divider = 1,
65 .sysclk_src = CLK_SRC_PLL,
66 .crtc_ps1_active = 0x41060010,
67};
68
69
70static struct w100_gpio_regs e740_w100_gpio_info = {
71 .init_data1 = 0x21002103,
72 .gpio_dir1 = 0xffffdeff,
73 .gpio_oe1 = 0x03c00643,
74 .init_data2 = 0x003f003f,
75 .gpio_dir2 = 0xffffffff,
76 .gpio_oe2 = 0x000000ff,
77};
78
79static struct w100fb_mach_info e740_fb_info = {
80 .modelist = &e740_lcd_mode,
81 .num_modes = 1,
82 .regs = &e740_lcd_regs,
83 .gpio = &e740_w100_gpio_info,
84 .xtal_freq = 14318000,
85 .xtal_dbl = 1,
86};
87
88static struct resource e740_fb_resources[] = {
89 [0] = {
90 .start = 0x0c000000,
91 .end = 0x0cffffff,
92 .flags = IORESOURCE_MEM,
93 },
94};
95
96/* ----------------------- device declarations -------------------------- */
97
98
99static struct platform_device e740_fb_device = {
100 .name = "w100fb",
101 .id = -1,
102 .dev = {
103 .platform_data = &e740_fb_info,
104 },
105 .num_resources = ARRAY_SIZE(e740_fb_resources),
106 .resource = e740_fb_resources,
107};
108
109static int e740_lcd_init(void)
110{
111 int ret;
112
113 if (!machine_is_e740())
114 return -ENODEV;
115
116 return platform_device_register(&e740_fb_device);
117}
118
119module_init(e740_lcd_init);
120
121MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
122MODULE_DESCRIPTION("e740 lcd driver");
123MODULE_LICENSE("GPLv2");
diff --git a/arch/arm/mach-pxa/e750_lcd.c b/arch/arm/mach-pxa/e750.c
index 75edc3b5390f..640e738b85df 100644
--- a/arch/arm/mach-pxa/e750_lcd.c
+++ b/arch/arm/mach-pxa/e750.c
@@ -1,25 +1,35 @@
1/* e750_lcd.c 1/*
2 * Hardware definitions for the Toshiba eseries PDAs
2 * 3 *
3 * This file contains the definitions for the LCD timings and functions 4 * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
4 * to control the LCD power / frontlighting via the w100fb driver.
5 * 5 *
6 * (c) 2005 Ian Molton <spyro@f2s.com> 6 * This file is licensed under
7 * 7 * the terms of the GNU General Public License version 2. This program
8 * This program is free software; you can redistribute it and/or modify 8 * is licensed "as is" without any warranty of any kind, whether express
9 * it under the terms of the GNU General Public License version 2 as 9 * or implied.
10 * published by the Free Software Foundation.
11 * 10 *
12 */ 11 */
13 12
14#include <linux/module.h> 13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/fb.h>
17#include <linux/err.h>
18#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/fb.h>
18
19#include <video/w100fb.h>
19 20
21#include <asm/setup.h>
22#include <asm/mach/arch.h>
20#include <asm/mach-types.h> 23#include <asm/mach-types.h>
21 24
22#include <video/w100fb.h> 25#include <mach/mfp-pxa25x.h>
26#include <mach/hardware.h>
27#include <mach/udc.h>
28
29#include "generic.h"
30#include "eseries.h"
31
32/* ---------------------- E750 LCD definitions -------------------- */
23 33
24static struct w100_gen_regs e750_lcd_regs = { 34static struct w100_gen_regs e750_lcd_regs = {
25 .lcd_format = 0x00008003, 35 .lcd_format = 0x00008003,
@@ -54,7 +64,6 @@ static struct w100_mode e750_lcd_mode = {
54 .sysclk_src = CLK_SRC_PLL, 64 .sysclk_src = CLK_SRC_PLL,
55}; 65};
56 66
57
58static struct w100_gpio_regs e750_w100_gpio_info = { 67static struct w100_gpio_regs e750_w100_gpio_info = {
59 .init_data1 = 0x01192f1b, 68 .init_data1 = 0x01192f1b,
60 .gpio_dir1 = 0xd5ffdeff, 69 .gpio_dir1 = 0xd5ffdeff,
@@ -81,9 +90,6 @@ static struct resource e750_fb_resources[] = {
81 }, 90 },
82}; 91};
83 92
84/* ----------------------- device declarations -------------------------- */
85
86
87static struct platform_device e750_fb_device = { 93static struct platform_device e750_fb_device = {
88 .name = "w100fb", 94 .name = "w100fb",
89 .id = -1, 95 .id = -1,
@@ -94,16 +100,27 @@ static struct platform_device e750_fb_device = {
94 .resource = e750_fb_resources, 100 .resource = e750_fb_resources,
95}; 101};
96 102
97static int e750_lcd_init(void) 103/* ----------------------------------------------------------------------- */
98{
99 if (!machine_is_e750())
100 return -ENODEV;
101 104
102 return platform_device_register(&e750_fb_device); 105static struct platform_device *devices[] __initdata = {
106 &e750_fb_device,
107};
108
109static void __init e750_init(void)
110{
111 platform_add_devices(devices, ARRAY_SIZE(devices));
112 pxa_set_udc_info(&e7xx_udc_mach_info);
103} 113}
104 114
105module_init(e750_lcd_init); 115MACHINE_START(E750, "Toshiba e750")
116 /* Maintainer: Ian Molton (spyro@f2s.com) */
117 .phys_io = 0x40000000,
118 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
119 .boot_params = 0xa0000100,
120 .map_io = pxa_map_io,
121 .init_irq = pxa25x_init_irq,
122 .fixup = eseries_fixup,
123 .init_machine = e750_init,
124 .timer = &pxa_timer,
125MACHINE_END
106 126
107MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
108MODULE_DESCRIPTION("e750 lcd driver");
109MODULE_LICENSE("GPLv2");
diff --git a/arch/arm/mach-pxa/e800_lcd.c b/arch/arm/mach-pxa/e800.c
index e6aeab0ebc22..a293e09bfe25 100644
--- a/arch/arm/mach-pxa/e800_lcd.c
+++ b/arch/arm/mach-pxa/e800.c
@@ -1,25 +1,36 @@
1/* e800_lcd.c 1/*
2 * Hardware definitions for the Toshiba eseries PDAs
2 * 3 *
3 * This file contains the definitions for the LCD timings and functions 4 * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
4 * to control the LCD power / frontlighting via the w100fb driver.
5 * 5 *
6 * (c) 2005 Ian Molton <spyro@f2s.com> 6 * This file is licensed under
7 * 7 * the terms of the GNU General Public License version 2. This program
8 * This program is free software; you can redistribute it and/or modify 8 * is licensed "as is" without any warranty of any kind, whether express
9 * it under the terms of the GNU General Public License version 2 as 9 * or implied.
10 * published by the Free Software Foundation.
11 * 10 *
12 */ 11 */
13 12
14#include <linux/module.h> 13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/fb.h>
17#include <linux/err.h>
18#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/fb.h>
18
19#include <video/w100fb.h>
19 20
21#include <asm/setup.h>
22#include <asm/mach/arch.h>
20#include <asm/mach-types.h> 23#include <asm/mach-types.h>
21 24
22#include <video/w100fb.h> 25#include <mach/mfp-pxa25x.h>
26#include <mach/hardware.h>
27#include <mach/eseries-gpio.h>
28#include <mach/udc.h>
29
30#include "generic.h"
31#include "eseries.h"
32
33/* ------------------------ e800 LCD definitions ------------------------- */
23 34
24static struct w100_gen_regs e800_lcd_regs = { 35static struct w100_gen_regs e800_lcd_regs = {
25 .lcd_format = 0x00008003, 36 .lcd_format = 0x00008003,
@@ -71,8 +82,8 @@ static struct w100_mode e800_lcd_mode[2] = {
71 .crtc_goe = 0x80cc0015, 82 .crtc_goe = 0x80cc0015,
72 .crtc_ps1_active = 0x00000000, 83 .crtc_ps1_active = 0x00000000,
73 .pll_freq = 100, 84 .pll_freq = 100,
74 .pixclk_divider = 6, /* Wince uses 14 which gives a 7MHz pclk. */ 85 .pixclk_divider = 6, /* Wince uses 14 which gives a */
75 .pixclk_divider_rotated = 6, /* we want a 14MHz one (much nicer to look at) */ 86 .pixclk_divider_rotated = 6, /* 7MHz Pclk. We use a 14MHz one */
76 .pixclk_src = CLK_SRC_PLL, 87 .pixclk_src = CLK_SRC_PLL,
77 .sysclk_divider = 0, 88 .sysclk_divider = 0,
78 .sysclk_src = CLK_SRC_PLL, 89 .sysclk_src = CLK_SRC_PLL,
@@ -131,9 +142,6 @@ static struct resource e800_fb_resources[] = {
131 }, 142 },
132}; 143};
133 144
134/* ----------------------- device declarations -------------------------- */
135
136
137static struct platform_device e800_fb_device = { 145static struct platform_device e800_fb_device = {
138 .name = "w100fb", 146 .name = "w100fb",
139 .id = -1, 147 .id = -1,
@@ -144,16 +152,35 @@ static struct platform_device e800_fb_device = {
144 .resource = e800_fb_resources, 152 .resource = e800_fb_resources,
145}; 153};
146 154
147static int e800_lcd_init(void) 155/* --------------------------- UDC definitions --------------------------- */
148{ 156
149 if (!machine_is_e800()) 157static struct pxa2xx_udc_mach_info e800_udc_mach_info = {
150 return -ENODEV; 158 .gpio_vbus = GPIO_E800_USB_DISC,
159 .gpio_pullup = GPIO_E800_USB_PULLUP,
160 .gpio_pullup_inverted = 1
161};
151 162
152 return platform_device_register(&e800_fb_device); 163/* ----------------------------------------------------------------------- */
164
165static struct platform_device *devices[] __initdata = {
166 &e800_fb_device,
167};
168
169static void __init e800_init(void)
170{
171 platform_add_devices(devices, ARRAY_SIZE(devices));
172 pxa_set_udc_info(&e800_udc_mach_info);
153} 173}
154 174
155module_init(e800_lcd_init); 175MACHINE_START(E800, "Toshiba e800")
176 /* Maintainer: Ian Molton (spyro@f2s.com) */
177 .phys_io = 0x40000000,
178 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
179 .boot_params = 0xa0000100,
180 .map_io = pxa_map_io,
181 .init_irq = pxa25x_init_irq,
182 .fixup = eseries_fixup,
183 .init_machine = e800_init,
184 .timer = &pxa_timer,
185MACHINE_END
156 186
157MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
158MODULE_DESCRIPTION("e800 lcd driver");
159MODULE_LICENSE("GPLv2");
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index 7a0a681a5847..f5ed8038ede5 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -373,10 +373,6 @@ static inline void em_x270_init_nand(void) {}
373#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 373#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
374static int em_x270_ohci_init(struct device *dev) 374static int em_x270_ohci_init(struct device *dev)
375{ 375{
376 /* Set the Power Control Polarity Low */
377 UHCHR = (UHCHR | UHCHR_PCPL) &
378 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE);
379
380 /* enable port 2 transiever */ 376 /* enable port 2 transiever */
381 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE; 377 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
382 378
@@ -385,6 +381,7 @@ static int em_x270_ohci_init(struct device *dev)
385 381
386static struct pxaohci_platform_data em_x270_ohci_platform_data = { 382static struct pxaohci_platform_data em_x270_ohci_platform_data = {
387 .port_mode = PMM_PERPORT_MODE, 383 .port_mode = PMM_PERPORT_MODE,
384 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
388 .init = em_x270_ohci_init, 385 .init = em_x270_ohci_init,
389}; 386};
390 387
diff --git a/arch/arm/mach-pxa/eseries.c b/arch/arm/mach-pxa/eseries.c
index 001a252bd514..d28849b50a14 100644
--- a/arch/arm/mach-pxa/eseries.c
+++ b/arch/arm/mach-pxa/eseries.c
@@ -19,68 +19,13 @@
19 19
20#include <mach/mfp-pxa25x.h> 20#include <mach/mfp-pxa25x.h>
21#include <mach/hardware.h> 21#include <mach/hardware.h>
22#include <mach/eseries-gpio.h>
23#include <mach/udc.h>
22 24
23#include "generic.h" 25#include "generic.h"
24 26
25static unsigned long e740_pin_config[] __initdata = {
26 /* Chip selects */
27 GPIO15_nCS_1, /* CS1 - Flash */
28 GPIO79_nCS_3, /* CS3 - IMAGEON */
29 GPIO80_nCS_4, /* CS4 - TMIO */
30
31 /* Clocks */
32 GPIO12_32KHz,
33
34 /* BTUART */
35 GPIO42_BTUART_RXD,
36 GPIO43_BTUART_TXD,
37 GPIO44_BTUART_CTS,
38 GPIO45_GPIO, /* Used by TMIO for #SUSPEND */
39
40 /* PC Card */
41 GPIO8_GPIO, /* CD0 */
42 GPIO44_GPIO, /* CD1 */
43 GPIO11_GPIO, /* IRQ0 */
44 GPIO6_GPIO, /* IRQ1 */
45 GPIO27_GPIO, /* RST0 */
46 GPIO24_GPIO, /* RST1 */
47 GPIO20_GPIO, /* PWR0 */
48 GPIO23_GPIO, /* PWR1 */
49 GPIO48_nPOE,
50 GPIO49_nPWE,
51 GPIO50_nPIOR,
52 GPIO51_nPIOW,
53 GPIO52_nPCE_1,
54 GPIO53_nPCE_2,
55 GPIO54_nPSKTSEL,
56 GPIO55_nPREG,
57 GPIO56_nPWAIT,
58 GPIO57_nIOIS16,
59
60 /* wakeup */
61 GPIO0_GPIO | WAKEUP_ON_EDGE_RISE,
62};
63
64static unsigned long e400_pin_config[] __initdata = {
65 /* Chip selects */
66 GPIO15_nCS_1, /* CS1 - Flash */
67 GPIO80_nCS_4, /* CS4 - TMIO */
68
69 /* Clocks */
70 GPIO12_32KHz,
71
72 /* BTUART */
73 GPIO42_BTUART_RXD,
74 GPIO43_BTUART_TXD,
75 GPIO44_BTUART_CTS,
76 GPIO45_GPIO, /* Used by TMIO for #SUSPEND */
77
78 /* wakeup */
79 GPIO0_GPIO | WAKEUP_ON_EDGE_RISE,
80};
81
82/* Only e800 has 128MB RAM */ 27/* Only e800 has 128MB RAM */
83static void __init eseries_fixup(struct machine_desc *desc, 28void __init eseries_fixup(struct machine_desc *desc,
84 struct tag *tags, char **cmdline, struct meminfo *mi) 29 struct tag *tags, char **cmdline, struct meminfo *mi)
85{ 30{
86 mi->nr_banks=1; 31 mi->nr_banks=1;
@@ -92,95 +37,9 @@ static void __init eseries_fixup(struct machine_desc *desc,
92 mi->bank[0].size = (64*1024*1024); 37 mi->bank[0].size = (64*1024*1024);
93} 38}
94 39
95static void __init e740_init(void) 40struct pxa2xx_udc_mach_info e7xx_udc_mach_info = {
96{ 41 .gpio_vbus = GPIO_E7XX_USB_DISC,
97 pxa2xx_mfp_config(ARRAY_AND_SIZE(e740_pin_config)); 42 .gpio_pullup = GPIO_E7XX_USB_PULLUP,
98} 43 .gpio_pullup_inverted = 1
99 44};
100static void __init e400_init(void)
101{
102 pxa2xx_mfp_config(ARRAY_AND_SIZE(e400_pin_config));
103}
104
105/* e-series machine definitions */
106
107#ifdef CONFIG_MACH_E330
108MACHINE_START(E330, "Toshiba e330")
109 /* Maintainer: Ian Molton (spyro@f2s.com) */
110 .phys_io = 0x40000000,
111 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
112 .boot_params = 0xa0000100,
113 .map_io = pxa_map_io,
114 .init_irq = pxa25x_init_irq,
115 .fixup = eseries_fixup,
116 .timer = &pxa_timer,
117MACHINE_END
118#endif
119
120#ifdef CONFIG_MACH_E350
121MACHINE_START(E350, "Toshiba e350")
122 /* Maintainer: Ian Molton (spyro@f2s.com) */
123 .phys_io = 0x40000000,
124 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
125 .boot_params = 0xa0000100,
126 .map_io = pxa_map_io,
127 .init_irq = pxa25x_init_irq,
128 .fixup = eseries_fixup,
129 .timer = &pxa_timer,
130MACHINE_END
131#endif
132
133#ifdef CONFIG_MACH_E740
134MACHINE_START(E740, "Toshiba e740")
135 /* Maintainer: Ian Molton (spyro@f2s.com) */
136 .phys_io = 0x40000000,
137 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
138 .boot_params = 0xa0000100,
139 .map_io = pxa_map_io,
140 .init_irq = pxa25x_init_irq,
141 .fixup = eseries_fixup,
142 .init_machine = e740_init,
143 .timer = &pxa_timer,
144MACHINE_END
145#endif
146
147#ifdef CONFIG_MACH_E750
148MACHINE_START(E750, "Toshiba e750")
149 /* Maintainer: Ian Molton (spyro@f2s.com) */
150 .phys_io = 0x40000000,
151 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
152 .boot_params = 0xa0000100,
153 .map_io = pxa_map_io,
154 .init_irq = pxa25x_init_irq,
155 .fixup = eseries_fixup,
156 .timer = &pxa_timer,
157MACHINE_END
158#endif
159
160#ifdef CONFIG_MACH_E400
161MACHINE_START(E400, "Toshiba e400")
162 /* Maintainer: Ian Molton (spyro@f2s.com) */
163 .phys_io = 0x40000000,
164 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
165 .boot_params = 0xa0000100,
166 .map_io = pxa_map_io,
167 .init_irq = pxa25x_init_irq,
168 .fixup = eseries_fixup,
169 .init_machine = e400_init,
170 .timer = &pxa_timer,
171MACHINE_END
172#endif
173
174#ifdef CONFIG_MACH_E800
175MACHINE_START(E800, "Toshiba e800")
176 /* Maintainer: Ian Molton (spyro@f2s.com) */
177 .phys_io = 0x40000000,
178 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
179 .boot_params = 0xa0000100,
180 .map_io = pxa_map_io,
181 .init_irq = pxa25x_init_irq,
182 .fixup = eseries_fixup,
183 .timer = &pxa_timer,
184MACHINE_END
185#endif
186 45
diff --git a/arch/arm/mach-pxa/eseries.h b/arch/arm/mach-pxa/eseries.h
new file mode 100644
index 000000000000..a83f88d4b6ad
--- /dev/null
+++ b/arch/arm/mach-pxa/eseries.h
@@ -0,0 +1,4 @@
1void __init eseries_fixup(struct machine_desc *desc,
2 struct tag *tags, char **cmdline, struct meminfo *mi);
3
4extern struct pxa2xx_udc_mach_info e7xx_udc_mach_info;
diff --git a/arch/arm/mach-pxa/eseries_udc.c b/arch/arm/mach-pxa/eseries_udc.c
deleted file mode 100644
index d622c04c0d44..000000000000
--- a/arch/arm/mach-pxa/eseries_udc.c
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * UDC functions for the Toshiba e-series PDAs
3 *
4 * Copyright (c) Ian Molton 2003
5 *
6 * This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/device.h>
16
17#include <mach/udc.h>
18#include <mach/eseries-gpio.h>
19#include <mach/hardware.h>
20#include <mach/pxa-regs.h>
21#include <asm/mach/arch.h>
22#include <asm/mach-types.h>
23#include <asm/mach/map.h>
24#include <asm/domain.h>
25
26/* local PXA generic code */
27#include "generic.h"
28
29static struct pxa2xx_udc_mach_info e7xx_udc_mach_info = {
30 .gpio_vbus = GPIO_E7XX_USB_DISC,
31 .gpio_pullup = GPIO_E7XX_USB_PULLUP,
32 .gpio_pullup_inverted = 1
33};
34
35static struct pxa2xx_udc_mach_info e800_udc_mach_info = {
36 .gpio_vbus = GPIO_E800_USB_DISC,
37 .gpio_pullup = GPIO_E800_USB_PULLUP,
38 .gpio_pullup_inverted = 1
39};
40
41static int __init eseries_udc_init(void)
42{
43 if (machine_is_e330() || machine_is_e350() ||
44 machine_is_e740() || machine_is_e750() ||
45 machine_is_e400())
46 pxa_set_udc_info(&e7xx_udc_mach_info);
47 else if (machine_is_e800())
48 pxa_set_udc_info(&e800_udc_mach_info);
49
50 return 0;
51}
52
53module_init(eseries_udc_init);
54
55MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
56MODULE_DESCRIPTION("eseries UDC support");
57MODULE_LICENSE("GPLv2");
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index ceaed0076366..85ed0b33331f 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -46,7 +46,7 @@ void clear_reset_status(unsigned int mask)
46 */ 46 */
47unsigned int get_clk_frequency_khz(int info) 47unsigned int get_clk_frequency_khz(int info)
48{ 48{
49 if (cpu_is_pxa21x() || cpu_is_pxa25x()) 49 if (cpu_is_pxa25x())
50 return pxa25x_get_clk_frequency_khz(info); 50 return pxa25x_get_clk_frequency_khz(info);
51 else if (cpu_is_pxa27x()) 51 else if (cpu_is_pxa27x())
52 return pxa27x_get_clk_frequency_khz(info); 52 return pxa27x_get_clk_frequency_khz(info);
@@ -60,7 +60,7 @@ EXPORT_SYMBOL(get_clk_frequency_khz);
60 */ 60 */
61unsigned int get_memclk_frequency_10khz(void) 61unsigned int get_memclk_frequency_10khz(void)
62{ 62{
63 if (cpu_is_pxa21x() || cpu_is_pxa25x()) 63 if (cpu_is_pxa25x())
64 return pxa25x_get_memclk_frequency_10khz(); 64 return pxa25x_get_memclk_frequency_10khz();
65 else if (cpu_is_pxa27x()) 65 else if (cpu_is_pxa27x())
66 return pxa27x_get_memclk_frequency_10khz(); 66 return pxa27x_get_memclk_frequency_10khz();
@@ -88,11 +88,6 @@ static struct map_desc standard_io_desc[] __initdata = {
88 .pfn = __phys_to_pfn(0x48000000), 88 .pfn = __phys_to_pfn(0x48000000),
89 .length = 0x00200000, 89 .length = 0x00200000,
90 .type = MT_DEVICE 90 .type = MT_DEVICE
91 }, { /* USB host */
92 .virtual = 0xf8000000,
93 .pfn = __phys_to_pfn(0x4c000000),
94 .length = 0x00100000,
95 .type = MT_DEVICE
96 }, { /* Camera */ 91 }, { /* Camera */
97 .virtual = 0xfa000000, 92 .virtual = 0xfa000000,
98 .pfn = __phys_to_pfn(0x50000000), 93 .pfn = __phys_to_pfn(0x50000000),
diff --git a/arch/arm/mach-pxa/generic.h b/arch/arm/mach-pxa/generic.h
index 041c048320e4..dc876a8e6668 100644
--- a/arch/arm/mach-pxa/generic.h
+++ b/arch/arm/mach-pxa/generic.h
@@ -65,4 +65,5 @@ static inline void pxa3xx_clear_reset_status(unsigned int mask) {}
65 65
66extern struct sysdev_class pxa_irq_sysclass; 66extern struct sysdev_class pxa_irq_sysclass;
67extern struct sysdev_class pxa_gpio_sysclass; 67extern struct sysdev_class pxa_gpio_sysclass;
68extern struct sysdev_class pxa2xx_mfp_sysclass;
68extern struct sysdev_class pxa3xx_mfp_sysclass; 69extern struct sysdev_class pxa3xx_mfp_sysclass;
diff --git a/arch/arm/mach-pxa/gpio.c b/arch/arm/mach-pxa/gpio.c
index 07acc1b23857..14930cf8be7b 100644
--- a/arch/arm/mach-pxa/gpio.c
+++ b/arch/arm/mach-pxa/gpio.c
@@ -16,10 +16,10 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/irq.h> 17#include <linux/irq.h>
18#include <linux/sysdev.h> 18#include <linux/sysdev.h>
19#include <linux/io.h>
19 20
20#include <asm/gpio.h> 21#include <asm/gpio.h>
21#include <mach/hardware.h> 22#include <mach/hardware.h>
22#include <asm/io.h>
23#include <mach/pxa-regs.h> 23#include <mach/pxa-regs.h>
24#include <mach/pxa2xx-gpio.h> 24#include <mach/pxa2xx-gpio.h>
25 25
@@ -275,7 +275,7 @@ static void pxa_gpio_demux_handler(unsigned int irq, struct irq_desc *desc)
275 loop = 1; 275 loop = 1;
276 276
277 n = PXA_GPIO_IRQ_BASE + bit; 277 n = PXA_GPIO_IRQ_BASE + bit;
278 desc_handle_irq(n, irq_desc + n); 278 generic_handle_irq(n);
279 279
280 bit = find_next_bit(gedr, GEDR_BITS, bit + 1); 280 bit = find_next_bit(gedr, GEDR_BITS, bit + 1);
281 } 281 }
diff --git a/arch/arm/mach-pxa/gumstix.c b/arch/arm/mach-pxa/gumstix.c
index c0092472fa58..d8962a0fb98d 100644
--- a/arch/arm/mach-pxa/gumstix.c
+++ b/arch/arm/mach-pxa/gumstix.c
@@ -20,8 +20,12 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/delay.h>
23#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
24#include <linux/mtd/partitions.h> 25#include <linux/mtd/partitions.h>
26#include <linux/gpio.h>
27#include <linux/err.h>
28#include <linux/clk.h>
25 29
26#include <asm/setup.h> 30#include <asm/setup.h>
27#include <asm/memory.h> 31#include <asm/memory.h>
@@ -40,7 +44,7 @@
40 44
41#include <mach/pxa-regs.h> 45#include <mach/pxa-regs.h>
42#include <mach/pxa2xx-regs.h> 46#include <mach/pxa2xx-regs.h>
43#include <mach/pxa2xx-gpio.h> 47#include <mach/mfp-pxa25x.h>
44 48
45#include "generic.h" 49#include "generic.h"
46 50
@@ -85,21 +89,8 @@ static struct platform_device *devices[] __initdata = {
85}; 89};
86 90
87#ifdef CONFIG_MMC_PXA 91#ifdef CONFIG_MMC_PXA
88static struct pxamci_platform_data gumstix_mci_platform_data;
89
90static int gumstix_mci_init(struct device *dev, irq_handler_t detect_int,
91 void *data)
92{
93 pxa_gpio_mode(GPIO6_MMCCLK_MD);
94 pxa_gpio_mode(GPIO53_MMCCLK_MD);
95 pxa_gpio_mode(GPIO8_MMCCS0_MD);
96
97 return 0;
98}
99
100static struct pxamci_platform_data gumstix_mci_platform_data = { 92static struct pxamci_platform_data gumstix_mci_platform_data = {
101 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 93 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
102 .init = gumstix_mci_init,
103}; 94};
104 95
105static void __init gumstix_mmc_init(void) 96static void __init gumstix_mmc_init(void)
@@ -109,11 +100,11 @@ static void __init gumstix_mmc_init(void)
109#else 100#else
110static void __init gumstix_mmc_init(void) 101static void __init gumstix_mmc_init(void)
111{ 102{
112 printk(KERN_INFO "Gumstix mmc disabled\n"); 103 pr_debug("Gumstix mmc disabled\n");
113} 104}
114#endif 105#endif
115 106
116#ifdef CONFIG_USB_GADGET_PXA2XX 107#ifdef CONFIG_USB_GADGET_PXA25X
117static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = { 108static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = {
118 .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn, 109 .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn,
119 .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx, 110 .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
@@ -126,12 +117,87 @@ static void __init gumstix_udc_init(void)
126#else 117#else
127static void gumstix_udc_init(void) 118static void gumstix_udc_init(void)
128{ 119{
129 printk(KERN_INFO "Gumstix udc is disabled\n"); 120 pr_debug("Gumstix udc is disabled\n");
130} 121}
131#endif 122#endif
132 123
124#ifdef CONFIG_BT
125/* Normally, the bootloader would have enabled this 32kHz clock but many
126** boards still have u-boot 1.1.4 so we check if it has been turned on and
127** if not, we turn it on with a warning message. */
128static void gumstix_setup_bt_clock(void)
129{
130 int timeout = 500;
131
132 if (!(OSCC & OSCC_OOK))
133 pr_warning("32kHz clock was not on. Bootloader may need to "
134 "be updated\n");
135 else
136 return;
137
138 OSCC |= OSCC_OON;
139 do {
140 if (OSCC & OSCC_OOK)
141 break;
142 udelay(1);
143 } while (--timeout);
144 if (!timeout)
145 pr_err("Failed to start 32kHz clock\n");
146}
147
148static void __init gumstix_bluetooth_init(void)
149{
150 int err;
151
152 gumstix_setup_bt_clock();
153
154 err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
155 if (err) {
156 pr_err("gumstix: failed request gpio for bluetooth reset\n");
157 return;
158 }
159
160 err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
161 if (err) {
162 pr_err("gumstix: can't reset bluetooth\n");
163 return;
164 }
165 gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
166 udelay(100);
167 gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
168}
169#else
170static void gumstix_bluetooth_init(void)
171{
172 pr_debug("Gumstix Bluetooth is disabled\n");
173}
174#endif
175
176static unsigned long gumstix_pin_config[] __initdata = {
177 GPIO12_32KHz,
178 /* BTUART */
179 GPIO42_HWUART_RXD,
180 GPIO43_HWUART_TXD,
181 GPIO44_HWUART_CTS,
182 GPIO45_HWUART_RTS,
183 /* MMC */
184 GPIO6_MMC_CLK,
185 GPIO53_MMC_CLK,
186 GPIO8_MMC_CS0,
187 /* these are used by AM200EPD */
188 GPIO51_GPIO,
189 GPIO49_GPIO,
190 GPIO48_GPIO,
191 GPIO32_GPIO,
192 GPIO17_GPIO,
193 GPIO16_GPIO,
194};
195
133static void __init gumstix_init(void) 196static void __init gumstix_init(void)
134{ 197{
198 pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
199
200 gumstix_bluetooth_init();
135 gumstix_udc_init(); 201 gumstix_udc_init();
136 gumstix_mmc_init(); 202 gumstix_mmc_init();
137 (void) platform_add_devices(devices, ARRAY_SIZE(devices)); 203 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
index 5aa0270d5605..013b15baa034 100644
--- a/arch/arm/mach-pxa/idp.c
+++ b/arch/arm/mach-pxa/idp.c
@@ -32,7 +32,7 @@
32#include <asm/mach/map.h> 32#include <asm/mach/map.h>
33 33
34#include <mach/pxa-regs.h> 34#include <mach/pxa-regs.h>
35#include <mach/pxa2xx-gpio.h> 35#include <mach/mfp-pxa25x.h>
36#include <mach/idp.h> 36#include <mach/idp.h>
37#include <mach/pxafb.h> 37#include <mach/pxafb.h>
38#include <mach/bitfield.h> 38#include <mach/bitfield.h>
@@ -46,6 +46,47 @@
46 * - Ethernet interrupt 46 * - Ethernet interrupt
47 */ 47 */
48 48
49static unsigned long idp_pin_config[] __initdata = {
50 /* LCD */
51 GPIO58_LCD_LDD_0,
52 GPIO59_LCD_LDD_1,
53 GPIO60_LCD_LDD_2,
54 GPIO61_LCD_LDD_3,
55 GPIO62_LCD_LDD_4,
56 GPIO63_LCD_LDD_5,
57 GPIO64_LCD_LDD_6,
58 GPIO65_LCD_LDD_7,
59 GPIO66_LCD_LDD_8,
60 GPIO67_LCD_LDD_9,
61 GPIO68_LCD_LDD_10,
62 GPIO69_LCD_LDD_11,
63 GPIO70_LCD_LDD_12,
64 GPIO71_LCD_LDD_13,
65 GPIO72_LCD_LDD_14,
66 GPIO73_LCD_LDD_15,
67 GPIO74_LCD_FCLK,
68 GPIO75_LCD_LCLK,
69 GPIO76_LCD_PCLK,
70
71 /* BTUART */
72 GPIO42_BTUART_RXD,
73 GPIO43_BTUART_TXD,
74 GPIO44_BTUART_CTS,
75 GPIO45_BTUART_RTS,
76
77 /* STUART */
78 GPIO46_STUART_RXD,
79 GPIO47_STUART_TXD,
80
81 /* MMC */
82 GPIO6_MMC_CLK,
83 GPIO8_MMC_CS0,
84
85 /* Ethernet */
86 GPIO33_nCS_5, /* Ethernet CS */
87 GPIO4_GPIO, /* Ethernet IRQ */
88};
89
49static struct resource smc91x_resources[] = { 90static struct resource smc91x_resources[] = {
50 [0] = { 91 [0] = {
51 .start = (IDP_ETH_PHYS + 0x300), 92 .start = (IDP_ETH_PHYS + 0x300),
@@ -121,44 +162,28 @@ static struct pxafb_mach_info sharp_lm8v31 = {
121 .num_modes = 1, 162 .num_modes = 1,
122 .cmap_inverse = 0, 163 .cmap_inverse = 0,
123 .cmap_static = 0, 164 .cmap_static = 0,
124 .lccr0 = LCCR0_SDS, 165 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
125 .lccr3 = LCCR3_PCP | LCCR3_Acb(255), 166 LCD_AC_BIAS_FREQ(255),
126 .pxafb_backlight_power = &idp_backlight_power, 167 .pxafb_backlight_power = &idp_backlight_power,
127 .pxafb_lcd_power = &idp_lcd_power 168 .pxafb_lcd_power = &idp_lcd_power
128}; 169};
129 170
130static int idp_mci_init(struct device *dev, irq_handler_t idp_detect_int, void *data)
131{
132 /* setup GPIO for PXA25x MMC controller */
133 pxa_gpio_mode(GPIO6_MMCCLK_MD);
134 pxa_gpio_mode(GPIO8_MMCCS0_MD);
135
136 return 0;
137}
138
139static struct pxamci_platform_data idp_mci_platform_data = { 171static struct pxamci_platform_data idp_mci_platform_data = {
140 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 172 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
141 .init = idp_mci_init,
142}; 173};
143 174
144static void __init idp_init(void) 175static void __init idp_init(void)
145{ 176{
146 printk("idp_init()\n"); 177 printk("idp_init()\n");
147 178
179 pxa2xx_mfp_config(ARRAY_AND_SIZE(idp_pin_config));
180
148 platform_device_register(&smc91x_device); 181 platform_device_register(&smc91x_device);
149 //platform_device_register(&mst_audio_device); 182 //platform_device_register(&mst_audio_device);
150 set_pxa_fb_info(&sharp_lm8v31); 183 set_pxa_fb_info(&sharp_lm8v31);
151 pxa_set_mci_info(&idp_mci_platform_data); 184 pxa_set_mci_info(&idp_mci_platform_data);
152} 185}
153 186
154static void __init idp_init_irq(void)
155{
156
157 pxa25x_init_irq();
158
159 set_irq_type(TOUCH_PANEL_IRQ, TOUCH_PANEL_IRQ_EDGE);
160}
161
162static struct map_desc idp_io_desc[] __initdata = { 187static struct map_desc idp_io_desc[] __initdata = {
163 { 188 {
164 .virtual = IDP_COREVOLT_VIRT, 189 .virtual = IDP_COREVOLT_VIRT,
@@ -177,15 +202,6 @@ static void __init idp_map_io(void)
177{ 202{
178 pxa_map_io(); 203 pxa_map_io();
179 iotable_init(idp_io_desc, ARRAY_SIZE(idp_io_desc)); 204 iotable_init(idp_io_desc, ARRAY_SIZE(idp_io_desc));
180
181 // serial ports 2 & 3
182 pxa_gpio_mode(GPIO42_BTRXD_MD);
183 pxa_gpio_mode(GPIO43_BTTXD_MD);
184 pxa_gpio_mode(GPIO44_BTCTS_MD);
185 pxa_gpio_mode(GPIO45_BTRTS_MD);
186 pxa_gpio_mode(GPIO46_STRXD_MD);
187 pxa_gpio_mode(GPIO47_STTXD_MD);
188
189} 205}
190 206
191 207
@@ -194,7 +210,7 @@ MACHINE_START(PXA_IDP, "Vibren PXA255 IDP")
194 .phys_io = 0x40000000, 210 .phys_io = 0x40000000,
195 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, 211 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
196 .map_io = idp_map_io, 212 .map_io = idp_map_io,
197 .init_irq = idp_init_irq, 213 .init_irq = pxa25x_init_irq,
198 .timer = &pxa_timer, 214 .timer = &pxa_timer,
199 .init_machine = idp_init, 215 .init_machine = idp_init,
200MACHINE_END 216MACHINE_END
diff --git a/arch/arm/mach-pxa/include/mach/akita.h b/arch/arm/mach-pxa/include/mach/akita.h
deleted file mode 100644
index 5d8cc1d9cb10..000000000000
--- a/arch/arm/mach-pxa/include/mach/akita.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Hardware specific definitions for SL-C1000 (Akita)
3 *
4 * Copyright (c) 2005 Richard Purdie
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12/* Akita IO Expander GPIOs */
13
14#define AKITA_IOEXP_RESERVED_7 (1 << 7)
15#define AKITA_IOEXP_IR_ON (1 << 6)
16#define AKITA_IOEXP_AKIN_PULLUP (1 << 5)
17#define AKITA_IOEXP_BACKLIGHT_CONT (1 << 4)
18#define AKITA_IOEXP_BACKLIGHT_ON (1 << 3)
19#define AKITA_IOEXP_MIC_BIAS (1 << 2)
20#define AKITA_IOEXP_RESERVED_1 (1 << 1)
21#define AKITA_IOEXP_RESERVED_0 (1 << 0)
22
23/* Direction Bitfield 0=output 1=input */
24#define AKITA_IOEXP_IO_DIR 0
25/* Default Values */
26#define AKITA_IOEXP_IO_OUT (AKITA_IOEXP_IR_ON | AKITA_IOEXP_AKIN_PULLUP)
27
28extern struct platform_device akitaioexp_device;
29
30void akita_set_ioexp(struct device *dev, unsigned char bitmask);
31void akita_reset_ioexp(struct device *dev, unsigned char bitmask);
32
diff --git a/arch/arm/mach-pxa/include/mach/corgi.h b/arch/arm/mach-pxa/include/mach/corgi.h
index bf856503baf6..585970ef08ce 100644
--- a/arch/arm/mach-pxa/include/mach/corgi.h
+++ b/arch/arm/mach-pxa/include/mach/corgi.h
@@ -98,12 +98,21 @@
98 CORGI_SCP_MIC_BIAS ) 98 CORGI_SCP_MIC_BIAS )
99#define CORGI_SCOOP_IO_OUT ( CORGI_SCP_MUTE_L | CORGI_SCP_MUTE_R ) 99#define CORGI_SCOOP_IO_OUT ( CORGI_SCP_MUTE_L | CORGI_SCP_MUTE_R )
100 100
101#define CORGI_SCOOP_GPIO_BASE (NR_BUILTIN_GPIO)
102#define CORGI_GPIO_LED_GREEN (CORGI_SCOOP_GPIO_BASE + 0)
103#define CORGI_GPIO_SWA (CORGI_SCOOP_GPIO_BASE + 1) /* Hinge Switch A */
104#define CORGI_GPIO_SWB (CORGI_SCOOP_GPIO_BASE + 2) /* Hinge Switch B */
105#define CORGI_GPIO_MUTE_L (CORGI_SCOOP_GPIO_BASE + 3)
106#define CORGI_GPIO_MUTE_R (CORGI_SCOOP_GPIO_BASE + 4)
107#define CORGI_GPIO_AKIN_PULLUP (CORGI_SCOOP_GPIO_BASE + 5)
108#define CORGI_GPIO_APM_ON (CORGI_SCOOP_GPIO_BASE + 6)
109#define CORGI_GPIO_BACKLIGHT_CONT (CORGI_SCOOP_GPIO_BASE + 7)
110#define CORGI_GPIO_MIC_BIAS (CORGI_SCOOP_GPIO_BASE + 8)
101 111
102/* 112/*
103 * Shared data structures 113 * Shared data structures
104 */ 114 */
105extern struct platform_device corgiscoop_device; 115extern struct platform_device corgiscoop_device;
106extern struct platform_device corgissp_device;
107 116
108#endif /* __ASM_ARCH_CORGI_H */ 117#endif /* __ASM_ARCH_CORGI_H */
109 118
diff --git a/arch/arm/mach-pxa/include/mach/entry-macro.S b/arch/arm/mach-pxa/include/mach/entry-macro.S
index de16c12d5232..f6b4bf3e73d2 100644
--- a/arch/arm/mach-pxa/include/mach/entry-macro.S
+++ b/arch/arm/mach-pxa/include/mach/entry-macro.S
@@ -41,7 +41,7 @@
41 and \irqstat, \irqstat, \irqnr 41 and \irqstat, \irqstat, \irqnr
42 clz \irqnr, \irqstat 42 clz \irqnr, \irqstat
43 rsb \irqnr, \irqnr, #31 43 rsb \irqnr, \irqnr, #31
44 add \irqnr, \irqnr, #32 44 add \irqnr, \irqnr, #(32 + PXA_IRQ(0))
45 b 1001f 45 b 1001f
461003: 461003:
47 mrc p6, 0, \irqstat, c0, c0, 0 @ ICIP 47 mrc p6, 0, \irqstat, c0, c0, 0 @ ICIP
@@ -52,6 +52,6 @@
52 rsb \irqstat, \irqnr, #0 52 rsb \irqstat, \irqnr, #0
53 and \irqstat, \irqstat, \irqnr 53 and \irqstat, \irqstat, \irqnr
54 clz \irqnr, \irqstat 54 clz \irqnr, \irqstat
55 rsb \irqnr, \irqnr, #31 55 rsb \irqnr, \irqnr, #(31 + PXA_IRQ(0))
561001: 561001:
57 .endm 57 .endm
diff --git a/arch/arm/mach-pxa/include/mach/hardware.h b/arch/arm/mach-pxa/include/mach/hardware.h
index e89df4d0d239..a582a6d9b92b 100644
--- a/arch/arm/mach-pxa/include/mach/hardware.h
+++ b/arch/arm/mach-pxa/include/mach/hardware.h
@@ -62,26 +62,74 @@
62 62
63#ifndef __ASSEMBLY__ 63#ifndef __ASSEMBLY__
64 64
65#include <asm/cputype.h>
66
67/*
68 * CPU Stepping CPU_ID JTAG_ID
69 *
70 * PXA210 B0 0x69052922 0x2926C013
71 * PXA210 B1 0x69052923 0x3926C013
72 * PXA210 B2 0x69052924 0x4926C013
73 * PXA210 C0 0x69052D25 0x5926C013
74 *
75 * PXA250 A0 0x69052100 0x09264013
76 * PXA250 A1 0x69052101 0x19264013
77 * PXA250 B0 0x69052902 0x29264013
78 * PXA250 B1 0x69052903 0x39264013
79 * PXA250 B2 0x69052904 0x49264013
80 * PXA250 C0 0x69052D05 0x59264013
81 *
82 * PXA255 A0 0x69052D06 0x69264013
83 *
84 * PXA26x A0 0x69052903 0x39264013
85 * PXA26x B0 0x69052D05 0x59264013
86 *
87 * PXA27x A0 0x69054110 0x09265013
88 * PXA27x A1 0x69054111 0x19265013
89 * PXA27x B0 0x69054112 0x29265013
90 * PXA27x B1 0x69054113 0x39265013
91 * PXA27x C0 0x69054114 0x49265013
92 * PXA27x C5 0x69054117 0x79265013
93 *
94 * PXA30x A0 0x69056880 0x0E648013
95 * PXA30x A1 0x69056881 0x1E648013
96 * PXA31x A0 0x69056890 0x0E649013
97 * PXA31x A1 0x69056891 0x1E649013
98 * PXA31x A2 0x69056892 0x2E649013
99 * PXA32x B1 0x69056825 0x5E642013
100 * PXA32x B2 0x69056826 0x6E642013
101 *
102 * PXA930 B0 0x69056835 0x5E643013
103 * PXA930 B1 0x69056837 0x7E643013
104 * PXA930 B2 0x69056838 0x8E643013
105 */
65#ifdef CONFIG_PXA25x 106#ifdef CONFIG_PXA25x
66#define __cpu_is_pxa21x(id) \ 107#define __cpu_is_pxa210(id) \
67 ({ \ 108 ({ \
68 unsigned int _id = (id) >> 4 & 0xf3f; \ 109 unsigned int _id = (id) & 0xf3f0; \
69 _id == 0x212; \ 110 _id == 0x2120; \
70 }) 111 })
71 112
72#define __cpu_is_pxa255(id) \ 113#define __cpu_is_pxa250(id) \
73 ({ \ 114 ({ \
74 unsigned int _id = (id) >> 4 & 0xfff; \ 115 unsigned int _id = (id) & 0xf3ff; \
75 _id == 0x2d0; \ 116 _id <= 0x2105; \
76 }) 117 })
118
119#define __cpu_is_pxa255(id) \
120 ({ \
121 unsigned int _id = (id) & 0xffff; \
122 _id == 0x2d06; \
123 })
77 124
78#define __cpu_is_pxa25x(id) \ 125#define __cpu_is_pxa25x(id) \
79 ({ \ 126 ({ \
80 unsigned int _id = (id) >> 4 & 0xfff; \ 127 unsigned int _id = (id) & 0xf300; \
81 _id == 0x2d0 || _id == 0x290; \ 128 _id == 0x2100; \
82 }) 129 })
83#else 130#else
84#define __cpu_is_pxa21x(id) (0) 131#define __cpu_is_pxa210(id) (0)
132#define __cpu_is_pxa250(id) (0)
85#define __cpu_is_pxa255(id) (0) 133#define __cpu_is_pxa255(id) (0)
86#define __cpu_is_pxa25x(id) (0) 134#define __cpu_is_pxa25x(id) (0)
87#endif 135#endif
@@ -136,9 +184,14 @@
136#define __cpu_is_pxa930(id) (0) 184#define __cpu_is_pxa930(id) (0)
137#endif 185#endif
138 186
139#define cpu_is_pxa21x() \ 187#define cpu_is_pxa210() \
140 ({ \ 188 ({ \
141 __cpu_is_pxa21x(read_cpuid_id()); \ 189 __cpu_is_pxa210(read_cpuid_id()); \
190 })
191
192#define cpu_is_pxa250() \
193 ({ \
194 __cpu_is_pxa250(read_cpuid_id()); \
142 }) 195 })
143 196
144#define cpu_is_pxa255() \ 197#define cpu_is_pxa255() \
@@ -151,6 +204,8 @@
151 __cpu_is_pxa25x(read_cpuid_id()); \ 204 __cpu_is_pxa25x(read_cpuid_id()); \
152 }) 205 })
153 206
207extern int cpu_is_pxa26x(void);
208
154#define cpu_is_pxa27x() \ 209#define cpu_is_pxa27x() \
155 ({ \ 210 ({ \
156 __cpu_is_pxa27x(read_cpuid_id()); \ 211 __cpu_is_pxa27x(read_cpuid_id()); \
diff --git a/arch/arm/mach-pxa/include/mach/i2c.h b/arch/arm/mach-pxa/include/mach/i2c.h
index 80596b013443..1a9f65e6ec0f 100644
--- a/arch/arm/mach-pxa/include/mach/i2c.h
+++ b/arch/arm/mach-pxa/include/mach/i2c.h
@@ -65,13 +65,18 @@ struct i2c_pxa_platform_data {
65 unsigned int slave_addr; 65 unsigned int slave_addr;
66 struct i2c_slave_client *slave; 66 struct i2c_slave_client *slave;
67 unsigned int class; 67 unsigned int class;
68 int use_pio; 68 unsigned int use_pio :1;
69 unsigned int fast_mode :1;
69}; 70};
70 71
71extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info); 72extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
72 73
73#ifdef CONFIG_PXA27x 74#ifdef CONFIG_PXA27x
74extern void pxa_set_i2c_power_info(struct i2c_pxa_platform_data *info); 75extern void pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info);
76#endif
77
78#ifdef CONFIG_PXA3xx
79extern void pxa3xx_set_i2c_power_info(struct i2c_pxa_platform_data *info);
75#endif 80#endif
76 81
77#endif 82#endif
diff --git a/arch/arm/mach-pxa/include/mach/irqs.h b/arch/arm/mach-pxa/include/mach/irqs.h
index 108b5db9b2af..9c163e19ada9 100644
--- a/arch/arm/mach-pxa/include/mach/irqs.h
+++ b/arch/arm/mach-pxa/include/mach/irqs.h
@@ -11,7 +11,14 @@
11 */ 11 */
12 12
13 13
14#define PXA_IRQ(x) (x) 14#ifdef CONFIG_PXA_HAVE_ISA_IRQS
15#define PXA_ISA_IRQ(x) (x)
16#define PXA_ISA_IRQ_NUM (16)
17#else
18#define PXA_ISA_IRQ_NUM (0)
19#endif
20
21#define PXA_IRQ(x) (PXA_ISA_IRQ_NUM + (x))
15 22
16#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) 23#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
17#define IRQ_SSP3 PXA_IRQ(0) /* SSP3 service request */ 24#define IRQ_SSP3 PXA_IRQ(0) /* SSP3 service request */
@@ -73,7 +80,7 @@
73#define IRQ_MMC3 PXA_IRQ(55) /* MMC3 Controller (PXA310) */ 80#define IRQ_MMC3 PXA_IRQ(55) /* MMC3 Controller (PXA310) */
74#endif 81#endif
75 82
76#define PXA_GPIO_IRQ_BASE (64) 83#define PXA_GPIO_IRQ_BASE PXA_IRQ(64)
77#define PXA_GPIO_IRQ_NUM (128) 84#define PXA_GPIO_IRQ_NUM (128)
78 85
79#define GPIO_2_x_TO_IRQ(x) (PXA_GPIO_IRQ_BASE + (x)) 86#define GPIO_2_x_TO_IRQ(x) (PXA_GPIO_IRQ_BASE + (x))
@@ -178,13 +185,7 @@
178#define NR_IRQS (IRQ_S1_BVD1_STSCHG + 1) 185#define NR_IRQS (IRQ_S1_BVD1_STSCHG + 1)
179#elif defined(CONFIG_SHARP_LOCOMO) 186#elif defined(CONFIG_SHARP_LOCOMO)
180#define NR_IRQS (IRQ_LOCOMO_SPI_TEND + 1) 187#define NR_IRQS (IRQ_LOCOMO_SPI_TEND + 1)
181#elif defined(CONFIG_ARCH_LUBBOCK) || \ 188#elif defined(CONFIG_PXA_HAVE_BOARD_IRQS)
182 defined(CONFIG_MACH_LOGICPD_PXA270) || \
183 defined(CONFIG_MACH_TOSA) || \
184 defined(CONFIG_MACH_MAINSTONE) || \
185 defined(CONFIG_MACH_PCM027) || \
186 defined(CONFIG_ARCH_PXA_ESERIES) || \
187 defined(CONFIG_MACH_MAGICIAN)
188#define NR_IRQS (IRQ_BOARD_END) 189#define NR_IRQS (IRQ_BOARD_END)
189#elif defined(CONFIG_MACH_ZYLONITE) 190#elif defined(CONFIG_MACH_ZYLONITE)
190#define NR_IRQS (IRQ_BOARD_START + 32) 191#define NR_IRQS (IRQ_BOARD_START + 32)
diff --git a/arch/arm/mach-pxa/include/mach/littleton.h b/arch/arm/mach-pxa/include/mach/littleton.h
index 79d209b826f4..5c4e320c1437 100644
--- a/arch/arm/mach-pxa/include/mach/littleton.h
+++ b/arch/arm/mach-pxa/include/mach/littleton.h
@@ -3,4 +3,6 @@
3 3
4#define LITTLETON_ETH_PHYS 0x30000000 4#define LITTLETON_ETH_PHYS 0x30000000
5 5
6#define LITTLETON_GPIO_LCD_CS (17)
7
6#endif /* __ASM_ARCH_ZYLONITE_H */ 8#endif /* __ASM_ARCH_ZYLONITE_H */
diff --git a/arch/arm/mach-pxa/include/mach/memory.h b/arch/arm/mach-pxa/include/mach/memory.h
index 552eb7fa6579..59aef89808d6 100644
--- a/arch/arm/mach-pxa/include/mach/memory.h
+++ b/arch/arm/mach-pxa/include/mach/memory.h
@@ -40,11 +40,11 @@
40#define NODE_MEM_SIZE_BITS 26 40#define NODE_MEM_SIZE_BITS 26
41 41
42#if !defined(__ASSEMBLY__) && defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI) 42#if !defined(__ASSEMBLY__) && defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI)
43void cmx270_pci_adjust_zones(int node, unsigned long *size, 43void cmx2xx_pci_adjust_zones(int node, unsigned long *size,
44 unsigned long *holes); 44 unsigned long *holes);
45 45
46#define arch_adjust_zones(node, size, holes) \ 46#define arch_adjust_zones(node, size, holes) \
47 cmx270_pci_adjust_zones(node, size, holes) 47 cmx2xx_pci_adjust_zones(node, size, holes)
48 48
49#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_64M - 1) 49#define ISA_DMA_THRESHOLD (PHYS_OFFSET + SZ_64M - 1)
50#endif 50#endif
diff --git a/arch/arm/mach-pxa/include/mach/mfp-pxa25x.h b/arch/arm/mach-pxa/include/mach/mfp-pxa25x.h
index 6c8e72238bfd..617cab2cc8d0 100644
--- a/arch/arm/mach-pxa/include/mach/mfp-pxa25x.h
+++ b/arch/arm/mach-pxa/include/mach/mfp-pxa25x.h
@@ -17,7 +17,7 @@
17 17
18/* Crystal and Clock Signals */ 18/* Crystal and Clock Signals */
19#define GPIO10_RTCCLK MFP_CFG_OUT(GPIO10, AF1, DRIVE_LOW) 19#define GPIO10_RTCCLK MFP_CFG_OUT(GPIO10, AF1, DRIVE_LOW)
20#define GPIO70_RTC_CLK MFP_CFG_OUT(GPIO70, AF1, DRIVE_LOW) 20#define GPIO70_RTCCLK MFP_CFG_OUT(GPIO70, AF1, DRIVE_LOW)
21#define GPIO7_48MHz MFP_CFG_OUT(GPIO7, AF1, DRIVE_LOW) 21#define GPIO7_48MHz MFP_CFG_OUT(GPIO7, AF1, DRIVE_LOW)
22#define GPIO11_3_6MHz MFP_CFG_OUT(GPIO11, AF1, DRIVE_LOW) 22#define GPIO11_3_6MHz MFP_CFG_OUT(GPIO11, AF1, DRIVE_LOW)
23#define GPIO71_3_6MHz MFP_CFG_OUT(GPIO71, AF1, DRIVE_LOW) 23#define GPIO71_3_6MHz MFP_CFG_OUT(GPIO71, AF1, DRIVE_LOW)
@@ -156,6 +156,6 @@
156#define GPIO74_LCD_FCLK MFP_CFG_OUT(GPIO74, AF2, DRIVE_LOW) 156#define GPIO74_LCD_FCLK MFP_CFG_OUT(GPIO74, AF2, DRIVE_LOW)
157#define GPIO75_LCD_LCLK MFP_CFG_OUT(GPIO75, AF2, DRIVE_LOW) 157#define GPIO75_LCD_LCLK MFP_CFG_OUT(GPIO75, AF2, DRIVE_LOW)
158#define GPIO76_LCD_PCLK MFP_CFG_OUT(GPIO76, AF2, DRIVE_LOW) 158#define GPIO76_LCD_PCLK MFP_CFG_OUT(GPIO76, AF2, DRIVE_LOW)
159#define GPIO77_LCD_ACBIAS MFP_CFG_OUT(GPIO77, AF2, DRIVE_LOW) 159#define GPIO77_LCD_BIAS MFP_CFG_OUT(GPIO77, AF2, DRIVE_LOW)
160 160
161#endif /* __ASM_ARCH_MFP_PXA25X_H */ 161#endif /* __ASM_ARCH_MFP_PXA25X_H */
diff --git a/arch/arm/mach-pxa/include/mach/mfp-pxa320.h b/arch/arm/mach-pxa/include/mach/mfp-pxa320.h
index 74990510cf34..67f8385ea548 100644
--- a/arch/arm/mach-pxa/include/mach/mfp-pxa320.h
+++ b/arch/arm/mach-pxa/include/mach/mfp-pxa320.h
@@ -257,10 +257,10 @@
257#define GPIO38_SSP2_RXD MFP_CFG(GPIO38, AF2) 257#define GPIO38_SSP2_RXD MFP_CFG(GPIO38, AF2)
258#define GPIO38_SSP2_TXD MFP_CFG(GPIO38, AF5) 258#define GPIO38_SSP2_TXD MFP_CFG(GPIO38, AF5)
259 259
260#define GPIO69_SSP3_SCLK MFP_CFG(GPIO69, AF2, DS08X, FLOAT) 260#define GPIO69_SSP3_SCLK MFP_CFG_X(GPIO69, AF2, DS08X, FLOAT)
261#define GPIO70_SSP3_FRM MFP_CFG(GPIO70, AF2, DS08X, DRIVE_LOW) 261#define GPIO70_SSP3_FRM MFP_CFG_X(GPIO70, AF2, DS08X, DRIVE_LOW)
262#define GPIO89_SSP3_SCLK MFP_CFG(GPIO89, AF1, DS08X, FLOAT) 262#define GPIO89_SSP3_SCLK MFP_CFG_X(GPIO89, AF1, DS08X, FLOAT)
263#define GPIO90_SSP3_FRM MFP_CFG(GPIO90, AF1, DS08X, DRIVE_LOW) 263#define GPIO90_SSP3_FRM MFP_CFG_X(GPIO90, AF1, DS08X, DRIVE_LOW)
264#define GPIO71_SSP3_RXD MFP_CFG_X(GPIO71, AF5, DS08X, FLOAT) 264#define GPIO71_SSP3_RXD MFP_CFG_X(GPIO71, AF5, DS08X, FLOAT)
265#define GPIO71_SSP3_TXD MFP_CFG_X(GPIO71, AF2, DS08X, DRIVE_LOW) 265#define GPIO71_SSP3_TXD MFP_CFG_X(GPIO71, AF2, DS08X, DRIVE_LOW)
266#define GPIO72_SSP3_RXD MFP_CFG_X(GPIO72, AF2, DS08X, FLOAT) 266#define GPIO72_SSP3_RXD MFP_CFG_X(GPIO72, AF2, DS08X, FLOAT)
diff --git a/arch/arm/mach-pxa/include/mach/mfp.h b/arch/arm/mach-pxa/include/mach/mfp.h
index 8769567b389b..482185053a92 100644
--- a/arch/arm/mach-pxa/include/mach/mfp.h
+++ b/arch/arm/mach-pxa/include/mach/mfp.h
@@ -274,12 +274,13 @@ typedef unsigned long mfp_cfg_t;
274#define MFP_DS_MASK (0x7 << 13) 274#define MFP_DS_MASK (0x7 << 13)
275#define MFP_DS(x) (((x) >> 13) & 0x7) 275#define MFP_DS(x) (((x) >> 13) & 0x7)
276 276
277#define MFP_LPM_INPUT (0x0 << 16) 277#define MFP_LPM_DEFAULT (0x0 << 16)
278#define MFP_LPM_DRIVE_LOW (0x1 << 16) 278#define MFP_LPM_DRIVE_LOW (0x1 << 16)
279#define MFP_LPM_DRIVE_HIGH (0x2 << 16) 279#define MFP_LPM_DRIVE_HIGH (0x2 << 16)
280#define MFP_LPM_PULL_LOW (0x3 << 16) 280#define MFP_LPM_PULL_LOW (0x3 << 16)
281#define MFP_LPM_PULL_HIGH (0x4 << 16) 281#define MFP_LPM_PULL_HIGH (0x4 << 16)
282#define MFP_LPM_FLOAT (0x5 << 16) 282#define MFP_LPM_FLOAT (0x5 << 16)
283#define MFP_LPM_INPUT (0x6 << 16)
283#define MFP_LPM_STATE_MASK (0x7 << 16) 284#define MFP_LPM_STATE_MASK (0x7 << 16)
284#define MFP_LPM_STATE(x) (((x) >> 16) & 0x7) 285#define MFP_LPM_STATE(x) (((x) >> 16) & 0x7)
285 286
@@ -297,7 +298,7 @@ typedef unsigned long mfp_cfg_t;
297#define MFP_PULL_MASK (0x3 << 21) 298#define MFP_PULL_MASK (0x3 << 21)
298#define MFP_PULL(x) (((x) >> 21) & 0x3) 299#define MFP_PULL(x) (((x) >> 21) & 0x3)
299 300
300#define MFP_CFG_DEFAULT (MFP_AF0 | MFP_DS03X | MFP_LPM_INPUT |\ 301#define MFP_CFG_DEFAULT (MFP_AF0 | MFP_DS03X | MFP_LPM_DEFAULT |\
301 MFP_LPM_EDGE_NONE | MFP_PULL_NONE) 302 MFP_LPM_EDGE_NONE | MFP_PULL_NONE)
302 303
303#define MFP_CFG(pin, af) \ 304#define MFP_CFG(pin, af) \
diff --git a/arch/arm/mach-pxa/include/mach/mioa701.h b/arch/arm/mach-pxa/include/mach/mioa701.h
new file mode 100644
index 000000000000..8483cb511831
--- /dev/null
+++ b/arch/arm/mach-pxa/include/mach/mioa701.h
@@ -0,0 +1,67 @@
1#ifndef _MIOA701_H_
2#define _MIOA701_H_
3
4#define MIO_CFG_IN(pin, af) \
5 ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DIR_MASK)) |\
6 (MFP_PIN(pin) | MFP_##af | MFP_DIR_IN))
7
8#define MIO_CFG_OUT(pin, af, state) \
9 ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DIR_MASK | MFP_LPM_STATE_MASK)) |\
10 (MFP_PIN(pin) | MFP_##af | MFP_DIR_OUT | MFP_LPM_##state))
11
12/* Global GPIOs */
13#define GPIO9_CHARGE_nEN 9
14#define GPIO18_POWEROFF 18
15#define GPIO87_LCD_POWER 87
16
17/* USB */
18#define GPIO13_USB_DETECT 13
19#define GPIO22_USB_ENABLE 22
20
21/* SDIO bits */
22#define GPIO78_SDIO_RO 78
23#define GPIO15_SDIO_INSERT 15
24#define GPIO91_SDIO_EN 91
25
26/* Bluetooth */
27#define GPIO83_BT_ON 83
28
29/* GPS */
30#define GPIO23_GPS_UNKNOWN1 23
31#define GPIO26_GPS_ON 26
32#define GPIO27_GPS_RESET 27
33#define GPIO106_GPS_UNKNOWN2 106
34#define GPIO107_GPS_UNKNOWN3 107
35
36/* GSM */
37#define GPIO24_GSM_MOD_RESET_CMD 24
38#define GPIO88_GSM_nMOD_ON_CMD 88
39#define GPIO90_GSM_nMOD_OFF_CMD 90
40#define GPIO114_GSM_nMOD_DTE_UART_STATE 114
41#define GPIO25_GSM_MOD_ON_STATE 25
42#define GPIO113_GSM_EVENT 113
43
44/* SOUND */
45#define GPIO12_HPJACK_INSERT 12
46
47/* LEDS */
48#define GPIO10_LED_nCharging 10
49#define GPIO97_LED_nBlue 97
50#define GPIO98_LED_nOrange 98
51#define GPIO82_LED_nVibra 82
52#define GPIO115_LED_nKeyboard 115
53
54/* Keyboard */
55#define GPIO0_KEY_POWER 0
56#define GPIO93_KEY_VOLUME_UP 93
57#define GPIO94_KEY_VOLUME_DOWN 94
58
59extern struct input_dev *mioa701_evdev;
60extern void mioa701_gpio_lpm_set(unsigned long mfp_pin);
61
62/* Assembler externals mioa701_bootresume.S */
63extern u32 mioa701_bootstrap;
64extern u32 mioa701_jumpaddr;
65extern u32 mioa701_bootstrap_lg;
66
67#endif /* _MIOA701_H */
diff --git a/arch/arm/mach-pxa/include/mach/ohci.h b/arch/arm/mach-pxa/include/mach/ohci.h
index e848a47128cd..95b6e2a6e514 100644
--- a/arch/arm/mach-pxa/include/mach/ohci.h
+++ b/arch/arm/mach-pxa/include/mach/ohci.h
@@ -7,6 +7,22 @@ struct pxaohci_platform_data {
7 int (*init)(struct device *); 7 int (*init)(struct device *);
8 void (*exit)(struct device *); 8 void (*exit)(struct device *);
9 9
10 unsigned long flags;
11#define ENABLE_PORT1 (1 << 0)
12#define ENABLE_PORT2 (1 << 1)
13#define ENABLE_PORT3 (1 << 2)
14#define ENABLE_PORT_ALL (ENABLE_PORT1 | ENABLE_PORT2 | ENABLE_PORT3)
15
16#define POWER_SENSE_LOW (1 << 3)
17#define POWER_CONTROL_LOW (1 << 4)
18#define NO_OC_PROTECTION (1 << 5)
19#define OC_MODE_GLOBAL (0 << 6)
20#define OC_MODE_PERPORT (1 << 6)
21
22 int power_on_delay; /* Power On to Power Good time - in ms
23 * HCD must wait for this duration before
24 * accessing a powered on port
25 */
10 int port_mode; 26 int port_mode;
11#define PMM_NPS_MODE 1 27#define PMM_NPS_MODE 1
12#define PMM_GLOBAL_MODE 2 28#define PMM_GLOBAL_MODE 2
diff --git a/arch/arm/mach-pxa/include/mach/palmz72.h b/arch/arm/mach-pxa/include/mach/palmz72.h
new file mode 100644
index 000000000000..5032307ebf7d
--- /dev/null
+++ b/arch/arm/mach-pxa/include/mach/palmz72.h
@@ -0,0 +1,80 @@
1/*
2 * GPIOs and interrupts for Palm Zire72 Handheld Computer
3 *
4 * Authors: Alex Osborne <bobofdoom@gmail.com>
5 * Jan Herman <2hp@seznam.cz>
6 * Sergey Lapin <slapin@ossfans.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#ifndef _INCLUDE_PALMZ72_H_
15#define _INCLUDE_PALMZ72_H_
16
17/* Power and control */
18#define GPIO_NR_PALMZ72_GPIO_RESET 1
19#define GPIO_NR_PALMZ72_POWER_DETECT 0
20
21/* SD/MMC */
22#define GPIO_NR_PALMZ72_SD_DETECT_N 14
23#define GPIO_NR_PALMZ72_SD_POWER_N 98
24#define GPIO_NR_PALMZ72_SD_RO 115
25
26/* Touchscreen */
27#define GPIO_NR_PALMZ72_WM9712_IRQ 27
28
29/* IRDA - disable GPIO connected to SD pin of tranceiver (TFBS4710?) ? */
30#define GPIO_NR_PALMZ72_IR_DISABLE 49
31
32/* USB */
33#define GPIO_NR_PALMZ72_USB_DETECT_N 15
34#define GPIO_NR_PALMZ72_USB_POWER 95
35#define GPIO_NR_PALMZ72_USB_PULLUP 12
36
37/* LCD/Backlight */
38#define GPIO_NR_PALMZ72_BL_POWER 20
39#define GPIO_NR_PALMZ72_LCD_POWER 96
40
41/* LED */
42#define GPIO_NR_PALMZ72_LED_GREEN 88
43
44/* Bluetooth */
45#define GPIO_NR_PALMZ72_BT_POWER 17
46#define GPIO_NR_PALMZ72_BT_RESET 83
47
48/** Initial values **/
49
50/* Battery */
51#define PALMZ72_BAT_MAX_VOLTAGE 4000 /* 4.00v current voltage */
52#define PALMZ72_BAT_MIN_VOLTAGE 3550 /* 3.55v critical voltage */
53#define PALMZ72_BAT_MAX_CURRENT 0 /* unknokn */
54#define PALMZ72_BAT_MIN_CURRENT 0 /* unknown */
55#define PALMZ72_BAT_MAX_CHARGE 1 /* unknown */
56#define PALMZ72_BAT_MIN_CHARGE 1 /* unknown */
57#define PALMZ72_MAX_LIFE_MINS 360 /* on-life in minutes */
58
59/* Backlight */
60#define PALMZ72_MAX_INTENSITY 0xFE
61#define PALMZ72_DEFAULT_INTENSITY 0x7E
62#define PALMZ72_LIMIT_MASK 0x7F
63#define PALMZ72_PRESCALER 0x3F
64#define PALMZ72_PERIOD_NS 3500
65
66#ifdef CONFIG_PM
67struct palmz72_resume_info {
68 u32 magic0; /* 0x0 */
69 u32 magic1; /* 0x4 */
70 u32 resume_addr; /* 0x8 */
71 u32 pad[11]; /* 0xc..0x37 */
72 u32 arm_control; /* 0x38 */
73 u32 aux_control; /* 0x3c */
74 u32 ttb; /* 0x40 */
75 u32 domain_access; /* 0x44 */
76 u32 process_id; /* 0x48 */
77};
78#endif
79#endif
80
diff --git a/arch/arm/mach-pxa/include/mach/pm.h b/arch/arm/mach-pxa/include/mach/pm.h
index 261e5bc958db..83342469acac 100644
--- a/arch/arm/mach-pxa/include/mach/pm.h
+++ b/arch/arm/mach-pxa/include/mach/pm.h
@@ -15,6 +15,8 @@ struct pxa_cpu_pm_fns {
15 void (*restore)(unsigned long *); 15 void (*restore)(unsigned long *);
16 int (*valid)(suspend_state_t state); 16 int (*valid)(suspend_state_t state);
17 void (*enter)(suspend_state_t state); 17 void (*enter)(suspend_state_t state);
18 int (*prepare)(void);
19 void (*finish)(void);
18}; 20};
19 21
20extern struct pxa_cpu_pm_fns *pxa_cpu_pm_fns; 22extern struct pxa_cpu_pm_fns *pxa_cpu_pm_fns;
diff --git a/arch/arm/mach-pxa/include/mach/poodle.h b/arch/arm/mach-pxa/include/mach/poodle.h
index 67debc47e8c6..0b3e6d051c64 100644
--- a/arch/arm/mach-pxa/include/mach/poodle.h
+++ b/arch/arm/mach-pxa/include/mach/poodle.h
@@ -23,6 +23,7 @@
23#define POODLE_GPIO_AC_IN (1) 23#define POODLE_GPIO_AC_IN (1)
24#define POODLE_GPIO_CO 16 24#define POODLE_GPIO_CO 16
25#define POODLE_GPIO_TP_INT (5) 25#define POODLE_GPIO_TP_INT (5)
26#define POODLE_GPIO_TP_CS (24)
26#define POODLE_GPIO_WAKEUP (11) /* change battery */ 27#define POODLE_GPIO_WAKEUP (11) /* change battery */
27#define POODLE_GPIO_GA_INT (10) 28#define POODLE_GPIO_GA_INT (10)
28#define POODLE_GPIO_IR_ON (22) 29#define POODLE_GPIO_IR_ON (22)
@@ -70,6 +71,14 @@
70#define POODLE_SCOOP_IO_DIR ( POODLE_SCOOP_VPEN | POODLE_SCOOP_HS_OUT ) 71#define POODLE_SCOOP_IO_DIR ( POODLE_SCOOP_VPEN | POODLE_SCOOP_HS_OUT )
71#define POODLE_SCOOP_IO_OUT ( 0 ) 72#define POODLE_SCOOP_IO_OUT ( 0 )
72 73
74#define POODLE_SCOOP_GPIO_BASE (NR_BUILTIN_GPIO)
75#define POODLE_GPIO_CHARGE_ON (POODLE_SCOOP_GPIO_BASE + 0)
76#define POODLE_GPIO_CP401 (POODLE_SCOOP_GPIO_BASE + 2)
77#define POODLE_GPIO_VPEN (POODLE_SCOOP_GPIO_BASE + 7)
78#define POODLE_GPIO_L_PCLK (POODLE_SCOOP_GPIO_BASE + 9)
79#define POODLE_GPIO_L_LCLK (POODLE_SCOOP_GPIO_BASE + 10)
80#define POODLE_GPIO_HS_OUT (POODLE_SCOOP_GPIO_BASE + 11)
81
73#define POODLE_LOCOMO_GPIO_AMP_ON LOCOMO_GPIO(8) 82#define POODLE_LOCOMO_GPIO_AMP_ON LOCOMO_GPIO(8)
74#define POODLE_LOCOMO_GPIO_MUTE_L LOCOMO_GPIO(10) 83#define POODLE_LOCOMO_GPIO_MUTE_L LOCOMO_GPIO(10)
75#define POODLE_LOCOMO_GPIO_MUTE_R LOCOMO_GPIO(11) 84#define POODLE_LOCOMO_GPIO_MUTE_R LOCOMO_GPIO(11)
diff --git a/arch/arm/mach-pxa/include/mach/pxa-regs.h b/arch/arm/mach-pxa/include/mach/pxa-regs.h
index 12288ca3cbb2..15295d960000 100644
--- a/arch/arm/mach-pxa/include/mach/pxa-regs.h
+++ b/arch/arm/mach-pxa/include/mach/pxa-regs.h
@@ -69,30 +69,18 @@
69/* 69/*
70 * DMA Controller 70 * DMA Controller
71 */ 71 */
72
73#define DCSR0 __REG(0x40000000) /* DMA Control / Status Register for Channel 0 */
74#define DCSR1 __REG(0x40000004) /* DMA Control / Status Register for Channel 1 */
75#define DCSR2 __REG(0x40000008) /* DMA Control / Status Register for Channel 2 */
76#define DCSR3 __REG(0x4000000c) /* DMA Control / Status Register for Channel 3 */
77#define DCSR4 __REG(0x40000010) /* DMA Control / Status Register for Channel 4 */
78#define DCSR5 __REG(0x40000014) /* DMA Control / Status Register for Channel 5 */
79#define DCSR6 __REG(0x40000018) /* DMA Control / Status Register for Channel 6 */
80#define DCSR7 __REG(0x4000001c) /* DMA Control / Status Register for Channel 7 */
81#define DCSR8 __REG(0x40000020) /* DMA Control / Status Register for Channel 8 */
82#define DCSR9 __REG(0x40000024) /* DMA Control / Status Register for Channel 9 */
83#define DCSR10 __REG(0x40000028) /* DMA Control / Status Register for Channel 10 */
84#define DCSR11 __REG(0x4000002c) /* DMA Control / Status Register for Channel 11 */
85#define DCSR12 __REG(0x40000030) /* DMA Control / Status Register for Channel 12 */
86#define DCSR13 __REG(0x40000034) /* DMA Control / Status Register for Channel 13 */
87#define DCSR14 __REG(0x40000038) /* DMA Control / Status Register for Channel 14 */
88#define DCSR15 __REG(0x4000003c) /* DMA Control / Status Register for Channel 15 */
89
90#define DCSR(x) __REG2(0x40000000, (x) << 2) 72#define DCSR(x) __REG2(0x40000000, (x) << 2)
91 73
92#define DCSR_RUN (1 << 31) /* Run Bit (read / write) */ 74#define DCSR_RUN (1 << 31) /* Run Bit (read / write) */
93#define DCSR_NODESC (1 << 30) /* No-Descriptor Fetch (read / write) */ 75#define DCSR_NODESC (1 << 30) /* No-Descriptor Fetch (read / write) */
94#define DCSR_STOPIRQEN (1 << 29) /* Stop Interrupt Enable (read / write) */ 76#define DCSR_STOPIRQEN (1 << 29) /* Stop Interrupt Enable (read / write) */
95#ifdef CONFIG_PXA27x 77#define DCSR_REQPEND (1 << 8) /* Request Pending (read-only) */
78#define DCSR_STOPSTATE (1 << 3) /* Stop State (read-only) */
79#define DCSR_ENDINTR (1 << 2) /* End Interrupt (read / write) */
80#define DCSR_STARTINTR (1 << 1) /* Start Interrupt (read / write) */
81#define DCSR_BUSERR (1 << 0) /* Bus Error Interrupt (read / write) */
82
83#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
96#define DCSR_EORIRQEN (1 << 28) /* End of Receive Interrupt Enable (R/W) */ 84#define DCSR_EORIRQEN (1 << 28) /* End of Receive Interrupt Enable (R/W) */
97#define DCSR_EORJMPEN (1 << 27) /* Jump to next descriptor on EOR */ 85#define DCSR_EORJMPEN (1 << 27) /* Jump to next descriptor on EOR */
98#define DCSR_EORSTOPEN (1 << 26) /* STOP on an EOR */ 86#define DCSR_EORSTOPEN (1 << 26) /* STOP on an EOR */
@@ -101,11 +89,6 @@
101#define DCSR_CMPST (1 << 10) /* The Descriptor Compare Status */ 89#define DCSR_CMPST (1 << 10) /* The Descriptor Compare Status */
102#define DCSR_EORINTR (1 << 9) /* The end of Receive */ 90#define DCSR_EORINTR (1 << 9) /* The end of Receive */
103#endif 91#endif
104#define DCSR_REQPEND (1 << 8) /* Request Pending (read-only) */
105#define DCSR_STOPSTATE (1 << 3) /* Stop State (read-only) */
106#define DCSR_ENDINTR (1 << 2) /* End Interrupt (read / write) */
107#define DCSR_STARTINTR (1 << 1) /* Start Interrupt (read / write) */
108#define DCSR_BUSERR (1 << 0) /* Bus Error Interrupt (read / write) */
109 92
110#define DALGN __REG(0x400000a0) /* DMA Alignment Register */ 93#define DALGN __REG(0x400000a0) /* DMA Alignment Register */
111#define DINT __REG(0x400000f0) /* DMA Interrupt Register */ 94#define DINT __REG(0x400000f0) /* DMA Interrupt Register */
@@ -114,145 +97,9 @@
114 &__REG2(0x40000100, ((n) & 0x3f) << 2) : \ 97 &__REG2(0x40000100, ((n) & 0x3f) << 2) : \
115 &__REG2(0x40001100, ((n) & 0x3f) << 2))) 98 &__REG2(0x40001100, ((n) & 0x3f) << 2)))
116 99
117#define DRCMR0 __REG(0x40000100) /* Request to Channel Map Register for DREQ 0 */
118#define DRCMR1 __REG(0x40000104) /* Request to Channel Map Register for DREQ 1 */
119#define DRCMR2 __REG(0x40000108) /* Request to Channel Map Register for I2S receive Request */
120#define DRCMR3 __REG(0x4000010c) /* Request to Channel Map Register for I2S transmit Request */
121#define DRCMR4 __REG(0x40000110) /* Request to Channel Map Register for BTUART receive Request */
122#define DRCMR5 __REG(0x40000114) /* Request to Channel Map Register for BTUART transmit Request. */
123#define DRCMR6 __REG(0x40000118) /* Request to Channel Map Register for FFUART receive Request */
124#define DRCMR7 __REG(0x4000011c) /* Request to Channel Map Register for FFUART transmit Request */
125#define DRCMR8 __REG(0x40000120) /* Request to Channel Map Register for AC97 microphone Request */
126#define DRCMR9 __REG(0x40000124) /* Request to Channel Map Register for AC97 modem receive Request */
127#define DRCMR10 __REG(0x40000128) /* Request to Channel Map Register for AC97 modem transmit Request */
128#define DRCMR11 __REG(0x4000012c) /* Request to Channel Map Register for AC97 audio receive Request */
129#define DRCMR12 __REG(0x40000130) /* Request to Channel Map Register for AC97 audio transmit Request */
130#define DRCMR13 __REG(0x40000134) /* Request to Channel Map Register for SSP receive Request */
131#define DRCMR14 __REG(0x40000138) /* Request to Channel Map Register for SSP transmit Request */
132#define DRCMR15 __REG(0x4000013c) /* Request to Channel Map Register for SSP2 receive Request */
133#define DRCMR16 __REG(0x40000140) /* Request to Channel Map Register for SSP2 transmit Request */
134#define DRCMR17 __REG(0x40000144) /* Request to Channel Map Register for ICP receive Request */
135#define DRCMR18 __REG(0x40000148) /* Request to Channel Map Register for ICP transmit Request */
136#define DRCMR19 __REG(0x4000014c) /* Request to Channel Map Register for STUART receive Request */
137#define DRCMR20 __REG(0x40000150) /* Request to Channel Map Register for STUART transmit Request */
138#define DRCMR21 __REG(0x40000154) /* Request to Channel Map Register for MMC receive Request */
139#define DRCMR22 __REG(0x40000158) /* Request to Channel Map Register for MMC transmit Request */
140#define DRCMR23 __REG(0x4000015c) /* Reserved */
141#define DRCMR24 __REG(0x40000160) /* Reserved */
142#define DRCMR25 __REG(0x40000164) /* Request to Channel Map Register for USB endpoint 1 Request */
143#define DRCMR26 __REG(0x40000168) /* Request to Channel Map Register for USB endpoint 2 Request */
144#define DRCMR27 __REG(0x4000016C) /* Request to Channel Map Register for USB endpoint 3 Request */
145#define DRCMR28 __REG(0x40000170) /* Request to Channel Map Register for USB endpoint 4 Request */
146#define DRCMR29 __REG(0x40000174) /* Reserved */
147#define DRCMR30 __REG(0x40000178) /* Request to Channel Map Register for USB endpoint 6 Request */
148#define DRCMR31 __REG(0x4000017C) /* Request to Channel Map Register for USB endpoint 7 Request */
149#define DRCMR32 __REG(0x40000180) /* Request to Channel Map Register for USB endpoint 8 Request */
150#define DRCMR33 __REG(0x40000184) /* Request to Channel Map Register for USB endpoint 9 Request */
151#define DRCMR34 __REG(0x40000188) /* Reserved */
152#define DRCMR35 __REG(0x4000018C) /* Request to Channel Map Register for USB endpoint 11 Request */
153#define DRCMR36 __REG(0x40000190) /* Request to Channel Map Register for USB endpoint 12 Request */
154#define DRCMR37 __REG(0x40000194) /* Request to Channel Map Register for USB endpoint 13 Request */
155#define DRCMR38 __REG(0x40000198) /* Request to Channel Map Register for USB endpoint 14 Request */
156#define DRCMR39 __REG(0x4000019C) /* Reserved */
157#define DRCMR66 __REG(0x40001108) /* Request to Channel Map Register for SSP3 receive Request */
158#define DRCMR67 __REG(0x4000110C) /* Request to Channel Map Register for SSP3 transmit Request */
159#define DRCMR68 __REG(0x40001110) /* Request to Channel Map Register for Camera FIFO 0 Request */
160#define DRCMR69 __REG(0x40001114) /* Request to Channel Map Register for Camera FIFO 1 Request */
161#define DRCMR70 __REG(0x40001118) /* Request to Channel Map Register for Camera FIFO 2 Request */
162
163#define DRCMRRXSADR DRCMR2
164#define DRCMRTXSADR DRCMR3
165#define DRCMRRXBTRBR DRCMR4
166#define DRCMRTXBTTHR DRCMR5
167#define DRCMRRXFFRBR DRCMR6
168#define DRCMRTXFFTHR DRCMR7
169#define DRCMRRXMCDR DRCMR8
170#define DRCMRRXMODR DRCMR9
171#define DRCMRTXMODR DRCMR10
172#define DRCMRRXPCDR DRCMR11
173#define DRCMRTXPCDR DRCMR12
174#define DRCMRRXSSDR DRCMR13
175#define DRCMRTXSSDR DRCMR14
176#define DRCMRRXSS2DR DRCMR15
177#define DRCMRTXSS2DR DRCMR16
178#define DRCMRRXICDR DRCMR17
179#define DRCMRTXICDR DRCMR18
180#define DRCMRRXSTRBR DRCMR19
181#define DRCMRTXSTTHR DRCMR20
182#define DRCMRRXMMC DRCMR21
183#define DRCMRTXMMC DRCMR22
184#define DRCMRRXSS3DR DRCMR66
185#define DRCMRTXSS3DR DRCMR67
186#define DRCMRUDC(x) DRCMR((x) + 24)
187
188#define DRCMR_MAPVLD (1 << 7) /* Map Valid (read / write) */ 100#define DRCMR_MAPVLD (1 << 7) /* Map Valid (read / write) */
189#define DRCMR_CHLNUM 0x1f /* mask for Channel Number (read / write) */ 101#define DRCMR_CHLNUM 0x1f /* mask for Channel Number (read / write) */
190 102
191#define DDADR0 __REG(0x40000200) /* DMA Descriptor Address Register Channel 0 */
192#define DSADR0 __REG(0x40000204) /* DMA Source Address Register Channel 0 */
193#define DTADR0 __REG(0x40000208) /* DMA Target Address Register Channel 0 */
194#define DCMD0 __REG(0x4000020c) /* DMA Command Address Register Channel 0 */
195#define DDADR1 __REG(0x40000210) /* DMA Descriptor Address Register Channel 1 */
196#define DSADR1 __REG(0x40000214) /* DMA Source Address Register Channel 1 */
197#define DTADR1 __REG(0x40000218) /* DMA Target Address Register Channel 1 */
198#define DCMD1 __REG(0x4000021c) /* DMA Command Address Register Channel 1 */
199#define DDADR2 __REG(0x40000220) /* DMA Descriptor Address Register Channel 2 */
200#define DSADR2 __REG(0x40000224) /* DMA Source Address Register Channel 2 */
201#define DTADR2 __REG(0x40000228) /* DMA Target Address Register Channel 2 */
202#define DCMD2 __REG(0x4000022c) /* DMA Command Address Register Channel 2 */
203#define DDADR3 __REG(0x40000230) /* DMA Descriptor Address Register Channel 3 */
204#define DSADR3 __REG(0x40000234) /* DMA Source Address Register Channel 3 */
205#define DTADR3 __REG(0x40000238) /* DMA Target Address Register Channel 3 */
206#define DCMD3 __REG(0x4000023c) /* DMA Command Address Register Channel 3 */
207#define DDADR4 __REG(0x40000240) /* DMA Descriptor Address Register Channel 4 */
208#define DSADR4 __REG(0x40000244) /* DMA Source Address Register Channel 4 */
209#define DTADR4 __REG(0x40000248) /* DMA Target Address Register Channel 4 */
210#define DCMD4 __REG(0x4000024c) /* DMA Command Address Register Channel 4 */
211#define DDADR5 __REG(0x40000250) /* DMA Descriptor Address Register Channel 5 */
212#define DSADR5 __REG(0x40000254) /* DMA Source Address Register Channel 5 */
213#define DTADR5 __REG(0x40000258) /* DMA Target Address Register Channel 5 */
214#define DCMD5 __REG(0x4000025c) /* DMA Command Address Register Channel 5 */
215#define DDADR6 __REG(0x40000260) /* DMA Descriptor Address Register Channel 6 */
216#define DSADR6 __REG(0x40000264) /* DMA Source Address Register Channel 6 */
217#define DTADR6 __REG(0x40000268) /* DMA Target Address Register Channel 6 */
218#define DCMD6 __REG(0x4000026c) /* DMA Command Address Register Channel 6 */
219#define DDADR7 __REG(0x40000270) /* DMA Descriptor Address Register Channel 7 */
220#define DSADR7 __REG(0x40000274) /* DMA Source Address Register Channel 7 */
221#define DTADR7 __REG(0x40000278) /* DMA Target Address Register Channel 7 */
222#define DCMD7 __REG(0x4000027c) /* DMA Command Address Register Channel 7 */
223#define DDADR8 __REG(0x40000280) /* DMA Descriptor Address Register Channel 8 */
224#define DSADR8 __REG(0x40000284) /* DMA Source Address Register Channel 8 */
225#define DTADR8 __REG(0x40000288) /* DMA Target Address Register Channel 8 */
226#define DCMD8 __REG(0x4000028c) /* DMA Command Address Register Channel 8 */
227#define DDADR9 __REG(0x40000290) /* DMA Descriptor Address Register Channel 9 */
228#define DSADR9 __REG(0x40000294) /* DMA Source Address Register Channel 9 */
229#define DTADR9 __REG(0x40000298) /* DMA Target Address Register Channel 9 */
230#define DCMD9 __REG(0x4000029c) /* DMA Command Address Register Channel 9 */
231#define DDADR10 __REG(0x400002a0) /* DMA Descriptor Address Register Channel 10 */
232#define DSADR10 __REG(0x400002a4) /* DMA Source Address Register Channel 10 */
233#define DTADR10 __REG(0x400002a8) /* DMA Target Address Register Channel 10 */
234#define DCMD10 __REG(0x400002ac) /* DMA Command Address Register Channel 10 */
235#define DDADR11 __REG(0x400002b0) /* DMA Descriptor Address Register Channel 11 */
236#define DSADR11 __REG(0x400002b4) /* DMA Source Address Register Channel 11 */
237#define DTADR11 __REG(0x400002b8) /* DMA Target Address Register Channel 11 */
238#define DCMD11 __REG(0x400002bc) /* DMA Command Address Register Channel 11 */
239#define DDADR12 __REG(0x400002c0) /* DMA Descriptor Address Register Channel 12 */
240#define DSADR12 __REG(0x400002c4) /* DMA Source Address Register Channel 12 */
241#define DTADR12 __REG(0x400002c8) /* DMA Target Address Register Channel 12 */
242#define DCMD12 __REG(0x400002cc) /* DMA Command Address Register Channel 12 */
243#define DDADR13 __REG(0x400002d0) /* DMA Descriptor Address Register Channel 13 */
244#define DSADR13 __REG(0x400002d4) /* DMA Source Address Register Channel 13 */
245#define DTADR13 __REG(0x400002d8) /* DMA Target Address Register Channel 13 */
246#define DCMD13 __REG(0x400002dc) /* DMA Command Address Register Channel 13 */
247#define DDADR14 __REG(0x400002e0) /* DMA Descriptor Address Register Channel 14 */
248#define DSADR14 __REG(0x400002e4) /* DMA Source Address Register Channel 14 */
249#define DTADR14 __REG(0x400002e8) /* DMA Target Address Register Channel 14 */
250#define DCMD14 __REG(0x400002ec) /* DMA Command Address Register Channel 14 */
251#define DDADR15 __REG(0x400002f0) /* DMA Descriptor Address Register Channel 15 */
252#define DSADR15 __REG(0x400002f4) /* DMA Source Address Register Channel 15 */
253#define DTADR15 __REG(0x400002f8) /* DMA Target Address Register Channel 15 */
254#define DCMD15 __REG(0x400002fc) /* DMA Command Address Register Channel 15 */
255
256#define DDADR(x) __REG2(0x40000200, (x) << 4) 103#define DDADR(x) __REG2(0x40000200, (x) << 4)
257#define DSADR(x) __REG2(0x40000204, (x) << 4) 104#define DSADR(x) __REG2(0x40000204, (x) << 4)
258#define DTADR(x) __REG2(0x40000208, (x) << 4) 105#define DTADR(x) __REG2(0x40000208, (x) << 4)
@@ -418,91 +265,13 @@
418 265
419 266
420/* 267/*
421 * I2C registers 268 * I2C registers - moved into drivers/i2c/busses/i2c-pxa.c
422 */ 269 */
423 270
424#define IBMR __REG(0x40301680) /* I2C Bus Monitor Register - IBMR */
425#define IDBR __REG(0x40301688) /* I2C Data Buffer Register - IDBR */
426#define ICR __REG(0x40301690) /* I2C Control Register - ICR */
427#define ISR __REG(0x40301698) /* I2C Status Register - ISR */
428#define ISAR __REG(0x403016A0) /* I2C Slave Address Register - ISAR */
429
430#define PWRIBMR __REG(0x40f00180) /* Power I2C Bus Monitor Register-IBMR */
431#define PWRIDBR __REG(0x40f00188) /* Power I2C Data Buffer Register-IDBR */
432#define PWRICR __REG(0x40f00190) /* Power I2C Control Register - ICR */
433#define PWRISR __REG(0x40f00198) /* Power I2C Status Register - ISR */
434#define PWRISAR __REG(0x40f001A0) /*Power I2C Slave Address Register-ISAR */
435
436#define ICR_START (1 << 0) /* start bit */
437#define ICR_STOP (1 << 1) /* stop bit */
438#define ICR_ACKNAK (1 << 2) /* send ACK(0) or NAK(1) */
439#define ICR_TB (1 << 3) /* transfer byte bit */
440#define ICR_MA (1 << 4) /* master abort */
441#define ICR_SCLE (1 << 5) /* master clock enable */
442#define ICR_IUE (1 << 6) /* unit enable */
443#define ICR_GCD (1 << 7) /* general call disable */
444#define ICR_ITEIE (1 << 8) /* enable tx interrupts */
445#define ICR_IRFIE (1 << 9) /* enable rx interrupts */
446#define ICR_BEIE (1 << 10) /* enable bus error ints */
447#define ICR_SSDIE (1 << 11) /* slave STOP detected int enable */
448#define ICR_ALDIE (1 << 12) /* enable arbitration interrupt */
449#define ICR_SADIE (1 << 13) /* slave address detected int enable */
450#define ICR_UR (1 << 14) /* unit reset */
451
452#define ISR_RWM (1 << 0) /* read/write mode */
453#define ISR_ACKNAK (1 << 1) /* ack/nak status */
454#define ISR_UB (1 << 2) /* unit busy */
455#define ISR_IBB (1 << 3) /* bus busy */
456#define ISR_SSD (1 << 4) /* slave stop detected */
457#define ISR_ALD (1 << 5) /* arbitration loss detected */
458#define ISR_ITE (1 << 6) /* tx buffer empty */
459#define ISR_IRF (1 << 7) /* rx buffer full */
460#define ISR_GCAD (1 << 8) /* general call address detected */
461#define ISR_SAD (1 << 9) /* slave address detected */
462#define ISR_BED (1 << 10) /* bus error no ACK/NAK */
463
464
465/* 271/*
466 * Serial Audio Controller 272 * Serial Audio Controller - moved into sound/soc/pxa/pxa2xx-i2s.c
467 */ 273 */
468 274
469#define SACR0 __REG(0x40400000) /* Global Control Register */
470#define SACR1 __REG(0x40400004) /* Serial Audio I 2 S/MSB-Justified Control Register */
471#define SASR0 __REG(0x4040000C) /* Serial Audio I 2 S/MSB-Justified Interface and FIFO Status Register */
472#define SAIMR __REG(0x40400014) /* Serial Audio Interrupt Mask Register */
473#define SAICR __REG(0x40400018) /* Serial Audio Interrupt Clear Register */
474#define SADIV __REG(0x40400060) /* Audio Clock Divider Register. */
475#define SADR __REG(0x40400080) /* Serial Audio Data Register (TX and RX FIFO access Register). */
476
477#define SACR0_RFTH(x) ((x) << 12) /* Rx FIFO Interrupt or DMA Trigger Threshold */
478#define SACR0_TFTH(x) ((x) << 8) /* Tx FIFO Interrupt or DMA Trigger Threshold */
479#define SACR0_STRF (1 << 5) /* FIFO Select for EFWR Special Function */
480#define SACR0_EFWR (1 << 4) /* Enable EFWR Function */
481#define SACR0_RST (1 << 3) /* FIFO, i2s Register Reset */
482#define SACR0_BCKD (1 << 2) /* Bit Clock Direction */
483#define SACR0_ENB (1 << 0) /* Enable I2S Link */
484#define SACR1_ENLBF (1 << 5) /* Enable Loopback */
485#define SACR1_DRPL (1 << 4) /* Disable Replaying Function */
486#define SACR1_DREC (1 << 3) /* Disable Recording Function */
487#define SACR1_AMSL (1 << 0) /* Specify Alternate Mode */
488
489#define SASR0_I2SOFF (1 << 7) /* Controller Status */
490#define SASR0_ROR (1 << 6) /* Rx FIFO Overrun */
491#define SASR0_TUR (1 << 5) /* Tx FIFO Underrun */
492#define SASR0_RFS (1 << 4) /* Rx FIFO Service Request */
493#define SASR0_TFS (1 << 3) /* Tx FIFO Service Request */
494#define SASR0_BSY (1 << 2) /* I2S Busy */
495#define SASR0_RNE (1 << 1) /* Rx FIFO Not Empty */
496#define SASR0_TNF (1 << 0) /* Tx FIFO Not Empty */
497
498#define SAICR_ROR (1 << 6) /* Clear Rx FIFO Overrun Interrupt */
499#define SAICR_TUR (1 << 5) /* Clear Tx FIFO Underrun Interrupt */
500
501#define SAIMR_ROR (1 << 6) /* Enable Rx FIFO Overrun Condition Interrupt */
502#define SAIMR_TUR (1 << 5) /* Enable Tx FIFO Underrun Condition Interrupt */
503#define SAIMR_RFS (1 << 4) /* Enable Rx FIFO Service Interrupt */
504#define SAIMR_TFS (1 << 3) /* Enable Tx FIFO Service Interrupt */
505
506/* 275/*
507 * AC97 Controller registers 276 * AC97 Controller registers
508 */ 277 */
@@ -989,77 +758,6 @@
989 758
990#endif 759#endif
991 760
992#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
993/*
994 * UHC: USB Host Controller (OHCI-like) register definitions
995 */
996#define UHC_BASE_PHYS (0x4C000000)
997#define UHCREV __REG(0x4C000000) /* UHC HCI Spec Revision */
998#define UHCHCON __REG(0x4C000004) /* UHC Host Control Register */
999#define UHCCOMS __REG(0x4C000008) /* UHC Command Status Register */
1000#define UHCINTS __REG(0x4C00000C) /* UHC Interrupt Status Register */
1001#define UHCINTE __REG(0x4C000010) /* UHC Interrupt Enable */
1002#define UHCINTD __REG(0x4C000014) /* UHC Interrupt Disable */
1003#define UHCHCCA __REG(0x4C000018) /* UHC Host Controller Comm. Area */
1004#define UHCPCED __REG(0x4C00001C) /* UHC Period Current Endpt Descr */
1005#define UHCCHED __REG(0x4C000020) /* UHC Control Head Endpt Descr */
1006#define UHCCCED __REG(0x4C000024) /* UHC Control Current Endpt Descr */
1007#define UHCBHED __REG(0x4C000028) /* UHC Bulk Head Endpt Descr */
1008#define UHCBCED __REG(0x4C00002C) /* UHC Bulk Current Endpt Descr */
1009#define UHCDHEAD __REG(0x4C000030) /* UHC Done Head */
1010#define UHCFMI __REG(0x4C000034) /* UHC Frame Interval */
1011#define UHCFMR __REG(0x4C000038) /* UHC Frame Remaining */
1012#define UHCFMN __REG(0x4C00003C) /* UHC Frame Number */
1013#define UHCPERS __REG(0x4C000040) /* UHC Periodic Start */
1014#define UHCLS __REG(0x4C000044) /* UHC Low Speed Threshold */
1015
1016#define UHCRHDA __REG(0x4C000048) /* UHC Root Hub Descriptor A */
1017#define UHCRHDA_NOCP (1 << 12) /* No over current protection */
1018
1019#define UHCRHDB __REG(0x4C00004C) /* UHC Root Hub Descriptor B */
1020#define UHCRHS __REG(0x4C000050) /* UHC Root Hub Status */
1021#define UHCRHPS1 __REG(0x4C000054) /* UHC Root Hub Port 1 Status */
1022#define UHCRHPS2 __REG(0x4C000058) /* UHC Root Hub Port 2 Status */
1023#define UHCRHPS3 __REG(0x4C00005C) /* UHC Root Hub Port 3 Status */
1024
1025#define UHCSTAT __REG(0x4C000060) /* UHC Status Register */
1026#define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */
1027#define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/
1028#define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/
1029#define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */
1030#define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */
1031#define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */
1032#define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */
1033#define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */
1034#define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */
1035
1036#define UHCHR __REG(0x4C000064) /* UHC Reset Register */
1037#define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */
1038#define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */
1039#define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */
1040#define UHCHR_PCPL (1 << 7) /* Power control polarity low */
1041#define UHCHR_PSPL (1 << 6) /* Power sense polarity low */
1042#define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */
1043#define UHCHR_UIT (1 << 4) /* USB Interrupt Test */
1044#define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */
1045#define UHCHR_CGR (1 << 2) /* Clock Generation Reset */
1046#define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */
1047#define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */
1048
1049#define UHCHIE __REG(0x4C000068) /* UHC Interrupt Enable Register*/
1050#define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */
1051#define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */
1052#define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */
1053#define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */
1054#define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort
1055 Interrupt Enable*/
1056#define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */
1057#define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
1058
1059#define UHCHIT __REG(0x4C00006C) /* UHC Interrupt Test register */
1060
1061#endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
1062
1063/* PWRMODE register M field values */ 761/* PWRMODE register M field values */
1064 762
1065#define PWRMODE_IDLE 0x1 763#define PWRMODE_IDLE 0x1
diff --git a/arch/arm/mach-pxa/include/mach/pxa3xx-regs.h b/arch/arm/mach-pxa/include/mach/pxa3xx-regs.h
index 39eb68319e28..b1fcd10ab6c6 100644
--- a/arch/arm/mach-pxa/include/mach/pxa3xx-regs.h
+++ b/arch/arm/mach-pxa/include/mach/pxa3xx-regs.h
@@ -131,6 +131,28 @@
131#define CKENB __REG(0x41340010) /* B Clock Enable Register */ 131#define CKENB __REG(0x41340010) /* B Clock Enable Register */
132#define AC97_DIV __REG(0x41340014) /* AC97 clock divisor value register */ 132#define AC97_DIV __REG(0x41340014) /* AC97 clock divisor value register */
133 133
134#define ACCR_XPDIS (1 << 31) /* Core PLL Output Disable */
135#define ACCR_SPDIS (1 << 30) /* System PLL Output Disable */
136#define ACCR_D0CS (1 << 26) /* D0 Mode Clock Select */
137#define ACCR_PCCE (1 << 11) /* Power Mode Change Clock Enable */
138#define ACCR_DDR_D0CS (1 << 7) /* DDR SDRAM clock frequency in D0CS (PXA31x only) */
139
140#define ACCR_SMCFS_MASK (0x7 << 23) /* Static Memory Controller Frequency Select */
141#define ACCR_SFLFS_MASK (0x3 << 18) /* Frequency Select for Internal Memory Controller */
142#define ACCR_XSPCLK_MASK (0x3 << 16) /* Core Frequency during Frequency Change */
143#define ACCR_HSS_MASK (0x3 << 14) /* System Bus-Clock Frequency Select */
144#define ACCR_DMCFS_MASK (0x3 << 12) /* Dynamic Memory Controller Clock Frequency Select */
145#define ACCR_XN_MASK (0x7 << 8) /* Core PLL Turbo-Mode-to-Run-Mode Ratio */
146#define ACCR_XL_MASK (0x1f) /* Core PLL Run-Mode-to-Oscillator Ratio */
147
148#define ACCR_SMCFS(x) (((x) & 0x7) << 23)
149#define ACCR_SFLFS(x) (((x) & 0x3) << 18)
150#define ACCR_XSPCLK(x) (((x) & 0x3) << 16)
151#define ACCR_HSS(x) (((x) & 0x3) << 14)
152#define ACCR_DMCFS(x) (((x) & 0x3) << 12)
153#define ACCR_XN(x) (((x) & 0x7) << 8)
154#define ACCR_XL(x) ((x) & 0x1f)
155
134/* 156/*
135 * Clock Enable Bit 157 * Clock Enable Bit
136 */ 158 */
diff --git a/arch/arm/mach-pxa/include/mach/reset.h b/arch/arm/mach-pxa/include/mach/reset.h
index 9489a48871a8..7b8842cfa5fc 100644
--- a/arch/arm/mach-pxa/include/mach/reset.h
+++ b/arch/arm/mach-pxa/include/mach/reset.h
@@ -10,9 +10,12 @@
10extern unsigned int reset_status; 10extern unsigned int reset_status;
11extern void clear_reset_status(unsigned int mask); 11extern void clear_reset_status(unsigned int mask);
12 12
13/* 13/**
14 * register GPIO as reset generator 14 * init_gpio_reset() - register GPIO as reset generator
15 *
16 * @gpio - gpio nr
17 * @output - set gpio as out/low instead of input during normal work
15 */ 18 */
16extern int init_gpio_reset(int gpio); 19extern int init_gpio_reset(int gpio, int output);
17 20
18#endif /* __ASM_ARCH_RESET_H */ 21#endif /* __ASM_ARCH_RESET_H */
diff --git a/arch/arm/mach-pxa/include/mach/spitz.h b/arch/arm/mach-pxa/include/mach/spitz.h
index bd14365f7ed5..31ac26b55bc1 100644
--- a/arch/arm/mach-pxa/include/mach/spitz.h
+++ b/arch/arm/mach-pxa/include/mach/spitz.h
@@ -16,6 +16,7 @@
16#endif 16#endif
17 17
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/gpio.h>
19 20
20/* Spitz/Akita GPIOs */ 21/* Spitz/Akita GPIOs */
21 22
@@ -100,13 +101,24 @@
100#define SPITZ_SCP_JK_A SCOOP_GPCR_PA18 /* Low */ 101#define SPITZ_SCP_JK_A SCOOP_GPCR_PA18 /* Low */
101#define SPITZ_SCP_ADC_TEMP_ON SCOOP_GPCR_PA19 /* Low */ 102#define SPITZ_SCP_ADC_TEMP_ON SCOOP_GPCR_PA19 /* Low */
102 103
103#define SPITZ_SCP_IO_DIR (SPITZ_SCP_LED_GREEN | SPITZ_SCP_JK_B | SPITZ_SCP_CHRG_ON | \ 104#define SPITZ_SCP_IO_DIR (SPITZ_SCP_JK_B | SPITZ_SCP_CHRG_ON | \
104 SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_LED_ORANGE | \ 105 SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | \
105 SPITZ_SCP_CF_POWER | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON) 106 SPITZ_SCP_CF_POWER | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON)
106#define SPITZ_SCP_IO_OUT (SPITZ_SCP_CHRG_ON | SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R) 107#define SPITZ_SCP_IO_OUT (SPITZ_SCP_CHRG_ON | SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R)
107#define SPITZ_SCP_SUS_CLR (SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON) 108#define SPITZ_SCP_SUS_CLR (SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON)
108#define SPITZ_SCP_SUS_SET 0 109#define SPITZ_SCP_SUS_SET 0
109 110
111#define SPITZ_SCP_GPIO_BASE (NR_BUILTIN_GPIO)
112#define SPITZ_GPIO_LED_GREEN (SPITZ_SCP_GPIO_BASE + 0)
113#define SPITZ_GPIO_JK_B (SPITZ_SCP_GPIO_BASE + 1)
114#define SPITZ_GPIO_CHRG_ON (SPITZ_SCP_GPIO_BASE + 2)
115#define SPITZ_GPIO_MUTE_L (SPITZ_SCP_GPIO_BASE + 3)
116#define SPITZ_GPIO_MUTE_R (SPITZ_SCP_GPIO_BASE + 4)
117#define SPITZ_GPIO_CF_POWER (SPITZ_SCP_GPIO_BASE + 5)
118#define SPITZ_GPIO_LED_ORANGE (SPITZ_SCP_GPIO_BASE + 6)
119#define SPITZ_GPIO_JK_A (SPITZ_SCP_GPIO_BASE + 7)
120#define SPITZ_GPIO_ADC_TEMP_ON (SPITZ_SCP_GPIO_BASE + 8)
121
110/* Spitz Scoop Device (No. 2) GPIOs */ 122/* Spitz Scoop Device (No. 2) GPIOs */
111/* Suspend States in comments */ 123/* Suspend States in comments */
112#define SPITZ_SCP2_IR_ON SCOOP_GPCR_PA11 /* High */ 124#define SPITZ_SCP2_IR_ON SCOOP_GPCR_PA11 /* High */
@@ -119,15 +131,36 @@
119#define SPITZ_SCP2_BACKLIGHT_ON SCOOP_GPCR_PA18 /* Low */ 131#define SPITZ_SCP2_BACKLIGHT_ON SCOOP_GPCR_PA18 /* Low */
120#define SPITZ_SCP2_MIC_BIAS SCOOP_GPCR_PA19 /* Low */ 132#define SPITZ_SCP2_MIC_BIAS SCOOP_GPCR_PA19 /* Low */
121 133
122#define SPITZ_SCP2_IO_DIR (SPITZ_SCP2_IR_ON | SPITZ_SCP2_AKIN_PULLUP | SPITZ_SCP2_RESERVED_1 | \ 134#define SPITZ_SCP2_IO_DIR (SPITZ_SCP2_AKIN_PULLUP | SPITZ_SCP2_RESERVED_1 | \
123 SPITZ_SCP2_RESERVED_2 | SPITZ_SCP2_RESERVED_3 | SPITZ_SCP2_RESERVED_4 | \ 135 SPITZ_SCP2_RESERVED_2 | SPITZ_SCP2_RESERVED_3 | SPITZ_SCP2_RESERVED_4 | \
124 SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS) 136 SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS)
125 137
126#define SPITZ_SCP2_IO_OUT (SPITZ_SCP2_IR_ON | SPITZ_SCP2_AKIN_PULLUP | SPITZ_SCP2_RESERVED_1) 138#define SPITZ_SCP2_IO_OUT (SPITZ_SCP2_AKIN_PULLUP | SPITZ_SCP2_RESERVED_1)
127#define SPITZ_SCP2_SUS_CLR (SPITZ_SCP2_RESERVED_2 | SPITZ_SCP2_RESERVED_3 | SPITZ_SCP2_RESERVED_4 | \ 139#define SPITZ_SCP2_SUS_CLR (SPITZ_SCP2_RESERVED_2 | SPITZ_SCP2_RESERVED_3 | SPITZ_SCP2_RESERVED_4 | \
128 SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS) 140 SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS)
129#define SPITZ_SCP2_SUS_SET (SPITZ_SCP2_IR_ON | SPITZ_SCP2_RESERVED_1) 141#define SPITZ_SCP2_SUS_SET (SPITZ_SCP2_IR_ON | SPITZ_SCP2_RESERVED_1)
130 142
143#define SPITZ_SCP2_GPIO_BASE (NR_BUILTIN_GPIO + 12)
144#define SPITZ_GPIO_IR_ON (SPITZ_SCP2_GPIO_BASE + 0)
145#define SPITZ_GPIO_AKIN_PULLUP (SPITZ_SCP2_GPIO_BASE + 1
146#define SPITZ_GPIO_RESERVED_1 (SPITZ_SCP2_GPIO_BASE + 2)
147#define SPITZ_GPIO_RESERVED_2 (SPITZ_SCP2_GPIO_BASE + 3)
148#define SPITZ_GPIO_RESERVED_3 (SPITZ_SCP2_GPIO_BASE + 4)
149#define SPITZ_GPIO_RESERVED_4 (SPITZ_SCP2_GPIO_BASE + 5)
150#define SPITZ_GPIO_BACKLIGHT_CONT (SPITZ_SCP2_GPIO_BASE + 6)
151#define SPITZ_GPIO_BACKLIGHT_ON (SPITZ_SCP2_GPIO_BASE + 7)
152#define SPITZ_GPIO_MIC_BIAS (SPITZ_SCP2_GPIO_BASE + 8)
153
154/* Akita IO Expander GPIOs */
155#define AKITA_IOEXP_GPIO_BASE (NR_BUILTIN_GPIO + 12)
156#define AKITA_GPIO_RESERVED_0 (AKITA_IOEXP_GPIO_BASE + 0)
157#define AKITA_GPIO_RESERVED_1 (AKITA_IOEXP_GPIO_BASE + 1)
158#define AKITA_GPIO_MIC_BIAS (AKITA_IOEXP_GPIO_BASE + 2)
159#define AKITA_GPIO_BACKLIGHT_ON (AKITA_IOEXP_GPIO_BASE + 3)
160#define AKITA_GPIO_BACKLIGHT_CONT (AKITA_IOEXP_GPIO_BASE + 4)
161#define AKITA_GPIO_AKIN_PULLUP (AKITA_IOEXP_GPIO_BASE + 5)
162#define AKITA_GPIO_IR_ON (AKITA_IOEXP_GPIO_BASE + 6)
163#define AKITA_GPIO_RESERVED_7 (AKITA_IOEXP_GPIO_BASE + 7)
131 164
132/* Spitz IRQ Definitions */ 165/* Spitz IRQ Definitions */
133 166
@@ -154,5 +187,4 @@
154 */ 187 */
155extern struct platform_device spitzscoop_device; 188extern struct platform_device spitzscoop_device;
156extern struct platform_device spitzscoop2_device; 189extern struct platform_device spitzscoop2_device;
157extern struct platform_device spitzssp_device;
158extern struct sharpsl_charger_machinfo spitz_pm_machinfo; 190extern struct sharpsl_charger_machinfo spitz_pm_machinfo;
diff --git a/arch/arm/mach-pxa/include/mach/ssp.h b/arch/arm/mach-pxa/include/mach/ssp.h
index a012882c9ee6..cb5cb766f0f1 100644
--- a/arch/arm/mach-pxa/include/mach/ssp.h
+++ b/arch/arm/mach-pxa/include/mach/ssp.h
@@ -20,6 +20,7 @@
20#define __ASM_ARCH_SSP_H 20#define __ASM_ARCH_SSP_H
21 21
22#include <linux/list.h> 22#include <linux/list.h>
23#include <linux/io.h>
23 24
24enum pxa_ssp_type { 25enum pxa_ssp_type {
25 SSP_UNDEFINED = 0, 26 SSP_UNDEFINED = 0,
@@ -78,6 +79,29 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags);
78int ssp_config(struct ssp_dev *dev, u32 mode, u32 flags, u32 psp_flags, u32 speed); 79int ssp_config(struct ssp_dev *dev, u32 mode, u32 flags, u32 psp_flags, u32 speed);
79void ssp_exit(struct ssp_dev *dev); 80void ssp_exit(struct ssp_dev *dev);
80 81
82/**
83 * ssp_write_reg - Write to a SSP register
84 *
85 * @dev: SSP device to access
86 * @reg: Register to write to
87 * @val: Value to be written.
88 */
89static inline void ssp_write_reg(struct ssp_device *dev, u32 reg, u32 val)
90{
91 __raw_writel(val, dev->mmio_base + reg);
92}
93
94/**
95 * ssp_read_reg - Read from a SSP register
96 *
97 * @dev: SSP device to access
98 * @reg: Register to read from
99 */
100static inline u32 ssp_read_reg(struct ssp_device *dev, u32 reg)
101{
102 return __raw_readl(dev->mmio_base + reg);
103}
104
81struct ssp_device *ssp_request(int port, const char *label); 105struct ssp_device *ssp_request(int port, const char *label);
82void ssp_free(struct ssp_device *); 106void ssp_free(struct ssp_device *);
83#endif /* __ASM_ARCH_SSP_H */ 107#endif /* __ASM_ARCH_SSP_H */
diff --git a/arch/arm/mach-pxa/include/mach/trizeps4.h b/arch/arm/mach-pxa/include/mach/trizeps4.h
index 641d0ec110bb..903e1a2e6641 100644
--- a/arch/arm/mach-pxa/include/mach/trizeps4.h
+++ b/arch/arm/mach-pxa/include/mach/trizeps4.h
@@ -17,11 +17,16 @@
17#define TRIZEPS4_PIC_PHYS (PXA_CS3_PHYS) /* Logic chip on ConXS-Board */ 17#define TRIZEPS4_PIC_PHYS (PXA_CS3_PHYS) /* Logic chip on ConXS-Board */
18#define TRIZEPS4_SDRAM_BASE 0xa0000000 /* SDRAM region */ 18#define TRIZEPS4_SDRAM_BASE 0xa0000000 /* SDRAM region */
19 19
20#define TRIZEPS4_CFSR_PHYS (PXA_CS3_PHYS) /* Logic chip on ConXS-Board CSFR register */ 20 /* Logic on ConXS-board CSFR register*/
21#define TRIZEPS4_BOCR_PHYS (PXA_CS3_PHYS+0x02000000) /* Logic chip on ConXS-Board BOCR register */ 21#define TRIZEPS4_CFSR_PHYS (PXA_CS3_PHYS)
22#define TRIZEPS4_IRCR_PHYS (PXA_CS3_PHYS+0x02400000) /* Logic chip on ConXS-Board IRCR register*/ 22 /* Logic on ConXS-board BOCR register*/
23#define TRIZEPS4_UPSR_PHYS (PXA_CS3_PHYS+0x02800000) /* Logic chip on ConXS-Board UPSR register*/ 23#define TRIZEPS4_BOCR_PHYS (PXA_CS3_PHYS+0x02000000)
24#define TRIZEPS4_DICR_PHYS (PXA_CS3_PHYS+0x03800000) /* Logic chip on ConXS-Board DICR register*/ 24 /* Logic on ConXS-board IRCR register*/
25#define TRIZEPS4_IRCR_PHYS (PXA_CS3_PHYS+0x02400000)
26 /* Logic on ConXS-board UPSR register*/
27#define TRIZEPS4_UPSR_PHYS (PXA_CS3_PHYS+0x02800000)
28 /* Logic on ConXS-board DICR register*/
29#define TRIZEPS4_DICR_PHYS (PXA_CS3_PHYS+0x03800000)
25 30
26/* virtual memory regions */ 31/* virtual memory regions */
27#define TRIZEPS4_DISK_VIRT 0xF0000000 /* Disk On Chip region */ 32#define TRIZEPS4_DISK_VIRT 0xF0000000 /* Disk On Chip region */
@@ -54,6 +59,15 @@
54#define GPIO_MMC_DET 12 59#define GPIO_MMC_DET 12
55#define TRIZEPS4_MMC_IRQ IRQ_GPIO(GPIO_MMC_DET) 60#define TRIZEPS4_MMC_IRQ IRQ_GPIO(GPIO_MMC_DET)
56 61
62/* DOC NAND chip */
63#define GPIO_DOC_LOCK 94
64#define GPIO_DOC_IRQ 93
65#define TRIZEPS4_DOC_IRQ IRQ_GPIO(GPIO_DOC_IRQ)
66
67/* SPI interface */
68#define GPIO_SPI 53
69#define TRIZEPS4_SPI_IRQ IRQ_GPIO(GPIO_SPI)
70
57/* LEDS using tx2 / rx2 */ 71/* LEDS using tx2 / rx2 */
58#define GPIO_SYS_BUSY_LED 46 72#define GPIO_SYS_BUSY_LED 46
59#define GPIO_HEARTBEAT_LED 47 73#define GPIO_HEARTBEAT_LED 47
@@ -62,24 +76,66 @@
62#define GPIO_PIC 0 76#define GPIO_PIC 0
63#define TRIZEPS4_PIC_IRQ IRQ_GPIO(GPIO_PIC) 77#define TRIZEPS4_PIC_IRQ IRQ_GPIO(GPIO_PIC)
64 78
65#define CFSR_P2V(x) ((x) - TRIZEPS4_CFSR_PHYS + TRIZEPS4_CFSR_VIRT) 79#ifdef CONFIG_MACH_TRIZEPS_CONXS
66#define CFSR_V2P(x) ((x) - TRIZEPS4_CFSR_VIRT + TRIZEPS4_CFSR_PHYS) 80/* for CONXS base board define these registers */
81#define CFSR_P2V(x) ((x) - TRIZEPS4_CFSR_PHYS + TRIZEPS4_CFSR_VIRT)
82#define CFSR_V2P(x) ((x) - TRIZEPS4_CFSR_VIRT + TRIZEPS4_CFSR_PHYS)
67 83
68#define BCR_P2V(x) ((x) - TRIZEPS4_BOCR_PHYS + TRIZEPS4_BOCR_VIRT) 84#define BCR_P2V(x) ((x) - TRIZEPS4_BOCR_PHYS + TRIZEPS4_BOCR_VIRT)
69#define BCR_V2P(x) ((x) - TRIZEPS4_BOCR_VIRT + TRIZEPS4_BOCR_PHYS) 85#define BCR_V2P(x) ((x) - TRIZEPS4_BOCR_VIRT + TRIZEPS4_BOCR_PHYS)
70 86
71#define DCR_P2V(x) ((x) - TRIZEPS4_DICR_PHYS + TRIZEPS4_DICR_VIRT) 87#define DCR_P2V(x) ((x) - TRIZEPS4_DICR_PHYS + TRIZEPS4_DICR_VIRT)
72#define DCR_V2P(x) ((x) - TRIZEPS4_DICR_VIRT + TRIZEPS4_DICR_PHYS) 88#define DCR_V2P(x) ((x) - TRIZEPS4_DICR_VIRT + TRIZEPS4_DICR_PHYS)
89
90#define IRCR_P2V(x) ((x) - TRIZEPS4_IRCR_PHYS + TRIZEPS4_IRCR_VIRT)
91#define IRCR_V2P(x) ((x) - TRIZEPS4_IRCR_VIRT + TRIZEPS4_IRCR_PHYS)
73 92
74#ifndef __ASSEMBLY__ 93#ifndef __ASSEMBLY__
75#define ConXS_CFSR (*((volatile unsigned short *)CFSR_P2V(0x0C000000))) 94static inline unsigned short CFSR_readw(void)
76#define ConXS_BCR (*((volatile unsigned short *)BCR_P2V(0x0E000000))) 95{
77#define ConXS_DCR (*((volatile unsigned short *)DCR_P2V(0x0F800000))) 96 /* [Compact Flash Status Register] is read only */
97 return *((unsigned short *)CFSR_P2V(0x0C000000));
98}
99static inline void BCR_writew(unsigned short value)
100{
101 /* [Board Control Regsiter] is write only */
102 *((unsigned short *)BCR_P2V(0x0E000000)) = value;
103}
104static inline void DCR_writew(unsigned short value)
105{
106 /* [Display Control Register] is write only */
107 *((unsigned short *)DCR_P2V(0x0E000000)) = value;
108}
109static inline void IRCR_writew(unsigned short value)
110{
111 /* [InfraRed data Control Register] is write only */
112 *((unsigned short *)IRCR_P2V(0x0E000000)) = value;
113}
78#else 114#else
79#define ConXS_CFSR CFSR_P2V(0x0C000000) 115#define ConXS_CFSR CFSR_P2V(0x0C000000)
80#define ConXS_BCR BCR_P2V(0x0E000000) 116#define ConXS_BCR BCR_P2V(0x0E000000)
81#define ConXS_DCR DCR_P2V(0x0F800000) 117#define ConXS_DCR DCR_P2V(0x0F800000)
118#define ConXS_IRCR IRCR_P2V(0x0F800000)
82#endif 119#endif
120#else
121/* for whatever baseboard define function registers */
122static inline unsigned short CFSR_readw(void)
123{
124 return 0;
125}
126static inline void BCR_writew(unsigned short value)
127{
128 ;
129}
130static inline void DCR_writew(unsigned short value)
131{
132 ;
133}
134static inline void IRCR_writew(unsigned short value)
135{
136 ;
137}
138#endif /* CONFIG_MACH_TRIZEPS_CONXS */
83 139
84#define ConXS_CFSR_BVD_MASK 0x0003 140#define ConXS_CFSR_BVD_MASK 0x0003
85#define ConXS_CFSR_BVD1 (1 << 0) 141#define ConXS_CFSR_BVD1 (1 << 0)
diff --git a/arch/arm/mach-pxa/include/mach/viper.h b/arch/arm/mach-pxa/include/mach/viper.h
new file mode 100644
index 000000000000..10988c270ca3
--- /dev/null
+++ b/arch/arm/mach-pxa/include/mach/viper.h
@@ -0,0 +1,96 @@
1/*
2 * arch/arm/mach-pxa/include/mach/viper.h
3 *
4 * Author: Ian Campbell
5 * Created: Feb 03, 2003
6 * Copyright: Arcom Control Systems.
7 *
8 * Maintained by Marc Zyngier <maz@misterjones.org>
9 * <marc.zyngier@altran.com>
10 *
11 * Created based on lubbock.h:
12 * Author: Nicolas Pitre
13 * Created: Jun 15, 2001
14 * Copyright: MontaVista Software Inc.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation.
19 */
20
21#ifndef ARCH_VIPER_H
22#define ARCH_VIPER_H
23
24#define VIPER_BOOT_PHYS PXA_CS0_PHYS
25#define VIPER_FLASH_PHYS PXA_CS1_PHYS
26#define VIPER_ETH_PHYS PXA_CS2_PHYS
27#define VIPER_USB_PHYS PXA_CS3_PHYS
28#define VIPER_ETH_DATA_PHYS PXA_CS4_PHYS
29#define VIPER_CPLD_PHYS PXA_CS5_PHYS
30
31#define VIPER_CPLD_BASE (0xf0000000)
32#define VIPER_PC104IO_BASE (0xf1000000)
33#define VIPER_USB_BASE (0xf1800000)
34
35#define VIPER_ETH_GPIO (0)
36#define VIPER_CPLD_GPIO (1)
37#define VIPER_USB_GPIO (2)
38#define VIPER_UARTA_GPIO (4)
39#define VIPER_UARTB_GPIO (3)
40#define VIPER_CF_CD_GPIO (32)
41#define VIPER_CF_RDY_GPIO (8)
42#define VIPER_BCKLIGHT_EN_GPIO (9)
43#define VIPER_LCD_EN_GPIO (10)
44#define VIPER_PSU_DATA_GPIO (6)
45#define VIPER_PSU_CLK_GPIO (11)
46#define VIPER_UART_SHDN_GPIO (12)
47#define VIPER_BRIGHTNESS_GPIO (16)
48#define VIPER_PSU_nCS_LD_GPIO (19)
49#define VIPER_UPS_GPIO (20)
50#define VIPER_CF_POWER_GPIO (82)
51#define VIPER_TPM_I2C_SDA_GPIO (26)
52#define VIPER_TPM_I2C_SCL_GPIO (27)
53#define VIPER_RTC_I2C_SDA_GPIO (83)
54#define VIPER_RTC_I2C_SCL_GPIO (84)
55
56#define VIPER_CPLD_P2V(x) ((x) - VIPER_CPLD_PHYS + VIPER_CPLD_BASE)
57#define VIPER_CPLD_V2P(x) ((x) - VIPER_CPLD_BASE + VIPER_CPLD_PHYS)
58
59#ifndef __ASSEMBLY__
60# define __VIPER_CPLD_REG(x) (*((volatile u16 *)VIPER_CPLD_P2V(x)))
61#endif
62
63/* board level registers in the CPLD: (offsets from CPLD_BASE) ... */
64
65/* ... Physical addresses */
66#define _VIPER_LO_IRQ_STATUS (VIPER_CPLD_PHYS + 0x100000)
67#define _VIPER_ICR_PHYS (VIPER_CPLD_PHYS + 0x100002)
68#define _VIPER_HI_IRQ_STATUS (VIPER_CPLD_PHYS + 0x100004)
69#define _VIPER_VERSION_PHYS (VIPER_CPLD_PHYS + 0x100006)
70#define VIPER_UARTA_PHYS (VIPER_CPLD_PHYS + 0x300010)
71#define VIPER_UARTB_PHYS (VIPER_CPLD_PHYS + 0x300000)
72#define _VIPER_SRAM_BASE (VIPER_CPLD_PHYS + 0x800000)
73
74/* ... Virtual addresses */
75#define VIPER_LO_IRQ_STATUS __VIPER_CPLD_REG(_VIPER_LO_IRQ_STATUS)
76#define VIPER_HI_IRQ_STATUS __VIPER_CPLD_REG(_VIPER_HI_IRQ_STATUS)
77#define VIPER_VERSION __VIPER_CPLD_REG(_VIPER_VERSION_PHYS)
78#define VIPER_ICR __VIPER_CPLD_REG(_VIPER_ICR_PHYS)
79
80/* Decode VIPER_VERSION register */
81#define VIPER_CPLD_REVISION(x) (((x) >> 5) & 0x7)
82#define VIPER_BOARD_VERSION(x) (((x) >> 3) & 0x3)
83#define VIPER_BOARD_ISSUE(x) (((x) >> 0) & 0x7)
84
85/* Interrupt and Configuration Register (VIPER_ICR) */
86/* This is a write only register. Only CF_RST is used under Linux */
87
88extern void viper_cf_rst(int state);
89
90#define VIPER_ICR_RETRIG (1 << 0)
91#define VIPER_ICR_AUTO_CLR (1 << 1)
92#define VIPER_ICR_R_DIS (1 << 2)
93#define VIPER_ICR_CF_RST (1 << 3)
94
95#endif
96
diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c
index 5e95c5372fec..fa69c3a6a38e 100644
--- a/arch/arm/mach-pxa/irq.c
+++ b/arch/arm/mach-pxa/irq.c
@@ -57,7 +57,7 @@ void __init pxa_init_irq(int irq_nr, set_wake_t fn)
57 57
58 pxa_internal_irq_nr = irq_nr; 58 pxa_internal_irq_nr = irq_nr;
59 59
60 for (irq = 0; irq < irq_nr; irq += 32) { 60 for (irq = PXA_IRQ(0); irq < PXA_IRQ(irq_nr); irq += 32) {
61 _ICMR(irq) = 0; /* disable all IRQs */ 61 _ICMR(irq) = 0; /* disable all IRQs */
62 _ICLR(irq) = 0; /* all IRQs are IRQ, not FIQ */ 62 _ICLR(irq) = 0; /* all IRQs are IRQ, not FIQ */
63 } 63 }
diff --git a/arch/arm/mach-pxa/leds-trizeps4.c b/arch/arm/mach-pxa/leds-trizeps4.c
deleted file mode 100644
index 3bc29007df3a..000000000000
--- a/arch/arm/mach-pxa/leds-trizeps4.c
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * linux/arch/arm/mach-pxa/leds-trizeps4.c
3 *
4 * Author: Jürgen Schindele
5 * Created: 20 02, 2006
6 * Copyright: Jürgen Schindele
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14
15#include <mach/hardware.h>
16#include <asm/system.h>
17#include <asm/types.h>
18#include <asm/leds.h>
19
20#include <mach/pxa-regs.h>
21#include <mach/pxa2xx-gpio.h>
22#include <mach/trizeps4.h>
23
24#include "leds.h"
25
26#define LED_STATE_ENABLED 1
27#define LED_STATE_CLAIMED 2
28
29#define SYS_BUSY 0x01
30#define HEARTBEAT 0x02
31#define BLINK 0x04
32
33static unsigned int led_state;
34static unsigned int hw_led_state;
35
36void trizeps4_leds_event(led_event_t evt)
37{
38 unsigned long flags;
39
40 local_irq_save(flags);
41
42 switch (evt) {
43 case led_start:
44 hw_led_state = 0;
45 pxa_gpio_mode( GPIO_SYS_BUSY_LED | GPIO_OUT); /* LED1 */
46 pxa_gpio_mode( GPIO_HEARTBEAT_LED | GPIO_OUT); /* LED2 */
47 led_state = LED_STATE_ENABLED;
48 break;
49
50 case led_stop:
51 led_state &= ~LED_STATE_ENABLED;
52 break;
53
54 case led_claim:
55 led_state |= LED_STATE_CLAIMED;
56 hw_led_state = 0;
57 break;
58
59 case led_release:
60 led_state &= ~LED_STATE_CLAIMED;
61 hw_led_state = 0;
62 break;
63
64#ifdef CONFIG_LEDS_TIMER
65 case led_timer:
66 hw_led_state ^= HEARTBEAT;
67 break;
68#endif
69
70#ifdef CONFIG_LEDS_CPU
71 case led_idle_start:
72 hw_led_state &= ~SYS_BUSY;
73 break;
74
75 case led_idle_end:
76 hw_led_state |= SYS_BUSY;
77 break;
78#endif
79
80 case led_halted:
81 break;
82
83 case led_green_on:
84 hw_led_state |= BLINK;
85 break;
86
87 case led_green_off:
88 hw_led_state &= ~BLINK;
89 break;
90
91 case led_amber_on:
92 break;
93
94 case led_amber_off:
95 break;
96
97 case led_red_on:
98 break;
99
100 case led_red_off:
101 break;
102
103 default:
104 break;
105 }
106
107 if (led_state & LED_STATE_ENABLED) {
108 switch (hw_led_state) {
109 case 0:
110 GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
111 GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
112 break;
113 case 1:
114 GPCR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
115 GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
116 break;
117 case 2:
118 GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
119 GPCR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
120 break;
121 case 3:
122 GPCR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
123 GPCR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
124 break;
125 }
126 }
127 else {
128 /* turn all off */
129 GPSR(GPIO_SYS_BUSY_LED) |= GPIO_bit(GPIO_SYS_BUSY_LED);
130 GPSR(GPIO_HEARTBEAT_LED) |= GPIO_bit(GPIO_HEARTBEAT_LED);
131 }
132
133 local_irq_restore(flags);
134}
diff --git a/arch/arm/mach-pxa/leds.c b/arch/arm/mach-pxa/leds.c
index e13eb841e48d..bbe4d5f6afaa 100644
--- a/arch/arm/mach-pxa/leds.c
+++ b/arch/arm/mach-pxa/leds.c
@@ -24,8 +24,6 @@ pxa_leds_init(void)
24 leds_event = mainstone_leds_event; 24 leds_event = mainstone_leds_event;
25 if (machine_is_pxa_idp()) 25 if (machine_is_pxa_idp())
26 leds_event = idp_leds_event; 26 leds_event = idp_leds_event;
27 if (machine_is_trizeps4())
28 leds_event = trizeps4_leds_event;
29 27
30 leds_event(led_start); 28 leds_event(led_start);
31 return 0; 29 return 0;
diff --git a/arch/arm/mach-pxa/littleton.c b/arch/arm/mach-pxa/littleton.c
index 58f3402a0375..b4d00aba0e31 100644
--- a/arch/arm/mach-pxa/littleton.c
+++ b/arch/arm/mach-pxa/littleton.c
@@ -20,6 +20,7 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/spi/spi.h>
23#include <linux/smc91x.h> 24#include <linux/smc91x.h>
24 25
25#include <asm/types.h> 26#include <asm/types.h>
@@ -38,6 +39,7 @@
38#include <mach/gpio.h> 39#include <mach/gpio.h>
39#include <mach/pxafb.h> 40#include <mach/pxafb.h>
40#include <mach/ssp.h> 41#include <mach/ssp.h>
42#include <mach/pxa2xx_spi.h>
41#include <mach/pxa27x_keypad.h> 43#include <mach/pxa27x_keypad.h>
42#include <mach/pxa3xx_nand.h> 44#include <mach/pxa3xx_nand.h>
43#include <mach/littleton.h> 45#include <mach/littleton.h>
@@ -72,8 +74,8 @@ static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
72 74
73 /* SSP2 */ 75 /* SSP2 */
74 GPIO25_SSP2_SCLK, 76 GPIO25_SSP2_SCLK,
75 GPIO17_SSP2_FRM,
76 GPIO27_SSP2_TXD, 77 GPIO27_SSP2_TXD,
78 GPIO17_GPIO, /* SFRM as chip-select */
77 79
78 /* Debug Ethernet */ 80 /* Debug Ethernet */
79 GPIO90_GPIO, 81 GPIO90_GPIO,
@@ -123,160 +125,6 @@ static struct platform_device smc91x_device = {
123}; 125};
124 126
125#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) 127#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
126/* use bit 30, 31 as the indicator of command parameter number */
127#define CMD0(x) ((0x00000000) | ((x) << 9))
128#define CMD1(x, x1) ((0x40000000) | ((x) << 9) | 0x100 | (x1))
129#define CMD2(x, x1, x2) ((0x80000000) | ((x) << 18) | 0x20000 |\
130 ((x1) << 9) | 0x100 | (x2))
131
132static uint32_t lcd_panel_reset[] = {
133 CMD0(0x1), /* reset */
134 CMD0(0x0), /* nop */
135 CMD0(0x0), /* nop */
136 CMD0(0x0), /* nop */
137};
138
139static uint32_t lcd_panel_on[] = {
140 CMD0(0x29), /* Display ON */
141 CMD2(0xB8, 0xFF, 0xF9), /* Output Control */
142 CMD0(0x11), /* Sleep out */
143 CMD1(0xB0, 0x16), /* Wake */
144};
145
146static uint32_t lcd_panel_off[] = {
147 CMD0(0x28), /* Display OFF */
148 CMD2(0xB8, 0x80, 0x02), /* Output Control */
149 CMD0(0x10), /* Sleep in */
150 CMD1(0xB0, 0x00), /* Deep stand by in */
151};
152
153static uint32_t lcd_vga_pass_through[] = {
154 CMD1(0xB0, 0x16),
155 CMD1(0xBC, 0x80),
156 CMD1(0xE1, 0x00),
157 CMD1(0x36, 0x50),
158 CMD1(0x3B, 0x00),
159};
160
161static uint32_t lcd_qvga_pass_through[] = {
162 CMD1(0xB0, 0x16),
163 CMD1(0xBC, 0x81),
164 CMD1(0xE1, 0x00),
165 CMD1(0x36, 0x50),
166 CMD1(0x3B, 0x22),
167};
168
169static uint32_t lcd_vga_transfer[] = {
170 CMD1(0xcf, 0x02), /* Blanking period control (1) */
171 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
172 CMD1(0xd1, 0x01), /* CKV timing control on/off */
173 CMD2(0xd2, 0x14, 0x00), /* CKV 1,2 timing control */
174 CMD2(0xd3, 0x1a, 0x0f), /* OEV timing control */
175 CMD2(0xd4, 0x1f, 0xaf), /* ASW timing control (1) */
176 CMD1(0xd5, 0x14), /* ASW timing control (2) */
177 CMD0(0x21), /* Invert for normally black display */
178 CMD0(0x29), /* Display on */
179};
180
181static uint32_t lcd_qvga_transfer[] = {
182 CMD1(0xd6, 0x02), /* Blanking period control (1) */
183 CMD2(0xd7, 0x08, 0x04), /* Blanking period control (2) */
184 CMD1(0xd8, 0x01), /* CKV timing control on/off */
185 CMD2(0xd9, 0x00, 0x08), /* CKV 1,2 timing control */
186 CMD2(0xde, 0x05, 0x0a), /* OEV timing control */
187 CMD2(0xdf, 0x0a, 0x19), /* ASW timing control (1) */
188 CMD1(0xe0, 0x0a), /* ASW timing control (2) */
189 CMD0(0x21), /* Invert for normally black display */
190 CMD0(0x29), /* Display on */
191};
192
193static uint32_t lcd_panel_config[] = {
194 CMD2(0xb8, 0xff, 0xf9), /* Output control */
195 CMD0(0x11), /* sleep out */
196 CMD1(0xba, 0x01), /* Display mode (1) */
197 CMD1(0xbb, 0x00), /* Display mode (2) */
198 CMD1(0x3a, 0x60), /* Display mode 18-bit RGB */
199 CMD1(0xbf, 0x10), /* Drive system change control */
200 CMD1(0xb1, 0x56), /* Booster operation setup */
201 CMD1(0xb2, 0x33), /* Booster mode setup */
202 CMD1(0xb3, 0x11), /* Booster frequency setup */
203 CMD1(0xb4, 0x02), /* Op amp/system clock */
204 CMD1(0xb5, 0x35), /* VCS voltage */
205 CMD1(0xb6, 0x40), /* VCOM voltage */
206 CMD1(0xb7, 0x03), /* External display signal */
207 CMD1(0xbd, 0x00), /* ASW slew rate */
208 CMD1(0xbe, 0x00), /* Dummy data for QuadData operation */
209 CMD1(0xc0, 0x11), /* Sleep out FR count (A) */
210 CMD1(0xc1, 0x11), /* Sleep out FR count (B) */
211 CMD1(0xc2, 0x11), /* Sleep out FR count (C) */
212 CMD2(0xc3, 0x20, 0x40), /* Sleep out FR count (D) */
213 CMD2(0xc4, 0x60, 0xc0), /* Sleep out FR count (E) */
214 CMD2(0xc5, 0x10, 0x20), /* Sleep out FR count (F) */
215 CMD1(0xc6, 0xc0), /* Sleep out FR count (G) */
216 CMD2(0xc7, 0x33, 0x43), /* Gamma 1 fine tuning (1) */
217 CMD1(0xc8, 0x44), /* Gamma 1 fine tuning (2) */
218 CMD1(0xc9, 0x33), /* Gamma 1 inclination adjustment */
219 CMD1(0xca, 0x00), /* Gamma 1 blue offset adjustment */
220 CMD2(0xec, 0x01, 0xf0), /* Horizontal clock cycles */
221};
222
223static void ssp_reconfig(struct ssp_dev *dev, int nparam)
224{
225 static int last_nparam = -1;
226
227 /* check if it is necessary to re-config SSP */
228 if (nparam == last_nparam)
229 return;
230
231 ssp_disable(dev);
232 ssp_config(dev, (nparam == 2) ? 0x0010058a : 0x00100581, 0x18, 0, 0);
233
234 last_nparam = nparam;
235}
236
237static void ssp_send_cmd(uint32_t *cmd, int num)
238{
239 static int ssp_initialized;
240 static struct ssp_dev ssp2;
241
242 int i;
243
244 if (!ssp_initialized) {
245 ssp_init(&ssp2, 2, SSP_NO_IRQ);
246 ssp_initialized = 1;
247 }
248
249 clk_enable(ssp2.ssp->clk);
250 for (i = 0; i < num; i++, cmd++) {
251 ssp_reconfig(&ssp2, (*cmd >> 30) & 0x3);
252 ssp_write_word(&ssp2, *cmd & 0x3fffffff);
253
254 /* FIXME: ssp_flush() is mandatory here to work */
255 ssp_flush(&ssp2);
256 }
257 clk_disable(ssp2.ssp->clk);
258}
259
260static void littleton_lcd_power(int on, struct fb_var_screeninfo *var)
261{
262 if (on) {
263 ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_on));
264 ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_reset));
265 if (var->xres > 240) {
266 /* VGA */
267 ssp_send_cmd(ARRAY_AND_SIZE(lcd_vga_pass_through));
268 ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_config));
269 ssp_send_cmd(ARRAY_AND_SIZE(lcd_vga_transfer));
270 } else {
271 /* QVGA */
272 ssp_send_cmd(ARRAY_AND_SIZE(lcd_qvga_pass_through));
273 ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_config));
274 ssp_send_cmd(ARRAY_AND_SIZE(lcd_qvga_transfer));
275 }
276 } else
277 ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_off));
278}
279
280static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = { 128static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
281 [0] = { 129 [0] = {
282 /* VGA */ 130 /* VGA */
@@ -312,7 +160,6 @@ static struct pxafb_mach_info littleton_lcd_info = {
312 .modes = tpo_tdo24mtea1_modes, 160 .modes = tpo_tdo24mtea1_modes,
313 .num_modes = 2, 161 .num_modes = 2,
314 .lcd_conn = LCD_COLOR_TFT_16BPP, 162 .lcd_conn = LCD_COLOR_TFT_16BPP,
315 .pxafb_lcd_power = littleton_lcd_power,
316}; 163};
317 164
318static void littleton_init_lcd(void) 165static void littleton_init_lcd(void)
@@ -323,6 +170,51 @@ static void littleton_init_lcd(void)
323static inline void littleton_init_lcd(void) {}; 170static inline void littleton_init_lcd(void) {};
324#endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */ 171#endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
325 172
173#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
174static struct pxa2xx_spi_master littleton_spi_info = {
175 .num_chipselect = 1,
176};
177
178static void littleton_tdo24m_cs(u32 cmd)
179{
180 gpio_set_value(LITTLETON_GPIO_LCD_CS, !(cmd == PXA2XX_CS_ASSERT));
181}
182
183static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
184 .rx_threshold = 1,
185 .tx_threshold = 1,
186 .cs_control = littleton_tdo24m_cs,
187};
188
189static struct spi_board_info littleton_spi_devices[] __initdata = {
190 {
191 .modalias = "tdo24m",
192 .max_speed_hz = 1000000,
193 .bus_num = 2,
194 .chip_select = 0,
195 .controller_data= &littleton_tdo24m_chip,
196 },
197};
198
199static void __init littleton_init_spi(void)
200{
201 int err;
202
203 err = gpio_request(LITTLETON_GPIO_LCD_CS, "LCD_CS");
204 if (err) {
205 pr_warning("failed to request GPIO for LCS CS\n");
206 return;
207 }
208
209 gpio_direction_output(LITTLETON_GPIO_LCD_CS, 1);
210
211 pxa2xx_set_spi_info(2, &littleton_spi_info);
212 spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
213}
214#else
215static inline void littleton_init_spi(void) {}
216#endif
217
326#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) 218#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
327static unsigned int littleton_matrix_key_map[] = { 219static unsigned int littleton_matrix_key_map[] = {
328 /* KEY(row, col, key_code) */ 220 /* KEY(row, col, key_code) */
@@ -433,6 +325,7 @@ static void __init littleton_init(void)
433 */ 325 */
434 platform_device_register(&smc91x_device); 326 platform_device_register(&smc91x_device);
435 327
328 littleton_init_spi();
436 littleton_init_lcd(); 329 littleton_init_lcd();
437 littleton_init_keypad(); 330 littleton_init_keypad();
438 littleton_init_nand(); 331 littleton_init_nand();
diff --git a/arch/arm/mach-pxa/lpd270.c b/arch/arm/mach-pxa/lpd270.c
index b7038948d1d4..de3f67daaacf 100644
--- a/arch/arm/mach-pxa/lpd270.c
+++ b/arch/arm/mach-pxa/lpd270.c
@@ -40,7 +40,7 @@
40 40
41#include <mach/pxa-regs.h> 41#include <mach/pxa-regs.h>
42#include <mach/pxa2xx-regs.h> 42#include <mach/pxa2xx-regs.h>
43#include <mach/pxa2xx-gpio.h> 43#include <mach/mfp-pxa27x.h>
44#include <mach/lpd270.h> 44#include <mach/lpd270.h>
45#include <mach/audio.h> 45#include <mach/audio.h>
46#include <mach/pxafb.h> 46#include <mach/pxafb.h>
@@ -51,6 +51,43 @@
51#include "generic.h" 51#include "generic.h"
52#include "devices.h" 52#include "devices.h"
53 53
54static unsigned long lpd270_pin_config[] __initdata = {
55 /* Chip Selects */
56 GPIO15_nCS_1, /* Mainboard Flash */
57 GPIO78_nCS_2, /* CPLD + Ethernet */
58
59 /* LCD - 16bpp Active TFT */
60 GPIO58_LCD_LDD_0,
61 GPIO59_LCD_LDD_1,
62 GPIO60_LCD_LDD_2,
63 GPIO61_LCD_LDD_3,
64 GPIO62_LCD_LDD_4,
65 GPIO63_LCD_LDD_5,
66 GPIO64_LCD_LDD_6,
67 GPIO65_LCD_LDD_7,
68 GPIO66_LCD_LDD_8,
69 GPIO67_LCD_LDD_9,
70 GPIO68_LCD_LDD_10,
71 GPIO69_LCD_LDD_11,
72 GPIO70_LCD_LDD_12,
73 GPIO71_LCD_LDD_13,
74 GPIO72_LCD_LDD_14,
75 GPIO73_LCD_LDD_15,
76 GPIO74_LCD_FCLK,
77 GPIO75_LCD_LCLK,
78 GPIO76_LCD_PCLK,
79 GPIO77_LCD_BIAS,
80 GPIO16_PWM0_OUT, /* Backlight */
81
82 /* USB Host */
83 GPIO88_USBH1_PWR,
84 GPIO89_USBH1_PEN,
85
86 /* AC97 */
87 GPIO45_AC97_SYSCLK,
88
89 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
90};
54 91
55static unsigned int lpd270_irq_enabled; 92static unsigned int lpd270_irq_enabled;
56 93
@@ -88,8 +125,7 @@ static void lpd270_irq_handler(unsigned int irq, struct irq_desc *desc)
88 GEDR(0) = GPIO_bit(0); /* clear useless edge notification */ 125 GEDR(0) = GPIO_bit(0); /* clear useless edge notification */
89 if (likely(pending)) { 126 if (likely(pending)) {
90 irq = LPD270_IRQ(0) + __ffs(pending); 127 irq = LPD270_IRQ(0) + __ffs(pending);
91 desc = irq_desc + irq; 128 generic_handle_irq(irq);
92 desc_handle_irq(irq, desc);
93 129
94 pending = __raw_readw(LPD270_INT_STATUS) & 130 pending = __raw_readw(LPD270_INT_STATUS) &
95 lpd270_irq_enabled; 131 lpd270_irq_enabled;
@@ -265,8 +301,8 @@ static struct pxafb_mode_info sharp_lq057q3dc02_mode = {
265static struct pxafb_mach_info sharp_lq057q3dc02 = { 301static struct pxafb_mach_info sharp_lq057q3dc02 = {
266 .modes = &sharp_lq057q3dc02_mode, 302 .modes = &sharp_lq057q3dc02_mode,
267 .num_modes = 1, 303 .num_modes = 1,
268 .lccr0 = 0x07800080, 304 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
269 .lccr3 = 0x00400000, 305 LCD_ALTERNATE_MAPPING,
270}; 306};
271 307
272/* 12.1" TFT SVGA (LoLo display number 2) */ 308/* 12.1" TFT SVGA (LoLo display number 2) */
@@ -287,8 +323,8 @@ static struct pxafb_mode_info sharp_lq121s1dg31_mode = {
287static struct pxafb_mach_info sharp_lq121s1dg31 = { 323static struct pxafb_mach_info sharp_lq121s1dg31 = {
288 .modes = &sharp_lq121s1dg31_mode, 324 .modes = &sharp_lq121s1dg31_mode,
289 .num_modes = 1, 325 .num_modes = 1,
290 .lccr0 = 0x07800080, 326 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
291 .lccr3 = 0x00400000, 327 LCD_ALTERNATE_MAPPING,
292}; 328};
293 329
294/* 3.6" TFT QVGA (LoLo display number 3) */ 330/* 3.6" TFT QVGA (LoLo display number 3) */
@@ -309,8 +345,8 @@ static struct pxafb_mode_info sharp_lq036q1da01_mode = {
309static struct pxafb_mach_info sharp_lq036q1da01 = { 345static struct pxafb_mach_info sharp_lq036q1da01 = {
310 .modes = &sharp_lq036q1da01_mode, 346 .modes = &sharp_lq036q1da01_mode,
311 .num_modes = 1, 347 .num_modes = 1,
312 .lccr0 = 0x07800080, 348 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
313 .lccr3 = 0x00400000, 349 LCD_ALTERNATE_MAPPING,
314}; 350};
315 351
316/* 6.4" TFT VGA (LoLo display number 5) */ 352/* 6.4" TFT VGA (LoLo display number 5) */
@@ -331,8 +367,8 @@ static struct pxafb_mode_info sharp_lq64d343_mode = {
331static struct pxafb_mach_info sharp_lq64d343 = { 367static struct pxafb_mach_info sharp_lq64d343 = {
332 .modes = &sharp_lq64d343_mode, 368 .modes = &sharp_lq64d343_mode,
333 .num_modes = 1, 369 .num_modes = 1,
334 .lccr0 = 0x07800080, 370 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
335 .lccr3 = 0x00400000, 371 LCD_ALTERNATE_MAPPING,
336}; 372};
337 373
338/* 10.4" TFT VGA (LoLo display number 7) */ 374/* 10.4" TFT VGA (LoLo display number 7) */
@@ -353,8 +389,8 @@ static struct pxafb_mode_info sharp_lq10d368_mode = {
353static struct pxafb_mach_info sharp_lq10d368 = { 389static struct pxafb_mach_info sharp_lq10d368 = {
354 .modes = &sharp_lq10d368_mode, 390 .modes = &sharp_lq10d368_mode,
355 .num_modes = 1, 391 .num_modes = 1,
356 .lccr0 = 0x07800080, 392 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
357 .lccr3 = 0x00400000, 393 LCD_ALTERNATE_MAPPING,
358}; 394};
359 395
360/* 3.5" TFT QVGA (LoLo display number 8) */ 396/* 3.5" TFT QVGA (LoLo display number 8) */
@@ -375,8 +411,8 @@ static struct pxafb_mode_info sharp_lq035q7db02_20_mode = {
375static struct pxafb_mach_info sharp_lq035q7db02_20 = { 411static struct pxafb_mach_info sharp_lq035q7db02_20 = {
376 .modes = &sharp_lq035q7db02_20_mode, 412 .modes = &sharp_lq035q7db02_20_mode,
377 .num_modes = 1, 413 .num_modes = 1,
378 .lccr0 = 0x07800080, 414 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
379 .lccr3 = 0x00400000, 415 LCD_ALTERNATE_MAPPING,
380}; 416};
381 417
382static struct pxafb_mach_info *lpd270_lcd_to_use; 418static struct pxafb_mach_info *lpd270_lcd_to_use;
@@ -411,27 +447,15 @@ static struct platform_device *platform_devices[] __initdata = {
411 &lpd270_flash_device[1], 447 &lpd270_flash_device[1],
412}; 448};
413 449
414static int lpd270_ohci_init(struct device *dev)
415{
416 /* setup Port1 GPIO pin. */
417 pxa_gpio_mode(88 | GPIO_ALT_FN_1_IN); /* USBHPWR1 */
418 pxa_gpio_mode(89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */
419
420 /* Set the Power Control Polarity Low and Power Sense
421 Polarity Low to active low. */
422 UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
423 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
424
425 return 0;
426}
427
428static struct pxaohci_platform_data lpd270_ohci_platform_data = { 450static struct pxaohci_platform_data lpd270_ohci_platform_data = {
429 .port_mode = PMM_PERPORT_MODE, 451 .port_mode = PMM_PERPORT_MODE,
430 .init = lpd270_ohci_init, 452 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
431}; 453};
432 454
433static void __init lpd270_init(void) 455static void __init lpd270_init(void)
434{ 456{
457 pxa2xx_mfp_config(ARRAY_AND_SIZE(lpd270_pin_config));
458
435 lpd270_flash_data[0].width = (BOOT_DEF & 1) ? 2 : 4; 459 lpd270_flash_data[0].width = (BOOT_DEF & 1) ? 2 : 4;
436 lpd270_flash_data[1].width = 4; 460 lpd270_flash_data[1].width = 4;
437 461
@@ -442,12 +466,6 @@ static void __init lpd270_init(void)
442 */ 466 */
443 ARB_CNTRL = ARB_CORE_PARK | 0x234; 467 ARB_CNTRL = ARB_CORE_PARK | 0x234;
444 468
445 /*
446 * On LogicPD PXA270, we route AC97_SYSCLK via GPIO45.
447 */
448 pxa_gpio_mode(GPIO45_SYSCLK_AC97_MD);
449 pxa_gpio_mode(GPIO16_PWM0_MD);
450
451 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 469 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
452 470
453 pxa_set_ac97_info(NULL); 471 pxa_set_ac97_info(NULL);
@@ -473,15 +491,6 @@ static void __init lpd270_map_io(void)
473 pxa_map_io(); 491 pxa_map_io();
474 iotable_init(lpd270_io_desc, ARRAY_SIZE(lpd270_io_desc)); 492 iotable_init(lpd270_io_desc, ARRAY_SIZE(lpd270_io_desc));
475 493
476 /* initialize sleep mode regs (wake-up sources, etc) */
477 PGSR0 = 0x00008800;
478 PGSR1 = 0x00000002;
479 PGSR2 = 0x0001FC00;
480 PGSR3 = 0x00001F81;
481 PWER = 0xC0000002;
482 PRER = 0x00000002;
483 PFER = 0x00000002;
484
485 /* for use I SRAM as framebuffer. */ 494 /* for use I SRAM as framebuffer. */
486 PSLR |= 0x00000F04; 495 PSLR |= 0x00000F04;
487 PCFR = 0x00000066; 496 PCFR = 0x00000066;
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 4ffdff2d9ff1..bff704354c1a 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -57,13 +57,36 @@
57 57
58static unsigned long lubbock_pin_config[] __initdata = { 58static unsigned long lubbock_pin_config[] __initdata = {
59 GPIO15_nCS_1, /* CS1 - Flash */ 59 GPIO15_nCS_1, /* CS1 - Flash */
60 GPIO78_nCS_2, /* CS2 - Baseboard FGPA */
60 GPIO79_nCS_3, /* CS3 - SMC ethernet */ 61 GPIO79_nCS_3, /* CS3 - SMC ethernet */
62 GPIO80_nCS_4, /* CS4 - SA1111 */
61 63
62 /* SSP data pins */ 64 /* SSP data pins */
63 GPIO23_SSP1_SCLK, 65 GPIO23_SSP1_SCLK,
64 GPIO25_SSP1_TXD, 66 GPIO25_SSP1_TXD,
65 GPIO26_SSP1_RXD, 67 GPIO26_SSP1_RXD,
66 68
69 /* LCD - 16bpp DSTN */
70 GPIO58_LCD_LDD_0,
71 GPIO59_LCD_LDD_1,
72 GPIO60_LCD_LDD_2,
73 GPIO61_LCD_LDD_3,
74 GPIO62_LCD_LDD_4,
75 GPIO63_LCD_LDD_5,
76 GPIO64_LCD_LDD_6,
77 GPIO65_LCD_LDD_7,
78 GPIO66_LCD_LDD_8,
79 GPIO67_LCD_LDD_9,
80 GPIO68_LCD_LDD_10,
81 GPIO69_LCD_LDD_11,
82 GPIO70_LCD_LDD_12,
83 GPIO71_LCD_LDD_13,
84 GPIO72_LCD_LDD_14,
85 GPIO73_LCD_LDD_15,
86 GPIO74_LCD_FCLK,
87 GPIO75_LCD_LCLK,
88 GPIO76_LCD_PCLK,
89
67 /* BTUART */ 90 /* BTUART */
68 GPIO42_BTUART_RXD, 91 GPIO42_BTUART_RXD,
69 GPIO43_BTUART_TXD, 92 GPIO43_BTUART_TXD,
@@ -132,8 +155,7 @@ static void lubbock_irq_handler(unsigned int irq, struct irq_desc *desc)
132 GEDR(0) = GPIO_bit(0); /* clear our parent irq */ 155 GEDR(0) = GPIO_bit(0); /* clear our parent irq */
133 if (likely(pending)) { 156 if (likely(pending)) {
134 irq = LUBBOCK_IRQ(0) + __ffs(pending); 157 irq = LUBBOCK_IRQ(0) + __ffs(pending);
135 desc = irq_desc + irq; 158 generic_handle_irq(irq);
136 desc_handle_irq(irq, desc);
137 } 159 }
138 pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled; 160 pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
139 } while (pending); 161 } while (pending);
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index 143f28adaf95..519138bc5f85 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -409,7 +409,7 @@ static struct platform_device backlight = {
409 * LEDs 409 * LEDs
410 */ 410 */
411 411
412struct gpio_led gpio_leds[] = { 412static struct gpio_led gpio_leds[] = {
413 { 413 {
414 .name = "magician::vibra", 414 .name = "magician::vibra",
415 .default_trigger = "none", 415 .default_trigger = "none",
@@ -669,18 +669,10 @@ static struct pxamci_platform_data magician_mci_info = {
669 * USB OHCI 669 * USB OHCI
670 */ 670 */
671 671
672static int magician_ohci_init(struct device *dev)
673{
674 UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) &
675 ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE);
676
677 return 0;
678}
679
680static struct pxaohci_platform_data magician_ohci_info = { 672static struct pxaohci_platform_data magician_ohci_info = {
681 .port_mode = PMM_PERPORT_MODE, 673 .port_mode = PMM_PERPORT_MODE,
682 .init = magician_ohci_init, 674 .flags = ENABLE_PORT1 | ENABLE_PORT3 | POWER_CONTROL_LOW,
683 .power_budget = 0, 675 .power_budget = 0,
684}; 676};
685 677
686 678
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index d44af761564d..f2c7ad8f2b6b 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -162,8 +162,7 @@ static void mainstone_irq_handler(unsigned int irq, struct irq_desc *desc)
162 GEDR(0) = GPIO_bit(0); /* clear useless edge notification */ 162 GEDR(0) = GPIO_bit(0); /* clear useless edge notification */
163 if (likely(pending)) { 163 if (likely(pending)) {
164 irq = MAINSTONE_IRQ(0) + __ffs(pending); 164 irq = MAINSTONE_IRQ(0) + __ffs(pending);
165 desc = irq_desc + irq; 165 generic_handle_irq(irq);
166 desc_handle_irq(irq, desc);
167 } 166 }
168 pending = MST_INTSETCLR & mainstone_irq_enabled; 167 pending = MST_INTSETCLR & mainstone_irq_enabled;
169 } while (pending); 168 } while (pending);
@@ -508,19 +507,9 @@ static struct platform_device *platform_devices[] __initdata = {
508 &mst_gpio_keys_device, 507 &mst_gpio_keys_device,
509}; 508};
510 509
511static int mainstone_ohci_init(struct device *dev)
512{
513 /* Set the Power Control Polarity Low and Power Sense
514 Polarity Low to active low. */
515 UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
516 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
517
518 return 0;
519}
520
521static struct pxaohci_platform_data mainstone_ohci_platform_data = { 510static struct pxaohci_platform_data mainstone_ohci_platform_data = {
522 .port_mode = PMM_PERPORT_MODE, 511 .port_mode = PMM_PERPORT_MODE,
523 .init = mainstone_ohci_init, 512 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
524}; 513};
525 514
526#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) 515#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
diff --git a/arch/arm/mach-pxa/mfp-pxa2xx.c b/arch/arm/mach-pxa/mfp-pxa2xx.c
index 925575f10acf..2061c00c8ead 100644
--- a/arch/arm/mach-pxa/mfp-pxa2xx.c
+++ b/arch/arm/mach-pxa/mfp-pxa2xx.c
@@ -25,7 +25,12 @@
25 25
26#include "generic.h" 26#include "generic.h"
27 27
28#define PGSR(x) __REG2(0x40F00020, ((x) & 0x60) >> 3) 28#define gpio_to_bank(gpio) ((gpio) >> 5)
29
30#define PGSR(x) __REG2(0x40F00020, (x) << 2)
31#define __GAFR(u, x) __REG2((u) ? 0x40E00058 : 0x40E00054, (x) << 3)
32#define GAFR_L(x) __GAFR(0, x)
33#define GAFR_U(x) __GAFR(1, x)
29 34
30#define PWER_WE35 (1 << 24) 35#define PWER_WE35 (1 << 24)
31 36
@@ -38,49 +43,59 @@ struct gpio_desc {
38}; 43};
39 44
40static struct gpio_desc gpio_desc[MFP_PIN_GPIO127 + 1]; 45static struct gpio_desc gpio_desc[MFP_PIN_GPIO127 + 1];
46static int gpio_nr;
41 47
42static int __mfp_config_lpm(unsigned gpio, unsigned long lpm) 48static unsigned long gpdr_lpm[4];
43{
44 unsigned mask = GPIO_bit(gpio);
45
46 /* low power state */
47 switch (lpm) {
48 case MFP_LPM_DRIVE_HIGH:
49 PGSR(gpio) |= mask;
50 break;
51 case MFP_LPM_DRIVE_LOW:
52 PGSR(gpio) &= ~mask;
53 break;
54 case MFP_LPM_INPUT:
55 break;
56 default:
57 pr_warning("%s: invalid low power state for GPIO%d\n",
58 __func__, gpio);
59 return -EINVAL;
60 }
61 return 0;
62}
63 49
64static int __mfp_config_gpio(unsigned gpio, unsigned long c) 50static int __mfp_config_gpio(unsigned gpio, unsigned long c)
65{ 51{
66 unsigned long gafr, mask = GPIO_bit(gpio); 52 unsigned long gafr, mask = GPIO_bit(gpio);
67 int fn; 53 int bank = gpio_to_bank(gpio);
54 int uorl = !!(gpio & 0x10); /* GAFRx_U or GAFRx_L ? */
55 int shft = (gpio & 0xf) << 1;
56 int fn = MFP_AF(c);
57 int dir = c & MFP_DIR_OUT;
68 58
69 fn = MFP_AF(c);
70 if (fn > 3) 59 if (fn > 3)
71 return -EINVAL; 60 return -EINVAL;
72 61
73 /* alternate function and direction */ 62 /* alternate function and direction at run-time */
74 gafr = GAFR(gpio) & ~(0x3 << ((gpio & 0xf) * 2)); 63 gafr = (uorl == 0) ? GAFR_L(bank) : GAFR_U(bank);
75 GAFR(gpio) = gafr | (fn << ((gpio & 0xf) * 2)); 64 gafr = (gafr & ~(0x3 << shft)) | (fn << shft);
76 65
77 if (c & MFP_DIR_OUT) 66 if (uorl == 0)
67 GAFR_L(bank) = gafr;
68 else
69 GAFR_U(bank) = gafr;
70
71 if (dir == MFP_DIR_OUT)
78 GPDR(gpio) |= mask; 72 GPDR(gpio) |= mask;
79 else 73 else
80 GPDR(gpio) &= ~mask; 74 GPDR(gpio) &= ~mask;
81 75
82 if (__mfp_config_lpm(gpio, c & MFP_LPM_STATE_MASK)) 76 /* alternate function and direction at low power mode */
83 return -EINVAL; 77 switch (c & MFP_LPM_STATE_MASK) {
78 case MFP_LPM_DRIVE_HIGH:
79 PGSR(bank) |= mask;
80 dir = MFP_DIR_OUT;
81 break;
82 case MFP_LPM_DRIVE_LOW:
83 PGSR(bank) &= ~mask;
84 dir = MFP_DIR_OUT;
85 break;
86 case MFP_LPM_DEFAULT:
87 break;
88 default:
89 /* warning and fall through, treat as MFP_LPM_DEFAULT */
90 pr_warning("%s: GPIO%d: unsupported low power mode\n",
91 __func__, gpio);
92 break;
93 }
94
95 if (dir == MFP_DIR_OUT)
96 gpdr_lpm[bank] |= mask;
97 else
98 gpdr_lpm[bank] &= ~mask;
84 99
85 /* give early warning if MFP_LPM_CAN_WAKEUP is set on the 100 /* give early warning if MFP_LPM_CAN_WAKEUP is set on the
86 * configurations of those pins not able to wakeup 101 * configurations of those pins not able to wakeup
@@ -91,7 +106,7 @@ static int __mfp_config_gpio(unsigned gpio, unsigned long c)
91 return -EINVAL; 106 return -EINVAL;
92 } 107 }
93 108
94 if ((c & MFP_LPM_CAN_WAKEUP) && (c & MFP_DIR_OUT)) { 109 if ((c & MFP_LPM_CAN_WAKEUP) && (dir == MFP_DIR_OUT)) {
95 pr_warning("%s: output GPIO%d unable to wakeup\n", 110 pr_warning("%s: output GPIO%d unable to wakeup\n",
96 __func__, gpio); 111 __func__, gpio);
97 return -EINVAL; 112 return -EINVAL;
@@ -135,7 +150,7 @@ void pxa2xx_mfp_config(unsigned long *mfp_cfgs, int num)
135 150
136void pxa2xx_mfp_set_lpm(int mfp, unsigned long lpm) 151void pxa2xx_mfp_set_lpm(int mfp, unsigned long lpm)
137{ 152{
138 unsigned long flags; 153 unsigned long flags, c;
139 int gpio; 154 int gpio;
140 155
141 gpio = __mfp_validate(mfp); 156 gpio = __mfp_validate(mfp);
@@ -143,7 +158,11 @@ void pxa2xx_mfp_set_lpm(int mfp, unsigned long lpm)
143 return; 158 return;
144 159
145 local_irq_save(flags); 160 local_irq_save(flags);
146 __mfp_config_lpm(gpio, lpm); 161
162 c = gpio_desc[gpio].config;
163 c = (c & ~MFP_LPM_STATE_MASK) | lpm;
164 __mfp_config_gpio(gpio, c);
165
147 local_irq_restore(flags); 166 local_irq_restore(flags);
148} 167}
149 168
@@ -187,23 +206,22 @@ int gpio_set_wake(unsigned int gpio, unsigned int on)
187} 206}
188 207
189#ifdef CONFIG_PXA25x 208#ifdef CONFIG_PXA25x
190static int __init pxa25x_mfp_init(void) 209static void __init pxa25x_mfp_init(void)
191{ 210{
192 int i; 211 int i;
193 212
194 if (cpu_is_pxa25x()) { 213 for (i = 0; i <= 84; i++)
195 for (i = 0; i <= 84; i++) 214 gpio_desc[i].valid = 1;
196 gpio_desc[i].valid = 1;
197 215
198 for (i = 0; i <= 15; i++) { 216 for (i = 0; i <= 15; i++) {
199 gpio_desc[i].can_wakeup = 1; 217 gpio_desc[i].can_wakeup = 1;
200 gpio_desc[i].mask = GPIO_bit(i); 218 gpio_desc[i].mask = GPIO_bit(i);
201 }
202 } 219 }
203 220
204 return 0; 221 gpio_nr = 85;
205} 222}
206postcore_initcall(pxa25x_mfp_init); 223#else
224static inline void pxa25x_mfp_init(void) {}
207#endif /* CONFIG_PXA25x */ 225#endif /* CONFIG_PXA25x */
208 226
209#ifdef CONFIG_PXA27x 227#ifdef CONFIG_PXA27x
@@ -233,45 +251,106 @@ int keypad_set_wake(unsigned int on)
233 return 0; 251 return 0;
234} 252}
235 253
236static int __init pxa27x_mfp_init(void) 254static void __init pxa27x_mfp_init(void)
237{ 255{
238 int i, gpio; 256 int i, gpio;
239 257
240 if (cpu_is_pxa27x()) { 258 for (i = 0; i <= 120; i++) {
241 for (i = 0; i <= 120; i++) { 259 /* skip GPIO2, 5, 6, 7, 8, they are not
242 /* skip GPIO2, 5, 6, 7, 8, they are not 260 * valid pins allow configuration
243 * valid pins allow configuration 261 */
244 */ 262 if (i == 2 || i == 5 || i == 6 || i == 7 || i == 8)
245 if (i == 2 || i == 5 || i == 6 || 263 continue;
246 i == 7 || i == 8)
247 continue;
248 264
249 gpio_desc[i].valid = 1; 265 gpio_desc[i].valid = 1;
250 } 266 }
251 267
252 /* Keypad GPIOs */ 268 /* Keypad GPIOs */
253 for (i = 0; i < ARRAY_SIZE(pxa27x_pkwr_gpio); i++) { 269 for (i = 0; i < ARRAY_SIZE(pxa27x_pkwr_gpio); i++) {
254 gpio = pxa27x_pkwr_gpio[i]; 270 gpio = pxa27x_pkwr_gpio[i];
255 gpio_desc[gpio].can_wakeup = 1; 271 gpio_desc[gpio].can_wakeup = 1;
256 gpio_desc[gpio].keypad_gpio = 1; 272 gpio_desc[gpio].keypad_gpio = 1;
257 gpio_desc[gpio].mask = 1 << i; 273 gpio_desc[gpio].mask = 1 << i;
258 } 274 }
259 275
260 /* Overwrite GPIO13 as a PWER wakeup source */ 276 /* Overwrite GPIO13 as a PWER wakeup source */
261 for (i = 0; i <= 15; i++) { 277 for (i = 0; i <= 15; i++) {
262 /* skip GPIO2, 5, 6, 7, 8 */ 278 /* skip GPIO2, 5, 6, 7, 8 */
263 if (GPIO_bit(i) & 0x1e4) 279 if (GPIO_bit(i) & 0x1e4)
264 continue; 280 continue;
265 281
266 gpio_desc[i].can_wakeup = 1; 282 gpio_desc[i].can_wakeup = 1;
267 gpio_desc[i].mask = GPIO_bit(i); 283 gpio_desc[i].mask = GPIO_bit(i);
268 } 284 }
285
286 gpio_desc[35].can_wakeup = 1;
287 gpio_desc[35].mask = PWER_WE35;
288
289 gpio_nr = 121;
290}
291#else
292static inline void pxa27x_mfp_init(void) {}
293#endif /* CONFIG_PXA27x */
294
295#ifdef CONFIG_PM
296static unsigned long saved_gafr[2][4];
297static unsigned long saved_gpdr[4];
269 298
270 gpio_desc[35].can_wakeup = 1; 299static int pxa2xx_mfp_suspend(struct sys_device *d, pm_message_t state)
271 gpio_desc[35].mask = PWER_WE35; 300{
301 int i;
302
303 for (i = 0; i <= gpio_to_bank(gpio_nr); i++) {
304
305 saved_gafr[0][i] = GAFR_L(i);
306 saved_gafr[1][i] = GAFR_U(i);
307 saved_gpdr[i] = GPDR(i * 32);
308
309 GPDR(i * 32) = gpdr_lpm[i];
272 } 310 }
311 return 0;
312}
273 313
314static int pxa2xx_mfp_resume(struct sys_device *d)
315{
316 int i;
317
318 for (i = 0; i <= gpio_to_bank(gpio_nr); i++) {
319 GAFR_L(i) = saved_gafr[0][i];
320 GAFR_U(i) = saved_gafr[1][i];
321 GPDR(i * 32) = saved_gpdr[i];
322 }
323 PSSR = PSSR_RDH | PSSR_PH;
274 return 0; 324 return 0;
275} 325}
276postcore_initcall(pxa27x_mfp_init); 326#else
277#endif /* CONFIG_PXA27x */ 327#define pxa2xx_mfp_suspend NULL
328#define pxa2xx_mfp_resume NULL
329#endif
330
331struct sysdev_class pxa2xx_mfp_sysclass = {
332 .name = "mfp",
333 .suspend = pxa2xx_mfp_suspend,
334 .resume = pxa2xx_mfp_resume,
335};
336
337static int __init pxa2xx_mfp_init(void)
338{
339 int i;
340
341 if (!cpu_is_pxa2xx())
342 return 0;
343
344 if (cpu_is_pxa25x())
345 pxa25x_mfp_init();
346
347 if (cpu_is_pxa27x())
348 pxa27x_mfp_init();
349
350 /* initialize gafr_run[], pgsr_lpm[] from existing values */
351 for (i = 0; i <= gpio_to_bank(gpio_nr); i++)
352 gpdr_lpm[i] = GPDR(i * 32);
353
354 return sysdev_class_register(&pxa2xx_mfp_sysclass);
355}
356postcore_initcall(pxa2xx_mfp_init);
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
new file mode 100644
index 000000000000..0842c531ee4d
--- /dev/null
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -0,0 +1,905 @@
1/*
2 * Handles the Mitac Mio A701 Board
3 *
4 * Copyright (C) 2008 Robert Jarzmik
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/platform_device.h>
25#include <linux/sysdev.h>
26#include <linux/input.h>
27#include <linux/delay.h>
28#include <linux/gpio_keys.h>
29#include <linux/pwm_backlight.h>
30#include <linux/rtc.h>
31#include <linux/leds.h>
32#include <linux/gpio.h>
33#include <linux/interrupt.h>
34#include <linux/irq.h>
35#include <linux/pda_power.h>
36#include <linux/power_supply.h>
37#include <linux/wm97xx.h>
38#include <linux/mtd/physmap.h>
39
40#include <asm/mach-types.h>
41#include <asm/mach/arch.h>
42#include <mach/mfp-pxa27x.h>
43#include <mach/pxa27x_keypad.h>
44#include <mach/pxafb.h>
45#include <mach/pxa2xx-regs.h>
46#include <mach/mmc.h>
47#include <mach/udc.h>
48#include <mach/pxa27x-udc.h>
49
50#include <mach/mioa701.h>
51
52#include "generic.h"
53#include "devices.h"
54
55static unsigned long mioa701_pin_config[] = {
56 /* Mio global */
57 MIO_CFG_OUT(GPIO9_CHARGE_nEN, AF0, DRIVE_LOW),
58 MIO_CFG_OUT(GPIO18_POWEROFF, AF0, DRIVE_LOW),
59 MFP_CFG_OUT(GPIO3, AF0, DRIVE_HIGH),
60 MFP_CFG_OUT(GPIO4, AF0, DRIVE_HIGH),
61
62 /* Backlight PWM 0 */
63 GPIO16_PWM0_OUT,
64
65 /* MMC */
66 GPIO32_MMC_CLK,
67 GPIO92_MMC_DAT_0,
68 GPIO109_MMC_DAT_1,
69 GPIO110_MMC_DAT_2,
70 GPIO111_MMC_DAT_3,
71 GPIO112_MMC_CMD,
72 MIO_CFG_IN(GPIO78_SDIO_RO, AF0),
73 MIO_CFG_IN(GPIO15_SDIO_INSERT, AF0),
74 MIO_CFG_OUT(GPIO91_SDIO_EN, AF0, DRIVE_LOW),
75
76 /* USB */
77 MIO_CFG_IN(GPIO13_USB_DETECT, AF0),
78 MIO_CFG_OUT(GPIO22_USB_ENABLE, AF0, DRIVE_LOW),
79
80 /* LCD */
81 GPIO58_LCD_LDD_0,
82 GPIO59_LCD_LDD_1,
83 GPIO60_LCD_LDD_2,
84 GPIO61_LCD_LDD_3,
85 GPIO62_LCD_LDD_4,
86 GPIO63_LCD_LDD_5,
87 GPIO64_LCD_LDD_6,
88 GPIO65_LCD_LDD_7,
89 GPIO66_LCD_LDD_8,
90 GPIO67_LCD_LDD_9,
91 GPIO68_LCD_LDD_10,
92 GPIO69_LCD_LDD_11,
93 GPIO70_LCD_LDD_12,
94 GPIO71_LCD_LDD_13,
95 GPIO72_LCD_LDD_14,
96 GPIO73_LCD_LDD_15,
97 GPIO74_LCD_FCLK,
98 GPIO75_LCD_LCLK,
99 GPIO76_LCD_PCLK,
100
101 /* Bluetooth */
102 GPIO44_BTUART_CTS,
103 GPIO42_BTUART_RXD,
104 GPIO45_BTUART_RTS,
105 GPIO43_BTUART_TXD,
106 MIO_CFG_OUT(GPIO83_BT_ON, AF0, DRIVE_LOW),
107
108 /* GPS */
109 MIO_CFG_OUT(GPIO23_GPS_UNKNOWN1, AF0, DRIVE_LOW),
110 MIO_CFG_OUT(GPIO26_GPS_ON, AF0, DRIVE_LOW),
111 MIO_CFG_OUT(GPIO27_GPS_RESET, AF0, DRIVE_LOW),
112 MIO_CFG_OUT(GPIO106_GPS_UNKNOWN2, AF0, DRIVE_LOW),
113 MIO_CFG_OUT(GPIO107_GPS_UNKNOWN3, AF0, DRIVE_LOW),
114 GPIO46_STUART_RXD,
115 GPIO47_STUART_TXD,
116
117 /* GSM */
118 MIO_CFG_OUT(GPIO24_GSM_MOD_RESET_CMD, AF0, DRIVE_LOW),
119 MIO_CFG_OUT(GPIO88_GSM_nMOD_ON_CMD, AF0, DRIVE_HIGH),
120 MIO_CFG_OUT(GPIO90_GSM_nMOD_OFF_CMD, AF0, DRIVE_HIGH),
121 MIO_CFG_OUT(GPIO114_GSM_nMOD_DTE_UART_STATE, AF0, DRIVE_HIGH),
122 MIO_CFG_IN(GPIO25_GSM_MOD_ON_STATE, AF0),
123 MIO_CFG_IN(GPIO113_GSM_EVENT, AF0) | WAKEUP_ON_EDGE_BOTH,
124 GPIO34_FFUART_RXD,
125 GPIO35_FFUART_CTS,
126 GPIO36_FFUART_DCD,
127 GPIO37_FFUART_DSR,
128 GPIO39_FFUART_TXD,
129 GPIO40_FFUART_DTR,
130 GPIO41_FFUART_RTS,
131
132 /* Sound */
133 GPIO89_AC97_SYSCLK,
134 MIO_CFG_IN(GPIO12_HPJACK_INSERT, AF0),
135
136 /* Leds */
137 MIO_CFG_OUT(GPIO10_LED_nCharging, AF0, DRIVE_HIGH),
138 MIO_CFG_OUT(GPIO97_LED_nBlue, AF0, DRIVE_HIGH),
139 MIO_CFG_OUT(GPIO98_LED_nOrange, AF0, DRIVE_HIGH),
140 MIO_CFG_OUT(GPIO82_LED_nVibra, AF0, DRIVE_HIGH),
141 MIO_CFG_OUT(GPIO115_LED_nKeyboard, AF0, DRIVE_HIGH),
142
143 /* Keyboard */
144 MIO_CFG_IN(GPIO0_KEY_POWER, AF0) | WAKEUP_ON_EDGE_BOTH,
145 MIO_CFG_IN(GPIO93_KEY_VOLUME_UP, AF0),
146 MIO_CFG_IN(GPIO94_KEY_VOLUME_DOWN, AF0),
147 GPIO100_KP_MKIN_0,
148 GPIO101_KP_MKIN_1,
149 GPIO102_KP_MKIN_2,
150 GPIO103_KP_MKOUT_0,
151 GPIO104_KP_MKOUT_1,
152 GPIO105_KP_MKOUT_2,
153
154 /* Unknown */
155 MFP_CFG_IN(GPIO14, AF0),
156 MFP_CFG_IN(GPIO20, AF0),
157 MFP_CFG_IN(GPIO21, AF0),
158 MFP_CFG_IN(GPIO33, AF0),
159 MFP_CFG_OUT(GPIO49, AF0, DRIVE_HIGH),
160 MFP_CFG_OUT(GPIO57, AF0, DRIVE_HIGH),
161 MFP_CFG_OUT(GPIO77, AF0, DRIVE_HIGH),
162 MFP_CFG_IN(GPIO80, AF0),
163 MFP_CFG_OUT(GPIO86, AF0, DRIVE_HIGH),
164 MFP_CFG_IN(GPIO96, AF0),
165 MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
166};
167
168#define MIO_GPIO_IN(num, _desc) \
169 { .gpio = (num), .dir = 0, .desc = (_desc) }
170#define MIO_GPIO_OUT(num, _init, _desc) \
171 { .gpio = (num), .dir = 1, .init = (_init), .desc = (_desc) }
172struct gpio_ress {
173 unsigned gpio : 8;
174 unsigned dir : 1;
175 unsigned init : 1;
176 char *desc;
177};
178
179static int mio_gpio_request(struct gpio_ress *gpios, int size)
180{
181 int i, rc = 0;
182 int gpio;
183 int dir;
184
185 for (i = 0; (!rc) && (i < size); i++) {
186 gpio = gpios[i].gpio;
187 dir = gpios[i].dir;
188 rc = gpio_request(gpio, gpios[i].desc);
189 if (rc) {
190 printk(KERN_ERR "Error requesting GPIO %d(%s) : %d\n",
191 gpio, gpios[i].desc, rc);
192 continue;
193 }
194 if (dir)
195 gpio_direction_output(gpio, gpios[i].init);
196 else
197 gpio_direction_input(gpio);
198 }
199 while ((rc) && (--i >= 0))
200 gpio_free(gpios[i].gpio);
201 return rc;
202}
203
204static void mio_gpio_free(struct gpio_ress *gpios, int size)
205{
206 int i;
207
208 for (i = 0; i < size; i++)
209 gpio_free(gpios[i].gpio);
210}
211
212/* LCD Screen and Backlight */
213static struct platform_pwm_backlight_data mioa701_backlight_data = {
214 .pwm_id = 0,
215 .max_brightness = 100,
216 .dft_brightness = 50,
217 .pwm_period_ns = 4000 * 1024, /* Fl = 250kHz */
218};
219
220/*
221 * LTM0305A776C LCD panel timings
222 *
223 * see:
224 * - the LTM0305A776C datasheet,
225 * - and the PXA27x Programmers' manual
226 */
227static struct pxafb_mode_info mioa701_ltm0305a776c = {
228 .pixclock = 220000, /* CLK=4.545 MHz */
229 .xres = 240,
230 .yres = 320,
231 .bpp = 16,
232 .hsync_len = 4,
233 .vsync_len = 2,
234 .left_margin = 6,
235 .right_margin = 4,
236 .upper_margin = 5,
237 .lower_margin = 3,
238};
239
240static void mioa701_lcd_power(int on, struct fb_var_screeninfo *si)
241{
242 gpio_set_value(GPIO87_LCD_POWER, on);
243}
244
245static struct pxafb_mach_info mioa701_pxafb_info = {
246 .modes = &mioa701_ltm0305a776c,
247 .num_modes = 1,
248 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
249 .pxafb_lcd_power = mioa701_lcd_power,
250};
251
252/*
253 * Keyboard configuration
254 */
255static unsigned int mioa701_matrix_keys[] = {
256 KEY(0, 0, KEY_UP),
257 KEY(0, 1, KEY_RIGHT),
258 KEY(0, 2, KEY_MEDIA),
259 KEY(1, 0, KEY_DOWN),
260 KEY(1, 1, KEY_ENTER),
261 KEY(1, 2, KEY_CONNECT), /* GPS key */
262 KEY(2, 0, KEY_LEFT),
263 KEY(2, 1, KEY_PHONE), /* Phone Green key */
264 KEY(2, 2, KEY_CAMERA) /* Camera key */
265};
266static struct pxa27x_keypad_platform_data mioa701_keypad_info = {
267 .matrix_key_rows = 3,
268 .matrix_key_cols = 3,
269 .matrix_key_map = mioa701_matrix_keys,
270 .matrix_key_map_size = ARRAY_SIZE(mioa701_matrix_keys),
271};
272
273/*
274 * GPIO Key Configuration
275 */
276#define MIO_KEY(key, _gpio, _desc, _wakeup) \
277 { .code = (key), .gpio = (_gpio), .active_low = 0, \
278 .desc = (_desc), .type = EV_KEY, .wakeup = (_wakeup) }
279static struct gpio_keys_button mioa701_button_table[] = {
280 MIO_KEY(KEY_EXIT, GPIO0_KEY_POWER, "Power button", 1),
281 MIO_KEY(KEY_VOLUMEUP, GPIO93_KEY_VOLUME_UP, "Volume up", 0),
282 MIO_KEY(KEY_VOLUMEDOWN, GPIO94_KEY_VOLUME_DOWN, "Volume down", 0),
283 MIO_KEY(KEY_HP, GPIO12_HPJACK_INSERT, "HP jack detect", 0)
284};
285
286static struct gpio_keys_platform_data mioa701_gpio_keys_data = {
287 .buttons = mioa701_button_table,
288 .nbuttons = ARRAY_SIZE(mioa701_button_table),
289};
290
291/*
292 * Leds and vibrator
293 */
294#define ONE_LED(_gpio, _name) \
295{ .gpio = (_gpio), .name = (_name), .active_low = true }
296static struct gpio_led gpio_leds[] = {
297 ONE_LED(GPIO10_LED_nCharging, "mioa701:charging"),
298 ONE_LED(GPIO97_LED_nBlue, "mioa701:blue"),
299 ONE_LED(GPIO98_LED_nOrange, "mioa701:orange"),
300 ONE_LED(GPIO82_LED_nVibra, "mioa701:vibra"),
301 ONE_LED(GPIO115_LED_nKeyboard, "mioa701:keyboard")
302};
303
304static struct gpio_led_platform_data gpio_led_info = {
305 .leds = gpio_leds,
306 .num_leds = ARRAY_SIZE(gpio_leds),
307};
308
309/*
310 * GSM Sagem XS200 chip
311 *
312 * GSM handling was purged from kernel. For history, this is the way to go :
313 * - init : GPIO24_GSM_MOD_RESET_CMD = 0, GPIO114_GSM_nMOD_DTE_UART_STATE = 1
314 * GPIO88_GSM_nMOD_ON_CMD = 1, GPIO90_GSM_nMOD_OFF_CMD = 1
315 * - reset : GPIO24_GSM_MOD_RESET_CMD = 1, msleep(100),
316 * GPIO24_GSM_MOD_RESET_CMD = 0
317 * - turn on : GPIO88_GSM_nMOD_ON_CMD = 0, msleep(1000),
318 * GPIO88_GSM_nMOD_ON_CMD = 1
319 * - turn off : GPIO90_GSM_nMOD_OFF_CMD = 0, msleep(1000),
320 * GPIO90_GSM_nMOD_OFF_CMD = 1
321 */
322static int is_gsm_on(void)
323{
324 int is_on;
325
326 is_on = !!gpio_get_value(GPIO25_GSM_MOD_ON_STATE);
327 return is_on;
328}
329
330irqreturn_t gsm_on_irq(int irq, void *p)
331{
332 printk(KERN_DEBUG "Mioa701: GSM status changed to %s\n",
333 is_gsm_on() ? "on" : "off");
334 return IRQ_HANDLED;
335}
336
337struct gpio_ress gsm_gpios[] = {
338 MIO_GPIO_IN(GPIO25_GSM_MOD_ON_STATE, "GSM state"),
339 MIO_GPIO_IN(GPIO113_GSM_EVENT, "GSM event"),
340};
341
342static int __init gsm_init(void)
343{
344 int rc;
345
346 rc = mio_gpio_request(ARRAY_AND_SIZE(gsm_gpios));
347 if (rc)
348 goto err_gpio;
349 rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq,
350 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
351 "GSM XS200 Power Irq", NULL);
352 if (rc)
353 goto err_irq;
354
355 gpio_set_wake(GPIO113_GSM_EVENT, 1);
356 return 0;
357
358err_irq:
359 printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n");
360 mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
361err_gpio:
362 printk(KERN_ERR "Mioa701: gsm not available\n");
363 return rc;
364}
365
366static void gsm_exit(void)
367{
368 free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL);
369 mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
370}
371
372/*
373 * Bluetooth BRF6150 chip
374 *
375 * BT handling was purged from kernel. For history, this is the way to go :
376 * - turn on : GPIO83_BT_ON = 1
377 * - turn off : GPIO83_BT_ON = 0
378 */
379
380/*
381 * GPS Sirf Star III chip
382 *
383 * GPS handling was purged from kernel. For history, this is the way to go :
384 * - init : GPIO23_GPS_UNKNOWN1 = 1, GPIO26_GPS_ON = 0, GPIO27_GPS_RESET = 0
385 * GPIO106_GPS_UNKNOWN2 = 0, GPIO107_GPS_UNKNOWN3 = 0
386 * - turn on : GPIO27_GPS_RESET = 1, GPIO26_GPS_ON = 1
387 * - turn off : GPIO26_GPS_ON = 0, GPIO27_GPS_RESET = 0
388 */
389
390/*
391 * USB UDC
392 */
393static void udc_power_command(int cmd)
394{
395 switch (cmd) {
396 case PXA2XX_UDC_CMD_DISCONNECT:
397 gpio_set_value(GPIO22_USB_ENABLE, 0);
398 break;
399 case PXA2XX_UDC_CMD_CONNECT:
400 gpio_set_value(GPIO22_USB_ENABLE, 1);
401 break;
402 default:
403 printk(KERN_INFO "udc_control: unknown command (0x%x)!\n", cmd);
404 break;
405 }
406}
407
408static int is_usb_connected(void)
409{
410 return !!gpio_get_value(GPIO13_USB_DETECT);
411}
412
413static struct pxa2xx_udc_mach_info mioa701_udc_info = {
414 .udc_is_connected = is_usb_connected,
415 .udc_command = udc_power_command,
416};
417
418struct gpio_ress udc_gpios[] = {
419 MIO_GPIO_OUT(GPIO22_USB_ENABLE, 0, "USB Vbus enable")
420};
421
422static int __init udc_init(void)
423{
424 pxa_set_udc_info(&mioa701_udc_info);
425 return mio_gpio_request(ARRAY_AND_SIZE(udc_gpios));
426}
427
428static void udc_exit(void)
429{
430 mio_gpio_free(ARRAY_AND_SIZE(udc_gpios));
431}
432
433/*
434 * SDIO/MMC Card controller
435 */
436static void mci_setpower(struct device *dev, unsigned int vdd)
437{
438 struct pxamci_platform_data *p_d = dev->platform_data;
439
440 if ((1 << vdd) & p_d->ocr_mask)
441 gpio_set_value(GPIO91_SDIO_EN, 1); /* enable SDIO power */
442 else
443 gpio_set_value(GPIO91_SDIO_EN, 0); /* disable SDIO power */
444}
445
446static int mci_get_ro(struct device *dev)
447{
448 return gpio_get_value(GPIO78_SDIO_RO);
449}
450
451struct gpio_ress mci_gpios[] = {
452 MIO_GPIO_IN(GPIO78_SDIO_RO, "SDIO readonly detect"),
453 MIO_GPIO_IN(GPIO15_SDIO_INSERT, "SDIO insertion detect"),
454 MIO_GPIO_OUT(GPIO91_SDIO_EN, 0, "SDIO power enable")
455};
456
457static void mci_exit(struct device *dev, void *data)
458{
459 mio_gpio_free(ARRAY_AND_SIZE(mci_gpios));
460 free_irq(gpio_to_irq(GPIO15_SDIO_INSERT), data);
461}
462
463static struct pxamci_platform_data mioa701_mci_info;
464
465/**
466 * The card detect interrupt isn't debounced so we delay it by 250ms
467 * to give the card a chance to fully insert/eject.
468 */
469static int mci_init(struct device *dev, irq_handler_t detect_int, void *data)
470{
471 int rc;
472 int irq = gpio_to_irq(GPIO15_SDIO_INSERT);
473
474 rc = mio_gpio_request(ARRAY_AND_SIZE(mci_gpios));
475 if (rc)
476 goto err_gpio;
477 /* enable RE/FE interrupt on card insertion and removal */
478 rc = request_irq(irq, detect_int,
479 IRQF_DISABLED | IRQF_TRIGGER_RISING |
480 IRQF_TRIGGER_FALLING,
481 "MMC card detect", data);
482 if (rc)
483 goto err_irq;
484
485 mioa701_mci_info.detect_delay = msecs_to_jiffies(250);
486 return 0;
487
488err_irq:
489 dev_err(dev, "mioa701_mci_init: MMC/SD:"
490 " can't request MMC card detect IRQ\n");
491 mio_gpio_free(ARRAY_AND_SIZE(mci_gpios));
492err_gpio:
493 return rc;
494}
495
496static struct pxamci_platform_data mioa701_mci_info = {
497 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
498 .init = mci_init,
499 .get_ro = mci_get_ro,
500 .setpower = mci_setpower,
501 .exit = mci_exit,
502};
503
504/* FlashRAM */
505static struct resource strataflash_resource = {
506 .start = PXA_CS0_PHYS,
507 .end = PXA_CS0_PHYS + SZ_64M - 1,
508 .flags = IORESOURCE_MEM,
509};
510
511static struct physmap_flash_data strataflash_data = {
512 .width = 2,
513 /* .set_vpp = mioa701_set_vpp, */
514};
515
516static struct platform_device strataflash = {
517 .name = "physmap-flash",
518 .id = -1,
519 .resource = &strataflash_resource,
520 .num_resources = 1,
521 .dev = {
522 .platform_data = &strataflash_data,
523 },
524};
525
526/*
527 * Suspend/Resume bootstrap management
528 *
529 * MIO A701 reboot sequence is highly ROM dependant. From the one dissassembled,
530 * this sequence is as follows :
531 * - disables interrupts
532 * - initialize SDRAM (self refresh RAM into active RAM)
533 * - initialize GPIOs (depends on value at 0xa020b020)
534 * - initialize coprossessors
535 * - if edge detect on PWR_SCL(GPIO3), then proceed to cold start
536 * - or if value at 0xa020b000 not equal to 0x0f0f0f0f, proceed to cold start
537 * - else do a resume, ie. jump to addr 0xa0100000
538 */
539#define RESUME_ENABLE_ADDR 0xa020b000
540#define RESUME_ENABLE_VAL 0x0f0f0f0f
541#define RESUME_BT_ADDR 0xa020b020
542#define RESUME_UNKNOWN_ADDR 0xa020b024
543#define RESUME_VECTOR_ADDR 0xa0100000
544#define BOOTSTRAP_WORDS mioa701_bootstrap_lg/4
545
546static u32 *save_buffer;
547
548static void install_bootstrap(void)
549{
550 int i;
551 u32 *rom_bootstrap = phys_to_virt(RESUME_VECTOR_ADDR);
552 u32 *src = &mioa701_bootstrap;
553
554 for (i = 0; i < BOOTSTRAP_WORDS; i++)
555 rom_bootstrap[i] = src[i];
556}
557
558
559static int mioa701_sys_suspend(struct sys_device *sysdev, pm_message_t state)
560{
561 int i = 0, is_bt_on;
562 u32 *mem_resume_vector = phys_to_virt(RESUME_VECTOR_ADDR);
563 u32 *mem_resume_enabler = phys_to_virt(RESUME_ENABLE_ADDR);
564 u32 *mem_resume_bt = phys_to_virt(RESUME_BT_ADDR);
565 u32 *mem_resume_unknown = phys_to_virt(RESUME_UNKNOWN_ADDR);
566
567 /* Devices prepare suspend */
568 is_bt_on = gpio_get_value(GPIO83_BT_ON);
569 pxa2xx_mfp_set_lpm(GPIO83_BT_ON,
570 is_bt_on ? MFP_LPM_DRIVE_HIGH : MFP_LPM_DRIVE_LOW);
571
572 for (i = 0; i < BOOTSTRAP_WORDS; i++)
573 save_buffer[i] = mem_resume_vector[i];
574 save_buffer[i++] = *mem_resume_enabler;
575 save_buffer[i++] = *mem_resume_bt;
576 save_buffer[i++] = *mem_resume_unknown;
577
578 *mem_resume_enabler = RESUME_ENABLE_VAL;
579 *mem_resume_bt = is_bt_on;
580
581 install_bootstrap();
582 return 0;
583}
584
585static int mioa701_sys_resume(struct sys_device *sysdev)
586{
587 int i = 0;
588 u32 *mem_resume_vector = phys_to_virt(RESUME_VECTOR_ADDR);
589 u32 *mem_resume_enabler = phys_to_virt(RESUME_ENABLE_ADDR);
590 u32 *mem_resume_bt = phys_to_virt(RESUME_BT_ADDR);
591 u32 *mem_resume_unknown = phys_to_virt(RESUME_UNKNOWN_ADDR);
592
593 for (i = 0; i < BOOTSTRAP_WORDS; i++)
594 mem_resume_vector[i] = save_buffer[i];
595 *mem_resume_enabler = save_buffer[i++];
596 *mem_resume_bt = save_buffer[i++];
597 *mem_resume_unknown = save_buffer[i++];
598
599 return 0;
600}
601
602static struct sysdev_class mioa701_sysclass = {
603 .name = "mioa701",
604};
605
606static struct sys_device sysdev_bootstrap = {
607 .cls = &mioa701_sysclass,
608};
609
610static struct sysdev_driver driver_bootstrap = {
611 .suspend = &mioa701_sys_suspend,
612 .resume = &mioa701_sys_resume,
613};
614
615static int __init bootstrap_init(void)
616{
617 int rc;
618 int save_size = mioa701_bootstrap_lg + (sizeof(u32) * 3);
619
620 rc = sysdev_class_register(&mioa701_sysclass);
621 if (rc) {
622 printk(KERN_ERR "Failed registering mioa701 sys class\n");
623 return -ENODEV;
624 }
625 rc = sysdev_register(&sysdev_bootstrap);
626 if (rc) {
627 printk(KERN_ERR "Failed registering mioa701 sys device\n");
628 return -ENODEV;
629 }
630 rc = sysdev_driver_register(&mioa701_sysclass, &driver_bootstrap);
631 if (rc) {
632 printk(KERN_ERR "Failed registering PMU sys driver\n");
633 return -ENODEV;
634 }
635
636 save_buffer = kmalloc(save_size, GFP_KERNEL);
637 if (!save_buffer)
638 return -ENOMEM;
639 printk(KERN_INFO "MioA701: allocated %d bytes for bootstrap\n",
640 save_size);
641 return 0;
642}
643
644static void bootstrap_exit(void)
645{
646 kfree(save_buffer);
647 sysdev_driver_unregister(&mioa701_sysclass, &driver_bootstrap);
648 sysdev_unregister(&sysdev_bootstrap);
649 sysdev_class_unregister(&mioa701_sysclass);
650
651 printk(KERN_CRIT "Unregistering mioa701 suspend will hang next"
652 "resume !!!\n");
653}
654
655/*
656 * Power Supply
657 */
658static char *supplicants[] = {
659 "mioa701_battery"
660};
661
662static void mioa701_set_charge(int flags)
663{
664 gpio_set_value(GPIO9_CHARGE_nEN, !flags);
665}
666
667static struct pda_power_pdata power_pdata = {
668 .is_ac_online = is_usb_connected,
669 .set_charge = mioa701_set_charge,
670 .supplied_to = supplicants,
671 .num_supplicants = ARRAY_SIZE(supplicants),
672};
673
674static struct resource power_resources[] = {
675 [0] = {
676 .name = "ac",
677 .start = gpio_to_irq(GPIO13_USB_DETECT),
678 .end = gpio_to_irq(GPIO13_USB_DETECT),
679 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
680 IORESOURCE_IRQ_LOWEDGE,
681 },
682};
683
684static struct platform_device power_dev = {
685 .name = "pda-power",
686 .id = -1,
687 .resource = power_resources,
688 .num_resources = ARRAY_SIZE(power_resources),
689 .dev = {
690 .platform_data = &power_pdata,
691 },
692};
693
694#if defined(CONFIG_PDA_POWER) && defined(CONFIG_TOUCHSCREEN_WM97XX)
695static struct wm97xx *battery_wm;
696
697static enum power_supply_property battery_props[] = {
698 POWER_SUPPLY_PROP_STATUS,
699 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
700 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
701 POWER_SUPPLY_PROP_VOLTAGE_NOW,
702 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, /* Necessary for apm */
703};
704
705static int get_battery_voltage(void)
706{
707 int adc = -1;
708
709 if (battery_wm)
710 adc = wm97xx_read_aux_adc(battery_wm, WM97XX_AUX_ID1);
711 return adc;
712}
713
714static int get_battery_status(struct power_supply *b)
715{
716 int status;
717
718 if (is_usb_connected())
719 status = POWER_SUPPLY_STATUS_CHARGING;
720 else
721 status = POWER_SUPPLY_STATUS_DISCHARGING;
722
723 return status;
724}
725
726static int get_property(struct power_supply *b,
727 enum power_supply_property psp,
728 union power_supply_propval *val)
729{
730 int rc = 0;
731
732 switch (psp) {
733 case POWER_SUPPLY_PROP_STATUS:
734 val->intval = get_battery_status(b);
735 break;
736 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
737 val->intval = 0xfd0;
738 break;
739 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
740 val->intval = 0xc00;
741 break;
742 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
743 val->intval = get_battery_voltage();
744 break;
745 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
746 val->intval = 100;
747 break;
748 default:
749 val->intval = -1;
750 rc = -1;
751 }
752
753 return rc;
754};
755
756static struct power_supply battery_ps = {
757 .name = "mioa701_battery",
758 .type = POWER_SUPPLY_TYPE_BATTERY,
759 .get_property = get_property,
760 .properties = battery_props,
761 .num_properties = ARRAY_SIZE(battery_props),
762};
763
764static int battery_probe(struct platform_device *pdev)
765{
766 struct wm97xx *wm = platform_get_drvdata(pdev);
767 int rc;
768
769 battery_wm = wm;
770
771 rc = power_supply_register(NULL, &battery_ps);
772 if (rc)
773 dev_err(&pdev->dev,
774 "Could not register mioa701 battery -> %d\n", rc);
775 return rc;
776}
777
778static int battery_remove(struct platform_device *pdev)
779{
780 battery_wm = NULL;
781 return 0;
782}
783
784static struct platform_driver mioa701_battery_driver = {
785 .driver = {
786 .name = "wm97xx-battery",
787 },
788 .probe = battery_probe,
789 .remove = battery_remove
790};
791
792static int __init mioa701_battery_init(void)
793{
794 int rc;
795
796 rc = platform_driver_register(&mioa701_battery_driver);
797 if (rc)
798 printk(KERN_ERR "Could not register mioa701 battery driver\n");
799 return rc;
800}
801
802#else
803static int __init mioa701_battery_init(void)
804{
805 return 0;
806}
807#endif
808
809/*
810 * Mio global
811 */
812
813/* Devices */
814#define MIO_PARENT_DEV(var, strname, tparent, pdata) \
815static struct platform_device var = { \
816 .name = strname, \
817 .id = -1, \
818 .dev = { \
819 .platform_data = pdata, \
820 .parent = tparent, \
821 }, \
822};
823#define MIO_SIMPLE_DEV(var, strname, pdata) \
824 MIO_PARENT_DEV(var, strname, NULL, pdata)
825
826MIO_SIMPLE_DEV(mioa701_gpio_keys, "gpio-keys", &mioa701_gpio_keys_data)
827MIO_PARENT_DEV(mioa701_backlight, "pwm-backlight", &pxa27x_device_pwm0.dev,
828 &mioa701_backlight_data);
829MIO_SIMPLE_DEV(mioa701_led, "leds-gpio", &gpio_led_info)
830MIO_SIMPLE_DEV(pxa2xx_pcm, "pxa2xx-pcm", NULL)
831MIO_SIMPLE_DEV(pxa2xx_ac97, "pxa2xx-ac97", NULL)
832MIO_PARENT_DEV(mio_wm9713_codec, "wm9713-codec", &pxa2xx_ac97.dev, NULL)
833MIO_SIMPLE_DEV(mioa701_sound, "mioa701-wm9713", NULL)
834MIO_SIMPLE_DEV(mioa701_board, "mioa701-board", NULL)
835
836static struct platform_device *devices[] __initdata = {
837 &mioa701_gpio_keys,
838 &mioa701_backlight,
839 &mioa701_led,
840 &pxa2xx_pcm,
841 &pxa2xx_ac97,
842 &mio_wm9713_codec,
843 &mioa701_sound,
844 &power_dev,
845 &strataflash,
846 &mioa701_board
847};
848
849static void mioa701_machine_exit(void);
850
851static void mioa701_poweroff(void)
852{
853 mioa701_machine_exit();
854 gpio_set_value(GPIO18_POWEROFF, 1);
855}
856
857static void mioa701_restart(char c)
858{
859 mioa701_machine_exit();
860 arm_machine_restart(c);
861}
862
863struct gpio_ress global_gpios[] = {
864 MIO_GPIO_OUT(GPIO9_CHARGE_nEN, 1, "Charger enable"),
865 MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"),
866 MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power")
867};
868
869static void __init mioa701_machine_init(void)
870{
871 PSLR = 0xff100000; /* SYSDEL=125ms, PWRDEL=125ms, PSLR_SL_ROD=1 */
872 PCFR = PCFR_DC_EN | PCFR_GPR_EN | PCFR_OPDE;
873 RTTR = 32768 - 1; /* Reset crazy WinCE value */
874 UP2OCR = UP2OCR_HXOE;
875
876 pxa2xx_mfp_config(ARRAY_AND_SIZE(mioa701_pin_config));
877 mio_gpio_request(ARRAY_AND_SIZE(global_gpios));
878 bootstrap_init();
879 set_pxa_fb_info(&mioa701_pxafb_info);
880 pxa_set_mci_info(&mioa701_mci_info);
881 pxa_set_keypad_info(&mioa701_keypad_info);
882 udc_init();
883 pm_power_off = mioa701_poweroff;
884 arm_pm_restart = mioa701_restart;
885 platform_add_devices(devices, ARRAY_SIZE(devices));
886 gsm_init();
887 mioa701_battery_init();
888}
889
890static void mioa701_machine_exit(void)
891{
892 udc_exit();
893 bootstrap_exit();
894 gsm_exit();
895}
896
897MACHINE_START(MIOA701, "MIO A701")
898 .phys_io = 0x40000000,
899 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
900 .boot_params = 0xa0000100,
901 .map_io = &pxa_map_io,
902 .init_irq = &pxa27x_init_irq,
903 .init_machine = mioa701_machine_init,
904 .timer = &pxa_timer,
905MACHINE_END
diff --git a/arch/arm/mach-pxa/mioa701_bootresume.S b/arch/arm/mach-pxa/mioa701_bootresume.S
new file mode 100644
index 000000000000..a647693d9856
--- /dev/null
+++ b/arch/arm/mach-pxa/mioa701_bootresume.S
@@ -0,0 +1,36 @@
1/* Bootloader to resume MIO A701
2 *
3 * 2007-1-12 Robert Jarzmik
4 *
5 * This code is licenced under the GPLv2.
6*/
7
8#include <linux/linkage.h>
9#include <asm/assembler.h>
10
11/*
12 * Note: Yes, part of the following code is located into the .data section.
13 * This is to allow jumpaddr to be accessed with a relative load
14 * while we can't rely on any MMU translation. We could have put
15 * sleep_save_sp in the .text section as well, but some setups might
16 * insist on it to be truly read-only.
17 */
18 .data
19ENTRY(mioa701_bootstrap)
200:
21 b 1f
22ENTRY(mioa701_jumpaddr)
23 .word 0x40f00008 @ PSPR in no-MMU mode
241:
25 mov r0, #0xa0000000 @ Don't suppose memory access works
26 orr r0, r0, #0x00200000 @ even if it's supposed to
27 mov r1, #0
28 str r1, [r0] @ Early disable resume for next boot
29 ldr r0, mioa701_jumpaddr @ (Murphy's Law)
30 ldr r0, [r0]
31 mov pc, r0
322:
33
34ENTRY(mioa701_bootstrap_lg)
35 .data
36 .word 2b-0b
diff --git a/arch/arm/mach-pxa/mp900.c b/arch/arm/mach-pxa/mp900.c
new file mode 100644
index 000000000000..8a73814126b1
--- /dev/null
+++ b/arch/arm/mach-pxa/mp900.c
@@ -0,0 +1,100 @@
1/*
2 * linux/arch/arm/mach-pxa/mp900.c
3 *
4 * Support for the NEC MobilePro900/C platform
5 *
6 * Based on mach-pxa/gumstix.c
7 *
8 * 2007, 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
9 * 2007, 2008 Michael Petchkovsky <mkpetch@internode.on.net>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/init.h>
17#include <linux/device.h>
18#include <linux/platform_device.h>
19#include <linux/types.h>
20#include <linux/usb/isp116x.h>
21
22#include <mach/hardware.h>
23#include <mach/pxa-regs.h>
24#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26#include "generic.h"
27
28static void isp116x_pfm_delay(struct device *dev, int delay)
29{
30
31 /* 400Mhz PXA2 = 2.5ns / instruction */
32
33 int cyc = delay / 10;
34
35 /* 4 Instructions = 4 x 2.5ns = 10ns */
36 __asm__ volatile ("0:\n"
37 "subs %0, %1, #1\n"
38 "bge 0b\n"
39 :"=r" (cyc)
40 :"0"(cyc)
41 );
42}
43
44static struct isp116x_platform_data isp116x_pfm_data = {
45 .remote_wakeup_enable = 1,
46 .delay = isp116x_pfm_delay,
47};
48
49static struct resource isp116x_pfm_resources[] = {
50 [0] = {
51 .start = 0x0d000000,
52 .end = 0x0d000000 + 1,
53 .flags = IORESOURCE_MEM,
54 },
55 [1] = {
56 .start = 0x0d000000 + 4,
57 .end = 0x0d000000 + 5,
58 .flags = IORESOURCE_MEM,
59 },
60 [2] = {
61 .start = 61,
62 .end = 61,
63 .flags = IORESOURCE_IRQ,
64 },
65};
66
67static struct platform_device mp900c_dummy_device = {
68 .name = "mp900c_dummy",
69 .id = -1,
70};
71
72static struct platform_device mp900c_usb = {
73 .name = "isp116x-hcd",
74 .num_resources = ARRAY_SIZE(isp116x_pfm_resources),
75 .resource = isp116x_pfm_resources,
76 .dev.platform_data = &isp116x_pfm_data,
77};
78
79static struct platform_device *devices[] __initdata = {
80 &mp900c_dummy_device,
81 &mp900c_usb,
82};
83
84static void __init mp900c_init(void)
85{
86 printk(KERN_INFO "MobilePro 900/C machine init\n");
87 platform_add_devices(devices, ARRAY_SIZE(devices));
88}
89
90/* Maintainer - Michael Petchkovsky <mkpetch@internode.on.net> */
91MACHINE_START(NEC_MP900, "MobilePro900/C")
92 .phys_io = 0x40000000,
93 .boot_params = 0xa0220100,
94 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
95 .timer = &pxa_timer,
96 .map_io = pxa_map_io,
97 .init_irq = pxa25x_init_irq,
98 .init_machine = mp900c_init,
99MACHINE_END
100
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index fe924a23debe..4447711c9fc6 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -25,6 +25,8 @@
25#include <linux/pda_power.h> 25#include <linux/pda_power.h>
26#include <linux/pwm_backlight.h> 26#include <linux/pwm_backlight.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/wm97xx_batt.h>
29#include <linux/power_supply.h>
28 30
29#include <asm/mach-types.h> 31#include <asm/mach-types.h>
30#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
@@ -340,6 +342,23 @@ static struct platform_device power_supply = {
340}; 342};
341 343
342/****************************************************************************** 344/******************************************************************************
345 * WM97xx battery
346 ******************************************************************************/
347static struct wm97xx_batt_info wm97xx_batt_pdata = {
348 .batt_aux = WM97XX_AUX_ID3,
349 .temp_aux = WM97XX_AUX_ID2,
350 .charge_gpio = -1,
351 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
352 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
353 .batt_mult = 1000,
354 .batt_div = 414,
355 .temp_mult = 1,
356 .temp_div = 1,
357 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
358 .batt_name = "main-batt",
359};
360
361/******************************************************************************
343 * Framebuffer 362 * Framebuffer
344 ******************************************************************************/ 363 ******************************************************************************/
345static struct pxafb_mode_info palmtx_lcd_modes[] = { 364static struct pxafb_mode_info palmtx_lcd_modes[] = {
@@ -401,6 +420,7 @@ static void __init palmtx_init(void)
401 pxa_set_ac97_info(NULL); 420 pxa_set_ac97_info(NULL);
402 pxa_set_ficp_info(&palmtx_ficp_platform_data); 421 pxa_set_ficp_info(&palmtx_ficp_platform_data);
403 pxa_set_keypad_info(&palmtx_keypad_platform_data); 422 pxa_set_keypad_info(&palmtx_keypad_platform_data);
423 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
404 424
405 platform_add_devices(devices, ARRAY_SIZE(devices)); 425 platform_add_devices(devices, ARRAY_SIZE(devices));
406} 426}
diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c
new file mode 100644
index 000000000000..2f730da3bba8
--- /dev/null
+++ b/arch/arm/mach-pxa/palmz72.c
@@ -0,0 +1,554 @@
1/*
2 * Hardware definitions for Palm Zire72
3 *
4 * Authors:
5 * Vladimir "Farcaller" Pouzanov <farcaller@gmail.com>
6 * Sergey Lapin <slapin@ossfans.org>
7 * Alex Osborne <bobofdoom@gmail.com>
8 * Jan Herman <2hp@seznam.cz>
9 *
10 * Rewrite for mainline:
11 * Marek Vasut <marek.vasut@gmail.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 *
17 * (find more info at www.hackndev.com)
18 *
19 */
20
21#include <linux/platform_device.h>
22#include <linux/sysdev.h>
23#include <linux/delay.h>
24#include <linux/irq.h>
25#include <linux/gpio_keys.h>
26#include <linux/input.h>
27#include <linux/pda_power.h>
28#include <linux/pwm_backlight.h>
29#include <linux/gpio.h>
30#include <linux/power_supply.h>
31
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35
36#include <mach/audio.h>
37#include <mach/palmz72.h>
38#include <mach/mmc.h>
39#include <mach/pxafb.h>
40#include <mach/pxa-regs.h>
41#include <mach/pxa2xx-regs.h>
42#include <mach/mfp-pxa27x.h>
43#include <mach/irda.h>
44#include <mach/pxa27x_keypad.h>
45#include <mach/udc.h>
46#include <mach/pm.h>
47
48#include "generic.h"
49#include "devices.h"
50
51/******************************************************************************
52 * Pin configuration
53 ******************************************************************************/
54static unsigned long palmz72_pin_config[] __initdata = {
55 /* MMC */
56 GPIO32_MMC_CLK,
57 GPIO92_MMC_DAT_0,
58 GPIO109_MMC_DAT_1,
59 GPIO110_MMC_DAT_2,
60 GPIO111_MMC_DAT_3,
61 GPIO112_MMC_CMD,
62 GPIO14_GPIO, /* SD detect */
63 GPIO115_GPIO, /* SD RO */
64 GPIO98_GPIO, /* SD power */
65
66 /* AC97 */
67 GPIO28_AC97_BITCLK,
68 GPIO29_AC97_SDATA_IN_0,
69 GPIO30_AC97_SDATA_OUT,
70 GPIO31_AC97_SYNC,
71
72 /* IrDA */
73 GPIO49_GPIO, /* ir disable */
74 GPIO46_FICP_RXD,
75 GPIO47_FICP_TXD,
76
77 /* PWM */
78 GPIO16_PWM0_OUT,
79
80 /* USB */
81 GPIO15_GPIO, /* usb detect */
82 GPIO12_GPIO, /* usb pullup */
83 GPIO95_GPIO, /* usb power */
84
85 /* Matrix keypad */
86 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
87 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
88 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
89 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
90 GPIO103_KP_MKOUT_0,
91 GPIO104_KP_MKOUT_1,
92 GPIO105_KP_MKOUT_2,
93
94 /* LCD */
95 GPIO58_LCD_LDD_0,
96 GPIO59_LCD_LDD_1,
97 GPIO60_LCD_LDD_2,
98 GPIO61_LCD_LDD_3,
99 GPIO62_LCD_LDD_4,
100 GPIO63_LCD_LDD_5,
101 GPIO64_LCD_LDD_6,
102 GPIO65_LCD_LDD_7,
103 GPIO66_LCD_LDD_8,
104 GPIO67_LCD_LDD_9,
105 GPIO68_LCD_LDD_10,
106 GPIO69_LCD_LDD_11,
107 GPIO70_LCD_LDD_12,
108 GPIO71_LCD_LDD_13,
109 GPIO72_LCD_LDD_14,
110 GPIO73_LCD_LDD_15,
111 GPIO74_LCD_FCLK,
112 GPIO75_LCD_LCLK,
113 GPIO76_LCD_PCLK,
114 GPIO77_LCD_BIAS,
115 GPIO20_GPIO, /* bl power */
116 GPIO21_GPIO, /* LCD border switch */
117 GPIO22_GPIO, /* LCD border color */
118 GPIO96_GPIO, /* lcd power */
119
120 /* Misc. */
121 GPIO0_GPIO | WAKEUP_ON_LEVEL_HIGH, /* power detect */
122 GPIO88_GPIO, /* green led */
123 GPIO27_GPIO, /* WM9712 IRQ */
124};
125
126/******************************************************************************
127 * SD/MMC card controller
128 ******************************************************************************/
129static int palmz72_mci_init(struct device *dev,
130 irq_handler_t palmz72_detect_int, void *data)
131{
132 int err = 0;
133
134 /* Setup an interrupt for detecting card insert/remove events */
135 err = gpio_request(GPIO_NR_PALMZ72_SD_DETECT_N, "SD IRQ");
136 if (err)
137 goto err;
138 err = gpio_direction_input(GPIO_NR_PALMZ72_SD_DETECT_N);
139 if (err)
140 goto err2;
141 err = request_irq(gpio_to_irq(GPIO_NR_PALMZ72_SD_DETECT_N),
142 palmz72_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
143 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
144 "SD/MMC card detect", data);
145 if (err) {
146 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
147 __func__);
148 goto err2;
149 }
150
151 /* SD_POWER is not actually power, but it is more like chip
152 * select, i.e. it is inverted */
153
154 err = gpio_request(GPIO_NR_PALMZ72_SD_POWER_N, "SD_POWER");
155 if (err)
156 goto err3;
157 err = gpio_direction_output(GPIO_NR_PALMZ72_SD_POWER_N, 0);
158 if (err)
159 goto err4;
160 err = gpio_request(GPIO_NR_PALMZ72_SD_RO, "SD_RO");
161 if (err)
162 goto err4;
163 err = gpio_direction_input(GPIO_NR_PALMZ72_SD_RO);
164 if (err)
165 goto err5;
166
167 printk(KERN_DEBUG "%s: irq registered\n", __func__);
168
169 return 0;
170
171err5:
172 gpio_free(GPIO_NR_PALMZ72_SD_RO);
173err4:
174 gpio_free(GPIO_NR_PALMZ72_SD_POWER_N);
175err3:
176 free_irq(gpio_to_irq(GPIO_NR_PALMZ72_SD_DETECT_N), data);
177err2:
178 gpio_free(GPIO_NR_PALMZ72_SD_DETECT_N);
179err:
180 return err;
181}
182
183static void palmz72_mci_exit(struct device *dev, void *data)
184{
185 gpio_free(GPIO_NR_PALMZ72_SD_POWER_N);
186 free_irq(gpio_to_irq(GPIO_NR_PALMZ72_SD_DETECT_N), data);
187 gpio_free(GPIO_NR_PALMZ72_SD_DETECT_N);
188 gpio_free(GPIO_NR_PALMZ72_SD_RO);
189}
190
191static void palmz72_mci_power(struct device *dev, unsigned int vdd)
192{
193 struct pxamci_platform_data *p_d = dev->platform_data;
194 if (p_d->ocr_mask & (1 << vdd))
195 gpio_set_value(GPIO_NR_PALMZ72_SD_POWER_N, 0);
196 else
197 gpio_set_value(GPIO_NR_PALMZ72_SD_POWER_N, 1);
198}
199
200static int palmz72_mci_ro(struct device *dev)
201{
202 return gpio_get_value(GPIO_NR_PALMZ72_SD_RO);
203}
204
205static struct pxamci_platform_data palmz72_mci_platform_data = {
206 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
207 .setpower = palmz72_mci_power,
208 .get_ro = palmz72_mci_ro,
209 .init = palmz72_mci_init,
210 .exit = palmz72_mci_exit,
211};
212
213/******************************************************************************
214 * GPIO keyboard
215 ******************************************************************************/
216static unsigned int palmz72_matrix_keys[] = {
217 KEY(0, 0, KEY_POWER),
218 KEY(0, 1, KEY_F1),
219 KEY(0, 2, KEY_ENTER),
220
221 KEY(1, 0, KEY_F2),
222 KEY(1, 1, KEY_F3),
223 KEY(1, 2, KEY_F4),
224
225 KEY(2, 0, KEY_UP),
226 KEY(2, 2, KEY_DOWN),
227
228 KEY(3, 0, KEY_RIGHT),
229 KEY(3, 2, KEY_LEFT),
230};
231
232static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data = {
233 .matrix_key_rows = 4,
234 .matrix_key_cols = 3,
235 .matrix_key_map = palmz72_matrix_keys,
236 .matrix_key_map_size = ARRAY_SIZE(palmz72_matrix_keys),
237
238 .debounce_interval = 30,
239};
240
241/******************************************************************************
242 * Backlight
243 ******************************************************************************/
244static int palmz72_backlight_init(struct device *dev)
245{
246 int ret;
247
248 ret = gpio_request(GPIO_NR_PALMZ72_BL_POWER, "BL POWER");
249 if (ret)
250 goto err;
251 ret = gpio_direction_output(GPIO_NR_PALMZ72_BL_POWER, 0);
252 if (ret)
253 goto err2;
254 ret = gpio_request(GPIO_NR_PALMZ72_LCD_POWER, "LCD POWER");
255 if (ret)
256 goto err2;
257 ret = gpio_direction_output(GPIO_NR_PALMZ72_LCD_POWER, 0);
258 if (ret)
259 goto err3;
260
261 return 0;
262err3:
263 gpio_free(GPIO_NR_PALMZ72_LCD_POWER);
264err2:
265 gpio_free(GPIO_NR_PALMZ72_BL_POWER);
266err:
267 return ret;
268}
269
270static int palmz72_backlight_notify(int brightness)
271{
272 gpio_set_value(GPIO_NR_PALMZ72_BL_POWER, brightness);
273 gpio_set_value(GPIO_NR_PALMZ72_LCD_POWER, brightness);
274 return brightness;
275}
276
277static void palmz72_backlight_exit(struct device *dev)
278{
279 gpio_free(GPIO_NR_PALMZ72_BL_POWER);
280 gpio_free(GPIO_NR_PALMZ72_LCD_POWER);
281}
282
283static struct platform_pwm_backlight_data palmz72_backlight_data = {
284 .pwm_id = 0,
285 .max_brightness = PALMZ72_MAX_INTENSITY,
286 .dft_brightness = PALMZ72_MAX_INTENSITY,
287 .pwm_period_ns = PALMZ72_PERIOD_NS,
288 .init = palmz72_backlight_init,
289 .notify = palmz72_backlight_notify,
290 .exit = palmz72_backlight_exit,
291};
292
293static struct platform_device palmz72_backlight = {
294 .name = "pwm-backlight",
295 .dev = {
296 .parent = &pxa27x_device_pwm0.dev,
297 .platform_data = &palmz72_backlight_data,
298 },
299};
300
301/******************************************************************************
302 * IrDA
303 ******************************************************************************/
304static int palmz72_irda_startup(struct device *dev)
305{
306 int err;
307 err = gpio_request(GPIO_NR_PALMZ72_IR_DISABLE, "IR DISABLE");
308 if (err)
309 goto err;
310 err = gpio_direction_output(GPIO_NR_PALMZ72_IR_DISABLE, 1);
311 if (err)
312 gpio_free(GPIO_NR_PALMZ72_IR_DISABLE);
313err:
314 return err;
315}
316
317static void palmz72_irda_shutdown(struct device *dev)
318{
319 gpio_free(GPIO_NR_PALMZ72_IR_DISABLE);
320}
321
322static void palmz72_irda_transceiver_mode(struct device *dev, int mode)
323{
324 gpio_set_value(GPIO_NR_PALMZ72_IR_DISABLE, mode & IR_OFF);
325 pxa2xx_transceiver_mode(dev, mode);
326}
327
328static struct pxaficp_platform_data palmz72_ficp_platform_data = {
329 .startup = palmz72_irda_startup,
330 .shutdown = palmz72_irda_shutdown,
331 .transceiver_cap = IR_SIRMODE | IR_OFF,
332 .transceiver_mode = palmz72_irda_transceiver_mode,
333};
334
335/******************************************************************************
336 * LEDs
337 ******************************************************************************/
338static struct gpio_led gpio_leds[] = {
339 {
340 .name = "palmz72:green:led",
341 .default_trigger = "none",
342 .gpio = GPIO_NR_PALMZ72_LED_GREEN,
343 },
344};
345
346static struct gpio_led_platform_data gpio_led_info = {
347 .leds = gpio_leds,
348 .num_leds = ARRAY_SIZE(gpio_leds),
349};
350
351static struct platform_device palmz72_leds = {
352 .name = "leds-gpio",
353 .id = -1,
354 .dev = {
355 .platform_data = &gpio_led_info,
356 }
357};
358
359/******************************************************************************
360 * Power supply
361 ******************************************************************************/
362static int power_supply_init(struct device *dev)
363{
364 int ret;
365
366 ret = gpio_request(GPIO_NR_PALMZ72_POWER_DETECT, "CABLE_STATE_AC");
367 if (ret)
368 goto err1;
369 ret = gpio_direction_input(GPIO_NR_PALMZ72_POWER_DETECT);
370 if (ret)
371 goto err2;
372
373 ret = gpio_request(GPIO_NR_PALMZ72_USB_DETECT_N, "CABLE_STATE_USB");
374 if (ret)
375 goto err2;
376 ret = gpio_direction_input(GPIO_NR_PALMZ72_USB_DETECT_N);
377 if (ret)
378 goto err3;
379
380 return 0;
381err3:
382 gpio_free(GPIO_NR_PALMZ72_USB_DETECT_N);
383err2:
384 gpio_free(GPIO_NR_PALMZ72_POWER_DETECT);
385err1:
386 return ret;
387}
388
389static int palmz72_is_ac_online(void)
390{
391 return gpio_get_value(GPIO_NR_PALMZ72_POWER_DETECT);
392}
393
394static int palmz72_is_usb_online(void)
395{
396 return !gpio_get_value(GPIO_NR_PALMZ72_USB_DETECT_N);
397}
398
399static void power_supply_exit(struct device *dev)
400{
401 gpio_free(GPIO_NR_PALMZ72_USB_DETECT_N);
402 gpio_free(GPIO_NR_PALMZ72_POWER_DETECT);
403}
404
405static char *palmz72_supplicants[] = {
406 "main-battery",
407};
408
409static struct pda_power_pdata power_supply_info = {
410 .init = power_supply_init,
411 .is_ac_online = palmz72_is_ac_online,
412 .is_usb_online = palmz72_is_usb_online,
413 .exit = power_supply_exit,
414 .supplied_to = palmz72_supplicants,
415 .num_supplicants = ARRAY_SIZE(palmz72_supplicants),
416};
417
418static struct platform_device power_supply = {
419 .name = "pda-power",
420 .id = -1,
421 .dev = {
422 .platform_data = &power_supply_info,
423 },
424};
425
426/******************************************************************************
427 * Framebuffer
428 ******************************************************************************/
429static struct pxafb_mode_info palmz72_lcd_modes[] = {
430{
431 .pixclock = 115384,
432 .xres = 320,
433 .yres = 320,
434 .bpp = 16,
435
436 .left_margin = 27,
437 .right_margin = 7,
438 .upper_margin = 7,
439 .lower_margin = 8,
440
441 .hsync_len = 6,
442 .vsync_len = 1,
443},
444};
445
446static struct pxafb_mach_info palmz72_lcd_screen = {
447 .modes = palmz72_lcd_modes,
448 .num_modes = ARRAY_SIZE(palmz72_lcd_modes),
449 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
450};
451
452#ifdef CONFIG_PM
453
454/* We have some black magic here
455 * PalmOS ROM on recover expects special struct physical address
456 * to be transferred via PSPR. Using this struct PalmOS restores
457 * its state after sleep. As for Linux, we need to setup it the
458 * same way. More than that, PalmOS ROM changes some values in memory.
459 * For now only one location is found, which needs special treatment.
460 * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
461 * for reading backtraces for me :)
462 */
463
464#define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
465
466static struct palmz72_resume_info palmz72_resume_info = {
467 .magic0 = 0xb4e6,
468 .magic1 = 1,
469
470 /* reset state, MMU off etc */
471 .arm_control = 0,
472 .aux_control = 0,
473 .ttb = 0,
474 .domain_access = 0,
475 .process_id = 0,
476};
477
478static unsigned long store_ptr;
479
480/* sys_device for Palm Zire 72 PM */
481
482static int palmz72_pm_suspend(struct sys_device *dev, pm_message_t msg)
483{
484 /* setup the resume_info struct for the original bootloader */
485 palmz72_resume_info.resume_addr = (u32) pxa_cpu_resume;
486
487 /* Storing memory touched by ROM */
488 store_ptr = *PALMZ72_SAVE_DWORD;
489
490 /* Setting PSPR to a proper value */
491 PSPR = virt_to_phys(&palmz72_resume_info);
492
493 return 0;
494}
495
496static int palmz72_pm_resume(struct sys_device *dev)
497{
498 *PALMZ72_SAVE_DWORD = store_ptr;
499 return 0;
500}
501
502static struct sysdev_class palmz72_pm_sysclass = {
503 .name = "palmz72_pm",
504 .suspend = palmz72_pm_suspend,
505 .resume = palmz72_pm_resume,
506};
507
508static struct sys_device palmz72_pm_device = {
509 .cls = &palmz72_pm_sysclass,
510};
511
512static int __init palmz72_pm_init(void)
513{
514 int ret = -ENODEV;
515 if (machine_is_palmz72()) {
516 ret = sysdev_class_register(&palmz72_pm_sysclass);
517 if (ret == 0)
518 ret = sysdev_register(&palmz72_pm_device);
519 }
520 return ret;
521}
522
523device_initcall(palmz72_pm_init);
524#endif
525
526/******************************************************************************
527 * Machine init
528 ******************************************************************************/
529static struct platform_device *devices[] __initdata = {
530 &palmz72_backlight,
531 &palmz72_leds,
532 &power_supply,
533};
534
535static void __init palmz72_init(void)
536{
537 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config));
538 set_pxa_fb_info(&palmz72_lcd_screen);
539 pxa_set_mci_info(&palmz72_mci_platform_data);
540 pxa_set_ac97_info(NULL);
541 pxa_set_ficp_info(&palmz72_ficp_platform_data);
542 pxa_set_keypad_info(&palmz72_keypad_platform_data);
543 platform_add_devices(devices, ARRAY_SIZE(devices));
544}
545
546MACHINE_START(PALMZ72, "Palm Zire72")
547 .phys_io = 0x40000000,
548 .io_pg_offst = io_p2v(0x40000000),
549 .boot_params = 0xa0000100,
550 .map_io = pxa_map_io,
551 .init_irq = pxa27x_init_irq,
552 .timer = &pxa_timer,
553 .init_machine = palmz72_init
554MACHINE_END
diff --git a/arch/arm/mach-pxa/pcm027.c b/arch/arm/mach-pxa/pcm027.c
index 730b9f6ede1d..36135a02fdc7 100644
--- a/arch/arm/mach-pxa/pcm027.c
+++ b/arch/arm/mach-pxa/pcm027.c
@@ -31,7 +31,7 @@
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32#include <mach/hardware.h> 32#include <mach/hardware.h>
33#include <mach/pxa-regs.h> 33#include <mach/pxa-regs.h>
34#include <mach/pxa2xx-gpio.h> 34#include <mach/mfp-pxa27x.h>
35#include <mach/pxa2xx-regs.h> 35#include <mach/pxa2xx-regs.h>
36#include <mach/pxa2xx_spi.h> 36#include <mach/pxa2xx_spi.h>
37#include <mach/pcm027.h> 37#include <mach/pcm027.h>
@@ -86,6 +86,28 @@
86 * *) CPU internal use only 86 * *) CPU internal use only
87 */ 87 */
88 88
89static unsigned long pcm027_pin_config[] __initdata = {
90 /* Chip Selects */
91 GPIO20_nSDCS_2,
92 GPIO21_nSDCS_3,
93 GPIO15_nCS_1,
94 GPIO78_nCS_2,
95 GPIO80_nCS_4,
96 GPIO33_nCS_5, /* Ethernet */
97
98 /* I2C */
99 GPIO117_I2C_SCL,
100 GPIO118_I2C_SDA,
101
102 /* GPIO */
103 GPIO52_GPIO, /* IRQ from network controller */
104#ifdef CONFIG_LEDS_GPIO
105 GPIO90_GPIO, /* PCM027_LED_CPU */
106 GPIO91_GPIO, /* PCM027_LED_HEART_BEAT */
107#endif
108 GPIO114_GPIO, /* IRQ from CAN controller */
109};
110
89/* 111/*
90 * SMC91x network controller specific stuff 112 * SMC91x network controller specific stuff
91 */ 113 */
@@ -206,13 +228,9 @@ static void __init pcm027_init(void)
206 */ 228 */
207 ARB_CNTRL = ARB_CORE_PARK | 0x234; 229 ARB_CNTRL = ARB_CORE_PARK | 0x234;
208 230
209 platform_add_devices(devices, ARRAY_SIZE(devices)); 231 pxa2xx_mfp_config(pcm027_pin_config, ARRAY_SIZE(pcm027_pin_config));
210 232
211 /* LEDs (on demand only) */ 233 platform_add_devices(devices, ARRAY_SIZE(devices));
212#ifdef CONFIG_LEDS_GPIO
213 pxa_gpio_mode(PCM027_LED_CPU | GPIO_OUT);
214 pxa_gpio_mode(PCM027_LED_HEARD_BEAT | GPIO_OUT);
215#endif /* CONFIG_LEDS_GPIO */
216 234
217 /* at last call the baseboard to initialize itself */ 235 /* at last call the baseboard to initialize itself */
218#ifdef CONFIG_MACH_PCM990_BASEBOARD 236#ifdef CONFIG_MACH_PCM990_BASEBOARD
diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index 420c9b3813f6..f601425f1b1e 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -262,8 +262,7 @@ static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
262 GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO); 262 GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO);
263 if (likely(pending)) { 263 if (likely(pending)) {
264 irq = PCM027_IRQ(0) + __ffs(pending); 264 irq = PCM027_IRQ(0) + __ffs(pending);
265 desc = irq_desc + irq; 265 generic_handle_irq(irq);
266 desc_handle_irq(irq, desc);
267 } 266 }
268 pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled; 267 pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
269 } while (pending); 268 } while (pending);
@@ -328,36 +327,10 @@ static struct pxamci_platform_data pcm990_mci_platform_data = {
328 .exit = pcm990_mci_exit, 327 .exit = pcm990_mci_exit,
329}; 328};
330 329
331/*
332 * init OHCI hardware to work with
333 *
334 * Note: Only USB port 1 (host only) is connected
335 *
336 * GPIO88 (USBHPWR#1): overcurrent in, overcurrent when low
337 * GPIO89 (USBHPEN#1): power-on out, on when low
338 */
339static int pcm990_ohci_init(struct device *dev)
340{
341 /*
342 * disable USB port 2 and 3
343 * power sense is active low
344 */
345 UHCHR = ((UHCHR) | UHCHR_PCPL | UHCHR_PSPL | UHCHR_SSEP2 |
346 UHCHR_SSEP3) & ~(UHCHR_SSEP1 | UHCHR_SSE);
347 /*
348 * wait 10ms after Power on
349 * overcurrent per port
350 * power switch per port
351 */
352 UHCRHDA = (5<<24) | (1<<11) | (1<<8); /* FIXME: Required? */
353
354 return 0;
355}
356
357static struct pxaohci_platform_data pcm990_ohci_platform_data = { 330static struct pxaohci_platform_data pcm990_ohci_platform_data = {
358 .port_mode = PMM_PERPORT_MODE, 331 .port_mode = PMM_PERPORT_MODE,
359 .init = pcm990_ohci_init, 332 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
360 .exit = NULL, 333 .power_on_delay = 10,
361}; 334};
362 335
363/* 336/*
diff --git a/arch/arm/mach-pxa/pm.c b/arch/arm/mach-pxa/pm.c
index 1b539e675579..164eb0bb6321 100644
--- a/arch/arm/mach-pxa/pm.c
+++ b/arch/arm/mach-pxa/pm.c
@@ -86,9 +86,27 @@ static int pxa_pm_valid(suspend_state_t state)
86 return -EINVAL; 86 return -EINVAL;
87} 87}
88 88
89static int pxa_pm_prepare(void)
90{
91 int ret = 0;
92
93 if (pxa_cpu_pm_fns && pxa_cpu_pm_fns->prepare)
94 ret = pxa_cpu_pm_fns->prepare();
95
96 return ret;
97}
98
99static void pxa_pm_finish(void)
100{
101 if (pxa_cpu_pm_fns && pxa_cpu_pm_fns->finish)
102 pxa_cpu_pm_fns->finish();
103}
104
89static struct platform_suspend_ops pxa_pm_ops = { 105static struct platform_suspend_ops pxa_pm_ops = {
90 .valid = pxa_pm_valid, 106 .valid = pxa_pm_valid,
91 .enter = pxa_pm_enter, 107 .enter = pxa_pm_enter,
108 .prepare = pxa_pm_prepare,
109 .finish = pxa_pm_finish,
92}; 110};
93 111
94static int __init pxa_pm_init(void) 112static int __init pxa_pm_init(void)
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 3f5f484549b3..2e3bd8b1523b 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -20,6 +20,9 @@
20#include <linux/fb.h> 20#include <linux/fb.h>
21#include <linux/pm.h> 21#include <linux/pm.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/gpio.h>
24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h>
23 26
24#include <mach/hardware.h> 27#include <mach/hardware.h>
25#include <asm/mach-types.h> 28#include <asm/mach-types.h>
@@ -33,7 +36,7 @@
33 36
34#include <mach/pxa-regs.h> 37#include <mach/pxa-regs.h>
35#include <mach/pxa2xx-regs.h> 38#include <mach/pxa2xx-regs.h>
36#include <mach/pxa2xx-gpio.h> 39#include <mach/mfp-pxa25x.h>
37#include <mach/mmc.h> 40#include <mach/mmc.h>
38#include <mach/udc.h> 41#include <mach/udc.h>
39#include <mach/i2c.h> 42#include <mach/i2c.h>
@@ -42,6 +45,7 @@
42#include <mach/pxafb.h> 45#include <mach/pxafb.h>
43#include <mach/sharpsl.h> 46#include <mach/sharpsl.h>
44#include <mach/ssp.h> 47#include <mach/ssp.h>
48#include <mach/pxa2xx_spi.h>
45 49
46#include <asm/hardware/scoop.h> 50#include <asm/hardware/scoop.h>
47#include <asm/hardware/locomo.h> 51#include <asm/hardware/locomo.h>
@@ -51,6 +55,88 @@
51#include "devices.h" 55#include "devices.h"
52#include "sharpsl.h" 56#include "sharpsl.h"
53 57
58static unsigned long poodle_pin_config[] __initdata = {
59 /* I/O */
60 GPIO79_nCS_3,
61 GPIO80_nCS_4,
62 GPIO18_RDY,
63
64 /* Clock */
65 GPIO12_32KHz,
66
67 /* SSP1 */
68 GPIO23_SSP1_SCLK,
69 GPIO25_SSP1_TXD,
70 GPIO26_SSP1_RXD,
71 GPIO24_GPIO, /* POODLE_GPIO_TP_CS - SFRM as chip select */
72
73 /* I2S */
74 GPIO28_I2S_BITCLK_OUT,
75 GPIO29_I2S_SDATA_IN,
76 GPIO30_I2S_SDATA_OUT,
77 GPIO31_I2S_SYNC,
78 GPIO32_I2S_SYSCLK,
79
80 /* Infra-Red */
81 GPIO47_FICP_TXD,
82 GPIO46_FICP_RXD,
83
84 /* FFUART */
85 GPIO40_FFUART_DTR,
86 GPIO41_FFUART_RTS,
87 GPIO39_FFUART_TXD,
88 GPIO37_FFUART_DSR,
89 GPIO34_FFUART_RXD,
90 GPIO35_FFUART_CTS,
91
92 /* LCD */
93 GPIO58_LCD_LDD_0,
94 GPIO59_LCD_LDD_1,
95 GPIO60_LCD_LDD_2,
96 GPIO61_LCD_LDD_3,
97 GPIO62_LCD_LDD_4,
98 GPIO63_LCD_LDD_5,
99 GPIO64_LCD_LDD_6,
100 GPIO65_LCD_LDD_7,
101 GPIO66_LCD_LDD_8,
102 GPIO67_LCD_LDD_9,
103 GPIO68_LCD_LDD_10,
104 GPIO69_LCD_LDD_11,
105 GPIO70_LCD_LDD_12,
106 GPIO71_LCD_LDD_13,
107 GPIO72_LCD_LDD_14,
108 GPIO73_LCD_LDD_15,
109 GPIO74_LCD_FCLK,
110 GPIO75_LCD_LCLK,
111 GPIO76_LCD_PCLK,
112 GPIO77_LCD_BIAS,
113
114 /* PC Card */
115 GPIO48_nPOE,
116 GPIO49_nPWE,
117 GPIO50_nPIOR,
118 GPIO51_nPIOW,
119 GPIO52_nPCE_1,
120 GPIO53_nPCE_2,
121 GPIO54_nPSKTSEL,
122 GPIO55_nPREG,
123 GPIO56_nPWAIT,
124 GPIO57_nIOIS16,
125
126 /* MMC */
127 GPIO6_MMC_CLK,
128 GPIO8_MMC_CS0,
129
130 /* GPIO */
131 GPIO9_GPIO, /* POODLE_GPIO_nSD_DETECT */
132 GPIO7_GPIO, /* POODLE_GPIO_nSD_WP */
133 GPIO3_GPIO, /* POODLE_GPIO_SD_PWR */
134 GPIO33_GPIO, /* POODLE_GPIO_SD_PWR1 */
135
136 GPIO20_GPIO, /* POODLE_GPIO_USB_PULLUP */
137 GPIO22_GPIO, /* POODLE_GPIO_IR_ON */
138};
139
54static struct resource poodle_scoop_resources[] = { 140static struct resource poodle_scoop_resources[] = {
55 [0] = { 141 [0] = {
56 .start = 0x10800000, 142 .start = 0x10800000,
@@ -62,6 +148,7 @@ static struct resource poodle_scoop_resources[] = {
62static struct scoop_config poodle_scoop_setup = { 148static struct scoop_config poodle_scoop_setup = {
63 .io_dir = POODLE_SCOOP_IO_DIR, 149 .io_dir = POODLE_SCOOP_IO_DIR,
64 .io_out = POODLE_SCOOP_IO_OUT, 150 .io_out = POODLE_SCOOP_IO_OUT,
151 .gpio_base = POODLE_SCOOP_GPIO_BASE,
65}; 152};
66 153
67struct platform_device poodle_scoop_device = { 154struct platform_device poodle_scoop_device = {
@@ -74,27 +161,6 @@ struct platform_device poodle_scoop_device = {
74 .resource = poodle_scoop_resources, 161 .resource = poodle_scoop_resources,
75}; 162};
76 163
77static void poodle_pcmcia_init(void)
78{
79 /* Setup default state of GPIO outputs
80 before we enable them as outputs. */
81 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
82 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
83 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
84 GPIO_bit(GPIO53_nPCE_2);
85
86 pxa_gpio_mode(GPIO48_nPOE_MD);
87 pxa_gpio_mode(GPIO49_nPWE_MD);
88 pxa_gpio_mode(GPIO50_nPIOR_MD);
89 pxa_gpio_mode(GPIO51_nPIOW_MD);
90 pxa_gpio_mode(GPIO55_nPREG_MD);
91 pxa_gpio_mode(GPIO56_nPWAIT_MD);
92 pxa_gpio_mode(GPIO57_nIOIS16_MD);
93 pxa_gpio_mode(GPIO52_nPCE_1_MD);
94 pxa_gpio_mode(GPIO53_nPCE_2_MD);
95 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
96}
97
98static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = { 164static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
99{ 165{
100 .dev = &poodle_scoop_device.dev, 166 .dev = &poodle_scoop_device.dev,
@@ -107,7 +173,6 @@ static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
107static struct scoop_pcmcia_config poodle_pcmcia_config = { 173static struct scoop_pcmcia_config poodle_pcmcia_config = {
108 .devs = &poodle_pcmcia_scoop[0], 174 .devs = &poodle_pcmcia_scoop[0],
109 .num_devs = 1, 175 .num_devs = 1,
110 .pcmcia_init = poodle_pcmcia_init,
111}; 176};
112 177
113EXPORT_SYMBOL(poodle_scoop_device); 178EXPORT_SYMBOL(poodle_scoop_device);
@@ -136,62 +201,55 @@ struct platform_device poodle_locomo_device = {
136 201
137EXPORT_SYMBOL(poodle_locomo_device); 202EXPORT_SYMBOL(poodle_locomo_device);
138 203
139/* 204#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
140 * Poodle SSP Device 205static struct pxa2xx_spi_master poodle_spi_info = {
141 */ 206 .num_chipselect = 1,
142
143struct platform_device poodle_ssp_device = {
144 .name = "corgi-ssp",
145 .id = -1,
146};
147
148struct corgissp_machinfo poodle_ssp_machinfo = {
149 .port = 1,
150 .cs_lcdcon = -1,
151 .cs_ads7846 = -1,
152 .cs_max1111 = -1,
153 .clk_lcdcon = 2,
154 .clk_ads7846 = 36,
155 .clk_max1111 = 2,
156}; 207};
157 208
158 209static struct ads7846_platform_data poodle_ads7846_info = {
159/* 210 .model = 7846,
160 * Poodle Touch Screen Device 211 .vref_delay_usecs = 100,
161 */ 212 .x_plate_ohms = 419,
162static struct resource poodlets_resources[] = { 213 .y_plate_ohms = 486,
163 [0] = { 214 .gpio_pendown = POODLE_GPIO_TP_INT,
164 .start = POODLE_IRQ_GPIO_TP_INT,
165 .end = POODLE_IRQ_GPIO_TP_INT,
166 .flags = IORESOURCE_IRQ,
167 },
168}; 215};
169 216
170static unsigned long poodle_get_hsync_invperiod(void) 217static void ads7846_cs(u32 command)
171{ 218{
172 return 0; 219 gpio_set_value(POODLE_GPIO_TP_CS, !(command == PXA2XX_CS_ASSERT));
173} 220}
174 221
175static void poodle_null_hsync(void) 222static struct pxa2xx_spi_chip poodle_ads7846_chip = {
176{ 223 .cs_control = ads7846_cs,
177}
178
179static struct corgits_machinfo poodle_ts_machinfo = {
180 .get_hsync_invperiod = poodle_get_hsync_invperiod,
181 .put_hsync = poodle_null_hsync,
182 .wait_hsync = poodle_null_hsync,
183}; 224};
184 225
185static struct platform_device poodle_ts_device = { 226static struct spi_board_info poodle_spi_devices[] = {
186 .name = "corgi-ts", 227 {
187 .dev = { 228 .modalias = "ads7846",
188 .platform_data = &poodle_ts_machinfo, 229 .max_speed_hz = 10000,
230 .bus_num = 1,
231 .platform_data = &poodle_ads7846_info,
232 .controller_data= &poodle_ads7846_chip,
233 .irq = gpio_to_irq(POODLE_GPIO_TP_INT),
189 }, 234 },
190 .id = -1,
191 .num_resources = ARRAY_SIZE(poodlets_resources),
192 .resource = poodlets_resources,
193}; 235};
194 236
237static void __init poodle_init_spi(void)
238{
239 int err;
240
241 err = gpio_request(POODLE_GPIO_TP_CS, "ADS7846_CS");
242 if (err)
243 return;
244
245 gpio_direction_output(POODLE_GPIO_TP_CS, 1);
246
247 pxa2xx_set_spi_info(1, &poodle_spi_info);
248 spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
249}
250#else
251static inline void poodle_init_spi(void) {}
252#endif
195 253
196/* 254/*
197 * MMC/SD Device 255 * MMC/SD Device
@@ -205,22 +263,50 @@ static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int,
205{ 263{
206 int err; 264 int err;
207 265
208 /* setup GPIO for PXA25x MMC controller */ 266 err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
209 pxa_gpio_mode(GPIO6_MMCCLK_MD); 267 if (err)
210 pxa_gpio_mode(GPIO8_MMCCS0_MD); 268 goto err_out;
211 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN); 269
212 pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN); 270 err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
213 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT); 271 if (err)
214 pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT); 272 goto err_free_1;
273
274 err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
275 if (err)
276 goto err_free_2;
277
278 err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
279 if (err)
280 goto err_free_3;
281
282 gpio_direction_input(POODLE_GPIO_nSD_DETECT);
283 gpio_direction_input(POODLE_GPIO_nSD_WP);
284
285 gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
286 gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
215 287
216 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250); 288 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
217 289
218 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int, 290 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
219 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 291 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
220 "MMC card detect", data); 292 "MMC card detect", data);
221 if (err) 293 if (err) {
222 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); 294 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
295 __func__);
296 goto err_free_4;
297 }
298
299 return 0;
223 300
301err_free_4:
302 gpio_free(POODLE_GPIO_SD_PWR1);
303err_free_3:
304 gpio_free(POODLE_GPIO_SD_PWR);
305err_free_2:
306 gpio_free(POODLE_GPIO_nSD_WP);
307err_free_1:
308 gpio_free(POODLE_GPIO_nSD_DETECT);
309err_out:
224 return err; 310 return err;
225} 311}
226 312
@@ -228,18 +314,19 @@ static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
228{ 314{
229 struct pxamci_platform_data* p_d = dev->platform_data; 315 struct pxamci_platform_data* p_d = dev->platform_data;
230 316
231 if (( 1 << vdd) & p_d->ocr_mask) { 317 if ((1 << vdd) & p_d->ocr_mask) {
232 GPSR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR); 318 gpio_set_value(POODLE_GPIO_SD_PWR, 1);
233 mdelay(2); 319 mdelay(2);
234 GPSR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1); 320 gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
235 } else { 321 } else {
236 GPCR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1); 322 gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
237 GPCR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR); 323 gpio_set_value(POODLE_GPIO_SD_PWR, 0);
238 } 324 }
239} 325}
240 326
241static int poodle_mci_get_ro(struct device *dev) 327static int poodle_mci_get_ro(struct device *dev)
242{ 328{
329 return !!gpio_get_value(POODLE_GPIO_nSD_WP);
243 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP); 330 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
244} 331}
245 332
@@ -247,6 +334,10 @@ static int poodle_mci_get_ro(struct device *dev)
247static void poodle_mci_exit(struct device *dev, void *data) 334static void poodle_mci_exit(struct device *dev, void *data)
248{ 335{
249 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data); 336 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
337 gpio_free(POODLE_GPIO_SD_PWR1);
338 gpio_free(POODLE_GPIO_SD_PWR);
339 gpio_free(POODLE_GPIO_nSD_WP);
340 gpio_free(POODLE_GPIO_nSD_DETECT);
250} 341}
251 342
252static struct pxamci_platform_data poodle_mci_platform_data = { 343static struct pxamci_platform_data poodle_mci_platform_data = {
@@ -263,38 +354,41 @@ static struct pxamci_platform_data poodle_mci_platform_data = {
263 */ 354 */
264static void poodle_irda_transceiver_mode(struct device *dev, int mode) 355static void poodle_irda_transceiver_mode(struct device *dev, int mode)
265{ 356{
266 if (mode & IR_OFF) { 357 gpio_set_value(POODLE_GPIO_IR_ON, mode & IR_OFF);
267 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
268 } else {
269 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
270 }
271 pxa2xx_transceiver_mode(dev, mode); 358 pxa2xx_transceiver_mode(dev, mode);
272} 359}
273 360
361static int poodle_irda_startup(struct device *dev)
362{
363 int err;
364
365 err = gpio_request(POODLE_GPIO_IR_ON, "IR_ON");
366 if (err)
367 return err;
368
369 gpio_direction_output(POODLE_GPIO_IR_ON, 1);
370 return 0;
371}
372
373static void poodle_irda_shutdown(struct device *dev)
374{
375 gpio_free(POODLE_GPIO_IR_ON);
376}
377
274static struct pxaficp_platform_data poodle_ficp_platform_data = { 378static struct pxaficp_platform_data poodle_ficp_platform_data = {
275 .transceiver_cap = IR_SIRMODE | IR_OFF, 379 .transceiver_cap = IR_SIRMODE | IR_OFF,
276 .transceiver_mode = poodle_irda_transceiver_mode, 380 .transceiver_mode = poodle_irda_transceiver_mode,
381 .startup = poodle_irda_startup,
382 .shutdown = poodle_irda_shutdown,
277}; 383};
278 384
279 385
280/* 386/*
281 * USB Device Controller 387 * USB Device Controller
282 */ 388 */
283static void poodle_udc_command(int cmd)
284{
285 switch(cmd) {
286 case PXA2XX_UDC_CMD_CONNECT:
287 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
288 break;
289 case PXA2XX_UDC_CMD_DISCONNECT:
290 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
291 break;
292 }
293}
294
295static struct pxa2xx_udc_mach_info udc_info __initdata = { 389static struct pxa2xx_udc_mach_info udc_info __initdata = {
296 /* no connect GPIO; poodle can't tell connection status */ 390 /* no connect GPIO; poodle can't tell connection status */
297 .udc_command = poodle_udc_command, 391 .gpio_pullup = POODLE_GPIO_USB_PULLUP,
298}; 392};
299 393
300 394
@@ -316,15 +410,12 @@ static struct pxafb_mode_info poodle_fb_mode = {
316static struct pxafb_mach_info poodle_fb_info = { 410static struct pxafb_mach_info poodle_fb_info = {
317 .modes = &poodle_fb_mode, 411 .modes = &poodle_fb_mode,
318 .num_modes = 1, 412 .num_modes = 1,
319 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color, 413 .lcd_conn = LCD_COLOR_TFT_16BPP,
320 .lccr3 = 0,
321}; 414};
322 415
323static struct platform_device *devices[] __initdata = { 416static struct platform_device *devices[] __initdata = {
324 &poodle_locomo_device, 417 &poodle_locomo_device,
325 &poodle_scoop_device, 418 &poodle_scoop_device,
326 &poodle_ssp_device,
327 &poodle_ts_device,
328}; 419};
329 420
330static void poodle_poweroff(void) 421static void poodle_poweroff(void)
@@ -344,59 +435,23 @@ static void __init poodle_init(void)
344 pm_power_off = poodle_poweroff; 435 pm_power_off = poodle_poweroff;
345 arm_pm_restart = poodle_restart; 436 arm_pm_restart = poodle_restart;
346 437
347 /* setup sleep mode values */
348 PWER = 0x00000002;
349 PFER = 0x00000000;
350 PRER = 0x00000002;
351 PGSR0 = 0x00008000;
352 PGSR1 = 0x003F0202;
353 PGSR2 = 0x0001C000;
354 PCFR |= PCFR_OPDE; 438 PCFR |= PCFR_OPDE;
355 439
356 /* cpu initialize */ 440 pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
357 /* Pgsr Register */ 441
358 PGSR0 = 0x0146dd80; 442 platform_scoop_config = &poodle_pcmcia_config;
359 PGSR1 = 0x03bf0890; 443
360 PGSR2 = 0x0001c000; 444 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
361 445 if (ret)
362 /* Alternate Register */ 446 pr_warning("poodle: Unable to register LoCoMo device\n");
363 GAFR0_L = 0x01001000;
364 GAFR0_U = 0x591a8010;
365 GAFR1_L = 0x900a8451;
366 GAFR1_U = 0xaaa5aaaa;
367 GAFR2_L = 0x8aaaaaaa;
368 GAFR2_U = 0x00000002;
369
370 /* Direction Register */
371 GPDR0 = 0xd3f0904c;
372 GPDR1 = 0xfcffb7d3;
373 GPDR2 = 0x0001ffff;
374
375 /* Output Register */
376 GPCR0 = 0x00000000;
377 GPCR1 = 0x00000000;
378 GPCR2 = 0x00000000;
379
380 GPSR0 = 0x00400000;
381 GPSR1 = 0x00000000;
382 GPSR2 = 0x00000000;
383 447
384 set_pxa_fb_parent(&poodle_locomo_device.dev); 448 set_pxa_fb_parent(&poodle_locomo_device.dev);
385 set_pxa_fb_info(&poodle_fb_info); 449 set_pxa_fb_info(&poodle_fb_info);
386 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
387 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
388 pxa_set_udc_info(&udc_info); 450 pxa_set_udc_info(&udc_info);
389 pxa_set_mci_info(&poodle_mci_platform_data); 451 pxa_set_mci_info(&poodle_mci_platform_data);
390 pxa_set_ficp_info(&poodle_ficp_platform_data); 452 pxa_set_ficp_info(&poodle_ficp_platform_data);
391 pxa_set_i2c_info(NULL); 453 pxa_set_i2c_info(NULL);
392 454 poodle_init_spi();
393 platform_scoop_config = &poodle_pcmcia_config;
394
395 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
396 if (ret) {
397 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
398 }
399 corgi_ssp_set_machinfo(&poodle_ssp_machinfo);
400} 455}
401 456
402static void __init fixup_poodle(struct machine_desc *desc, 457static void __init fixup_poodle(struct machine_desc *desc,
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index 305452b56e91..25d17a1dab78 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -36,6 +36,12 @@
36#include "devices.h" 36#include "devices.h"
37#include "clock.h" 37#include "clock.h"
38 38
39int cpu_is_pxa26x(void)
40{
41 return cpu_is_pxa250() && ((BOOT_DEF & 0x8) == 0);
42}
43EXPORT_SYMBOL_GPL(cpu_is_pxa26x);
44
39/* 45/*
40 * Various clock factors driven by the CCCR register. 46 * Various clock factors driven by the CCCR register.
41 */ 47 */
@@ -203,48 +209,21 @@ static struct clk pxa25x_clks[] = {
203 * More ones like CP and general purpose register values are preserved 209 * More ones like CP and general purpose register values are preserved
204 * with the stack pointer in sleep.S. 210 * with the stack pointer in sleep.S.
205 */ 211 */
206enum { SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, 212enum {
207
208 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
209 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
210 SLEEP_SAVE_GAFR2_L, SLEEP_SAVE_GAFR2_U,
211
212 SLEEP_SAVE_PSTR, 213 SLEEP_SAVE_PSTR,
213
214 SLEEP_SAVE_CKEN, 214 SLEEP_SAVE_CKEN,
215
216 SLEEP_SAVE_COUNT 215 SLEEP_SAVE_COUNT
217}; 216};
218 217
219 218
220static void pxa25x_cpu_pm_save(unsigned long *sleep_save) 219static void pxa25x_cpu_pm_save(unsigned long *sleep_save)
221{ 220{
222 SAVE(PGSR0); SAVE(PGSR1); SAVE(PGSR2);
223
224 SAVE(GAFR0_L); SAVE(GAFR0_U);
225 SAVE(GAFR1_L); SAVE(GAFR1_U);
226 SAVE(GAFR2_L); SAVE(GAFR2_U);
227
228 SAVE(CKEN); 221 SAVE(CKEN);
229 SAVE(PSTR); 222 SAVE(PSTR);
230
231 /* Clear GPIO transition detect bits */
232 GEDR0 = GEDR0; GEDR1 = GEDR1; GEDR2 = GEDR2;
233} 223}
234 224
235static void pxa25x_cpu_pm_restore(unsigned long *sleep_save) 225static void pxa25x_cpu_pm_restore(unsigned long *sleep_save)
236{ 226{
237 /* ensure not to come back here if it wasn't intended */
238 PSPR = 0;
239
240 /* restore registers */
241 RESTORE(GAFR0_L); RESTORE(GAFR0_U);
242 RESTORE(GAFR1_L); RESTORE(GAFR1_U);
243 RESTORE(GAFR2_L); RESTORE(GAFR2_U);
244 RESTORE(PGSR0); RESTORE(PGSR1); RESTORE(PGSR2);
245
246 PSSR = PSSR_RDH | PSSR_PH;
247
248 RESTORE(CKEN); 227 RESTORE(CKEN);
249 RESTORE(PSTR); 228 RESTORE(PSTR);
250} 229}
@@ -256,19 +235,32 @@ static void pxa25x_cpu_pm_enter(suspend_state_t state)
256 235
257 switch (state) { 236 switch (state) {
258 case PM_SUSPEND_MEM: 237 case PM_SUSPEND_MEM:
259 /* set resume return address */
260 PSPR = virt_to_phys(pxa_cpu_resume);
261 pxa25x_cpu_suspend(PWRMODE_SLEEP); 238 pxa25x_cpu_suspend(PWRMODE_SLEEP);
262 break; 239 break;
263 } 240 }
264} 241}
265 242
243static int pxa25x_cpu_pm_prepare(void)
244{
245 /* set resume return address */
246 PSPR = virt_to_phys(pxa_cpu_resume);
247 return 0;
248}
249
250static void pxa25x_cpu_pm_finish(void)
251{
252 /* ensure not to come back here if it wasn't intended */
253 PSPR = 0;
254}
255
266static struct pxa_cpu_pm_fns pxa25x_cpu_pm_fns = { 256static struct pxa_cpu_pm_fns pxa25x_cpu_pm_fns = {
267 .save_count = SLEEP_SAVE_COUNT, 257 .save_count = SLEEP_SAVE_COUNT,
268 .valid = suspend_valid_only_mem, 258 .valid = suspend_valid_only_mem,
269 .save = pxa25x_cpu_pm_save, 259 .save = pxa25x_cpu_pm_save,
270 .restore = pxa25x_cpu_pm_restore, 260 .restore = pxa25x_cpu_pm_restore,
271 .enter = pxa25x_cpu_pm_enter, 261 .enter = pxa25x_cpu_pm_enter,
262 .prepare = pxa25x_cpu_pm_prepare,
263 .finish = pxa25x_cpu_pm_finish,
272}; 264};
273 265
274static void __init pxa25x_init_pm(void) 266static void __init pxa25x_init_pm(void)
@@ -330,6 +322,8 @@ static struct sys_device pxa25x_sysdev[] = {
330 { 322 {
331 .cls = &pxa_irq_sysclass, 323 .cls = &pxa_irq_sysclass,
332 }, { 324 }, {
325 .cls = &pxa2xx_mfp_sysclass,
326 }, {
333 .cls = &pxa_gpio_sysclass, 327 .cls = &pxa_gpio_sysclass,
334 }, 328 },
335}; 329};
@@ -338,11 +332,7 @@ static int __init pxa25x_init(void)
338{ 332{
339 int i, ret = 0; 333 int i, ret = 0;
340 334
341 /* Only add HWUART for PXA255/26x; PXA210/250/27x do not have it. */ 335 if (cpu_is_pxa25x()) {
342 if (cpu_is_pxa255())
343 clks_register(&pxa25x_hwuart_clk, 1);
344
345 if (cpu_is_pxa21x() || cpu_is_pxa25x()) {
346 336
347 reset_status = RCSR; 337 reset_status = RCSR;
348 338
@@ -365,9 +355,11 @@ static int __init pxa25x_init(void)
365 return ret; 355 return ret;
366 } 356 }
367 357
368 /* Only add HWUART for PXA255/26x; PXA210/250/27x do not have it. */ 358 /* Only add HWUART for PXA255/26x; PXA210/250 do not have it. */
369 if (cpu_is_pxa255()) 359 if (cpu_is_pxa255() || cpu_is_pxa26x()) {
360 clks_register(&pxa25x_hwuart_clk, 1);
370 ret = platform_device_register(&pxa_device_hwuart); 361 ret = platform_device_register(&pxa_device_hwuart);
362 }
371 363
372 return ret; 364 return ret;
373} 365}
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index f9f6a9c31f4b..3e4ab2279c99 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -34,6 +34,13 @@
34#include "devices.h" 34#include "devices.h"
35#include "clock.h" 35#include "clock.h"
36 36
37void pxa27x_clear_otgph(void)
38{
39 if (cpu_is_pxa27x() && (PSSR & PSSR_OTGPH))
40 PSSR |= PSSR_OTGPH;
41}
42EXPORT_SYMBOL(pxa27x_clear_otgph);
43
37/* Crystal clock: 13MHz */ 44/* Crystal clock: 13MHz */
38#define BASE_CLK 13000000 45#define BASE_CLK 13000000
39 46
@@ -183,36 +190,18 @@ static struct clk pxa27x_clks[] = {
183 * More ones like CP and general purpose register values are preserved 190 * More ones like CP and general purpose register values are preserved
184 * with the stack pointer in sleep.S. 191 * with the stack pointer in sleep.S.
185 */ 192 */
186enum { SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3, 193enum {
187
188 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
189 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
190 SLEEP_SAVE_GAFR2_L, SLEEP_SAVE_GAFR2_U,
191 SLEEP_SAVE_GAFR3_L, SLEEP_SAVE_GAFR3_U,
192
193 SLEEP_SAVE_PSTR, 194 SLEEP_SAVE_PSTR,
194
195 SLEEP_SAVE_CKEN, 195 SLEEP_SAVE_CKEN,
196
197 SLEEP_SAVE_MDREFR, 196 SLEEP_SAVE_MDREFR,
198 SLEEP_SAVE_PWER, SLEEP_SAVE_PCFR, SLEEP_SAVE_PRER, 197 SLEEP_SAVE_PCFR,
199 SLEEP_SAVE_PFER, SLEEP_SAVE_PKWR,
200
201 SLEEP_SAVE_COUNT 198 SLEEP_SAVE_COUNT
202}; 199};
203 200
204void pxa27x_cpu_pm_save(unsigned long *sleep_save) 201void pxa27x_cpu_pm_save(unsigned long *sleep_save)
205{ 202{
206 SAVE(PGSR0); SAVE(PGSR1); SAVE(PGSR2); SAVE(PGSR3);
207
208 SAVE(GAFR0_L); SAVE(GAFR0_U);
209 SAVE(GAFR1_L); SAVE(GAFR1_U);
210 SAVE(GAFR2_L); SAVE(GAFR2_U);
211 SAVE(GAFR3_L); SAVE(GAFR3_U);
212
213 SAVE(MDREFR); 203 SAVE(MDREFR);
214 SAVE(PWER); SAVE(PCFR); SAVE(PRER); 204 SAVE(PCFR);
215 SAVE(PFER); SAVE(PKWR);
216 205
217 SAVE(CKEN); 206 SAVE(CKEN);
218 SAVE(PSTR); 207 SAVE(PSTR);
@@ -220,24 +209,12 @@ void pxa27x_cpu_pm_save(unsigned long *sleep_save)
220 209
221void pxa27x_cpu_pm_restore(unsigned long *sleep_save) 210void pxa27x_cpu_pm_restore(unsigned long *sleep_save)
222{ 211{
223 /* ensure not to come back here if it wasn't intended */
224 PSPR = 0;
225
226 /* restore registers */
227 RESTORE(GAFR0_L); RESTORE(GAFR0_U);
228 RESTORE(GAFR1_L); RESTORE(GAFR1_U);
229 RESTORE(GAFR2_L); RESTORE(GAFR2_U);
230 RESTORE(GAFR3_L); RESTORE(GAFR3_U);
231 RESTORE(PGSR0); RESTORE(PGSR1); RESTORE(PGSR2); RESTORE(PGSR3);
232
233 RESTORE(MDREFR); 212 RESTORE(MDREFR);
234 RESTORE(PWER); RESTORE(PCFR); RESTORE(PRER); 213 RESTORE(PCFR);
235 RESTORE(PFER); RESTORE(PKWR);
236 214
237 PSSR = PSSR_RDH | PSSR_PH; 215 PSSR = PSSR_RDH | PSSR_PH;
238 216
239 RESTORE(CKEN); 217 RESTORE(CKEN);
240
241 RESTORE(PSTR); 218 RESTORE(PSTR);
242} 219}
243 220
@@ -259,8 +236,6 @@ void pxa27x_cpu_pm_enter(suspend_state_t state)
259 pxa_cpu_standby(); 236 pxa_cpu_standby();
260 break; 237 break;
261 case PM_SUSPEND_MEM: 238 case PM_SUSPEND_MEM:
262 /* set resume return address */
263 PSPR = virt_to_phys(pxa_cpu_resume);
264 pxa27x_cpu_suspend(PWRMODE_SLEEP); 239 pxa27x_cpu_suspend(PWRMODE_SLEEP);
265 break; 240 break;
266 } 241 }
@@ -271,12 +246,27 @@ static int pxa27x_cpu_pm_valid(suspend_state_t state)
271 return state == PM_SUSPEND_MEM || state == PM_SUSPEND_STANDBY; 246 return state == PM_SUSPEND_MEM || state == PM_SUSPEND_STANDBY;
272} 247}
273 248
249static int pxa27x_cpu_pm_prepare(void)
250{
251 /* set resume return address */
252 PSPR = virt_to_phys(pxa_cpu_resume);
253 return 0;
254}
255
256static void pxa27x_cpu_pm_finish(void)
257{
258 /* ensure not to come back here if it wasn't intended */
259 PSPR = 0;
260}
261
274static struct pxa_cpu_pm_fns pxa27x_cpu_pm_fns = { 262static struct pxa_cpu_pm_fns pxa27x_cpu_pm_fns = {
275 .save_count = SLEEP_SAVE_COUNT, 263 .save_count = SLEEP_SAVE_COUNT,
276 .save = pxa27x_cpu_pm_save, 264 .save = pxa27x_cpu_pm_save,
277 .restore = pxa27x_cpu_pm_restore, 265 .restore = pxa27x_cpu_pm_restore,
278 .valid = pxa27x_cpu_pm_valid, 266 .valid = pxa27x_cpu_pm_valid,
279 .enter = pxa27x_cpu_pm_enter, 267 .enter = pxa27x_cpu_pm_enter,
268 .prepare = pxa27x_cpu_pm_prepare,
269 .finish = pxa27x_cpu_pm_finish,
280}; 270};
281 271
282static void __init pxa27x_init_pm(void) 272static void __init pxa27x_init_pm(void)
@@ -349,7 +339,7 @@ struct platform_device pxa27x_device_i2c_power = {
349 .num_resources = ARRAY_SIZE(i2c_power_resources), 339 .num_resources = ARRAY_SIZE(i2c_power_resources),
350}; 340};
351 341
352void __init pxa_set_i2c_power_info(struct i2c_pxa_platform_data *info) 342void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info)
353{ 343{
354 local_irq_disable(); 344 local_irq_disable();
355 PCFR |= PCFR_PI2CEN; 345 PCFR |= PCFR_PI2CEN;
@@ -376,6 +366,8 @@ static struct sys_device pxa27x_sysdev[] = {
376 { 366 {
377 .cls = &pxa_irq_sysclass, 367 .cls = &pxa_irq_sysclass,
378 }, { 368 }, {
369 .cls = &pxa2xx_mfp_sysclass,
370 }, {
379 .cls = &pxa_gpio_sysclass, 371 .cls = &pxa_gpio_sysclass,
380 }, 372 },
381}; 373};
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index 03cbc38103ed..b3cd5d0b0f35 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -203,6 +203,19 @@ static const struct clkops clk_pout_ops = {
203 .disable = clk_pout_disable, 203 .disable = clk_pout_disable,
204}; 204};
205 205
206static void clk_dummy_enable(struct clk *clk)
207{
208}
209
210static void clk_dummy_disable(struct clk *clk)
211{
212}
213
214static const struct clkops clk_dummy_ops = {
215 .enable = clk_dummy_enable,
216 .disable = clk_dummy_disable,
217};
218
206static struct clk pxa3xx_clks[] = { 219static struct clk pxa3xx_clks[] = {
207 { 220 {
208 .name = "CLK_POUT", 221 .name = "CLK_POUT",
@@ -211,6 +224,13 @@ static struct clk pxa3xx_clks[] = {
211 .delay = 70, 224 .delay = 70,
212 }, 225 },
213 226
227 /* Power I2C clock is always on */
228 {
229 .name = "I2CCLK",
230 .ops = &clk_dummy_ops,
231 .dev = &pxa3xx_device_i2c_power.dev,
232 },
233
214 PXA3xx_CK("LCDCLK", LCD, &clk_pxa3xx_hsio_ops, &pxa_device_fb.dev), 234 PXA3xx_CK("LCDCLK", LCD, &clk_pxa3xx_hsio_ops, &pxa_device_fb.dev),
215 PXA3xx_CK("CAMCLK", CAMERA, &clk_pxa3xx_hsio_ops, NULL), 235 PXA3xx_CK("CAMCLK", CAMERA, &clk_pxa3xx_hsio_ops, NULL),
216 PXA3xx_CK("AC97CLK", AC97, &clk_pxa3xx_ac97_ops, NULL), 236 PXA3xx_CK("AC97CLK", AC97, &clk_pxa3xx_ac97_ops, NULL),
@@ -509,6 +529,30 @@ void __init pxa3xx_init_irq(void)
509 * device registration specific to PXA3xx. 529 * device registration specific to PXA3xx.
510 */ 530 */
511 531
532static struct resource i2c_power_resources[] = {
533 {
534 .start = 0x40f500c0,
535 .end = 0x40f500d3,
536 .flags = IORESOURCE_MEM,
537 }, {
538 .start = IRQ_PWRI2C,
539 .end = IRQ_PWRI2C,
540 .flags = IORESOURCE_IRQ,
541 },
542};
543
544struct platform_device pxa3xx_device_i2c_power = {
545 .name = "pxa2xx-i2c",
546 .id = 1,
547 .resource = i2c_power_resources,
548 .num_resources = ARRAY_SIZE(i2c_power_resources),
549};
550
551void __init pxa3xx_set_i2c_power_info(struct i2c_pxa_platform_data *info)
552{
553 pxa3xx_device_i2c_power.dev.platform_data = info;
554}
555
512static struct platform_device *devices[] __initdata = { 556static struct platform_device *devices[] __initdata = {
513/* &pxa_device_udc, The UDC driver is PXA25x only */ 557/* &pxa_device_udc, The UDC driver is PXA25x only */
514 &pxa_device_ffuart, 558 &pxa_device_ffuart,
@@ -522,6 +566,7 @@ static struct platform_device *devices[] __initdata = {
522 &pxa3xx_device_ssp4, 566 &pxa3xx_device_ssp4,
523 &pxa27x_device_pwm0, 567 &pxa27x_device_pwm0,
524 &pxa27x_device_pwm1, 568 &pxa27x_device_pwm1,
569 &pxa3xx_device_i2c_power,
525}; 570};
526 571
527static struct sys_device pxa3xx_sysdev[] = { 572static struct sys_device pxa3xx_sysdev[] = {
diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c
index 9996c612c3d6..1b2af575c40f 100644
--- a/arch/arm/mach-pxa/reset.c
+++ b/arch/arm/mach-pxa/reset.c
@@ -7,7 +7,7 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/delay.h> 8#include <linux/delay.h>
9#include <linux/gpio.h> 9#include <linux/gpio.h>
10#include <asm/io.h> 10#include <linux/io.h>
11#include <asm/proc-fns.h> 11#include <asm/proc-fns.h>
12 12
13#include <mach/pxa-regs.h> 13#include <mach/pxa-regs.h>
@@ -20,7 +20,7 @@ static void do_hw_reset(void);
20 20
21static int reset_gpio = -1; 21static int reset_gpio = -1;
22 22
23int init_gpio_reset(int gpio) 23int init_gpio_reset(int gpio, int output)
24{ 24{
25 int rc; 25 int rc;
26 26
@@ -30,9 +30,12 @@ int init_gpio_reset(int gpio)
30 goto out; 30 goto out;
31 } 31 }
32 32
33 rc = gpio_direction_input(gpio); 33 if (output)
34 rc = gpio_direction_output(gpio, 0);
35 else
36 rc = gpio_direction_input(gpio);
34 if (rc) { 37 if (rc) {
35 printk(KERN_ERR "Can't configure reset_gpio for input\n"); 38 printk(KERN_ERR "Can't configure reset_gpio\n");
36 gpio_free(gpio); 39 gpio_free(gpio);
37 goto out; 40 goto out;
38 } 41 }
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index e804ae09370c..15c2f1a8623b 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -116,24 +116,20 @@ struct battery_thresh spitz_battery_levels_noac[] = {
116 { 0, 0}, 116 { 0, 0},
117}; 117};
118 118
119/* MAX1111 Commands */
120#define MAXCTRL_PD0 1u << 0
121#define MAXCTRL_PD1 1u << 1
122#define MAXCTRL_SGL 1u << 2
123#define MAXCTRL_UNI 1u << 3
124#define MAXCTRL_SEL_SH 4
125#define MAXCTRL_STR 1u << 7
126
127/* 119/*
128 * Read MAX1111 ADC 120 * Read MAX1111 ADC
129 */ 121 */
122extern int max1111_read_channel(int);
123
130int sharpsl_pm_pxa_read_max1111(int channel) 124int sharpsl_pm_pxa_read_max1111(int channel)
131{ 125{
132 if (machine_is_tosa()) // Ugly, better move this function into another module 126 if (machine_is_tosa()) // Ugly, better move this function into another module
133 return 0; 127 return 0;
134 128
135 return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1 129 /* max1111 accepts channels from 0-3, however,
136 | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR); 130 * it is encoded from 0-7 here in the code.
131 */
132 return max1111_read_channel(channel >> 1);
137} 133}
138 134
139void sharpsl_pm_pxa_init(void) 135void sharpsl_pm_pxa_init(void)
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index b569f3b4cf3a..524f656dc56d 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -19,16 +19,23 @@
19#include <linux/major.h> 19#include <linux/major.h>
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/gpio.h>
23#include <linux/leds.h>
22#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
23#include <linux/pm.h> 25#include <linux/pm.h>
24#include <linux/backlight.h> 26#include <linux/backlight.h>
27#include <linux/io.h>
28#include <linux/i2c.h>
29#include <linux/i2c/pca953x.h>
30#include <linux/spi/spi.h>
31#include <linux/spi/ads7846.h>
32#include <linux/spi/corgi_lcd.h>
25 33
26#include <asm/setup.h> 34#include <asm/setup.h>
27#include <asm/memory.h> 35#include <asm/memory.h>
28#include <asm/mach-types.h> 36#include <asm/mach-types.h>
29#include <mach/hardware.h> 37#include <mach/hardware.h>
30#include <asm/irq.h> 38#include <asm/irq.h>
31#include <asm/io.h>
32#include <asm/system.h> 39#include <asm/system.h>
33 40
34#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
@@ -37,7 +44,7 @@
37 44
38#include <mach/pxa-regs.h> 45#include <mach/pxa-regs.h>
39#include <mach/pxa2xx-regs.h> 46#include <mach/pxa2xx-regs.h>
40#include <mach/pxa2xx-gpio.h> 47#include <mach/mfp-pxa27x.h>
41#include <mach/pxa27x-udc.h> 48#include <mach/pxa27x-udc.h>
42#include <mach/reset.h> 49#include <mach/reset.h>
43#include <mach/i2c.h> 50#include <mach/i2c.h>
@@ -46,7 +53,7 @@
46#include <mach/ohci.h> 53#include <mach/ohci.h>
47#include <mach/udc.h> 54#include <mach/udc.h>
48#include <mach/pxafb.h> 55#include <mach/pxafb.h>
49#include <mach/akita.h> 56#include <mach/pxa2xx_spi.h>
50#include <mach/spitz.h> 57#include <mach/spitz.h>
51#include <mach/sharpsl.h> 58#include <mach/sharpsl.h>
52 59
@@ -57,6 +64,66 @@
57#include "devices.h" 64#include "devices.h"
58#include "sharpsl.h" 65#include "sharpsl.h"
59 66
67static unsigned long spitz_pin_config[] __initdata = {
68 /* Chip Selects */
69 GPIO78_nCS_2, /* SCOOP #2 */
70 GPIO80_nCS_4, /* SCOOP #1 */
71
72 /* LCD - 16bpp Active TFT */
73 GPIO58_LCD_LDD_0,
74 GPIO59_LCD_LDD_1,
75 GPIO60_LCD_LDD_2,
76 GPIO61_LCD_LDD_3,
77 GPIO62_LCD_LDD_4,
78 GPIO63_LCD_LDD_5,
79 GPIO64_LCD_LDD_6,
80 GPIO65_LCD_LDD_7,
81 GPIO66_LCD_LDD_8,
82 GPIO67_LCD_LDD_9,
83 GPIO68_LCD_LDD_10,
84 GPIO69_LCD_LDD_11,
85 GPIO70_LCD_LDD_12,
86 GPIO71_LCD_LDD_13,
87 GPIO72_LCD_LDD_14,
88 GPIO73_LCD_LDD_15,
89 GPIO74_LCD_FCLK,
90 GPIO75_LCD_LCLK,
91 GPIO76_LCD_PCLK,
92
93 /* PC Card */
94 GPIO48_nPOE,
95 GPIO49_nPWE,
96 GPIO50_nPIOR,
97 GPIO51_nPIOW,
98 GPIO85_nPCE_1,
99 GPIO54_nPCE_2,
100 GPIO79_PSKTSEL,
101 GPIO55_nPREG,
102 GPIO56_nPWAIT,
103 GPIO57_nIOIS16,
104
105 /* MMC */
106 GPIO32_MMC_CLK,
107 GPIO112_MMC_CMD,
108 GPIO92_MMC_DAT_0,
109 GPIO109_MMC_DAT_1,
110 GPIO110_MMC_DAT_2,
111 GPIO111_MMC_DAT_3,
112
113 /* GPIOs */
114 GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
115 GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
116 GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
117 GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
118 GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
119 GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
120 GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
121 GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
122 GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
123
124 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
125};
126
60/* 127/*
61 * Spitz SCOOP Device #1 128 * Spitz SCOOP Device #1
62 */ 129 */
@@ -69,10 +136,11 @@ static struct resource spitz_scoop_resources[] = {
69}; 136};
70 137
71static struct scoop_config spitz_scoop_setup = { 138static struct scoop_config spitz_scoop_setup = {
72 .io_dir = SPITZ_SCP_IO_DIR, 139 .io_dir = SPITZ_SCP_IO_DIR,
73 .io_out = SPITZ_SCP_IO_OUT, 140 .io_out = SPITZ_SCP_IO_OUT,
74 .suspend_clr = SPITZ_SCP_SUS_CLR, 141 .suspend_clr = SPITZ_SCP_SUS_CLR,
75 .suspend_set = SPITZ_SCP_SUS_SET, 142 .suspend_set = SPITZ_SCP_SUS_SET,
143 .gpio_base = SPITZ_SCP_GPIO_BASE,
76}; 144};
77 145
78struct platform_device spitzscoop_device = { 146struct platform_device spitzscoop_device = {
@@ -97,10 +165,11 @@ static struct resource spitz_scoop2_resources[] = {
97}; 165};
98 166
99static struct scoop_config spitz_scoop2_setup = { 167static struct scoop_config spitz_scoop2_setup = {
100 .io_dir = SPITZ_SCP2_IO_DIR, 168 .io_dir = SPITZ_SCP2_IO_DIR,
101 .io_out = SPITZ_SCP2_IO_OUT, 169 .io_out = SPITZ_SCP2_IO_OUT,
102 .suspend_clr = SPITZ_SCP2_SUS_CLR, 170 .suspend_clr = SPITZ_SCP2_SUS_CLR,
103 .suspend_set = SPITZ_SCP2_SUS_SET, 171 .suspend_set = SPITZ_SCP2_SUS_SET,
172 .gpio_base = SPITZ_SCP2_GPIO_BASE,
104}; 173};
105 174
106struct platform_device spitzscoop2_device = { 175struct platform_device spitzscoop2_device = {
@@ -122,7 +191,7 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
122 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); 191 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
123 192
124 if (new_cpr & 0x0007) { 193 if (new_cpr & 0x0007) {
125 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); 194 gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
126 if (!(cpr & 0x0002) && !(cpr & 0x0004)) 195 if (!(cpr & 0x0002) && !(cpr & 0x0004))
127 mdelay(5); 196 mdelay(5);
128 if (device == SPITZ_PWR_CF) 197 if (device == SPITZ_PWR_CF)
@@ -138,34 +207,13 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
138 if (!(cpr & 0x0002) && !(cpr & 0x0004)) { 207 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
139 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); 208 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
140 mdelay(1); 209 mdelay(1);
141 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); 210 gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
142 } else { 211 } else {
143 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); 212 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
144 } 213 }
145 } 214 }
146} 215}
147 216
148static void spitz_pcmcia_init(void)
149{
150 /* Setup default state of GPIO outputs
151 before we enable them as outputs. */
152 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
153 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
154 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO54_nPCE_2);
155 GPSR(GPIO85_nPCE_1) = GPIO_bit(GPIO85_nPCE_1);
156
157 pxa_gpio_mode(GPIO48_nPOE_MD);
158 pxa_gpio_mode(GPIO49_nPWE_MD);
159 pxa_gpio_mode(GPIO50_nPIOR_MD);
160 pxa_gpio_mode(GPIO51_nPIOW_MD);
161 pxa_gpio_mode(GPIO55_nPREG_MD);
162 pxa_gpio_mode(GPIO56_nPWAIT_MD);
163 pxa_gpio_mode(GPIO57_nIOIS16_MD);
164 pxa_gpio_mode(GPIO85_nPCE_1_MD);
165 pxa_gpio_mode(GPIO54_nPCE_2_MD);
166 pxa_gpio_mode(GPIO104_pSKTSEL_MD);
167}
168
169static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr) 217static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
170{ 218{
171 /* Only need to override behaviour for slot 0 */ 219 /* Only need to override behaviour for slot 0 */
@@ -191,165 +239,169 @@ static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
191static struct scoop_pcmcia_config spitz_pcmcia_config = { 239static struct scoop_pcmcia_config spitz_pcmcia_config = {
192 .devs = &spitz_pcmcia_scoop[0], 240 .devs = &spitz_pcmcia_scoop[0],
193 .num_devs = 2, 241 .num_devs = 2,
194 .pcmcia_init = spitz_pcmcia_init,
195 .power_ctrl = spitz_pcmcia_pwr, 242 .power_ctrl = spitz_pcmcia_pwr,
196}; 243};
197 244
198EXPORT_SYMBOL(spitzscoop_device); 245EXPORT_SYMBOL(spitzscoop_device);
199EXPORT_SYMBOL(spitzscoop2_device); 246EXPORT_SYMBOL(spitzscoop2_device);
200 247
201
202/* 248/*
203 * Spitz SSP Device 249 * Spitz Keyboard Device
204 *
205 * Set the parent as the scoop device because a lot of SSP devices
206 * also use scoop functions and this makes the power up/down order
207 * work correctly.
208 */ 250 */
209struct platform_device spitzssp_device = { 251static struct platform_device spitzkbd_device = {
210 .name = "corgi-ssp", 252 .name = "spitz-keyboard",
211 .dev = {
212 .parent = &spitzscoop_device.dev,
213 },
214 .id = -1, 253 .id = -1,
215}; 254};
216 255
217struct corgissp_machinfo spitz_ssp_machinfo = {
218 .port = 2,
219 .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
220 .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
221 .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
222 .clk_lcdcon = 520,
223 .clk_ads7846 = 14,
224 .clk_max1111 = 56,
225};
226
227 256
228/* 257/*
229 * Spitz Backlight Device 258 * Spitz LEDs
230 */ 259 */
231static void spitz_bl_kick_battery(void) 260static struct gpio_led spitz_gpio_leds[] = {
232{ 261 {
233 void (*kick_batt)(void); 262 .name = "spitz:amber:charge",
234 263 .default_trigger = "sharpsl-charge",
235 kick_batt = symbol_get(sharpsl_battery_kick); 264 .gpio = SPITZ_GPIO_LED_ORANGE,
236 if (kick_batt) { 265 },
237 kick_batt(); 266 {
238 symbol_put(sharpsl_battery_kick); 267 .name = "spitz:green:hddactivity",
239 } 268 .default_trigger = "ide-disk",
240} 269 .gpio = SPITZ_GPIO_LED_GREEN,
241
242static struct generic_bl_info spitz_bl_machinfo = {
243 .name = "corgi-bl",
244 .default_intensity = 0x1f,
245 .limit_mask = 0x0b,
246 .max_intensity = 0x2f,
247 .kick_battery = spitz_bl_kick_battery,
248};
249
250static struct platform_device spitzbl_device = {
251 .name = "generic-bl",
252 .dev = {
253 .platform_data = &spitz_bl_machinfo,
254 }, 270 },
255 .id = -1,
256}; 271};
257 272
258 273static struct gpio_led_platform_data spitz_gpio_leds_info = {
259/* 274 .leds = spitz_gpio_leds,
260 * Spitz Keyboard Device 275 .num_leds = ARRAY_SIZE(spitz_gpio_leds),
261 */
262static struct platform_device spitzkbd_device = {
263 .name = "spitz-keyboard",
264 .id = -1,
265}; 276};
266 277
267
268/*
269 * Spitz LEDs
270 */
271static struct platform_device spitzled_device = { 278static struct platform_device spitzled_device = {
272 .name = "spitz-led", 279 .name = "leds-gpio",
273 .id = -1, 280 .id = -1,
281 .dev = {
282 .platform_data = &spitz_gpio_leds_info,
283 },
274}; 284};
275 285
276/* 286#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
277 * Spitz Touch Screen Device 287static struct pxa2xx_spi_master spitz_spi_info = {
278 */ 288 .num_chipselect = 3,
289};
279 290
280static unsigned long (*get_hsync_invperiod)(struct device *dev); 291static struct ads7846_platform_data spitz_ads7846_info = {
292 .model = 7846,
293 .vref_delay_usecs = 100,
294 .x_plate_ohms = 419,
295 .y_plate_ohms = 486,
296 .gpio_pendown = SPITZ_GPIO_TP_INT,
297};
281 298
282static void inline sharpsl_wait_sync(int gpio) 299static void spitz_ads7846_cs(u32 command)
283{ 300{
284 while((GPLR(gpio) & GPIO_bit(gpio)) == 0); 301 gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
285 while((GPLR(gpio) & GPIO_bit(gpio)) != 0);
286} 302}
287 303
288static struct device *spitz_pxafb_dev; 304static struct pxa2xx_spi_chip spitz_ads7846_chip = {
305 .cs_control = spitz_ads7846_cs,
306};
289 307
290static int is_pxafb_device(struct device * dev, void * data) 308static void spitz_bl_kick_battery(void)
291{ 309{
292 struct platform_device *pdev = container_of(dev, struct platform_device, dev); 310 void (*kick_batt)(void);
293
294 return (strncmp(pdev->name, "pxa2xx-fb", 9) == 0);
295}
296 311
297static unsigned long spitz_get_hsync_invperiod(void) 312 kick_batt = symbol_get(sharpsl_battery_kick);
298{ 313 if (kick_batt) {
299#ifdef CONFIG_FB_PXA 314 kick_batt();
300 if (!spitz_pxafb_dev) { 315 symbol_put(sharpsl_battery_kick);
301 spitz_pxafb_dev = bus_find_device(&platform_bus_type, NULL, NULL, is_pxafb_device);
302 if (!spitz_pxafb_dev)
303 return 0;
304 } 316 }
305 if (!get_hsync_invperiod)
306 get_hsync_invperiod = symbol_get(pxafb_get_hsync_time);
307 if (!get_hsync_invperiod)
308#endif
309 return 0;
310
311 return get_hsync_invperiod(spitz_pxafb_dev);
312} 317}
313 318
314static void spitz_put_hsync(void) 319static struct corgi_lcd_platform_data spitz_lcdcon_info = {
315{ 320 .init_mode = CORGI_LCD_MODE_VGA,
316 put_device(spitz_pxafb_dev); 321 .max_intensity = 0x2f,
317 if (get_hsync_invperiod) 322 .default_intensity = 0x1f,
318 symbol_put(pxafb_get_hsync_time); 323 .limit_mask = 0x0b,
319 spitz_pxafb_dev = NULL; 324 .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
320 get_hsync_invperiod = NULL; 325 .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
321} 326 .kick_battery = spitz_bl_kick_battery,
327};
322 328
323static void spitz_wait_hsync(void) 329static void spitz_lcdcon_cs(u32 command)
324{ 330{
325 sharpsl_wait_sync(SPITZ_GPIO_HSYNC); 331 gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
326} 332}
327 333
328static struct resource spitzts_resources[] = { 334static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
329 [0] = { 335 .cs_control = spitz_lcdcon_cs,
330 .start = SPITZ_IRQ_GPIO_TP_INT,
331 .end = SPITZ_IRQ_GPIO_TP_INT,
332 .flags = IORESOURCE_IRQ,
333 },
334}; 336};
335 337
336static struct corgits_machinfo spitz_ts_machinfo = { 338static void spitz_max1111_cs(u32 command)
337 .get_hsync_invperiod = spitz_get_hsync_invperiod, 339{
338 .put_hsync = spitz_put_hsync, 340 gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
339 .wait_hsync = spitz_wait_hsync, 341}
342
343static struct pxa2xx_spi_chip spitz_max1111_chip = {
344 .cs_control = spitz_max1111_cs,
340}; 345};
341 346
342static struct platform_device spitzts_device = { 347static struct spi_board_info spitz_spi_devices[] = {
343 .name = "corgi-ts", 348 {
344 .dev = { 349 .modalias = "ads7846",
345 .parent = &spitzssp_device.dev, 350 .max_speed_hz = 1200000,
346 .platform_data = &spitz_ts_machinfo, 351 .bus_num = 2,
352 .chip_select = 0,
353 .platform_data = &spitz_ads7846_info,
354 .controller_data= &spitz_ads7846_chip,
355 .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
356 }, {
357 .modalias = "corgi-lcd",
358 .max_speed_hz = 50000,
359 .bus_num = 2,
360 .chip_select = 1,
361 .platform_data = &spitz_lcdcon_info,
362 .controller_data= &spitz_lcdcon_chip,
363 }, {
364 .modalias = "max1111",
365 .max_speed_hz = 450000,
366 .bus_num = 2,
367 .chip_select = 2,
368 .controller_data= &spitz_max1111_chip,
347 }, 369 },
348 .id = -1,
349 .num_resources = ARRAY_SIZE(spitzts_resources),
350 .resource = spitzts_resources,
351}; 370};
352 371
372static void __init spitz_init_spi(void)
373{
374 int err;
375
376 err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS");
377 if (err)
378 return;
379
380 err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS");
381 if (err)
382 goto err_free_1;
383
384 err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS");
385 if (err)
386 goto err_free_2;
387
388 if (machine_is_akita()) {
389 spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
390 spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
391 }
392
393 pxa2xx_set_spi_info(2, &spitz_spi_info);
394 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
395 return;
396
397err_free_2:
398 gpio_free(SPITZ_GPIO_LCDCON_CS);
399err_free_1:
400 gpio_free(SPITZ_GPIO_ADS7846_CS);
401}
402#else
403static inline void spitz_init_spi(void) {}
404#endif
353 405
354/* 406/*
355 * MMC/SD Device 407 * MMC/SD Device
@@ -364,24 +416,35 @@ static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, vo
364{ 416{
365 int err; 417 int err;
366 418
367 /* setup GPIO for PXA27x MMC controller */ 419 err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
368 pxa_gpio_mode(GPIO32_MMCCLK_MD); 420 if (err)
369 pxa_gpio_mode(GPIO112_MMCCMD_MD); 421 goto err_out;
370 pxa_gpio_mode(GPIO92_MMCDAT0_MD); 422
371 pxa_gpio_mode(GPIO109_MMCDAT1_MD); 423 err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
372 pxa_gpio_mode(GPIO110_MMCDAT2_MD); 424 if (err)
373 pxa_gpio_mode(GPIO111_MMCDAT3_MD); 425 goto err_free_1;
374 pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN); 426
375 pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN); 427 gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
428 gpio_direction_input(SPITZ_GPIO_nSD_WP);
376 429
377 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250); 430 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
378 431
379 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, 432 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
380 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 433 IRQF_DISABLED | IRQF_TRIGGER_RISING |
434 IRQF_TRIGGER_FALLING,
381 "MMC card detect", data); 435 "MMC card detect", data);
382 if (err) 436 if (err) {
383 printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); 437 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
438 __func__);
439 goto err_free_2;
440 }
441 return 0;
384 442
443err_free_2:
444 gpio_free(SPITZ_GPIO_nSD_WP);
445err_free_1:
446 gpio_free(SPITZ_GPIO_nSD_DETECT);
447err_out:
385 return err; 448 return err;
386} 449}
387 450
@@ -397,12 +460,14 @@ static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
397 460
398static int spitz_mci_get_ro(struct device *dev) 461static int spitz_mci_get_ro(struct device *dev)
399{ 462{
400 return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP); 463 return gpio_get_value(SPITZ_GPIO_nSD_WP);
401} 464}
402 465
403static void spitz_mci_exit(struct device *dev, void *data) 466static void spitz_mci_exit(struct device *dev, void *data)
404{ 467{
405 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data); 468 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
469 gpio_free(SPITZ_GPIO_nSD_WP);
470 gpio_free(SPITZ_GPIO_nSD_DETECT);
406} 471}
407 472
408static struct pxamci_platform_data spitz_mci_platform_data = { 473static struct pxamci_platform_data spitz_mci_platform_data = {
@@ -419,27 +484,24 @@ static struct pxamci_platform_data spitz_mci_platform_data = {
419 */ 484 */
420static int spitz_ohci_init(struct device *dev) 485static int spitz_ohci_init(struct device *dev)
421{ 486{
422 /* Only Port 2 is connected */ 487 int err;
423 pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN);
424 pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT);
425 pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN);
426
427 /* Setup USB Port 2 Output Control Register */
428 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
429
430 GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST);
431 488
432 UHCHR = (UHCHR) & 489 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
433 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); 490 if (err)
491 return err;
434 492
435 UHCRHDA |= UHCRHDA_NOCP; 493 /* Only Port 2 is connected
494 * Setup USB Port 2 Output Control Register
495 */
496 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
436 497
437 return 0; 498 return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
438} 499}
439 500
440static struct pxaohci_platform_data spitz_ohci_platform_data = { 501static struct pxaohci_platform_data spitz_ohci_platform_data = {
441 .port_mode = PMM_NPS_MODE, 502 .port_mode = PMM_NPS_MODE,
442 .init = spitz_ohci_init, 503 .init = spitz_ohci_init,
504 .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
443 .power_budget = 150, 505 .power_budget = 150,
444}; 506};
445 507
@@ -447,29 +509,50 @@ static struct pxaohci_platform_data spitz_ohci_platform_data = {
447/* 509/*
448 * Irda 510 * Irda
449 */ 511 */
512static int spitz_irda_startup(struct device *dev)
513{
514 int rc;
515
516 rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
517 if (rc)
518 goto err;
519
520 rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
521 if (rc)
522 goto err_dir;
523
524 return 0;
525
526err_dir:
527 gpio_free(SPITZ_GPIO_IR_ON);
528err:
529 return rc;
530}
531
532static void spitz_irda_shutdown(struct device *dev)
533{
534 gpio_free(SPITZ_GPIO_IR_ON);
535}
536
450static void spitz_irda_transceiver_mode(struct device *dev, int mode) 537static void spitz_irda_transceiver_mode(struct device *dev, int mode)
451{ 538{
452 if (mode & IR_OFF) 539 gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
453 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
454 else
455 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
456 pxa2xx_transceiver_mode(dev, mode); 540 pxa2xx_transceiver_mode(dev, mode);
457} 541}
458 542
459#ifdef CONFIG_MACH_AKITA 543#ifdef CONFIG_MACH_AKITA
460static void akita_irda_transceiver_mode(struct device *dev, int mode) 544static void akita_irda_transceiver_mode(struct device *dev, int mode)
461{ 545{
462 if (mode & IR_OFF) 546 gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
463 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
464 else
465 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
466 pxa2xx_transceiver_mode(dev, mode); 547 pxa2xx_transceiver_mode(dev, mode);
467} 548}
468#endif 549#endif
469 550
470static struct pxaficp_platform_data spitz_ficp_platform_data = { 551static struct pxaficp_platform_data spitz_ficp_platform_data = {
471 .transceiver_cap = IR_SIRMODE | IR_OFF, 552 .transceiver_cap = IR_SIRMODE | IR_OFF,
472 .transceiver_mode = spitz_irda_transceiver_mode, 553 .transceiver_mode = spitz_irda_transceiver_mode,
554 .startup = spitz_irda_startup,
555 .shutdown = spitz_irda_shutdown,
473}; 556};
474 557
475 558
@@ -477,14 +560,6 @@ static struct pxaficp_platform_data spitz_ficp_platform_data = {
477 * Spitz PXA Framebuffer 560 * Spitz PXA Framebuffer
478 */ 561 */
479 562
480static void spitz_lcd_power(int on, struct fb_var_screeninfo *var)
481{
482 if (on)
483 corgi_lcdtg_hw_init(var->xres);
484 else
485 corgi_lcdtg_suspend();
486}
487
488static struct pxafb_mode_info spitz_pxafb_modes[] = { 563static struct pxafb_mode_info spitz_pxafb_modes[] = {
489{ 564{
490 .pixclock = 19231, 565 .pixclock = 19231,
@@ -517,18 +592,13 @@ static struct pxafb_mach_info spitz_pxafb_info = {
517 .modes = &spitz_pxafb_modes[0], 592 .modes = &spitz_pxafb_modes[0],
518 .num_modes = 2, 593 .num_modes = 2,
519 .fixed_modes = 1, 594 .fixed_modes = 1,
520 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM, 595 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
521 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
522 .pxafb_lcd_power = spitz_lcd_power,
523}; 596};
524 597
525 598
526static struct platform_device *devices[] __initdata = { 599static struct platform_device *devices[] __initdata = {
527 &spitzscoop_device, 600 &spitzscoop_device,
528 &spitzssp_device,
529 &spitzkbd_device, 601 &spitzkbd_device,
530 &spitzts_device,
531 &spitzbl_device,
532 &spitzled_device, 602 &spitzled_device,
533}; 603};
534 604
@@ -548,63 +618,32 @@ static void spitz_restart(char mode)
548 618
549static void __init common_init(void) 619static void __init common_init(void)
550{ 620{
551 init_gpio_reset(SPITZ_GPIO_ON_RESET); 621 init_gpio_reset(SPITZ_GPIO_ON_RESET, 1);
552 pm_power_off = spitz_poweroff; 622 pm_power_off = spitz_poweroff;
553 arm_pm_restart = spitz_restart; 623 arm_pm_restart = spitz_restart;
554 624
555 PMCR = 0x00; 625 PMCR = 0x00;
556 626
557 /* setup sleep mode values */
558 PWER = 0x00000002;
559 PFER = 0x00000000;
560 PRER = 0x00000002;
561 PGSR0 = 0x0158C000;
562 PGSR1 = 0x00FF0080;
563 PGSR2 = 0x0001C004;
564
565 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ 627 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
566 PCFR |= PCFR_OPDE; 628 PCFR |= PCFR_OPDE;
567 629
568 corgi_ssp_set_machinfo(&spitz_ssp_machinfo); 630 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
569 631
570 pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN); 632 spitz_init_spi();
571 633
572 platform_add_devices(devices, ARRAY_SIZE(devices)); 634 platform_add_devices(devices, ARRAY_SIZE(devices));
573 pxa_set_mci_info(&spitz_mci_platform_data); 635 pxa_set_mci_info(&spitz_mci_platform_data);
574 pxa_set_ohci_info(&spitz_ohci_platform_data); 636 pxa_set_ohci_info(&spitz_ohci_platform_data);
575 pxa_set_ficp_info(&spitz_ficp_platform_data); 637 pxa_set_ficp_info(&spitz_ficp_platform_data);
576 set_pxa_fb_parent(&spitzssp_device.dev);
577 set_pxa_fb_info(&spitz_pxafb_info); 638 set_pxa_fb_info(&spitz_pxafb_info);
578 pxa_set_i2c_info(NULL); 639 pxa_set_i2c_info(NULL);
579} 640}
580 641
581#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) 642#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
582static void spitz_bl_set_intensity(int intensity)
583{
584 if (intensity > 0x10)
585 intensity += 0x10;
586
587 /* Bits 0-4 are accessed via the SSP interface */
588 corgi_ssp_blduty_set(intensity & 0x1f);
589
590 /* Bit 5 is via SCOOP */
591 if (intensity & 0x0020)
592 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
593 else
594 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
595
596 if (intensity)
597 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
598 else
599 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
600}
601
602static void __init spitz_init(void) 643static void __init spitz_init(void)
603{ 644{
604 platform_scoop_config = &spitz_pcmcia_config; 645 platform_scoop_config = &spitz_pcmcia_config;
605 646
606 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
607
608 common_init(); 647 common_init();
609 648
610 platform_device_register(&spitzscoop2_device); 649 platform_device_register(&spitzscoop2_device);
@@ -615,32 +654,17 @@ static void __init spitz_init(void)
615/* 654/*
616 * Akita IO Expander 655 * Akita IO Expander
617 */ 656 */
618struct platform_device akitaioexp_device = { 657static struct pca953x_platform_data akita_ioexp = {
619 .name = "akita-ioexp", 658 .gpio_base = AKITA_IOEXP_GPIO_BASE,
620 .id = -1,
621}; 659};
622 660
623EXPORT_SYMBOL_GPL(akitaioexp_device); 661static struct i2c_board_info akita_i2c_board_info[] = {
624 662 {
625static void akita_bl_set_intensity(int intensity) 663 .type = "max7310",
626{ 664 .addr = 0x18,
627 if (intensity > 0x10) 665 .platform_data = &akita_ioexp,
628 intensity += 0x10; 666 },
629 667};
630 /* Bits 0-4 are accessed via the SSP interface */
631 corgi_ssp_blduty_set(intensity & 0x1f);
632
633 /* Bit 5 is via IO-Expander */
634 if (intensity & 0x0020)
635 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
636 else
637 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
638
639 if (intensity)
640 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
641 else
642 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
643}
644 668
645static void __init akita_init(void) 669static void __init akita_init(void)
646{ 670{
@@ -649,11 +673,10 @@ static void __init akita_init(void)
649 /* We just pretend the second element of the array doesn't exist */ 673 /* We just pretend the second element of the array doesn't exist */
650 spitz_pcmcia_config.num_devs = 1; 674 spitz_pcmcia_config.num_devs = 1;
651 platform_scoop_config = &spitz_pcmcia_config; 675 platform_scoop_config = &spitz_pcmcia_config;
652 spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity;
653 676
654 platform_device_register(&akitaioexp_device); 677 pxa_set_i2c_info(NULL);
678 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
655 679
656 spitzscoop_device.dev.parent = &akitaioexp_device.dev;
657 common_init(); 680 common_init();
658} 681}
659#endif 682#endif
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 8a40505dfd28..53018db106ac 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -21,7 +21,6 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <asm/hardware/scoop.h>
25 24
26#include <mach/sharpsl.h> 25#include <mach/sharpsl.h>
27#include <mach/spitz.h> 26#include <mach/spitz.h>
@@ -48,44 +47,35 @@ static void spitz_charger_init(void)
48 47
49static void spitz_measure_temp(int on) 48static void spitz_measure_temp(int on)
50{ 49{
51 if (on) 50 gpio_set_value(SPITZ_GPIO_ADC_TEMP_ON, on);
52 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
53 else
54 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
55} 51}
56 52
57static void spitz_charge(int on) 53static void spitz_charge(int on)
58{ 54{
59 if (on) { 55 if (on) {
60 if (sharpsl_pm.flags & SHARPSL_SUSPENDED) { 56 if (sharpsl_pm.flags & SHARPSL_SUSPENDED) {
61 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 57 gpio_set_value(SPITZ_GPIO_JK_B, 1);
62 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 58 gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
63 } else { 59 } else {
64 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 60 gpio_set_value(SPITZ_GPIO_JK_B, 0);
65 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 61 gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
66 } 62 }
67 } else { 63 } else {
68 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 64 gpio_set_value(SPITZ_GPIO_JK_B, 0);
69 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 65 gpio_set_value(SPITZ_GPIO_CHRG_ON, 1);
70 } 66 }
71} 67}
72 68
73static void spitz_discharge(int on) 69static void spitz_discharge(int on)
74{ 70{
75 if (on) 71 gpio_set_value(SPITZ_GPIO_JK_A, on);
76 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
77 else
78 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
79} 72}
80 73
81/* HACK - For unknown reasons, accurate voltage readings are only made with a load 74/* HACK - For unknown reasons, accurate voltage readings are only made with a load
82 on the power bus which the green led on spitz provides */ 75 on the power bus which the green led on spitz provides */
83static void spitz_discharge1(int on) 76static void spitz_discharge1(int on)
84{ 77{
85 if (on) 78 gpio_set_value(SPITZ_GPIO_LED_GREEN, on);
86 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
87 else
88 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
89} 79}
90 80
91static void spitz_presuspend(void) 81static void spitz_presuspend(void)
diff --git a/arch/arm/mach-pxa/ssp.c b/arch/arm/mach-pxa/ssp.c
index 9bd93c5f28b2..2c31ec725688 100644
--- a/arch/arm/mach-pxa/ssp.c
+++ b/arch/arm/mach-pxa/ssp.c
@@ -28,8 +28,8 @@
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/io.h>
31 32
32#include <asm/io.h>
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <mach/hardware.h> 34#include <mach/hardware.h>
35#include <mach/ssp.h> 35#include <mach/ssp.h>
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index b0d6b32654cf..f8a9a62959e5 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -155,7 +155,7 @@ static void __init pxa_timer_init(void)
155 OIER = 0; 155 OIER = 0;
156 OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; 156 OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3;
157 157
158 if (cpu_is_pxa21x() || cpu_is_pxa25x()) 158 if (cpu_is_pxa25x())
159 clock_tick_rate = 3686400; 159 clock_tick_rate = 3686400;
160 else if (machine_is_mainstone()) 160 else if (machine_is_mainstone())
161 clock_tick_rate = 3249600; 161 clock_tick_rate = 3249600;
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 9f3ef9eb32e3..130e37e4ebdd 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -781,7 +781,7 @@ static void __init tosa_init(void)
781 gpio_set_wake(MFP_PIN_GPIO1, 1); 781 gpio_set_wake(MFP_PIN_GPIO1, 1);
782 /* We can't pass to gpio-keys since it will drop the Reset altfunc */ 782 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
783 783
784 init_gpio_reset(TOSA_GPIO_ON_RESET); 784 init_gpio_reset(TOSA_GPIO_ON_RESET, 0);
785 785
786 pm_power_off = tosa_poweroff; 786 pm_power_off = tosa_poweroff;
787 arm_pm_restart = tosa_restart; 787 arm_pm_restart = tosa_restart;
diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c
index 3ed757e6bcc8..a13dbf3c2c05 100644
--- a/arch/arm/mach-pxa/trizeps4.c
+++ b/arch/arm/mach-pxa/trizeps4.c
@@ -22,8 +22,8 @@
22#include <linux/fb.h> 22#include <linux/fb.h>
23#include <linux/ioport.h> 23#include <linux/ioport.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/serial_8250.h> 25#include <linux/gpio.h>
26#include <linux/mtd/mtd.h> 26#include <linux/dm9000.h>
27#include <linux/mtd/physmap.h> 27#include <linux/mtd/physmap.h>
28#include <linux/mtd/partitions.h> 28#include <linux/mtd/partitions.h>
29 29
@@ -31,7 +31,6 @@
31#include <asm/setup.h> 31#include <asm/setup.h>
32#include <asm/memory.h> 32#include <asm/memory.h>
33#include <asm/mach-types.h> 33#include <asm/mach-types.h>
34#include <mach/hardware.h>
35#include <asm/irq.h> 34#include <asm/irq.h>
36#include <asm/sizes.h> 35#include <asm/sizes.h>
37 36
@@ -40,41 +39,148 @@
40#include <asm/mach/irq.h> 39#include <asm/mach/irq.h>
41#include <asm/mach/flash.h> 40#include <asm/mach/flash.h>
42 41
42#include <mach/hardware.h>
43#include <mach/pxa-regs.h> 43#include <mach/pxa-regs.h>
44#include <mach/pxa2xx-regs.h> 44#include <mach/pxa2xx-regs.h>
45#include <mach/pxa2xx-gpio.h> 45#include <mach/mfp-pxa27x.h>
46#include <mach/pxa2xx_spi.h>
46#include <mach/trizeps4.h> 47#include <mach/trizeps4.h>
47#include <mach/audio.h> 48#include <mach/audio.h>
48#include <mach/pxafb.h> 49#include <mach/pxafb.h>
49#include <mach/mmc.h> 50#include <mach/mmc.h>
50#include <mach/irda.h> 51#include <mach/irda.h>
51#include <mach/ohci.h> 52#include <mach/ohci.h>
53#include <mach/i2c.h>
52 54
53#include "generic.h" 55#include "generic.h"
54#include "devices.h" 56#include "devices.h"
55 57
56/******************************************************************************************** 58/* comment out the following line if you want to use the
59 * Standard UART from PXA for serial / irda transmission
60 * and acivate it if you have status leds connected */
61#define STATUS_LEDS_ON_STUART_PINS 1
62
63/*****************************************************************************
64 * MultiFunctionPins of CPU
65 *****************************************************************************/
66static unsigned long trizeps4_pin_config[] __initdata = {
67 /* Chip Selects */
68 GPIO15_nCS_1, /* DiskOnChip CS */
69 GPIO93_GPIO, /* TRIZEPS4_DOC_IRQ */
70 GPIO94_GPIO, /* DOC lock */
71
72 GPIO78_nCS_2, /* DM9000 CS */
73 GPIO101_GPIO, /* TRIZEPS4_ETH_IRQ */
74
75 GPIO79_nCS_3, /* Logic CS */
76 GPIO0_GPIO | WAKEUP_ON_EDGE_RISE, /* Logic irq */
77
78 /* LCD - 16bpp Active TFT */
79 GPIO58_LCD_LDD_0,
80 GPIO59_LCD_LDD_1,
81 GPIO60_LCD_LDD_2,
82 GPIO61_LCD_LDD_3,
83 GPIO62_LCD_LDD_4,
84 GPIO63_LCD_LDD_5,
85 GPIO64_LCD_LDD_6,
86 GPIO65_LCD_LDD_7,
87 GPIO66_LCD_LDD_8,
88 GPIO67_LCD_LDD_9,
89 GPIO68_LCD_LDD_10,
90 GPIO69_LCD_LDD_11,
91 GPIO70_LCD_LDD_12,
92 GPIO71_LCD_LDD_13,
93 GPIO72_LCD_LDD_14,
94 GPIO73_LCD_LDD_15,
95 GPIO74_LCD_FCLK,
96 GPIO75_LCD_LCLK,
97 GPIO76_LCD_PCLK,
98 GPIO77_LCD_BIAS,
99
100 /* UART */
101 GPIO9_FFUART_CTS,
102 GPIO10_FFUART_DCD,
103 GPIO16_FFUART_TXD,
104 GPIO33_FFUART_DSR,
105 GPIO38_FFUART_RI,
106 GPIO82_FFUART_DTR,
107 GPIO83_FFUART_RTS,
108 GPIO96_FFUART_RXD,
109
110 GPIO42_BTUART_RXD,
111 GPIO43_BTUART_TXD,
112 GPIO44_BTUART_CTS,
113 GPIO45_BTUART_RTS,
114#ifdef STATUS_LEDS_ON_STUART_PINS
115 GPIO46_GPIO,
116 GPIO47_GPIO,
117#else
118 GPIO46_STUART_RXD,
119 GPIO47_STUART_TXD,
120#endif
121 /* PCMCIA */
122 GPIO11_GPIO, /* TRIZEPS4_CD_IRQ */
123 GPIO13_GPIO, /* TRIZEPS4_READY_NINT */
124 GPIO48_nPOE,
125 GPIO49_nPWE,
126 GPIO50_nPIOR,
127 GPIO51_nPIOW,
128 GPIO54_nPCE_2,
129 GPIO55_nPREG,
130 GPIO56_nPWAIT,
131 GPIO57_nIOIS16,
132 GPIO102_nPCE_1,
133 GPIO104_PSKTSEL,
134
135 /* MultiMediaCard */
136 GPIO32_MMC_CLK,
137 GPIO92_MMC_DAT_0,
138 GPIO109_MMC_DAT_1,
139 GPIO110_MMC_DAT_2,
140 GPIO111_MMC_DAT_3,
141 GPIO112_MMC_CMD,
142 GPIO12_GPIO, /* TRIZEPS4_MMC_IRQ */
143
144 /* USB OHCI */
145 GPIO88_USBH1_PWR, /* USBHPWR1 */
146 GPIO89_USBH1_PEN, /* USBHPEN1 */
147
148 /* I2C */
149 GPIO117_I2C_SCL,
150 GPIO118_I2C_SDA,
151};
152
153static unsigned long trizeps4wl_pin_config[] __initdata = {
154 /* SSP 2 */
155 GPIO14_SSP2_SFRM,
156 GPIO19_SSP2_SCLK,
157 GPIO53_GPIO, /* TRIZEPS4_SPI_IRQ */
158 GPIO86_SSP2_RXD,
159 GPIO87_SSP2_TXD,
160};
161
162/****************************************************************************
57 * ONBOARD FLASH 163 * ONBOARD FLASH
58 ********************************************************************************************/ 164 ****************************************************************************/
59static struct mtd_partition trizeps4_partitions[] = { 165static struct mtd_partition trizeps4_partitions[] = {
60 { 166 {
61 .name = "Bootloader", 167 .name = "Bootloader",
62 .offset = 0x00000000, 168 .offset = 0x00000000,
63 .size = 0x00040000, 169 .size = 0x00040000,
64 .mask_flags = MTD_WRITEABLE /* force read-only */ 170 .mask_flags = MTD_WRITEABLE /* force read-only */
65 },{ 171 }, {
66 .name = "Backup", 172 .name = "Backup",
67 .offset = 0x00040000, 173 .offset = 0x00040000,
68 .size = 0x00040000, 174 .size = 0x00040000,
69 },{ 175 }, {
70 .name = "Image", 176 .name = "Image",
71 .offset = 0x00080000, 177 .offset = 0x00080000,
72 .size = 0x01080000, 178 .size = 0x01080000,
73 },{ 179 }, {
74 .name = "IPSM", 180 .name = "IPSM",
75 .offset = 0x01100000, 181 .offset = 0x01100000,
76 .size = 0x00e00000, 182 .size = 0x00e00000,
77 },{ 183 }, {
78 .name = "Registry", 184 .name = "Registry",
79 .offset = 0x01f00000, 185 .offset = 0x01f00000,
80 .size = MTDPART_SIZ_FULL, 186 .size = MTDPART_SIZ_FULL,
@@ -105,9 +211,9 @@ static struct platform_device flash_device = {
105 .num_resources = 1, 211 .num_resources = 1,
106}; 212};
107 213
108/******************************************************************************************** 214/****************************************************************************
109 * DAVICOM DM9000 Ethernet 215 * DAVICOM DM9000 Ethernet
110 ********************************************************************************************/ 216 ****************************************************************************/
111static struct resource dm9000_resources[] = { 217static struct resource dm9000_resources[] = {
112 [0] = { 218 [0] = {
113 .start = TRIZEPS4_ETH_PHYS+0x300, 219 .start = TRIZEPS4_ETH_PHYS+0x300,
@@ -122,67 +228,68 @@ static struct resource dm9000_resources[] = {
122 [2] = { 228 [2] = {
123 .start = TRIZEPS4_ETH_IRQ, 229 .start = TRIZEPS4_ETH_IRQ,
124 .end = TRIZEPS4_ETH_IRQ, 230 .end = TRIZEPS4_ETH_IRQ,
125 .flags = (IORESOURCE_IRQ | IRQ_TYPE_EDGE_RISING), 231 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
126 }, 232 },
127}; 233};
128 234
235static struct dm9000_plat_data tri_dm9000_platdata = {
236 .flags = DM9000_PLATF_32BITONLY,
237};
238
129static struct platform_device dm9000_device = { 239static struct platform_device dm9000_device = {
130 .name = "dm9000", 240 .name = "dm9000",
131 .id = -1, 241 .id = -1,
132 .num_resources = ARRAY_SIZE(dm9000_resources), 242 .num_resources = ARRAY_SIZE(dm9000_resources),
133 .resource = dm9000_resources, 243 .resource = dm9000_resources,
244 .dev = {
245 .platform_data = &tri_dm9000_platdata,
246 }
134}; 247};
135 248
136/******************************************************************************************** 249/****************************************************************************
137 * PXA270 serial ports 250 * LED's on GPIO pins of PXA
138 ********************************************************************************************/ 251 ****************************************************************************/
139static struct plat_serial8250_port tri_serial_ports[] = { 252static struct gpio_led trizeps4_led[] = {
140#ifdef CONFIG_SERIAL_PXA 253#ifdef STATUS_LEDS_ON_STUART_PINS
141 /* this uses the own PXA driver */
142 { 254 {
143 0, 255 .name = "led0:orange:heartbeat", /* */
144 }, 256 .default_trigger = "heartbeat",
145#else 257 .gpio = GPIO_HEARTBEAT_LED,
146 /* this uses the generic 8520 driver */ 258 .active_low = 1,
147 [0] = {
148 .membase = (void *)&FFUART,
149 .irq = IRQ_FFUART,
150 .flags = UPF_BOOT_AUTOCONF,
151 .iotype = UPIO_MEM32,
152 .regshift = 2,
153 .uartclk = (921600*16),
154 },
155 [1] = {
156 .membase = (void *)&BTUART,
157 .irq = IRQ_BTUART,
158 .flags = UPF_BOOT_AUTOCONF,
159 .iotype = UPIO_MEM32,
160 .regshift = 2,
161 .uartclk = (921600*16),
162 }, 259 },
163 { 260 {
164 0, 261 .name = "led1:yellow:cpubusy", /* */
262 .default_trigger = "cpu-busy",
263 .gpio = GPIO_SYS_BUSY_LED,
264 .active_low = 1,
165 }, 265 },
166#endif 266#endif
167}; 267};
168 268
169static struct platform_device uart_devices = { 269static struct gpio_led_platform_data trizeps4_led_data = {
170 .name = "serial8250", 270 .leds = trizeps4_led,
171 .id = 0, 271 .num_leds = ARRAY_SIZE(trizeps4_led),
272};
273
274static struct platform_device leds_devices = {
275 .name = "leds-gpio",
276 .id = -1,
172 .dev = { 277 .dev = {
173 .platform_data = tri_serial_ports, 278 .platform_data = &trizeps4_led_data,
174 }, 279 },
175 .num_resources = 0,
176 .resource = NULL,
177}; 280};
178 281
179static struct platform_device * trizeps4_devices[] __initdata = { 282static struct platform_device *trizeps4_devices[] __initdata = {
180 &flash_device, 283 &flash_device,
181 &uart_devices,
182 &dm9000_device, 284 &dm9000_device,
285 &leds_devices,
286};
287
288static struct platform_device *trizeps4wl_devices[] __initdata = {
289 &flash_device,
290 &leds_devices,
183}; 291};
184 292
185#ifdef CONFIG_MACH_TRIZEPS4_CONXS
186static short trizeps_conxs_bcr; 293static short trizeps_conxs_bcr;
187 294
188/* PCCARD power switching supports only 3,3V */ 295/* PCCARD power switching supports only 3,3V */
@@ -192,108 +299,63 @@ void board_pcmcia_power(int power)
192 /* switch power on, put in reset and enable buffers */ 299 /* switch power on, put in reset and enable buffers */
193 trizeps_conxs_bcr |= power; 300 trizeps_conxs_bcr |= power;
194 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET; 301 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
195 trizeps_conxs_bcr &= ~(ConXS_BCR_CF_BUF_EN); 302 trizeps_conxs_bcr &= ~ConXS_BCR_CF_BUF_EN;
196 ConXS_BCR = trizeps_conxs_bcr; 303 BCR_writew(trizeps_conxs_bcr);
197 /* wait a little */ 304 /* wait a little */
198 udelay(2000); 305 udelay(2000);
199 /* take reset away */ 306 /* take reset away */
200 trizeps_conxs_bcr &= ~(ConXS_BCR_CF_RESET); 307 trizeps_conxs_bcr &= ~ConXS_BCR_CF_RESET;
201 ConXS_BCR = trizeps_conxs_bcr; 308 BCR_writew(trizeps_conxs_bcr);
202 udelay(2000); 309 udelay(2000);
203 } else { 310 } else {
204 /* put in reset */ 311 /* put in reset */
205 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET; 312 trizeps_conxs_bcr |= ConXS_BCR_CF_RESET;
206 ConXS_BCR = trizeps_conxs_bcr; 313 BCR_writew(trizeps_conxs_bcr);
207 udelay(1000); 314 udelay(1000);
208 /* switch power off */ 315 /* switch power off */
209 trizeps_conxs_bcr &= ~(0xf); 316 trizeps_conxs_bcr &= ~0xf;
210 ConXS_BCR = trizeps_conxs_bcr; 317 BCR_writew(trizeps_conxs_bcr);
211
212 } 318 }
213 pr_debug("%s: o%s 0x%x\n", __func__, power ? "n": "ff", trizeps_conxs_bcr); 319 pr_debug("%s: o%s 0x%x\n", __func__, power ? "n" : "ff",
320 trizeps_conxs_bcr);
214} 321}
322EXPORT_SYMBOL(board_pcmcia_power);
215 323
216/* backlight power switching for LCD panel */ 324/* backlight power switching for LCD panel */
217static void board_backlight_power(int on) 325static void board_backlight_power(int on)
218{ 326{
219 if (on) { 327 if (on)
220 trizeps_conxs_bcr |= ConXS_BCR_L_DISP; 328 trizeps_conxs_bcr |= ConXS_BCR_L_DISP;
221 } else { 329 else
222 trizeps_conxs_bcr &= ~ConXS_BCR_L_DISP; 330 trizeps_conxs_bcr &= ~ConXS_BCR_L_DISP;
223 }
224 pr_debug("%s: o%s 0x%x\n", __func__, on ? "n" : "ff", trizeps_conxs_bcr);
225 ConXS_BCR = trizeps_conxs_bcr;
226}
227 331
228/* Powersupply for MMC/SD cardslot */ 332 pr_debug("%s: o%s 0x%x\n", __func__, on ? "n" : "ff",
229static void board_mci_power(struct device *dev, unsigned int vdd) 333 trizeps_conxs_bcr);
230{ 334 BCR_writew(trizeps_conxs_bcr);
231 struct pxamci_platform_data* p_d = dev->platform_data;
232
233 if (( 1 << vdd) & p_d->ocr_mask) {
234 pr_debug("%s: on\n", __func__);
235 /* FIXME fill in values here */
236 } else {
237 pr_debug("%s: off\n", __func__);
238 /* FIXME fill in values here */
239 }
240}
241
242static short trizeps_conxs_ircr;
243
244/* Switch modes and Power for IRDA receiver */
245static void board_irda_mode(struct device *dev, int mode)
246{
247 unsigned long flags;
248
249 local_irq_save(flags);
250 if (mode & IR_SIRMODE) {
251 /* Slow mode */
252 trizeps_conxs_ircr &= ~ConXS_IRCR_MODE;
253 } else if (mode & IR_FIRMODE) {
254 /* Fast mode */
255 trizeps_conxs_ircr |= ConXS_IRCR_MODE;
256 }
257 pxa2xx_transceiver_mode(dev, mode);
258 if (mode & IR_OFF) {
259 trizeps_conxs_ircr |= ConXS_IRCR_SD;
260 } else {
261 trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
262 }
263 /* FIXME write values to register */
264 local_irq_restore(flags);
265} 335}
266 336
267#else 337/* a I2C based RTC is known on CONXS board */
268/* for other baseboards define dummies */ 338static struct i2c_board_info trizeps4_i2c_devices[] __initdata = {
269void board_pcmcia_power(int power) {;} 339 { I2C_BOARD_INFO("rtc-pcf8593", 0x51) }
270#define board_backlight_power NULL 340};
271#define board_mci_power NULL
272#define board_irda_mode NULL
273
274#endif /* CONFIG_MACH_TRIZEPS4_CONXS */
275EXPORT_SYMBOL(board_pcmcia_power);
276 341
277static int trizeps4_mci_init(struct device *dev, irq_handler_t mci_detect_int, void *data) 342/****************************************************************************
343 * MMC card slot external to module
344 ****************************************************************************/
345static int trizeps4_mci_init(struct device *dev, irq_handler_t mci_detect_int,
346 void *data)
278{ 347{
279 int err; 348 int err;
280 /* setup GPIO for PXA27x MMC controller */
281 pxa_gpio_mode(GPIO32_MMCCLK_MD);
282 pxa_gpio_mode(GPIO112_MMCCMD_MD);
283 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
284 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
285 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
286 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
287
288 pxa_gpio_mode(GPIO_MMC_DET | GPIO_IN);
289 349
290 err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int, 350 err = request_irq(TRIZEPS4_MMC_IRQ, mci_detect_int,
291 IRQF_DISABLED | IRQF_TRIGGER_RISING, 351 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_SAMPLE_RANDOM,
292 "MMC card detect", data); 352 "MMC card detect", data);
293 if (err) 353 if (err) {
294 printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); 354 printk(KERN_ERR "trizeps4_mci_init: MMC/SD: can't request"
295 355 "MMC card detect IRQ\n");
296 return err; 356 return -1;
357 }
358 return 0;
297} 359}
298 360
299static void trizeps4_mci_exit(struct device *dev, void *data) 361static void trizeps4_mci_exit(struct device *dev, void *data)
@@ -303,39 +365,69 @@ static void trizeps4_mci_exit(struct device *dev, void *data)
303 365
304static struct pxamci_platform_data trizeps4_mci_platform_data = { 366static struct pxamci_platform_data trizeps4_mci_platform_data = {
305 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 367 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
368 .detect_delay = 1,
306 .init = trizeps4_mci_init, 369 .init = trizeps4_mci_init,
307 .exit = trizeps4_mci_exit, 370 .exit = trizeps4_mci_exit,
308 .setpower = board_mci_power, 371 .get_ro = NULL, /* write-protection not supported */
372 .setpower = NULL, /* power-switching not supported */
309}; 373};
310 374
311static struct pxaficp_platform_data trizeps4_ficp_platform_data = { 375/****************************************************************************
312 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF, 376 * IRDA mode switching on stuart
313 .transceiver_mode = board_irda_mode, 377 ****************************************************************************/
314}; 378#ifndef STATUS_LEDS_ON_STUART_PINS
379static short trizeps_conxs_ircr;
315 380
316static int trizeps4_ohci_init(struct device *dev) 381static int trizeps4_irda_startup(struct device *dev)
317{ 382{
318 /* setup Port1 GPIO pin. */ 383 trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
319 pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN); /* USBHPWR1 */ 384 IRCR_writew(trizeps_conxs_ircr);
320 pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */
321
322 /* Set the Power Control Polarity Low and Power Sense
323 Polarity Low to active low. */
324 UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
325 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
326
327 return 0; 385 return 0;
328} 386}
329 387
330static void trizeps4_ohci_exit(struct device *dev) 388static void trizeps4_irda_shutdown(struct device *dev)
389{
390 trizeps_conxs_ircr |= ConXS_IRCR_SD;
391 IRCR_writew(trizeps_conxs_ircr);
392}
393
394static void trizeps4_irda_transceiver_mode(struct device *dev, int mode)
331{ 395{
332 ; 396 unsigned long flags;
397
398 local_irq_save(flags);
399 /* Switch mode */
400 if (mode & IR_SIRMODE)
401 trizeps_conxs_ircr &= ~ConXS_IRCR_MODE; /* Slow mode */
402 else if (mode & IR_FIRMODE) {
403 trizeps_conxs_ircr |= ConXS_IRCR_MODE; /* Fast mode */
404
405 /* Switch power */
406 if (mode & IR_OFF)
407 trizeps_conxs_ircr |= ConXS_IRCR_SD;
408 else
409 trizeps_conxs_ircr &= ~ConXS_IRCR_SD;
410
411 IRCR_writew(trizeps_conxs_ircr);
412 local_irq_restore(flags);
413
414 pxa2xx_transceiver_mode(dev, mode);
333} 415}
334 416
417static struct pxaficp_platform_data trizeps4_ficp_platform_data = {
418 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
419 .transceiver_mode = trizeps4_irda_transceiver_mode,
420 .startup = trizeps4_irda_startup,
421 .shutdown = trizeps4_irda_shutdown,
422};
423#endif
424
425/****************************************************************************
426 * OHCI USB port
427 ****************************************************************************/
335static struct pxaohci_platform_data trizeps4_ohci_platform_data = { 428static struct pxaohci_platform_data trizeps4_ohci_platform_data = {
336 .port_mode = PMM_PERPORT_MODE, 429 .port_mode = PMM_PERPORT_MODE,
337 .init = trizeps4_ohci_init, 430 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
338 .exit = trizeps4_ohci_exit,
339}; 431};
340 432
341static struct map_desc trizeps4_io_desc[] __initdata = { 433static struct map_desc trizeps4_io_desc[] __initdata = {
@@ -372,105 +464,80 @@ static struct map_desc trizeps4_io_desc[] __initdata = {
372}; 464};
373 465
374static struct pxafb_mode_info sharp_lcd_mode = { 466static struct pxafb_mode_info sharp_lcd_mode = {
375 .pixclock = 78000, 467 .pixclock = 78000,
376 .xres = 640, 468 .xres = 640,
377 .yres = 480, 469 .yres = 480,
378 .bpp = 8, 470 .bpp = 8,
379 .hsync_len = 4, 471 .hsync_len = 4,
380 .left_margin = 4, 472 .left_margin = 4,
381 .right_margin = 4, 473 .right_margin = 4,
382 .vsync_len = 2, 474 .vsync_len = 2,
383 .upper_margin = 0, 475 .upper_margin = 0,
384 .lower_margin = 0, 476 .lower_margin = 0,
385 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 477 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
386 .cmap_greyscale = 0, 478 .cmap_greyscale = 0,
387}; 479};
388 480
389static struct pxafb_mach_info sharp_lcd = { 481static struct pxafb_mach_info sharp_lcd = {
390 .modes = &sharp_lcd_mode, 482 .modes = &sharp_lcd_mode,
391 .num_modes = 1, 483 .num_modes = 1,
392 .cmap_inverse = 0, 484 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL,
393 .cmap_static = 0, 485 .cmap_inverse = 0,
394 .lccr0 = LCCR0_Color | LCCR0_Pas | LCCR0_Dual, 486 .cmap_static = 0,
395 .lccr3 = 0x0340ff02, 487 .pxafb_backlight_power = board_backlight_power,
396 .pxafb_backlight_power = board_backlight_power,
397}; 488};
398 489
399static struct pxafb_mode_info toshiba_lcd_mode = { 490static struct pxafb_mode_info toshiba_lcd_mode = {
400 .pixclock = 39720, 491 .pixclock = 39720,
401 .xres = 640, 492 .xres = 640,
402 .yres = 480, 493 .yres = 480,
403 .bpp = 8, 494 .bpp = 8,
404 .hsync_len = 63, 495 .hsync_len = 63,
405 .left_margin = 12, 496 .left_margin = 12,
406 .right_margin = 12, 497 .right_margin = 12,
407 .vsync_len = 4, 498 .vsync_len = 4,
408 .upper_margin = 32, 499 .upper_margin = 32,
409 .lower_margin = 10, 500 .lower_margin = 10,
410 .sync = 0, 501 .sync = 0,
411 .cmap_greyscale = 0, 502 .cmap_greyscale = 0,
412}; 503};
413 504
414static struct pxafb_mach_info toshiba_lcd = { 505static struct pxafb_mach_info toshiba_lcd = {
415 .modes = &toshiba_lcd_mode, 506 .modes = &toshiba_lcd_mode,
416 .num_modes = 1, 507 .num_modes = 1,
417 .cmap_inverse = 0, 508 .lcd_conn = (LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL),
418 .cmap_static = 0, 509 .cmap_inverse = 0,
419 .lccr0 = LCCR0_Color | LCCR0_Act, 510 .cmap_static = 0,
420 .lccr3 = 0x03400002, 511 .pxafb_backlight_power = board_backlight_power,
421 .pxafb_backlight_power = board_backlight_power,
422}; 512};
423 513
424static void __init trizeps4_init(void) 514static void __init trizeps4_init(void)
425{ 515{
426 platform_add_devices(trizeps4_devices, ARRAY_SIZE(trizeps4_devices)); 516 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4_pin_config));
517 if (machine_is_trizeps4wl()) {
518 pxa2xx_mfp_config(ARRAY_AND_SIZE(trizeps4wl_pin_config));
519 platform_add_devices(trizeps4wl_devices,
520 ARRAY_SIZE(trizeps4wl_devices));
521 } else {
522 platform_add_devices(trizeps4_devices,
523 ARRAY_SIZE(trizeps4_devices));
524 }
427 525
428/* set_pxa_fb_info(&sharp_lcd); */ 526 if (0) /* dont know how to determine LCD */
429 set_pxa_fb_info(&toshiba_lcd); 527 set_pxa_fb_info(&sharp_lcd);
528 else
529 set_pxa_fb_info(&toshiba_lcd);
430 530
431 pxa_set_mci_info(&trizeps4_mci_platform_data); 531 pxa_set_mci_info(&trizeps4_mci_platform_data);
532#ifndef STATUS_LEDS_ON_STUART_PINS
432 pxa_set_ficp_info(&trizeps4_ficp_platform_data); 533 pxa_set_ficp_info(&trizeps4_ficp_platform_data);
534#endif
433 pxa_set_ohci_info(&trizeps4_ohci_platform_data); 535 pxa_set_ohci_info(&trizeps4_ohci_platform_data);
434 pxa_set_ac97_info(NULL); 536 pxa_set_ac97_info(NULL);
435} 537 pxa_set_i2c_info(NULL);
436 538 i2c_register_board_info(0, trizeps4_i2c_devices,
437static void __init trizeps4_map_io(void) 539 ARRAY_SIZE(trizeps4_i2c_devices));
438{
439 pxa_map_io();
440 iotable_init(trizeps4_io_desc, ARRAY_SIZE(trizeps4_io_desc));
441
442 /* for DiskOnChip */
443 pxa_gpio_mode(GPIO15_nCS_1_MD);
444
445 /* for off-module PIC on ConXS board */
446 pxa_gpio_mode(GPIO_PIC | GPIO_IN);
447
448 /* UCB1400 irq */
449 pxa_gpio_mode(GPIO_UCB1400 | GPIO_IN);
450
451 /* for DM9000 LAN */
452 pxa_gpio_mode(GPIO78_nCS_2_MD);
453 pxa_gpio_mode(GPIO_DM9000 | GPIO_IN);
454
455 /* for PCMCIA device */
456 pxa_gpio_mode(GPIO_PCD | GPIO_IN);
457 pxa_gpio_mode(GPIO_PRDY | GPIO_IN);
458
459 /* for I2C adapter */
460 pxa_gpio_mode(GPIO117_I2CSCL_MD);
461 pxa_gpio_mode(GPIO118_I2CSDA_MD);
462 540
463 /* MMC_DET s.o. */
464 pxa_gpio_mode(GPIO_MMC_DET | GPIO_IN);
465
466 /* whats that for ??? */
467 pxa_gpio_mode(GPIO79_nCS_3_MD);
468
469#ifdef CONFIG_LEDS
470 pxa_gpio_mode( GPIO_SYS_BUSY_LED | GPIO_OUT); /* LED1 */
471 pxa_gpio_mode( GPIO_HEARTBEAT_LED | GPIO_OUT); /* LED2 */
472#endif
473#ifdef CONFIG_MACH_TRIZEPS4_CONXS
474#ifdef CONFIG_IDE_PXA_CF 541#ifdef CONFIG_IDE_PXA_CF
475 /* if boot direct from compact flash dont disable power */ 542 /* if boot direct from compact flash dont disable power */
476 trizeps_conxs_bcr = 0x0009; 543 trizeps_conxs_bcr = 0x0009;
@@ -478,18 +545,24 @@ static void __init trizeps4_map_io(void)
478 /* this is the reset value */ 545 /* this is the reset value */
479 trizeps_conxs_bcr = 0x00A0; 546 trizeps_conxs_bcr = 0x00A0;
480#endif 547#endif
481 ConXS_BCR = trizeps_conxs_bcr; 548 BCR_writew(trizeps_conxs_bcr);
482#endif 549 board_backlight_power(1);
550}
551
552static void __init trizeps4_map_io(void)
553{
554 pxa_map_io();
555 iotable_init(trizeps4_io_desc, ARRAY_SIZE(trizeps4_io_desc));
483 556
484#warning FIXME - accessing PM registers directly is deprecated 557 if ((MSC0 & 0x8) && (BOOT_DEF & 0x1)) {
485 PWER = 0x00000002; 558 /* if flash is 16 bit wide its a Trizeps4 WL */
486 PFER = 0x00000000; 559 __machine_arch_type = MACH_TYPE_TRIZEPS4WL;
487 PRER = 0x00000002; 560 trizeps4_flash_data[0].width = 2;
488 PGSR0 = 0x0158C000; 561 } else {
489 PGSR1 = 0x00FF0080; 562 /* if flash is 32 bit wide its a Trizeps4 */
490 PGSR2 = 0x0001C004; 563 __machine_arch_type = MACH_TYPE_TRIZEPS4;
491 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ 564 trizeps4_flash_data[0].width = 4;
492 PCFR |= PCFR_OPDE; 565 }
493} 566}
494 567
495MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module") 568MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
@@ -503,3 +576,13 @@ MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
503 .timer = &pxa_timer, 576 .timer = &pxa_timer,
504MACHINE_END 577MACHINE_END
505 578
579MACHINE_START(TRIZEPS4WL, "Keith und Koep Trizeps IV-WL module")
580 /* MAINTAINER("Jürgen Schindele") */
581 .phys_io = 0x40000000,
582 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
583 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
584 .init_machine = trizeps4_init,
585 .map_io = trizeps4_map_io,
586 .init_irq = pxa27x_init_irq,
587 .timer = &pxa_timer,
588MACHINE_END
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
new file mode 100644
index 000000000000..d7632f63603c
--- /dev/null
+++ b/arch/arm/mach-pxa/viper.c
@@ -0,0 +1,951 @@
1/*
2 * linux/arch/arm/mach-pxa/viper.c
3 *
4 * Support for the Arcom VIPER SBC.
5 *
6 * Author: Ian Campbell
7 * Created: Feb 03, 2003
8 * Copyright: Arcom Control Systems
9 *
10 * Maintained by Marc Zyngier <maz@misterjones.org>
11 * <marc.zyngier@altran.com>
12 *
13 * Based on lubbock.c:
14 * Author: Nicolas Pitre
15 * Created: Jun 15, 2001
16 * Copyright: MontaVista Software Inc.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License version 2 as
20 * published by the Free Software Foundation.
21 */
22
23#include <linux/types.h>
24#include <linux/memory.h>
25#include <linux/cpu.h>
26#include <linux/cpufreq.h>
27#include <linux/delay.h>
28#include <linux/fs.h>
29#include <linux/init.h>
30#include <linux/interrupt.h>
31#include <linux/major.h>
32#include <linux/module.h>
33#include <linux/pm.h>
34#include <linux/sched.h>
35#include <linux/gpio.h>
36#include <linux/i2c-gpio.h>
37#include <linux/serial_8250.h>
38#include <linux/smc91x.h>
39#include <linux/pwm_backlight.h>
40#include <linux/usb/isp116x.h>
41#include <linux/mtd/mtd.h>
42#include <linux/mtd/partitions.h>
43#include <linux/mtd/physmap.h>
44
45#include <mach/pxa-regs.h>
46#include <mach/pxa2xx-regs.h>
47#include <mach/bitfield.h>
48#include <mach/audio.h>
49#include <mach/pxafb.h>
50#include <mach/mfp-pxa25x.h>
51#include <mach/i2c.h>
52#include <mach/viper.h>
53
54#include <asm/setup.h>
55#include <asm/mach-types.h>
56#include <asm/irq.h>
57#include <asm/sizes.h>
58
59#include <asm/mach/arch.h>
60#include <asm/mach/map.h>
61#include <asm/mach/irq.h>
62
63#include "generic.h"
64#include "devices.h"
65
66static unsigned int icr;
67
68static void viper_icr_set_bit(unsigned int bit)
69{
70 icr |= bit;
71 VIPER_ICR = icr;
72}
73
74static void viper_icr_clear_bit(unsigned int bit)
75{
76 icr &= ~bit;
77 VIPER_ICR = icr;
78}
79
80/* This function is used from the pcmcia module to reset the CF */
81void viper_cf_rst(int state)
82{
83 if (state)
84 viper_icr_set_bit(VIPER_ICR_CF_RST);
85 else
86 viper_icr_clear_bit(VIPER_ICR_CF_RST);
87}
88EXPORT_SYMBOL(viper_cf_rst);
89
90/*
91 * The CPLD version register was not present on VIPER boards prior to
92 * v2i1. On v1 boards where the version register is not present we
93 * will just read back the previous value from the databus.
94 *
95 * Therefore we do two reads. The first time we write 0 to the
96 * (read-only) register before reading and the second time we write
97 * 0xff first. If the two reads do not match or they read back as 0xff
98 * or 0x00 then we have version 1 hardware.
99 */
100static u8 viper_hw_version(void)
101{
102 u8 v1, v2;
103 unsigned long flags;
104
105 local_irq_save(flags);
106
107 VIPER_VERSION = 0;
108 v1 = VIPER_VERSION;
109 VIPER_VERSION = 0xff;
110 v2 = VIPER_VERSION;
111
112 v1 = (v1 != v2 || v1 == 0xff) ? 0 : v1;
113
114 local_irq_restore(flags);
115 return v1;
116}
117
118/* CPU sysdev */
119static int viper_cpu_suspend(struct sys_device *sysdev, pm_message_t state)
120{
121 viper_icr_set_bit(VIPER_ICR_R_DIS);
122 return 0;
123}
124
125static int viper_cpu_resume(struct sys_device *sysdev)
126{
127 viper_icr_clear_bit(VIPER_ICR_R_DIS);
128 return 0;
129}
130
131static struct sysdev_driver viper_cpu_sysdev_driver = {
132 .suspend = viper_cpu_suspend,
133 .resume = viper_cpu_resume,
134};
135
136static unsigned int current_voltage_divisor;
137
138/*
139 * If force is not true then step from existing to new divisor. If
140 * force is true then jump straight to the new divisor. Stepping is
141 * used because if the jump in voltage is too large, the VCC can dip
142 * too low and the regulator cuts out.
143 *
144 * force can be used to initialize the divisor to a know state by
145 * setting the value for the current clock speed, since we are already
146 * running at that speed we know the voltage should be pretty close so
147 * the jump won't be too large
148 */
149static void viper_set_core_cpu_voltage(unsigned long khz, int force)
150{
151 int i = 0;
152 unsigned int divisor = 0;
153 const char *v;
154
155 if (khz < 200000) {
156 v = "1.0"; divisor = 0xfff;
157 } else if (khz < 300000) {
158 v = "1.1"; divisor = 0xde5;
159 } else {
160 v = "1.3"; divisor = 0x325;
161 }
162
163 pr_debug("viper: setting CPU core voltage to %sV at %d.%03dMHz\n",
164 v, (int)khz / 1000, (int)khz % 1000);
165
166#define STEP 0x100
167 do {
168 int step;
169
170 if (force)
171 step = divisor;
172 else if (current_voltage_divisor < divisor - STEP)
173 step = current_voltage_divisor + STEP;
174 else if (current_voltage_divisor > divisor + STEP)
175 step = current_voltage_divisor - STEP;
176 else
177 step = divisor;
178 force = 0;
179
180 gpio_set_value(VIPER_PSU_CLK_GPIO, 0);
181 gpio_set_value(VIPER_PSU_nCS_LD_GPIO, 0);
182
183 for (i = 1 << 11 ; i > 0 ; i >>= 1) {
184 udelay(1);
185
186 gpio_set_value(VIPER_PSU_DATA_GPIO, step & i);
187 udelay(1);
188
189 gpio_set_value(VIPER_PSU_CLK_GPIO, 1);
190 udelay(1);
191
192 gpio_set_value(VIPER_PSU_CLK_GPIO, 0);
193 }
194 udelay(1);
195
196 gpio_set_value(VIPER_PSU_nCS_LD_GPIO, 1);
197 udelay(1);
198
199 gpio_set_value(VIPER_PSU_nCS_LD_GPIO, 0);
200
201 current_voltage_divisor = step;
202 } while (current_voltage_divisor != divisor);
203}
204
205/* Interrupt handling */
206static unsigned long viper_irq_enabled_mask;
207
208static void viper_ack_irq(unsigned int irq)
209{
210 int viper_irq = irq - PXA_ISA_IRQ(0);
211
212 if (viper_irq < 8)
213 VIPER_LO_IRQ_STATUS = 1 << viper_irq;
214 else
215 VIPER_HI_IRQ_STATUS = 1 << (viper_irq - 8);
216}
217
218static void viper_mask_irq(unsigned int irq)
219{
220 viper_irq_enabled_mask &= ~(1 << (irq - PXA_ISA_IRQ(0)));
221}
222
223static void viper_unmask_irq(unsigned int irq)
224{
225 viper_irq_enabled_mask |= (1 << (irq - PXA_ISA_IRQ(0)));
226}
227
228static inline unsigned long viper_irq_pending(void)
229{
230 return (VIPER_HI_IRQ_STATUS << 8 | VIPER_LO_IRQ_STATUS) &
231 viper_irq_enabled_mask;
232}
233
234static void viper_irq_handler(unsigned int irq, struct irq_desc *desc)
235{
236 unsigned long pending;
237
238 pending = viper_irq_pending();
239 do {
240 if (likely(pending)) {
241 irq = PXA_ISA_IRQ(0) + __ffs(pending);
242 generic_handle_irq(irq);
243 }
244 pending = viper_irq_pending();
245 } while (pending);
246}
247
248static struct irq_chip viper_irq_chip = {
249 .name = "ISA",
250 .ack = viper_ack_irq,
251 .mask = viper_mask_irq,
252 .unmask = viper_unmask_irq
253};
254
255static void __init viper_init_irq(void)
256{
257 const int isa_irqs[] = { 3, 4, 5, 6, 7, 10, 11, 12, 9, 14, 15 };
258 int irq;
259 int isa_irq;
260
261 pxa25x_init_irq();
262
263 /* setup ISA IRQs */
264 for (irq = 0; irq < ARRAY_SIZE(isa_irqs); irq++) {
265 isa_irq = isa_irqs[irq];
266 set_irq_chip(isa_irq, &viper_irq_chip);
267 set_irq_handler(isa_irq, handle_edge_irq);
268 set_irq_flags(isa_irq, IRQF_VALID | IRQF_PROBE);
269 }
270
271 set_irq_chained_handler(gpio_to_irq(VIPER_CPLD_GPIO),
272 viper_irq_handler);
273 set_irq_type(gpio_to_irq(VIPER_CPLD_GPIO), IRQ_TYPE_EDGE_BOTH);
274
275#ifndef CONFIG_SERIAL_PXA
276 /*
277 * 8250 doesn't support IRQ_TYPE being passed as part
278 * of the plat_serial8250_port structure...
279 */
280 set_irq_type(gpio_to_irq(VIPER_UARTA_GPIO), IRQ_TYPE_EDGE_RISING);
281 set_irq_type(gpio_to_irq(VIPER_UARTB_GPIO), IRQ_TYPE_EDGE_RISING);
282#endif
283}
284
285/* Flat Panel */
286static struct pxafb_mode_info fb_mode_info[] = {
287 {
288 .pixclock = 157500,
289
290 .xres = 320,
291 .yres = 240,
292
293 .bpp = 16,
294
295 .hsync_len = 63,
296 .left_margin = 7,
297 .right_margin = 13,
298
299 .vsync_len = 20,
300 .upper_margin = 0,
301 .lower_margin = 0,
302
303 .sync = 0,
304 },
305};
306
307static struct pxafb_mach_info fb_info = {
308 .modes = fb_mode_info,
309 .num_modes = 1,
310 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
311};
312
313static int viper_backlight_init(struct device *dev)
314{
315 int ret;
316
317 /* GPIO9 and 10 control FB backlight. Initialise to off */
318 ret = gpio_request(VIPER_BCKLIGHT_EN_GPIO, "Backlight");
319 if (ret)
320 goto err_request_bckl;
321
322 ret = gpio_request(VIPER_LCD_EN_GPIO, "LCD");
323 if (ret)
324 goto err_request_lcd;
325
326 ret = gpio_direction_output(VIPER_BCKLIGHT_EN_GPIO, 0);
327 if (ret)
328 goto err_dir;
329
330 ret = gpio_direction_output(VIPER_LCD_EN_GPIO, 0);
331 if (ret)
332 goto err_dir;
333
334 return 0;
335
336err_dir:
337 gpio_free(VIPER_LCD_EN_GPIO);
338err_request_lcd:
339 gpio_free(VIPER_BCKLIGHT_EN_GPIO);
340err_request_bckl:
341 dev_err(dev, "Failed to setup LCD GPIOs\n");
342
343 return ret;
344}
345
346static int viper_backlight_notify(int brightness)
347{
348 gpio_set_value(VIPER_LCD_EN_GPIO, !!brightness);
349 gpio_set_value(VIPER_BCKLIGHT_EN_GPIO, !!brightness);
350
351 return brightness;
352}
353
354static void viper_backlight_exit(struct device *dev)
355{
356 gpio_free(VIPER_LCD_EN_GPIO);
357 gpio_free(VIPER_BCKLIGHT_EN_GPIO);
358}
359
360static struct platform_pwm_backlight_data viper_backlight_data = {
361 .pwm_id = 0,
362 .max_brightness = 100,
363 .dft_brightness = 100,
364 .pwm_period_ns = 1000000,
365 .init = viper_backlight_init,
366 .notify = viper_backlight_notify,
367 .exit = viper_backlight_exit,
368};
369
370static struct platform_device viper_backlight_device = {
371 .name = "pwm-backlight",
372 .dev = {
373 .parent = &pxa25x_device_pwm0.dev,
374 .platform_data = &viper_backlight_data,
375 },
376};
377
378/* Ethernet */
379static struct resource smc91x_resources[] = {
380 [0] = {
381 .name = "smc91x-regs",
382 .start = VIPER_ETH_PHYS + 0x300,
383 .end = VIPER_ETH_PHYS + 0x30f,
384 .flags = IORESOURCE_MEM,
385 },
386 [1] = {
387 .start = gpio_to_irq(VIPER_ETH_GPIO),
388 .end = gpio_to_irq(VIPER_ETH_GPIO),
389 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
390 },
391 [2] = {
392 .name = "smc91x-data32",
393 .start = VIPER_ETH_DATA_PHYS,
394 .end = VIPER_ETH_DATA_PHYS + 3,
395 .flags = IORESOURCE_MEM,
396 },
397};
398
399static struct smc91x_platdata viper_smc91x_info = {
400 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
401 .leda = RPC_LED_100_10,
402 .ledb = RPC_LED_TX_RX,
403};
404
405static struct platform_device smc91x_device = {
406 .name = "smc91x",
407 .id = -1,
408 .num_resources = ARRAY_SIZE(smc91x_resources),
409 .resource = smc91x_resources,
410 .dev = {
411 .platform_data = &viper_smc91x_info,
412 },
413};
414
415/* i2c */
416static struct i2c_gpio_platform_data i2c_bus_data = {
417 .sda_pin = VIPER_RTC_I2C_SDA_GPIO,
418 .scl_pin = VIPER_RTC_I2C_SCL_GPIO,
419 .udelay = 10,
420 .timeout = 100,
421};
422
423static struct platform_device i2c_bus_device = {
424 .name = "i2c-gpio",
425 .id = 1, /* pxa2xx-i2c is bus 0, so start at 1 */
426 .dev = {
427 .platform_data = &i2c_bus_data,
428 }
429};
430
431static struct i2c_board_info __initdata viper_i2c_devices[] = {
432 {
433 I2C_BOARD_INFO("ds1338", 0x68),
434 },
435};
436
437/*
438 * Serial configuration:
439 * You can either have the standard PXA ports driven by the PXA driver,
440 * or all the ports (PXA + 16850) driven by the 8250 driver.
441 * Choose your poison.
442 */
443
444static struct resource viper_serial_resources[] = {
445#ifndef CONFIG_SERIAL_PXA
446 {
447 .start = 0x40100000,
448 .end = 0x4010001f,
449 .flags = IORESOURCE_MEM,
450 },
451 {
452 .start = 0x40200000,
453 .end = 0x4020001f,
454 .flags = IORESOURCE_MEM,
455 },
456 {
457 .start = 0x40700000,
458 .end = 0x4070001f,
459 .flags = IORESOURCE_MEM,
460 },
461 {
462 .start = VIPER_UARTA_PHYS,
463 .end = VIPER_UARTA_PHYS + 0xf,
464 .flags = IORESOURCE_MEM,
465 },
466 {
467 .start = VIPER_UARTB_PHYS,
468 .end = VIPER_UARTB_PHYS + 0xf,
469 .flags = IORESOURCE_MEM,
470 },
471#else
472 {
473 0,
474 },
475#endif
476};
477
478static struct plat_serial8250_port serial_platform_data[] = {
479#ifndef CONFIG_SERIAL_PXA
480 /* Internal UARTs */
481 {
482 .membase = (void *)&FFUART,
483 .mapbase = __PREG(FFUART),
484 .irq = IRQ_FFUART,
485 .uartclk = 921600 * 16,
486 .regshift = 2,
487 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
488 .iotype = UPIO_MEM,
489 },
490 {
491 .membase = (void *)&BTUART,
492 .mapbase = __PREG(BTUART),
493 .irq = IRQ_BTUART,
494 .uartclk = 921600 * 16,
495 .regshift = 2,
496 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
497 .iotype = UPIO_MEM,
498 },
499 {
500 .membase = (void *)&STUART,
501 .mapbase = __PREG(STUART),
502 .irq = IRQ_STUART,
503 .uartclk = 921600 * 16,
504 .regshift = 2,
505 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
506 .iotype = UPIO_MEM,
507 },
508 /* External UARTs */
509 {
510 .mapbase = VIPER_UARTA_PHYS,
511 .irq = gpio_to_irq(VIPER_UARTA_GPIO),
512 .uartclk = 1843200,
513 .regshift = 1,
514 .iotype = UPIO_MEM,
515 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP |
516 UPF_SKIP_TEST,
517 },
518 {
519 .mapbase = VIPER_UARTB_PHYS,
520 .irq = gpio_to_irq(VIPER_UARTB_GPIO),
521 .uartclk = 1843200,
522 .regshift = 1,
523 .iotype = UPIO_MEM,
524 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP |
525 UPF_SKIP_TEST,
526 },
527#endif
528 { },
529};
530
531static struct platform_device serial_device = {
532 .name = "serial8250",
533 .id = 0,
534 .dev = {
535 .platform_data = serial_platform_data,
536 },
537 .num_resources = ARRAY_SIZE(viper_serial_resources),
538 .resource = viper_serial_resources,
539};
540
541/* USB */
542static void isp116x_delay(struct device *dev, int delay)
543{
544 ndelay(delay);
545}
546
547static struct resource isp116x_resources[] = {
548 [0] = { /* DATA */
549 .start = VIPER_USB_PHYS + 0,
550 .end = VIPER_USB_PHYS + 1,
551 .flags = IORESOURCE_MEM,
552 },
553 [1] = { /* ADDR */
554 .start = VIPER_USB_PHYS + 2,
555 .end = VIPER_USB_PHYS + 3,
556 .flags = IORESOURCE_MEM,
557 },
558 [2] = {
559 .start = gpio_to_irq(VIPER_USB_GPIO),
560 .end = gpio_to_irq(VIPER_USB_GPIO),
561 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
562 },
563};
564
565/* (DataBusWidth16|AnalogOCEnable|DREQOutputPolarity|DownstreamPort15KRSel ) */
566static struct isp116x_platform_data isp116x_platform_data = {
567 /* Enable internal resistors on downstream ports */
568 .sel15Kres = 1,
569 /* On-chip overcurrent protection */
570 .oc_enable = 1,
571 /* INT output polarity */
572 .int_act_high = 1,
573 /* INT edge or level triggered */
574 .int_edge_triggered = 0,
575
576 /* WAKEUP pin connected - NOT SUPPORTED */
577 /* .remote_wakeup_connected = 0, */
578 /* Wakeup by devices on usb bus enabled */
579 .remote_wakeup_enable = 0,
580 .delay = isp116x_delay,
581};
582
583static struct platform_device isp116x_device = {
584 .name = "isp116x-hcd",
585 .id = -1,
586 .num_resources = ARRAY_SIZE(isp116x_resources),
587 .resource = isp116x_resources,
588 .dev = {
589 .platform_data = &isp116x_platform_data,
590 },
591
592};
593
594/* MTD */
595static struct resource mtd_resources[] = {
596 [0] = { /* RedBoot config + filesystem flash */
597 .start = VIPER_FLASH_PHYS,
598 .end = VIPER_FLASH_PHYS + SZ_32M - 1,
599 .flags = IORESOURCE_MEM,
600 },
601 [1] = { /* Boot flash */
602 .start = VIPER_BOOT_PHYS,
603 .end = VIPER_BOOT_PHYS + SZ_1M - 1,
604 .flags = IORESOURCE_MEM,
605 },
606 [2] = { /*
607 * SRAM size is actually 256KB, 8bits, with a sparse mapping
608 * (each byte is on a 16bit boundary).
609 */
610 .start = _VIPER_SRAM_BASE,
611 .end = _VIPER_SRAM_BASE + SZ_512K - 1,
612 .flags = IORESOURCE_MEM,
613 },
614};
615
616static struct mtd_partition viper_boot_flash_partition = {
617 .name = "RedBoot",
618 .size = SZ_1M,
619 .offset = 0,
620 .mask_flags = MTD_WRITEABLE, /* force R/O */
621};
622
623static struct physmap_flash_data viper_flash_data[] = {
624 [0] = {
625 .width = 2,
626 .parts = NULL,
627 .nr_parts = 0,
628 },
629 [1] = {
630 .width = 2,
631 .parts = &viper_boot_flash_partition,
632 .nr_parts = 1,
633 },
634};
635
636static struct platform_device viper_mtd_devices[] = {
637 [0] = {
638 .name = "physmap-flash",
639 .id = 0,
640 .dev = {
641 .platform_data = &viper_flash_data[0],
642 },
643 .resource = &mtd_resources[0],
644 .num_resources = 1,
645 },
646 [1] = {
647 .name = "physmap-flash",
648 .id = 1,
649 .dev = {
650 .platform_data = &viper_flash_data[1],
651 },
652 .resource = &mtd_resources[1],
653 .num_resources = 1,
654 },
655};
656
657static struct platform_device *viper_devs[] __initdata = {
658 &smc91x_device,
659 &i2c_bus_device,
660 &serial_device,
661 &isp116x_device,
662 &viper_mtd_devices[0],
663 &viper_mtd_devices[1],
664 &viper_backlight_device,
665};
666
667static mfp_cfg_t viper_pin_config[] __initdata = {
668 /* Chip selects */
669 GPIO15_nCS_1,
670 GPIO78_nCS_2,
671 GPIO79_nCS_3,
672 GPIO80_nCS_4,
673 GPIO33_nCS_5,
674
675 /* FP Backlight */
676 GPIO9_GPIO, /* VIPER_BCKLIGHT_EN_GPIO */
677 GPIO10_GPIO, /* VIPER_LCD_EN_GPIO */
678 GPIO16_PWM0_OUT,
679
680 /* Ethernet PHY Ready */
681 GPIO18_RDY,
682
683 /* Serial shutdown */
684 GPIO12_GPIO | MFP_LPM_DRIVE_HIGH, /* VIPER_UART_SHDN_GPIO */
685
686 /* Compact-Flash / PC104 */
687 GPIO48_nPOE,
688 GPIO49_nPWE,
689 GPIO50_nPIOR,
690 GPIO51_nPIOW,
691 GPIO52_nPCE_1,
692 GPIO53_nPCE_2,
693 GPIO54_nPSKTSEL,
694 GPIO55_nPREG,
695 GPIO56_nPWAIT,
696 GPIO57_nIOIS16,
697 GPIO8_GPIO, /* VIPER_CF_RDY_GPIO */
698 GPIO32_GPIO, /* VIPER_CF_CD_GPIO */
699 GPIO82_GPIO, /* VIPER_CF_POWER_GPIO */
700
701 /* Integrated UPS control */
702 GPIO20_GPIO, /* VIPER_UPS_GPIO */
703
704 /* Vcc regulator control */
705 GPIO6_GPIO, /* VIPER_PSU_DATA_GPIO */
706 GPIO11_GPIO, /* VIPER_PSU_CLK_GPIO */
707 GPIO19_GPIO, /* VIPER_PSU_nCS_LD_GPIO */
708
709 /* i2c busses */
710 GPIO26_GPIO, /* VIPER_TPM_I2C_SDA_GPIO */
711 GPIO27_GPIO, /* VIPER_TPM_I2C_SCL_GPIO */
712 GPIO83_GPIO, /* VIPER_RTC_I2C_SDA_GPIO */
713 GPIO84_GPIO, /* VIPER_RTC_I2C_SCL_GPIO */
714
715 /* PC/104 Interrupt */
716 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE, /* VIPER_CPLD_GPIO */
717};
718
719static unsigned long viper_tpm;
720
721static int __init viper_tpm_setup(char *str)
722{
723 strict_strtoul(str, 10, &viper_tpm);
724 return 1;
725}
726
727__setup("tpm=", viper_tpm_setup);
728
729static void __init viper_tpm_init(void)
730{
731 struct platform_device *tpm_device;
732 struct i2c_gpio_platform_data i2c_tpm_data = {
733 .sda_pin = VIPER_TPM_I2C_SDA_GPIO,
734 .scl_pin = VIPER_TPM_I2C_SCL_GPIO,
735 .udelay = 10,
736 .timeout = 100,
737 };
738 char *errstr;
739
740 /* Allocate TPM i2c bus if requested */
741 if (!viper_tpm)
742 return;
743
744 tpm_device = platform_device_alloc("i2c-gpio", 2);
745 if (tpm_device) {
746 if (!platform_device_add_data(tpm_device,
747 &i2c_tpm_data,
748 sizeof(i2c_tpm_data))) {
749 if (platform_device_add(tpm_device)) {
750 errstr = "register TPM i2c bus";
751 goto error_free_tpm;
752 }
753 } else {
754 errstr = "allocate TPM i2c bus data";
755 goto error_free_tpm;
756 }
757 } else {
758 errstr = "allocate TPM i2c device";
759 goto error_tpm;
760 }
761
762 return;
763
764error_free_tpm:
765 kfree(tpm_device);
766error_tpm:
767 pr_err("viper: Couldn't %s, giving up\n", errstr);
768}
769
770static void __init viper_init_vcore_gpios(void)
771{
772 if (gpio_request(VIPER_PSU_DATA_GPIO, "PSU data"))
773 goto err_request_data;
774
775 if (gpio_request(VIPER_PSU_CLK_GPIO, "PSU clock"))
776 goto err_request_clk;
777
778 if (gpio_request(VIPER_PSU_nCS_LD_GPIO, "PSU cs"))
779 goto err_request_cs;
780
781 if (gpio_direction_output(VIPER_PSU_DATA_GPIO, 0) ||
782 gpio_direction_output(VIPER_PSU_CLK_GPIO, 0) ||
783 gpio_direction_output(VIPER_PSU_nCS_LD_GPIO, 0))
784 goto err_dir;
785
786 /* c/should assume redboot set the correct level ??? */
787 viper_set_core_cpu_voltage(get_clk_frequency_khz(0), 1);
788
789 return;
790
791err_dir:
792 gpio_free(VIPER_PSU_nCS_LD_GPIO);
793err_request_cs:
794 gpio_free(VIPER_PSU_CLK_GPIO);
795err_request_clk:
796 gpio_free(VIPER_PSU_DATA_GPIO);
797err_request_data:
798 pr_err("viper: Failed to setup vcore control GPIOs\n");
799}
800
801static void __init viper_init_serial_gpio(void)
802{
803 if (gpio_request(VIPER_UART_SHDN_GPIO, "UARTs shutdown"))
804 goto err_request;
805
806 if (gpio_direction_output(VIPER_UART_SHDN_GPIO, 0))
807 goto err_dir;
808
809 return;
810
811err_dir:
812 gpio_free(VIPER_UART_SHDN_GPIO);
813err_request:
814 pr_err("viper: Failed to setup UART shutdown GPIO\n");
815}
816
817#ifdef CONFIG_CPU_FREQ
818static int viper_cpufreq_notifier(struct notifier_block *nb,
819 unsigned long val, void *data)
820{
821 struct cpufreq_freqs *freq = data;
822
823 /* TODO: Adjust timings??? */
824
825 switch (val) {
826 case CPUFREQ_PRECHANGE:
827 if (freq->old < freq->new) {
828 /* we are getting faster so raise the voltage
829 * before we change freq */
830 viper_set_core_cpu_voltage(freq->new, 0);
831 }
832 break;
833 case CPUFREQ_POSTCHANGE:
834 if (freq->old > freq->new) {
835 /* we are slowing down so drop the power
836 * after we change freq */
837 viper_set_core_cpu_voltage(freq->new, 0);
838 }
839 break;
840 case CPUFREQ_RESUMECHANGE:
841 viper_set_core_cpu_voltage(freq->new, 0);
842 break;
843 default:
844 /* ignore */
845 break;
846 }
847
848 return 0;
849}
850
851static struct notifier_block viper_cpufreq_notifier_block = {
852 .notifier_call = viper_cpufreq_notifier
853};
854
855static void __init viper_init_cpufreq(void)
856{
857 if (cpufreq_register_notifier(&viper_cpufreq_notifier_block,
858 CPUFREQ_TRANSITION_NOTIFIER))
859 pr_err("viper: Failed to setup cpufreq notifier\n");
860}
861#else
862static inline void viper_init_cpufreq(void) {}
863#endif
864
865static void viper_power_off(void)
866{
867 pr_notice("Shutting off UPS\n");
868 gpio_set_value(VIPER_UPS_GPIO, 1);
869 /* Spin to death... */
870 while (1);
871}
872
873static void __init viper_init(void)
874{
875 u8 version;
876
877 pm_power_off = viper_power_off;
878
879 pxa2xx_mfp_config(ARRAY_AND_SIZE(viper_pin_config));
880
881 /* Wake-up serial console */
882 viper_init_serial_gpio();
883
884 set_pxa_fb_info(&fb_info);
885
886 /* v1 hardware cannot use the datacs line */
887 version = viper_hw_version();
888 if (version == 0)
889 smc91x_device.num_resources--;
890
891 pxa_set_i2c_info(NULL);
892 platform_add_devices(viper_devs, ARRAY_SIZE(viper_devs));
893
894 viper_init_vcore_gpios();
895 viper_init_cpufreq();
896
897 sysdev_driver_register(&cpu_sysdev_class, &viper_cpu_sysdev_driver);
898
899 if (version) {
900 pr_info("viper: hardware v%di%d detected. "
901 "CPLD revision %d.\n",
902 VIPER_BOARD_VERSION(version),
903 VIPER_BOARD_ISSUE(version),
904 VIPER_CPLD_REVISION(version));
905 system_rev = (VIPER_BOARD_VERSION(version) << 8) |
906 (VIPER_BOARD_ISSUE(version) << 4) |
907 VIPER_CPLD_REVISION(version);
908 } else {
909 pr_info("viper: No version register.\n");
910 }
911
912 i2c_register_board_info(1, ARRAY_AND_SIZE(viper_i2c_devices));
913
914 viper_tpm_init();
915 pxa_set_ac97_info(NULL);
916}
917
918static struct map_desc viper_io_desc[] __initdata = {
919 {
920 .virtual = VIPER_CPLD_BASE,
921 .pfn = __phys_to_pfn(VIPER_CPLD_PHYS),
922 .length = 0x00300000,
923 .type = MT_DEVICE,
924 },
925 {
926 .virtual = VIPER_PC104IO_BASE,
927 .pfn = __phys_to_pfn(_PCMCIA1IO),
928 .length = 0x00800000,
929 .type = MT_DEVICE,
930 },
931};
932
933static void __init viper_map_io(void)
934{
935 pxa_map_io();
936
937 iotable_init(viper_io_desc, ARRAY_SIZE(viper_io_desc));
938
939 PCFR |= PCFR_OPDE;
940}
941
942MACHINE_START(VIPER, "Arcom/Eurotech VIPER SBC")
943 /* Maintainer: Marc Zyngier <maz@misterjones.org> */
944 .phys_io = 0x40000000,
945 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
946 .boot_params = 0xa0000100,
947 .map_io = viper_map_io,
948 .init_irq = viper_init_irq,
949 .timer = &pxa_timer,
950 .init_machine = viper_init,
951MACHINE_END
diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c
index 0cb65b5772fe..813804433466 100644
--- a/arch/arm/mach-pxa/zylonite.c
+++ b/arch/arm/mach-pxa/zylonite.c
@@ -29,6 +29,7 @@
29#include <mach/pxafb.h> 29#include <mach/pxafb.h>
30#include <mach/zylonite.h> 30#include <mach/zylonite.h>
31#include <mach/mmc.h> 31#include <mach/mmc.h>
32#include <mach/ohci.h>
32#include <mach/pxa27x_keypad.h> 33#include <mach/pxa27x_keypad.h>
33#include <mach/pxa3xx_nand.h> 34#include <mach/pxa3xx_nand.h>
34 35
@@ -423,6 +424,21 @@ static void __init zylonite_init_nand(void)
423static inline void zylonite_init_nand(void) {} 424static inline void zylonite_init_nand(void) {}
424#endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */ 425#endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
425 426
427#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
428static struct pxaohci_platform_data zylonite_ohci_info = {
429 .port_mode = PMM_PERPORT_MODE,
430 .flags = ENABLE_PORT1 | ENABLE_PORT2 |
431 POWER_CONTROL_LOW | POWER_SENSE_LOW,
432};
433
434static void __init zylonite_init_ohci(void)
435{
436 pxa_set_ohci_info(&zylonite_ohci_info);
437}
438#else
439static inline void zylonite_init_ohci(void) {}
440#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
441
426static void __init zylonite_init(void) 442static void __init zylonite_init(void)
427{ 443{
428 /* board-processor specific initialization */ 444 /* board-processor specific initialization */
@@ -443,6 +459,7 @@ static void __init zylonite_init(void)
443 zylonite_init_keypad(); 459 zylonite_init_keypad();
444 zylonite_init_nand(); 460 zylonite_init_nand();
445 zylonite_init_leds(); 461 zylonite_init_leds();
462 zylonite_init_ohci();
446} 463}
447 464
448MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)") 465MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
diff --git a/arch/arm/mach-pxa/zylonite_pxa300.c b/arch/arm/mach-pxa/zylonite_pxa300.c
index 095f5c648236..46538885a58a 100644
--- a/arch/arm/mach-pxa/zylonite_pxa300.c
+++ b/arch/arm/mach-pxa/zylonite_pxa300.c
@@ -73,6 +73,12 @@ static mfp_cfg_t common_mfp_cfg[] __initdata = {
73 GPIO27_AC97_SDATA_OUT, 73 GPIO27_AC97_SDATA_OUT,
74 GPIO28_AC97_SYNC, 74 GPIO28_AC97_SYNC,
75 75
76 /* SSP3 */
77 GPIO91_SSP3_SCLK,
78 GPIO92_SSP3_FRM,
79 GPIO93_SSP3_TXD,
80 GPIO94_SSP3_RXD,
81
76 /* WM9713 IRQ */ 82 /* WM9713 IRQ */
77 GPIO26_GPIO, 83 GPIO26_GPIO,
78 84
@@ -113,6 +119,10 @@ static mfp_cfg_t common_mfp_cfg[] __initdata = {
113 GPIO13_MMC2_CLK, 119 GPIO13_MMC2_CLK,
114 GPIO14_MMC2_CMD, 120 GPIO14_MMC2_CMD,
115 121
122 /* USB Host */
123 GPIO0_2_USBH_PEN,
124 GPIO1_2_USBH_PWR,
125
116 /* Standard I2C */ 126 /* Standard I2C */
117 GPIO21_I2C_SCL, 127 GPIO21_I2C_SCL,
118 GPIO22_I2C_SDA, 128 GPIO22_I2C_SDA,
@@ -209,7 +219,7 @@ static struct pca953x_platform_data gpio_exp[] = {
209 }, 219 },
210}; 220};
211 221
212struct i2c_board_info zylonite_i2c_board_info[] = { 222static struct i2c_board_info zylonite_i2c_board_info[] = {
213 { 223 {
214 .type = "pca9539", 224 .type = "pca9539",
215 .addr = 0x74, 225 .addr = 0x74,
diff --git a/arch/arm/mach-pxa/zylonite_pxa320.c b/arch/arm/mach-pxa/zylonite_pxa320.c
index 9879d7da2df5..0f244744daae 100644
--- a/arch/arm/mach-pxa/zylonite_pxa320.c
+++ b/arch/arm/mach-pxa/zylonite_pxa320.c
@@ -69,6 +69,12 @@ static mfp_cfg_t mfp_cfg[] __initdata = {
69 GPIO39_AC97_BITCLK, 69 GPIO39_AC97_BITCLK,
70 GPIO40_AC97_nACRESET, 70 GPIO40_AC97_nACRESET,
71 71
72 /* SSP3 */
73 GPIO89_SSP3_SCLK,
74 GPIO90_SSP3_FRM,
75 GPIO91_SSP3_TXD,
76 GPIO92_SSP3_RXD,
77
72 /* WM9713 IRQ */ 78 /* WM9713 IRQ */
73 GPIO15_GPIO, 79 GPIO15_GPIO,
74 80
@@ -117,6 +123,10 @@ static mfp_cfg_t mfp_cfg[] __initdata = {
117 GPIO28_MMC2_CLK, 123 GPIO28_MMC2_CLK,
118 GPIO29_MMC2_CMD, 124 GPIO29_MMC2_CMD,
119 125
126 /* USB Host */
127 GPIO2_2_USBH_PEN,
128 GPIO3_2_USBH_PWR,
129
120 /* Debug LEDs */ 130 /* Debug LEDs */
121 GPIO1_2_GPIO | MFP_LPM_DRIVE_HIGH, 131 GPIO1_2_GPIO | MFP_LPM_DRIVE_HIGH,
122 GPIO4_2_GPIO | MFP_LPM_DRIVE_HIGH, 132 GPIO4_2_GPIO | MFP_LPM_DRIVE_HIGH,
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 4f9c84ab781c..2f04d54711e7 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -27,10 +27,10 @@
27#include <linux/amba/clcd.h> 27#include <linux/amba/clcd.h>
28#include <linux/clocksource.h> 28#include <linux/clocksource.h>
29#include <linux/clockchips.h> 29#include <linux/clockchips.h>
30#include <linux/io.h>
30 31
31#include <asm/system.h> 32#include <asm/system.h>
32#include <mach/hardware.h> 33#include <mach/hardware.h>
33#include <asm/io.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <asm/leds.h> 35#include <asm/leds.h>
36#include <asm/hardware/arm_timer.h> 36#include <asm/hardware/arm_timer.h>
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h
index 33dbbb41a663..3cea92c70d8f 100644
--- a/arch/arm/mach-realview/core.h
+++ b/arch/arm/mach-realview/core.h
@@ -23,9 +23,9 @@
23#define __ASM_ARCH_REALVIEW_H 23#define __ASM_ARCH_REALVIEW_H
24 24
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/io.h>
26 27
27#include <asm/leds.h> 28#include <asm/leds.h>
28#include <asm/io.h>
29 29
30#define AMBA_DEVICE(name,busid,base,plat) \ 30#define AMBA_DEVICE(name,busid,base,plat) \
31static struct amba_device name##_device = { \ 31static struct amba_device name##_device = { \
diff --git a/arch/arm/mach-realview/include/mach/system.h b/arch/arm/mach-realview/include/mach/system.h
index 4d3c8f3f8053..a2f61c78adbf 100644
--- a/arch/arm/mach-realview/include/mach/system.h
+++ b/arch/arm/mach-realview/include/mach/system.h
@@ -21,8 +21,8 @@
21#ifndef __ASM_ARCH_SYSTEM_H 21#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H 22#define __ASM_ARCH_SYSTEM_H
23 23
24#include <linux/io.h>
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/io.h>
26#include <mach/platform.h> 26#include <mach/platform.h>
27 27
28static inline void arch_idle(void) 28static inline void arch_idle(void)
diff --git a/arch/arm/mach-realview/localtimer.c b/arch/arm/mach-realview/localtimer.c
index 82fa1f26e026..44d178cd5733 100644
--- a/arch/arm/mach-realview/localtimer.c
+++ b/arch/arm/mach-realview/localtimer.c
@@ -17,11 +17,11 @@
17#include <linux/percpu.h> 17#include <linux/percpu.h>
18#include <linux/clockchips.h> 18#include <linux/clockchips.h>
19#include <linux/irq.h> 19#include <linux/irq.h>
20#include <linux/io.h>
20 21
21#include <asm/hardware/arm_twd.h> 22#include <asm/hardware/arm_twd.h>
22#include <asm/hardware/gic.h> 23#include <asm/hardware/gic.h>
23#include <mach/hardware.h> 24#include <mach/hardware.h>
24#include <asm/io.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26 26
27static DEFINE_PER_CPU(struct clock_event_device, local_clockevent); 27static DEFINE_PER_CPU(struct clock_event_device, local_clockevent);
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index 1907d22f4fed..e102aeb0f76e 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -13,10 +13,10 @@
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/smp.h> 15#include <linux/smp.h>
16#include <linux/io.h>
16 17
17#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
18#include <mach/hardware.h> 19#include <mach/hardware.h>
19#include <asm/io.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21 21
22#include <mach/board-eb.h> 22#include <mach/board-eb.h>
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index 19a9968fc5b9..eb829eb1ebe2 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -23,9 +23,9 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/sysdev.h> 24#include <linux/sysdev.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/io.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/leds.h> 30#include <asm/leds.h>
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c
index 0986cbd15943..cccdb3eb90fe 100644
--- a/arch/arm/mach-realview/realview_pb1176.c
+++ b/arch/arm/mach-realview/realview_pb1176.c
@@ -23,9 +23,9 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/sysdev.h> 24#include <linux/sysdev.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/io.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/leds.h> 30#include <asm/leds.h>
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c
index f4e7135e3eb5..8b863148ec18 100644
--- a/arch/arm/mach-realview/realview_pb11mp.c
+++ b/arch/arm/mach-realview/realview_pb11mp.c
@@ -23,9 +23,9 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/sysdev.h> 24#include <linux/sysdev.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/io.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/leds.h> 30#include <asm/leds.h>
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
diff --git a/arch/arm/mach-rpc/dma.c b/arch/arm/mach-rpc/dma.c
index 4b19fe484190..7958a30f8932 100644
--- a/arch/arm/mach-rpc/dma.c
+++ b/arch/arm/mach-rpc/dma.c
@@ -14,11 +14,11 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/io.h>
17 18
18#include <asm/page.h> 19#include <asm/page.h>
19#include <asm/dma.h> 20#include <asm/dma.h>
20#include <asm/fiq.h> 21#include <asm/fiq.h>
21#include <asm/io.h>
22#include <asm/irq.h> 22#include <asm/irq.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
diff --git a/arch/arm/mach-rpc/include/mach/memory.h b/arch/arm/mach-rpc/include/mach/memory.h
index 05425d558ee7..9bf7e43e2863 100644
--- a/arch/arm/mach-rpc/include/mach/memory.h
+++ b/arch/arm/mach-rpc/include/mach/memory.h
@@ -36,4 +36,12 @@
36#define FLUSH_BASE_PHYS 0x00000000 36#define FLUSH_BASE_PHYS 0x00000000
37#define FLUSH_BASE 0xdf000000 37#define FLUSH_BASE 0xdf000000
38 38
39/*
40 * Sparsemem support. Each section is a maximum of 64MB. The sections
41 * are offset by 128MB and can cover 128MB, so that gives us a maximum
42 * of 29 physmem bits.
43 */
44#define MAX_PHYSMEM_BITS 29
45#define SECTION_SIZE_BITS 26
46
39#endif 47#endif
diff --git a/arch/arm/mach-rpc/include/mach/system.h b/arch/arm/mach-rpc/include/mach/system.h
index 54d6e3f2d319..bd7268ba17e2 100644
--- a/arch/arm/mach-rpc/include/mach/system.h
+++ b/arch/arm/mach-rpc/include/mach/system.h
@@ -7,9 +7,9 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#include <linux/io.h>
10#include <mach/hardware.h> 11#include <mach/hardware.h>
11#include <asm/hardware/iomd.h> 12#include <asm/hardware/iomd.h>
12#include <asm/io.h>
13 13
14static inline void arch_idle(void) 14static inline void arch_idle(void)
15{ 15{
diff --git a/arch/arm/mach-rpc/include/mach/uncompress.h b/arch/arm/mach-rpc/include/mach/uncompress.h
index baa9c866d7bf..d5862368c4f2 100644
--- a/arch/arm/mach-rpc/include/mach/uncompress.h
+++ b/arch/arm/mach-rpc/include/mach/uncompress.h
@@ -9,8 +9,8 @@
9 */ 9 */
10#define VIDMEM ((char *)SCREEN_START) 10#define VIDMEM ((char *)SCREEN_START)
11 11
12#include <linux/io.h>
12#include <mach/hardware.h> 13#include <mach/hardware.h>
13#include <asm/io.h>
14#include <asm/setup.h> 14#include <asm/setup.h>
15#include <asm/page.h> 15#include <asm/page.h>
16 16
diff --git a/arch/arm/mach-rpc/irq.c b/arch/arm/mach-rpc/irq.c
index 7a029621db43..9dd15d679c5d 100644
--- a/arch/arm/mach-rpc/irq.c
+++ b/arch/arm/mach-rpc/irq.c
@@ -1,10 +1,10 @@
1#include <linux/init.h> 1#include <linux/init.h>
2#include <linux/list.h> 2#include <linux/list.h>
3#include <linux/io.h>
3 4
4#include <asm/mach/irq.h> 5#include <asm/mach/irq.h>
5#include <asm/hardware/iomd.h> 6#include <asm/hardware/iomd.h>
6#include <asm/irq.h> 7#include <asm/irq.h>
7#include <asm/io.h>
8 8
9static void iomd_ack_irq_a(unsigned int irq) 9static void iomd_ack_irq_a(unsigned int irq)
10{ 10{
diff --git a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
index ce8470fea887..e88d417736af 100644
--- a/arch/arm/mach-rpc/riscpc.c
+++ b/arch/arm/mach-rpc/riscpc.c
@@ -18,9 +18,9 @@
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/serial_8250.h> 19#include <linux/serial_8250.h>
20#include <linux/ata_platform.h> 20#include <linux/ata_platform.h>
21#include <linux/io.h>
21 22
22#include <asm/elf.h> 23#include <asm/elf.h>
23#include <asm/io.h>
24#include <asm/mach-types.h> 24#include <asm/mach-types.h>
25#include <mach/hardware.h> 25#include <mach/hardware.h>
26#include <asm/page.h> 26#include <asm/page.h>
diff --git a/arch/arm/mach-s3c2400/gpio.c b/arch/arm/mach-s3c2400/gpio.c
index 148d0ddef3e8..7a7ed4174c8c 100644
--- a/arch/arm/mach-s3c2400/gpio.c
+++ b/arch/arm/mach-s3c2400/gpio.c
@@ -24,10 +24,10 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/io.h>
31 31
32#include <mach/regs-gpio.h> 32#include <mach/regs-gpio.h>
33 33
diff --git a/arch/arm/mach-s3c2410/bast-irq.c b/arch/arm/mach-s3c2410/bast-irq.c
index c66021b5fa4d..75738000272b 100644
--- a/arch/arm/mach-s3c2410/bast-irq.c
+++ b/arch/arm/mach-s3c2410/bast-irq.c
@@ -25,12 +25,12 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/io.h>
28 29
29#include <asm/mach-types.h> 30#include <asm/mach-types.h>
30 31
31#include <mach/hardware.h> 32#include <mach/hardware.h>
32#include <asm/irq.h> 33#include <asm/irq.h>
33#include <asm/io.h>
34 34
35#include <asm/mach/irq.h> 35#include <asm/mach/irq.h>
36 36
@@ -130,8 +130,7 @@ bast_irq_pc104_demux(unsigned int irq,
130 for (i = 0; stat != 0; i++, stat >>= 1) { 130 for (i = 0; stat != 0; i++, stat >>= 1) {
131 if (stat & 1) { 131 if (stat & 1) {
132 irqno = bast_pc104_irqs[i]; 132 irqno = bast_pc104_irqs[i];
133 desc = irq_desc + irqno; 133 generic_handle_irq(irqno);
134 desc_handle_irq(irqno, desc);
135 } 134 }
136 } 135 }
137 } 136 }
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index 1322851d1acb..fef646c36b54 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -31,11 +31,11 @@
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/serial_core.h> 33#include <linux/serial_core.h>
34#include <linux/io.h>
34 35
35#include <asm/mach/map.h> 36#include <asm/mach/map.h>
36 37
37#include <mach/hardware.h> 38#include <mach/hardware.h>
38#include <asm/io.h>
39 39
40#include <asm/plat-s3c/regs-serial.h> 40#include <asm/plat-s3c/regs-serial.h>
41#include <mach/regs-clock.h> 41#include <mach/regs-clock.h>
diff --git a/arch/arm/mach-s3c2410/gpio.c b/arch/arm/mach-s3c2410/gpio.c
index c6eefb1d590c..36a3132f39e7 100644
--- a/arch/arm/mach-s3c2410/gpio.c
+++ b/arch/arm/mach-s3c2410/gpio.c
@@ -25,10 +25,10 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/io.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/irq.h> 31#include <asm/irq.h>
31#include <asm/io.h>
32 32
33#include <mach/regs-gpio.h> 33#include <mach/regs-gpio.h>
34 34
diff --git a/arch/arm/mach-s3c2410/include/mach/system-reset.h b/arch/arm/mach-s3c2410/include/mach/system-reset.h
index ec2defebf0d5..43535a0e7186 100644
--- a/arch/arm/mach-s3c2410/include/mach/system-reset.h
+++ b/arch/arm/mach-s3c2410/include/mach/system-reset.h
@@ -11,7 +11,7 @@
11*/ 11*/
12 12
13#include <mach/hardware.h> 13#include <mach/hardware.h>
14#include <asm/io.h> 14#include <linux/io.h>
15 15
16#include <asm/plat-s3c/regs-watchdog.h> 16#include <asm/plat-s3c/regs-watchdog.h>
17#include <mach/regs-clock.h> 17#include <mach/regs-clock.h>
diff --git a/arch/arm/mach-s3c2410/include/mach/system.h b/arch/arm/mach-s3c2410/include/mach/system.h
index e9f676bc0116..a8cbca6701e5 100644
--- a/arch/arm/mach-s3c2410/include/mach/system.h
+++ b/arch/arm/mach-s3c2410/include/mach/system.h
@@ -10,8 +10,8 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11*/ 11*/
12 12
13#include <linux/io.h>
13#include <mach/hardware.h> 14#include <mach/hardware.h>
14#include <asm/io.h>
15 15
16#include <mach/map.h> 16#include <mach/map.h>
17#include <mach/idle.h> 17#include <mach/idle.h>
diff --git a/arch/arm/mach-s3c2410/mach-amlm5900.c b/arch/arm/mach-s3c2410/mach-amlm5900.c
index f0de3c23ce78..527f88a288ec 100644
--- a/arch/arm/mach-s3c2410/mach-amlm5900.c
+++ b/arch/arm/mach-s3c2410/mach-amlm5900.c
@@ -36,6 +36,7 @@
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/serial_core.h> 38#include <linux/serial_core.h>
39#include <linux/io.h>
39 40
40#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
41#include <asm/mach/map.h> 42#include <asm/mach/map.h>
@@ -43,7 +44,6 @@
43#include <asm/mach/flash.h> 44#include <asm/mach/flash.h>
44 45
45#include <mach/hardware.h> 46#include <mach/hardware.h>
46#include <asm/io.h>
47#include <asm/irq.h> 47#include <asm/irq.h>
48#include <asm/mach-types.h> 48#include <asm/mach-types.h>
49#include <mach/fb.h> 49#include <mach/fb.h>
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index 24c6334fac89..e4368e6e7e6c 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -22,6 +22,7 @@
22#include <linux/dm9000.h> 22#include <linux/dm9000.h>
23#include <linux/ata_platform.h> 23#include <linux/ata_platform.h>
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/io.h>
25 26
26#include <net/ax88796.h> 27#include <net/ax88796.h>
27 28
@@ -34,7 +35,6 @@
34#include <mach/bast-cpld.h> 35#include <mach/bast-cpld.h>
35 36
36#include <mach/hardware.h> 37#include <mach/hardware.h>
37#include <asm/io.h>
38#include <asm/irq.h> 38#include <asm/irq.h>
39#include <asm/mach-types.h> 39#include <asm/mach-types.h>
40 40
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index e35933a46d10..85e710f2863b 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -20,13 +20,13 @@
20#include <linux/sysdev.h> 20#include <linux/sysdev.h>
21#include <linux/serial_core.h> 21#include <linux/serial_core.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/io.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
26#include <asm/mach/irq.h> 27#include <asm/mach/irq.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
32 32
diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c
index 80fe2ed0775c..3ece2d04934e 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c2410/mach-n30.c
@@ -25,9 +25,9 @@
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/serial_core.h> 26#include <linux/serial_core.h>
27#include <linux/timer.h> 27#include <linux/timer.h>
28#include <linux/io.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/io.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
diff --git a/arch/arm/mach-s3c2410/mach-otom.c b/arch/arm/mach-s3c2410/mach-otom.c
index 606ee15911b6..c4dfe3eabe1d 100644
--- a/arch/arm/mach-s3c2410/mach-otom.c
+++ b/arch/arm/mach-s3c2410/mach-otom.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/serial_core.h> 18#include <linux/serial_core.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/io.h>
20 21
21#include <asm/mach/arch.h> 22#include <asm/mach/arch.h>
22#include <asm/mach/map.h> 23#include <asm/mach/map.h>
@@ -25,7 +26,6 @@
25#include <mach/otom-map.h> 26#include <mach/otom-map.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31 31
diff --git a/arch/arm/mach-s3c2410/mach-qt2410.c b/arch/arm/mach-s3c2410/mach-qt2410.c
index 7d34844debde..97c13192315b 100644
--- a/arch/arm/mach-s3c2410/mach-qt2410.c
+++ b/arch/arm/mach-s3c2410/mach-qt2410.c
@@ -32,7 +32,7 @@
32#include <linux/serial_core.h> 32#include <linux/serial_core.h>
33#include <linux/spi/spi.h> 33#include <linux/spi/spi.h>
34#include <linux/spi/spi_bitbang.h> 34#include <linux/spi/spi_bitbang.h>
35 35#include <linux/io.h>
36#include <linux/mtd/mtd.h> 36#include <linux/mtd/mtd.h>
37#include <linux/mtd/nand.h> 37#include <linux/mtd/nand.h>
38#include <linux/mtd/nand_ecc.h> 38#include <linux/mtd/nand_ecc.h>
@@ -43,7 +43,6 @@
43#include <asm/mach/irq.h> 43#include <asm/mach/irq.h>
44 44
45#include <mach/hardware.h> 45#include <mach/hardware.h>
46#include <asm/io.h>
47#include <asm/irq.h> 46#include <asm/irq.h>
48#include <asm/mach-types.h> 47#include <asm/mach-types.h>
49 48
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c
index b88939d72282..d49e58acb03b 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2410.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2410.c
@@ -36,13 +36,13 @@
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/serial_core.h> 37#include <linux/serial_core.h>
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/io.h>
39 40
40#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
41#include <asm/mach/map.h> 42#include <asm/mach/map.h>
42#include <asm/mach/irq.h> 43#include <asm/mach/irq.h>
43 44
44#include <mach/hardware.h> 45#include <mach/hardware.h>
45#include <asm/io.h>
46#include <asm/irq.h> 46#include <asm/irq.h>
47#include <asm/mach-types.h> 47#include <asm/mach-types.h>
48 48
diff --git a/arch/arm/mach-s3c2410/mach-tct_hammer.c b/arch/arm/mach-s3c2410/mach-tct_hammer.c
index ec87306a8c24..cc2e79fe4f9f 100644
--- a/arch/arm/mach-s3c2410/mach-tct_hammer.c
+++ b/arch/arm/mach-s3c2410/mach-tct_hammer.c
@@ -33,6 +33,7 @@
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/serial_core.h> 35#include <linux/serial_core.h>
36#include <linux/io.h>
36 37
37#include <asm/mach/arch.h> 38#include <asm/mach/arch.h>
38#include <asm/mach/map.h> 39#include <asm/mach/map.h>
@@ -40,7 +41,6 @@
40#include <asm/mach/flash.h> 41#include <asm/mach/flash.h>
41 42
42#include <mach/hardware.h> 43#include <mach/hardware.h>
43#include <asm/io.h>
44#include <asm/irq.h> 44#include <asm/irq.h>
45#include <asm/mach-types.h> 45#include <asm/mach-types.h>
46 46
diff --git a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c2410/mach-vr1000.c
index fbc0213d5485..ed3acb05c855 100644
--- a/arch/arm/mach-s3c2410/mach-vr1000.c
+++ b/arch/arm/mach-s3c2410/mach-vr1000.c
@@ -25,6 +25,7 @@
25#include <linux/tty.h> 25#include <linux/tty.h>
26#include <linux/serial_8250.h> 26#include <linux/serial_8250.h>
27#include <linux/serial_reg.h> 27#include <linux/serial_reg.h>
28#include <linux/io.h>
28 29
29#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
30#include <asm/mach/map.h> 31#include <asm/mach/map.h>
@@ -36,7 +37,6 @@
36#include <mach/vr1000-cpld.h> 37#include <mach/vr1000-cpld.h>
37 38
38#include <mach/hardware.h> 39#include <mach/hardware.h>
39#include <asm/io.h>
40#include <asm/irq.h> 40#include <asm/irq.h>
41#include <asm/mach-types.h> 41#include <asm/mach-types.h>
42 42
diff --git a/arch/arm/mach-s3c2410/pm.c b/arch/arm/mach-s3c2410/pm.c
index ba43ff9e8164..733f8a227775 100644
--- a/arch/arm/mach-s3c2410/pm.c
+++ b/arch/arm/mach-s3c2410/pm.c
@@ -25,9 +25,9 @@
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/time.h> 26#include <linux/time.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/io.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/io.h>
31 31
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c
index 5d977f9c88ac..b1e658c917a0 100644
--- a/arch/arm/mach-s3c2410/s3c2410.c
+++ b/arch/arm/mach-s3c2410/s3c2410.c
@@ -19,13 +19,13 @@
19#include <linux/sysdev.h> 19#include <linux/sysdev.h>
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/io.h>
22 23
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24#include <asm/mach/map.h> 25#include <asm/mach/map.h>
25#include <asm/mach/irq.h> 26#include <asm/mach/irq.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#include <mach/regs-clock.h> 31#include <mach/regs-clock.h>
diff --git a/arch/arm/mach-s3c2410/usb-simtec.c b/arch/arm/mach-s3c2410/usb-simtec.c
index 4dacf8a1750d..eb6fc0bfd47e 100644
--- a/arch/arm/mach-s3c2410/usb-simtec.c
+++ b/arch/arm/mach-s3c2410/usb-simtec.c
@@ -21,6 +21,7 @@
21#include <linux/timer.h> 21#include <linux/timer.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/io.h>
24 25
25#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
26#include <asm/mach/map.h> 27#include <asm/mach/map.h>
@@ -32,7 +33,6 @@
32#include <mach/regs-gpio.h> 33#include <mach/regs-gpio.h>
33 34
34#include <mach/hardware.h> 35#include <mach/hardware.h>
35#include <asm/io.h>
36#include <asm/irq.h> 36#include <asm/irq.h>
37 37
38#include <asm/plat-s3c24xx/devs.h> 38#include <asm/plat-s3c24xx/devs.h>
diff --git a/arch/arm/mach-s3c2412/clock.c b/arch/arm/mach-s3c2412/clock.c
index af4b2ce516f9..5fbaac6054f8 100644
--- a/arch/arm/mach-s3c2412/clock.c
+++ b/arch/arm/mach-s3c2412/clock.c
@@ -31,11 +31,11 @@
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/serial_core.h> 33#include <linux/serial_core.h>
34#include <linux/io.h>
34 35
35#include <asm/mach/map.h> 36#include <asm/mach/map.h>
36 37
37#include <mach/hardware.h> 38#include <mach/hardware.h>
38#include <asm/io.h>
39 39
40#include <asm/plat-s3c/regs-serial.h> 40#include <asm/plat-s3c/regs-serial.h>
41#include <mach/regs-clock.h> 41#include <mach/regs-clock.h>
diff --git a/arch/arm/mach-s3c2412/dma.c b/arch/arm/mach-s3c2412/dma.c
index 22fc04a3b533..dcfff6b8b958 100644
--- a/arch/arm/mach-s3c2412/dma.c
+++ b/arch/arm/mach-s3c2412/dma.c
@@ -16,10 +16,10 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/sysdev.h> 17#include <linux/sysdev.h>
18#include <linux/serial_core.h> 18#include <linux/serial_core.h>
19#include <linux/io.h>
19 20
20#include <asm/dma.h> 21#include <asm/dma.h>
21#include <mach/dma.h> 22#include <mach/dma.h>
22#include <asm/io.h>
23 23
24#include <asm/plat-s3c24xx/dma.h> 24#include <asm/plat-s3c24xx/dma.h>
25#include <asm/plat-s3c24xx/cpu.h> 25#include <asm/plat-s3c24xx/cpu.h>
diff --git a/arch/arm/mach-s3c2412/irq.c b/arch/arm/mach-s3c2412/irq.c
index ac62b79044f4..41720f2c1fea 100644
--- a/arch/arm/mach-s3c2412/irq.c
+++ b/arch/arm/mach-s3c2412/irq.c
@@ -24,10 +24,10 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/io.h>
31 31
32#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
33 33
@@ -123,10 +123,10 @@ static void s3c2412_irq_demux_cfsdi(unsigned int irq, struct irq_desc *desc)
123 subsrc &= ~submsk; 123 subsrc &= ~submsk;
124 124
125 if (subsrc & INTBIT(IRQ_S3C2412_SDI)) 125 if (subsrc & INTBIT(IRQ_S3C2412_SDI))
126 desc_handle_irq(IRQ_S3C2412_SDI, irq_desc + IRQ_S3C2412_SDI); 126 generic_handle_irq(IRQ_S3C2412_SDI);
127 127
128 if (subsrc & INTBIT(IRQ_S3C2412_CF)) 128 if (subsrc & INTBIT(IRQ_S3C2412_CF))
129 desc_handle_irq(IRQ_S3C2412_CF, irq_desc + IRQ_S3C2412_CF); 129 generic_handle_irq(IRQ_S3C2412_CF);
130} 130}
131 131
132#define INTMSK_CFSDI (1UL << (IRQ_S3C2412_CFSDI - IRQ_EINT0)) 132#define INTMSK_CFSDI (1UL << (IRQ_S3C2412_CFSDI - IRQ_EINT0))
diff --git a/arch/arm/mach-s3c2412/mach-smdk2413.c b/arch/arm/mach-s3c2412/mach-smdk2413.c
index 80affb1ee4cd..8f8d9117b968 100644
--- a/arch/arm/mach-s3c2412/mach-smdk2413.c
+++ b/arch/arm/mach-s3c2412/mach-smdk2413.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/io.h>
22 23
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24#include <asm/mach/map.h> 25#include <asm/mach/map.h>
@@ -27,7 +28,6 @@
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/hardware/iomd.h> 29#include <asm/hardware/iomd.h>
29#include <asm/setup.h> 30#include <asm/setup.h>
30#include <asm/io.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
diff --git a/arch/arm/mach-s3c2412/mach-vstms.c b/arch/arm/mach-s3c2412/mach-vstms.c
index 7a08b3789915..bb9bf63b2e02 100644
--- a/arch/arm/mach-s3c2412/mach-vstms.c
+++ b/arch/arm/mach-s3c2412/mach-vstms.c
@@ -17,7 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/serial_core.h> 18#include <linux/serial_core.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20 20#include <linux/io.h>
21#include <linux/mtd/mtd.h> 21#include <linux/mtd/mtd.h>
22#include <linux/mtd/nand.h> 22#include <linux/mtd/nand.h>
23#include <linux/mtd/nand_ecc.h> 23#include <linux/mtd/nand_ecc.h>
@@ -29,7 +29,6 @@
29 29
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <asm/setup.h> 31#include <asm/setup.h>
32#include <asm/io.h>
33#include <asm/irq.h> 32#include <asm/irq.h>
34#include <asm/mach-types.h> 33#include <asm/mach-types.h>
35 34
diff --git a/arch/arm/mach-s3c2412/pm.c b/arch/arm/mach-s3c2412/pm.c
index 737523a4e037..9540ef752f73 100644
--- a/arch/arm/mach-s3c2412/pm.c
+++ b/arch/arm/mach-s3c2412/pm.c
@@ -18,9 +18,9 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/sysdev.h> 19#include <linux/sysdev.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/io.h>
21 22
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <asm/io.h>
24#include <asm/irq.h> 24#include <asm/irq.h>
25 25
26#include <mach/regs-power.h> 26#include <mach/regs-power.h>
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c
index d278010b9f60..42440fc55681 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c2412/s3c2412.c
@@ -20,6 +20,7 @@
20#include <linux/sysdev.h> 20#include <linux/sysdev.h>
21#include <linux/serial_core.h> 21#include <linux/serial_core.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/io.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
@@ -27,7 +28,6 @@
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/proc-fns.h> 30#include <asm/proc-fns.h>
30#include <asm/io.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32 32
33#include <mach/reset.h> 33#include <mach/reset.h>
diff --git a/arch/arm/mach-s3c2440/clock.c b/arch/arm/mach-s3c2440/clock.c
index 95567e6daea1..40503a65bacf 100644
--- a/arch/arm/mach-s3c2440/clock.c
+++ b/arch/arm/mach-s3c2440/clock.c
@@ -33,11 +33,11 @@
33#include <linux/ioport.h> 33#include <linux/ioport.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/io.h>
36 37
37#include <mach/hardware.h> 38#include <mach/hardware.h>
38#include <asm/atomic.h> 39#include <asm/atomic.h>
39#include <asm/irq.h> 40#include <asm/irq.h>
40#include <asm/io.h>
41 41
42#include <mach/regs-clock.h> 42#include <mach/regs-clock.h>
43 43
diff --git a/arch/arm/mach-s3c2440/dsc.c b/arch/arm/mach-s3c2440/dsc.c
index c0c67438d0a4..4f7d06baf0d3 100644
--- a/arch/arm/mach-s3c2440/dsc.c
+++ b/arch/arm/mach-s3c2440/dsc.c
@@ -15,13 +15,13 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/io.h>
18 19
19#include <asm/mach/arch.h> 20#include <asm/mach/arch.h>
20#include <asm/mach/map.h> 21#include <asm/mach/map.h>
21#include <asm/mach/irq.h> 22#include <asm/mach/irq.h>
22 23
23#include <mach/hardware.h> 24#include <mach/hardware.h>
24#include <asm/io.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26 26
27#include <mach/regs-gpio.h> 27#include <mach/regs-gpio.h>
diff --git a/arch/arm/mach-s3c2440/irq.c b/arch/arm/mach-s3c2440/irq.c
index 276b823f4e27..33e3ede0a2b3 100644
--- a/arch/arm/mach-s3c2440/irq.c
+++ b/arch/arm/mach-s3c2440/irq.c
@@ -24,10 +24,10 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/io.h>
31 31
32#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
33 33
@@ -44,7 +44,6 @@ static void s3c_irq_demux_wdtac97(unsigned int irq,
44 struct irq_desc *desc) 44 struct irq_desc *desc)
45{ 45{
46 unsigned int subsrc, submsk; 46 unsigned int subsrc, submsk;
47 struct irq_desc *mydesc;
48 47
49 /* read the current pending interrupts, and the mask 48 /* read the current pending interrupts, and the mask
50 * for what it is available */ 49 * for what it is available */
@@ -58,12 +57,10 @@ static void s3c_irq_demux_wdtac97(unsigned int irq,
58 57
59 if (subsrc != 0) { 58 if (subsrc != 0) {
60 if (subsrc & 1) { 59 if (subsrc & 1) {
61 mydesc = irq_desc + IRQ_S3C2440_WDT; 60 generic_handle_irq(IRQ_S3C2440_WDT);
62 desc_handle_irq(IRQ_S3C2440_WDT, mydesc);
63 } 61 }
64 if (subsrc & 2) { 62 if (subsrc & 2) {
65 mydesc = irq_desc + IRQ_S3C2440_AC97; 63 generic_handle_irq(IRQ_S3C2440_AC97);
66 desc_handle_irq(IRQ_S3C2440_AC97, mydesc);
67 } 64 }
68 } 65 }
69} 66}
diff --git a/arch/arm/mach-s3c2440/mach-anubis.c b/arch/arm/mach-s3c2440/mach-anubis.c
index 441f4bc09472..19eb0e5269ac 100644
--- a/arch/arm/mach-s3c2440/mach-anubis.c
+++ b/arch/arm/mach-s3c2440/mach-anubis.c
@@ -19,7 +19,7 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/ata_platform.h> 20#include <linux/ata_platform.h>
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22 22#include <linux/io.h>
23#include <linux/sm501.h> 23#include <linux/sm501.h>
24#include <linux/sm501-regs.h> 24#include <linux/sm501-regs.h>
25 25
@@ -32,7 +32,6 @@
32#include <mach/anubis-cpld.h> 32#include <mach/anubis-cpld.h>
33 33
34#include <mach/hardware.h> 34#include <mach/hardware.h>
35#include <asm/io.h>
36#include <asm/irq.h> 35#include <asm/irq.h>
37#include <asm/mach-types.h> 36#include <asm/mach-types.h>
38 37
diff --git a/arch/arm/mach-s3c2440/mach-nexcoder.c b/arch/arm/mach-s3c2440/mach-nexcoder.c
index 1a5e7027b41b..49e828d1d4d8 100644
--- a/arch/arm/mach-s3c2440/mach-nexcoder.c
+++ b/arch/arm/mach-s3c2440/mach-nexcoder.c
@@ -21,6 +21,7 @@
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/io.h>
24 25
25#include <linux/mtd/map.h> 26#include <linux/mtd/map.h>
26 27
@@ -30,7 +31,6 @@
30 31
31#include <asm/setup.h> 32#include <asm/setup.h>
32#include <mach/hardware.h> 33#include <mach/hardware.h>
33#include <asm/io.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <asm/mach-types.h> 35#include <asm/mach-types.h>
36 36
diff --git a/arch/arm/mach-s3c2440/mach-osiris.c b/arch/arm/mach-s3c2440/mach-osiris.c
index 8b83f93b6102..85144aa52c27 100644
--- a/arch/arm/mach-s3c2440/mach-osiris.c
+++ b/arch/arm/mach-s3c2440/mach-osiris.c
@@ -20,6 +20,7 @@
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/io.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
@@ -29,7 +30,6 @@
29#include <mach/osiris-cpld.h> 30#include <mach/osiris-cpld.h>
30 31
31#include <mach/hardware.h> 32#include <mach/hardware.h>
32#include <asm/io.h>
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35 35
diff --git a/arch/arm/mach-s3c2440/mach-rx3715.c b/arch/arm/mach-s3c2440/mach-rx3715.c
index e0b07e6a0a18..a4c690456d19 100644
--- a/arch/arm/mach-s3c2440/mach-rx3715.c
+++ b/arch/arm/mach-s3c2440/mach-rx3715.c
@@ -23,7 +23,7 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/serial_core.h> 24#include <linux/serial_core.h>
25#include <linux/serial.h> 25#include <linux/serial.h>
26 26#include <linux/io.h>
27#include <linux/mtd/mtd.h> 27#include <linux/mtd/mtd.h>
28#include <linux/mtd/nand.h> 28#include <linux/mtd/nand.h>
29#include <linux/mtd/nand_ecc.h> 29#include <linux/mtd/nand_ecc.h>
@@ -34,7 +34,6 @@
34#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
35 35
36#include <mach/hardware.h> 36#include <mach/hardware.h>
37#include <asm/io.h>
38#include <asm/irq.h> 37#include <asm/irq.h>
39#include <asm/mach-types.h> 38#include <asm/mach-types.h>
40 39
diff --git a/arch/arm/mach-s3c2440/mach-smdk2440.c b/arch/arm/mach-s3c2440/mach-smdk2440.c
index 327c8f371984..7ac60b869e7f 100644
--- a/arch/arm/mach-s3c2440/mach-smdk2440.c
+++ b/arch/arm/mach-s3c2440/mach-smdk2440.c
@@ -21,13 +21,13 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/io.h>
24 25
25#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
26#include <asm/mach/map.h> 27#include <asm/mach/map.h>
27#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/io.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
diff --git a/arch/arm/mach-s3c2440/s3c2440.c b/arch/arm/mach-s3c2440/s3c2440.c
index d6b9a92d284e..c81cdb330712 100644
--- a/arch/arm/mach-s3c2440/s3c2440.c
+++ b/arch/arm/mach-s3c2440/s3c2440.c
@@ -20,13 +20,13 @@
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <linux/sysdev.h> 21#include <linux/sysdev.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/io.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
26#include <asm/mach/irq.h> 27#include <asm/mach/irq.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31 31
32#include <asm/plat-s3c24xx/s3c2440.h> 32#include <asm/plat-s3c24xx/s3c2440.h>
diff --git a/arch/arm/mach-s3c2442/clock.c b/arch/arm/mach-s3c2442/clock.c
index 569b5c3d334a..18f2ce4d7b23 100644
--- a/arch/arm/mach-s3c2442/clock.c
+++ b/arch/arm/mach-s3c2442/clock.c
@@ -33,11 +33,11 @@
33#include <linux/ioport.h> 33#include <linux/ioport.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/io.h>
36 37
37#include <mach/hardware.h> 38#include <mach/hardware.h>
38#include <asm/atomic.h> 39#include <asm/atomic.h>
39#include <asm/irq.h> 40#include <asm/irq.h>
40#include <asm/io.h>
41 41
42#include <mach/regs-clock.h> 42#include <mach/regs-clock.h>
43 43
diff --git a/arch/arm/mach-s3c2443/clock.c b/arch/arm/mach-s3c2443/clock.c
index 6a8d7cced4a2..603b5ea1deab 100644
--- a/arch/arm/mach-s3c2443/clock.c
+++ b/arch/arm/mach-s3c2443/clock.c
@@ -31,11 +31,11 @@
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/serial_core.h> 33#include <linux/serial_core.h>
34#include <linux/io.h>
34 35
35#include <asm/mach/map.h> 36#include <asm/mach/map.h>
36 37
37#include <mach/hardware.h> 38#include <mach/hardware.h>
38#include <asm/io.h>
39 39
40#include <mach/regs-s3c2443-clock.h> 40#include <mach/regs-s3c2443-clock.h>
41 41
diff --git a/arch/arm/mach-s3c2443/dma.c b/arch/arm/mach-s3c2443/dma.c
index c1ff03aebfda..5d9ee772659b 100644
--- a/arch/arm/mach-s3c2443/dma.c
+++ b/arch/arm/mach-s3c2443/dma.c
@@ -16,10 +16,10 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/sysdev.h> 17#include <linux/sysdev.h>
18#include <linux/serial_core.h> 18#include <linux/serial_core.h>
19#include <linux/io.h>
19 20
20#include <asm/dma.h> 21#include <asm/dma.h>
21#include <mach/dma.h> 22#include <mach/dma.h>
22#include <asm/io.h>
23 23
24#include <asm/plat-s3c24xx/dma.h> 24#include <asm/plat-s3c24xx/dma.h>
25#include <asm/plat-s3c24xx/cpu.h> 25#include <asm/plat-s3c24xx/cpu.h>
diff --git a/arch/arm/mach-s3c2443/irq.c b/arch/arm/mach-s3c2443/irq.c
index 9674de7223fd..e44341d7dfef 100644
--- a/arch/arm/mach-s3c2443/irq.c
+++ b/arch/arm/mach-s3c2443/irq.c
@@ -24,10 +24,10 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/io.h>
31 31
32#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
33 33
@@ -44,7 +44,6 @@ static inline void s3c2443_irq_demux(unsigned int irq, unsigned int len)
44{ 44{
45 unsigned int subsrc, submsk; 45 unsigned int subsrc, submsk;
46 unsigned int end; 46 unsigned int end;
47 struct irq_desc *mydesc;
48 47
49 /* read the current pending interrupts, and the mask 48 /* read the current pending interrupts, and the mask
50 * for what it is available */ 49 * for what it is available */
@@ -57,13 +56,11 @@ static inline void s3c2443_irq_demux(unsigned int irq, unsigned int len)
57 subsrc &= (1 << len)-1; 56 subsrc &= (1 << len)-1;
58 57
59 end = len + irq; 58 end = len + irq;
60 mydesc = irq_desc + irq;
61 59
62 for (; irq < end && subsrc; irq++) { 60 for (; irq < end && subsrc; irq++) {
63 if (subsrc & 1) 61 if (subsrc & 1)
64 desc_handle_irq(irq, mydesc); 62 generic_handle_irq(irq);
65 63
66 mydesc++;
67 subsrc >>= 1; 64 subsrc >>= 1;
68 } 65 }
69} 66}
diff --git a/arch/arm/mach-s3c2443/mach-smdk2443.c b/arch/arm/mach-s3c2443/mach-smdk2443.c
index e3c0d587bd10..f0d119dc0409 100644
--- a/arch/arm/mach-s3c2443/mach-smdk2443.c
+++ b/arch/arm/mach-s3c2443/mach-smdk2443.c
@@ -21,13 +21,13 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/io.h>
24 25
25#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
26#include <asm/mach/map.h> 27#include <asm/mach/map.h>
27#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/io.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
diff --git a/arch/arm/mach-s3c2443/s3c2443.c b/arch/arm/mach-s3c2443/s3c2443.c
index 37793f924b5e..c973b68cc735 100644
--- a/arch/arm/mach-s3c2443/s3c2443.c
+++ b/arch/arm/mach-s3c2443/s3c2443.c
@@ -20,13 +20,13 @@
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <linux/sysdev.h> 21#include <linux/sysdev.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/io.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
26#include <asm/mach/irq.h> 27#include <asm/mach/irq.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31 31
32#include <mach/regs-s3c2443-clock.h> 32#include <mach/regs-s3c2443-clock.h>
diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c
index 3efefbdd2527..ab5883b39ddf 100644
--- a/arch/arm/mach-sa1100/badge4.c
+++ b/arch/arm/mach-sa1100/badge4.c
@@ -95,19 +95,19 @@ static int __init badge4_sa1111_init(void)
95 * One-hundred-twenty-seven 32 KiW Main Blocks (8128 Ki b) 95 * One-hundred-twenty-seven 32 KiW Main Blocks (8128 Ki b)
96 */ 96 */
97static struct mtd_partition badge4_partitions[] = { 97static struct mtd_partition badge4_partitions[] = {
98 { 98 {
99 .name = "BLOB boot loader", 99 .name = "BLOB boot loader",
100 .offset = 0, 100 .offset = 0,
101 .size = 0x0000A000 101 .size = 0x0000A000
102 }, { 102 }, {
103 .name = "params", 103 .name = "params",
104 .offset = MTDPART_OFS_APPEND, 104 .offset = MTDPART_OFS_APPEND,
105 .size = 0x00006000 105 .size = 0x00006000
106 }, { 106 }, {
107 .name = "root", 107 .name = "root",
108 .offset = MTDPART_OFS_APPEND, 108 .offset = MTDPART_OFS_APPEND,
109 .size = MTDPART_SIZ_FULL 109 .size = MTDPART_SIZ_FULL
110 } 110 }
111}; 111};
112 112
113static struct flash_platform_data badge4_flash_data = { 113static struct flash_platform_data badge4_flash_data = {
@@ -126,7 +126,7 @@ static int five_v_on __initdata = 0;
126 126
127static int __init five_v_on_setup(char *ignore) 127static int __init five_v_on_setup(char *ignore)
128{ 128{
129 five_v_on = 1; 129 five_v_on = 1;
130 return 1; 130 return 1;
131} 131}
132__setup("five_v_on", five_v_on_setup); 132__setup("five_v_on", five_v_on_setup);
@@ -171,15 +171,15 @@ static int __init badge4_init(void)
171 GPCR = BADGE4_GPIO_TESTPT_J7; 171 GPCR = BADGE4_GPIO_TESTPT_J7;
172 GPDR |= BADGE4_GPIO_TESTPT_J7; 172 GPDR |= BADGE4_GPIO_TESTPT_J7;
173 173
174 /* 5V supply rail. */ 174 /* 5V supply rail. */
175 GPCR = BADGE4_GPIO_PCMEN5V; /* initially off */ 175 GPCR = BADGE4_GPIO_PCMEN5V; /* initially off */
176 GPDR |= BADGE4_GPIO_PCMEN5V; 176 GPDR |= BADGE4_GPIO_PCMEN5V;
177 177
178 /* CPLD sdram type inputs; set up by blob */ 178 /* CPLD sdram type inputs; set up by blob */
179 //GPDR |= (BADGE4_GPIO_SDTYP1 | BADGE4_GPIO_SDTYP0); 179 //GPDR |= (BADGE4_GPIO_SDTYP1 | BADGE4_GPIO_SDTYP0);
180 printk(KERN_DEBUG __FILE__ ": SDRAM CPLD typ1=%d typ0=%d\n", 180 printk(KERN_DEBUG __FILE__ ": SDRAM CPLD typ1=%d typ0=%d\n",
181 !!(GPLR & BADGE4_GPIO_SDTYP1), 181 !!(GPLR & BADGE4_GPIO_SDTYP1),
182 !!(GPLR & BADGE4_GPIO_SDTYP0)); 182 !!(GPLR & BADGE4_GPIO_SDTYP0));
183 183
184 /* SA1111 reset pin; set up by blob */ 184 /* SA1111 reset pin; set up by blob */
185 //GPSR = BADGE4_GPIO_SA1111_NRST; 185 //GPSR = BADGE4_GPIO_SA1111_NRST;
@@ -205,8 +205,8 @@ static int __init badge4_init(void)
205 ret = badge4_sa1111_init(); 205 ret = badge4_sa1111_init();
206 if (ret < 0) 206 if (ret < 0)
207 printk(KERN_ERR 207 printk(KERN_ERR
208 "%s: SA-1111 initialization failed (%d)\n", 208 "%s: SA-1111 initialization failed (%d)\n",
209 __func__, ret); 209 __func__, ret);
210 210
211 211
212 /* maybe turn on 5v0 from the start */ 212 /* maybe turn on 5v0 from the start */
@@ -254,7 +254,7 @@ EXPORT_SYMBOL(badge4_set_5V);
254 254
255 255
256static struct map_desc badge4_io_desc[] __initdata = { 256static struct map_desc badge4_io_desc[] __initdata = {
257 { /* SRAM bank 1 */ 257 { /* SRAM bank 1 */
258 .virtual = 0xf1000000, 258 .virtual = 0xf1000000,
259 .pfn = __phys_to_pfn(0x08000000), 259 .pfn = __phys_to_pfn(0x08000000),
260 .length = 0x00100000, 260 .length = 0x00100000,
diff --git a/arch/arm/mach-sa1100/cpu-sa1100.c b/arch/arm/mach-sa1100/cpu-sa1100.c
index da3a898a6d66..f7fa03478efd 100644
--- a/arch/arm/mach-sa1100/cpu-sa1100.c
+++ b/arch/arm/mach-sa1100/cpu-sa1100.c
@@ -88,6 +88,8 @@
88#include <linux/init.h> 88#include <linux/init.h>
89#include <linux/cpufreq.h> 89#include <linux/cpufreq.h>
90 90
91#include <asm/cputype.h>
92
91#include <mach/hardware.h> 93#include <mach/hardware.h>
92 94
93#include "generic.h" 95#include "generic.h"
@@ -240,7 +242,7 @@ static struct cpufreq_driver sa1100_driver = {
240 242
241static int __init sa1100_dram_init(void) 243static int __init sa1100_dram_init(void)
242{ 244{
243 if ((processor_id & CPU_SA1100_MASK) == CPU_SA1100_ID) 245 if (cpu_is_sa1100())
244 return cpufreq_register_driver(&sa1100_driver); 246 return cpufreq_register_driver(&sa1100_driver);
245 else 247 else
246 return -ENODEV; 248 return -ENODEV;
diff --git a/arch/arm/mach-sa1100/cpu-sa1110.c b/arch/arm/mach-sa1100/cpu-sa1110.c
index 029dbfbbafcf..3e4fb214eada 100644
--- a/arch/arm/mach-sa1100/cpu-sa1110.c
+++ b/arch/arm/mach-sa1100/cpu-sa1110.c
@@ -23,10 +23,11 @@
23#include <linux/cpufreq.h> 23#include <linux/cpufreq.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/io.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
29#include <asm/cputype.h>
28#include <asm/mach-types.h> 30#include <asm/mach-types.h>
29#include <asm/io.h>
30#include <asm/system.h> 31#include <asm/system.h>
31 32
32#include "generic.h" 33#include "generic.h"
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index b422526f6d8b..c1fbd5b5f9c4 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -42,7 +42,7 @@ EXPORT_SYMBOL(reset_status);
42static const unsigned short cclk_frequency_100khz[NR_FREQS] = { 42static const unsigned short cclk_frequency_100khz[NR_FREQS] = {
43 590, /* 59.0 MHz */ 43 590, /* 59.0 MHz */
44 737, /* 73.7 MHz */ 44 737, /* 73.7 MHz */
45 885, /* 88.5 MHz */ 45 885, /* 88.5 MHz */
46 1032, /* 103.2 MHz */ 46 1032, /* 103.2 MHz */
47 1180, /* 118.0 MHz */ 47 1180, /* 118.0 MHz */
48 1327, /* 132.7 MHz */ 48 1327, /* 132.7 MHz */
@@ -52,10 +52,10 @@ static const unsigned short cclk_frequency_100khz[NR_FREQS] = {
52 1917, /* 191.7 MHz */ 52 1917, /* 191.7 MHz */
53 2064, /* 206.4 MHz */ 53 2064, /* 206.4 MHz */
54 2212, /* 221.2 MHz */ 54 2212, /* 221.2 MHz */
55 2359, /* 235.9 MHz */ 55 2359, /* 235.9 MHz */
56 2507, /* 250.7 MHz */ 56 2507, /* 250.7 MHz */
57 2654, /* 265.4 MHz */ 57 2654, /* 265.4 MHz */
58 2802 /* 280.2 MHz */ 58 2802 /* 280.2 MHz */
59}; 59};
60 60
61#if defined(CONFIG_CPU_FREQ_SA1100) || defined(CONFIG_CPU_FREQ_SA1110) 61#if defined(CONFIG_CPU_FREQ_SA1100) || defined(CONFIG_CPU_FREQ_SA1110)
@@ -113,7 +113,7 @@ unsigned int sa11x0_getspeed(unsigned int cpu)
113#else 113#else
114/* 114/*
115 * We still need to provide this so building without cpufreq works. 115 * We still need to provide this so building without cpufreq works.
116 */ 116 */
117unsigned int cpufreq_get(unsigned int cpu) 117unsigned int cpufreq_get(unsigned int cpu)
118{ 118{
119 return cclk_frequency_100khz[PPCR & 0xf] * 100; 119 return cclk_frequency_100khz[PPCR & 0xf] * 100;
@@ -389,7 +389,7 @@ EXPORT_SYMBOL(sa1100fb_lcd_power);
389 */ 389 */
390 390
391static struct map_desc standard_io_desc[] __initdata = { 391static struct map_desc standard_io_desc[] __initdata = {
392 { /* PCM */ 392 { /* PCM */
393 .virtual = 0xf8000000, 393 .virtual = 0xf8000000,
394 .pfn = __phys_to_pfn(0x80000000), 394 .pfn = __phys_to_pfn(0x80000000),
395 .length = 0x00100000, 395 .length = 0x00100000,
diff --git a/arch/arm/mach-sa1100/include/mach/SA-1100.h b/arch/arm/mach-sa1100/include/mach/SA-1100.h
index 62aaf04a3906..4f7ea012e1e5 100644
--- a/arch/arm/mach-sa1100/include/mach/SA-1100.h
+++ b/arch/arm/mach-sa1100/include/mach/SA-1100.h
@@ -2054,19 +2054,3 @@
2054 /* active display mode) */ 2054 /* active display mode) */
2055#define LCCR3_OutEnH (LCCR3_OEP*0) /* Output Enable active High */ 2055#define LCCR3_OutEnH (LCCR3_OEP*0) /* Output Enable active High */
2056#define LCCR3_OutEnL (LCCR3_OEP*1) /* Output Enable active Low */ 2056#define LCCR3_OutEnL (LCCR3_OEP*1) /* Output Enable active Low */
2057
2058#ifndef __ASSEMBLY__
2059extern unsigned int processor_id;
2060#endif
2061
2062#define CPU_REVISION (processor_id & 15)
2063#define CPU_SA1110_A0 (0)
2064#define CPU_SA1110_B0 (4)
2065#define CPU_SA1110_B1 (5)
2066#define CPU_SA1110_B2 (6)
2067#define CPU_SA1110_B4 (8)
2068
2069#define CPU_SA1100_ID (0x4401a110)
2070#define CPU_SA1100_MASK (0xfffffff0)
2071#define CPU_SA1110_ID (0x6901b110)
2072#define CPU_SA1110_MASK (0xfffffff0)
diff --git a/arch/arm/mach-sa1100/include/mach/hardware.h b/arch/arm/mach-sa1100/include/mach/hardware.h
index 5976435f42c2..b70846c096aa 100644
--- a/arch/arm/mach-sa1100/include/mach/hardware.h
+++ b/arch/arm/mach-sa1100/include/mach/hardware.h
@@ -36,8 +36,26 @@
36#define io_v2p( x ) \ 36#define io_v2p( x ) \
37 ( (((x)&0x00ffffff) | (((x)&(0x30000000>>VIO_SHIFT))<<VIO_SHIFT)) + PIO_START ) 37 ( (((x)&0x00ffffff) | (((x)&(0x30000000>>VIO_SHIFT))<<VIO_SHIFT)) + PIO_START )
38 38
39#define CPU_SA1110_A0 (0)
40#define CPU_SA1110_B0 (4)
41#define CPU_SA1110_B1 (5)
42#define CPU_SA1110_B2 (6)
43#define CPU_SA1110_B4 (8)
44
45#define CPU_SA1100_ID (0x4401a110)
46#define CPU_SA1100_MASK (0xfffffff0)
47#define CPU_SA1110_ID (0x6901b110)
48#define CPU_SA1110_MASK (0xfffffff0)
49
39#ifndef __ASSEMBLY__ 50#ifndef __ASSEMBLY__
40 51
52#include <asm/cputype.h>
53
54#define CPU_REVISION (read_cpuid_id() & 15)
55
56#define cpu_is_sa1100() ((read_cpuid_id() & CPU_SA1100_MASK) == CPU_SA1100_ID)
57#define cpu_is_sa1110() ((read_cpuid_id() & CPU_SA1110_MASK) == CPU_SA1110_ID)
58
41# define __REG(x) (*((volatile unsigned long *)io_p2v(x))) 59# define __REG(x) (*((volatile unsigned long *)io_p2v(x)))
42# define __PREG(x) (io_v2p((unsigned long)&(x))) 60# define __PREG(x) (io_v2p((unsigned long)&(x)))
43 61
diff --git a/arch/arm/mach-sa1100/include/mach/memory.h b/arch/arm/mach-sa1100/include/mach/memory.h
index 29f639e2afc6..1c127b68581d 100644
--- a/arch/arm/mach-sa1100/include/mach/memory.h
+++ b/arch/arm/mach-sa1100/include/mach/memory.h
@@ -40,23 +40,21 @@ void sa1111_adjust_zones(int node, unsigned long *size, unsigned long *holes);
40#define __bus_to_virt(x) __phys_to_virt(x) 40#define __bus_to_virt(x) __phys_to_virt(x)
41 41
42/* 42/*
43 * Because of the wide memory address space between physical RAM banks on the 43 * Because of the wide memory address space between physical RAM banks on the
44 * SA1100, it's much convenient to use Linux's NUMA support to implement our 44 * SA1100, it's much convenient to use Linux's SparseMEM support to implement
45 * memory map representation. Assuming all memory nodes have equal access 45 * our memory map representation. Assuming all memory nodes have equal access
46 * characteristics, we then have generic discontiguous memory support. 46 * characteristics, we then have generic discontiguous memory support.
47 * 47 *
48 * Of course, all this isn't mandatory for SA1100 implementations with only 48 * The sparsemem banks are matched with the physical memory bank addresses
49 * one used memory bank. For those, simply undefine CONFIG_DISCONTIGMEM. 49 * which are incidentally the same as virtual addresses.
50 *
51 * The nodes are matched with the physical memory bank addresses which are
52 * incidentally the same as virtual addresses.
53 * 50 *
54 * node 0: 0xc0000000 - 0xc7ffffff 51 * node 0: 0xc0000000 - 0xc7ffffff
55 * node 1: 0xc8000000 - 0xcfffffff 52 * node 1: 0xc8000000 - 0xcfffffff
56 * node 2: 0xd0000000 - 0xd7ffffff 53 * node 2: 0xd0000000 - 0xd7ffffff
57 * node 3: 0xd8000000 - 0xdfffffff 54 * node 3: 0xd8000000 - 0xdfffffff
58 */ 55 */
59#define NODE_MEM_SIZE_BITS 27 56#define MAX_PHYSMEM_BITS 32
57#define SECTION_SIZE_BITS 27
60 58
61/* 59/*
62 * Cache flushing area - SA1100 zero bank 60 * Cache flushing area - SA1100 zero bank
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c
index 86369a8f0cea..3093d46a9c6f 100644
--- a/arch/arm/mach-sa1100/irq.c
+++ b/arch/arm/mach-sa1100/irq.c
@@ -122,14 +122,12 @@ sa1100_high_gpio_handler(unsigned int irq, struct irq_desc *desc)
122 GEDR = mask; 122 GEDR = mask;
123 123
124 irq = IRQ_GPIO11; 124 irq = IRQ_GPIO11;
125 desc = irq_desc + irq;
126 mask >>= 11; 125 mask >>= 11;
127 do { 126 do {
128 if (mask & 1) 127 if (mask & 1)
129 desc_handle_irq(irq, desc); 128 generic_handle_irq(irq);
130 mask >>= 1; 129 mask >>= 1;
131 irq++; 130 irq++;
132 desc++;
133 } while (mask); 131 } while (mask);
134 132
135 mask = GEDR & 0xfffff800; 133 mask = GEDR & 0xfffff800;
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index 4856a6bd2482..6ccd175bc4cf 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -33,8 +33,6 @@ neponset_irq_handler(unsigned int irq, struct irq_desc *desc)
33 unsigned int irr; 33 unsigned int irr;
34 34
35 while (1) { 35 while (1) {
36 struct irq_desc *d;
37
38 /* 36 /*
39 * Acknowledge the parent IRQ. 37 * Acknowledge the parent IRQ.
40 */ 38 */
@@ -67,21 +65,18 @@ neponset_irq_handler(unsigned int irq, struct irq_desc *desc)
67 desc->chip->ack(irq); 65 desc->chip->ack(irq);
68 66
69 if (irr & IRR_ETHERNET) { 67 if (irr & IRR_ETHERNET) {
70 d = irq_desc + IRQ_NEPONSET_SMC9196; 68 generic_handle_irq(IRQ_NEPONSET_SMC9196);
71 desc_handle_irq(IRQ_NEPONSET_SMC9196, d);
72 } 69 }
73 70
74 if (irr & IRR_USAR) { 71 if (irr & IRR_USAR) {
75 d = irq_desc + IRQ_NEPONSET_USAR; 72 generic_handle_irq(IRQ_NEPONSET_USAR);
76 desc_handle_irq(IRQ_NEPONSET_USAR, d);
77 } 73 }
78 74
79 desc->chip->unmask(irq); 75 desc->chip->unmask(irq);
80 } 76 }
81 77
82 if (irr & IRR_SA1111) { 78 if (irr & IRR_SA1111) {
83 d = irq_desc + IRQ_NEPONSET_SA1111; 79 generic_handle_irq(IRQ_NEPONSET_SA1111);
84 desc_handle_irq(IRQ_NEPONSET_SA1111, d);
85 } 80 }
86 } 81 }
87} 82}
diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c
index 83be1c6c5f80..e45d3a1890bc 100644
--- a/arch/arm/mach-sa1100/pleb.c
+++ b/arch/arm/mach-sa1100/pleb.c
@@ -8,11 +8,10 @@
8#include <linux/ioport.h> 8#include <linux/ioport.h>
9#include <linux/platform_device.h> 9#include <linux/platform_device.h>
10#include <linux/irq.h> 10#include <linux/irq.h>
11 11#include <linux/io.h>
12#include <linux/mtd/partitions.h> 12#include <linux/mtd/partitions.h>
13 13
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <asm/io.h>
16#include <asm/setup.h> 15#include <asm/setup.h>
17#include <asm/mach-types.h> 16#include <asm/mach-types.h>
18 17
@@ -39,8 +38,8 @@
39 38
40static struct resource smc91x_resources[] = { 39static struct resource smc91x_resources[] = {
41 [0] = { 40 [0] = {
42 .start = PLEB_ETH0_P, 41 .start = PLEB_ETH0_P,
43 .end = PLEB_ETH0_P | 0x03ffffff, 42 .end = PLEB_ETH0_P | 0x03ffffff,
44 .flags = IORESOURCE_MEM, 43 .flags = IORESOURCE_MEM,
45 }, 44 },
46#if 0 /* Autoprobe instead, to get rising/falling edge characteristic right */ 45#if 0 /* Autoprobe instead, to get rising/falling edge characteristic right */
@@ -87,15 +86,15 @@ static struct resource pleb_flash_resources[] = {
87static struct mtd_partition pleb_partitions[] = { 86static struct mtd_partition pleb_partitions[] = {
88 { 87 {
89 .name = "blob", 88 .name = "blob",
90 .offset = 0, 89 .offset = 0,
91 .size = 0x00020000, 90 .size = 0x00020000,
92 }, { 91 }, {
93 .name = "kernel", 92 .name = "kernel",
94 .offset = MTDPART_OFS_APPEND, 93 .offset = MTDPART_OFS_APPEND,
95 .size = 0x000e0000, 94 .size = 0x000e0000,
96 }, { 95 }, {
97 .name = "rootfs", 96 .name = "rootfs",
98 .offset = MTDPART_OFS_APPEND, 97 .offset = MTDPART_OFS_APPEND,
99 .size = 0x00300000, 98 .size = 0x00300000,
100 } 99 }
101}; 100};
diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c
index 8dd635317959..3c74534f7fee 100644
--- a/arch/arm/mach-sa1100/simpad.c
+++ b/arch/arm/mach-sa1100/simpad.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/mtd/mtd.h> 13#include <linux/mtd/mtd.h>
14#include <linux/mtd/partitions.h> 14#include <linux/mtd/partitions.h>
15#include <linux/io.h>
15 16
16#include <asm/irq.h> 17#include <asm/irq.h>
17#include <mach/hardware.h> 18#include <mach/hardware.h>
@@ -27,7 +28,6 @@
27 28
28#include <linux/serial_core.h> 29#include <linux/serial_core.h>
29#include <linux/ioport.h> 30#include <linux/ioport.h>
30#include <asm/io.h>
31 31
32#include "generic.h" 32#include "generic.h"
33 33
diff --git a/arch/arm/mach-sa1100/ssp.c b/arch/arm/mach-sa1100/ssp.c
index 641f361c56f4..b20ff93b84a5 100644
--- a/arch/arm/mach-sa1100/ssp.c
+++ b/arch/arm/mach-sa1100/ssp.c
@@ -17,8 +17,8 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/ioport.h> 18#include <linux/ioport.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/io.h>
20 21
21#include <asm/io.h>
22#include <asm/irq.h> 22#include <asm/irq.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <asm/hardware/ssp.h> 24#include <asm/hardware/ssp.h>
diff --git a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c
index 09d9f33d4072..a9400d984451 100644
--- a/arch/arm/mach-shark/core.c
+++ b/arch/arm/mach-shark/core.c
@@ -9,10 +9,10 @@
9#include <linux/irq.h> 9#include <linux/irq.h>
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/serial_8250.h> 11#include <linux/serial_8250.h>
12#include <linux/io.h>
12 13
13#include <asm/setup.h> 14#include <asm/setup.h>
14#include <asm/mach-types.h> 15#include <asm/mach-types.h>
15#include <asm/io.h>
16#include <asm/leds.h> 16#include <asm/leds.h>
17#include <asm/param.h> 17#include <asm/param.h>
18 18
diff --git a/arch/arm/mach-shark/include/mach/system.h b/arch/arm/mach-shark/include/mach/system.h
index 85aceef6f874..e45bd734a03e 100644
--- a/arch/arm/mach-shark/include/mach/system.h
+++ b/arch/arm/mach-shark/include/mach/system.h
@@ -6,7 +6,7 @@
6#ifndef __ASM_ARCH_SYSTEM_H 6#ifndef __ASM_ARCH_SYSTEM_H
7#define __ASM_ARCH_SYSTEM_H 7#define __ASM_ARCH_SYSTEM_H
8 8
9#include <asm/io.h> 9#include <linux/io.h>
10 10
11static void arch_reset(char mode) 11static void arch_reset(char mode)
12{ 12{
diff --git a/arch/arm/mach-shark/irq.c b/arch/arm/mach-shark/irq.c
index 44b0811b400c..c04eb6a1e2be 100644
--- a/arch/arm/mach-shark/irq.c
+++ b/arch/arm/mach-shark/irq.c
@@ -11,9 +11,9 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/io.h>
14 15
15#include <asm/irq.h> 16#include <asm/irq.h>
16#include <asm/io.h>
17#include <asm/mach/irq.h> 17#include <asm/mach/irq.h>
18 18
19/* 19/*
diff --git a/arch/arm/mach-shark/leds.c b/arch/arm/mach-shark/leds.c
index b1896471aa3c..8bd8d6bb4d92 100644
--- a/arch/arm/mach-shark/leds.c
+++ b/arch/arm/mach-shark/leds.c
@@ -20,10 +20,10 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/io.h>
23 24
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/leds.h> 26#include <asm/leds.h>
26#include <asm/io.h>
27#include <asm/system.h> 27#include <asm/system.h>
28 28
29#define LED_STATE_ENABLED 1 29#define LED_STATE_ENABLED 1
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index b638f10411e8..565e0ba0d67e 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -29,10 +29,10 @@
29#include <linux/clocksource.h> 29#include <linux/clocksource.h>
30#include <linux/clockchips.h> 30#include <linux/clockchips.h>
31#include <linux/cnt32_to_63.h> 31#include <linux/cnt32_to_63.h>
32#include <linux/io.h>
32 33
33#include <asm/system.h> 34#include <asm/system.h>
34#include <mach/hardware.h> 35#include <mach/hardware.h>
35#include <asm/io.h>
36#include <asm/irq.h> 36#include <asm/irq.h>
37#include <asm/leds.h> 37#include <asm/leds.h>
38#include <asm/hardware/arm_timer.h> 38#include <asm/hardware/arm_timer.h>
@@ -95,8 +95,7 @@ sic_handle_irq(unsigned int irq, struct irq_desc *desc)
95 95
96 irq += IRQ_SIC_START; 96 irq += IRQ_SIC_START;
97 97
98 desc = irq_desc + irq; 98 generic_handle_irq(irq);
99 desc_handle_irq(irq, desc);
100 } while (status); 99 } while (status);
101} 100}
102 101
diff --git a/arch/arm/mach-versatile/include/mach/system.h b/arch/arm/mach-versatile/include/mach/system.h
index 91fa559c7cca..c59e6100c7e3 100644
--- a/arch/arm/mach-versatile/include/mach/system.h
+++ b/arch/arm/mach-versatile/include/mach/system.h
@@ -21,8 +21,8 @@
21#ifndef __ASM_ARCH_SYSTEM_H 21#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H 22#define __ASM_ARCH_SYSTEM_H
23 23
24#include <linux/io.h>
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/io.h>
26#include <mach/platform.h> 26#include <mach/platform.h>
27 27
28static inline void arch_idle(void) 28static inline void arch_idle(void)
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
index 36f23f896503..7161ba23b58a 100644
--- a/arch/arm/mach-versatile/pci.c
+++ b/arch/arm/mach-versatile/pci.c
@@ -21,9 +21,9 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/io.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/io.h>
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/system.h> 28#include <asm/system.h>
29#include <asm/mach/pci.h> 29#include <asm/mach/pci.h>
diff --git a/arch/arm/mach-versatile/versatile_ab.c b/arch/arm/mach-versatile/versatile_ab.c
index 76375c64413a..bb8ec7724f79 100644
--- a/arch/arm/mach-versatile/versatile_ab.c
+++ b/arch/arm/mach-versatile/versatile_ab.c
@@ -23,9 +23,9 @@
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/sysdev.h> 24#include <linux/sysdev.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/io.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31 31
diff --git a/arch/arm/mach-versatile/versatile_pb.c b/arch/arm/mach-versatile/versatile_pb.c
index 1725f019fc85..aa051c0884f8 100644
--- a/arch/arm/mach-versatile/versatile_pb.c
+++ b/arch/arm/mach-versatile/versatile_pb.c
@@ -23,9 +23,9 @@
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/sysdev.h> 24#include <linux/sysdev.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/io.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31 31
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index ed15f876c725..330814d1ee25 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -735,6 +735,14 @@ config CACHE_FEROCEON_L2
735 help 735 help
736 This option enables the Feroceon L2 cache controller. 736 This option enables the Feroceon L2 cache controller.
737 737
738config CACHE_FEROCEON_L2_WRITETHROUGH
739 bool "Force Feroceon L2 cache write through"
740 depends on CACHE_FEROCEON_L2
741 default n
742 help
743 Say Y here to use the Feroceon L2 cache in writethrough mode.
744 Unless you specifically require this, say N for writeback mode.
745
738config CACHE_L2X0 746config CACHE_L2X0
739 bool "Enable the L2x0 outer cache controller" 747 bool "Enable the L2x0 outer cache controller"
740 depends on REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP || MACH_REALVIEW_PB1176 748 depends on REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP || MACH_REALVIEW_PB1176
diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
index 2e27a8c8372b..480f78a3611a 100644
--- a/arch/arm/mm/Makefile
+++ b/arch/arm/mm/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux arm-specific parts of the memory manager. 2# Makefile for the linux arm-specific parts of the memory manager.
3# 3#
4 4
5obj-y := consistent.o extable.o fault.o init.o \ 5obj-y := dma-mapping.o extable.o fault.o init.o \
6 iomap.o 6 iomap.o
7 7
8obj-$(CONFIG_MMU) += fault-armv.o flush.o ioremap.o mmap.o \ 8obj-$(CONFIG_MMU) += fault-armv.o flush.o ioremap.o mmap.o \
diff --git a/arch/arm/mm/abort-ev7.S b/arch/arm/mm/abort-ev7.S
index eb90bce38e14..2e6dc040c654 100644
--- a/arch/arm/mm/abort-ev7.S
+++ b/arch/arm/mm/abort-ev7.S
@@ -30,3 +30,4 @@ ENTRY(v7_early_abort)
30 * New designs should not need to patch up faults. 30 * New designs should not need to patch up faults.
31 */ 31 */
32 mov pc, lr 32 mov pc, lr
33ENDPROC(v7_early_abort)
diff --git a/arch/arm/mm/abort-nommu.S b/arch/arm/mm/abort-nommu.S
index a7cc7f9ee45d..625e580945b5 100644
--- a/arch/arm/mm/abort-nommu.S
+++ b/arch/arm/mm/abort-nommu.S
@@ -17,3 +17,4 @@ ENTRY(nommu_early_abort)
17 mov r0, #0 @ clear r0, r1 (no FSR/FAR) 17 mov r0, #0 @ clear r0, r1 (no FSR/FAR)
18 mov r1, #0 18 mov r1, #0
19 mov pc, lr 19 mov pc, lr
20ENDPROC(nommu_early_abort)
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index e162cca5917f..133e65d166b3 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -17,8 +17,8 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/proc_fs.h> 18#include <linux/proc_fs.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/uaccess.h>
20 21
21#include <asm/uaccess.h>
22#include <asm/unaligned.h> 22#include <asm/unaligned.h>
23 23
24#include "fault.h" 24#include "fault.h"
diff --git a/arch/arm/mm/cache-feroceon-l2.c b/arch/arm/mm/cache-feroceon-l2.c
index 7b5a25d81576..13cdae8b0d44 100644
--- a/arch/arm/mm/cache-feroceon-l2.c
+++ b/arch/arm/mm/cache-feroceon-l2.c
@@ -48,11 +48,12 @@ static inline void l2_clean_mva_range(unsigned long start, unsigned long end)
48 * L2 is PIPT and range operations only do a TLB lookup on 48 * L2 is PIPT and range operations only do a TLB lookup on
49 * the start address. 49 * the start address.
50 */ 50 */
51 BUG_ON((start ^ end) & ~(PAGE_SIZE - 1)); 51 BUG_ON((start ^ end) >> PAGE_SHIFT);
52 52
53 raw_local_irq_save(flags); 53 raw_local_irq_save(flags);
54 __asm__("mcr p15, 1, %0, c15, c9, 4" : : "r" (start)); 54 __asm__("mcr p15, 1, %0, c15, c9, 4\n\t"
55 __asm__("mcr p15, 1, %0, c15, c9, 5" : : "r" (end)); 55 "mcr p15, 1, %1, c15, c9, 5"
56 : : "r" (start), "r" (end));
56 raw_local_irq_restore(flags); 57 raw_local_irq_restore(flags);
57} 58}
58 59
@@ -80,11 +81,12 @@ static inline void l2_inv_mva_range(unsigned long start, unsigned long end)
80 * L2 is PIPT and range operations only do a TLB lookup on 81 * L2 is PIPT and range operations only do a TLB lookup on
81 * the start address. 82 * the start address.
82 */ 83 */
83 BUG_ON((start ^ end) & ~(PAGE_SIZE - 1)); 84 BUG_ON((start ^ end) >> PAGE_SHIFT);
84 85
85 raw_local_irq_save(flags); 86 raw_local_irq_save(flags);
86 __asm__("mcr p15, 1, %0, c15, c11, 4" : : "r" (start)); 87 __asm__("mcr p15, 1, %0, c15, c11, 4\n\t"
87 __asm__("mcr p15, 1, %0, c15, c11, 5" : : "r" (end)); 88 "mcr p15, 1, %1, c15, c11, 5"
89 : : "r" (start), "r" (end));
88 raw_local_irq_restore(flags); 90 raw_local_irq_restore(flags);
89} 91}
90 92
@@ -205,7 +207,7 @@ static void feroceon_l2_flush_range(unsigned long start, unsigned long end)
205 * time. These are necessary because the L2 cache can only be enabled 207 * time. These are necessary because the L2 cache can only be enabled
206 * or disabled while the L1 Dcache and Icache are both disabled. 208 * or disabled while the L1 Dcache and Icache are both disabled.
207 */ 209 */
208static void __init invalidate_and_disable_dcache(void) 210static int __init flush_and_disable_dcache(void)
209{ 211{
210 u32 cr; 212 u32 cr;
211 213
@@ -217,7 +219,9 @@ static void __init invalidate_and_disable_dcache(void)
217 flush_cache_all(); 219 flush_cache_all();
218 set_cr(cr & ~CR_C); 220 set_cr(cr & ~CR_C);
219 raw_local_irq_restore(flags); 221 raw_local_irq_restore(flags);
222 return 1;
220 } 223 }
224 return 0;
221} 225}
222 226
223static void __init enable_dcache(void) 227static void __init enable_dcache(void)
@@ -225,18 +229,17 @@ static void __init enable_dcache(void)
225 u32 cr; 229 u32 cr;
226 230
227 cr = get_cr(); 231 cr = get_cr();
228 if (!(cr & CR_C)) 232 set_cr(cr | CR_C);
229 set_cr(cr | CR_C);
230} 233}
231 234
232static void __init __invalidate_icache(void) 235static void __init __invalidate_icache(void)
233{ 236{
234 int dummy; 237 int dummy;
235 238
236 __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0\n" : "=r" (dummy)); 239 __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : "=r" (dummy));
237} 240}
238 241
239static void __init invalidate_and_disable_icache(void) 242static int __init invalidate_and_disable_icache(void)
240{ 243{
241 u32 cr; 244 u32 cr;
242 245
@@ -244,7 +247,9 @@ static void __init invalidate_and_disable_icache(void)
244 if (cr & CR_I) { 247 if (cr & CR_I) {
245 set_cr(cr & ~CR_I); 248 set_cr(cr & ~CR_I);
246 __invalidate_icache(); 249 __invalidate_icache();
250 return 1;
247 } 251 }
252 return 0;
248} 253}
249 254
250static void __init enable_icache(void) 255static void __init enable_icache(void)
@@ -252,8 +257,7 @@ static void __init enable_icache(void)
252 u32 cr; 257 u32 cr;
253 258
254 cr = get_cr(); 259 cr = get_cr();
255 if (!(cr & CR_I)) 260 set_cr(cr | CR_I);
256 set_cr(cr | CR_I);
257} 261}
258 262
259static inline u32 read_extra_features(void) 263static inline u32 read_extra_features(void)
@@ -291,13 +295,17 @@ static void __init enable_l2(void)
291 295
292 u = read_extra_features(); 296 u = read_extra_features();
293 if (!(u & 0x00400000)) { 297 if (!(u & 0x00400000)) {
298 int i, d;
299
294 printk(KERN_INFO "Feroceon L2: Enabling L2\n"); 300 printk(KERN_INFO "Feroceon L2: Enabling L2\n");
295 301
296 invalidate_and_disable_dcache(); 302 d = flush_and_disable_dcache();
297 invalidate_and_disable_icache(); 303 i = invalidate_and_disable_icache();
298 write_extra_features(u | 0x00400000); 304 write_extra_features(u | 0x00400000);
299 enable_icache(); 305 if (i)
300 enable_dcache(); 306 enable_icache();
307 if (d)
308 enable_dcache();
301 } 309 }
302} 310}
303 311
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 76b800a95191..b480f1d3591f 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -18,9 +18,9 @@
18 */ 18 */
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/io.h>
21 22
22#include <asm/cacheflush.h> 23#include <asm/cacheflush.h>
23#include <asm/io.h>
24#include <asm/hardware/cache-l2x0.h> 24#include <asm/hardware/cache-l2x0.h>
25 25
26#define CACHE_LINE_SIZE 32 26#define CACHE_LINE_SIZE 32
diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
index 35ffc4d95997..d19c2bec2b1f 100644
--- a/arch/arm/mm/cache-v7.S
+++ b/arch/arm/mm/cache-v7.S
@@ -66,6 +66,7 @@ finished:
66 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr 66 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
67 isb 67 isb
68 mov pc, lr 68 mov pc, lr
69ENDPROC(v7_flush_dcache_all)
69 70
70/* 71/*
71 * v7_flush_cache_all() 72 * v7_flush_cache_all()
@@ -85,6 +86,7 @@ ENTRY(v7_flush_kern_cache_all)
85 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate 86 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
86 ldmfd sp!, {r4-r5, r7, r9-r11, lr} 87 ldmfd sp!, {r4-r5, r7, r9-r11, lr}
87 mov pc, lr 88 mov pc, lr
89ENDPROC(v7_flush_kern_cache_all)
88 90
89/* 91/*
90 * v7_flush_cache_all() 92 * v7_flush_cache_all()
@@ -110,6 +112,8 @@ ENTRY(v7_flush_user_cache_all)
110 */ 112 */
111ENTRY(v7_flush_user_cache_range) 113ENTRY(v7_flush_user_cache_range)
112 mov pc, lr 114 mov pc, lr
115ENDPROC(v7_flush_user_cache_all)
116ENDPROC(v7_flush_user_cache_range)
113 117
114/* 118/*
115 * v7_coherent_kern_range(start,end) 119 * v7_coherent_kern_range(start,end)
@@ -155,6 +159,8 @@ ENTRY(v7_coherent_user_range)
155 dsb 159 dsb
156 isb 160 isb
157 mov pc, lr 161 mov pc, lr
162ENDPROC(v7_coherent_kern_range)
163ENDPROC(v7_coherent_user_range)
158 164
159/* 165/*
160 * v7_flush_kern_dcache_page(kaddr) 166 * v7_flush_kern_dcache_page(kaddr)
@@ -174,6 +180,7 @@ ENTRY(v7_flush_kern_dcache_page)
174 blo 1b 180 blo 1b
175 dsb 181 dsb
176 mov pc, lr 182 mov pc, lr
183ENDPROC(v7_flush_kern_dcache_page)
177 184
178/* 185/*
179 * v7_dma_inv_range(start,end) 186 * v7_dma_inv_range(start,end)
@@ -202,6 +209,7 @@ ENTRY(v7_dma_inv_range)
202 blo 1b 209 blo 1b
203 dsb 210 dsb
204 mov pc, lr 211 mov pc, lr
212ENDPROC(v7_dma_inv_range)
205 213
206/* 214/*
207 * v7_dma_clean_range(start,end) 215 * v7_dma_clean_range(start,end)
@@ -219,6 +227,7 @@ ENTRY(v7_dma_clean_range)
219 blo 1b 227 blo 1b
220 dsb 228 dsb
221 mov pc, lr 229 mov pc, lr
230ENDPROC(v7_dma_clean_range)
222 231
223/* 232/*
224 * v7_dma_flush_range(start,end) 233 * v7_dma_flush_range(start,end)
@@ -236,6 +245,7 @@ ENTRY(v7_dma_flush_range)
236 blo 1b 245 blo 1b
237 dsb 246 dsb
238 mov pc, lr 247 mov pc, lr
248ENDPROC(v7_dma_flush_range)
239 249
240 __INITDATA 250 __INITDATA
241 251
diff --git a/arch/arm/mm/cache-xsc3l2.c b/arch/arm/mm/cache-xsc3l2.c
index 158bd96763d3..10b1bae1a258 100644
--- a/arch/arm/mm/cache-xsc3l2.c
+++ b/arch/arm/mm/cache-xsc3l2.c
@@ -18,10 +18,11 @@
18 */ 18 */
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/io.h>
21 22
22#include <asm/system.h> 23#include <asm/system.h>
24#include <asm/cputype.h>
23#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
24#include <asm/io.h>
25 26
26#define CR_L2 (1 << 26) 27#define CR_L2 (1 << 26)
27 28
diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
index ded0e96d069d..8d33e2549344 100644
--- a/arch/arm/mm/copypage-v4mc.c
+++ b/arch/arm/mm/copypage-v4mc.c
@@ -28,7 +28,7 @@
28 * specific hacks for copying pages efficiently. 28 * specific hacks for copying pages efficiently.
29 */ 29 */
30#define minicache_pgprot __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | \ 30#define minicache_pgprot __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | \
31 L_PTE_CACHEABLE) 31 L_PTE_MT_MINICACHE)
32 32
33static DEFINE_SPINLOCK(minicache_lock); 33static DEFINE_SPINLOCK(minicache_lock);
34 34
diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
index 3adb79257f43..0e21c0767580 100644
--- a/arch/arm/mm/copypage-v6.c
+++ b/arch/arm/mm/copypage-v6.c
@@ -16,6 +16,7 @@
16#include <asm/shmparam.h> 16#include <asm/shmparam.h>
17#include <asm/tlbflush.h> 17#include <asm/tlbflush.h>
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19#include <asm/cachetype.h>
19 20
20#include "mm.h" 21#include "mm.h"
21 22
diff --git a/arch/arm/mm/copypage-xscale.c b/arch/arm/mm/copypage-xscale.c
index 2e455f82a4d5..bad49331bbf9 100644
--- a/arch/arm/mm/copypage-xscale.c
+++ b/arch/arm/mm/copypage-xscale.c
@@ -30,7 +30,7 @@
30#define COPYPAGE_MINICACHE 0xffff8000 30#define COPYPAGE_MINICACHE 0xffff8000
31 31
32#define minicache_pgprot __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | \ 32#define minicache_pgprot __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | \
33 L_PTE_CACHEABLE) 33 L_PTE_MT_MINICACHE)
34 34
35static DEFINE_SPINLOCK(minicache_lock); 35static DEFINE_SPINLOCK(minicache_lock);
36 36
diff --git a/arch/arm/mm/consistent.c b/arch/arm/mm/dma-mapping.c
index db7b3e38ef1d..67960017dc8f 100644
--- a/arch/arm/mm/consistent.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/arm/mm/consistent.c 2 * linux/arch/arm/mm/dma-mapping.c
3 * 3 *
4 * Copyright (C) 2000-2004 Russell King 4 * Copyright (C) 2000-2004 Russell King
5 * 5 *
@@ -512,3 +512,105 @@ void dma_cache_maint(const void *start, size_t size, int direction)
512 } 512 }
513} 513}
514EXPORT_SYMBOL(dma_cache_maint); 514EXPORT_SYMBOL(dma_cache_maint);
515
516/**
517 * dma_map_sg - map a set of SG buffers for streaming mode DMA
518 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
519 * @sg: list of buffers
520 * @nents: number of buffers to map
521 * @dir: DMA transfer direction
522 *
523 * Map a set of buffers described by scatterlist in streaming mode for DMA.
524 * This is the scatter-gather version of the dma_map_single interface.
525 * Here the scatter gather list elements are each tagged with the
526 * appropriate dma address and length. They are obtained via
527 * sg_dma_{address,length}.
528 *
529 * Device ownership issues as mentioned for dma_map_single are the same
530 * here.
531 */
532int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
533 enum dma_data_direction dir)
534{
535 struct scatterlist *s;
536 int i, j;
537
538 for_each_sg(sg, s, nents, i) {
539 s->dma_address = dma_map_page(dev, sg_page(s), s->offset,
540 s->length, dir);
541 if (dma_mapping_error(dev, s->dma_address))
542 goto bad_mapping;
543 }
544 return nents;
545
546 bad_mapping:
547 for_each_sg(sg, s, i, j)
548 dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
549 return 0;
550}
551EXPORT_SYMBOL(dma_map_sg);
552
553/**
554 * dma_unmap_sg - unmap a set of SG buffers mapped by dma_map_sg
555 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
556 * @sg: list of buffers
557 * @nents: number of buffers to unmap (returned from dma_map_sg)
558 * @dir: DMA transfer direction (same as was passed to dma_map_sg)
559 *
560 * Unmap a set of streaming mode DMA translations. Again, CPU access
561 * rules concerning calls here are the same as for dma_unmap_single().
562 */
563void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
564 enum dma_data_direction dir)
565{
566 struct scatterlist *s;
567 int i;
568
569 for_each_sg(sg, s, nents, i)
570 dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
571}
572EXPORT_SYMBOL(dma_unmap_sg);
573
574/**
575 * dma_sync_sg_for_cpu
576 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
577 * @sg: list of buffers
578 * @nents: number of buffers to map (returned from dma_map_sg)
579 * @dir: DMA transfer direction (same as was passed to dma_map_sg)
580 */
581void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
582 int nents, enum dma_data_direction dir)
583{
584 struct scatterlist *s;
585 int i;
586
587 for_each_sg(sg, s, nents, i) {
588 dmabounce_sync_for_cpu(dev, sg_dma_address(s), 0,
589 sg_dma_len(s), dir);
590 }
591}
592EXPORT_SYMBOL(dma_sync_sg_for_cpu);
593
594/**
595 * dma_sync_sg_for_device
596 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
597 * @sg: list of buffers
598 * @nents: number of buffers to map (returned from dma_map_sg)
599 * @dir: DMA transfer direction (same as was passed to dma_map_sg)
600 */
601void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
602 int nents, enum dma_data_direction dir)
603{
604 struct scatterlist *s;
605 int i;
606
607 for_each_sg(sg, s, nents, i) {
608 if (!dmabounce_sync_for_device(dev, sg_dma_address(s), 0,
609 sg_dma_len(s), dir))
610 continue;
611
612 if (!arch_is_coherent())
613 dma_cache_maint(sg_virt(s), s->length, dir);
614 }
615}
616EXPORT_SYMBOL(dma_sync_sg_for_device);
diff --git a/arch/arm/mm/extable.c b/arch/arm/mm/extable.c
index 9592c3ee4cb2..9d285626bc7d 100644
--- a/arch/arm/mm/extable.c
+++ b/arch/arm/mm/extable.c
@@ -2,7 +2,7 @@
2 * linux/arch/arm/mm/extable.c 2 * linux/arch/arm/mm/extable.c
3 */ 3 */
4#include <linux/module.h> 4#include <linux/module.h>
5#include <asm/uaccess.h> 5#include <linux/uaccess.h>
6 6
7int fixup_exception(struct pt_regs *regs) 7int fixup_exception(struct pt_regs *regs)
8{ 8{
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index a8ec97b4752e..81d0b8772de3 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -17,11 +17,13 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/pagemap.h> 18#include <linux/pagemap.h>
19 19
20#include <asm/bugs.h>
20#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
22#include <asm/cachetype.h>
21#include <asm/pgtable.h> 23#include <asm/pgtable.h>
22#include <asm/tlbflush.h> 24#include <asm/tlbflush.h>
23 25
24static unsigned long shared_pte_mask = L_PTE_CACHEABLE; 26static unsigned long shared_pte_mask = L_PTE_MT_BUFFERABLE;
25 27
26/* 28/*
27 * We take the easy way out of this problem - we make the 29 * We take the easy way out of this problem - we make the
@@ -63,9 +65,10 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
63 * If this page isn't present, or is already setup to 65 * If this page isn't present, or is already setup to
64 * fault (ie, is old), we can safely ignore any issues. 66 * fault (ie, is old), we can safely ignore any issues.
65 */ 67 */
66 if (ret && pte_val(entry) & shared_pte_mask) { 68 if (ret && (pte_val(entry) & L_PTE_MT_MASK) != shared_pte_mask) {
67 flush_cache_page(vma, address, pte_pfn(entry)); 69 flush_cache_page(vma, address, pte_pfn(entry));
68 pte_val(entry) &= ~shared_pte_mask; 70 pte_val(entry) &= ~L_PTE_MT_MASK;
71 pte_val(entry) |= shared_pte_mask;
69 set_pte_at(vma->vm_mm, address, pte, entry); 72 set_pte_at(vma->vm_mm, address, pte, entry);
70 flush_tlb_page(vma, address); 73 flush_tlb_page(vma, address);
71 } 74 }
@@ -197,7 +200,7 @@ void __init check_writebuffer_bugs(void)
197 unsigned long *p1, *p2; 200 unsigned long *p1, *p2;
198 pgprot_t prot = __pgprot(L_PTE_PRESENT|L_PTE_YOUNG| 201 pgprot_t prot = __pgprot(L_PTE_PRESENT|L_PTE_YOUNG|
199 L_PTE_DIRTY|L_PTE_WRITE| 202 L_PTE_DIRTY|L_PTE_WRITE|
200 L_PTE_BUFFERABLE); 203 L_PTE_MT_BUFFERABLE);
201 204
202 p1 = vmap(&page, 1, VM_IOREMAP, prot); 205 p1 = vmap(&page, 1, VM_IOREMAP, prot);
203 p2 = vmap(&page, 1, VM_IOREMAP, prot); 206 p2 = vmap(&page, 1, VM_IOREMAP, prot);
@@ -218,7 +221,7 @@ void __init check_writebuffer_bugs(void)
218 221
219 if (v) { 222 if (v) {
220 printk("failed, %s\n", reason); 223 printk("failed, %s\n", reason);
221 shared_pte_mask |= L_PTE_BUFFERABLE; 224 shared_pte_mask = L_PTE_MT_UNCACHED;
222 } else { 225 } else {
223 printk("ok\n"); 226 printk("ok\n");
224 } 227 }
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 28ad7ab1c0cd..2df8d9facf57 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -13,11 +13,11 @@
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/kprobes.h> 15#include <linux/kprobes.h>
16#include <linux/uaccess.h>
16 17
17#include <asm/system.h> 18#include <asm/system.h>
18#include <asm/pgtable.h> 19#include <asm/pgtable.h>
19#include <asm/tlbflush.h> 20#include <asm/tlbflush.h>
20#include <asm/uaccess.h>
21 21
22#include "fault.h" 22#include "fault.h"
23 23
@@ -72,9 +72,8 @@ void show_pte(struct mm_struct *mm, unsigned long addr)
72 } 72 }
73 73
74 pmd = pmd_offset(pgd, addr); 74 pmd = pmd_offset(pgd, addr);
75#if PTRS_PER_PMD != 1 75 if (PTRS_PER_PMD != 1)
76 printk(", *pmd=%08lx", pmd_val(*pmd)); 76 printk(", *pmd=%08lx", pmd_val(*pmd));
77#endif
78 77
79 if (pmd_none(*pmd)) 78 if (pmd_none(*pmd))
80 break; 79 break;
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index 029ee65fda2b..0fa9bf388f0b 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -12,6 +12,7 @@
12#include <linux/pagemap.h> 12#include <linux/pagemap.h>
13 13
14#include <asm/cacheflush.h> 14#include <asm/cacheflush.h>
15#include <asm/cachetype.h>
15#include <asm/system.h> 16#include <asm/system.h>
16#include <asm/tlbflush.h> 17#include <asm/tlbflush.h>
17 18
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 30a69d67d673..82c4b4217989 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -26,9 +26,42 @@
26 26
27#include "mm.h" 27#include "mm.h"
28 28
29extern void _text, _etext, __data_start, _end, __init_begin, __init_end; 29static unsigned long phys_initrd_start __initdata = 0;
30extern unsigned long phys_initrd_start; 30static unsigned long phys_initrd_size __initdata = 0;
31extern unsigned long phys_initrd_size; 31
32static void __init early_initrd(char **p)
33{
34 unsigned long start, size;
35
36 start = memparse(*p, p);
37 if (**p == ',') {
38 size = memparse((*p) + 1, p);
39
40 phys_initrd_start = start;
41 phys_initrd_size = size;
42 }
43}
44__early_param("initrd=", early_initrd);
45
46static int __init parse_tag_initrd(const struct tag *tag)
47{
48 printk(KERN_WARNING "ATAG_INITRD is deprecated; "
49 "please update your bootloader.\n");
50 phys_initrd_start = __virt_to_phys(tag->u.initrd.start);
51 phys_initrd_size = tag->u.initrd.size;
52 return 0;
53}
54
55__tagtable(ATAG_INITRD, parse_tag_initrd);
56
57static int __init parse_tag_initrd2(const struct tag *tag)
58{
59 phys_initrd_start = tag->u.initrd.start;
60 phys_initrd_size = tag->u.initrd.size;
61 return 0;
62}
63
64__tagtable(ATAG_INITRD2, parse_tag_initrd2);
32 65
33/* 66/*
34 * This is used to pass memory configuration data from paging_init 67 * This is used to pass memory configuration data from paging_init
@@ -36,10 +69,6 @@ extern unsigned long phys_initrd_size;
36 */ 69 */
37static struct meminfo meminfo = { 0, }; 70static struct meminfo meminfo = { 0, };
38 71
39#define for_each_nodebank(iter,mi,no) \
40 for (iter = 0; iter < mi->nr_banks; iter++) \
41 if (mi->bank[iter].node == no)
42
43void show_mem(void) 72void show_mem(void)
44{ 73{
45 int free = 0, total = 0, reserved = 0; 74 int free = 0, total = 0, reserved = 0;
@@ -50,14 +79,15 @@ void show_mem(void)
50 show_free_areas(); 79 show_free_areas();
51 for_each_online_node(node) { 80 for_each_online_node(node) {
52 pg_data_t *n = NODE_DATA(node); 81 pg_data_t *n = NODE_DATA(node);
53 struct page *map = n->node_mem_map - n->node_start_pfn; 82 struct page *map = pgdat_page_nr(n, 0) - n->node_start_pfn;
54 83
55 for_each_nodebank (i,mi,node) { 84 for_each_nodebank (i,mi,node) {
85 struct membank *bank = &mi->bank[i];
56 unsigned int pfn1, pfn2; 86 unsigned int pfn1, pfn2;
57 struct page *page, *end; 87 struct page *page, *end;
58 88
59 pfn1 = __phys_to_pfn(mi->bank[i].start); 89 pfn1 = bank_pfn_start(bank);
60 pfn2 = __phys_to_pfn(mi->bank[i].size + mi->bank[i].start); 90 pfn2 = bank_pfn_end(bank);
61 91
62 page = map + pfn1; 92 page = map + pfn1;
63 end = map + pfn2; 93 end = map + pfn2;
@@ -96,17 +126,17 @@ void show_mem(void)
96static unsigned int __init 126static unsigned int __init
97find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages) 127find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages)
98{ 128{
99 unsigned int start_pfn, bank, bootmap_pfn; 129 unsigned int start_pfn, i, bootmap_pfn;
100 130
101 start_pfn = PAGE_ALIGN(__pa(&_end)) >> PAGE_SHIFT; 131 start_pfn = PAGE_ALIGN(__pa(&_end)) >> PAGE_SHIFT;
102 bootmap_pfn = 0; 132 bootmap_pfn = 0;
103 133
104 for_each_nodebank(bank, mi, node) { 134 for_each_nodebank(i, mi, node) {
135 struct membank *bank = &mi->bank[i];
105 unsigned int start, end; 136 unsigned int start, end;
106 137
107 start = mi->bank[bank].start >> PAGE_SHIFT; 138 start = bank_pfn_start(bank);
108 end = (mi->bank[bank].size + 139 end = bank_pfn_end(bank);
109 mi->bank[bank].start) >> PAGE_SHIFT;
110 140
111 if (end < start_pfn) 141 if (end < start_pfn)
112 continue; 142 continue;
@@ -145,13 +175,10 @@ static int __init check_initrd(struct meminfo *mi)
145 initrd_node = -1; 175 initrd_node = -1;
146 176
147 for (i = 0; i < mi->nr_banks; i++) { 177 for (i = 0; i < mi->nr_banks; i++) {
148 unsigned long bank_end; 178 struct membank *bank = &mi->bank[i];
149 179 if (bank_phys_start(bank) <= phys_initrd_start &&
150 bank_end = mi->bank[i].start + mi->bank[i].size; 180 end <= bank_phys_end(bank))
151 181 initrd_node = bank->node;
152 if (mi->bank[i].start <= phys_initrd_start &&
153 end <= bank_end)
154 initrd_node = mi->bank[i].node;
155 } 182 }
156 } 183 }
157 184
@@ -171,19 +198,17 @@ static inline void map_memory_bank(struct membank *bank)
171#ifdef CONFIG_MMU 198#ifdef CONFIG_MMU
172 struct map_desc map; 199 struct map_desc map;
173 200
174 map.pfn = __phys_to_pfn(bank->start); 201 map.pfn = bank_pfn_start(bank);
175 map.virtual = __phys_to_virt(bank->start); 202 map.virtual = __phys_to_virt(bank_phys_start(bank));
176 map.length = bank->size; 203 map.length = bank_phys_size(bank);
177 map.type = MT_MEMORY; 204 map.type = MT_MEMORY;
178 205
179 create_mapping(&map); 206 create_mapping(&map);
180#endif 207#endif
181} 208}
182 209
183static unsigned long __init 210static unsigned long __init bootmem_init_node(int node, struct meminfo *mi)
184bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
185{ 211{
186 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
187 unsigned long start_pfn, end_pfn, boot_pfn; 212 unsigned long start_pfn, end_pfn, boot_pfn;
188 unsigned int boot_pages; 213 unsigned int boot_pages;
189 pg_data_t *pgdat; 214 pg_data_t *pgdat;
@@ -199,8 +224,8 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
199 struct membank *bank = &mi->bank[i]; 224 struct membank *bank = &mi->bank[i];
200 unsigned long start, end; 225 unsigned long start, end;
201 226
202 start = bank->start >> PAGE_SHIFT; 227 start = bank_pfn_start(bank);
203 end = (bank->start + bank->size) >> PAGE_SHIFT; 228 end = bank_pfn_end(bank);
204 229
205 if (start_pfn > start) 230 if (start_pfn > start)
206 start_pfn = start; 231 start_pfn = start;
@@ -230,8 +255,11 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
230 pgdat = NODE_DATA(node); 255 pgdat = NODE_DATA(node);
231 init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn); 256 init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn);
232 257
233 for_each_nodebank(i, mi, node) 258 for_each_nodebank(i, mi, node) {
234 free_bootmem_node(pgdat, mi->bank[i].start, mi->bank[i].size); 259 struct membank *bank = &mi->bank[i];
260 free_bootmem_node(pgdat, bank_phys_start(bank), bank_phys_size(bank));
261 memory_present(node, bank_pfn_start(bank), bank_pfn_end(bank));
262 }
235 263
236 /* 264 /*
237 * Reserve the bootmem bitmap for this node. 265 * Reserve the bootmem bitmap for this node.
@@ -239,31 +267,39 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
239 reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT, 267 reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT,
240 boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT); 268 boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT);
241 269
242 /* 270 return end_pfn;
243 * Reserve any special node zero regions. 271}
244 */
245 if (node == 0)
246 reserve_node_zero(pgdat);
247 272
273static void __init bootmem_reserve_initrd(int node)
274{
248#ifdef CONFIG_BLK_DEV_INITRD 275#ifdef CONFIG_BLK_DEV_INITRD
249 /* 276 pg_data_t *pgdat = NODE_DATA(node);
250 * If the initrd is in this node, reserve its memory. 277 int res;
251 */ 278
252 if (node == initrd_node) { 279 res = reserve_bootmem_node(pgdat, phys_initrd_start,
253 int res = reserve_bootmem_node(pgdat, phys_initrd_start, 280 phys_initrd_size, BOOTMEM_EXCLUSIVE);
254 phys_initrd_size, BOOTMEM_EXCLUSIVE); 281
255 282 if (res == 0) {
256 if (res == 0) { 283 initrd_start = __phys_to_virt(phys_initrd_start);
257 initrd_start = __phys_to_virt(phys_initrd_start); 284 initrd_end = initrd_start + phys_initrd_size;
258 initrd_end = initrd_start + phys_initrd_size; 285 } else {
259 } else { 286 printk(KERN_ERR
260 printk(KERN_ERR 287 "INITRD: 0x%08lx+0x%08lx overlaps in-use "
261 "INITRD: 0x%08lx+0x%08lx overlaps in-use " 288 "memory region - disabling initrd\n",
262 "memory region - disabling initrd\n", 289 phys_initrd_start, phys_initrd_size);
263 phys_initrd_start, phys_initrd_size);
264 }
265 } 290 }
266#endif 291#endif
292}
293
294static void __init bootmem_free_node(int node, struct meminfo *mi)
295{
296 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
297 unsigned long start_pfn, end_pfn;
298 pg_data_t *pgdat = NODE_DATA(node);
299 int i;
300
301 start_pfn = pgdat->bdata->node_min_pfn;
302 end_pfn = pgdat->bdata->node_low_pfn;
267 303
268 /* 304 /*
269 * initialise the zones within this node. 305 * initialise the zones within this node.
@@ -284,7 +320,7 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
284 */ 320 */
285 zhole_size[0] = zone_size[0]; 321 zhole_size[0] = zone_size[0];
286 for_each_nodebank(i, mi, node) 322 for_each_nodebank(i, mi, node)
287 zhole_size[0] -= mi->bank[i].size >> PAGE_SHIFT; 323 zhole_size[0] -= bank_pfn_size(&mi->bank[i]);
288 324
289 /* 325 /*
290 * Adjust the sizes according to any special requirements for 326 * Adjust the sizes according to any special requirements for
@@ -293,21 +329,12 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
293 arch_adjust_zones(node, zone_size, zhole_size); 329 arch_adjust_zones(node, zone_size, zhole_size);
294 330
295 free_area_init_node(node, zone_size, start_pfn, zhole_size); 331 free_area_init_node(node, zone_size, start_pfn, zhole_size);
296
297 return end_pfn;
298} 332}
299 333
300void __init bootmem_init(struct meminfo *mi) 334void __init bootmem_init(struct meminfo *mi)
301{ 335{
302 unsigned long memend_pfn = 0; 336 unsigned long memend_pfn = 0;
303 int node, initrd_node, i; 337 int node, initrd_node;
304
305 /*
306 * Invalidate the node number for empty or invalid memory banks
307 */
308 for (i = 0; i < mi->nr_banks; i++)
309 if (mi->bank[i].size == 0 || mi->bank[i].node >= MAX_NUMNODES)
310 mi->bank[i].node = -1;
311 338
312 memcpy(&meminfo, mi, sizeof(meminfo)); 339 memcpy(&meminfo, mi, sizeof(meminfo));
313 340
@@ -320,9 +347,19 @@ void __init bootmem_init(struct meminfo *mi)
320 * Run through each node initialising the bootmem allocator. 347 * Run through each node initialising the bootmem allocator.
321 */ 348 */
322 for_each_node(node) { 349 for_each_node(node) {
323 unsigned long end_pfn; 350 unsigned long end_pfn = bootmem_init_node(node, mi);
324 351
325 end_pfn = bootmem_init_node(node, initrd_node, mi); 352 /*
353 * Reserve any special node zero regions.
354 */
355 if (node == 0)
356 reserve_node_zero(NODE_DATA(node));
357
358 /*
359 * If the initrd is in this node, reserve its memory.
360 */
361 if (node == initrd_node)
362 bootmem_reserve_initrd(node);
326 363
327 /* 364 /*
328 * Remember the highest memory PFN. 365 * Remember the highest memory PFN.
@@ -331,6 +368,19 @@ void __init bootmem_init(struct meminfo *mi)
331 memend_pfn = end_pfn; 368 memend_pfn = end_pfn;
332 } 369 }
333 370
371 /*
372 * sparse_init() needs the bootmem allocator up and running.
373 */
374 sparse_init();
375
376 /*
377 * Now free memory in each node - free_area_init_node needs
378 * the sparse mem_map arrays initialized by sparse_init()
379 * for memmap_init_zone(), otherwise all PFNs are invalid.
380 */
381 for_each_node(node)
382 bootmem_free_node(node, mi);
383
334 high_memory = __va(memend_pfn << PAGE_SHIFT); 384 high_memory = __va(memend_pfn << PAGE_SHIFT);
335 385
336 /* 386 /*
@@ -401,7 +451,9 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
401 * information on the command line. 451 * information on the command line.
402 */ 452 */
403 for_each_nodebank(i, mi, node) { 453 for_each_nodebank(i, mi, node) {
404 bank_start = mi->bank[i].start >> PAGE_SHIFT; 454 struct membank *bank = &mi->bank[i];
455
456 bank_start = bank_pfn_start(bank);
405 if (bank_start < prev_bank_end) { 457 if (bank_start < prev_bank_end) {
406 printk(KERN_ERR "MEM: unordered memory banks. " 458 printk(KERN_ERR "MEM: unordered memory banks. "
407 "Not freeing memmap.\n"); 459 "Not freeing memmap.\n");
@@ -415,8 +467,7 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
415 if (prev_bank_end && prev_bank_end != bank_start) 467 if (prev_bank_end && prev_bank_end != bank_start)
416 free_memmap(node, prev_bank_end, bank_start); 468 free_memmap(node, prev_bank_end, bank_start);
417 469
418 prev_bank_end = (mi->bank[i].start + 470 prev_bank_end = bank_pfn_end(bank);
419 mi->bank[i].size) >> PAGE_SHIFT;
420 } 471 }
421} 472}
422 473
@@ -461,8 +512,8 @@ void __init mem_init(void)
461 512
462 num_physpages = 0; 513 num_physpages = 0;
463 for (i = 0; i < meminfo.nr_banks; i++) { 514 for (i = 0; i < meminfo.nr_banks; i++) {
464 num_physpages += meminfo.bank[i].size >> PAGE_SHIFT; 515 num_physpages += bank_pfn_size(&meminfo.bank[i]);
465 printk(" %ldMB", meminfo.bank[i].size >> 20); 516 printk(" %ldMB", bank_phys_size(&meminfo.bank[i]) >> 20);
466 } 517 }
467 518
468 printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT)); 519 printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
diff --git a/arch/arm/mm/iomap.c b/arch/arm/mm/iomap.c
index 7429f8c01015..ffad039cbb73 100644
--- a/arch/arm/mm/iomap.c
+++ b/arch/arm/mm/iomap.c
@@ -7,8 +7,7 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/pci.h> 8#include <linux/pci.h>
9#include <linux/ioport.h> 9#include <linux/ioport.h>
10 10#include <linux/io.h>
11#include <asm/io.h>
12 11
13#ifdef __io 12#ifdef __io
14void __iomem *ioport_map(unsigned long port, unsigned int nr) 13void __iomem *ioport_map(unsigned long port, unsigned int nr)
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index b81dbf9ffb77..18373f73f2fc 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -24,9 +24,10 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/io.h>
27 28
29#include <asm/cputype.h>
28#include <asm/cacheflush.h> 30#include <asm/cacheflush.h>
29#include <asm/io.h>
30#include <asm/mmu_context.h> 31#include <asm/mmu_context.h>
31#include <asm/pgalloc.h> 32#include <asm/pgalloc.h>
32#include <asm/tlbflush.h> 33#include <asm/tlbflush.h>
@@ -55,8 +56,7 @@ static int remap_area_pte(pmd_t *pmd, unsigned long addr, unsigned long end,
55 if (!pte_none(*pte)) 56 if (!pte_none(*pte))
56 goto bad; 57 goto bad;
57 58
58 set_pte_ext(pte, pfn_pte(phys_addr >> PAGE_SHIFT, prot), 59 set_pte_ext(pte, pfn_pte(phys_addr >> PAGE_SHIFT, prot), 0);
59 type->prot_pte_ext);
60 phys_addr += PAGE_SIZE; 60 phys_addr += PAGE_SIZE;
61 } while (pte++, addr += PAGE_SIZE, addr != end); 61 } while (pte++, addr += PAGE_SIZE, addr != end);
62 return 0; 62 return 0;
@@ -332,15 +332,14 @@ __arm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
332} 332}
333EXPORT_SYMBOL(__arm_ioremap); 333EXPORT_SYMBOL(__arm_ioremap);
334 334
335void __iounmap(volatile void __iomem *addr) 335void __iounmap(volatile void __iomem *io_addr)
336{ 336{
337 void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr);
337#ifndef CONFIG_SMP 338#ifndef CONFIG_SMP
338 struct vm_struct **p, *tmp; 339 struct vm_struct **p, *tmp;
339#endif 340#endif
340 unsigned int section_mapping = 0; 341 unsigned int section_mapping = 0;
341 342
342 addr = (volatile void __iomem *)(PAGE_MASK & (unsigned long)addr);
343
344#ifndef CONFIG_SMP 343#ifndef CONFIG_SMP
345 /* 344 /*
346 * If this is a section based mapping we need to handle it 345 * If this is a section based mapping we need to handle it
@@ -351,7 +350,7 @@ void __iounmap(volatile void __iomem *addr)
351 */ 350 */
352 write_lock(&vmlist_lock); 351 write_lock(&vmlist_lock);
353 for (p = &vmlist ; (tmp = *p) ; p = &tmp->next) { 352 for (p = &vmlist ; (tmp = *p) ; p = &tmp->next) {
354 if((tmp->flags & VM_IOREMAP) && (tmp->addr == addr)) { 353 if ((tmp->flags & VM_IOREMAP) && (tmp->addr == addr)) {
355 if (tmp->flags & VM_ARM_SECTION_MAPPING) { 354 if (tmp->flags & VM_ARM_SECTION_MAPPING) {
356 *p = tmp->next; 355 *p = tmp->next;
357 unmap_area_sections((unsigned long)tmp->addr, 356 unmap_area_sections((unsigned long)tmp->addr,
@@ -366,6 +365,6 @@ void __iounmap(volatile void __iomem *addr)
366#endif 365#endif
367 366
368 if (!section_mapping) 367 if (!section_mapping)
369 vunmap((void __force *)addr); 368 vunmap(addr);
370} 369}
371EXPORT_SYMBOL(__iounmap); 370EXPORT_SYMBOL(__iounmap);
diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h
index 7647c597fc59..5d9f53907b4e 100644
--- a/arch/arm/mm/mm.h
+++ b/arch/arm/mm/mm.h
@@ -18,7 +18,6 @@ static inline pmd_t *pmd_off_k(unsigned long virt)
18 18
19struct mem_type { 19struct mem_type {
20 unsigned int prot_pte; 20 unsigned int prot_pte;
21 unsigned int prot_pte_ext;
22 unsigned int prot_l1; 21 unsigned int prot_l1;
23 unsigned int prot_sect; 22 unsigned int prot_sect;
24 unsigned int domain; 23 unsigned int domain;
@@ -35,3 +34,5 @@ struct pglist_data;
35void __init create_mapping(struct map_desc *md); 34void __init create_mapping(struct map_desc *md);
36void __init bootmem_init(struct meminfo *mi); 35void __init bootmem_init(struct meminfo *mi);
37void reserve_node_zero(struct pglist_data *pgdat); 36void reserve_node_zero(struct pglist_data *pgdat);
37
38extern void _text, _stext, _etext, __data_start, _end, __init_begin, __init_end;
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 3f6dc40b8353..5358fcc7f61e 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -6,6 +6,8 @@
6#include <linux/mman.h> 6#include <linux/mman.h>
7#include <linux/shm.h> 7#include <linux/shm.h>
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/io.h>
10#include <asm/cputype.h>
9#include <asm/system.h> 11#include <asm/system.h>
10 12
11#define COLOUR_ALIGN(addr,pgoff) \ 13#define COLOUR_ALIGN(addr,pgoff) \
@@ -37,8 +39,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
37 * caches alias. This is indicated by bits 9 and 21 of the 39 * caches alias. This is indicated by bits 9 and 21 of the
38 * cache type register. 40 * cache type register.
39 */ 41 */
40 cache_type = read_cpuid(CPUID_CACHETYPE); 42 cache_type = read_cpuid_cachetype();
41 if (cache_type != read_cpuid(CPUID_ID)) { 43 if (cache_type != read_cpuid_id()) {
42 aliasing = (cache_type | cache_type >> 12) & (1 << 11); 44 aliasing = (cache_type | cache_type >> 12) & (1 << 11);
43 if (aliasing) 45 if (aliasing)
44 do_align = filp || flags & MAP_SHARED; 46 do_align = filp || flags & MAP_SHARED;
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index a713e40e1f1a..8ba754064559 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -15,6 +15,7 @@
15#include <linux/mman.h> 15#include <linux/mman.h>
16#include <linux/nodemask.h> 16#include <linux/nodemask.h>
17 17
18#include <asm/cputype.h>
18#include <asm/mach-types.h> 19#include <asm/mach-types.h>
19#include <asm/setup.h> 20#include <asm/setup.h>
20#include <asm/sizes.h> 21#include <asm/sizes.h>
@@ -27,9 +28,6 @@
27 28
28DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 29DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
29 30
30extern void _stext, _etext, __data_start, _end;
31extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
32
33/* 31/*
34 * empty_zero_page is a special page that is used for 32 * empty_zero_page is a special page that is used for
35 * zero-initialized data and COW. 33 * zero-initialized data and COW.
@@ -68,27 +66,27 @@ static struct cachepolicy cache_policies[] __initdata = {
68 .policy = "uncached", 66 .policy = "uncached",
69 .cr_mask = CR_W|CR_C, 67 .cr_mask = CR_W|CR_C,
70 .pmd = PMD_SECT_UNCACHED, 68 .pmd = PMD_SECT_UNCACHED,
71 .pte = 0, 69 .pte = L_PTE_MT_UNCACHED,
72 }, { 70 }, {
73 .policy = "buffered", 71 .policy = "buffered",
74 .cr_mask = CR_C, 72 .cr_mask = CR_C,
75 .pmd = PMD_SECT_BUFFERED, 73 .pmd = PMD_SECT_BUFFERED,
76 .pte = PTE_BUFFERABLE, 74 .pte = L_PTE_MT_BUFFERABLE,
77 }, { 75 }, {
78 .policy = "writethrough", 76 .policy = "writethrough",
79 .cr_mask = 0, 77 .cr_mask = 0,
80 .pmd = PMD_SECT_WT, 78 .pmd = PMD_SECT_WT,
81 .pte = PTE_CACHEABLE, 79 .pte = L_PTE_MT_WRITETHROUGH,
82 }, { 80 }, {
83 .policy = "writeback", 81 .policy = "writeback",
84 .cr_mask = 0, 82 .cr_mask = 0,
85 .pmd = PMD_SECT_WB, 83 .pmd = PMD_SECT_WB,
86 .pte = PTE_BUFFERABLE|PTE_CACHEABLE, 84 .pte = L_PTE_MT_WRITEBACK,
87 }, { 85 }, {
88 .policy = "writealloc", 86 .policy = "writealloc",
89 .cr_mask = 0, 87 .cr_mask = 0,
90 .pmd = PMD_SECT_WBWA, 88 .pmd = PMD_SECT_WBWA,
91 .pte = PTE_BUFFERABLE|PTE_CACHEABLE, 89 .pte = L_PTE_MT_WRITEALLOC,
92 } 90 }
93}; 91};
94 92
@@ -186,35 +184,28 @@ void adjust_cr(unsigned long mask, unsigned long set)
186 184
187static struct mem_type mem_types[] = { 185static struct mem_type mem_types[] = {
188 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */ 186 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
189 .prot_pte = PROT_PTE_DEVICE, 187 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
188 L_PTE_SHARED,
190 .prot_l1 = PMD_TYPE_TABLE, 189 .prot_l1 = PMD_TYPE_TABLE,
191 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_UNCACHED, 190 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_UNCACHED,
192 .domain = DOMAIN_IO, 191 .domain = DOMAIN_IO,
193 }, 192 },
194 [MT_DEVICE_NONSHARED] = { /* ARMv6 non-shared device */ 193 [MT_DEVICE_NONSHARED] = { /* ARMv6 non-shared device */
195 .prot_pte = PROT_PTE_DEVICE, 194 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_NONSHARED,
196 .prot_pte_ext = PTE_EXT_TEX(2),
197 .prot_l1 = PMD_TYPE_TABLE, 195 .prot_l1 = PMD_TYPE_TABLE,
198 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_TEX(2), 196 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_TEX(2),
199 .domain = DOMAIN_IO, 197 .domain = DOMAIN_IO,
200 }, 198 },
201 [MT_DEVICE_CACHED] = { /* ioremap_cached */ 199 [MT_DEVICE_CACHED] = { /* ioremap_cached */
202 .prot_pte = PROT_PTE_DEVICE | L_PTE_CACHEABLE | L_PTE_BUFFERABLE, 200 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_CACHED,
203 .prot_l1 = PMD_TYPE_TABLE, 201 .prot_l1 = PMD_TYPE_TABLE,
204 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_WB, 202 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_WB,
205 .domain = DOMAIN_IO, 203 .domain = DOMAIN_IO,
206 }, 204 },
207 [MT_DEVICE_IXP2000] = { /* IXP2400 requires XCB=101 for on-chip I/O */
208 .prot_pte = PROT_PTE_DEVICE,
209 .prot_l1 = PMD_TYPE_TABLE,
210 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_BUFFERABLE |
211 PMD_SECT_TEX(1),
212 .domain = DOMAIN_IO,
213 },
214 [MT_DEVICE_WC] = { /* ioremap_wc */ 205 [MT_DEVICE_WC] = { /* ioremap_wc */
215 .prot_pte = PROT_PTE_DEVICE, 206 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_WC,
216 .prot_l1 = PMD_TYPE_TABLE, 207 .prot_l1 = PMD_TYPE_TABLE,
217 .prot_sect = PROT_SECT_DEVICE, 208 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_BUFFERABLE,
218 .domain = DOMAIN_IO, 209 .domain = DOMAIN_IO,
219 }, 210 },
220 [MT_CACHECLEAN] = { 211 [MT_CACHECLEAN] = {
@@ -259,7 +250,7 @@ static void __init build_mem_type_table(void)
259{ 250{
260 struct cachepolicy *cp; 251 struct cachepolicy *cp;
261 unsigned int cr = get_cr(); 252 unsigned int cr = get_cr();
262 unsigned int user_pgprot, kern_pgprot; 253 unsigned int user_pgprot, kern_pgprot, vecs_pgprot;
263 int cpu_arch = cpu_architecture(); 254 int cpu_arch = cpu_architecture();
264 int i; 255 int i;
265 256
@@ -277,6 +268,9 @@ static void __init build_mem_type_table(void)
277 cachepolicy = CPOLICY_WRITEBACK; 268 cachepolicy = CPOLICY_WRITEBACK;
278 ecc_mask = 0; 269 ecc_mask = 0;
279 } 270 }
271#ifdef CONFIG_SMP
272 cachepolicy = CPOLICY_WRITEALLOC;
273#endif
280 274
281 /* 275 /*
282 * On non-Xscale3 ARMv5-and-older systems, use CB=01 276 * On non-Xscale3 ARMv5-and-older systems, use CB=01
@@ -285,11 +279,8 @@ static void __init build_mem_type_table(void)
285 * in xsc3 parlance, Uncached Normal in ARMv6 parlance). 279 * in xsc3 parlance, Uncached Normal in ARMv6 parlance).
286 */ 280 */
287 if (cpu_is_xsc3() || cpu_arch >= CPU_ARCH_ARMv6) { 281 if (cpu_is_xsc3() || cpu_arch >= CPU_ARCH_ARMv6) {
288 mem_types[MT_DEVICE_WC].prot_pte_ext |= PTE_EXT_TEX(1);
289 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_TEX(1); 282 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_TEX(1);
290 } else { 283 mem_types[MT_DEVICE_WC].prot_sect &= ~PMD_SECT_BUFFERABLE;
291 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_BUFFERABLE;
292 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_BUFFERABLE;
293 } 284 }
294 285
295 /* 286 /*
@@ -312,7 +303,15 @@ static void __init build_mem_type_table(void)
312 } 303 }
313 304
314 cp = &cache_policies[cachepolicy]; 305 cp = &cache_policies[cachepolicy];
315 kern_pgprot = user_pgprot = cp->pte; 306 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte;
307
308#ifndef CONFIG_SMP
309 /*
310 * Only use write-through for non-SMP systems
311 */
312 if (cpu_arch >= CPU_ARCH_ARMv5 && cachepolicy > CPOLICY_WRITETHROUGH)
313 vecs_pgprot = cache_policies[CPOLICY_WRITETHROUGH].pte;
314#endif
316 315
317 /* 316 /*
318 * Enable CPU-specific coherency if supported. 317 * Enable CPU-specific coherency if supported.
@@ -340,7 +339,6 @@ static void __init build_mem_type_table(void)
340 /* 339 /*
341 * Mark the device area as "shared device" 340 * Mark the device area as "shared device"
342 */ 341 */
343 mem_types[MT_DEVICE].prot_pte |= L_PTE_BUFFERABLE;
344 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_BUFFERED; 342 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_BUFFERED;
345 343
346#ifdef CONFIG_SMP 344#ifdef CONFIG_SMP
@@ -349,30 +347,21 @@ static void __init build_mem_type_table(void)
349 */ 347 */
350 user_pgprot |= L_PTE_SHARED; 348 user_pgprot |= L_PTE_SHARED;
351 kern_pgprot |= L_PTE_SHARED; 349 kern_pgprot |= L_PTE_SHARED;
350 vecs_pgprot |= L_PTE_SHARED;
352 mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S; 351 mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
353#endif 352#endif
354 } 353 }
355 354
356 for (i = 0; i < 16; i++) { 355 for (i = 0; i < 16; i++) {
357 unsigned long v = pgprot_val(protection_map[i]); 356 unsigned long v = pgprot_val(protection_map[i]);
358 v = (v & ~(L_PTE_BUFFERABLE|L_PTE_CACHEABLE)) | user_pgprot; 357 protection_map[i] = __pgprot(v | user_pgprot);
359 protection_map[i] = __pgprot(v);
360 } 358 }
361 359
362 mem_types[MT_LOW_VECTORS].prot_pte |= kern_pgprot; 360 mem_types[MT_LOW_VECTORS].prot_pte |= vecs_pgprot;
363 mem_types[MT_HIGH_VECTORS].prot_pte |= kern_pgprot; 361 mem_types[MT_HIGH_VECTORS].prot_pte |= vecs_pgprot;
364 362
365 if (cpu_arch >= CPU_ARCH_ARMv5) { 363 if (cpu_arch < CPU_ARCH_ARMv5)
366#ifndef CONFIG_SMP
367 /*
368 * Only use write-through for non-SMP systems
369 */
370 mem_types[MT_LOW_VECTORS].prot_pte &= ~L_PTE_BUFFERABLE;
371 mem_types[MT_HIGH_VECTORS].prot_pte &= ~L_PTE_BUFFERABLE;
372#endif
373 } else {
374 mem_types[MT_MINICLEAN].prot_sect &= ~PMD_SECT_TEX(1); 364 mem_types[MT_MINICLEAN].prot_sect &= ~PMD_SECT_TEX(1);
375 }
376 365
377 pgprot_user = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | user_pgprot); 366 pgprot_user = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | user_pgprot);
378 pgprot_kernel = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | 367 pgprot_kernel = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG |
@@ -420,8 +409,7 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
420 409
421 pte = pte_offset_kernel(pmd, addr); 410 pte = pte_offset_kernel(pmd, addr);
422 do { 411 do {
423 set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 412 set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
424 type->prot_pte_ext);
425 pfn++; 413 pfn++;
426 } while (pte++, addr += PAGE_SIZE, addr != end); 414 } while (pte++, addr += PAGE_SIZE, addr != end);
427} 415}
@@ -588,12 +576,35 @@ void __init iotable_init(struct map_desc *io_desc, int nr)
588 create_mapping(io_desc + i); 576 create_mapping(io_desc + i);
589} 577}
590 578
579static unsigned long __initdata vmalloc_reserve = SZ_128M;
580
581/*
582 * vmalloc=size forces the vmalloc area to be exactly 'size'
583 * bytes. This can be used to increase (or decrease) the vmalloc
584 * area - the default is 128m.
585 */
586static void __init early_vmalloc(char **arg)
587{
588 vmalloc_reserve = memparse(*arg, arg);
589
590 if (vmalloc_reserve < SZ_16M) {
591 vmalloc_reserve = SZ_16M;
592 printk(KERN_WARNING
593 "vmalloc area too small, limiting to %luMB\n",
594 vmalloc_reserve >> 20);
595 }
596}
597__early_param("vmalloc=", early_vmalloc);
598
599#define VMALLOC_MIN (void *)(VMALLOC_END - vmalloc_reserve)
600
591static int __init check_membank_valid(struct membank *mb) 601static int __init check_membank_valid(struct membank *mb)
592{ 602{
593 /* 603 /*
594 * Check whether this memory region has non-zero size. 604 * Check whether this memory region has non-zero size or
605 * invalid node number.
595 */ 606 */
596 if (mb->size == 0) 607 if (mb->size == 0 || mb->node >= MAX_NUMNODES)
597 return 0; 608 return 0;
598 609
599 /* 610 /*
@@ -627,8 +638,7 @@ static int __init check_membank_valid(struct membank *mb)
627 638
628static void __init sanity_check_meminfo(struct meminfo *mi) 639static void __init sanity_check_meminfo(struct meminfo *mi)
629{ 640{
630 int i; 641 int i, j;
631 int j;
632 642
633 for (i = 0, j = 0; i < mi->nr_banks; i++) { 643 for (i = 0, j = 0; i < mi->nr_banks; i++) {
634 if (check_membank_valid(&mi->bank[i])) 644 if (check_membank_valid(&mi->bank[i]))
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 63c62fdea521..07b62b238979 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -7,16 +7,14 @@
7#include <linux/mm.h> 7#include <linux/mm.h>
8#include <linux/pagemap.h> 8#include <linux/pagemap.h>
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/io.h>
10 11
11#include <asm/cacheflush.h> 12#include <asm/cacheflush.h>
12#include <asm/io.h>
13#include <asm/page.h> 13#include <asm/page.h>
14#include <asm/mach/arch.h> 14#include <asm/mach/arch.h>
15 15
16#include "mm.h" 16#include "mm.h"
17 17
18extern void _stext, __data_start, _end;
19
20/* 18/*
21 * Reserve the various regions of node 0 19 * Reserve the various regions of node 0
22 */ 20 */
@@ -43,12 +41,26 @@ void __init reserve_node_zero(pg_data_t *pgdat)
43 BOOTMEM_DEFAULT); 41 BOOTMEM_DEFAULT);
44} 42}
45 43
44static void __init sanity_check_meminfo(struct meminfo *mi)
45{
46 int i, j;
47
48 for (i = 0, j = 0; i < mi->nr_banks; i++) {
49 struct membank *mb = &mi->bank[i];
50
51 if (mb->size != 0 && mb->node < MAX_NUMNODES)
52 mi->bank[j++] = mi->bank[i];
53 }
54 mi->nr_banks = j;
55}
56
46/* 57/*
47 * paging_init() sets up the page tables, initialises the zone memory 58 * paging_init() sets up the page tables, initialises the zone memory
48 * maps, and sets up the zero page, bad page and bad page tables. 59 * maps, and sets up the zero page, bad page and bad page tables.
49 */ 60 */
50void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc) 61void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc)
51{ 62{
63 sanity_check_meminfo(mi);
52 bootmem_init(mi); 64 bootmem_init(mi);
53} 65}
54 66
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 5673f4d6113b..b5551bf010aa 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -29,7 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/asm-offsets.h> 31#include <asm/asm-offsets.h>
32#include <asm/elf.h> 32#include <asm/hwcap.h>
33#include <asm/pgtable-hwdef.h> 33#include <asm/pgtable-hwdef.h>
34#include <asm/pgtable.h> 34#include <asm/pgtable.h>
35#include <asm/ptrace.h> 35#include <asm/ptrace.h>
@@ -399,29 +399,7 @@ ENTRY(cpu_arm1020_switch_mm)
399 .align 5 399 .align 5
400ENTRY(cpu_arm1020_set_pte_ext) 400ENTRY(cpu_arm1020_set_pte_ext)
401#ifdef CONFIG_MMU 401#ifdef CONFIG_MMU
402 str r1, [r0], #-2048 @ linux version 402 armv3_set_pte_ext
403
404 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
405
406 bic r2, r1, #PTE_SMALL_AP_MASK
407 bic r2, r2, #PTE_TYPE_MASK
408 orr r2, r2, #PTE_TYPE_SMALL
409
410 tst r1, #L_PTE_USER @ User?
411 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
412
413 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
414 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
415
416 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
417 movne r2, #0
418
419#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
420 eor r3, r1, #0x0a @ C & small page?
421 tst r3, #0x0b
422 biceq r2, r2, #4
423#endif
424 str r2, [r0] @ hardware version
425 mov r0, r0 403 mov r0, r0
426#ifndef CONFIG_CPU_DCACHE_DISABLE 404#ifndef CONFIG_CPU_DCACHE_DISABLE
427 mcr p15, 0, r0, c7, c10, 4 405 mcr p15, 0, r0, c7, c10, 4
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index 4343fdb0e9e5..8bc6740c29eb 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -29,7 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/asm-offsets.h> 31#include <asm/asm-offsets.h>
32#include <asm/elf.h> 32#include <asm/hwcap.h>
33#include <asm/pgtable-hwdef.h> 33#include <asm/pgtable-hwdef.h>
34#include <asm/pgtable.h> 34#include <asm/pgtable.h>
35#include <asm/ptrace.h> 35#include <asm/ptrace.h>
@@ -383,29 +383,7 @@ ENTRY(cpu_arm1020e_switch_mm)
383 .align 5 383 .align 5
384ENTRY(cpu_arm1020e_set_pte_ext) 384ENTRY(cpu_arm1020e_set_pte_ext)
385#ifdef CONFIG_MMU 385#ifdef CONFIG_MMU
386 str r1, [r0], #-2048 @ linux version 386 armv3_set_pte_ext
387
388 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
389
390 bic r2, r1, #PTE_SMALL_AP_MASK
391 bic r2, r2, #PTE_TYPE_MASK
392 orr r2, r2, #PTE_TYPE_SMALL
393
394 tst r1, #L_PTE_USER @ User?
395 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
396
397 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
398 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
399
400 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
401 movne r2, #0
402
403#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
404 eor r3, r1, #0x0a @ C & small page?
405 tst r3, #0x0b
406 biceq r2, r2, #4
407#endif
408 str r2, [r0] @ hardware version
409 mov r0, r0 387 mov r0, r0
410#ifndef CONFIG_CPU_DCACHE_DISABLE 388#ifndef CONFIG_CPU_DCACHE_DISABLE
411 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 389 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S
index 2a4ea1659e96..2cd03e66c0a3 100644
--- a/arch/arm/mm/proc-arm1022.S
+++ b/arch/arm/mm/proc-arm1022.S
@@ -18,7 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <asm/assembler.h> 19#include <asm/assembler.h>
20#include <asm/asm-offsets.h> 20#include <asm/asm-offsets.h>
21#include <asm/elf.h> 21#include <asm/hwcap.h>
22#include <asm/pgtable-hwdef.h> 22#include <asm/pgtable-hwdef.h>
23#include <asm/pgtable.h> 23#include <asm/pgtable.h>
24#include <asm/ptrace.h> 24#include <asm/ptrace.h>
@@ -365,29 +365,7 @@ ENTRY(cpu_arm1022_switch_mm)
365 .align 5 365 .align 5
366ENTRY(cpu_arm1022_set_pte_ext) 366ENTRY(cpu_arm1022_set_pte_ext)
367#ifdef CONFIG_MMU 367#ifdef CONFIG_MMU
368 str r1, [r0], #-2048 @ linux version 368 armv3_set_pte_ext
369
370 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
371
372 bic r2, r1, #PTE_SMALL_AP_MASK
373 bic r2, r2, #PTE_TYPE_MASK
374 orr r2, r2, #PTE_TYPE_SMALL
375
376 tst r1, #L_PTE_USER @ User?
377 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
378
379 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
380 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
381
382 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
383 movne r2, #0
384
385#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
386 eor r3, r1, #0x0a @ C & small page?
387 tst r3, #0x0b
388 biceq r2, r2, #4
389#endif
390 str r2, [r0] @ hardware version
391 mov r0, r0 369 mov r0, r0
392#ifndef CONFIG_CPU_DCACHE_DISABLE 370#ifndef CONFIG_CPU_DCACHE_DISABLE
393 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 371 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S
index 77a1babd421c..ad961a897f6e 100644
--- a/arch/arm/mm/proc-arm1026.S
+++ b/arch/arm/mm/proc-arm1026.S
@@ -18,7 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <asm/assembler.h> 19#include <asm/assembler.h>
20#include <asm/asm-offsets.h> 20#include <asm/asm-offsets.h>
21#include <asm/elf.h> 21#include <asm/hwcap.h>
22#include <asm/pgtable-hwdef.h> 22#include <asm/pgtable-hwdef.h>
23#include <asm/pgtable.h> 23#include <asm/pgtable.h>
24#include <asm/ptrace.h> 24#include <asm/ptrace.h>
@@ -354,29 +354,7 @@ ENTRY(cpu_arm1026_switch_mm)
354 .align 5 354 .align 5
355ENTRY(cpu_arm1026_set_pte_ext) 355ENTRY(cpu_arm1026_set_pte_ext)
356#ifdef CONFIG_MMU 356#ifdef CONFIG_MMU
357 str r1, [r0], #-2048 @ linux version 357 armv3_set_pte_ext
358
359 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
360
361 bic r2, r1, #PTE_SMALL_AP_MASK
362 bic r2, r2, #PTE_TYPE_MASK
363 orr r2, r2, #PTE_TYPE_SMALL
364
365 tst r1, #L_PTE_USER @ User?
366 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
367
368 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
369 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
370
371 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
372 movne r2, #0
373
374#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
375 eor r3, r1, #0x0a @ C & small page?
376 tst r3, #0x0b
377 biceq r2, r2, #4
378#endif
379 str r2, [r0] @ hardware version
380 mov r0, r0 358 mov r0, r0
381#ifndef CONFIG_CPU_DCACHE_DISABLE 359#ifndef CONFIG_CPU_DCACHE_DISABLE
382 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 360 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
diff --git a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S
index c371fc87776e..80d6e1de069a 100644
--- a/arch/arm/mm/proc-arm6_7.S
+++ b/arch/arm/mm/proc-arm6_7.S
@@ -15,11 +15,13 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <asm/assembler.h> 16#include <asm/assembler.h>
17#include <asm/asm-offsets.h> 17#include <asm/asm-offsets.h>
18#include <asm/elf.h> 18#include <asm/hwcap.h>
19#include <asm/pgtable-hwdef.h> 19#include <asm/pgtable-hwdef.h>
20#include <asm/pgtable.h> 20#include <asm/pgtable.h>
21#include <asm/ptrace.h> 21#include <asm/ptrace.h>
22 22
23#include "proc-macros.S"
24
23ENTRY(cpu_arm6_dcache_clean_area) 25ENTRY(cpu_arm6_dcache_clean_area)
24ENTRY(cpu_arm7_dcache_clean_area) 26ENTRY(cpu_arm7_dcache_clean_area)
25 mov pc, lr 27 mov pc, lr
@@ -214,30 +216,13 @@ ENTRY(cpu_arm7_switch_mm)
214 * : r1 = value to set 216 * : r1 = value to set
215 * Purpose : Set a PTE and flush it out of any WB cache 217 * Purpose : Set a PTE and flush it out of any WB cache
216 */ 218 */
217 .align 5 219 .align 5
218ENTRY(cpu_arm6_set_pte_ext) 220ENTRY(cpu_arm6_set_pte_ext)
219ENTRY(cpu_arm7_set_pte_ext) 221ENTRY(cpu_arm7_set_pte_ext)
220#ifdef CONFIG_MMU 222#ifdef CONFIG_MMU
221 str r1, [r0], #-2048 @ linux version 223 armv3_set_pte_ext wc_disable=0
222
223 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
224
225 bic r2, r1, #PTE_SMALL_AP_MASK
226 bic r2, r2, #PTE_TYPE_MASK
227 orr r2, r2, #PTE_TYPE_SMALL
228
229 tst r1, #L_PTE_USER @ User?
230 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
231
232 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
233 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
234
235 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young
236 movne r2, #0
237
238 str r2, [r0] @ hardware version
239#endif /* CONFIG_MMU */ 224#endif /* CONFIG_MMU */
240 mov pc, lr 225 mov pc, lr
241 226
242/* 227/*
243 * Function: _arm6_7_reset 228 * Function: _arm6_7_reset
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index eda733d30455..85ae18695f10 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -36,7 +36,7 @@
36#include <linux/init.h> 36#include <linux/init.h>
37#include <asm/assembler.h> 37#include <asm/assembler.h>
38#include <asm/asm-offsets.h> 38#include <asm/asm-offsets.h>
39#include <asm/elf.h> 39#include <asm/hwcap.h>
40#include <asm/pgtable-hwdef.h> 40#include <asm/pgtable-hwdef.h>
41#include <asm/pgtable.h> 41#include <asm/pgtable.h>
42#include <asm/ptrace.h> 42#include <asm/ptrace.h>
@@ -93,29 +93,12 @@ ENTRY(cpu_arm720_switch_mm)
93 * : r1 = value to set 93 * : r1 = value to set
94 * Purpose : Set a PTE and flush it out of any WB cache 94 * Purpose : Set a PTE and flush it out of any WB cache
95 */ 95 */
96 .align 5 96 .align 5
97ENTRY(cpu_arm720_set_pte_ext) 97ENTRY(cpu_arm720_set_pte_ext)
98#ifdef CONFIG_MMU 98#ifdef CONFIG_MMU
99 str r1, [r0], #-2048 @ linux version 99 armv3_set_pte_ext wc_disable=0
100
101 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
102
103 bic r2, r1, #PTE_SMALL_AP_MASK
104 bic r2, r2, #PTE_TYPE_MASK
105 orr r2, r2, #PTE_TYPE_SMALL
106
107 tst r1, #L_PTE_USER @ User?
108 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
109
110 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
111 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
112
113 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young
114 movne r2, #0
115
116 str r2, [r0] @ hardware version
117#endif 100#endif
118 mov pc, lr 101 mov pc, lr
119 102
120/* 103/*
121 * Function: arm720_reset 104 * Function: arm720_reset
diff --git a/arch/arm/mm/proc-arm740.S b/arch/arm/mm/proc-arm740.S
index 3a57376c8bc9..4f95bee63e95 100644
--- a/arch/arm/mm/proc-arm740.S
+++ b/arch/arm/mm/proc-arm740.S
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
15#include <asm/elf.h> 15#include <asm/hwcap.h>
16#include <asm/pgtable-hwdef.h> 16#include <asm/pgtable-hwdef.h>
17#include <asm/pgtable.h> 17#include <asm/pgtable.h>
18#include <asm/ptrace.h> 18#include <asm/ptrace.h>
diff --git a/arch/arm/mm/proc-arm7tdmi.S b/arch/arm/mm/proc-arm7tdmi.S
index 7b3ecdeb5370..93e05fa7bed4 100644
--- a/arch/arm/mm/proc-arm7tdmi.S
+++ b/arch/arm/mm/proc-arm7tdmi.S
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
15#include <asm/elf.h> 15#include <asm/hwcap.h>
16#include <asm/pgtable-hwdef.h> 16#include <asm/pgtable-hwdef.h>
17#include <asm/pgtable.h> 17#include <asm/pgtable.h>
18#include <asm/ptrace.h> 18#include <asm/ptrace.h>
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index 28cdb060df45..914d688394fc 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -28,7 +28,7 @@
28#include <linux/linkage.h> 28#include <linux/linkage.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/elf.h> 31#include <asm/hwcap.h>
32#include <asm/pgtable-hwdef.h> 32#include <asm/pgtable-hwdef.h>
33#include <asm/pgtable.h> 33#include <asm/pgtable.h>
34#include <asm/page.h> 34#include <asm/page.h>
@@ -351,33 +351,11 @@ ENTRY(cpu_arm920_switch_mm)
351 .align 5 351 .align 5
352ENTRY(cpu_arm920_set_pte_ext) 352ENTRY(cpu_arm920_set_pte_ext)
353#ifdef CONFIG_MMU 353#ifdef CONFIG_MMU
354 str r1, [r0], #-2048 @ linux version 354 armv3_set_pte_ext
355
356 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
357
358 bic r2, r1, #PTE_SMALL_AP_MASK
359 bic r2, r2, #PTE_TYPE_MASK
360 orr r2, r2, #PTE_TYPE_SMALL
361
362 tst r1, #L_PTE_USER @ User?
363 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
364
365 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
366 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
367
368 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
369 movne r2, #0
370
371#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
372 eor r3, r2, #0x0a @ C & small page?
373 tst r3, #0x0b
374 biceq r2, r2, #4
375#endif
376 str r2, [r0] @ hardware version
377 mov r0, r0 355 mov r0, r0
378 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 356 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
379 mcr p15, 0, r0, c7, c10, 4 @ drain WB 357 mcr p15, 0, r0, c7, c10, 4 @ drain WB
380#endif /* CONFIG_MMU */ 358#endif
381 mov pc, lr 359 mov pc, lr
382 360
383 __INIT 361 __INIT
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index 94ddcb4a4b76..51c9c9859e58 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -29,7 +29,7 @@
29#include <linux/linkage.h> 29#include <linux/linkage.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <asm/assembler.h> 31#include <asm/assembler.h>
32#include <asm/elf.h> 32#include <asm/hwcap.h>
33#include <asm/pgtable-hwdef.h> 33#include <asm/pgtable-hwdef.h>
34#include <asm/pgtable.h> 34#include <asm/pgtable.h>
35#include <asm/page.h> 35#include <asm/page.h>
@@ -355,29 +355,7 @@ ENTRY(cpu_arm922_switch_mm)
355 .align 5 355 .align 5
356ENTRY(cpu_arm922_set_pte_ext) 356ENTRY(cpu_arm922_set_pte_ext)
357#ifdef CONFIG_MMU 357#ifdef CONFIG_MMU
358 str r1, [r0], #-2048 @ linux version 358 armv3_set_pte_ext
359
360 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
361
362 bic r2, r1, #PTE_SMALL_AP_MASK
363 bic r2, r2, #PTE_TYPE_MASK
364 orr r2, r2, #PTE_TYPE_SMALL
365
366 tst r1, #L_PTE_USER @ User?
367 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
368
369 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
370 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
371
372 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
373 movne r2, #0
374
375#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
376 eor r3, r2, #0x0a @ C & small page?
377 tst r3, #0x0b
378 biceq r2, r2, #4
379#endif
380 str r2, [r0] @ hardware version
381 mov r0, r0 359 mov r0, r0
382 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 360 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
383 mcr p15, 0, r0, c7, c10, 4 @ drain WB 361 mcr p15, 0, r0, c7, c10, 4 @ drain WB
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index d045812f3399..2724526d89c1 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -52,7 +52,7 @@
52#include <linux/linkage.h> 52#include <linux/linkage.h>
53#include <linux/init.h> 53#include <linux/init.h>
54#include <asm/assembler.h> 54#include <asm/assembler.h>
55#include <asm/elf.h> 55#include <asm/hwcap.h>
56#include <asm/pgtable-hwdef.h> 56#include <asm/pgtable-hwdef.h>
57#include <asm/pgtable.h> 57#include <asm/pgtable.h>
58#include <asm/page.h> 58#include <asm/page.h>
@@ -398,29 +398,7 @@ ENTRY(cpu_arm925_switch_mm)
398 .align 5 398 .align 5
399ENTRY(cpu_arm925_set_pte_ext) 399ENTRY(cpu_arm925_set_pte_ext)
400#ifdef CONFIG_MMU 400#ifdef CONFIG_MMU
401 str r1, [r0], #-2048 @ linux version 401 armv3_set_pte_ext
402
403 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
404
405 bic r2, r1, #PTE_SMALL_AP_MASK
406 bic r2, r2, #PTE_TYPE_MASK
407 orr r2, r2, #PTE_TYPE_SMALL
408
409 tst r1, #L_PTE_USER @ User?
410 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
411
412 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
413 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
414
415 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
416 movne r2, #0
417
418#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
419 eor r3, r2, #0x0a @ C & small page?
420 tst r3, #0x0b
421 biceq r2, r2, #4
422#endif
423 str r2, [r0] @ hardware version
424 mov r0, r0 402 mov r0, r0
425#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH 403#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
426 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 404 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 4cd33169a7c9..54466937bff9 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -28,7 +28,7 @@
28#include <linux/linkage.h> 28#include <linux/linkage.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <asm/assembler.h> 30#include <asm/assembler.h>
31#include <asm/elf.h> 31#include <asm/hwcap.h>
32#include <asm/pgtable-hwdef.h> 32#include <asm/pgtable-hwdef.h>
33#include <asm/pgtable.h> 33#include <asm/pgtable.h>
34#include <asm/page.h> 34#include <asm/page.h>
@@ -359,29 +359,7 @@ ENTRY(cpu_arm926_switch_mm)
359 .align 5 359 .align 5
360ENTRY(cpu_arm926_set_pte_ext) 360ENTRY(cpu_arm926_set_pte_ext)
361#ifdef CONFIG_MMU 361#ifdef CONFIG_MMU
362 str r1, [r0], #-2048 @ linux version 362 armv3_set_pte_ext
363
364 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
365
366 bic r2, r1, #PTE_SMALL_AP_MASK
367 bic r2, r2, #PTE_TYPE_MASK
368 orr r2, r2, #PTE_TYPE_SMALL
369
370 tst r1, #L_PTE_USER @ User?
371 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
372
373 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
374 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
375
376 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
377 movne r2, #0
378
379#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
380 eor r3, r2, #0x0a @ C & small page?
381 tst r3, #0x0b
382 biceq r2, r2, #4
383#endif
384 str r2, [r0] @ hardware version
385 mov r0, r0 363 mov r0, r0
386#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH 364#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
387 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 365 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
diff --git a/arch/arm/mm/proc-arm940.S b/arch/arm/mm/proc-arm940.S
index 551244d5ca19..f595117caf55 100644
--- a/arch/arm/mm/proc-arm940.S
+++ b/arch/arm/mm/proc-arm940.S
@@ -11,7 +11,7 @@
11#include <linux/linkage.h> 11#include <linux/linkage.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/elf.h> 14#include <asm/hwcap.h>
15#include <asm/pgtable-hwdef.h> 15#include <asm/pgtable-hwdef.h>
16#include <asm/pgtable.h> 16#include <asm/pgtable.h>
17#include <asm/ptrace.h> 17#include <asm/ptrace.h>
diff --git a/arch/arm/mm/proc-arm946.S b/arch/arm/mm/proc-arm946.S
index 6168c6160dee..e03f6ff1fb26 100644
--- a/arch/arm/mm/proc-arm946.S
+++ b/arch/arm/mm/proc-arm946.S
@@ -13,7 +13,7 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <asm/assembler.h> 15#include <asm/assembler.h>
16#include <asm/elf.h> 16#include <asm/hwcap.h>
17#include <asm/pgtable-hwdef.h> 17#include <asm/pgtable-hwdef.h>
18#include <asm/pgtable.h> 18#include <asm/pgtable.h>
19#include <asm/ptrace.h> 19#include <asm/ptrace.h>
diff --git a/arch/arm/mm/proc-arm9tdmi.S b/arch/arm/mm/proc-arm9tdmi.S
index c85c1f50e396..be6c11d2b3fb 100644
--- a/arch/arm/mm/proc-arm9tdmi.S
+++ b/arch/arm/mm/proc-arm9tdmi.S
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
15#include <asm/elf.h> 15#include <asm/hwcap.h>
16#include <asm/pgtable-hwdef.h> 16#include <asm/pgtable-hwdef.h>
17#include <asm/pgtable.h> 17#include <asm/pgtable.h>
18#include <asm/ptrace.h> 18#include <asm/ptrace.h>
diff --git a/arch/arm/mm/proc-feroceon.S b/arch/arm/mm/proc-feroceon.S
index f2e5884c513a..0fe1f8fc3488 100644
--- a/arch/arm/mm/proc-feroceon.S
+++ b/arch/arm/mm/proc-feroceon.S
@@ -22,7 +22,7 @@
22#include <linux/linkage.h> 22#include <linux/linkage.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <asm/assembler.h> 24#include <asm/assembler.h>
25#include <asm/elf.h> 25#include <asm/hwcap.h>
26#include <asm/pgtable-hwdef.h> 26#include <asm/pgtable-hwdef.h>
27#include <asm/pgtable.h> 27#include <asm/pgtable.h>
28#include <asm/page.h> 28#include <asm/page.h>
@@ -80,7 +80,8 @@ ENTRY(cpu_feroceon_proc_fin)
80 msr cpsr_c, ip 80 msr cpsr_c, ip
81 bl feroceon_flush_kern_cache_all 81 bl feroceon_flush_kern_cache_all
82 82
83#if defined(CONFIG_CACHE_FEROCEON_L2) && !defined(CONFIG_L2_CACHE_WRITETHROUGH) 83#if defined(CONFIG_CACHE_FEROCEON_L2) && \
84 !defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH)
84 mov r0, #0 85 mov r0, #0
85 mcr p15, 1, r0, c15, c9, 0 @ clean L2 86 mcr p15, 1, r0, c15, c9, 0 @ clean L2
86 mcr p15, 0, r0, c7, c10, 4 @ drain WB 87 mcr p15, 0, r0, c7, c10, 4 @ drain WB
@@ -389,7 +390,8 @@ ENTRY(feroceon_range_cache_fns)
389 390
390 .align 5 391 .align 5
391ENTRY(cpu_feroceon_dcache_clean_area) 392ENTRY(cpu_feroceon_dcache_clean_area)
392#if defined(CONFIG_CACHE_FEROCEON_L2) && !defined(CONFIG_L2_CACHE_WRITETHROUGH) 393#if defined(CONFIG_CACHE_FEROCEON_L2) && \
394 !defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH)
393 mov r2, r0 395 mov r2, r0
394 mov r3, r1 396 mov r3, r1
395#endif 397#endif
@@ -397,7 +399,8 @@ ENTRY(cpu_feroceon_dcache_clean_area)
397 add r0, r0, #CACHE_DLINESIZE 399 add r0, r0, #CACHE_DLINESIZE
398 subs r1, r1, #CACHE_DLINESIZE 400 subs r1, r1, #CACHE_DLINESIZE
399 bhi 1b 401 bhi 1b
400#if defined(CONFIG_CACHE_FEROCEON_L2) && !defined(CONFIG_L2_CACHE_WRITETHROUGH) 402#if defined(CONFIG_CACHE_FEROCEON_L2) && \
403 !defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH)
4011: mcr p15, 1, r2, c15, c9, 1 @ clean L2 entry 4041: mcr p15, 1, r2, c15, c9, 1 @ clean L2 entry
402 add r2, r2, #CACHE_DLINESIZE 405 add r2, r2, #CACHE_DLINESIZE
403 subs r3, r3, #CACHE_DLINESIZE 406 subs r3, r3, #CACHE_DLINESIZE
@@ -446,27 +449,11 @@ ENTRY(cpu_feroceon_switch_mm)
446 .align 5 449 .align 5
447ENTRY(cpu_feroceon_set_pte_ext) 450ENTRY(cpu_feroceon_set_pte_ext)
448#ifdef CONFIG_MMU 451#ifdef CONFIG_MMU
449 str r1, [r0], #-2048 @ linux version 452 armv3_set_pte_ext wc_disable=0
450
451 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
452
453 bic r2, r1, #PTE_SMALL_AP_MASK
454 bic r2, r2, #PTE_TYPE_MASK
455 orr r2, r2, #PTE_TYPE_SMALL
456
457 tst r1, #L_PTE_USER @ User?
458 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
459
460 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
461 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
462
463 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
464 movne r2, #0
465
466 str r2, [r0] @ hardware version
467 mov r0, r0 453 mov r0, r0
468 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 454 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
469#if defined(CONFIG_CACHE_FEROCEON_L2) && !defined(CONFIG_L2_CACHE_WRITETHROUGH) 455#if defined(CONFIG_CACHE_FEROCEON_L2) && \
456 !defined(CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH)
470 mcr p15, 1, r0, c15, c9, 1 @ clean L2 entry 457 mcr p15, 1, r0, c15, c9, 1 @ clean L2 entry
471#endif 458#endif
472 mcr p15, 0, r0, c7, c10, 4 @ drain WB 459 mcr p15, 0, r0, c7, c10, 4 @ drain WB
diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
index b13150052a76..54b1f721dec8 100644
--- a/arch/arm/mm/proc-macros.S
+++ b/arch/arm/mm/proc-macros.S
@@ -71,3 +71,173 @@
71 mov \reg, #16 @ size offset 71 mov \reg, #16 @ size offset
72 mov \reg, \reg, lsl \tmp @ actual cache line size 72 mov \reg, \reg, lsl \tmp @ actual cache line size
73 .endm 73 .endm
74
75
76/*
77 * Sanity check the PTE configuration for the code below - which makes
78 * certain assumptions about how these bits are layed out.
79 */
80#if L_PTE_SHARED != PTE_EXT_SHARED
81#error PTE shared bit mismatch
82#endif
83#if L_PTE_BUFFERABLE != PTE_BUFFERABLE
84#error PTE bufferable bit mismatch
85#endif
86#if L_PTE_CACHEABLE != PTE_CACHEABLE
87#error PTE cacheable bit mismatch
88#endif
89#if (L_PTE_EXEC+L_PTE_USER+L_PTE_WRITE+L_PTE_DIRTY+L_PTE_YOUNG+\
90 L_PTE_FILE+L_PTE_PRESENT) > L_PTE_SHARED
91#error Invalid Linux PTE bit settings
92#endif
93
94/*
95 * The ARMv6 and ARMv7 set_pte_ext translation function.
96 *
97 * Permission translation:
98 * YUWD APX AP1 AP0 SVC User
99 * 0xxx 0 0 0 no acc no acc
100 * 100x 1 0 1 r/o no acc
101 * 10x0 1 0 1 r/o no acc
102 * 1011 0 0 1 r/w no acc
103 * 110x 0 1 0 r/w r/o
104 * 11x0 0 1 0 r/w r/o
105 * 1111 0 1 1 r/w r/w
106 */
107 .macro armv6_mt_table pfx
108\pfx\()_mt_table:
109 .long 0x00 @ L_PTE_MT_UNCACHED
110 .long PTE_EXT_TEX(1) @ L_PTE_MT_BUFFERABLE
111 .long PTE_CACHEABLE @ L_PTE_MT_WRITETHROUGH
112 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEBACK
113 .long PTE_BUFFERABLE @ L_PTE_MT_DEV_SHARED
114 .long 0x00 @ unused
115 .long 0x00 @ L_PTE_MT_MINICACHE (not present)
116 .long PTE_EXT_TEX(1) | PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEALLOC
117 .long 0x00 @ unused
118 .long PTE_EXT_TEX(1) @ L_PTE_MT_DEV_WC
119 .long 0x00 @ unused
120 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_DEV_CACHED
121 .long PTE_EXT_TEX(2) @ L_PTE_MT_DEV_NONSHARED
122 .long 0x00 @ unused
123 .long 0x00 @ unused
124 .long 0x00 @ unused
125 .endm
126
127 .macro armv6_set_pte_ext pfx
128 str r1, [r0], #-2048 @ linux version
129
130 bic r3, r1, #0x000003fc
131 bic r3, r3, #PTE_TYPE_MASK
132 orr r3, r3, r2
133 orr r3, r3, #PTE_EXT_AP0 | 2
134
135 adr ip, \pfx\()_mt_table
136 and r2, r1, #L_PTE_MT_MASK
137 ldr r2, [ip, r2]
138
139 tst r1, #L_PTE_WRITE
140 tstne r1, #L_PTE_DIRTY
141 orreq r3, r3, #PTE_EXT_APX
142
143 tst r1, #L_PTE_USER
144 orrne r3, r3, #PTE_EXT_AP1
145 tstne r3, #PTE_EXT_APX
146 bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
147
148 tst r1, #L_PTE_EXEC
149 orreq r3, r3, #PTE_EXT_XN
150
151 orr r3, r3, r2
152
153 tst r1, #L_PTE_YOUNG
154 tstne r1, #L_PTE_PRESENT
155 moveq r3, #0
156
157 str r3, [r0]
158 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
159 .endm
160
161
162/*
163 * The ARMv3, ARMv4 and ARMv5 set_pte_ext translation function,
164 * covering most CPUs except Xscale and Xscale 3.
165 *
166 * Permission translation:
167 * YUWD AP SVC User
168 * 0xxx 0x00 no acc no acc
169 * 100x 0x00 r/o no acc
170 * 10x0 0x00 r/o no acc
171 * 1011 0x55 r/w no acc
172 * 110x 0xaa r/w r/o
173 * 11x0 0xaa r/w r/o
174 * 1111 0xff r/w r/w
175 */
176 .macro armv3_set_pte_ext wc_disable=1
177 str r1, [r0], #-2048 @ linux version
178
179 eor r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
180
181 bic r2, r1, #PTE_SMALL_AP_MASK @ keep C, B bits
182 bic r2, r2, #PTE_TYPE_MASK
183 orr r2, r2, #PTE_TYPE_SMALL
184
185 tst r3, #L_PTE_USER @ user?
186 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
187
188 tst r3, #L_PTE_WRITE | L_PTE_DIRTY @ write and dirty?
189 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
190
191 tst r3, #L_PTE_PRESENT | L_PTE_YOUNG @ present and young?
192 movne r2, #0
193
194 .if \wc_disable
195#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
196 tst r2, #PTE_CACHEABLE
197 bicne r2, r2, #PTE_BUFFERABLE
198#endif
199 .endif
200 str r2, [r0] @ hardware version
201 .endm
202
203
204/*
205 * Xscale set_pte_ext translation, split into two halves to cope
206 * with work-arounds. r3 must be preserved by code between these
207 * two macros.
208 *
209 * Permission translation:
210 * YUWD AP SVC User
211 * 0xxx 00 no acc no acc
212 * 100x 00 r/o no acc
213 * 10x0 00 r/o no acc
214 * 1011 01 r/w no acc
215 * 110x 10 r/w r/o
216 * 11x0 10 r/w r/o
217 * 1111 11 r/w r/w
218 */
219 .macro xscale_set_pte_ext_prologue
220 str r1, [r0], #-2048 @ linux version
221
222 eor r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
223
224 bic r2, r1, #PTE_SMALL_AP_MASK @ keep C, B bits
225 orr r2, r2, #PTE_TYPE_EXT @ extended page
226
227 tst r3, #L_PTE_USER @ user?
228 orrne r2, r2, #PTE_EXT_AP_URO_SRW @ yes -> user r/o, system r/w
229
230 tst r3, #L_PTE_WRITE | L_PTE_DIRTY @ write and dirty?
231 orreq r2, r2, #PTE_EXT_AP_UNO_SRW @ yes -> user n/a, system r/w
232 @ combined with user -> user r/w
233 .endm
234
235 .macro xscale_set_pte_ext_epilogue
236 tst r3, #L_PTE_PRESENT | L_PTE_YOUNG @ present and young?
237 movne r2, #0 @ no -> fault
238
239 str r2, [r0] @ hardware version
240 mov ip, #0
241 mcr p15, 0, r0, c7, c10, 1 @ clean L1 D line
242 mcr p15, 0, ip, c7, c10, 4 @ data write barrier
243 .endm
diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
index bbe10576c861..90a7e5279f29 100644
--- a/arch/arm/mm/proc-sa110.S
+++ b/arch/arm/mm/proc-sa110.S
@@ -17,7 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <asm/assembler.h> 18#include <asm/assembler.h>
19#include <asm/asm-offsets.h> 19#include <asm/asm-offsets.h>
20#include <asm/elf.h> 20#include <asm/hwcap.h>
21#include <mach/hardware.h> 21#include <mach/hardware.h>
22#include <asm/pgtable-hwdef.h> 22#include <asm/pgtable-hwdef.h>
23#include <asm/pgtable.h> 23#include <asm/pgtable.h>
@@ -153,24 +153,7 @@ ENTRY(cpu_sa110_switch_mm)
153 .align 5 153 .align 5
154ENTRY(cpu_sa110_set_pte_ext) 154ENTRY(cpu_sa110_set_pte_ext)
155#ifdef CONFIG_MMU 155#ifdef CONFIG_MMU
156 str r1, [r0], #-2048 @ linux version 156 armv3_set_pte_ext wc_disable=0
157
158 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
159
160 bic r2, r1, #PTE_SMALL_AP_MASK
161 bic r2, r2, #PTE_TYPE_MASK
162 orr r2, r2, #PTE_TYPE_SMALL
163
164 tst r1, #L_PTE_USER @ User?
165 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
166
167 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
168 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
169
170 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
171 movne r2, #0
172
173 str r2, [r0] @ hardware version
174 mov r0, r0 157 mov r0, r0
175 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 158 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
176 mcr p15, 0, r0, c7, c10, 4 @ drain WB 159 mcr p15, 0, r0, c7, c10, 4 @ drain WB
diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
index 871ba018252e..451e2d953e2a 100644
--- a/arch/arm/mm/proc-sa1100.S
+++ b/arch/arm/mm/proc-sa1100.S
@@ -22,7 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <asm/assembler.h> 23#include <asm/assembler.h>
24#include <asm/asm-offsets.h> 24#include <asm/asm-offsets.h>
25#include <asm/elf.h> 25#include <asm/hwcap.h>
26#include <mach/hardware.h> 26#include <mach/hardware.h>
27#include <asm/pgtable-hwdef.h> 27#include <asm/pgtable-hwdef.h>
28#include <asm/pgtable.h> 28#include <asm/pgtable.h>
@@ -166,24 +166,7 @@ ENTRY(cpu_sa1100_switch_mm)
166 .align 5 166 .align 5
167ENTRY(cpu_sa1100_set_pte_ext) 167ENTRY(cpu_sa1100_set_pte_ext)
168#ifdef CONFIG_MMU 168#ifdef CONFIG_MMU
169 str r1, [r0], #-2048 @ linux version 169 armv3_set_pte_ext wc_disable=0
170
171 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
172
173 bic r2, r1, #PTE_SMALL_AP_MASK
174 bic r2, r2, #PTE_TYPE_MASK
175 orr r2, r2, #PTE_TYPE_SMALL
176
177 tst r1, #L_PTE_USER @ User?
178 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
179
180 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
181 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
182
183 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
184 movne r2, #0
185
186 str r2, [r0] @ hardware version
187 mov r0, r0 170 mov r0, r0
188 mcr p15, 0, r0, c7, c10, 1 @ clean D entry 171 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
189 mcr p15, 0, r0, c7, c10, 4 @ drain WB 172 mcr p15, 0, r0, c7, c10, 4 @ drain WB
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 5702ec58b2a2..294943b85973 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -13,7 +13,7 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/assembler.h> 14#include <asm/assembler.h>
15#include <asm/asm-offsets.h> 15#include <asm/asm-offsets.h>
16#include <asm/elf.h> 16#include <asm/hwcap.h>
17#include <asm/pgtable-hwdef.h> 17#include <asm/pgtable-hwdef.h>
18#include <asm/pgtable.h> 18#include <asm/pgtable.h>
19 19
@@ -114,46 +114,12 @@ ENTRY(cpu_v6_switch_mm)
114 * (hardware version is stored at -1024 bytes) 114 * (hardware version is stored at -1024 bytes)
115 * - pte - PTE value to store 115 * - pte - PTE value to store
116 * - ext - value for extended PTE bits 116 * - ext - value for extended PTE bits
117 *
118 * Permissions:
119 * YUWD APX AP1 AP0 SVC User
120 * 0xxx 0 0 0 no acc no acc
121 * 100x 1 0 1 r/o no acc
122 * 10x0 1 0 1 r/o no acc
123 * 1011 0 0 1 r/w no acc
124 * 110x 0 1 0 r/w r/o
125 * 11x0 0 1 0 r/w r/o
126 * 1111 0 1 1 r/w r/w
127 */ 117 */
118 armv6_mt_table cpu_v6
119
128ENTRY(cpu_v6_set_pte_ext) 120ENTRY(cpu_v6_set_pte_ext)
129#ifdef CONFIG_MMU 121#ifdef CONFIG_MMU
130 str r1, [r0], #-2048 @ linux version 122 armv6_set_pte_ext cpu_v6
131
132 bic r3, r1, #0x000003f0
133 bic r3, r3, #0x00000003
134 orr r3, r3, r2
135 orr r3, r3, #PTE_EXT_AP0 | 2
136
137 tst r1, #L_PTE_WRITE
138 tstne r1, #L_PTE_DIRTY
139 orreq r3, r3, #PTE_EXT_APX
140
141 tst r1, #L_PTE_USER
142 orrne r3, r3, #PTE_EXT_AP1
143 tstne r3, #PTE_EXT_APX
144 bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
145
146 tst r1, #L_PTE_YOUNG
147 biceq r3, r3, #PTE_EXT_APX | PTE_EXT_AP_MASK
148
149 tst r1, #L_PTE_EXEC
150 orreq r3, r3, #PTE_EXT_XN
151
152 tst r1, #L_PTE_PRESENT
153 moveq r3, #0
154
155 str r3, [r0]
156 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
157#endif 123#endif
158 mov pc, lr 124 mov pc, lr
159 125
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index b49f9a4c82c8..34e424041927 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -12,7 +12,7 @@
12#include <linux/linkage.h> 12#include <linux/linkage.h>
13#include <asm/assembler.h> 13#include <asm/assembler.h>
14#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
15#include <asm/elf.h> 15#include <asm/hwcap.h>
16#include <asm/pgtable-hwdef.h> 16#include <asm/pgtable-hwdef.h>
17#include <asm/pgtable.h> 17#include <asm/pgtable.h>
18 18
@@ -25,9 +25,11 @@
25 25
26ENTRY(cpu_v7_proc_init) 26ENTRY(cpu_v7_proc_init)
27 mov pc, lr 27 mov pc, lr
28ENDPROC(cpu_v7_proc_init)
28 29
29ENTRY(cpu_v7_proc_fin) 30ENTRY(cpu_v7_proc_fin)
30 mov pc, lr 31 mov pc, lr
32ENDPROC(cpu_v7_proc_fin)
31 33
32/* 34/*
33 * cpu_v7_reset(loc) 35 * cpu_v7_reset(loc)
@@ -43,6 +45,7 @@ ENTRY(cpu_v7_proc_fin)
43 .align 5 45 .align 5
44ENTRY(cpu_v7_reset) 46ENTRY(cpu_v7_reset)
45 mov pc, r0 47 mov pc, r0
48ENDPROC(cpu_v7_reset)
46 49
47/* 50/*
48 * cpu_v7_do_idle() 51 * cpu_v7_do_idle()
@@ -52,8 +55,9 @@ ENTRY(cpu_v7_reset)
52 * IRQs are already disabled. 55 * IRQs are already disabled.
53 */ 56 */
54ENTRY(cpu_v7_do_idle) 57ENTRY(cpu_v7_do_idle)
55 .long 0xe320f003 @ ARM V7 WFI instruction 58 wfi
56 mov pc, lr 59 mov pc, lr
60ENDPROC(cpu_v7_do_idle)
57 61
58ENTRY(cpu_v7_dcache_clean_area) 62ENTRY(cpu_v7_dcache_clean_area)
59#ifndef TLB_CAN_READ_FROM_L1_CACHE 63#ifndef TLB_CAN_READ_FROM_L1_CACHE
@@ -65,6 +69,7 @@ ENTRY(cpu_v7_dcache_clean_area)
65 dsb 69 dsb
66#endif 70#endif
67 mov pc, lr 71 mov pc, lr
72ENDPROC(cpu_v7_dcache_clean_area)
68 73
69/* 74/*
70 * cpu_v7_switch_mm(pgd_phys, tsk) 75 * cpu_v7_switch_mm(pgd_phys, tsk)
@@ -89,6 +94,7 @@ ENTRY(cpu_v7_switch_mm)
89 isb 94 isb
90#endif 95#endif
91 mov pc, lr 96 mov pc, lr
97ENDPROC(cpu_v7_switch_mm)
92 98
93/* 99/*
94 * cpu_v7_set_pte_ext(ptep, pte) 100 * cpu_v7_set_pte_ext(ptep, pte)
@@ -99,26 +105,19 @@ ENTRY(cpu_v7_switch_mm)
99 * (hardware version is stored at -1024 bytes) 105 * (hardware version is stored at -1024 bytes)
100 * - pte - PTE value to store 106 * - pte - PTE value to store
101 * - ext - value for extended PTE bits 107 * - ext - value for extended PTE bits
102 *
103 * Permissions:
104 * YUWD APX AP1 AP0 SVC User
105 * 0xxx 0 0 0 no acc no acc
106 * 100x 1 0 1 r/o no acc
107 * 10x0 1 0 1 r/o no acc
108 * 1011 0 0 1 r/w no acc
109 * 110x 0 1 0 r/w r/o
110 * 11x0 0 1 0 r/w r/o
111 * 1111 0 1 1 r/w r/w
112 */ 108 */
113ENTRY(cpu_v7_set_pte_ext) 109ENTRY(cpu_v7_set_pte_ext)
114#ifdef CONFIG_MMU 110#ifdef CONFIG_MMU
115 str r1, [r0], #-2048 @ linux version 111 str r1, [r0], #-2048 @ linux version
116 112
117 bic r3, r1, #0x000003f0 113 bic r3, r1, #0x000003f0
118 bic r3, r3, #0x00000003 114 bic r3, r3, #PTE_TYPE_MASK
119 orr r3, r3, r2 115 orr r3, r3, r2
120 orr r3, r3, #PTE_EXT_AP0 | 2 116 orr r3, r3, #PTE_EXT_AP0 | 2
121 117
118 tst r2, #1 << 4
119 orrne r3, r3, #PTE_EXT_TEX(1)
120
122 tst r1, #L_PTE_WRITE 121 tst r1, #L_PTE_WRITE
123 tstne r1, #L_PTE_DIRTY 122 tstne r1, #L_PTE_DIRTY
124 orreq r3, r3, #PTE_EXT_APX 123 orreq r3, r3, #PTE_EXT_APX
@@ -128,19 +127,18 @@ ENTRY(cpu_v7_set_pte_ext)
128 tstne r3, #PTE_EXT_APX 127 tstne r3, #PTE_EXT_APX
129 bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0 128 bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
130 129
131 tst r1, #L_PTE_YOUNG
132 biceq r3, r3, #PTE_EXT_APX | PTE_EXT_AP_MASK
133
134 tst r1, #L_PTE_EXEC 130 tst r1, #L_PTE_EXEC
135 orreq r3, r3, #PTE_EXT_XN 131 orreq r3, r3, #PTE_EXT_XN
136 132
137 tst r1, #L_PTE_PRESENT 133 tst r1, #L_PTE_YOUNG
134 tstne r1, #L_PTE_PRESENT
138 moveq r3, #0 135 moveq r3, #0
139 136
140 str r3, [r0] 137 str r3, [r0]
141 mcr p15, 0, r0, c7, c10, 1 @ flush_pte 138 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
142#endif 139#endif
143 mov pc, lr 140 mov pc, lr
141ENDPROC(cpu_v7_set_pte_ext)
144 142
145cpu_v7_name: 143cpu_v7_name:
146 .ascii "ARMv7 Processor" 144 .ascii "ARMv7 Processor"
@@ -182,12 +180,17 @@ __v7_setup:
182 mov r10, #0x1f @ domains 0, 1 = manager 180 mov r10, #0x1f @ domains 0, 1 = manager
183 mcr p15, 0, r10, c3, c0, 0 @ load domain access register 181 mcr p15, 0, r10, c3, c0, 0 @ load domain access register
184#endif 182#endif
183 ldr r5, =0x40e040e0
184 ldr r6, =0xff0aa1a8
185 mcr p15, 0, r5, c10, c2, 0 @ write PRRR
186 mcr p15, 0, r6, c10, c2, 1 @ write NMRR
185 adr r5, v7_crval 187 adr r5, v7_crval
186 ldmia r5, {r5, r6} 188 ldmia r5, {r5, r6}
187 mrc p15, 0, r0, c1, c0, 0 @ read control register 189 mrc p15, 0, r0, c1, c0, 0 @ read control register
188 bic r0, r0, r5 @ clear bits them 190 bic r0, r0, r5 @ clear bits them
189 orr r0, r0, r6 @ set them 191 orr r0, r0, r6 @ set them
190 mov pc, lr @ return to head.S:__ret 192 mov pc, lr @ return to head.S:__ret
193ENDPROC(__v7_setup)
191 194
192 /* 195 /*
193 * V X F I D LR 196 * V X F I D LR
@@ -197,7 +200,7 @@ __v7_setup:
197 */ 200 */
198 .type v7_crval, #object 201 .type v7_crval, #object
199v7_crval: 202v7_crval:
200 crval clear=0x0120c302, mmuset=0x00c0387d, ucset=0x00c0187c 203 crval clear=0x0120c302, mmuset=0x10c0387d, ucset=0x00c0187c
201 204
202__v7_setup_stack: 205__v7_setup_stack:
203 .space 4 * 11 @ 11 registers 206 .space 4 * 11 @ 11 registers
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S
index 7bd9e7197f60..04dc8b65401b 100644
--- a/arch/arm/mm/proc-xsc3.S
+++ b/arch/arm/mm/proc-xsc3.S
@@ -27,7 +27,7 @@
27#include <linux/linkage.h> 27#include <linux/linkage.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <asm/assembler.h> 29#include <asm/assembler.h>
30#include <asm/elf.h> 30#include <asm/hwcap.h>
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <asm/pgtable.h> 32#include <asm/pgtable.h>
33#include <asm/pgtable-hwdef.h> 33#include <asm/pgtable-hwdef.h>
@@ -345,38 +345,38 @@ ENTRY(cpu_xsc3_switch_mm)
345 * cpu_xsc3_set_pte_ext(ptep, pte, ext) 345 * cpu_xsc3_set_pte_ext(ptep, pte, ext)
346 * 346 *
347 * Set a PTE and flush it out 347 * Set a PTE and flush it out
348 *
349 */ 348 */
349cpu_xsc3_mt_table:
350 .long 0x00 @ L_PTE_MT_UNCACHED
351 .long PTE_EXT_TEX(1) @ L_PTE_MT_BUFFERABLE
352 .long PTE_CACHEABLE @ L_PTE_MT_WRITETHROUGH
353 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEBACK
354 .long PTE_EXT_TEX(1) | PTE_BUFFERABLE @ L_PTE_MT_DEV_SHARED
355 .long 0x00 @ unused
356 .long 0x00 @ L_PTE_MT_MINICACHE (not present)
357 .long PTE_EXT_TEX(5) | PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEALLOC (not present?)
358 .long 0x00 @ unused
359 .long PTE_EXT_TEX(1) @ L_PTE_MT_DEV_WC
360 .long 0x00 @ unused
361 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_DEV_CACHED
362 .long PTE_EXT_TEX(2) @ L_PTE_MT_DEV_NONSHARED
363 .long 0x00 @ unused
364 .long 0x00 @ unused
365 .long 0x00 @ unused
366
350 .align 5 367 .align 5
351ENTRY(cpu_xsc3_set_pte_ext) 368ENTRY(cpu_xsc3_set_pte_ext)
352 str r1, [r0], #-2048 @ linux version 369 xscale_set_pte_ext_prologue
353 370
354 bic r2, r1, #0xff0 @ keep C, B bits
355 orr r2, r2, #PTE_TYPE_EXT @ extended page
356 tst r1, #L_PTE_SHARED @ shared? 371 tst r1, #L_PTE_SHARED @ shared?
357 orrne r2, r2, #0x200 372 and r1, r1, #L_PTE_MT_MASK
358 373 adr ip, cpu_xsc3_mt_table
359 eor r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY 374 ldr ip, [ip, r1]
360 375 orrne r2, r2, #PTE_EXT_COHERENT @ interlock: mask in coherent bit
361 tst r3, #L_PTE_USER @ user? 376 bic r2, r2, #0x0c @ clear old C,B bits
362 orrne r2, r2, #PTE_EXT_AP_URO_SRW @ yes -> user r/o, system r/w 377 orr r2, r2, ip
363 378
364 tst r3, #L_PTE_WRITE | L_PTE_DIRTY @ write and dirty? 379 xscale_set_pte_ext_epilogue
365 orreq r2, r2, #PTE_EXT_AP_UNO_SRW @ yes -> user n/a, system r/w
366 @ combined with user -> user r/w
367
368 @ If it's cacheable, it needs to be in L2 also.
369 eor ip, r1, #L_PTE_CACHEABLE
370 tst ip, #L_PTE_CACHEABLE
371 orreq r2, r2, #PTE_EXT_TEX(0x5)
372
373 tst r3, #L_PTE_PRESENT | L_PTE_YOUNG @ present and young?
374 movne r2, #0 @ no -> fault
375
376 str r2, [r0] @ hardware version
377 mov ip, #0
378 mcr p15, 0, r0, c7, c10, 1 @ clean L1 D line
379 mcr p15, 0, ip, c7, c10, 4 @ data write barrier
380 mov pc, lr 380 mov pc, lr
381 381
382 .ltorg 382 .ltorg
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 2dd85273976f..0cce37b93937 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -23,7 +23,7 @@
23#include <linux/linkage.h> 23#include <linux/linkage.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <asm/assembler.h> 25#include <asm/assembler.h>
26#include <asm/elf.h> 26#include <asm/hwcap.h>
27#include <asm/pgtable.h> 27#include <asm/pgtable.h>
28#include <asm/pgtable-hwdef.h> 28#include <asm/pgtable-hwdef.h>
29#include <asm/page.h> 29#include <asm/page.h>
@@ -406,8 +406,6 @@ ENTRY(cpu_xscale_dcache_clean_area)
406 406
407/* =============================== PageTable ============================== */ 407/* =============================== PageTable ============================== */
408 408
409#define PTE_CACHE_WRITE_ALLOCATE 0
410
411/* 409/*
412 * cpu_xscale_switch_mm(pgd) 410 * cpu_xscale_switch_mm(pgd)
413 * 411 *
@@ -431,56 +429,42 @@ ENTRY(cpu_xscale_switch_mm)
431 * 429 *
432 * Errata 40: must set memory to write-through for user read-only pages. 430 * Errata 40: must set memory to write-through for user read-only pages.
433 */ 431 */
432cpu_xscale_mt_table:
433 .long 0x00 @ L_PTE_MT_UNCACHED
434 .long PTE_BUFFERABLE @ L_PTE_MT_BUFFERABLE
435 .long PTE_CACHEABLE @ L_PTE_MT_WRITETHROUGH
436 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEBACK
437 .long PTE_EXT_TEX(1) | PTE_BUFFERABLE @ L_PTE_MT_DEV_SHARED
438 .long 0x00 @ unused
439 .long PTE_EXT_TEX(1) | PTE_CACHEABLE @ L_PTE_MT_MINICACHE
440 .long PTE_EXT_TEX(1) | PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_WRITEALLOC
441 .long 0x00 @ unused
442 .long PTE_BUFFERABLE @ L_PTE_MT_DEV_WC
443 .long 0x00 @ unused
444 .long PTE_CACHEABLE | PTE_BUFFERABLE @ L_PTE_MT_DEV_CACHED
445 .long 0x00 @ L_PTE_MT_DEV_NONSHARED
446 .long 0x00 @ unused
447 .long 0x00 @ unused
448 .long 0x00 @ unused
449
434 .align 5 450 .align 5
435ENTRY(cpu_xscale_set_pte_ext) 451ENTRY(cpu_xscale_set_pte_ext)
436 str r1, [r0], #-2048 @ linux version 452 xscale_set_pte_ext_prologue
437
438 bic r2, r1, #0xff0
439 orr r2, r2, #PTE_TYPE_EXT @ extended page
440
441 eor r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
442
443 tst r3, #L_PTE_USER @ User?
444 orrne r2, r2, #PTE_EXT_AP_URO_SRW @ yes -> user r/o, system r/w
445
446 tst r3, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
447 orreq r2, r2, #PTE_EXT_AP_UNO_SRW @ yes -> user n/a, system r/w
448 @ combined with user -> user r/w
449
450 @
451 @ Handle the X bit. We want to set this bit for the minicache
452 @ (U = E = B = W = 0, C = 1) or when write allocate is enabled,
453 @ and we have a writeable, cacheable region. If we ignore the
454 @ U and E bits, we can allow user space to use the minicache as
455 @ well.
456 @
457 @ X = (C & ~W & ~B) | (C & W & B & write_allocate)
458 @
459 eor ip, r1, #L_PTE_CACHEABLE
460 tst ip, #L_PTE_CACHEABLE | L_PTE_WRITE | L_PTE_BUFFERABLE
461#if PTE_CACHE_WRITE_ALLOCATE
462 eorne ip, r1, #L_PTE_CACHEABLE | L_PTE_WRITE | L_PTE_BUFFERABLE
463 tstne ip, #L_PTE_CACHEABLE | L_PTE_WRITE | L_PTE_BUFFERABLE
464#endif
465 orreq r2, r2, #PTE_EXT_TEX(1)
466 453
467 @ 454 @
468 @ Erratum 40: The B bit must be cleared for a user read-only 455 @ Erratum 40: must set memory to write-through for user read-only pages
469 @ cacheable page.
470 @
471 @ B = B & ~(U & C & ~W)
472 @ 456 @
473 and ip, r1, #L_PTE_USER | L_PTE_WRITE | L_PTE_CACHEABLE 457 and ip, r1, #(L_PTE_MT_MASK | L_PTE_USER | L_PTE_WRITE) & ~(4 << 2)
474 teq ip, #L_PTE_USER | L_PTE_CACHEABLE 458 teq ip, #L_PTE_MT_WRITEBACK | L_PTE_USER
475 biceq r2, r2, #PTE_BUFFERABLE
476 459
477 tst r3, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young? 460 moveq r1, #L_PTE_MT_WRITETHROUGH
478 movne r2, #0 @ no -> fault 461 and r1, r1, #L_PTE_MT_MASK
462 adr ip, cpu_xscale_mt_table
463 ldr ip, [ip, r1]
464 bic r2, r2, #0x0c
465 orr r2, r2, ip
479 466
480 str r2, [r0] @ hardware version 467 xscale_set_pte_ext_epilogue
481 mov ip, #0
482 mcr p15, 0, r0, c7, c10, 1 @ Clean D cache line
483 mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
484 mov pc, lr 468 mov pc, lr
485 469
486 470
diff --git a/arch/arm/mm/tlb-v7.S b/arch/arm/mm/tlb-v7.S
index b56dda8052f7..24ba5109f2e7 100644
--- a/arch/arm/mm/tlb-v7.S
+++ b/arch/arm/mm/tlb-v7.S
@@ -51,6 +51,7 @@ ENTRY(v7wbi_flush_user_tlb_range)
51 mcr p15, 0, ip, c7, c5, 6 @ flush BTAC/BTB 51 mcr p15, 0, ip, c7, c5, 6 @ flush BTAC/BTB
52 dsb 52 dsb
53 mov pc, lr 53 mov pc, lr
54ENDPROC(v7wbi_flush_user_tlb_range)
54 55
55/* 56/*
56 * v7wbi_flush_kern_tlb_range(start,end) 57 * v7wbi_flush_kern_tlb_range(start,end)
@@ -77,6 +78,7 @@ ENTRY(v7wbi_flush_kern_tlb_range)
77 dsb 78 dsb
78 isb 79 isb
79 mov pc, lr 80 mov pc, lr
81ENDPROC(v7wbi_flush_kern_tlb_range)
80 82
81 .section ".text.init", #alloc, #execinstr 83 .section ".text.init", #alloc, #execinstr
82 84
diff --git a/arch/arm/nwfpe/fpa11_cpdt.c b/arch/arm/nwfpe/fpa11_cpdt.c
index 79f8e67cc6c1..d31c49f953b1 100644
--- a/arch/arm/nwfpe/fpa11_cpdt.c
+++ b/arch/arm/nwfpe/fpa11_cpdt.c
@@ -26,7 +26,7 @@
26#include "fpmodule.h" 26#include "fpmodule.h"
27#include "fpmodule.inl" 27#include "fpmodule.inl"
28 28
29#include <asm/uaccess.h> 29#include <linux/uaccess.h>
30 30
31static inline void loadSingle(const unsigned int Fn, const unsigned int __user *pMem) 31static inline void loadSingle(const unsigned int Fn, const unsigned int __user *pMem)
32{ 32{
diff --git a/arch/arm/oprofile/Makefile b/arch/arm/oprofile/Makefile
index e61d0cc520b7..88e31f549f50 100644
--- a/arch/arm/oprofile/Makefile
+++ b/arch/arm/oprofile/Makefile
@@ -11,3 +11,4 @@ oprofile-$(CONFIG_CPU_XSCALE) += op_model_xscale.o
11oprofile-$(CONFIG_OPROFILE_ARM11_CORE) += op_model_arm11_core.o 11oprofile-$(CONFIG_OPROFILE_ARM11_CORE) += op_model_arm11_core.o
12oprofile-$(CONFIG_OPROFILE_ARMV6) += op_model_v6.o 12oprofile-$(CONFIG_OPROFILE_ARMV6) += op_model_v6.o
13oprofile-$(CONFIG_OPROFILE_MPCORE) += op_model_mpcore.o 13oprofile-$(CONFIG_OPROFILE_MPCORE) += op_model_mpcore.o
14oprofile-$(CONFIG_OPROFILE_ARMV7) += op_model_v7.o
diff --git a/arch/arm/oprofile/backtrace.c b/arch/arm/oprofile/backtrace.c
index f5ebf30151fa..cefc21c2eee4 100644
--- a/arch/arm/oprofile/backtrace.c
+++ b/arch/arm/oprofile/backtrace.c
@@ -16,8 +16,8 @@
16#include <linux/oprofile.h> 16#include <linux/oprofile.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/uaccess.h>
19#include <asm/ptrace.h> 20#include <asm/ptrace.h>
20#include <asm/uaccess.h>
21 21
22#include "../kernel/stacktrace.h" 22#include "../kernel/stacktrace.h"
23 23
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index 0a5cf3a6438b..3fcd752d6146 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -145,6 +145,10 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
145 spec = &op_mpcore_spec; 145 spec = &op_mpcore_spec;
146#endif 146#endif
147 147
148#ifdef CONFIG_OPROFILE_ARMV7
149 spec = &op_armv7_spec;
150#endif
151
148 if (spec) { 152 if (spec) {
149 ret = spec->init(); 153 ret = spec->init();
150 if (ret < 0) 154 if (ret < 0)
diff --git a/arch/arm/oprofile/op_arm_model.h b/arch/arm/oprofile/op_arm_model.h
index 4899c629aa03..8c4e4f6a1de3 100644
--- a/arch/arm/oprofile/op_arm_model.h
+++ b/arch/arm/oprofile/op_arm_model.h
@@ -26,6 +26,7 @@ extern struct op_arm_model_spec op_xscale_spec;
26 26
27extern struct op_arm_model_spec op_armv6_spec; 27extern struct op_arm_model_spec op_armv6_spec;
28extern struct op_arm_model_spec op_mpcore_spec; 28extern struct op_arm_model_spec op_mpcore_spec;
29extern struct op_arm_model_spec op_armv7_spec;
29 30
30extern void arm_backtrace(struct pt_regs * const regs, unsigned int depth); 31extern void arm_backtrace(struct pt_regs * const regs, unsigned int depth);
31 32
diff --git a/arch/arm/oprofile/op_model_mpcore.c b/arch/arm/oprofile/op_model_mpcore.c
index 92db6e035c65..4de366e8b4c5 100644
--- a/arch/arm/oprofile/op_model_mpcore.c
+++ b/arch/arm/oprofile/op_model_mpcore.c
@@ -36,8 +36,8 @@
36#include <linux/oprofile.h> 36#include <linux/oprofile.h>
37#include <linux/interrupt.h> 37#include <linux/interrupt.h>
38#include <linux/smp.h> 38#include <linux/smp.h>
39#include <linux/io.h>
39 40
40#include <asm/io.h>
41#include <asm/irq.h> 41#include <asm/irq.h>
42#include <asm/mach/irq.h> 42#include <asm/mach/irq.h>
43#include <mach/hardware.h> 43#include <mach/hardware.h>
diff --git a/arch/arm/oprofile/op_model_v7.c b/arch/arm/oprofile/op_model_v7.c
new file mode 100644
index 000000000000..f20295f14adb
--- /dev/null
+++ b/arch/arm/oprofile/op_model_v7.c
@@ -0,0 +1,411 @@
1/**
2 * op_model_v7.c
3 * ARM V7 (Cortex A8) Event Monitor Driver
4 *
5 * Copyright 2008 Jean Pihet <jpihet@mvista.com>
6 * Copyright 2004 ARM SMP Development Team
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/types.h>
13#include <linux/errno.h>
14#include <linux/oprofile.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
17#include <linux/smp.h>
18
19#include "op_counter.h"
20#include "op_arm_model.h"
21#include "op_model_v7.h"
22
23/* #define DEBUG */
24
25
26/*
27 * ARM V7 PMNC support
28 */
29
30static u32 cnt_en[CNTMAX];
31
32static inline void armv7_pmnc_write(u32 val)
33{
34 val &= PMNC_MASK;
35 asm volatile("mcr p15, 0, %0, c9, c12, 0" : : "r" (val));
36}
37
38static inline u32 armv7_pmnc_read(void)
39{
40 u32 val;
41
42 asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r" (val));
43 return val;
44}
45
46static inline u32 armv7_pmnc_enable_counter(unsigned int cnt)
47{
48 u32 val;
49
50 if (cnt >= CNTMAX) {
51 printk(KERN_ERR "oprofile: CPU%u enabling wrong PMNC counter"
52 " %d\n", smp_processor_id(), cnt);
53 return -1;
54 }
55
56 if (cnt == CCNT)
57 val = CNTENS_C;
58 else
59 val = (1 << (cnt - CNT0));
60
61 val &= CNTENS_MASK;
62 asm volatile("mcr p15, 0, %0, c9, c12, 1" : : "r" (val));
63
64 return cnt;
65}
66
67static inline u32 armv7_pmnc_disable_counter(unsigned int cnt)
68{
69 u32 val;
70
71 if (cnt >= CNTMAX) {
72 printk(KERN_ERR "oprofile: CPU%u disabling wrong PMNC counter"
73 " %d\n", smp_processor_id(), cnt);
74 return -1;
75 }
76
77 if (cnt == CCNT)
78 val = CNTENC_C;
79 else
80 val = (1 << (cnt - CNT0));
81
82 val &= CNTENC_MASK;
83 asm volatile("mcr p15, 0, %0, c9, c12, 2" : : "r" (val));
84
85 return cnt;
86}
87
88static inline u32 armv7_pmnc_enable_intens(unsigned int cnt)
89{
90 u32 val;
91
92 if (cnt >= CNTMAX) {
93 printk(KERN_ERR "oprofile: CPU%u enabling wrong PMNC counter"
94 " interrupt enable %d\n", smp_processor_id(), cnt);
95 return -1;
96 }
97
98 if (cnt == CCNT)
99 val = INTENS_C;
100 else
101 val = (1 << (cnt - CNT0));
102
103 val &= INTENS_MASK;
104 asm volatile("mcr p15, 0, %0, c9, c14, 1" : : "r" (val));
105
106 return cnt;
107}
108
109static inline u32 armv7_pmnc_getreset_flags(void)
110{
111 u32 val;
112
113 /* Read */
114 asm volatile("mrc p15, 0, %0, c9, c12, 3" : "=r" (val));
115
116 /* Write to clear flags */
117 val &= FLAG_MASK;
118 asm volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (val));
119
120 return val;
121}
122
123static inline int armv7_pmnc_select_counter(unsigned int cnt)
124{
125 u32 val;
126
127 if ((cnt == CCNT) || (cnt >= CNTMAX)) {
128 printk(KERN_ERR "oprofile: CPU%u selecting wrong PMNC counteri"
129 " %d\n", smp_processor_id(), cnt);
130 return -1;
131 }
132
133 val = (cnt - CNT0) & SELECT_MASK;
134 asm volatile("mcr p15, 0, %0, c9, c12, 5" : : "r" (val));
135
136 return cnt;
137}
138
139static inline void armv7_pmnc_write_evtsel(unsigned int cnt, u32 val)
140{
141 if (armv7_pmnc_select_counter(cnt) == cnt) {
142 val &= EVTSEL_MASK;
143 asm volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (val));
144 }
145}
146
147static void armv7_pmnc_reset_counter(unsigned int cnt)
148{
149 u32 cpu_cnt = CPU_COUNTER(smp_processor_id(), cnt);
150 u32 val = -(u32)counter_config[cpu_cnt].count;
151
152 switch (cnt) {
153 case CCNT:
154 armv7_pmnc_disable_counter(cnt);
155
156 asm volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (val));
157
158 if (cnt_en[cnt] != 0)
159 armv7_pmnc_enable_counter(cnt);
160
161 break;
162
163 case CNT0:
164 case CNT1:
165 case CNT2:
166 case CNT3:
167 armv7_pmnc_disable_counter(cnt);
168
169 if (armv7_pmnc_select_counter(cnt) == cnt)
170 asm volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (val));
171
172 if (cnt_en[cnt] != 0)
173 armv7_pmnc_enable_counter(cnt);
174
175 break;
176
177 default:
178 printk(KERN_ERR "oprofile: CPU%u resetting wrong PMNC counter"
179 " %d\n", smp_processor_id(), cnt);
180 break;
181 }
182}
183
184int armv7_setup_pmnc(void)
185{
186 unsigned int cnt;
187
188 if (armv7_pmnc_read() & PMNC_E) {
189 printk(KERN_ERR "oprofile: CPU%u PMNC still enabled when setup"
190 " new event counter.\n", smp_processor_id());
191 return -EBUSY;
192 }
193
194 /*
195 * Initialize & Reset PMNC: C bit, D bit and P bit.
196 * Note: Using a slower count for CCNT (D bit: divide by 64) results
197 * in a more stable system
198 */
199 armv7_pmnc_write(PMNC_P | PMNC_C | PMNC_D);
200
201
202 for (cnt = CCNT; cnt < CNTMAX; cnt++) {
203 unsigned long event;
204 u32 cpu_cnt = CPU_COUNTER(smp_processor_id(), cnt);
205
206 /*
207 * Disable counter
208 */
209 armv7_pmnc_disable_counter(cnt);
210 cnt_en[cnt] = 0;
211
212 if (!counter_config[cpu_cnt].enabled)
213 continue;
214
215 event = counter_config[cpu_cnt].event & 255;
216
217 /*
218 * Set event (if destined for PMNx counters)
219 * We don't need to set the event if it's a cycle count
220 */
221 if (cnt != CCNT)
222 armv7_pmnc_write_evtsel(cnt, event);
223
224 /*
225 * Enable interrupt for this counter
226 */
227 armv7_pmnc_enable_intens(cnt);
228
229 /*
230 * Reset counter
231 */
232 armv7_pmnc_reset_counter(cnt);
233
234 /*
235 * Enable counter
236 */
237 armv7_pmnc_enable_counter(cnt);
238 cnt_en[cnt] = 1;
239 }
240
241 return 0;
242}
243
244static inline void armv7_start_pmnc(void)
245{
246 armv7_pmnc_write(armv7_pmnc_read() | PMNC_E);
247}
248
249static inline void armv7_stop_pmnc(void)
250{
251 armv7_pmnc_write(armv7_pmnc_read() & ~PMNC_E);
252}
253
254/*
255 * CPU counters' IRQ handler (one IRQ per CPU)
256 */
257static irqreturn_t armv7_pmnc_interrupt(int irq, void *arg)
258{
259 struct pt_regs *regs = get_irq_regs();
260 unsigned int cnt;
261 u32 flags;
262
263
264 /*
265 * Stop IRQ generation
266 */
267 armv7_stop_pmnc();
268
269 /*
270 * Get and reset overflow status flags
271 */
272 flags = armv7_pmnc_getreset_flags();
273
274 /*
275 * Cycle counter
276 */
277 if (flags & FLAG_C) {
278 u32 cpu_cnt = CPU_COUNTER(smp_processor_id(), CCNT);
279 armv7_pmnc_reset_counter(CCNT);
280 oprofile_add_sample(regs, cpu_cnt);
281 }
282
283 /*
284 * PMNC counters 0:3
285 */
286 for (cnt = CNT0; cnt < CNTMAX; cnt++) {
287 if (flags & (1 << (cnt - CNT0))) {
288 u32 cpu_cnt = CPU_COUNTER(smp_processor_id(), cnt);
289 armv7_pmnc_reset_counter(cnt);
290 oprofile_add_sample(regs, cpu_cnt);
291 }
292 }
293
294 /*
295 * Allow IRQ generation
296 */
297 armv7_start_pmnc();
298
299 return IRQ_HANDLED;
300}
301
302int armv7_request_interrupts(int *irqs, int nr)
303{
304 unsigned int i;
305 int ret = 0;
306
307 for (i = 0; i < nr; i++) {
308 ret = request_irq(irqs[i], armv7_pmnc_interrupt,
309 IRQF_DISABLED, "CP15 PMNC", NULL);
310 if (ret != 0) {
311 printk(KERN_ERR "oprofile: unable to request IRQ%u"
312 " for ARMv7\n",
313 irqs[i]);
314 break;
315 }
316 }
317
318 if (i != nr)
319 while (i-- != 0)
320 free_irq(irqs[i], NULL);
321
322 return ret;
323}
324
325void armv7_release_interrupts(int *irqs, int nr)
326{
327 unsigned int i;
328
329 for (i = 0; i < nr; i++)
330 free_irq(irqs[i], NULL);
331}
332
333#ifdef DEBUG
334static void armv7_pmnc_dump_regs(void)
335{
336 u32 val;
337 unsigned int cnt;
338
339 printk(KERN_INFO "PMNC registers dump:\n");
340
341 asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r" (val));
342 printk(KERN_INFO "PMNC =0x%08x\n", val);
343
344 asm volatile("mrc p15, 0, %0, c9, c12, 1" : "=r" (val));
345 printk(KERN_INFO "CNTENS=0x%08x\n", val);
346
347 asm volatile("mrc p15, 0, %0, c9, c14, 1" : "=r" (val));
348 printk(KERN_INFO "INTENS=0x%08x\n", val);
349
350 asm volatile("mrc p15, 0, %0, c9, c12, 3" : "=r" (val));
351 printk(KERN_INFO "FLAGS =0x%08x\n", val);
352
353 asm volatile("mrc p15, 0, %0, c9, c12, 5" : "=r" (val));
354 printk(KERN_INFO "SELECT=0x%08x\n", val);
355
356 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (val));
357 printk(KERN_INFO "CCNT =0x%08x\n", val);
358
359 for (cnt = CNT0; cnt < CNTMAX; cnt++) {
360 armv7_pmnc_select_counter(cnt);
361 asm volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (val));
362 printk(KERN_INFO "CNT[%d] count =0x%08x\n", cnt-CNT0, val);
363 asm volatile("mrc p15, 0, %0, c9, c13, 1" : "=r" (val));
364 printk(KERN_INFO "CNT[%d] evtsel=0x%08x\n", cnt-CNT0, val);
365 }
366}
367#endif
368
369
370static int irqs[] = {
371#ifdef CONFIG_ARCH_OMAP3
372 INT_34XX_BENCH_MPU_EMUL,
373#endif
374};
375
376static void armv7_pmnc_stop(void)
377{
378#ifdef DEBUG
379 armv7_pmnc_dump_regs();
380#endif
381 armv7_stop_pmnc();
382 armv7_release_interrupts(irqs, ARRAY_SIZE(irqs));
383}
384
385static int armv7_pmnc_start(void)
386{
387 int ret;
388
389#ifdef DEBUG
390 armv7_pmnc_dump_regs();
391#endif
392 ret = armv7_request_interrupts(irqs, ARRAY_SIZE(irqs));
393 if (ret >= 0)
394 armv7_start_pmnc();
395
396 return ret;
397}
398
399static int armv7_detect_pmnc(void)
400{
401 return 0;
402}
403
404struct op_arm_model_spec op_armv7_spec = {
405 .init = armv7_detect_pmnc,
406 .num_counters = 5,
407 .setup_ctrs = armv7_setup_pmnc,
408 .start = armv7_pmnc_start,
409 .stop = armv7_pmnc_stop,
410 .name = "arm/armv7",
411};
diff --git a/arch/arm/oprofile/op_model_v7.h b/arch/arm/oprofile/op_model_v7.h
new file mode 100644
index 000000000000..0e19bcc2e100
--- /dev/null
+++ b/arch/arm/oprofile/op_model_v7.h
@@ -0,0 +1,103 @@
1/**
2 * op_model_v7.h
3 * ARM v7 (Cortex A8) Event Monitor Driver
4 *
5 * Copyright 2008 Jean Pihet <jpihet@mvista.com>
6 * Copyright 2004 ARM SMP Development Team
7 * Copyright 2000-2004 Deepak Saxena <dsaxena@mvista.com>
8 * Copyright 2000-2004 MontaVista Software Inc
9 * Copyright 2004 Dave Jiang <dave.jiang@intel.com>
10 * Copyright 2004 Intel Corporation
11 * Copyright 2004 Zwane Mwaikambo <zwane@arm.linux.org.uk>
12 * Copyright 2004 Oprofile Authors
13 *
14 * Read the file COPYING
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation.
19 */
20#ifndef OP_MODEL_V7_H
21#define OP_MODEL_V7_H
22
23/*
24 * Per-CPU PMNC: config reg
25 */
26#define PMNC_E (1 << 0) /* Enable all counters */
27#define PMNC_P (1 << 1) /* Reset all counters */
28#define PMNC_C (1 << 2) /* Cycle counter reset */
29#define PMNC_D (1 << 3) /* CCNT counts every 64th cpu cycle */
30#define PMNC_X (1 << 4) /* Export to ETM */
31#define PMNC_DP (1 << 5) /* Disable CCNT if non-invasive debug*/
32#define PMNC_MASK 0x3f /* Mask for writable bits */
33
34/*
35 * Available counters
36 */
37#define CCNT 0
38#define CNT0 1
39#define CNT1 2
40#define CNT2 3
41#define CNT3 4
42#define CNTMAX 5
43
44#define CPU_COUNTER(cpu, counter) ((cpu) * CNTMAX + (counter))
45
46/*
47 * CNTENS: counters enable reg
48 */
49#define CNTENS_P0 (1 << 0)
50#define CNTENS_P1 (1 << 1)
51#define CNTENS_P2 (1 << 2)
52#define CNTENS_P3 (1 << 3)
53#define CNTENS_C (1 << 31)
54#define CNTENS_MASK 0x8000000f /* Mask for writable bits */
55
56/*
57 * CNTENC: counters disable reg
58 */
59#define CNTENC_P0 (1 << 0)
60#define CNTENC_P1 (1 << 1)
61#define CNTENC_P2 (1 << 2)
62#define CNTENC_P3 (1 << 3)
63#define CNTENC_C (1 << 31)
64#define CNTENC_MASK 0x8000000f /* Mask for writable bits */
65
66/*
67 * INTENS: counters overflow interrupt enable reg
68 */
69#define INTENS_P0 (1 << 0)
70#define INTENS_P1 (1 << 1)
71#define INTENS_P2 (1 << 2)
72#define INTENS_P3 (1 << 3)
73#define INTENS_C (1 << 31)
74#define INTENS_MASK 0x8000000f /* Mask for writable bits */
75
76/*
77 * EVTSEL: Event selection reg
78 */
79#define EVTSEL_MASK 0x7f /* Mask for writable bits */
80
81/*
82 * SELECT: Counter selection reg
83 */
84#define SELECT_MASK 0x1f /* Mask for writable bits */
85
86/*
87 * FLAG: counters overflow flag status reg
88 */
89#define FLAG_P0 (1 << 0)
90#define FLAG_P1 (1 << 1)
91#define FLAG_P2 (1 << 2)
92#define FLAG_P3 (1 << 3)
93#define FLAG_C (1 << 31)
94#define FLAG_MASK 0x8000000f /* Mask for writable bits */
95
96
97int armv7_setup_pmu(void);
98int armv7_start_pmu(void);
99int armv7_stop_pmu(void);
100int armv7_request_interrupts(int *, int);
101void armv7_release_interrupts(int *, int);
102
103#endif
diff --git a/arch/arm/oprofile/op_model_xscale.c b/arch/arm/oprofile/op_model_xscale.c
index 7c3289c2acd7..724ab9ce2526 100644
--- a/arch/arm/oprofile/op_model_xscale.c
+++ b/arch/arm/oprofile/op_model_xscale.c
@@ -22,7 +22,7 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24 24
25#include <asm/system.h> 25#include <asm/cputype.h>
26 26
27#include "op_counter.h" 27#include "op_counter.h"
28#include "op_arm_model.h" 28#include "op_arm_model.h"
diff --git a/arch/arm/plat-iop/i2c.c b/arch/arm/plat-iop/i2c.c
index 6dcbcc4ad419..4efe392859ee 100644
--- a/arch/arm/plat-iop/i2c.c
+++ b/arch/arm/plat-iop/i2c.c
@@ -18,7 +18,7 @@
18#include <linux/serial.h> 18#include <linux/serial.h>
19#include <linux/tty.h> 19#include <linux/tty.h>
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <asm/pgtable.h> 22#include <asm/pgtable.h>
23#include <asm/page.h> 23#include <asm/page.h>
24#include <asm/mach/map.h> 24#include <asm/mach/map.h>
diff --git a/arch/arm/plat-iop/io.c b/arch/arm/plat-iop/io.c
index 39dcfb4bdc71..ed0bbece0d61 100644
--- a/arch/arm/plat-iop/io.c
+++ b/arch/arm/plat-iop/io.c
@@ -18,8 +18,8 @@
18 */ 18 */
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/io.h>
21#include <mach/hardware.h> 22#include <mach/hardware.h>
22#include <asm/io.h>
23 23
24void * __iomem __iop3xx_ioremap(unsigned long cookie, size_t size, 24void * __iomem __iop3xx_ioremap(unsigned long cookie, size_t size,
25 unsigned int mtype) 25 unsigned int mtype)
diff --git a/arch/arm/plat-iop/pci.c b/arch/arm/plat-iop/pci.c
index 54708bf9cb15..77fa7cc7d162 100644
--- a/arch/arm/plat-iop/pci.c
+++ b/arch/arm/plat-iop/pci.c
@@ -17,7 +17,7 @@
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <asm/io.h> 20#include <linux/io.h>
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/signal.h> 22#include <asm/signal.h>
23#include <asm/system.h> 23#include <asm/system.h>
diff --git a/arch/arm/plat-iop/time.c b/arch/arm/plat-iop/time.c
index c53fefb6aac4..3695bbe3ee28 100644
--- a/arch/arm/plat-iop/time.c
+++ b/arch/arm/plat-iop/time.c
@@ -18,8 +18,8 @@
18#include <linux/time.h> 18#include <linux/time.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/timex.h> 20#include <linux/timex.h>
21#include <linux/io.h>
21#include <mach/hardware.h> 22#include <mach/hardware.h>
22#include <asm/io.h>
23#include <asm/irq.h> 23#include <asm/irq.h>
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <asm/mach/irq.h> 25#include <asm/mach/irq.h>
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
index e14eaad11dd5..b2a7e3fad117 100644
--- a/arch/arm/plat-mxc/Kconfig
+++ b/arch/arm/plat-mxc/Kconfig
@@ -23,4 +23,15 @@ source "arch/arm/mach-mx3/Kconfig"
23 23
24endmenu 24endmenu
25 25
26config MXC_IRQ_PRIOR
27 bool "Use IRQ priority"
28 depends on ARCH_MXC
29 help
30 Select this if you want to use prioritized IRQ handling.
31 This feature prevents higher priority ISR to be interrupted
32 by lower priority IRQ even IRQF_DISABLED flag is not set.
33 This may be useful in embedded applications, where are strong
34 requirements for timing.
35 Say N here, unless you have a specialized requirement.
36
26endif 37endif
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index db66e9ae8414..067556f7c91f 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -3,6 +3,6 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := irq.o clock.o gpio.o time.o 6obj-y := irq.o clock.o gpio.o time.o devices.o
7 7
8obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o 8obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
diff --git a/arch/arm/plat-mxc/devices.c b/arch/arm/plat-mxc/devices.c
new file mode 100644
index 000000000000..c66748267c45
--- /dev/null
+++ b/arch/arm/plat-mxc/devices.c
@@ -0,0 +1,36 @@
1/*
2 * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h>
22
23int __init mxc_register_device(struct platform_device *pdev, void *data)
24{
25 int ret;
26
27 pdev->dev.platform_data = data;
28
29 ret = platform_device_register(pdev);
30 if (ret)
31 pr_debug("Unable to register platform device '%s': %d\n",
32 pdev->name, ret);
33
34 return ret;
35}
36
diff --git a/arch/arm/plat-mxc/dma-mx1-mx2.c b/arch/arm/plat-mxc/dma-mx1-mx2.c
new file mode 100644
index 000000000000..b296f19fd89a
--- /dev/null
+++ b/arch/arm/plat-mxc/dma-mx1-mx2.c
@@ -0,0 +1,840 @@
1/*
2 * linux/arch/arm/plat-mxc/dma-mx1-mx2.c
3 *
4 * i.MX DMA registration and IRQ dispatching
5 *
6 * Copyright 2006 Pavel Pisa <pisa@cmp.felk.cvut.cz>
7 * Copyright 2008 Juergen Beisert, <kernel@pengutronix.de>
8 * Copyright 2008 Sascha Hauer, <s.hauer@pengutronix.de>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301, USA.
23 */
24
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/kernel.h>
28#include <linux/interrupt.h>
29#include <linux/errno.h>
30#include <linux/clk.h>
31#include <linux/scatterlist.h>
32#include <linux/io.h>
33
34#include <asm/system.h>
35#include <asm/irq.h>
36#include <mach/hardware.h>
37#include <asm/dma.h>
38#include <mach/dma-mx1-mx2.h>
39
40#define DMA_DCR 0x00 /* Control Register */
41#define DMA_DISR 0x04 /* Interrupt status Register */
42#define DMA_DIMR 0x08 /* Interrupt mask Register */
43#define DMA_DBTOSR 0x0c /* Burst timeout status Register */
44#define DMA_DRTOSR 0x10 /* Request timeout Register */
45#define DMA_DSESR 0x14 /* Transfer Error Status Register */
46#define DMA_DBOSR 0x18 /* Buffer overflow status Register */
47#define DMA_DBTOCR 0x1c /* Burst timeout control Register */
48#define DMA_WSRA 0x40 /* W-Size Register A */
49#define DMA_XSRA 0x44 /* X-Size Register A */
50#define DMA_YSRA 0x48 /* Y-Size Register A */
51#define DMA_WSRB 0x4c /* W-Size Register B */
52#define DMA_XSRB 0x50 /* X-Size Register B */
53#define DMA_YSRB 0x54 /* Y-Size Register B */
54#define DMA_SAR(x) (0x80 + ((x) << 6)) /* Source Address Registers */
55#define DMA_DAR(x) (0x84 + ((x) << 6)) /* Destination Address Registers */
56#define DMA_CNTR(x) (0x88 + ((x) << 6)) /* Count Registers */
57#define DMA_CCR(x) (0x8c + ((x) << 6)) /* Control Registers */
58#define DMA_RSSR(x) (0x90 + ((x) << 6)) /* Request source select Registers */
59#define DMA_BLR(x) (0x94 + ((x) << 6)) /* Burst length Registers */
60#define DMA_RTOR(x) (0x98 + ((x) << 6)) /* Request timeout Registers */
61#define DMA_BUCR(x) (0x98 + ((x) << 6)) /* Bus Utilization Registers */
62#define DMA_CCNR(x) (0x9C + ((x) << 6)) /* Channel counter Registers */
63
64#define DCR_DRST (1<<1)
65#define DCR_DEN (1<<0)
66#define DBTOCR_EN (1<<15)
67#define DBTOCR_CNT(x) ((x) & 0x7fff)
68#define CNTR_CNT(x) ((x) & 0xffffff)
69#define CCR_ACRPT (1<<14)
70#define CCR_DMOD_LINEAR (0x0 << 12)
71#define CCR_DMOD_2D (0x1 << 12)
72#define CCR_DMOD_FIFO (0x2 << 12)
73#define CCR_DMOD_EOBFIFO (0x3 << 12)
74#define CCR_SMOD_LINEAR (0x0 << 10)
75#define CCR_SMOD_2D (0x1 << 10)
76#define CCR_SMOD_FIFO (0x2 << 10)
77#define CCR_SMOD_EOBFIFO (0x3 << 10)
78#define CCR_MDIR_DEC (1<<9)
79#define CCR_MSEL_B (1<<8)
80#define CCR_DSIZ_32 (0x0 << 6)
81#define CCR_DSIZ_8 (0x1 << 6)
82#define CCR_DSIZ_16 (0x2 << 6)
83#define CCR_SSIZ_32 (0x0 << 4)
84#define CCR_SSIZ_8 (0x1 << 4)
85#define CCR_SSIZ_16 (0x2 << 4)
86#define CCR_REN (1<<3)
87#define CCR_RPT (1<<2)
88#define CCR_FRC (1<<1)
89#define CCR_CEN (1<<0)
90#define RTOR_EN (1<<15)
91#define RTOR_CLK (1<<14)
92#define RTOR_PSC (1<<13)
93
94/*
95 * struct imx_dma_channel - i.MX specific DMA extension
96 * @name: name specified by DMA client
97 * @irq_handler: client callback for end of transfer
98 * @err_handler: client callback for error condition
99 * @data: clients context data for callbacks
100 * @dma_mode: direction of the transfer %DMA_MODE_READ or %DMA_MODE_WRITE
101 * @sg: pointer to the actual read/written chunk for scatter-gather emulation
102 * @resbytes: total residual number of bytes to transfer
103 * (it can be lower or same as sum of SG mapped chunk sizes)
104 * @sgcount: number of chunks to be read/written
105 *
106 * Structure is used for IMX DMA processing. It would be probably good
107 * @struct dma_struct in the future for external interfacing and use
108 * @struct imx_dma_channel only as extension to it.
109 */
110
111struct imx_dma_channel {
112 const char *name;
113 void (*irq_handler) (int, void *);
114 void (*err_handler) (int, void *, int errcode);
115 void (*prog_handler) (int, void *, struct scatterlist *);
116 void *data;
117 dmamode_t dma_mode;
118 struct scatterlist *sg;
119 unsigned int resbytes;
120 int dma_num;
121
122 int in_use;
123
124 u32 ccr_from_device;
125 u32 ccr_to_device;
126
127 struct timer_list watchdog;
128
129 int hw_chaining;
130};
131
132static struct imx_dma_channel imx_dma_channels[IMX_DMA_CHANNELS];
133
134static struct clk *dma_clk;
135
136static int imx_dma_hw_chain(struct imx_dma_channel *imxdma)
137{
138 if (cpu_is_mx27())
139 return imxdma->hw_chaining;
140 else
141 return 0;
142}
143
144
145/*
146 * imx_dma_sg_next - prepare next chunk for scatter-gather DMA emulation
147 */
148static inline int imx_dma_sg_next(int channel, struct scatterlist *sg)
149{
150 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
151 unsigned long now;
152
153 if (!imxdma->name) {
154 printk(KERN_CRIT "%s: called for not allocated channel %d\n",
155 __func__, channel);
156 return 0;
157 }
158
159 now = min(imxdma->resbytes, sg->length);
160 imxdma->resbytes -= now;
161
162 if ((imxdma->dma_mode & DMA_MODE_MASK) == DMA_MODE_READ)
163 __raw_writel(sg->dma_address, DMA_BASE + DMA_DAR(channel));
164 else
165 __raw_writel(sg->dma_address, DMA_BASE + DMA_SAR(channel));
166
167 __raw_writel(now, DMA_BASE + DMA_CNTR(channel));
168
169 pr_debug("imxdma%d: next sg chunk dst 0x%08x, src 0x%08x, "
170 "size 0x%08x\n", channel,
171 __raw_readl(DMA_BASE + DMA_DAR(channel)),
172 __raw_readl(DMA_BASE + DMA_SAR(channel)),
173 __raw_readl(DMA_BASE + DMA_CNTR(channel)));
174
175 return now;
176}
177
178/**
179 * imx_dma_setup_single - setup i.MX DMA channel for linear memory to/from
180 * device transfer
181 *
182 * @channel: i.MX DMA channel number
183 * @dma_address: the DMA/physical memory address of the linear data block
184 * to transfer
185 * @dma_length: length of the data block in bytes
186 * @dev_addr: physical device port address
187 * @dmamode: DMA transfer mode, %DMA_MODE_READ from the device to the memory
188 * or %DMA_MODE_WRITE from memory to the device
189 *
190 * Return value: if incorrect parameters are provided -%EINVAL.
191 * Zero indicates success.
192 */
193int
194imx_dma_setup_single(int channel, dma_addr_t dma_address,
195 unsigned int dma_length, unsigned int dev_addr,
196 dmamode_t dmamode)
197{
198 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
199
200 imxdma->sg = NULL;
201 imxdma->dma_mode = dmamode;
202
203 if (!dma_address) {
204 printk(KERN_ERR "imxdma%d: imx_dma_setup_single null address\n",
205 channel);
206 return -EINVAL;
207 }
208
209 if (!dma_length) {
210 printk(KERN_ERR "imxdma%d: imx_dma_setup_single zero length\n",
211 channel);
212 return -EINVAL;
213 }
214
215 if ((dmamode & DMA_MODE_MASK) == DMA_MODE_READ) {
216 pr_debug("imxdma%d: %s dma_addressg=0x%08x dma_length=%d "
217 "dev_addr=0x%08x for read\n",
218 channel, __func__, (unsigned int)dma_address,
219 dma_length, dev_addr);
220
221 __raw_writel(dev_addr, DMA_BASE + DMA_SAR(channel));
222 __raw_writel(dma_address, DMA_BASE + DMA_DAR(channel));
223 __raw_writel(imxdma->ccr_from_device,
224 DMA_BASE + DMA_CCR(channel));
225 } else if ((dmamode & DMA_MODE_MASK) == DMA_MODE_WRITE) {
226 pr_debug("imxdma%d: %s dma_addressg=0x%08x dma_length=%d "
227 "dev_addr=0x%08x for write\n",
228 channel, __func__, (unsigned int)dma_address,
229 dma_length, dev_addr);
230
231 __raw_writel(dma_address, DMA_BASE + DMA_SAR(channel));
232 __raw_writel(dev_addr, DMA_BASE + DMA_DAR(channel));
233 __raw_writel(imxdma->ccr_to_device,
234 DMA_BASE + DMA_CCR(channel));
235 } else {
236 printk(KERN_ERR "imxdma%d: imx_dma_setup_single bad dmamode\n",
237 channel);
238 return -EINVAL;
239 }
240
241 __raw_writel(dma_length, DMA_BASE + DMA_CNTR(channel));
242
243 return 0;
244}
245EXPORT_SYMBOL(imx_dma_setup_single);
246
247/**
248 * imx_dma_setup_sg - setup i.MX DMA channel SG list to/from device transfer
249 * @channel: i.MX DMA channel number
250 * @sg: pointer to the scatter-gather list/vector
251 * @sgcount: scatter-gather list hungs count
252 * @dma_length: total length of the transfer request in bytes
253 * @dev_addr: physical device port address
254 * @dmamode: DMA transfer mode, %DMA_MODE_READ from the device to the memory
255 * or %DMA_MODE_WRITE from memory to the device
256 *
257 * The function sets up DMA channel state and registers to be ready for
258 * transfer specified by provided parameters. The scatter-gather emulation
259 * is set up according to the parameters.
260 *
261 * The full preparation of the transfer requires setup of more register
262 * by the caller before imx_dma_enable() can be called.
263 *
264 * %BLR(channel) holds transfer burst length in bytes, 0 means 64 bytes
265 *
266 * %RSSR(channel) has to be set to the DMA request line source %DMA_REQ_xxx
267 *
268 * %CCR(channel) has to specify transfer parameters, the next settings is
269 * typical for linear or simple scatter-gather transfers if %DMA_MODE_READ is
270 * specified
271 *
272 * %CCR_DMOD_LINEAR | %CCR_DSIZ_32 | %CCR_SMOD_FIFO | %CCR_SSIZ_x
273 *
274 * The typical setup for %DMA_MODE_WRITE is specified by next options
275 * combination
276 *
277 * %CCR_SMOD_LINEAR | %CCR_SSIZ_32 | %CCR_DMOD_FIFO | %CCR_DSIZ_x
278 *
279 * Be careful here and do not mistakenly mix source and target device
280 * port sizes constants, they are really different:
281 * %CCR_SSIZ_8, %CCR_SSIZ_16, %CCR_SSIZ_32,
282 * %CCR_DSIZ_8, %CCR_DSIZ_16, %CCR_DSIZ_32
283 *
284 * Return value: if incorrect parameters are provided -%EINVAL.
285 * Zero indicates success.
286 */
287int
288imx_dma_setup_sg(int channel,
289 struct scatterlist *sg, unsigned int sgcount,
290 unsigned int dma_length, unsigned int dev_addr,
291 dmamode_t dmamode)
292{
293 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
294
295 if (imxdma->in_use)
296 return -EBUSY;
297
298 imxdma->sg = sg;
299 imxdma->dma_mode = dmamode;
300 imxdma->resbytes = dma_length;
301
302 if (!sg || !sgcount) {
303 printk(KERN_ERR "imxdma%d: imx_dma_setup_sg epty sg list\n",
304 channel);
305 return -EINVAL;
306 }
307
308 if (!sg->length) {
309 printk(KERN_ERR "imxdma%d: imx_dma_setup_sg zero length\n",
310 channel);
311 return -EINVAL;
312 }
313
314 if ((dmamode & DMA_MODE_MASK) == DMA_MODE_READ) {
315 pr_debug("imxdma%d: %s sg=%p sgcount=%d total length=%d "
316 "dev_addr=0x%08x for read\n",
317 channel, __func__, sg, sgcount, dma_length, dev_addr);
318
319 __raw_writel(dev_addr, DMA_BASE + DMA_SAR(channel));
320 __raw_writel(imxdma->ccr_from_device,
321 DMA_BASE + DMA_CCR(channel));
322 } else if ((dmamode & DMA_MODE_MASK) == DMA_MODE_WRITE) {
323 pr_debug("imxdma%d: %s sg=%p sgcount=%d total length=%d "
324 "dev_addr=0x%08x for write\n",
325 channel, __func__, sg, sgcount, dma_length, dev_addr);
326
327 __raw_writel(dev_addr, DMA_BASE + DMA_DAR(channel));
328 __raw_writel(imxdma->ccr_to_device,
329 DMA_BASE + DMA_CCR(channel));
330 } else {
331 printk(KERN_ERR "imxdma%d: imx_dma_setup_sg bad dmamode\n",
332 channel);
333 return -EINVAL;
334 }
335
336 imx_dma_sg_next(channel, sg);
337
338 return 0;
339}
340EXPORT_SYMBOL(imx_dma_setup_sg);
341
342int
343imx_dma_config_channel(int channel, unsigned int config_port,
344 unsigned int config_mem, unsigned int dmareq, int hw_chaining)
345{
346 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
347 u32 dreq = 0;
348
349 imxdma->hw_chaining = 0;
350
351 if (hw_chaining) {
352 imxdma->hw_chaining = 1;
353 if (!imx_dma_hw_chain(imxdma))
354 return -EINVAL;
355 }
356
357 if (dmareq)
358 dreq = CCR_REN;
359
360 imxdma->ccr_from_device = config_port | (config_mem << 2) | dreq;
361 imxdma->ccr_to_device = config_mem | (config_port << 2) | dreq;
362
363 __raw_writel(dmareq, DMA_BASE + DMA_RSSR(channel));
364
365 return 0;
366}
367EXPORT_SYMBOL(imx_dma_config_channel);
368
369void imx_dma_config_burstlen(int channel, unsigned int burstlen)
370{
371 __raw_writel(burstlen, DMA_BASE + DMA_BLR(channel));
372}
373EXPORT_SYMBOL(imx_dma_config_burstlen);
374
375/**
376 * imx_dma_setup_handlers - setup i.MX DMA channel end and error notification
377 * handlers
378 * @channel: i.MX DMA channel number
379 * @irq_handler: the pointer to the function called if the transfer
380 * ends successfully
381 * @err_handler: the pointer to the function called if the premature
382 * end caused by error occurs
383 * @data: user specified value to be passed to the handlers
384 */
385int
386imx_dma_setup_handlers(int channel,
387 void (*irq_handler) (int, void *),
388 void (*err_handler) (int, void *, int),
389 void *data)
390{
391 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
392 unsigned long flags;
393
394 if (!imxdma->name) {
395 printk(KERN_CRIT "%s: called for not allocated channel %d\n",
396 __func__, channel);
397 return -ENODEV;
398 }
399
400 local_irq_save(flags);
401 __raw_writel(1 << channel, DMA_BASE + DMA_DISR);
402 imxdma->irq_handler = irq_handler;
403 imxdma->err_handler = err_handler;
404 imxdma->data = data;
405 local_irq_restore(flags);
406 return 0;
407}
408EXPORT_SYMBOL(imx_dma_setup_handlers);
409
410/**
411 * imx_dma_setup_progression_handler - setup i.MX DMA channel progression
412 * handlers
413 * @channel: i.MX DMA channel number
414 * @prog_handler: the pointer to the function called if the transfer progresses
415 */
416int
417imx_dma_setup_progression_handler(int channel,
418 void (*prog_handler) (int, void*, struct scatterlist*))
419{
420 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
421 unsigned long flags;
422
423 if (!imxdma->name) {
424 printk(KERN_CRIT "%s: called for not allocated channel %d\n",
425 __func__, channel);
426 return -ENODEV;
427 }
428
429 local_irq_save(flags);
430 imxdma->prog_handler = prog_handler;
431 local_irq_restore(flags);
432 return 0;
433}
434EXPORT_SYMBOL(imx_dma_setup_progression_handler);
435
436/**
437 * imx_dma_enable - function to start i.MX DMA channel operation
438 * @channel: i.MX DMA channel number
439 *
440 * The channel has to be allocated by driver through imx_dma_request()
441 * or imx_dma_request_by_prio() function.
442 * The transfer parameters has to be set to the channel registers through
443 * call of the imx_dma_setup_single() or imx_dma_setup_sg() function
444 * and registers %BLR(channel), %RSSR(channel) and %CCR(channel) has to
445 * be set prior this function call by the channel user.
446 */
447void imx_dma_enable(int channel)
448{
449 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
450 unsigned long flags;
451
452 pr_debug("imxdma%d: imx_dma_enable\n", channel);
453
454 if (!imxdma->name) {
455 printk(KERN_CRIT "%s: called for not allocated channel %d\n",
456 __func__, channel);
457 return;
458 }
459
460 if (imxdma->in_use)
461 return;
462
463 local_irq_save(flags);
464
465 __raw_writel(1 << channel, DMA_BASE + DMA_DISR);
466 __raw_writel(__raw_readl(DMA_BASE + DMA_DIMR) & ~(1 << channel),
467 DMA_BASE + DMA_DIMR);
468 __raw_writel(__raw_readl(DMA_BASE + DMA_CCR(channel)) | CCR_CEN |
469 CCR_ACRPT,
470 DMA_BASE + DMA_CCR(channel));
471
472#ifdef CONFIG_ARCH_MX2
473 if (imxdma->sg && imx_dma_hw_chain(imxdma)) {
474 imxdma->sg = sg_next(imxdma->sg);
475 if (imxdma->sg) {
476 u32 tmp;
477 imx_dma_sg_next(channel, imxdma->sg);
478 tmp = __raw_readl(DMA_BASE + DMA_CCR(channel));
479 __raw_writel(tmp | CCR_RPT | CCR_ACRPT,
480 DMA_BASE + DMA_CCR(channel));
481 }
482 }
483#endif
484 imxdma->in_use = 1;
485
486 local_irq_restore(flags);
487}
488EXPORT_SYMBOL(imx_dma_enable);
489
490/**
491 * imx_dma_disable - stop, finish i.MX DMA channel operatin
492 * @channel: i.MX DMA channel number
493 */
494void imx_dma_disable(int channel)
495{
496 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
497 unsigned long flags;
498
499 pr_debug("imxdma%d: imx_dma_disable\n", channel);
500
501 if (imx_dma_hw_chain(imxdma))
502 del_timer(&imxdma->watchdog);
503
504 local_irq_save(flags);
505 __raw_writel(__raw_readl(DMA_BASE + DMA_DIMR) | (1 << channel),
506 DMA_BASE + DMA_DIMR);
507 __raw_writel(__raw_readl(DMA_BASE + DMA_CCR(channel)) & ~CCR_CEN,
508 DMA_BASE + DMA_CCR(channel));
509 __raw_writel(1 << channel, DMA_BASE + DMA_DISR);
510 imxdma->in_use = 0;
511 local_irq_restore(flags);
512}
513EXPORT_SYMBOL(imx_dma_disable);
514
515static void imx_dma_watchdog(unsigned long chno)
516{
517 struct imx_dma_channel *imxdma = &imx_dma_channels[chno];
518
519 __raw_writel(0, DMA_BASE + DMA_CCR(chno));
520 imxdma->in_use = 0;
521 imxdma->sg = NULL;
522
523 if (imxdma->err_handler)
524 imxdma->err_handler(chno, imxdma->data, IMX_DMA_ERR_TIMEOUT);
525}
526
527static irqreturn_t dma_err_handler(int irq, void *dev_id)
528{
529 int i, disr;
530 struct imx_dma_channel *imxdma;
531 unsigned int err_mask;
532 int errcode;
533
534 disr = __raw_readl(DMA_BASE + DMA_DISR);
535
536 err_mask = __raw_readl(DMA_BASE + DMA_DBTOSR) |
537 __raw_readl(DMA_BASE + DMA_DRTOSR) |
538 __raw_readl(DMA_BASE + DMA_DSESR) |
539 __raw_readl(DMA_BASE + DMA_DBOSR);
540
541 if (!err_mask)
542 return IRQ_HANDLED;
543
544 __raw_writel(disr & err_mask, DMA_BASE + DMA_DISR);
545
546 for (i = 0; i < IMX_DMA_CHANNELS; i++) {
547 if (!(err_mask & (1 << i)))
548 continue;
549 imxdma = &imx_dma_channels[i];
550 errcode = 0;
551
552 if (__raw_readl(DMA_BASE + DMA_DBTOSR) & (1 << i)) {
553 __raw_writel(1 << i, DMA_BASE + DMA_DBTOSR);
554 errcode |= IMX_DMA_ERR_BURST;
555 }
556 if (__raw_readl(DMA_BASE + DMA_DRTOSR) & (1 << i)) {
557 __raw_writel(1 << i, DMA_BASE + DMA_DRTOSR);
558 errcode |= IMX_DMA_ERR_REQUEST;
559 }
560 if (__raw_readl(DMA_BASE + DMA_DSESR) & (1 << i)) {
561 __raw_writel(1 << i, DMA_BASE + DMA_DSESR);
562 errcode |= IMX_DMA_ERR_TRANSFER;
563 }
564 if (__raw_readl(DMA_BASE + DMA_DBOSR) & (1 << i)) {
565 __raw_writel(1 << i, DMA_BASE + DMA_DBOSR);
566 errcode |= IMX_DMA_ERR_BUFFER;
567 }
568 if (imxdma->name && imxdma->err_handler) {
569 imxdma->err_handler(i, imxdma->data, errcode);
570 continue;
571 }
572
573 imx_dma_channels[i].sg = NULL;
574
575 printk(KERN_WARNING
576 "DMA timeout on channel %d (%s) -%s%s%s%s\n",
577 i, imxdma->name,
578 errcode & IMX_DMA_ERR_BURST ? " burst" : "",
579 errcode & IMX_DMA_ERR_REQUEST ? " request" : "",
580 errcode & IMX_DMA_ERR_TRANSFER ? " transfer" : "",
581 errcode & IMX_DMA_ERR_BUFFER ? " buffer" : "");
582 }
583 return IRQ_HANDLED;
584}
585
586static void dma_irq_handle_channel(int chno)
587{
588 struct imx_dma_channel *imxdma = &imx_dma_channels[chno];
589
590 if (!imxdma->name) {
591 /*
592 * IRQ for an unregistered DMA channel:
593 * let's clear the interrupts and disable it.
594 */
595 printk(KERN_WARNING
596 "spurious IRQ for DMA channel %d\n", chno);
597 return;
598 }
599
600 if (imxdma->sg) {
601 u32 tmp;
602 struct scatterlist *current_sg = imxdma->sg;
603 imxdma->sg = sg_next(imxdma->sg);
604
605 if (imxdma->sg) {
606 imx_dma_sg_next(chno, imxdma->sg);
607
608 tmp = __raw_readl(DMA_BASE + DMA_CCR(chno));
609
610 if (imx_dma_hw_chain(imxdma)) {
611 /* FIXME: The timeout should probably be
612 * configurable
613 */
614 mod_timer(&imxdma->watchdog,
615 jiffies + msecs_to_jiffies(500));
616
617 tmp |= CCR_CEN | CCR_RPT | CCR_ACRPT;
618 __raw_writel(tmp, DMA_BASE +
619 DMA_CCR(chno));
620 } else {
621 __raw_writel(tmp & ~CCR_CEN, DMA_BASE +
622 DMA_CCR(chno));
623 tmp |= CCR_CEN;
624 }
625
626 __raw_writel(tmp, DMA_BASE + DMA_CCR(chno));
627
628 if (imxdma->prog_handler)
629 imxdma->prog_handler(chno, imxdma->data,
630 current_sg);
631
632 return;
633 }
634
635 if (imx_dma_hw_chain(imxdma)) {
636 del_timer(&imxdma->watchdog);
637 return;
638 }
639 }
640
641 __raw_writel(0, DMA_BASE + DMA_CCR(chno));
642 imxdma->in_use = 0;
643 if (imxdma->irq_handler)
644 imxdma->irq_handler(chno, imxdma->data);
645}
646
647static irqreturn_t dma_irq_handler(int irq, void *dev_id)
648{
649 int i, disr;
650
651#ifdef CONFIG_ARCH_MX2
652 dma_err_handler(irq, dev_id);
653#endif
654
655 disr = __raw_readl(DMA_BASE + DMA_DISR);
656
657 pr_debug("imxdma: dma_irq_handler called, disr=0x%08x\n",
658 disr);
659
660 __raw_writel(disr, DMA_BASE + DMA_DISR);
661 for (i = 0; i < IMX_DMA_CHANNELS; i++) {
662 if (disr & (1 << i))
663 dma_irq_handle_channel(i);
664 }
665
666 return IRQ_HANDLED;
667}
668
669/**
670 * imx_dma_request - request/allocate specified channel number
671 * @channel: i.MX DMA channel number
672 * @name: the driver/caller own non-%NULL identification
673 */
674int imx_dma_request(int channel, const char *name)
675{
676 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
677 unsigned long flags;
678 int ret;
679
680 /* basic sanity checks */
681 if (!name)
682 return -EINVAL;
683
684 if (channel >= IMX_DMA_CHANNELS) {
685 printk(KERN_CRIT "%s: called for non-existed channel %d\n",
686 __func__, channel);
687 return -EINVAL;
688 }
689
690 local_irq_save(flags);
691 if (imxdma->name) {
692 local_irq_restore(flags);
693 return -EBUSY;
694 }
695
696#ifdef CONFIG_ARCH_MX2
697 ret = request_irq(MXC_INT_DMACH0 + channel, dma_irq_handler, 0, "DMA",
698 NULL);
699 if (ret) {
700 printk(KERN_CRIT "Can't register IRQ %d for DMA channel %d\n",
701 MXC_INT_DMACH0 + channel, channel);
702 return ret;
703 }
704 init_timer(&imxdma->watchdog);
705 imxdma->watchdog.function = &imx_dma_watchdog;
706 imxdma->watchdog.data = channel;
707#endif
708
709 imxdma->name = name;
710 imxdma->irq_handler = NULL;
711 imxdma->err_handler = NULL;
712 imxdma->data = NULL;
713 imxdma->sg = NULL;
714
715 local_irq_restore(flags);
716 return 0;
717}
718EXPORT_SYMBOL(imx_dma_request);
719
720/**
721 * imx_dma_free - release previously acquired channel
722 * @channel: i.MX DMA channel number
723 */
724void imx_dma_free(int channel)
725{
726 unsigned long flags;
727 struct imx_dma_channel *imxdma = &imx_dma_channels[channel];
728
729 if (!imxdma->name) {
730 printk(KERN_CRIT
731 "%s: trying to free free channel %d\n",
732 __func__, channel);
733 return;
734 }
735
736 local_irq_save(flags);
737 /* Disable interrupts */
738 __raw_writel(__raw_readl(DMA_BASE + DMA_DIMR) | (1 << channel),
739 DMA_BASE + DMA_DIMR);
740 __raw_writel(__raw_readl(DMA_BASE + DMA_CCR(channel)) & ~CCR_CEN,
741 DMA_BASE + DMA_CCR(channel));
742 imxdma->name = NULL;
743
744#ifdef CONFIG_ARCH_MX2
745 free_irq(MXC_INT_DMACH0 + channel, NULL);
746#endif
747
748 local_irq_restore(flags);
749}
750EXPORT_SYMBOL(imx_dma_free);
751
752/**
753 * imx_dma_request_by_prio - find and request some of free channels best
754 * suiting requested priority
755 * @channel: i.MX DMA channel number
756 * @name: the driver/caller own non-%NULL identification
757 *
758 * This function tries to find a free channel in the specified priority group
759 * This function tries to find a free channel in the specified priority group
760 * if the priority cannot be achieved it tries to look for free channel
761 * in the higher and then even lower priority groups.
762 *
763 * Return value: If there is no free channel to allocate, -%ENODEV is returned.
764 * On successful allocation channel is returned.
765 */
766int imx_dma_request_by_prio(const char *name, enum imx_dma_prio prio)
767{
768 int i;
769 int best;
770
771 switch (prio) {
772 case (DMA_PRIO_HIGH):
773 best = 8;
774 break;
775 case (DMA_PRIO_MEDIUM):
776 best = 4;
777 break;
778 case (DMA_PRIO_LOW):
779 default:
780 best = 0;
781 break;
782 }
783
784 for (i = best; i < IMX_DMA_CHANNELS; i++)
785 if (!imx_dma_request(i, name))
786 return i;
787
788 for (i = best - 1; i >= 0; i--)
789 if (!imx_dma_request(i, name))
790 return i;
791
792 printk(KERN_ERR "%s: no free DMA channel found\n", __func__);
793
794 return -ENODEV;
795}
796EXPORT_SYMBOL(imx_dma_request_by_prio);
797
798static int __init imx_dma_init(void)
799{
800 int ret = 0;
801 int i;
802
803 dma_clk = clk_get(NULL, "dma_clk");
804 clk_enable(dma_clk);
805
806 /* reset DMA module */
807 __raw_writel(DCR_DRST, DMA_BASE + DMA_DCR);
808
809#ifdef CONFIG_ARCH_MX1
810 ret = request_irq(DMA_INT, dma_irq_handler, 0, "DMA", NULL);
811 if (ret) {
812 printk(KERN_CRIT "Wow! Can't register IRQ for DMA\n");
813 return ret;
814 }
815
816 ret = request_irq(DMA_ERR, dma_err_handler, 0, "DMA", NULL);
817 if (ret) {
818 printk(KERN_CRIT "Wow! Can't register ERRIRQ for DMA\n");
819 free_irq(DMA_INT, NULL);
820 return ret;
821 }
822#endif
823 /* enable DMA module */
824 __raw_writel(DCR_DEN, DMA_BASE + DMA_DCR);
825
826 /* clear all interrupts */
827 __raw_writel((1 << IMX_DMA_CHANNELS) - 1, DMA_BASE + DMA_DISR);
828
829 /* disable interrupts */
830 __raw_writel((1 << IMX_DMA_CHANNELS) - 1, DMA_BASE + DMA_DIMR);
831
832 for (i = 0; i < IMX_DMA_CHANNELS; i++) {
833 imx_dma_channels[i].sg = NULL;
834 imx_dma_channels[i].dma_num = i;
835 }
836
837 return ret;
838}
839
840arch_initcall(imx_dma_init);
diff --git a/arch/arm/plat-mxc/include/mach/board-mx31ads.h b/arch/arm/plat-mxc/include/mach/board-mx31ads.h
index 1bc6fb0f9a83..745b48864f93 100644
--- a/arch/arm/plat-mxc/include/mach/board-mx31ads.h
+++ b/arch/arm/plat-mxc/include/mach/board-mx31ads.h
@@ -90,6 +90,9 @@
90#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS) 90#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS)
91#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4) 91#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4)
92 92
93#define MXC_EXP_IO_BASE (MXC_MAX_INT_LINES + MXC_MAX_GPIO_LINES)
94#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE)
95
93#define EXPIO_INT_LOW_BAT (MXC_EXP_IO_BASE + 0) 96#define EXPIO_INT_LOW_BAT (MXC_EXP_IO_BASE + 0)
94#define EXPIO_INT_PB_IRQ (MXC_EXP_IO_BASE + 1) 97#define EXPIO_INT_PB_IRQ (MXC_EXP_IO_BASE + 1)
95#define EXPIO_INT_OTG_FS_OVR (MXC_EXP_IO_BASE + 2) 98#define EXPIO_INT_OTG_FS_OVR (MXC_EXP_IO_BASE + 2)
diff --git a/arch/arm/plat-mxc/include/mach/clock.h b/arch/arm/plat-mxc/include/mach/clock.h
index 24caa2b7c91d..d21f78e78819 100644
--- a/arch/arm/plat-mxc/include/mach/clock.h
+++ b/arch/arm/plat-mxc/include/mach/clock.h
@@ -39,7 +39,7 @@ struct clk {
39 /* Register bit position for clock's enable/disable control. */ 39 /* Register bit position for clock's enable/disable control. */
40 u8 enable_shift; 40 u8 enable_shift;
41 /* Register address for clock's enable/disable control. */ 41 /* Register address for clock's enable/disable control. */
42 u32 enable_reg; 42 void __iomem *enable_reg;
43 u32 flags; 43 u32 flags;
44 /* get the current clock rate (always a fresh value) */ 44 /* get the current clock rate (always a fresh value) */
45 unsigned long (*get_rate) (struct clk *); 45 unsigned long (*get_rate) (struct clk *);
diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h
index a6d2e24aab15..6350287a59b9 100644
--- a/arch/arm/plat-mxc/include/mach/common.h
+++ b/arch/arm/plat-mxc/include/mach/common.h
@@ -11,10 +11,13 @@
11#ifndef __ASM_ARCH_MXC_COMMON_H__ 11#ifndef __ASM_ARCH_MXC_COMMON_H__
12#define __ASM_ARCH_MXC_COMMON_H__ 12#define __ASM_ARCH_MXC_COMMON_H__
13 13
14struct platform_device;
15
14extern void mxc_map_io(void); 16extern void mxc_map_io(void);
15extern void mxc_init_irq(void); 17extern void mxc_init_irq(void);
16extern void mxc_timer_init(const char *clk_timer); 18extern void mxc_timer_init(const char *clk_timer);
17extern int mxc_clocks_init(unsigned long fref); 19extern int mxc_clocks_init(unsigned long fref);
18extern int mxc_register_gpios(void); 20extern int mxc_register_gpios(void);
21extern int mxc_register_device(struct platform_device *pdev, void *data);
19 22
20#endif 23#endif
diff --git a/arch/arm/plat-mxc/include/mach/dma-mx1-mx2.h b/arch/arm/plat-mxc/include/mach/dma-mx1-mx2.h
new file mode 100644
index 000000000000..e85fd946116c
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/dma-mx1-mx2.h
@@ -0,0 +1,89 @@
1/*
2 * linux/arch/arm/plat-mxc/include/mach/dma-mx1-mx2.h
3 *
4 * i.MX DMA registration and IRQ dispatching
5 *
6 * Copyright 2006 Pavel Pisa <pisa@cmp.felk.cvut.cz>
7 * Copyright 2008 Juergen Beisert, <kernel@pengutronix.de>
8 * Copyright 2008 Sascha Hauer, <s.hauer@pengutronix.de>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301, USA.
23 */
24
25#include <asm/dma.h>
26
27#ifndef __ASM_ARCH_MXC_DMA_H
28#define __ASM_ARCH_MXC_DMA_H
29
30#define IMX_DMA_CHANNELS 16
31
32#define DMA_BASE IO_ADDRESS(DMA_BASE_ADDR)
33
34#define IMX_DMA_MEMSIZE_32 (0 << 4)
35#define IMX_DMA_MEMSIZE_8 (1 << 4)
36#define IMX_DMA_MEMSIZE_16 (2 << 4)
37#define IMX_DMA_TYPE_LINEAR (0 << 10)
38#define IMX_DMA_TYPE_2D (1 << 10)
39#define IMX_DMA_TYPE_FIFO (2 << 10)
40
41#define IMX_DMA_ERR_BURST (1 << 0)
42#define IMX_DMA_ERR_REQUEST (1 << 1)
43#define IMX_DMA_ERR_TRANSFER (1 << 2)
44#define IMX_DMA_ERR_BUFFER (1 << 3)
45#define IMX_DMA_ERR_TIMEOUT (1 << 4)
46
47int
48imx_dma_config_channel(int channel, unsigned int config_port,
49 unsigned int config_mem, unsigned int dmareq, int hw_chaining);
50
51void
52imx_dma_config_burstlen(int channel, unsigned int burstlen);
53
54int
55imx_dma_setup_single(int channel, dma_addr_t dma_address,
56 unsigned int dma_length, unsigned int dev_addr,
57 dmamode_t dmamode);
58
59int
60imx_dma_setup_sg(int channel, struct scatterlist *sg,
61 unsigned int sgcount, unsigned int dma_length,
62 unsigned int dev_addr, dmamode_t dmamode);
63
64int
65imx_dma_setup_handlers(int channel,
66 void (*irq_handler) (int, void *),
67 void (*err_handler) (int, void *, int), void *data);
68
69int
70imx_dma_setup_progression_handler(int channel,
71 void (*prog_handler) (int, void*, struct scatterlist*));
72
73void imx_dma_enable(int channel);
74
75void imx_dma_disable(int channel);
76
77int imx_dma_request(int channel, const char *name);
78
79void imx_dma_free(int channel);
80
81enum imx_dma_prio {
82 DMA_PRIO_HIGH = 0,
83 DMA_PRIO_MEDIUM = 1,
84 DMA_PRIO_LOW = 2
85};
86
87int imx_dma_request_by_prio(const char *name, enum imx_dma_prio prio);
88
89#endif /* _ASM_ARCH_MXC_DMA_H */
diff --git a/arch/arm/plat-mxc/include/mach/entry-macro.S b/arch/arm/plat-mxc/include/mach/entry-macro.S
index b542433afb1b..11632028f7d1 100644
--- a/arch/arm/plat-mxc/include/mach/entry-macro.S
+++ b/arch/arm/plat-mxc/include/mach/entry-macro.S
@@ -9,11 +9,17 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#define AVIC_NIMASK 0x04
13
12 @ this macro disables fast irq (not implemented) 14 @ this macro disables fast irq (not implemented)
13 .macro disable_fiq 15 .macro disable_fiq
14 .endm 16 .endm
15 17
16 .macro get_irqnr_preamble, base, tmp 18 .macro get_irqnr_preamble, base, tmp
19 ldr \base, =AVIC_IO_ADDRESS(AVIC_BASE_ADDR)
20#ifdef CONFIG_MXC_IRQ_PRIOR
21 ldr r4, [\base, #AVIC_NIMASK]
22#endif
17 .endm 23 .endm
18 24
19 .macro arch_ret_to_user, tmp1, tmp2 25 .macro arch_ret_to_user, tmp1, tmp2
@@ -23,7 +29,6 @@
23 @ and returns its number in irqnr 29 @ and returns its number in irqnr
24 @ and returns if an interrupt occured in irqstat 30 @ and returns if an interrupt occured in irqstat
25 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 31 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
26 ldr \base, =AVIC_IO_ADDRESS(AVIC_BASE_ADDR)
27 @ Load offset & priority of the highest priority 32 @ Load offset & priority of the highest priority
28 @ interrupt pending from AVIC_NIVECSR 33 @ interrupt pending from AVIC_NIVECSR
29 ldr \irqstat, [\base, #0x40] 34 ldr \irqstat, [\base, #0x40]
@@ -32,6 +37,11 @@
32 mov \irqnr, \irqstat, asr #16 37 mov \irqnr, \irqstat, asr #16
33 @ set zero flag if IRQ + 1 == 0 38 @ set zero flag if IRQ + 1 == 0
34 adds \tmp, \irqnr, #1 39 adds \tmp, \irqnr, #1
40#ifdef CONFIG_MXC_IRQ_PRIOR
41 bicne \tmp, \irqstat, #0xFFFFFFE0
42 strne \tmp, [\base, #AVIC_NIMASK]
43 streq r4, [\base, #AVIC_NIMASK]
44#endif
35 .endm 45 .endm
36 46
37 @ irq priority table (not used) 47 @ irq priority table (not used)
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h b/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h
index 076d37b38eb2..3d09bfd6c53d 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx1-mx2.h
@@ -247,6 +247,11 @@ extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
247#endif 247#endif
248 248
249#ifdef CONFIG_ARCH_MX2 249#ifdef CONFIG_ARCH_MX2
250#define PA0_PF_USBH2_CLK (GPIO_PORTA | GPIO_PF | 0)
251#define PA1_PF_USBH2_DIR (GPIO_PORTA | GPIO_PF | 1)
252#define PA2_PF_USBH2_DATA7 (GPIO_PORTA | GPIO_PF | 2)
253#define PA3_PF_USBH2_NXT (GPIO_PORTA | GPIO_PF | 3)
254#define PA4_PF_USBH2_STP (GPIO_PORTA | GPIO_PF | 4)
250#define PA5_PF_LSCLK (GPIO_PORTA | GPIO_OUT | GPIO_PF | 5) 255#define PA5_PF_LSCLK (GPIO_PORTA | GPIO_OUT | GPIO_PF | 5)
251#define PA6_PF_LD0 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 6) 256#define PA6_PF_LD0 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 6)
252#define PA7_PF_LD1 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 7) 257#define PA7_PF_LD1 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 7)
@@ -294,6 +299,16 @@ extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
294#define PB20_AF_UART5_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 20) 299#define PB20_AF_UART5_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 20)
295#define PB21_PF_CSI_HSYNC (GPIO_PORTB | GPIO_OUT | GPIO_PF | 21) 300#define PB21_PF_CSI_HSYNC (GPIO_PORTB | GPIO_OUT | GPIO_PF | 21)
296#define PB21_AF_UART5_RTS (GPIO_PORTB | GPIO_IN | GPIO_AF | 21) 301#define PB21_AF_UART5_RTS (GPIO_PORTB | GPIO_IN | GPIO_AF | 21)
302#define PB22_PF_USBH1_SUSP (GPIO_PORTB | GPIO_PF | 22)
303#define PB23_PF_USB_PWR (GPIO_PORTB | GPIO_PF | 23)
304#define PB24_PF_USB_OC_B (GPIO_PORTB | GPIO_PF | 24)
305#define PB25_PF_USBH1_RCV (GPIO_PORTB | GPIO_PF | 25)
306#define PB26_PF_USBH1_FS (GPIO_PORTB | GPIO_PF | 26)
307#define PB27_PF_USBH1_OE_B (GPIO_PORTB | GPIO_PF | 27)
308#define PB28_PF_USBH1_TXDM (GPIO_PORTB | GPIO_PF | 28)
309#define PB29_PF_USBH1_TXDP (GPIO_PORTB | GPIO_PF | 29)
310#define PB30_PF_USBH1_RXDM (GPIO_PORTB | GPIO_PF | 30)
311#define PB31_PF_USBH1_RXDP (GPIO_PORTB | GPIO_PF | 31)
297#define PB26_AF_UART4_RTS (GPIO_PORTB | GPIO_IN | GPIO_PF | 26) 312#define PB26_AF_UART4_RTS (GPIO_PORTB | GPIO_IN | GPIO_PF | 26)
298#define PB28_AF_UART4_TXD (GPIO_PORTB | GPIO_OUT | GPIO_AF | 28) 313#define PB28_AF_UART4_TXD (GPIO_PORTB | GPIO_OUT | GPIO_AF | 28)
299#define PB29_AF_UART4_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 29) 314#define PB29_AF_UART4_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 29)
@@ -335,8 +350,15 @@ extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
335#define PD16_AIN_FEC_TX_ER (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 16) 350#define PD16_AIN_FEC_TX_ER (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 16)
336#define PD17_PF_I2C_DATA (GPIO_PORTD | GPIO_OUT | GPIO_PF | 17) 351#define PD17_PF_I2C_DATA (GPIO_PORTD | GPIO_OUT | GPIO_PF | 17)
337#define PD18_PF_I2C_CLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 18) 352#define PD18_PF_I2C_CLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 18)
353#define PD19_AF_USBH2_DATA4 (GPIO_PORTD | GPIO_AF | 19)
354#define PD20_AF_USBH2_DATA3 (GPIO_PORTD | GPIO_AF | 20)
355#define PD21_AF_USBH2_DATA6 (GPIO_PORTD | GPIO_AF | 21)
356#define PD22_AF_USBH2_DATA0 (GPIO_PORTD | GPIO_AF | 22)
357#define PD23_AF_USBH2_DATA2 (GPIO_PORTD | GPIO_AF | 23)
358#define PD24_AF_USBH2_DATA1 (GPIO_PORTD | GPIO_AF | 24)
338#define PD25_PF_CSPI1_RDY (GPIO_PORTD | GPIO_OUT | GPIO_PF | 25) 359#define PD25_PF_CSPI1_RDY (GPIO_PORTD | GPIO_OUT | GPIO_PF | 25)
339#define PD26_PF_CSPI1_SS2 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 26) 360#define PD26_PF_CSPI1_SS2 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 26)
361#define PD26_AF_USBH2_DATA5 (GPIO_PORTD | GPIO_AF | 26)
340#define PD27_PF_CSPI1_SS1 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 27) 362#define PD27_PF_CSPI1_SS1 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 27)
341#define PD28_PF_CSPI1_SS0 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 28) 363#define PD28_PF_CSPI1_SS0 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 28)
342#define PD29_PF_CSPI1_SCLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 29) 364#define PD29_PF_CSPI1_SCLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 29)
@@ -355,6 +377,8 @@ extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
355#define PE13_PF_UART1_RXD (GPIO_PORTE | GPIO_IN | GPIO_PF | 13) 377#define PE13_PF_UART1_RXD (GPIO_PORTE | GPIO_IN | GPIO_PF | 13)
356#define PE14_PF_UART1_CTS (GPIO_PORTE | GPIO_OUT | GPIO_PF | 14) 378#define PE14_PF_UART1_CTS (GPIO_PORTE | GPIO_OUT | GPIO_PF | 14)
357#define PE15_PF_UART1_RTS (GPIO_PORTE | GPIO_IN | GPIO_PF | 15) 379#define PE15_PF_UART1_RTS (GPIO_PORTE | GPIO_IN | GPIO_PF | 15)
380#define PE16_AF_RTCK (GPIO_PORTE | GPIO_OUT | GPIO_AF | 16)
381#define PE16_PF_RTCK (GPIO_PORTE | GPIO_OUT | GPIO_PF | 16)
358#define PE18_AF_CSPI3_MISO (GPIO_PORTE | GPIO_IN | GPIO_AF | 18) 382#define PE18_AF_CSPI3_MISO (GPIO_PORTE | GPIO_IN | GPIO_AF | 18)
359#define PE21_AF_CSPI3_SS (GPIO_PORTE | GPIO_OUT | GPIO_AF | 21) 383#define PE21_AF_CSPI3_SS (GPIO_PORTE | GPIO_OUT | GPIO_AF | 21)
360#define PE22_AF_CSPI3_MOSI (GPIO_PORTE | GPIO_OUT | GPIO_AF | 22) 384#define PE22_AF_CSPI3_MOSI (GPIO_PORTE | GPIO_OUT | GPIO_AF | 22)
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx3.h b/arch/arm/plat-mxc/include/mach/iomux-mx3.h
index 7509e7692f08..c9f39c2fb8c6 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx3.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx3.h
@@ -491,6 +491,26 @@ enum iomux_pins {
491#define MX31_PIN_RTS1__RTS1 IOMUX_MODE(MX31_PIN_RTS1, IOMUX_CONFIG_FUNC) 491#define MX31_PIN_RTS1__RTS1 IOMUX_MODE(MX31_PIN_RTS1, IOMUX_CONFIG_FUNC)
492#define MX31_PIN_TXD1__TXD1 IOMUX_MODE(MX31_PIN_TXD1, IOMUX_CONFIG_FUNC) 492#define MX31_PIN_TXD1__TXD1 IOMUX_MODE(MX31_PIN_TXD1, IOMUX_CONFIG_FUNC)
493#define MX31_PIN_RXD1__RXD1 IOMUX_MODE(MX31_PIN_RXD1, IOMUX_CONFIG_FUNC) 493#define MX31_PIN_RXD1__RXD1 IOMUX_MODE(MX31_PIN_RXD1, IOMUX_CONFIG_FUNC)
494#define MX31_PIN_CSPI1_MOSI__MOSI IOMUX_MODE(MX31_PIN_CSPI1_MOSI, IOMUX_CONFIG_FUNC)
495#define MX31_PIN_CSPI1_MISO__MISO IOMUX_MODE(MX31_PIN_CSPI1_MISO, IOMUX_CONFIG_FUNC)
496#define MX31_PIN_CSPI1_SCLK__SCLK IOMUX_MODE(MX31_PIN_CSPI1_SCLK, IOMUX_CONFIG_FUNC)
497#define MX31_PIN_CSPI1_SPI_RDY__SPI_RDY IOMUX_MODE(MX31_PIN_CSPI1_SPI_RDY, IOMUX_CONFIG_FUNC)
498#define MX31_PIN_CSPI1_SS0__SS0 IOMUX_MODE(MX31_PIN_CSPI1_SS0, IOMUX_CONFIG_FUNC)
499#define MX31_PIN_CSPI1_SS1__SS1 IOMUX_MODE(MX31_PIN_CSPI1_SS1, IOMUX_CONFIG_FUNC)
500#define MX31_PIN_CSPI1_SS2__SS2 IOMUX_MODE(MX31_PIN_CSPI1_SS2, IOMUX_CONFIG_FUNC)
501#define MX31_PIN_CSPI2_MOSI__MOSI IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_FUNC)
502#define MX31_PIN_CSPI2_MISO__MISO IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_FUNC)
503#define MX31_PIN_CSPI2_SCLK__SCLK IOMUX_MODE(MX31_PIN_CSPI2_SCLK, IOMUX_CONFIG_FUNC)
504#define MX31_PIN_CSPI2_SPI_RDY__SPI_RDY IOMUX_MODE(MX31_PIN_CSPI2_SPI_RDY, IOMUX_CONFIG_FUNC)
505#define MX31_PIN_CSPI2_SS0__SS0 IOMUX_MODE(MX31_PIN_CSPI2_SS0, IOMUX_CONFIG_FUNC)
506#define MX31_PIN_CSPI2_SS1__SS1 IOMUX_MODE(MX31_PIN_CSPI2_SS1, IOMUX_CONFIG_FUNC)
507#define MX31_PIN_CSPI2_SS2__SS2 IOMUX_MODE(MX31_PIN_CSPI2_SS2, IOMUX_CONFIG_FUNC)
508#define MX31_PIN_CSPI3_MOSI__MOSI IOMUX_MODE(MX31_PIN_CSPI3_MOSI, IOMUX_CONFIG_FUNC)
509#define MX31_PIN_CSPI3_MISO__MISO IOMUX_MODE(MX31_PIN_CSPI3_MISO, IOMUX_CONFIG_FUNC)
510#define MX31_PIN_CSPI3_SCLK__SCLK IOMUX_MODE(MX31_PIN_CSPI3_SCLK, IOMUX_CONFIG_FUNC)
511#define MX31_PIN_CSPI3_SPI_RDY__SPI_RDY IOMUX_MODE(MX31_PIN_CSPI3_SPI_RDY, IOMUX_CONFIG_FUNC)
512/*XXX: The SS0, SS1, SS2, SS3 lines of spi3 are multiplexed by cspi2_ss0, cspi2_ss1, cspi1_ss0
513 * cspi1_ss1*/
494 514
495/* 515/*
496 * This function configures the pad value for a IOMUX pin. 516 * This function configures the pad value for a IOMUX pin.
diff --git a/arch/arm/plat-mxc/include/mach/irqs.h b/arch/arm/plat-mxc/include/mach/irqs.h
index 228c4f68ccdf..b55bba35e18a 100644
--- a/arch/arm/plat-mxc/include/mach/irqs.h
+++ b/arch/arm/plat-mxc/include/mach/irqs.h
@@ -12,5 +12,6 @@
12#define __ASM_ARCH_MXC_IRQS_H__ 12#define __ASM_ARCH_MXC_IRQS_H__
13 13
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15extern void imx_irq_set_priority(unsigned char irq, unsigned char prio);
15 16
16#endif /* __ASM_ARCH_MXC_IRQS_H__ */ 17#endif /* __ASM_ARCH_MXC_IRQS_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx27.h b/arch/arm/plat-mxc/include/mach/mx27.h
index 212ecc246626..a86db64744a1 100644
--- a/arch/arm/plat-mxc/include/mach/mx27.h
+++ b/arch/arm/plat-mxc/include/mach/mx27.h
@@ -128,6 +128,7 @@
128 * it returns 0xDEADBEEF 128 * it returns 0xDEADBEEF
129 */ 129 */
130#define IO_ADDRESS(x) \ 130#define IO_ADDRESS(x) \
131 (void __iomem *) \
131 (((x >= AIPI_BASE_ADDR) && (x < (AIPI_BASE_ADDR + AIPI_SIZE))) ? \ 132 (((x >= AIPI_BASE_ADDR) && (x < (AIPI_BASE_ADDR + AIPI_SIZE))) ? \
132 AIPI_IO_ADDRESS(x) : \ 133 AIPI_IO_ADDRESS(x) : \
133 ((x >= SAHB1_BASE_ADDR) && (x < (SAHB1_BASE_ADDR + SAHB1_SIZE))) ? \ 134 ((x >= SAHB1_BASE_ADDR) && (x < (SAHB1_BASE_ADDR + SAHB1_SIZE))) ? \
diff --git a/arch/arm/plat-mxc/include/mach/mx31.h b/arch/arm/plat-mxc/include/mach/mx31.h
index a7373e4a56cb..0536f8917bc0 100644
--- a/arch/arm/plat-mxc/include/mach/mx31.h
+++ b/arch/arm/plat-mxc/include/mach/mx31.h
@@ -198,6 +198,7 @@
198 * it returns 0xDEADBEEF 198 * it returns 0xDEADBEEF
199 */ 199 */
200#define IO_ADDRESS(x) \ 200#define IO_ADDRESS(x) \
201 (void __iomem *) \
201 (((x >= IRAM_BASE_ADDR) && (x < (IRAM_BASE_ADDR + IRAM_SIZE))) ? IRAM_IO_ADDRESS(x):\ 202 (((x >= IRAM_BASE_ADDR) && (x < (IRAM_BASE_ADDR + IRAM_SIZE))) ? IRAM_IO_ADDRESS(x):\
202 ((x >= L2CC_BASE_ADDR) && (x < (L2CC_BASE_ADDR + L2CC_SIZE))) ? L2CC_IO_ADDRESS(x):\ 203 ((x >= L2CC_BASE_ADDR) && (x < (L2CC_BASE_ADDR + L2CC_SIZE))) ? L2CC_IO_ADDRESS(x):\
203 ((x >= AIPS1_BASE_ADDR) && (x < (AIPS1_BASE_ADDR + AIPS1_SIZE))) ? AIPS1_IO_ADDRESS(x):\ 204 ((x >= AIPS1_BASE_ADDR) && (x < (AIPS1_BASE_ADDR + AIPS1_SIZE))) ? AIPS1_IO_ADDRESS(x):\
diff --git a/arch/arm/plat-mxc/include/mach/mxc.h b/arch/arm/plat-mxc/include/mach/mxc.h
index 332eda4dbd3b..f6caab062131 100644
--- a/arch/arm/plat-mxc/include/mach/mxc.h
+++ b/arch/arm/plat-mxc/include/mach/mxc.h
@@ -33,4 +33,10 @@
33# define cpu_is_mx27() (0) 33# define cpu_is_mx27() (0)
34#endif 34#endif
35 35
36#if defined(CONFIG_ARCH_MX3) || defined(CONFIG_ARCH_MX2)
37#define CSCR_U(n) (IO_ADDRESS(WEIM_BASE_ADDR) + n * 0x10)
38#define CSCR_L(n) (IO_ADDRESS(WEIM_BASE_ADDR) + n * 0x10 + 0x4)
39#define CSCR_A(n) (IO_ADDRESS(WEIM_BASE_ADDR) + n * 0x10 + 0x8)
40#endif
41
36#endif /* __ASM_ARCH_MXC_H__ */ 42#endif /* __ASM_ARCH_MXC_H__ */
diff --git a/arch/arm/plat-mxc/irq.c b/arch/arm/plat-mxc/irq.c
index 1053b666c676..d862c9e5f8db 100644
--- a/arch/arm/plat-mxc/irq.c
+++ b/arch/arm/plat-mxc/irq.c
@@ -18,7 +18,7 @@
18 */ 18 */
19 19
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <asm/io.h> 21#include <linux/io.h>
22#include <mach/common.h> 22#include <mach/common.h>
23 23
24#define AVIC_BASE IO_ADDRESS(AVIC_BASE_ADDR) 24#define AVIC_BASE IO_ADDRESS(AVIC_BASE_ADDR)
@@ -30,14 +30,7 @@
30#define AVIC_INTENABLEL (AVIC_BASE + 0x14) /* int enable reg low */ 30#define AVIC_INTENABLEL (AVIC_BASE + 0x14) /* int enable reg low */
31#define AVIC_INTTYPEH (AVIC_BASE + 0x18) /* int type reg high */ 31#define AVIC_INTTYPEH (AVIC_BASE + 0x18) /* int type reg high */
32#define AVIC_INTTYPEL (AVIC_BASE + 0x1C) /* int type reg low */ 32#define AVIC_INTTYPEL (AVIC_BASE + 0x1C) /* int type reg low */
33#define AVIC_NIPRIORITY7 (AVIC_BASE + 0x20) /* norm int priority lvl7 */ 33#define AVIC_NIPRIORITY(x) (AVIC_BASE + (0x20 + 4 * (7 - (x)))) /* int priority */
34#define AVIC_NIPRIORITY6 (AVIC_BASE + 0x24) /* norm int priority lvl6 */
35#define AVIC_NIPRIORITY5 (AVIC_BASE + 0x28) /* norm int priority lvl5 */
36#define AVIC_NIPRIORITY4 (AVIC_BASE + 0x2C) /* norm int priority lvl4 */
37#define AVIC_NIPRIORITY3 (AVIC_BASE + 0x30) /* norm int priority lvl3 */
38#define AVIC_NIPRIORITY2 (AVIC_BASE + 0x34) /* norm int priority lvl2 */
39#define AVIC_NIPRIORITY1 (AVIC_BASE + 0x38) /* norm int priority lvl1 */
40#define AVIC_NIPRIORITY0 (AVIC_BASE + 0x3C) /* norm int priority lvl0 */
41#define AVIC_NIVECSR (AVIC_BASE + 0x40) /* norm int vector/status */ 34#define AVIC_NIVECSR (AVIC_BASE + 0x40) /* norm int vector/status */
42#define AVIC_FIVECSR (AVIC_BASE + 0x44) /* fast int vector/status */ 35#define AVIC_FIVECSR (AVIC_BASE + 0x44) /* fast int vector/status */
43#define AVIC_INTSRCH (AVIC_BASE + 0x48) /* int source reg high */ 36#define AVIC_INTSRCH (AVIC_BASE + 0x48) /* int source reg high */
@@ -54,6 +47,24 @@
54#define IIM_PROD_REV_SH 3 47#define IIM_PROD_REV_SH 3
55#define IIM_PROD_REV_LEN 5 48#define IIM_PROD_REV_LEN 5
56 49
50#ifdef CONFIG_MXC_IRQ_PRIOR
51void imx_irq_set_priority(unsigned char irq, unsigned char prio)
52{
53 unsigned int temp;
54 unsigned int mask = 0x0F << irq % 8 * 4;
55
56 if (irq > 63)
57 return;
58
59 temp = __raw_readl(AVIC_NIPRIORITY(irq / 8));
60 temp &= ~mask;
61 temp |= prio & mask;
62
63 __raw_writel(temp, AVIC_NIPRIORITY(irq / 8));
64}
65EXPORT_SYMBOL(imx_irq_set_priority);
66#endif
67
57/* Disable interrupt number "irq" in the AVIC */ 68/* Disable interrupt number "irq" in the AVIC */
58static void mxc_mask_irq(unsigned int irq) 69static void mxc_mask_irq(unsigned int irq)
59{ 70{
@@ -101,10 +112,9 @@ void __init mxc_init_irq(void)
101 set_irq_flags(i, IRQF_VALID); 112 set_irq_flags(i, IRQF_VALID);
102 } 113 }
103 114
104 /* Set WDOG2's interrupt the highest priority level (bit 28-31) */ 115 /* Set default priority value (0) for all IRQ's */
105 reg = __raw_readl(AVIC_NIPRIORITY6); 116 for (i = 0; i < 8; i++)
106 reg |= (0xF << 28); 117 __raw_writel(0, AVIC_NIPRIORITY(i));
107 __raw_writel(reg, AVIC_NIPRIORITY6);
108 118
109 /* init architectures chained interrupt handler */ 119 /* init architectures chained interrupt handler */
110 mxc_register_gpios(); 120 mxc_register_gpios();
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 197974defbe4..bf6a10c5fc4f 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -22,8 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/cpufreq.h> 23#include <linux/cpufreq.h>
24#include <linux/debugfs.h> 24#include <linux/debugfs.h>
25 25#include <linux/io.h>
26#include <asm/io.h>
27 26
28#include <mach/clock.h> 27#include <mach/clock.h>
29 28
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index f4dff423ae7c..8bdf0ead0cf3 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -18,12 +18,12 @@
18#include <linux/serial_8250.h> 18#include <linux/serial_8250.h>
19#include <linux/serial_reg.h> 19#include <linux/serial_reg.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/io.h>
21 22
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <asm/system.h> 24#include <asm/system.h>
24#include <asm/pgtable.h> 25#include <asm/pgtable.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
26#include <asm/io.h>
27#include <asm/setup.h> 27#include <asm/setup.h>
28 28
29#include <mach/common.h> 29#include <mach/common.h>
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index ae1de308aaad..b2690242a390 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -20,9 +20,9 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/io.h>
23 24
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/io.h>
26#include <asm/system.h> 26#include <asm/system.h>
27 27
28#define VERY_HI_RATE 900000000 28#define VERY_HI_RATE 900000000
diff --git a/arch/arm/plat-omap/debug-devices.c b/arch/arm/plat-omap/debug-devices.c
index 5b73bb274452..e31154b15d9e 100644
--- a/arch/arm/plat-omap/debug-devices.c
+++ b/arch/arm/plat-omap/debug-devices.c
@@ -12,9 +12,9 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/io.h>
15 16
16#include <mach/hardware.h> 17#include <mach/hardware.h>
17#include <asm/io.h>
18 18
19#include <mach/board.h> 19#include <mach/board.h>
20#include <mach/gpio.h> 20#include <mach/gpio.h>
diff --git a/arch/arm/plat-omap/debug-leds.c b/arch/arm/plat-omap/debug-leds.c
index 9422dee7de84..2f4c0cabfd34 100644
--- a/arch/arm/plat-omap/debug-leds.c
+++ b/arch/arm/plat-omap/debug-leds.c
@@ -11,8 +11,8 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/leds.h> 13#include <linux/leds.h>
14#include <linux/io.h>
14 15
15#include <asm/io.h>
16#include <mach/hardware.h> 16#include <mach/hardware.h>
17#include <asm/leds.h> 17#include <asm/leds.h>
18#include <asm/system.h> 18#include <asm/system.h>
diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c
index 01da719a7453..97187fa0ae52 100644
--- a/arch/arm/plat-omap/devices.c
+++ b/arch/arm/plat-omap/devices.c
@@ -13,9 +13,9 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h>
16 17
17#include <mach/hardware.h> 18#include <mach/hardware.h>
18#include <asm/io.h>
19#include <asm/mach-types.h> 19#include <asm/mach-types.h>
20#include <asm/mach/map.h> 20#include <asm/mach/map.h>
21 21
@@ -441,16 +441,8 @@ static inline void omap_init_uwire(void) {}
441 441
442#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE) 442#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
443 443
444#ifdef CONFIG_ARCH_OMAP24XX
445#define OMAP_WDT_BASE 0x48022000
446#else
447#define OMAP_WDT_BASE 0xfffeb000
448#endif
449
450static struct resource wdt_resources[] = { 444static struct resource wdt_resources[] = {
451 { 445 {
452 .start = OMAP_WDT_BASE,
453 .end = OMAP_WDT_BASE + 0x4f,
454 .flags = IORESOURCE_MEM, 446 .flags = IORESOURCE_MEM,
455 }, 447 },
456}; 448};
@@ -464,6 +456,19 @@ static struct platform_device omap_wdt_device = {
464 456
465static void omap_init_wdt(void) 457static void omap_init_wdt(void)
466{ 458{
459 if (cpu_is_omap16xx())
460 wdt_resources[0].start = 0xfffeb000;
461 else if (cpu_is_omap2420())
462 wdt_resources[0].start = 0x48022000; /* WDT2 */
463 else if (cpu_is_omap2430())
464 wdt_resources[0].start = 0x49016000; /* WDT2 */
465 else if (cpu_is_omap343x())
466 wdt_resources[0].start = 0x48314000; /* WDT2 */
467 else
468 return;
469
470 wdt_resources[0].end = wdt_resources[0].start + 0x4f;
471
467 (void) platform_device_register(&omap_wdt_device); 472 (void) platform_device_register(&omap_wdt_device);
468} 473}
469#else 474#else
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 743a4abcd85d..606fcffdcefc 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -32,9 +32,9 @@
32#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/clk.h> 33#include <linux/clk.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/io.h>
35#include <mach/hardware.h> 36#include <mach/hardware.h>
36#include <mach/dmtimer.h> 37#include <mach/dmtimer.h>
37#include <asm/io.h>
38#include <mach/irqs.h> 38#include <mach/irqs.h>
39 39
40/* register offsets */ 40/* register offsets */
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 17a92a31e746..ce6b4baeedec 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -27,9 +27,9 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/bootmem.h> 29#include <linux/bootmem.h>
30#include <linux/io.h>
30 31
31#include <mach/hardware.h> 32#include <mach/hardware.h>
32#include <asm/io.h>
33#include <asm/mach/map.h> 33#include <asm/mach/map.h>
34 34
35#include <mach/board.h> 35#include <mach/board.h>
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 9e1341ebc14e..5935ae4e550b 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -17,6 +17,7 @@
17#include <linux/sysdev.h> 17#include <linux/sysdev.h>
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/io.h>
20 21
21#include <mach/hardware.h> 22#include <mach/hardware.h>
22#include <asm/irq.h> 23#include <asm/irq.h>
@@ -24,8 +25,6 @@
24#include <mach/gpio.h> 25#include <mach/gpio.h>
25#include <asm/mach/irq.h> 26#include <asm/mach/irq.h>
26 27
27#include <asm/io.h>
28
29/* 28/*
30 * OMAP1510 GPIO registers 29 * OMAP1510 GPIO registers
31 */ 30 */
@@ -1051,13 +1050,10 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
1051 1050
1052 gpio_irq = bank->virtual_irq_start; 1051 gpio_irq = bank->virtual_irq_start;
1053 for (; isr != 0; isr >>= 1, gpio_irq++) { 1052 for (; isr != 0; isr >>= 1, gpio_irq++) {
1054 struct irq_desc *d;
1055
1056 if (!(isr & 1)) 1053 if (!(isr & 1))
1057 continue; 1054 continue;
1058 d = irq_desc + gpio_irq;
1059 1055
1060 desc_handle_irq(gpio_irq, d); 1056 generic_handle_irq(gpio_irq);
1061 } 1057 }
1062 } 1058 }
1063 /* if bank has any level sensitive GPIO pin interrupt 1059 /* if bank has any level sensitive GPIO pin interrupt
diff --git a/arch/arm/plat-omap/include/mach/gpio.h b/arch/arm/plat-omap/include/mach/gpio.h
index 94ce2780e8ee..8c71e288860f 100644
--- a/arch/arm/plat-omap/include/mach/gpio.h
+++ b/arch/arm/plat-omap/include/mach/gpio.h
@@ -26,8 +26,8 @@
26#ifndef __ASM_ARCH_OMAP_GPIO_H 26#ifndef __ASM_ARCH_OMAP_GPIO_H
27#define __ASM_ARCH_OMAP_GPIO_H 27#define __ASM_ARCH_OMAP_GPIO_H
28 28
29#include <linux/io.h>
29#include <mach/irqs.h> 30#include <mach/irqs.h>
30#include <asm/io.h>
31 31
32#define OMAP_MPUIO_BASE (void __iomem *)0xfffb5000 32#define OMAP_MPUIO_BASE (void __iomem *)0xfffb5000
33 33
diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-omap/include/mach/irqs.h
index 17248bbf3f27..62aa7dfb9464 100644
--- a/arch/arm/plat-omap/include/mach/irqs.h
+++ b/arch/arm/plat-omap/include/mach/irqs.h
@@ -280,6 +280,8 @@
280#define INT_24XX_USB_IRQ_OTG 80 280#define INT_24XX_USB_IRQ_OTG 80
281#define INT_24XX_MMC_IRQ 83 281#define INT_24XX_MMC_IRQ 83
282 282
283#define INT_34XX_BENCH_MPU_EMUL 3
284
283/* Max. 128 level 2 IRQs (OMAP1610), 192 GPIOs (OMAP730) and 285/* Max. 128 level 2 IRQs (OMAP1610), 192 GPIOs (OMAP730) and
284 * 16 MPUIO lines */ 286 * 16 MPUIO lines */
285#define OMAP_MAX_GPIO_LINES 192 287#define OMAP_MAX_GPIO_LINES 192
diff --git a/arch/arm/plat-omap/include/mach/mtd-xip.h b/arch/arm/plat-omap/include/mach/mtd-xip.h
index 5cee7e16a1b4..39b591ff54bb 100644
--- a/arch/arm/plat-omap/include/mach/mtd-xip.h
+++ b/arch/arm/plat-omap/include/mach/mtd-xip.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Do not include this file directly. It's included from linux/mtd/xip.h 4 * Do not include this file directly. It's included from linux/mtd/xip.h
5 * 5 *
6 * Author: Vladimir Barinov <vbarinov@ru.mvista.com> 6 * Author: Vladimir Barinov <vbarinov@embeddedalley.com>
7 * 7 *
8 * (c) 2005 MontaVista Software, Inc. This file is licensed under the 8 * (c) 2005 MontaVista Software, Inc. This file is licensed under the
9 * terms of the GNU General Public License version 2. This program is 9 * terms of the GNU General Public License version 2. This program is
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 1d7aec1a691a..b52ce053e6f2 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -30,7 +30,7 @@
30#include <linux/blkdev.h> 30#include <linux/blkdev.h>
31#include <linux/err.h> 31#include <linux/err.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <asm/io.h> 33#include <linux/io.h>
34#include <mach/mailbox.h> 34#include <mach/mailbox.h>
35#include "mailbox.h" 35#include "mailbox.h"
36 36
diff --git a/arch/arm/plat-omap/mux.c b/arch/arm/plat-omap/mux.c
index 847df208c46c..80b040fd5ca7 100644
--- a/arch/arm/plat-omap/mux.c
+++ b/arch/arm/plat-omap/mux.c
@@ -25,8 +25,8 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/io.h>
28#include <asm/system.h> 29#include <asm/system.h>
29#include <asm/io.h>
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <mach/mux.h> 31#include <mach/mux.h>
32 32
diff --git a/arch/arm/plat-omap/ocpi.c b/arch/arm/plat-omap/ocpi.c
index 8bdbf979a257..ebe0c73c8901 100644
--- a/arch/arm/plat-omap/ocpi.c
+++ b/arch/arm/plat-omap/ocpi.c
@@ -31,8 +31,8 @@
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/clk.h> 33#include <linux/clk.h>
34#include <linux/io.h>
34 35
35#include <asm/io.h>
36#include <mach/hardware.h> 36#include <mach/hardware.h>
37 37
38#define OCPI_BASE 0xfffec320 38#define OCPI_BASE 0xfffec320
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index ac67eeb6ca6a..e0003e0746e7 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -15,9 +15,9 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/io.h>
18 19
19#include <asm/tlb.h> 20#include <asm/tlb.h>
20#include <asm/io.h>
21#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
22 22
23#include <asm/mach/map.h> 23#include <asm/mach/map.h>
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c
index 777485e0636b..67ca1e216df7 100644
--- a/arch/arm/plat-omap/usb.c
+++ b/arch/arm/plat-omap/usb.c
@@ -27,8 +27,8 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/usb/otg.h> 29#include <linux/usb/otg.h>
30#include <linux/io.h>
30 31
31#include <asm/io.h>
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <asm/system.h> 33#include <asm/system.h>
34#include <mach/hardware.h> 34#include <mach/hardware.h>
diff --git a/arch/arm/plat-s3c24xx/clock.c b/arch/arm/plat-s3c24xx/clock.c
index 54d4b8e2263c..400541359bfb 100644
--- a/arch/arm/plat-s3c24xx/clock.c
+++ b/arch/arm/plat-s3c24xx/clock.c
@@ -39,10 +39,10 @@
39#include <linux/clk.h> 39#include <linux/clk.h>
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/io.h>
42 43
43#include <mach/hardware.h> 44#include <mach/hardware.h>
44#include <asm/irq.h> 45#include <asm/irq.h>
45#include <asm/io.h>
46 46
47#include <mach/regs-clock.h> 47#include <mach/regs-clock.h>
48#include <mach/regs-gpio.h> 48#include <mach/regs-gpio.h>
diff --git a/arch/arm/plat-s3c24xx/common-smdk.c b/arch/arm/plat-s3c24xx/common-smdk.c
index 1863a1b1bc49..d528f460f6bc 100644
--- a/arch/arm/plat-s3c24xx/common-smdk.c
+++ b/arch/arm/plat-s3c24xx/common-smdk.c
@@ -25,6 +25,7 @@
25#include <linux/mtd/nand.h> 25#include <linux/mtd/nand.h>
26#include <linux/mtd/nand_ecc.h> 26#include <linux/mtd/nand_ecc.h>
27#include <linux/mtd/partitions.h> 27#include <linux/mtd/partitions.h>
28#include <linux/io.h>
28 29
29#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
30#include <asm/mach/map.h> 31#include <asm/mach/map.h>
@@ -32,7 +33,6 @@
32 33
33#include <asm/mach-types.h> 34#include <asm/mach-types.h>
34#include <mach/hardware.h> 35#include <mach/hardware.h>
35#include <asm/io.h>
36#include <asm/irq.h> 36#include <asm/irq.h>
37 37
38#include <mach/regs-gpio.h> 38#include <mach/regs-gpio.h>
diff --git a/arch/arm/plat-s3c24xx/cpu.c b/arch/arm/plat-s3c24xx/cpu.c
index 89ce60eabd5b..9c607bbc9343 100644
--- a/arch/arm/plat-s3c24xx/cpu.c
+++ b/arch/arm/plat-s3c24xx/cpu.c
@@ -29,11 +29,11 @@
29#include <linux/serial_core.h> 29#include <linux/serial_core.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/io.h>
33#include <linux/delay.h>
32 34
33#include <mach/hardware.h> 35#include <mach/hardware.h>
34#include <asm/irq.h> 36#include <asm/irq.h>
35#include <asm/io.h>
36#include <asm/delay.h>
37#include <asm/cacheflush.h> 37#include <asm/cacheflush.h>
38 38
39#include <asm/mach/arch.h> 39#include <asm/mach/arch.h>
diff --git a/arch/arm/plat-s3c24xx/devs.c b/arch/arm/plat-s3c24xx/devs.c
index d6fb76578b11..6b13b5455dfc 100644
--- a/arch/arm/plat-s3c24xx/devs.c
+++ b/arch/arm/plat-s3c24xx/devs.c
@@ -19,13 +19,13 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/io.h>
22 23
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24#include <asm/mach/map.h> 25#include <asm/mach/map.h>
25#include <asm/mach/irq.h> 26#include <asm/mach/irq.h>
26#include <mach/fb.h> 27#include <mach/fb.h>
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#include <asm/plat-s3c/regs-serial.h> 31#include <asm/plat-s3c/regs-serial.h>
diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c
index 08c2aaf14c41..d6344461a83b 100644
--- a/arch/arm/plat-s3c24xx/dma.c
+++ b/arch/arm/plat-s3c24xx/dma.c
@@ -26,11 +26,11 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/io.h>
29 30
30#include <asm/system.h> 31#include <asm/system.h>
31#include <asm/irq.h> 32#include <asm/irq.h>
32#include <mach/hardware.h> 33#include <mach/hardware.h>
33#include <asm/io.h>
34#include <asm/dma.h> 34#include <asm/dma.h>
35 35
36#include <asm/mach/dma.h> 36#include <asm/mach/dma.h>
diff --git a/arch/arm/plat-s3c24xx/gpio.c b/arch/arm/plat-s3c24xx/gpio.c
index dd27334e3d7e..4a899c279eb5 100644
--- a/arch/arm/plat-s3c24xx/gpio.c
+++ b/arch/arm/plat-s3c24xx/gpio.c
@@ -26,10 +26,10 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/io.h>
29 30
30#include <mach/hardware.h> 31#include <mach/hardware.h>
31#include <asm/irq.h> 32#include <asm/irq.h>
32#include <asm/io.h>
33 33
34#include <mach/regs-gpio.h> 34#include <mach/regs-gpio.h>
35 35
diff --git a/arch/arm/plat-s3c24xx/irq.c b/arch/arm/plat-s3c24xx/irq.c
index 36cefe176835..590fc5a3ab06 100644
--- a/arch/arm/plat-s3c24xx/irq.c
+++ b/arch/arm/plat-s3c24xx/irq.c
@@ -55,10 +55,10 @@
55#include <linux/interrupt.h> 55#include <linux/interrupt.h>
56#include <linux/ioport.h> 56#include <linux/ioport.h>
57#include <linux/sysdev.h> 57#include <linux/sysdev.h>
58#include <linux/io.h>
58 59
59#include <mach/hardware.h> 60#include <mach/hardware.h>
60#include <asm/irq.h> 61#include <asm/irq.h>
61#include <asm/io.h>
62 62
63#include <asm/mach/irq.h> 63#include <asm/mach/irq.h>
64 64
@@ -468,7 +468,6 @@ static void s3c_irq_demux_adc(unsigned int irq,
468{ 468{
469 unsigned int subsrc, submsk; 469 unsigned int subsrc, submsk;
470 unsigned int offset = 9; 470 unsigned int offset = 9;
471 struct irq_desc *mydesc;
472 471
473 /* read the current pending interrupts, and the mask 472 /* read the current pending interrupts, and the mask
474 * for what it is available */ 473 * for what it is available */
@@ -482,12 +481,10 @@ static void s3c_irq_demux_adc(unsigned int irq,
482 481
483 if (subsrc != 0) { 482 if (subsrc != 0) {
484 if (subsrc & 1) { 483 if (subsrc & 1) {
485 mydesc = irq_desc + IRQ_TC; 484 generic_handle_irq(IRQ_TC);
486 desc_handle_irq(IRQ_TC, mydesc);
487 } 485 }
488 if (subsrc & 2) { 486 if (subsrc & 2) {
489 mydesc = irq_desc + IRQ_ADC; 487 generic_handle_irq(IRQ_ADC);
490 desc_handle_irq(IRQ_ADC, mydesc);
491 } 488 }
492 } 489 }
493} 490}
@@ -496,7 +493,6 @@ static void s3c_irq_demux_uart(unsigned int start)
496{ 493{
497 unsigned int subsrc, submsk; 494 unsigned int subsrc, submsk;
498 unsigned int offset = start - IRQ_S3CUART_RX0; 495 unsigned int offset = start - IRQ_S3CUART_RX0;
499 struct irq_desc *desc;
500 496
501 /* read the current pending interrupts, and the mask 497 /* read the current pending interrupts, and the mask
502 * for what it is available */ 498 * for what it is available */
@@ -512,20 +508,14 @@ static void s3c_irq_demux_uart(unsigned int start)
512 subsrc &= 7; 508 subsrc &= 7;
513 509
514 if (subsrc != 0) { 510 if (subsrc != 0) {
515 desc = irq_desc + start;
516
517 if (subsrc & 1) 511 if (subsrc & 1)
518 desc_handle_irq(start, desc); 512 generic_handle_irq(start);
519
520 desc++;
521 513
522 if (subsrc & 2) 514 if (subsrc & 2)
523 desc_handle_irq(start+1, desc); 515 generic_handle_irq(start+1);
524
525 desc++;
526 516
527 if (subsrc & 4) 517 if (subsrc & 4)
528 desc_handle_irq(start+2, desc); 518 generic_handle_irq(start+2);
529 } 519 }
530} 520}
531 521
@@ -572,7 +562,7 @@ s3c_irq_demux_extint8(unsigned int irq,
572 eintpnd &= ~(1<<irq); 562 eintpnd &= ~(1<<irq);
573 563
574 irq += (IRQ_EINT4 - 4); 564 irq += (IRQ_EINT4 - 4);
575 desc_handle_irq(irq, irq_desc + irq); 565 generic_handle_irq(irq);
576 } 566 }
577 567
578} 568}
@@ -595,7 +585,7 @@ s3c_irq_demux_extint4t7(unsigned int irq,
595 585
596 irq += (IRQ_EINT4 - 4); 586 irq += (IRQ_EINT4 - 4);
597 587
598 desc_handle_irq(irq, irq_desc + irq); 588 generic_handle_irq(irq);
599 } 589 }
600} 590}
601 591
diff --git a/arch/arm/plat-s3c24xx/pm-simtec.c b/arch/arm/plat-s3c24xx/pm-simtec.c
index e6705014b2a0..0a074d35890a 100644
--- a/arch/arm/plat-s3c24xx/pm-simtec.c
+++ b/arch/arm/plat-s3c24xx/pm-simtec.c
@@ -20,12 +20,12 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/sysdev.h> 21#include <linux/sysdev.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/io.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28#include <asm/io.h>
29 29
30#include <mach/map.h> 30#include <mach/map.h>
31#include <mach/regs-gpio.h> 31#include <mach/regs-gpio.h>
diff --git a/arch/arm/plat-s3c24xx/pm.c b/arch/arm/plat-s3c24xx/pm.c
index fc4b731a949c..d3934b1119a9 100644
--- a/arch/arm/plat-s3c24xx/pm.c
+++ b/arch/arm/plat-s3c24xx/pm.c
@@ -35,10 +35,10 @@
35#include <linux/ioport.h> 35#include <linux/ioport.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/serial_core.h> 37#include <linux/serial_core.h>
38#include <linux/io.h>
38 39
39#include <asm/cacheflush.h> 40#include <asm/cacheflush.h>
40#include <mach/hardware.h> 41#include <mach/hardware.h>
41#include <asm/io.h>
42 42
43#include <asm/plat-s3c/regs-serial.h> 43#include <asm/plat-s3c/regs-serial.h>
44#include <mach/regs-clock.h> 44#include <mach/regs-clock.h>
diff --git a/arch/arm/plat-s3c24xx/s3c244x-clock.c b/arch/arm/plat-s3c24xx/s3c244x-clock.c
index 8a5fffde6631..119647a5eaa6 100644
--- a/arch/arm/plat-s3c24xx/s3c244x-clock.c
+++ b/arch/arm/plat-s3c24xx/s3c244x-clock.c
@@ -33,11 +33,11 @@
33#include <linux/ioport.h> 33#include <linux/ioport.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/io.h>
36 37
37#include <mach/hardware.h> 38#include <mach/hardware.h>
38#include <asm/atomic.h> 39#include <asm/atomic.h>
39#include <asm/irq.h> 40#include <asm/irq.h>
40#include <asm/io.h>
41 41
42#include <mach/regs-clock.h> 42#include <mach/regs-clock.h>
43 43
diff --git a/arch/arm/plat-s3c24xx/s3c244x-irq.c b/arch/arm/plat-s3c24xx/s3c244x-irq.c
index f3dc38cf1de4..0601c5f3230b 100644
--- a/arch/arm/plat-s3c24xx/s3c244x-irq.c
+++ b/arch/arm/plat-s3c24xx/s3c244x-irq.c
@@ -24,10 +24,10 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/io.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/io.h>
31 31
32#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
33 33
@@ -44,7 +44,6 @@ static void s3c_irq_demux_cam(unsigned int irq,
44 struct irq_desc *desc) 44 struct irq_desc *desc)
45{ 45{
46 unsigned int subsrc, submsk; 46 unsigned int subsrc, submsk;
47 struct irq_desc *mydesc;
48 47
49 /* read the current pending interrupts, and the mask 48 /* read the current pending interrupts, and the mask
50 * for what it is available */ 49 * for what it is available */
@@ -58,12 +57,10 @@ static void s3c_irq_demux_cam(unsigned int irq,
58 57
59 if (subsrc != 0) { 58 if (subsrc != 0) {
60 if (subsrc & 1) { 59 if (subsrc & 1) {
61 mydesc = irq_desc + IRQ_S3C2440_CAM_C; 60 generic_handle_irq(IRQ_S3C2440_CAM_C);
62 desc_handle_irq(IRQ_S3C2440_CAM_C, mydesc);
63 } 61 }
64 if (subsrc & 2) { 62 if (subsrc & 2) {
65 mydesc = irq_desc + IRQ_S3C2440_CAM_P; 63 generic_handle_irq(IRQ_S3C2440_CAM_P);
66 desc_handle_irq(IRQ_S3C2440_CAM_P, mydesc);
67 } 64 }
68 } 65 }
69} 66}
diff --git a/arch/arm/plat-s3c24xx/s3c244x.c b/arch/arm/plat-s3c24xx/s3c244x.c
index 281b4804ed38..146863a69aeb 100644
--- a/arch/arm/plat-s3c24xx/s3c244x.c
+++ b/arch/arm/plat-s3c24xx/s3c244x.c
@@ -20,13 +20,13 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/sysdev.h> 21#include <linux/sysdev.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/io.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
26#include <asm/mach/irq.h> 27#include <asm/mach/irq.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/io.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31 31
32#include <mach/regs-clock.h> 32#include <mach/regs-clock.h>
diff --git a/arch/arm/plat-s3c24xx/time.c b/arch/arm/plat-s3c24xx/time.c
index b471a21ae2e4..64bfa19ae951 100644
--- a/arch/arm/plat-s3c24xx/time.c
+++ b/arch/arm/plat-s3c24xx/time.c
@@ -25,12 +25,12 @@
25#include <linux/irq.h> 25#include <linux/irq.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/io.h>
28 29
29#include <asm/system.h> 30#include <asm/system.h>
30#include <asm/leds.h> 31#include <asm/leds.h>
31#include <asm/mach-types.h> 32#include <asm/mach-types.h>
32 33
33#include <asm/io.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <mach/map.h> 35#include <mach/map.h>
36#include <asm/plat-s3c/regs-timer.h> 36#include <asm/plat-s3c/regs-timer.h>
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index 56281c030a7b..43aa2020f85c 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -12,7 +12,7 @@
12# 12#
13# http://www.arm.linux.org.uk/developer/machines/?action=new 13# http://www.arm.linux.org.uk/developer/machines/?action=new
14# 14#
15# Last update: Wed Aug 13 21:56:02 2008 15# Last update: Thu Sep 25 10:10:50 2008
16# 16#
17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number 17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number
18# 18#
@@ -1810,7 +1810,7 @@ kriss_sensor MACH_KRISS_SENSOR KRISS_SENSOR 1819
1810pilz_pmi5 MACH_PILZ_PMI5 PILZ_PMI5 1820 1810pilz_pmi5 MACH_PILZ_PMI5 PILZ_PMI5 1820
1811jade MACH_JADE JADE 1821 1811jade MACH_JADE JADE 1821
1812ks8695_softplc MACH_KS8695_SOFTPLC KS8695_SOFTPLC 1822 1812ks8695_softplc MACH_KS8695_SOFTPLC KS8695_SOFTPLC 1822
1813gprisc3 MACH_GPRISC4 GPRISC4 1823 1813gprisc3 MACH_GPRISC3 GPRISC3 1823
1814stamp9260 MACH_STAMP9260 STAMP9260 1824 1814stamp9260 MACH_STAMP9260 STAMP9260 1824
1815smdk6430 MACH_SMDK6430 SMDK6430 1825 1815smdk6430 MACH_SMDK6430 SMDK6430 1825
1816smdkc100 MACH_SMDKC100 SMDKC100 1826 1816smdkc100 MACH_SMDKC100 SMDKC100 1826
@@ -1859,5 +1859,43 @@ kbio9260 MACH_KBIO9260 KBIO9260 1868
1859ginza MACH_GINZA GINZA 1869 1859ginza MACH_GINZA GINZA 1869
1860a636n MACH_A636N A636N 1870 1860a636n MACH_A636N A636N 1870
1861imx27ipcam MACH_IMX27IPCAM IMX27IPCAM 1871 1861imx27ipcam MACH_IMX27IPCAM IMX27IPCAM 1871
1862nenoc MACH_NEMOC NEMOC 1872 1862nemoc MACH_NEMOC NEMOC 1872
1863geneva MACH_GENEVA GENEVA 1873 1863geneva MACH_GENEVA GENEVA 1873
1864htcpharos MACH_HTCPHAROS HTCPHAROS 1874
1865neonc MACH_NEONC NEONC 1875
1866nas7100 MACH_NAS7100 NAS7100 1876
1867teuphone MACH_TEUPHONE TEUPHONE 1877
1868annax_eth2 MACH_ANNAX_ETH2 ANNAX_ETH2 1878
1869csb733 MACH_CSB733 CSB733 1879
1870bk3 MACH_BK3 BK3 1880
1871omap_em32 MACH_OMAP_EM32 OMAP_EM32 1881
1872et9261cp MACH_ET9261CP ET9261CP 1882
1873jasperc MACH_JASPERC JASPERC 1883
1874issi_arm9 MACH_ISSI_ARM9 ISSI_ARM9 1884
1875ued MACH_UED UED 1885
1876esiblade MACH_ESIBLADE ESIBLADE 1886
1877eye02 MACH_EYE02 EYE02 1887
1878imx27kbd MACH_IMX27KBD IMX27KBD 1888
1879sst61vc010_fpga MACH_SST61VC010_FPGA SST61VC010_FPGA 1889
1880kixvp435 MACH_KIXVP435 KIXVP435 1890
1881kixnp435 MACH_KIXNP435 KIXNP435 1891
1882africa MACH_AFRICA AFRICA 1892
1883nh233 MACH_NH233 NH233 1893
1884rd88f6183ap_ge MACH_RD88F6183AP_GE RD88F6183AP_GE 1894
1885bcm4760 MACH_BCM4760 BCM4760 1895
1886eddy_v2 MACH_EDDY_V2 EDDY_V2 1896
1887realview_pba8 MACH_REALVIEW_PBA8 REALVIEW_PBA8 1897
1888hid_a7 MACH_HID_A7 HID_A7 1898
1889hero MACH_HERO HERO 1899
1890omap_poseidon MACH_OMAP_POSEIDON OMAP_POSEIDON 1900
1891realview_pbx MACH_REALVIEW_PBX REALVIEW_PBX 1901
1892micro9s MACH_MICRO9S MICRO9S 1902
1893mako MACH_MAKO MAKO 1903
1894xdaflame MACH_XDAFLAME XDAFLAME 1904
1895phidget_sbc2 MACH_PHIDGET_SBC2 PHIDGET_SBC2 1905
1896limestone MACH_LIMESTONE LIMESTONE 1906
1897iprobe_c32 MACH_IPROBE_C32 IPROBE_C32 1907
1898rut100 MACH_RUT100 RUT100 1908
1899asusp535 MACH_ASUSP535 ASUSP535 1909
1900htcraphael MACH_HTCRAPHAEL HTCRAPHAEL 1910
1901sygdg1 MACH_SYGDG1 SYGDG1 1911
diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S
index 806ce26d5243..ba592a9e6fb3 100644
--- a/arch/arm/vfp/entry.S
+++ b/arch/arm/vfp/entry.S
@@ -21,13 +21,13 @@
21#include <asm/assembler.h> 21#include <asm/assembler.h>
22#include <asm/vfpmacros.h> 22#include <asm/vfpmacros.h>
23 23
24 .globl do_vfp 24ENTRY(do_vfp)
25do_vfp:
26 enable_irq 25 enable_irq
27 ldr r4, .LCvfp 26 ldr r4, .LCvfp
28 ldr r11, [r10, #TI_CPU] @ CPU number 27 ldr r11, [r10, #TI_CPU] @ CPU number
29 add r10, r10, #TI_VFPSTATE @ r10 = workspace 28 add r10, r10, #TI_VFPSTATE @ r10 = workspace
30 ldr pc, [r4] @ call VFP entry point 29 ldr pc, [r4] @ call VFP entry point
30ENDPROC(do_vfp)
31 31
32ENTRY(vfp_null_entry) 32ENTRY(vfp_null_entry)
33 mov pc, lr 33 mov pc, lr
@@ -40,11 +40,11 @@ ENDPROC(vfp_null_entry)
40@ failure to the VFP initialisation code. 40@ failure to the VFP initialisation code.
41 41
42 __INIT 42 __INIT
43 .globl vfp_testing_entry 43ENTRY(vfp_testing_entry)
44vfp_testing_entry:
45 ldr r0, VFP_arch_address 44 ldr r0, VFP_arch_address
46 str r5, [r0] @ known non-zero value 45 str r5, [r0] @ known non-zero value
47 mov pc, r9 @ we have handled the fault 46 mov pc, r9 @ we have handled the fault
47ENDPROC(vfp_testing_entry)
48 48
49VFP_arch_address: 49VFP_arch_address:
50 .word VFP_arch 50 .word VFP_arch
diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
index 353f9e5c7919..a62dcf7098ba 100644
--- a/arch/arm/vfp/vfphw.S
+++ b/arch/arm/vfp/vfphw.S
@@ -68,8 +68,7 @@
68@ r11 = CPU number 68@ r11 = CPU number
69@ lr = failure return 69@ lr = failure return
70 70
71 .globl vfp_support_entry 71ENTRY(vfp_support_entry)
72vfp_support_entry:
73 DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10 72 DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10
74 73
75 VFPFMRX r1, FPEXC @ Is the VFP enabled? 74 VFPFMRX r1, FPEXC @ Is the VFP enabled?
@@ -165,11 +164,10 @@ process_exception:
165 @ code will raise an exception if 164 @ code will raise an exception if
166 @ required. If not, the user code will 165 @ required. If not, the user code will
167 @ retry the faulted instruction 166 @ retry the faulted instruction
167ENDPROC(vfp_support_entry)
168 168
169#ifdef CONFIG_SMP 169#ifdef CONFIG_SMP
170 .globl vfp_save_state 170ENTRY(vfp_save_state)
171 .type vfp_save_state, %function
172vfp_save_state:
173 @ Save the current VFP state 171 @ Save the current VFP state
174 @ r0 - save location 172 @ r0 - save location
175 @ r1 - FPEXC 173 @ r1 - FPEXC
@@ -182,13 +180,13 @@ vfp_save_state:
182 VFPFMRX r12, FPINST2, NE @ FPINST2 if needed (and present) 180 VFPFMRX r12, FPINST2, NE @ FPINST2 if needed (and present)
183 stmia r0, {r1, r2, r3, r12} @ save FPEXC, FPSCR, FPINST, FPINST2 181 stmia r0, {r1, r2, r3, r12} @ save FPEXC, FPSCR, FPINST, FPINST2
184 mov pc, lr 182 mov pc, lr
183ENDPROC(vfp_save_state)
185#endif 184#endif
186 185
187last_VFP_context_address: 186last_VFP_context_address:
188 .word last_VFP_context 187 .word last_VFP_context
189 188
190 .globl vfp_get_float 189ENTRY(vfp_get_float)
191vfp_get_float:
192 add pc, pc, r0, lsl #3 190 add pc, pc, r0, lsl #3
193 mov r0, r0 191 mov r0, r0
194 .irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 192 .irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
@@ -197,9 +195,9 @@ vfp_get_float:
197 mrc p10, 0, r0, c\dr, c0, 4 @ fmrs r0, s1 195 mrc p10, 0, r0, c\dr, c0, 4 @ fmrs r0, s1
198 mov pc, lr 196 mov pc, lr
199 .endr 197 .endr
198ENDPROC(vfp_get_float)
200 199
201 .globl vfp_put_float 200ENTRY(vfp_put_float)
202vfp_put_float:
203 add pc, pc, r1, lsl #3 201 add pc, pc, r1, lsl #3
204 mov r0, r0 202 mov r0, r0
205 .irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 203 .irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
@@ -208,9 +206,9 @@ vfp_put_float:
208 mcr p10, 0, r0, c\dr, c0, 4 @ fmsr r0, s1 206 mcr p10, 0, r0, c\dr, c0, 4 @ fmsr r0, s1
209 mov pc, lr 207 mov pc, lr
210 .endr 208 .endr
209ENDPROC(vfp_put_float)
211 210
212 .globl vfp_get_double 211ENTRY(vfp_get_double)
213vfp_get_double:
214 add pc, pc, r0, lsl #3 212 add pc, pc, r0, lsl #3
215 mov r0, r0 213 mov r0, r0
216 .irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 214 .irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
@@ -229,9 +227,9 @@ vfp_get_double:
229 mov r0, #0 227 mov r0, #0
230 mov r1, #0 228 mov r1, #0
231 mov pc, lr 229 mov pc, lr
230ENDPROC(vfp_get_double)
232 231
233 .globl vfp_put_double 232ENTRY(vfp_put_double)
234vfp_put_double:
235 add pc, pc, r2, lsl #3 233 add pc, pc, r2, lsl #3
236 mov r0, r0 234 mov r0, r0
237 .irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 235 .irp dr,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
@@ -245,3 +243,4 @@ vfp_put_double:
245 mov pc, lr 243 mov pc, lr
246 .endr 244 .endr
247#endif 245#endif
246ENDPROC(vfp_put_double)
diff --git a/arch/avr32/boards/atngw100/setup.c b/arch/avr32/boards/atngw100/setup.c
index b8286f1ce854..6c54580a66df 100644
--- a/arch/avr32/boards/atngw100/setup.c
+++ b/arch/avr32/boards/atngw100/setup.c
@@ -9,6 +9,7 @@
9 */ 9 */
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/etherdevice.h> 11#include <linux/etherdevice.h>
12#include <linux/gpio.h>
12#include <linux/irq.h> 13#include <linux/irq.h>
13#include <linux/i2c.h> 14#include <linux/i2c.h>
14#include <linux/i2c-gpio.h> 15#include <linux/i2c-gpio.h>
@@ -53,8 +54,11 @@ static struct spi_board_info spi0_board_info[] __initdata = {
53}; 54};
54 55
55static struct mci_platform_data __initdata mci0_data = { 56static struct mci_platform_data __initdata mci0_data = {
56 .detect_pin = GPIO_PIN_PC(25), 57 .slot[0] = {
57 .wp_pin = GPIO_PIN_PE(0), 58 .bus_width = 4,
59 .detect_pin = GPIO_PIN_PC(25),
60 .wp_pin = GPIO_PIN_PE(0),
61 },
58}; 62};
59 63
60/* 64/*
@@ -190,7 +194,7 @@ static int __init atngw100_init(void)
190 * PB28/EXTINT3 doesn't; it should be SMBALERT# (for PMBus), 194 * PB28/EXTINT3 doesn't; it should be SMBALERT# (for PMBus),
191 * but it's not available off-board. 195 * but it's not available off-board.
192 */ 196 */
193 at32_select_periph(GPIO_PIN_PB(28), 0, AT32_GPIOF_PULLUP); 197 at32_select_periph(GPIO_PIOB_BASE, 1 << 28, 0, AT32_GPIOF_PULLUP);
194 at32_select_gpio(i2c_gpio_data.sda_pin, 198 at32_select_gpio(i2c_gpio_data.sda_pin,
195 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); 199 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
196 at32_select_gpio(i2c_gpio_data.scl_pin, 200 at32_select_gpio(i2c_gpio_data.scl_pin,
@@ -204,6 +208,15 @@ postcore_initcall(atngw100_init);
204 208
205static int __init atngw100_arch_init(void) 209static int __init atngw100_arch_init(void)
206{ 210{
211 /* PB30 is the otherwise unused jumper on the mainboard, with an
212 * external pullup; the jumper grounds it. Use it however you
213 * like, including letting U-Boot or Linux tweak boot sequences.
214 */
215 at32_select_gpio(GPIO_PIN_PB(30), 0);
216 gpio_request(GPIO_PIN_PB(30), "j15");
217 gpio_direction_input(GPIO_PIN_PB(30));
218 gpio_export(GPIO_PIN_PB(30), false);
219
207 /* set_irq_type() after the arch_initcall for EIC has run, and 220 /* set_irq_type() after the arch_initcall for EIC has run, and
208 * before the I2C subsystem could try using this IRQ. 221 * before the I2C subsystem could try using this IRQ.
209 */ 222 */
diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c
index dfc3443e23aa..29e5b51a7fd2 100644
--- a/arch/avr32/boards/atstk1000/atstk1002.c
+++ b/arch/avr32/boards/atstk1000/atstk1002.c
@@ -232,7 +232,7 @@ static void __init atstk1002_setup_extdac(void)
232 goto err_set_clk; 232 goto err_set_clk;
233 } 233 }
234 234
235 at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0); 235 at32_select_periph(GPIO_PIOA_BASE, (1 << 30), GPIO_PERIPH_A, 0);
236 at73c213_data.dac_clk = gclk; 236 at73c213_data.dac_clk = gclk;
237 237
238err_set_clk: 238err_set_clk:
@@ -264,16 +264,20 @@ void __init setup_board(void)
264 264
265#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM 265#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
266 266
267static struct mci_platform_data __initdata mci0_data = {
268 .slot[0] = {
269 .bus_width = 4,
270
267/* MMC card detect requires MACB0 *NOT* be used */ 271/* MMC card detect requires MACB0 *NOT* be used */
268#ifdef CONFIG_BOARD_ATSTK1002_SW6_CUSTOM 272#ifdef CONFIG_BOARD_ATSTK1002_SW6_CUSTOM
269static struct mci_platform_data __initdata mci0_data = { 273 .detect_pin = GPIO_PIN_PC(14), /* gpio30/sdcd */
270 .detect_pin = GPIO_PIN_PC(14), /* gpio30/sdcd */ 274 .wp_pin = GPIO_PIN_PC(15), /* gpio31/sdwp */
271 .wp_pin = GPIO_PIN_PC(15), /* gpio31/sdwp */
272};
273#define MCI_PDATA &mci0_data
274#else 275#else
275#define MCI_PDATA NULL 276 .detect_pin = -ENODEV,
277 .wp_pin = -ENODEV,
276#endif /* SW6 for sd{cd,wp} routing */ 278#endif /* SW6 for sd{cd,wp} routing */
279 },
280};
277 281
278#endif /* SW2 for MMC signal routing */ 282#endif /* SW2 for MMC signal routing */
279 283
@@ -326,13 +330,14 @@ static int __init atstk1002_init(void)
326 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 330 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
327#endif 331#endif
328#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM 332#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
329 at32_add_device_mci(0, MCI_PDATA); 333 at32_add_device_mci(0, &mci0_data);
330#endif 334#endif
331#ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM 335#ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM
332 set_hw_addr(at32_add_device_eth(1, &eth_data[1])); 336 set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
333#else 337#else
334 at32_add_device_lcdc(0, &atstk1000_lcdc_data, 338 at32_add_device_lcdc(0, &atstk1000_lcdc_data,
335 fbmem_start, fbmem_size, 0); 339 fbmem_start, fbmem_size,
340 ATMEL_LCDC_PRI_24BIT | ATMEL_LCDC_PRI_CONTROL);
336#endif 341#endif
337 at32_add_device_usba(0, NULL); 342 at32_add_device_usba(0, NULL);
338#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM 343#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
diff --git a/arch/avr32/boards/atstk1000/atstk1003.c b/arch/avr32/boards/atstk1000/atstk1003.c
index 0cf664174c17..be089d7f37eb 100644
--- a/arch/avr32/boards/atstk1000/atstk1003.c
+++ b/arch/avr32/boards/atstk1000/atstk1003.c
@@ -19,6 +19,7 @@
19#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
20 20
21#include <asm/setup.h> 21#include <asm/setup.h>
22#include <asm/atmel-mci.h>
22 23
23#include <mach/at32ap700x.h> 24#include <mach/at32ap700x.h>
24#include <mach/board.h> 25#include <mach/board.h>
@@ -66,6 +67,16 @@ static struct spi_board_info spi1_board_info[] __initdata = { {
66} }; 67} };
67#endif 68#endif
68 69
70#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
71static struct mci_platform_data __initdata mci0_data = {
72 .slot[0] = {
73 .bus_width = 4,
74 .detect_pin = -ENODEV,
75 .wp_pin = -ENODEV,
76 },
77};
78#endif
79
69#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC 80#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
70static void __init atstk1003_setup_extdac(void) 81static void __init atstk1003_setup_extdac(void)
71{ 82{
@@ -84,7 +95,7 @@ static void __init atstk1003_setup_extdac(void)
84 goto err_set_clk; 95 goto err_set_clk;
85 } 96 }
86 97
87 at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0); 98 at32_select_periph(GPIO_PIOA_BASE, (1 << 30), GPIO_PERIPH_A, 0);
88 at73c213_data.dac_clk = gclk; 99 at73c213_data.dac_clk = gclk;
89 100
90err_set_clk: 101err_set_clk:
@@ -154,7 +165,7 @@ static int __init atstk1003_init(void)
154 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 165 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
155#endif 166#endif
156#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM 167#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
157 at32_add_device_mci(0, NULL); 168 at32_add_device_mci(0, &mci0_data);
158#endif 169#endif
159 at32_add_device_usba(0, NULL); 170 at32_add_device_usba(0, NULL);
160#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM 171#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
diff --git a/arch/avr32/boards/atstk1000/atstk1004.c b/arch/avr32/boards/atstk1000/atstk1004.c
index 50a5273e5916..248ef237c167 100644
--- a/arch/avr32/boards/atstk1000/atstk1004.c
+++ b/arch/avr32/boards/atstk1000/atstk1004.c
@@ -21,6 +21,7 @@
21#include <video/atmel_lcdc.h> 21#include <video/atmel_lcdc.h>
22 22
23#include <asm/setup.h> 23#include <asm/setup.h>
24#include <asm/atmel-mci.h>
24 25
25#include <mach/at32ap700x.h> 26#include <mach/at32ap700x.h>
26#include <mach/board.h> 27#include <mach/board.h>
@@ -71,6 +72,16 @@ static struct spi_board_info spi1_board_info[] __initdata = { {
71} }; 72} };
72#endif 73#endif
73 74
75#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
76static struct mci_platform_data __initdata mci0_data = {
77 .slot[0] = {
78 .bus_width = 4,
79 .detect_pin = -ENODEV,
80 .wp_pin = -ENODEV,
81 },
82};
83#endif
84
74#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC 85#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
75static void __init atstk1004_setup_extdac(void) 86static void __init atstk1004_setup_extdac(void)
76{ 87{
@@ -89,7 +100,7 @@ static void __init atstk1004_setup_extdac(void)
89 goto err_set_clk; 100 goto err_set_clk;
90 } 101 }
91 102
92 at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0); 103 at32_select_periph(GPIO_PIOA_BASE, (1 << 30), GPIO_PERIPH_A, 0);
93 at73c213_data.dac_clk = gclk; 104 at73c213_data.dac_clk = gclk;
94 105
95err_set_clk: 106err_set_clk:
@@ -137,10 +148,11 @@ static int __init atstk1004_init(void)
137 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 148 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
138#endif 149#endif
139#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM 150#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
140 at32_add_device_mci(0, NULL); 151 at32_add_device_mci(0, &mci0_data);
141#endif 152#endif
142 at32_add_device_lcdc(0, &atstk1000_lcdc_data, 153 at32_add_device_lcdc(0, &atstk1000_lcdc_data,
143 fbmem_start, fbmem_size, 0); 154 fbmem_start, fbmem_size,
155 ATMEL_LCDC_PRI_24BIT | ATMEL_LCDC_PRI_CONTROL);
144 at32_add_device_usba(0, NULL); 156 at32_add_device_usba(0, NULL);
145#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM 157#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
146 at32_add_device_ssc(0, ATMEL_SSC_TX); 158 at32_add_device_ssc(0, ATMEL_SSC_TX);
diff --git a/arch/avr32/include/asm/atmel-mci.h b/arch/avr32/include/asm/atmel-mci.h
index c2ea6e1c9aa1..59f3fadd0b68 100644
--- a/arch/avr32/include/asm/atmel-mci.h
+++ b/arch/avr32/include/asm/atmel-mci.h
@@ -1,9 +1,39 @@
1#ifndef __ASM_AVR32_ATMEL_MCI_H 1#ifndef __ASM_AVR32_ATMEL_MCI_H
2#define __ASM_AVR32_ATMEL_MCI_H 2#define __ASM_AVR32_ATMEL_MCI_H
3 3
4struct mci_platform_data { 4#define ATMEL_MCI_MAX_NR_SLOTS 2
5
6struct dma_slave;
7
8/**
9 * struct mci_slot_pdata - board-specific per-slot configuration
10 * @bus_width: Number of data lines wired up the slot
11 * @detect_pin: GPIO pin wired to the card detect switch
12 * @wp_pin: GPIO pin wired to the write protect sensor
13 *
14 * If a given slot is not present on the board, @bus_width should be
15 * set to 0. The other fields are ignored in this case.
16 *
17 * Any pins that aren't available should be set to a negative value.
18 *
19 * Note that support for multiple slots is experimental -- some cards
20 * might get upset if we don't get the clock management exactly right.
21 * But in most cases, it should work just fine.
22 */
23struct mci_slot_pdata {
24 unsigned int bus_width;
5 int detect_pin; 25 int detect_pin;
6 int wp_pin; 26 int wp_pin;
7}; 27};
8 28
29/**
30 * struct mci_platform_data - board-specific MMC/SDcard configuration
31 * @dma_slave: DMA slave interface to use in data transfers, or NULL.
32 * @slot: Per-slot configuration data.
33 */
34struct mci_platform_data {
35 struct dma_slave *dma_slave;
36 struct mci_slot_pdata slot[ATMEL_MCI_MAX_NR_SLOTS];
37};
38
9#endif /* __ASM_AVR32_ATMEL_MCI_H */ 39#endif /* __ASM_AVR32_ATMEL_MCI_H */
diff --git a/arch/avr32/include/asm/byteorder.h b/arch/avr32/include/asm/byteorder.h
index d77b48ba7338..8e3af02076dd 100644
--- a/arch/avr32/include/asm/byteorder.h
+++ b/arch/avr32/include/asm/byteorder.h
@@ -7,6 +7,9 @@
7#include <asm/types.h> 7#include <asm/types.h>
8#include <linux/compiler.h> 8#include <linux/compiler.h>
9 9
10#define __BIG_ENDIAN
11#define __SWAB_64_THRU_32__
12
10#ifdef __CHECKER__ 13#ifdef __CHECKER__
11extern unsigned long __builtin_bswap_32(unsigned long x); 14extern unsigned long __builtin_bswap_32(unsigned long x);
12extern unsigned short __builtin_bswap_16(unsigned short x); 15extern unsigned short __builtin_bswap_16(unsigned short x);
@@ -17,15 +20,18 @@ extern unsigned short __builtin_bswap_16(unsigned short x);
17 * the result. 20 * the result.
18 */ 21 */
19#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 2) 22#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 2)
20#define __arch__swab32(x) __builtin_bswap_32(x) 23static inline __attribute_const__ __u16 __arch_swab16(__u16 val)
21#define __arch__swab16(x) __builtin_bswap_16(x) 24{
22#endif 25 return __builtin_bswap_16(val);
26}
27#define __arch_swab16 __arch_swab16
23 28
24#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) 29static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
25# define __BYTEORDER_HAS_U64__ 30{
26# define __SWAB_64_THRU_32__ 31 return __builtin_bswap_32(val);
32}
33#define __arch_swab32 __arch_swab32
27#endif 34#endif
28 35
29#include <linux/byteorder/big_endian.h> 36#include <linux/byteorder.h>
30
31#endif /* __ASM_AVR32_BYTEORDER_H */ 37#endif /* __ASM_AVR32_BYTEORDER_H */
diff --git a/arch/avr32/include/asm/io.h b/arch/avr32/include/asm/io.h
index a520f77ead96..22c97ef92201 100644
--- a/arch/avr32/include/asm/io.h
+++ b/arch/avr32/include/asm/io.h
@@ -160,6 +160,14 @@ BUILDIO_IOPORT(l, u32)
160#define readw_relaxed readw 160#define readw_relaxed readw
161#define readl_relaxed readl 161#define readl_relaxed readl
162 162
163#define readb_be __raw_readb
164#define readw_be __raw_readw
165#define readl_be __raw_readl
166
167#define writeb_be __raw_writeb
168#define writew_be __raw_writew
169#define writel_be __raw_writel
170
163#define __BUILD_MEMORY_STRING(bwl, type) \ 171#define __BUILD_MEMORY_STRING(bwl, type) \
164static inline void writes##bwl(volatile void __iomem *addr, \ 172static inline void writes##bwl(volatile void __iomem *addr, \
165 const void *data, unsigned int count) \ 173 const void *data, unsigned int count) \
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c
index 2c08ac992ac3..134d5302b6dd 100644
--- a/arch/avr32/kernel/process.c
+++ b/arch/avr32/kernel/process.c
@@ -9,6 +9,7 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/kallsyms.h> 10#include <linux/kallsyms.h>
11#include <linux/fs.h> 11#include <linux/fs.h>
12#include <linux/pm.h>
12#include <linux/ptrace.h> 13#include <linux/ptrace.h>
13#include <linux/reboot.h> 14#include <linux/reboot.h>
14#include <linux/tick.h> 15#include <linux/tick.h>
@@ -20,7 +21,7 @@
20 21
21#include <mach/pm.h> 22#include <mach/pm.h>
22 23
23void (*pm_power_off)(void) = NULL; 24void (*pm_power_off)(void);
24EXPORT_SYMBOL(pm_power_off); 25EXPORT_SYMBOL(pm_power_off);
25 26
26/* 27/*
diff --git a/arch/avr32/kernel/setup.c b/arch/avr32/kernel/setup.c
index d8e623c426c1..5c7083916c33 100644
--- a/arch/avr32/kernel/setup.c
+++ b/arch/avr32/kernel/setup.c
@@ -283,6 +283,25 @@ static int __init early_parse_fbmem(char *p)
283} 283}
284early_param("fbmem", early_parse_fbmem); 284early_param("fbmem", early_parse_fbmem);
285 285
286/*
287 * Pick out the memory size. We look for mem=size@start,
288 * where start and size are "size[KkMmGg]"
289 */
290static int __init early_mem(char *p)
291{
292 resource_size_t size, start;
293
294 start = system_ram->start;
295 size = memparse(p, &p);
296 if (*p == '@')
297 start = memparse(p + 1, &p);
298
299 system_ram->start = start;
300 system_ram->end = system_ram->start + size - 1;
301 return 0;
302}
303early_param("mem", early_mem);
304
286static int __init parse_tag_core(struct tag *tag) 305static int __init parse_tag_core(struct tag *tag)
287{ 306{
288 if (tag->hdr.size > 2) { 307 if (tag->hdr.size > 2) {
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index e01dbe4ebb40..813b6844cdf6 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -82,8 +82,9 @@ static struct platform_device _name##_id##_device = { \
82 .num_resources = ARRAY_SIZE(_name##_id##_resource), \ 82 .num_resources = ARRAY_SIZE(_name##_id##_resource), \
83} 83}
84 84
85#define select_peripheral(pin, periph, flags) \ 85#define select_peripheral(port, pin_mask, periph, flags) \
86 at32_select_periph(GPIO_PIN_##pin, GPIO_##periph, flags) 86 at32_select_periph(GPIO_##port##_BASE, pin_mask, \
87 GPIO_##periph, flags)
87 88
88#define DEV_CLK(_name, devname, bus, _index) \ 89#define DEV_CLK(_name, devname, bus, _index) \
89static struct clk devname##_##_name = { \ 90static struct clk devname##_##_name = { \
@@ -871,6 +872,7 @@ static struct clk atmel_psif1_pclk = {
871struct platform_device *__init at32_add_device_psif(unsigned int id) 872struct platform_device *__init at32_add_device_psif(unsigned int id)
872{ 873{
873 struct platform_device *pdev; 874 struct platform_device *pdev;
875 u32 pin_mask;
874 876
875 if (!(id == 0 || id == 1)) 877 if (!(id == 0 || id == 1))
876 return NULL; 878 return NULL;
@@ -881,20 +883,22 @@ struct platform_device *__init at32_add_device_psif(unsigned int id)
881 883
882 switch (id) { 884 switch (id) {
883 case 0: 885 case 0:
886 pin_mask = (1 << 8) | (1 << 9); /* CLOCK & DATA */
887
884 if (platform_device_add_resources(pdev, atmel_psif0_resource, 888 if (platform_device_add_resources(pdev, atmel_psif0_resource,
885 ARRAY_SIZE(atmel_psif0_resource))) 889 ARRAY_SIZE(atmel_psif0_resource)))
886 goto err_add_resources; 890 goto err_add_resources;
887 atmel_psif0_pclk.dev = &pdev->dev; 891 atmel_psif0_pclk.dev = &pdev->dev;
888 select_peripheral(PA(8), PERIPH_A, 0); /* CLOCK */ 892 select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
889 select_peripheral(PA(9), PERIPH_A, 0); /* DATA */
890 break; 893 break;
891 case 1: 894 case 1:
895 pin_mask = (1 << 11) | (1 << 12); /* CLOCK & DATA */
896
892 if (platform_device_add_resources(pdev, atmel_psif1_resource, 897 if (platform_device_add_resources(pdev, atmel_psif1_resource,
893 ARRAY_SIZE(atmel_psif1_resource))) 898 ARRAY_SIZE(atmel_psif1_resource)))
894 goto err_add_resources; 899 goto err_add_resources;
895 atmel_psif1_pclk.dev = &pdev->dev; 900 atmel_psif1_pclk.dev = &pdev->dev;
896 select_peripheral(PB(11), PERIPH_A, 0); /* CLOCK */ 901 select_peripheral(PIOB, pin_mask, PERIPH_A, 0);
897 select_peripheral(PB(12), PERIPH_A, 0); /* DATA */
898 break; 902 break;
899 default: 903 default:
900 return NULL; 904 return NULL;
@@ -958,26 +962,30 @@ DEV_CLK(usart, atmel_usart3, pba, 6);
958 962
959static inline void configure_usart0_pins(void) 963static inline void configure_usart0_pins(void)
960{ 964{
961 select_peripheral(PA(8), PERIPH_B, 0); /* RXD */ 965 u32 pin_mask = (1 << 8) | (1 << 9); /* RXD & TXD */
962 select_peripheral(PA(9), PERIPH_B, 0); /* TXD */ 966
967 select_peripheral(PIOA, pin_mask, PERIPH_B, 0);
963} 968}
964 969
965static inline void configure_usart1_pins(void) 970static inline void configure_usart1_pins(void)
966{ 971{
967 select_peripheral(PA(17), PERIPH_A, 0); /* RXD */ 972 u32 pin_mask = (1 << 17) | (1 << 18); /* RXD & TXD */
968 select_peripheral(PA(18), PERIPH_A, 0); /* TXD */ 973
974 select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
969} 975}
970 976
971static inline void configure_usart2_pins(void) 977static inline void configure_usart2_pins(void)
972{ 978{
973 select_peripheral(PB(26), PERIPH_B, 0); /* RXD */ 979 u32 pin_mask = (1 << 26) | (1 << 27); /* RXD & TXD */
974 select_peripheral(PB(27), PERIPH_B, 0); /* TXD */ 980
981 select_peripheral(PIOB, pin_mask, PERIPH_B, 0);
975} 982}
976 983
977static inline void configure_usart3_pins(void) 984static inline void configure_usart3_pins(void)
978{ 985{
979 select_peripheral(PB(18), PERIPH_B, 0); /* RXD */ 986 u32 pin_mask = (1 << 18) | (1 << 17); /* RXD & TXD */
980 select_peripheral(PB(17), PERIPH_B, 0); /* TXD */ 987
988 select_peripheral(PIOB, pin_mask, PERIPH_B, 0);
981} 989}
982 990
983static struct platform_device *__initdata at32_usarts[4]; 991static struct platform_device *__initdata at32_usarts[4];
@@ -1057,59 +1065,69 @@ struct platform_device *__init
1057at32_add_device_eth(unsigned int id, struct eth_platform_data *data) 1065at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
1058{ 1066{
1059 struct platform_device *pdev; 1067 struct platform_device *pdev;
1068 u32 pin_mask;
1060 1069
1061 switch (id) { 1070 switch (id) {
1062 case 0: 1071 case 0:
1063 pdev = &macb0_device; 1072 pdev = &macb0_device;
1064 1073
1065 select_peripheral(PC(3), PERIPH_A, 0); /* TXD0 */ 1074 pin_mask = (1 << 3); /* TXD0 */
1066 select_peripheral(PC(4), PERIPH_A, 0); /* TXD1 */ 1075 pin_mask |= (1 << 4); /* TXD1 */
1067 select_peripheral(PC(7), PERIPH_A, 0); /* TXEN */ 1076 pin_mask |= (1 << 7); /* TXEN */
1068 select_peripheral(PC(8), PERIPH_A, 0); /* TXCK */ 1077 pin_mask |= (1 << 8); /* TXCK */
1069 select_peripheral(PC(9), PERIPH_A, 0); /* RXD0 */ 1078 pin_mask |= (1 << 9); /* RXD0 */
1070 select_peripheral(PC(10), PERIPH_A, 0); /* RXD1 */ 1079 pin_mask |= (1 << 10); /* RXD1 */
1071 select_peripheral(PC(13), PERIPH_A, 0); /* RXER */ 1080 pin_mask |= (1 << 13); /* RXER */
1072 select_peripheral(PC(15), PERIPH_A, 0); /* RXDV */ 1081 pin_mask |= (1 << 15); /* RXDV */
1073 select_peripheral(PC(16), PERIPH_A, 0); /* MDC */ 1082 pin_mask |= (1 << 16); /* MDC */
1074 select_peripheral(PC(17), PERIPH_A, 0); /* MDIO */ 1083 pin_mask |= (1 << 17); /* MDIO */
1075 1084
1076 if (!data->is_rmii) { 1085 if (!data->is_rmii) {
1077 select_peripheral(PC(0), PERIPH_A, 0); /* COL */ 1086 pin_mask |= (1 << 0); /* COL */
1078 select_peripheral(PC(1), PERIPH_A, 0); /* CRS */ 1087 pin_mask |= (1 << 1); /* CRS */
1079 select_peripheral(PC(2), PERIPH_A, 0); /* TXER */ 1088 pin_mask |= (1 << 2); /* TXER */
1080 select_peripheral(PC(5), PERIPH_A, 0); /* TXD2 */ 1089 pin_mask |= (1 << 5); /* TXD2 */
1081 select_peripheral(PC(6), PERIPH_A, 0); /* TXD3 */ 1090 pin_mask |= (1 << 6); /* TXD3 */
1082 select_peripheral(PC(11), PERIPH_A, 0); /* RXD2 */ 1091 pin_mask |= (1 << 11); /* RXD2 */
1083 select_peripheral(PC(12), PERIPH_A, 0); /* RXD3 */ 1092 pin_mask |= (1 << 12); /* RXD3 */
1084 select_peripheral(PC(14), PERIPH_A, 0); /* RXCK */ 1093 pin_mask |= (1 << 14); /* RXCK */
1085 select_peripheral(PC(18), PERIPH_A, 0); /* SPD */ 1094 pin_mask |= (1 << 18); /* SPD */
1086 } 1095 }
1096
1097 select_peripheral(PIOC, pin_mask, PERIPH_A, 0);
1098
1087 break; 1099 break;
1088 1100
1089 case 1: 1101 case 1:
1090 pdev = &macb1_device; 1102 pdev = &macb1_device;
1091 1103
1092 select_peripheral(PD(13), PERIPH_B, 0); /* TXD0 */ 1104 pin_mask = (1 << 13); /* TXD0 */
1093 select_peripheral(PD(14), PERIPH_B, 0); /* TXD1 */ 1105 pin_mask |= (1 << 14); /* TXD1 */
1094 select_peripheral(PD(11), PERIPH_B, 0); /* TXEN */ 1106 pin_mask |= (1 << 11); /* TXEN */
1095 select_peripheral(PD(12), PERIPH_B, 0); /* TXCK */ 1107 pin_mask |= (1 << 12); /* TXCK */
1096 select_peripheral(PD(10), PERIPH_B, 0); /* RXD0 */ 1108 pin_mask |= (1 << 10); /* RXD0 */
1097 select_peripheral(PD(6), PERIPH_B, 0); /* RXD1 */ 1109 pin_mask |= (1 << 6); /* RXD1 */
1098 select_peripheral(PD(5), PERIPH_B, 0); /* RXER */ 1110 pin_mask |= (1 << 5); /* RXER */
1099 select_peripheral(PD(4), PERIPH_B, 0); /* RXDV */ 1111 pin_mask |= (1 << 4); /* RXDV */
1100 select_peripheral(PD(3), PERIPH_B, 0); /* MDC */ 1112 pin_mask |= (1 << 3); /* MDC */
1101 select_peripheral(PD(2), PERIPH_B, 0); /* MDIO */ 1113 pin_mask |= (1 << 2); /* MDIO */
1114
1115 if (!data->is_rmii)
1116 pin_mask |= (1 << 15); /* SPD */
1117
1118 select_peripheral(PIOD, pin_mask, PERIPH_B, 0);
1102 1119
1103 if (!data->is_rmii) { 1120 if (!data->is_rmii) {
1104 select_peripheral(PC(19), PERIPH_B, 0); /* COL */ 1121 pin_mask = (1 << 19); /* COL */
1105 select_peripheral(PC(23), PERIPH_B, 0); /* CRS */ 1122 pin_mask |= (1 << 23); /* CRS */
1106 select_peripheral(PC(26), PERIPH_B, 0); /* TXER */ 1123 pin_mask |= (1 << 26); /* TXER */
1107 select_peripheral(PC(27), PERIPH_B, 0); /* TXD2 */ 1124 pin_mask |= (1 << 27); /* TXD2 */
1108 select_peripheral(PC(28), PERIPH_B, 0); /* TXD3 */ 1125 pin_mask |= (1 << 28); /* TXD3 */
1109 select_peripheral(PC(29), PERIPH_B, 0); /* RXD2 */ 1126 pin_mask |= (1 << 29); /* RXD2 */
1110 select_peripheral(PC(30), PERIPH_B, 0); /* RXD3 */ 1127 pin_mask |= (1 << 30); /* RXD3 */
1111 select_peripheral(PC(24), PERIPH_B, 0); /* RXCK */ 1128 pin_mask |= (1 << 24); /* RXCK */
1112 select_peripheral(PD(15), PERIPH_B, 0); /* SPD */ 1129
1130 select_peripheral(PIOC, pin_mask, PERIPH_B, 0);
1113 } 1131 }
1114 break; 1132 break;
1115 1133
@@ -1177,23 +1195,28 @@ at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
1177 { GPIO_PIN_PB(2), GPIO_PIN_PB(3), 1195 { GPIO_PIN_PB(2), GPIO_PIN_PB(3),
1178 GPIO_PIN_PB(4), GPIO_PIN_PA(27), }; 1196 GPIO_PIN_PB(4), GPIO_PIN_PA(27), };
1179 struct platform_device *pdev; 1197 struct platform_device *pdev;
1198 u32 pin_mask;
1180 1199
1181 switch (id) { 1200 switch (id) {
1182 case 0: 1201 case 0:
1183 pdev = &atmel_spi0_device; 1202 pdev = &atmel_spi0_device;
1203 pin_mask = (1 << 1) | (1 << 2); /* MOSI & SCK */
1204
1184 /* pullup MISO so a level is always defined */ 1205 /* pullup MISO so a level is always defined */
1185 select_peripheral(PA(0), PERIPH_A, AT32_GPIOF_PULLUP); 1206 select_peripheral(PIOA, (1 << 0), PERIPH_A, AT32_GPIOF_PULLUP);
1186 select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */ 1207 select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
1187 select_peripheral(PA(2), PERIPH_A, 0); /* SCK */ 1208
1188 at32_spi_setup_slaves(0, b, n, spi0_pins); 1209 at32_spi_setup_slaves(0, b, n, spi0_pins);
1189 break; 1210 break;
1190 1211
1191 case 1: 1212 case 1:
1192 pdev = &atmel_spi1_device; 1213 pdev = &atmel_spi1_device;
1214 pin_mask = (1 << 1) | (1 << 5); /* MOSI */
1215
1193 /* pullup MISO so a level is always defined */ 1216 /* pullup MISO so a level is always defined */
1194 select_peripheral(PB(0), PERIPH_B, AT32_GPIOF_PULLUP); 1217 select_peripheral(PIOB, (1 << 0), PERIPH_B, AT32_GPIOF_PULLUP);
1195 select_peripheral(PB(1), PERIPH_B, 0); /* MOSI */ 1218 select_peripheral(PIOB, pin_mask, PERIPH_B, 0);
1196 select_peripheral(PB(5), PERIPH_B, 0); /* SCK */ 1219
1197 at32_spi_setup_slaves(1, b, n, spi1_pins); 1220 at32_spi_setup_slaves(1, b, n, spi1_pins);
1198 break; 1221 break;
1199 1222
@@ -1226,6 +1249,7 @@ struct platform_device *__init at32_add_device_twi(unsigned int id,
1226 unsigned int n) 1249 unsigned int n)
1227{ 1250{
1228 struct platform_device *pdev; 1251 struct platform_device *pdev;
1252 u32 pin_mask;
1229 1253
1230 if (id != 0) 1254 if (id != 0)
1231 return NULL; 1255 return NULL;
@@ -1238,8 +1262,9 @@ struct platform_device *__init at32_add_device_twi(unsigned int id,
1238 ARRAY_SIZE(atmel_twi0_resource))) 1262 ARRAY_SIZE(atmel_twi0_resource)))
1239 goto err_add_resources; 1263 goto err_add_resources;
1240 1264
1241 select_peripheral(PA(6), PERIPH_A, 0); /* SDA */ 1265 pin_mask = (1 << 6) | (1 << 7); /* SDA & SDL */
1242 select_peripheral(PA(7), PERIPH_A, 0); /* SDL */ 1266
1267 select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
1243 1268
1244 atmel_twi0_pclk.dev = &pdev->dev; 1269 atmel_twi0_pclk.dev = &pdev->dev;
1245 1270
@@ -1272,10 +1297,16 @@ static struct clk atmel_mci0_pclk = {
1272struct platform_device *__init 1297struct platform_device *__init
1273at32_add_device_mci(unsigned int id, struct mci_platform_data *data) 1298at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
1274{ 1299{
1275 struct mci_platform_data _data;
1276 struct platform_device *pdev; 1300 struct platform_device *pdev;
1301 struct dw_dma_slave *dws;
1302 u32 pioa_mask;
1303 u32 piob_mask;
1277 1304
1278 if (id != 0) 1305 if (id != 0 || !data)
1306 return NULL;
1307
1308 /* Must have at least one usable slot */
1309 if (!data->slot[0].bus_width && !data->slot[1].bus_width)
1279 return NULL; 1310 return NULL;
1280 1311
1281 pdev = platform_device_alloc("atmel_mci", id); 1312 pdev = platform_device_alloc("atmel_mci", id);
@@ -1286,28 +1317,80 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
1286 ARRAY_SIZE(atmel_mci0_resource))) 1317 ARRAY_SIZE(atmel_mci0_resource)))
1287 goto fail; 1318 goto fail;
1288 1319
1289 if (!data) { 1320 if (data->dma_slave)
1290 data = &_data; 1321 dws = kmemdup(to_dw_dma_slave(data->dma_slave),
1291 memset(data, -1, sizeof(struct mci_platform_data)); 1322 sizeof(struct dw_dma_slave), GFP_KERNEL);
1292 data->detect_pin = GPIO_PIN_NONE; 1323 else
1293 data->wp_pin = GPIO_PIN_NONE; 1324 dws = kzalloc(sizeof(struct dw_dma_slave), GFP_KERNEL);
1294 } 1325
1326 dws->slave.dev = &pdev->dev;
1327 dws->slave.dma_dev = &dw_dmac0_device.dev;
1328 dws->slave.reg_width = DMA_SLAVE_WIDTH_32BIT;
1329 dws->cfg_hi = (DWC_CFGH_SRC_PER(0)
1330 | DWC_CFGH_DST_PER(1));
1331 dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL
1332 | DWC_CFGL_HS_SRC_POL);
1333
1334 data->dma_slave = &dws->slave;
1295 1335
1296 if (platform_device_add_data(pdev, data, 1336 if (platform_device_add_data(pdev, data,
1297 sizeof(struct mci_platform_data))) 1337 sizeof(struct mci_platform_data)))
1298 goto fail; 1338 goto fail;
1299 1339
1300 select_peripheral(PA(10), PERIPH_A, 0); /* CLK */ 1340 /* CLK line is common to both slots */
1301 select_peripheral(PA(11), PERIPH_A, 0); /* CMD */ 1341 pioa_mask = 1 << 10;
1302 select_peripheral(PA(12), PERIPH_A, 0); /* DATA0 */
1303 select_peripheral(PA(13), PERIPH_A, 0); /* DATA1 */
1304 select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */
1305 select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */
1306 1342
1307 if (gpio_is_valid(data->detect_pin)) 1343 switch (data->slot[0].bus_width) {
1308 at32_select_gpio(data->detect_pin, 0); 1344 case 4:
1309 if (gpio_is_valid(data->wp_pin)) 1345 pioa_mask |= 1 << 13; /* DATA1 */
1310 at32_select_gpio(data->wp_pin, 0); 1346 pioa_mask |= 1 << 14; /* DATA2 */
1347 pioa_mask |= 1 << 15; /* DATA3 */
1348 /* fall through */
1349 case 1:
1350 pioa_mask |= 1 << 11; /* CMD */
1351 pioa_mask |= 1 << 12; /* DATA0 */
1352
1353 if (gpio_is_valid(data->slot[0].detect_pin))
1354 at32_select_gpio(data->slot[0].detect_pin, 0);
1355 if (gpio_is_valid(data->slot[0].wp_pin))
1356 at32_select_gpio(data->slot[0].wp_pin, 0);
1357 break;
1358 case 0:
1359 /* Slot is unused */
1360 break;
1361 default:
1362 goto fail;
1363 }
1364
1365 select_peripheral(PIOA, pioa_mask, PERIPH_A, 0);
1366 piob_mask = 0;
1367
1368 switch (data->slot[1].bus_width) {
1369 case 4:
1370 piob_mask |= 1 << 8; /* DATA1 */
1371 piob_mask |= 1 << 9; /* DATA2 */
1372 piob_mask |= 1 << 10; /* DATA3 */
1373 /* fall through */
1374 case 1:
1375 piob_mask |= 1 << 6; /* CMD */
1376 piob_mask |= 1 << 7; /* DATA0 */
1377 select_peripheral(PIOB, piob_mask, PERIPH_B, 0);
1378
1379 if (gpio_is_valid(data->slot[1].detect_pin))
1380 at32_select_gpio(data->slot[1].detect_pin, 0);
1381 if (gpio_is_valid(data->slot[1].wp_pin))
1382 at32_select_gpio(data->slot[1].wp_pin, 0);
1383 break;
1384 case 0:
1385 /* Slot is unused */
1386 break;
1387 default:
1388 if (!data->slot[0].bus_width)
1389 goto fail;
1390
1391 data->slot[1].bus_width = 0;
1392 break;
1393 }
1311 1394
1312 atmel_mci0_pclk.dev = &pdev->dev; 1395 atmel_mci0_pclk.dev = &pdev->dev;
1313 1396
@@ -1353,13 +1436,14 @@ static struct clk atmel_lcdfb0_pixclk = {
1353struct platform_device *__init 1436struct platform_device *__init
1354at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data, 1437at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
1355 unsigned long fbmem_start, unsigned long fbmem_len, 1438 unsigned long fbmem_start, unsigned long fbmem_len,
1356 unsigned int pin_config) 1439 u64 pin_mask)
1357{ 1440{
1358 struct platform_device *pdev; 1441 struct platform_device *pdev;
1359 struct atmel_lcdfb_info *info; 1442 struct atmel_lcdfb_info *info;
1360 struct fb_monspecs *monspecs; 1443 struct fb_monspecs *monspecs;
1361 struct fb_videomode *modedb; 1444 struct fb_videomode *modedb;
1362 unsigned int modedb_size; 1445 unsigned int modedb_size;
1446 u32 portc_mask, portd_mask, porte_mask;
1363 1447
1364 /* 1448 /*
1365 * Do a deep copy of the fb data, monspecs and modedb. Make 1449 * Do a deep copy of the fb data, monspecs and modedb. Make
@@ -1381,76 +1465,21 @@ at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
1381 case 0: 1465 case 0:
1382 pdev = &atmel_lcdfb0_device; 1466 pdev = &atmel_lcdfb0_device;
1383 1467
1384 switch (pin_config) { 1468 if (pin_mask == 0ULL)
1385 case 0: 1469 /* Default to "full" lcdc control signals and 24bit */
1386 select_peripheral(PC(19), PERIPH_A, 0); /* CC */ 1470 pin_mask = ATMEL_LCDC_PRI_24BIT | ATMEL_LCDC_PRI_CONTROL;
1387 select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */ 1471
1388 select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */ 1472 /* LCDC on port C */
1389 select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */ 1473 portc_mask = (pin_mask & 0xfff80000) >> 19;
1390 select_peripheral(PC(23), PERIPH_A, 0); /* DVAL */ 1474 select_peripheral(PIOC, portc_mask, PERIPH_A, 0);
1391 select_peripheral(PC(24), PERIPH_A, 0); /* MODE */ 1475
1392 select_peripheral(PC(25), PERIPH_A, 0); /* PWR */ 1476 /* LCDC on port D */
1393 select_peripheral(PC(26), PERIPH_A, 0); /* DATA0 */ 1477 portd_mask = pin_mask & 0x0003ffff;
1394 select_peripheral(PC(27), PERIPH_A, 0); /* DATA1 */ 1478 select_peripheral(PIOD, portd_mask, PERIPH_A, 0);
1395 select_peripheral(PC(28), PERIPH_A, 0); /* DATA2 */ 1479
1396 select_peripheral(PC(29), PERIPH_A, 0); /* DATA3 */ 1480 /* LCDC on port E */
1397 select_peripheral(PC(30), PERIPH_A, 0); /* DATA4 */ 1481 porte_mask = (pin_mask >> 32) & 0x0007ffff;
1398 select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */ 1482 select_peripheral(PIOE, porte_mask, PERIPH_B, 0);
1399 select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
1400 select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
1401 select_peripheral(PD(2), PERIPH_A, 0); /* DATA8 */
1402 select_peripheral(PD(3), PERIPH_A, 0); /* DATA9 */
1403 select_peripheral(PD(4), PERIPH_A, 0); /* DATA10 */
1404 select_peripheral(PD(5), PERIPH_A, 0); /* DATA11 */
1405 select_peripheral(PD(6), PERIPH_A, 0); /* DATA12 */
1406 select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
1407 select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
1408 select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
1409 select_peripheral(PD(10), PERIPH_A, 0); /* DATA16 */
1410 select_peripheral(PD(11), PERIPH_A, 0); /* DATA17 */
1411 select_peripheral(PD(12), PERIPH_A, 0); /* DATA18 */
1412 select_peripheral(PD(13), PERIPH_A, 0); /* DATA19 */
1413 select_peripheral(PD(14), PERIPH_A, 0); /* DATA20 */
1414 select_peripheral(PD(15), PERIPH_A, 0); /* DATA21 */
1415 select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
1416 select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
1417 break;
1418 case 1:
1419 select_peripheral(PE(0), PERIPH_B, 0); /* CC */
1420 select_peripheral(PC(20), PERIPH_A, 0); /* HSYNC */
1421 select_peripheral(PC(21), PERIPH_A, 0); /* PCLK */
1422 select_peripheral(PC(22), PERIPH_A, 0); /* VSYNC */
1423 select_peripheral(PE(1), PERIPH_B, 0); /* DVAL */
1424 select_peripheral(PE(2), PERIPH_B, 0); /* MODE */
1425 select_peripheral(PC(25), PERIPH_A, 0); /* PWR */
1426 select_peripheral(PE(3), PERIPH_B, 0); /* DATA0 */
1427 select_peripheral(PE(4), PERIPH_B, 0); /* DATA1 */
1428 select_peripheral(PE(5), PERIPH_B, 0); /* DATA2 */
1429 select_peripheral(PE(6), PERIPH_B, 0); /* DATA3 */
1430 select_peripheral(PE(7), PERIPH_B, 0); /* DATA4 */
1431 select_peripheral(PC(31), PERIPH_A, 0); /* DATA5 */
1432 select_peripheral(PD(0), PERIPH_A, 0); /* DATA6 */
1433 select_peripheral(PD(1), PERIPH_A, 0); /* DATA7 */
1434 select_peripheral(PE(8), PERIPH_B, 0); /* DATA8 */
1435 select_peripheral(PE(9), PERIPH_B, 0); /* DATA9 */
1436 select_peripheral(PE(10), PERIPH_B, 0); /* DATA10 */
1437 select_peripheral(PE(11), PERIPH_B, 0); /* DATA11 */
1438 select_peripheral(PE(12), PERIPH_B, 0); /* DATA12 */
1439 select_peripheral(PD(7), PERIPH_A, 0); /* DATA13 */
1440 select_peripheral(PD(8), PERIPH_A, 0); /* DATA14 */
1441 select_peripheral(PD(9), PERIPH_A, 0); /* DATA15 */
1442 select_peripheral(PE(13), PERIPH_B, 0); /* DATA16 */
1443 select_peripheral(PE(14), PERIPH_B, 0); /* DATA17 */
1444 select_peripheral(PE(15), PERIPH_B, 0); /* DATA18 */
1445 select_peripheral(PE(16), PERIPH_B, 0); /* DATA19 */
1446 select_peripheral(PE(17), PERIPH_B, 0); /* DATA20 */
1447 select_peripheral(PE(18), PERIPH_B, 0); /* DATA21 */
1448 select_peripheral(PD(16), PERIPH_A, 0); /* DATA22 */
1449 select_peripheral(PD(17), PERIPH_A, 0); /* DATA23 */
1450 break;
1451 default:
1452 goto err_invalid_id;
1453 }
1454 1483
1455 clk_set_parent(&atmel_lcdfb0_pixclk, &pll0); 1484 clk_set_parent(&atmel_lcdfb0_pixclk, &pll0);
1456 clk_set_rate(&atmel_lcdfb0_pixclk, clk_get_rate(&pll0)); 1485 clk_set_rate(&atmel_lcdfb0_pixclk, clk_get_rate(&pll0));
@@ -1499,6 +1528,7 @@ static struct clk atmel_pwm0_mck = {
1499struct platform_device *__init at32_add_device_pwm(u32 mask) 1528struct platform_device *__init at32_add_device_pwm(u32 mask)
1500{ 1529{
1501 struct platform_device *pdev; 1530 struct platform_device *pdev;
1531 u32 pin_mask;
1502 1532
1503 if (!mask) 1533 if (!mask)
1504 return NULL; 1534 return NULL;
@@ -1514,14 +1544,21 @@ struct platform_device *__init at32_add_device_pwm(u32 mask)
1514 if (platform_device_add_data(pdev, &mask, sizeof(mask))) 1544 if (platform_device_add_data(pdev, &mask, sizeof(mask)))
1515 goto out_free_pdev; 1545 goto out_free_pdev;
1516 1546
1547 pin_mask = 0;
1517 if (mask & (1 << 0)) 1548 if (mask & (1 << 0))
1518 select_peripheral(PA(28), PERIPH_A, 0); 1549 pin_mask |= (1 << 28);
1519 if (mask & (1 << 1)) 1550 if (mask & (1 << 1))
1520 select_peripheral(PA(29), PERIPH_A, 0); 1551 pin_mask |= (1 << 29);
1552 if (pin_mask > 0)
1553 select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
1554
1555 pin_mask = 0;
1521 if (mask & (1 << 2)) 1556 if (mask & (1 << 2))
1522 select_peripheral(PA(21), PERIPH_B, 0); 1557 pin_mask |= (1 << 21);
1523 if (mask & (1 << 3)) 1558 if (mask & (1 << 3))
1524 select_peripheral(PA(22), PERIPH_B, 0); 1559 pin_mask |= (1 << 22);
1560 if (pin_mask > 0)
1561 select_peripheral(PIOA, pin_mask, PERIPH_B, 0);
1525 1562
1526 atmel_pwm0_mck.dev = &pdev->dev; 1563 atmel_pwm0_mck.dev = &pdev->dev;
1527 1564
@@ -1562,52 +1599,65 @@ struct platform_device *__init
1562at32_add_device_ssc(unsigned int id, unsigned int flags) 1599at32_add_device_ssc(unsigned int id, unsigned int flags)
1563{ 1600{
1564 struct platform_device *pdev; 1601 struct platform_device *pdev;
1602 u32 pin_mask = 0;
1565 1603
1566 switch (id) { 1604 switch (id) {
1567 case 0: 1605 case 0:
1568 pdev = &ssc0_device; 1606 pdev = &ssc0_device;
1569 if (flags & ATMEL_SSC_RF) 1607 if (flags & ATMEL_SSC_RF)
1570 select_peripheral(PA(21), PERIPH_A, 0); /* RF */ 1608 pin_mask |= (1 << 21); /* RF */
1571 if (flags & ATMEL_SSC_RK) 1609 if (flags & ATMEL_SSC_RK)
1572 select_peripheral(PA(22), PERIPH_A, 0); /* RK */ 1610 pin_mask |= (1 << 22); /* RK */
1573 if (flags & ATMEL_SSC_TK) 1611 if (flags & ATMEL_SSC_TK)
1574 select_peripheral(PA(23), PERIPH_A, 0); /* TK */ 1612 pin_mask |= (1 << 23); /* TK */
1575 if (flags & ATMEL_SSC_TF) 1613 if (flags & ATMEL_SSC_TF)
1576 select_peripheral(PA(24), PERIPH_A, 0); /* TF */ 1614 pin_mask |= (1 << 24); /* TF */
1577 if (flags & ATMEL_SSC_TD) 1615 if (flags & ATMEL_SSC_TD)
1578 select_peripheral(PA(25), PERIPH_A, 0); /* TD */ 1616 pin_mask |= (1 << 25); /* TD */
1579 if (flags & ATMEL_SSC_RD) 1617 if (flags & ATMEL_SSC_RD)
1580 select_peripheral(PA(26), PERIPH_A, 0); /* RD */ 1618 pin_mask |= (1 << 26); /* RD */
1619
1620 if (pin_mask > 0)
1621 select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
1622
1581 break; 1623 break;
1582 case 1: 1624 case 1:
1583 pdev = &ssc1_device; 1625 pdev = &ssc1_device;
1584 if (flags & ATMEL_SSC_RF) 1626 if (flags & ATMEL_SSC_RF)
1585 select_peripheral(PA(0), PERIPH_B, 0); /* RF */ 1627 pin_mask |= (1 << 0); /* RF */
1586 if (flags & ATMEL_SSC_RK) 1628 if (flags & ATMEL_SSC_RK)
1587 select_peripheral(PA(1), PERIPH_B, 0); /* RK */ 1629 pin_mask |= (1 << 1); /* RK */
1588 if (flags & ATMEL_SSC_TK) 1630 if (flags & ATMEL_SSC_TK)
1589 select_peripheral(PA(2), PERIPH_B, 0); /* TK */ 1631 pin_mask |= (1 << 2); /* TK */
1590 if (flags & ATMEL_SSC_TF) 1632 if (flags & ATMEL_SSC_TF)
1591 select_peripheral(PA(3), PERIPH_B, 0); /* TF */ 1633 pin_mask |= (1 << 3); /* TF */
1592 if (flags & ATMEL_SSC_TD) 1634 if (flags & ATMEL_SSC_TD)
1593 select_peripheral(PA(4), PERIPH_B, 0); /* TD */ 1635 pin_mask |= (1 << 4); /* TD */
1594 if (flags & ATMEL_SSC_RD) 1636 if (flags & ATMEL_SSC_RD)
1595 select_peripheral(PA(5), PERIPH_B, 0); /* RD */ 1637 pin_mask |= (1 << 5); /* RD */
1638
1639 if (pin_mask > 0)
1640 select_peripheral(PIOA, pin_mask, PERIPH_B, 0);
1641
1596 break; 1642 break;
1597 case 2: 1643 case 2:
1598 pdev = &ssc2_device; 1644 pdev = &ssc2_device;
1599 if (flags & ATMEL_SSC_TD) 1645 if (flags & ATMEL_SSC_TD)
1600 select_peripheral(PB(13), PERIPH_A, 0); /* TD */ 1646 pin_mask |= (1 << 13); /* TD */
1601 if (flags & ATMEL_SSC_RD) 1647 if (flags & ATMEL_SSC_RD)
1602 select_peripheral(PB(14), PERIPH_A, 0); /* RD */ 1648 pin_mask |= (1 << 14); /* RD */
1603 if (flags & ATMEL_SSC_TK) 1649 if (flags & ATMEL_SSC_TK)
1604 select_peripheral(PB(15), PERIPH_A, 0); /* TK */ 1650 pin_mask |= (1 << 15); /* TK */
1605 if (flags & ATMEL_SSC_TF) 1651 if (flags & ATMEL_SSC_TF)
1606 select_peripheral(PB(16), PERIPH_A, 0); /* TF */ 1652 pin_mask |= (1 << 16); /* TF */
1607 if (flags & ATMEL_SSC_RF) 1653 if (flags & ATMEL_SSC_RF)
1608 select_peripheral(PB(17), PERIPH_A, 0); /* RF */ 1654 pin_mask |= (1 << 17); /* RF */
1609 if (flags & ATMEL_SSC_RK) 1655 if (flags & ATMEL_SSC_RK)
1610 select_peripheral(PB(18), PERIPH_A, 0); /* RK */ 1656 pin_mask |= (1 << 18); /* RK */
1657
1658 if (pin_mask > 0)
1659 select_peripheral(PIOB, pin_mask, PERIPH_A, 0);
1660
1611 break; 1661 break;
1612 default: 1662 default:
1613 return NULL; 1663 return NULL;
@@ -1745,14 +1795,15 @@ static int __init at32_init_ide_or_cf(struct platform_device *pdev,
1745 unsigned int cs, unsigned int extint) 1795 unsigned int cs, unsigned int extint)
1746{ 1796{
1747 static unsigned int extint_pin_map[4] __initdata = { 1797 static unsigned int extint_pin_map[4] __initdata = {
1748 GPIO_PIN_PB(25), 1798 (1 << 25),
1749 GPIO_PIN_PB(26), 1799 (1 << 26),
1750 GPIO_PIN_PB(27), 1800 (1 << 27),
1751 GPIO_PIN_PB(28), 1801 (1 << 28),
1752 }; 1802 };
1753 static bool common_pins_initialized __initdata = false; 1803 static bool common_pins_initialized __initdata = false;
1754 unsigned int extint_pin; 1804 unsigned int extint_pin;
1755 int ret; 1805 int ret;
1806 u32 pin_mask;
1756 1807
1757 if (extint >= ARRAY_SIZE(extint_pin_map)) 1808 if (extint >= ARRAY_SIZE(extint_pin_map))
1758 return -EINVAL; 1809 return -EINVAL;
@@ -1766,7 +1817,8 @@ static int __init at32_init_ide_or_cf(struct platform_device *pdev,
1766 if (ret) 1817 if (ret)
1767 return ret; 1818 return ret;
1768 1819
1769 select_peripheral(PE(21), PERIPH_A, 0); /* NCS4 -> OE_N */ 1820 /* NCS4 -> OE_N */
1821 select_peripheral(PIOE, (1 << 21), PERIPH_A, 0);
1770 hmatrix_sfr_set_bits(HMATRIX_SLAVE_EBI, HMATRIX_EBI_CF0_ENABLE); 1822 hmatrix_sfr_set_bits(HMATRIX_SLAVE_EBI, HMATRIX_EBI_CF0_ENABLE);
1771 break; 1823 break;
1772 case 5: 1824 case 5:
@@ -1776,7 +1828,8 @@ static int __init at32_init_ide_or_cf(struct platform_device *pdev,
1776 if (ret) 1828 if (ret)
1777 return ret; 1829 return ret;
1778 1830
1779 select_peripheral(PE(22), PERIPH_A, 0); /* NCS5 -> OE_N */ 1831 /* NCS5 -> OE_N */
1832 select_peripheral(PIOE, (1 << 22), PERIPH_A, 0);
1780 hmatrix_sfr_set_bits(HMATRIX_SLAVE_EBI, HMATRIX_EBI_CF1_ENABLE); 1833 hmatrix_sfr_set_bits(HMATRIX_SLAVE_EBI, HMATRIX_EBI_CF1_ENABLE);
1781 break; 1834 break;
1782 default: 1835 default:
@@ -1784,14 +1837,17 @@ static int __init at32_init_ide_or_cf(struct platform_device *pdev,
1784 } 1837 }
1785 1838
1786 if (!common_pins_initialized) { 1839 if (!common_pins_initialized) {
1787 select_peripheral(PE(19), PERIPH_A, 0); /* CFCE1 -> CS0_N */ 1840 pin_mask = (1 << 19); /* CFCE1 -> CS0_N */
1788 select_peripheral(PE(20), PERIPH_A, 0); /* CFCE2 -> CS1_N */ 1841 pin_mask |= (1 << 20); /* CFCE2 -> CS1_N */
1789 select_peripheral(PE(23), PERIPH_A, 0); /* CFRNW -> DIR */ 1842 pin_mask |= (1 << 23); /* CFRNW -> DIR */
1790 select_peripheral(PE(24), PERIPH_A, 0); /* NWAIT <- IORDY */ 1843 pin_mask |= (1 << 24); /* NWAIT <- IORDY */
1844
1845 select_peripheral(PIOE, pin_mask, PERIPH_A, 0);
1846
1791 common_pins_initialized = true; 1847 common_pins_initialized = true;
1792 } 1848 }
1793 1849
1794 at32_select_periph(extint_pin, GPIO_PERIPH_A, AT32_GPIOF_DEGLITCH); 1850 select_peripheral(PIOB, extint_pin, PERIPH_A, AT32_GPIOF_DEGLITCH);
1795 1851
1796 pdev->resource[1].start = EIM_IRQ_BASE + extint; 1852 pdev->resource[1].start = EIM_IRQ_BASE + extint;
1797 pdev->resource[1].end = pdev->resource[1].start; 1853 pdev->resource[1].end = pdev->resource[1].start;
@@ -1930,6 +1986,7 @@ at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data)
1930{ 1986{
1931 struct platform_device *pdev; 1987 struct platform_device *pdev;
1932 struct ac97c_platform_data _data; 1988 struct ac97c_platform_data _data;
1989 u32 pin_mask;
1933 1990
1934 if (id != 0) 1991 if (id != 0)
1935 return NULL; 1992 return NULL;
@@ -1956,10 +2013,10 @@ at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data)
1956 sizeof(struct ac97c_platform_data))) 2013 sizeof(struct ac97c_platform_data)))
1957 goto fail; 2014 goto fail;
1958 2015
1959 select_peripheral(PB(20), PERIPH_B, 0); /* SDO */ 2016 pin_mask = (1 << 20) | (1 << 21); /* SDO & SYNC */
1960 select_peripheral(PB(21), PERIPH_B, 0); /* SYNC */ 2017 pin_mask |= (1 << 22) | (1 << 23); /* SCLK & SDI */
1961 select_peripheral(PB(22), PERIPH_B, 0); /* SCLK */ 2018
1962 select_peripheral(PB(23), PERIPH_B, 0); /* SDI */ 2019 select_peripheral(PIOB, pin_mask, PERIPH_B, 0);
1963 2020
1964 /* TODO: gpio_is_valid(data->reset_pin) with kernel 2.6.26. */ 2021 /* TODO: gpio_is_valid(data->reset_pin) with kernel 2.6.26. */
1965 if (data->reset_pin != GPIO_PIN_NONE) 2022 if (data->reset_pin != GPIO_PIN_NONE)
@@ -2001,6 +2058,7 @@ static struct clk abdac0_sample_clk = {
2001struct platform_device *__init at32_add_device_abdac(unsigned int id) 2058struct platform_device *__init at32_add_device_abdac(unsigned int id)
2002{ 2059{
2003 struct platform_device *pdev; 2060 struct platform_device *pdev;
2061 u32 pin_mask;
2004 2062
2005 if (id != 0) 2063 if (id != 0)
2006 return NULL; 2064 return NULL;
@@ -2013,10 +2071,10 @@ struct platform_device *__init at32_add_device_abdac(unsigned int id)
2013 ARRAY_SIZE(abdac0_resource))) 2071 ARRAY_SIZE(abdac0_resource)))
2014 goto err_add_resources; 2072 goto err_add_resources;
2015 2073
2016 select_peripheral(PB(20), PERIPH_A, 0); /* DATA1 */ 2074 pin_mask = (1 << 20) | (1 << 22); /* DATA1 & DATAN1 */
2017 select_peripheral(PB(21), PERIPH_A, 0); /* DATA0 */ 2075 pin_mask |= (1 << 21) | (1 << 23); /* DATA0 & DATAN0 */
2018 select_peripheral(PB(22), PERIPH_A, 0); /* DATAN1 */ 2076
2019 select_peripheral(PB(23), PERIPH_A, 0); /* DATAN0 */ 2077 select_peripheral(PIOB, pin_mask, PERIPH_A, 0);
2020 2078
2021 abdac0_pclk.dev = &pdev->dev; 2079 abdac0_pclk.dev = &pdev->dev;
2022 abdac0_sample_clk.dev = &pdev->dev; 2080 abdac0_sample_clk.dev = &pdev->dev;
@@ -2073,7 +2131,7 @@ static struct clk gclk4 = {
2073 .index = 4, 2131 .index = 4,
2074}; 2132};
2075 2133
2076struct clk *at32_clock_list[] = { 2134static __initdata struct clk *init_clocks[] = {
2077 &osc32k, 2135 &osc32k,
2078 &osc0, 2136 &osc0,
2079 &osc1, 2137 &osc1,
@@ -2137,7 +2195,6 @@ struct clk *at32_clock_list[] = {
2137 &gclk3, 2195 &gclk3,
2138 &gclk4, 2196 &gclk4,
2139}; 2197};
2140unsigned int at32_nr_clocks = ARRAY_SIZE(at32_clock_list);
2141 2198
2142void __init setup_platform(void) 2199void __init setup_platform(void)
2143{ 2200{
@@ -2168,14 +2225,19 @@ void __init setup_platform(void)
2168 genclk_init_parent(&abdac0_sample_clk); 2225 genclk_init_parent(&abdac0_sample_clk);
2169 2226
2170 /* 2227 /*
2171 * Turn on all clocks that have at least one user already, and 2228 * Build initial dynamic clock list by registering all clocks
2172 * turn off everything else. We only do this for module 2229 * from the array.
2173 * clocks, and even though it isn't particularly pretty to 2230 * At the same time, turn on all clocks that have at least one
2174 * check the address of the mode function, it should do the 2231 * user already, and turn off everything else. We only do this
2175 * trick... 2232 * for module clocks, and even though it isn't particularly
2233 * pretty to check the address of the mode function, it should
2234 * do the trick...
2176 */ 2235 */
2177 for (i = 0; i < ARRAY_SIZE(at32_clock_list); i++) { 2236 for (i = 0; i < ARRAY_SIZE(init_clocks); i++) {
2178 struct clk *clk = at32_clock_list[i]; 2237 struct clk *clk = init_clocks[i];
2238
2239 /* first, register clock */
2240 at32_clk_register(clk);
2179 2241
2180 if (clk->users == 0) 2242 if (clk->users == 0)
2181 continue; 2243 continue;
diff --git a/arch/avr32/mach-at32ap/clock.c b/arch/avr32/mach-at32ap/clock.c
index 6c27ddac5adf..138a00a2a2d0 100644
--- a/arch/avr32/mach-at32ap/clock.c
+++ b/arch/avr32/mach-at32ap/clock.c
@@ -15,24 +15,40 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/list.h>
18 19
19#include <mach/chip.h> 20#include <mach/chip.h>
20 21
21#include "clock.h" 22#include "clock.h"
22 23
24/* at32 clock list */
25static LIST_HEAD(at32_clock_list);
26
23static DEFINE_SPINLOCK(clk_lock); 27static DEFINE_SPINLOCK(clk_lock);
28static DEFINE_SPINLOCK(clk_list_lock);
29
30void at32_clk_register(struct clk *clk)
31{
32 spin_lock(&clk_list_lock);
33 /* add the new item to the end of the list */
34 list_add_tail(&clk->list, &at32_clock_list);
35 spin_unlock(&clk_list_lock);
36}
24 37
25struct clk *clk_get(struct device *dev, const char *id) 38struct clk *clk_get(struct device *dev, const char *id)
26{ 39{
27 int i; 40 struct clk *clk;
28 41
29 for (i = 0; i < at32_nr_clocks; i++) { 42 spin_lock(&clk_list_lock);
30 struct clk *clk = at32_clock_list[i];
31 43
32 if (clk->dev == dev && strcmp(id, clk->name) == 0) 44 list_for_each_entry(clk, &at32_clock_list, list) {
45 if (clk->dev == dev && strcmp(id, clk->name) == 0) {
46 spin_unlock(&clk_list_lock);
33 return clk; 47 return clk;
48 }
34 } 49 }
35 50
51 spin_unlock(&clk_list_lock);
36 return ERR_PTR(-ENOENT); 52 return ERR_PTR(-ENOENT);
37} 53}
38EXPORT_SYMBOL(clk_get); 54EXPORT_SYMBOL(clk_get);
@@ -203,8 +219,8 @@ dump_clock(struct clk *parent, struct clkinf *r)
203 219
204 /* cost of this scan is small, but not linear... */ 220 /* cost of this scan is small, but not linear... */
205 r->nest = nest + NEST_DELTA; 221 r->nest = nest + NEST_DELTA;
206 for (i = 3; i < at32_nr_clocks; i++) { 222
207 clk = at32_clock_list[i]; 223 list_for_each_entry(clk, &at32_clock_list, list) {
208 if (clk->parent == parent) 224 if (clk->parent == parent)
209 dump_clock(clk, r); 225 dump_clock(clk, r);
210 } 226 }
@@ -215,6 +231,7 @@ static int clk_show(struct seq_file *s, void *unused)
215{ 231{
216 struct clkinf r; 232 struct clkinf r;
217 int i; 233 int i;
234 struct clk *clk;
218 235
219 /* show all the power manager registers */ 236 /* show all the power manager registers */
220 seq_printf(s, "MCCTRL = %8x\n", pm_readl(MCCTRL)); 237 seq_printf(s, "MCCTRL = %8x\n", pm_readl(MCCTRL));
@@ -234,14 +251,25 @@ static int clk_show(struct seq_file *s, void *unused)
234 251
235 seq_printf(s, "\n"); 252 seq_printf(s, "\n");
236 253
237 /* show clock tree as derived from the three oscillators
238 * we "know" are at the head of the list
239 */
240 r.s = s; 254 r.s = s;
241 r.nest = 0; 255 r.nest = 0;
242 dump_clock(at32_clock_list[0], &r); 256 /* protected from changes on the list while dumping */
243 dump_clock(at32_clock_list[1], &r); 257 spin_lock(&clk_list_lock);
244 dump_clock(at32_clock_list[2], &r); 258
259 /* show clock tree as derived from the three oscillators */
260 clk = clk_get(NULL, "osc32k");
261 dump_clock(clk, &r);
262 clk_put(clk);
263
264 clk = clk_get(NULL, "osc0");
265 dump_clock(clk, &r);
266 clk_put(clk);
267
268 clk = clk_get(NULL, "osc1");
269 dump_clock(clk, &r);
270 clk_put(clk);
271
272 spin_unlock(&clk_list_lock);
245 273
246 return 0; 274 return 0;
247} 275}
diff --git a/arch/avr32/mach-at32ap/clock.h b/arch/avr32/mach-at32ap/clock.h
index bb8e1f295835..623bf0e9a1e7 100644
--- a/arch/avr32/mach-at32ap/clock.h
+++ b/arch/avr32/mach-at32ap/clock.h
@@ -12,8 +12,13 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/list.h>
16
17
18void at32_clk_register(struct clk *clk);
15 19
16struct clk { 20struct clk {
21 struct list_head list; /* linking element */
17 const char *name; /* Clock name/function */ 22 const char *name; /* Clock name/function */
18 struct device *dev; /* Device the clock is used by */ 23 struct device *dev; /* Device the clock is used by */
19 struct clk *parent; /* Parent clock, if any */ 24 struct clk *parent; /* Parent clock, if any */
@@ -25,6 +30,3 @@ struct clk {
25 u16 users; /* Enabled if non-zero */ 30 u16 users; /* Enabled if non-zero */
26 u16 index; /* Sibling index */ 31 u16 index; /* Sibling index */
27}; 32};
28
29extern struct clk *at32_clock_list[];
30extern unsigned int at32_nr_clocks;
diff --git a/arch/avr32/mach-at32ap/include/mach/at32ap700x.h b/arch/avr32/mach-at32ap/include/mach/at32ap700x.h
index 1e9852d65cca..a77d372f6f3e 100644
--- a/arch/avr32/mach-at32ap/include/mach/at32ap700x.h
+++ b/arch/avr32/mach-at32ap/include/mach/at32ap700x.h
@@ -83,4 +83,132 @@
83#define HMATRIX_BASE 0xfff00800 83#define HMATRIX_BASE 0xfff00800
84#define SDRAMC_BASE 0xfff03800 84#define SDRAMC_BASE 0xfff03800
85 85
86/* LCDC on port C */
87#define ATMEL_LCDC_PC_CC (1ULL << 19)
88#define ATMEL_LCDC_PC_HSYNC (1ULL << 20)
89#define ATMEL_LCDC_PC_PCLK (1ULL << 21)
90#define ATMEL_LCDC_PC_VSYNC (1ULL << 22)
91#define ATMEL_LCDC_PC_DVAL (1ULL << 23)
92#define ATMEL_LCDC_PC_MODE (1ULL << 24)
93#define ATMEL_LCDC_PC_PWR (1ULL << 25)
94#define ATMEL_LCDC_PC_DATA0 (1ULL << 26)
95#define ATMEL_LCDC_PC_DATA1 (1ULL << 27)
96#define ATMEL_LCDC_PC_DATA2 (1ULL << 28)
97#define ATMEL_LCDC_PC_DATA3 (1ULL << 29)
98#define ATMEL_LCDC_PC_DATA4 (1ULL << 30)
99#define ATMEL_LCDC_PC_DATA5 (1ULL << 31)
100
101/* LCDC on port D */
102#define ATMEL_LCDC_PD_DATA6 (1ULL << 0)
103#define ATMEL_LCDC_PD_DATA7 (1ULL << 1)
104#define ATMEL_LCDC_PD_DATA8 (1ULL << 2)
105#define ATMEL_LCDC_PD_DATA9 (1ULL << 3)
106#define ATMEL_LCDC_PD_DATA10 (1ULL << 4)
107#define ATMEL_LCDC_PD_DATA11 (1ULL << 5)
108#define ATMEL_LCDC_PD_DATA12 (1ULL << 6)
109#define ATMEL_LCDC_PD_DATA13 (1ULL << 7)
110#define ATMEL_LCDC_PD_DATA14 (1ULL << 8)
111#define ATMEL_LCDC_PD_DATA15 (1ULL << 9)
112#define ATMEL_LCDC_PD_DATA16 (1ULL << 10)
113#define ATMEL_LCDC_PD_DATA17 (1ULL << 11)
114#define ATMEL_LCDC_PD_DATA18 (1ULL << 12)
115#define ATMEL_LCDC_PD_DATA19 (1ULL << 13)
116#define ATMEL_LCDC_PD_DATA20 (1ULL << 14)
117#define ATMEL_LCDC_PD_DATA21 (1ULL << 15)
118#define ATMEL_LCDC_PD_DATA22 (1ULL << 16)
119#define ATMEL_LCDC_PD_DATA23 (1ULL << 17)
120
121/* LCDC on port E */
122#define ATMEL_LCDC_PE_CC (1ULL << (32 + 0))
123#define ATMEL_LCDC_PE_DVAL (1ULL << (32 + 1))
124#define ATMEL_LCDC_PE_MODE (1ULL << (32 + 2))
125#define ATMEL_LCDC_PE_DATA0 (1ULL << (32 + 3))
126#define ATMEL_LCDC_PE_DATA1 (1ULL << (32 + 4))
127#define ATMEL_LCDC_PE_DATA2 (1ULL << (32 + 5))
128#define ATMEL_LCDC_PE_DATA3 (1ULL << (32 + 6))
129#define ATMEL_LCDC_PE_DATA4 (1ULL << (32 + 7))
130#define ATMEL_LCDC_PE_DATA8 (1ULL << (32 + 8))
131#define ATMEL_LCDC_PE_DATA9 (1ULL << (32 + 9))
132#define ATMEL_LCDC_PE_DATA10 (1ULL << (32 + 10))
133#define ATMEL_LCDC_PE_DATA11 (1ULL << (32 + 11))
134#define ATMEL_LCDC_PE_DATA12 (1ULL << (32 + 12))
135#define ATMEL_LCDC_PE_DATA16 (1ULL << (32 + 13))
136#define ATMEL_LCDC_PE_DATA17 (1ULL << (32 + 14))
137#define ATMEL_LCDC_PE_DATA18 (1ULL << (32 + 15))
138#define ATMEL_LCDC_PE_DATA19 (1ULL << (32 + 16))
139#define ATMEL_LCDC_PE_DATA20 (1ULL << (32 + 17))
140#define ATMEL_LCDC_PE_DATA21 (1ULL << (32 + 18))
141
142
143#define ATMEL_LCDC(PORT, PIN) (ATMEL_LCDC_##PORT##_##PIN)
144
145
146#define ATMEL_LCDC_PRI_24B_DATA ( \
147 ATMEL_LCDC(PC, DATA0) | ATMEL_LCDC(PC, DATA1) | \
148 ATMEL_LCDC(PC, DATA2) | ATMEL_LCDC(PC, DATA3) | \
149 ATMEL_LCDC(PC, DATA4) | ATMEL_LCDC(PC, DATA5) | \
150 ATMEL_LCDC(PD, DATA6) | ATMEL_LCDC(PD, DATA7) | \
151 ATMEL_LCDC(PD, DATA8) | ATMEL_LCDC(PD, DATA9) | \
152 ATMEL_LCDC(PD, DATA10) | ATMEL_LCDC(PD, DATA11) | \
153 ATMEL_LCDC(PD, DATA12) | ATMEL_LCDC(PD, DATA13) | \
154 ATMEL_LCDC(PD, DATA14) | ATMEL_LCDC(PD, DATA15) | \
155 ATMEL_LCDC(PD, DATA16) | ATMEL_LCDC(PD, DATA17) | \
156 ATMEL_LCDC(PD, DATA18) | ATMEL_LCDC(PD, DATA19) | \
157 ATMEL_LCDC(PD, DATA20) | ATMEL_LCDC(PD, DATA21) | \
158 ATMEL_LCDC(PD, DATA22) | ATMEL_LCDC(PD, DATA23))
159
160#define ATMEL_LCDC_ALT_24B_DATA ( \
161 ATMEL_LCDC(PE, DATA0) | ATMEL_LCDC(PE, DATA1) | \
162 ATMEL_LCDC(PE, DATA2) | ATMEL_LCDC(PE, DATA3) | \
163 ATMEL_LCDC(PE, DATA4) | ATMEL_LCDC(PC, DATA5) | \
164 ATMEL_LCDC(PD, DATA6) | ATMEL_LCDC(PD, DATA7) | \
165 ATMEL_LCDC(PE, DATA8) | ATMEL_LCDC(PE, DATA9) | \
166 ATMEL_LCDC(PE, DATA10) | ATMEL_LCDC(PE, DATA11) | \
167 ATMEL_LCDC(PE, DATA12) | ATMEL_LCDC(PD, DATA13) | \
168 ATMEL_LCDC(PD, DATA14) | ATMEL_LCDC(PD, DATA15) | \
169 ATMEL_LCDC(PE, DATA16) | ATMEL_LCDC(PE, DATA17) | \
170 ATMEL_LCDC(PE, DATA18) | ATMEL_LCDC(PE, DATA19) | \
171 ATMEL_LCDC(PE, DATA20) | ATMEL_LCDC(PE, DATA21) | \
172 ATMEL_LCDC(PD, DATA22) | ATMEL_LCDC(PD, DATA23))
173
174#define ATMEL_LCDC_PRI_15B_DATA ( \
175 ATMEL_LCDC(PC, DATA0) | ATMEL_LCDC(PC, DATA1) | \
176 ATMEL_LCDC(PC, DATA2) | ATMEL_LCDC(PC, DATA3) | \
177 ATMEL_LCDC(PC, DATA4) | ATMEL_LCDC(PC, DATA5) | \
178 ATMEL_LCDC(PD, DATA8) | ATMEL_LCDC(PD, DATA9) | \
179 ATMEL_LCDC(PD, DATA10) | ATMEL_LCDC(PD, DATA11) | \
180 ATMEL_LCDC(PD, DATA12) | ATMEL_LCDC(PD, DATA16) | \
181 ATMEL_LCDC(PD, DATA17) | ATMEL_LCDC(PD, DATA18) | \
182 ATMEL_LCDC(PD, DATA19) | ATMEL_LCDC(PD, DATA20))
183
184#define ATMEL_LCDC_ALT_15B_DATA ( \
185 ATMEL_LCDC(PE, DATA0) | ATMEL_LCDC(PE, DATA1) | \
186 ATMEL_LCDC(PE, DATA2) | ATMEL_LCDC(PE, DATA3) | \
187 ATMEL_LCDC(PE, DATA4) | ATMEL_LCDC(PC, DATA5) | \
188 ATMEL_LCDC(PE, DATA8) | ATMEL_LCDC(PE, DATA9) | \
189 ATMEL_LCDC(PE, DATA10) | ATMEL_LCDC(PE, DATA11) | \
190 ATMEL_LCDC(PE, DATA12) | ATMEL_LCDC(PE, DATA16) | \
191 ATMEL_LCDC(PE, DATA17) | ATMEL_LCDC(PE, DATA18) | \
192 ATMEL_LCDC(PE, DATA19) | ATMEL_LCDC(PE, DATA20))
193
194#define ATMEL_LCDC_PRI_CONTROL ( \
195 ATMEL_LCDC(PC, CC) | ATMEL_LCDC(PC, DVAL) | \
196 ATMEL_LCDC(PC, MODE) | ATMEL_LCDC(PC, PWR))
197
198#define ATMEL_LCDC_ALT_CONTROL ( \
199 ATMEL_LCDC(PE, CC) | ATMEL_LCDC(PE, DVAL) | \
200 ATMEL_LCDC(PE, MODE) | ATMEL_LCDC(PC, PWR))
201
202#define ATMEL_LCDC_CONTROL ( \
203 ATMEL_LCDC(PC, HSYNC) | ATMEL_LCDC(PC, VSYNC) | \
204 ATMEL_LCDC(PC, PCLK))
205
206#define ATMEL_LCDC_PRI_24BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_PRI_24B_DATA)
207
208#define ATMEL_LCDC_ALT_24BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_ALT_24B_DATA)
209
210#define ATMEL_LCDC_PRI_15BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_PRI_15B_DATA)
211
212#define ATMEL_LCDC_ALT_15BIT (ATMEL_LCDC_CONTROL | ATMEL_LCDC_ALT_15B_DATA)
213
86#endif /* __ASM_ARCH_AT32AP700X_H__ */ 214#endif /* __ASM_ARCH_AT32AP700X_H__ */
diff --git a/arch/avr32/mach-at32ap/include/mach/board.h b/arch/avr32/mach-at32ap/include/mach/board.h
index e60e9076544d..c48386d66bc3 100644
--- a/arch/avr32/mach-at32ap/include/mach/board.h
+++ b/arch/avr32/mach-at32ap/include/mach/board.h
@@ -43,7 +43,7 @@ struct atmel_lcdfb_info;
43struct platform_device * 43struct platform_device *
44at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data, 44at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
45 unsigned long fbmem_start, unsigned long fbmem_len, 45 unsigned long fbmem_start, unsigned long fbmem_len,
46 unsigned int pin_config); 46 u64 pin_mask);
47 47
48struct usba_platform_data; 48struct usba_platform_data;
49struct platform_device * 49struct platform_device *
diff --git a/arch/avr32/mach-at32ap/include/mach/io.h b/arch/avr32/mach-at32ap/include/mach/io.h
index 4ec6abc68ea3..22ea79b74052 100644
--- a/arch/avr32/mach-at32ap/include/mach/io.h
+++ b/arch/avr32/mach-at32ap/include/mach/io.h
@@ -1,8 +1,7 @@
1#ifndef __ASM_AVR32_ARCH_AT32AP_IO_H 1#ifndef __ASM_AVR32_ARCH_AT32AP_IO_H
2#define __ASM_AVR32_ARCH_AT32AP_IO_H 2#define __ASM_AVR32_ARCH_AT32AP_IO_H
3 3
4/* For "bizarre" halfword swapping */ 4#include <linux/swab.h>
5#include <linux/byteorder/swabb.h>
6 5
7#if defined(CONFIG_AP700X_32_BIT_SMC) 6#if defined(CONFIG_AP700X_32_BIT_SMC)
8# define __swizzle_addr_b(addr) (addr ^ 3UL) 7# define __swizzle_addr_b(addr) (addr ^ 3UL)
diff --git a/arch/avr32/mach-at32ap/include/mach/portmux.h b/arch/avr32/mach-at32ap/include/mach/portmux.h
index b1abe6b4e4ef..21c79373b53f 100644
--- a/arch/avr32/mach-at32ap/include/mach/portmux.h
+++ b/arch/avr32/mach-at32ap/include/mach/portmux.h
@@ -21,9 +21,10 @@
21#define AT32_GPIOF_DEGLITCH 0x00000008 /* (IN) Filter glitches */ 21#define AT32_GPIOF_DEGLITCH 0x00000008 /* (IN) Filter glitches */
22#define AT32_GPIOF_MULTIDRV 0x00000010 /* Enable multidriver option */ 22#define AT32_GPIOF_MULTIDRV 0x00000010 /* Enable multidriver option */
23 23
24void at32_select_periph(unsigned int pin, unsigned int periph, 24void at32_select_periph(unsigned int port, unsigned int pin,
25 unsigned long flags); 25 unsigned int periph, unsigned long flags);
26void at32_select_gpio(unsigned int pin, unsigned long flags); 26void at32_select_gpio(unsigned int pin, unsigned long flags);
27void at32_deselect_pin(unsigned int pin);
27void at32_reserve_pin(unsigned int pin); 28void at32_reserve_pin(unsigned int pin);
28 29
29#endif /* __ASM_ARCH_PORTMUX_H__ */ 30#endif /* __ASM_ARCH_PORTMUX_H__ */
diff --git a/arch/avr32/mach-at32ap/pdc.c b/arch/avr32/mach-at32ap/pdc.c
index 1040bda4fda7..61ab15aae970 100644
--- a/arch/avr32/mach-at32ap/pdc.c
+++ b/arch/avr32/mach-at32ap/pdc.c
@@ -35,7 +35,6 @@ static int __init pdc_probe(struct platform_device *pdev)
35} 35}
36 36
37static struct platform_driver pdc_driver = { 37static struct platform_driver pdc_driver = {
38 .probe = pdc_probe,
39 .driver = { 38 .driver = {
40 .name = "pdc", 39 .name = "pdc",
41 }, 40 },
@@ -43,6 +42,6 @@ static struct platform_driver pdc_driver = {
43 42
44static int __init pdc_init(void) 43static int __init pdc_init(void)
45{ 44{
46 return platform_driver_register(&pdc_driver); 45 return platform_driver_probe(&pdc_driver, pdc_probe);
47} 46}
48arch_initcall(pdc_init); 47arch_initcall(pdc_init);
diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c
index 405ee6bad4ce..ed81a8bcb22d 100644
--- a/arch/avr32/mach-at32ap/pio.c
+++ b/arch/avr32/mach-at32ap/pio.c
@@ -50,35 +50,48 @@ static struct pio_device *gpio_to_pio(unsigned int gpio)
50} 50}
51 51
52/* Pin multiplexing API */ 52/* Pin multiplexing API */
53static DEFINE_SPINLOCK(pio_lock);
53 54
54void __init at32_select_periph(unsigned int pin, unsigned int periph, 55void __init at32_select_periph(unsigned int port, u32 pin_mask,
55 unsigned long flags) 56 unsigned int periph, unsigned long flags)
56{ 57{
57 struct pio_device *pio; 58 struct pio_device *pio;
58 unsigned int pin_index = pin & 0x1f;
59 u32 mask = 1 << pin_index;
60 59
61 pio = gpio_to_pio(pin); 60 /* assign and verify pio */
61 pio = gpio_to_pio(port);
62 if (unlikely(!pio)) { 62 if (unlikely(!pio)) {
63 printk("pio: invalid pin %u\n", pin); 63 printk(KERN_WARNING "pio: invalid port %u\n", port);
64 goto fail; 64 goto fail;
65 } 65 }
66 66
67 if (unlikely(test_and_set_bit(pin_index, &pio->pinmux_mask) 67 /* Test if any of the requested pins is already muxed */
68 || gpiochip_is_requested(&pio->chip, pin_index))) { 68 spin_lock(&pio_lock);
69 printk("%s: pin %u is busy\n", pio->name, pin_index); 69 if (unlikely(pio->pinmux_mask & pin_mask)) {
70 printk(KERN_WARNING "%s: pin(s) busy (requested 0x%x, busy 0x%x)\n",
71 pio->name, pin_mask, pio->pinmux_mask & pin_mask);
72 spin_unlock(&pio_lock);
70 goto fail; 73 goto fail;
71 } 74 }
72 75
73 pio_writel(pio, PUER, mask); 76 pio->pinmux_mask |= pin_mask;
77
78 /* enable pull ups */
79 pio_writel(pio, PUER, pin_mask);
80
81 /* select either peripheral A or B */
74 if (periph) 82 if (periph)
75 pio_writel(pio, BSR, mask); 83 pio_writel(pio, BSR, pin_mask);
76 else 84 else
77 pio_writel(pio, ASR, mask); 85 pio_writel(pio, ASR, pin_mask);
86
87 /* enable peripheral control */
88 pio_writel(pio, PDR, pin_mask);
78 89
79 pio_writel(pio, PDR, mask); 90 /* Disable pull ups if not requested. */
80 if (!(flags & AT32_GPIOF_PULLUP)) 91 if (!(flags & AT32_GPIOF_PULLUP))
81 pio_writel(pio, PUDR, mask); 92 pio_writel(pio, PUDR, pin_mask);
93
94 spin_unlock(&pio_lock);
82 95
83 return; 96 return;
84 97
@@ -134,6 +147,25 @@ fail:
134 dump_stack(); 147 dump_stack();
135} 148}
136 149
150/*
151 * Undo a previous pin reservation. Will not affect the hardware
152 * configuration.
153 */
154void at32_deselect_pin(unsigned int pin)
155{
156 struct pio_device *pio;
157 unsigned int pin_index = pin & 0x1f;
158
159 pio = gpio_to_pio(pin);
160 if (unlikely(!pio)) {
161 printk("pio: invalid pin %u\n", pin);
162 dump_stack();
163 return;
164 }
165
166 clear_bit(pin_index, &pio->pinmux_mask);
167}
168
137/* Reserve a pin, preventing anyone else from changing its configuration. */ 169/* Reserve a pin, preventing anyone else from changing its configuration. */
138void __init at32_reserve_pin(unsigned int pin) 170void __init at32_reserve_pin(unsigned int pin)
139{ 171{
@@ -382,7 +414,6 @@ static int __init pio_probe(struct platform_device *pdev)
382} 414}
383 415
384static struct platform_driver pio_driver = { 416static struct platform_driver pio_driver = {
385 .probe = pio_probe,
386 .driver = { 417 .driver = {
387 .name = "pio", 418 .name = "pio",
388 }, 419 },
@@ -390,7 +421,7 @@ static struct platform_driver pio_driver = {
390 421
391static int __init pio_init(void) 422static int __init pio_init(void)
392{ 423{
393 return platform_driver_register(&pio_driver); 424 return platform_driver_probe(&pio_driver, pio_probe);
394} 425}
395postcore_initcall(pio_init); 426postcore_initcall(pio_init);
396 427
diff --git a/arch/avr32/oprofile/Makefile b/arch/avr32/oprofile/Makefile
index 1fe81c3c1e86..e0eb520e0287 100644
--- a/arch/avr32/oprofile/Makefile
+++ b/arch/avr32/oprofile/Makefile
@@ -5,4 +5,4 @@ oprofile-y := $(addprefix ../../../drivers/oprofile/, \
5 event_buffer.o oprofile_files.o \ 5 event_buffer.o oprofile_files.o \
6 oprofilefs.o oprofile_stats.o \ 6 oprofilefs.o oprofile_stats.o \
7 timer_int.o) 7 timer_int.o)
8oprofile-y += op_model_avr32.o 8oprofile-y += op_model_avr32.o backtrace.o
diff --git a/arch/avr32/oprofile/backtrace.c b/arch/avr32/oprofile/backtrace.c
new file mode 100644
index 000000000000..75d9ad6f99cf
--- /dev/null
+++ b/arch/avr32/oprofile/backtrace.c
@@ -0,0 +1,81 @@
1/*
2 * AVR32 specific backtracing code for oprofile
3 *
4 * Copyright 2008 Weinmann GmbH
5 *
6 * Author: Nikolaus Voss <n.voss@weinmann.de>
7 *
8 * Based on i386 oprofile backtrace code by John Levon and David Smith
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 */
15
16#include <linux/oprofile.h>
17#include <linux/sched.h>
18#include <linux/uaccess.h>
19
20/* The first two words of each frame on the stack look like this if we have
21 * frame pointers */
22struct frame_head {
23 unsigned long lr;
24 struct frame_head *fp;
25};
26
27/* copied from arch/avr32/kernel/process.c */
28static inline int valid_stack_ptr(struct thread_info *tinfo, unsigned long p)
29{
30 return (p > (unsigned long)tinfo)
31 && (p < (unsigned long)tinfo + THREAD_SIZE - 3);
32}
33
34/* copied from arch/x86/oprofile/backtrace.c */
35static struct frame_head *dump_user_backtrace(struct frame_head *head)
36{
37 struct frame_head bufhead[2];
38
39 /* Also check accessibility of one struct frame_head beyond */
40 if (!access_ok(VERIFY_READ, head, sizeof(bufhead)))
41 return NULL;
42 if (__copy_from_user_inatomic(bufhead, head, sizeof(bufhead)))
43 return NULL;
44
45 oprofile_add_trace(bufhead[0].lr);
46
47 /* frame pointers should strictly progress back up the stack
48 * (towards higher addresses) */
49 if (bufhead[0].fp <= head)
50 return NULL;
51
52 return bufhead[0].fp;
53}
54
55void avr32_backtrace(struct pt_regs * const regs, unsigned int depth)
56{
57 /* Get first frame pointer */
58 struct frame_head *head = (struct frame_head *)(regs->r7);
59
60 if (!user_mode(regs)) {
61#ifdef CONFIG_FRAME_POINTER
62 /*
63 * Traverse the kernel stack from frame to frame up to
64 * "depth" steps.
65 */
66 while (depth-- && valid_stack_ptr(task_thread_info(current),
67 (unsigned long)head)) {
68 oprofile_add_trace(head->lr);
69 if (head->fp <= head)
70 break;
71 head = head->fp;
72 }
73#endif
74 } else {
75 /* Assume we have frame pointers in user mode process */
76 while (depth-- && head)
77 head = dump_user_backtrace(head);
78 }
79}
80
81
diff --git a/arch/avr32/oprofile/op_model_avr32.c b/arch/avr32/oprofile/op_model_avr32.c
index df42325c7f81..a3e9b3c4845a 100644
--- a/arch/avr32/oprofile/op_model_avr32.c
+++ b/arch/avr32/oprofile/op_model_avr32.c
@@ -22,6 +22,8 @@
22#define AVR32_PERFCTR_IRQ_GROUP 0 22#define AVR32_PERFCTR_IRQ_GROUP 0
23#define AVR32_PERFCTR_IRQ_LINE 1 23#define AVR32_PERFCTR_IRQ_LINE 1
24 24
25void avr32_backtrace(struct pt_regs * const regs, unsigned int depth);
26
25enum { PCCNT, PCNT0, PCNT1, NR_counter }; 27enum { PCCNT, PCNT0, PCNT1, NR_counter };
26 28
27struct avr32_perf_counter { 29struct avr32_perf_counter {
@@ -223,6 +225,8 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
223 memcpy(ops, &avr32_perf_counter_ops, 225 memcpy(ops, &avr32_perf_counter_ops,
224 sizeof(struct oprofile_operations)); 226 sizeof(struct oprofile_operations));
225 227
228 ops->backtrace = avr32_backtrace;
229
226 printk(KERN_INFO "oprofile: using AVR32 performance monitoring.\n"); 230 printk(KERN_INFO "oprofile: using AVR32 performance monitoring.\n");
227 231
228 return 0; 232 return 0;
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 952a24b2f5a9..52e16c6436f9 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -178,6 +178,7 @@ void __init smp_callin(void)
178 unmask_irq(IPI_INTR_VECT); 178 unmask_irq(IPI_INTR_VECT);
179 unmask_irq(TIMER0_INTR_VECT); 179 unmask_irq(TIMER0_INTR_VECT);
180 preempt_disable(); 180 preempt_disable();
181 notify_cpu_starting(cpu);
181 local_irq_enable(); 182 local_irq_enable();
182 183
183 cpu_set(cpu, cpu_online_map); 184 cpu_set(cpu, cpu_online_map);
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index 9f0df9bd46b7..06ff1ba21465 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -8,7 +8,9 @@
8#include <asm/machvec.h> 8#include <asm/machvec.h>
9#include <linux/scatterlist.h> 9#include <linux/scatterlist.h>
10 10
11#define dma_alloc_coherent platform_dma_alloc_coherent 11#define dma_alloc_coherent(dev, size, handle, gfp) \
12 platform_dma_alloc_coherent(dev, size, handle, (gfp) | GFP_DMA)
13
12/* coherent mem. is cheap */ 14/* coherent mem. is cheap */
13static inline void * 15static inline void *
14dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 16dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
diff --git a/arch/ia64/include/asm/sections.h b/arch/ia64/include/asm/sections.h
index f66799891036..1a873b36a4a1 100644
--- a/arch/ia64/include/asm/sections.h
+++ b/arch/ia64/include/asm/sections.h
@@ -11,6 +11,9 @@
11#include <asm-generic/sections.h> 11#include <asm-generic/sections.h>
12 12
13extern char __per_cpu_start[], __per_cpu_end[], __phys_per_cpu_start[]; 13extern char __per_cpu_start[], __per_cpu_end[], __phys_per_cpu_start[];
14#ifdef CONFIG_SMP
15extern char __cpu0_per_cpu[];
16#endif
14extern char __start___vtop_patchlist[], __end___vtop_patchlist[]; 17extern char __start___vtop_patchlist[], __end___vtop_patchlist[];
15extern char __start___rse_patchlist[], __end___rse_patchlist[]; 18extern char __start___rse_patchlist[], __end___rse_patchlist[];
16extern char __start___mckinley_e9_bundles[], __end___mckinley_e9_bundles[]; 19extern char __start___mckinley_e9_bundles[], __end___mckinley_e9_bundles[];
diff --git a/arch/ia64/include/asm/siginfo.h b/arch/ia64/include/asm/siginfo.h
index 9294e4b0c8bc..118d42979003 100644
--- a/arch/ia64/include/asm/siginfo.h
+++ b/arch/ia64/include/asm/siginfo.h
@@ -113,11 +113,6 @@ typedef struct siginfo {
113#undef NSIGSEGV 113#undef NSIGSEGV
114#define NSIGSEGV 3 114#define NSIGSEGV 3
115 115
116/*
117 * SIGTRAP si_codes
118 */
119#define TRAP_BRANCH (__SI_FAULT|3) /* process taken branch trap */
120#define TRAP_HWBKPT (__SI_FAULT|4) /* hardware breakpoint or watchpoint */
121#undef NSIGTRAP 116#undef NSIGTRAP
122#define NSIGTRAP 4 117#define NSIGTRAP 4
123 118
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 8bdea8eb62e3..66e491d8baac 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -367,16 +367,17 @@ start_ap:
367 ;; 367 ;;
368#else 368#else
369(isAP) br.few 2f 369(isAP) br.few 2f
370 mov r20=r19 370 movl r20=__cpu0_per_cpu
371 sub r19=r19,r18
372 ;; 371 ;;
373 shr.u r18=r18,3 372 shr.u r18=r18,3
3741: 3731:
375 ld8 r21=[r20],8;; 374 ld8 r21=[r19],8;;
376 st8[r19]=r21,8 375 st8[r20]=r21,8
377 adds r18=-1,r18;; 376 adds r18=-1,r18;;
378 cmp4.lt p7,p6=0,r18 377 cmp4.lt p7,p6=0,r18
379(p7) br.cond.dptk.few 1b 378(p7) br.cond.dptk.few 1b
379 mov r19=r20
380 ;;
3802: 3812:
381#endif 382#endif
382 tpa r19=r19 383 tpa r19=r19
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index d8f05e504fbf..1dcbb85fc4ee 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -401,6 +401,7 @@ smp_callin (void)
401 spin_lock(&vector_lock); 401 spin_lock(&vector_lock);
402 /* Setup the per cpu irq handling data structures */ 402 /* Setup the per cpu irq handling data structures */
403 __setup_vector_irq(cpuid); 403 __setup_vector_irq(cpuid);
404 notify_cpu_starting(cpuid);
404 cpu_set(cpuid, cpu_online_map); 405 cpu_set(cpuid, cpu_online_map);
405 per_cpu(cpu_state, cpuid) = CPU_ONLINE; 406 per_cpu(cpu_state, cpuid) = CPU_ONLINE;
406 spin_unlock(&vector_lock); 407 spin_unlock(&vector_lock);
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index de71da811cd6..10a7d47e8510 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -215,9 +215,6 @@ SECTIONS
215 /* Per-cpu data: */ 215 /* Per-cpu data: */
216 percpu : { } :percpu 216 percpu : { } :percpu
217 . = ALIGN(PERCPU_PAGE_SIZE); 217 . = ALIGN(PERCPU_PAGE_SIZE);
218#ifdef CONFIG_SMP
219 . = . + PERCPU_PAGE_SIZE; /* cpu0 per-cpu space */
220#endif
221 __phys_per_cpu_start = .; 218 __phys_per_cpu_start = .;
222 .data.percpu PERCPU_ADDR : AT(__phys_per_cpu_start - LOAD_OFFSET) 219 .data.percpu PERCPU_ADDR : AT(__phys_per_cpu_start - LOAD_OFFSET)
223 { 220 {
@@ -233,6 +230,11 @@ SECTIONS
233 data : { } :data 230 data : { } :data
234 .data : AT(ADDR(.data) - LOAD_OFFSET) 231 .data : AT(ADDR(.data) - LOAD_OFFSET)
235 { 232 {
233#ifdef CONFIG_SMP
234 . = ALIGN(PERCPU_PAGE_SIZE);
235 __cpu0_per_cpu = .;
236 . = . + PERCPU_PAGE_SIZE; /* cpu0 per-cpu space */
237#endif
236 DATA_DATA 238 DATA_DATA
237 *(.data1) 239 *(.data1)
238 *(.gnu.linkonce.d*) 240 *(.gnu.linkonce.d*)
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index e566ff43884a..0ee085efbe29 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -163,7 +163,7 @@ per_cpu_init (void)
163 * get_zeroed_page(). 163 * get_zeroed_page().
164 */ 164 */
165 if (first_time) { 165 if (first_time) {
166 void *cpu0_data = __phys_per_cpu_start - PERCPU_PAGE_SIZE; 166 void *cpu0_data = __cpu0_per_cpu;
167 167
168 first_time=0; 168 first_time=0;
169 169
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 78026aabaa7f..d8c5fcd89e5b 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -144,7 +144,7 @@ static void *per_cpu_node_setup(void *cpu_data, int node)
144 144
145 for_each_possible_early_cpu(cpu) { 145 for_each_possible_early_cpu(cpu) {
146 if (cpu == 0) { 146 if (cpu == 0) {
147 void *cpu0_data = __phys_per_cpu_start - PERCPU_PAGE_SIZE; 147 void *cpu0_data = __cpu0_per_cpu;
148 __per_cpu_offset[cpu] = (char*)cpu0_data - 148 __per_cpu_offset[cpu] = (char*)cpu0_data -
149 __per_cpu_start; 149 __per_cpu_start;
150 } else if (node == node_cpuid[cpu].nid) { 150 } else if (node == node_cpuid[cpu].nid) {
diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
index 2c03ac1d005f..fc2994811f15 100644
--- a/arch/m32r/kernel/smpboot.c
+++ b/arch/m32r/kernel/smpboot.c
@@ -498,6 +498,8 @@ static void __init smp_online(void)
498{ 498{
499 int cpu_id = smp_processor_id(); 499 int cpu_id = smp_processor_id();
500 500
501 notify_cpu_starting(cpu_id);
502
501 local_irq_enable(); 503 local_irq_enable();
502 504
503 /* Get our bogomips. */ 505 /* Get our bogomips. */
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 49896a2a1d72..cd5fbf6f0784 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -211,6 +211,7 @@ config MIPS_MALTA
211 select SYS_SUPPORTS_64BIT_KERNEL 211 select SYS_SUPPORTS_64BIT_KERNEL
212 select SYS_SUPPORTS_BIG_ENDIAN 212 select SYS_SUPPORTS_BIG_ENDIAN
213 select SYS_SUPPORTS_LITTLE_ENDIAN 213 select SYS_SUPPORTS_LITTLE_ENDIAN
214 select SYS_SUPPORTS_MIPS_CMP if BROKEN # because SYNC_R4K is broken
214 select SYS_SUPPORTS_MULTITHREADING 215 select SYS_SUPPORTS_MULTITHREADING
215 select SYS_SUPPORTS_SMARTMIPS 216 select SYS_SUPPORTS_SMARTMIPS
216 help 217 help
@@ -567,7 +568,7 @@ config MIKROTIK_RB532
567 select SYS_SUPPORTS_LITTLE_ENDIAN 568 select SYS_SUPPORTS_LITTLE_ENDIAN
568 select SWAP_IO_SPACE 569 select SWAP_IO_SPACE
569 select BOOT_RAW 570 select BOOT_RAW
570 select GENERIC_GPIO 571 select ARCH_REQUIRE_GPIOLIB
571 help 572 help
572 Support the Mikrotik(tm) RouterBoard 532 series, 573 Support the Mikrotik(tm) RouterBoard 532 series,
573 based on the IDT RC32434 SoC. 574 based on the IDT RC32434 SoC.
@@ -597,7 +598,7 @@ config WR_PPMC
597 598
598endchoice 599endchoice
599 600
600source "arch/mips/au1000/Kconfig" 601source "arch/mips/alchemy/Kconfig"
601source "arch/mips/basler/excite/Kconfig" 602source "arch/mips/basler/excite/Kconfig"
602source "arch/mips/jazz/Kconfig" 603source "arch/mips/jazz/Kconfig"
603source "arch/mips/lasat/Kconfig" 604source "arch/mips/lasat/Kconfig"
@@ -609,11 +610,6 @@ source "arch/mips/vr41xx/Kconfig"
609 610
610endmenu 611endmenu
611 612
612config GENERIC_LOCKBREAK
613 bool
614 default y
615 depends on SMP && PREEMPT
616
617config RWSEM_GENERIC_SPINLOCK 613config RWSEM_GENERIC_SPINLOCK
618 bool 614 bool
619 default y 615 default y
@@ -1272,6 +1268,13 @@ config CPU_SUPPORTS_32BIT_KERNEL
1272config CPU_SUPPORTS_64BIT_KERNEL 1268config CPU_SUPPORTS_64BIT_KERNEL
1273 bool 1269 bool
1274 1270
1271#
1272# Set to y for ptrace access to watch registers.
1273#
1274config HARDWARE_WATCHPOINTS
1275 bool
1276 default y if CPU_MIPS32 || CPU_MIPS64
1277
1275menu "Kernel type" 1278menu "Kernel type"
1276 1279
1277choice 1280choice
@@ -1403,7 +1406,6 @@ config MIPS_MT_SMTC
1403 depends on CPU_MIPS32_R2 1406 depends on CPU_MIPS32_R2
1404 #depends on CPU_MIPS64_R2 # once there is hardware ... 1407 #depends on CPU_MIPS64_R2 # once there is hardware ...
1405 depends on SYS_SUPPORTS_MULTITHREADING 1408 depends on SYS_SUPPORTS_MULTITHREADING
1406 select GENERIC_CLOCKEVENTS_BROADCAST
1407 select CPU_MIPSR2_IRQ_VI 1409 select CPU_MIPSR2_IRQ_VI
1408 select CPU_MIPSR2_IRQ_EI 1410 select CPU_MIPSR2_IRQ_EI
1409 select MIPS_MT 1411 select MIPS_MT
@@ -1451,32 +1453,17 @@ config MIPS_VPE_LOADER
1451 Includes a loader for loading an elf relocatable object 1453 Includes a loader for loading an elf relocatable object
1452 onto another VPE and running it. 1454 onto another VPE and running it.
1453 1455
1454config MIPS_MT_SMTC_INSTANT_REPLAY
1455 bool "Low-latency Dispatch of Deferred SMTC IPIs"
1456 depends on MIPS_MT_SMTC && !PREEMPT
1457 default y
1458 help
1459 SMTC pseudo-interrupts between TCs are deferred and queued
1460 if the target TC is interrupt-inhibited (IXMT). In the first
1461 SMTC prototypes, these queued IPIs were serviced on return
1462 to user mode, or on entry into the kernel idle loop. The
1463 INSTANT_REPLAY option dispatches them as part of local_irq_restore()
1464 processing, which adds runtime overhead (hence the option to turn
1465 it off), but ensures that IPIs are handled promptly even under
1466 heavy I/O interrupt load.
1467
1468config MIPS_MT_SMTC_IM_BACKSTOP 1456config MIPS_MT_SMTC_IM_BACKSTOP
1469 bool "Use per-TC register bits as backstop for inhibited IM bits" 1457 bool "Use per-TC register bits as backstop for inhibited IM bits"
1470 depends on MIPS_MT_SMTC 1458 depends on MIPS_MT_SMTC
1471 default y 1459 default n
1472 help 1460 help
1473 To support multiple TC microthreads acting as "CPUs" within 1461 To support multiple TC microthreads acting as "CPUs" within
1474 a VPE, VPE-wide interrupt mask bits must be specially manipulated 1462 a VPE, VPE-wide interrupt mask bits must be specially manipulated
1475 during interrupt handling. To support legacy drivers and interrupt 1463 during interrupt handling. To support legacy drivers and interrupt
1476 controller management code, SMTC has a "backstop" to track and 1464 controller management code, SMTC has a "backstop" to track and
1477 if necessary restore the interrupt mask. This has some performance 1465 if necessary restore the interrupt mask. This has some performance
1478 impact on interrupt service overhead. Disable it only if you know 1466 impact on interrupt service overhead.
1479 what you are doing.
1480 1467
1481config MIPS_MT_SMTC_IRQAFF 1468config MIPS_MT_SMTC_IRQAFF
1482 bool "Support IRQ affinity API" 1469 bool "Support IRQ affinity API"
@@ -1486,10 +1473,8 @@ config MIPS_MT_SMTC_IRQAFF
1486 Enables SMP IRQ affinity API (/proc/irq/*/smp_affinity, etc.) 1473 Enables SMP IRQ affinity API (/proc/irq/*/smp_affinity, etc.)
1487 for SMTC Linux kernel. Requires platform support, of which 1474 for SMTC Linux kernel. Requires platform support, of which
1488 an example can be found in the MIPS kernel i8259 and Malta 1475 an example can be found in the MIPS kernel i8259 and Malta
1489 platform code. It is recommended that MIPS_MT_SMTC_INSTANT_REPLAY 1476 platform code. Adds some overhead to interrupt dispatch, and
1490 be enabled if MIPS_MT_SMTC_IRQAFF is used. Adds overhead to 1477 should be used only if you know what you are doing.
1491 interrupt dispatch, and should be used only if you know what
1492 you are doing.
1493 1478
1494config MIPS_VPE_LOADER_TOM 1479config MIPS_VPE_LOADER_TOM
1495 bool "Load VPE program into memory hidden from linux" 1480 bool "Load VPE program into memory hidden from linux"
@@ -1517,6 +1502,18 @@ config MIPS_APSP_KSPD
1517 "exit" syscall notifying other kernel modules the SP program is 1502 "exit" syscall notifying other kernel modules the SP program is
1518 exiting. You probably want to say yes here. 1503 exiting. You probably want to say yes here.
1519 1504
1505config MIPS_CMP
1506 bool "MIPS CMP framework support"
1507 depends on SYS_SUPPORTS_MIPS_CMP
1508 select SYNC_R4K if BROKEN
1509 select SYS_SUPPORTS_SMP
1510 select SYS_SUPPORTS_SCHED_SMT if SMP
1511 select WEAK_ORDERING
1512 default n
1513 help
1514 This is a placeholder option for the GCMP work. It will need to
1515 be handled differently...
1516
1520config SB1_PASS_1_WORKAROUNDS 1517config SB1_PASS_1_WORKAROUNDS
1521 bool 1518 bool
1522 depends on CPU_SB1_PASS_1 1519 depends on CPU_SB1_PASS_1
@@ -1693,6 +1690,9 @@ config SMP
1693config SMP_UP 1690config SMP_UP
1694 bool 1691 bool
1695 1692
1693config SYS_SUPPORTS_MIPS_CMP
1694 bool
1695
1696config SYS_SUPPORTS_SMP 1696config SYS_SUPPORTS_SMP
1697 bool 1697 bool
1698 1698
@@ -1740,17 +1740,6 @@ config NR_CPUS
1740 performance should round up your number of processors to the next 1740 performance should round up your number of processors to the next
1741 power of two. 1741 power of two.
1742 1742
1743config MIPS_CMP
1744 bool "MIPS CMP framework support"
1745 depends on SMP
1746 select SYNC_R4K
1747 select SYS_SUPPORTS_SCHED_SMT
1748 select WEAK_ORDERING
1749 default n
1750 help
1751 This is a placeholder option for the GCMP work. It will need to
1752 be handled differently...
1753
1754source "kernel/time/Kconfig" 1743source "kernel/time/Kconfig"
1755 1744
1756# 1745#
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 9aab51caf16a..7f39fd8a91fe 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -170,123 +170,123 @@ libs-$(CONFIG_SIBYTE_CFE) += arch/mips/sibyte/cfe/
170# Acer PICA 61, Mips Magnum 4000 and Olivetti M700. 170# Acer PICA 61, Mips Magnum 4000 and Olivetti M700.
171# 171#
172core-$(CONFIG_MACH_JAZZ) += arch/mips/jazz/ 172core-$(CONFIG_MACH_JAZZ) += arch/mips/jazz/
173cflags-$(CONFIG_MACH_JAZZ) += -Iinclude/asm-mips/mach-jazz 173cflags-$(CONFIG_MACH_JAZZ) += -I$(srctree)/arch/mips/include/asm/mach-jazz
174load-$(CONFIG_MACH_JAZZ) += 0xffffffff80080000 174load-$(CONFIG_MACH_JAZZ) += 0xffffffff80080000
175 175
176# 176#
177# Common Alchemy Au1x00 stuff 177# Common Alchemy Au1x00 stuff
178# 178#
179core-$(CONFIG_SOC_AU1X00) += arch/mips/au1000/common/ 179core-$(CONFIG_SOC_AU1X00) += arch/mips/alchemy/common/
180cflags-$(CONFIG_SOC_AU1X00) += -Iinclude/asm-mips/mach-au1x00 180cflags-$(CONFIG_SOC_AU1X00) += -I$(srctree)/arch/mips/include/asm/mach-au1x00
181 181
182# 182#
183# AMD Alchemy Pb1000 eval board 183# AMD Alchemy Pb1000 eval board
184# 184#
185libs-$(CONFIG_MIPS_PB1000) += arch/mips/au1000/pb1000/ 185libs-$(CONFIG_MIPS_PB1000) += arch/mips/alchemy/pb1000/
186cflags-$(CONFIG_MIPS_PB1000) += -Iinclude/asm-mips/mach-pb1x00 186cflags-$(CONFIG_MIPS_PB1000) += -I$(srctree)/arch/mips/include/asm/mach-pb1x00
187load-$(CONFIG_MIPS_PB1000) += 0xffffffff80100000 187load-$(CONFIG_MIPS_PB1000) += 0xffffffff80100000
188 188
189# 189#
190# AMD Alchemy Pb1100 eval board 190# AMD Alchemy Pb1100 eval board
191# 191#
192libs-$(CONFIG_MIPS_PB1100) += arch/mips/au1000/pb1100/ 192libs-$(CONFIG_MIPS_PB1100) += arch/mips/alchemy/pb1100/
193cflags-$(CONFIG_MIPS_PB1100) += -Iinclude/asm-mips/mach-pb1x00 193cflags-$(CONFIG_MIPS_PB1100) += -I$(srctree)/arch/mips/include/asm/mach-pb1x00
194load-$(CONFIG_MIPS_PB1100) += 0xffffffff80100000 194load-$(CONFIG_MIPS_PB1100) += 0xffffffff80100000
195 195
196# 196#
197# AMD Alchemy Pb1500 eval board 197# AMD Alchemy Pb1500 eval board
198# 198#
199libs-$(CONFIG_MIPS_PB1500) += arch/mips/au1000/pb1500/ 199libs-$(CONFIG_MIPS_PB1500) += arch/mips/alchemy/pb1500/
200cflags-$(CONFIG_MIPS_PB1500) += -Iinclude/asm-mips/mach-pb1x00 200cflags-$(CONFIG_MIPS_PB1500) += -I$(srctree)/arch/mips/include/asm/mach-pb1x00
201load-$(CONFIG_MIPS_PB1500) += 0xffffffff80100000 201load-$(CONFIG_MIPS_PB1500) += 0xffffffff80100000
202 202
203# 203#
204# AMD Alchemy Pb1550 eval board 204# AMD Alchemy Pb1550 eval board
205# 205#
206libs-$(CONFIG_MIPS_PB1550) += arch/mips/au1000/pb1550/ 206libs-$(CONFIG_MIPS_PB1550) += arch/mips/alchemy/pb1550/
207cflags-$(CONFIG_MIPS_PB1550) += -Iinclude/asm-mips/mach-pb1x00 207cflags-$(CONFIG_MIPS_PB1550) += -I$(srctree)/arch/mips/include/asm/mach-pb1x00
208load-$(CONFIG_MIPS_PB1550) += 0xffffffff80100000 208load-$(CONFIG_MIPS_PB1550) += 0xffffffff80100000
209 209
210# 210#
211# AMD Alchemy Pb1200 eval board 211# AMD Alchemy Pb1200 eval board
212# 212#
213libs-$(CONFIG_MIPS_PB1200) += arch/mips/au1000/pb1200/ 213libs-$(CONFIG_MIPS_PB1200) += arch/mips/alchemy/pb1200/
214cflags-$(CONFIG_MIPS_PB1200) += -Iinclude/asm-mips/mach-pb1x00 214cflags-$(CONFIG_MIPS_PB1200) += -I$(srctree)/arch/mips/include/asm/mach-pb1x00
215load-$(CONFIG_MIPS_PB1200) += 0xffffffff80100000 215load-$(CONFIG_MIPS_PB1200) += 0xffffffff80100000
216 216
217# 217#
218# AMD Alchemy Db1000 eval board 218# AMD Alchemy Db1000 eval board
219# 219#
220libs-$(CONFIG_MIPS_DB1000) += arch/mips/au1000/db1x00/ 220libs-$(CONFIG_MIPS_DB1000) += arch/mips/alchemy/db1x00/
221cflags-$(CONFIG_MIPS_DB1000) += -Iinclude/asm-mips/mach-db1x00 221cflags-$(CONFIG_MIPS_DB1000) += -I$(srctree)/arch/mips/include/asm/mach-db1x00
222load-$(CONFIG_MIPS_DB1000) += 0xffffffff80100000 222load-$(CONFIG_MIPS_DB1000) += 0xffffffff80100000
223 223
224# 224#
225# AMD Alchemy Db1100 eval board 225# AMD Alchemy Db1100 eval board
226# 226#
227libs-$(CONFIG_MIPS_DB1100) += arch/mips/au1000/db1x00/ 227libs-$(CONFIG_MIPS_DB1100) += arch/mips/alchemy/db1x00/
228cflags-$(CONFIG_MIPS_DB1100) += -Iinclude/asm-mips/mach-db1x00 228cflags-$(CONFIG_MIPS_DB1100) += -I$(srctree)/arch/mips/include/asm/mach-db1x00
229load-$(CONFIG_MIPS_DB1100) += 0xffffffff80100000 229load-$(CONFIG_MIPS_DB1100) += 0xffffffff80100000
230 230
231# 231#
232# AMD Alchemy Db1500 eval board 232# AMD Alchemy Db1500 eval board
233# 233#
234libs-$(CONFIG_MIPS_DB1500) += arch/mips/au1000/db1x00/ 234libs-$(CONFIG_MIPS_DB1500) += arch/mips/alchemy/db1x00/
235cflags-$(CONFIG_MIPS_DB1500) += -Iinclude/asm-mips/mach-db1x00 235cflags-$(CONFIG_MIPS_DB1500) += -I$(srctree)/arch/mips/include/asm/mach-db1x00
236load-$(CONFIG_MIPS_DB1500) += 0xffffffff80100000 236load-$(CONFIG_MIPS_DB1500) += 0xffffffff80100000
237 237
238# 238#
239# AMD Alchemy Db1550 eval board 239# AMD Alchemy Db1550 eval board
240# 240#
241libs-$(CONFIG_MIPS_DB1550) += arch/mips/au1000/db1x00/ 241libs-$(CONFIG_MIPS_DB1550) += arch/mips/alchemy/db1x00/
242cflags-$(CONFIG_MIPS_DB1550) += -Iinclude/asm-mips/mach-db1x00 242cflags-$(CONFIG_MIPS_DB1550) += -I$(srctree)/arch/mips/include/asm/mach-db1x00
243load-$(CONFIG_MIPS_DB1550) += 0xffffffff80100000 243load-$(CONFIG_MIPS_DB1550) += 0xffffffff80100000
244 244
245# 245#
246# AMD Alchemy Db1200 eval board 246# AMD Alchemy Db1200 eval board
247# 247#
248libs-$(CONFIG_MIPS_DB1200) += arch/mips/au1000/pb1200/ 248libs-$(CONFIG_MIPS_DB1200) += arch/mips/alchemy/pb1200/
249cflags-$(CONFIG_MIPS_DB1200) += -Iinclude/asm-mips/mach-db1x00 249cflags-$(CONFIG_MIPS_DB1200) += -I$(srctree)/arch/mips/include/asm/mach-db1x00
250load-$(CONFIG_MIPS_DB1200) += 0xffffffff80100000 250load-$(CONFIG_MIPS_DB1200) += 0xffffffff80100000
251 251
252# 252#
253# AMD Alchemy Bosporus eval board 253# AMD Alchemy Bosporus eval board
254# 254#
255libs-$(CONFIG_MIPS_BOSPORUS) += arch/mips/au1000/db1x00/ 255libs-$(CONFIG_MIPS_BOSPORUS) += arch/mips/alchemy/db1x00/
256cflags-$(CONFIG_MIPS_BOSPORUS) += -Iinclude/asm-mips/mach-db1x00 256cflags-$(CONFIG_MIPS_BOSPORUS) += -I$(srctree)/arch/mips/include/asm/mach-db1x00
257load-$(CONFIG_MIPS_BOSPORUS) += 0xffffffff80100000 257load-$(CONFIG_MIPS_BOSPORUS) += 0xffffffff80100000
258 258
259# 259#
260# AMD Alchemy Mirage eval board 260# AMD Alchemy Mirage eval board
261# 261#
262libs-$(CONFIG_MIPS_MIRAGE) += arch/mips/au1000/db1x00/ 262libs-$(CONFIG_MIPS_MIRAGE) += arch/mips/alchemy/db1x00/
263cflags-$(CONFIG_MIPS_MIRAGE) += -Iinclude/asm-mips/mach-db1x00 263cflags-$(CONFIG_MIPS_MIRAGE) += -I$(srctree)/arch/mips/include/asm/mach-db1x00
264load-$(CONFIG_MIPS_MIRAGE) += 0xffffffff80100000 264load-$(CONFIG_MIPS_MIRAGE) += 0xffffffff80100000
265 265
266# 266#
267# 4G-Systems eval board 267# 4G-Systems eval board
268# 268#
269libs-$(CONFIG_MIPS_MTX1) += arch/mips/au1000/mtx-1/ 269libs-$(CONFIG_MIPS_MTX1) += arch/mips/alchemy/mtx-1/
270load-$(CONFIG_MIPS_MTX1) += 0xffffffff80100000 270load-$(CONFIG_MIPS_MTX1) += 0xffffffff80100000
271 271
272# 272#
273# MyCable eval board 273# MyCable eval board
274# 274#
275libs-$(CONFIG_MIPS_XXS1500) += arch/mips/au1000/xxs1500/ 275libs-$(CONFIG_MIPS_XXS1500) += arch/mips/alchemy/xxs1500/
276load-$(CONFIG_MIPS_XXS1500) += 0xffffffff80100000 276load-$(CONFIG_MIPS_XXS1500) += 0xffffffff80100000
277 277
278# 278#
279# Cobalt Server 279# Cobalt Server
280# 280#
281core-$(CONFIG_MIPS_COBALT) += arch/mips/cobalt/ 281core-$(CONFIG_MIPS_COBALT) += arch/mips/cobalt/
282cflags-$(CONFIG_MIPS_COBALT) += -Iinclude/asm-mips/mach-cobalt 282cflags-$(CONFIG_MIPS_COBALT) += -I$(srctree)/arch/mips/include/asm/mach-cobalt
283load-$(CONFIG_MIPS_COBALT) += 0xffffffff80080000 283load-$(CONFIG_MIPS_COBALT) += 0xffffffff80080000
284 284
285# 285#
286# DECstation family 286# DECstation family
287# 287#
288core-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/ 288core-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/
289cflags-$(CONFIG_MACH_DECSTATION)+= -Iinclude/asm-mips/mach-dec 289cflags-$(CONFIG_MACH_DECSTATION)+= -I$(srctree)/arch/mips/include/asm/mach-dec
290libs-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/prom/ 290libs-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/prom/
291load-$(CONFIG_MACH_DECSTATION) += 0xffffffff80040000 291load-$(CONFIG_MACH_DECSTATION) += 0xffffffff80040000
292 292
@@ -294,7 +294,7 @@ load-$(CONFIG_MACH_DECSTATION) += 0xffffffff80040000
294# Wind River PPMC Board (4KC + GT64120) 294# Wind River PPMC Board (4KC + GT64120)
295# 295#
296core-$(CONFIG_WR_PPMC) += arch/mips/gt64120/wrppmc/ 296core-$(CONFIG_WR_PPMC) += arch/mips/gt64120/wrppmc/
297cflags-$(CONFIG_WR_PPMC) += -Iinclude/asm-mips/mach-wrppmc 297cflags-$(CONFIG_WR_PPMC) += -I$(srctree)/arch/mips/include/asm/mach-wrppmc
298load-$(CONFIG_WR_PPMC) += 0xffffffff80100000 298load-$(CONFIG_WR_PPMC) += 0xffffffff80100000
299 299
300# 300#
@@ -302,13 +302,13 @@ load-$(CONFIG_WR_PPMC) += 0xffffffff80100000
302# 302#
303core-$(CONFIG_LEMOTE_FULONG) +=arch/mips/lemote/lm2e/ 303core-$(CONFIG_LEMOTE_FULONG) +=arch/mips/lemote/lm2e/
304load-$(CONFIG_LEMOTE_FULONG) +=0xffffffff80100000 304load-$(CONFIG_LEMOTE_FULONG) +=0xffffffff80100000
305cflags-$(CONFIG_LEMOTE_FULONG) += -Iinclude/asm-mips/mach-lemote 305cflags-$(CONFIG_LEMOTE_FULONG) += -I$(srctree)/arch/mips/include/asm/mach-lemote
306 306
307# 307#
308# MIPS Malta board 308# MIPS Malta board
309# 309#
310core-$(CONFIG_MIPS_MALTA) += arch/mips/mti-malta/ 310core-$(CONFIG_MIPS_MALTA) += arch/mips/mti-malta/
311cflags-$(CONFIG_MIPS_MALTA) += -Iinclude/asm-mips/mach-malta 311cflags-$(CONFIG_MIPS_MALTA) += -I$(srctree)/arch/mips/include/asm/mach-malta
312load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000 312load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000
313all-$(CONFIG_MIPS_MALTA) := vmlinux.bin 313all-$(CONFIG_MIPS_MALTA) := vmlinux.bin
314 314
@@ -316,14 +316,14 @@ all-$(CONFIG_MIPS_MALTA) := vmlinux.bin
316# MIPS SIM 316# MIPS SIM
317# 317#
318core-$(CONFIG_MIPS_SIM) += arch/mips/mipssim/ 318core-$(CONFIG_MIPS_SIM) += arch/mips/mipssim/
319cflags-$(CONFIG_MIPS_SIM) += -Iinclude/asm-mips/mach-mipssim 319cflags-$(CONFIG_MIPS_SIM) += -I$(srctree)/arch/mips/include/asm/mach-mipssim
320load-$(CONFIG_MIPS_SIM) += 0x80100000 320load-$(CONFIG_MIPS_SIM) += 0x80100000
321 321
322# 322#
323# PMC-Sierra MSP SOCs 323# PMC-Sierra MSP SOCs
324# 324#
325core-$(CONFIG_PMC_MSP) += arch/mips/pmc-sierra/msp71xx/ 325core-$(CONFIG_PMC_MSP) += arch/mips/pmc-sierra/msp71xx/
326cflags-$(CONFIG_PMC_MSP) += -Iinclude/asm-mips/pmc-sierra/msp71xx \ 326cflags-$(CONFIG_PMC_MSP) += -I$(srctree)/arch/mips/include/asm/pmc-sierra/msp71xx \
327 -mno-branch-likely 327 -mno-branch-likely
328load-$(CONFIG_PMC_MSP) += 0xffffffff80100000 328load-$(CONFIG_PMC_MSP) += 0xffffffff80100000
329 329
@@ -331,28 +331,28 @@ load-$(CONFIG_PMC_MSP) += 0xffffffff80100000
331# PMC-Sierra Yosemite 331# PMC-Sierra Yosemite
332# 332#
333core-$(CONFIG_PMC_YOSEMITE) += arch/mips/pmc-sierra/yosemite/ 333core-$(CONFIG_PMC_YOSEMITE) += arch/mips/pmc-sierra/yosemite/
334cflags-$(CONFIG_PMC_YOSEMITE) += -Iinclude/asm-mips/mach-yosemite 334cflags-$(CONFIG_PMC_YOSEMITE) += -I$(srctree)/arch/mips/include/asm/mach-yosemite
335load-$(CONFIG_PMC_YOSEMITE) += 0xffffffff80100000 335load-$(CONFIG_PMC_YOSEMITE) += 0xffffffff80100000
336 336
337# 337#
338# Basler eXcite 338# Basler eXcite
339# 339#
340core-$(CONFIG_BASLER_EXCITE) += arch/mips/basler/excite/ 340core-$(CONFIG_BASLER_EXCITE) += arch/mips/basler/excite/
341cflags-$(CONFIG_BASLER_EXCITE) += -Iinclude/asm-mips/mach-excite 341cflags-$(CONFIG_BASLER_EXCITE) += -I$(srctree)/arch/mips/include/asm/mach-excite
342load-$(CONFIG_BASLER_EXCITE) += 0x80100000 342load-$(CONFIG_BASLER_EXCITE) += 0x80100000
343 343
344# 344#
345# LASAT platforms 345# LASAT platforms
346# 346#
347core-$(CONFIG_LASAT) += arch/mips/lasat/ 347core-$(CONFIG_LASAT) += arch/mips/lasat/
348cflags-$(CONFIG_LASAT) += -Iinclude/asm-mips/mach-lasat 348cflags-$(CONFIG_LASAT) += -I$(srctree)/arch/mips/include/asm/mach-lasat
349load-$(CONFIG_LASAT) += 0xffffffff80000000 349load-$(CONFIG_LASAT) += 0xffffffff80000000
350 350
351# 351#
352# Common VR41xx 352# Common VR41xx
353# 353#
354core-$(CONFIG_MACH_VR41XX) += arch/mips/vr41xx/common/ 354core-$(CONFIG_MACH_VR41XX) += arch/mips/vr41xx/common/
355cflags-$(CONFIG_MACH_VR41XX) += -Iinclude/asm-mips/mach-vr41xx 355cflags-$(CONFIG_MACH_VR41XX) += -I$(srctree)/arch/mips/include/asm/mach-vr41xx
356 356
357# 357#
358# ZAO Networks Capcella (VR4131) 358# ZAO Networks Capcella (VR4131)
@@ -385,13 +385,13 @@ load-$(CONFIG_TANBAC_TB022X) += 0xffffffff80000000
385# Common NXP PNX8550 385# Common NXP PNX8550
386# 386#
387core-$(CONFIG_SOC_PNX8550) += arch/mips/nxp/pnx8550/common/ 387core-$(CONFIG_SOC_PNX8550) += arch/mips/nxp/pnx8550/common/
388cflags-$(CONFIG_SOC_PNX8550) += -Iinclude/asm-mips/mach-pnx8550 388cflags-$(CONFIG_SOC_PNX8550) += -I$(srctree)/arch/mips/include/asm/mach-pnx8550
389 389
390# 390#
391# NXP PNX8550 JBS board 391# NXP PNX8550 JBS board
392# 392#
393libs-$(CONFIG_PNX8550_JBS) += arch/mips/nxp/pnx8550/jbs/ 393libs-$(CONFIG_PNX8550_JBS) += arch/mips/nxp/pnx8550/jbs/
394#cflags-$(CONFIG_PNX8550_JBS) += -Iinclude/asm-mips/mach-pnx8550 394#cflags-$(CONFIG_PNX8550_JBS) += -I$(srctree)/arch/mips/include/asm/mach-pnx8550
395load-$(CONFIG_PNX8550_JBS) += 0xffffffff80060000 395load-$(CONFIG_PNX8550_JBS) += 0xffffffff80060000
396 396
397# NXP PNX8550 STB810 board 397# NXP PNX8550 STB810 board
@@ -402,7 +402,7 @@ load-$(CONFIG_PNX8550_STB810) += 0xffffffff80060000
402# NEC EMMA2RH boards 402# NEC EMMA2RH boards
403# 403#
404core-$(CONFIG_EMMA2RH) += arch/mips/emma2rh/common/ 404core-$(CONFIG_EMMA2RH) += arch/mips/emma2rh/common/
405cflags-$(CONFIG_EMMA2RH) += -Iinclude/asm-mips/mach-emma2rh 405cflags-$(CONFIG_EMMA2RH) += -I$(srctree)/arch/mips/include/asm/mach-emma2rh
406 406
407# NEC EMMA2RH Mark-eins 407# NEC EMMA2RH Mark-eins
408core-$(CONFIG_MARKEINS) += arch/mips/emma2rh/markeins/ 408core-$(CONFIG_MARKEINS) += arch/mips/emma2rh/markeins/
@@ -418,7 +418,7 @@ load-$(CONFIG_MARKEINS) += 0xffffffff88100000
418# address by 8kb. 418# address by 8kb.
419# 419#
420core-$(CONFIG_SGI_IP22) += arch/mips/sgi-ip22/ 420core-$(CONFIG_SGI_IP22) += arch/mips/sgi-ip22/
421cflags-$(CONFIG_SGI_IP22) += -Iinclude/asm-mips/mach-ip22 421cflags-$(CONFIG_SGI_IP22) += -I$(srctree)/arch/mips/include/asm/mach-ip22
422ifdef CONFIG_32BIT 422ifdef CONFIG_32BIT
423load-$(CONFIG_SGI_IP22) += 0xffffffff88002000 423load-$(CONFIG_SGI_IP22) += 0xffffffff88002000
424endif 424endif
@@ -435,7 +435,7 @@ endif
435# 435#
436ifdef CONFIG_SGI_IP27 436ifdef CONFIG_SGI_IP27
437core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/ 437core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/
438cflags-$(CONFIG_SGI_IP27) += -Iinclude/asm-mips/mach-ip27 438cflags-$(CONFIG_SGI_IP27) += -I$(srctree)/arch/mips/include/asm/mach-ip27
439ifdef CONFIG_MAPPED_KERNEL 439ifdef CONFIG_MAPPED_KERNEL
440load-$(CONFIG_SGI_IP27) += 0xc00000004001c000 440load-$(CONFIG_SGI_IP27) += 0xc00000004001c000
441OBJCOPYFLAGS := --change-addresses=0x3fffffff80000000 441OBJCOPYFLAGS := --change-addresses=0x3fffffff80000000
@@ -460,7 +460,7 @@ ifdef CONFIG_SGI_IP28
460 endif 460 endif
461endif 461endif
462core-$(CONFIG_SGI_IP28) += arch/mips/sgi-ip22/ 462core-$(CONFIG_SGI_IP28) += arch/mips/sgi-ip22/
463cflags-$(CONFIG_SGI_IP28) += -mr10k-cache-barrier=1 -Iinclude/asm-mips/mach-ip28 463cflags-$(CONFIG_SGI_IP28) += -mr10k-cache-barrier=1 -I$(srctree)/arch/mips/include/asm/mach-ip28
464load-$(CONFIG_SGI_IP28) += 0xa800000020004000 464load-$(CONFIG_SGI_IP28) += 0xa800000020004000
465 465
466# 466#
@@ -472,7 +472,7 @@ load-$(CONFIG_SGI_IP28) += 0xa800000020004000
472# will break. 472# will break.
473# 473#
474core-$(CONFIG_SGI_IP32) += arch/mips/sgi-ip32/ 474core-$(CONFIG_SGI_IP32) += arch/mips/sgi-ip32/
475cflags-$(CONFIG_SGI_IP32) += -Iinclude/asm-mips/mach-ip32 475cflags-$(CONFIG_SGI_IP32) += -I$(srctree)/arch/mips/include/asm/mach-ip32
476load-$(CONFIG_SGI_IP32) += 0xffffffff80004000 476load-$(CONFIG_SGI_IP32) += 0xffffffff80004000
477 477
478# 478#
@@ -484,22 +484,22 @@ load-$(CONFIG_SGI_IP32) += 0xffffffff80004000
484# 484#
485core-$(CONFIG_SIBYTE_BCM112X) += arch/mips/sibyte/sb1250/ 485core-$(CONFIG_SIBYTE_BCM112X) += arch/mips/sibyte/sb1250/
486core-$(CONFIG_SIBYTE_BCM112X) += arch/mips/sibyte/common/ 486core-$(CONFIG_SIBYTE_BCM112X) += arch/mips/sibyte/common/
487cflags-$(CONFIG_SIBYTE_BCM112X) += -Iinclude/asm-mips/mach-sibyte \ 487cflags-$(CONFIG_SIBYTE_BCM112X) += -I$(srctree)/arch/mips/include/asm/mach-sibyte \
488 -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1250_112x_ALL 488 -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1250_112x_ALL
489 489
490core-$(CONFIG_SIBYTE_SB1250) += arch/mips/sibyte/sb1250/ 490core-$(CONFIG_SIBYTE_SB1250) += arch/mips/sibyte/sb1250/
491core-$(CONFIG_SIBYTE_SB1250) += arch/mips/sibyte/common/ 491core-$(CONFIG_SIBYTE_SB1250) += arch/mips/sibyte/common/
492cflags-$(CONFIG_SIBYTE_SB1250) += -Iinclude/asm-mips/mach-sibyte \ 492cflags-$(CONFIG_SIBYTE_SB1250) += -I$(srctree)/arch/mips/include/asm/mach-sibyte \
493 -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1250_112x_ALL 493 -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1250_112x_ALL
494 494
495core-$(CONFIG_SIBYTE_BCM1x55) += arch/mips/sibyte/bcm1480/ 495core-$(CONFIG_SIBYTE_BCM1x55) += arch/mips/sibyte/bcm1480/
496core-$(CONFIG_SIBYTE_BCM1x55) += arch/mips/sibyte/common/ 496core-$(CONFIG_SIBYTE_BCM1x55) += arch/mips/sibyte/common/
497cflags-$(CONFIG_SIBYTE_BCM1x55) += -Iinclude/asm-mips/mach-sibyte \ 497cflags-$(CONFIG_SIBYTE_BCM1x55) += -I$(srctree)/arch/mips/include/asm/mach-sibyte \
498 -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1480_ALL 498 -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1480_ALL
499 499
500core-$(CONFIG_SIBYTE_BCM1x80) += arch/mips/sibyte/bcm1480/ 500core-$(CONFIG_SIBYTE_BCM1x80) += arch/mips/sibyte/bcm1480/
501core-$(CONFIG_SIBYTE_BCM1x80) += arch/mips/sibyte/common/ 501core-$(CONFIG_SIBYTE_BCM1x80) += arch/mips/sibyte/common/
502cflags-$(CONFIG_SIBYTE_BCM1x80) += -Iinclude/asm-mips/mach-sibyte \ 502cflags-$(CONFIG_SIBYTE_BCM1x80) += -I$(srctree)/arch/mips/include/asm/mach-sibyte \
503 -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1480_ALL 503 -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1480_ALL
504 504
505# 505#
@@ -529,14 +529,14 @@ load-$(CONFIG_SIBYTE_BIGSUR) := 0xffffffff80100000
529# Broadcom BCM47XX boards 529# Broadcom BCM47XX boards
530# 530#
531core-$(CONFIG_BCM47XX) += arch/mips/bcm47xx/ 531core-$(CONFIG_BCM47XX) += arch/mips/bcm47xx/
532cflags-$(CONFIG_BCM47XX) += -Iinclude/asm-mips/mach-bcm47xx 532cflags-$(CONFIG_BCM47XX) += -I$(srctree)/arch/mips/include/asm/mach-bcm47xx
533load-$(CONFIG_BCM47XX) := 0xffffffff80001000 533load-$(CONFIG_BCM47XX) := 0xffffffff80001000
534 534
535# 535#
536# SNI RM 536# SNI RM
537# 537#
538core-$(CONFIG_SNI_RM) += arch/mips/sni/ 538core-$(CONFIG_SNI_RM) += arch/mips/sni/
539cflags-$(CONFIG_SNI_RM) += -Iinclude/asm-mips/mach-rm 539cflags-$(CONFIG_SNI_RM) += -I$(srctree)/arch/mips/include/asm/mach-rm
540ifdef CONFIG_CPU_LITTLE_ENDIAN 540ifdef CONFIG_CPU_LITTLE_ENDIAN
541load-$(CONFIG_SNI_RM) += 0xffffffff80600000 541load-$(CONFIG_SNI_RM) += 0xffffffff80600000
542else 542else
@@ -548,10 +548,10 @@ all-$(CONFIG_SNI_RM) := vmlinux.ecoff
548# Common TXx9 548# Common TXx9
549# 549#
550core-$(CONFIG_MACH_TX39XX) += arch/mips/txx9/generic/ 550core-$(CONFIG_MACH_TX39XX) += arch/mips/txx9/generic/
551cflags-$(CONFIG_MACH_TX39XX) += -Iinclude/asm-mips/mach-tx39xx 551cflags-$(CONFIG_MACH_TX39XX) += -I$(srctree)/arch/mips/include/asm/mach-tx39xx
552load-$(CONFIG_MACH_TX39XX) += 0xffffffff80050000 552load-$(CONFIG_MACH_TX39XX) += 0xffffffff80050000
553core-$(CONFIG_MACH_TX49XX) += arch/mips/txx9/generic/ 553core-$(CONFIG_MACH_TX49XX) += arch/mips/txx9/generic/
554cflags-$(CONFIG_MACH_TX49XX) += -Iinclude/asm-mips/mach-tx49xx 554cflags-$(CONFIG_MACH_TX49XX) += -I$(srctree)/arch/mips/include/asm/mach-tx49xx
555load-$(CONFIG_MACH_TX49XX) += 0xffffffff80100000 555load-$(CONFIG_MACH_TX49XX) += 0xffffffff80100000
556 556
557# 557#
@@ -563,21 +563,17 @@ core-$(CONFIG_TOSHIBA_JMR3927) += arch/mips/txx9/jmr3927/
563# Routerboard 532 board 563# Routerboard 532 board
564# 564#
565core-$(CONFIG_MIKROTIK_RB532) += arch/mips/rb532/ 565core-$(CONFIG_MIKROTIK_RB532) += arch/mips/rb532/
566cflags-$(CONFIG_MIKROTIK_RB532) += -Iinclude/asm-mips/mach-rc32434 566cflags-$(CONFIG_MIKROTIK_RB532) += -I$(srctree)/arch/mips/include/asm/mach-rc32434
567load-$(CONFIG_MIKROTIK_RB532) += 0xffffffff80101000 567load-$(CONFIG_MIKROTIK_RB532) += 0xffffffff80101000
568 568
569# 569#
570# Toshiba RBTX4927 board or 570# Toshiba RBTX49XX boards
571# Toshiba RBTX4937 board
572# 571#
573core-$(CONFIG_TOSHIBA_RBTX4927) += arch/mips/txx9/rbtx4927/ 572core-$(CONFIG_TOSHIBA_RBTX4927) += arch/mips/txx9/rbtx4927/
574
575#
576# Toshiba RBTX4938 board
577#
578core-$(CONFIG_TOSHIBA_RBTX4938) += arch/mips/txx9/rbtx4938/ 573core-$(CONFIG_TOSHIBA_RBTX4938) += arch/mips/txx9/rbtx4938/
574core-$(CONFIG_TOSHIBA_RBTX4939) += arch/mips/txx9/rbtx4939/
579 575
580cflags-y += -Iinclude/asm-mips/mach-generic 576cflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic
581drivers-$(CONFIG_PCI) += arch/mips/pci/ 577drivers-$(CONFIG_PCI) += arch/mips/pci/
582 578
583ifdef CONFIG_32BIT 579ifdef CONFIG_32BIT
diff --git a/arch/mips/au1000/Kconfig b/arch/mips/alchemy/Kconfig
index e4a057d80ab6..e4a057d80ab6 100644
--- a/arch/mips/au1000/Kconfig
+++ b/arch/mips/alchemy/Kconfig
diff --git a/arch/mips/au1000/common/Makefile b/arch/mips/alchemy/common/Makefile
index df48fd65bbf3..df48fd65bbf3 100644
--- a/arch/mips/au1000/common/Makefile
+++ b/arch/mips/alchemy/common/Makefile
diff --git a/arch/mips/au1000/common/au1xxx_irqmap.c b/arch/mips/alchemy/common/au1xxx_irqmap.c
index c7ca1596394c..c7ca1596394c 100644
--- a/arch/mips/au1000/common/au1xxx_irqmap.c
+++ b/arch/mips/alchemy/common/au1xxx_irqmap.c
diff --git a/arch/mips/au1000/common/clocks.c b/arch/mips/alchemy/common/clocks.c
index 043429d17c5f..043429d17c5f 100644
--- a/arch/mips/au1000/common/clocks.c
+++ b/arch/mips/alchemy/common/clocks.c
diff --git a/arch/mips/au1000/common/cputable.c b/arch/mips/alchemy/common/cputable.c
index ba6430bc2d03..ba6430bc2d03 100644
--- a/arch/mips/au1000/common/cputable.c
+++ b/arch/mips/alchemy/common/cputable.c
diff --git a/arch/mips/au1000/common/dbdma.c b/arch/mips/alchemy/common/dbdma.c
index 601ee9180ee4..601ee9180ee4 100644
--- a/arch/mips/au1000/common/dbdma.c
+++ b/arch/mips/alchemy/common/dbdma.c
diff --git a/arch/mips/au1000/common/dma.c b/arch/mips/alchemy/common/dma.c
index d6fbda232e6a..d6fbda232e6a 100644
--- a/arch/mips/au1000/common/dma.c
+++ b/arch/mips/alchemy/common/dma.c
diff --git a/arch/mips/au1000/common/gpio.c b/arch/mips/alchemy/common/gpio.c
index e660ddd611c4..e660ddd611c4 100644
--- a/arch/mips/au1000/common/gpio.c
+++ b/arch/mips/alchemy/common/gpio.c
diff --git a/arch/mips/au1000/common/irq.c b/arch/mips/alchemy/common/irq.c
index 40c6ceceb5f9..40c6ceceb5f9 100644
--- a/arch/mips/au1000/common/irq.c
+++ b/arch/mips/alchemy/common/irq.c
diff --git a/arch/mips/au1000/common/pci.c b/arch/mips/alchemy/common/pci.c
index 7866cf50cf99..7866cf50cf99 100644
--- a/arch/mips/au1000/common/pci.c
+++ b/arch/mips/alchemy/common/pci.c
diff --git a/arch/mips/au1000/common/platform.c b/arch/mips/alchemy/common/platform.c
index dc8a67efac28..dc8a67efac28 100644
--- a/arch/mips/au1000/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
diff --git a/arch/mips/au1000/common/power.c b/arch/mips/alchemy/common/power.c
index bd854a6d1d89..bd854a6d1d89 100644
--- a/arch/mips/au1000/common/power.c
+++ b/arch/mips/alchemy/common/power.c
diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/alchemy/common/prom.c
index 18b310b475ca..18b310b475ca 100644
--- a/arch/mips/au1000/common/prom.c
+++ b/arch/mips/alchemy/common/prom.c
diff --git a/arch/mips/au1000/common/puts.c b/arch/mips/alchemy/common/puts.c
index 55bbe24d45b6..55bbe24d45b6 100644
--- a/arch/mips/au1000/common/puts.c
+++ b/arch/mips/alchemy/common/puts.c
diff --git a/arch/mips/au1000/common/reset.c b/arch/mips/alchemy/common/reset.c
index d555429c8d6f..d555429c8d6f 100644
--- a/arch/mips/au1000/common/reset.c
+++ b/arch/mips/alchemy/common/reset.c
diff --git a/arch/mips/au1000/common/setup.c b/arch/mips/alchemy/common/setup.c
index 1ac6b06f42a3..1ac6b06f42a3 100644
--- a/arch/mips/au1000/common/setup.c
+++ b/arch/mips/alchemy/common/setup.c
diff --git a/arch/mips/au1000/common/sleeper.S b/arch/mips/alchemy/common/sleeper.S
index 4b3cf021a454..3006e270c8bc 100644
--- a/arch/mips/au1000/common/sleeper.S
+++ b/arch/mips/alchemy/common/sleeper.S
@@ -79,12 +79,12 @@ LEAF(save_and_sleep)
79/* Put SDRAM into self refresh. Preload instructions into cache, 79/* Put SDRAM into self refresh. Preload instructions into cache,
80 * issue a precharge, then auto refresh, then sleep commands to it. 80 * issue a precharge, then auto refresh, then sleep commands to it.
81 */ 81 */
82 la t0, sdsleep 82 la t0, sdsleep
83 .set mips3 83 .set mips3
84 cache 0x14, 0(t0) 84 cache 0x14, 0(t0)
85 cache 0x14, 32(t0) 85 cache 0x14, 32(t0)
86 cache 0x14, 64(t0) 86 cache 0x14, 64(t0)
87 cache 0x14, 96(t0) 87 cache 0x14, 96(t0)
88 .set mips0 88 .set mips0
89 89
90sdsleep: 90sdsleep:
diff --git a/arch/mips/au1000/common/time.c b/arch/mips/alchemy/common/time.c
index 563d9390a872..563d9390a872 100644
--- a/arch/mips/au1000/common/time.c
+++ b/arch/mips/alchemy/common/time.c
diff --git a/arch/mips/au1000/db1x00/Makefile b/arch/mips/alchemy/db1x00/Makefile
index 274db3b55d82..274db3b55d82 100644
--- a/arch/mips/au1000/db1x00/Makefile
+++ b/arch/mips/alchemy/db1x00/Makefile
diff --git a/arch/mips/au1000/db1x00/board_setup.c b/arch/mips/alchemy/db1x00/board_setup.c
index 9e5ccbbfcedd..9e5ccbbfcedd 100644
--- a/arch/mips/au1000/db1x00/board_setup.c
+++ b/arch/mips/alchemy/db1x00/board_setup.c
diff --git a/arch/mips/au1000/db1x00/init.c b/arch/mips/alchemy/db1x00/init.c
index 847413514964..847413514964 100644
--- a/arch/mips/au1000/db1x00/init.c
+++ b/arch/mips/alchemy/db1x00/init.c
diff --git a/arch/mips/au1000/db1x00/irqmap.c b/arch/mips/alchemy/db1x00/irqmap.c
index 94c090e8bf7a..94c090e8bf7a 100644
--- a/arch/mips/au1000/db1x00/irqmap.c
+++ b/arch/mips/alchemy/db1x00/irqmap.c
diff --git a/arch/mips/au1000/mtx-1/Makefile b/arch/mips/alchemy/mtx-1/Makefile
index 7c67b3d33bec..7c67b3d33bec 100644
--- a/arch/mips/au1000/mtx-1/Makefile
+++ b/arch/mips/alchemy/mtx-1/Makefile
diff --git a/arch/mips/au1000/mtx-1/board_setup.c b/arch/mips/alchemy/mtx-1/board_setup.c
index 3f8079186cf2..3f8079186cf2 100644
--- a/arch/mips/au1000/mtx-1/board_setup.c
+++ b/arch/mips/alchemy/mtx-1/board_setup.c
diff --git a/arch/mips/au1000/mtx-1/init.c b/arch/mips/alchemy/mtx-1/init.c
index 3bae13c28954..3bae13c28954 100644
--- a/arch/mips/au1000/mtx-1/init.c
+++ b/arch/mips/alchemy/mtx-1/init.c
diff --git a/arch/mips/au1000/mtx-1/irqmap.c b/arch/mips/alchemy/mtx-1/irqmap.c
index f2bf02951e9c..f2bf02951e9c 100644
--- a/arch/mips/au1000/mtx-1/irqmap.c
+++ b/arch/mips/alchemy/mtx-1/irqmap.c
diff --git a/arch/mips/au1000/mtx-1/platform.c b/arch/mips/alchemy/mtx-1/platform.c
index 8b5914d1241f..8b5914d1241f 100644
--- a/arch/mips/au1000/mtx-1/platform.c
+++ b/arch/mips/alchemy/mtx-1/platform.c
diff --git a/arch/mips/au1000/pb1000/Makefile b/arch/mips/alchemy/pb1000/Makefile
index 99bbec0ca41b..99bbec0ca41b 100644
--- a/arch/mips/au1000/pb1000/Makefile
+++ b/arch/mips/alchemy/pb1000/Makefile
diff --git a/arch/mips/au1000/pb1000/board_setup.c b/arch/mips/alchemy/pb1000/board_setup.c
index 25df167a95b3..25df167a95b3 100644
--- a/arch/mips/au1000/pb1000/board_setup.c
+++ b/arch/mips/alchemy/pb1000/board_setup.c
diff --git a/arch/mips/au1000/pb1000/init.c b/arch/mips/alchemy/pb1000/init.c
index 8a9c7d57208d..8a9c7d57208d 100644
--- a/arch/mips/au1000/pb1000/init.c
+++ b/arch/mips/alchemy/pb1000/init.c
diff --git a/arch/mips/au1000/pb1000/irqmap.c b/arch/mips/alchemy/pb1000/irqmap.c
index b3d56b0af321..b3d56b0af321 100644
--- a/arch/mips/au1000/pb1000/irqmap.c
+++ b/arch/mips/alchemy/pb1000/irqmap.c
diff --git a/arch/mips/au1000/pb1100/Makefile b/arch/mips/alchemy/pb1100/Makefile
index 793e97c49e46..793e97c49e46 100644
--- a/arch/mips/au1000/pb1100/Makefile
+++ b/arch/mips/alchemy/pb1100/Makefile
diff --git a/arch/mips/au1000/pb1100/board_setup.c b/arch/mips/alchemy/pb1100/board_setup.c
index c0bfd59a7a36..c0bfd59a7a36 100644
--- a/arch/mips/au1000/pb1100/board_setup.c
+++ b/arch/mips/alchemy/pb1100/board_setup.c
diff --git a/arch/mips/au1000/pb1100/init.c b/arch/mips/alchemy/pb1100/init.c
index 7c6792308bc5..7c6792308bc5 100644
--- a/arch/mips/au1000/pb1100/init.c
+++ b/arch/mips/alchemy/pb1100/init.c
diff --git a/arch/mips/au1000/pb1100/irqmap.c b/arch/mips/alchemy/pb1100/irqmap.c
index 9b7dd8b41283..9b7dd8b41283 100644
--- a/arch/mips/au1000/pb1100/irqmap.c
+++ b/arch/mips/alchemy/pb1100/irqmap.c
diff --git a/arch/mips/au1000/pb1200/Makefile b/arch/mips/alchemy/pb1200/Makefile
index d678adf7ce85..d678adf7ce85 100644
--- a/arch/mips/au1000/pb1200/Makefile
+++ b/arch/mips/alchemy/pb1200/Makefile
diff --git a/arch/mips/au1000/pb1200/board_setup.c b/arch/mips/alchemy/pb1200/board_setup.c
index 6cb2115059ad..6cb2115059ad 100644
--- a/arch/mips/au1000/pb1200/board_setup.c
+++ b/arch/mips/alchemy/pb1200/board_setup.c
diff --git a/arch/mips/au1000/pb1200/init.c b/arch/mips/alchemy/pb1200/init.c
index e9b2a0fd48ae..e9b2a0fd48ae 100644
--- a/arch/mips/au1000/pb1200/init.c
+++ b/arch/mips/alchemy/pb1200/init.c
diff --git a/arch/mips/au1000/pb1200/irqmap.c b/arch/mips/alchemy/pb1200/irqmap.c
index 2a505ad8715b..2a505ad8715b 100644
--- a/arch/mips/au1000/pb1200/irqmap.c
+++ b/arch/mips/alchemy/pb1200/irqmap.c
diff --git a/arch/mips/au1000/pb1200/platform.c b/arch/mips/alchemy/pb1200/platform.c
index f8fb0aeac571..f8fb0aeac571 100644
--- a/arch/mips/au1000/pb1200/platform.c
+++ b/arch/mips/alchemy/pb1200/platform.c
diff --git a/arch/mips/au1000/pb1500/Makefile b/arch/mips/alchemy/pb1500/Makefile
index 602f38df20bb..602f38df20bb 100644
--- a/arch/mips/au1000/pb1500/Makefile
+++ b/arch/mips/alchemy/pb1500/Makefile
diff --git a/arch/mips/au1000/pb1500/board_setup.c b/arch/mips/alchemy/pb1500/board_setup.c
index 035771c6e5b8..035771c6e5b8 100644
--- a/arch/mips/au1000/pb1500/board_setup.c
+++ b/arch/mips/alchemy/pb1500/board_setup.c
diff --git a/arch/mips/au1000/pb1500/init.c b/arch/mips/alchemy/pb1500/init.c
index 3b6e395cf952..3b6e395cf952 100644
--- a/arch/mips/au1000/pb1500/init.c
+++ b/arch/mips/alchemy/pb1500/init.c
diff --git a/arch/mips/au1000/pb1500/irqmap.c b/arch/mips/alchemy/pb1500/irqmap.c
index 39c4682766a8..39c4682766a8 100644
--- a/arch/mips/au1000/pb1500/irqmap.c
+++ b/arch/mips/alchemy/pb1500/irqmap.c
diff --git a/arch/mips/au1000/pb1550/Makefile b/arch/mips/alchemy/pb1550/Makefile
index 7d8beca87fa5..7d8beca87fa5 100644
--- a/arch/mips/au1000/pb1550/Makefile
+++ b/arch/mips/alchemy/pb1550/Makefile
diff --git a/arch/mips/au1000/pb1550/board_setup.c b/arch/mips/alchemy/pb1550/board_setup.c
index 0ed76b64b6ab..0ed76b64b6ab 100644
--- a/arch/mips/au1000/pb1550/board_setup.c
+++ b/arch/mips/alchemy/pb1550/board_setup.c
diff --git a/arch/mips/au1000/pb1550/init.c b/arch/mips/alchemy/pb1550/init.c
index e1055a13a1a0..e1055a13a1a0 100644
--- a/arch/mips/au1000/pb1550/init.c
+++ b/arch/mips/alchemy/pb1550/init.c
diff --git a/arch/mips/au1000/pb1550/irqmap.c b/arch/mips/alchemy/pb1550/irqmap.c
index a02a4d1fa899..a02a4d1fa899 100644
--- a/arch/mips/au1000/pb1550/irqmap.c
+++ b/arch/mips/alchemy/pb1550/irqmap.c
diff --git a/arch/mips/au1000/xxs1500/Makefile b/arch/mips/alchemy/xxs1500/Makefile
index db3c526f64d8..db3c526f64d8 100644
--- a/arch/mips/au1000/xxs1500/Makefile
+++ b/arch/mips/alchemy/xxs1500/Makefile
diff --git a/arch/mips/au1000/xxs1500/board_setup.c b/arch/mips/alchemy/xxs1500/board_setup.c
index 4c587acac5c3..4c587acac5c3 100644
--- a/arch/mips/au1000/xxs1500/board_setup.c
+++ b/arch/mips/alchemy/xxs1500/board_setup.c
diff --git a/arch/mips/au1000/xxs1500/init.c b/arch/mips/alchemy/xxs1500/init.c
index 7516434760a1..7516434760a1 100644
--- a/arch/mips/au1000/xxs1500/init.c
+++ b/arch/mips/alchemy/xxs1500/init.c
diff --git a/arch/mips/au1000/xxs1500/irqmap.c b/arch/mips/alchemy/xxs1500/irqmap.c
index edf06ed11870..edf06ed11870 100644
--- a/arch/mips/au1000/xxs1500/irqmap.c
+++ b/arch/mips/alchemy/xxs1500/irqmap.c
diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild
new file mode 100644
index 000000000000..7897f05e3165
--- /dev/null
+++ b/arch/mips/include/asm/Kbuild
@@ -0,0 +1,3 @@
1include include/asm-generic/Kbuild.asm
2
3header-y += cachectl.h sgidefs.h sysmips.h
diff --git a/arch/mips/include/asm/a.out.h b/arch/mips/include/asm/a.out.h
new file mode 100644
index 000000000000..cad8371422ab
--- /dev/null
+++ b/arch/mips/include/asm/a.out.h
@@ -0,0 +1,35 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 1999, 2003 by Ralf Baechle
7 */
8#ifndef _ASM_A_OUT_H
9#define _ASM_A_OUT_H
10
11#ifdef __KERNEL__
12
13
14#endif
15
16struct exec
17{
18 unsigned long a_info; /* Use macros N_MAGIC, etc for access */
19 unsigned a_text; /* length of text, in bytes */
20 unsigned a_data; /* length of data, in bytes */
21 unsigned a_bss; /* length of uninitialized data area for
22 file, in bytes */
23 unsigned a_syms; /* length of symbol table data in file,
24 in bytes */
25 unsigned a_entry; /* start address */
26 unsigned a_trsize; /* length of relocation info for text, in
27 bytes */
28 unsigned a_drsize; /* length of relocation info for data, in bytes */
29};
30
31#define N_TRSIZE(a) ((a).a_trsize)
32#define N_DRSIZE(a) ((a).a_drsize)
33#define N_SYMSIZE(a) ((a).a_syms)
34
35#endif /* _ASM_A_OUT_H */
diff --git a/arch/mips/include/asm/abi.h b/arch/mips/include/asm/abi.h
new file mode 100644
index 000000000000..1dd74fbdc09b
--- /dev/null
+++ b/arch/mips/include/asm/abi.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005, 06 by Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (C) 2005 MIPS Technologies, Inc.
8 */
9#ifndef _ASM_ABI_H
10#define _ASM_ABI_H
11
12#include <asm/signal.h>
13#include <asm/siginfo.h>
14
15struct mips_abi {
16 int (* const setup_frame)(struct k_sigaction * ka,
17 struct pt_regs *regs, int signr,
18 sigset_t *set);
19 int (* const setup_rt_frame)(struct k_sigaction * ka,
20 struct pt_regs *regs, int signr,
21 sigset_t *set, siginfo_t *info);
22 const unsigned long restart;
23};
24
25#endif /* _ASM_ABI_H */
diff --git a/arch/mips/include/asm/addrspace.h b/arch/mips/include/asm/addrspace.h
new file mode 100644
index 000000000000..569f80aacbd2
--- /dev/null
+++ b/arch/mips/include/asm/addrspace.h
@@ -0,0 +1,154 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 99 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999 by Silicon Graphics, Inc.
9 */
10#ifndef _ASM_ADDRSPACE_H
11#define _ASM_ADDRSPACE_H
12
13#include <spaces.h>
14
15/*
16 * Configure language
17 */
18#ifdef __ASSEMBLY__
19#define _ATYPE_
20#define _ATYPE32_
21#define _ATYPE64_
22#define _CONST64_(x) x
23#else
24#define _ATYPE_ __PTRDIFF_TYPE__
25#define _ATYPE32_ int
26#define _ATYPE64_ __s64
27#ifdef CONFIG_64BIT
28#define _CONST64_(x) x ## L
29#else
30#define _CONST64_(x) x ## LL
31#endif
32#endif
33
34/*
35 * 32-bit MIPS address spaces
36 */
37#ifdef __ASSEMBLY__
38#define _ACAST32_
39#define _ACAST64_
40#else
41#define _ACAST32_ (_ATYPE_)(_ATYPE32_) /* widen if necessary */
42#define _ACAST64_ (_ATYPE64_) /* do _not_ narrow */
43#endif
44
45/*
46 * Returns the kernel segment base of a given address
47 */
48#define KSEGX(a) ((_ACAST32_ (a)) & 0xe0000000)
49
50/*
51 * Returns the physical address of a CKSEGx / XKPHYS address
52 */
53#define CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff)
54#define XPHYSADDR(a) ((_ACAST64_(a)) & \
55 _CONST64_(0x000000ffffffffff))
56
57#ifdef CONFIG_64BIT
58
59/*
60 * Memory segments (64bit kernel mode addresses)
61 * The compatibility segments use the full 64-bit sign extended value. Note
62 * the R8000 doesn't have them so don't reference these in generic MIPS code.
63 */
64#define XKUSEG _CONST64_(0x0000000000000000)
65#define XKSSEG _CONST64_(0x4000000000000000)
66#define XKPHYS _CONST64_(0x8000000000000000)
67#define XKSEG _CONST64_(0xc000000000000000)
68#define CKSEG0 _CONST64_(0xffffffff80000000)
69#define CKSEG1 _CONST64_(0xffffffffa0000000)
70#define CKSSEG _CONST64_(0xffffffffc0000000)
71#define CKSEG3 _CONST64_(0xffffffffe0000000)
72
73#define CKSEG0ADDR(a) (CPHYSADDR(a) | CKSEG0)
74#define CKSEG1ADDR(a) (CPHYSADDR(a) | CKSEG1)
75#define CKSEG2ADDR(a) (CPHYSADDR(a) | CKSEG2)
76#define CKSEG3ADDR(a) (CPHYSADDR(a) | CKSEG3)
77
78#else
79
80#define CKSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
81#define CKSEG1ADDR(a) (CPHYSADDR(a) | KSEG1)
82#define CKSEG2ADDR(a) (CPHYSADDR(a) | KSEG2)
83#define CKSEG3ADDR(a) (CPHYSADDR(a) | KSEG3)
84
85/*
86 * Map an address to a certain kernel segment
87 */
88#define KSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
89#define KSEG1ADDR(a) (CPHYSADDR(a) | KSEG1)
90#define KSEG2ADDR(a) (CPHYSADDR(a) | KSEG2)
91#define KSEG3ADDR(a) (CPHYSADDR(a) | KSEG3)
92
93/*
94 * Memory segments (32bit kernel mode addresses)
95 * These are the traditional names used in the 32-bit universe.
96 */
97#define KUSEG 0x00000000
98#define KSEG0 0x80000000
99#define KSEG1 0xa0000000
100#define KSEG2 0xc0000000
101#define KSEG3 0xe0000000
102
103#define CKUSEG 0x00000000
104#define CKSEG0 0x80000000
105#define CKSEG1 0xa0000000
106#define CKSEG2 0xc0000000
107#define CKSEG3 0xe0000000
108
109#endif
110
111/*
112 * Cache modes for XKPHYS address conversion macros
113 */
114#define K_CALG_COH_EXCL1_NOL2 0
115#define K_CALG_COH_SHRL1_NOL2 1
116#define K_CALG_UNCACHED 2
117#define K_CALG_NONCOHERENT 3
118#define K_CALG_COH_EXCL 4
119#define K_CALG_COH_SHAREABLE 5
120#define K_CALG_NOTUSED 6
121#define K_CALG_UNCACHED_ACCEL 7
122
123/*
124 * 64-bit address conversions
125 */
126#define PHYS_TO_XKSEG_UNCACHED(p) PHYS_TO_XKPHYS(K_CALG_UNCACHED, (p))
127#define PHYS_TO_XKSEG_CACHED(p) PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE, (p))
128#define XKPHYS_TO_PHYS(p) ((p) & TO_PHYS_MASK)
129#define PHYS_TO_XKPHYS(cm, a) (_CONST64_(0x8000000000000000) | \
130 (_CONST64_(cm) << 59) | (a))
131
132/*
133 * The ultimate limited of the 64-bit MIPS architecture: 2 bits for selecting
134 * the region, 3 bits for the CCA mode. This leaves 59 bits of which the
135 * R8000 implements most with its 48-bit physical address space.
136 */
137#define TO_PHYS_MASK _CONST64_(0x07ffffffffffffff) /* 2^^59 - 1 */
138
139#ifndef CONFIG_CPU_R8000
140
141/*
142 * The R8000 doesn't have the 32-bit compat spaces so we don't define them
143 * in order to catch bugs in the source code.
144 */
145
146#define COMPAT_K1BASE32 _CONST64_(0xffffffffa0000000)
147#define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */
148
149#endif
150
151#define KDM_TO_PHYS(x) (_ACAST64_ (x) & TO_PHYS_MASK)
152#define PHYS_TO_K0(x) (_ACAST64_ (x) | CAC_BASE)
153
154#endif /* _ASM_ADDRSPACE_H */
diff --git a/arch/mips/include/asm/asm.h b/arch/mips/include/asm/asm.h
new file mode 100644
index 000000000000..608cfcfbb3ea
--- /dev/null
+++ b/arch/mips/include/asm/asm.h
@@ -0,0 +1,409 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1996, 1997, 1999, 2001 by Ralf Baechle
7 * Copyright (C) 1999 by Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
9 * Copyright (C) 2002 Maciej W. Rozycki
10 *
11 * Some useful macros for MIPS assembler code
12 *
13 * Some of the routines below contain useless nops that will be optimized
14 * away by gas in -O mode. These nops are however required to fill delay
15 * slots in noreorder mode.
16 */
17#ifndef __ASM_ASM_H
18#define __ASM_ASM_H
19
20#include <asm/sgidefs.h>
21
22#ifndef CAT
23#ifdef __STDC__
24#define __CAT(str1, str2) str1##str2
25#else
26#define __CAT(str1, str2) str1/**/str2
27#endif
28#define CAT(str1, str2) __CAT(str1, str2)
29#endif
30
31/*
32 * PIC specific declarations
33 * Not used for the kernel but here seems to be the right place.
34 */
35#ifdef __PIC__
36#define CPRESTORE(register) \
37 .cprestore register
38#define CPADD(register) \
39 .cpadd register
40#define CPLOAD(register) \
41 .cpload register
42#else
43#define CPRESTORE(register)
44#define CPADD(register)
45#define CPLOAD(register)
46#endif
47
48/*
49 * LEAF - declare leaf routine
50 */
51#define LEAF(symbol) \
52 .globl symbol; \
53 .align 2; \
54 .type symbol, @function; \
55 .ent symbol, 0; \
56symbol: .frame sp, 0, ra
57
58/*
59 * NESTED - declare nested routine entry point
60 */
61#define NESTED(symbol, framesize, rpc) \
62 .globl symbol; \
63 .align 2; \
64 .type symbol, @function; \
65 .ent symbol, 0; \
66symbol: .frame sp, framesize, rpc
67
68/*
69 * END - mark end of function
70 */
71#define END(function) \
72 .end function; \
73 .size function, .-function
74
75/*
76 * EXPORT - export definition of symbol
77 */
78#define EXPORT(symbol) \
79 .globl symbol; \
80symbol:
81
82/*
83 * FEXPORT - export definition of a function symbol
84 */
85#define FEXPORT(symbol) \
86 .globl symbol; \
87 .type symbol, @function; \
88symbol:
89
90/*
91 * ABS - export absolute symbol
92 */
93#define ABS(symbol,value) \
94 .globl symbol; \
95symbol = value
96
97#define PANIC(msg) \
98 .set push; \
99 .set reorder; \
100 PTR_LA a0, 8f; \
101 jal panic; \
1029: b 9b; \
103 .set pop; \
104 TEXT(msg)
105
106/*
107 * Print formatted string
108 */
109#ifdef CONFIG_PRINTK
110#define PRINT(string) \
111 .set push; \
112 .set reorder; \
113 PTR_LA a0, 8f; \
114 jal printk; \
115 .set pop; \
116 TEXT(string)
117#else
118#define PRINT(string)
119#endif
120
121#define TEXT(msg) \
122 .pushsection .data; \
1238: .asciiz msg; \
124 .popsection;
125
126/*
127 * Build text tables
128 */
129#define TTABLE(string) \
130 .pushsection .text; \
131 .word 1f; \
132 .popsection \
133 .pushsection .data; \
1341: .asciiz string; \
135 .popsection
136
137/*
138 * MIPS IV pref instruction.
139 * Use with .set noreorder only!
140 *
141 * MIPS IV implementations are free to treat this as a nop. The R5000
142 * is one of them. So we should have an option not to use this instruction.
143 */
144#ifdef CONFIG_CPU_HAS_PREFETCH
145
146#define PREF(hint,addr) \
147 .set push; \
148 .set mips4; \
149 pref hint, addr; \
150 .set pop
151
152#define PREFX(hint,addr) \
153 .set push; \
154 .set mips4; \
155 prefx hint, addr; \
156 .set pop
157
158#else /* !CONFIG_CPU_HAS_PREFETCH */
159
160#define PREF(hint, addr)
161#define PREFX(hint, addr)
162
163#endif /* !CONFIG_CPU_HAS_PREFETCH */
164
165/*
166 * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
167 */
168#if (_MIPS_ISA == _MIPS_ISA_MIPS1)
169#define MOVN(rd, rs, rt) \
170 .set push; \
171 .set reorder; \
172 beqz rt, 9f; \
173 move rd, rs; \
174 .set pop; \
1759:
176#define MOVZ(rd, rs, rt) \
177 .set push; \
178 .set reorder; \
179 bnez rt, 9f; \
180 move rd, rs; \
181 .set pop; \
1829:
183#endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
184#if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
185#define MOVN(rd, rs, rt) \
186 .set push; \
187 .set noreorder; \
188 bnezl rt, 9f; \
189 move rd, rs; \
190 .set pop; \
1919:
192#define MOVZ(rd, rs, rt) \
193 .set push; \
194 .set noreorder; \
195 beqzl rt, 9f; \
196 move rd, rs; \
197 .set pop; \
1989:
199#endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
200#if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
201 (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
202#define MOVN(rd, rs, rt) \
203 movn rd, rs, rt
204#define MOVZ(rd, rs, rt) \
205 movz rd, rs, rt
206#endif /* MIPS IV, MIPS V, MIPS32 or MIPS64 */
207
208/*
209 * Stack alignment
210 */
211#if (_MIPS_SIM == _MIPS_SIM_ABI32)
212#define ALSZ 7
213#define ALMASK ~7
214#endif
215#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
216#define ALSZ 15
217#define ALMASK ~15
218#endif
219
220/*
221 * Macros to handle different pointer/register sizes for 32/64-bit code
222 */
223
224/*
225 * Size of a register
226 */
227#ifdef __mips64
228#define SZREG 8
229#else
230#define SZREG 4
231#endif
232
233/*
234 * Use the following macros in assemblercode to load/store registers,
235 * pointers etc.
236 */
237#if (_MIPS_SIM == _MIPS_SIM_ABI32)
238#define REG_S sw
239#define REG_L lw
240#define REG_SUBU subu
241#define REG_ADDU addu
242#endif
243#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
244#define REG_S sd
245#define REG_L ld
246#define REG_SUBU dsubu
247#define REG_ADDU daddu
248#endif
249
250/*
251 * How to add/sub/load/store/shift C int variables.
252 */
253#if (_MIPS_SZINT == 32)
254#define INT_ADD add
255#define INT_ADDU addu
256#define INT_ADDI addi
257#define INT_ADDIU addiu
258#define INT_SUB sub
259#define INT_SUBU subu
260#define INT_L lw
261#define INT_S sw
262#define INT_SLL sll
263#define INT_SLLV sllv
264#define INT_SRL srl
265#define INT_SRLV srlv
266#define INT_SRA sra
267#define INT_SRAV srav
268#endif
269
270#if (_MIPS_SZINT == 64)
271#define INT_ADD dadd
272#define INT_ADDU daddu
273#define INT_ADDI daddi
274#define INT_ADDIU daddiu
275#define INT_SUB dsub
276#define INT_SUBU dsubu
277#define INT_L ld
278#define INT_S sd
279#define INT_SLL dsll
280#define INT_SLLV dsllv
281#define INT_SRL dsrl
282#define INT_SRLV dsrlv
283#define INT_SRA dsra
284#define INT_SRAV dsrav
285#endif
286
287/*
288 * How to add/sub/load/store/shift C long variables.
289 */
290#if (_MIPS_SZLONG == 32)
291#define LONG_ADD add
292#define LONG_ADDU addu
293#define LONG_ADDI addi
294#define LONG_ADDIU addiu
295#define LONG_SUB sub
296#define LONG_SUBU subu
297#define LONG_L lw
298#define LONG_S sw
299#define LONG_SLL sll
300#define LONG_SLLV sllv
301#define LONG_SRL srl
302#define LONG_SRLV srlv
303#define LONG_SRA sra
304#define LONG_SRAV srav
305
306#define LONG .word
307#define LONGSIZE 4
308#define LONGMASK 3
309#define LONGLOG 2
310#endif
311
312#if (_MIPS_SZLONG == 64)
313#define LONG_ADD dadd
314#define LONG_ADDU daddu
315#define LONG_ADDI daddi
316#define LONG_ADDIU daddiu
317#define LONG_SUB dsub
318#define LONG_SUBU dsubu
319#define LONG_L ld
320#define LONG_S sd
321#define LONG_SLL dsll
322#define LONG_SLLV dsllv
323#define LONG_SRL dsrl
324#define LONG_SRLV dsrlv
325#define LONG_SRA dsra
326#define LONG_SRAV dsrav
327
328#define LONG .dword
329#define LONGSIZE 8
330#define LONGMASK 7
331#define LONGLOG 3
332#endif
333
334/*
335 * How to add/sub/load/store/shift pointers.
336 */
337#if (_MIPS_SZPTR == 32)
338#define PTR_ADD add
339#define PTR_ADDU addu
340#define PTR_ADDI addi
341#define PTR_ADDIU addiu
342#define PTR_SUB sub
343#define PTR_SUBU subu
344#define PTR_L lw
345#define PTR_S sw
346#define PTR_LA la
347#define PTR_LI li
348#define PTR_SLL sll
349#define PTR_SLLV sllv
350#define PTR_SRL srl
351#define PTR_SRLV srlv
352#define PTR_SRA sra
353#define PTR_SRAV srav
354
355#define PTR_SCALESHIFT 2
356
357#define PTR .word
358#define PTRSIZE 4
359#define PTRLOG 2
360#endif
361
362#if (_MIPS_SZPTR == 64)
363#define PTR_ADD dadd
364#define PTR_ADDU daddu
365#define PTR_ADDI daddi
366#define PTR_ADDIU daddiu
367#define PTR_SUB dsub
368#define PTR_SUBU dsubu
369#define PTR_L ld
370#define PTR_S sd
371#define PTR_LA dla
372#define PTR_LI dli
373#define PTR_SLL dsll
374#define PTR_SLLV dsllv
375#define PTR_SRL dsrl
376#define PTR_SRLV dsrlv
377#define PTR_SRA dsra
378#define PTR_SRAV dsrav
379
380#define PTR_SCALESHIFT 3
381
382#define PTR .dword
383#define PTRSIZE 8
384#define PTRLOG 3
385#endif
386
387/*
388 * Some cp0 registers were extended to 64bit for MIPS III.
389 */
390#if (_MIPS_SIM == _MIPS_SIM_ABI32)
391#define MFC0 mfc0
392#define MTC0 mtc0
393#endif
394#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
395#define MFC0 dmfc0
396#define MTC0 dmtc0
397#endif
398
399#define SSNOP sll zero, zero, 1
400
401#ifdef CONFIG_SGI_IP28
402/* Inhibit speculative stores to volatile (e.g.DMA) or invalid addresses. */
403#include <asm/cacheops.h>
404#define R10KCBARRIER(addr) cache Cache_Barrier, addr;
405#else
406#define R10KCBARRIER(addr)
407#endif
408
409#endif /* __ASM_ASM_H */
diff --git a/arch/mips/include/asm/asmmacro-32.h b/arch/mips/include/asm/asmmacro-32.h
new file mode 100644
index 000000000000..5de3963f511e
--- /dev/null
+++ b/arch/mips/include/asm/asmmacro-32.h
@@ -0,0 +1,158 @@
1/*
2 * asmmacro.h: Assembler macros to make things easier to read.
3 *
4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
5 * Copyright (C) 1998, 1999, 2003 Ralf Baechle
6 */
7#ifndef _ASM_ASMMACRO_32_H
8#define _ASM_ASMMACRO_32_H
9
10#include <asm/asm-offsets.h>
11#include <asm/regdef.h>
12#include <asm/fpregdef.h>
13#include <asm/mipsregs.h>
14
15 .macro fpu_save_double thread status tmp1=t0
16 cfc1 \tmp1, fcr31
17 sdc1 $f0, THREAD_FPR0(\thread)
18 sdc1 $f2, THREAD_FPR2(\thread)
19 sdc1 $f4, THREAD_FPR4(\thread)
20 sdc1 $f6, THREAD_FPR6(\thread)
21 sdc1 $f8, THREAD_FPR8(\thread)
22 sdc1 $f10, THREAD_FPR10(\thread)
23 sdc1 $f12, THREAD_FPR12(\thread)
24 sdc1 $f14, THREAD_FPR14(\thread)
25 sdc1 $f16, THREAD_FPR16(\thread)
26 sdc1 $f18, THREAD_FPR18(\thread)
27 sdc1 $f20, THREAD_FPR20(\thread)
28 sdc1 $f22, THREAD_FPR22(\thread)
29 sdc1 $f24, THREAD_FPR24(\thread)
30 sdc1 $f26, THREAD_FPR26(\thread)
31 sdc1 $f28, THREAD_FPR28(\thread)
32 sdc1 $f30, THREAD_FPR30(\thread)
33 sw \tmp1, THREAD_FCR31(\thread)
34 .endm
35
36 .macro fpu_save_single thread tmp=t0
37 cfc1 \tmp, fcr31
38 swc1 $f0, THREAD_FPR0(\thread)
39 swc1 $f1, THREAD_FPR1(\thread)
40 swc1 $f2, THREAD_FPR2(\thread)
41 swc1 $f3, THREAD_FPR3(\thread)
42 swc1 $f4, THREAD_FPR4(\thread)
43 swc1 $f5, THREAD_FPR5(\thread)
44 swc1 $f6, THREAD_FPR6(\thread)
45 swc1 $f7, THREAD_FPR7(\thread)
46 swc1 $f8, THREAD_FPR8(\thread)
47 swc1 $f9, THREAD_FPR9(\thread)
48 swc1 $f10, THREAD_FPR10(\thread)
49 swc1 $f11, THREAD_FPR11(\thread)
50 swc1 $f12, THREAD_FPR12(\thread)
51 swc1 $f13, THREAD_FPR13(\thread)
52 swc1 $f14, THREAD_FPR14(\thread)
53 swc1 $f15, THREAD_FPR15(\thread)
54 swc1 $f16, THREAD_FPR16(\thread)
55 swc1 $f17, THREAD_FPR17(\thread)
56 swc1 $f18, THREAD_FPR18(\thread)
57 swc1 $f19, THREAD_FPR19(\thread)
58 swc1 $f20, THREAD_FPR20(\thread)
59 swc1 $f21, THREAD_FPR21(\thread)
60 swc1 $f22, THREAD_FPR22(\thread)
61 swc1 $f23, THREAD_FPR23(\thread)
62 swc1 $f24, THREAD_FPR24(\thread)
63 swc1 $f25, THREAD_FPR25(\thread)
64 swc1 $f26, THREAD_FPR26(\thread)
65 swc1 $f27, THREAD_FPR27(\thread)
66 swc1 $f28, THREAD_FPR28(\thread)
67 swc1 $f29, THREAD_FPR29(\thread)
68 swc1 $f30, THREAD_FPR30(\thread)
69 swc1 $f31, THREAD_FPR31(\thread)
70 sw \tmp, THREAD_FCR31(\thread)
71 .endm
72
73 .macro fpu_restore_double thread status tmp=t0
74 lw \tmp, THREAD_FCR31(\thread)
75 ldc1 $f0, THREAD_FPR0(\thread)
76 ldc1 $f2, THREAD_FPR2(\thread)
77 ldc1 $f4, THREAD_FPR4(\thread)
78 ldc1 $f6, THREAD_FPR6(\thread)
79 ldc1 $f8, THREAD_FPR8(\thread)
80 ldc1 $f10, THREAD_FPR10(\thread)
81 ldc1 $f12, THREAD_FPR12(\thread)
82 ldc1 $f14, THREAD_FPR14(\thread)
83 ldc1 $f16, THREAD_FPR16(\thread)
84 ldc1 $f18, THREAD_FPR18(\thread)
85 ldc1 $f20, THREAD_FPR20(\thread)
86 ldc1 $f22, THREAD_FPR22(\thread)
87 ldc1 $f24, THREAD_FPR24(\thread)
88 ldc1 $f26, THREAD_FPR26(\thread)
89 ldc1 $f28, THREAD_FPR28(\thread)
90 ldc1 $f30, THREAD_FPR30(\thread)
91 ctc1 \tmp, fcr31
92 .endm
93
94 .macro fpu_restore_single thread tmp=t0
95 lw \tmp, THREAD_FCR31(\thread)
96 lwc1 $f0, THREAD_FPR0(\thread)
97 lwc1 $f1, THREAD_FPR1(\thread)
98 lwc1 $f2, THREAD_FPR2(\thread)
99 lwc1 $f3, THREAD_FPR3(\thread)
100 lwc1 $f4, THREAD_FPR4(\thread)
101 lwc1 $f5, THREAD_FPR5(\thread)
102 lwc1 $f6, THREAD_FPR6(\thread)
103 lwc1 $f7, THREAD_FPR7(\thread)
104 lwc1 $f8, THREAD_FPR8(\thread)
105 lwc1 $f9, THREAD_FPR9(\thread)
106 lwc1 $f10, THREAD_FPR10(\thread)
107 lwc1 $f11, THREAD_FPR11(\thread)
108 lwc1 $f12, THREAD_FPR12(\thread)
109 lwc1 $f13, THREAD_FPR13(\thread)
110 lwc1 $f14, THREAD_FPR14(\thread)
111 lwc1 $f15, THREAD_FPR15(\thread)
112 lwc1 $f16, THREAD_FPR16(\thread)
113 lwc1 $f17, THREAD_FPR17(\thread)
114 lwc1 $f18, THREAD_FPR18(\thread)
115 lwc1 $f19, THREAD_FPR19(\thread)
116 lwc1 $f20, THREAD_FPR20(\thread)
117 lwc1 $f21, THREAD_FPR21(\thread)
118 lwc1 $f22, THREAD_FPR22(\thread)
119 lwc1 $f23, THREAD_FPR23(\thread)
120 lwc1 $f24, THREAD_FPR24(\thread)
121 lwc1 $f25, THREAD_FPR25(\thread)
122 lwc1 $f26, THREAD_FPR26(\thread)
123 lwc1 $f27, THREAD_FPR27(\thread)
124 lwc1 $f28, THREAD_FPR28(\thread)
125 lwc1 $f29, THREAD_FPR29(\thread)
126 lwc1 $f30, THREAD_FPR30(\thread)
127 lwc1 $f31, THREAD_FPR31(\thread)
128 ctc1 \tmp, fcr31
129 .endm
130
131 .macro cpu_save_nonscratch thread
132 LONG_S s0, THREAD_REG16(\thread)
133 LONG_S s1, THREAD_REG17(\thread)
134 LONG_S s2, THREAD_REG18(\thread)
135 LONG_S s3, THREAD_REG19(\thread)
136 LONG_S s4, THREAD_REG20(\thread)
137 LONG_S s5, THREAD_REG21(\thread)
138 LONG_S s6, THREAD_REG22(\thread)
139 LONG_S s7, THREAD_REG23(\thread)
140 LONG_S sp, THREAD_REG29(\thread)
141 LONG_S fp, THREAD_REG30(\thread)
142 .endm
143
144 .macro cpu_restore_nonscratch thread
145 LONG_L s0, THREAD_REG16(\thread)
146 LONG_L s1, THREAD_REG17(\thread)
147 LONG_L s2, THREAD_REG18(\thread)
148 LONG_L s3, THREAD_REG19(\thread)
149 LONG_L s4, THREAD_REG20(\thread)
150 LONG_L s5, THREAD_REG21(\thread)
151 LONG_L s6, THREAD_REG22(\thread)
152 LONG_L s7, THREAD_REG23(\thread)
153 LONG_L sp, THREAD_REG29(\thread)
154 LONG_L fp, THREAD_REG30(\thread)
155 LONG_L ra, THREAD_REG31(\thread)
156 .endm
157
158#endif /* _ASM_ASMMACRO_32_H */
diff --git a/arch/mips/include/asm/asmmacro-64.h b/arch/mips/include/asm/asmmacro-64.h
new file mode 100644
index 000000000000..225feefcb25d
--- /dev/null
+++ b/arch/mips/include/asm/asmmacro-64.h
@@ -0,0 +1,139 @@
1/*
2 * asmmacro.h: Assembler macros to make things easier to read.
3 *
4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
5 * Copyright (C) 1998, 1999 Ralf Baechle
6 * Copyright (C) 1999 Silicon Graphics, Inc.
7 */
8#ifndef _ASM_ASMMACRO_64_H
9#define _ASM_ASMMACRO_64_H
10
11#include <asm/asm-offsets.h>
12#include <asm/regdef.h>
13#include <asm/fpregdef.h>
14#include <asm/mipsregs.h>
15
16 .macro fpu_save_16even thread tmp=t0
17 cfc1 \tmp, fcr31
18 sdc1 $f0, THREAD_FPR0(\thread)
19 sdc1 $f2, THREAD_FPR2(\thread)
20 sdc1 $f4, THREAD_FPR4(\thread)
21 sdc1 $f6, THREAD_FPR6(\thread)
22 sdc1 $f8, THREAD_FPR8(\thread)
23 sdc1 $f10, THREAD_FPR10(\thread)
24 sdc1 $f12, THREAD_FPR12(\thread)
25 sdc1 $f14, THREAD_FPR14(\thread)
26 sdc1 $f16, THREAD_FPR16(\thread)
27 sdc1 $f18, THREAD_FPR18(\thread)
28 sdc1 $f20, THREAD_FPR20(\thread)
29 sdc1 $f22, THREAD_FPR22(\thread)
30 sdc1 $f24, THREAD_FPR24(\thread)
31 sdc1 $f26, THREAD_FPR26(\thread)
32 sdc1 $f28, THREAD_FPR28(\thread)
33 sdc1 $f30, THREAD_FPR30(\thread)
34 sw \tmp, THREAD_FCR31(\thread)
35 .endm
36
37 .macro fpu_save_16odd thread
38 sdc1 $f1, THREAD_FPR1(\thread)
39 sdc1 $f3, THREAD_FPR3(\thread)
40 sdc1 $f5, THREAD_FPR5(\thread)
41 sdc1 $f7, THREAD_FPR7(\thread)
42 sdc1 $f9, THREAD_FPR9(\thread)
43 sdc1 $f11, THREAD_FPR11(\thread)
44 sdc1 $f13, THREAD_FPR13(\thread)
45 sdc1 $f15, THREAD_FPR15(\thread)
46 sdc1 $f17, THREAD_FPR17(\thread)
47 sdc1 $f19, THREAD_FPR19(\thread)
48 sdc1 $f21, THREAD_FPR21(\thread)
49 sdc1 $f23, THREAD_FPR23(\thread)
50 sdc1 $f25, THREAD_FPR25(\thread)
51 sdc1 $f27, THREAD_FPR27(\thread)
52 sdc1 $f29, THREAD_FPR29(\thread)
53 sdc1 $f31, THREAD_FPR31(\thread)
54 .endm
55
56 .macro fpu_save_double thread status tmp
57 sll \tmp, \status, 5
58 bgez \tmp, 2f
59 fpu_save_16odd \thread
602:
61 fpu_save_16even \thread \tmp
62 .endm
63
64 .macro fpu_restore_16even thread tmp=t0
65 lw \tmp, THREAD_FCR31(\thread)
66 ldc1 $f0, THREAD_FPR0(\thread)
67 ldc1 $f2, THREAD_FPR2(\thread)
68 ldc1 $f4, THREAD_FPR4(\thread)
69 ldc1 $f6, THREAD_FPR6(\thread)
70 ldc1 $f8, THREAD_FPR8(\thread)
71 ldc1 $f10, THREAD_FPR10(\thread)
72 ldc1 $f12, THREAD_FPR12(\thread)
73 ldc1 $f14, THREAD_FPR14(\thread)
74 ldc1 $f16, THREAD_FPR16(\thread)
75 ldc1 $f18, THREAD_FPR18(\thread)
76 ldc1 $f20, THREAD_FPR20(\thread)
77 ldc1 $f22, THREAD_FPR22(\thread)
78 ldc1 $f24, THREAD_FPR24(\thread)
79 ldc1 $f26, THREAD_FPR26(\thread)
80 ldc1 $f28, THREAD_FPR28(\thread)
81 ldc1 $f30, THREAD_FPR30(\thread)
82 ctc1 \tmp, fcr31
83 .endm
84
85 .macro fpu_restore_16odd thread
86 ldc1 $f1, THREAD_FPR1(\thread)
87 ldc1 $f3, THREAD_FPR3(\thread)
88 ldc1 $f5, THREAD_FPR5(\thread)
89 ldc1 $f7, THREAD_FPR7(\thread)
90 ldc1 $f9, THREAD_FPR9(\thread)
91 ldc1 $f11, THREAD_FPR11(\thread)
92 ldc1 $f13, THREAD_FPR13(\thread)
93 ldc1 $f15, THREAD_FPR15(\thread)
94 ldc1 $f17, THREAD_FPR17(\thread)
95 ldc1 $f19, THREAD_FPR19(\thread)
96 ldc1 $f21, THREAD_FPR21(\thread)
97 ldc1 $f23, THREAD_FPR23(\thread)
98 ldc1 $f25, THREAD_FPR25(\thread)
99 ldc1 $f27, THREAD_FPR27(\thread)
100 ldc1 $f29, THREAD_FPR29(\thread)
101 ldc1 $f31, THREAD_FPR31(\thread)
102 .endm
103
104 .macro fpu_restore_double thread status tmp
105 sll \tmp, \status, 5
106 bgez \tmp, 1f # 16 register mode?
107
108 fpu_restore_16odd \thread
1091: fpu_restore_16even \thread \tmp
110 .endm
111
112 .macro cpu_save_nonscratch thread
113 LONG_S s0, THREAD_REG16(\thread)
114 LONG_S s1, THREAD_REG17(\thread)
115 LONG_S s2, THREAD_REG18(\thread)
116 LONG_S s3, THREAD_REG19(\thread)
117 LONG_S s4, THREAD_REG20(\thread)
118 LONG_S s5, THREAD_REG21(\thread)
119 LONG_S s6, THREAD_REG22(\thread)
120 LONG_S s7, THREAD_REG23(\thread)
121 LONG_S sp, THREAD_REG29(\thread)
122 LONG_S fp, THREAD_REG30(\thread)
123 .endm
124
125 .macro cpu_restore_nonscratch thread
126 LONG_L s0, THREAD_REG16(\thread)
127 LONG_L s1, THREAD_REG17(\thread)
128 LONG_L s2, THREAD_REG18(\thread)
129 LONG_L s3, THREAD_REG19(\thread)
130 LONG_L s4, THREAD_REG20(\thread)
131 LONG_L s5, THREAD_REG21(\thread)
132 LONG_L s6, THREAD_REG22(\thread)
133 LONG_L s7, THREAD_REG23(\thread)
134 LONG_L sp, THREAD_REG29(\thread)
135 LONG_L fp, THREAD_REG30(\thread)
136 LONG_L ra, THREAD_REG31(\thread)
137 .endm
138
139#endif /* _ASM_ASMMACRO_64_H */
diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
new file mode 100644
index 000000000000..7a881755800f
--- /dev/null
+++ b/arch/mips/include/asm/asmmacro.h
@@ -0,0 +1,82 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 Ralf Baechle
7 */
8#ifndef _ASM_ASMMACRO_H
9#define _ASM_ASMMACRO_H
10
11#include <asm/hazards.h>
12
13#ifdef CONFIG_32BIT
14#include <asm/asmmacro-32.h>
15#endif
16#ifdef CONFIG_64BIT
17#include <asm/asmmacro-64.h>
18#endif
19#ifdef CONFIG_MIPS_MT_SMTC
20#include <asm/mipsmtregs.h>
21#endif
22
23#ifdef CONFIG_MIPS_MT_SMTC
24 .macro local_irq_enable reg=t0
25 mfc0 \reg, CP0_TCSTATUS
26 ori \reg, \reg, TCSTATUS_IXMT
27 xori \reg, \reg, TCSTATUS_IXMT
28 mtc0 \reg, CP0_TCSTATUS
29 _ehb
30 .endm
31
32 .macro local_irq_disable reg=t0
33 mfc0 \reg, CP0_TCSTATUS
34 ori \reg, \reg, TCSTATUS_IXMT
35 mtc0 \reg, CP0_TCSTATUS
36 _ehb
37 .endm
38#else
39 .macro local_irq_enable reg=t0
40 mfc0 \reg, CP0_STATUS
41 ori \reg, \reg, 1
42 mtc0 \reg, CP0_STATUS
43 irq_enable_hazard
44 .endm
45
46 .macro local_irq_disable reg=t0
47 mfc0 \reg, CP0_STATUS
48 ori \reg, \reg, 1
49 xori \reg, \reg, 1
50 mtc0 \reg, CP0_STATUS
51 irq_disable_hazard
52 .endm
53#endif /* CONFIG_MIPS_MT_SMTC */
54
55/*
56 * Temporary until all gas have MT ASE support
57 */
58 .macro DMT reg=0
59 .word 0x41600bc1 | (\reg << 16)
60 .endm
61
62 .macro EMT reg=0
63 .word 0x41600be1 | (\reg << 16)
64 .endm
65
66 .macro DVPE reg=0
67 .word 0x41600001 | (\reg << 16)
68 .endm
69
70 .macro EVPE reg=0
71 .word 0x41600021 | (\reg << 16)
72 .endm
73
74 .macro MFTR rt=0, rd=0, u=0, sel=0
75 .word 0x41000000 | (\rt << 16) | (\rd << 11) | (\u << 5) | (\sel)
76 .endm
77
78 .macro MTTR rt=0, rd=0, u=0, sel=0
79 .word 0x41800000 | (\rt << 16) | (\rd << 11) | (\u << 5) | (\sel)
80 .endm
81
82#endif /* _ASM_ASMMACRO_H */
diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
new file mode 100644
index 000000000000..1232be3885b0
--- /dev/null
+++ b/arch/mips/include/asm/atomic.h
@@ -0,0 +1,801 @@
1/*
2 * Atomic operations that C can't guarantee us. Useful for
3 * resource counting etc..
4 *
5 * But use these as seldom as possible since they are much more slower
6 * than regular operations.
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 *
12 * Copyright (C) 1996, 97, 99, 2000, 03, 04, 06 by Ralf Baechle
13 */
14#ifndef _ASM_ATOMIC_H
15#define _ASM_ATOMIC_H
16
17#include <linux/irqflags.h>
18#include <asm/barrier.h>
19#include <asm/cpu-features.h>
20#include <asm/war.h>
21#include <asm/system.h>
22
23typedef struct { volatile int counter; } atomic_t;
24
25#define ATOMIC_INIT(i) { (i) }
26
27/*
28 * atomic_read - read atomic variable
29 * @v: pointer of type atomic_t
30 *
31 * Atomically reads the value of @v.
32 */
33#define atomic_read(v) ((v)->counter)
34
35/*
36 * atomic_set - set atomic variable
37 * @v: pointer of type atomic_t
38 * @i: required value
39 *
40 * Atomically sets the value of @v to @i.
41 */
42#define atomic_set(v, i) ((v)->counter = (i))
43
44/*
45 * atomic_add - add integer to atomic variable
46 * @i: integer value to add
47 * @v: pointer of type atomic_t
48 *
49 * Atomically adds @i to @v.
50 */
51static __inline__ void atomic_add(int i, atomic_t * v)
52{
53 if (cpu_has_llsc && R10000_LLSC_WAR) {
54 unsigned long temp;
55
56 __asm__ __volatile__(
57 " .set mips3 \n"
58 "1: ll %0, %1 # atomic_add \n"
59 " addu %0, %2 \n"
60 " sc %0, %1 \n"
61 " beqzl %0, 1b \n"
62 " .set mips0 \n"
63 : "=&r" (temp), "=m" (v->counter)
64 : "Ir" (i), "m" (v->counter));
65 } else if (cpu_has_llsc) {
66 unsigned long temp;
67
68 __asm__ __volatile__(
69 " .set mips3 \n"
70 "1: ll %0, %1 # atomic_add \n"
71 " addu %0, %2 \n"
72 " sc %0, %1 \n"
73 " beqz %0, 2f \n"
74 " .subsection 2 \n"
75 "2: b 1b \n"
76 " .previous \n"
77 " .set mips0 \n"
78 : "=&r" (temp), "=m" (v->counter)
79 : "Ir" (i), "m" (v->counter));
80 } else {
81 unsigned long flags;
82
83 raw_local_irq_save(flags);
84 v->counter += i;
85 raw_local_irq_restore(flags);
86 }
87}
88
89/*
90 * atomic_sub - subtract the atomic variable
91 * @i: integer value to subtract
92 * @v: pointer of type atomic_t
93 *
94 * Atomically subtracts @i from @v.
95 */
96static __inline__ void atomic_sub(int i, atomic_t * v)
97{
98 if (cpu_has_llsc && R10000_LLSC_WAR) {
99 unsigned long temp;
100
101 __asm__ __volatile__(
102 " .set mips3 \n"
103 "1: ll %0, %1 # atomic_sub \n"
104 " subu %0, %2 \n"
105 " sc %0, %1 \n"
106 " beqzl %0, 1b \n"
107 " .set mips0 \n"
108 : "=&r" (temp), "=m" (v->counter)
109 : "Ir" (i), "m" (v->counter));
110 } else if (cpu_has_llsc) {
111 unsigned long temp;
112
113 __asm__ __volatile__(
114 " .set mips3 \n"
115 "1: ll %0, %1 # atomic_sub \n"
116 " subu %0, %2 \n"
117 " sc %0, %1 \n"
118 " beqz %0, 2f \n"
119 " .subsection 2 \n"
120 "2: b 1b \n"
121 " .previous \n"
122 " .set mips0 \n"
123 : "=&r" (temp), "=m" (v->counter)
124 : "Ir" (i), "m" (v->counter));
125 } else {
126 unsigned long flags;
127
128 raw_local_irq_save(flags);
129 v->counter -= i;
130 raw_local_irq_restore(flags);
131 }
132}
133
134/*
135 * Same as above, but return the result value
136 */
137static __inline__ int atomic_add_return(int i, atomic_t * v)
138{
139 unsigned long result;
140
141 smp_llsc_mb();
142
143 if (cpu_has_llsc && R10000_LLSC_WAR) {
144 unsigned long temp;
145
146 __asm__ __volatile__(
147 " .set mips3 \n"
148 "1: ll %1, %2 # atomic_add_return \n"
149 " addu %0, %1, %3 \n"
150 " sc %0, %2 \n"
151 " beqzl %0, 1b \n"
152 " addu %0, %1, %3 \n"
153 " .set mips0 \n"
154 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
155 : "Ir" (i), "m" (v->counter)
156 : "memory");
157 } else if (cpu_has_llsc) {
158 unsigned long temp;
159
160 __asm__ __volatile__(
161 " .set mips3 \n"
162 "1: ll %1, %2 # atomic_add_return \n"
163 " addu %0, %1, %3 \n"
164 " sc %0, %2 \n"
165 " beqz %0, 2f \n"
166 " addu %0, %1, %3 \n"
167 " .subsection 2 \n"
168 "2: b 1b \n"
169 " .previous \n"
170 " .set mips0 \n"
171 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
172 : "Ir" (i), "m" (v->counter)
173 : "memory");
174 } else {
175 unsigned long flags;
176
177 raw_local_irq_save(flags);
178 result = v->counter;
179 result += i;
180 v->counter = result;
181 raw_local_irq_restore(flags);
182 }
183
184 smp_llsc_mb();
185
186 return result;
187}
188
189static __inline__ int atomic_sub_return(int i, atomic_t * v)
190{
191 unsigned long result;
192
193 smp_llsc_mb();
194
195 if (cpu_has_llsc && R10000_LLSC_WAR) {
196 unsigned long temp;
197
198 __asm__ __volatile__(
199 " .set mips3 \n"
200 "1: ll %1, %2 # atomic_sub_return \n"
201 " subu %0, %1, %3 \n"
202 " sc %0, %2 \n"
203 " beqzl %0, 1b \n"
204 " subu %0, %1, %3 \n"
205 " .set mips0 \n"
206 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
207 : "Ir" (i), "m" (v->counter)
208 : "memory");
209 } else if (cpu_has_llsc) {
210 unsigned long temp;
211
212 __asm__ __volatile__(
213 " .set mips3 \n"
214 "1: ll %1, %2 # atomic_sub_return \n"
215 " subu %0, %1, %3 \n"
216 " sc %0, %2 \n"
217 " beqz %0, 2f \n"
218 " subu %0, %1, %3 \n"
219 " .subsection 2 \n"
220 "2: b 1b \n"
221 " .previous \n"
222 " .set mips0 \n"
223 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
224 : "Ir" (i), "m" (v->counter)
225 : "memory");
226 } else {
227 unsigned long flags;
228
229 raw_local_irq_save(flags);
230 result = v->counter;
231 result -= i;
232 v->counter = result;
233 raw_local_irq_restore(flags);
234 }
235
236 smp_llsc_mb();
237
238 return result;
239}
240
241/*
242 * atomic_sub_if_positive - conditionally subtract integer from atomic variable
243 * @i: integer value to subtract
244 * @v: pointer of type atomic_t
245 *
246 * Atomically test @v and subtract @i if @v is greater or equal than @i.
247 * The function returns the old value of @v minus @i.
248 */
249static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
250{
251 unsigned long result;
252
253 smp_llsc_mb();
254
255 if (cpu_has_llsc && R10000_LLSC_WAR) {
256 unsigned long temp;
257
258 __asm__ __volatile__(
259 " .set mips3 \n"
260 "1: ll %1, %2 # atomic_sub_if_positive\n"
261 " subu %0, %1, %3 \n"
262 " bltz %0, 1f \n"
263 " sc %0, %2 \n"
264 " .set noreorder \n"
265 " beqzl %0, 1b \n"
266 " subu %0, %1, %3 \n"
267 " .set reorder \n"
268 "1: \n"
269 " .set mips0 \n"
270 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
271 : "Ir" (i), "m" (v->counter)
272 : "memory");
273 } else if (cpu_has_llsc) {
274 unsigned long temp;
275
276 __asm__ __volatile__(
277 " .set mips3 \n"
278 "1: ll %1, %2 # atomic_sub_if_positive\n"
279 " subu %0, %1, %3 \n"
280 " bltz %0, 1f \n"
281 " sc %0, %2 \n"
282 " .set noreorder \n"
283 " beqz %0, 2f \n"
284 " subu %0, %1, %3 \n"
285 " .set reorder \n"
286 " .subsection 2 \n"
287 "2: b 1b \n"
288 " .previous \n"
289 "1: \n"
290 " .set mips0 \n"
291 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
292 : "Ir" (i), "m" (v->counter)
293 : "memory");
294 } else {
295 unsigned long flags;
296
297 raw_local_irq_save(flags);
298 result = v->counter;
299 result -= i;
300 if (result >= 0)
301 v->counter = result;
302 raw_local_irq_restore(flags);
303 }
304
305 smp_llsc_mb();
306
307 return result;
308}
309
310#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
311#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
312
313/**
314 * atomic_add_unless - add unless the number is a given value
315 * @v: pointer of type atomic_t
316 * @a: the amount to add to v...
317 * @u: ...unless v is equal to u.
318 *
319 * Atomically adds @a to @v, so long as it was not @u.
320 * Returns non-zero if @v was not @u, and zero otherwise.
321 */
322static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
323{
324 int c, old;
325 c = atomic_read(v);
326 for (;;) {
327 if (unlikely(c == (u)))
328 break;
329 old = atomic_cmpxchg((v), c, c + (a));
330 if (likely(old == c))
331 break;
332 c = old;
333 }
334 return c != (u);
335}
336#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
337
338#define atomic_dec_return(v) atomic_sub_return(1, (v))
339#define atomic_inc_return(v) atomic_add_return(1, (v))
340
341/*
342 * atomic_sub_and_test - subtract value from variable and test result
343 * @i: integer value to subtract
344 * @v: pointer of type atomic_t
345 *
346 * Atomically subtracts @i from @v and returns
347 * true if the result is zero, or false for all
348 * other cases.
349 */
350#define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0)
351
352/*
353 * atomic_inc_and_test - increment and test
354 * @v: pointer of type atomic_t
355 *
356 * Atomically increments @v by 1
357 * and returns true if the result is zero, or false for all
358 * other cases.
359 */
360#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
361
362/*
363 * atomic_dec_and_test - decrement by 1 and test
364 * @v: pointer of type atomic_t
365 *
366 * Atomically decrements @v by 1 and
367 * returns true if the result is 0, or false for all other
368 * cases.
369 */
370#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
371
372/*
373 * atomic_dec_if_positive - decrement by 1 if old value positive
374 * @v: pointer of type atomic_t
375 */
376#define atomic_dec_if_positive(v) atomic_sub_if_positive(1, v)
377
378/*
379 * atomic_inc - increment atomic variable
380 * @v: pointer of type atomic_t
381 *
382 * Atomically increments @v by 1.
383 */
384#define atomic_inc(v) atomic_add(1, (v))
385
386/*
387 * atomic_dec - decrement and test
388 * @v: pointer of type atomic_t
389 *
390 * Atomically decrements @v by 1.
391 */
392#define atomic_dec(v) atomic_sub(1, (v))
393
394/*
395 * atomic_add_negative - add and test if negative
396 * @v: pointer of type atomic_t
397 * @i: integer value to add
398 *
399 * Atomically adds @i to @v and returns true
400 * if the result is negative, or false when
401 * result is greater than or equal to zero.
402 */
403#define atomic_add_negative(i, v) (atomic_add_return(i, (v)) < 0)
404
405#ifdef CONFIG_64BIT
406
407typedef struct { volatile long counter; } atomic64_t;
408
409#define ATOMIC64_INIT(i) { (i) }
410
411/*
412 * atomic64_read - read atomic variable
413 * @v: pointer of type atomic64_t
414 *
415 */
416#define atomic64_read(v) ((v)->counter)
417
418/*
419 * atomic64_set - set atomic variable
420 * @v: pointer of type atomic64_t
421 * @i: required value
422 */
423#define atomic64_set(v, i) ((v)->counter = (i))
424
425/*
426 * atomic64_add - add integer to atomic variable
427 * @i: integer value to add
428 * @v: pointer of type atomic64_t
429 *
430 * Atomically adds @i to @v.
431 */
432static __inline__ void atomic64_add(long i, atomic64_t * v)
433{
434 if (cpu_has_llsc && R10000_LLSC_WAR) {
435 unsigned long temp;
436
437 __asm__ __volatile__(
438 " .set mips3 \n"
439 "1: lld %0, %1 # atomic64_add \n"
440 " addu %0, %2 \n"
441 " scd %0, %1 \n"
442 " beqzl %0, 1b \n"
443 " .set mips0 \n"
444 : "=&r" (temp), "=m" (v->counter)
445 : "Ir" (i), "m" (v->counter));
446 } else if (cpu_has_llsc) {
447 unsigned long temp;
448
449 __asm__ __volatile__(
450 " .set mips3 \n"
451 "1: lld %0, %1 # atomic64_add \n"
452 " addu %0, %2 \n"
453 " scd %0, %1 \n"
454 " beqz %0, 2f \n"
455 " .subsection 2 \n"
456 "2: b 1b \n"
457 " .previous \n"
458 " .set mips0 \n"
459 : "=&r" (temp), "=m" (v->counter)
460 : "Ir" (i), "m" (v->counter));
461 } else {
462 unsigned long flags;
463
464 raw_local_irq_save(flags);
465 v->counter += i;
466 raw_local_irq_restore(flags);
467 }
468}
469
470/*
471 * atomic64_sub - subtract the atomic variable
472 * @i: integer value to subtract
473 * @v: pointer of type atomic64_t
474 *
475 * Atomically subtracts @i from @v.
476 */
477static __inline__ void atomic64_sub(long i, atomic64_t * v)
478{
479 if (cpu_has_llsc && R10000_LLSC_WAR) {
480 unsigned long temp;
481
482 __asm__ __volatile__(
483 " .set mips3 \n"
484 "1: lld %0, %1 # atomic64_sub \n"
485 " subu %0, %2 \n"
486 " scd %0, %1 \n"
487 " beqzl %0, 1b \n"
488 " .set mips0 \n"
489 : "=&r" (temp), "=m" (v->counter)
490 : "Ir" (i), "m" (v->counter));
491 } else if (cpu_has_llsc) {
492 unsigned long temp;
493
494 __asm__ __volatile__(
495 " .set mips3 \n"
496 "1: lld %0, %1 # atomic64_sub \n"
497 " subu %0, %2 \n"
498 " scd %0, %1 \n"
499 " beqz %0, 2f \n"
500 " .subsection 2 \n"
501 "2: b 1b \n"
502 " .previous \n"
503 " .set mips0 \n"
504 : "=&r" (temp), "=m" (v->counter)
505 : "Ir" (i), "m" (v->counter));
506 } else {
507 unsigned long flags;
508
509 raw_local_irq_save(flags);
510 v->counter -= i;
511 raw_local_irq_restore(flags);
512 }
513}
514
515/*
516 * Same as above, but return the result value
517 */
518static __inline__ long atomic64_add_return(long i, atomic64_t * v)
519{
520 unsigned long result;
521
522 smp_llsc_mb();
523
524 if (cpu_has_llsc && R10000_LLSC_WAR) {
525 unsigned long temp;
526
527 __asm__ __volatile__(
528 " .set mips3 \n"
529 "1: lld %1, %2 # atomic64_add_return \n"
530 " addu %0, %1, %3 \n"
531 " scd %0, %2 \n"
532 " beqzl %0, 1b \n"
533 " addu %0, %1, %3 \n"
534 " .set mips0 \n"
535 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
536 : "Ir" (i), "m" (v->counter)
537 : "memory");
538 } else if (cpu_has_llsc) {
539 unsigned long temp;
540
541 __asm__ __volatile__(
542 " .set mips3 \n"
543 "1: lld %1, %2 # atomic64_add_return \n"
544 " addu %0, %1, %3 \n"
545 " scd %0, %2 \n"
546 " beqz %0, 2f \n"
547 " addu %0, %1, %3 \n"
548 " .subsection 2 \n"
549 "2: b 1b \n"
550 " .previous \n"
551 " .set mips0 \n"
552 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
553 : "Ir" (i), "m" (v->counter)
554 : "memory");
555 } else {
556 unsigned long flags;
557
558 raw_local_irq_save(flags);
559 result = v->counter;
560 result += i;
561 v->counter = result;
562 raw_local_irq_restore(flags);
563 }
564
565 smp_llsc_mb();
566
567 return result;
568}
569
570static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
571{
572 unsigned long result;
573
574 smp_llsc_mb();
575
576 if (cpu_has_llsc && R10000_LLSC_WAR) {
577 unsigned long temp;
578
579 __asm__ __volatile__(
580 " .set mips3 \n"
581 "1: lld %1, %2 # atomic64_sub_return \n"
582 " subu %0, %1, %3 \n"
583 " scd %0, %2 \n"
584 " beqzl %0, 1b \n"
585 " subu %0, %1, %3 \n"
586 " .set mips0 \n"
587 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
588 : "Ir" (i), "m" (v->counter)
589 : "memory");
590 } else if (cpu_has_llsc) {
591 unsigned long temp;
592
593 __asm__ __volatile__(
594 " .set mips3 \n"
595 "1: lld %1, %2 # atomic64_sub_return \n"
596 " subu %0, %1, %3 \n"
597 " scd %0, %2 \n"
598 " beqz %0, 2f \n"
599 " subu %0, %1, %3 \n"
600 " .subsection 2 \n"
601 "2: b 1b \n"
602 " .previous \n"
603 " .set mips0 \n"
604 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
605 : "Ir" (i), "m" (v->counter)
606 : "memory");
607 } else {
608 unsigned long flags;
609
610 raw_local_irq_save(flags);
611 result = v->counter;
612 result -= i;
613 v->counter = result;
614 raw_local_irq_restore(flags);
615 }
616
617 smp_llsc_mb();
618
619 return result;
620}
621
622/*
623 * atomic64_sub_if_positive - conditionally subtract integer from atomic variable
624 * @i: integer value to subtract
625 * @v: pointer of type atomic64_t
626 *
627 * Atomically test @v and subtract @i if @v is greater or equal than @i.
628 * The function returns the old value of @v minus @i.
629 */
630static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
631{
632 unsigned long result;
633
634 smp_llsc_mb();
635
636 if (cpu_has_llsc && R10000_LLSC_WAR) {
637 unsigned long temp;
638
639 __asm__ __volatile__(
640 " .set mips3 \n"
641 "1: lld %1, %2 # atomic64_sub_if_positive\n"
642 " dsubu %0, %1, %3 \n"
643 " bltz %0, 1f \n"
644 " scd %0, %2 \n"
645 " .set noreorder \n"
646 " beqzl %0, 1b \n"
647 " dsubu %0, %1, %3 \n"
648 " .set reorder \n"
649 "1: \n"
650 " .set mips0 \n"
651 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
652 : "Ir" (i), "m" (v->counter)
653 : "memory");
654 } else if (cpu_has_llsc) {
655 unsigned long temp;
656
657 __asm__ __volatile__(
658 " .set mips3 \n"
659 "1: lld %1, %2 # atomic64_sub_if_positive\n"
660 " dsubu %0, %1, %3 \n"
661 " bltz %0, 1f \n"
662 " scd %0, %2 \n"
663 " .set noreorder \n"
664 " beqz %0, 2f \n"
665 " dsubu %0, %1, %3 \n"
666 " .set reorder \n"
667 " .subsection 2 \n"
668 "2: b 1b \n"
669 " .previous \n"
670 "1: \n"
671 " .set mips0 \n"
672 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
673 : "Ir" (i), "m" (v->counter)
674 : "memory");
675 } else {
676 unsigned long flags;
677
678 raw_local_irq_save(flags);
679 result = v->counter;
680 result -= i;
681 if (result >= 0)
682 v->counter = result;
683 raw_local_irq_restore(flags);
684 }
685
686 smp_llsc_mb();
687
688 return result;
689}
690
691#define atomic64_cmpxchg(v, o, n) \
692 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
693#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
694
695/**
696 * atomic64_add_unless - add unless the number is a given value
697 * @v: pointer of type atomic64_t
698 * @a: the amount to add to v...
699 * @u: ...unless v is equal to u.
700 *
701 * Atomically adds @a to @v, so long as it was not @u.
702 * Returns non-zero if @v was not @u, and zero otherwise.
703 */
704static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
705{
706 long c, old;
707 c = atomic64_read(v);
708 for (;;) {
709 if (unlikely(c == (u)))
710 break;
711 old = atomic64_cmpxchg((v), c, c + (a));
712 if (likely(old == c))
713 break;
714 c = old;
715 }
716 return c != (u);
717}
718
719#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
720
721#define atomic64_dec_return(v) atomic64_sub_return(1, (v))
722#define atomic64_inc_return(v) atomic64_add_return(1, (v))
723
724/*
725 * atomic64_sub_and_test - subtract value from variable and test result
726 * @i: integer value to subtract
727 * @v: pointer of type atomic64_t
728 *
729 * Atomically subtracts @i from @v and returns
730 * true if the result is zero, or false for all
731 * other cases.
732 */
733#define atomic64_sub_and_test(i, v) (atomic64_sub_return((i), (v)) == 0)
734
735/*
736 * atomic64_inc_and_test - increment and test
737 * @v: pointer of type atomic64_t
738 *
739 * Atomically increments @v by 1
740 * and returns true if the result is zero, or false for all
741 * other cases.
742 */
743#define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
744
745/*
746 * atomic64_dec_and_test - decrement by 1 and test
747 * @v: pointer of type atomic64_t
748 *
749 * Atomically decrements @v by 1 and
750 * returns true if the result is 0, or false for all other
751 * cases.
752 */
753#define atomic64_dec_and_test(v) (atomic64_sub_return(1, (v)) == 0)
754
755/*
756 * atomic64_dec_if_positive - decrement by 1 if old value positive
757 * @v: pointer of type atomic64_t
758 */
759#define atomic64_dec_if_positive(v) atomic64_sub_if_positive(1, v)
760
761/*
762 * atomic64_inc - increment atomic variable
763 * @v: pointer of type atomic64_t
764 *
765 * Atomically increments @v by 1.
766 */
767#define atomic64_inc(v) atomic64_add(1, (v))
768
769/*
770 * atomic64_dec - decrement and test
771 * @v: pointer of type atomic64_t
772 *
773 * Atomically decrements @v by 1.
774 */
775#define atomic64_dec(v) atomic64_sub(1, (v))
776
777/*
778 * atomic64_add_negative - add and test if negative
779 * @v: pointer of type atomic64_t
780 * @i: integer value to add
781 *
782 * Atomically adds @i to @v and returns true
783 * if the result is negative, or false when
784 * result is greater than or equal to zero.
785 */
786#define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
787
788#endif /* CONFIG_64BIT */
789
790/*
791 * atomic*_return operations are serializing but not the non-*_return
792 * versions.
793 */
794#define smp_mb__before_atomic_dec() smp_llsc_mb()
795#define smp_mb__after_atomic_dec() smp_llsc_mb()
796#define smp_mb__before_atomic_inc() smp_llsc_mb()
797#define smp_mb__after_atomic_inc() smp_llsc_mb()
798
799#include <asm-generic/atomic.h>
800
801#endif /* _ASM_ATOMIC_H */
diff --git a/arch/mips/include/asm/auxvec.h b/arch/mips/include/asm/auxvec.h
new file mode 100644
index 000000000000..7cf7f2d21943
--- /dev/null
+++ b/arch/mips/include/asm/auxvec.h
@@ -0,0 +1,4 @@
1#ifndef _ASM_AUXVEC_H
2#define _ASM_AUXVEC_H
3
4#endif /* _ASM_AUXVEC_H */
diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h
new file mode 100644
index 000000000000..8e9ac313ca3b
--- /dev/null
+++ b/arch/mips/include/asm/barrier.h
@@ -0,0 +1,155 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2006 by Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef __ASM_BARRIER_H
9#define __ASM_BARRIER_H
10
11/*
12 * read_barrier_depends - Flush all pending reads that subsequents reads
13 * depend on.
14 *
15 * No data-dependent reads from memory-like regions are ever reordered
16 * over this barrier. All reads preceding this primitive are guaranteed
17 * to access memory (but not necessarily other CPUs' caches) before any
18 * reads following this primitive that depend on the data return by
19 * any of the preceding reads. This primitive is much lighter weight than
20 * rmb() on most CPUs, and is never heavier weight than is
21 * rmb().
22 *
23 * These ordering constraints are respected by both the local CPU
24 * and the compiler.
25 *
26 * Ordering is not guaranteed by anything other than these primitives,
27 * not even by data dependencies. See the documentation for
28 * memory_barrier() for examples and URLs to more information.
29 *
30 * For example, the following code would force ordering (the initial
31 * value of "a" is zero, "b" is one, and "p" is "&a"):
32 *
33 * <programlisting>
34 * CPU 0 CPU 1
35 *
36 * b = 2;
37 * memory_barrier();
38 * p = &b; q = p;
39 * read_barrier_depends();
40 * d = *q;
41 * </programlisting>
42 *
43 * because the read of "*q" depends on the read of "p" and these
44 * two reads are separated by a read_barrier_depends(). However,
45 * the following code, with the same initial values for "a" and "b":
46 *
47 * <programlisting>
48 * CPU 0 CPU 1
49 *
50 * a = 2;
51 * memory_barrier();
52 * b = 3; y = b;
53 * read_barrier_depends();
54 * x = a;
55 * </programlisting>
56 *
57 * does not enforce ordering, since there is no data dependency between
58 * the read of "a" and the read of "b". Therefore, on some CPUs, such
59 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
60 * in cases like this where there are no data dependencies.
61 */
62
63#define read_barrier_depends() do { } while(0)
64#define smp_read_barrier_depends() do { } while(0)
65
66#ifdef CONFIG_CPU_HAS_SYNC
67#define __sync() \
68 __asm__ __volatile__( \
69 ".set push\n\t" \
70 ".set noreorder\n\t" \
71 ".set mips2\n\t" \
72 "sync\n\t" \
73 ".set pop" \
74 : /* no output */ \
75 : /* no input */ \
76 : "memory")
77#else
78#define __sync() do { } while(0)
79#endif
80
81#define __fast_iob() \
82 __asm__ __volatile__( \
83 ".set push\n\t" \
84 ".set noreorder\n\t" \
85 "lw $0,%0\n\t" \
86 "nop\n\t" \
87 ".set pop" \
88 : /* no output */ \
89 : "m" (*(int *)CKSEG1) \
90 : "memory")
91
92#define fast_wmb() __sync()
93#define fast_rmb() __sync()
94#define fast_mb() __sync()
95#ifdef CONFIG_SGI_IP28
96#define fast_iob() \
97 __asm__ __volatile__( \
98 ".set push\n\t" \
99 ".set noreorder\n\t" \
100 "lw $0,%0\n\t" \
101 "sync\n\t" \
102 "lw $0,%0\n\t" \
103 ".set pop" \
104 : /* no output */ \
105 : "m" (*(int *)CKSEG1ADDR(0x1fa00004)) \
106 : "memory")
107#else
108#define fast_iob() \
109 do { \
110 __sync(); \
111 __fast_iob(); \
112 } while (0)
113#endif
114
115#ifdef CONFIG_CPU_HAS_WB
116
117#include <asm/wbflush.h>
118
119#define wmb() fast_wmb()
120#define rmb() fast_rmb()
121#define mb() wbflush()
122#define iob() wbflush()
123
124#else /* !CONFIG_CPU_HAS_WB */
125
126#define wmb() fast_wmb()
127#define rmb() fast_rmb()
128#define mb() fast_mb()
129#define iob() fast_iob()
130
131#endif /* !CONFIG_CPU_HAS_WB */
132
133#if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP)
134#define __WEAK_ORDERING_MB " sync \n"
135#else
136#define __WEAK_ORDERING_MB " \n"
137#endif
138#if defined(CONFIG_WEAK_REORDERING_BEYOND_LLSC) && defined(CONFIG_SMP)
139#define __WEAK_LLSC_MB " sync \n"
140#else
141#define __WEAK_LLSC_MB " \n"
142#endif
143
144#define smp_mb() __asm__ __volatile__(__WEAK_ORDERING_MB : : :"memory")
145#define smp_rmb() __asm__ __volatile__(__WEAK_ORDERING_MB : : :"memory")
146#define smp_wmb() __asm__ __volatile__(__WEAK_ORDERING_MB : : :"memory")
147
148#define set_mb(var, value) \
149 do { var = value; smp_mb(); } while (0)
150
151#define smp_llsc_mb() __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory")
152#define smp_llsc_rmb() __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory")
153#define smp_llsc_wmb() __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory")
154
155#endif /* __ASM_BARRIER_H */
diff --git a/arch/mips/include/asm/bcache.h b/arch/mips/include/asm/bcache.h
new file mode 100644
index 000000000000..0ba9d6ef76a7
--- /dev/null
+++ b/arch/mips/include/asm/bcache.h
@@ -0,0 +1,60 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 1997, 1999 by Ralf Baechle
7 * Copyright (c) 1999 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_BCACHE_H
10#define _ASM_BCACHE_H
11
12
13/* 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 cache thing itself. */
16struct bcache_ops {
17 void (*bc_enable)(void);
18 void (*bc_disable)(void);
19 void (*bc_wback_inv)(unsigned long page, unsigned long size);
20 void (*bc_inv)(unsigned long page, unsigned long size);
21};
22
23extern void indy_sc_init(void);
24
25#ifdef CONFIG_BOARD_SCACHE
26
27extern struct bcache_ops *bcops;
28
29static inline void bc_enable(void)
30{
31 bcops->bc_enable();
32}
33
34static inline void bc_disable(void)
35{
36 bcops->bc_disable();
37}
38
39static inline void bc_wback_inv(unsigned long page, unsigned long size)
40{
41 bcops->bc_wback_inv(page, size);
42}
43
44static inline void bc_inv(unsigned long page, unsigned long size)
45{
46 bcops->bc_inv(page, size);
47}
48
49#else /* !defined(CONFIG_BOARD_SCACHE) */
50
51/* Not R4000 / R4400 / R4600 / R5000. */
52
53#define bc_enable() do { } while (0)
54#define bc_disable() do { } while (0)
55#define bc_wback_inv(page, size) do { } while (0)
56#define bc_inv(page, size) do { } while (0)
57
58#endif /* !defined(CONFIG_BOARD_SCACHE) */
59
60#endif /* _ASM_BCACHE_H */
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
new file mode 100644
index 000000000000..49df8c4c9d25
--- /dev/null
+++ b/arch/mips/include/asm/bitops.h
@@ -0,0 +1,672 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 1994 - 1997, 99, 2000, 06, 07 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (c) 1999, 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_BITOPS_H
10#define _ASM_BITOPS_H
11
12#ifndef _LINUX_BITOPS_H
13#error only <linux/bitops.h> can be included directly
14#endif
15
16#include <linux/compiler.h>
17#include <linux/irqflags.h>
18#include <linux/types.h>
19#include <asm/barrier.h>
20#include <asm/bug.h>
21#include <asm/byteorder.h> /* sigh ... */
22#include <asm/cpu-features.h>
23#include <asm/sgidefs.h>
24#include <asm/war.h>
25
26#if _MIPS_SZLONG == 32
27#define SZLONG_LOG 5
28#define SZLONG_MASK 31UL
29#define __LL "ll "
30#define __SC "sc "
31#define __INS "ins "
32#define __EXT "ext "
33#elif _MIPS_SZLONG == 64
34#define SZLONG_LOG 6
35#define SZLONG_MASK 63UL
36#define __LL "lld "
37#define __SC "scd "
38#define __INS "dins "
39#define __EXT "dext "
40#endif
41
42/*
43 * clear_bit() doesn't provide any barrier for the compiler.
44 */
45#define smp_mb__before_clear_bit() smp_llsc_mb()
46#define smp_mb__after_clear_bit() smp_llsc_mb()
47
48/*
49 * set_bit - Atomically set a bit in memory
50 * @nr: the bit to set
51 * @addr: the address to start counting from
52 *
53 * This function is atomic and may not be reordered. See __set_bit()
54 * if you do not require the atomic guarantees.
55 * Note that @nr may be almost arbitrarily large; this function is not
56 * restricted to acting on a single-word quantity.
57 */
58static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
59{
60 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
61 unsigned short bit = nr & SZLONG_MASK;
62 unsigned long temp;
63
64 if (cpu_has_llsc && R10000_LLSC_WAR) {
65 __asm__ __volatile__(
66 " .set mips3 \n"
67 "1: " __LL "%0, %1 # set_bit \n"
68 " or %0, %2 \n"
69 " " __SC "%0, %1 \n"
70 " beqzl %0, 1b \n"
71 " .set mips0 \n"
72 : "=&r" (temp), "=m" (*m)
73 : "ir" (1UL << bit), "m" (*m));
74#ifdef CONFIG_CPU_MIPSR2
75 } else if (__builtin_constant_p(bit)) {
76 __asm__ __volatile__(
77 "1: " __LL "%0, %1 # set_bit \n"
78 " " __INS "%0, %4, %2, 1 \n"
79 " " __SC "%0, %1 \n"
80 " beqz %0, 2f \n"
81 " .subsection 2 \n"
82 "2: b 1b \n"
83 " .previous \n"
84 : "=&r" (temp), "=m" (*m)
85 : "ir" (bit), "m" (*m), "r" (~0));
86#endif /* CONFIG_CPU_MIPSR2 */
87 } else if (cpu_has_llsc) {
88 __asm__ __volatile__(
89 " .set mips3 \n"
90 "1: " __LL "%0, %1 # set_bit \n"
91 " or %0, %2 \n"
92 " " __SC "%0, %1 \n"
93 " beqz %0, 2f \n"
94 " .subsection 2 \n"
95 "2: b 1b \n"
96 " .previous \n"
97 " .set mips0 \n"
98 : "=&r" (temp), "=m" (*m)
99 : "ir" (1UL << bit), "m" (*m));
100 } else {
101 volatile unsigned long *a = addr;
102 unsigned long mask;
103 unsigned long flags;
104
105 a += nr >> SZLONG_LOG;
106 mask = 1UL << bit;
107 raw_local_irq_save(flags);
108 *a |= mask;
109 raw_local_irq_restore(flags);
110 }
111}
112
113/*
114 * clear_bit - Clears a bit in memory
115 * @nr: Bit to clear
116 * @addr: Address to start counting from
117 *
118 * clear_bit() is atomic and may not be reordered. However, it does
119 * not contain a memory barrier, so if it is used for locking purposes,
120 * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
121 * in order to ensure changes are visible on other processors.
122 */
123static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
124{
125 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
126 unsigned short bit = nr & SZLONG_MASK;
127 unsigned long temp;
128
129 if (cpu_has_llsc && R10000_LLSC_WAR) {
130 __asm__ __volatile__(
131 " .set mips3 \n"
132 "1: " __LL "%0, %1 # clear_bit \n"
133 " and %0, %2 \n"
134 " " __SC "%0, %1 \n"
135 " beqzl %0, 1b \n"
136 " .set mips0 \n"
137 : "=&r" (temp), "=m" (*m)
138 : "ir" (~(1UL << bit)), "m" (*m));
139#ifdef CONFIG_CPU_MIPSR2
140 } else if (__builtin_constant_p(bit)) {
141 __asm__ __volatile__(
142 "1: " __LL "%0, %1 # clear_bit \n"
143 " " __INS "%0, $0, %2, 1 \n"
144 " " __SC "%0, %1 \n"
145 " beqz %0, 2f \n"
146 " .subsection 2 \n"
147 "2: b 1b \n"
148 " .previous \n"
149 : "=&r" (temp), "=m" (*m)
150 : "ir" (bit), "m" (*m));
151#endif /* CONFIG_CPU_MIPSR2 */
152 } else if (cpu_has_llsc) {
153 __asm__ __volatile__(
154 " .set mips3 \n"
155 "1: " __LL "%0, %1 # clear_bit \n"
156 " and %0, %2 \n"
157 " " __SC "%0, %1 \n"
158 " beqz %0, 2f \n"
159 " .subsection 2 \n"
160 "2: b 1b \n"
161 " .previous \n"
162 " .set mips0 \n"
163 : "=&r" (temp), "=m" (*m)
164 : "ir" (~(1UL << bit)), "m" (*m));
165 } else {
166 volatile unsigned long *a = addr;
167 unsigned long mask;
168 unsigned long flags;
169
170 a += nr >> SZLONG_LOG;
171 mask = 1UL << bit;
172 raw_local_irq_save(flags);
173 *a &= ~mask;
174 raw_local_irq_restore(flags);
175 }
176}
177
178/*
179 * clear_bit_unlock - Clears a bit in memory
180 * @nr: Bit to clear
181 * @addr: Address to start counting from
182 *
183 * clear_bit() is atomic and implies release semantics before the memory
184 * operation. It can be used for an unlock.
185 */
186static inline void clear_bit_unlock(unsigned long nr, volatile unsigned long *addr)
187{
188 smp_mb__before_clear_bit();
189 clear_bit(nr, addr);
190}
191
192/*
193 * change_bit - Toggle a bit in memory
194 * @nr: Bit to change
195 * @addr: Address to start counting from
196 *
197 * change_bit() is atomic and may not be reordered.
198 * Note that @nr may be almost arbitrarily large; this function is not
199 * restricted to acting on a single-word quantity.
200 */
201static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
202{
203 unsigned short bit = nr & SZLONG_MASK;
204
205 if (cpu_has_llsc && R10000_LLSC_WAR) {
206 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
207 unsigned long temp;
208
209 __asm__ __volatile__(
210 " .set mips3 \n"
211 "1: " __LL "%0, %1 # change_bit \n"
212 " xor %0, %2 \n"
213 " " __SC "%0, %1 \n"
214 " beqzl %0, 1b \n"
215 " .set mips0 \n"
216 : "=&r" (temp), "=m" (*m)
217 : "ir" (1UL << bit), "m" (*m));
218 } else if (cpu_has_llsc) {
219 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
220 unsigned long temp;
221
222 __asm__ __volatile__(
223 " .set mips3 \n"
224 "1: " __LL "%0, %1 # change_bit \n"
225 " xor %0, %2 \n"
226 " " __SC "%0, %1 \n"
227 " beqz %0, 2f \n"
228 " .subsection 2 \n"
229 "2: b 1b \n"
230 " .previous \n"
231 " .set mips0 \n"
232 : "=&r" (temp), "=m" (*m)
233 : "ir" (1UL << bit), "m" (*m));
234 } else {
235 volatile unsigned long *a = addr;
236 unsigned long mask;
237 unsigned long flags;
238
239 a += nr >> SZLONG_LOG;
240 mask = 1UL << bit;
241 raw_local_irq_save(flags);
242 *a ^= mask;
243 raw_local_irq_restore(flags);
244 }
245}
246
247/*
248 * test_and_set_bit - Set a bit and return its old value
249 * @nr: Bit to set
250 * @addr: Address to count from
251 *
252 * This operation is atomic and cannot be reordered.
253 * It also implies a memory barrier.
254 */
255static inline int test_and_set_bit(unsigned long nr,
256 volatile unsigned long *addr)
257{
258 unsigned short bit = nr & SZLONG_MASK;
259 unsigned long res;
260
261 smp_llsc_mb();
262
263 if (cpu_has_llsc && R10000_LLSC_WAR) {
264 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
265 unsigned long temp;
266
267 __asm__ __volatile__(
268 " .set mips3 \n"
269 "1: " __LL "%0, %1 # test_and_set_bit \n"
270 " or %2, %0, %3 \n"
271 " " __SC "%2, %1 \n"
272 " beqzl %2, 1b \n"
273 " and %2, %0, %3 \n"
274 " .set mips0 \n"
275 : "=&r" (temp), "=m" (*m), "=&r" (res)
276 : "r" (1UL << bit), "m" (*m)
277 : "memory");
278 } else if (cpu_has_llsc) {
279 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
280 unsigned long temp;
281
282 __asm__ __volatile__(
283 " .set push \n"
284 " .set noreorder \n"
285 " .set mips3 \n"
286 "1: " __LL "%0, %1 # test_and_set_bit \n"
287 " or %2, %0, %3 \n"
288 " " __SC "%2, %1 \n"
289 " beqz %2, 2f \n"
290 " and %2, %0, %3 \n"
291 " .subsection 2 \n"
292 "2: b 1b \n"
293 " nop \n"
294 " .previous \n"
295 " .set pop \n"
296 : "=&r" (temp), "=m" (*m), "=&r" (res)
297 : "r" (1UL << bit), "m" (*m)
298 : "memory");
299 } else {
300 volatile unsigned long *a = addr;
301 unsigned long mask;
302 unsigned long flags;
303
304 a += nr >> SZLONG_LOG;
305 mask = 1UL << bit;
306 raw_local_irq_save(flags);
307 res = (mask & *a);
308 *a |= mask;
309 raw_local_irq_restore(flags);
310 }
311
312 smp_llsc_mb();
313
314 return res != 0;
315}
316
317/*
318 * test_and_set_bit_lock - Set a bit and return its old value
319 * @nr: Bit to set
320 * @addr: Address to count from
321 *
322 * This operation is atomic and implies acquire ordering semantics
323 * after the memory operation.
324 */
325static inline int test_and_set_bit_lock(unsigned long nr,
326 volatile unsigned long *addr)
327{
328 unsigned short bit = nr & SZLONG_MASK;
329 unsigned long res;
330
331 if (cpu_has_llsc && R10000_LLSC_WAR) {
332 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
333 unsigned long temp;
334
335 __asm__ __volatile__(
336 " .set mips3 \n"
337 "1: " __LL "%0, %1 # test_and_set_bit \n"
338 " or %2, %0, %3 \n"
339 " " __SC "%2, %1 \n"
340 " beqzl %2, 1b \n"
341 " and %2, %0, %3 \n"
342 " .set mips0 \n"
343 : "=&r" (temp), "=m" (*m), "=&r" (res)
344 : "r" (1UL << bit), "m" (*m)
345 : "memory");
346 } else if (cpu_has_llsc) {
347 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
348 unsigned long temp;
349
350 __asm__ __volatile__(
351 " .set push \n"
352 " .set noreorder \n"
353 " .set mips3 \n"
354 "1: " __LL "%0, %1 # test_and_set_bit \n"
355 " or %2, %0, %3 \n"
356 " " __SC "%2, %1 \n"
357 " beqz %2, 2f \n"
358 " and %2, %0, %3 \n"
359 " .subsection 2 \n"
360 "2: b 1b \n"
361 " nop \n"
362 " .previous \n"
363 " .set pop \n"
364 : "=&r" (temp), "=m" (*m), "=&r" (res)
365 : "r" (1UL << bit), "m" (*m)
366 : "memory");
367 } else {
368 volatile unsigned long *a = addr;
369 unsigned long mask;
370 unsigned long flags;
371
372 a += nr >> SZLONG_LOG;
373 mask = 1UL << bit;
374 raw_local_irq_save(flags);
375 res = (mask & *a);
376 *a |= mask;
377 raw_local_irq_restore(flags);
378 }
379
380 smp_llsc_mb();
381
382 return res != 0;
383}
384/*
385 * test_and_clear_bit - Clear a bit and return its old value
386 * @nr: Bit to clear
387 * @addr: Address to count from
388 *
389 * This operation is atomic and cannot be reordered.
390 * It also implies a memory barrier.
391 */
392static inline int test_and_clear_bit(unsigned long nr,
393 volatile unsigned long *addr)
394{
395 unsigned short bit = nr & SZLONG_MASK;
396 unsigned long res;
397
398 smp_llsc_mb();
399
400 if (cpu_has_llsc && R10000_LLSC_WAR) {
401 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
402 unsigned long temp;
403
404 __asm__ __volatile__(
405 " .set mips3 \n"
406 "1: " __LL "%0, %1 # test_and_clear_bit \n"
407 " or %2, %0, %3 \n"
408 " xor %2, %3 \n"
409 " " __SC "%2, %1 \n"
410 " beqzl %2, 1b \n"
411 " and %2, %0, %3 \n"
412 " .set mips0 \n"
413 : "=&r" (temp), "=m" (*m), "=&r" (res)
414 : "r" (1UL << bit), "m" (*m)
415 : "memory");
416#ifdef CONFIG_CPU_MIPSR2
417 } else if (__builtin_constant_p(nr)) {
418 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
419 unsigned long temp;
420
421 __asm__ __volatile__(
422 "1: " __LL "%0, %1 # test_and_clear_bit \n"
423 " " __EXT "%2, %0, %3, 1 \n"
424 " " __INS "%0, $0, %3, 1 \n"
425 " " __SC "%0, %1 \n"
426 " beqz %0, 2f \n"
427 " .subsection 2 \n"
428 "2: b 1b \n"
429 " .previous \n"
430 : "=&r" (temp), "=m" (*m), "=&r" (res)
431 : "ir" (bit), "m" (*m)
432 : "memory");
433#endif
434 } else if (cpu_has_llsc) {
435 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
436 unsigned long temp;
437
438 __asm__ __volatile__(
439 " .set push \n"
440 " .set noreorder \n"
441 " .set mips3 \n"
442 "1: " __LL "%0, %1 # test_and_clear_bit \n"
443 " or %2, %0, %3 \n"
444 " xor %2, %3 \n"
445 " " __SC "%2, %1 \n"
446 " beqz %2, 2f \n"
447 " and %2, %0, %3 \n"
448 " .subsection 2 \n"
449 "2: b 1b \n"
450 " nop \n"
451 " .previous \n"
452 " .set pop \n"
453 : "=&r" (temp), "=m" (*m), "=&r" (res)
454 : "r" (1UL << bit), "m" (*m)
455 : "memory");
456 } else {
457 volatile unsigned long *a = addr;
458 unsigned long mask;
459 unsigned long flags;
460
461 a += nr >> SZLONG_LOG;
462 mask = 1UL << bit;
463 raw_local_irq_save(flags);
464 res = (mask & *a);
465 *a &= ~mask;
466 raw_local_irq_restore(flags);
467 }
468
469 smp_llsc_mb();
470
471 return res != 0;
472}
473
474/*
475 * test_and_change_bit - Change a bit and return its old value
476 * @nr: Bit to change
477 * @addr: Address to count from
478 *
479 * This operation is atomic and cannot be reordered.
480 * It also implies a memory barrier.
481 */
482static inline int test_and_change_bit(unsigned long nr,
483 volatile unsigned long *addr)
484{
485 unsigned short bit = nr & SZLONG_MASK;
486 unsigned long res;
487
488 smp_llsc_mb();
489
490 if (cpu_has_llsc && R10000_LLSC_WAR) {
491 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
492 unsigned long temp;
493
494 __asm__ __volatile__(
495 " .set mips3 \n"
496 "1: " __LL "%0, %1 # test_and_change_bit \n"
497 " xor %2, %0, %3 \n"
498 " " __SC "%2, %1 \n"
499 " beqzl %2, 1b \n"
500 " and %2, %0, %3 \n"
501 " .set mips0 \n"
502 : "=&r" (temp), "=m" (*m), "=&r" (res)
503 : "r" (1UL << bit), "m" (*m)
504 : "memory");
505 } else if (cpu_has_llsc) {
506 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
507 unsigned long temp;
508
509 __asm__ __volatile__(
510 " .set push \n"
511 " .set noreorder \n"
512 " .set mips3 \n"
513 "1: " __LL "%0, %1 # test_and_change_bit \n"
514 " xor %2, %0, %3 \n"
515 " " __SC "\t%2, %1 \n"
516 " beqz %2, 2f \n"
517 " and %2, %0, %3 \n"
518 " .subsection 2 \n"
519 "2: b 1b \n"
520 " nop \n"
521 " .previous \n"
522 " .set pop \n"
523 : "=&r" (temp), "=m" (*m), "=&r" (res)
524 : "r" (1UL << bit), "m" (*m)
525 : "memory");
526 } else {
527 volatile unsigned long *a = addr;
528 unsigned long mask;
529 unsigned long flags;
530
531 a += nr >> SZLONG_LOG;
532 mask = 1UL << bit;
533 raw_local_irq_save(flags);
534 res = (mask & *a);
535 *a ^= mask;
536 raw_local_irq_restore(flags);
537 }
538
539 smp_llsc_mb();
540
541 return res != 0;
542}
543
544#include <asm-generic/bitops/non-atomic.h>
545
546/*
547 * __clear_bit_unlock - Clears a bit in memory
548 * @nr: Bit to clear
549 * @addr: Address to start counting from
550 *
551 * __clear_bit() is non-atomic and implies release semantics before the memory
552 * operation. It can be used for an unlock if no other CPUs can concurrently
553 * modify other bits in the word.
554 */
555static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *addr)
556{
557 smp_mb();
558 __clear_bit(nr, addr);
559}
560
561#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
562
563/*
564 * Return the bit position (0..63) of the most significant 1 bit in a word
565 * Returns -1 if no 1 bit exists
566 */
567static inline unsigned long __fls(unsigned long x)
568{
569 int lz;
570
571 if (sizeof(x) == 4) {
572 __asm__(
573 " .set push \n"
574 " .set mips32 \n"
575 " clz %0, %1 \n"
576 " .set pop \n"
577 : "=r" (lz)
578 : "r" (x));
579
580 return 31 - lz;
581 }
582
583 BUG_ON(sizeof(x) != 8);
584
585 __asm__(
586 " .set push \n"
587 " .set mips64 \n"
588 " dclz %0, %1 \n"
589 " .set pop \n"
590 : "=r" (lz)
591 : "r" (x));
592
593 return 63 - lz;
594}
595
596/*
597 * __ffs - find first bit in word.
598 * @word: The word to search
599 *
600 * Returns 0..SZLONG-1
601 * Undefined if no bit exists, so code should check against 0 first.
602 */
603static inline unsigned long __ffs(unsigned long word)
604{
605 return __fls(word & -word);
606}
607
608/*
609 * fls - find last bit set.
610 * @word: The word to search
611 *
612 * This is defined the same way as ffs.
613 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
614 */
615static inline int fls(int word)
616{
617 __asm__("clz %0, %1" : "=r" (word) : "r" (word));
618
619 return 32 - word;
620}
621
622#if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPS64)
623static inline int fls64(__u64 word)
624{
625 __asm__("dclz %0, %1" : "=r" (word) : "r" (word));
626
627 return 64 - word;
628}
629#else
630#include <asm-generic/bitops/fls64.h>
631#endif
632
633/*
634 * ffs - find first bit set.
635 * @word: The word to search
636 *
637 * This is defined the same way as
638 * the libc and compiler builtin ffs routines, therefore
639 * differs in spirit from the above ffz (man ffs).
640 */
641static inline int ffs(int word)
642{
643 if (!word)
644 return 0;
645
646 return fls(word & -word);
647}
648
649#else
650
651#include <asm-generic/bitops/__ffs.h>
652#include <asm-generic/bitops/__fls.h>
653#include <asm-generic/bitops/ffs.h>
654#include <asm-generic/bitops/fls.h>
655#include <asm-generic/bitops/fls64.h>
656
657#endif /*defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) */
658
659#include <asm-generic/bitops/ffz.h>
660#include <asm-generic/bitops/find.h>
661
662#ifdef __KERNEL__
663
664#include <asm-generic/bitops/sched.h>
665#include <asm-generic/bitops/hweight.h>
666#include <asm-generic/bitops/ext2-non-atomic.h>
667#include <asm-generic/bitops/ext2-atomic.h>
668#include <asm-generic/bitops/minix.h>
669
670#endif /* __KERNEL__ */
671
672#endif /* _ASM_BITOPS_H */
diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
new file mode 100644
index 000000000000..610fe3af7a03
--- /dev/null
+++ b/arch/mips/include/asm/bootinfo.h
@@ -0,0 +1,110 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file COPYING in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1996, 2003 by Ralf Baechle
7 * Copyright (C) 1995, 1996 Andreas Busse
8 * Copyright (C) 1995, 1996 Stoned Elipot
9 * Copyright (C) 1995, 1996 Paul M. Antoine.
10 */
11#ifndef _ASM_BOOTINFO_H
12#define _ASM_BOOTINFO_H
13
14#include <linux/types.h>
15#include <asm/setup.h>
16
17/*
18 * The MACH_ IDs are sort of equivalent to PCI product IDs. As such the
19 * numbers do not necessarily reflect technical relations or similarities
20 * between systems.
21 */
22
23/*
24 * Valid machtype values for group unknown
25 */
26#define MACH_UNKNOWN 0 /* whatever... */
27
28/*
29 * Valid machtype for group DEC
30 */
31#define MACH_DSUNKNOWN 0
32#define MACH_DS23100 1 /* DECstation 2100 or 3100 */
33#define MACH_DS5100 2 /* DECsystem 5100 */
34#define MACH_DS5000_200 3 /* DECstation 5000/200 */
35#define MACH_DS5000_1XX 4 /* DECstation 5000/120, 125, 133, 150 */
36#define MACH_DS5000_XX 5 /* DECstation 5000/20, 25, 33, 50 */
37#define MACH_DS5000_2X0 6 /* DECstation 5000/240, 260 */
38#define MACH_DS5400 7 /* DECsystem 5400 */
39#define MACH_DS5500 8 /* DECsystem 5500 */
40#define MACH_DS5800 9 /* DECsystem 5800 */
41#define MACH_DS5900 10 /* DECsystem 5900 */
42
43/*
44 * Valid machtype for group PMC-MSP
45 */
46#define MACH_MSP4200_EVAL 0 /* PMC-Sierra MSP4200 Evaluation */
47#define MACH_MSP4200_GW 1 /* PMC-Sierra MSP4200 Gateway demo */
48#define MACH_MSP4200_FPGA 2 /* PMC-Sierra MSP4200 Emulation */
49#define MACH_MSP7120_EVAL 3 /* PMC-Sierra MSP7120 Evaluation */
50#define MACH_MSP7120_GW 4 /* PMC-Sierra MSP7120 Residential GW */
51#define MACH_MSP7120_FPGA 5 /* PMC-Sierra MSP7120 Emulation */
52#define MACH_MSP_OTHER 255 /* PMC-Sierra unknown board type */
53
54/*
55 * Valid machtype for group Mikrotik
56 */
57#define MACH_MIKROTIK_RB532 0 /* Mikrotik RouterBoard 532 */
58#define MACH_MIKROTIK_RB532A 1 /* Mikrotik RouterBoard 532A */
59
60#define CL_SIZE COMMAND_LINE_SIZE
61
62extern char *system_type;
63const char *get_system_type(void);
64
65extern unsigned long mips_machtype;
66
67#define BOOT_MEM_MAP_MAX 32
68#define BOOT_MEM_RAM 1
69#define BOOT_MEM_ROM_DATA 2
70#define BOOT_MEM_RESERVED 3
71
72/*
73 * A memory map that's built upon what was determined
74 * or specified on the command line.
75 */
76struct boot_mem_map {
77 int nr_map;
78 struct boot_mem_map_entry {
79 phys_t addr; /* start of memory segment */
80 phys_t size; /* size of memory segment */
81 long type; /* type of memory segment */
82 } map[BOOT_MEM_MAP_MAX];
83};
84
85extern struct boot_mem_map boot_mem_map;
86
87extern void add_memory_region(phys_t start, phys_t size, long type);
88
89extern void prom_init(void);
90extern void prom_free_prom_memory(void);
91
92extern void free_init_pages(const char *what,
93 unsigned long begin, unsigned long end);
94
95/*
96 * Initial kernel command line, usually setup by prom_init()
97 */
98extern char arcs_cmdline[CL_SIZE];
99
100/*
101 * Registers a0, a1, a3 and a4 as passed to the kernel entry by firmware
102 */
103extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
104
105/*
106 * Platform memory detection hook called by setup_arch
107 */
108extern void plat_mem_setup(void);
109
110#endif /* _ASM_BOOTINFO_H */
diff --git a/arch/mips/include/asm/branch.h b/arch/mips/include/asm/branch.h
new file mode 100644
index 000000000000..37c6857c8d4a
--- /dev/null
+++ b/arch/mips/include/asm/branch.h
@@ -0,0 +1,38 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1998, 2001 by Ralf Baechle
7 */
8#ifndef _ASM_BRANCH_H
9#define _ASM_BRANCH_H
10
11#include <asm/ptrace.h>
12
13static inline int delay_slot(struct pt_regs *regs)
14{
15 return regs->cp0_cause & CAUSEF_BD;
16}
17
18static inline unsigned long exception_epc(struct pt_regs *regs)
19{
20 if (!delay_slot(regs))
21 return regs->cp0_epc;
22
23 return regs->cp0_epc + 4;
24}
25
26extern int __compute_return_epc(struct pt_regs *regs);
27
28static inline int compute_return_epc(struct pt_regs *regs)
29{
30 if (!delay_slot(regs)) {
31 regs->cp0_epc += 4;
32 return 0;
33 }
34
35 return __compute_return_epc(regs);
36}
37
38#endif /* _ASM_BRANCH_H */
diff --git a/arch/mips/include/asm/break.h b/arch/mips/include/asm/break.h
new file mode 100644
index 000000000000..25b980c91e7e
--- /dev/null
+++ b/arch/mips/include/asm/break.h
@@ -0,0 +1,34 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 2003 by Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 */
9#ifndef __ASM_BREAK_H
10#define __ASM_BREAK_H
11
12/*
13 * The following break codes are or were in use for specific purposes in
14 * other MIPS operating systems. Linux/MIPS doesn't use all of them. The
15 * unused ones are here as placeholders; we might encounter them in
16 * non-Linux/MIPS object files or make use of them in the future.
17 */
18#define BRK_USERBP 0 /* User bp (used by debuggers) */
19#define BRK_KERNELBP 1 /* Break in the kernel */
20#define BRK_ABORT 2 /* Sometimes used by abort(3) to SIGIOT */
21#define BRK_BD_TAKEN 3 /* For bd slot emulation - not implemented */
22#define BRK_BD_NOTTAKEN 4 /* For bd slot emulation - not implemented */
23#define BRK_SSTEPBP 5 /* User bp (used by debuggers) */
24#define BRK_OVERFLOW 6 /* Overflow check */
25#define BRK_DIVZERO 7 /* Divide by zero check */
26#define BRK_RANGE 8 /* Range error check */
27#define BRK_STACKOVERFLOW 9 /* For Ada stackchecking */
28#define BRK_NORLD 10 /* No rld found - not used by Linux/MIPS */
29#define _BRK_THREADBP 11 /* For threads, user bp (used by debuggers) */
30#define BRK_BUG 512 /* Used by BUG() */
31#define BRK_KDB 513 /* Used in KDB_ENTER() */
32#define BRK_MULOVF 1023 /* Multiply overflow */
33
34#endif /* __ASM_BREAK_H */
diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h
new file mode 100644
index 000000000000..7eb63de808bc
--- /dev/null
+++ b/arch/mips/include/asm/bug.h
@@ -0,0 +1,33 @@
1#ifndef __ASM_BUG_H
2#define __ASM_BUG_H
3
4#include <asm/sgidefs.h>
5
6#ifdef CONFIG_BUG
7
8#include <asm/break.h>
9
10#define BUG() \
11do { \
12 __asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \
13} while (0)
14
15#define HAVE_ARCH_BUG
16
17#if (_MIPS_ISA > _MIPS_ISA_MIPS1)
18
19#define BUG_ON(condition) \
20do { \
21 __asm__ __volatile__("tne $0, %0, %1" \
22 : : "r" (condition), "i" (BRK_BUG)); \
23} while (0)
24
25#define HAVE_ARCH_BUG_ON
26
27#endif /* _MIPS_ISA > _MIPS_ISA_MIPS1 */
28
29#endif
30
31#include <asm-generic/bug.h>
32
33#endif /* __ASM_BUG_H */
diff --git a/arch/mips/include/asm/bugs.h b/arch/mips/include/asm/bugs.h
new file mode 100644
index 000000000000..9dc10df32078
--- /dev/null
+++ b/arch/mips/include/asm/bugs.h
@@ -0,0 +1,53 @@
1/*
2 * This is included by init/main.c to check for architecture-dependent bugs.
3 *
4 * Copyright (C) 2007 Maciej W. Rozycki
5 *
6 * Needs:
7 * void check_bugs(void);
8 */
9#ifndef _ASM_BUGS_H
10#define _ASM_BUGS_H
11
12#include <linux/bug.h>
13#include <linux/delay.h>
14
15#include <asm/cpu.h>
16#include <asm/cpu-info.h>
17
18extern int daddiu_bug;
19
20extern void check_bugs64_early(void);
21
22extern void check_bugs32(void);
23extern void check_bugs64(void);
24
25static inline void check_bugs_early(void)
26{
27#ifdef CONFIG_64BIT
28 check_bugs64_early();
29#endif
30}
31
32static inline void check_bugs(void)
33{
34 unsigned int cpu = smp_processor_id();
35
36 cpu_data[cpu].udelay_val = loops_per_jiffy;
37 check_bugs32();
38#ifdef CONFIG_64BIT
39 check_bugs64();
40#endif
41}
42
43static inline int r4k_daddiu_bug(void)
44{
45#ifdef CONFIG_64BIT
46 WARN_ON(daddiu_bug < 0);
47 return daddiu_bug != 0;
48#else
49 return 0;
50#endif
51}
52
53#endif /* _ASM_BUGS_H */
diff --git a/arch/mips/include/asm/byteorder.h b/arch/mips/include/asm/byteorder.h
new file mode 100644
index 000000000000..fe7dc2d59b69
--- /dev/null
+++ b/arch/mips/include/asm/byteorder.h
@@ -0,0 +1,76 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 99, 2003 by Ralf Baechle
7 */
8#ifndef _ASM_BYTEORDER_H
9#define _ASM_BYTEORDER_H
10
11#include <linux/compiler.h>
12#include <asm/types.h>
13
14#ifdef __GNUC__
15
16#ifdef CONFIG_CPU_MIPSR2
17
18static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
19{
20 __asm__(
21 " wsbh %0, %1 \n"
22 : "=r" (x)
23 : "r" (x));
24
25 return x;
26}
27#define __arch__swab16(x) ___arch__swab16(x)
28
29static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
30{
31 __asm__(
32 " wsbh %0, %1 \n"
33 " rotr %0, %0, 16 \n"
34 : "=r" (x)
35 : "r" (x));
36
37 return x;
38}
39#define __arch__swab32(x) ___arch__swab32(x)
40
41#ifdef CONFIG_CPU_MIPS64_R2
42
43static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
44{
45 __asm__(
46 " dsbh %0, %1 \n"
47 " dshd %0, %0 \n"
48 " drotr %0, %0, 32 \n"
49 : "=r" (x)
50 : "r" (x));
51
52 return x;
53}
54
55#define __arch__swab64(x) ___arch__swab64(x)
56
57#endif /* CONFIG_CPU_MIPS64_R2 */
58
59#endif /* CONFIG_CPU_MIPSR2 */
60
61#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
62# define __BYTEORDER_HAS_U64__
63# define __SWAB_64_THRU_32__
64#endif
65
66#endif /* __GNUC__ */
67
68#if defined(__MIPSEB__)
69# include <linux/byteorder/big_endian.h>
70#elif defined(__MIPSEL__)
71# include <linux/byteorder/little_endian.h>
72#else
73# error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???"
74#endif
75
76#endif /* _ASM_BYTEORDER_H */
diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
new file mode 100644
index 000000000000..37f175c42bb5
--- /dev/null
+++ b/arch/mips/include/asm/cache.h
@@ -0,0 +1,20 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1997, 98, 99, 2000, 2003 Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_CACHE_H
10#define _ASM_CACHE_H
11
12#include <kmalloc.h>
13
14#define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
15#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
16
17#define SMP_CACHE_SHIFT L1_CACHE_SHIFT
18#define SMP_CACHE_BYTES L1_CACHE_BYTES
19
20#endif /* _ASM_CACHE_H */
diff --git a/arch/mips/include/asm/cachectl.h b/arch/mips/include/asm/cachectl.h
new file mode 100644
index 000000000000..f3ce721861d3
--- /dev/null
+++ b/arch/mips/include/asm/cachectl.h
@@ -0,0 +1,26 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 1995, 1996 by Ralf Baechle
7 */
8#ifndef _ASM_CACHECTL
9#define _ASM_CACHECTL
10
11/*
12 * Options for cacheflush system call
13 */
14#define ICACHE (1<<0) /* flush instruction cache */
15#define DCACHE (1<<1) /* writeback and flush data cache */
16#define BCACHE (ICACHE|DCACHE) /* flush both caches */
17
18/*
19 * Caching modes for the cachectl(2) call
20 *
21 * cachectl(2) is currently not supported and returns ENOSYS.
22 */
23#define CACHEABLE 0 /* make pages cacheable */
24#define UNCACHEABLE 1 /* make pages uncacheable */
25
26#endif /* _ASM_CACHECTL */
diff --git a/arch/mips/include/asm/cacheflush.h b/arch/mips/include/asm/cacheflush.h
new file mode 100644
index 000000000000..03b1d69b142f
--- /dev/null
+++ b/arch/mips/include/asm/cacheflush.h
@@ -0,0 +1,116 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 03 by Ralf Baechle
7 * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_CACHEFLUSH_H
10#define _ASM_CACHEFLUSH_H
11
12/* Keep includes the same across arches. */
13#include <linux/mm.h>
14#include <asm/cpu-features.h>
15
16/* Cache flushing:
17 *
18 * - flush_cache_all() flushes entire cache
19 * - flush_cache_mm(mm) flushes the specified mm context's cache lines
20 * - flush_cache_dup mm(mm) handles cache flushing when forking
21 * - flush_cache_page(mm, vmaddr, pfn) flushes a single page
22 * - flush_cache_range(vma, start, end) flushes a range of pages
23 * - flush_icache_range(start, end) flush a range of instructions
24 * - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache
25 *
26 * MIPS specific flush operations:
27 *
28 * - flush_cache_sigtramp() flush signal trampoline
29 * - flush_icache_all() flush the entire instruction cache
30 * - flush_data_cache_page() flushes a page from the data cache
31 */
32extern void (*flush_cache_all)(void);
33extern void (*__flush_cache_all)(void);
34extern void (*flush_cache_mm)(struct mm_struct *mm);
35#define flush_cache_dup_mm(mm) do { (void) (mm); } while (0)
36extern void (*flush_cache_range)(struct vm_area_struct *vma,
37 unsigned long start, unsigned long end);
38extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn);
39extern void __flush_dcache_page(struct page *page);
40
41static inline void flush_dcache_page(struct page *page)
42{
43 if (cpu_has_dc_aliases || !cpu_has_ic_fills_f_dc)
44 __flush_dcache_page(page);
45
46}
47
48#define flush_dcache_mmap_lock(mapping) do { } while (0)
49#define flush_dcache_mmap_unlock(mapping) do { } while (0)
50
51#define ARCH_HAS_FLUSH_ANON_PAGE
52extern void __flush_anon_page(struct page *, unsigned long);
53static inline void flush_anon_page(struct vm_area_struct *vma,
54 struct page *page, unsigned long vmaddr)
55{
56 if (cpu_has_dc_aliases && PageAnon(page))
57 __flush_anon_page(page, vmaddr);
58}
59
60static inline void flush_icache_page(struct vm_area_struct *vma,
61 struct page *page)
62{
63}
64
65extern void (*flush_icache_range)(unsigned long start, unsigned long end);
66extern void (*local_flush_icache_range)(unsigned long start, unsigned long end);
67
68extern void (*__flush_cache_vmap)(void);
69
70static inline void flush_cache_vmap(unsigned long start, unsigned long end)
71{
72 if (cpu_has_dc_aliases)
73 __flush_cache_vmap();
74}
75
76extern void (*__flush_cache_vunmap)(void);
77
78static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
79{
80 if (cpu_has_dc_aliases)
81 __flush_cache_vunmap();
82}
83
84extern void copy_to_user_page(struct vm_area_struct *vma,
85 struct page *page, unsigned long vaddr, void *dst, const void *src,
86 unsigned long len);
87
88extern void copy_from_user_page(struct vm_area_struct *vma,
89 struct page *page, unsigned long vaddr, void *dst, const void *src,
90 unsigned long len);
91
92extern void (*flush_cache_sigtramp)(unsigned long addr);
93extern void (*flush_icache_all)(void);
94extern void (*local_flush_data_cache_page)(void * addr);
95extern void (*flush_data_cache_page)(unsigned long addr);
96
97/*
98 * This flag is used to indicate that the page pointed to by a pte
99 * is dirty and requires cleaning before returning it to the user.
100 */
101#define PG_dcache_dirty PG_arch_1
102
103#define Page_dcache_dirty(page) \
104 test_bit(PG_dcache_dirty, &(page)->flags)
105#define SetPageDcacheDirty(page) \
106 set_bit(PG_dcache_dirty, &(page)->flags)
107#define ClearPageDcacheDirty(page) \
108 clear_bit(PG_dcache_dirty, &(page)->flags)
109
110/* Run kernel code uncached, useful for cache probing functions. */
111unsigned long run_uncached(void *func);
112
113extern void *kmap_coherent(struct page *page, unsigned long addr);
114extern void kunmap_coherent(void);
115
116#endif /* _ASM_CACHEFLUSH_H */
diff --git a/arch/mips/include/asm/cacheops.h b/arch/mips/include/asm/cacheops.h
new file mode 100644
index 000000000000..256ad2cc6eb8
--- /dev/null
+++ b/arch/mips/include/asm/cacheops.h
@@ -0,0 +1,85 @@
1/*
2 * Cache operations for the cache instruction.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * (C) Copyright 1996, 97, 99, 2002, 03 Ralf Baechle
9 * (C) Copyright 1999 Silicon Graphics, Inc.
10 */
11#ifndef __ASM_CACHEOPS_H
12#define __ASM_CACHEOPS_H
13
14/*
15 * Cache Operations available on all MIPS processors with R4000-style caches
16 */
17#define Index_Invalidate_I 0x00
18#define Index_Writeback_Inv_D 0x01
19#define Index_Load_Tag_I 0x04
20#define Index_Load_Tag_D 0x05
21#define Index_Store_Tag_I 0x08
22#define Index_Store_Tag_D 0x09
23#if defined(CONFIG_CPU_LOONGSON2)
24#define Hit_Invalidate_I 0x00
25#else
26#define Hit_Invalidate_I 0x10
27#endif
28#define Hit_Invalidate_D 0x11
29#define Hit_Writeback_Inv_D 0x15
30
31/*
32 * R4000-specific cacheops
33 */
34#define Create_Dirty_Excl_D 0x0d
35#define Fill 0x14
36#define Hit_Writeback_I 0x18
37#define Hit_Writeback_D 0x19
38
39/*
40 * R4000SC and R4400SC-specific cacheops
41 */
42#define Index_Invalidate_SI 0x02
43#define Index_Writeback_Inv_SD 0x03
44#define Index_Load_Tag_SI 0x06
45#define Index_Load_Tag_SD 0x07
46#define Index_Store_Tag_SI 0x0A
47#define Index_Store_Tag_SD 0x0B
48#define Create_Dirty_Excl_SD 0x0f
49#define Hit_Invalidate_SI 0x12
50#define Hit_Invalidate_SD 0x13
51#define Hit_Writeback_Inv_SD 0x17
52#define Hit_Writeback_SD 0x1b
53#define Hit_Set_Virtual_SI 0x1e
54#define Hit_Set_Virtual_SD 0x1f
55
56/*
57 * R5000-specific cacheops
58 */
59#define R5K_Page_Invalidate_S 0x17
60
61/*
62 * RM7000-specific cacheops
63 */
64#define Page_Invalidate_T 0x16
65
66/*
67 * R10000-specific cacheops
68 *
69 * Cacheops 0x02, 0x06, 0x0a, 0x0c-0x0e, 0x16, 0x1a and 0x1e are unused.
70 * Most of the _S cacheops are identical to the R4000SC _SD cacheops.
71 */
72#define Index_Writeback_Inv_S 0x03
73#define Index_Load_Tag_S 0x07
74#define Index_Store_Tag_S 0x0B
75#define Hit_Invalidate_S 0x13
76#define Cache_Barrier 0x14
77#define Hit_Writeback_Inv_S 0x17
78#define Index_Load_Data_I 0x18
79#define Index_Load_Data_D 0x19
80#define Index_Load_Data_S 0x1b
81#define Index_Store_Data_I 0x1c
82#define Index_Store_Data_D 0x1d
83#define Index_Store_Data_S 0x1f
84
85#endif /* __ASM_CACHEOPS_H */
diff --git a/arch/mips/include/asm/checksum.h b/arch/mips/include/asm/checksum.h
new file mode 100644
index 000000000000..290485ac5407
--- /dev/null
+++ b/arch/mips/include/asm/checksum.h
@@ -0,0 +1,260 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 96, 97, 98, 99, 2001 by Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 * Copyright (C) 2001 Thiemo Seufer.
9 * Copyright (C) 2002 Maciej W. Rozycki
10 */
11#ifndef _ASM_CHECKSUM_H
12#define _ASM_CHECKSUM_H
13
14#include <linux/in6.h>
15
16#include <asm/uaccess.h>
17
18/*
19 * computes the checksum of a memory block at buff, length len,
20 * and adds in "sum" (32-bit)
21 *
22 * returns a 32-bit number suitable for feeding into itself
23 * or csum_tcpudp_magic
24 *
25 * this function must be called with even lengths, except
26 * for the last fragment, which may be odd
27 *
28 * it's best to have buff aligned on a 32-bit boundary
29 */
30__wsum csum_partial(const void *buff, int len, __wsum sum);
31
32__wsum __csum_partial_copy_user(const void *src, void *dst,
33 int len, __wsum sum, int *err_ptr);
34
35/*
36 * this is a new version of the above that records errors it finds in *errp,
37 * but continues and zeros the rest of the buffer.
38 */
39static inline
40__wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len,
41 __wsum sum, int *err_ptr)
42{
43 might_sleep();
44 return __csum_partial_copy_user((__force void *)src, dst,
45 len, sum, err_ptr);
46}
47
48/*
49 * Copy and checksum to user
50 */
51#define HAVE_CSUM_COPY_USER
52static inline
53__wsum csum_and_copy_to_user(const void *src, void __user *dst, int len,
54 __wsum sum, int *err_ptr)
55{
56 might_sleep();
57 if (access_ok(VERIFY_WRITE, dst, len))
58 return __csum_partial_copy_user(src, (__force void *)dst,
59 len, sum, err_ptr);
60 if (len)
61 *err_ptr = -EFAULT;
62
63 return (__force __wsum)-1; /* invalid checksum */
64}
65
66/*
67 * the same as csum_partial, but copies from user space (but on MIPS
68 * we have just one address space, so this is identical to the above)
69 */
70__wsum csum_partial_copy_nocheck(const void *src, void *dst,
71 int len, __wsum sum);
72
73/*
74 * Fold a partial checksum without adding pseudo headers
75 */
76static inline __sum16 csum_fold(__wsum sum)
77{
78 __asm__(
79 " .set push # csum_fold\n"
80 " .set noat \n"
81 " sll $1, %0, 16 \n"
82 " addu %0, $1 \n"
83 " sltu $1, %0, $1 \n"
84 " srl %0, %0, 16 \n"
85 " addu %0, $1 \n"
86 " xori %0, 0xffff \n"
87 " .set pop"
88 : "=r" (sum)
89 : "0" (sum));
90
91 return (__force __sum16)sum;
92}
93
94/*
95 * This is a version of ip_compute_csum() optimized for IP headers,
96 * which always checksum on 4 octet boundaries.
97 *
98 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
99 * Arnt Gulbrandsen.
100 */
101static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
102{
103 const unsigned int *word = iph;
104 const unsigned int *stop = word + ihl;
105 unsigned int csum;
106 int carry;
107
108 csum = word[0];
109 csum += word[1];
110 carry = (csum < word[1]);
111 csum += carry;
112
113 csum += word[2];
114 carry = (csum < word[2]);
115 csum += carry;
116
117 csum += word[3];
118 carry = (csum < word[3]);
119 csum += carry;
120
121 word += 4;
122 do {
123 csum += *word;
124 carry = (csum < *word);
125 csum += carry;
126 word++;
127 } while (word != stop);
128
129 return csum_fold(csum);
130}
131
132static inline __wsum csum_tcpudp_nofold(__be32 saddr,
133 __be32 daddr, unsigned short len, unsigned short proto,
134 __wsum sum)
135{
136 __asm__(
137 " .set push # csum_tcpudp_nofold\n"
138 " .set noat \n"
139#ifdef CONFIG_32BIT
140 " addu %0, %2 \n"
141 " sltu $1, %0, %2 \n"
142 " addu %0, $1 \n"
143
144 " addu %0, %3 \n"
145 " sltu $1, %0, %3 \n"
146 " addu %0, $1 \n"
147
148 " addu %0, %4 \n"
149 " sltu $1, %0, %4 \n"
150 " addu %0, $1 \n"
151#endif
152#ifdef CONFIG_64BIT
153 " daddu %0, %2 \n"
154 " daddu %0, %3 \n"
155 " daddu %0, %4 \n"
156 " dsll32 $1, %0, 0 \n"
157 " daddu %0, $1 \n"
158 " dsra32 %0, %0, 0 \n"
159#endif
160 " .set pop"
161 : "=r" (sum)
162 : "0" ((__force unsigned long)daddr),
163 "r" ((__force unsigned long)saddr),
164#ifdef __MIPSEL__
165 "r" ((proto + len) << 8),
166#else
167 "r" (proto + len),
168#endif
169 "r" ((__force unsigned long)sum));
170
171 return sum;
172}
173
174/*
175 * computes the checksum of the TCP/UDP pseudo-header
176 * returns a 16-bit checksum, already complemented
177 */
178static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
179 unsigned short len,
180 unsigned short proto,
181 __wsum sum)
182{
183 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
184}
185
186/*
187 * this routine is used for miscellaneous IP-like checksums, mainly
188 * in icmp.c
189 */
190static inline __sum16 ip_compute_csum(const void *buff, int len)
191{
192 return csum_fold(csum_partial(buff, len, 0));
193}
194
195#define _HAVE_ARCH_IPV6_CSUM
196static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
197 const struct in6_addr *daddr,
198 __u32 len, unsigned short proto,
199 __wsum sum)
200{
201 __asm__(
202 " .set push # csum_ipv6_magic\n"
203 " .set noreorder \n"
204 " .set noat \n"
205 " addu %0, %5 # proto (long in network byte order)\n"
206 " sltu $1, %0, %5 \n"
207 " addu %0, $1 \n"
208
209 " addu %0, %6 # csum\n"
210 " sltu $1, %0, %6 \n"
211 " lw %1, 0(%2) # four words source address\n"
212 " addu %0, $1 \n"
213 " addu %0, %1 \n"
214 " sltu $1, %0, %1 \n"
215
216 " lw %1, 4(%2) \n"
217 " addu %0, $1 \n"
218 " addu %0, %1 \n"
219 " sltu $1, %0, %1 \n"
220
221 " lw %1, 8(%2) \n"
222 " addu %0, $1 \n"
223 " addu %0, %1 \n"
224 " sltu $1, %0, %1 \n"
225
226 " lw %1, 12(%2) \n"
227 " addu %0, $1 \n"
228 " addu %0, %1 \n"
229 " sltu $1, %0, %1 \n"
230
231 " lw %1, 0(%3) \n"
232 " addu %0, $1 \n"
233 " addu %0, %1 \n"
234 " sltu $1, %0, %1 \n"
235
236 " lw %1, 4(%3) \n"
237 " addu %0, $1 \n"
238 " addu %0, %1 \n"
239 " sltu $1, %0, %1 \n"
240
241 " lw %1, 8(%3) \n"
242 " addu %0, $1 \n"
243 " addu %0, %1 \n"
244 " sltu $1, %0, %1 \n"
245
246 " lw %1, 12(%3) \n"
247 " addu %0, $1 \n"
248 " addu %0, %1 \n"
249 " sltu $1, %0, %1 \n"
250
251 " addu %0, $1 # Add final carry\n"
252 " .set pop"
253 : "=r" (sum), "=r" (proto)
254 : "r" (saddr), "r" (daddr),
255 "0" (htonl(len)), "1" (htonl(proto)), "r" (sum));
256
257 return csum_fold(sum);
258}
259
260#endif /* _ASM_CHECKSUM_H */
diff --git a/arch/mips/include/asm/cmp.h b/arch/mips/include/asm/cmp.h
new file mode 100644
index 000000000000..89a73fb93ae6
--- /dev/null
+++ b/arch/mips/include/asm/cmp.h
@@ -0,0 +1,18 @@
1#ifndef _ASM_CMP_H
2#define _ASM_CMP_H
3
4/*
5 * Definitions for CMP multitasking on MIPS cores
6 */
7struct task_struct;
8
9extern void cmp_smp_setup(void);
10extern void cmp_smp_finish(void);
11extern void cmp_boot_secondary(int cpu, struct task_struct *t);
12extern void cmp_init_secondary(void);
13extern void cmp_cpus_done(void);
14extern void cmp_prepare_cpus(unsigned int max_cpus);
15
16/* This is platform specific */
17extern void cmp_send_ipi(int cpu, unsigned int action);
18#endif /* _ASM_CMP_H */
diff --git a/arch/mips/include/asm/cmpxchg.h b/arch/mips/include/asm/cmpxchg.h
new file mode 100644
index 000000000000..4a812c3ceb90
--- /dev/null
+++ b/arch/mips/include/asm/cmpxchg.h
@@ -0,0 +1,124 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 06, 07 by Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef __ASM_CMPXCHG_H
9#define __ASM_CMPXCHG_H
10
11#include <linux/irqflags.h>
12
13#define __HAVE_ARCH_CMPXCHG 1
14
15#define __cmpxchg_asm(ld, st, m, old, new) \
16({ \
17 __typeof(*(m)) __ret; \
18 \
19 if (cpu_has_llsc && R10000_LLSC_WAR) { \
20 __asm__ __volatile__( \
21 " .set push \n" \
22 " .set noat \n" \
23 " .set mips3 \n" \
24 "1: " ld " %0, %2 # __cmpxchg_asm \n" \
25 " bne %0, %z3, 2f \n" \
26 " .set mips0 \n" \
27 " move $1, %z4 \n" \
28 " .set mips3 \n" \
29 " " st " $1, %1 \n" \
30 " beqzl $1, 1b \n" \
31 "2: \n" \
32 " .set pop \n" \
33 : "=&r" (__ret), "=R" (*m) \
34 : "R" (*m), "Jr" (old), "Jr" (new) \
35 : "memory"); \
36 } else if (cpu_has_llsc) { \
37 __asm__ __volatile__( \
38 " .set push \n" \
39 " .set noat \n" \
40 " .set mips3 \n" \
41 "1: " ld " %0, %2 # __cmpxchg_asm \n" \
42 " bne %0, %z3, 2f \n" \
43 " .set mips0 \n" \
44 " move $1, %z4 \n" \
45 " .set mips3 \n" \
46 " " st " $1, %1 \n" \
47 " beqz $1, 3f \n" \
48 "2: \n" \
49 " .subsection 2 \n" \
50 "3: b 1b \n" \
51 " .previous \n" \
52 " .set pop \n" \
53 : "=&r" (__ret), "=R" (*m) \
54 : "R" (*m), "Jr" (old), "Jr" (new) \
55 : "memory"); \
56 } else { \
57 unsigned long __flags; \
58 \
59 raw_local_irq_save(__flags); \
60 __ret = *m; \
61 if (__ret == old) \
62 *m = new; \
63 raw_local_irq_restore(__flags); \
64 } \
65 \
66 __ret; \
67})
68
69/*
70 * This function doesn't exist, so you'll get a linker error
71 * if something tries to do an invalid cmpxchg().
72 */
73extern void __cmpxchg_called_with_bad_pointer(void);
74
75#define __cmpxchg(ptr, old, new, barrier) \
76({ \
77 __typeof__(ptr) __ptr = (ptr); \
78 __typeof__(*(ptr)) __old = (old); \
79 __typeof__(*(ptr)) __new = (new); \
80 __typeof__(*(ptr)) __res = 0; \
81 \
82 barrier; \
83 \
84 switch (sizeof(*(__ptr))) { \
85 case 4: \
86 __res = __cmpxchg_asm("ll", "sc", __ptr, __old, __new); \
87 break; \
88 case 8: \
89 if (sizeof(long) == 8) { \
90 __res = __cmpxchg_asm("lld", "scd", __ptr, \
91 __old, __new); \
92 break; \
93 } \
94 default: \
95 __cmpxchg_called_with_bad_pointer(); \
96 break; \
97 } \
98 \
99 barrier; \
100 \
101 __res; \
102})
103
104#define cmpxchg(ptr, old, new) __cmpxchg(ptr, old, new, smp_llsc_mb())
105#define cmpxchg_local(ptr, old, new) __cmpxchg(ptr, old, new, )
106
107#define cmpxchg64(ptr, o, n) \
108 ({ \
109 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
110 cmpxchg((ptr), (o), (n)); \
111 })
112
113#ifdef CONFIG_64BIT
114#define cmpxchg64_local(ptr, o, n) \
115 ({ \
116 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
117 cmpxchg_local((ptr), (o), (n)); \
118 })
119#else
120#include <asm-generic/cmpxchg-local.h>
121#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
122#endif
123
124#endif /* __ASM_CMPXCHG_H */
diff --git a/arch/mips/include/asm/compat-signal.h b/arch/mips/include/asm/compat-signal.h
new file mode 100644
index 000000000000..368a99e5c3e1
--- /dev/null
+++ b/arch/mips/include/asm/compat-signal.h
@@ -0,0 +1,119 @@
1#ifndef __ASM_COMPAT_SIGNAL_H
2#define __ASM_COMPAT_SIGNAL_H
3
4#include <linux/bug.h>
5#include <linux/compat.h>
6#include <linux/compiler.h>
7
8#include <asm/signal.h>
9#include <asm/siginfo.h>
10
11#include <asm/uaccess.h>
12
13#define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
14
15typedef struct compat_siginfo {
16 int si_signo;
17 int si_code;
18 int si_errno;
19
20 union {
21 int _pad[SI_PAD_SIZE32];
22
23 /* kill() */
24 struct {
25 compat_pid_t _pid; /* sender's pid */
26 compat_uid_t _uid; /* sender's uid */
27 } _kill;
28
29 /* SIGCHLD */
30 struct {
31 compat_pid_t _pid; /* which child */
32 compat_uid_t _uid; /* sender's uid */
33 int _status; /* exit code */
34 compat_clock_t _utime;
35 compat_clock_t _stime;
36 } _sigchld;
37
38 /* IRIX SIGCHLD */
39 struct {
40 compat_pid_t _pid; /* which child */
41 compat_clock_t _utime;
42 int _status; /* exit code */
43 compat_clock_t _stime;
44 } _irix_sigchld;
45
46 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
47 struct {
48 s32 _addr; /* faulting insn/memory ref. */
49 } _sigfault;
50
51 /* SIGPOLL, SIGXFSZ (To do ...) */
52 struct {
53 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
54 int _fd;
55 } _sigpoll;
56
57 /* POSIX.1b timers */
58 struct {
59 timer_t _tid; /* timer id */
60 int _overrun; /* overrun count */
61 compat_sigval_t _sigval;/* same as below */
62 int _sys_private; /* not to be passed to user */
63 } _timer;
64
65 /* POSIX.1b signals */
66 struct {
67 compat_pid_t _pid; /* sender's pid */
68 compat_uid_t _uid; /* sender's uid */
69 compat_sigval_t _sigval;
70 } _rt;
71
72 } _sifields;
73} compat_siginfo_t;
74
75static inline int __copy_conv_sigset_to_user(compat_sigset_t __user *d,
76 const sigset_t *s)
77{
78 int err;
79
80 BUG_ON(sizeof(*d) != sizeof(*s));
81 BUG_ON(_NSIG_WORDS != 2);
82
83 err = __put_user(s->sig[0], &d->sig[0]);
84 err |= __put_user(s->sig[0] >> 32, &d->sig[1]);
85 err |= __put_user(s->sig[1], &d->sig[2]);
86 err |= __put_user(s->sig[1] >> 32, &d->sig[3]);
87
88 return err;
89}
90
91static inline int __copy_conv_sigset_from_user(sigset_t *d,
92 const compat_sigset_t __user *s)
93{
94 int err;
95 union sigset_u {
96 sigset_t s;
97 compat_sigset_t c;
98 } *u = (union sigset_u *) d;
99
100 BUG_ON(sizeof(*d) != sizeof(*s));
101 BUG_ON(_NSIG_WORDS != 2);
102
103#ifdef CONFIG_CPU_BIG_ENDIAN
104 err = __get_user(u->c.sig[1], &s->sig[0]);
105 err |= __get_user(u->c.sig[0], &s->sig[1]);
106 err |= __get_user(u->c.sig[3], &s->sig[2]);
107 err |= __get_user(u->c.sig[2], &s->sig[3]);
108#endif
109#ifdef CONFIG_CPU_LITTLE_ENDIAN
110 err = __get_user(u->c.sig[0], &s->sig[0]);
111 err |= __get_user(u->c.sig[1], &s->sig[1]);
112 err |= __get_user(u->c.sig[2], &s->sig[2]);
113 err |= __get_user(u->c.sig[3], &s->sig[3]);
114#endif
115
116 return err;
117}
118
119#endif /* __ASM_COMPAT_SIGNAL_H */
diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
new file mode 100644
index 000000000000..ac5d541368e9
--- /dev/null
+++ b/arch/mips/include/asm/compat.h
@@ -0,0 +1,221 @@
1#ifndef _ASM_COMPAT_H
2#define _ASM_COMPAT_H
3/*
4 * Architecture specific compatibility types
5 */
6#include <linux/types.h>
7#include <asm/page.h>
8#include <asm/ptrace.h>
9
10#define COMPAT_USER_HZ 100
11
12typedef u32 compat_size_t;
13typedef s32 compat_ssize_t;
14typedef s32 compat_time_t;
15typedef s32 compat_clock_t;
16typedef s32 compat_suseconds_t;
17
18typedef s32 compat_pid_t;
19typedef s32 __compat_uid_t;
20typedef s32 __compat_gid_t;
21typedef __compat_uid_t __compat_uid32_t;
22typedef __compat_gid_t __compat_gid32_t;
23typedef u32 compat_mode_t;
24typedef u32 compat_ino_t;
25typedef u32 compat_dev_t;
26typedef s32 compat_off_t;
27typedef s64 compat_loff_t;
28typedef u32 compat_nlink_t;
29typedef s32 compat_ipc_pid_t;
30typedef s32 compat_daddr_t;
31typedef s32 compat_caddr_t;
32typedef struct {
33 s32 val[2];
34} compat_fsid_t;
35typedef s32 compat_timer_t;
36typedef s32 compat_key_t;
37
38typedef s32 compat_int_t;
39typedef s32 compat_long_t;
40typedef s64 compat_s64;
41typedef u32 compat_uint_t;
42typedef u32 compat_ulong_t;
43typedef u64 compat_u64;
44
45struct compat_timespec {
46 compat_time_t tv_sec;
47 s32 tv_nsec;
48};
49
50struct compat_timeval {
51 compat_time_t tv_sec;
52 s32 tv_usec;
53};
54
55struct compat_stat {
56 compat_dev_t st_dev;
57 s32 st_pad1[3];
58 compat_ino_t st_ino;
59 compat_mode_t st_mode;
60 compat_nlink_t st_nlink;
61 __compat_uid_t st_uid;
62 __compat_gid_t st_gid;
63 compat_dev_t st_rdev;
64 s32 st_pad2[2];
65 compat_off_t st_size;
66 s32 st_pad3;
67 compat_time_t st_atime;
68 s32 st_atime_nsec;
69 compat_time_t st_mtime;
70 s32 st_mtime_nsec;
71 compat_time_t st_ctime;
72 s32 st_ctime_nsec;
73 s32 st_blksize;
74 s32 st_blocks;
75 s32 st_pad4[14];
76};
77
78struct compat_flock {
79 short l_type;
80 short l_whence;
81 compat_off_t l_start;
82 compat_off_t l_len;
83 s32 l_sysid;
84 compat_pid_t l_pid;
85 short __unused;
86 s32 pad[4];
87};
88
89#define F_GETLK64 33
90#define F_SETLK64 34
91#define F_SETLKW64 35
92
93struct compat_flock64 {
94 short l_type;
95 short l_whence;
96 compat_loff_t l_start;
97 compat_loff_t l_len;
98 compat_pid_t l_pid;
99};
100
101struct compat_statfs {
102 int f_type;
103 int f_bsize;
104 int f_frsize;
105 int f_blocks;
106 int f_bfree;
107 int f_files;
108 int f_ffree;
109 int f_bavail;
110 compat_fsid_t f_fsid;
111 int f_namelen;
112 int f_spare[6];
113};
114
115#define COMPAT_RLIM_INFINITY 0x7fffffffUL
116
117typedef u32 compat_old_sigset_t; /* at least 32 bits */
118
119#define _COMPAT_NSIG 128 /* Don't ask !$@#% ... */
120#define _COMPAT_NSIG_BPW 32
121
122typedef u32 compat_sigset_word;
123
124#define COMPAT_OFF_T_MAX 0x7fffffff
125#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
126
127/*
128 * A pointer passed in from user mode. This should not
129 * be used for syscall parameters, just declare them
130 * as pointers because the syscall entry code will have
131 * appropriately converted them already.
132 */
133typedef u32 compat_uptr_t;
134
135static inline void __user *compat_ptr(compat_uptr_t uptr)
136{
137 /* cast to a __user pointer via "unsigned long" makes sparse happy */
138 return (void __user *)(unsigned long)(long)uptr;
139}
140
141static inline compat_uptr_t ptr_to_compat(void __user *uptr)
142{
143 return (u32)(unsigned long)uptr;
144}
145
146static inline void __user *compat_alloc_user_space(long len)
147{
148 struct pt_regs *regs = (struct pt_regs *)
149 ((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1;
150
151 return (void __user *) (regs->regs[29] - len);
152}
153
154struct compat_ipc64_perm {
155 compat_key_t key;
156 __compat_uid32_t uid;
157 __compat_gid32_t gid;
158 __compat_uid32_t cuid;
159 __compat_gid32_t cgid;
160 compat_mode_t mode;
161 unsigned short seq;
162 unsigned short __pad2;
163 compat_ulong_t __unused1;
164 compat_ulong_t __unused2;
165};
166
167struct compat_semid64_ds {
168 struct compat_ipc64_perm sem_perm;
169 compat_time_t sem_otime;
170 compat_time_t sem_ctime;
171 compat_ulong_t sem_nsems;
172 compat_ulong_t __unused1;
173 compat_ulong_t __unused2;
174};
175
176struct compat_msqid64_ds {
177 struct compat_ipc64_perm msg_perm;
178#ifndef CONFIG_CPU_LITTLE_ENDIAN
179 compat_ulong_t __unused1;
180#endif
181 compat_time_t msg_stime;
182#ifdef CONFIG_CPU_LITTLE_ENDIAN
183 compat_ulong_t __unused1;
184#endif
185#ifndef CONFIG_CPU_LITTLE_ENDIAN
186 compat_ulong_t __unused2;
187#endif
188 compat_time_t msg_rtime;
189#ifdef CONFIG_CPU_LITTLE_ENDIAN
190 compat_ulong_t __unused2;
191#endif
192#ifndef CONFIG_CPU_LITTLE_ENDIAN
193 compat_ulong_t __unused3;
194#endif
195 compat_time_t msg_ctime;
196#ifdef CONFIG_CPU_LITTLE_ENDIAN
197 compat_ulong_t __unused3;
198#endif
199 compat_ulong_t msg_cbytes;
200 compat_ulong_t msg_qnum;
201 compat_ulong_t msg_qbytes;
202 compat_pid_t msg_lspid;
203 compat_pid_t msg_lrpid;
204 compat_ulong_t __unused4;
205 compat_ulong_t __unused5;
206};
207
208struct compat_shmid64_ds {
209 struct compat_ipc64_perm shm_perm;
210 compat_size_t shm_segsz;
211 compat_time_t shm_atime;
212 compat_time_t shm_dtime;
213 compat_time_t shm_ctime;
214 compat_pid_t shm_cpid;
215 compat_pid_t shm_lpid;
216 compat_ulong_t shm_nattch;
217 compat_ulong_t __unused1;
218 compat_ulong_t __unused2;
219};
220
221#endif /* _ASM_COMPAT_H */
diff --git a/arch/mips/include/asm/compiler.h b/arch/mips/include/asm/compiler.h
new file mode 100644
index 000000000000..71f5c5cfc58a
--- /dev/null
+++ b/arch/mips/include/asm/compiler.h
@@ -0,0 +1,19 @@
1/*
2 * Copyright (C) 2004, 2007 Maciej W. Rozycki
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8#ifndef _ASM_COMPILER_H
9#define _ASM_COMPILER_H
10
11#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
12#define GCC_IMM_ASM() "n"
13#define GCC_REG_ACCUM "$0"
14#else
15#define GCC_IMM_ASM() "rn"
16#define GCC_REG_ACCUM "accum"
17#endif
18
19#endif /* _ASM_COMPILER_H */
diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
new file mode 100644
index 000000000000..5ea701fc3425
--- /dev/null
+++ b/arch/mips/include/asm/cpu-features.h
@@ -0,0 +1,219 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2004 Ralf Baechle
7 * Copyright (C) 2004 Maciej W. Rozycki
8 */
9#ifndef __ASM_CPU_FEATURES_H
10#define __ASM_CPU_FEATURES_H
11
12#include <asm/cpu.h>
13#include <asm/cpu-info.h>
14#include <cpu-feature-overrides.h>
15
16#ifndef current_cpu_type
17#define current_cpu_type() current_cpu_data.cputype
18#endif
19
20/*
21 * SMP assumption: Options of CPU 0 are a superset of all processors.
22 * This is true for all known MIPS systems.
23 */
24#ifndef cpu_has_tlb
25#define cpu_has_tlb (cpu_data[0].options & MIPS_CPU_TLB)
26#endif
27#ifndef cpu_has_4kex
28#define cpu_has_4kex (cpu_data[0].options & MIPS_CPU_4KEX)
29#endif
30#ifndef cpu_has_3k_cache
31#define cpu_has_3k_cache (cpu_data[0].options & MIPS_CPU_3K_CACHE)
32#endif
33#define cpu_has_6k_cache 0
34#define cpu_has_8k_cache 0
35#ifndef cpu_has_4k_cache
36#define cpu_has_4k_cache (cpu_data[0].options & MIPS_CPU_4K_CACHE)
37#endif
38#ifndef cpu_has_tx39_cache
39#define cpu_has_tx39_cache (cpu_data[0].options & MIPS_CPU_TX39_CACHE)
40#endif
41#ifndef cpu_has_fpu
42#define cpu_has_fpu (current_cpu_data.options & MIPS_CPU_FPU)
43#define raw_cpu_has_fpu (raw_current_cpu_data.options & MIPS_CPU_FPU)
44#else
45#define raw_cpu_has_fpu cpu_has_fpu
46#endif
47#ifndef cpu_has_32fpr
48#define cpu_has_32fpr (cpu_data[0].options & MIPS_CPU_32FPR)
49#endif
50#ifndef cpu_has_counter
51#define cpu_has_counter (cpu_data[0].options & MIPS_CPU_COUNTER)
52#endif
53#ifndef cpu_has_watch
54#define cpu_has_watch (cpu_data[0].options & MIPS_CPU_WATCH)
55#endif
56#ifndef cpu_has_divec
57#define cpu_has_divec (cpu_data[0].options & MIPS_CPU_DIVEC)
58#endif
59#ifndef cpu_has_vce
60#define cpu_has_vce (cpu_data[0].options & MIPS_CPU_VCE)
61#endif
62#ifndef cpu_has_cache_cdex_p
63#define cpu_has_cache_cdex_p (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_P)
64#endif
65#ifndef cpu_has_cache_cdex_s
66#define cpu_has_cache_cdex_s (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_S)
67#endif
68#ifndef cpu_has_prefetch
69#define cpu_has_prefetch (cpu_data[0].options & MIPS_CPU_PREFETCH)
70#endif
71#ifndef cpu_has_mcheck
72#define cpu_has_mcheck (cpu_data[0].options & MIPS_CPU_MCHECK)
73#endif
74#ifndef cpu_has_ejtag
75#define cpu_has_ejtag (cpu_data[0].options & MIPS_CPU_EJTAG)
76#endif
77#ifndef cpu_has_llsc
78#define cpu_has_llsc (cpu_data[0].options & MIPS_CPU_LLSC)
79#endif
80#ifndef cpu_has_mips16
81#define cpu_has_mips16 (cpu_data[0].ases & MIPS_ASE_MIPS16)
82#endif
83#ifndef cpu_has_mdmx
84#define cpu_has_mdmx (cpu_data[0].ases & MIPS_ASE_MDMX)
85#endif
86#ifndef cpu_has_mips3d
87#define cpu_has_mips3d (cpu_data[0].ases & MIPS_ASE_MIPS3D)
88#endif
89#ifndef cpu_has_smartmips
90#define cpu_has_smartmips (cpu_data[0].ases & MIPS_ASE_SMARTMIPS)
91#endif
92#ifndef cpu_has_vtag_icache
93#define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG)
94#endif
95#ifndef cpu_has_dc_aliases
96#define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
97#endif
98#ifndef cpu_has_ic_fills_f_dc
99#define cpu_has_ic_fills_f_dc (cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC)
100#endif
101#ifndef cpu_has_pindexed_dcache
102#define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
103#endif
104
105/*
106 * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
107 * such as the R10000 have I-Caches that snoop local stores; the embedded ones
108 * don't. For maintaining I-cache coherency this means we need to flush the
109 * D-cache all the way back to whever the I-cache does refills from, so the
110 * I-cache has a chance to see the new data at all. Then we have to flush the
111 * I-cache also.
112 * Note we may have been rescheduled and may no longer be running on the CPU
113 * that did the store so we can't optimize this into only doing the flush on
114 * the local CPU.
115 */
116#ifndef cpu_icache_snoops_remote_store
117#ifdef CONFIG_SMP
118#define cpu_icache_snoops_remote_store (cpu_data[0].icache.flags & MIPS_IC_SNOOPS_REMOTE)
119#else
120#define cpu_icache_snoops_remote_store 1
121#endif
122#endif
123
124# ifndef cpu_has_mips32r1
125# define cpu_has_mips32r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R1)
126# endif
127# ifndef cpu_has_mips32r2
128# define cpu_has_mips32r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R2)
129# endif
130# ifndef cpu_has_mips64r1
131# define cpu_has_mips64r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R1)
132# endif
133# ifndef cpu_has_mips64r2
134# define cpu_has_mips64r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R2)
135# endif
136
137/*
138 * Shortcuts ...
139 */
140#define cpu_has_mips32 (cpu_has_mips32r1 | cpu_has_mips32r2)
141#define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2)
142#define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1)
143#define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2)
144
145#ifndef cpu_has_dsp
146#define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP)
147#endif
148
149#ifndef cpu_has_mipsmt
150#define cpu_has_mipsmt (cpu_data[0].ases & MIPS_ASE_MIPSMT)
151#endif
152
153#ifndef cpu_has_userlocal
154#define cpu_has_userlocal (cpu_data[0].options & MIPS_CPU_ULRI)
155#endif
156
157#ifdef CONFIG_32BIT
158# ifndef cpu_has_nofpuex
159# define cpu_has_nofpuex (cpu_data[0].options & MIPS_CPU_NOFPUEX)
160# endif
161# ifndef cpu_has_64bits
162# define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
163# endif
164# ifndef cpu_has_64bit_zero_reg
165# define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
166# endif
167# ifndef cpu_has_64bit_gp_regs
168# define cpu_has_64bit_gp_regs 0
169# endif
170# ifndef cpu_has_64bit_addresses
171# define cpu_has_64bit_addresses 0
172# endif
173#endif
174
175#ifdef CONFIG_64BIT
176# ifndef cpu_has_nofpuex
177# define cpu_has_nofpuex 0
178# endif
179# ifndef cpu_has_64bits
180# define cpu_has_64bits 1
181# endif
182# ifndef cpu_has_64bit_zero_reg
183# define cpu_has_64bit_zero_reg 1
184# endif
185# ifndef cpu_has_64bit_gp_regs
186# define cpu_has_64bit_gp_regs 1
187# endif
188# ifndef cpu_has_64bit_addresses
189# define cpu_has_64bit_addresses 1
190# endif
191#endif
192
193#if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint)
194# define cpu_has_vint (cpu_data[0].options & MIPS_CPU_VINT)
195#elif !defined(cpu_has_vint)
196# define cpu_has_vint 0
197#endif
198
199#if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic)
200# define cpu_has_veic (cpu_data[0].options & MIPS_CPU_VEIC)
201#elif !defined(cpu_has_veic)
202# define cpu_has_veic 0
203#endif
204
205#ifndef cpu_has_inclusive_pcaches
206#define cpu_has_inclusive_pcaches (cpu_data[0].options & MIPS_CPU_INCLUSIVE_CACHES)
207#endif
208
209#ifndef cpu_dcache_line_size
210#define cpu_dcache_line_size() cpu_data[0].dcache.linesz
211#endif
212#ifndef cpu_icache_line_size
213#define cpu_icache_line_size() cpu_data[0].icache.linesz
214#endif
215#ifndef cpu_scache_line_size
216#define cpu_scache_line_size() cpu_data[0].scache.linesz
217#endif
218
219#endif /* __ASM_CPU_FEATURES_H */
diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h
new file mode 100644
index 000000000000..744cd8fb107f
--- /dev/null
+++ b/arch/mips/include/asm/cpu-info.h
@@ -0,0 +1,90 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 Waldorf GMBH
7 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
8 * Copyright (C) 1996 Paul M. Antoine
9 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
10 * Copyright (C) 2004 Maciej W. Rozycki
11 */
12#ifndef __ASM_CPU_INFO_H
13#define __ASM_CPU_INFO_H
14
15#include <linux/types.h>
16
17#include <asm/cache.h>
18
19/*
20 * Descriptor for a cache
21 */
22struct cache_desc {
23 unsigned int waysize; /* Bytes per way */
24 unsigned short sets; /* Number of lines per set */
25 unsigned char ways; /* Number of ways */
26 unsigned char linesz; /* Size of line in bytes */
27 unsigned char waybit; /* Bits to select in a cache set */
28 unsigned char flags; /* Flags describing cache properties */
29};
30
31/*
32 * Flag definitions
33 */
34#define MIPS_CACHE_NOT_PRESENT 0x00000001
35#define MIPS_CACHE_VTAG 0x00000002 /* Virtually tagged cache */
36#define MIPS_CACHE_ALIASES 0x00000004 /* Cache could have aliases */
37#define MIPS_CACHE_IC_F_DC 0x00000008 /* Ic can refill from D-cache */
38#define MIPS_IC_SNOOPS_REMOTE 0x00000010 /* Ic snoops remote stores */
39#define MIPS_CACHE_PINDEX 0x00000020 /* Physically indexed cache */
40
41struct cpuinfo_mips {
42 unsigned long udelay_val;
43 unsigned long asid_cache;
44
45 /*
46 * Capability and feature descriptor structure for MIPS CPU
47 */
48 unsigned long options;
49 unsigned long ases;
50 unsigned int processor_id;
51 unsigned int fpu_id;
52 unsigned int cputype;
53 int isa_level;
54 int tlbsize;
55 struct cache_desc icache; /* Primary I-cache */
56 struct cache_desc dcache; /* Primary D or combined I/D cache */
57 struct cache_desc scache; /* Secondary cache */
58 struct cache_desc tcache; /* Tertiary/split secondary cache */
59 int srsets; /* Shadow register sets */
60 int core; /* physical core number */
61#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC)
62 /*
63 * In the MIPS MT "SMTC" model, each TC is considered
64 * to be a "CPU" for the purposes of scheduling, but
65 * exception resources, ASID spaces, etc, are common
66 * to all TCs within the same VPE.
67 */
68 int vpe_id; /* Virtual Processor number */
69#endif
70#ifdef CONFIG_MIPS_MT_SMTC
71 int tc_id; /* Thread Context number */
72#endif
73 void *data; /* Additional data */
74 unsigned int watch_reg_count; /* Number that exist */
75 unsigned int watch_reg_use_cnt; /* Usable by ptrace */
76#define NUM_WATCH_REGS 4
77 u16 watch_reg_masks[NUM_WATCH_REGS];
78} __attribute__((aligned(SMP_CACHE_BYTES)));
79
80extern struct cpuinfo_mips cpu_data[];
81#define current_cpu_data cpu_data[smp_processor_id()]
82#define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
83
84extern void cpu_probe(void);
85extern void cpu_report(void);
86
87extern const char *__cpu_name[];
88#define cpu_name_string() __cpu_name[smp_processor_id()]
89
90#endif /* __ASM_CPU_INFO_H */
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
new file mode 100644
index 000000000000..229a786101d9
--- /dev/null
+++ b/arch/mips/include/asm/cpu.h
@@ -0,0 +1,267 @@
1/*
2 * cpu.h: Values of the PRId register used to match up
3 * various MIPS cpu types.
4 *
5 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
6 * Copyright (C) 2004 Maciej W. Rozycki
7 */
8#ifndef _ASM_CPU_H
9#define _ASM_CPU_H
10
11/* Assigned Company values for bits 23:16 of the PRId Register
12 (CP0 register 15, select 0). As of the MIPS32 and MIPS64 specs from
13 MTI, the PRId register is defined in this (backwards compatible)
14 way:
15
16 +----------------+----------------+----------------+----------------+
17 | Company Options| Company ID | Processor ID | Revision |
18 +----------------+----------------+----------------+----------------+
19 31 24 23 16 15 8 7
20
21 I don't have docs for all the previous processors, but my impression is
22 that bits 16-23 have been 0 for all MIPS processors before the MIPS32/64
23 spec.
24*/
25
26#define PRID_COMP_LEGACY 0x000000
27#define PRID_COMP_MIPS 0x010000
28#define PRID_COMP_BROADCOM 0x020000
29#define PRID_COMP_ALCHEMY 0x030000
30#define PRID_COMP_SIBYTE 0x040000
31#define PRID_COMP_SANDCRAFT 0x050000
32#define PRID_COMP_NXP 0x060000
33#define PRID_COMP_TOSHIBA 0x070000
34#define PRID_COMP_LSI 0x080000
35#define PRID_COMP_LEXRA 0x0b0000
36
37
38/*
39 * Assigned values for the product ID register. In order to detect a
40 * certain CPU type exactly eventually additional registers may need to
41 * be examined. These are valid when 23:16 == PRID_COMP_LEGACY
42 */
43#define PRID_IMP_R2000 0x0100
44#define PRID_IMP_AU1_REV1 0x0100
45#define PRID_IMP_AU1_REV2 0x0200
46#define PRID_IMP_R3000 0x0200 /* Same as R2000A */
47#define PRID_IMP_R6000 0x0300 /* Same as R3000A */
48#define PRID_IMP_R4000 0x0400
49#define PRID_IMP_R6000A 0x0600
50#define PRID_IMP_R10000 0x0900
51#define PRID_IMP_R4300 0x0b00
52#define PRID_IMP_VR41XX 0x0c00
53#define PRID_IMP_R12000 0x0e00
54#define PRID_IMP_R14000 0x0f00
55#define PRID_IMP_R8000 0x1000
56#define PRID_IMP_PR4450 0x1200
57#define PRID_IMP_R4600 0x2000
58#define PRID_IMP_R4700 0x2100
59#define PRID_IMP_TX39 0x2200
60#define PRID_IMP_R4640 0x2200
61#define PRID_IMP_R4650 0x2200 /* Same as R4640 */
62#define PRID_IMP_R5000 0x2300
63#define PRID_IMP_TX49 0x2d00
64#define PRID_IMP_SONIC 0x2400
65#define PRID_IMP_MAGIC 0x2500
66#define PRID_IMP_RM7000 0x2700
67#define PRID_IMP_NEVADA 0x2800 /* RM5260 ??? */
68#define PRID_IMP_RM9000 0x3400
69#define PRID_IMP_LOONGSON1 0x4200
70#define PRID_IMP_R5432 0x5400
71#define PRID_IMP_R5500 0x5500
72#define PRID_IMP_LOONGSON2 0x6300
73
74#define PRID_IMP_UNKNOWN 0xff00
75
76/*
77 * These are the PRID's for when 23:16 == PRID_COMP_MIPS
78 */
79
80#define PRID_IMP_4KC 0x8000
81#define PRID_IMP_5KC 0x8100
82#define PRID_IMP_20KC 0x8200
83#define PRID_IMP_4KEC 0x8400
84#define PRID_IMP_4KSC 0x8600
85#define PRID_IMP_25KF 0x8800
86#define PRID_IMP_5KE 0x8900
87#define PRID_IMP_4KECR2 0x9000
88#define PRID_IMP_4KEMPR2 0x9100
89#define PRID_IMP_4KSD 0x9200
90#define PRID_IMP_24K 0x9300
91#define PRID_IMP_34K 0x9500
92#define PRID_IMP_24KE 0x9600
93#define PRID_IMP_74K 0x9700
94#define PRID_IMP_1004K 0x9900
95
96/*
97 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
98 */
99
100#define PRID_IMP_SB1 0x0100
101#define PRID_IMP_SB1A 0x1100
102
103/*
104 * These are the PRID's for when 23:16 == PRID_COMP_SANDCRAFT
105 */
106
107#define PRID_IMP_SR71000 0x0400
108
109/*
110 * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM
111 */
112
113#define PRID_IMP_BCM4710 0x4000
114#define PRID_IMP_BCM3302 0x9000
115
116/*
117 * Definitions for 7:0 on legacy processors
118 */
119
120#define PRID_REV_MASK 0x00ff
121
122#define PRID_REV_TX4927 0x0022
123#define PRID_REV_TX4937 0x0030
124#define PRID_REV_R4400 0x0040
125#define PRID_REV_R3000A 0x0030
126#define PRID_REV_R3000 0x0020
127#define PRID_REV_R2000A 0x0010
128#define PRID_REV_TX3912 0x0010
129#define PRID_REV_TX3922 0x0030
130#define PRID_REV_TX3927 0x0040
131#define PRID_REV_VR4111 0x0050
132#define PRID_REV_VR4181 0x0050 /* Same as VR4111 */
133#define PRID_REV_VR4121 0x0060
134#define PRID_REV_VR4122 0x0070
135#define PRID_REV_VR4181A 0x0070 /* Same as VR4122 */
136#define PRID_REV_VR4130 0x0080
137#define PRID_REV_34K_V1_0_2 0x0022
138
139/*
140 * Older processors used to encode processor version and revision in two
141 * 4-bit bitfields, the 4K seems to simply count up and even newer MTI cores
142 * have switched to use the 8-bits as 3:3:2 bitfield with the last field as
143 * the patch number. *ARGH*
144 */
145#define PRID_REV_ENCODE_44(ver, rev) \
146 ((ver) << 4 | (rev))
147#define PRID_REV_ENCODE_332(ver, rev, patch) \
148 ((ver) << 5 | (rev) << 2 | (patch))
149
150/*
151 * FPU implementation/revision register (CP1 control register 0).
152 *
153 * +---------------------------------+----------------+----------------+
154 * | 0 | Implementation | Revision |
155 * +---------------------------------+----------------+----------------+
156 * 31 16 15 8 7 0
157 */
158
159#define FPIR_IMP_NONE 0x0000
160
161enum cpu_type_enum {
162 CPU_UNKNOWN,
163
164 /*
165 * R2000 class processors
166 */
167 CPU_R2000, CPU_R3000, CPU_R3000A, CPU_R3041, CPU_R3051, CPU_R3052,
168 CPU_R3081, CPU_R3081E,
169
170 /*
171 * R6000 class processors
172 */
173 CPU_R6000, CPU_R6000A,
174
175 /*
176 * R4000 class processors
177 */
178 CPU_R4000PC, CPU_R4000SC, CPU_R4000MC, CPU_R4200, CPU_R4300, CPU_R4310,
179 CPU_R4400PC, CPU_R4400SC, CPU_R4400MC, CPU_R4600, CPU_R4640, CPU_R4650,
180 CPU_R4700, CPU_R5000, CPU_R5000A, CPU_R5500, CPU_NEVADA, CPU_R5432,
181 CPU_R10000, CPU_R12000, CPU_R14000, CPU_VR41XX, CPU_VR4111, CPU_VR4121,
182 CPU_VR4122, CPU_VR4131, CPU_VR4133, CPU_VR4181, CPU_VR4181A, CPU_RM7000,
183 CPU_SR71000, CPU_RM9000, CPU_TX49XX,
184
185 /*
186 * R8000 class processors
187 */
188 CPU_R8000,
189
190 /*
191 * TX3900 class processors
192 */
193 CPU_TX3912, CPU_TX3922, CPU_TX3927,
194
195 /*
196 * MIPS32 class processors
197 */
198 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K,
199 CPU_AU1000, CPU_AU1100, CPU_AU1200, CPU_AU1210, CPU_AU1250, CPU_AU1500,
200 CPU_AU1550, CPU_PR4450, CPU_BCM3302, CPU_BCM4710,
201
202 /*
203 * MIPS64 class processors
204 */
205 CPU_5KC, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2,
206
207 CPU_LAST
208};
209
210
211/*
212 * ISA Level encodings
213 *
214 */
215#define MIPS_CPU_ISA_I 0x00000001
216#define MIPS_CPU_ISA_II 0x00000002
217#define MIPS_CPU_ISA_III 0x00000004
218#define MIPS_CPU_ISA_IV 0x00000008
219#define MIPS_CPU_ISA_V 0x00000010
220#define MIPS_CPU_ISA_M32R1 0x00000020
221#define MIPS_CPU_ISA_M32R2 0x00000040
222#define MIPS_CPU_ISA_M64R1 0x00000080
223#define MIPS_CPU_ISA_M64R2 0x00000100
224
225#define MIPS_CPU_ISA_32BIT (MIPS_CPU_ISA_I | MIPS_CPU_ISA_II | \
226 MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 )
227#define MIPS_CPU_ISA_64BIT (MIPS_CPU_ISA_III | MIPS_CPU_ISA_IV | \
228 MIPS_CPU_ISA_V | MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)
229
230/*
231 * CPU Option encodings
232 */
233#define MIPS_CPU_TLB 0x00000001 /* CPU has TLB */
234#define MIPS_CPU_4KEX 0x00000002 /* "R4K" exception model */
235#define MIPS_CPU_3K_CACHE 0x00000004 /* R3000-style caches */
236#define MIPS_CPU_4K_CACHE 0x00000008 /* R4000-style caches */
237#define MIPS_CPU_TX39_CACHE 0x00000010 /* TX3900-style caches */
238#define MIPS_CPU_FPU 0x00000020 /* CPU has FPU */
239#define MIPS_CPU_32FPR 0x00000040 /* 32 dbl. prec. FP registers */
240#define MIPS_CPU_COUNTER 0x00000080 /* Cycle count/compare */
241#define MIPS_CPU_WATCH 0x00000100 /* watchpoint registers */
242#define MIPS_CPU_DIVEC 0x00000200 /* dedicated interrupt vector */
243#define MIPS_CPU_VCE 0x00000400 /* virt. coherence conflict possible */
244#define MIPS_CPU_CACHE_CDEX_P 0x00000800 /* Create_Dirty_Exclusive CACHE op */
245#define MIPS_CPU_CACHE_CDEX_S 0x00001000 /* ... same for seconary cache ... */
246#define MIPS_CPU_MCHECK 0x00002000 /* Machine check exception */
247#define MIPS_CPU_EJTAG 0x00004000 /* EJTAG exception */
248#define MIPS_CPU_NOFPUEX 0x00008000 /* no FPU exception */
249#define MIPS_CPU_LLSC 0x00010000 /* CPU has ll/sc instructions */
250#define MIPS_CPU_INCLUSIVE_CACHES 0x00020000 /* P-cache subset enforced */
251#define MIPS_CPU_PREFETCH 0x00040000 /* CPU has usable prefetch */
252#define MIPS_CPU_VINT 0x00080000 /* CPU supports MIPSR2 vectored interrupts */
253#define MIPS_CPU_VEIC 0x00100000 /* CPU supports MIPSR2 external interrupt controller mode */
254#define MIPS_CPU_ULRI 0x00200000 /* CPU has ULRI feature */
255
256/*
257 * CPU ASE encodings
258 */
259#define MIPS_ASE_MIPS16 0x00000001 /* code compression */
260#define MIPS_ASE_MDMX 0x00000002 /* MIPS digital media extension */
261#define MIPS_ASE_MIPS3D 0x00000004 /* MIPS-3D */
262#define MIPS_ASE_SMARTMIPS 0x00000008 /* SmartMIPS */
263#define MIPS_ASE_DSP 0x00000010 /* Signal Processing ASE */
264#define MIPS_ASE_MIPSMT 0x00000020 /* CPU supports MIPS MT */
265
266
267#endif /* _ASM_CPU_H */
diff --git a/arch/mips/include/asm/cputime.h b/arch/mips/include/asm/cputime.h
new file mode 100644
index 000000000000..c00eacbdd979
--- /dev/null
+++ b/arch/mips/include/asm/cputime.h
@@ -0,0 +1,6 @@
1#ifndef __MIPS_CPUTIME_H
2#define __MIPS_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __MIPS_CPUTIME_H */
diff --git a/arch/mips/include/asm/current.h b/arch/mips/include/asm/current.h
new file mode 100644
index 000000000000..559db66b9790
--- /dev/null
+++ b/arch/mips/include/asm/current.h
@@ -0,0 +1,23 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2002 Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_CURRENT_H
10#define _ASM_CURRENT_H
11
12#include <linux/thread_info.h>
13
14struct task_struct;
15
16static inline struct task_struct * get_current(void)
17{
18 return current_thread_info()->task;
19}
20
21#define current get_current()
22
23#endif /* _ASM_CURRENT_H */
diff --git a/arch/mips/include/asm/debug.h b/arch/mips/include/asm/debug.h
new file mode 100644
index 000000000000..1fd5a2b39445
--- /dev/null
+++ b/arch/mips/include/asm/debug.h
@@ -0,0 +1,48 @@
1/*
2 * Debug macros for run-time debugging.
3 * Turned on/off with CONFIG_RUNTIME_DEBUG option.
4 *
5 * Copyright (C) 2001 MontaVista Software Inc.
6 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#ifndef _ASM_DEBUG_H
16#define _ASM_DEBUG_H
17
18
19/*
20 * run-time macros for catching spurious errors. Eable CONFIG_RUNTIME_DEBUG in
21 * kernel hacking config menu to use them.
22 *
23 * Use them as run-time debugging aid. NEVER USE THEM AS ERROR HANDLING CODE!!!
24 */
25
26#ifdef CONFIG_RUNTIME_DEBUG
27
28#include <linux/kernel.h>
29
30#define db_assert(x) if (!(x)) { \
31 panic("assertion failed at %s:%d: %s", __FILE__, __LINE__, #x); }
32#define db_warn(x) if (!(x)) { \
33 printk(KERN_WARNING "warning at %s:%d: %s", __FILE__, __LINE__, #x); }
34#define db_verify(x, y) db_assert(x y)
35#define db_verify_warn(x, y) db_warn(x y)
36#define db_run(x) do { x; } while (0)
37
38#else
39
40#define db_assert(x)
41#define db_warn(x)
42#define db_verify(x, y) x
43#define db_verify_warn(x, y) x
44#define db_run(x)
45
46#endif
47
48#endif /* _ASM_DEBUG_H */
diff --git a/arch/mips/include/asm/dec/ecc.h b/arch/mips/include/asm/dec/ecc.h
new file mode 100644
index 000000000000..707ffdbc9add
--- /dev/null
+++ b/arch/mips/include/asm/dec/ecc.h
@@ -0,0 +1,55 @@
1/*
2 * include/asm-mips/dec/ecc.h
3 *
4 * ECC handling logic definitions common to DECstation/DECsystem
5 * 5000/200 (KN02), 5000/240 (KN03), 5000/260 (KN05) and
6 * DECsystem 5900 (KN03), 5900/260 (KN05) systems.
7 *
8 * Copyright (C) 2003 Maciej W. Rozycki
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15#ifndef __ASM_MIPS_DEC_ECC_H
16#define __ASM_MIPS_DEC_ECC_H
17
18/*
19 * Error Address Register bits.
20 * The register is r/wc -- any write clears it.
21 */
22#define KN0X_EAR_VALID (1<<31) /* error data valid, bus IRQ */
23#define KN0X_EAR_CPU (1<<30) /* CPU/DMA transaction */
24#define KN0X_EAR_WRITE (1<<29) /* write/read transaction */
25#define KN0X_EAR_ECCERR (1<<28) /* ECC/timeout or overrun */
26#define KN0X_EAR_RES_27 (1<<27) /* unused */
27#define KN0X_EAR_ADDRESS (0x7ffffff<<0) /* address involved */
28
29/*
30 * Error Syndrome Register bits.
31 * The register is frozen when EAR.VALID is set, otherwise it records bits
32 * from the last memory read. The register is r/wc -- any write clears it.
33 */
34#define KN0X_ESR_VLDHI (1<<31) /* error data valid hi word */
35#define KN0X_ESR_CHKHI (0x7f<<24) /* check bits read from mem */
36#define KN0X_ESR_SNGHI (1<<23) /* single/double bit error */
37#define KN0X_ESR_SYNHI (0x7f<<16) /* syndrome from ECC logic */
38#define KN0X_ESR_VLDLO (1<<15) /* error data valid lo word */
39#define KN0X_ESR_CHKLO (0x7f<<8) /* check bits read from mem */
40#define KN0X_ESR_SNGLO (1<<7) /* single/double bit error */
41#define KN0X_ESR_SYNLO (0x7f<<0) /* syndrome from ECC logic */
42
43
44#ifndef __ASSEMBLY__
45
46#include <linux/interrupt.h>
47
48struct pt_regs;
49
50extern void dec_ecc_be_init(void);
51extern int dec_ecc_be_handler(struct pt_regs *regs, int is_fixup);
52extern irqreturn_t dec_ecc_be_interrupt(int irq, void *dev_id);
53#endif
54
55#endif /* __ASM_MIPS_DEC_ECC_H */
diff --git a/arch/mips/include/asm/dec/interrupts.h b/arch/mips/include/asm/dec/interrupts.h
new file mode 100644
index 000000000000..e10d341067c8
--- /dev/null
+++ b/arch/mips/include/asm/dec/interrupts.h
@@ -0,0 +1,126 @@
1/*
2 * Miscellaneous definitions used to initialise the interrupt vector table
3 * with the machine-specific interrupt routines.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (C) 1997 by Paul M. Antoine.
10 * reworked 1998 by Harald Koerfgen.
11 * Copyright (C) 2001, 2002, 2003 Maciej W. Rozycki
12 */
13
14#ifndef __ASM_DEC_INTERRUPTS_H
15#define __ASM_DEC_INTERRUPTS_H
16
17#include <irq.h>
18#include <asm/mipsregs.h>
19
20
21/*
22 * The list of possible system devices which provide an
23 * interrupt. Not all devices exist on a given system.
24 */
25#define DEC_IRQ_CASCADE 0 /* cascade from CSR or I/O ASIC */
26
27/* Ordinary interrupts */
28#define DEC_IRQ_AB_RECV 1 /* ACCESS.bus receive */
29#define DEC_IRQ_AB_XMIT 2 /* ACCESS.bus transmit */
30#define DEC_IRQ_DZ11 3 /* DZ11 (DC7085) serial */
31#define DEC_IRQ_ASC 4 /* ASC (NCR53C94) SCSI */
32#define DEC_IRQ_FLOPPY 5 /* 82077 FDC */
33#define DEC_IRQ_FPU 6 /* R3k FPU */
34#define DEC_IRQ_HALT 7 /* HALT button or from ACCESS.Bus */
35#define DEC_IRQ_ISDN 8 /* Am79C30A ISDN */
36#define DEC_IRQ_LANCE 9 /* LANCE (Am7990) Ethernet */
37#define DEC_IRQ_BUS 10 /* memory, I/O bus read/write errors */
38#define DEC_IRQ_PSU 11 /* power supply unit warning */
39#define DEC_IRQ_RTC 12 /* DS1287 RTC */
40#define DEC_IRQ_SCC0 13 /* SCC (Z85C30) serial #0 */
41#define DEC_IRQ_SCC1 14 /* SCC (Z85C30) serial #1 */
42#define DEC_IRQ_SII 15 /* SII (DC7061) SCSI */
43#define DEC_IRQ_TC0 16 /* TURBOchannel slot #0 */
44#define DEC_IRQ_TC1 17 /* TURBOchannel slot #1 */
45#define DEC_IRQ_TC2 18 /* TURBOchannel slot #2 */
46#define DEC_IRQ_TIMER 19 /* ARC periodic timer */
47#define DEC_IRQ_VIDEO 20 /* framebuffer */
48
49/* I/O ASIC DMA interrupts */
50#define DEC_IRQ_ASC_MERR 21 /* ASC memory read error */
51#define DEC_IRQ_ASC_ERR 22 /* ASC page overrun */
52#define DEC_IRQ_ASC_DMA 23 /* ASC buffer pointer loaded */
53#define DEC_IRQ_FLOPPY_ERR 24 /* FDC error */
54#define DEC_IRQ_ISDN_ERR 25 /* ISDN memory read/overrun error */
55#define DEC_IRQ_ISDN_RXDMA 26 /* ISDN recv buffer pointer loaded */
56#define DEC_IRQ_ISDN_TXDMA 27 /* ISDN xmit buffer pointer loaded */
57#define DEC_IRQ_LANCE_MERR 28 /* LANCE memory read error */
58#define DEC_IRQ_SCC0A_RXERR 29 /* SCC0A (printer) receive overrun */
59#define DEC_IRQ_SCC0A_RXDMA 30 /* SCC0A receive half page */
60#define DEC_IRQ_SCC0A_TXERR 31 /* SCC0A xmit memory read/overrun */
61#define DEC_IRQ_SCC0A_TXDMA 32 /* SCC0A transmit page end */
62#define DEC_IRQ_AB_RXERR 33 /* ACCESS.bus receive overrun */
63#define DEC_IRQ_AB_RXDMA 34 /* ACCESS.bus receive half page */
64#define DEC_IRQ_AB_TXERR 35 /* ACCESS.bus xmit memory read/ovrn */
65#define DEC_IRQ_AB_TXDMA 36 /* ACCESS.bus transmit page end */
66#define DEC_IRQ_SCC1A_RXERR 37 /* SCC1A (modem) receive overrun */
67#define DEC_IRQ_SCC1A_RXDMA 38 /* SCC1A receive half page */
68#define DEC_IRQ_SCC1A_TXERR 39 /* SCC1A xmit memory read/overrun */
69#define DEC_IRQ_SCC1A_TXDMA 40 /* SCC1A transmit page end */
70
71/* TC5 & TC6 are virtual slots for KN02's onboard devices */
72#define DEC_IRQ_TC5 DEC_IRQ_ASC /* virtual PMAZ-AA */
73#define DEC_IRQ_TC6 DEC_IRQ_LANCE /* virtual PMAD-AA */
74
75#define DEC_NR_INTS 41
76
77
78/* Largest of cpu mask_nr tables. */
79#define DEC_MAX_CPU_INTS 6
80/* Largest of asic mask_nr tables. */
81#define DEC_MAX_ASIC_INTS 9
82
83
84/*
85 * CPU interrupt bits common to all systems.
86 */
87#define DEC_CPU_INR_FPU 7 /* R3k FPU */
88#define DEC_CPU_INR_SW1 1 /* software #1 */
89#define DEC_CPU_INR_SW0 0 /* software #0 */
90
91#define DEC_CPU_IRQ_BASE MIPS_CPU_IRQ_BASE /* first IRQ assigned to CPU */
92
93#define DEC_CPU_IRQ_NR(n) ((n) + DEC_CPU_IRQ_BASE)
94#define DEC_CPU_IRQ_MASK(n) (1 << ((n) + CAUSEB_IP))
95#define DEC_CPU_IRQ_ALL (0xff << CAUSEB_IP)
96
97
98#ifndef __ASSEMBLY__
99
100/*
101 * Interrupt table structures to hide differences between systems.
102 */
103typedef union { int i; void *p; } int_ptr;
104extern int dec_interrupt[DEC_NR_INTS];
105extern int_ptr cpu_mask_nr_tbl[DEC_MAX_CPU_INTS][2];
106extern int_ptr asic_mask_nr_tbl[DEC_MAX_ASIC_INTS][2];
107extern int cpu_fpu_mask;
108
109
110/*
111 * Common interrupt routine prototypes for all DECStations
112 */
113extern void kn02_io_int(void);
114extern void kn02xa_io_int(void);
115extern void kn03_io_int(void);
116extern void asic_dma_int(void);
117extern void asic_all_int(void);
118extern void kn02_all_int(void);
119extern void cpu_all_int(void);
120
121extern void dec_intr_unimplemented(void);
122extern void asic_intr_unimplemented(void);
123
124#endif /* __ASSEMBLY__ */
125
126#endif
diff --git a/arch/mips/include/asm/dec/ioasic.h b/arch/mips/include/asm/dec/ioasic.h
new file mode 100644
index 000000000000..98badd6bf22d
--- /dev/null
+++ b/arch/mips/include/asm/dec/ioasic.h
@@ -0,0 +1,38 @@
1/*
2 * include/asm-mips/dec/ioasic.h
3 *
4 * DEC I/O ASIC access operations.
5 *
6 * Copyright (C) 2000, 2002, 2003 Maciej W. Rozycki
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13
14#ifndef __ASM_DEC_IOASIC_H
15#define __ASM_DEC_IOASIC_H
16
17#include <linux/spinlock.h>
18#include <linux/types.h>
19
20extern spinlock_t ioasic_ssr_lock;
21
22extern volatile u32 *ioasic_base;
23
24static inline void ioasic_write(unsigned int reg, u32 v)
25{
26 ioasic_base[reg / 4] = v;
27}
28
29static inline u32 ioasic_read(unsigned int reg)
30{
31 return ioasic_base[reg / 4];
32}
33
34extern void init_ioasic_irqs(int base);
35
36extern void dec_ioasic_clocksource_init(void);
37
38#endif /* __ASM_DEC_IOASIC_H */
diff --git a/arch/mips/include/asm/dec/ioasic_addrs.h b/arch/mips/include/asm/dec/ioasic_addrs.h
new file mode 100644
index 000000000000..4cbc1f8a1129
--- /dev/null
+++ b/arch/mips/include/asm/dec/ioasic_addrs.h
@@ -0,0 +1,152 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Definitions for the address map in the JUNKIO Asic
7 *
8 * Created with Information from:
9 *
10 * "DEC 3000 300/400/500/600/700/800/900 AXP Models System Programmer's Manual"
11 *
12 * and the Mach Sources
13 *
14 * Copyright (C) 199x the Anonymous
15 * Copyright (C) 2002, 2003 Maciej W. Rozycki
16 */
17
18#ifndef __ASM_MIPS_DEC_IOASIC_ADDRS_H
19#define __ASM_MIPS_DEC_IOASIC_ADDRS_H
20
21#define IOASIC_SLOT_SIZE 0x00040000
22
23/*
24 * Address ranges decoded by the I/O ASIC for onboard devices.
25 */
26#define IOASIC_SYS_ROM (0*IOASIC_SLOT_SIZE) /* system board ROM */
27#define IOASIC_IOCTL (1*IOASIC_SLOT_SIZE) /* I/O ASIC */
28#define IOASIC_ESAR (2*IOASIC_SLOT_SIZE) /* LANCE MAC address chip */
29#define IOASIC_LANCE (3*IOASIC_SLOT_SIZE) /* LANCE Ethernet */
30#define IOASIC_SCC0 (4*IOASIC_SLOT_SIZE) /* SCC #0 */
31#define IOASIC_VDAC_HI (5*IOASIC_SLOT_SIZE) /* VDAC (maxine) */
32#define IOASIC_SCC1 (6*IOASIC_SLOT_SIZE) /* SCC #1 (3min, 3max+) */
33#define IOASIC_VDAC_LO (7*IOASIC_SLOT_SIZE) /* VDAC (maxine) */
34#define IOASIC_TOY (8*IOASIC_SLOT_SIZE) /* RTC */
35#define IOASIC_ISDN (9*IOASIC_SLOT_SIZE) /* ISDN (maxine) */
36#define IOASIC_ERRADDR (9*IOASIC_SLOT_SIZE) /* bus error address (3max+) */
37#define IOASIC_CHKSYN (10*IOASIC_SLOT_SIZE) /* ECC syndrome (3max+) */
38#define IOASIC_ACC_BUS (10*IOASIC_SLOT_SIZE) /* ACCESS.bus (maxine) */
39#define IOASIC_MCR (11*IOASIC_SLOT_SIZE) /* memory control (3max+) */
40#define IOASIC_FLOPPY (11*IOASIC_SLOT_SIZE) /* FDC (maxine) */
41#define IOASIC_SCSI (12*IOASIC_SLOT_SIZE) /* ASC SCSI */
42#define IOASIC_FDC_DMA (13*IOASIC_SLOT_SIZE) /* FDC DMA (maxine) */
43#define IOASIC_SCSI_DMA (14*IOASIC_SLOT_SIZE) /* ??? */
44#define IOASIC_RES_15 (15*IOASIC_SLOT_SIZE) /* unused? */
45
46
47/*
48 * Offsets for I/O ASIC registers
49 * (relative to (dec_kn_slot_base + IOASIC_IOCTL)).
50 */
51 /* all systems */
52#define IO_REG_SCSI_DMA_P 0x00 /* SCSI DMA Pointer */
53#define IO_REG_SCSI_DMA_BP 0x10 /* SCSI DMA Buffer Pointer */
54#define IO_REG_LANCE_DMA_P 0x20 /* LANCE DMA Pointer */
55#define IO_REG_SCC0A_T_DMA_P 0x30 /* SCC0A Transmit DMA Pointer */
56#define IO_REG_SCC0A_R_DMA_P 0x40 /* SCC0A Receive DMA Pointer */
57
58 /* except Maxine */
59#define IO_REG_SCC1A_T_DMA_P 0x50 /* SCC1A Transmit DMA Pointer */
60#define IO_REG_SCC1A_R_DMA_P 0x60 /* SCC1A Receive DMA Pointer */
61
62 /* Maxine */
63#define IO_REG_AB_T_DMA_P 0x50 /* ACCESS.bus Transmit DMA Pointer */
64#define IO_REG_AB_R_DMA_P 0x60 /* ACCESS.bus Receive DMA Pointer */
65#define IO_REG_FLOPPY_DMA_P 0x70 /* Floppy DMA Pointer */
66#define IO_REG_ISDN_T_DMA_P 0x80 /* ISDN Transmit DMA Pointer */
67#define IO_REG_ISDN_T_DMA_BP 0x90 /* ISDN Transmit DMA Buffer Pointer */
68#define IO_REG_ISDN_R_DMA_P 0xa0 /* ISDN Receive DMA Pointer */
69#define IO_REG_ISDN_R_DMA_BP 0xb0 /* ISDN Receive DMA Buffer Pointer */
70
71 /* all systems */
72#define IO_REG_DATA_0 0xc0 /* System Data Buffer 0 */
73#define IO_REG_DATA_1 0xd0 /* System Data Buffer 1 */
74#define IO_REG_DATA_2 0xe0 /* System Data Buffer 2 */
75#define IO_REG_DATA_3 0xf0 /* System Data Buffer 3 */
76
77 /* all systems */
78#define IO_REG_SSR 0x100 /* System Support Register */
79#define IO_REG_SIR 0x110 /* System Interrupt Register */
80#define IO_REG_SIMR 0x120 /* System Interrupt Mask Reg. */
81#define IO_REG_SAR 0x130 /* System Address Register */
82
83 /* Maxine */
84#define IO_REG_ISDN_T_DATA 0x140 /* ISDN Xmit Data Register */
85#define IO_REG_ISDN_R_DATA 0x150 /* ISDN Receive Data Register */
86
87 /* all systems */
88#define IO_REG_LANCE_SLOT 0x160 /* LANCE I/O Slot Register */
89#define IO_REG_SCSI_SLOT 0x170 /* SCSI Slot Register */
90#define IO_REG_SCC0A_SLOT 0x180 /* SCC0A DMA Slot Register */
91
92 /* except Maxine */
93#define IO_REG_SCC1A_SLOT 0x190 /* SCC1A DMA Slot Register */
94
95 /* Maxine */
96#define IO_REG_AB_SLOT 0x190 /* ACCESS.bus DMA Slot Register */
97#define IO_REG_FLOPPY_SLOT 0x1a0 /* Floppy Slot Register */
98
99 /* all systems */
100#define IO_REG_SCSI_SCR 0x1b0 /* SCSI Partial-Word DMA Control */
101#define IO_REG_SCSI_SDR0 0x1c0 /* SCSI DMA Partial Word 0 */
102#define IO_REG_SCSI_SDR1 0x1d0 /* SCSI DMA Partial Word 1 */
103#define IO_REG_FCTR 0x1e0 /* Free-Running Counter */
104#define IO_REG_RES_31 0x1f0 /* unused */
105
106
107/*
108 * The upper 16 bits of the System Support Register are a part of the
109 * I/O ASIC's internal DMA engine and thus are common to all I/O ASIC
110 * machines. The exception is the Maxine, which makes use of the
111 * FLOPPY and ISDN bits (otherwise unused) and has a different SCC
112 * wiring.
113 */
114 /* all systems */
115#define IO_SSR_SCC0A_TX_DMA_EN (1<<31) /* SCC0A transmit DMA enable */
116#define IO_SSR_SCC0A_RX_DMA_EN (1<<30) /* SCC0A receive DMA enable */
117#define IO_SSR_RES_27 (1<<27) /* unused */
118#define IO_SSR_RES_26 (1<<26) /* unused */
119#define IO_SSR_RES_25 (1<<25) /* unused */
120#define IO_SSR_RES_24 (1<<24) /* unused */
121#define IO_SSR_RES_23 (1<<23) /* unused */
122#define IO_SSR_SCSI_DMA_DIR (1<<18) /* SCSI DMA direction */
123#define IO_SSR_SCSI_DMA_EN (1<<17) /* SCSI DMA enable */
124#define IO_SSR_LANCE_DMA_EN (1<<16) /* LANCE DMA enable */
125
126 /* except Maxine */
127#define IO_SSR_SCC1A_TX_DMA_EN (1<<29) /* SCC1A transmit DMA enable */
128#define IO_SSR_SCC1A_RX_DMA_EN (1<<28) /* SCC1A receive DMA enable */
129#define IO_SSR_RES_22 (1<<22) /* unused */
130#define IO_SSR_RES_21 (1<<21) /* unused */
131#define IO_SSR_RES_20 (1<<20) /* unused */
132#define IO_SSR_RES_19 (1<<19) /* unused */
133
134 /* Maxine */
135#define IO_SSR_AB_TX_DMA_EN (1<<29) /* ACCESS.bus xmit DMA enable */
136#define IO_SSR_AB_RX_DMA_EN (1<<28) /* ACCESS.bus recv DMA enable */
137#define IO_SSR_FLOPPY_DMA_DIR (1<<22) /* Floppy DMA direction */
138#define IO_SSR_FLOPPY_DMA_EN (1<<21) /* Floppy DMA enable */
139#define IO_SSR_ISDN_TX_DMA_EN (1<<20) /* ISDN transmit DMA enable */
140#define IO_SSR_ISDN_RX_DMA_EN (1<<19) /* ISDN receive DMA enable */
141
142/*
143 * The lower 16 bits are system-specific. Bits 15,11:8 are common and
144 * defined here. The rest is defined in system-specific headers.
145 */
146#define KN0X_IO_SSR_DIAGDN (1<<15) /* diagnostic jumper */
147#define KN0X_IO_SSR_SCC_RST (1<<11) /* ~SCC0,1 (Z85C30) reset */
148#define KN0X_IO_SSR_RTC_RST (1<<10) /* ~RTC (DS1287) reset */
149#define KN0X_IO_SSR_ASC_RST (1<<9) /* ~ASC (NCR53C94) reset */
150#define KN0X_IO_SSR_LANCE_RST (1<<8) /* ~LANCE (Am7990) reset */
151
152#endif /* __ASM_MIPS_DEC_IOASIC_ADDRS_H */
diff --git a/arch/mips/include/asm/dec/ioasic_ints.h b/arch/mips/include/asm/dec/ioasic_ints.h
new file mode 100644
index 000000000000..9aaa9869615f
--- /dev/null
+++ b/arch/mips/include/asm/dec/ioasic_ints.h
@@ -0,0 +1,74 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Definitions for the interrupt related bits in the I/O ASIC
7 * interrupt status register (and the interrupt mask register, of course)
8 *
9 * Created with Information from:
10 *
11 * "DEC 3000 300/400/500/600/700/800/900 AXP Models System Programmer's Manual"
12 *
13 * and the Mach Sources
14 *
15 * Copyright (C) 199x the Anonymous
16 * Copyright (C) 2002 Maciej W. Rozycki
17 */
18
19#ifndef __ASM_DEC_IOASIC_INTS_H
20#define __ASM_DEC_IOASIC_INTS_H
21
22/*
23 * The upper 16 bits are a part of the I/O ASIC's internal DMA engine
24 * and thus are common to all I/O ASIC machines. The exception is
25 * the Maxine, which makes use of the FLOPPY and ISDN bits (otherwise
26 * unused) and has a different SCC wiring.
27 */
28 /* all systems */
29#define IO_INR_SCC0A_TXDMA 31 /* SCC0A transmit page end */
30#define IO_INR_SCC0A_TXERR 30 /* SCC0A transmit memory read error */
31#define IO_INR_SCC0A_RXDMA 29 /* SCC0A receive half page */
32#define IO_INR_SCC0A_RXERR 28 /* SCC0A receive overrun */
33#define IO_INR_ASC_DMA 19 /* ASC buffer pointer loaded */
34#define IO_INR_ASC_ERR 18 /* ASC page overrun */
35#define IO_INR_ASC_MERR 17 /* ASC memory read error */
36#define IO_INR_LANCE_MERR 16 /* LANCE memory read error */
37
38 /* except Maxine */
39#define IO_INR_SCC1A_TXDMA 27 /* SCC1A transmit page end */
40#define IO_INR_SCC1A_TXERR 26 /* SCC1A transmit memory read error */
41#define IO_INR_SCC1A_RXDMA 25 /* SCC1A receive half page */
42#define IO_INR_SCC1A_RXERR 24 /* SCC1A receive overrun */
43#define IO_INR_RES_23 23 /* unused */
44#define IO_INR_RES_22 22 /* unused */
45#define IO_INR_RES_21 21 /* unused */
46#define IO_INR_RES_20 20 /* unused */
47
48 /* Maxine */
49#define IO_INR_AB_TXDMA 27 /* ACCESS.bus transmit page end */
50#define IO_INR_AB_TXERR 26 /* ACCESS.bus xmit memory read error */
51#define IO_INR_AB_RXDMA 25 /* ACCESS.bus receive half page */
52#define IO_INR_AB_RXERR 24 /* ACCESS.bus receive overrun */
53#define IO_INR_FLOPPY_ERR 23 /* FDC error */
54#define IO_INR_ISDN_TXDMA 22 /* ISDN xmit buffer pointer loaded */
55#define IO_INR_ISDN_RXDMA 21 /* ISDN recv buffer pointer loaded */
56#define IO_INR_ISDN_ERR 20 /* ISDN memory read/overrun error */
57
58#define IO_INR_DMA 16 /* first DMA IRQ */
59
60/*
61 * The lower 16 bits are system-specific and thus defined in
62 * system-specific headers.
63 */
64
65
66#define IO_IRQ_BASE 8 /* first IRQ assigned to I/O ASIC */
67#define IO_IRQ_LINES 32 /* number of I/O ASIC interrupts */
68
69#define IO_IRQ_NR(n) ((n) + IO_IRQ_BASE)
70#define IO_IRQ_MASK(n) (1 << (n))
71#define IO_IRQ_ALL 0x0000ffff
72#define IO_IRQ_DMA 0xffff0000
73
74#endif /* __ASM_DEC_IOASIC_INTS_H */
diff --git a/arch/mips/include/asm/dec/kn01.h b/arch/mips/include/asm/dec/kn01.h
new file mode 100644
index 000000000000..28fa717ac423
--- /dev/null
+++ b/arch/mips/include/asm/dec/kn01.h
@@ -0,0 +1,90 @@
1/*
2 * Hardware info about DECstation DS2100/3100 systems (otherwise known as
3 * pmin/pmax or KN01).
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (C) 1995,1996 by Paul M. Antoine, some code and definitions
10 * are by courtesy of Chris Fraser.
11 * Copyright (C) 2002, 2003, 2005 Maciej W. Rozycki
12 */
13#ifndef __ASM_MIPS_DEC_KN01_H
14#define __ASM_MIPS_DEC_KN01_H
15
16#define KN01_SLOT_BASE 0x10000000
17#define KN01_SLOT_SIZE 0x01000000
18
19/*
20 * Address ranges for devices.
21 */
22#define KN01_PMASK (0*KN01_SLOT_SIZE) /* color plane mask */
23#define KN01_PCC (1*KN01_SLOT_SIZE) /* PCC (DC503) cursor */
24#define KN01_VDAC (2*KN01_SLOT_SIZE) /* color map */
25#define KN01_RES_3 (3*KN01_SLOT_SIZE) /* unused */
26#define KN01_RES_4 (4*KN01_SLOT_SIZE) /* unused */
27#define KN01_RES_5 (5*KN01_SLOT_SIZE) /* unused */
28#define KN01_RES_6 (6*KN01_SLOT_SIZE) /* unused */
29#define KN01_ERRADDR (7*KN01_SLOT_SIZE) /* write error address */
30#define KN01_LANCE (8*KN01_SLOT_SIZE) /* LANCE (Am7990) Ethernet */
31#define KN01_LANCE_MEM (9*KN01_SLOT_SIZE) /* LANCE buffer memory */
32#define KN01_SII (10*KN01_SLOT_SIZE) /* SII (DC7061) SCSI */
33#define KN01_SII_MEM (11*KN01_SLOT_SIZE) /* SII buffer memory */
34#define KN01_DZ11 (12*KN01_SLOT_SIZE) /* DZ11 (DC7085) serial */
35#define KN01_RTC (13*KN01_SLOT_SIZE) /* DS1287 RTC (bytes #0) */
36#define KN01_ESAR (13*KN01_SLOT_SIZE) /* MAC address (bytes #1) */
37#define KN01_CSR (14*KN01_SLOT_SIZE) /* system ctrl & status reg */
38#define KN01_SYS_ROM (15*KN01_SLOT_SIZE) /* system board ROM */
39
40
41/*
42 * Frame buffer memory address.
43 */
44#define KN01_VFB_MEM 0x0fc00000
45
46/*
47 * CPU interrupt bits.
48 */
49#define KN01_CPU_INR_BUS 6 /* memory, I/O bus read/write errors */
50#define KN01_CPU_INR_VIDEO 6 /* PCC area detect #2 */
51#define KN01_CPU_INR_RTC 5 /* DS1287 RTC */
52#define KN01_CPU_INR_DZ11 4 /* DZ11 (DC7085) serial */
53#define KN01_CPU_INR_LANCE 3 /* LANCE (Am7990) Ethernet */
54#define KN01_CPU_INR_SII 2 /* SII (DC7061) SCSI */
55
56
57/*
58 * System Control & Status Register bits.
59 */
60#define KN01_CSR_MNFMOD (1<<15) /* MNFMOD manufacturing jumper */
61#define KN01_CSR_STATUS (1<<14) /* self-test result status output */
62#define KN01_CSR_PARDIS (1<<13) /* parity error disable */
63#define KN01_CSR_CRSRTST (1<<12) /* PCC test output */
64#define KN01_CSR_MONO (1<<11) /* mono/color fb SIMM installed */
65#define KN01_CSR_MEMERR (1<<10) /* write timeout error status & ack*/
66#define KN01_CSR_VINT (1<<9) /* PCC area detect #2 status & ack */
67#define KN01_CSR_TXDIS (1<<8) /* DZ11 transmit disable */
68#define KN01_CSR_VBGTRG (1<<2) /* blue DAC voltage over green (r/o) */
69#define KN01_CSR_VRGTRG (1<<1) /* red DAC voltage over green (r/o) */
70#define KN01_CSR_VRGTRB (1<<0) /* red DAC voltage over blue (r/o) */
71#define KN01_CSR_LEDS (0xff<<0) /* ~diagnostic LEDs (w/o) */
72
73
74#ifndef __ASSEMBLY__
75
76#include <linux/interrupt.h>
77#include <linux/spinlock.h>
78#include <linux/types.h>
79
80struct pt_regs;
81
82extern u16 cached_kn01_csr;
83extern spinlock_t kn01_lock;
84
85extern void dec_kn01_be_init(void);
86extern int dec_kn01_be_handler(struct pt_regs *regs, int is_fixup);
87extern irqreturn_t dec_kn01_be_interrupt(int irq, void *dev_id);
88#endif
89
90#endif /* __ASM_MIPS_DEC_KN01_H */
diff --git a/arch/mips/include/asm/dec/kn02.h b/arch/mips/include/asm/dec/kn02.h
new file mode 100644
index 000000000000..93430b5f4724
--- /dev/null
+++ b/arch/mips/include/asm/dec/kn02.h
@@ -0,0 +1,91 @@
1/*
2 * Hardware info about DECstation 5000/200 systems (otherwise known as
3 * 3max or KN02).
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (C) 1995,1996 by Paul M. Antoine, some code and definitions
10 * are by courtesy of Chris Fraser.
11 * Copyright (C) 2002, 2003, 2005 Maciej W. Rozycki
12 */
13#ifndef __ASM_MIPS_DEC_KN02_H
14#define __ASM_MIPS_DEC_KN02_H
15
16#define KN02_SLOT_BASE 0x1fc00000
17#define KN02_SLOT_SIZE 0x00080000
18
19/*
20 * Address ranges decoded by the "system slot" logic for onboard devices.
21 */
22#define KN02_SYS_ROM (0*KN02_SLOT_SIZE) /* system board ROM */
23#define KN02_RES_1 (1*KN02_SLOT_SIZE) /* unused */
24#define KN02_CHKSYN (2*KN02_SLOT_SIZE) /* ECC syndrome */
25#define KN02_ERRADDR (3*KN02_SLOT_SIZE) /* bus error address */
26#define KN02_DZ11 (4*KN02_SLOT_SIZE) /* DZ11 (DC7085) serial */
27#define KN02_RTC (5*KN02_SLOT_SIZE) /* DS1287 RTC */
28#define KN02_CSR (6*KN02_SLOT_SIZE) /* system ctrl & status reg */
29#define KN02_SYS_ROM_7 (7*KN02_SLOT_SIZE) /* system board ROM (alias) */
30
31
32/*
33 * System Control & Status Register bits.
34 */
35#define KN02_CSR_RES_28 (0xf<<28) /* unused */
36#define KN02_CSR_PSU (1<<27) /* power supply unit warning */
37#define KN02_CSR_NVRAM (1<<26) /* ~NVRAM clear jumper */
38#define KN02_CSR_REFEVEN (1<<25) /* mem refresh bank toggle */
39#define KN02_CSR_NRMOD (1<<24) /* ~NRMOD manufact. jumper */
40#define KN02_CSR_IOINTEN (0xff<<16) /* IRQ mask bits */
41#define KN02_CSR_DIAGCHK (1<<15) /* diagn/norml ECC reads */
42#define KN02_CSR_DIAGGEN (1<<14) /* diagn/norml ECC writes */
43#define KN02_CSR_CORRECT (1<<13) /* ECC correct/check */
44#define KN02_CSR_LEDIAG (1<<12) /* ECC diagn. latch strobe */
45#define KN02_CSR_TXDIS (1<<11) /* DZ11 transmit disable */
46#define KN02_CSR_BNK32M (1<<10) /* 32M/8M stride */
47#define KN02_CSR_DIAGDN (1<<9) /* DIAGDN manufact. jumper */
48#define KN02_CSR_BAUD38 (1<<8) /* DZ11 38/19kbps ext. rate */
49#define KN02_CSR_IOINT (0xff<<0) /* IRQ status bits (r/o) */
50#define KN02_CSR_LEDS (0xff<<0) /* ~diagnostic LEDs (w/o) */
51
52
53/*
54 * CPU interrupt bits.
55 */
56#define KN02_CPU_INR_RES_6 6 /* unused */
57#define KN02_CPU_INR_BUS 5 /* memory, I/O bus read/write errors */
58#define KN02_CPU_INR_RES_4 4 /* unused */
59#define KN02_CPU_INR_RTC 3 /* DS1287 RTC */
60#define KN02_CPU_INR_CASCADE 2 /* CSR cascade */
61
62/*
63 * CSR interrupt bits.
64 */
65#define KN02_CSR_INR_DZ11 7 /* DZ11 (DC7085) serial */
66#define KN02_CSR_INR_LANCE 6 /* LANCE (Am7990) Ethernet */
67#define KN02_CSR_INR_ASC 5 /* ASC (NCR53C94) SCSI */
68#define KN02_CSR_INR_RES_4 4 /* unused */
69#define KN02_CSR_INR_RES_3 3 /* unused */
70#define KN02_CSR_INR_TC2 2 /* TURBOchannel slot #2 */
71#define KN02_CSR_INR_TC1 1 /* TURBOchannel slot #1 */
72#define KN02_CSR_INR_TC0 0 /* TURBOchannel slot #0 */
73
74
75#define KN02_IRQ_BASE 8 /* first IRQ assigned to CSR */
76#define KN02_IRQ_LINES 8 /* number of CSR interrupts */
77
78#define KN02_IRQ_NR(n) ((n) + KN02_IRQ_BASE)
79#define KN02_IRQ_MASK(n) (1 << (n))
80#define KN02_IRQ_ALL 0xff
81
82
83#ifndef __ASSEMBLY__
84
85#include <linux/types.h>
86
87extern u32 cached_kn02_csr;
88extern void init_kn02_irqs(int base);
89#endif
90
91#endif /* __ASM_MIPS_DEC_KN02_H */
diff --git a/arch/mips/include/asm/dec/kn02ba.h b/arch/mips/include/asm/dec/kn02ba.h
new file mode 100644
index 000000000000..c957a4f1b32d
--- /dev/null
+++ b/arch/mips/include/asm/dec/kn02ba.h
@@ -0,0 +1,67 @@
1/*
2 * include/asm-mips/dec/kn02ba.h
3 *
4 * DECstation 5000/1xx (3min or KN02-BA) definitions.
5 *
6 * Copyright (C) 2002, 2003 Maciej W. Rozycki
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#ifndef __ASM_MIPS_DEC_KN02BA_H
14#define __ASM_MIPS_DEC_KN02BA_H
15
16#include <asm/dec/kn02xa.h> /* For common definitions. */
17
18/*
19 * CPU interrupt bits.
20 */
21#define KN02BA_CPU_INR_HALT 6 /* HALT button */
22#define KN02BA_CPU_INR_CASCADE 5 /* I/O ASIC cascade */
23#define KN02BA_CPU_INR_TC2 4 /* TURBOchannel slot #2 */
24#define KN02BA_CPU_INR_TC1 3 /* TURBOchannel slot #1 */
25#define KN02BA_CPU_INR_TC0 2 /* TURBOchannel slot #0 */
26
27/*
28 * I/O ASIC interrupt bits. Star marks denote non-IRQ status bits.
29 */
30#define KN02BA_IO_INR_RES_15 15 /* unused */
31#define KN02BA_IO_INR_NVRAM 14 /* (*) NVRAM clear jumper */
32#define KN02BA_IO_INR_RES_13 13 /* unused */
33#define KN02BA_IO_INR_BUS 12 /* memory, I/O bus read/write errors */
34#define KN02BA_IO_INR_RES_11 11 /* unused */
35#define KN02BA_IO_INR_NRMOD 10 /* (*) NRMOD manufacturing jumper */
36#define KN02BA_IO_INR_ASC 9 /* ASC (NCR53C94) SCSI */
37#define KN02BA_IO_INR_LANCE 8 /* LANCE (Am7990) Ethernet */
38#define KN02BA_IO_INR_SCC1 7 /* SCC (Z85C30) serial #1 */
39#define KN02BA_IO_INR_SCC0 6 /* SCC (Z85C30) serial #0 */
40#define KN02BA_IO_INR_RTC 5 /* DS1287 RTC */
41#define KN02BA_IO_INR_PSU 4 /* power supply unit warning */
42#define KN02BA_IO_INR_RES_3 3 /* unused */
43#define KN02BA_IO_INR_ASC_DATA 2 /* SCSI data ready (for PIO) */
44#define KN02BA_IO_INR_PBNC 1 /* ~HALT button debouncer */
45#define KN02BA_IO_INR_PBNO 0 /* HALT button debouncer */
46
47
48/*
49 * Memory Error Register bits.
50 */
51#define KN02BA_MER_RES_27 (1<<27) /* unused */
52
53/*
54 * Memory Size Register bits.
55 */
56#define KN02BA_MSR_RES_17 (0x3ff<<17) /* unused */
57
58/*
59 * I/O ASIC System Support Register bits.
60 */
61#define KN02BA_IO_SSR_TXDIS1 (1<<14) /* SCC1 transmit disable */
62#define KN02BA_IO_SSR_TXDIS0 (1<<13) /* SCC0 transmit disable */
63#define KN02BA_IO_SSR_RES_12 (1<<12) /* unused */
64
65#define KN02BA_IO_SSR_LEDS (0xff<<0) /* ~diagnostic LEDs */
66
67#endif /* __ASM_MIPS_DEC_KN02BA_H */
diff --git a/arch/mips/include/asm/dec/kn02ca.h b/arch/mips/include/asm/dec/kn02ca.h
new file mode 100644
index 000000000000..92c0fe256099
--- /dev/null
+++ b/arch/mips/include/asm/dec/kn02ca.h
@@ -0,0 +1,79 @@
1/*
2 * include/asm-mips/dec/kn02ca.h
3 *
4 * Personal DECstation 5000/xx (Maxine or KN02-CA) definitions.
5 *
6 * Copyright (C) 2002, 2003 Maciej W. Rozycki
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#ifndef __ASM_MIPS_DEC_KN02CA_H
14#define __ASM_MIPS_DEC_KN02CA_H
15
16#include <asm/dec/kn02xa.h> /* For common definitions. */
17
18/*
19 * CPU interrupt bits.
20 */
21#define KN02CA_CPU_INR_HALT 6 /* HALT from ACCESS.Bus */
22#define KN02CA_CPU_INR_CASCADE 5 /* I/O ASIC cascade */
23#define KN02CA_CPU_INR_BUS 4 /* memory, I/O bus read/write errors */
24#define KN02CA_CPU_INR_RTC 3 /* DS1287 RTC */
25#define KN02CA_CPU_INR_TIMER 2 /* ARC periodic timer */
26
27/*
28 * I/O ASIC interrupt bits. Star marks denote non-IRQ status bits.
29 */
30#define KN02CA_IO_INR_FLOPPY 15 /* 82077 FDC */
31#define KN02CA_IO_INR_NVRAM 14 /* (*) NVRAM clear jumper */
32#define KN02CA_IO_INR_POWERON 13 /* (*) ACCESS.Bus/power-on reset */
33#define KN02CA_IO_INR_TC0 12 /* TURBOchannel slot #0 */
34#define KN02CA_IO_INR_TIMER 12 /* ARC periodic timer (?) */
35#define KN02CA_IO_INR_ISDN 11 /* Am79C30A ISDN */
36#define KN02CA_IO_INR_NRMOD 10 /* (*) NRMOD manufacturing jumper */
37#define KN02CA_IO_INR_ASC 9 /* ASC (NCR53C94) SCSI */
38#define KN02CA_IO_INR_LANCE 8 /* LANCE (Am7990) Ethernet */
39#define KN02CA_IO_INR_HDFLOPPY 7 /* (*) HD (1.44MB) floppy status */
40#define KN02CA_IO_INR_SCC0 6 /* SCC (Z85C30) serial #0 */
41#define KN02CA_IO_INR_TC1 5 /* TURBOchannel slot #1 */
42#define KN02CA_IO_INR_XDFLOPPY 4 /* (*) XD (2.88MB) floppy status */
43#define KN02CA_IO_INR_VIDEO 3 /* framebuffer */
44#define KN02CA_IO_INR_XVIDEO 2 /* ~framebuffer */
45#define KN02CA_IO_INR_AB_XMIT 1 /* ACCESS.bus transmit */
46#define KN02CA_IO_INR_AB_RECV 0 /* ACCESS.bus receive */
47
48
49/*
50 * Memory Error Register bits.
51 */
52#define KN02CA_MER_INTR (1<<27) /* ARC IRQ status & ack */
53
54/*
55 * Memory Size Register bits.
56 */
57#define KN02CA_MSR_INTREN (1<<26) /* ARC periodic IRQ enable */
58#define KN02CA_MSR_MS10EN (1<<25) /* 10/1ms IRQ period select */
59#define KN02CA_MSR_PFORCE (0xf<<21) /* byte lane error force */
60#define KN02CA_MSR_MABEN (1<<20) /* A side VFB address enable */
61#define KN02CA_MSR_LASTBANK (0x7<<17) /* onboard RAM bank # */
62
63/*
64 * I/O ASIC System Support Register bits.
65 */
66#define KN03CA_IO_SSR_RES_14 (1<<14) /* unused */
67#define KN03CA_IO_SSR_RES_13 (1<<13) /* unused */
68#define KN03CA_IO_SSR_ISDN_RST (1<<12) /* ~ISDN (Am79C30A) reset */
69
70#define KN03CA_IO_SSR_FLOPPY_RST (1<<7) /* ~FDC (82077) reset */
71#define KN03CA_IO_SSR_VIDEO_RST (1<<6) /* ~framebuffer reset */
72#define KN03CA_IO_SSR_AB_RST (1<<5) /* ACCESS.bus reset */
73#define KN03CA_IO_SSR_RES_4 (1<<4) /* unused */
74#define KN03CA_IO_SSR_RES_3 (1<<4) /* unused */
75#define KN03CA_IO_SSR_RES_2 (1<<2) /* unused */
76#define KN03CA_IO_SSR_RES_1 (1<<1) /* unused */
77#define KN03CA_IO_SSR_LED (1<<0) /* power LED */
78
79#endif /* __ASM_MIPS_DEC_KN02CA_H */
diff --git a/arch/mips/include/asm/dec/kn02xa.h b/arch/mips/include/asm/dec/kn02xa.h
new file mode 100644
index 000000000000..b56b4577f6ef
--- /dev/null
+++ b/arch/mips/include/asm/dec/kn02xa.h
@@ -0,0 +1,84 @@
1/*
2 * Hardware info common to DECstation 5000/1xx systems (otherwise
3 * known as 3min or kn02ba) and Personal DECstations 5000/xx ones
4 * (otherwise known as maxine or kn02ca).
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 1995,1996 by Paul M. Antoine, some code and definitions
11 * are by courtesy of Chris Fraser.
12 * Copyright (C) 2000, 2002, 2003, 2005 Maciej W. Rozycki
13 *
14 * These are addresses which have to be known early in the boot process.
15 * For other addresses refer to tc.h, ioasic_addrs.h and friends.
16 */
17#ifndef __ASM_MIPS_DEC_KN02XA_H
18#define __ASM_MIPS_DEC_KN02XA_H
19
20#include <asm/dec/ioasic_addrs.h>
21
22#define KN02XA_SLOT_BASE 0x1c000000
23
24/*
25 * Memory control ASIC registers.
26 */
27#define KN02XA_MER 0x0c400000 /* memory error register */
28#define KN02XA_MSR 0x0c800000 /* memory size register */
29
30/*
31 * CPU control ASIC registers.
32 */
33#define KN02XA_MEM_CONF 0x0e000000 /* write timeout config */
34#define KN02XA_EAR 0x0e000004 /* error address register */
35#define KN02XA_BOOT0 0x0e000008 /* boot 0 register */
36#define KN02XA_MEM_INTR 0x0e00000c /* write err IRQ stat & ack */
37
38/*
39 * Memory Error Register bits, common definitions.
40 * The rest is defined in system-specific headers.
41 */
42#define KN02XA_MER_RES_28 (0xf<<28) /* unused */
43#define KN02XA_MER_RES_17 (0x3ff<<17) /* unused */
44#define KN02XA_MER_PAGERR (1<<16) /* 2k page boundary error */
45#define KN02XA_MER_TRANSERR (1<<15) /* transfer length error */
46#define KN02XA_MER_PARDIS (1<<14) /* parity error disable */
47#define KN02XA_MER_SIZE (1<<13) /* r/o mirror of MSR_SIZE */
48#define KN02XA_MER_RES_12 (1<<12) /* unused */
49#define KN02XA_MER_BYTERR (0xf<<8) /* byte lane error bitmask: */
50#define KN02XA_MER_BYTERR_3 (0x8<<8) /* byte lane #3 */
51#define KN02XA_MER_BYTERR_2 (0x4<<8) /* byte lane #2 */
52#define KN02XA_MER_BYTERR_1 (0x2<<8) /* byte lane #1 */
53#define KN02XA_MER_BYTERR_0 (0x1<<8) /* byte lane #0 */
54#define KN02XA_MER_RES_0 (0xff<<0) /* unused */
55
56/*
57 * Memory Size Register bits, common definitions.
58 * The rest is defined in system-specific headers.
59 */
60#define KN02XA_MSR_RES_27 (0x1f<<27) /* unused */
61#define KN02XA_MSR_RES_14 (0x7<<14) /* unused */
62#define KN02XA_MSR_SIZE (1<<13) /* 16M/4M stride */
63#define KN02XA_MSR_RES_0 (0x1fff<<0) /* unused */
64
65/*
66 * Error Address Register bits.
67 */
68#define KN02XA_EAR_RES_29 (0x7<<29) /* unused */
69#define KN02XA_EAR_ADDRESS (0x7ffffff<<2) /* address involved */
70#define KN02XA_EAR_RES_0 (0x3<<0) /* unused */
71
72
73#ifndef __ASSEMBLY__
74
75#include <linux/interrupt.h>
76
77struct pt_regs;
78
79extern void dec_kn02xa_be_init(void);
80extern int dec_kn02xa_be_handler(struct pt_regs *regs, int is_fixup);
81extern irqreturn_t dec_kn02xa_be_interrupt(int irq, void *dev_id);
82#endif
83
84#endif /* __ASM_MIPS_DEC_KN02XA_H */
diff --git a/arch/mips/include/asm/dec/kn03.h b/arch/mips/include/asm/dec/kn03.h
new file mode 100644
index 000000000000..edede923ffb8
--- /dev/null
+++ b/arch/mips/include/asm/dec/kn03.h
@@ -0,0 +1,74 @@
1/*
2 * Hardware info about DECstation 5000/2x0 systems (otherwise known as
3 * 3max+) and DECsystem 5900 systems (otherwise known as bigmax) which
4 * differ mechanically but are otherwise identical (both are known as
5 * KN03).
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 *
11 * Copyright (C) 1995,1996 by Paul M. Antoine, some code and definitions
12 * are by courtesy of Chris Fraser.
13 * Copyright (C) 2000, 2002, 2003, 2005 Maciej W. Rozycki
14 */
15#ifndef __ASM_MIPS_DEC_KN03_H
16#define __ASM_MIPS_DEC_KN03_H
17
18#include <asm/dec/ecc.h>
19#include <asm/dec/ioasic_addrs.h>
20
21#define KN03_SLOT_BASE 0x1f800000
22
23/*
24 * CPU interrupt bits.
25 */
26#define KN03_CPU_INR_HALT 6 /* HALT button */
27#define KN03_CPU_INR_BUS 5 /* memory, I/O bus read/write errors */
28#define KN03_CPU_INR_RES_4 4 /* unused */
29#define KN03_CPU_INR_RTC 3 /* DS1287 RTC */
30#define KN03_CPU_INR_CASCADE 2 /* I/O ASIC cascade */
31
32/*
33 * I/O ASIC interrupt bits. Star marks denote non-IRQ status bits.
34 */
35#define KN03_IO_INR_3MAXP 15 /* (*) 3max+/bigmax ID */
36#define KN03_IO_INR_NVRAM 14 /* (*) NVRAM clear jumper */
37#define KN03_IO_INR_TC2 13 /* TURBOchannel slot #2 */
38#define KN03_IO_INR_TC1 12 /* TURBOchannel slot #1 */
39#define KN03_IO_INR_TC0 11 /* TURBOchannel slot #0 */
40#define KN03_IO_INR_NRMOD 10 /* (*) NRMOD manufacturing jumper */
41#define KN03_IO_INR_ASC 9 /* ASC (NCR53C94) SCSI */
42#define KN03_IO_INR_LANCE 8 /* LANCE (Am7990) Ethernet */
43#define KN03_IO_INR_SCC1 7 /* SCC (Z85C30) serial #1 */
44#define KN03_IO_INR_SCC0 6 /* SCC (Z85C30) serial #0 */
45#define KN03_IO_INR_RTC 5 /* DS1287 RTC */
46#define KN03_IO_INR_PSU 4 /* power supply unit warning */
47#define KN03_IO_INR_RES_3 3 /* unused */
48#define KN03_IO_INR_ASC_DATA 2 /* SCSI data ready (for PIO) */
49#define KN03_IO_INR_PBNC 1 /* ~HALT button debouncer */
50#define KN03_IO_INR_PBNO 0 /* HALT button debouncer */
51
52
53/*
54 * Memory Control Register bits.
55 */
56#define KN03_MCR_RES_16 (0xffff<<16) /* unused */
57#define KN03_MCR_DIAGCHK (1<<15) /* diagn/norml ECC reads */
58#define KN03_MCR_DIAGGEN (1<<14) /* diagn/norml ECC writes */
59#define KN03_MCR_CORRECT (1<<13) /* ECC correct/check */
60#define KN03_MCR_RES_11 (0x3<<12) /* unused */
61#define KN03_MCR_BNK32M (1<<10) /* 32M/8M stride */
62#define KN03_MCR_RES_7 (0x7<<7) /* unused */
63#define KN03_MCR_CHECK (0x7f<<0) /* diagnostic check bits */
64
65/*
66 * I/O ASIC System Support Register bits.
67 */
68#define KN03_IO_SSR_TXDIS1 (1<<14) /* SCC1 transmit disable */
69#define KN03_IO_SSR_TXDIS0 (1<<13) /* SCC0 transmit disable */
70#define KN03_IO_SSR_RES_12 (1<<12) /* unused */
71
72#define KN03_IO_SSR_LEDS (0xff<<0) /* ~diagnostic LEDs */
73
74#endif /* __ASM_MIPS_DEC_KN03_H */
diff --git a/arch/mips/include/asm/dec/kn05.h b/arch/mips/include/asm/dec/kn05.h
new file mode 100644
index 000000000000..56d22dc8803a
--- /dev/null
+++ b/arch/mips/include/asm/dec/kn05.h
@@ -0,0 +1,76 @@
1/*
2 * include/asm-mips/dec/kn05.h
3 *
4 * DECstation/DECsystem 5000/260 (4max+ or KN05), 5000/150 (4min
5 * or KN04-BA), Personal DECstation/DECsystem 5000/50 (4maxine or
6 * KN04-CA) and DECsystem 5900/260 (KN05) R4k CPU card MB ASIC
7 * definitions.
8 *
9 * Copyright (C) 2002, 2003, 2005, 2008 Maciej W. Rozycki
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 *
16 * WARNING! All this information is pure guesswork based on the
17 * ROM. It is provided here in hope it will give someone some
18 * food for thought. No documentation for the KN05 nor the KN04
19 * module has been located so far.
20 */
21#ifndef __ASM_MIPS_DEC_KN05_H
22#define __ASM_MIPS_DEC_KN05_H
23
24#include <asm/dec/ioasic_addrs.h>
25
26/*
27 * The oncard MB (Memory Buffer) ASIC provides an additional address
28 * decoder. Certain address ranges within the "high" 16 slots are
29 * passed to the I/O ASIC's decoder like with the KN03 or KN02-BA/CA.
30 * Others are handled locally. "Low" slots are always passed.
31 */
32#define KN4K_SLOT_BASE 0x1fc00000
33
34#define KN4K_MB_ROM (0*IOASIC_SLOT_SIZE) /* KN05/KN04 card ROM */
35#define KN4K_IOCTL (1*IOASIC_SLOT_SIZE) /* I/O ASIC */
36#define KN4K_ESAR (2*IOASIC_SLOT_SIZE) /* LANCE MAC address chip */
37#define KN4K_LANCE (3*IOASIC_SLOT_SIZE) /* LANCE Ethernet */
38#define KN4K_MB_INT (4*IOASIC_SLOT_SIZE) /* MB interrupt register */
39#define KN4K_MB_EA (5*IOASIC_SLOT_SIZE) /* MB error address? */
40#define KN4K_MB_EC (6*IOASIC_SLOT_SIZE) /* MB error ??? */
41#define KN4K_MB_CSR (7*IOASIC_SLOT_SIZE) /* MB control & status */
42#define KN4K_RES_08 (8*IOASIC_SLOT_SIZE) /* unused? */
43#define KN4K_RES_09 (9*IOASIC_SLOT_SIZE) /* unused? */
44#define KN4K_RES_10 (10*IOASIC_SLOT_SIZE) /* unused? */
45#define KN4K_RES_11 (11*IOASIC_SLOT_SIZE) /* unused? */
46#define KN4K_SCSI (12*IOASIC_SLOT_SIZE) /* ASC SCSI */
47#define KN4K_RES_13 (13*IOASIC_SLOT_SIZE) /* unused? */
48#define KN4K_RES_14 (14*IOASIC_SLOT_SIZE) /* unused? */
49#define KN4K_RES_15 (15*IOASIC_SLOT_SIZE) /* unused? */
50
51/*
52 * Bits for the MB interrupt register.
53 * The register appears read-only.
54 */
55#define KN4K_MB_INT_TC (1<<0) /* TURBOchannel? */
56#define KN4K_MB_INT_RTC (1<<1) /* RTC? */
57#define KN4K_MB_INT_MT (1<<3) /* I/O ASIC cascade */
58
59/*
60 * Bits for the MB control & status register.
61 * Set to 0x00bf8001 for KN05 and to 0x003f8000 for KN04 by the firmware.
62 */
63#define KN4K_MB_CSR_PF (1<<0) /* PreFetching enable? */
64#define KN4K_MB_CSR_F (1<<1) /* ??? */
65#define KN4K_MB_CSR_ECC (0xff<<2) /* ??? */
66#define KN4K_MB_CSR_OD (1<<10) /* ??? */
67#define KN4K_MB_CSR_CP (1<<11) /* ??? */
68#define KN4K_MB_CSR_UNC (1<<12) /* ??? */
69#define KN4K_MB_CSR_IM (1<<13) /* ??? */
70#define KN4K_MB_CSR_NC (1<<14) /* ??? */
71#define KN4K_MB_CSR_EE (1<<15) /* (bus) Exception Enable? */
72#define KN4K_MB_CSR_MSK (0x1f<<16) /* CPU Int[4:0] mask */
73#define KN4K_MB_CSR_FW (1<<21) /* ??? */
74#define KN4K_MB_CSR_W (1<<31) /* ??? */
75
76#endif /* __ASM_MIPS_DEC_KN05_H */
diff --git a/arch/mips/include/asm/dec/kn230.h b/arch/mips/include/asm/dec/kn230.h
new file mode 100644
index 000000000000..ff1bf17de8d8
--- /dev/null
+++ b/arch/mips/include/asm/dec/kn230.h
@@ -0,0 +1,26 @@
1/*
2 * include/asm-mips/dec/kn230.h
3 *
4 * DECsystem 5100 (MIPSmate or KN230) definitions.
5 *
6 * Copyright (C) 2002, 2003 Maciej W. Rozycki
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#ifndef __ASM_MIPS_DEC_KN230_H
14#define __ASM_MIPS_DEC_KN230_H
15
16/*
17 * CPU interrupt bits.
18 */
19#define KN230_CPU_INR_HALT 6 /* HALT button */
20#define KN230_CPU_INR_BUS 5 /* memory, I/O bus read/write errors */
21#define KN230_CPU_INR_RTC 4 /* DS1287 RTC */
22#define KN230_CPU_INR_SII 3 /* SII (DC7061) SCSI */
23#define KN230_CPU_INR_LANCE 3 /* LANCE (Am7990) Ethernet */
24#define KN230_CPU_INR_DZ11 2 /* DZ11 (DC7085) serial */
25
26#endif /* __ASM_MIPS_DEC_KN230_H */
diff --git a/arch/mips/include/asm/dec/machtype.h b/arch/mips/include/asm/dec/machtype.h
new file mode 100644
index 000000000000..a6ecdebc430a
--- /dev/null
+++ b/arch/mips/include/asm/dec/machtype.h
@@ -0,0 +1,27 @@
1/*
2 * Various machine type macros
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (c) 1998, 2000 Harald Koerfgen
9 */
10
11#ifndef __ASM_DEC_MACHTYPE_H
12#define __ASM_DEC_MACHTYPE_H
13
14#include <asm/bootinfo.h>
15
16#define TURBOCHANNEL (mips_machtype == MACH_DS5000_200 || \
17 mips_machtype == MACH_DS5000_1XX || \
18 mips_machtype == MACH_DS5000_XX || \
19 mips_machtype == MACH_DS5000_2X0 || \
20 mips_machtype == MACH_DS5900)
21
22#define IOASIC (mips_machtype == MACH_DS5000_1XX || \
23 mips_machtype == MACH_DS5000_XX || \
24 mips_machtype == MACH_DS5000_2X0 || \
25 mips_machtype == MACH_DS5900)
26
27#endif
diff --git a/arch/mips/include/asm/dec/prom.h b/arch/mips/include/asm/dec/prom.h
new file mode 100644
index 000000000000..b9c8203688d5
--- /dev/null
+++ b/arch/mips/include/asm/dec/prom.h
@@ -0,0 +1,174 @@
1/*
2 * include/asm-mips/dec/prom.h
3 *
4 * DECstation PROM interface.
5 *
6 * Copyright (C) 2002 Maciej W. Rozycki
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 *
13 * Based on arch/mips/dec/prom/prom.h by the Anonymous.
14 */
15#ifndef _ASM_DEC_PROM_H
16#define _ASM_DEC_PROM_H
17
18#include <linux/types.h>
19
20#include <asm/addrspace.h>
21
22/*
23 * PMAX/3MAX PROM entry points for DS2100/3100's and DS5000/2xx's.
24 * Many of these will work for MIPSen as well!
25 */
26#define VEC_RESET (u64 *)CKSEG1ADDR(0x1fc00000)
27 /* Prom base address */
28
29#define PMAX_PROM_ENTRY(x) (VEC_RESET + (x)) /* Prom jump table */
30
31#define PMAX_PROM_HALT PMAX_PROM_ENTRY(2) /* valid on MIPSen */
32#define PMAX_PROM_AUTOBOOT PMAX_PROM_ENTRY(5) /* valid on MIPSen */
33#define PMAX_PROM_OPEN PMAX_PROM_ENTRY(6)
34#define PMAX_PROM_READ PMAX_PROM_ENTRY(7)
35#define PMAX_PROM_CLOSE PMAX_PROM_ENTRY(10)
36#define PMAX_PROM_LSEEK PMAX_PROM_ENTRY(11)
37#define PMAX_PROM_GETCHAR PMAX_PROM_ENTRY(12)
38#define PMAX_PROM_PUTCHAR PMAX_PROM_ENTRY(13) /* 12 on MIPSen */
39#define PMAX_PROM_GETS PMAX_PROM_ENTRY(15)
40#define PMAX_PROM_PRINTF PMAX_PROM_ENTRY(17)
41#define PMAX_PROM_GETENV PMAX_PROM_ENTRY(33) /* valid on MIPSen */
42
43
44/*
45 * Magic number indicating REX PROM available on DECstation. Found in
46 * register a2 on transfer of control to program from PROM.
47 */
48#define REX_PROM_MAGIC 0x30464354
49
50#ifdef CONFIG_64BIT
51
52#define prom_is_rex(magic) 1 /* KN04 and KN05 are REX PROMs. */
53
54#else /* !CONFIG_64BIT */
55
56#define prom_is_rex(magic) ((magic) == REX_PROM_MAGIC)
57
58#endif /* !CONFIG_64BIT */
59
60
61/*
62 * 3MIN/MAXINE PROM entry points for DS5000/1xx's, DS5000/xx's and
63 * DS5000/2x0.
64 */
65#define REX_PROM_GETBITMAP 0x84/4 /* get mem bitmap */
66#define REX_PROM_GETCHAR 0x24/4 /* getch() */
67#define REX_PROM_GETENV 0x64/4 /* get env. variable */
68#define REX_PROM_GETSYSID 0x80/4 /* get system id */
69#define REX_PROM_GETTCINFO 0xa4/4
70#define REX_PROM_PRINTF 0x30/4 /* printf() */
71#define REX_PROM_SLOTADDR 0x6c/4 /* slotaddr */
72#define REX_PROM_BOOTINIT 0x54/4 /* open() */
73#define REX_PROM_BOOTREAD 0x58/4 /* read() */
74#define REX_PROM_CLEARCACHE 0x7c/4
75
76
77/*
78 * Used by rex_getbitmap().
79 */
80typedef struct {
81 int pagesize;
82 unsigned char bitmap[0];
83} memmap;
84
85
86/*
87 * Function pointers as read from a PROM's callback vector.
88 */
89extern int (*__rex_bootinit)(void);
90extern int (*__rex_bootread)(void);
91extern int (*__rex_getbitmap)(memmap *);
92extern unsigned long *(*__rex_slot_address)(int);
93extern void *(*__rex_gettcinfo)(void);
94extern int (*__rex_getsysid)(void);
95extern void (*__rex_clear_cache)(void);
96
97extern int (*__prom_getchar)(void);
98extern char *(*__prom_getenv)(char *);
99extern int (*__prom_printf)(char *, ...);
100
101extern int (*__pmax_open)(char*, int);
102extern int (*__pmax_lseek)(int, long, int);
103extern int (*__pmax_read)(int, void *, int);
104extern int (*__pmax_close)(int);
105
106
107#ifdef CONFIG_64BIT
108
109/*
110 * On MIPS64 we have to call PROM functions via a helper
111 * dispatcher to accomodate ABI incompatibilities.
112 */
113#define __DEC_PROM_O32(fun, arg) fun arg __asm__(#fun); \
114 __asm__(#fun " = call_o32")
115
116int __DEC_PROM_O32(_rex_bootinit, (int (*)(void)));
117int __DEC_PROM_O32(_rex_bootread, (int (*)(void)));
118int __DEC_PROM_O32(_rex_getbitmap, (int (*)(memmap *), memmap *));
119unsigned long *__DEC_PROM_O32(_rex_slot_address,
120 (unsigned long *(*)(int), int));
121void *__DEC_PROM_O32(_rex_gettcinfo, (void *(*)(void)));
122int __DEC_PROM_O32(_rex_getsysid, (int (*)(void)));
123void __DEC_PROM_O32(_rex_clear_cache, (void (*)(void)));
124
125int __DEC_PROM_O32(_prom_getchar, (int (*)(void)));
126char *__DEC_PROM_O32(_prom_getenv, (char *(*)(char *), char *));
127int __DEC_PROM_O32(_prom_printf, (int (*)(char *, ...), char *, ...));
128
129
130#define rex_bootinit() _rex_bootinit(__rex_bootinit)
131#define rex_bootread() _rex_bootread(__rex_bootread)
132#define rex_getbitmap(x) _rex_getbitmap(__rex_getbitmap, x)
133#define rex_slot_address(x) _rex_slot_address(__rex_slot_address, x)
134#define rex_gettcinfo() _rex_gettcinfo(__rex_gettcinfo)
135#define rex_getsysid() _rex_getsysid(__rex_getsysid)
136#define rex_clear_cache() _rex_clear_cache(__rex_clear_cache)
137
138#define prom_getchar() _prom_getchar(__prom_getchar)
139#define prom_getenv(x) _prom_getenv(__prom_getenv, x)
140#define prom_printf(x...) _prom_printf(__prom_printf, x)
141
142#else /* !CONFIG_64BIT */
143
144/*
145 * On plain MIPS we just call PROM functions directly.
146 */
147#define rex_bootinit __rex_bootinit
148#define rex_bootread __rex_bootread
149#define rex_getbitmap __rex_getbitmap
150#define rex_slot_address __rex_slot_address
151#define rex_gettcinfo __rex_gettcinfo
152#define rex_getsysid __rex_getsysid
153#define rex_clear_cache __rex_clear_cache
154
155#define prom_getchar __prom_getchar
156#define prom_getenv __prom_getenv
157#define prom_printf __prom_printf
158
159#define pmax_open __pmax_open
160#define pmax_lseek __pmax_lseek
161#define pmax_read __pmax_read
162#define pmax_close __pmax_close
163
164#endif /* !CONFIG_64BIT */
165
166
167extern void prom_meminit(u32);
168extern void prom_identify_arch(u32);
169extern void prom_init_cmdline(s32, s32 *, u32);
170
171extern void register_prom_console(void);
172extern void unregister_prom_console(void);
173
174#endif /* _ASM_DEC_PROM_H */
diff --git a/arch/mips/include/asm/dec/system.h b/arch/mips/include/asm/dec/system.h
new file mode 100644
index 000000000000..b2afaccd6831
--- /dev/null
+++ b/arch/mips/include/asm/dec/system.h
@@ -0,0 +1,19 @@
1/*
2 * include/asm-mips/dec/system.h
3 *
4 * Generic DECstation/DECsystem bits.
5 *
6 * Copyright (C) 2005, 2006 Maciej W. Rozycki
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#ifndef __ASM_DEC_SYSTEM_H
14#define __ASM_DEC_SYSTEM_H
15
16extern unsigned long dec_kn_slot_base, dec_kn_slot_size;
17extern int dec_tc_bus;
18
19#endif /* __ASM_DEC_SYSTEM_H */
diff --git a/arch/mips/include/asm/delay.h b/arch/mips/include/asm/delay.h
new file mode 100644
index 000000000000..b0bccd2c4ed5
--- /dev/null
+++ b/arch/mips/include/asm/delay.h
@@ -0,0 +1,112 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 by Waldorf Electronics
7 * Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 2007 Maciej W. Rozycki
10 */
11#ifndef _ASM_DELAY_H
12#define _ASM_DELAY_H
13
14#include <linux/param.h>
15#include <linux/smp.h>
16
17#include <asm/compiler.h>
18#include <asm/war.h>
19
20static inline void __delay(unsigned long loops)
21{
22 if (sizeof(long) == 4)
23 __asm__ __volatile__ (
24 " .set noreorder \n"
25 " .align 3 \n"
26 "1: bnez %0, 1b \n"
27 " subu %0, 1 \n"
28 " .set reorder \n"
29 : "=r" (loops)
30 : "0" (loops));
31 else if (sizeof(long) == 8 && !DADDI_WAR)
32 __asm__ __volatile__ (
33 " .set noreorder \n"
34 " .align 3 \n"
35 "1: bnez %0, 1b \n"
36 " dsubu %0, 1 \n"
37 " .set reorder \n"
38 : "=r" (loops)
39 : "0" (loops));
40 else if (sizeof(long) == 8 && DADDI_WAR)
41 __asm__ __volatile__ (
42 " .set noreorder \n"
43 " .align 3 \n"
44 "1: bnez %0, 1b \n"
45 " dsubu %0, %2 \n"
46 " .set reorder \n"
47 : "=r" (loops)
48 : "0" (loops), "r" (1));
49}
50
51
52/*
53 * Division by multiplication: you don't have to worry about
54 * loss of precision.
55 *
56 * Use only for very small delays ( < 1 msec). Should probably use a
57 * lookup table, really, as the multiplications take much too long with
58 * short delays. This is a "reasonable" implementation, though (and the
59 * first constant multiplications gets optimized away if the delay is
60 * a constant)
61 */
62
63static inline void __udelay(unsigned long usecs, unsigned long lpj)
64{
65 unsigned long hi, lo;
66
67 /*
68 * The rates of 128 is rounded wrongly by the catchall case
69 * for 64-bit. Excessive precission? Probably ...
70 */
71#if defined(CONFIG_64BIT) && (HZ == 128)
72 usecs *= 0x0008637bd05af6c7UL; /* 2**64 / (1000000 / HZ) */
73#elif defined(CONFIG_64BIT)
74 usecs *= (0x8000000000000000UL / (500000 / HZ));
75#else /* 32-bit junk follows here */
76 usecs *= (unsigned long) (((0x8000000000000000ULL / (500000 / HZ)) +
77 0x80000000ULL) >> 32);
78#endif
79
80 if (sizeof(long) == 4)
81 __asm__("multu\t%2, %3"
82 : "=h" (usecs), "=l" (lo)
83 : "r" (usecs), "r" (lpj)
84 : GCC_REG_ACCUM);
85 else if (sizeof(long) == 8 && !R4000_WAR)
86 __asm__("dmultu\t%2, %3"
87 : "=h" (usecs), "=l" (lo)
88 : "r" (usecs), "r" (lpj)
89 : GCC_REG_ACCUM);
90 else if (sizeof(long) == 8 && R4000_WAR)
91 __asm__("dmultu\t%3, %4\n\tmfhi\t%0"
92 : "=r" (usecs), "=h" (hi), "=l" (lo)
93 : "r" (usecs), "r" (lpj)
94 : GCC_REG_ACCUM);
95
96 __delay(usecs);
97}
98
99#define __udelay_val cpu_data[raw_smp_processor_id()].udelay_val
100
101#define udelay(usecs) __udelay((usecs), __udelay_val)
102
103/* make sure "usecs *= ..." in udelay do not overflow. */
104#if HZ >= 1000
105#define MAX_UDELAY_MS 1
106#elif HZ <= 200
107#define MAX_UDELAY_MS 5
108#else
109#define MAX_UDELAY_MS (1000 / HZ)
110#endif
111
112#endif /* _ASM_DELAY_H */
diff --git a/arch/mips/include/asm/device.h b/arch/mips/include/asm/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/arch/mips/include/asm/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/arch/mips/include/asm/div64.h b/arch/mips/include/asm/div64.h
new file mode 100644
index 000000000000..d1d699105c11
--- /dev/null
+++ b/arch/mips/include/asm/div64.h
@@ -0,0 +1,110 @@
1/*
2 * Copyright (C) 2000, 2004 Maciej W. Rozycki
3 * Copyright (C) 2003, 07 Ralf Baechle (ralf@linux-mips.org)
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9#ifndef _ASM_DIV64_H
10#define _ASM_DIV64_H
11
12#include <linux/types.h>
13
14#if (_MIPS_SZLONG == 32)
15
16#include <asm/compiler.h>
17
18/*
19 * No traps on overflows for any of these...
20 */
21
22#define do_div64_32(res, high, low, base) ({ \
23 unsigned long __quot32, __mod32; \
24 unsigned long __cf, __tmp, __tmp2, __i; \
25 \
26 __asm__(".set push\n\t" \
27 ".set noat\n\t" \
28 ".set noreorder\n\t" \
29 "move %2, $0\n\t" \
30 "move %3, $0\n\t" \
31 "b 1f\n\t" \
32 " li %4, 0x21\n" \
33 "0:\n\t" \
34 "sll $1, %0, 0x1\n\t" \
35 "srl %3, %0, 0x1f\n\t" \
36 "or %0, $1, %5\n\t" \
37 "sll %1, %1, 0x1\n\t" \
38 "sll %2, %2, 0x1\n" \
39 "1:\n\t" \
40 "bnez %3, 2f\n\t" \
41 " sltu %5, %0, %z6\n\t" \
42 "bnez %5, 3f\n" \
43 "2:\n\t" \
44 " addiu %4, %4, -1\n\t" \
45 "subu %0, %0, %z6\n\t" \
46 "addiu %2, %2, 1\n" \
47 "3:\n\t" \
48 "bnez %4, 0b\n\t" \
49 " srl %5, %1, 0x1f\n\t" \
50 ".set pop" \
51 : "=&r" (__mod32), "=&r" (__tmp), \
52 "=&r" (__quot32), "=&r" (__cf), \
53 "=&r" (__i), "=&r" (__tmp2) \
54 : "Jr" (base), "0" (high), "1" (low)); \
55 \
56 (res) = __quot32; \
57 __mod32; })
58
59#define do_div(n, base) ({ \
60 unsigned long long __quot; \
61 unsigned long __mod; \
62 unsigned long long __div; \
63 unsigned long __upper, __low, __high, __base; \
64 \
65 __div = (n); \
66 __base = (base); \
67 \
68 __high = __div >> 32; \
69 __low = __div; \
70 __upper = __high; \
71 \
72 if (__high) \
73 __asm__("divu $0, %z2, %z3" \
74 : "=h" (__upper), "=l" (__high) \
75 : "Jr" (__high), "Jr" (__base) \
76 : GCC_REG_ACCUM); \
77 \
78 __mod = do_div64_32(__low, __upper, __low, __base); \
79 \
80 __quot = __high; \
81 __quot = __quot << 32 | __low; \
82 (n) = __quot; \
83 __mod; })
84
85#endif /* (_MIPS_SZLONG == 32) */
86
87#if (_MIPS_SZLONG == 64)
88
89/*
90 * Hey, we're already 64-bit, no
91 * need to play games..
92 */
93#define do_div(n, base) ({ \
94 unsigned long __quot; \
95 unsigned int __mod; \
96 unsigned long __div; \
97 unsigned int __base; \
98 \
99 __div = (n); \
100 __base = (base); \
101 \
102 __mod = __div % __base; \
103 __quot = __div / __base; \
104 \
105 (n) = __quot; \
106 __mod; })
107
108#endif /* (_MIPS_SZLONG == 64) */
109
110#endif /* _ASM_DIV64_H */
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
new file mode 100644
index 000000000000..c64afb40cd06
--- /dev/null
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -0,0 +1,81 @@
1#ifndef _ASM_DMA_MAPPING_H
2#define _ASM_DMA_MAPPING_H
3
4#include <asm/scatterlist.h>
5#include <asm/cache.h>
6
7void *dma_alloc_noncoherent(struct device *dev, size_t size,
8 dma_addr_t *dma_handle, gfp_t flag);
9
10void dma_free_noncoherent(struct device *dev, size_t size,
11 void *vaddr, dma_addr_t dma_handle);
12
13void *dma_alloc_coherent(struct device *dev, size_t size,
14 dma_addr_t *dma_handle, gfp_t flag);
15
16void dma_free_coherent(struct device *dev, size_t size,
17 void *vaddr, dma_addr_t dma_handle);
18
19extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
20 enum dma_data_direction direction);
21extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
22 size_t size, enum dma_data_direction direction);
23extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
24 enum dma_data_direction direction);
25extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
26 unsigned long offset, size_t size, enum dma_data_direction direction);
27extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
28 size_t size, enum dma_data_direction direction);
29extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
30 int nhwentries, enum dma_data_direction direction);
31extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
32 size_t size, enum dma_data_direction direction);
33extern void dma_sync_single_for_device(struct device *dev,
34 dma_addr_t dma_handle, size_t size, enum dma_data_direction direction);
35extern void dma_sync_single_range_for_cpu(struct device *dev,
36 dma_addr_t dma_handle, unsigned long offset, size_t size,
37 enum dma_data_direction direction);
38extern void dma_sync_single_range_for_device(struct device *dev,
39 dma_addr_t dma_handle, unsigned long offset, size_t size,
40 enum dma_data_direction direction);
41extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
42 int nelems, enum dma_data_direction direction);
43extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
44 int nelems, enum dma_data_direction direction);
45extern int dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
46extern int dma_supported(struct device *dev, u64 mask);
47
48static inline int
49dma_set_mask(struct device *dev, u64 mask)
50{
51 if(!dev->dma_mask || !dma_supported(dev, mask))
52 return -EIO;
53
54 *dev->dma_mask = mask;
55
56 return 0;
57}
58
59static inline int
60dma_get_cache_alignment(void)
61{
62 /* XXX Largest on any MIPS */
63 return 128;
64}
65
66extern int dma_is_consistent(struct device *dev, dma_addr_t dma_addr);
67
68extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
69 enum dma_data_direction direction);
70
71#if 0
72#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
73
74extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
75 dma_addr_t device_addr, size_t size, int flags);
76extern void dma_release_declared_memory(struct device *dev);
77extern void * dma_mark_declared_memory_occupied(struct device *dev,
78 dma_addr_t device_addr, size_t size);
79#endif
80
81#endif /* _ASM_DMA_MAPPING_H */
diff --git a/arch/mips/include/asm/dma.h b/arch/mips/include/asm/dma.h
new file mode 100644
index 000000000000..1353c81065d1
--- /dev/null
+++ b/arch/mips/include/asm/dma.h
@@ -0,0 +1,315 @@
1/*
2 * linux/include/asm/dma.h: Defines for using and allocating dma channels.
3 * Written by Hennus Bergman, 1992.
4 * High DMA channel support & info by Hannu Savolainen
5 * and John Boyd, Nov. 1992.
6 *
7 * NOTE: all this is true *only* for ISA/EISA expansions on Mips boards
8 * and can only be used for expansion cards. Onboard DMA controllers, such
9 * as the R4030 on Jazz boards behave totally different!
10 */
11
12#ifndef _ASM_DMA_H
13#define _ASM_DMA_H
14
15#include <asm/io.h> /* need byte IO */
16#include <linux/spinlock.h> /* And spinlocks */
17#include <linux/delay.h>
18#include <asm/system.h>
19
20
21#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
22#define dma_outb outb_p
23#else
24#define dma_outb outb
25#endif
26
27#define dma_inb inb
28
29/*
30 * NOTES about DMA transfers:
31 *
32 * controller 1: channels 0-3, byte operations, ports 00-1F
33 * controller 2: channels 4-7, word operations, ports C0-DF
34 *
35 * - ALL registers are 8 bits only, regardless of transfer size
36 * - channel 4 is not used - cascades 1 into 2.
37 * - channels 0-3 are byte - addresses/counts are for physical bytes
38 * - channels 5-7 are word - addresses/counts are for physical words
39 * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
40 * - transfer count loaded to registers is 1 less than actual count
41 * - controller 2 offsets are all even (2x offsets for controller 1)
42 * - page registers for 5-7 don't use data bit 0, represent 128K pages
43 * - page registers for 0-3 use bit 0, represent 64K pages
44 *
45 * DMA transfers are limited to the lower 16MB of _physical_ memory.
46 * Note that addresses loaded into registers must be _physical_ addresses,
47 * not logical addresses (which may differ if paging is active).
48 *
49 * Address mapping for channels 0-3:
50 *
51 * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
52 * | ... | | ... | | ... |
53 * | ... | | ... | | ... |
54 * | ... | | ... | | ... |
55 * P7 ... P0 A7 ... A0 A7 ... A0
56 * | Page | Addr MSB | Addr LSB | (DMA registers)
57 *
58 * Address mapping for channels 5-7:
59 *
60 * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
61 * | ... | \ \ ... \ \ \ ... \ \
62 * | ... | \ \ ... \ \ \ ... \ (not used)
63 * | ... | \ \ ... \ \ \ ... \
64 * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
65 * | Page | Addr MSB | Addr LSB | (DMA registers)
66 *
67 * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
68 * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
69 * the hardware level, so odd-byte transfers aren't possible).
70 *
71 * Transfer count (_not # bytes_) is limited to 64K, represented as actual
72 * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
73 * and up to 128K bytes may be transferred on channels 5-7 in one operation.
74 *
75 */
76
77#ifndef CONFIG_GENERIC_ISA_DMA_SUPPORT_BROKEN
78#define MAX_DMA_CHANNELS 8
79#endif
80
81/*
82 * The maximum address in KSEG0 that we can perform a DMA transfer to on this
83 * platform. This describes only the PC style part of the DMA logic like on
84 * Deskstations or Acer PICA but not the much more versatile DMA logic used
85 * for the local devices on Acer PICA or Magnums.
86 */
87#if defined(CONFIG_SGI_IP22) || defined(CONFIG_SGI_IP28)
88/* don't care; ISA bus master won't work, ISA slave DMA supports 32bit addr */
89#define MAX_DMA_ADDRESS PAGE_OFFSET
90#else
91#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
92#endif
93#define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS))
94#define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT))
95
96/* 8237 DMA controllers */
97#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
98#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
99
100/* DMA controller registers */
101#define DMA1_CMD_REG 0x08 /* command register (w) */
102#define DMA1_STAT_REG 0x08 /* status register (r) */
103#define DMA1_REQ_REG 0x09 /* request register (w) */
104#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
105#define DMA1_MODE_REG 0x0B /* mode register (w) */
106#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
107#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
108#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
109#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
110#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
111
112#define DMA2_CMD_REG 0xD0 /* command register (w) */
113#define DMA2_STAT_REG 0xD0 /* status register (r) */
114#define DMA2_REQ_REG 0xD2 /* request register (w) */
115#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
116#define DMA2_MODE_REG 0xD6 /* mode register (w) */
117#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
118#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
119#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
120#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
121#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
122
123#define DMA_ADDR_0 0x00 /* DMA address registers */
124#define DMA_ADDR_1 0x02
125#define DMA_ADDR_2 0x04
126#define DMA_ADDR_3 0x06
127#define DMA_ADDR_4 0xC0
128#define DMA_ADDR_5 0xC4
129#define DMA_ADDR_6 0xC8
130#define DMA_ADDR_7 0xCC
131
132#define DMA_CNT_0 0x01 /* DMA count registers */
133#define DMA_CNT_1 0x03
134#define DMA_CNT_2 0x05
135#define DMA_CNT_3 0x07
136#define DMA_CNT_4 0xC2
137#define DMA_CNT_5 0xC6
138#define DMA_CNT_6 0xCA
139#define DMA_CNT_7 0xCE
140
141#define DMA_PAGE_0 0x87 /* DMA page registers */
142#define DMA_PAGE_1 0x83
143#define DMA_PAGE_2 0x81
144#define DMA_PAGE_3 0x82
145#define DMA_PAGE_5 0x8B
146#define DMA_PAGE_6 0x89
147#define DMA_PAGE_7 0x8A
148
149#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
150#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
151#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
152
153#define DMA_AUTOINIT 0x10
154
155extern spinlock_t dma_spin_lock;
156
157static __inline__ unsigned long claim_dma_lock(void)
158{
159 unsigned long flags;
160 spin_lock_irqsave(&dma_spin_lock, flags);
161 return flags;
162}
163
164static __inline__ void release_dma_lock(unsigned long flags)
165{
166 spin_unlock_irqrestore(&dma_spin_lock, flags);
167}
168
169/* enable/disable a specific DMA channel */
170static __inline__ void enable_dma(unsigned int dmanr)
171{
172 if (dmanr<=3)
173 dma_outb(dmanr, DMA1_MASK_REG);
174 else
175 dma_outb(dmanr & 3, DMA2_MASK_REG);
176}
177
178static __inline__ void disable_dma(unsigned int dmanr)
179{
180 if (dmanr<=3)
181 dma_outb(dmanr | 4, DMA1_MASK_REG);
182 else
183 dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
184}
185
186/* Clear the 'DMA Pointer Flip Flop'.
187 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
188 * Use this once to initialize the FF to a known state.
189 * After that, keep track of it. :-)
190 * --- In order to do that, the DMA routines below should ---
191 * --- only be used while holding the DMA lock ! ---
192 */
193static __inline__ void clear_dma_ff(unsigned int dmanr)
194{
195 if (dmanr<=3)
196 dma_outb(0, DMA1_CLEAR_FF_REG);
197 else
198 dma_outb(0, DMA2_CLEAR_FF_REG);
199}
200
201/* set mode (above) for a specific DMA channel */
202static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
203{
204 if (dmanr<=3)
205 dma_outb(mode | dmanr, DMA1_MODE_REG);
206 else
207 dma_outb(mode | (dmanr&3), DMA2_MODE_REG);
208}
209
210/* Set only the page register bits of the transfer address.
211 * This is used for successive transfers when we know the contents of
212 * the lower 16 bits of the DMA current address register, but a 64k boundary
213 * may have been crossed.
214 */
215static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
216{
217 switch(dmanr) {
218 case 0:
219 dma_outb(pagenr, DMA_PAGE_0);
220 break;
221 case 1:
222 dma_outb(pagenr, DMA_PAGE_1);
223 break;
224 case 2:
225 dma_outb(pagenr, DMA_PAGE_2);
226 break;
227 case 3:
228 dma_outb(pagenr, DMA_PAGE_3);
229 break;
230 case 5:
231 dma_outb(pagenr & 0xfe, DMA_PAGE_5);
232 break;
233 case 6:
234 dma_outb(pagenr & 0xfe, DMA_PAGE_6);
235 break;
236 case 7:
237 dma_outb(pagenr & 0xfe, DMA_PAGE_7);
238 break;
239 }
240}
241
242
243/* Set transfer address & page bits for specific DMA channel.
244 * Assumes dma flipflop is clear.
245 */
246static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
247{
248 set_dma_page(dmanr, a>>16);
249 if (dmanr <= 3) {
250 dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
251 dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
252 } else {
253 dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
254 dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
255 }
256}
257
258
259/* Set transfer size (max 64k for DMA0..3, 128k for DMA5..7) for
260 * a specific DMA channel.
261 * You must ensure the parameters are valid.
262 * NOTE: from a manual: "the number of transfers is one more
263 * than the initial word count"! This is taken into account.
264 * Assumes dma flip-flop is clear.
265 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
266 */
267static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
268{
269 count--;
270 if (dmanr <= 3) {
271 dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
272 dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
273 } else {
274 dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
275 dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
276 }
277}
278
279
280/* Get DMA residue count. After a DMA transfer, this
281 * should return zero. Reading this while a DMA transfer is
282 * still in progress will return unpredictable results.
283 * If called before the channel has been used, it may return 1.
284 * Otherwise, it returns the number of _bytes_ left to transfer.
285 *
286 * Assumes DMA flip-flop is clear.
287 */
288static __inline__ int get_dma_residue(unsigned int dmanr)
289{
290 unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
291 : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
292
293 /* using short to get 16-bit wrap around */
294 unsigned short count;
295
296 count = 1 + dma_inb(io_port);
297 count += dma_inb(io_port) << 8;
298
299 return (dmanr<=3)? count : (count<<1);
300}
301
302
303/* These are in kernel/dma.c: */
304extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */
305extern void free_dma(unsigned int dmanr); /* release it again */
306
307/* From PCI */
308
309#ifdef CONFIG_PCI
310extern int isa_dma_bridge_buggy;
311#else
312#define isa_dma_bridge_buggy (0)
313#endif
314
315#endif /* _ASM_DMA_H */
diff --git a/arch/mips/include/asm/ds1286.h b/arch/mips/include/asm/ds1286.h
new file mode 100644
index 000000000000..6983b6ff0af3
--- /dev/null
+++ b/arch/mips/include/asm/ds1286.h
@@ -0,0 +1,15 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Machine dependent access functions for RTC registers.
7 *
8 * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org)
9 */
10#ifndef _ASM_DS1286_H
11#define _ASM_DS1286_H
12
13#include <ds1286.h>
14
15#endif /* _ASM_DS1286_H */
diff --git a/arch/mips/include/asm/ds1287.h b/arch/mips/include/asm/ds1287.h
new file mode 100644
index 000000000000..ba1702e86931
--- /dev/null
+++ b/arch/mips/include/asm/ds1287.h
@@ -0,0 +1,27 @@
1/*
2 * DS1287 timer functions.
3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#ifndef __ASM_DS1287_H
21#define __ASM_DS1287_H
22
23extern int ds1287_timer_state(void);
24extern void ds1287_set_base_clock(unsigned int clock);
25extern int ds1287_clockevent_init(int irq);
26
27#endif
diff --git a/arch/mips/include/asm/dsp.h b/arch/mips/include/asm/dsp.h
new file mode 100644
index 000000000000..e9bfc0813c72
--- /dev/null
+++ b/arch/mips/include/asm/dsp.h
@@ -0,0 +1,85 @@
1/*
2 * Copyright (C) 2005 Mips Technologies
3 * Author: Chris Dearman, chris@mips.com derived from fpu.h
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#ifndef _ASM_DSP_H
11#define _ASM_DSP_H
12
13#include <asm/cpu.h>
14#include <asm/cpu-features.h>
15#include <asm/hazards.h>
16#include <asm/mipsregs.h>
17
18#define DSP_DEFAULT 0x00000000
19#define DSP_MASK 0x3ff
20
21#define __enable_dsp_hazard() \
22do { \
23 asm("_ehb"); \
24} while (0)
25
26static inline void __init_dsp(void)
27{
28 mthi1(0);
29 mtlo1(0);
30 mthi2(0);
31 mtlo2(0);
32 mthi3(0);
33 mtlo3(0);
34 wrdsp(DSP_DEFAULT, DSP_MASK);
35}
36
37static inline void init_dsp(void)
38{
39 if (cpu_has_dsp)
40 __init_dsp();
41}
42
43#define __save_dsp(tsk) \
44do { \
45 tsk->thread.dsp.dspr[0] = mfhi1(); \
46 tsk->thread.dsp.dspr[1] = mflo1(); \
47 tsk->thread.dsp.dspr[2] = mfhi2(); \
48 tsk->thread.dsp.dspr[3] = mflo2(); \
49 tsk->thread.dsp.dspr[4] = mfhi3(); \
50 tsk->thread.dsp.dspr[5] = mflo3(); \
51 tsk->thread.dsp.dspcontrol = rddsp(DSP_MASK); \
52} while (0)
53
54#define save_dsp(tsk) \
55do { \
56 if (cpu_has_dsp) \
57 __save_dsp(tsk); \
58} while (0)
59
60#define __restore_dsp(tsk) \
61do { \
62 mthi1(tsk->thread.dsp.dspr[0]); \
63 mtlo1(tsk->thread.dsp.dspr[1]); \
64 mthi2(tsk->thread.dsp.dspr[2]); \
65 mtlo2(tsk->thread.dsp.dspr[3]); \
66 mthi3(tsk->thread.dsp.dspr[4]); \
67 mtlo3(tsk->thread.dsp.dspr[5]); \
68 wrdsp(tsk->thread.dsp.dspcontrol, DSP_MASK); \
69} while (0)
70
71#define restore_dsp(tsk) \
72do { \
73 if (cpu_has_dsp) \
74 __restore_dsp(tsk); \
75} while (0)
76
77#define __get_dsp_regs(tsk) \
78({ \
79 if (tsk == current) \
80 __save_dsp(current); \
81 \
82 tsk->thread.dsp.dspr; \
83})
84
85#endif /* _ASM_DSP_H */
diff --git a/arch/mips/include/asm/edac.h b/arch/mips/include/asm/edac.h
new file mode 100644
index 000000000000..4da0c1fe30d9
--- /dev/null
+++ b/arch/mips/include/asm/edac.h
@@ -0,0 +1,34 @@
1#ifndef ASM_EDAC_H
2#define ASM_EDAC_H
3
4/* ECC atomic, DMA, SMP and interrupt safe scrub function */
5
6static inline void atomic_scrub(void *va, u32 size)
7{
8 unsigned long *virt_addr = va;
9 unsigned long temp;
10 u32 i;
11
12 for (i = 0; i < size / sizeof(unsigned long); i++) {
13 /*
14 * Very carefully read and write to memory atomically
15 * so we are interrupt, DMA and SMP safe.
16 *
17 * Intel: asm("lock; addl $0, %0"::"m"(*virt_addr));
18 */
19
20 __asm__ __volatile__ (
21 " .set mips2 \n"
22 "1: ll %0, %1 # atomic_scrub \n"
23 " addu %0, $0 \n"
24 " sc %0, %1 \n"
25 " beqz %0, 1b \n"
26 " .set mips0 \n"
27 : "=&r" (temp), "=m" (*virt_addr)
28 : "m" (*virt_addr));
29
30 virt_addr++;
31 }
32}
33
34#endif
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
new file mode 100644
index 000000000000..f69f7acba637
--- /dev/null
+++ b/arch/mips/include/asm/elf.h
@@ -0,0 +1,371 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Much of this is taken from binutils and GNU libc ...
7 */
8#ifndef _ASM_ELF_H
9#define _ASM_ELF_H
10
11
12/* ELF header e_flags defines. */
13/* MIPS architecture level. */
14#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
15#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
16#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
17#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
18#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
19#define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */
20#define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */
21#define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32 R2 code. */
22#define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64 R2 code. */
23
24/* The ABI of a file. */
25#define EF_MIPS_ABI_O32 0x00001000 /* O32 ABI. */
26#define EF_MIPS_ABI_O64 0x00002000 /* O32 extended for 64 bit. */
27
28#define PT_MIPS_REGINFO 0x70000000
29#define PT_MIPS_RTPROC 0x70000001
30#define PT_MIPS_OPTIONS 0x70000002
31
32/* Flags in the e_flags field of the header */
33#define EF_MIPS_NOREORDER 0x00000001
34#define EF_MIPS_PIC 0x00000002
35#define EF_MIPS_CPIC 0x00000004
36#define EF_MIPS_ABI2 0x00000020
37#define EF_MIPS_OPTIONS_FIRST 0x00000080
38#define EF_MIPS_32BITMODE 0x00000100
39#define EF_MIPS_ABI 0x0000f000
40#define EF_MIPS_ARCH 0xf0000000
41
42#define DT_MIPS_RLD_VERSION 0x70000001
43#define DT_MIPS_TIME_STAMP 0x70000002
44#define DT_MIPS_ICHECKSUM 0x70000003
45#define DT_MIPS_IVERSION 0x70000004
46#define DT_MIPS_FLAGS 0x70000005
47 #define RHF_NONE 0x00000000
48 #define RHF_HARDWAY 0x00000001
49 #define RHF_NOTPOT 0x00000002
50 #define RHF_SGI_ONLY 0x00000010
51#define DT_MIPS_BASE_ADDRESS 0x70000006
52#define DT_MIPS_CONFLICT 0x70000008
53#define DT_MIPS_LIBLIST 0x70000009
54#define DT_MIPS_LOCAL_GOTNO 0x7000000a
55#define DT_MIPS_CONFLICTNO 0x7000000b
56#define DT_MIPS_LIBLISTNO 0x70000010
57#define DT_MIPS_SYMTABNO 0x70000011
58#define DT_MIPS_UNREFEXTNO 0x70000012
59#define DT_MIPS_GOTSYM 0x70000013
60#define DT_MIPS_HIPAGENO 0x70000014
61#define DT_MIPS_RLD_MAP 0x70000016
62
63#define R_MIPS_NONE 0
64#define R_MIPS_16 1
65#define R_MIPS_32 2
66#define R_MIPS_REL32 3
67#define R_MIPS_26 4
68#define R_MIPS_HI16 5
69#define R_MIPS_LO16 6
70#define R_MIPS_GPREL16 7
71#define R_MIPS_LITERAL 8
72#define R_MIPS_GOT16 9
73#define R_MIPS_PC16 10
74#define R_MIPS_CALL16 11
75#define R_MIPS_GPREL32 12
76/* The remaining relocs are defined on Irix, although they are not
77 in the MIPS ELF ABI. */
78#define R_MIPS_UNUSED1 13
79#define R_MIPS_UNUSED2 14
80#define R_MIPS_UNUSED3 15
81#define R_MIPS_SHIFT5 16
82#define R_MIPS_SHIFT6 17
83#define R_MIPS_64 18
84#define R_MIPS_GOT_DISP 19
85#define R_MIPS_GOT_PAGE 20
86#define R_MIPS_GOT_OFST 21
87/*
88 * The following two relocation types are specified in the MIPS ABI
89 * conformance guide version 1.2 but not yet in the psABI.
90 */
91#define R_MIPS_GOTHI16 22
92#define R_MIPS_GOTLO16 23
93#define R_MIPS_SUB 24
94#define R_MIPS_INSERT_A 25
95#define R_MIPS_INSERT_B 26
96#define R_MIPS_DELETE 27
97#define R_MIPS_HIGHER 28
98#define R_MIPS_HIGHEST 29
99/*
100 * The following two relocation types are specified in the MIPS ABI
101 * conformance guide version 1.2 but not yet in the psABI.
102 */
103#define R_MIPS_CALLHI16 30
104#define R_MIPS_CALLLO16 31
105/*
106 * This range is reserved for vendor specific relocations.
107 */
108#define R_MIPS_LOVENDOR 100
109#define R_MIPS_HIVENDOR 127
110
111#define SHN_MIPS_ACCOMON 0xff00 /* Allocated common symbols */
112#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
113#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
114#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
115#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
116
117#define SHT_MIPS_LIST 0x70000000
118#define SHT_MIPS_CONFLICT 0x70000002
119#define SHT_MIPS_GPTAB 0x70000003
120#define SHT_MIPS_UCODE 0x70000004
121#define SHT_MIPS_DEBUG 0x70000005
122#define SHT_MIPS_REGINFO 0x70000006
123#define SHT_MIPS_PACKAGE 0x70000007
124#define SHT_MIPS_PACKSYM 0x70000008
125#define SHT_MIPS_RELD 0x70000009
126#define SHT_MIPS_IFACE 0x7000000b
127#define SHT_MIPS_CONTENT 0x7000000c
128#define SHT_MIPS_OPTIONS 0x7000000d
129#define SHT_MIPS_SHDR 0x70000010
130#define SHT_MIPS_FDESC 0x70000011
131#define SHT_MIPS_EXTSYM 0x70000012
132#define SHT_MIPS_DENSE 0x70000013
133#define SHT_MIPS_PDESC 0x70000014
134#define SHT_MIPS_LOCSYM 0x70000015
135#define SHT_MIPS_AUXSYM 0x70000016
136#define SHT_MIPS_OPTSYM 0x70000017
137#define SHT_MIPS_LOCSTR 0x70000018
138#define SHT_MIPS_LINE 0x70000019
139#define SHT_MIPS_RFDESC 0x7000001a
140#define SHT_MIPS_DELTASYM 0x7000001b
141#define SHT_MIPS_DELTAINST 0x7000001c
142#define SHT_MIPS_DELTACLASS 0x7000001d
143#define SHT_MIPS_DWARF 0x7000001e
144#define SHT_MIPS_DELTADECL 0x7000001f
145#define SHT_MIPS_SYMBOL_LIB 0x70000020
146#define SHT_MIPS_EVENTS 0x70000021
147#define SHT_MIPS_TRANSLATE 0x70000022
148#define SHT_MIPS_PIXIE 0x70000023
149#define SHT_MIPS_XLATE 0x70000024
150#define SHT_MIPS_XLATE_DEBUG 0x70000025
151#define SHT_MIPS_WHIRL 0x70000026
152#define SHT_MIPS_EH_REGION 0x70000027
153#define SHT_MIPS_XLATE_OLD 0x70000028
154#define SHT_MIPS_PDR_EXCEPTION 0x70000029
155
156#define SHF_MIPS_GPREL 0x10000000
157#define SHF_MIPS_MERGE 0x20000000
158#define SHF_MIPS_ADDR 0x40000000
159#define SHF_MIPS_STRING 0x80000000
160#define SHF_MIPS_NOSTRIP 0x08000000
161#define SHF_MIPS_LOCAL 0x04000000
162#define SHF_MIPS_NAMES 0x02000000
163#define SHF_MIPS_NODUPES 0x01000000
164
165#ifndef ELF_ARCH
166/* ELF register definitions */
167#define ELF_NGREG 45
168#define ELF_NFPREG 33
169
170typedef unsigned long elf_greg_t;
171typedef elf_greg_t elf_gregset_t[ELF_NGREG];
172
173typedef double elf_fpreg_t;
174typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
175
176#ifdef CONFIG_32BIT
177
178/*
179 * This is used to ensure we don't load something for the wrong architecture.
180 */
181#define elf_check_arch(hdr) \
182({ \
183 int __res = 1; \
184 struct elfhdr *__h = (hdr); \
185 \
186 if (__h->e_machine != EM_MIPS) \
187 __res = 0; \
188 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \
189 __res = 0; \
190 if ((__h->e_flags & EF_MIPS_ABI2) != 0) \
191 __res = 0; \
192 if (((__h->e_flags & EF_MIPS_ABI) != 0) && \
193 ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32)) \
194 __res = 0; \
195 \
196 __res; \
197})
198
199/*
200 * These are used to set parameters in the core dumps.
201 */
202#define ELF_CLASS ELFCLASS32
203
204#endif /* CONFIG_32BIT */
205
206#ifdef CONFIG_64BIT
207/*
208 * This is used to ensure we don't load something for the wrong architecture.
209 */
210#define elf_check_arch(hdr) \
211({ \
212 int __res = 1; \
213 struct elfhdr *__h = (hdr); \
214 \
215 if (__h->e_machine != EM_MIPS) \
216 __res = 0; \
217 if (__h->e_ident[EI_CLASS] != ELFCLASS64) \
218 __res = 0; \
219 \
220 __res; \
221})
222
223/*
224 * These are used to set parameters in the core dumps.
225 */
226#define ELF_CLASS ELFCLASS64
227
228#endif /* CONFIG_64BIT */
229
230/*
231 * These are used to set parameters in the core dumps.
232 */
233#ifdef __MIPSEB__
234#define ELF_DATA ELFDATA2MSB
235#elif __MIPSEL__
236#define ELF_DATA ELFDATA2LSB
237#endif
238#define ELF_ARCH EM_MIPS
239
240#endif /* !defined(ELF_ARCH) */
241
242struct mips_abi;
243
244extern struct mips_abi mips_abi;
245extern struct mips_abi mips_abi_32;
246extern struct mips_abi mips_abi_n32;
247
248#ifdef CONFIG_32BIT
249
250#define SET_PERSONALITY(ex, ibcs2) \
251do { \
252 if (ibcs2) \
253 set_personality(PER_SVR4); \
254 set_personality(PER_LINUX); \
255 \
256 current->thread.abi = &mips_abi; \
257} while (0)
258
259#endif /* CONFIG_32BIT */
260
261#ifdef CONFIG_64BIT
262
263#ifdef CONFIG_MIPS32_N32
264#define __SET_PERSONALITY32_N32() \
265 do { \
266 set_thread_flag(TIF_32BIT_ADDR); \
267 current->thread.abi = &mips_abi_n32; \
268 } while (0)
269#else
270#define __SET_PERSONALITY32_N32() \
271 do { } while (0)
272#endif
273
274#ifdef CONFIG_MIPS32_O32
275#define __SET_PERSONALITY32_O32() \
276 do { \
277 set_thread_flag(TIF_32BIT_REGS); \
278 set_thread_flag(TIF_32BIT_ADDR); \
279 current->thread.abi = &mips_abi_32; \
280 } while (0)
281#else
282#define __SET_PERSONALITY32_O32() \
283 do { } while (0)
284#endif
285
286#ifdef CONFIG_MIPS32_COMPAT
287#define __SET_PERSONALITY32(ex) \
288do { \
289 if ((((ex).e_flags & EF_MIPS_ABI2) != 0) && \
290 ((ex).e_flags & EF_MIPS_ABI) == 0) \
291 __SET_PERSONALITY32_N32(); \
292 else \
293 __SET_PERSONALITY32_O32(); \
294} while (0)
295#else
296#define __SET_PERSONALITY32(ex) do { } while (0)
297#endif
298
299#define SET_PERSONALITY(ex, ibcs2) \
300do { \
301 clear_thread_flag(TIF_32BIT_REGS); \
302 clear_thread_flag(TIF_32BIT_ADDR); \
303 \
304 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
305 __SET_PERSONALITY32(ex); \
306 else \
307 current->thread.abi = &mips_abi; \
308 \
309 if (ibcs2) \
310 set_personality(PER_SVR4); \
311 else if (current->personality != PER_LINUX32) \
312 set_personality(PER_LINUX); \
313} while (0)
314
315#endif /* CONFIG_64BIT */
316
317struct task_struct;
318
319extern void elf_dump_regs(elf_greg_t *, struct pt_regs *regs);
320extern int dump_task_regs(struct task_struct *, elf_gregset_t *);
321extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
322
323#define ELF_CORE_COPY_REGS(elf_regs, regs) \
324 elf_dump_regs((elf_greg_t *)&(elf_regs), regs);
325#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
326#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) \
327 dump_task_fpu(tsk, elf_fpregs)
328
329#define USE_ELF_CORE_DUMP
330#define ELF_EXEC_PAGESIZE PAGE_SIZE
331
332/* This yields a mask that user programs can use to figure out what
333 instruction set this cpu supports. This could be done in userspace,
334 but it's not easy, and we've already done it here. */
335
336#define ELF_HWCAP (0)
337
338/* This yields a string that ld.so will use to load implementation
339 specific libraries for optimization. This is more specific in
340 intent than poking at uname or /proc/cpuinfo.
341
342 For the moment, we have only optimizations for the Intel generations,
343 but that could change... */
344
345#define ELF_PLATFORM (NULL)
346
347/*
348 * See comments in asm-alpha/elf.h, this is the same thing
349 * on the MIPS.
350 */
351#define ELF_PLAT_INIT(_r, load_addr) do { \
352 _r->regs[1] = _r->regs[2] = _r->regs[3] = _r->regs[4] = 0; \
353 _r->regs[5] = _r->regs[6] = _r->regs[7] = _r->regs[8] = 0; \
354 _r->regs[9] = _r->regs[10] = _r->regs[11] = _r->regs[12] = 0; \
355 _r->regs[13] = _r->regs[14] = _r->regs[15] = _r->regs[16] = 0; \
356 _r->regs[17] = _r->regs[18] = _r->regs[19] = _r->regs[20] = 0; \
357 _r->regs[21] = _r->regs[22] = _r->regs[23] = _r->regs[24] = 0; \
358 _r->regs[25] = _r->regs[26] = _r->regs[27] = _r->regs[28] = 0; \
359 _r->regs[30] = _r->regs[31] = 0; \
360} while (0)
361
362/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
363 use of this is to invoke "./ld.so someprog" to test out a new version of
364 the loader. We need to make sure that it is out of the way of the program
365 that it will "exec", and that there is sufficient room for the brk. */
366
367#ifndef ELF_ET_DYN_BASE
368#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
369#endif
370
371#endif /* _ASM_ELF_H */
diff --git a/arch/mips/include/asm/emergency-restart.h b/arch/mips/include/asm/emergency-restart.h
new file mode 100644
index 000000000000..108d8c48e42e
--- /dev/null
+++ b/arch/mips/include/asm/emergency-restart.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_EMERGENCY_RESTART_H
2#define _ASM_EMERGENCY_RESTART_H
3
4#include <asm-generic/emergency-restart.h>
5
6#endif /* _ASM_EMERGENCY_RESTART_H */
diff --git a/arch/mips/include/asm/emma2rh/emma2rh.h b/arch/mips/include/asm/emma2rh/emma2rh.h
new file mode 100644
index 000000000000..6a1af0af51e3
--- /dev/null
+++ b/arch/mips/include/asm/emma2rh/emma2rh.h
@@ -0,0 +1,333 @@
1/*
2 * include/asm-mips/emma2rh/emma2rh.h
3 * This file is EMMA2RH common header.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006
6 *
7 * This file based on include/asm-mips/ddb5xxx/ddb5xxx.h
8 * Copyright 2001 MontaVista Software Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24#ifndef __ASM_EMMA2RH_EMMA2RH_H
25#define __ASM_EMMA2RH_EMMA2RH_H
26
27#include <irq.h>
28
29/*
30 * EMMA2RH registers
31 */
32#define REGBASE 0x10000000
33
34#define EMMA2RH_BHIF_STRAP_0 (0x000010+REGBASE)
35#define EMMA2RH_BHIF_INT_ST_0 (0x000030+REGBASE)
36#define EMMA2RH_BHIF_INT_ST_1 (0x000034+REGBASE)
37#define EMMA2RH_BHIF_INT_ST_2 (0x000038+REGBASE)
38#define EMMA2RH_BHIF_INT_EN_0 (0x000040+REGBASE)
39#define EMMA2RH_BHIF_INT_EN_1 (0x000044+REGBASE)
40#define EMMA2RH_BHIF_INT_EN_2 (0x000048+REGBASE)
41#define EMMA2RH_BHIF_INT1_EN_0 (0x000050+REGBASE)
42#define EMMA2RH_BHIF_INT1_EN_1 (0x000054+REGBASE)
43#define EMMA2RH_BHIF_INT1_EN_2 (0x000058+REGBASE)
44#define EMMA2RH_BHIF_SW_INT (0x000070+REGBASE)
45#define EMMA2RH_BHIF_SW_INT_EN (0x000080+REGBASE)
46#define EMMA2RH_BHIF_SW_INT_CLR (0x000090+REGBASE)
47#define EMMA2RH_BHIF_MAIN_CTRL (0x0000b4+REGBASE)
48#define EMMA2RH_BHIF_EXCEPT_VECT_BASE_ADDRESS (0x0000c0+REGBASE)
49#define EMMA2RH_GPIO_DIR (0x110d20+REGBASE)
50#define EMMA2RH_GPIO_INT_ST (0x110d30+REGBASE)
51#define EMMA2RH_GPIO_INT_MASK (0x110d3c+REGBASE)
52#define EMMA2RH_GPIO_INT_MODE (0x110d48+REGBASE)
53#define EMMA2RH_GPIO_INT_CND_A (0x110d54+REGBASE)
54#define EMMA2RH_GPIO_INT_CND_B (0x110d60+REGBASE)
55#define EMMA2RH_PBRD_INT_EN (0x100010+REGBASE)
56#define EMMA2RH_PBRD_CLKSEL (0x100028+REGBASE)
57#define EMMA2RH_PFUR0_BASE (0x101000+REGBASE)
58#define EMMA2RH_PFUR1_BASE (0x102000+REGBASE)
59#define EMMA2RH_PFUR2_BASE (0x103000+REGBASE)
60#define EMMA2RH_PIIC0_BASE (0x107000+REGBASE)
61#define EMMA2RH_PIIC1_BASE (0x108000+REGBASE)
62#define EMMA2RH_PIIC2_BASE (0x109000+REGBASE)
63#define EMMA2RH_PCI_CONTROL (0x200000+REGBASE)
64#define EMMA2RH_PCI_ARBIT_CTR (0x200004+REGBASE)
65#define EMMA2RH_PCI_IWIN0_CTR (0x200010+REGBASE)
66#define EMMA2RH_PCI_IWIN1_CTR (0x200014+REGBASE)
67#define EMMA2RH_PCI_INIT_ESWP (0x200018+REGBASE)
68#define EMMA2RH_PCI_INT (0x200020+REGBASE)
69#define EMMA2RH_PCI_INT_EN (0x200024+REGBASE)
70#define EMMA2RH_PCI_TWIN_CTR (0x200030+REGBASE)
71#define EMMA2RH_PCI_TWIN_BADR (0x200034+REGBASE)
72#define EMMA2RH_PCI_TWIN0_DADR (0x200038+REGBASE)
73#define EMMA2RH_PCI_TWIN1_DADR (0x20003c+REGBASE)
74
75/*
76 * Memory map (physical address)
77 *
78 * Note most of the following address must be properly aligned by the
79 * corresponding size. For example, if PCI_IO_SIZE is 16MB, then
80 * PCI_IO_BASE must be aligned along 16MB boundary.
81 */
82
83/* the actual ram size is detected at run-time */
84#define EMMA2RH_RAM_BASE 0x00000000
85#define EMMA2RH_RAM_SIZE 0x10000000 /* less than 256MB */
86
87#define EMMA2RH_IO_BASE 0x10000000
88#define EMMA2RH_IO_SIZE 0x01000000 /* 16 MB */
89
90#define EMMA2RH_GENERALIO_BASE 0x11000000
91#define EMMA2RH_GENERALIO_SIZE 0x01000000 /* 16 MB */
92
93#define EMMA2RH_PCI_IO_BASE 0x12000000
94#define EMMA2RH_PCI_IO_SIZE 0x02000000 /* 32 MB */
95
96#define EMMA2RH_PCI_MEM_BASE 0x14000000
97#define EMMA2RH_PCI_MEM_SIZE 0x08000000 /* 128 MB */
98
99#define EMMA2RH_ROM_BASE 0x1c000000
100#define EMMA2RH_ROM_SIZE 0x04000000 /* 64 MB */
101
102#define EMMA2RH_PCI_CONFIG_BASE EMMA2RH_PCI_IO_BASE
103#define EMMA2RH_PCI_CONFIG_SIZE EMMA2RH_PCI_IO_SIZE
104
105#define NUM_CPU_IRQ 8
106#define NUM_EMMA2RH_IRQ 96
107
108#define CPU_EMMA2RH_CASCADE 2
109#define CPU_IRQ_BASE MIPS_CPU_IRQ_BASE
110#define EMMA2RH_IRQ_BASE (CPU_IRQ_BASE + NUM_CPU_IRQ)
111
112/*
113 * emma2rh irq defs
114 */
115
116#define EMMA2RH_IRQ_INT0 (0 + EMMA2RH_IRQ_BASE)
117#define EMMA2RH_IRQ_INT1 (1 + EMMA2RH_IRQ_BASE)
118#define EMMA2RH_IRQ_INT2 (2 + EMMA2RH_IRQ_BASE)
119#define EMMA2RH_IRQ_INT3 (3 + EMMA2RH_IRQ_BASE)
120#define EMMA2RH_IRQ_INT4 (4 + EMMA2RH_IRQ_BASE)
121#define EMMA2RH_IRQ_INT5 (5 + EMMA2RH_IRQ_BASE)
122#define EMMA2RH_IRQ_INT6 (6 + EMMA2RH_IRQ_BASE)
123#define EMMA2RH_IRQ_INT7 (7 + EMMA2RH_IRQ_BASE)
124#define EMMA2RH_IRQ_INT8 (8 + EMMA2RH_IRQ_BASE)
125#define EMMA2RH_IRQ_INT9 (9 + EMMA2RH_IRQ_BASE)
126#define EMMA2RH_IRQ_INT10 (10 + EMMA2RH_IRQ_BASE)
127#define EMMA2RH_IRQ_INT11 (11 + EMMA2RH_IRQ_BASE)
128#define EMMA2RH_IRQ_INT12 (12 + EMMA2RH_IRQ_BASE)
129#define EMMA2RH_IRQ_INT13 (13 + EMMA2RH_IRQ_BASE)
130#define EMMA2RH_IRQ_INT14 (14 + EMMA2RH_IRQ_BASE)
131#define EMMA2RH_IRQ_INT15 (15 + EMMA2RH_IRQ_BASE)
132#define EMMA2RH_IRQ_INT16 (16 + EMMA2RH_IRQ_BASE)
133#define EMMA2RH_IRQ_INT17 (17 + EMMA2RH_IRQ_BASE)
134#define EMMA2RH_IRQ_INT18 (18 + EMMA2RH_IRQ_BASE)
135#define EMMA2RH_IRQ_INT19 (19 + EMMA2RH_IRQ_BASE)
136#define EMMA2RH_IRQ_INT20 (20 + EMMA2RH_IRQ_BASE)
137#define EMMA2RH_IRQ_INT21 (21 + EMMA2RH_IRQ_BASE)
138#define EMMA2RH_IRQ_INT22 (22 + EMMA2RH_IRQ_BASE)
139#define EMMA2RH_IRQ_INT23 (23 + EMMA2RH_IRQ_BASE)
140#define EMMA2RH_IRQ_INT24 (24 + EMMA2RH_IRQ_BASE)
141#define EMMA2RH_IRQ_INT25 (25 + EMMA2RH_IRQ_BASE)
142#define EMMA2RH_IRQ_INT26 (26 + EMMA2RH_IRQ_BASE)
143#define EMMA2RH_IRQ_INT27 (27 + EMMA2RH_IRQ_BASE)
144#define EMMA2RH_IRQ_INT28 (28 + EMMA2RH_IRQ_BASE)
145#define EMMA2RH_IRQ_INT29 (29 + EMMA2RH_IRQ_BASE)
146#define EMMA2RH_IRQ_INT30 (30 + EMMA2RH_IRQ_BASE)
147#define EMMA2RH_IRQ_INT31 (31 + EMMA2RH_IRQ_BASE)
148#define EMMA2RH_IRQ_INT32 (32 + EMMA2RH_IRQ_BASE)
149#define EMMA2RH_IRQ_INT33 (33 + EMMA2RH_IRQ_BASE)
150#define EMMA2RH_IRQ_INT34 (34 + EMMA2RH_IRQ_BASE)
151#define EMMA2RH_IRQ_INT35 (35 + EMMA2RH_IRQ_BASE)
152#define EMMA2RH_IRQ_INT36 (36 + EMMA2RH_IRQ_BASE)
153#define EMMA2RH_IRQ_INT37 (37 + EMMA2RH_IRQ_BASE)
154#define EMMA2RH_IRQ_INT38 (38 + EMMA2RH_IRQ_BASE)
155#define EMMA2RH_IRQ_INT39 (39 + EMMA2RH_IRQ_BASE)
156#define EMMA2RH_IRQ_INT40 (40 + EMMA2RH_IRQ_BASE)
157#define EMMA2RH_IRQ_INT41 (41 + EMMA2RH_IRQ_BASE)
158#define EMMA2RH_IRQ_INT42 (42 + EMMA2RH_IRQ_BASE)
159#define EMMA2RH_IRQ_INT43 (43 + EMMA2RH_IRQ_BASE)
160#define EMMA2RH_IRQ_INT44 (44 + EMMA2RH_IRQ_BASE)
161#define EMMA2RH_IRQ_INT45 (45 + EMMA2RH_IRQ_BASE)
162#define EMMA2RH_IRQ_INT46 (46 + EMMA2RH_IRQ_BASE)
163#define EMMA2RH_IRQ_INT47 (47 + EMMA2RH_IRQ_BASE)
164#define EMMA2RH_IRQ_INT48 (48 + EMMA2RH_IRQ_BASE)
165#define EMMA2RH_IRQ_INT49 (49 + EMMA2RH_IRQ_BASE)
166#define EMMA2RH_IRQ_INT50 (50 + EMMA2RH_IRQ_BASE)
167#define EMMA2RH_IRQ_INT51 (51 + EMMA2RH_IRQ_BASE)
168#define EMMA2RH_IRQ_INT52 (52 + EMMA2RH_IRQ_BASE)
169#define EMMA2RH_IRQ_INT53 (53 + EMMA2RH_IRQ_BASE)
170#define EMMA2RH_IRQ_INT54 (54 + EMMA2RH_IRQ_BASE)
171#define EMMA2RH_IRQ_INT55 (55 + EMMA2RH_IRQ_BASE)
172#define EMMA2RH_IRQ_INT56 (56 + EMMA2RH_IRQ_BASE)
173#define EMMA2RH_IRQ_INT57 (57 + EMMA2RH_IRQ_BASE)
174#define EMMA2RH_IRQ_INT58 (58 + EMMA2RH_IRQ_BASE)
175#define EMMA2RH_IRQ_INT59 (59 + EMMA2RH_IRQ_BASE)
176#define EMMA2RH_IRQ_INT60 (60 + EMMA2RH_IRQ_BASE)
177#define EMMA2RH_IRQ_INT61 (61 + EMMA2RH_IRQ_BASE)
178#define EMMA2RH_IRQ_INT62 (62 + EMMA2RH_IRQ_BASE)
179#define EMMA2RH_IRQ_INT63 (63 + EMMA2RH_IRQ_BASE)
180
181#define EMMA2RH_IRQ_PFUR0 EMMA2RH_IRQ_INT49
182#define EMMA2RH_IRQ_PFUR1 EMMA2RH_IRQ_INT50
183#define EMMA2RH_IRQ_PFUR2 EMMA2RH_IRQ_INT51
184#define EMMA2RH_IRQ_PIIC0 EMMA2RH_IRQ_INT56
185#define EMMA2RH_IRQ_PIIC1 EMMA2RH_IRQ_INT57
186#define EMMA2RH_IRQ_PIIC2 EMMA2RH_IRQ_INT58
187
188/*
189 * EMMA2RH Register Access
190 */
191
192#define EMMA2RH_BASE (0xa0000000)
193
194static inline void emma2rh_sync(void)
195{
196 volatile u32 *p = (volatile u32 *)0xbfc00000;
197 (void)(*p);
198}
199
200static inline void emma2rh_out32(u32 offset, u32 val)
201{
202 *(volatile u32 *)(EMMA2RH_BASE | offset) = val;
203 emma2rh_sync();
204}
205
206static inline u32 emma2rh_in32(u32 offset)
207{
208 u32 val = *(volatile u32 *)(EMMA2RH_BASE | offset);
209 emma2rh_sync();
210 return val;
211}
212
213static inline void emma2rh_out16(u32 offset, u16 val)
214{
215 *(volatile u16 *)(EMMA2RH_BASE | offset) = val;
216 emma2rh_sync();
217}
218
219static inline u16 emma2rh_in16(u32 offset)
220{
221 u16 val = *(volatile u16 *)(EMMA2RH_BASE | offset);
222 emma2rh_sync();
223 return val;
224}
225
226static inline void emma2rh_out8(u32 offset, u8 val)
227{
228 *(volatile u8 *)(EMMA2RH_BASE | offset) = val;
229 emma2rh_sync();
230}
231
232static inline u8 emma2rh_in8(u32 offset)
233{
234 u8 val = *(volatile u8 *)(EMMA2RH_BASE | offset);
235 emma2rh_sync();
236 return val;
237}
238
239/**
240 * IIC registers map
241 **/
242
243/*---------------------------------------------------------------------------*/
244/* CNT - Control register (00H R/W) */
245/*---------------------------------------------------------------------------*/
246#define SPT 0x00000001
247#define STT 0x00000002
248#define ACKE 0x00000004
249#define WTIM 0x00000008
250#define SPIE 0x00000010
251#define WREL 0x00000020
252#define LREL 0x00000040
253#define IICE 0x00000080
254#define CNT_RESERVED 0x000000ff /* reserved bit 0 */
255
256#define I2C_EMMA_START (IICE | STT)
257#define I2C_EMMA_STOP (IICE | SPT)
258#define I2C_EMMA_REPSTART I2C_EMMA_START
259
260/*---------------------------------------------------------------------------*/
261/* STA - Status register (10H Read) */
262/*---------------------------------------------------------------------------*/
263#define MSTS 0x00000080
264#define ALD 0x00000040
265#define EXC 0x00000020
266#define COI 0x00000010
267#define TRC 0x00000008
268#define ACKD 0x00000004
269#define STD 0x00000002
270#define SPD 0x00000001
271
272/*---------------------------------------------------------------------------*/
273/* CSEL - Clock select register (20H R/W) */
274/*---------------------------------------------------------------------------*/
275#define FCL 0x00000080
276#define ND50 0x00000040
277#define CLD 0x00000020
278#define DAD 0x00000010
279#define SMC 0x00000008
280#define DFC 0x00000004
281#define CL 0x00000003
282#define CSEL_RESERVED 0x000000ff /* reserved bit 0 */
283
284#define FAST397 0x0000008b
285#define FAST297 0x0000008a
286#define FAST347 0x0000000b
287#define FAST260 0x0000000a
288#define FAST130 0x00000008
289#define STANDARD108 0x00000083
290#define STANDARD83 0x00000082
291#define STANDARD95 0x00000003
292#define STANDARD73 0x00000002
293#define STANDARD36 0x00000001
294#define STANDARD71 0x00000000
295
296/*---------------------------------------------------------------------------*/
297/* SVA - Slave address register (30H R/W) */
298/*---------------------------------------------------------------------------*/
299#define SVA 0x000000fe
300
301/*---------------------------------------------------------------------------*/
302/* SHR - Shift register (40H R/W) */
303/*---------------------------------------------------------------------------*/
304#define SR 0x000000ff
305
306/*---------------------------------------------------------------------------*/
307/* INT - Interrupt register (50H R/W) */
308/* INTM - Interrupt mask register (60H R/W) */
309/*---------------------------------------------------------------------------*/
310#define INTE0 0x00000001
311
312/***********************************************************************
313 * I2C registers
314 ***********************************************************************
315 */
316#define I2C_EMMA_CNT 0x00
317#define I2C_EMMA_STA 0x10
318#define I2C_EMMA_CSEL 0x20
319#define I2C_EMMA_SVA 0x30
320#define I2C_EMMA_SHR 0x40
321#define I2C_EMMA_INT 0x50
322#define I2C_EMMA_INTM 0x60
323
324/*
325 * include the board dependent part
326 */
327#if defined(CONFIG_MARKEINS)
328#include <asm/emma2rh/markeins.h>
329#else
330#error "Unknown EMMA2RH board!"
331#endif
332
333#endif /* __ASM_EMMA2RH_EMMA2RH_H */
diff --git a/arch/mips/include/asm/emma2rh/markeins.h b/arch/mips/include/asm/emma2rh/markeins.h
new file mode 100644
index 000000000000..973b0628490d
--- /dev/null
+++ b/arch/mips/include/asm/emma2rh/markeins.h
@@ -0,0 +1,75 @@
1/*
2 * include/asm-mips/emma2rh/markeins.h
3 * This file is EMMA2RH board depended header.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006
6 *
7 * This file based on include/asm-mips/ddb5xxx/ddb5xxx.h
8 * Copyright 2001 MontaVista Software Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#ifndef MARKEINS_H
26#define MARKEINS_H
27
28#define NUM_EMMA2RH_IRQ_SW 32
29#define NUM_EMMA2RH_IRQ_GPIO 32
30
31#define EMMA2RH_SW_CASCADE (EMMA2RH_IRQ_INT7 - EMMA2RH_IRQ_INT0)
32#define EMMA2RH_GPIO_CASCADE (EMMA2RH_IRQ_INT46 - EMMA2RH_IRQ_INT0)
33
34#define EMMA2RH_SW_IRQ_BASE (EMMA2RH_IRQ_BASE + NUM_EMMA2RH_IRQ)
35#define EMMA2RH_GPIO_IRQ_BASE (EMMA2RH_SW_IRQ_BASE + NUM_EMMA2RH_IRQ_SW)
36
37#define EMMA2RH_SW_IRQ_INT0 (0+EMMA2RH_SW_IRQ_BASE)
38#define EMMA2RH_SW_IRQ_INT1 (1+EMMA2RH_SW_IRQ_BASE)
39#define EMMA2RH_SW_IRQ_INT2 (2+EMMA2RH_SW_IRQ_BASE)
40#define EMMA2RH_SW_IRQ_INT3 (3+EMMA2RH_SW_IRQ_BASE)
41#define EMMA2RH_SW_IRQ_INT4 (4+EMMA2RH_SW_IRQ_BASE)
42#define EMMA2RH_SW_IRQ_INT5 (5+EMMA2RH_SW_IRQ_BASE)
43#define EMMA2RH_SW_IRQ_INT6 (6+EMMA2RH_SW_IRQ_BASE)
44#define EMMA2RH_SW_IRQ_INT7 (7+EMMA2RH_SW_IRQ_BASE)
45#define EMMA2RH_SW_IRQ_INT8 (8+EMMA2RH_SW_IRQ_BASE)
46#define EMMA2RH_SW_IRQ_INT9 (9+EMMA2RH_SW_IRQ_BASE)
47#define EMMA2RH_SW_IRQ_INT10 (10+EMMA2RH_SW_IRQ_BASE)
48#define EMMA2RH_SW_IRQ_INT11 (11+EMMA2RH_SW_IRQ_BASE)
49#define EMMA2RH_SW_IRQ_INT12 (12+EMMA2RH_SW_IRQ_BASE)
50#define EMMA2RH_SW_IRQ_INT13 (13+EMMA2RH_SW_IRQ_BASE)
51#define EMMA2RH_SW_IRQ_INT14 (14+EMMA2RH_SW_IRQ_BASE)
52#define EMMA2RH_SW_IRQ_INT15 (15+EMMA2RH_SW_IRQ_BASE)
53#define EMMA2RH_SW_IRQ_INT16 (16+EMMA2RH_SW_IRQ_BASE)
54#define EMMA2RH_SW_IRQ_INT17 (17+EMMA2RH_SW_IRQ_BASE)
55#define EMMA2RH_SW_IRQ_INT18 (18+EMMA2RH_SW_IRQ_BASE)
56#define EMMA2RH_SW_IRQ_INT19 (19+EMMA2RH_SW_IRQ_BASE)
57#define EMMA2RH_SW_IRQ_INT20 (20+EMMA2RH_SW_IRQ_BASE)
58#define EMMA2RH_SW_IRQ_INT21 (21+EMMA2RH_SW_IRQ_BASE)
59#define EMMA2RH_SW_IRQ_INT22 (22+EMMA2RH_SW_IRQ_BASE)
60#define EMMA2RH_SW_IRQ_INT23 (23+EMMA2RH_SW_IRQ_BASE)
61#define EMMA2RH_SW_IRQ_INT24 (24+EMMA2RH_SW_IRQ_BASE)
62#define EMMA2RH_SW_IRQ_INT25 (25+EMMA2RH_SW_IRQ_BASE)
63#define EMMA2RH_SW_IRQ_INT26 (26+EMMA2RH_SW_IRQ_BASE)
64#define EMMA2RH_SW_IRQ_INT27 (27+EMMA2RH_SW_IRQ_BASE)
65#define EMMA2RH_SW_IRQ_INT28 (28+EMMA2RH_SW_IRQ_BASE)
66#define EMMA2RH_SW_IRQ_INT29 (29+EMMA2RH_SW_IRQ_BASE)
67#define EMMA2RH_SW_IRQ_INT30 (30+EMMA2RH_SW_IRQ_BASE)
68#define EMMA2RH_SW_IRQ_INT31 (31+EMMA2RH_SW_IRQ_BASE)
69
70#define MARKEINS_PCI_IRQ_INTA EMMA2RH_GPIO_IRQ_BASE+15
71#define MARKEINS_PCI_IRQ_INTB EMMA2RH_GPIO_IRQ_BASE+16
72#define MARKEINS_PCI_IRQ_INTC EMMA2RH_GPIO_IRQ_BASE+17
73#define MARKEINS_PCI_IRQ_INTD EMMA2RH_GPIO_IRQ_BASE+18
74
75#endif /* CONFIG_MARKEINS */
diff --git a/arch/mips/include/asm/errno.h b/arch/mips/include/asm/errno.h
new file mode 100644
index 000000000000..3c0d840e4577
--- /dev/null
+++ b/arch/mips/include/asm/errno.h
@@ -0,0 +1,131 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1999, 2001, 2002 by Ralf Baechle
7 */
8#ifndef _ASM_ERRNO_H
9#define _ASM_ERRNO_H
10
11/*
12 * These error numbers are intended to be MIPS ABI compatible
13 */
14
15#include <asm-generic/errno-base.h>
16
17#define ENOMSG 35 /* No message of desired type */
18#define EIDRM 36 /* Identifier removed */
19#define ECHRNG 37 /* Channel number out of range */
20#define EL2NSYNC 38 /* Level 2 not synchronized */
21#define EL3HLT 39 /* Level 3 halted */
22#define EL3RST 40 /* Level 3 reset */
23#define ELNRNG 41 /* Link number out of range */
24#define EUNATCH 42 /* Protocol driver not attached */
25#define ENOCSI 43 /* No CSI structure available */
26#define EL2HLT 44 /* Level 2 halted */
27#define EDEADLK 45 /* Resource deadlock would occur */
28#define ENOLCK 46 /* No record locks available */
29#define EBADE 50 /* Invalid exchange */
30#define EBADR 51 /* Invalid request descriptor */
31#define EXFULL 52 /* Exchange full */
32#define ENOANO 53 /* No anode */
33#define EBADRQC 54 /* Invalid request code */
34#define EBADSLT 55 /* Invalid slot */
35#define EDEADLOCK 56 /* File locking deadlock error */
36#define EBFONT 59 /* Bad font file format */
37#define ENOSTR 60 /* Device not a stream */
38#define ENODATA 61 /* No data available */
39#define ETIME 62 /* Timer expired */
40#define ENOSR 63 /* Out of streams resources */
41#define ENONET 64 /* Machine is not on the network */
42#define ENOPKG 65 /* Package not installed */
43#define EREMOTE 66 /* Object is remote */
44#define ENOLINK 67 /* Link has been severed */
45#define EADV 68 /* Advertise error */
46#define ESRMNT 69 /* Srmount error */
47#define ECOMM 70 /* Communication error on send */
48#define EPROTO 71 /* Protocol error */
49#define EDOTDOT 73 /* RFS specific error */
50#define EMULTIHOP 74 /* Multihop attempted */
51#define EBADMSG 77 /* Not a data message */
52#define ENAMETOOLONG 78 /* File name too long */
53#define EOVERFLOW 79 /* Value too large for defined data type */
54#define ENOTUNIQ 80 /* Name not unique on network */
55#define EBADFD 81 /* File descriptor in bad state */
56#define EREMCHG 82 /* Remote address changed */
57#define ELIBACC 83 /* Can not access a needed shared library */
58#define ELIBBAD 84 /* Accessing a corrupted shared library */
59#define ELIBSCN 85 /* .lib section in a.out corrupted */
60#define ELIBMAX 86 /* Attempting to link in too many shared libraries */
61#define ELIBEXEC 87 /* Cannot exec a shared library directly */
62#define EILSEQ 88 /* Illegal byte sequence */
63#define ENOSYS 89 /* Function not implemented */
64#define ELOOP 90 /* Too many symbolic links encountered */
65#define ERESTART 91 /* Interrupted system call should be restarted */
66#define ESTRPIPE 92 /* Streams pipe error */
67#define ENOTEMPTY 93 /* Directory not empty */
68#define EUSERS 94 /* Too many users */
69#define ENOTSOCK 95 /* Socket operation on non-socket */
70#define EDESTADDRREQ 96 /* Destination address required */
71#define EMSGSIZE 97 /* Message too long */
72#define EPROTOTYPE 98 /* Protocol wrong type for socket */
73#define ENOPROTOOPT 99 /* Protocol not available */
74#define EPROTONOSUPPORT 120 /* Protocol not supported */
75#define ESOCKTNOSUPPORT 121 /* Socket type not supported */
76#define EOPNOTSUPP 122 /* Operation not supported on transport endpoint */
77#define EPFNOSUPPORT 123 /* Protocol family not supported */
78#define EAFNOSUPPORT 124 /* Address family not supported by protocol */
79#define EADDRINUSE 125 /* Address already in use */
80#define EADDRNOTAVAIL 126 /* Cannot assign requested address */
81#define ENETDOWN 127 /* Network is down */
82#define ENETUNREACH 128 /* Network is unreachable */
83#define ENETRESET 129 /* Network dropped connection because of reset */
84#define ECONNABORTED 130 /* Software caused connection abort */
85#define ECONNRESET 131 /* Connection reset by peer */
86#define ENOBUFS 132 /* No buffer space available */
87#define EISCONN 133 /* Transport endpoint is already connected */
88#define ENOTCONN 134 /* Transport endpoint is not connected */
89#define EUCLEAN 135 /* Structure needs cleaning */
90#define ENOTNAM 137 /* Not a XENIX named type file */
91#define ENAVAIL 138 /* No XENIX semaphores available */
92#define EISNAM 139 /* Is a named type file */
93#define EREMOTEIO 140 /* Remote I/O error */
94#define EINIT 141 /* Reserved */
95#define EREMDEV 142 /* Error 142 */
96#define ESHUTDOWN 143 /* Cannot send after transport endpoint shutdown */
97#define ETOOMANYREFS 144 /* Too many references: cannot splice */
98#define ETIMEDOUT 145 /* Connection timed out */
99#define ECONNREFUSED 146 /* Connection refused */
100#define EHOSTDOWN 147 /* Host is down */
101#define EHOSTUNREACH 148 /* No route to host */
102#define EWOULDBLOCK EAGAIN /* Operation would block */
103#define EALREADY 149 /* Operation already in progress */
104#define EINPROGRESS 150 /* Operation now in progress */
105#define ESTALE 151 /* Stale NFS file handle */
106#define ECANCELED 158 /* AIO operation canceled */
107
108/*
109 * These error are Linux extensions.
110 */
111#define ENOMEDIUM 159 /* No medium found */
112#define EMEDIUMTYPE 160 /* Wrong medium type */
113#define ENOKEY 161 /* Required key not available */
114#define EKEYEXPIRED 162 /* Key has expired */
115#define EKEYREVOKED 163 /* Key has been revoked */
116#define EKEYREJECTED 164 /* Key was rejected by service */
117
118/* for robust mutexes */
119#define EOWNERDEAD 165 /* Owner died */
120#define ENOTRECOVERABLE 166 /* State not recoverable */
121
122#define EDQUOT 1133 /* Quota exceeded */
123
124#ifdef __KERNEL__
125
126/* The biggest error number defined here or in <linux/errno.h>. */
127#define EMAXERRNO 1133
128
129#endif /* __KERNEL__ */
130
131#endif /* _ASM_ERRNO_H */
diff --git a/arch/mips/include/asm/fb.h b/arch/mips/include/asm/fb.h
new file mode 100644
index 000000000000..bd3f68c9ddfc
--- /dev/null
+++ b/arch/mips/include/asm/fb.h
@@ -0,0 +1,19 @@
1#ifndef _ASM_FB_H_
2#define _ASM_FB_H_
3
4#include <linux/fb.h>
5#include <linux/fs.h>
6#include <asm/page.h>
7
8static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
9 unsigned long off)
10{
11 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
12}
13
14static inline int fb_is_primary_device(struct fb_info *info)
15{
16 return 0;
17}
18
19#endif /* _ASM_FB_H_ */
diff --git a/arch/mips/include/asm/fcntl.h b/arch/mips/include/asm/fcntl.h
new file mode 100644
index 000000000000..2a52333a062d
--- /dev/null
+++ b/arch/mips/include/asm/fcntl.h
@@ -0,0 +1,61 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 96, 97, 98, 99, 2003, 05 Ralf Baechle
7 */
8#ifndef _ASM_FCNTL_H
9#define _ASM_FCNTL_H
10
11
12#define O_APPEND 0x0008
13#define O_SYNC 0x0010
14#define O_NONBLOCK 0x0080
15#define O_CREAT 0x0100 /* not fcntl */
16#define O_TRUNC 0x0200 /* not fcntl */
17#define O_EXCL 0x0400 /* not fcntl */
18#define O_NOCTTY 0x0800 /* not fcntl */
19#define FASYNC 0x1000 /* fcntl, for BSD compatibility */
20#define O_LARGEFILE 0x2000 /* allow large file opens */
21#define O_DIRECT 0x8000 /* direct disk access hint */
22
23#define F_GETLK 14
24#define F_SETLK 6
25#define F_SETLKW 7
26
27#define F_SETOWN 24 /* for sockets. */
28#define F_GETOWN 23 /* for sockets. */
29
30#ifndef __mips64
31#define F_GETLK64 33 /* using 'struct flock64' */
32#define F_SETLK64 34
33#define F_SETLKW64 35
34#endif
35
36/*
37 * The flavours of struct flock. "struct flock" is the ABI compliant
38 * variant. Finally struct flock64 is the LFS variant of struct flock. As
39 * a historic accident and inconsistence with the ABI definition it doesn't
40 * contain all the same fields as struct flock.
41 */
42
43#ifdef CONFIG_32BIT
44
45struct flock {
46 short l_type;
47 short l_whence;
48 off_t l_start;
49 off_t l_len;
50 long l_sysid;
51 __kernel_pid_t l_pid;
52 long pad[4];
53};
54
55#define HAVE_ARCH_STRUCT_FLOCK
56
57#endif /* CONFIG_32BIT */
58
59#include <asm-generic/fcntl.h>
60
61#endif /* _ASM_FCNTL_H */
diff --git a/arch/mips/include/asm/fixmap.h b/arch/mips/include/asm/fixmap.h
new file mode 100644
index 000000000000..9cc8522a394f
--- /dev/null
+++ b/arch/mips/include/asm/fixmap.h
@@ -0,0 +1,118 @@
1/*
2 * fixmap.h: compile-time virtual memory allocation
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1998 Ingo Molnar
9 *
10 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
11 */
12
13#ifndef _ASM_FIXMAP_H
14#define _ASM_FIXMAP_H
15
16#include <asm/page.h>
17#ifdef CONFIG_HIGHMEM
18#include <linux/threads.h>
19#include <asm/kmap_types.h>
20#endif
21
22/*
23 * Here we define all the compile-time 'special' virtual
24 * addresses. The point is to have a constant address at
25 * compile time, but to set the physical address only
26 * in the boot process. We allocate these special addresses
27 * from the end of virtual memory (0xfffff000) backwards.
28 * Also this lets us do fail-safe vmalloc(), we
29 * can guarantee that these special addresses and
30 * vmalloc()-ed addresses never overlap.
31 *
32 * these 'compile-time allocated' memory buffers are
33 * fixed-size 4k pages. (or larger if used with an increment
34 * highger than 1) use fixmap_set(idx,phys) to associate
35 * physical memory with fixmap indices.
36 *
37 * TLB entries of such buffers will not be flushed across
38 * task switches.
39 */
40
41/*
42 * on UP currently we will have no trace of the fixmap mechanizm,
43 * no page table allocations, etc. This might change in the
44 * future, say framebuffers for the console driver(s) could be
45 * fix-mapped?
46 */
47enum fixed_addresses {
48#define FIX_N_COLOURS 8
49 FIX_CMAP_BEGIN,
50#ifdef CONFIG_MIPS_MT_SMTC
51 FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS),
52#else
53 FIX_CMAP_END = FIX_CMAP_BEGIN + FIX_N_COLOURS,
54#endif
55#ifdef CONFIG_HIGHMEM
56 /* reserved pte's for temporary kernel mappings */
57 FIX_KMAP_BEGIN = FIX_CMAP_END + 1,
58 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
59#endif
60 __end_of_fixed_addresses
61};
62
63/*
64 * used by vmalloc.c.
65 *
66 * Leave one empty page between vmalloc'ed areas and
67 * the start of the fixmap, and leave one page empty
68 * at the top of mem..
69 */
70#if defined(CONFIG_CPU_TX39XX) || defined(CONFIG_CPU_TX49XX)
71#define FIXADDR_TOP ((unsigned long)(long)(int)(0xff000000 - 0x20000))
72#else
73#define FIXADDR_TOP ((unsigned long)(long)(int)0xfffe0000)
74#endif
75#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
76#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
77
78#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
79#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
80
81extern void __this_fixmap_does_not_exist(void);
82
83/*
84 * 'index to address' translation. If anyone tries to use the idx
85 * directly without tranlation, we catch the bug with a NULL-deference
86 * kernel oops. Illegal ranges of incoming indices are caught too.
87 */
88static inline unsigned long fix_to_virt(const unsigned int idx)
89{
90 /*
91 * this branch gets completely eliminated after inlining,
92 * except when someone tries to use fixaddr indices in an
93 * illegal way. (such as mixing up address types or using
94 * out-of-range indices).
95 *
96 * If it doesn't get removed, the linker will complain
97 * loudly with a reasonably clear error message..
98 */
99 if (idx >= __end_of_fixed_addresses)
100 __this_fixmap_does_not_exist();
101
102 return __fix_to_virt(idx);
103}
104
105static inline unsigned long virt_to_fix(const unsigned long vaddr)
106{
107 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
108 return __virt_to_fix(vaddr);
109}
110
111/*
112 * Called from pgtable_init()
113 */
114extern void fixrange_init(unsigned long start, unsigned long end,
115 pgd_t *pgd_base);
116
117
118#endif
diff --git a/arch/mips/include/asm/floppy.h b/arch/mips/include/asm/floppy.h
new file mode 100644
index 000000000000..992d232adc83
--- /dev/null
+++ b/arch/mips/include/asm/floppy.h
@@ -0,0 +1,56 @@
1/*
2 * Architecture specific parts of the Floppy driver
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1995 - 2000 Ralf Baechle
9 */
10#ifndef _ASM_FLOPPY_H
11#define _ASM_FLOPPY_H
12
13#include <linux/dma-mapping.h>
14
15static inline void fd_cacheflush(char * addr, long size)
16{
17 dma_cache_sync(NULL, addr, size, DMA_BIDIRECTIONAL);
18}
19
20#define MAX_BUFFER_SECTORS 24
21
22
23/*
24 * And on Mips's the CMOS info fails also ...
25 *
26 * FIXME: This information should come from the ARC configuration tree
27 * or whereever a particular machine has stored this ...
28 */
29#define FLOPPY0_TYPE fd_drive_type(0)
30#define FLOPPY1_TYPE fd_drive_type(1)
31
32#define FDC1 fd_getfdaddr1();
33
34#define N_FDC 1 /* do you *really* want a second controller? */
35#define N_DRIVE 8
36
37/*
38 * The DMA channel used by the floppy controller cannot access data at
39 * addresses >= 16MB
40 *
41 * Went back to the 1MB limit, as some people had problems with the floppy
42 * driver otherwise. It doesn't matter much for performance anyway, as most
43 * floppy accesses go through the track buffer.
44 *
45 * On MIPSes using vdma, this actually means that *all* transfers go thru
46 * the * track buffer since 0x1000000 is always smaller than KSEG0/1.
47 * Actually this needs to be a bit more complicated since the so much different
48 * hardware available with MIPS CPUs ...
49 */
50#define CROSS_64KB(a, s) ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64)
51
52#define EXTRA_FLOPPY_PARAMS
53
54#include <floppy.h>
55
56#endif /* _ASM_FLOPPY_H */
diff --git a/arch/mips/include/asm/fpregdef.h b/arch/mips/include/asm/fpregdef.h
new file mode 100644
index 000000000000..2b5fddc8f487
--- /dev/null
+++ b/arch/mips/include/asm/fpregdef.h
@@ -0,0 +1,99 @@
1/*
2 * Definitions for the FPU register names
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1995, 1999 Ralf Baechle
9 * Copyright (C) 1985 MIPS Computer Systems, Inc.
10 * Copyright (C) 1990 - 1992, 1999 Silicon Graphics, Inc.
11 */
12#ifndef _ASM_FPREGDEF_H
13#define _ASM_FPREGDEF_H
14
15#include <asm/sgidefs.h>
16
17#if _MIPS_SIM == _MIPS_SIM_ABI32
18
19/*
20 * These definitions only cover the R3000-ish 16/32 register model.
21 * But we're trying to be R3000 friendly anyway ...
22 */
23#define fv0 $f0 /* return value */
24#define fv0f $f1
25#define fv1 $f2
26#define fv1f $f3
27#define fa0 $f12 /* argument registers */
28#define fa0f $f13
29#define fa1 $f14
30#define fa1f $f15
31#define ft0 $f4 /* caller saved */
32#define ft0f $f5
33#define ft1 $f6
34#define ft1f $f7
35#define ft2 $f8
36#define ft2f $f9
37#define ft3 $f10
38#define ft3f $f11
39#define ft4 $f16
40#define ft4f $f17
41#define ft5 $f18
42#define ft5f $f19
43#define fs0 $f20 /* callee saved */
44#define fs0f $f21
45#define fs1 $f22
46#define fs1f $f23
47#define fs2 $f24
48#define fs2f $f25
49#define fs3 $f26
50#define fs3f $f27
51#define fs4 $f28
52#define fs4f $f29
53#define fs5 $f30
54#define fs5f $f31
55
56#define fcr31 $31 /* FPU status register */
57
58#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
59
60#if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
61
62#define fv0 $f0 /* return value */
63#define fv1 $f2
64#define fa0 $f12 /* argument registers */
65#define fa1 $f13
66#define fa2 $f14
67#define fa3 $f15
68#define fa4 $f16
69#define fa5 $f17
70#define fa6 $f18
71#define fa7 $f19
72#define ft0 $f4 /* caller saved */
73#define ft1 $f5
74#define ft2 $f6
75#define ft3 $f7
76#define ft4 $f8
77#define ft5 $f9
78#define ft6 $f10
79#define ft7 $f11
80#define ft8 $f20
81#define ft9 $f21
82#define ft10 $f22
83#define ft11 $f23
84#define ft12 $f1
85#define ft13 $f3
86#define fs0 $f24 /* callee saved */
87#define fs1 $f25
88#define fs2 $f26
89#define fs3 $f27
90#define fs4 $f28
91#define fs5 $f29
92#define fs6 $f30
93#define fs7 $f31
94
95#define fcr31 $31
96
97#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 */
98
99#endif /* _ASM_FPREGDEF_H */
diff --git a/arch/mips/include/asm/fpu.h b/arch/mips/include/asm/fpu.h
new file mode 100644
index 000000000000..8a3ef247659a
--- /dev/null
+++ b/arch/mips/include/asm/fpu.h
@@ -0,0 +1,153 @@
1/*
2 * Copyright (C) 2002 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
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#ifndef _ASM_FPU_H
11#define _ASM_FPU_H
12
13#include <linux/sched.h>
14#include <linux/thread_info.h>
15#include <linux/bitops.h>
16
17#include <asm/mipsregs.h>
18#include <asm/cpu.h>
19#include <asm/cpu-features.h>
20#include <asm/hazards.h>
21#include <asm/processor.h>
22#include <asm/current.h>
23
24#ifdef CONFIG_MIPS_MT_FPAFF
25#include <asm/mips_mt.h>
26#endif
27
28struct sigcontext;
29struct sigcontext32;
30
31extern asmlinkage int (*save_fp_context)(struct sigcontext __user *sc);
32extern asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc);
33
34extern asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc);
35extern asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *sc);
36
37extern void fpu_emulator_init_fpu(void);
38extern int fpu_emulator_save_context(struct sigcontext __user *sc);
39extern int fpu_emulator_restore_context(struct sigcontext __user *sc);
40extern void _init_fpu(void);
41extern void _save_fp(struct task_struct *);
42extern void _restore_fp(struct task_struct *);
43
44#define __enable_fpu() \
45do { \
46 set_c0_status(ST0_CU1); \
47 enable_fpu_hazard(); \
48} while (0)
49
50#define __disable_fpu() \
51do { \
52 clear_c0_status(ST0_CU1); \
53 disable_fpu_hazard(); \
54} while (0)
55
56#define enable_fpu() \
57do { \
58 if (cpu_has_fpu) \
59 __enable_fpu(); \
60} while (0)
61
62#define disable_fpu() \
63do { \
64 if (cpu_has_fpu) \
65 __disable_fpu(); \
66} while (0)
67
68
69#define clear_fpu_owner() clear_thread_flag(TIF_USEDFPU)
70
71static inline int __is_fpu_owner(void)
72{
73 return test_thread_flag(TIF_USEDFPU);
74}
75
76static inline int is_fpu_owner(void)
77{
78 return cpu_has_fpu && __is_fpu_owner();
79}
80
81static inline void __own_fpu(void)
82{
83 __enable_fpu();
84 KSTK_STATUS(current) |= ST0_CU1;
85 set_thread_flag(TIF_USEDFPU);
86}
87
88static inline void own_fpu_inatomic(int restore)
89{
90 if (cpu_has_fpu && !__is_fpu_owner()) {
91 __own_fpu();
92 if (restore)
93 _restore_fp(current);
94 }
95}
96
97static inline void own_fpu(int restore)
98{
99 preempt_disable();
100 own_fpu_inatomic(restore);
101 preempt_enable();
102}
103
104static inline void lose_fpu(int save)
105{
106 preempt_disable();
107 if (is_fpu_owner()) {
108 if (save)
109 _save_fp(current);
110 KSTK_STATUS(current) &= ~ST0_CU1;
111 clear_thread_flag(TIF_USEDFPU);
112 __disable_fpu();
113 }
114 preempt_enable();
115}
116
117static inline void init_fpu(void)
118{
119 preempt_disable();
120 if (cpu_has_fpu) {
121 __own_fpu();
122 _init_fpu();
123 } else {
124 fpu_emulator_init_fpu();
125 }
126 preempt_enable();
127}
128
129static inline void save_fp(struct task_struct *tsk)
130{
131 if (cpu_has_fpu)
132 _save_fp(tsk);
133}
134
135static inline void restore_fp(struct task_struct *tsk)
136{
137 if (cpu_has_fpu)
138 _restore_fp(tsk);
139}
140
141static inline fpureg_t *get_fpu_regs(struct task_struct *tsk)
142{
143 if (tsk == current) {
144 preempt_disable();
145 if (is_fpu_owner())
146 _save_fp(current);
147 preempt_enable();
148 }
149
150 return tsk->thread.fpu.fpr;
151}
152
153#endif /* _ASM_FPU_H */
diff --git a/arch/mips/include/asm/fpu_emulator.h b/arch/mips/include/asm/fpu_emulator.h
new file mode 100644
index 000000000000..2731c38bd7ae
--- /dev/null
+++ b/arch/mips/include/asm/fpu_emulator.h
@@ -0,0 +1,37 @@
1/*
2 * This program is free software; you can distribute it and/or modify it
3 * under the terms of the GNU General Public License (Version 2) as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope it will be useful, but WITHOUT
7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9 * for more details.
10 *
11 * You should have received a copy of the GNU General Public License along
12 * with this program; if not, write to the Free Software Foundation, Inc.,
13 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
14 *
15 * Further private data for which no space exists in mips_fpu_struct.
16 * This should be subsumed into the mips_fpu_struct structure as
17 * defined in processor.h as soon as the absurd wired absolute assembler
18 * offsets become dynamic at compile time.
19 *
20 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
21 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
22 */
23#ifndef _ASM_FPU_EMULATOR_H
24#define _ASM_FPU_EMULATOR_H
25
26struct mips_fpu_emulator_stats {
27 unsigned int emulated;
28 unsigned int loads;
29 unsigned int stores;
30 unsigned int cp1ops;
31 unsigned int cp1xops;
32 unsigned int errors;
33};
34
35extern struct mips_fpu_emulator_stats fpuemustats;
36
37#endif /* _ASM_FPU_EMULATOR_H */
diff --git a/arch/mips/include/asm/futex.h b/arch/mips/include/asm/futex.h
new file mode 100644
index 000000000000..b9cce90346cf
--- /dev/null
+++ b/arch/mips/include/asm/futex.h
@@ -0,0 +1,203 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2006 Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef _ASM_FUTEX_H
9#define _ASM_FUTEX_H
10
11#ifdef __KERNEL__
12
13#include <linux/futex.h>
14#include <linux/uaccess.h>
15#include <asm/barrier.h>
16#include <asm/errno.h>
17#include <asm/war.h>
18
19#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
20{ \
21 if (cpu_has_llsc && R10000_LLSC_WAR) { \
22 __asm__ __volatile__( \
23 " .set push \n" \
24 " .set noat \n" \
25 " .set mips3 \n" \
26 "1: ll %1, %4 # __futex_atomic_op \n" \
27 " .set mips0 \n" \
28 " " insn " \n" \
29 " .set mips3 \n" \
30 "2: sc $1, %2 \n" \
31 " beqzl $1, 1b \n" \
32 __WEAK_LLSC_MB \
33 "3: \n" \
34 " .set pop \n" \
35 " .set mips0 \n" \
36 " .section .fixup,\"ax\" \n" \
37 "4: li %0, %6 \n" \
38 " j 3b \n" \
39 " .previous \n" \
40 " .section __ex_table,\"a\" \n" \
41 " "__UA_ADDR "\t1b, 4b \n" \
42 " "__UA_ADDR "\t2b, 4b \n" \
43 " .previous \n" \
44 : "=r" (ret), "=&r" (oldval), "=R" (*uaddr) \
45 : "0" (0), "R" (*uaddr), "Jr" (oparg), "i" (-EFAULT) \
46 : "memory"); \
47 } else if (cpu_has_llsc) { \
48 __asm__ __volatile__( \
49 " .set push \n" \
50 " .set noat \n" \
51 " .set mips3 \n" \
52 "1: ll %1, %4 # __futex_atomic_op \n" \
53 " .set mips0 \n" \
54 " " insn " \n" \
55 " .set mips3 \n" \
56 "2: sc $1, %2 \n" \
57 " beqz $1, 1b \n" \
58 __WEAK_LLSC_MB \
59 "3: \n" \
60 " .set pop \n" \
61 " .set mips0 \n" \
62 " .section .fixup,\"ax\" \n" \
63 "4: li %0, %6 \n" \
64 " j 3b \n" \
65 " .previous \n" \
66 " .section __ex_table,\"a\" \n" \
67 " "__UA_ADDR "\t1b, 4b \n" \
68 " "__UA_ADDR "\t2b, 4b \n" \
69 " .previous \n" \
70 : "=r" (ret), "=&r" (oldval), "=R" (*uaddr) \
71 : "0" (0), "R" (*uaddr), "Jr" (oparg), "i" (-EFAULT) \
72 : "memory"); \
73 } else \
74 ret = -ENOSYS; \
75}
76
77static inline int
78futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
79{
80 int op = (encoded_op >> 28) & 7;
81 int cmp = (encoded_op >> 24) & 15;
82 int oparg = (encoded_op << 8) >> 20;
83 int cmparg = (encoded_op << 20) >> 20;
84 int oldval = 0, ret;
85 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
86 oparg = 1 << oparg;
87
88 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
89 return -EFAULT;
90
91 pagefault_disable();
92
93 switch (op) {
94 case FUTEX_OP_SET:
95 __futex_atomic_op("move $1, %z5", ret, oldval, uaddr, oparg);
96 break;
97
98 case FUTEX_OP_ADD:
99 __futex_atomic_op("addu $1, %1, %z5",
100 ret, oldval, uaddr, oparg);
101 break;
102 case FUTEX_OP_OR:
103 __futex_atomic_op("or $1, %1, %z5",
104 ret, oldval, uaddr, oparg);
105 break;
106 case FUTEX_OP_ANDN:
107 __futex_atomic_op("and $1, %1, %z5",
108 ret, oldval, uaddr, ~oparg);
109 break;
110 case FUTEX_OP_XOR:
111 __futex_atomic_op("xor $1, %1, %z5",
112 ret, oldval, uaddr, oparg);
113 break;
114 default:
115 ret = -ENOSYS;
116 }
117
118 pagefault_enable();
119
120 if (!ret) {
121 switch (cmp) {
122 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
123 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
124 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
125 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
126 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
127 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
128 default: ret = -ENOSYS;
129 }
130 }
131 return ret;
132}
133
134static inline int
135futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
136{
137 int retval;
138
139 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
140 return -EFAULT;
141
142 if (cpu_has_llsc && R10000_LLSC_WAR) {
143 __asm__ __volatile__(
144 "# futex_atomic_cmpxchg_inatomic \n"
145 " .set push \n"
146 " .set noat \n"
147 " .set mips3 \n"
148 "1: ll %0, %2 \n"
149 " bne %0, %z3, 3f \n"
150 " .set mips0 \n"
151 " move $1, %z4 \n"
152 " .set mips3 \n"
153 "2: sc $1, %1 \n"
154 " beqzl $1, 1b \n"
155 __WEAK_LLSC_MB
156 "3: \n"
157 " .set pop \n"
158 " .section .fixup,\"ax\" \n"
159 "4: li %0, %5 \n"
160 " j 3b \n"
161 " .previous \n"
162 " .section __ex_table,\"a\" \n"
163 " "__UA_ADDR "\t1b, 4b \n"
164 " "__UA_ADDR "\t2b, 4b \n"
165 " .previous \n"
166 : "=&r" (retval), "=R" (*uaddr)
167 : "R" (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT)
168 : "memory");
169 } else if (cpu_has_llsc) {
170 __asm__ __volatile__(
171 "# futex_atomic_cmpxchg_inatomic \n"
172 " .set push \n"
173 " .set noat \n"
174 " .set mips3 \n"
175 "1: ll %0, %2 \n"
176 " bne %0, %z3, 3f \n"
177 " .set mips0 \n"
178 " move $1, %z4 \n"
179 " .set mips3 \n"
180 "2: sc $1, %1 \n"
181 " beqz $1, 1b \n"
182 __WEAK_LLSC_MB
183 "3: \n"
184 " .set pop \n"
185 " .section .fixup,\"ax\" \n"
186 "4: li %0, %5 \n"
187 " j 3b \n"
188 " .previous \n"
189 " .section __ex_table,\"a\" \n"
190 " "__UA_ADDR "\t1b, 4b \n"
191 " "__UA_ADDR "\t2b, 4b \n"
192 " .previous \n"
193 : "=&r" (retval), "=R" (*uaddr)
194 : "R" (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT)
195 : "memory");
196 } else
197 return -ENOSYS;
198
199 return retval;
200}
201
202#endif
203#endif /* _ASM_FUTEX_H */
diff --git a/arch/mips/include/asm/fw/arc/hinv.h b/arch/mips/include/asm/fw/arc/hinv.h
new file mode 100644
index 000000000000..e6ff4add04e2
--- /dev/null
+++ b/arch/mips/include/asm/fw/arc/hinv.h
@@ -0,0 +1,175 @@
1/*
2 * ARCS hardware/memory inventory/configuration and system ID definitions.
3 */
4#ifndef _ASM_ARC_HINV_H
5#define _ASM_ARC_HINV_H
6
7#include <asm/sgidefs.h>
8#include <asm/fw/arc/types.h>
9
10/* configuration query defines */
11typedef enum configclass {
12 SystemClass,
13 ProcessorClass,
14 CacheClass,
15#ifndef _NT_PROM
16 MemoryClass,
17 AdapterClass,
18 ControllerClass,
19 PeripheralClass
20#else /* _NT_PROM */
21 AdapterClass,
22 ControllerClass,
23 PeripheralClass,
24 MemoryClass
25#endif /* _NT_PROM */
26} CONFIGCLASS;
27
28typedef enum configtype {
29 ARC,
30 CPU,
31 FPU,
32 PrimaryICache,
33 PrimaryDCache,
34 SecondaryICache,
35 SecondaryDCache,
36 SecondaryCache,
37#ifndef _NT_PROM
38 Memory,
39#endif
40 EISAAdapter,
41 TCAdapter,
42 SCSIAdapter,
43 DTIAdapter,
44 MultiFunctionAdapter,
45 DiskController,
46 TapeController,
47 CDROMController,
48 WORMController,
49 SerialController,
50 NetworkController,
51 DisplayController,
52 ParallelController,
53 PointerController,
54 KeyboardController,
55 AudioController,
56 OtherController,
57 DiskPeripheral,
58 FloppyDiskPeripheral,
59 TapePeripheral,
60 ModemPeripheral,
61 MonitorPeripheral,
62 PrinterPeripheral,
63 PointerPeripheral,
64 KeyboardPeripheral,
65 TerminalPeripheral,
66 LinePeripheral,
67 NetworkPeripheral,
68#ifdef _NT_PROM
69 Memory,
70#endif
71 OtherPeripheral,
72
73 /* new stuff for IP30 */
74 /* added without moving anything */
75 /* except ANONYMOUS. */
76
77 XTalkAdapter,
78 PCIAdapter,
79 GIOAdapter,
80 TPUAdapter,
81
82 Anonymous
83} CONFIGTYPE;
84
85typedef enum {
86 Failed = 1,
87 ReadOnly = 2,
88 Removable = 4,
89 ConsoleIn = 8,
90 ConsoleOut = 16,
91 Input = 32,
92 Output = 64
93} IDENTIFIERFLAG;
94
95#ifndef NULL /* for GetChild(NULL); */
96#define NULL 0
97#endif
98
99union key_u {
100 struct {
101#ifdef _MIPSEB
102 unsigned char c_bsize; /* block size in lines */
103 unsigned char c_lsize; /* line size in bytes/tag */
104 unsigned short c_size; /* cache size in 4K pages */
105#else /* _MIPSEL */
106 unsigned short c_size; /* cache size in 4K pages */
107 unsigned char c_lsize; /* line size in bytes/tag */
108 unsigned char c_bsize; /* block size in lines */
109#endif /* _MIPSEL */
110 } cache;
111 ULONG FullKey;
112};
113
114#if _MIPS_SIM == _MIPS_SIM_ABI64
115#define SGI_ARCS_VERS 64 /* sgi 64-bit version */
116#define SGI_ARCS_REV 0 /* rev .00 */
117#else
118#define SGI_ARCS_VERS 1 /* first version */
119#define SGI_ARCS_REV 10 /* rev .10, 3/04/92 */
120#endif
121
122typedef struct component {
123 CONFIGCLASS Class;
124 CONFIGTYPE Type;
125 IDENTIFIERFLAG Flags;
126 USHORT Version;
127 USHORT Revision;
128 ULONG Key;
129 ULONG AffinityMask;
130 ULONG ConfigurationDataSize;
131 ULONG IdentifierLength;
132 char *Identifier;
133} COMPONENT;
134
135/* internal structure that holds pathname parsing data */
136struct cfgdata {
137 char *name; /* full name */
138 int minlen; /* minimum length to match */
139 CONFIGTYPE type; /* type of token */
140};
141
142/* System ID */
143typedef struct systemid {
144 CHAR VendorId[8];
145 CHAR ProductId[8];
146} SYSTEMID;
147
148/* memory query functions */
149typedef enum memorytype {
150 ExceptionBlock,
151 SPBPage, /* ARCS == SystemParameterBlock */
152#ifndef _NT_PROM
153 FreeContiguous,
154 FreeMemory,
155 BadMemory,
156 LoadedProgram,
157 FirmwareTemporary,
158 FirmwarePermanent
159#else /* _NT_PROM */
160 FreeMemory,
161 BadMemory,
162 LoadedProgram,
163 FirmwareTemporary,
164 FirmwarePermanent,
165 FreeContiguous
166#endif /* _NT_PROM */
167} MEMORYTYPE;
168
169typedef struct memorydescriptor {
170 MEMORYTYPE Type;
171 LONG BasePage;
172 LONG PageCount;
173} MEMORYDESCRIPTOR;
174
175#endif /* _ASM_ARC_HINV_H */
diff --git a/arch/mips/include/asm/fw/arc/types.h b/arch/mips/include/asm/fw/arc/types.h
new file mode 100644
index 000000000000..b9adcd6f0860
--- /dev/null
+++ b/arch/mips/include/asm/fw/arc/types.h
@@ -0,0 +1,86 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright 1999 Ralf Baechle (ralf@gnu.org)
7 * Copyright 1999 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_ARC_TYPES_H
10#define _ASM_ARC_TYPES_H
11
12
13#ifdef CONFIG_ARC32
14
15typedef char CHAR;
16typedef short SHORT;
17typedef long LARGE_INTEGER __attribute__ ((__mode__ (__DI__)));
18typedef long LONG __attribute__ ((__mode__ (__SI__)));
19typedef unsigned char UCHAR;
20typedef unsigned short USHORT;
21typedef unsigned long ULONG __attribute__ ((__mode__ (__SI__)));
22typedef void VOID;
23
24/* The pointer types. Note that we're using a 64-bit compiler but all
25 pointer in the ARC structures are only 32-bit, so we need some disgusting
26 workarounds. Keep your vomit bag handy. */
27typedef LONG _PCHAR;
28typedef LONG _PSHORT;
29typedef LONG _PLARGE_INTEGER;
30typedef LONG _PLONG;
31typedef LONG _PUCHAR;
32typedef LONG _PUSHORT;
33typedef LONG _PULONG;
34typedef LONG _PVOID;
35
36#endif /* CONFIG_ARC32 */
37
38#ifdef CONFIG_ARC64
39
40typedef char CHAR;
41typedef short SHORT;
42typedef long LARGE_INTEGER __attribute__ ((__mode__ (__DI__)));
43typedef long LONG __attribute__ ((__mode__ (__DI__)));
44typedef unsigned char UCHAR;
45typedef unsigned short USHORT;
46typedef unsigned long ULONG __attribute__ ((__mode__ (__DI__)));
47typedef void VOID;
48
49/* The pointer types. We're 64-bit and the firmware is also 64-bit, so
50 live is sane ... */
51typedef CHAR *_PCHAR;
52typedef SHORT *_PSHORT;
53typedef LARGE_INTEGER *_PLARGE_INTEGER;
54typedef LONG *_PLONG;
55typedef UCHAR *_PUCHAR;
56typedef USHORT *_PUSHORT;
57typedef ULONG *_PULONG;
58typedef VOID *_PVOID;
59
60#endif /* CONFIG_ARC64 */
61
62typedef CHAR *PCHAR;
63typedef SHORT *PSHORT;
64typedef LARGE_INTEGER *PLARGE_INTEGER;
65typedef LONG *PLONG;
66typedef UCHAR *PUCHAR;
67typedef USHORT *PUSHORT;
68typedef ULONG *PULONG;
69typedef VOID *PVOID;
70
71/*
72 * Return type of ArcGetDisplayStatus()
73 */
74typedef struct {
75 USHORT CursorXPosition;
76 USHORT CursorYPosition;
77 USHORT CursorMaxXPosition;
78 USHORT CursorMaxYPosition;
79 USHORT ForegroundColor;
80 USHORT BackgroundColor;
81 UCHAR HighIntensity;
82 UCHAR Underscored;
83 UCHAR ReverseVideo;
84} DISPLAY_STATUS;
85
86#endif /* _ASM_ARC_TYPES_H */
diff --git a/arch/mips/include/asm/fw/cfe/cfe_api.h b/arch/mips/include/asm/fw/cfe/cfe_api.h
new file mode 100644
index 000000000000..0995575db320
--- /dev/null
+++ b/arch/mips/include/asm/fw/cfe/cfe_api.h
@@ -0,0 +1,122 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18/*
19 * Broadcom Common Firmware Environment (CFE)
20 *
21 * This file contains declarations for doing callbacks to
22 * cfe from an application. It should be the only header
23 * needed by the application to use this library
24 *
25 * Authors: Mitch Lichtenberg, Chris Demetriou
26 */
27#ifndef CFE_API_H
28#define CFE_API_H
29
30#include <linux/types.h>
31#include <linux/string.h>
32
33typedef long intptr_t;
34
35
36/*
37 * Constants
38 */
39
40/* Seal indicating CFE's presence, passed to user program. */
41#define CFE_EPTSEAL 0x43464531
42
43#define CFE_MI_RESERVED 0 /* memory is reserved, do not use */
44#define CFE_MI_AVAILABLE 1 /* memory is available */
45
46#define CFE_FLG_WARMSTART 0x00000001
47#define CFE_FLG_FULL_ARENA 0x00000001
48#define CFE_FLG_ENV_PERMANENT 0x00000001
49
50#define CFE_CPU_CMD_START 1
51#define CFE_CPU_CMD_STOP 0
52
53#define CFE_STDHANDLE_CONSOLE 0
54
55#define CFE_DEV_NETWORK 1
56#define CFE_DEV_DISK 2
57#define CFE_DEV_FLASH 3
58#define CFE_DEV_SERIAL 4
59#define CFE_DEV_CPU 5
60#define CFE_DEV_NVRAM 6
61#define CFE_DEV_CLOCK 7
62#define CFE_DEV_OTHER 8
63#define CFE_DEV_MASK 0x0F
64
65#define CFE_CACHE_FLUSH_D 1
66#define CFE_CACHE_INVAL_I 2
67#define CFE_CACHE_INVAL_D 4
68#define CFE_CACHE_INVAL_L2 8
69
70#define CFE_FWI_64BIT 0x00000001
71#define CFE_FWI_32BIT 0x00000002
72#define CFE_FWI_RELOC 0x00000004
73#define CFE_FWI_UNCACHED 0x00000008
74#define CFE_FWI_MULTICPU 0x00000010
75#define CFE_FWI_FUNCSIM 0x00000020
76#define CFE_FWI_RTLSIM 0x00000040
77
78typedef struct {
79 int64_t fwi_version; /* major, minor, eco version */
80 int64_t fwi_totalmem; /* total installed mem */
81 int64_t fwi_flags; /* various flags */
82 int64_t fwi_boardid; /* board ID */
83 int64_t fwi_bootarea_va; /* VA of boot area */
84 int64_t fwi_bootarea_pa; /* PA of boot area */
85 int64_t fwi_bootarea_size; /* size of boot area */
86} cfe_fwinfo_t;
87
88
89/*
90 * Defines and prototypes for functions which take no arguments.
91 */
92int64_t cfe_getticks(void);
93
94/*
95 * Defines and prototypes for the rest of the functions.
96 */
97int cfe_close(int handle);
98int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1);
99int cfe_cpu_stop(int cpu);
100int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen);
101int cfe_enummem(int idx, int flags, uint64_t * start, uint64_t * length,
102 uint64_t * type);
103int cfe_exit(int warm, int status);
104int cfe_flushcache(int flg);
105int cfe_getdevinfo(char *name);
106int cfe_getenv(char *name, char *dest, int destlen);
107int cfe_getfwinfo(cfe_fwinfo_t * info);
108int cfe_getstdhandle(int flg);
109int cfe_init(uint64_t handle, uint64_t ept);
110int cfe_inpstat(int handle);
111int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
112 int length, int *retlen, uint64_t offset);
113int cfe_open(char *name);
114int cfe_read(int handle, unsigned char *buffer, int length);
115int cfe_readblk(int handle, int64_t offset, unsigned char *buffer,
116 int length);
117int cfe_setenv(char *name, char *val);
118int cfe_write(int handle, unsigned char *buffer, int length);
119int cfe_writeblk(int handle, int64_t offset, unsigned char *buffer,
120 int length);
121
122#endif /* CFE_API_H */
diff --git a/arch/mips/include/asm/fw/cfe/cfe_error.h b/arch/mips/include/asm/fw/cfe/cfe_error.h
new file mode 100644
index 000000000000..b80374636279
--- /dev/null
+++ b/arch/mips/include/asm/fw/cfe/cfe_error.h
@@ -0,0 +1,80 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19/*
20 * Broadcom Common Firmware Environment (CFE)
21 *
22 * CFE's global error code list is here.
23 *
24 * Author: Mitch Lichtenberg
25 */
26
27#define CFE_OK 0
28#define CFE_ERR -1 /* generic error */
29#define CFE_ERR_INV_COMMAND -2
30#define CFE_ERR_EOF -3
31#define CFE_ERR_IOERR -4
32#define CFE_ERR_NOMEM -5
33#define CFE_ERR_DEVNOTFOUND -6
34#define CFE_ERR_DEVOPEN -7
35#define CFE_ERR_INV_PARAM -8
36#define CFE_ERR_ENVNOTFOUND -9
37#define CFE_ERR_ENVREADONLY -10
38
39#define CFE_ERR_NOTELF -11
40#define CFE_ERR_NOT32BIT -12
41#define CFE_ERR_WRONGENDIAN -13
42#define CFE_ERR_BADELFVERS -14
43#define CFE_ERR_NOTMIPS -15
44#define CFE_ERR_BADELFFMT -16
45#define CFE_ERR_BADADDR -17
46
47#define CFE_ERR_FILENOTFOUND -18
48#define CFE_ERR_UNSUPPORTED -19
49
50#define CFE_ERR_HOSTUNKNOWN -20
51
52#define CFE_ERR_TIMEOUT -21
53
54#define CFE_ERR_PROTOCOLERR -22
55
56#define CFE_ERR_NETDOWN -23
57#define CFE_ERR_NONAMESERVER -24
58
59#define CFE_ERR_NOHANDLES -25
60#define CFE_ERR_ALREADYBOUND -26
61
62#define CFE_ERR_CANNOTSET -27
63#define CFE_ERR_NOMORE -28
64#define CFE_ERR_BADFILESYS -29
65#define CFE_ERR_FSNOTAVAIL -30
66
67#define CFE_ERR_INVBOOTBLOCK -31
68#define CFE_ERR_WRONGDEVTYPE -32
69#define CFE_ERR_BBCHECKSUM -33
70#define CFE_ERR_BOOTPROGCHKSUM -34
71
72#define CFE_ERR_LDRNOTAVAIL -35
73
74#define CFE_ERR_NOTREADY -36
75
76#define CFE_ERR_GETMEM -37
77#define CFE_ERR_SETMEM -38
78
79#define CFE_ERR_NOTCONN -39
80#define CFE_ERR_ADDRINUSE -40
diff --git a/arch/mips/include/asm/gcmpregs.h b/arch/mips/include/asm/gcmpregs.h
new file mode 100644
index 000000000000..d74a8a4ca861
--- /dev/null
+++ b/arch/mips/include/asm/gcmpregs.h
@@ -0,0 +1,117 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000, 07 MIPS Technologies, Inc.
7 *
8 * Multiprocessor Subsystem Register Definitions
9 *
10 */
11#ifndef _ASM_GCMPREGS_H
12#define _ASM_GCMPREGS_H
13
14
15/* Offsets to major blocks within GCMP from GCMP base */
16#define GCMP_GCB_OFS 0x0000 /* Global Control Block */
17#define GCMP_CLCB_OFS 0x2000 /* Core Local Control Block */
18#define GCMP_COCB_OFS 0x4000 /* Core Other Control Block */
19#define GCMP_GDB_OFS 0x8000 /* Global Debug Block */
20
21/* Offsets to individual GCMP registers from GCMP base */
22#define GCMPOFS(block, tag, reg) (GCMP_##block##_OFS + GCMP_##tag##_##reg##_OFS)
23
24#define GCMPGCBOFS(reg) GCMPOFS(GCB, GCB, reg)
25#define GCMPCLCBOFS(reg) GCMPOFS(CLCB, CCB, reg)
26#define GCMPCOCBOFS(reg) GCMPOFS(COCB, CCB, reg)
27#define GCMPGDBOFS(reg) GCMPOFS(GDB, GDB, reg)
28
29/* GCMP register access */
30#define GCMPGCB(reg) REGP(_gcmp_base, GCMPGCBOFS(reg))
31#define GCMPCLCB(reg) REGP(_gcmp_base, GCMPCLCBOFS(reg))
32#define GCMPCOCB(reg) REGP(_gcmp_base, GCMPCOCBOFS(reg))
33#define GCMPGDB(reg) REGP(_gcmp_base, GCMPGDBOFS(reg))
34
35/* Mask generation */
36#define GCMPMSK(block, reg, bits) (MSK(bits)<<GCMP_##block##_##reg##_SHF)
37#define GCMPGCBMSK(reg, bits) GCMPMSK(GCB, reg, bits)
38#define GCMPCCBMSK(reg, bits) GCMPMSK(CCB, reg, bits)
39#define GCMPGDBMSK(reg, bits) GCMPMSK(GDB, reg, bits)
40
41/* GCB registers */
42#define GCMP_GCB_GC_OFS 0x0000 /* Global Config Register */
43#define GCMP_GCB_GC_NUMIOCU_SHF 8
44#define GCMP_GCB_GC_NUMIOCU_MSK GCMPGCBMSK(GC_NUMIOCU, 4)
45#define GCMP_GCB_GC_NUMCORES_SHF 0
46#define GCMP_GCB_GC_NUMCORES_MSK GCMPGCBMSK(GC_NUMCORES, 8)
47#define GCMP_GCB_GCMPB_OFS 0x0008 /* Global GCMP Base */
48#define GCMP_GCB_GCMPB_GCMPBASE_SHF 15
49#define GCMP_GCB_GCMPB_GCMPBASE_MSK GCMPGCBMSK(GCMPB_GCMPBASE, 17)
50#define GCMP_GCB_GCMPB_CMDEFTGT_SHF 0
51#define GCMP_GCB_GCMPB_CMDEFTGT_MSK GCMPGCBMSK(GCMPB_CMDEFTGT, 2)
52#define GCMP_GCB_GCMPB_CMDEFTGT_MEM 0
53#define GCMP_GCB_GCMPB_CMDEFTGT_MEM1 1
54#define GCMP_GCB_GCMPB_CMDEFTGT_IOCU1 2
55#define GCMP_GCB_GCMPB_CMDEFTGT_IOCU2 3
56#define GCMP_GCB_CCMC_OFS 0x0010 /* Global CM Control */
57#define GCMP_GCB_GCSRAP_OFS 0x0020 /* Global CSR Access Privilege */
58#define GCMP_GCB_GCSRAP_CMACCESS_SHF 0
59#define GCMP_GCB_GCSRAP_CMACCESS_MSK GCMPGCBMSK(GCSRAP_CMACCESS, 8)
60#define GCMP_GCB_GCMPREV_OFS 0x0030 /* GCMP Revision Register */
61#define GCMP_GCB_GCMEM_OFS 0x0040 /* Global CM Error Mask */
62#define GCMP_GCB_GCMEC_OFS 0x0048 /* Global CM Error Cause */
63#define GCMP_GCB_GMEC_ERROR_TYPE_SHF 27
64#define GCMP_GCB_GMEC_ERROR_TYPE_MSK GCMPGCBMSK(GMEC_ERROR_TYPE, 5)
65#define GCMP_GCB_GMEC_ERROR_INFO_SHF 0
66#define GCMP_GCB_GMEC_ERROR_INFO_MSK GCMPGCBMSK(GMEC_ERROR_INFO, 27)
67#define GCMP_GCB_GCMEA_OFS 0x0050 /* Global CM Error Address */
68#define GCMP_GCB_GCMEO_OFS 0x0058 /* Global CM Error Multiple */
69#define GCMP_GCB_GMEO_ERROR_2ND_SHF 0
70#define GCMP_GCB_GMEO_ERROR_2ND_MSK GCMPGCBMSK(GMEO_ERROR_2ND, 5)
71#define GCMP_GCB_GICBA_OFS 0x0080 /* Global Interrupt Controller Base Address */
72#define GCMP_GCB_GICBA_BASE_SHF 17
73#define GCMP_GCB_GICBA_BASE_MSK GCMPGCBMSK(GICBA_BASE, 15)
74#define GCMP_GCB_GICBA_EN_SHF 0
75#define GCMP_GCB_GICBA_EN_MSK GCMPGCBMSK(GICBA_EN, 1)
76
77/* GCB Regions */
78#define GCMP_GCB_CMxBASE_OFS(n) (0x0090+16*(n)) /* Global Region[0-3] Base Address */
79#define GCMP_GCB_CMxBASE_BASE_SHF 16
80#define GCMP_GCB_CMxBASE_BASE_MSK GCMPGCBMSK(CMxBASE_BASE, 16)
81#define GCMP_GCB_CMxMASK_OFS(n) (0x0098+16*(n)) /* Global Region[0-3] Address Mask */
82#define GCMP_GCB_CMxMASK_MASK_SHF 16
83#define GCMP_GCB_CMxMASK_MASK_MSK GCMPGCBMSK(CMxMASK_MASK, 16)
84#define GCMP_GCB_CMxMASK_CMREGTGT_SHF 0
85#define GCMP_GCB_CMxMASK_CMREGTGT_MSK GCMPGCBMSK(CMxMASK_CMREGTGT, 2)
86#define GCMP_GCB_CMxMASK_CMREGTGT_MEM 0
87#define GCMP_GCB_CMxMASK_CMREGTGT_MEM1 1
88#define GCMP_GCB_CMxMASK_CMREGTGT_IOCU1 2
89#define GCMP_GCB_CMxMASK_CMREGTGT_IOCU2 3
90
91
92/* Core local/Core other control block registers */
93#define GCMP_CCB_RESETR_OFS 0x0000 /* Reset Release */
94#define GCMP_CCB_RESETR_INRESET_SHF 0
95#define GCMP_CCB_RESETR_INRESET_MSK GCMPCCBMSK(RESETR_INRESET, 16)
96#define GCMP_CCB_COHCTL_OFS 0x0008 /* Coherence Control */
97#define GCMP_CCB_COHCTL_DOMAIN_SHF 0
98#define GCMP_CCB_COHCTL_DOMAIN_MSK GCMPCCBMSK(COHCTL_DOMAIN, 8)
99#define GCMP_CCB_CFG_OFS 0x0010 /* Config */
100#define GCMP_CCB_CFG_IOCUTYPE_SHF 10
101#define GCMP_CCB_CFG_IOCUTYPE_MSK GCMPCCBMSK(CFG_IOCUTYPE, 2)
102#define GCMP_CCB_CFG_IOCUTYPE_CPU 0
103#define GCMP_CCB_CFG_IOCUTYPE_NCIOCU 1
104#define GCMP_CCB_CFG_IOCUTYPE_CIOCU 2
105#define GCMP_CCB_CFG_NUMVPE_SHF 0
106#define GCMP_CCB_CFG_NUMVPE_MSK GCMPCCBMSK(CFG_NUMVPE, 10)
107#define GCMP_CCB_OTHER_OFS 0x0018 /* Other Address */
108#define GCMP_CCB_OTHER_CORENUM_SHF 16
109#define GCMP_CCB_OTHER_CORENUM_MSK GCMPCCBMSK(OTHER_CORENUM, 16)
110#define GCMP_CCB_RESETBASE_OFS 0x0020 /* Reset Exception Base */
111#define GCMP_CCB_RESETBASE_BEV_SHF 12
112#define GCMP_CCB_RESETBASE_BEV_MSK GCMPCCBMSK(RESETBASE_BEV, 20)
113#define GCMP_CCB_ID_OFS 0x0028 /* Identification */
114#define GCMP_CCB_DINTGROUP_OFS 0x0030 /* DINT Group Participate */
115#define GCMP_CCB_DBGGROUP_OFS 0x0100 /* DebugBreak Group */
116
117#endif /* _ASM_GCMPREGS_H */
diff --git a/arch/mips/include/asm/gic.h b/arch/mips/include/asm/gic.h
new file mode 100644
index 000000000000..954807d9d66a
--- /dev/null
+++ b/arch/mips/include/asm/gic.h
@@ -0,0 +1,487 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000, 07 MIPS Technologies, Inc.
7 *
8 * GIC Register Definitions
9 *
10 */
11#ifndef _ASM_GICREGS_H
12#define _ASM_GICREGS_H
13
14#undef GICISBYTELITTLEENDIAN
15#define GICISWORDLITTLEENDIAN
16
17/* Constants */
18#define GIC_POL_POS 1
19#define GIC_POL_NEG 0
20#define GIC_TRIG_EDGE 1
21#define GIC_TRIG_LEVEL 0
22
23#define GIC_NUM_INTRS 32
24
25#define MSK(n) ((1 << (n)) - 1)
26#define REG32(addr) (*(volatile unsigned int *) (addr))
27#define REG(base, offs) REG32((unsigned long)(base) + offs##_##OFS)
28#define REGP(base, phys) REG32((unsigned long)(base) + (phys))
29
30/* Accessors */
31#define GIC_REG(segment, offset) \
32 REG32(_gic_base + segment##_##SECTION_OFS + offset##_##OFS)
33#define GIC_REG_ADDR(segment, offset) \
34 REG32(_gic_base + segment##_##SECTION_OFS + offset)
35
36#define GIC_ABS_REG(segment, offset) \
37 (_gic_base + segment##_##SECTION_OFS + offset##_##OFS)
38#define GIC_REG_ABS_ADDR(segment, offset) \
39 (_gic_base + segment##_##SECTION_OFS + offset)
40
41#ifdef GICISBYTELITTLEENDIAN
42#define GICREAD(reg, data) (data) = (reg), (data) = le32_to_cpu(data)
43#define GICWRITE(reg, data) (reg) = cpu_to_le32(data)
44#define GICBIS(reg, bits) \
45 ({unsigned int data; \
46 GICREAD(reg, data); \
47 data |= bits; \
48 GICWRITE(reg, data); \
49 })
50
51#else
52#define GICREAD(reg, data) (data) = (reg)
53#define GICWRITE(reg, data) (reg) = (data)
54#define GICBIS(reg, bits) (reg) |= (bits)
55#endif
56
57
58/* GIC Address Space */
59#define SHARED_SECTION_OFS 0x0000
60#define SHARED_SECTION_SIZE 0x8000
61#define VPE_LOCAL_SECTION_OFS 0x8000
62#define VPE_LOCAL_SECTION_SIZE 0x4000
63#define VPE_OTHER_SECTION_OFS 0xc000
64#define VPE_OTHER_SECTION_SIZE 0x4000
65#define USM_VISIBLE_SECTION_OFS 0x10000
66#define USM_VISIBLE_SECTION_SIZE 0x10000
67
68/* Register Map for Shared Section */
69#if defined(CONFIG_CPU_LITTLE_ENDIAN) || defined(GICISWORDLITTLEENDIAN)
70
71#define GIC_SH_CONFIG_OFS 0x0000
72
73/* Shared Global Counter */
74#define GIC_SH_COUNTER_31_00_OFS 0x0010
75#define GIC_SH_COUNTER_63_32_OFS 0x0014
76
77/* Interrupt Polarity */
78#define GIC_SH_POL_31_0_OFS 0x0100
79#define GIC_SH_POL_63_32_OFS 0x0104
80#define GIC_SH_POL_95_64_OFS 0x0108
81#define GIC_SH_POL_127_96_OFS 0x010c
82#define GIC_SH_POL_159_128_OFS 0x0110
83#define GIC_SH_POL_191_160_OFS 0x0114
84#define GIC_SH_POL_223_192_OFS 0x0118
85#define GIC_SH_POL_255_224_OFS 0x011c
86
87/* Edge/Level Triggering */
88#define GIC_SH_TRIG_31_0_OFS 0x0180
89#define GIC_SH_TRIG_63_32_OFS 0x0184
90#define GIC_SH_TRIG_95_64_OFS 0x0188
91#define GIC_SH_TRIG_127_96_OFS 0x018c
92#define GIC_SH_TRIG_159_128_OFS 0x0190
93#define GIC_SH_TRIG_191_160_OFS 0x0194
94#define GIC_SH_TRIG_223_192_OFS 0x0198
95#define GIC_SH_TRIG_255_224_OFS 0x019c
96
97/* Dual Edge Triggering */
98#define GIC_SH_DUAL_31_0_OFS 0x0200
99#define GIC_SH_DUAL_63_32_OFS 0x0204
100#define GIC_SH_DUAL_95_64_OFS 0x0208
101#define GIC_SH_DUAL_127_96_OFS 0x020c
102#define GIC_SH_DUAL_159_128_OFS 0x0210
103#define GIC_SH_DUAL_191_160_OFS 0x0214
104#define GIC_SH_DUAL_223_192_OFS 0x0218
105#define GIC_SH_DUAL_255_224_OFS 0x021c
106
107/* Set/Clear corresponding bit in Edge Detect Register */
108#define GIC_SH_WEDGE_OFS 0x0280
109
110/* Reset Mask - Disables Interrupt */
111#define GIC_SH_RMASK_31_0_OFS 0x0300
112#define GIC_SH_RMASK_63_32_OFS 0x0304
113#define GIC_SH_RMASK_95_64_OFS 0x0308
114#define GIC_SH_RMASK_127_96_OFS 0x030c
115#define GIC_SH_RMASK_159_128_OFS 0x0310
116#define GIC_SH_RMASK_191_160_OFS 0x0314
117#define GIC_SH_RMASK_223_192_OFS 0x0318
118#define GIC_SH_RMASK_255_224_OFS 0x031c
119
120/* Set Mask (WO) - Enables Interrupt */
121#define GIC_SH_SMASK_31_0_OFS 0x0380
122#define GIC_SH_SMASK_63_32_OFS 0x0384
123#define GIC_SH_SMASK_95_64_OFS 0x0388
124#define GIC_SH_SMASK_127_96_OFS 0x038c
125#define GIC_SH_SMASK_159_128_OFS 0x0390
126#define GIC_SH_SMASK_191_160_OFS 0x0394
127#define GIC_SH_SMASK_223_192_OFS 0x0398
128#define GIC_SH_SMASK_255_224_OFS 0x039c
129
130/* Global Interrupt Mask Register (RO) - Bit Set == Interrupt enabled */
131#define GIC_SH_MASK_31_0_OFS 0x0400
132#define GIC_SH_MASK_63_32_OFS 0x0404
133#define GIC_SH_MASK_95_64_OFS 0x0408
134#define GIC_SH_MASK_127_96_OFS 0x040c
135#define GIC_SH_MASK_159_128_OFS 0x0410
136#define GIC_SH_MASK_191_160_OFS 0x0414
137#define GIC_SH_MASK_223_192_OFS 0x0418
138#define GIC_SH_MASK_255_224_OFS 0x041c
139
140/* Pending Global Interrupts (RO) */
141#define GIC_SH_PEND_31_0_OFS 0x0480
142#define GIC_SH_PEND_63_32_OFS 0x0484
143#define GIC_SH_PEND_95_64_OFS 0x0488
144#define GIC_SH_PEND_127_96_OFS 0x048c
145#define GIC_SH_PEND_159_128_OFS 0x0490
146#define GIC_SH_PEND_191_160_OFS 0x0494
147#define GIC_SH_PEND_223_192_OFS 0x0498
148#define GIC_SH_PEND_255_224_OFS 0x049c
149
150#define GIC_SH_INTR_MAP_TO_PIN_BASE_OFS 0x0500
151
152/* Maps Interrupt X to a Pin */
153#define GIC_SH_MAP_TO_PIN(intr) \
154 (GIC_SH_INTR_MAP_TO_PIN_BASE_OFS + (4 * intr))
155
156#define GIC_SH_INTR_MAP_TO_VPE_BASE_OFS 0x2000
157
158/* Maps Interrupt X to a VPE */
159#define GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe) \
160 (GIC_SH_INTR_MAP_TO_VPE_BASE_OFS + (32 * (intr)) + (((vpe) / 32) * 4))
161#define GIC_SH_MAP_TO_VPE_REG_BIT(vpe) (1 << ((vpe) % 32))
162
163/* Polarity : Reset Value is always 0 */
164#define GIC_SH_SET_POLARITY_OFS 0x0100
165#define GIC_SET_POLARITY(intr, pol) \
166 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + (((intr) / 32) * 4)), (pol) << ((intr) % 32))
167
168/* Triggering : Reset Value is always 0 */
169#define GIC_SH_SET_TRIGGER_OFS 0x0180
170#define GIC_SET_TRIGGER(intr, trig) \
171 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + (((intr) / 32) * 4)), (trig) << ((intr) % 32))
172
173/* Mask manipulation */
174#define GIC_SH_SMASK_OFS 0x0380
175#define GIC_SET_INTR_MASK(intr, val) \
176 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_SMASK_OFS + (((intr) / 32) * 4)), ((val) << ((intr) % 32)))
177
178#define GIC_SH_RMASK_OFS 0x0300
179#define GIC_CLR_INTR_MASK(intr, val) \
180 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_RMASK_OFS + (((intr) / 32) * 4)), ((val) << ((intr) % 32)))
181
182/* Register Map for Local Section */
183#define GIC_VPE_CTL_OFS 0x0000
184#define GIC_VPE_PEND_OFS 0x0004
185#define GIC_VPE_MASK_OFS 0x0008
186#define GIC_VPE_RMASK_OFS 0x000c
187#define GIC_VPE_SMASK_OFS 0x0010
188#define GIC_VPE_WD_MAP_OFS 0x0040
189#define GIC_VPE_COMPARE_MAP_OFS 0x0044
190#define GIC_VPE_TIMER_MAP_OFS 0x0048
191#define GIC_VPE_PERFCTR_MAP_OFS 0x0050
192#define GIC_VPE_SWINT0_MAP_OFS 0x0054
193#define GIC_VPE_SWINT1_MAP_OFS 0x0058
194#define GIC_VPE_OTHER_ADDR_OFS 0x0080
195#define GIC_VPE_WD_CONFIG0_OFS 0x0090
196#define GIC_VPE_WD_COUNT0_OFS 0x0094
197#define GIC_VPE_WD_INITIAL0_OFS 0x0098
198#define GIC_VPE_COMPARE_LO_OFS 0x00a0
199#define GIC_VPE_COMPARE_HI 0x00a4
200
201#define GIC_VPE_EIC_SHADOW_SET_BASE 0x0100
202#define GIC_VPE_EIC_SS(intr) \
203 (GIC_EIC_SHADOW_SET_BASE + (4 * intr))
204
205#define GIC_VPE_EIC_VEC_BASE 0x0800
206#define GIC_VPE_EIC_VEC(intr) \
207 (GIC_VPE_EIC_VEC_BASE + (4 * intr))
208
209#define GIC_VPE_TENABLE_NMI_OFS 0x1000
210#define GIC_VPE_TENABLE_YQ_OFS 0x1004
211#define GIC_VPE_TENABLE_INT_31_0_OFS 0x1080
212#define GIC_VPE_TENABLE_INT_63_32_OFS 0x1084
213
214/* User Mode Visible Section Register Map */
215#define GIC_UMV_SH_COUNTER_31_00_OFS 0x0000
216#define GIC_UMV_SH_COUNTER_63_32_OFS 0x0004
217
218#else /* CONFIG_CPU_BIG_ENDIAN */
219
220#define GIC_SH_CONFIG_OFS 0x0000
221
222/* Shared Global Counter */
223#define GIC_SH_COUNTER_31_00_OFS 0x0014
224#define GIC_SH_COUNTER_63_32_OFS 0x0010
225
226/* Interrupt Polarity */
227#define GIC_SH_POL_31_0_OFS 0x0104
228#define GIC_SH_POL_63_32_OFS 0x0100
229#define GIC_SH_POL_95_64_OFS 0x010c
230#define GIC_SH_POL_127_96_OFS 0x0108
231#define GIC_SH_POL_159_128_OFS 0x0114
232#define GIC_SH_POL_191_160_OFS 0x0110
233#define GIC_SH_POL_223_192_OFS 0x011c
234#define GIC_SH_POL_255_224_OFS 0x0118
235
236/* Edge/Level Triggering */
237#define GIC_SH_TRIG_31_0_OFS 0x0184
238#define GIC_SH_TRIG_63_32_OFS 0x0180
239#define GIC_SH_TRIG_95_64_OFS 0x018c
240#define GIC_SH_TRIG_127_96_OFS 0x0188
241#define GIC_SH_TRIG_159_128_OFS 0x0194
242#define GIC_SH_TRIG_191_160_OFS 0x0190
243#define GIC_SH_TRIG_223_192_OFS 0x019c
244#define GIC_SH_TRIG_255_224_OFS 0x0198
245
246/* Dual Edge Triggering */
247#define GIC_SH_DUAL_31_0_OFS 0x0204
248#define GIC_SH_DUAL_63_32_OFS 0x0200
249#define GIC_SH_DUAL_95_64_OFS 0x020c
250#define GIC_SH_DUAL_127_96_OFS 0x0208
251#define GIC_SH_DUAL_159_128_OFS 0x0214
252#define GIC_SH_DUAL_191_160_OFS 0x0210
253#define GIC_SH_DUAL_223_192_OFS 0x021c
254#define GIC_SH_DUAL_255_224_OFS 0x0218
255
256/* Set/Clear corresponding bit in Edge Detect Register */
257#define GIC_SH_WEDGE_OFS 0x0280
258
259/* Reset Mask - Disables Interrupt */
260#define GIC_SH_RMASK_31_0_OFS 0x0304
261#define GIC_SH_RMASK_63_32_OFS 0x0300
262#define GIC_SH_RMASK_95_64_OFS 0x030c
263#define GIC_SH_RMASK_127_96_OFS 0x0308
264#define GIC_SH_RMASK_159_128_OFS 0x0314
265#define GIC_SH_RMASK_191_160_OFS 0x0310
266#define GIC_SH_RMASK_223_192_OFS 0x031c
267#define GIC_SH_RMASK_255_224_OFS 0x0318
268
269/* Set Mask (WO) - Enables Interrupt */
270#define GIC_SH_SMASK_31_0_OFS 0x0384
271#define GIC_SH_SMASK_63_32_OFS 0x0380
272#define GIC_SH_SMASK_95_64_OFS 0x038c
273#define GIC_SH_SMASK_127_96_OFS 0x0388
274#define GIC_SH_SMASK_159_128_OFS 0x0394
275#define GIC_SH_SMASK_191_160_OFS 0x0390
276#define GIC_SH_SMASK_223_192_OFS 0x039c
277#define GIC_SH_SMASK_255_224_OFS 0x0398
278
279/* Global Interrupt Mask Register (RO) - Bit Set == Interrupt enabled */
280#define GIC_SH_MASK_31_0_OFS 0x0404
281#define GIC_SH_MASK_63_32_OFS 0x0400
282#define GIC_SH_MASK_95_64_OFS 0x040c
283#define GIC_SH_MASK_127_96_OFS 0x0408
284#define GIC_SH_MASK_159_128_OFS 0x0414
285#define GIC_SH_MASK_191_160_OFS 0x0410
286#define GIC_SH_MASK_223_192_OFS 0x041c
287#define GIC_SH_MASK_255_224_OFS 0x0418
288
289/* Pending Global Interrupts (RO) */
290#define GIC_SH_PEND_31_0_OFS 0x0484
291#define GIC_SH_PEND_63_32_OFS 0x0480
292#define GIC_SH_PEND_95_64_OFS 0x048c
293#define GIC_SH_PEND_127_96_OFS 0x0488
294#define GIC_SH_PEND_159_128_OFS 0x0494
295#define GIC_SH_PEND_191_160_OFS 0x0490
296#define GIC_SH_PEND_223_192_OFS 0x049c
297#define GIC_SH_PEND_255_224_OFS 0x0498
298
299#define GIC_SH_INTR_MAP_TO_PIN_BASE_OFS 0x0500
300
301/* Maps Interrupt X to a Pin */
302#define GIC_SH_MAP_TO_PIN(intr) \
303 (GIC_SH_INTR_MAP_TO_PIN_BASE_OFS + (4 * intr))
304
305#define GIC_SH_INTR_MAP_TO_VPE_BASE_OFS 0x2004
306
307/*
308 * Maps Interrupt X to a VPE. This is more complex than the LE case, as
309 * odd and even registers need to be transposed. It does work - trust me!
310 */
311#define GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe) \
312 (GIC_SH_INTR_MAP_TO_VPE_BASE_OFS + (32 * (intr)) + \
313 (((((vpe) / 32) ^ 1) - 1) * 4))
314#define GIC_SH_MAP_TO_VPE_REG_BIT(vpe) (1 << ((vpe) % 32))
315
316/* Polarity */
317#define GIC_SH_SET_POLARITY_OFS 0x0100
318#define GIC_SET_POLARITY(intr, pol) \
319 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), (pol) << ((intr) % 32))
320
321/* Triggering */
322#define GIC_SH_SET_TRIGGER_OFS 0x0180
323#define GIC_SET_TRIGGER(intr, trig) \
324 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), (trig) << ((intr) % 32))
325
326/* Mask manipulation */
327#define GIC_SH_SMASK_OFS 0x0380
328#define GIC_SET_INTR_MASK(intr, val) \
329 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_SMASK_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), ((val) << ((intr) % 32)))
330
331#define GIC_SH_RMASK_OFS 0x0300
332#define GIC_CLR_INTR_MASK(intr, val) \
333 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_RMASK_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), ((val) << ((intr) % 32)))
334
335/* Register Map for Local Section */
336#define GIC_VPE_CTL_OFS 0x0000
337#define GIC_VPE_PEND_OFS 0x0004
338#define GIC_VPE_MASK_OFS 0x0008
339#define GIC_VPE_RMASK_OFS 0x000c
340#define GIC_VPE_SMASK_OFS 0x0010
341#define GIC_VPE_WD_MAP_OFS 0x0040
342#define GIC_VPE_COMPARE_MAP_OFS 0x0044
343#define GIC_VPE_TIMER_MAP_OFS 0x0048
344#define GIC_VPE_PERFCTR_MAP_OFS 0x0050
345#define GIC_VPE_SWINT0_MAP_OFS 0x0054
346#define GIC_VPE_SWINT1_MAP_OFS 0x0058
347#define GIC_VPE_OTHER_ADDR_OFS 0x0080
348#define GIC_VPE_WD_CONFIG0_OFS 0x0090
349#define GIC_VPE_WD_COUNT0_OFS 0x0094
350#define GIC_VPE_WD_INITIAL0_OFS 0x0098
351#define GIC_VPE_COMPARE_LO_OFS 0x00a4
352#define GIC_VPE_COMPARE_HI_OFS 0x00a0
353
354#define GIC_VPE_EIC_SHADOW_SET_BASE 0x0100
355#define GIC_VPE_EIC_SS(intr) \
356 (GIC_EIC_SHADOW_SET_BASE + (4 * intr))
357
358#define GIC_VPE_EIC_VEC_BASE 0x0800
359#define GIC_VPE_EIC_VEC(intr) \
360 (GIC_VPE_EIC_VEC_BASE + (4 * intr))
361
362#define GIC_VPE_TENABLE_NMI_OFS 0x1000
363#define GIC_VPE_TENABLE_YQ_OFS 0x1004
364#define GIC_VPE_TENABLE_INT_31_0_OFS 0x1080
365#define GIC_VPE_TENABLE_INT_63_32_OFS 0x1084
366
367/* User Mode Visible Section Register Map */
368#define GIC_UMV_SH_COUNTER_31_00_OFS 0x0004
369#define GIC_UMV_SH_COUNTER_63_32_OFS 0x0000
370
371#endif /* !LE */
372
373/* Masks */
374#define GIC_SH_CONFIG_COUNTSTOP_SHF 28
375#define GIC_SH_CONFIG_COUNTSTOP_MSK (MSK(1) << GIC_SH_CONFIG_COUNTSTOP_SHF)
376
377#define GIC_SH_CONFIG_COUNTBITS_SHF 24
378#define GIC_SH_CONFIG_COUNTBITS_MSK (MSK(4) << GIC_SH_CONFIG_COUNTBITS_SHF)
379
380#define GIC_SH_CONFIG_NUMINTRS_SHF 16
381#define GIC_SH_CONFIG_NUMINTRS_MSK (MSK(8) << GIC_SH_CONFIG_NUMINTRS_SHF)
382
383#define GIC_SH_CONFIG_NUMVPES_SHF 0
384#define GIC_SH_CONFIG_NUMVPES_MSK (MSK(8) << GIC_SH_CONFIG_NUMVPES_SHF)
385
386#define GIC_SH_WEDGE_SET(intr) (intr | (0x1 << 31))
387#define GIC_SH_WEDGE_CLR(intr) (intr & ~(0x1 << 31))
388
389#define GIC_MAP_TO_PIN_SHF 31
390#define GIC_MAP_TO_PIN_MSK (MSK(1) << GIC_MAP_TO_PIN_SHF)
391#define GIC_MAP_TO_NMI_SHF 30
392#define GIC_MAP_TO_NMI_MSK (MSK(1) << GIC_MAP_TO_NMI_SHF)
393#define GIC_MAP_TO_YQ_SHF 29
394#define GIC_MAP_TO_YQ_MSK (MSK(1) << GIC_MAP_TO_YQ_SHF)
395#define GIC_MAP_SHF 0
396#define GIC_MAP_MSK (MSK(6) << GIC_MAP_SHF)
397
398/* GIC_VPE_CTL Masks */
399#define GIC_VPE_CTL_PERFCNT_RTBL_SHF 2
400#define GIC_VPE_CTL_PERFCNT_RTBL_MSK (MSK(1) << GIC_VPE_CTL_PERFCNT_RTBL_SHF)
401#define GIC_VPE_CTL_TIMER_RTBL_SHF 1
402#define GIC_VPE_CTL_TIMER_RTBL_MSK (MSK(1) << GIC_VPE_CTL_TIMER_RTBL_SHF)
403#define GIC_VPE_CTL_EIC_MODE_SHF 0
404#define GIC_VPE_CTL_EIC_MODE_MSK (MSK(1) << GIC_VPE_CTL_EIC_MODE_SHF)
405
406/* GIC_VPE_PEND Masks */
407#define GIC_VPE_PEND_WD_SHF 0
408#define GIC_VPE_PEND_WD_MSK (MSK(1) << GIC_VPE_PEND_WD_SHF)
409#define GIC_VPE_PEND_CMP_SHF 1
410#define GIC_VPE_PEND_CMP_MSK (MSK(1) << GIC_VPE_PEND_CMP_SHF)
411#define GIC_VPE_PEND_TIMER_SHF 2
412#define GIC_VPE_PEND_TIMER_MSK (MSK(1) << GIC_VPE_PEND_TIMER_SHF)
413#define GIC_VPE_PEND_PERFCOUNT_SHF 3
414#define GIC_VPE_PEND_PERFCOUNT_MSK (MSK(1) << GIC_VPE_PEND_PERFCOUNT_SHF)
415#define GIC_VPE_PEND_SWINT0_SHF 4
416#define GIC_VPE_PEND_SWINT0_MSK (MSK(1) << GIC_VPE_PEND_SWINT0_SHF)
417#define GIC_VPE_PEND_SWINT1_SHF 5
418#define GIC_VPE_PEND_SWINT1_MSK (MSK(1) << GIC_VPE_PEND_SWINT1_SHF)
419
420/* GIC_VPE_RMASK Masks */
421#define GIC_VPE_RMASK_WD_SHF 0
422#define GIC_VPE_RMASK_WD_MSK (MSK(1) << GIC_VPE_RMASK_WD_SHF)
423#define GIC_VPE_RMASK_CMP_SHF 1
424#define GIC_VPE_RMASK_CMP_MSK (MSK(1) << GIC_VPE_RMASK_CMP_SHF)
425#define GIC_VPE_RMASK_TIMER_SHF 2
426#define GIC_VPE_RMASK_TIMER_MSK (MSK(1) << GIC_VPE_RMASK_TIMER_SHF)
427#define GIC_VPE_RMASK_PERFCNT_SHF 3
428#define GIC_VPE_RMASK_PERFCNT_MSK (MSK(1) << GIC_VPE_RMASK_PERFCNT_SHF)
429#define GIC_VPE_RMASK_SWINT0_SHF 4
430#define GIC_VPE_RMASK_SWINT0_MSK (MSK(1) << GIC_VPE_RMASK_SWINT0_SHF)
431#define GIC_VPE_RMASK_SWINT1_SHF 5
432#define GIC_VPE_RMASK_SWINT1_MSK (MSK(1) << GIC_VPE_RMASK_SWINT1_SHF)
433
434/* GIC_VPE_SMASK Masks */
435#define GIC_VPE_SMASK_WD_SHF 0
436#define GIC_VPE_SMASK_WD_MSK (MSK(1) << GIC_VPE_SMASK_WD_SHF)
437#define GIC_VPE_SMASK_CMP_SHF 1
438#define GIC_VPE_SMASK_CMP_MSK (MSK(1) << GIC_VPE_SMASK_CMP_SHF)
439#define GIC_VPE_SMASK_TIMER_SHF 2
440#define GIC_VPE_SMASK_TIMER_MSK (MSK(1) << GIC_VPE_SMASK_TIMER_SHF)
441#define GIC_VPE_SMASK_PERFCNT_SHF 3
442#define GIC_VPE_SMASK_PERFCNT_MSK (MSK(1) << GIC_VPE_SMASK_PERFCNT_SHF)
443#define GIC_VPE_SMASK_SWINT0_SHF 4
444#define GIC_VPE_SMASK_SWINT0_MSK (MSK(1) << GIC_VPE_SMASK_SWINT0_SHF)
445#define GIC_VPE_SMASK_SWINT1_SHF 5
446#define GIC_VPE_SMASK_SWINT1_MSK (MSK(1) << GIC_VPE_SMASK_SWINT1_SHF)
447
448/*
449 * Set the Mapping of Interrupt X to a VPE.
450 */
451#define GIC_SH_MAP_TO_VPE_SMASK(intr, vpe) \
452 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe)), \
453 GIC_SH_MAP_TO_VPE_REG_BIT(vpe))
454
455struct gic_pcpu_mask {
456 DECLARE_BITMAP(pcpu_mask, GIC_NUM_INTRS);
457};
458
459struct gic_pending_regs {
460 DECLARE_BITMAP(pending, GIC_NUM_INTRS);
461};
462
463struct gic_intrmask_regs {
464 DECLARE_BITMAP(intrmask, GIC_NUM_INTRS);
465};
466
467/*
468 * Interrupt Meta-data specification. The ipiflag helps
469 * in building ipi_map.
470 */
471struct gic_intr_map {
472 unsigned int intrnum; /* Ext Intr Num */
473 unsigned int cpunum; /* Directed to this CPU */
474 unsigned int pin; /* Directed to this Pin */
475 unsigned int polarity; /* Polarity : +/- */
476 unsigned int trigtype; /* Trigger : Edge/Levl */
477 unsigned int ipiflag; /* Is used for IPI ? */
478};
479
480extern void gic_init(unsigned long gic_base_addr,
481 unsigned long gic_addrspace_size, struct gic_intr_map *intrmap,
482 unsigned int intrmap_size, unsigned int irqbase);
483
484extern unsigned int gic_get_int(void);
485extern void gic_send_ipi(unsigned int intr);
486
487#endif /* _ASM_GICREGS_H */
diff --git a/arch/mips/include/asm/gpio.h b/arch/mips/include/asm/gpio.h
new file mode 100644
index 000000000000..06e46faf862d
--- /dev/null
+++ b/arch/mips/include/asm/gpio.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_MIPS_GPIO_H
2#define __ASM_MIPS_GPIO_H
3
4#include <gpio.h>
5
6#endif /* __ASM_MIPS_GPIO_H */
diff --git a/arch/mips/include/asm/gt64120.h b/arch/mips/include/asm/gt64120.h
new file mode 100644
index 000000000000..e64b41093c49
--- /dev/null
+++ b/arch/mips/include/asm/gt64120.h
@@ -0,0 +1,580 @@
1/*
2 * Copyright (C) 2000, 2004, 2005 MIPS Technologies, Inc.
3 * All rights reserved.
4 * Authors: Carsten Langgaard <carstenl@mips.com>
5 * Maciej W. Rozycki <macro@mips.com>
6 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
7 *
8 * This program is free software; you can distribute it and/or modify it
9 * under the terms of the GNU General Public License (Version 2) as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 */
21#ifndef _ASM_GT64120_H
22#define _ASM_GT64120_H
23
24#include <linux/clocksource.h>
25
26#include <asm/addrspace.h>
27#include <asm/byteorder.h>
28
29#define MSK(n) ((1 << (n)) - 1)
30
31/*
32 * Register offset addresses
33 */
34/* CPU Configuration. */
35#define GT_CPU_OFS 0x000
36
37#define GT_MULTI_OFS 0x120
38
39/* CPU Address Decode. */
40#define GT_SCS10LD_OFS 0x008
41#define GT_SCS10HD_OFS 0x010
42#define GT_SCS32LD_OFS 0x018
43#define GT_SCS32HD_OFS 0x020
44#define GT_CS20LD_OFS 0x028
45#define GT_CS20HD_OFS 0x030
46#define GT_CS3BOOTLD_OFS 0x038
47#define GT_CS3BOOTHD_OFS 0x040
48#define GT_PCI0IOLD_OFS 0x048
49#define GT_PCI0IOHD_OFS 0x050
50#define GT_PCI0M0LD_OFS 0x058
51#define GT_PCI0M0HD_OFS 0x060
52#define GT_ISD_OFS 0x068
53
54#define GT_PCI0M1LD_OFS 0x080
55#define GT_PCI0M1HD_OFS 0x088
56#define GT_PCI1IOLD_OFS 0x090
57#define GT_PCI1IOHD_OFS 0x098
58#define GT_PCI1M0LD_OFS 0x0a0
59#define GT_PCI1M0HD_OFS 0x0a8
60#define GT_PCI1M1LD_OFS 0x0b0
61#define GT_PCI1M1HD_OFS 0x0b8
62#define GT_PCI1M1LD_OFS 0x0b0
63#define GT_PCI1M1HD_OFS 0x0b8
64
65#define GT_SCS10AR_OFS 0x0d0
66#define GT_SCS32AR_OFS 0x0d8
67#define GT_CS20R_OFS 0x0e0
68#define GT_CS3BOOTR_OFS 0x0e8
69
70#define GT_PCI0IOREMAP_OFS 0x0f0
71#define GT_PCI0M0REMAP_OFS 0x0f8
72#define GT_PCI0M1REMAP_OFS 0x100
73#define GT_PCI1IOREMAP_OFS 0x108
74#define GT_PCI1M0REMAP_OFS 0x110
75#define GT_PCI1M1REMAP_OFS 0x118
76
77/* CPU Error Report. */
78#define GT_CPUERR_ADDRLO_OFS 0x070
79#define GT_CPUERR_ADDRHI_OFS 0x078
80
81#define GT_CPUERR_DATALO_OFS 0x128 /* GT-64120A only */
82#define GT_CPUERR_DATAHI_OFS 0x130 /* GT-64120A only */
83#define GT_CPUERR_PARITY_OFS 0x138 /* GT-64120A only */
84
85/* CPU Sync Barrier. */
86#define GT_PCI0SYNC_OFS 0x0c0
87#define GT_PCI1SYNC_OFS 0x0c8
88
89/* SDRAM and Device Address Decode. */
90#define GT_SCS0LD_OFS 0x400
91#define GT_SCS0HD_OFS 0x404
92#define GT_SCS1LD_OFS 0x408
93#define GT_SCS1HD_OFS 0x40c
94#define GT_SCS2LD_OFS 0x410
95#define GT_SCS2HD_OFS 0x414
96#define GT_SCS3LD_OFS 0x418
97#define GT_SCS3HD_OFS 0x41c
98#define GT_CS0LD_OFS 0x420
99#define GT_CS0HD_OFS 0x424
100#define GT_CS1LD_OFS 0x428
101#define GT_CS1HD_OFS 0x42c
102#define GT_CS2LD_OFS 0x430
103#define GT_CS2HD_OFS 0x434
104#define GT_CS3LD_OFS 0x438
105#define GT_CS3HD_OFS 0x43c
106#define GT_BOOTLD_OFS 0x440
107#define GT_BOOTHD_OFS 0x444
108
109#define GT_ADERR_OFS 0x470
110
111/* SDRAM Configuration. */
112#define GT_SDRAM_CFG_OFS 0x448
113
114#define GT_SDRAM_OPMODE_OFS 0x474
115#define GT_SDRAM_BM_OFS 0x478
116#define GT_SDRAM_ADDRDECODE_OFS 0x47c
117
118/* SDRAM Parameters. */
119#define GT_SDRAM_B0_OFS 0x44c
120#define GT_SDRAM_B1_OFS 0x450
121#define GT_SDRAM_B2_OFS 0x454
122#define GT_SDRAM_B3_OFS 0x458
123
124/* Device Parameters. */
125#define GT_DEV_B0_OFS 0x45c
126#define GT_DEV_B1_OFS 0x460
127#define GT_DEV_B2_OFS 0x464
128#define GT_DEV_B3_OFS 0x468
129#define GT_DEV_BOOT_OFS 0x46c
130
131/* ECC. */
132#define GT_ECC_ERRDATALO 0x480 /* GT-64120A only */
133#define GT_ECC_ERRDATAHI 0x484 /* GT-64120A only */
134#define GT_ECC_MEM 0x488 /* GT-64120A only */
135#define GT_ECC_CALC 0x48c /* GT-64120A only */
136#define GT_ECC_ERRADDR 0x490 /* GT-64120A only */
137
138/* DMA Record. */
139#define GT_DMA0_CNT_OFS 0x800
140#define GT_DMA1_CNT_OFS 0x804
141#define GT_DMA2_CNT_OFS 0x808
142#define GT_DMA3_CNT_OFS 0x80c
143#define GT_DMA0_SA_OFS 0x810
144#define GT_DMA1_SA_OFS 0x814
145#define GT_DMA2_SA_OFS 0x818
146#define GT_DMA3_SA_OFS 0x81c
147#define GT_DMA0_DA_OFS 0x820
148#define GT_DMA1_DA_OFS 0x824
149#define GT_DMA2_DA_OFS 0x828
150#define GT_DMA3_DA_OFS 0x82c
151#define GT_DMA0_NEXT_OFS 0x830
152#define GT_DMA1_NEXT_OFS 0x834
153#define GT_DMA2_NEXT_OFS 0x838
154#define GT_DMA3_NEXT_OFS 0x83c
155
156#define GT_DMA0_CUR_OFS 0x870
157#define GT_DMA1_CUR_OFS 0x874
158#define GT_DMA2_CUR_OFS 0x878
159#define GT_DMA3_CUR_OFS 0x87c
160
161/* DMA Channel Control. */
162#define GT_DMA0_CTRL_OFS 0x840
163#define GT_DMA1_CTRL_OFS 0x844
164#define GT_DMA2_CTRL_OFS 0x848
165#define GT_DMA3_CTRL_OFS 0x84c
166
167/* DMA Arbiter. */
168#define GT_DMA_ARB_OFS 0x860
169
170/* Timer/Counter. */
171#define GT_TC0_OFS 0x850
172#define GT_TC1_OFS 0x854
173#define GT_TC2_OFS 0x858
174#define GT_TC3_OFS 0x85c
175
176#define GT_TC_CONTROL_OFS 0x864
177
178/* PCI Internal. */
179#define GT_PCI0_CMD_OFS 0xc00
180#define GT_PCI0_TOR_OFS 0xc04
181#define GT_PCI0_BS_SCS10_OFS 0xc08
182#define GT_PCI0_BS_SCS32_OFS 0xc0c
183#define GT_PCI0_BS_CS20_OFS 0xc10
184#define GT_PCI0_BS_CS3BT_OFS 0xc14
185
186#define GT_PCI1_IACK_OFS 0xc30
187#define GT_PCI0_IACK_OFS 0xc34
188
189#define GT_PCI0_BARE_OFS 0xc3c
190#define GT_PCI0_PREFMBR_OFS 0xc40
191
192#define GT_PCI0_SCS10_BAR_OFS 0xc48
193#define GT_PCI0_SCS32_BAR_OFS 0xc4c
194#define GT_PCI0_CS20_BAR_OFS 0xc50
195#define GT_PCI0_CS3BT_BAR_OFS 0xc54
196#define GT_PCI0_SSCS10_BAR_OFS 0xc58
197#define GT_PCI0_SSCS32_BAR_OFS 0xc5c
198
199#define GT_PCI0_SCS3BT_BAR_OFS 0xc64
200
201#define GT_PCI1_CMD_OFS 0xc80
202#define GT_PCI1_TOR_OFS 0xc84
203#define GT_PCI1_BS_SCS10_OFS 0xc88
204#define GT_PCI1_BS_SCS32_OFS 0xc8c
205#define GT_PCI1_BS_CS20_OFS 0xc90
206#define GT_PCI1_BS_CS3BT_OFS 0xc94
207
208#define GT_PCI1_BARE_OFS 0xcbc
209#define GT_PCI1_PREFMBR_OFS 0xcc0
210
211#define GT_PCI1_SCS10_BAR_OFS 0xcc8
212#define GT_PCI1_SCS32_BAR_OFS 0xccc
213#define GT_PCI1_CS20_BAR_OFS 0xcd0
214#define GT_PCI1_CS3BT_BAR_OFS 0xcd4
215#define GT_PCI1_SSCS10_BAR_OFS 0xcd8
216#define GT_PCI1_SSCS32_BAR_OFS 0xcdc
217
218#define GT_PCI1_SCS3BT_BAR_OFS 0xce4
219
220#define GT_PCI1_CFGADDR_OFS 0xcf0
221#define GT_PCI1_CFGDATA_OFS 0xcf4
222#define GT_PCI0_CFGADDR_OFS 0xcf8
223#define GT_PCI0_CFGDATA_OFS 0xcfc
224
225/* Interrupts. */
226#define GT_INTRCAUSE_OFS 0xc18
227#define GT_INTRMASK_OFS 0xc1c
228
229#define GT_PCI0_ICMASK_OFS 0xc24
230#define GT_PCI0_SERR0MASK_OFS 0xc28
231
232#define GT_CPU_INTSEL_OFS 0xc70
233#define GT_PCI0_INTSEL_OFS 0xc74
234
235#define GT_HINTRCAUSE_OFS 0xc98
236#define GT_HINTRMASK_OFS 0xc9c
237
238#define GT_PCI0_HICMASK_OFS 0xca4
239#define GT_PCI1_SERR1MASK_OFS 0xca8
240
241
242/*
243 * I2O Support Registers
244 */
245#define INBOUND_MESSAGE_REGISTER0_PCI_SIDE 0x010
246#define INBOUND_MESSAGE_REGISTER1_PCI_SIDE 0x014
247#define OUTBOUND_MESSAGE_REGISTER0_PCI_SIDE 0x018
248#define OUTBOUND_MESSAGE_REGISTER1_PCI_SIDE 0x01c
249#define INBOUND_DOORBELL_REGISTER_PCI_SIDE 0x020
250#define INBOUND_INTERRUPT_CAUSE_REGISTER_PCI_SIDE 0x024
251#define INBOUND_INTERRUPT_MASK_REGISTER_PCI_SIDE 0x028
252#define OUTBOUND_DOORBELL_REGISTER_PCI_SIDE 0x02c
253#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_PCI_SIDE 0x030
254#define OUTBOUND_INTERRUPT_MASK_REGISTER_PCI_SIDE 0x034
255#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI_SIDE 0x040
256#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI_SIDE 0x044
257#define QUEUE_CONTROL_REGISTER_PCI_SIDE 0x050
258#define QUEUE_BASE_ADDRESS_REGISTER_PCI_SIDE 0x054
259#define INBOUND_FREE_HEAD_POINTER_REGISTER_PCI_SIDE 0x060
260#define INBOUND_FREE_TAIL_POINTER_REGISTER_PCI_SIDE 0x064
261#define INBOUND_POST_HEAD_POINTER_REGISTER_PCI_SIDE 0x068
262#define INBOUND_POST_TAIL_POINTER_REGISTER_PCI_SIDE 0x06c
263#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_PCI_SIDE 0x070
264#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_PCI_SIDE 0x074
265#define OUTBOUND_POST_HEAD_POINTER_REGISTER_PCI_SIDE 0x078
266#define OUTBOUND_POST_TAIL_POINTER_REGISTER_PCI_SIDE 0x07c
267
268#define INBOUND_MESSAGE_REGISTER0_CPU_SIDE 0x1c10
269#define INBOUND_MESSAGE_REGISTER1_CPU_SIDE 0x1c14
270#define OUTBOUND_MESSAGE_REGISTER0_CPU_SIDE 0x1c18
271#define OUTBOUND_MESSAGE_REGISTER1_CPU_SIDE 0x1c1c
272#define INBOUND_DOORBELL_REGISTER_CPU_SIDE 0x1c20
273#define INBOUND_INTERRUPT_CAUSE_REGISTER_CPU_SIDE 0x1c24
274#define INBOUND_INTERRUPT_MASK_REGISTER_CPU_SIDE 0x1c28
275#define OUTBOUND_DOORBELL_REGISTER_CPU_SIDE 0x1c2c
276#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_CPU_SIDE 0x1c30
277#define OUTBOUND_INTERRUPT_MASK_REGISTER_CPU_SIDE 0x1c34
278#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU_SIDE 0x1c40
279#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU_SIDE 0x1c44
280#define QUEUE_CONTROL_REGISTER_CPU_SIDE 0x1c50
281#define QUEUE_BASE_ADDRESS_REGISTER_CPU_SIDE 0x1c54
282#define INBOUND_FREE_HEAD_POINTER_REGISTER_CPU_SIDE 0x1c60
283#define INBOUND_FREE_TAIL_POINTER_REGISTER_CPU_SIDE 0x1c64
284#define INBOUND_POST_HEAD_POINTER_REGISTER_CPU_SIDE 0x1c68
285#define INBOUND_POST_TAIL_POINTER_REGISTER_CPU_SIDE 0x1c6c
286#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_CPU_SIDE 0x1c70
287#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_CPU_SIDE 0x1c74
288#define OUTBOUND_POST_HEAD_POINTER_REGISTER_CPU_SIDE 0x1c78
289#define OUTBOUND_POST_TAIL_POINTER_REGISTER_CPU_SIDE 0x1c7c
290
291/*
292 * Register encodings
293 */
294#define GT_CPU_ENDIAN_SHF 12
295#define GT_CPU_ENDIAN_MSK (MSK(1) << GT_CPU_ENDIAN_SHF)
296#define GT_CPU_ENDIAN_BIT GT_CPU_ENDIAN_MSK
297#define GT_CPU_WR_SHF 16
298#define GT_CPU_WR_MSK (MSK(1) << GT_CPU_WR_SHF)
299#define GT_CPU_WR_BIT GT_CPU_WR_MSK
300#define GT_CPU_WR_DXDXDXDX 0
301#define GT_CPU_WR_DDDD 1
302
303
304#define GT_PCI_DCRM_SHF 21
305#define GT_PCI_LD_SHF 0
306#define GT_PCI_LD_MSK (MSK(15) << GT_PCI_LD_SHF)
307#define GT_PCI_HD_SHF 0
308#define GT_PCI_HD_MSK (MSK(7) << GT_PCI_HD_SHF)
309#define GT_PCI_REMAP_SHF 0
310#define GT_PCI_REMAP_MSK (MSK(11) << GT_PCI_REMAP_SHF)
311
312
313#define GT_CFGADDR_CFGEN_SHF 31
314#define GT_CFGADDR_CFGEN_MSK (MSK(1) << GT_CFGADDR_CFGEN_SHF)
315#define GT_CFGADDR_CFGEN_BIT GT_CFGADDR_CFGEN_MSK
316
317#define GT_CFGADDR_BUSNUM_SHF 16
318#define GT_CFGADDR_BUSNUM_MSK (MSK(8) << GT_CFGADDR_BUSNUM_SHF)
319
320#define GT_CFGADDR_DEVNUM_SHF 11
321#define GT_CFGADDR_DEVNUM_MSK (MSK(5) << GT_CFGADDR_DEVNUM_SHF)
322
323#define GT_CFGADDR_FUNCNUM_SHF 8
324#define GT_CFGADDR_FUNCNUM_MSK (MSK(3) << GT_CFGADDR_FUNCNUM_SHF)
325
326#define GT_CFGADDR_REGNUM_SHF 2
327#define GT_CFGADDR_REGNUM_MSK (MSK(6) << GT_CFGADDR_REGNUM_SHF)
328
329
330#define GT_SDRAM_BM_ORDER_SHF 2
331#define GT_SDRAM_BM_ORDER_MSK (MSK(1) << GT_SDRAM_BM_ORDER_SHF)
332#define GT_SDRAM_BM_ORDER_BIT GT_SDRAM_BM_ORDER_MSK
333#define GT_SDRAM_BM_ORDER_SUB 1
334#define GT_SDRAM_BM_ORDER_LIN 0
335
336#define GT_SDRAM_BM_RSVD_ALL1 0xffb
337
338
339#define GT_SDRAM_ADDRDECODE_ADDR_SHF 0
340#define GT_SDRAM_ADDRDECODE_ADDR_MSK (MSK(3) << GT_SDRAM_ADDRDECODE_ADDR_SHF)
341#define GT_SDRAM_ADDRDECODE_ADDR_0 0
342#define GT_SDRAM_ADDRDECODE_ADDR_1 1
343#define GT_SDRAM_ADDRDECODE_ADDR_2 2
344#define GT_SDRAM_ADDRDECODE_ADDR_3 3
345#define GT_SDRAM_ADDRDECODE_ADDR_4 4
346#define GT_SDRAM_ADDRDECODE_ADDR_5 5
347#define GT_SDRAM_ADDRDECODE_ADDR_6 6
348#define GT_SDRAM_ADDRDECODE_ADDR_7 7
349
350
351#define GT_SDRAM_B0_CASLAT_SHF 0
352#define GT_SDRAM_B0_CASLAT_MSK (MSK(2) << GT_SDRAM_B0__SHF)
353#define GT_SDRAM_B0_CASLAT_2 1
354#define GT_SDRAM_B0_CASLAT_3 2
355
356#define GT_SDRAM_B0_FTDIS_SHF 2
357#define GT_SDRAM_B0_FTDIS_MSK (MSK(1) << GT_SDRAM_B0_FTDIS_SHF)
358#define GT_SDRAM_B0_FTDIS_BIT GT_SDRAM_B0_FTDIS_MSK
359
360#define GT_SDRAM_B0_SRASPRCHG_SHF 3
361#define GT_SDRAM_B0_SRASPRCHG_MSK (MSK(1) << GT_SDRAM_B0_SRASPRCHG_SHF)
362#define GT_SDRAM_B0_SRASPRCHG_BIT GT_SDRAM_B0_SRASPRCHG_MSK
363#define GT_SDRAM_B0_SRASPRCHG_2 0
364#define GT_SDRAM_B0_SRASPRCHG_3 1
365
366#define GT_SDRAM_B0_B0COMPAB_SHF 4
367#define GT_SDRAM_B0_B0COMPAB_MSK (MSK(1) << GT_SDRAM_B0_B0COMPAB_SHF)
368#define GT_SDRAM_B0_B0COMPAB_BIT GT_SDRAM_B0_B0COMPAB_MSK
369
370#define GT_SDRAM_B0_64BITINT_SHF 5
371#define GT_SDRAM_B0_64BITINT_MSK (MSK(1) << GT_SDRAM_B0_64BITINT_SHF)
372#define GT_SDRAM_B0_64BITINT_BIT GT_SDRAM_B0_64BITINT_MSK
373#define GT_SDRAM_B0_64BITINT_2 0
374#define GT_SDRAM_B0_64BITINT_4 1
375
376#define GT_SDRAM_B0_BW_SHF 6
377#define GT_SDRAM_B0_BW_MSK (MSK(1) << GT_SDRAM_B0_BW_SHF)
378#define GT_SDRAM_B0_BW_BIT GT_SDRAM_B0_BW_MSK
379#define GT_SDRAM_B0_BW_32 0
380#define GT_SDRAM_B0_BW_64 1
381
382#define GT_SDRAM_B0_BLODD_SHF 7
383#define GT_SDRAM_B0_BLODD_MSK (MSK(1) << GT_SDRAM_B0_BLODD_SHF)
384#define GT_SDRAM_B0_BLODD_BIT GT_SDRAM_B0_BLODD_MSK
385
386#define GT_SDRAM_B0_PAR_SHF 8
387#define GT_SDRAM_B0_PAR_MSK (MSK(1) << GT_SDRAM_B0_PAR_SHF)
388#define GT_SDRAM_B0_PAR_BIT GT_SDRAM_B0_PAR_MSK
389
390#define GT_SDRAM_B0_BYPASS_SHF 9
391#define GT_SDRAM_B0_BYPASS_MSK (MSK(1) << GT_SDRAM_B0_BYPASS_SHF)
392#define GT_SDRAM_B0_BYPASS_BIT GT_SDRAM_B0_BYPASS_MSK
393
394#define GT_SDRAM_B0_SRAS2SCAS_SHF 10
395#define GT_SDRAM_B0_SRAS2SCAS_MSK (MSK(1) << GT_SDRAM_B0_SRAS2SCAS_SHF)
396#define GT_SDRAM_B0_SRAS2SCAS_BIT GT_SDRAM_B0_SRAS2SCAS_MSK
397#define GT_SDRAM_B0_SRAS2SCAS_2 0
398#define GT_SDRAM_B0_SRAS2SCAS_3 1
399
400#define GT_SDRAM_B0_SIZE_SHF 11
401#define GT_SDRAM_B0_SIZE_MSK (MSK(1) << GT_SDRAM_B0_SIZE_SHF)
402#define GT_SDRAM_B0_SIZE_BIT GT_SDRAM_B0_SIZE_MSK
403#define GT_SDRAM_B0_SIZE_16M 0
404#define GT_SDRAM_B0_SIZE_64M 1
405
406#define GT_SDRAM_B0_EXTPAR_SHF 12
407#define GT_SDRAM_B0_EXTPAR_MSK (MSK(1) << GT_SDRAM_B0_EXTPAR_SHF)
408#define GT_SDRAM_B0_EXTPAR_BIT GT_SDRAM_B0_EXTPAR_MSK
409
410#define GT_SDRAM_B0_BLEN_SHF 13
411#define GT_SDRAM_B0_BLEN_MSK (MSK(1) << GT_SDRAM_B0_BLEN_SHF)
412#define GT_SDRAM_B0_BLEN_BIT GT_SDRAM_B0_BLEN_MSK
413#define GT_SDRAM_B0_BLEN_8 0
414#define GT_SDRAM_B0_BLEN_4 1
415
416
417#define GT_SDRAM_CFG_REFINT_SHF 0
418#define GT_SDRAM_CFG_REFINT_MSK (MSK(14) << GT_SDRAM_CFG_REFINT_SHF)
419
420#define GT_SDRAM_CFG_NINTERLEAVE_SHF 14
421#define GT_SDRAM_CFG_NINTERLEAVE_MSK (MSK(1) << GT_SDRAM_CFG_NINTERLEAVE_SHF)
422#define GT_SDRAM_CFG_NINTERLEAVE_BIT GT_SDRAM_CFG_NINTERLEAVE_MSK
423
424#define GT_SDRAM_CFG_RMW_SHF 15
425#define GT_SDRAM_CFG_RMW_MSK (MSK(1) << GT_SDRAM_CFG_RMW_SHF)
426#define GT_SDRAM_CFG_RMW_BIT GT_SDRAM_CFG_RMW_MSK
427
428#define GT_SDRAM_CFG_NONSTAGREF_SHF 16
429#define GT_SDRAM_CFG_NONSTAGREF_MSK (MSK(1) << GT_SDRAM_CFG_NONSTAGREF_SHF)
430#define GT_SDRAM_CFG_NONSTAGREF_BIT GT_SDRAM_CFG_NONSTAGREF_MSK
431
432#define GT_SDRAM_CFG_DUPCNTL_SHF 19
433#define GT_SDRAM_CFG_DUPCNTL_MSK (MSK(1) << GT_SDRAM_CFG_DUPCNTL_SHF)
434#define GT_SDRAM_CFG_DUPCNTL_BIT GT_SDRAM_CFG_DUPCNTL_MSK
435
436#define GT_SDRAM_CFG_DUPBA_SHF 20
437#define GT_SDRAM_CFG_DUPBA_MSK (MSK(1) << GT_SDRAM_CFG_DUPBA_SHF)
438#define GT_SDRAM_CFG_DUPBA_BIT GT_SDRAM_CFG_DUPBA_MSK
439
440#define GT_SDRAM_CFG_DUPEOT0_SHF 21
441#define GT_SDRAM_CFG_DUPEOT0_MSK (MSK(1) << GT_SDRAM_CFG_DUPEOT0_SHF)
442#define GT_SDRAM_CFG_DUPEOT0_BIT GT_SDRAM_CFG_DUPEOT0_MSK
443
444#define GT_SDRAM_CFG_DUPEOT1_SHF 22
445#define GT_SDRAM_CFG_DUPEOT1_MSK (MSK(1) << GT_SDRAM_CFG_DUPEOT1_SHF)
446#define GT_SDRAM_CFG_DUPEOT1_BIT GT_SDRAM_CFG_DUPEOT1_MSK
447
448#define GT_SDRAM_OPMODE_OP_SHF 0
449#define GT_SDRAM_OPMODE_OP_MSK (MSK(3) << GT_SDRAM_OPMODE_OP_SHF)
450#define GT_SDRAM_OPMODE_OP_NORMAL 0
451#define GT_SDRAM_OPMODE_OP_NOP 1
452#define GT_SDRAM_OPMODE_OP_PRCHG 2
453#define GT_SDRAM_OPMODE_OP_MODE 3
454#define GT_SDRAM_OPMODE_OP_CBR 4
455
456#define GT_TC_CONTROL_ENTC0_SHF 0
457#define GT_TC_CONTROL_ENTC0_MSK (MSK(1) << GT_TC_CONTROL_ENTC0_SHF)
458#define GT_TC_CONTROL_ENTC0_BIT GT_TC_CONTROL_ENTC0_MSK
459#define GT_TC_CONTROL_SELTC0_SHF 1
460#define GT_TC_CONTROL_SELTC0_MSK (MSK(1) << GT_TC_CONTROL_SELTC0_SHF)
461#define GT_TC_CONTROL_SELTC0_BIT GT_TC_CONTROL_SELTC0_MSK
462
463
464#define GT_PCI0_BARE_SWSCS3BOOTDIS_SHF 0
465#define GT_PCI0_BARE_SWSCS3BOOTDIS_MSK (MSK(1) << GT_PCI0_BARE_SWSCS3BOOTDIS_SHF)
466#define GT_PCI0_BARE_SWSCS3BOOTDIS_BIT GT_PCI0_BARE_SWSCS3BOOTDIS_MSK
467
468#define GT_PCI0_BARE_SWSCS32DIS_SHF 1
469#define GT_PCI0_BARE_SWSCS32DIS_MSK (MSK(1) << GT_PCI0_BARE_SWSCS32DIS_SHF)
470#define GT_PCI0_BARE_SWSCS32DIS_BIT GT_PCI0_BARE_SWSCS32DIS_MSK
471
472#define GT_PCI0_BARE_SWSCS10DIS_SHF 2
473#define GT_PCI0_BARE_SWSCS10DIS_MSK (MSK(1) << GT_PCI0_BARE_SWSCS10DIS_SHF)
474#define GT_PCI0_BARE_SWSCS10DIS_BIT GT_PCI0_BARE_SWSCS10DIS_MSK
475
476#define GT_PCI0_BARE_INTIODIS_SHF 3
477#define GT_PCI0_BARE_INTIODIS_MSK (MSK(1) << GT_PCI0_BARE_INTIODIS_SHF)
478#define GT_PCI0_BARE_INTIODIS_BIT GT_PCI0_BARE_INTIODIS_MSK
479
480#define GT_PCI0_BARE_INTMEMDIS_SHF 4
481#define GT_PCI0_BARE_INTMEMDIS_MSK (MSK(1) << GT_PCI0_BARE_INTMEMDIS_SHF)
482#define GT_PCI0_BARE_INTMEMDIS_BIT GT_PCI0_BARE_INTMEMDIS_MSK
483
484#define GT_PCI0_BARE_CS3BOOTDIS_SHF 5
485#define GT_PCI0_BARE_CS3BOOTDIS_MSK (MSK(1) << GT_PCI0_BARE_CS3BOOTDIS_SHF)
486#define GT_PCI0_BARE_CS3BOOTDIS_BIT GT_PCI0_BARE_CS3BOOTDIS_MSK
487
488#define GT_PCI0_BARE_CS20DIS_SHF 6
489#define GT_PCI0_BARE_CS20DIS_MSK (MSK(1) << GT_PCI0_BARE_CS20DIS_SHF)
490#define GT_PCI0_BARE_CS20DIS_BIT GT_PCI0_BARE_CS20DIS_MSK
491
492#define GT_PCI0_BARE_SCS32DIS_SHF 7
493#define GT_PCI0_BARE_SCS32DIS_MSK (MSK(1) << GT_PCI0_BARE_SCS32DIS_SHF)
494#define GT_PCI0_BARE_SCS32DIS_BIT GT_PCI0_BARE_SCS32DIS_MSK
495
496#define GT_PCI0_BARE_SCS10DIS_SHF 8
497#define GT_PCI0_BARE_SCS10DIS_MSK (MSK(1) << GT_PCI0_BARE_SCS10DIS_SHF)
498#define GT_PCI0_BARE_SCS10DIS_BIT GT_PCI0_BARE_SCS10DIS_MSK
499
500
501#define GT_INTRCAUSE_MASABORT0_SHF 18
502#define GT_INTRCAUSE_MASABORT0_MSK (MSK(1) << GT_INTRCAUSE_MASABORT0_SHF)
503#define GT_INTRCAUSE_MASABORT0_BIT GT_INTRCAUSE_MASABORT0_MSK
504
505#define GT_INTRCAUSE_TARABORT0_SHF 19
506#define GT_INTRCAUSE_TARABORT0_MSK (MSK(1) << GT_INTRCAUSE_TARABORT0_SHF)
507#define GT_INTRCAUSE_TARABORT0_BIT GT_INTRCAUSE_TARABORT0_MSK
508
509
510#define GT_PCI0_CFGADDR_REGNUM_SHF 2
511#define GT_PCI0_CFGADDR_REGNUM_MSK (MSK(6) << GT_PCI0_CFGADDR_REGNUM_SHF)
512#define GT_PCI0_CFGADDR_FUNCTNUM_SHF 8
513#define GT_PCI0_CFGADDR_FUNCTNUM_MSK (MSK(3) << GT_PCI0_CFGADDR_FUNCTNUM_SHF)
514#define GT_PCI0_CFGADDR_DEVNUM_SHF 11
515#define GT_PCI0_CFGADDR_DEVNUM_MSK (MSK(5) << GT_PCI0_CFGADDR_DEVNUM_SHF)
516#define GT_PCI0_CFGADDR_BUSNUM_SHF 16
517#define GT_PCI0_CFGADDR_BUSNUM_MSK (MSK(8) << GT_PCI0_CFGADDR_BUSNUM_SHF)
518#define GT_PCI0_CFGADDR_CONFIGEN_SHF 31
519#define GT_PCI0_CFGADDR_CONFIGEN_MSK (MSK(1) << GT_PCI0_CFGADDR_CONFIGEN_SHF)
520#define GT_PCI0_CFGADDR_CONFIGEN_BIT GT_PCI0_CFGADDR_CONFIGEN_MSK
521
522#define GT_PCI0_CMD_MBYTESWAP_SHF 0
523#define GT_PCI0_CMD_MBYTESWAP_MSK (MSK(1) << GT_PCI0_CMD_MBYTESWAP_SHF)
524#define GT_PCI0_CMD_MBYTESWAP_BIT GT_PCI0_CMD_MBYTESWAP_MSK
525#define GT_PCI0_CMD_MWORDSWAP_SHF 10
526#define GT_PCI0_CMD_MWORDSWAP_MSK (MSK(1) << GT_PCI0_CMD_MWORDSWAP_SHF)
527#define GT_PCI0_CMD_MWORDSWAP_BIT GT_PCI0_CMD_MWORDSWAP_MSK
528#define GT_PCI0_CMD_SBYTESWAP_SHF 16
529#define GT_PCI0_CMD_SBYTESWAP_MSK (MSK(1) << GT_PCI0_CMD_SBYTESWAP_SHF)
530#define GT_PCI0_CMD_SBYTESWAP_BIT GT_PCI0_CMD_SBYTESWAP_MSK
531#define GT_PCI0_CMD_SWORDSWAP_SHF 11
532#define GT_PCI0_CMD_SWORDSWAP_MSK (MSK(1) << GT_PCI0_CMD_SWORDSWAP_SHF)
533#define GT_PCI0_CMD_SWORDSWAP_BIT GT_PCI0_CMD_SWORDSWAP_MSK
534
535#define GT_INTR_T0EXP_SHF 8
536#define GT_INTR_T0EXP_MSK (MSK(1) << GT_INTR_T0EXP_SHF)
537#define GT_INTR_T0EXP_BIT GT_INTR_T0EXP_MSK
538#define GT_INTR_RETRYCTR0_SHF 20
539#define GT_INTR_RETRYCTR0_MSK (MSK(1) << GT_INTR_RETRYCTR0_SHF)
540#define GT_INTR_RETRYCTR0_BIT GT_INTR_RETRYCTR0_MSK
541
542/*
543 * Misc
544 */
545#define GT_DEF_PCI0_IO_BASE 0x10000000UL
546#define GT_DEF_PCI0_IO_SIZE 0x02000000UL
547#define GT_DEF_PCI0_MEM0_BASE 0x12000000UL
548#define GT_DEF_PCI0_MEM0_SIZE 0x02000000UL
549#define GT_DEF_BASE 0x14000000UL
550
551#define GT_MAX_BANKSIZE (256 * 1024 * 1024) /* Max 256MB bank */
552#define GT_LATTIM_MIN 6 /* Minimum lat */
553
554/*
555 * The gt64120_dep.h file must define the following macros
556 *
557 * GT_READ(ofs, data_pointer)
558 * GT_WRITE(ofs, data) - read/write GT64120 registers in 32bit
559 *
560 * TIMER - gt64120 timer irq, temporary solution until
561 * full gt64120 cascade interrupt support is in place
562 */
563
564#include <mach-gt64120.h>
565
566/*
567 * Because of an error/peculiarity in the Galileo chip, we need to swap the
568 * bytes when running bigendian. We also provide non-swapping versions.
569 */
570#define __GT_READ(ofs) \
571 (*(volatile u32 *)(GT64120_BASE+(ofs)))
572#define __GT_WRITE(ofs, data) \
573 do { *(volatile u32 *)(GT64120_BASE+(ofs)) = (data); } while (0)
574#define GT_READ(ofs) le32_to_cpu(__GT_READ(ofs))
575#define GT_WRITE(ofs, data) __GT_WRITE(ofs, cpu_to_le32(data))
576
577extern void gt641xx_set_base_clock(unsigned int clock);
578extern int gt641xx_timer0_state(void);
579
580#endif /* _ASM_GT64120_H */
diff --git a/arch/mips/include/asm/hardirq.h b/arch/mips/include/asm/hardirq.h
new file mode 100644
index 000000000000..90bf399e6dd9
--- /dev/null
+++ b/arch/mips/include/asm/hardirq.h
@@ -0,0 +1,24 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1997, 98, 99, 2000, 01, 05 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
9 */
10#ifndef _ASM_HARDIRQ_H
11#define _ASM_HARDIRQ_H
12
13#include <linux/threads.h>
14#include <linux/irq.h>
15
16typedef struct {
17 unsigned int __softirq_pending;
18} ____cacheline_aligned irq_cpustat_t;
19
20#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
21
22extern void ack_bad_irq(unsigned int irq);
23
24#endif /* _ASM_HARDIRQ_H */
diff --git a/arch/mips/include/asm/hazards.h b/arch/mips/include/asm/hazards.h
new file mode 100644
index 000000000000..2de638f84c86
--- /dev/null
+++ b/arch/mips/include/asm/hazards.h
@@ -0,0 +1,271 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 04, 07 Ralf Baechle <ralf@linux-mips.org>
7 * Copyright (C) MIPS Technologies, Inc.
8 * written by Ralf Baechle <ralf@linux-mips.org>
9 */
10#ifndef _ASM_HAZARDS_H
11#define _ASM_HAZARDS_H
12
13#ifdef __ASSEMBLY__
14#define ASMMACRO(name, code...) .macro name; code; .endm
15#else
16
17#include <asm/cpu-features.h>
18
19#define ASMMACRO(name, code...) \
20__asm__(".macro " #name "; " #code "; .endm"); \
21 \
22static inline void name(void) \
23{ \
24 __asm__ __volatile__ (#name); \
25}
26
27/*
28 * MIPS R2 instruction hazard barrier. Needs to be called as a subroutine.
29 */
30extern void mips_ihb(void);
31
32#endif
33
34ASMMACRO(_ssnop,
35 sll $0, $0, 1
36 )
37
38ASMMACRO(_ehb,
39 sll $0, $0, 3
40 )
41
42/*
43 * TLB hazards
44 */
45#if defined(CONFIG_CPU_MIPSR2)
46
47/*
48 * MIPSR2 defines ehb for hazard avoidance
49 */
50
51ASMMACRO(mtc0_tlbw_hazard,
52 _ehb
53 )
54ASMMACRO(tlbw_use_hazard,
55 _ehb
56 )
57ASMMACRO(tlb_probe_hazard,
58 _ehb
59 )
60ASMMACRO(irq_enable_hazard,
61 _ehb
62 )
63ASMMACRO(irq_disable_hazard,
64 _ehb
65 )
66ASMMACRO(back_to_back_c0_hazard,
67 _ehb
68 )
69/*
70 * gcc has a tradition of misscompiling the previous construct using the
71 * address of a label as argument to inline assembler. Gas otoh has the
72 * annoying difference between la and dla which are only usable for 32-bit
73 * rsp. 64-bit code, so can't be used without conditional compilation.
74 * The alterantive is switching the assembler to 64-bit code which happens
75 * to work right even for 32-bit code ...
76 */
77#define instruction_hazard() \
78do { \
79 unsigned long tmp; \
80 \
81 __asm__ __volatile__( \
82 " .set mips64r2 \n" \
83 " dla %0, 1f \n" \
84 " jr.hb %0 \n" \
85 " .set mips0 \n" \
86 "1: \n" \
87 : "=r" (tmp)); \
88} while (0)
89
90#elif defined(CONFIG_CPU_MIPSR1)
91
92/*
93 * These are slightly complicated by the fact that we guarantee R1 kernels to
94 * run fine on R2 processors.
95 */
96ASMMACRO(mtc0_tlbw_hazard,
97 _ssnop; _ssnop; _ehb
98 )
99ASMMACRO(tlbw_use_hazard,
100 _ssnop; _ssnop; _ssnop; _ehb
101 )
102ASMMACRO(tlb_probe_hazard,
103 _ssnop; _ssnop; _ssnop; _ehb
104 )
105ASMMACRO(irq_enable_hazard,
106 _ssnop; _ssnop; _ssnop; _ehb
107 )
108ASMMACRO(irq_disable_hazard,
109 _ssnop; _ssnop; _ssnop; _ehb
110 )
111ASMMACRO(back_to_back_c0_hazard,
112 _ssnop; _ssnop; _ssnop; _ehb
113 )
114/*
115 * gcc has a tradition of misscompiling the previous construct using the
116 * address of a label as argument to inline assembler. Gas otoh has the
117 * annoying difference between la and dla which are only usable for 32-bit
118 * rsp. 64-bit code, so can't be used without conditional compilation.
119 * The alterantive is switching the assembler to 64-bit code which happens
120 * to work right even for 32-bit code ...
121 */
122#define __instruction_hazard() \
123do { \
124 unsigned long tmp; \
125 \
126 __asm__ __volatile__( \
127 " .set mips64r2 \n" \
128 " dla %0, 1f \n" \
129 " jr.hb %0 \n" \
130 " .set mips0 \n" \
131 "1: \n" \
132 : "=r" (tmp)); \
133} while (0)
134
135#define instruction_hazard() \
136do { \
137 if (cpu_has_mips_r2) \
138 __instruction_hazard(); \
139} while (0)
140
141#elif defined(CONFIG_CPU_R10000)
142
143/*
144 * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer.
145 */
146
147ASMMACRO(mtc0_tlbw_hazard,
148 )
149ASMMACRO(tlbw_use_hazard,
150 )
151ASMMACRO(tlb_probe_hazard,
152 )
153ASMMACRO(irq_enable_hazard,
154 )
155ASMMACRO(irq_disable_hazard,
156 )
157ASMMACRO(back_to_back_c0_hazard,
158 )
159#define instruction_hazard() do { } while (0)
160
161#elif defined(CONFIG_CPU_RM9000)
162
163/*
164 * RM9000 hazards. When the JTLB is updated by tlbwi or tlbwr, a subsequent
165 * use of the JTLB for instructions should not occur for 4 cpu cycles and use
166 * for data translations should not occur for 3 cpu cycles.
167 */
168
169ASMMACRO(mtc0_tlbw_hazard,
170 _ssnop; _ssnop; _ssnop; _ssnop
171 )
172ASMMACRO(tlbw_use_hazard,
173 _ssnop; _ssnop; _ssnop; _ssnop
174 )
175ASMMACRO(tlb_probe_hazard,
176 _ssnop; _ssnop; _ssnop; _ssnop
177 )
178ASMMACRO(irq_enable_hazard,
179 )
180ASMMACRO(irq_disable_hazard,
181 )
182ASMMACRO(back_to_back_c0_hazard,
183 )
184#define instruction_hazard() do { } while (0)
185
186#elif defined(CONFIG_CPU_SB1)
187
188/*
189 * Mostly like R4000 for historic reasons
190 */
191ASMMACRO(mtc0_tlbw_hazard,
192 )
193ASMMACRO(tlbw_use_hazard,
194 )
195ASMMACRO(tlb_probe_hazard,
196 )
197ASMMACRO(irq_enable_hazard,
198 )
199ASMMACRO(irq_disable_hazard,
200 _ssnop; _ssnop; _ssnop
201 )
202ASMMACRO(back_to_back_c0_hazard,
203 )
204#define instruction_hazard() do { } while (0)
205
206#else
207
208/*
209 * Finally the catchall case for all other processors including R4000, R4400,
210 * R4600, R4700, R5000, RM7000, NEC VR41xx etc.
211 *
212 * The taken branch will result in a two cycle penalty for the two killed
213 * instructions on R4000 / R4400. Other processors only have a single cycle
214 * hazard so this is nice trick to have an optimal code for a range of
215 * processors.
216 */
217ASMMACRO(mtc0_tlbw_hazard,
218 nop; nop
219 )
220ASMMACRO(tlbw_use_hazard,
221 nop; nop; nop
222 )
223ASMMACRO(tlb_probe_hazard,
224 nop; nop; nop
225 )
226ASMMACRO(irq_enable_hazard,
227 _ssnop; _ssnop; _ssnop;
228 )
229ASMMACRO(irq_disable_hazard,
230 nop; nop; nop
231 )
232ASMMACRO(back_to_back_c0_hazard,
233 _ssnop; _ssnop; _ssnop;
234 )
235#define instruction_hazard() do { } while (0)
236
237#endif
238
239
240/* FPU hazards */
241
242#if defined(CONFIG_CPU_SB1)
243ASMMACRO(enable_fpu_hazard,
244 .set push;
245 .set mips64;
246 .set noreorder;
247 _ssnop;
248 bnezl $0, .+4;
249 _ssnop;
250 .set pop
251)
252ASMMACRO(disable_fpu_hazard,
253)
254
255#elif defined(CONFIG_CPU_MIPSR2)
256ASMMACRO(enable_fpu_hazard,
257 _ehb
258)
259ASMMACRO(disable_fpu_hazard,
260 _ehb
261)
262#else
263ASMMACRO(enable_fpu_hazard,
264 nop; nop; nop; nop
265)
266ASMMACRO(disable_fpu_hazard,
267 _ehb
268)
269#endif
270
271#endif /* _ASM_HAZARDS_H */
diff --git a/arch/mips/include/asm/highmem.h b/arch/mips/include/asm/highmem.h
new file mode 100644
index 000000000000..4374ab2adc75
--- /dev/null
+++ b/arch/mips/include/asm/highmem.h
@@ -0,0 +1,67 @@
1/*
2 * highmem.h: virtual kernel memory mappings for high memory
3 *
4 * Used in CONFIG_HIGHMEM systems for memory pages which
5 * are not addressable by direct kernel virtual addresses.
6 *
7 * Copyright (C) 1999 Gerhard Wichert, Siemens AG
8 * Gerhard.Wichert@pdb.siemens.de
9 *
10 *
11 * Redesigned the x86 32-bit VM architecture to deal with
12 * up to 16 Terabyte physical memory. With current x86 CPUs
13 * we now support up to 64 Gigabytes physical RAM.
14 *
15 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
16 */
17#ifndef _ASM_HIGHMEM_H
18#define _ASM_HIGHMEM_H
19
20#ifdef __KERNEL__
21
22#include <linux/init.h>
23#include <linux/interrupt.h>
24#include <linux/uaccess.h>
25#include <asm/kmap_types.h>
26
27/* undef for production */
28#define HIGHMEM_DEBUG 1
29
30/* declarations for highmem.c */
31extern unsigned long highstart_pfn, highend_pfn;
32
33extern pte_t *kmap_pte;
34extern pgprot_t kmap_prot;
35extern pte_t *pkmap_page_table;
36
37/*
38 * Right now we initialize only a single pte table. It can be extended
39 * easily, subsequent pte tables have to be allocated in one physical
40 * chunk of RAM.
41 */
42#define LAST_PKMAP 1024
43#define LAST_PKMAP_MASK (LAST_PKMAP-1)
44#define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT)
45#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
46
47extern void * kmap_high(struct page *page);
48extern void kunmap_high(struct page *page);
49
50extern void *__kmap(struct page *page);
51extern void __kunmap(struct page *page);
52extern void *__kmap_atomic(struct page *page, enum km_type type);
53extern void __kunmap_atomic(void *kvaddr, enum km_type type);
54extern void *kmap_atomic_pfn(unsigned long pfn, enum km_type type);
55extern struct page *__kmap_atomic_to_page(void *ptr);
56
57#define kmap __kmap
58#define kunmap __kunmap
59#define kmap_atomic __kmap_atomic
60#define kunmap_atomic __kunmap_atomic
61#define kmap_atomic_to_page __kmap_atomic_to_page
62
63#define flush_cache_kmaps() flush_cache_all()
64
65#endif /* __KERNEL__ */
66
67#endif /* _ASM_HIGHMEM_H */
diff --git a/arch/mips/include/asm/hw_irq.h b/arch/mips/include/asm/hw_irq.h
new file mode 100644
index 000000000000..aca05a43a97b
--- /dev/null
+++ b/arch/mips/include/asm/hw_irq.h
@@ -0,0 +1,20 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000, 2001, 2002 by Ralf Baechle
7 */
8#ifndef __ASM_HW_IRQ_H
9#define __ASM_HW_IRQ_H
10
11#include <asm/atomic.h>
12
13extern atomic_t irq_err_count;
14
15/*
16 * interrupt-retrigger: NOP for now. This may not be apropriate for all
17 * machines, we'll see ...
18 */
19
20#endif /* __ASM_HW_IRQ_H */
diff --git a/arch/mips/include/asm/i8253.h b/arch/mips/include/asm/i8253.h
new file mode 100644
index 000000000000..5dabc870b322
--- /dev/null
+++ b/arch/mips/include/asm/i8253.h
@@ -0,0 +1,21 @@
1/*
2 * Machine specific IO port address definition for generic.
3 * Written by Osamu Tomita <tomita@cinet.co.jp>
4 */
5#ifndef __ASM_I8253_H
6#define __ASM_I8253_H
7
8#include <linux/spinlock.h>
9
10/* i8253A PIT registers */
11#define PIT_MODE 0x43
12#define PIT_CH0 0x40
13#define PIT_CH2 0x42
14
15#define PIT_TICK_RATE 1193182UL
16
17extern spinlock_t i8253_lock;
18
19extern void setup_pit_timer(void);
20
21#endif /* __ASM_I8253_H */
diff --git a/arch/mips/include/asm/i8259.h b/arch/mips/include/asm/i8259.h
new file mode 100644
index 000000000000..8572a2d90484
--- /dev/null
+++ b/arch/mips/include/asm/i8259.h
@@ -0,0 +1,86 @@
1/*
2 * include/asm-mips/i8259.h
3 *
4 * i8259A interrupt definitions.
5 *
6 * Copyright (C) 2003 Maciej W. Rozycki
7 * Copyright (C) 2003 Ralf Baechle <ralf@linux-mips.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14#ifndef _ASM_I8259_H
15#define _ASM_I8259_H
16
17#include <linux/compiler.h>
18#include <linux/spinlock.h>
19
20#include <asm/io.h>
21#include <irq.h>
22
23/* i8259A PIC registers */
24#define PIC_MASTER_CMD 0x20
25#define PIC_MASTER_IMR 0x21
26#define PIC_MASTER_ISR PIC_MASTER_CMD
27#define PIC_MASTER_POLL PIC_MASTER_ISR
28#define PIC_MASTER_OCW3 PIC_MASTER_ISR
29#define PIC_SLAVE_CMD 0xa0
30#define PIC_SLAVE_IMR 0xa1
31
32/* i8259A PIC related value */
33#define PIC_CASCADE_IR 2
34#define MASTER_ICW4_DEFAULT 0x01
35#define SLAVE_ICW4_DEFAULT 0x01
36#define PIC_ICW4_AEOI 2
37
38extern spinlock_t i8259A_lock;
39
40extern int i8259A_irq_pending(unsigned int irq);
41extern void make_8259A_irq(unsigned int irq);
42
43extern void init_i8259_irqs(void);
44
45/*
46 * Do the traditional i8259 interrupt polling thing. This is for the few
47 * cases where no better interrupt acknowledge method is available and we
48 * absolutely must touch the i8259.
49 */
50static inline int i8259_irq(void)
51{
52 int irq;
53
54 spin_lock(&i8259A_lock);
55
56 /* Perform an interrupt acknowledge cycle on controller 1. */
57 outb(0x0C, PIC_MASTER_CMD); /* prepare for poll */
58 irq = inb(PIC_MASTER_CMD) & 7;
59 if (irq == PIC_CASCADE_IR) {
60 /*
61 * Interrupt is cascaded so perform interrupt
62 * acknowledge on controller 2.
63 */
64 outb(0x0C, PIC_SLAVE_CMD); /* prepare for poll */
65 irq = (inb(PIC_SLAVE_CMD) & 7) + 8;
66 }
67
68 if (unlikely(irq == 7)) {
69 /*
70 * This may be a spurious interrupt.
71 *
72 * Read the interrupt status register (ISR). If the most
73 * significant bit is not set then there is no valid
74 * interrupt.
75 */
76 outb(0x0B, PIC_MASTER_ISR); /* ISR register */
77 if(~inb(PIC_MASTER_ISR) & 0x80)
78 irq = -1;
79 }
80
81 spin_unlock(&i8259A_lock);
82
83 return likely(irq >= 0) ? irq + I8259A_IRQ_BASE : irq;
84}
85
86#endif /* _ASM_I8259_H */
diff --git a/arch/mips/include/asm/ide.h b/arch/mips/include/asm/ide.h
new file mode 100644
index 000000000000..bb674c3b0303
--- /dev/null
+++ b/arch/mips/include/asm/ide.h
@@ -0,0 +1,13 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * This file contains the MIPS architecture specific IDE code.
7 */
8#ifndef __ASM_IDE_H
9#define __ASM_IDE_H
10
11#include <ide.h>
12
13#endif /* __ASM_IDE_H */
diff --git a/arch/mips/include/asm/inst.h b/arch/mips/include/asm/inst.h
new file mode 100644
index 000000000000..6489f00731ca
--- /dev/null
+++ b/arch/mips/include/asm/inst.h
@@ -0,0 +1,394 @@
1/*
2 * Format of an instruction in memory.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1996, 2000 by Ralf Baechle
9 * Copyright (C) 2006 by Thiemo Seufer
10 */
11#ifndef _ASM_INST_H
12#define _ASM_INST_H
13
14/*
15 * Major opcodes; before MIPS IV cop1x was called cop3.
16 */
17enum major_op {
18 spec_op, bcond_op, j_op, jal_op,
19 beq_op, bne_op, blez_op, bgtz_op,
20 addi_op, addiu_op, slti_op, sltiu_op,
21 andi_op, ori_op, xori_op, lui_op,
22 cop0_op, cop1_op, cop2_op, cop1x_op,
23 beql_op, bnel_op, blezl_op, bgtzl_op,
24 daddi_op, daddiu_op, ldl_op, ldr_op,
25 spec2_op, jalx_op, mdmx_op, spec3_op,
26 lb_op, lh_op, lwl_op, lw_op,
27 lbu_op, lhu_op, lwr_op, lwu_op,
28 sb_op, sh_op, swl_op, sw_op,
29 sdl_op, sdr_op, swr_op, cache_op,
30 ll_op, lwc1_op, lwc2_op, pref_op,
31 lld_op, ldc1_op, ldc2_op, ld_op,
32 sc_op, swc1_op, swc2_op, major_3b_op,
33 scd_op, sdc1_op, sdc2_op, sd_op
34};
35
36/*
37 * func field of spec opcode.
38 */
39enum spec_op {
40 sll_op, movc_op, srl_op, sra_op,
41 sllv_op, pmon_op, srlv_op, srav_op,
42 jr_op, jalr_op, movz_op, movn_op,
43 syscall_op, break_op, spim_op, sync_op,
44 mfhi_op, mthi_op, mflo_op, mtlo_op,
45 dsllv_op, spec2_unused_op, dsrlv_op, dsrav_op,
46 mult_op, multu_op, div_op, divu_op,
47 dmult_op, dmultu_op, ddiv_op, ddivu_op,
48 add_op, addu_op, sub_op, subu_op,
49 and_op, or_op, xor_op, nor_op,
50 spec3_unused_op, spec4_unused_op, slt_op, sltu_op,
51 dadd_op, daddu_op, dsub_op, dsubu_op,
52 tge_op, tgeu_op, tlt_op, tltu_op,
53 teq_op, spec5_unused_op, tne_op, spec6_unused_op,
54 dsll_op, spec7_unused_op, dsrl_op, dsra_op,
55 dsll32_op, spec8_unused_op, dsrl32_op, dsra32_op
56};
57
58/*
59 * func field of spec2 opcode.
60 */
61enum spec2_op {
62 madd_op, maddu_op, mul_op, spec2_3_unused_op,
63 msub_op, msubu_op, /* more unused ops */
64 clz_op = 0x20, clo_op,
65 dclz_op = 0x24, dclo_op,
66 sdbpp_op = 0x3f
67};
68
69/*
70 * func field of spec3 opcode.
71 */
72enum spec3_op {
73 ext_op, dextm_op, dextu_op, dext_op,
74 ins_op, dinsm_op, dinsu_op, dins_op,
75 bshfl_op = 0x20,
76 dbshfl_op = 0x24,
77 rdhwr_op = 0x3b
78};
79
80/*
81 * rt field of bcond opcodes.
82 */
83enum rt_op {
84 bltz_op, bgez_op, bltzl_op, bgezl_op,
85 spimi_op, unused_rt_op_0x05, unused_rt_op_0x06, unused_rt_op_0x07,
86 tgei_op, tgeiu_op, tlti_op, tltiu_op,
87 teqi_op, unused_0x0d_rt_op, tnei_op, unused_0x0f_rt_op,
88 bltzal_op, bgezal_op, bltzall_op, bgezall_op,
89 rt_op_0x14, rt_op_0x15, rt_op_0x16, rt_op_0x17,
90 rt_op_0x18, rt_op_0x19, rt_op_0x1a, rt_op_0x1b,
91 bposge32_op, rt_op_0x1d, rt_op_0x1e, rt_op_0x1f
92};
93
94/*
95 * rs field of cop opcodes.
96 */
97enum cop_op {
98 mfc_op = 0x00, dmfc_op = 0x01,
99 cfc_op = 0x02, mtc_op = 0x04,
100 dmtc_op = 0x05, ctc_op = 0x06,
101 bc_op = 0x08, cop_op = 0x10,
102 copm_op = 0x18
103};
104
105/*
106 * rt field of cop.bc_op opcodes
107 */
108enum bcop_op {
109 bcf_op, bct_op, bcfl_op, bctl_op
110};
111
112/*
113 * func field of cop0 coi opcodes.
114 */
115enum cop0_coi_func {
116 tlbr_op = 0x01, tlbwi_op = 0x02,
117 tlbwr_op = 0x06, tlbp_op = 0x08,
118 rfe_op = 0x10, eret_op = 0x18
119};
120
121/*
122 * func field of cop0 com opcodes.
123 */
124enum cop0_com_func {
125 tlbr1_op = 0x01, tlbw_op = 0x02,
126 tlbp1_op = 0x08, dctr_op = 0x09,
127 dctw_op = 0x0a
128};
129
130/*
131 * fmt field of cop1 opcodes.
132 */
133enum cop1_fmt {
134 s_fmt, d_fmt, e_fmt, q_fmt,
135 w_fmt, l_fmt
136};
137
138/*
139 * func field of cop1 instructions using d, s or w format.
140 */
141enum cop1_sdw_func {
142 fadd_op = 0x00, fsub_op = 0x01,
143 fmul_op = 0x02, fdiv_op = 0x03,
144 fsqrt_op = 0x04, fabs_op = 0x05,
145 fmov_op = 0x06, fneg_op = 0x07,
146 froundl_op = 0x08, ftruncl_op = 0x09,
147 fceill_op = 0x0a, ffloorl_op = 0x0b,
148 fround_op = 0x0c, ftrunc_op = 0x0d,
149 fceil_op = 0x0e, ffloor_op = 0x0f,
150 fmovc_op = 0x11, fmovz_op = 0x12,
151 fmovn_op = 0x13, frecip_op = 0x15,
152 frsqrt_op = 0x16, fcvts_op = 0x20,
153 fcvtd_op = 0x21, fcvte_op = 0x22,
154 fcvtw_op = 0x24, fcvtl_op = 0x25,
155 fcmp_op = 0x30
156};
157
158/*
159 * func field of cop1x opcodes (MIPS IV).
160 */
161enum cop1x_func {
162 lwxc1_op = 0x00, ldxc1_op = 0x01,
163 pfetch_op = 0x07, swxc1_op = 0x08,
164 sdxc1_op = 0x09, madd_s_op = 0x20,
165 madd_d_op = 0x21, madd_e_op = 0x22,
166 msub_s_op = 0x28, msub_d_op = 0x29,
167 msub_e_op = 0x2a, nmadd_s_op = 0x30,
168 nmadd_d_op = 0x31, nmadd_e_op = 0x32,
169 nmsub_s_op = 0x38, nmsub_d_op = 0x39,
170 nmsub_e_op = 0x3a
171};
172
173/*
174 * func field for mad opcodes (MIPS IV).
175 */
176enum mad_func {
177 madd_fp_op = 0x08, msub_fp_op = 0x0a,
178 nmadd_fp_op = 0x0c, nmsub_fp_op = 0x0e
179};
180
181/*
182 * Damn ... bitfields depend from byteorder :-(
183 */
184#ifdef __MIPSEB__
185struct j_format { /* Jump format */
186 unsigned int opcode : 6;
187 unsigned int target : 26;
188};
189
190struct i_format { /* Immediate format (addi, lw, ...) */
191 unsigned int opcode : 6;
192 unsigned int rs : 5;
193 unsigned int rt : 5;
194 signed int simmediate : 16;
195};
196
197struct u_format { /* Unsigned immediate format (ori, xori, ...) */
198 unsigned int opcode : 6;
199 unsigned int rs : 5;
200 unsigned int rt : 5;
201 unsigned int uimmediate : 16;
202};
203
204struct c_format { /* Cache (>= R6000) format */
205 unsigned int opcode : 6;
206 unsigned int rs : 5;
207 unsigned int c_op : 3;
208 unsigned int cache : 2;
209 unsigned int simmediate : 16;
210};
211
212struct r_format { /* Register format */
213 unsigned int opcode : 6;
214 unsigned int rs : 5;
215 unsigned int rt : 5;
216 unsigned int rd : 5;
217 unsigned int re : 5;
218 unsigned int func : 6;
219};
220
221struct p_format { /* Performance counter format (R10000) */
222 unsigned int opcode : 6;
223 unsigned int rs : 5;
224 unsigned int rt : 5;
225 unsigned int rd : 5;
226 unsigned int re : 5;
227 unsigned int func : 6;
228};
229
230struct f_format { /* FPU register format */
231 unsigned int opcode : 6;
232 unsigned int : 1;
233 unsigned int fmt : 4;
234 unsigned int rt : 5;
235 unsigned int rd : 5;
236 unsigned int re : 5;
237 unsigned int func : 6;
238};
239
240struct ma_format { /* FPU multipy and add format (MIPS IV) */
241 unsigned int opcode : 6;
242 unsigned int fr : 5;
243 unsigned int ft : 5;
244 unsigned int fs : 5;
245 unsigned int fd : 5;
246 unsigned int func : 4;
247 unsigned int fmt : 2;
248};
249
250#elif defined(__MIPSEL__)
251
252struct j_format { /* Jump format */
253 unsigned int target : 26;
254 unsigned int opcode : 6;
255};
256
257struct i_format { /* Immediate format */
258 signed int simmediate : 16;
259 unsigned int rt : 5;
260 unsigned int rs : 5;
261 unsigned int opcode : 6;
262};
263
264struct u_format { /* Unsigned immediate format */
265 unsigned int uimmediate : 16;
266 unsigned int rt : 5;
267 unsigned int rs : 5;
268 unsigned int opcode : 6;
269};
270
271struct c_format { /* Cache (>= R6000) format */
272 unsigned int simmediate : 16;
273 unsigned int cache : 2;
274 unsigned int c_op : 3;
275 unsigned int rs : 5;
276 unsigned int opcode : 6;
277};
278
279struct r_format { /* Register format */
280 unsigned int func : 6;
281 unsigned int re : 5;
282 unsigned int rd : 5;
283 unsigned int rt : 5;
284 unsigned int rs : 5;
285 unsigned int opcode : 6;
286};
287
288struct p_format { /* Performance counter format (R10000) */
289 unsigned int func : 6;
290 unsigned int re : 5;
291 unsigned int rd : 5;
292 unsigned int rt : 5;
293 unsigned int rs : 5;
294 unsigned int opcode : 6;
295};
296
297struct f_format { /* FPU register format */
298 unsigned int func : 6;
299 unsigned int re : 5;
300 unsigned int rd : 5;
301 unsigned int rt : 5;
302 unsigned int fmt : 4;
303 unsigned int : 1;
304 unsigned int opcode : 6;
305};
306
307struct ma_format { /* FPU multipy and add format (MIPS IV) */
308 unsigned int fmt : 2;
309 unsigned int func : 4;
310 unsigned int fd : 5;
311 unsigned int fs : 5;
312 unsigned int ft : 5;
313 unsigned int fr : 5;
314 unsigned int opcode : 6;
315};
316
317#else /* !defined (__MIPSEB__) && !defined (__MIPSEL__) */
318#error "MIPS but neither __MIPSEL__ nor __MIPSEB__?"
319#endif
320
321union mips_instruction {
322 unsigned int word;
323 unsigned short halfword[2];
324 unsigned char byte[4];
325 struct j_format j_format;
326 struct i_format i_format;
327 struct u_format u_format;
328 struct c_format c_format;
329 struct r_format r_format;
330 struct f_format f_format;
331 struct ma_format ma_format;
332};
333
334/* HACHACHAHCAHC ... */
335
336/* In case some other massaging is needed, keep MIPSInst as wrapper */
337
338#define MIPSInst(x) x
339
340#define I_OPCODE_SFT 26
341#define MIPSInst_OPCODE(x) (MIPSInst(x) >> I_OPCODE_SFT)
342
343#define I_JTARGET_SFT 0
344#define MIPSInst_JTARGET(x) (MIPSInst(x) & 0x03ffffff)
345
346#define I_RS_SFT 21
347#define MIPSInst_RS(x) ((MIPSInst(x) & 0x03e00000) >> I_RS_SFT)
348
349#define I_RT_SFT 16
350#define MIPSInst_RT(x) ((MIPSInst(x) & 0x001f0000) >> I_RT_SFT)
351
352#define I_IMM_SFT 0
353#define MIPSInst_SIMM(x) ((int)((short)(MIPSInst(x) & 0xffff)))
354#define MIPSInst_UIMM(x) (MIPSInst(x) & 0xffff)
355
356#define I_CACHEOP_SFT 18
357#define MIPSInst_CACHEOP(x) ((MIPSInst(x) & 0x001c0000) >> I_CACHEOP_SFT)
358
359#define I_CACHESEL_SFT 16
360#define MIPSInst_CACHESEL(x) ((MIPSInst(x) & 0x00030000) >> I_CACHESEL_SFT)
361
362#define I_RD_SFT 11
363#define MIPSInst_RD(x) ((MIPSInst(x) & 0x0000f800) >> I_RD_SFT)
364
365#define I_RE_SFT 6
366#define MIPSInst_RE(x) ((MIPSInst(x) & 0x000007c0) >> I_RE_SFT)
367
368#define I_FUNC_SFT 0
369#define MIPSInst_FUNC(x) (MIPSInst(x) & 0x0000003f)
370
371#define I_FFMT_SFT 21
372#define MIPSInst_FFMT(x) ((MIPSInst(x) & 0x01e00000) >> I_FFMT_SFT)
373
374#define I_FT_SFT 16
375#define MIPSInst_FT(x) ((MIPSInst(x) & 0x001f0000) >> I_FT_SFT)
376
377#define I_FS_SFT 11
378#define MIPSInst_FS(x) ((MIPSInst(x) & 0x0000f800) >> I_FS_SFT)
379
380#define I_FD_SFT 6
381#define MIPSInst_FD(x) ((MIPSInst(x) & 0x000007c0) >> I_FD_SFT)
382
383#define I_FR_SFT 21
384#define MIPSInst_FR(x) ((MIPSInst(x) & 0x03e00000) >> I_FR_SFT)
385
386#define I_FMA_FUNC_SFT 2
387#define MIPSInst_FMA_FUNC(x) ((MIPSInst(x) & 0x0000003c) >> I_FMA_FUNC_SFT)
388
389#define I_FMA_FFMT_SFT 0
390#define MIPSInst_FMA_FFMT(x) (MIPSInst(x) & 0x00000003)
391
392typedef unsigned int mips_instruction;
393
394#endif /* _ASM_INST_H */
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
new file mode 100644
index 000000000000..501a40b9f18d
--- /dev/null
+++ b/arch/mips/include/asm/io.h
@@ -0,0 +1,589 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 1995 Waldorf GmbH
7 * Copyright (C) 1994 - 2000, 06 Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved.
10 * Author: Maciej W. Rozycki <macro@mips.com>
11 */
12#ifndef _ASM_IO_H
13#define _ASM_IO_H
14
15#include <linux/compiler.h>
16#include <linux/kernel.h>
17#include <linux/types.h>
18
19#include <asm/addrspace.h>
20#include <asm/byteorder.h>
21#include <asm/cpu.h>
22#include <asm/cpu-features.h>
23#include <asm-generic/iomap.h>
24#include <asm/page.h>
25#include <asm/pgtable-bits.h>
26#include <asm/processor.h>
27#include <asm/string.h>
28
29#include <ioremap.h>
30#include <mangle-port.h>
31
32/*
33 * Slowdown I/O port space accesses for antique hardware.
34 */
35#undef CONF_SLOWDOWN_IO
36
37/*
38 * Raw operations are never swapped in software. OTOH values that raw
39 * operations are working on may or may not have been swapped by the bus
40 * hardware. An example use would be for flash memory that's used for
41 * execute in place.
42 */
43# define __raw_ioswabb(a, x) (x)
44# define __raw_ioswabw(a, x) (x)
45# define __raw_ioswabl(a, x) (x)
46# define __raw_ioswabq(a, x) (x)
47# define ____raw_ioswabq(a, x) (x)
48
49/* ioswab[bwlq], __mem_ioswab[bwlq] are defined in mangle-port.h */
50
51#define IO_SPACE_LIMIT 0xffff
52
53/*
54 * On MIPS I/O ports are memory mapped, so we access them using normal
55 * load/store instructions. mips_io_port_base is the virtual address to
56 * which all ports are being mapped. For sake of efficiency some code
57 * assumes that this is an address that can be loaded with a single lui
58 * instruction, so the lower 16 bits must be zero. Should be true on
59 * on any sane architecture; generic code does not use this assumption.
60 */
61extern const unsigned long mips_io_port_base;
62
63/*
64 * Gcc will generate code to load the value of mips_io_port_base after each
65 * function call which may be fairly wasteful in some cases. So we don't
66 * play quite by the book. We tell gcc mips_io_port_base is a long variable
67 * which solves the code generation issue. Now we need to violate the
68 * aliasing rules a little to make initialization possible and finally we
69 * will need the barrier() to fight side effects of the aliasing chat.
70 * This trickery will eventually collapse under gcc's optimizer. Oh well.
71 */
72static inline void set_io_port_base(unsigned long base)
73{
74 * (unsigned long *) &mips_io_port_base = base;
75 barrier();
76}
77
78/*
79 * Thanks to James van Artsdalen for a better timing-fix than
80 * the two short jumps: using outb's to a nonexistent port seems
81 * to guarantee better timings even on fast machines.
82 *
83 * On the other hand, I'd like to be sure of a non-existent port:
84 * I feel a bit unsafe about using 0x80 (should be safe, though)
85 *
86 * Linus
87 *
88 */
89
90#define __SLOW_DOWN_IO \
91 __asm__ __volatile__( \
92 "sb\t$0,0x80(%0)" \
93 : : "r" (mips_io_port_base));
94
95#ifdef CONF_SLOWDOWN_IO
96#ifdef REALLY_SLOW_IO
97#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
98#else
99#define SLOW_DOWN_IO __SLOW_DOWN_IO
100#endif
101#else
102#define SLOW_DOWN_IO
103#endif
104
105/*
106 * virt_to_phys - map virtual addresses to physical
107 * @address: address to remap
108 *
109 * The returned physical address is the physical (CPU) mapping for
110 * the memory address given. It is only valid to use this function on
111 * addresses directly mapped or allocated via kmalloc.
112 *
113 * This function does not give bus mappings for DMA transfers. In
114 * almost all conceivable cases a device driver should not be using
115 * this function
116 */
117static inline unsigned long virt_to_phys(volatile const void *address)
118{
119 return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
120}
121
122/*
123 * phys_to_virt - map physical address to virtual
124 * @address: address to remap
125 *
126 * The returned virtual address is a current CPU mapping for
127 * the memory address given. It is only valid to use this function on
128 * addresses that have a kernel mapping
129 *
130 * This function does not handle bus mappings for DMA transfers. In
131 * almost all conceivable cases a device driver should not be using
132 * this function
133 */
134static inline void * phys_to_virt(unsigned long address)
135{
136 return (void *)(address + PAGE_OFFSET - PHYS_OFFSET);
137}
138
139/*
140 * ISA I/O bus memory addresses are 1:1 with the physical address.
141 */
142static inline unsigned long isa_virt_to_bus(volatile void * address)
143{
144 return (unsigned long)address - PAGE_OFFSET;
145}
146
147static inline void * isa_bus_to_virt(unsigned long address)
148{
149 return (void *)(address + PAGE_OFFSET);
150}
151
152#define isa_page_to_bus page_to_phys
153
154/*
155 * However PCI ones are not necessarily 1:1 and therefore these interfaces
156 * are forbidden in portable PCI drivers.
157 *
158 * Allow them for x86 for legacy drivers, though.
159 */
160#define virt_to_bus virt_to_phys
161#define bus_to_virt phys_to_virt
162
163/*
164 * Change "struct page" to physical address.
165 */
166#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
167
168extern void __iomem * __ioremap(phys_t offset, phys_t size, unsigned long flags);
169extern void __iounmap(const volatile void __iomem *addr);
170
171static inline void __iomem * __ioremap_mode(phys_t offset, unsigned long size,
172 unsigned long flags)
173{
174 void __iomem *addr = plat_ioremap(offset, size, flags);
175
176 if (addr)
177 return addr;
178
179#define __IS_LOW512(addr) (!((phys_t)(addr) & (phys_t) ~0x1fffffffULL))
180
181 if (cpu_has_64bit_addresses) {
182 u64 base = UNCAC_BASE;
183
184 /*
185 * R10000 supports a 2 bit uncached attribute therefore
186 * UNCAC_BASE may not equal IO_BASE.
187 */
188 if (flags == _CACHE_UNCACHED)
189 base = (u64) IO_BASE;
190 return (void __iomem *) (unsigned long) (base + offset);
191 } else if (__builtin_constant_p(offset) &&
192 __builtin_constant_p(size) && __builtin_constant_p(flags)) {
193 phys_t phys_addr, last_addr;
194
195 phys_addr = fixup_bigphys_addr(offset, size);
196
197 /* Don't allow wraparound or zero size. */
198 last_addr = phys_addr + size - 1;
199 if (!size || last_addr < phys_addr)
200 return NULL;
201
202 /*
203 * Map uncached objects in the low 512MB of address
204 * space using KSEG1.
205 */
206 if (__IS_LOW512(phys_addr) && __IS_LOW512(last_addr) &&
207 flags == _CACHE_UNCACHED)
208 return (void __iomem *)
209 (unsigned long)CKSEG1ADDR(phys_addr);
210 }
211
212 return __ioremap(offset, size, flags);
213
214#undef __IS_LOW512
215}
216
217/*
218 * ioremap - map bus memory into CPU space
219 * @offset: bus address of the memory
220 * @size: size of the resource to map
221 *
222 * ioremap performs a platform specific sequence of operations to
223 * make bus memory CPU accessible via the readb/readw/readl/writeb/
224 * writew/writel functions and the other mmio helpers. The returned
225 * address is not guaranteed to be usable directly as a virtual
226 * address.
227 */
228#define ioremap(offset, size) \
229 __ioremap_mode((offset), (size), _CACHE_UNCACHED)
230
231/*
232 * ioremap_nocache - map bus memory into CPU space
233 * @offset: bus address of the memory
234 * @size: size of the resource to map
235 *
236 * ioremap_nocache performs a platform specific sequence of operations to
237 * make bus memory CPU accessible via the readb/readw/readl/writeb/
238 * writew/writel functions and the other mmio helpers. The returned
239 * address is not guaranteed to be usable directly as a virtual
240 * address.
241 *
242 * This version of ioremap ensures that the memory is marked uncachable
243 * on the CPU as well as honouring existing caching rules from things like
244 * the PCI bus. Note that there are other caches and buffers on many
245 * busses. In paticular driver authors should read up on PCI writes
246 *
247 * It's useful if some control registers are in such an area and
248 * write combining or read caching is not desirable:
249 */
250#define ioremap_nocache(offset, size) \
251 __ioremap_mode((offset), (size), _CACHE_UNCACHED)
252
253/*
254 * ioremap_cachable - map bus memory into CPU space
255 * @offset: bus address of the memory
256 * @size: size of the resource to map
257 *
258 * ioremap_nocache performs a platform specific sequence of operations to
259 * make bus memory CPU accessible via the readb/readw/readl/writeb/
260 * writew/writel functions and the other mmio helpers. The returned
261 * address is not guaranteed to be usable directly as a virtual
262 * address.
263 *
264 * This version of ioremap ensures that the memory is marked cachable by
265 * the CPU. Also enables full write-combining. Useful for some
266 * memory-like regions on I/O busses.
267 */
268#define ioremap_cachable(offset, size) \
269 __ioremap_mode((offset), (size), _page_cachable_default)
270
271/*
272 * These two are MIPS specific ioremap variant. ioremap_cacheable_cow
273 * requests a cachable mapping, ioremap_uncached_accelerated requests a
274 * mapping using the uncached accelerated mode which isn't supported on
275 * all processors.
276 */
277#define ioremap_cacheable_cow(offset, size) \
278 __ioremap_mode((offset), (size), _CACHE_CACHABLE_COW)
279#define ioremap_uncached_accelerated(offset, size) \
280 __ioremap_mode((offset), (size), _CACHE_UNCACHED_ACCELERATED)
281
282static inline void iounmap(const volatile void __iomem *addr)
283{
284 if (plat_iounmap(addr))
285 return;
286
287#define __IS_KSEG1(addr) (((unsigned long)(addr) & ~0x1fffffffUL) == CKSEG1)
288
289 if (cpu_has_64bit_addresses ||
290 (__builtin_constant_p(addr) && __IS_KSEG1(addr)))
291 return;
292
293 __iounmap(addr);
294
295#undef __IS_KSEG1
296}
297
298#define __BUILD_MEMORY_SINGLE(pfx, bwlq, type, irq) \
299 \
300static inline void pfx##write##bwlq(type val, \
301 volatile void __iomem *mem) \
302{ \
303 volatile type *__mem; \
304 type __val; \
305 \
306 __mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
307 \
308 __val = pfx##ioswab##bwlq(__mem, val); \
309 \
310 if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
311 *__mem = __val; \
312 else if (cpu_has_64bits) { \
313 unsigned long __flags; \
314 type __tmp; \
315 \
316 if (irq) \
317 local_irq_save(__flags); \
318 __asm__ __volatile__( \
319 ".set mips3" "\t\t# __writeq""\n\t" \
320 "dsll32 %L0, %L0, 0" "\n\t" \
321 "dsrl32 %L0, %L0, 0" "\n\t" \
322 "dsll32 %M0, %M0, 0" "\n\t" \
323 "or %L0, %L0, %M0" "\n\t" \
324 "sd %L0, %2" "\n\t" \
325 ".set mips0" "\n" \
326 : "=r" (__tmp) \
327 : "0" (__val), "m" (*__mem)); \
328 if (irq) \
329 local_irq_restore(__flags); \
330 } else \
331 BUG(); \
332} \
333 \
334static inline type pfx##read##bwlq(const volatile void __iomem *mem) \
335{ \
336 volatile type *__mem; \
337 type __val; \
338 \
339 __mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
340 \
341 if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
342 __val = *__mem; \
343 else if (cpu_has_64bits) { \
344 unsigned long __flags; \
345 \
346 if (irq) \
347 local_irq_save(__flags); \
348 __asm__ __volatile__( \
349 ".set mips3" "\t\t# __readq" "\n\t" \
350 "ld %L0, %1" "\n\t" \
351 "dsra32 %M0, %L0, 0" "\n\t" \
352 "sll %L0, %L0, 0" "\n\t" \
353 ".set mips0" "\n" \
354 : "=r" (__val) \
355 : "m" (*__mem)); \
356 if (irq) \
357 local_irq_restore(__flags); \
358 } else { \
359 __val = 0; \
360 BUG(); \
361 } \
362 \
363 return pfx##ioswab##bwlq(__mem, __val); \
364}
365
366#define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, p, slow) \
367 \
368static inline void pfx##out##bwlq##p(type val, unsigned long port) \
369{ \
370 volatile type *__addr; \
371 type __val; \
372 \
373 __addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
374 \
375 __val = pfx##ioswab##bwlq(__addr, val); \
376 \
377 /* Really, we want this to be atomic */ \
378 BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
379 \
380 *__addr = __val; \
381 slow; \
382} \
383 \
384static inline type pfx##in##bwlq##p(unsigned long port) \
385{ \
386 volatile type *__addr; \
387 type __val; \
388 \
389 __addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
390 \
391 BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
392 \
393 __val = *__addr; \
394 slow; \
395 \
396 return pfx##ioswab##bwlq(__addr, __val); \
397}
398
399#define __BUILD_MEMORY_PFX(bus, bwlq, type) \
400 \
401__BUILD_MEMORY_SINGLE(bus, bwlq, type, 1)
402
403#define BUILDIO_MEM(bwlq, type) \
404 \
405__BUILD_MEMORY_PFX(__raw_, bwlq, type) \
406__BUILD_MEMORY_PFX(, bwlq, type) \
407__BUILD_MEMORY_PFX(__mem_, bwlq, type) \
408
409BUILDIO_MEM(b, u8)
410BUILDIO_MEM(w, u16)
411BUILDIO_MEM(l, u32)
412BUILDIO_MEM(q, u64)
413
414#define __BUILD_IOPORT_PFX(bus, bwlq, type) \
415 __BUILD_IOPORT_SINGLE(bus, bwlq, type, ,) \
416 __BUILD_IOPORT_SINGLE(bus, bwlq, type, _p, SLOW_DOWN_IO)
417
418#define BUILDIO_IOPORT(bwlq, type) \
419 __BUILD_IOPORT_PFX(, bwlq, type) \
420 __BUILD_IOPORT_PFX(__mem_, bwlq, type)
421
422BUILDIO_IOPORT(b, u8)
423BUILDIO_IOPORT(w, u16)
424BUILDIO_IOPORT(l, u32)
425#ifdef CONFIG_64BIT
426BUILDIO_IOPORT(q, u64)
427#endif
428
429#define __BUILDIO(bwlq, type) \
430 \
431__BUILD_MEMORY_SINGLE(____raw_, bwlq, type, 0)
432
433__BUILDIO(q, u64)
434
435#define readb_relaxed readb
436#define readw_relaxed readw
437#define readl_relaxed readl
438#define readq_relaxed readq
439
440/*
441 * Some code tests for these symbols
442 */
443#define readq readq
444#define writeq writeq
445
446#define __BUILD_MEMORY_STRING(bwlq, type) \
447 \
448static inline void writes##bwlq(volatile void __iomem *mem, \
449 const void *addr, unsigned int count) \
450{ \
451 const volatile type *__addr = addr; \
452 \
453 while (count--) { \
454 __mem_write##bwlq(*__addr, mem); \
455 __addr++; \
456 } \
457} \
458 \
459static inline void reads##bwlq(volatile void __iomem *mem, void *addr, \
460 unsigned int count) \
461{ \
462 volatile type *__addr = addr; \
463 \
464 while (count--) { \
465 *__addr = __mem_read##bwlq(mem); \
466 __addr++; \
467 } \
468}
469
470#define __BUILD_IOPORT_STRING(bwlq, type) \
471 \
472static inline void outs##bwlq(unsigned long port, const void *addr, \
473 unsigned int count) \
474{ \
475 const volatile type *__addr = addr; \
476 \
477 while (count--) { \
478 __mem_out##bwlq(*__addr, port); \
479 __addr++; \
480 } \
481} \
482 \
483static inline void ins##bwlq(unsigned long port, void *addr, \
484 unsigned int count) \
485{ \
486 volatile type *__addr = addr; \
487 \
488 while (count--) { \
489 *__addr = __mem_in##bwlq(port); \
490 __addr++; \
491 } \
492}
493
494#define BUILDSTRING(bwlq, type) \
495 \
496__BUILD_MEMORY_STRING(bwlq, type) \
497__BUILD_IOPORT_STRING(bwlq, type)
498
499BUILDSTRING(b, u8)
500BUILDSTRING(w, u16)
501BUILDSTRING(l, u32)
502#ifdef CONFIG_64BIT
503BUILDSTRING(q, u64)
504#endif
505
506
507/* Depends on MIPS II instruction set */
508#define mmiowb() asm volatile ("sync" ::: "memory")
509
510static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
511{
512 memset((void __force *) addr, val, count);
513}
514static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
515{
516 memcpy(dst, (void __force *) src, count);
517}
518static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
519{
520 memcpy((void __force *) dst, src, count);
521}
522
523/*
524 * The caches on some architectures aren't dma-coherent and have need to
525 * handle this in software. There are three types of operations that
526 * can be applied to dma buffers.
527 *
528 * - dma_cache_wback_inv(start, size) makes caches and coherent by
529 * writing the content of the caches back to memory, if necessary.
530 * The function also invalidates the affected part of the caches as
531 * necessary before DMA transfers from outside to memory.
532 * - dma_cache_wback(start, size) makes caches and coherent by
533 * writing the content of the caches back to memory, if necessary.
534 * The function also invalidates the affected part of the caches as
535 * necessary before DMA transfers from outside to memory.
536 * - dma_cache_inv(start, size) invalidates the affected parts of the
537 * caches. Dirty lines of the caches may be written back or simply
538 * be discarded. This operation is necessary before dma operations
539 * to the memory.
540 *
541 * This API used to be exported; it now is for arch code internal use only.
542 */
543#ifdef CONFIG_DMA_NONCOHERENT
544
545extern void (*_dma_cache_wback_inv)(unsigned long start, unsigned long size);
546extern void (*_dma_cache_wback)(unsigned long start, unsigned long size);
547extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
548
549#define dma_cache_wback_inv(start, size) _dma_cache_wback_inv(start, size)
550#define dma_cache_wback(start, size) _dma_cache_wback(start, size)
551#define dma_cache_inv(start, size) _dma_cache_inv(start, size)
552
553#else /* Sane hardware */
554
555#define dma_cache_wback_inv(start,size) \
556 do { (void) (start); (void) (size); } while (0)
557#define dma_cache_wback(start,size) \
558 do { (void) (start); (void) (size); } while (0)
559#define dma_cache_inv(start,size) \
560 do { (void) (start); (void) (size); } while (0)
561
562#endif /* CONFIG_DMA_NONCOHERENT */
563
564/*
565 * Read a 32-bit register that requires a 64-bit read cycle on the bus.
566 * Avoid interrupt mucking, just adjust the address for 4-byte access.
567 * Assume the addresses are 8-byte aligned.
568 */
569#ifdef __MIPSEB__
570#define __CSR_32_ADJUST 4
571#else
572#define __CSR_32_ADJUST 0
573#endif
574
575#define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
576#define csr_in32(a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
577
578/*
579 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
580 * access
581 */
582#define xlate_dev_mem_ptr(p) __va(p)
583
584/*
585 * Convert a virtual cached pointer to an uncached pointer
586 */
587#define xlate_dev_kmem_ptr(p) p
588
589#endif /* _ASM_IO_H */
diff --git a/arch/mips/include/asm/ioctl.h b/arch/mips/include/asm/ioctl.h
new file mode 100644
index 000000000000..85067e248a83
--- /dev/null
+++ b/arch/mips/include/asm/ioctl.h
@@ -0,0 +1,94 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 96, 99, 2001 Ralf Baechle
7 */
8#ifndef _ASM_IOCTL_H
9#define _ASM_IOCTL_H
10
11/*
12 * The original linux ioctl numbering scheme was just a general
13 * "anything goes" setup, where more or less random numbers were
14 * assigned. Sorry, I was clueless when I started out on this.
15 *
16 * On the alpha, we'll try to clean it up a bit, using a more sane
17 * ioctl numbering, and also trying to be compatible with OSF/1 in
18 * the process. I'd like to clean it up for the i386 as well, but
19 * it's so painful recognizing both the new and the old numbers..
20 *
21 * The same applies for for the MIPS ABI; in fact even the macros
22 * from Linux/Alpha fit almost perfectly.
23 */
24
25#define _IOC_NRBITS 8
26#define _IOC_TYPEBITS 8
27#define _IOC_SIZEBITS 13
28#define _IOC_DIRBITS 3
29
30#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
31#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
32#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
33#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
34
35#define _IOC_NRSHIFT 0
36#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
37#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
38#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
39
40/*
41 * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
42 * And this turns out useful to catch old ioctl numbers in header
43 * files for us.
44 */
45#define _IOC_NONE 1U
46#define _IOC_READ 2U
47#define _IOC_WRITE 4U
48
49/*
50 * The following are included for compatibility
51 */
52#define _IOC_VOID 0x20000000
53#define _IOC_OUT 0x40000000
54#define _IOC_IN 0x80000000
55#define _IOC_INOUT (IOC_IN|IOC_OUT)
56
57#define _IOC(dir, type, nr, size) \
58 (((dir) << _IOC_DIRSHIFT) | \
59 ((type) << _IOC_TYPESHIFT) | \
60 ((nr) << _IOC_NRSHIFT) | \
61 ((size) << _IOC_SIZESHIFT))
62
63/* provoke compile error for invalid uses of size argument */
64extern unsigned int __invalid_size_argument_for_IOC;
65#define _IOC_TYPECHECK(t) \
66 ((sizeof(t) == sizeof(t[1]) && \
67 sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
68 sizeof(t) : __invalid_size_argument_for_IOC)
69
70/* used to create numbers */
71#define _IO(type, nr) _IOC(_IOC_NONE, (type), (nr), 0)
72#define _IOR(type, nr, size) _IOC(_IOC_READ, (type), (nr), (_IOC_TYPECHECK(size)))
73#define _IOW(type, nr, size) _IOC(_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
74#define _IOWR(type, nr, size) _IOC(_IOC_READ|_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
75#define _IOR_BAD(type, nr, size) _IOC(_IOC_READ, (type), (nr), sizeof(size))
76#define _IOW_BAD(type, nr, size) _IOC(_IOC_WRITE, (type), (nr), sizeof(size))
77#define _IOWR_BAD(type, nr, size) _IOC(_IOC_READ|_IOC_WRITE, (type), (nr), sizeof(size))
78
79
80/* used to decode them.. */
81#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
82#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
83#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
84#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
85
86/* ...and for the drivers/sound files... */
87
88#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
89#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
90#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
91#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
92#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
93
94#endif /* _ASM_IOCTL_H */
diff --git a/arch/mips/include/asm/ioctls.h b/arch/mips/include/asm/ioctls.h
new file mode 100644
index 000000000000..3f04a995ec54
--- /dev/null
+++ b/arch/mips/include/asm/ioctls.h
@@ -0,0 +1,109 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1996, 2001 Ralf Baechle
7 * Copyright (C) 2001 MIPS Technologies, Inc.
8 */
9#ifndef __ASM_IOCTLS_H
10#define __ASM_IOCTLS_H
11
12#include <asm/ioctl.h>
13
14#define TCGETA 0x5401
15#define TCSETA 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
16#define TCSETAW 0x5403
17#define TCSETAF 0x5404
18
19#define TCSBRK 0x5405
20#define TCXONC 0x5406
21#define TCFLSH 0x5407
22
23#define TCGETS 0x540d
24#define TCSETS 0x540e
25#define TCSETSW 0x540f
26#define TCSETSF 0x5410
27
28#define TIOCEXCL 0x740d /* set exclusive use of tty */
29#define TIOCNXCL 0x740e /* reset exclusive use of tty */
30#define TIOCOUTQ 0x7472 /* output queue size */
31#define TIOCSTI 0x5472 /* simulate terminal input */
32#define TIOCMGET 0x741d /* get all modem bits */
33#define TIOCMBIS 0x741b /* bis modem bits */
34#define TIOCMBIC 0x741c /* bic modem bits */
35#define TIOCMSET 0x741a /* set all modem bits */
36#define TIOCPKT 0x5470 /* pty: set/clear packet mode */
37#define TIOCPKT_DATA 0x00 /* data packet */
38#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
39#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
40#define TIOCPKT_STOP 0x04 /* stop output */
41#define TIOCPKT_START 0x08 /* start output */
42#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
43#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
44/* #define TIOCPKT_IOCTL 0x40 state change of pty driver */
45#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
46#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
47#define TIOCNOTTY 0x5471 /* void tty association */
48#define TIOCSETD 0x7401
49#define TIOCGETD 0x7400
50
51#define FIOCLEX 0x6601
52#define FIONCLEX 0x6602
53#define FIOASYNC 0x667d
54#define FIONBIO 0x667e
55#define FIOQSIZE 0x667f
56
57#define TIOCGLTC 0x7474 /* get special local chars */
58#define TIOCSLTC 0x7475 /* set special local chars */
59#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
60#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
61#define TIOCCONS _IOW('t', 120, int) /* become virtual console */
62
63#define FIONREAD 0x467f
64#define TIOCINQ FIONREAD
65
66#define TIOCGETP 0x7408
67#define TIOCSETP 0x7409
68#define TIOCSETN 0x740a /* TIOCSETP wo flush */
69
70/* #define TIOCSETA _IOW('t', 20, struct termios) set termios struct */
71/* #define TIOCSETAW _IOW('t', 21, struct termios) drain output, set */
72/* #define TIOCSETAF _IOW('t', 22, struct termios) drn out, fls in, set */
73/* #define TIOCGETD _IOR('t', 26, int) get line discipline */
74/* #define TIOCSETD _IOW('t', 27, int) set line discipline */
75 /* 127-124 compat */
76
77#define TIOCSBRK 0x5427 /* BSD compatibility */
78#define TIOCCBRK 0x5428 /* BSD compatibility */
79#define TIOCGSID 0x7416 /* Return the session ID of FD */
80#define TCGETS2 _IOR('T', 0x2A, struct termios2)
81#define TCSETS2 _IOW('T', 0x2B, struct termios2)
82#define TCSETSW2 _IOW('T', 0x2C, struct termios2)
83#define TCSETSF2 _IOW('T', 0x2D, struct termios2)
84#define TIOCGPTN _IOR('T', 0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
85#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */
86
87/* I hope the range from 0x5480 on is free ... */
88#define TIOCSCTTY 0x5480 /* become controlling tty */
89#define TIOCGSOFTCAR 0x5481
90#define TIOCSSOFTCAR 0x5482
91#define TIOCLINUX 0x5483
92#define TIOCGSERIAL 0x5484
93#define TIOCSSERIAL 0x5485
94#define TCSBRKP 0x5486 /* Needed for POSIX tcsendbreak() */
95#define TIOCSERCONFIG 0x5488
96#define TIOCSERGWILD 0x5489
97#define TIOCSERSWILD 0x548a
98#define TIOCGLCKTRMIOS 0x548b
99#define TIOCSLCKTRMIOS 0x548c
100#define TIOCSERGSTRUCT 0x548d /* For debugging only */
101#define TIOCSERGETLSR 0x548e /* Get line status register */
102#define TIOCSERGETMULTI 0x548f /* Get multiport config */
103#define TIOCSERSETMULTI 0x5490 /* Set multiport config */
104#define TIOCMIWAIT 0x5491 /* wait for a change on serial input line(s) */
105#define TIOCGICOUNT 0x5492 /* read serial port inline interrupt counts */
106#define TIOCGHAYESESP 0x5493 /* Get Hayes ESP configuration */
107#define TIOCSHAYESESP 0x5494 /* Set Hayes ESP configuration */
108
109#endif /* __ASM_IOCTLS_H */
diff --git a/arch/mips/include/asm/ip32/crime.h b/arch/mips/include/asm/ip32/crime.h
new file mode 100644
index 000000000000..7c36b0e5b1c6
--- /dev/null
+++ b/arch/mips/include/asm/ip32/crime.h
@@ -0,0 +1,158 @@
1/*
2 * Definitions for the SGI CRIME (CPU, Rendering, Interconnect and Memory
3 * Engine)
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (C) 2000 Harald Koerfgen
10 */
11
12#ifndef __ASM_CRIME_H__
13#define __ASM_CRIME_H__
14
15/*
16 * Address map
17 */
18#define CRIME_BASE 0x14000000 /* physical */
19
20struct sgi_crime {
21 volatile unsigned long id;
22#define CRIME_ID_MASK 0xff
23#define CRIME_ID_IDBITS 0xf0
24#define CRIME_ID_IDVALUE 0xa0
25#define CRIME_ID_REV 0x0f
26#define CRIME_REV_PETTY 0x00
27#define CRIME_REV_11 0x11
28#define CRIME_REV_13 0x13
29#define CRIME_REV_14 0x14
30
31 volatile unsigned long control;
32#define CRIME_CONTROL_MASK 0x3fff
33#define CRIME_CONTROL_TRITON_SYSADC 0x2000
34#define CRIME_CONTROL_CRIME_SYSADC 0x1000
35#define CRIME_CONTROL_HARD_RESET 0x0800
36#define CRIME_CONTROL_SOFT_RESET 0x0400
37#define CRIME_CONTROL_DOG_ENA 0x0200
38#define CRIME_CONTROL_ENDIANESS 0x0100
39#define CRIME_CONTROL_ENDIAN_BIG 0x0100
40#define CRIME_CONTROL_ENDIAN_LITTLE 0x0000
41#define CRIME_CONTROL_CQUEUE_HWM 0x000f
42#define CRIME_CONTROL_CQUEUE_SHFT 0
43#define CRIME_CONTROL_WBUF_HWM 0x00f0
44#define CRIME_CONTROL_WBUF_SHFT 8
45
46 volatile unsigned long istat;
47 volatile unsigned long imask;
48 volatile unsigned long soft_int;
49 volatile unsigned long hard_int;
50#define MACE_VID_IN1_INT BIT(0)
51#define MACE_VID_IN2_INT BIT(1)
52#define MACE_VID_OUT_INT BIT(2)
53#define MACE_ETHERNET_INT BIT(3)
54#define MACE_SUPERIO_INT BIT(4)
55#define MACE_MISC_INT BIT(5)
56#define MACE_AUDIO_INT BIT(6)
57#define MACE_PCI_BRIDGE_INT BIT(7)
58#define MACEPCI_SCSI0_INT BIT(8)
59#define MACEPCI_SCSI1_INT BIT(9)
60#define MACEPCI_SLOT0_INT BIT(10)
61#define MACEPCI_SLOT1_INT BIT(11)
62#define MACEPCI_SLOT2_INT BIT(12)
63#define MACEPCI_SHARED0_INT BIT(13)
64#define MACEPCI_SHARED1_INT BIT(14)
65#define MACEPCI_SHARED2_INT BIT(15)
66#define CRIME_GBE0_INT BIT(16)
67#define CRIME_GBE1_INT BIT(17)
68#define CRIME_GBE2_INT BIT(18)
69#define CRIME_GBE3_INT BIT(19)
70#define CRIME_CPUERR_INT BIT(20)
71#define CRIME_MEMERR_INT BIT(21)
72#define CRIME_RE_EMPTY_E_INT BIT(22)
73#define CRIME_RE_FULL_E_INT BIT(23)
74#define CRIME_RE_IDLE_E_INT BIT(24)
75#define CRIME_RE_EMPTY_L_INT BIT(25)
76#define CRIME_RE_FULL_L_INT BIT(26)
77#define CRIME_RE_IDLE_L_INT BIT(27)
78#define CRIME_SOFT0_INT BIT(28)
79#define CRIME_SOFT1_INT BIT(29)
80#define CRIME_SOFT2_INT BIT(30)
81#define CRIME_SYSCORERR_INT CRIME_SOFT2_INT
82#define CRIME_VICE_INT BIT(31)
83/* Masks for deciding who handles the interrupt */
84#define CRIME_MACE_INT_MASK 0x8f
85#define CRIME_MACEISA_INT_MASK 0x70
86#define CRIME_MACEPCI_INT_MASK 0xff00
87#define CRIME_CRIME_INT_MASK 0xffff0000
88
89 volatile unsigned long watchdog;
90#define CRIME_DOG_POWER_ON_RESET 0x00010000
91#define CRIME_DOG_WARM_RESET 0x00080000
92#define CRIME_DOG_TIMEOUT (CRIME_DOG_POWER_ON_RESET|CRIME_DOG_WARM_RESET)
93#define CRIME_DOG_VALUE 0x00007fff
94
95 volatile unsigned long timer;
96#define CRIME_MASTER_FREQ 66666500 /* Crime upcounter frequency */
97#define CRIME_NS_PER_TICK 15 /* for delay_calibrate */
98
99 volatile unsigned long cpu_error_addr;
100#define CRIME_CPU_ERROR_ADDR_MASK 0x3ffffffff
101
102 volatile unsigned long cpu_error_stat;
103#define CRIME_CPU_ERROR_MASK 0x7 /* cpu error stat is 3 bits */
104#define CRIME_CPU_ERROR_CPU_ILL_ADDR 0x4
105#define CRIME_CPU_ERROR_VICE_WRT_PRTY 0x2
106#define CRIME_CPU_ERROR_CPU_WRT_PRTY 0x1
107
108 unsigned long _pad0[54];
109
110 volatile unsigned long mc_ctrl;
111 volatile unsigned long bank_ctrl[8];
112#define CRIME_MEM_BANK_CONTROL_MASK 0x11f /* 9 bits 7:5 reserved */
113#define CRIME_MEM_BANK_CONTROL_ADDR 0x01f
114#define CRIME_MEM_BANK_CONTROL_SDRAM_SIZE 0x100
115#define CRIME_MAXBANKS 8
116
117 volatile unsigned long mem_ref_counter;
118#define CRIME_MEM_REF_COUNTER_MASK 0x3ff /* 10bit */
119
120 volatile unsigned long mem_error_stat;
121#define CRIME_MEM_ERROR_STAT_MASK 0x0ff7ffff /* 28-bit register */
122#define CRIME_MEM_ERROR_MACE_ID 0x0000007f
123#define CRIME_MEM_ERROR_MACE_ACCESS 0x00000080
124#define CRIME_MEM_ERROR_RE_ID 0x00007f00
125#define CRIME_MEM_ERROR_RE_ACCESS 0x00008000
126#define CRIME_MEM_ERROR_GBE_ACCESS 0x00010000
127#define CRIME_MEM_ERROR_VICE_ACCESS 0x00020000
128#define CRIME_MEM_ERROR_CPU_ACCESS 0x00040000
129#define CRIME_MEM_ERROR_RESERVED 0x00080000
130#define CRIME_MEM_ERROR_SOFT_ERR 0x00100000
131#define CRIME_MEM_ERROR_HARD_ERR 0x00200000
132#define CRIME_MEM_ERROR_MULTIPLE 0x00400000
133#define CRIME_MEM_ERROR_ECC 0x01800000
134#define CRIME_MEM_ERROR_MEM_ECC_RD 0x00800000
135#define CRIME_MEM_ERROR_MEM_ECC_RMW 0x01000000
136#define CRIME_MEM_ERROR_INV 0x0e000000
137#define CRIME_MEM_ERROR_INV_MEM_ADDR_RD 0x02000000
138#define CRIME_MEM_ERROR_INV_MEM_ADDR_WR 0x04000000
139#define CRIME_MEM_ERROR_INV_MEM_ADDR_RMW 0x08000000
140
141 volatile unsigned long mem_error_addr;
142#define CRIME_MEM_ERROR_ADDR_MASK 0x3fffffff
143
144 volatile unsigned long mem_ecc_syn;
145#define CRIME_MEM_ERROR_ECC_SYN_MASK 0xffffffff
146
147 volatile unsigned long mem_ecc_chk;
148#define CRIME_MEM_ERROR_ECC_CHK_MASK 0xffffffff
149
150 volatile unsigned long mem_ecc_repl;
151#define CRIME_MEM_ERROR_ECC_REPL_MASK 0xffffffff
152};
153
154extern struct sgi_crime __iomem *crime;
155
156#define CRIME_HI_MEM_BASE 0x40000000 /* this is where whole 1G of RAM is mapped */
157
158#endif /* __ASM_CRIME_H__ */
diff --git a/arch/mips/include/asm/ip32/ip32_ints.h b/arch/mips/include/asm/ip32/ip32_ints.h
new file mode 100644
index 000000000000..85bc5302bce0
--- /dev/null
+++ b/arch/mips/include/asm/ip32/ip32_ints.h
@@ -0,0 +1,114 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000 Harald Koerfgen
7 */
8
9#ifndef __ASM_IP32_INTS_H
10#define __ASM_IP32_INTS_H
11
12#include <asm/irq.h>
13
14/*
15 * This list reflects the assignment of interrupt numbers to
16 * interrupting events. Order is fairly irrelevant to handling
17 * priority. This differs from irix.
18 */
19
20enum ip32_irq_no {
21 /*
22 * CPU interrupts are 0 ... 7
23 */
24
25 CRIME_IRQ_BASE = MIPS_CPU_IRQ_BASE + 8,
26
27 /*
28 * MACE
29 */
30 MACE_VID_IN1_IRQ = CRIME_IRQ_BASE,
31 MACE_VID_IN2_IRQ,
32 MACE_VID_OUT_IRQ,
33 MACE_ETHERNET_IRQ,
34 /* SUPERIO, MISC, and AUDIO are MACEISA */
35 __MACE_SUPERIO,
36 __MACE_MISC,
37 __MACE_AUDIO,
38 MACE_PCI_BRIDGE_IRQ,
39
40 /*
41 * MACEPCI
42 */
43 MACEPCI_SCSI0_IRQ,
44 MACEPCI_SCSI1_IRQ,
45 MACEPCI_SLOT0_IRQ,
46 MACEPCI_SLOT1_IRQ,
47 MACEPCI_SLOT2_IRQ,
48 MACEPCI_SHARED0_IRQ,
49 MACEPCI_SHARED1_IRQ,
50 MACEPCI_SHARED2_IRQ,
51
52 /*
53 * CRIME
54 */
55 CRIME_GBE0_IRQ,
56 CRIME_GBE1_IRQ,
57 CRIME_GBE2_IRQ,
58 CRIME_GBE3_IRQ,
59 CRIME_CPUERR_IRQ,
60 CRIME_MEMERR_IRQ,
61 CRIME_RE_EMPTY_E_IRQ,
62 CRIME_RE_FULL_E_IRQ,
63 CRIME_RE_IDLE_E_IRQ,
64 CRIME_RE_EMPTY_L_IRQ,
65 CRIME_RE_FULL_L_IRQ,
66 CRIME_RE_IDLE_L_IRQ,
67 CRIME_SOFT0_IRQ,
68 CRIME_SOFT1_IRQ,
69 CRIME_SOFT2_IRQ,
70 CRIME_SYSCORERR_IRQ = CRIME_SOFT2_IRQ,
71 CRIME_VICE_IRQ,
72
73 /*
74 * MACEISA
75 */
76 MACEISA_AUDIO_SW_IRQ,
77 MACEISA_AUDIO_SC_IRQ,
78 MACEISA_AUDIO1_DMAT_IRQ,
79 MACEISA_AUDIO1_OF_IRQ,
80 MACEISA_AUDIO2_DMAT_IRQ,
81 MACEISA_AUDIO2_MERR_IRQ,
82 MACEISA_AUDIO3_DMAT_IRQ,
83 MACEISA_AUDIO3_MERR_IRQ,
84 MACEISA_RTC_IRQ,
85 MACEISA_KEYB_IRQ,
86 /* MACEISA_KEYB_POLL is not an IRQ */
87 __MACEISA_KEYB_POLL,
88 MACEISA_MOUSE_IRQ,
89 /* MACEISA_MOUSE_POLL is not an IRQ */
90 __MACEISA_MOUSE_POLL,
91 MACEISA_TIMER0_IRQ,
92 MACEISA_TIMER1_IRQ,
93 MACEISA_TIMER2_IRQ,
94 MACEISA_PARALLEL_IRQ,
95 MACEISA_PAR_CTXA_IRQ,
96 MACEISA_PAR_CTXB_IRQ,
97 MACEISA_PAR_MERR_IRQ,
98 MACEISA_SERIAL1_IRQ,
99 MACEISA_SERIAL1_TDMAT_IRQ,
100 MACEISA_SERIAL1_TDMAPR_IRQ,
101 MACEISA_SERIAL1_TDMAME_IRQ,
102 MACEISA_SERIAL1_RDMAT_IRQ,
103 MACEISA_SERIAL1_RDMAOR_IRQ,
104 MACEISA_SERIAL2_IRQ,
105 MACEISA_SERIAL2_TDMAT_IRQ,
106 MACEISA_SERIAL2_TDMAPR_IRQ,
107 MACEISA_SERIAL2_TDMAME_IRQ,
108 MACEISA_SERIAL2_RDMAT_IRQ,
109 MACEISA_SERIAL2_RDMAOR_IRQ,
110
111 IP32_IRQ_MAX = MACEISA_SERIAL2_RDMAOR_IRQ
112};
113
114#endif /* __ASM_IP32_INTS_H */
diff --git a/arch/mips/include/asm/ip32/mace.h b/arch/mips/include/asm/ip32/mace.h
new file mode 100644
index 000000000000..d08d7c672139
--- /dev/null
+++ b/arch/mips/include/asm/ip32/mace.h
@@ -0,0 +1,365 @@
1/*
2 * Definitions for the SGI MACE (Multimedia, Audio and Communications Engine)
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2000 Harald Koerfgen
9 * Copyright (C) 2004 Ladislav Michl
10 */
11
12#ifndef __ASM_MACE_H__
13#define __ASM_MACE_H__
14
15/*
16 * Address map
17 */
18#define MACE_BASE 0x1f000000 /* physical */
19
20/*
21 * PCI interface
22 */
23struct mace_pci {
24 volatile unsigned int error_addr;
25 volatile unsigned int error;
26#define MACEPCI_ERROR_MASTER_ABORT BIT(31)
27#define MACEPCI_ERROR_TARGET_ABORT BIT(30)
28#define MACEPCI_ERROR_DATA_PARITY_ERR BIT(29)
29#define MACEPCI_ERROR_RETRY_ERR BIT(28)
30#define MACEPCI_ERROR_ILLEGAL_CMD BIT(27)
31#define MACEPCI_ERROR_SYSTEM_ERR BIT(26)
32#define MACEPCI_ERROR_INTERRUPT_TEST BIT(25)
33#define MACEPCI_ERROR_PARITY_ERR BIT(24)
34#define MACEPCI_ERROR_OVERRUN BIT(23)
35#define MACEPCI_ERROR_RSVD BIT(22)
36#define MACEPCI_ERROR_MEMORY_ADDR BIT(21)
37#define MACEPCI_ERROR_CONFIG_ADDR BIT(20)
38#define MACEPCI_ERROR_MASTER_ABORT_ADDR_VALID BIT(19)
39#define MACEPCI_ERROR_TARGET_ABORT_ADDR_VALID BIT(18)
40#define MACEPCI_ERROR_DATA_PARITY_ADDR_VALID BIT(17)
41#define MACEPCI_ERROR_RETRY_ADDR_VALID BIT(16)
42#define MACEPCI_ERROR_SIG_TABORT BIT(4)
43#define MACEPCI_ERROR_DEVSEL_MASK 0xc0
44#define MACEPCI_ERROR_DEVSEL_FAST 0
45#define MACEPCI_ERROR_DEVSEL_MED 0x40
46#define MACEPCI_ERROR_DEVSEL_SLOW 0x80
47#define MACEPCI_ERROR_FBB BIT(1)
48#define MACEPCI_ERROR_66MHZ BIT(0)
49 volatile unsigned int control;
50#define MACEPCI_CONTROL_INT(x) BIT(x)
51#define MACEPCI_CONTROL_INT_MASK 0xff
52#define MACEPCI_CONTROL_SERR_ENA BIT(8)
53#define MACEPCI_CONTROL_ARB_N6 BIT(9)
54#define MACEPCI_CONTROL_PARITY_ERR BIT(10)
55#define MACEPCI_CONTROL_MRMRA_ENA BIT(11)
56#define MACEPCI_CONTROL_ARB_N3 BIT(12)
57#define MACEPCI_CONTROL_ARB_N4 BIT(13)
58#define MACEPCI_CONTROL_ARB_N5 BIT(14)
59#define MACEPCI_CONTROL_PARK_LIU BIT(15)
60#define MACEPCI_CONTROL_INV_INT(x) BIT(16+x)
61#define MACEPCI_CONTROL_INV_INT_MASK 0x00ff0000
62#define MACEPCI_CONTROL_OVERRUN_INT BIT(24)
63#define MACEPCI_CONTROL_PARITY_INT BIT(25)
64#define MACEPCI_CONTROL_SERR_INT BIT(26)
65#define MACEPCI_CONTROL_IT_INT BIT(27)
66#define MACEPCI_CONTROL_RE_INT BIT(28)
67#define MACEPCI_CONTROL_DPED_INT BIT(29)
68#define MACEPCI_CONTROL_TAR_INT BIT(30)
69#define MACEPCI_CONTROL_MAR_INT BIT(31)
70 volatile unsigned int rev;
71 unsigned int _pad[0xcf8/4 - 4];
72 volatile unsigned int config_addr;
73 union {
74 volatile unsigned char b[4];
75 volatile unsigned short w[2];
76 volatile unsigned int l;
77 } config_data;
78};
79#define MACEPCI_LOW_MEMORY 0x1a000000
80#define MACEPCI_LOW_IO 0x18000000
81#define MACEPCI_SWAPPED_VIEW 0
82#define MACEPCI_NATIVE_VIEW 0x40000000
83#define MACEPCI_IO 0x80000000
84#define MACEPCI_HI_MEMORY 0x280000000
85#define MACEPCI_HI_IO 0x100000000
86
87/*
88 * Video interface
89 */
90struct mace_video {
91 unsigned long xxx; /* later... */
92};
93
94/*
95 * Ethernet interface
96 */
97struct mace_ethernet {
98 volatile unsigned long mac_ctrl;
99 volatile unsigned long int_stat;
100 volatile unsigned long dma_ctrl;
101 volatile unsigned long timer;
102 volatile unsigned long tx_int_al;
103 volatile unsigned long rx_int_al;
104 volatile unsigned long tx_info;
105 volatile unsigned long tx_info_al;
106 volatile unsigned long rx_buff;
107 volatile unsigned long rx_buff_al1;
108 volatile unsigned long rx_buff_al2;
109 volatile unsigned long diag;
110 volatile unsigned long phy_data;
111 volatile unsigned long phy_regs;
112 volatile unsigned long phy_trans_go;
113 volatile unsigned long backoff_seed;
114 /*===================================*/
115 volatile unsigned long imq_reserved[4];
116 volatile unsigned long mac_addr;
117 volatile unsigned long mac_addr2;
118 volatile unsigned long mcast_filter;
119 volatile unsigned long tx_ring_base;
120 /* Following are read-only registers for debugging */
121 volatile unsigned long tx_pkt1_hdr;
122 volatile unsigned long tx_pkt1_ptr[3];
123 volatile unsigned long tx_pkt2_hdr;
124 volatile unsigned long tx_pkt2_ptr[3];
125 /*===================================*/
126 volatile unsigned long rx_fifo;
127};
128
129/*
130 * Peripherals
131 */
132
133/* Audio registers */
134struct mace_audio {
135 volatile unsigned long control;
136 volatile unsigned long codec_control; /* codec status control */
137 volatile unsigned long codec_mask; /* codec status input mask */
138 volatile unsigned long codec_read; /* codec status read data */
139 struct {
140 volatile unsigned long control; /* channel control */
141 volatile unsigned long read_ptr; /* channel read pointer */
142 volatile unsigned long write_ptr; /* channel write pointer */
143 volatile unsigned long depth; /* channel depth */
144 } chan[3];
145};
146
147
148/* register definitions for parallel port DMA */
149struct mace_parport {
150 /* 0 - do nothing,
151 * 1 - pulse terminal count to the device after buffer is drained */
152#define MACEPAR_CONTEXT_LASTFLAG BIT(63)
153 /* Should not cross 4K page boundary */
154#define MACEPAR_CONTEXT_DATA_BOUND 0x0000000000001000UL
155#define MACEPAR_CONTEXT_DATALEN_MASK 0x00000fff00000000UL
156#define MACEPAR_CONTEXT_DATALEN_SHIFT 32
157 /* Can be arbitrarily aligned on any byte boundary on output,
158 * 64 byte aligned on input */
159#define MACEPAR_CONTEXT_BASEADDR_MASK 0x00000000ffffffffUL
160 volatile u64 context_a;
161 volatile u64 context_b;
162 /* 0 - mem->device, 1 - device->mem */
163#define MACEPAR_CTLSTAT_DIRECTION BIT(0)
164 /* 0 - channel frozen, 1 - channel enabled */
165#define MACEPAR_CTLSTAT_ENABLE BIT(1)
166 /* 0 - channel active, 1 - complete channel reset */
167#define MACEPAR_CTLSTAT_RESET BIT(2)
168#define MACEPAR_CTLSTAT_CTXB_VALID BIT(3)
169#define MACEPAR_CTLSTAT_CTXA_VALID BIT(4)
170 volatile u64 cntlstat; /* Control/Status register */
171#define MACEPAR_DIAG_CTXINUSE BIT(0)
172 /* 1 - Dma engine is enabled and processing something */
173#define MACEPAR_DIAG_DMACTIVE BIT(1)
174 /* Counter of bytes left */
175#define MACEPAR_DIAG_CTRMASK 0x0000000000003ffcUL
176#define MACEPAR_DIAG_CTRSHIFT 2
177 volatile u64 diagnostic; /* RO: diagnostic register */
178};
179
180/* ISA Control and DMA registers */
181struct mace_isactrl {
182 volatile unsigned long ringbase;
183#define MACEISA_RINGBUFFERS_SIZE (8 * 4096)
184
185 volatile unsigned long misc;
186#define MACEISA_FLASH_WE BIT(0) /* 1=> Enable FLASH writes */
187#define MACEISA_PWD_CLEAR BIT(1) /* 1=> PWD CLEAR jumper detected */
188#define MACEISA_NIC_DEASSERT BIT(2)
189#define MACEISA_NIC_DATA BIT(3)
190#define MACEISA_LED_RED BIT(4) /* 0=> Illuminate red LED */
191#define MACEISA_LED_GREEN BIT(5) /* 0=> Illuminate green LED */
192#define MACEISA_DP_RAM_ENABLE BIT(6)
193
194 volatile unsigned long istat;
195 volatile unsigned long imask;
196#define MACEISA_AUDIO_SW_INT BIT(0)
197#define MACEISA_AUDIO_SC_INT BIT(1)
198#define MACEISA_AUDIO1_DMAT_INT BIT(2)
199#define MACEISA_AUDIO1_OF_INT BIT(3)
200#define MACEISA_AUDIO2_DMAT_INT BIT(4)
201#define MACEISA_AUDIO2_MERR_INT BIT(5)
202#define MACEISA_AUDIO3_DMAT_INT BIT(6)
203#define MACEISA_AUDIO3_MERR_INT BIT(7)
204#define MACEISA_RTC_INT BIT(8)
205#define MACEISA_KEYB_INT BIT(9)
206#define MACEISA_KEYB_POLL_INT BIT(10)
207#define MACEISA_MOUSE_INT BIT(11)
208#define MACEISA_MOUSE_POLL_INT BIT(12)
209#define MACEISA_TIMER0_INT BIT(13)
210#define MACEISA_TIMER1_INT BIT(14)
211#define MACEISA_TIMER2_INT BIT(15)
212#define MACEISA_PARALLEL_INT BIT(16)
213#define MACEISA_PAR_CTXA_INT BIT(17)
214#define MACEISA_PAR_CTXB_INT BIT(18)
215#define MACEISA_PAR_MERR_INT BIT(19)
216#define MACEISA_SERIAL1_INT BIT(20)
217#define MACEISA_SERIAL1_TDMAT_INT BIT(21)
218#define MACEISA_SERIAL1_TDMAPR_INT BIT(22)
219#define MACEISA_SERIAL1_TDMAME_INT BIT(23)
220#define MACEISA_SERIAL1_RDMAT_INT BIT(24)
221#define MACEISA_SERIAL1_RDMAOR_INT BIT(25)
222#define MACEISA_SERIAL2_INT BIT(26)
223#define MACEISA_SERIAL2_TDMAT_INT BIT(27)
224#define MACEISA_SERIAL2_TDMAPR_INT BIT(28)
225#define MACEISA_SERIAL2_TDMAME_INT BIT(29)
226#define MACEISA_SERIAL2_RDMAT_INT BIT(30)
227#define MACEISA_SERIAL2_RDMAOR_INT BIT(31)
228
229 volatile unsigned long _pad[0x2000/8 - 4];
230
231 volatile unsigned long dp_ram[0x400];
232 struct mace_parport parport;
233};
234
235/* Keyboard & Mouse registers
236 * -> drivers/input/serio/maceps2.c */
237struct mace_ps2port {
238 volatile unsigned long tx;
239 volatile unsigned long rx;
240 volatile unsigned long control;
241 volatile unsigned long status;
242};
243
244struct mace_ps2 {
245 struct mace_ps2port keyb;
246 struct mace_ps2port mouse;
247};
248
249/* I2C registers
250 * -> drivers/i2c/algos/i2c-algo-sgi.c */
251struct mace_i2c {
252 volatile unsigned long config;
253#define MACEI2C_RESET BIT(0)
254#define MACEI2C_FAST BIT(1)
255#define MACEI2C_DATA_OVERRIDE BIT(2)
256#define MACEI2C_CLOCK_OVERRIDE BIT(3)
257#define MACEI2C_DATA_STATUS BIT(4)
258#define MACEI2C_CLOCK_STATUS BIT(5)
259 volatile unsigned long control;
260 volatile unsigned long data;
261};
262
263/* Timer registers */
264typedef union {
265 volatile unsigned long ust_msc;
266 struct reg {
267 volatile unsigned int ust;
268 volatile unsigned int msc;
269 } reg;
270} timer_reg;
271
272struct mace_timers {
273 volatile unsigned long ust;
274#define MACE_UST_PERIOD_NS 960
275
276 volatile unsigned long compare1;
277 volatile unsigned long compare2;
278 volatile unsigned long compare3;
279
280 timer_reg audio_in;
281 timer_reg audio_out1;
282 timer_reg audio_out2;
283 timer_reg video_in1;
284 timer_reg video_in2;
285 timer_reg video_out;
286};
287
288struct mace_perif {
289 struct mace_audio audio;
290 char _pad0[0x10000 - sizeof(struct mace_audio)];
291
292 struct mace_isactrl ctrl;
293 char _pad1[0x10000 - sizeof(struct mace_isactrl)];
294
295 struct mace_ps2 ps2;
296 char _pad2[0x10000 - sizeof(struct mace_ps2)];
297
298 struct mace_i2c i2c;
299 char _pad3[0x10000 - sizeof(struct mace_i2c)];
300
301 struct mace_timers timers;
302 char _pad4[0x10000 - sizeof(struct mace_timers)];
303};
304
305
306/*
307 * ISA peripherals
308 */
309
310/* Parallel port */
311struct mace_parallel {
312};
313
314struct mace_ecp1284 { /* later... */
315};
316
317/* Serial port */
318struct mace_serial {
319 volatile unsigned long xxx; /* later... */
320};
321
322struct mace_isa {
323 struct mace_parallel parallel;
324 char _pad1[0x8000 - sizeof(struct mace_parallel)];
325
326 struct mace_ecp1284 ecp1284;
327 char _pad2[0x8000 - sizeof(struct mace_ecp1284)];
328
329 struct mace_serial serial1;
330 char _pad3[0x8000 - sizeof(struct mace_serial)];
331
332 struct mace_serial serial2;
333 char _pad4[0x8000 - sizeof(struct mace_serial)];
334
335 volatile unsigned char rtc[0x10000];
336};
337
338struct sgi_mace {
339 char _reserved[0x80000];
340
341 struct mace_pci pci;
342 char _pad0[0x80000 - sizeof(struct mace_pci)];
343
344 struct mace_video video_in1;
345 char _pad1[0x80000 - sizeof(struct mace_video)];
346
347 struct mace_video video_in2;
348 char _pad2[0x80000 - sizeof(struct mace_video)];
349
350 struct mace_video video_out;
351 char _pad3[0x80000 - sizeof(struct mace_video)];
352
353 struct mace_ethernet eth;
354 char _pad4[0x80000 - sizeof(struct mace_ethernet)];
355
356 struct mace_perif perif;
357 char _pad5[0x80000 - sizeof(struct mace_perif)];
358
359 struct mace_isa isa;
360 char _pad6[0x80000 - sizeof(struct mace_isa)];
361};
362
363extern struct sgi_mace __iomem *mace;
364
365#endif /* __ASM_MACE_H__ */
diff --git a/arch/mips/include/asm/ipcbuf.h b/arch/mips/include/asm/ipcbuf.h
new file mode 100644
index 000000000000..d47d08f264e7
--- /dev/null
+++ b/arch/mips/include/asm/ipcbuf.h
@@ -0,0 +1,28 @@
1#ifndef _ASM_IPCBUF_H
2#define _ASM_IPCBUF_H
3
4/*
5 * The ipc64_perm structure for alpha architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 32-bit seq
11 * - 2 miscellaneous 64-bit values
12 */
13
14struct ipc64_perm
15{
16 __kernel_key_t key;
17 __kernel_uid_t uid;
18 __kernel_gid_t gid;
19 __kernel_uid_t cuid;
20 __kernel_gid_t cgid;
21 __kernel_mode_t mode;
22 unsigned short seq;
23 unsigned short __pad1;
24 unsigned long __unused1;
25 unsigned long __unused2;
26};
27
28#endif /* _ASM_IPCBUF_H */
diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h
new file mode 100644
index 000000000000..a58f0eecc68f
--- /dev/null
+++ b/arch/mips/include/asm/irq.h
@@ -0,0 +1,163 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 by Waldorf GMBH, written by Ralf Baechle
7 * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02, 03 by Ralf Baechle
8 */
9#ifndef _ASM_IRQ_H
10#define _ASM_IRQ_H
11
12#include <linux/linkage.h>
13
14#include <asm/mipsmtregs.h>
15
16#include <irq.h>
17
18#ifdef CONFIG_I8259
19static inline int irq_canonicalize(int irq)
20{
21 return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq);
22}
23#else
24#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */
25#endif
26
27#ifdef CONFIG_MIPS_MT_SMTC
28
29struct irqaction;
30
31extern unsigned long irq_hwmask[];
32extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
33 unsigned long hwmask);
34
35static inline void smtc_im_ack_irq(unsigned int irq)
36{
37 if (irq_hwmask[irq] & ST0_IM)
38 set_c0_status(irq_hwmask[irq] & ST0_IM);
39}
40
41#else
42
43static inline void smtc_im_ack_irq(unsigned int irq)
44{
45}
46
47#endif /* CONFIG_MIPS_MT_SMTC */
48
49#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
50#include <linux/cpumask.h>
51
52extern void plat_set_irq_affinity(unsigned int irq, cpumask_t affinity);
53extern void smtc_forward_irq(unsigned int irq);
54
55/*
56 * IRQ affinity hook invoked at the beginning of interrupt dispatch
57 * if option is enabled.
58 *
59 * Up through Linux 2.6.22 (at least) cpumask operations are very
60 * inefficient on MIPS. Initial prototypes of SMTC IRQ affinity
61 * used a "fast path" per-IRQ-descriptor cache of affinity information
62 * to reduce latency. As there is a project afoot to optimize the
63 * cpumask implementations, this version is optimistically assuming
64 * that cpumask.h macro overhead is reasonable during interrupt dispatch.
65 */
66#define IRQ_AFFINITY_HOOK(irq) \
67do { \
68 if (!cpu_isset(smp_processor_id(), irq_desc[irq].affinity)) { \
69 smtc_forward_irq(irq); \
70 irq_exit(); \
71 return; \
72 } \
73} while (0)
74
75#else /* Not doing SMTC affinity */
76
77#define IRQ_AFFINITY_HOOK(irq) do { } while (0)
78
79#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
80
81#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
82
83/*
84 * Clear interrupt mask handling "backstop" if irq_hwmask
85 * entry so indicates. This implies that the ack() or end()
86 * functions will take over re-enabling the low-level mask.
87 * Otherwise it will be done on return from exception.
88 */
89#define __DO_IRQ_SMTC_HOOK(irq) \
90do { \
91 IRQ_AFFINITY_HOOK(irq); \
92 if (irq_hwmask[irq] & 0x0000ff00) \
93 write_c0_tccontext(read_c0_tccontext() & \
94 ~(irq_hwmask[irq] & 0x0000ff00)); \
95} while (0)
96
97#define __NO_AFFINITY_IRQ_SMTC_HOOK(irq) \
98do { \
99 if (irq_hwmask[irq] & 0x0000ff00) \
100 write_c0_tccontext(read_c0_tccontext() & \
101 ~(irq_hwmask[irq] & 0x0000ff00)); \
102} while (0)
103
104#else
105
106#define __DO_IRQ_SMTC_HOOK(irq) \
107do { \
108 IRQ_AFFINITY_HOOK(irq); \
109} while (0)
110#define __NO_AFFINITY_IRQ_SMTC_HOOK(irq) do { } while (0)
111
112#endif
113
114/*
115 * do_IRQ handles all normal device IRQ's (the special
116 * SMP cross-CPU interrupts have their own specific
117 * handlers).
118 *
119 * Ideally there should be away to get this into kernel/irq/handle.c to
120 * avoid the overhead of a call for just a tiny function ...
121 */
122#define do_IRQ(irq) \
123do { \
124 irq_enter(); \
125 __DO_IRQ_SMTC_HOOK(irq); \
126 generic_handle_irq(irq); \
127 irq_exit(); \
128} while (0)
129
130#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
131/*
132 * To avoid inefficient and in some cases pathological re-checking of
133 * IRQ affinity, we have this variant that skips the affinity check.
134 */
135
136
137#define do_IRQ_no_affinity(irq) \
138do { \
139 irq_enter(); \
140 __NO_AFFINITY_IRQ_SMTC_HOOK(irq); \
141 generic_handle_irq(irq); \
142 irq_exit(); \
143} while (0)
144
145#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
146
147extern void arch_init_irq(void);
148extern void spurious_interrupt(void);
149
150extern int allocate_irqno(void);
151extern void alloc_legacy_irqno(void);
152extern void free_irqno(unsigned int irq);
153
154/*
155 * Before R2 the timer and performance counter interrupts were both fixed to
156 * IE7. Since R2 their number has to be read from the c0_intctl register.
157 */
158#define CP0_LEGACY_COMPARE_IRQ 7
159
160extern int cp0_compare_irq;
161extern int cp0_perfcount_irq;
162
163#endif /* _ASM_IRQ_H */
diff --git a/arch/mips/include/asm/irq_cpu.h b/arch/mips/include/asm/irq_cpu.h
new file mode 100644
index 000000000000..ef6a07cddb23
--- /dev/null
+++ b/arch/mips/include/asm/irq_cpu.h
@@ -0,0 +1,20 @@
1/*
2 * include/asm-mips/irq_cpu.h
3 *
4 * MIPS CPU interrupt definitions.
5 *
6 * Copyright (C) 2002 Maciej W. Rozycki
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#ifndef _ASM_IRQ_CPU_H
14#define _ASM_IRQ_CPU_H
15
16extern void mips_cpu_irq_init(void);
17extern void rm7k_cpu_irq_init(void);
18extern void rm9k_cpu_irq_init(void);
19
20#endif /* _ASM_IRQ_CPU_H */
diff --git a/arch/mips/include/asm/irq_gt641xx.h b/arch/mips/include/asm/irq_gt641xx.h
new file mode 100644
index 000000000000..f9a7c3ac2e66
--- /dev/null
+++ b/arch/mips/include/asm/irq_gt641xx.h
@@ -0,0 +1,60 @@
1/*
2 * Galileo/Marvell GT641xx IRQ definitions.
3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#ifndef _ASM_IRQ_GT641XX_H
21#define _ASM_IRQ_GT641XX_H
22
23#ifndef GT641XX_IRQ_BASE
24#define GT641XX_IRQ_BASE 8
25#endif
26
27#define GT641XX_MEMORY_OUT_OF_RANGE_IRQ (GT641XX_IRQ_BASE + 1)
28#define GT641XX_DMA_OUT_OF_RANGE_IRQ (GT641XX_IRQ_BASE + 2)
29#define GT641XX_CPU_ACCESS_OUT_OF_RANGE_IRQ (GT641XX_IRQ_BASE + 3)
30#define GT641XX_DMA0_IRQ (GT641XX_IRQ_BASE + 4)
31#define GT641XX_DMA1_IRQ (GT641XX_IRQ_BASE + 5)
32#define GT641XX_DMA2_IRQ (GT641XX_IRQ_BASE + 6)
33#define GT641XX_DMA3_IRQ (GT641XX_IRQ_BASE + 7)
34#define GT641XX_TIMER0_IRQ (GT641XX_IRQ_BASE + 8)
35#define GT641XX_TIMER1_IRQ (GT641XX_IRQ_BASE + 9)
36#define GT641XX_TIMER2_IRQ (GT641XX_IRQ_BASE + 10)
37#define GT641XX_TIMER3_IRQ (GT641XX_IRQ_BASE + 11)
38#define GT641XX_PCI_0_MASTER_READ_ERROR_IRQ (GT641XX_IRQ_BASE + 12)
39#define GT641XX_PCI_0_SLAVE_WRITE_ERROR_IRQ (GT641XX_IRQ_BASE + 13)
40#define GT641XX_PCI_0_MASTER_WRITE_ERROR_IRQ (GT641XX_IRQ_BASE + 14)
41#define GT641XX_PCI_0_SLAVE_READ_ERROR_IRQ (GT641XX_IRQ_BASE + 15)
42#define GT641XX_PCI_0_ADDRESS_ERROR_IRQ (GT641XX_IRQ_BASE + 16)
43#define GT641XX_MEMORY_ERROR_IRQ (GT641XX_IRQ_BASE + 17)
44#define GT641XX_PCI_0_MASTER_ABORT_IRQ (GT641XX_IRQ_BASE + 18)
45#define GT641XX_PCI_0_TARGET_ABORT_IRQ (GT641XX_IRQ_BASE + 19)
46#define GT641XX_PCI_0_RETRY_TIMEOUT_IRQ (GT641XX_IRQ_BASE + 20)
47#define GT641XX_CPU_INT0_IRQ (GT641XX_IRQ_BASE + 21)
48#define GT641XX_CPU_INT1_IRQ (GT641XX_IRQ_BASE + 22)
49#define GT641XX_CPU_INT2_IRQ (GT641XX_IRQ_BASE + 23)
50#define GT641XX_CPU_INT3_IRQ (GT641XX_IRQ_BASE + 24)
51#define GT641XX_CPU_INT4_IRQ (GT641XX_IRQ_BASE + 25)
52#define GT641XX_PCI_INT0_IRQ (GT641XX_IRQ_BASE + 26)
53#define GT641XX_PCI_INT1_IRQ (GT641XX_IRQ_BASE + 27)
54#define GT641XX_PCI_INT2_IRQ (GT641XX_IRQ_BASE + 28)
55#define GT641XX_PCI_INT3_IRQ (GT641XX_IRQ_BASE + 29)
56
57extern void gt641xx_irq_dispatch(void);
58extern void gt641xx_irq_init(void);
59
60#endif /* _ASM_IRQ_GT641XX_H */
diff --git a/arch/mips/include/asm/irq_regs.h b/arch/mips/include/asm/irq_regs.h
new file mode 100644
index 000000000000..33bd2a06de57
--- /dev/null
+++ b/arch/mips/include/asm/irq_regs.h
@@ -0,0 +1,21 @@
1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version
5 * 2 of the License, or (at your option) any later version.
6 *
7 * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org)
8 */
9#ifndef __ASM_IRQ_REGS_H
10#define __ASM_IRQ_REGS_H
11
12#define ARCH_HAS_OWN_IRQ_REGS
13
14#include <linux/thread_info.h>
15
16static inline struct pt_regs *get_irq_regs(void)
17{
18 return current_thread_info()->regs;
19}
20
21#endif /* __ASM_IRQ_REGS_H */
diff --git a/arch/mips/include/asm/irqflags.h b/arch/mips/include/asm/irqflags.h
new file mode 100644
index 000000000000..701ec0ba8fa9
--- /dev/null
+++ b/arch/mips/include/asm/irqflags.h
@@ -0,0 +1,283 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003 by Ralf Baechle
7 * Copyright (C) 1996 by Paul M. Antoine
8 * Copyright (C) 1999 Silicon Graphics
9 * Copyright (C) 2000 MIPS Technologies, Inc.
10 */
11#ifndef _ASM_IRQFLAGS_H
12#define _ASM_IRQFLAGS_H
13
14#ifndef __ASSEMBLY__
15
16#include <linux/compiler.h>
17#include <asm/hazards.h>
18
19__asm__(
20 " .macro raw_local_irq_enable \n"
21 " .set push \n"
22 " .set reorder \n"
23 " .set noat \n"
24#ifdef CONFIG_MIPS_MT_SMTC
25 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
26 " ori $1, 0x400 \n"
27 " xori $1, 0x400 \n"
28 " mtc0 $1, $2, 1 \n"
29#elif defined(CONFIG_CPU_MIPSR2)
30 " ei \n"
31#else
32 " mfc0 $1,$12 \n"
33 " ori $1,0x1f \n"
34 " xori $1,0x1e \n"
35 " mtc0 $1,$12 \n"
36#endif
37 " irq_enable_hazard \n"
38 " .set pop \n"
39 " .endm");
40
41extern void smtc_ipi_replay(void);
42
43static inline void raw_local_irq_enable(void)
44{
45#ifdef CONFIG_MIPS_MT_SMTC
46 /*
47 * SMTC kernel needs to do a software replay of queued
48 * IPIs, at the cost of call overhead on each local_irq_enable()
49 */
50 smtc_ipi_replay();
51#endif
52 __asm__ __volatile__(
53 "raw_local_irq_enable"
54 : /* no outputs */
55 : /* no inputs */
56 : "memory");
57}
58
59
60/*
61 * For cli() we have to insert nops to make sure that the new value
62 * has actually arrived in the status register before the end of this
63 * macro.
64 * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
65 * no nops at all.
66 */
67/*
68 * For TX49, operating only IE bit is not enough.
69 *
70 * If mfc0 $12 follows store and the mfc0 is last instruction of a
71 * page and fetching the next instruction causes TLB miss, the result
72 * of the mfc0 might wrongly contain EXL bit.
73 *
74 * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
75 *
76 * Workaround: mask EXL bit of the result or place a nop before mfc0.
77 */
78__asm__(
79 " .macro raw_local_irq_disable\n"
80 " .set push \n"
81 " .set noat \n"
82#ifdef CONFIG_MIPS_MT_SMTC
83 " mfc0 $1, $2, 1 \n"
84 " ori $1, 0x400 \n"
85 " .set noreorder \n"
86 " mtc0 $1, $2, 1 \n"
87#elif defined(CONFIG_CPU_MIPSR2)
88 " di \n"
89#else
90 " mfc0 $1,$12 \n"
91 " ori $1,0x1f \n"
92 " xori $1,0x1f \n"
93 " .set noreorder \n"
94 " mtc0 $1,$12 \n"
95#endif
96 " irq_disable_hazard \n"
97 " .set pop \n"
98 " .endm \n");
99
100static inline void raw_local_irq_disable(void)
101{
102 __asm__ __volatile__(
103 "raw_local_irq_disable"
104 : /* no outputs */
105 : /* no inputs */
106 : "memory");
107}
108
109__asm__(
110 " .macro raw_local_save_flags flags \n"
111 " .set push \n"
112 " .set reorder \n"
113#ifdef CONFIG_MIPS_MT_SMTC
114 " mfc0 \\flags, $2, 1 \n"
115#else
116 " mfc0 \\flags, $12 \n"
117#endif
118 " .set pop \n"
119 " .endm \n");
120
121#define raw_local_save_flags(x) \
122__asm__ __volatile__( \
123 "raw_local_save_flags %0" \
124 : "=r" (x))
125
126__asm__(
127 " .macro raw_local_irq_save result \n"
128 " .set push \n"
129 " .set reorder \n"
130 " .set noat \n"
131#ifdef CONFIG_MIPS_MT_SMTC
132 " mfc0 \\result, $2, 1 \n"
133 " ori $1, \\result, 0x400 \n"
134 " .set noreorder \n"
135 " mtc0 $1, $2, 1 \n"
136 " andi \\result, \\result, 0x400 \n"
137#elif defined(CONFIG_CPU_MIPSR2)
138 " di \\result \n"
139 " andi \\result, 1 \n"
140#else
141 " mfc0 \\result, $12 \n"
142 " ori $1, \\result, 0x1f \n"
143 " xori $1, 0x1f \n"
144 " .set noreorder \n"
145 " mtc0 $1, $12 \n"
146#endif
147 " irq_disable_hazard \n"
148 " .set pop \n"
149 " .endm \n");
150
151#define raw_local_irq_save(x) \
152__asm__ __volatile__( \
153 "raw_local_irq_save\t%0" \
154 : "=r" (x) \
155 : /* no inputs */ \
156 : "memory")
157
158__asm__(
159 " .macro raw_local_irq_restore flags \n"
160 " .set push \n"
161 " .set noreorder \n"
162 " .set noat \n"
163#ifdef CONFIG_MIPS_MT_SMTC
164 "mfc0 $1, $2, 1 \n"
165 "andi \\flags, 0x400 \n"
166 "ori $1, 0x400 \n"
167 "xori $1, 0x400 \n"
168 "or \\flags, $1 \n"
169 "mtc0 \\flags, $2, 1 \n"
170#elif defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
171 /*
172 * Slow, but doesn't suffer from a relativly unlikely race
173 * condition we're having since days 1.
174 */
175 " beqz \\flags, 1f \n"
176 " di \n"
177 " ei \n"
178 "1: \n"
179#elif defined(CONFIG_CPU_MIPSR2)
180 /*
181 * Fast, dangerous. Life is fun, life is good.
182 */
183 " mfc0 $1, $12 \n"
184 " ins $1, \\flags, 0, 1 \n"
185 " mtc0 $1, $12 \n"
186#else
187 " mfc0 $1, $12 \n"
188 " andi \\flags, 1 \n"
189 " ori $1, 0x1f \n"
190 " xori $1, 0x1f \n"
191 " or \\flags, $1 \n"
192 " mtc0 \\flags, $12 \n"
193#endif
194 " irq_disable_hazard \n"
195 " .set pop \n"
196 " .endm \n");
197
198
199static inline void raw_local_irq_restore(unsigned long flags)
200{
201 unsigned long __tmp1;
202
203#ifdef CONFIG_MIPS_MT_SMTC
204 /*
205 * SMTC kernel needs to do a software replay of queued
206 * IPIs, at the cost of branch and call overhead on each
207 * local_irq_restore()
208 */
209 if (unlikely(!(flags & 0x0400)))
210 smtc_ipi_replay();
211#endif
212
213 __asm__ __volatile__(
214 "raw_local_irq_restore\t%0"
215 : "=r" (__tmp1)
216 : "0" (flags)
217 : "memory");
218}
219
220static inline void __raw_local_irq_restore(unsigned long flags)
221{
222 unsigned long __tmp1;
223
224 __asm__ __volatile__(
225 "raw_local_irq_restore\t%0"
226 : "=r" (__tmp1)
227 : "0" (flags)
228 : "memory");
229}
230
231static inline int raw_irqs_disabled_flags(unsigned long flags)
232{
233#ifdef CONFIG_MIPS_MT_SMTC
234 /*
235 * SMTC model uses TCStatus.IXMT to disable interrupts for a thread/CPU
236 */
237 return flags & 0x400;
238#else
239 return !(flags & 1);
240#endif
241}
242
243#endif
244
245/*
246 * Do the CPU's IRQ-state tracing from assembly code.
247 */
248#ifdef CONFIG_TRACE_IRQFLAGS
249/* Reload some registers clobbered by trace_hardirqs_on */
250#ifdef CONFIG_64BIT
251# define TRACE_IRQS_RELOAD_REGS \
252 LONG_L $11, PT_R11(sp); \
253 LONG_L $10, PT_R10(sp); \
254 LONG_L $9, PT_R9(sp); \
255 LONG_L $8, PT_R8(sp); \
256 LONG_L $7, PT_R7(sp); \
257 LONG_L $6, PT_R6(sp); \
258 LONG_L $5, PT_R5(sp); \
259 LONG_L $4, PT_R4(sp); \
260 LONG_L $2, PT_R2(sp)
261#else
262# define TRACE_IRQS_RELOAD_REGS \
263 LONG_L $7, PT_R7(sp); \
264 LONG_L $6, PT_R6(sp); \
265 LONG_L $5, PT_R5(sp); \
266 LONG_L $4, PT_R4(sp); \
267 LONG_L $2, PT_R2(sp)
268#endif
269# define TRACE_IRQS_ON \
270 CLI; /* make sure trace_hardirqs_on() is called in kernel level */ \
271 jal trace_hardirqs_on
272# define TRACE_IRQS_ON_RELOAD \
273 TRACE_IRQS_ON; \
274 TRACE_IRQS_RELOAD_REGS
275# define TRACE_IRQS_OFF \
276 jal trace_hardirqs_off
277#else
278# define TRACE_IRQS_ON
279# define TRACE_IRQS_ON_RELOAD
280# define TRACE_IRQS_OFF
281#endif
282
283#endif /* _ASM_IRQFLAGS_H */
diff --git a/arch/mips/include/asm/isadep.h b/arch/mips/include/asm/isadep.h
new file mode 100644
index 000000000000..24c6cda79377
--- /dev/null
+++ b/arch/mips/include/asm/isadep.h
@@ -0,0 +1,34 @@
1/*
2 * Various ISA level dependent constants.
3 * Most of the following constants reflect the different layout
4 * of Coprocessor 0 registers.
5 *
6 * Copyright (c) 1998 Harald Koerfgen
7 */
8
9#ifndef __ASM_ISADEP_H
10#define __ASM_ISADEP_H
11
12#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
13/*
14 * R2000 or R3000
15 */
16
17/*
18 * kernel or user mode? (CP0_STATUS)
19 */
20#define KU_MASK 0x08
21#define KU_USER 0x08
22#define KU_KERN 0x00
23
24#else
25/*
26 * kernel or user mode?
27 */
28#define KU_MASK 0x18
29#define KU_USER 0x10
30#define KU_KERN 0x00
31
32#endif
33
34#endif /* __ASM_ISADEP_H */
diff --git a/arch/mips/include/asm/jazz.h b/arch/mips/include/asm/jazz.h
new file mode 100644
index 000000000000..83f449dec95e
--- /dev/null
+++ b/arch/mips/include/asm/jazz.h
@@ -0,0 +1,310 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995 - 1998 by Andreas Busse and Ralf Baechle
7 */
8#ifndef __ASM_JAZZ_H
9#define __ASM_JAZZ_H
10
11/*
12 * The addresses below are virtual address. The mappings are
13 * created on startup via wired entries in the tlb. The Mips
14 * Magnum R3000 and R4000 machines are similar in many aspects,
15 * but many hardware register are accessible at 0xb9000000 in
16 * instead of 0xe0000000.
17 */
18
19#define JAZZ_LOCAL_IO_SPACE 0xe0000000
20
21/*
22 * Revision numbers in PICA_ASIC_REVISION
23 *
24 * 0xf0000000 - Rev1
25 * 0xf0000001 - Rev2
26 * 0xf0000002 - Rev3
27 */
28#define PICA_ASIC_REVISION 0xe0000008
29
30/*
31 * The segments of the seven segment LED are mapped
32 * to the control bits as follows:
33 *
34 * (7)
35 * ---------
36 * | |
37 * (2) | | (6)
38 * | (1) |
39 * ---------
40 * | |
41 * (3) | | (5)
42 * | (4) |
43 * --------- . (0)
44 */
45#define PICA_LED 0xe000f000
46
47/*
48 * Some characters for the LED control registers
49 * The original Mips machines seem to have a LED display
50 * with integrated decoder while the Acer machines can
51 * control each of the seven segments and the dot independently.
52 * It's only a toy, anyway...
53 */
54#define LED_DOT 0x01
55#define LED_SPACE 0x00
56#define LED_0 0xfc
57#define LED_1 0x60
58#define LED_2 0xda
59#define LED_3 0xf2
60#define LED_4 0x66
61#define LED_5 0xb6
62#define LED_6 0xbe
63#define LED_7 0xe0
64#define LED_8 0xfe
65#define LED_9 0xf6
66#define LED_A 0xee
67#define LED_b 0x3e
68#define LED_C 0x9c
69#define LED_d 0x7a
70#define LED_E 0x9e
71#define LED_F 0x8e
72
73#ifndef __ASSEMBLY__
74
75static __inline__ void pica_set_led(unsigned int bits)
76{
77 volatile unsigned int *led_register = (unsigned int *) PICA_LED;
78
79 *led_register = bits;
80}
81
82#endif /* !__ASSEMBLY__ */
83
84/*
85 * Base address of the Sonic Ethernet adapter in Jazz machines.
86 */
87#define JAZZ_ETHERNET_BASE 0xe0001000
88
89/*
90 * Base address of the 53C94 SCSI hostadapter in Jazz machines.
91 */
92#define JAZZ_SCSI_BASE 0xe0002000
93
94/*
95 * i8042 keyboard controller for JAZZ and PICA chipsets.
96 * This address is just a guess and seems to differ from
97 * other mips machines such as RC3xxx...
98 */
99#define JAZZ_KEYBOARD_ADDRESS 0xe0005000
100#define JAZZ_KEYBOARD_DATA 0xe0005000
101#define JAZZ_KEYBOARD_COMMAND 0xe0005001
102
103#ifndef __ASSEMBLY__
104
105typedef struct {
106 unsigned char data;
107 unsigned char command;
108} jazz_keyboard_hardware;
109
110#define jazz_kh ((keyboard_hardware *) JAZZ_KEYBOARD_ADDRESS)
111
112typedef struct {
113 unsigned char pad0[3];
114 unsigned char data;
115 unsigned char pad1[3];
116 unsigned char command;
117} mips_keyboard_hardware;
118
119/*
120 * For now. Needs to be changed for RC3xxx support. See below.
121 */
122#define keyboard_hardware jazz_keyboard_hardware
123
124#endif /* !__ASSEMBLY__ */
125
126/*
127 * i8042 keyboard controller for most other Mips machines.
128 */
129#define MIPS_KEYBOARD_ADDRESS 0xb9005000
130#define MIPS_KEYBOARD_DATA 0xb9005003
131#define MIPS_KEYBOARD_COMMAND 0xb9005007
132
133/*
134 * Serial and parallel ports (WD 16C552) on the Mips JAZZ
135 */
136#define JAZZ_SERIAL1_BASE (unsigned int)0xe0006000
137#define JAZZ_SERIAL2_BASE (unsigned int)0xe0007000
138#define JAZZ_PARALLEL_BASE (unsigned int)0xe0008000
139
140/*
141 * Dummy Device Address. Used in jazzdma.c
142 */
143#define JAZZ_DUMMY_DEVICE 0xe000d000
144
145/*
146 * JAZZ timer registers and interrupt no.
147 * Note that the hardware timer interrupt is actually on
148 * cpu level 6, but to keep compatibility with PC stuff
149 * it is remapped to vector 0. See arch/mips/kernel/entry.S.
150 */
151#define JAZZ_TIMER_INTERVAL 0xe0000228
152#define JAZZ_TIMER_REGISTER 0xe0000230
153
154/*
155 * DRAM configuration register
156 */
157#ifndef __ASSEMBLY__
158#ifdef __MIPSEL__
159typedef struct {
160 unsigned int bank2 : 3;
161 unsigned int bank1 : 3;
162 unsigned int mem_bus_width : 1;
163 unsigned int reserved2 : 1;
164 unsigned int page_mode : 1;
165 unsigned int reserved1 : 23;
166} dram_configuration;
167#else /* defined (__MIPSEB__) */
168typedef struct {
169 unsigned int reserved1 : 23;
170 unsigned int page_mode : 1;
171 unsigned int reserved2 : 1;
172 unsigned int mem_bus_width : 1;
173 unsigned int bank1 : 3;
174 unsigned int bank2 : 3;
175} dram_configuration;
176#endif
177#endif /* !__ASSEMBLY__ */
178
179#define PICA_DRAM_CONFIG 0xe00fffe0
180
181/*
182 * JAZZ interrupt control registers
183 */
184#define JAZZ_IO_IRQ_SOURCE 0xe0010000
185#define JAZZ_IO_IRQ_ENABLE 0xe0010002
186
187/*
188 * JAZZ Interrupt Level definitions
189 *
190 * This is somewhat broken. For reasons which nobody can remember anymore
191 * we remap the Jazz interrupts to the usual ISA style interrupt numbers.
192 */
193#define JAZZ_IRQ_START 24
194#define JAZZ_IRQ_END (24 + 9)
195#define JAZZ_PARALLEL_IRQ (JAZZ_IRQ_START + 0)
196#define JAZZ_FLOPPY_IRQ (JAZZ_IRQ_START + 1)
197#define JAZZ_SOUND_IRQ (JAZZ_IRQ_START + 2)
198#define JAZZ_VIDEO_IRQ (JAZZ_IRQ_START + 3)
199#define JAZZ_ETHERNET_IRQ (JAZZ_IRQ_START + 4)
200#define JAZZ_SCSI_IRQ (JAZZ_IRQ_START + 5)
201#define JAZZ_KEYBOARD_IRQ (JAZZ_IRQ_START + 6)
202#define JAZZ_MOUSE_IRQ (JAZZ_IRQ_START + 7)
203#define JAZZ_SERIAL1_IRQ (JAZZ_IRQ_START + 8)
204#define JAZZ_SERIAL2_IRQ (JAZZ_IRQ_START + 9)
205
206#define JAZZ_TIMER_IRQ (MIPS_CPU_IRQ_BASE+6)
207
208
209/*
210 * JAZZ DMA Channels
211 * Note: Channels 4...7 are not used with respect to the Acer PICA-61
212 * chipset which does not provide these DMA channels.
213 */
214#define JAZZ_SCSI_DMA 0 /* SCSI */
215#define JAZZ_FLOPPY_DMA 1 /* FLOPPY */
216#define JAZZ_AUDIOL_DMA 2 /* AUDIO L */
217#define JAZZ_AUDIOR_DMA 3 /* AUDIO R */
218
219/*
220 * JAZZ R4030 MCT_ADR chip (DMA controller)
221 * Note: Virtual Addresses !
222 */
223#define JAZZ_R4030_CONFIG 0xE0000000 /* R4030 config register */
224#define JAZZ_R4030_REVISION 0xE0000008 /* same as PICA_ASIC_REVISION */
225#define JAZZ_R4030_INV_ADDR 0xE0000010 /* Invalid Address register */
226
227#define JAZZ_R4030_TRSTBL_BASE 0xE0000018 /* Translation Table Base */
228#define JAZZ_R4030_TRSTBL_LIM 0xE0000020 /* Translation Table Limit */
229#define JAZZ_R4030_TRSTBL_INV 0xE0000028 /* Translation Table Invalidate */
230
231#define JAZZ_R4030_CACHE_MTNC 0xE0000030 /* Cache Maintenance */
232#define JAZZ_R4030_R_FAIL_ADDR 0xE0000038 /* Remote Failed Address */
233#define JAZZ_R4030_M_FAIL_ADDR 0xE0000040 /* Memory Failed Address */
234
235#define JAZZ_R4030_CACHE_PTAG 0xE0000048 /* I/O Cache Physical Tag */
236#define JAZZ_R4030_CACHE_LTAG 0xE0000050 /* I/O Cache Logical Tag */
237#define JAZZ_R4030_CACHE_BMASK 0xE0000058 /* I/O Cache Byte Mask */
238#define JAZZ_R4030_CACHE_BWIN 0xE0000060 /* I/O Cache Buffer Window */
239
240/*
241 * Remote Speed Registers.
242 *
243 * 0: free, 1: Ethernet, 2: SCSI, 3: Floppy,
244 * 4: RTC, 5: Kb./Mouse 6: serial 1, 7: serial 2,
245 * 8: parallel, 9: NVRAM, 10: CPU, 11: PROM,
246 * 12: reserved, 13: free, 14: 7seg LED, 15: ???
247 */
248#define JAZZ_R4030_REM_SPEED 0xE0000070 /* 16 Remote Speed Registers */
249 /* 0xE0000070,78,80... 0xE00000E8 */
250#define JAZZ_R4030_IRQ_ENABLE 0xE00000E8 /* Internal Interrupt Enable */
251#define JAZZ_R4030_INVAL_ADDR 0xE0000010 /* Invalid address Register */
252#define JAZZ_R4030_IRQ_SOURCE 0xE0000200 /* Interrupt Source Register */
253#define JAZZ_R4030_I386_ERROR 0xE0000208 /* i386/EISA Bus Error */
254
255/*
256 * Virtual (E)ISA controller address
257 */
258#define JAZZ_EISA_IRQ_ACK 0xE0000238 /* EISA interrupt acknowledge */
259
260/*
261 * Access the R4030 DMA and I/O Controller
262 */
263#ifndef __ASSEMBLY__
264
265static inline void r4030_delay(void)
266{
267__asm__ __volatile__(
268 ".set\tnoreorder\n\t"
269 "nop\n\t"
270 "nop\n\t"
271 "nop\n\t"
272 "nop\n\t"
273 ".set\treorder");
274}
275
276static inline unsigned short r4030_read_reg16(unsigned long addr)
277{
278 unsigned short ret = *((volatile unsigned short *)addr);
279 r4030_delay();
280 return ret;
281}
282
283static inline unsigned int r4030_read_reg32(unsigned long addr)
284{
285 unsigned int ret = *((volatile unsigned int *)addr);
286 r4030_delay();
287 return ret;
288}
289
290static inline void r4030_write_reg16(unsigned long addr, unsigned val)
291{
292 *((volatile unsigned short *)addr) = val;
293 r4030_delay();
294}
295
296static inline void r4030_write_reg32(unsigned long addr, unsigned val)
297{
298 *((volatile unsigned int *)addr) = val;
299 r4030_delay();
300}
301
302#endif /* !__ASSEMBLY__ */
303
304#define JAZZ_FDC_BASE 0xe0003000
305#define JAZZ_RTC_BASE 0xe0004000
306#define JAZZ_PORT_BASE 0xe2000000
307
308#define JAZZ_EISA_BASE 0xe3000000
309
310#endif /* __ASM_JAZZ_H */
diff --git a/arch/mips/include/asm/jazzdma.h b/arch/mips/include/asm/jazzdma.h
new file mode 100644
index 000000000000..8bb37bba68f0
--- /dev/null
+++ b/arch/mips/include/asm/jazzdma.h
@@ -0,0 +1,95 @@
1/*
2 * Helpfile for jazzdma.c -- Mips Jazz R4030 DMA controller support
3 */
4#ifndef _ASM_JAZZDMA_H
5#define _ASM_JAZZDMA_H
6
7/*
8 * Prototypes and macros
9 */
10extern unsigned long vdma_alloc(unsigned long paddr, unsigned long size);
11extern int vdma_free(unsigned long laddr);
12extern int vdma_remap(unsigned long laddr, unsigned long paddr,
13 unsigned long size);
14extern unsigned long vdma_phys2log(unsigned long paddr);
15extern unsigned long vdma_log2phys(unsigned long laddr);
16extern void vdma_stats(void); /* for debugging only */
17
18extern void vdma_enable(int channel);
19extern void vdma_disable(int channel);
20extern void vdma_set_mode(int channel, int mode);
21extern void vdma_set_addr(int channel, long addr);
22extern void vdma_set_count(int channel, int count);
23extern int vdma_get_residue(int channel);
24extern int vdma_get_enable(int channel);
25
26/*
27 * some definitions used by the driver functions
28 */
29#define VDMA_PAGESIZE 4096
30#define VDMA_PGTBL_ENTRIES 4096
31#define VDMA_PGTBL_SIZE (sizeof(VDMA_PGTBL_ENTRY) * VDMA_PGTBL_ENTRIES)
32#define VDMA_PAGE_EMPTY 0xff000000
33
34/*
35 * Macros to get page no. and offset of a given address
36 * Note that VDMA_PAGE() works for physical addresses only
37 */
38#define VDMA_PAGE(a) ((unsigned int)(a) >> 12)
39#define VDMA_OFFSET(a) ((unsigned int)(a) & (VDMA_PAGESIZE-1))
40
41/*
42 * error code returned by vdma_alloc()
43 * (See also arch/mips/kernel/jazzdma.c)
44 */
45#define VDMA_ERROR 0xffffffff
46
47/*
48 * VDMA pagetable entry description
49 */
50typedef volatile struct VDMA_PGTBL_ENTRY {
51 unsigned int frame; /* physical frame no. */
52 unsigned int owner; /* owner of this entry (0=free) */
53} VDMA_PGTBL_ENTRY;
54
55
56/*
57 * DMA channel control registers
58 * in the R4030 MCT_ADR chip
59 */
60#define JAZZ_R4030_CHNL_MODE 0xE0000100 /* 8 DMA Channel Mode Registers, */
61 /* 0xE0000100,120,140... */
62#define JAZZ_R4030_CHNL_ENABLE 0xE0000108 /* 8 DMA Channel Enable Regs, */
63 /* 0xE0000108,128,148... */
64#define JAZZ_R4030_CHNL_COUNT 0xE0000110 /* 8 DMA Channel Byte Cnt Regs, */
65 /* 0xE0000110,130,150... */
66#define JAZZ_R4030_CHNL_ADDR 0xE0000118 /* 8 DMA Channel Address Regs, */
67 /* 0xE0000118,138,158... */
68
69/* channel enable register bits */
70
71#define R4030_CHNL_ENABLE (1<<0)
72#define R4030_CHNL_WRITE (1<<1)
73#define R4030_TC_INTR (1<<8)
74#define R4030_MEM_INTR (1<<9)
75#define R4030_ADDR_INTR (1<<10)
76
77/*
78 * Channel mode register bits
79 */
80#define R4030_MODE_ATIME_40 (0) /* device access time on remote bus */
81#define R4030_MODE_ATIME_80 (1)
82#define R4030_MODE_ATIME_120 (2)
83#define R4030_MODE_ATIME_160 (3)
84#define R4030_MODE_ATIME_200 (4)
85#define R4030_MODE_ATIME_240 (5)
86#define R4030_MODE_ATIME_280 (6)
87#define R4030_MODE_ATIME_320 (7)
88#define R4030_MODE_WIDTH_8 (1<<3) /* device data bus width */
89#define R4030_MODE_WIDTH_16 (2<<3)
90#define R4030_MODE_WIDTH_32 (3<<3)
91#define R4030_MODE_INTR_EN (1<<5)
92#define R4030_MODE_BURST (1<<6) /* Rev. 2 only */
93#define R4030_MODE_FAST_ACK (1<<7) /* Rev. 2 only */
94
95#endif /* _ASM_JAZZDMA_H */
diff --git a/arch/mips/include/asm/kdebug.h b/arch/mips/include/asm/kdebug.h
new file mode 100644
index 000000000000..5bf62aafc890
--- /dev/null
+++ b/arch/mips/include/asm/kdebug.h
@@ -0,0 +1,13 @@
1#ifndef _ASM_MIPS_KDEBUG_H
2#define _ASM_MIPS_KDEBUG_H
3
4#include <linux/notifier.h>
5
6enum die_val {
7 DIE_OOPS = 1,
8 DIE_FP,
9 DIE_TRAP,
10 DIE_RI,
11};
12
13#endif /* _ASM_MIPS_KDEBUG_H */
diff --git a/arch/mips/include/asm/kexec.h b/arch/mips/include/asm/kexec.h
new file mode 100644
index 000000000000..4314892aaebb
--- /dev/null
+++ b/arch/mips/include/asm/kexec.h
@@ -0,0 +1,30 @@
1/*
2 * kexec.h for kexec
3 * Created by <nschichan@corp.free.fr> on Thu Oct 12 14:59:34 2006
4 *
5 * This source code is licensed under the GNU General Public License,
6 * Version 2. See the file COPYING for more details.
7 */
8
9#ifndef _MIPS_KEXEC
10# define _MIPS_KEXEC
11
12/* Maximum physical address we can use pages from */
13#define KEXEC_SOURCE_MEMORY_LIMIT (0x20000000)
14/* Maximum address we can reach in physical address mode */
15#define KEXEC_DESTINATION_MEMORY_LIMIT (0x20000000)
16 /* Maximum address we can use for the control code buffer */
17#define KEXEC_CONTROL_MEMORY_LIMIT (0x20000000)
18
19#define KEXEC_CONTROL_PAGE_SIZE 4096
20
21/* The native architecture */
22#define KEXEC_ARCH KEXEC_ARCH_MIPS
23
24static inline void crash_setup_regs(struct pt_regs *newregs,
25 struct pt_regs *oldregs)
26{
27 /* Dummy implementation for now */
28}
29
30#endif /* !_MIPS_KEXEC */
diff --git a/arch/mips/include/asm/kgdb.h b/arch/mips/include/asm/kgdb.h
new file mode 100644
index 000000000000..48223b09396c
--- /dev/null
+++ b/arch/mips/include/asm/kgdb.h
@@ -0,0 +1,44 @@
1#ifndef __ASM_KGDB_H_
2#define __ASM_KGDB_H_
3
4#ifdef __KERNEL__
5
6#include <asm/sgidefs.h>
7
8#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2) || \
9 (_MIPS_ISA == _MIPS_ISA_MIPS32)
10
11#define KGDB_GDB_REG_SIZE 32
12
13#elif (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
14 (_MIPS_ISA == _MIPS_ISA_MIPS64)
15
16#ifdef CONFIG_32BIT
17#define KGDB_GDB_REG_SIZE 32
18#else /* CONFIG_CPU_32BIT */
19#define KGDB_GDB_REG_SIZE 64
20#endif
21#else
22#error "Need to set KGDB_GDB_REG_SIZE for MIPS ISA"
23#endif /* _MIPS_ISA */
24
25#define BUFMAX 2048
26#if (KGDB_GDB_REG_SIZE == 32)
27#define NUMREGBYTES (90*sizeof(u32))
28#define NUMCRITREGBYTES (12*sizeof(u32))
29#else
30#define NUMREGBYTES (90*sizeof(u64))
31#define NUMCRITREGBYTES (12*sizeof(u64))
32#endif
33#define BREAK_INSTR_SIZE 4
34#define CACHE_FLUSH_IS_SAFE 0
35
36extern void arch_kgdb_breakpoint(void);
37extern int kgdb_early_setup;
38extern void *saved_vectors[32];
39extern void handle_exception(struct pt_regs *regs);
40extern void breakinst(void);
41
42#endif /* __KERNEL__ */
43
44#endif /* __ASM_KGDB_H_ */
diff --git a/arch/mips/include/asm/kmap_types.h b/arch/mips/include/asm/kmap_types.h
new file mode 100644
index 000000000000..806aae3c5338
--- /dev/null
+++ b/arch/mips/include/asm/kmap_types.h
@@ -0,0 +1,30 @@
1#ifndef _ASM_KMAP_TYPES_H
2#define _ASM_KMAP_TYPES_H
3
4
5#ifdef CONFIG_DEBUG_HIGHMEM
6# define D(n) __KM_FENCE_##n ,
7#else
8# define D(n)
9#endif
10
11enum km_type {
12D(0) KM_BOUNCE_READ,
13D(1) KM_SKB_SUNRPC_DATA,
14D(2) KM_SKB_DATA_SOFTIRQ,
15D(3) KM_USER0,
16D(4) KM_USER1,
17D(5) KM_BIO_SRC_IRQ,
18D(6) KM_BIO_DST_IRQ,
19D(7) KM_PTE0,
20D(8) KM_PTE1,
21D(9) KM_IRQ0,
22D(10) KM_IRQ1,
23D(11) KM_SOFTIRQ0,
24D(12) KM_SOFTIRQ1,
25D(13) KM_TYPE_NR
26};
27
28#undef D
29
30#endif
diff --git a/arch/mips/include/asm/kspd.h b/arch/mips/include/asm/kspd.h
new file mode 100644
index 000000000000..4e9e724c8935
--- /dev/null
+++ b/arch/mips/include/asm/kspd.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
3 *
4 * This program is free software; you can distribute it and/or modify it
5 * under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 *
17 */
18
19#ifndef _ASM_KSPD_H
20#define _ASM_KSPD_H
21
22struct kspd_notifications {
23 void (*kspd_sp_exit)(int sp_id);
24
25 struct list_head list;
26};
27
28#ifdef CONFIG_MIPS_APSP_KSPD
29extern void kspd_notify(struct kspd_notifications *notify);
30#else
31static inline void kspd_notify(struct kspd_notifications *notify)
32{
33}
34#endif
35
36#endif
diff --git a/arch/mips/include/asm/lasat/ds1603.h b/arch/mips/include/asm/lasat/ds1603.h
new file mode 100644
index 000000000000..edcd7544b358
--- /dev/null
+++ b/arch/mips/include/asm/lasat/ds1603.h
@@ -0,0 +1,18 @@
1#include <asm/addrspace.h>
2
3/* Lasat 100 */
4#define DS1603_REG_100 (KSEG1ADDR(0x1c810000))
5#define DS1603_RST_100 (1 << 2)
6#define DS1603_CLK_100 (1 << 0)
7#define DS1603_DATA_SHIFT_100 1
8#define DS1603_DATA_100 (1 << DS1603_DATA_SHIFT_100)
9
10/* Lasat 200 */
11#define DS1603_REG_200 (KSEG1ADDR(0x11000000))
12#define DS1603_RST_200 (1 << 3)
13#define DS1603_CLK_200 (1 << 4)
14#define DS1603_DATA_200 (1 << 5)
15
16#define DS1603_DATA_REG_200 (DS1603_REG_200 + 0x10000)
17#define DS1603_DATA_READ_SHIFT_200 9
18#define DS1603_DATA_READ_200 (1 << DS1603_DATA_READ_SHIFT_200)
diff --git a/arch/mips/include/asm/lasat/eeprom.h b/arch/mips/include/asm/lasat/eeprom.h
new file mode 100644
index 000000000000..3dac203697fa
--- /dev/null
+++ b/arch/mips/include/asm/lasat/eeprom.h
@@ -0,0 +1,17 @@
1#include <asm/addrspace.h>
2
3/* lasat 100 */
4#define AT93C_REG_100 KSEG1ADDR(0x1c810000)
5#define AT93C_RDATA_REG_100 AT93C_REG_100
6#define AT93C_RDATA_SHIFT_100 4
7#define AT93C_WDATA_SHIFT_100 4
8#define AT93C_CS_M_100 (1 << 5)
9#define AT93C_CLK_M_100 (1 << 3)
10
11/* lasat 200 */
12#define AT93C_REG_200 KSEG1ADDR(0x11000000)
13#define AT93C_RDATA_REG_200 (AT93C_REG_200+0x10000)
14#define AT93C_RDATA_SHIFT_200 8
15#define AT93C_WDATA_SHIFT_200 2
16#define AT93C_CS_M_200 (1 << 0)
17#define AT93C_CLK_M_200 (1 << 1)
diff --git a/arch/mips/include/asm/lasat/head.h b/arch/mips/include/asm/lasat/head.h
new file mode 100644
index 000000000000..f5589f31a197
--- /dev/null
+++ b/arch/mips/include/asm/lasat/head.h
@@ -0,0 +1,22 @@
1/*
2 * Image header stuff
3 */
4#ifndef _HEAD_H
5#define _HEAD_H
6
7#define LASAT_K_MAGIC0_VAL 0xfedeabba
8#define LASAT_K_MAGIC1_VAL 0x00bedead
9
10#ifndef _LANGUAGE_ASSEMBLY
11#include <linux/types.h>
12struct bootloader_header {
13 u32 magic[2];
14 u32 version;
15 u32 image_start;
16 u32 image_size;
17 u32 kernel_start;
18 u32 kernel_entry;
19};
20#endif
21
22#endif /* _HEAD_H */
diff --git a/arch/mips/include/asm/lasat/lasat.h b/arch/mips/include/asm/lasat/lasat.h
new file mode 100644
index 000000000000..caeba1e302a2
--- /dev/null
+++ b/arch/mips/include/asm/lasat/lasat.h
@@ -0,0 +1,258 @@
1/*
2 * lasat.h
3 *
4 * Thomas Horsten <thh@lasat.com>
5 * Copyright (C) 2000 LASAT Networks A/S.
6 *
7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 *
20 * Configuration for LASAT boards, loads the appropriate include files.
21 */
22#ifndef _LASAT_H
23#define _LASAT_H
24
25#ifndef _LANGUAGE_ASSEMBLY
26
27extern struct lasat_misc {
28 volatile u32 *reset_reg;
29 volatile u32 *flash_wp_reg;
30 u32 flash_wp_bit;
31} *lasat_misc;
32
33enum lasat_mtdparts {
34 LASAT_MTD_BOOTLOADER,
35 LASAT_MTD_SERVICE,
36 LASAT_MTD_NORMAL,
37 LASAT_MTD_CONFIG,
38 LASAT_MTD_FS,
39 LASAT_MTD_LAST
40};
41
42/*
43 * The format of the data record in the EEPROM.
44 * See Documentation/LASAT/eeprom.txt for a detailed description
45 * of the fields in this struct, and the LASAT Hardware Configuration
46 * field specification for a detailed description of the config
47 * field.
48 */
49#include <linux/types.h>
50
51#define LASAT_EEPROM_VERSION 7
52struct lasat_eeprom_struct {
53 unsigned int version;
54 unsigned int cfg[3];
55 unsigned char hwaddr[6];
56 unsigned char print_partno[12];
57 unsigned char term0;
58 unsigned char print_serial[14];
59 unsigned char term1;
60 unsigned char prod_partno[12];
61 unsigned char term2;
62 unsigned char prod_serial[14];
63 unsigned char term3;
64 unsigned char passwd_hash[16];
65 unsigned char pwdnull;
66 unsigned char vendid;
67 unsigned char ts_ref;
68 unsigned char ts_signoff;
69 unsigned char reserved[11];
70 unsigned char debugaccess;
71 unsigned short prid;
72 unsigned int serviceflag;
73 unsigned int ipaddr;
74 unsigned int netmask;
75 unsigned int crc32;
76};
77
78struct lasat_eeprom_struct_pre7 {
79 unsigned int version;
80 unsigned int flags[3];
81 unsigned char hwaddr0[6];
82 unsigned char hwaddr1[6];
83 unsigned char print_partno[9];
84 unsigned char term0;
85 unsigned char print_serial[14];
86 unsigned char term1;
87 unsigned char prod_partno[9];
88 unsigned char term2;
89 unsigned char prod_serial[14];
90 unsigned char term3;
91 unsigned char passwd_hash[24];
92 unsigned char pwdnull;
93 unsigned char vendor;
94 unsigned char ts_ref;
95 unsigned char ts_signoff;
96 unsigned char reserved[6];
97 unsigned int writecount;
98 unsigned int ipaddr;
99 unsigned int netmask;
100 unsigned int crc32;
101};
102
103/* Configuration descriptor encoding - see the doc for details */
104
105#define LASAT_W0_DSCTYPE(v) (((v)) & 0xf)
106#define LASAT_W0_BMID(v) (((v) >> 0x04) & 0xf)
107#define LASAT_W0_CPUTYPE(v) (((v) >> 0x08) & 0xf)
108#define LASAT_W0_BUSSPEED(v) (((v) >> 0x0c) & 0xf)
109#define LASAT_W0_CPUCLK(v) (((v) >> 0x10) & 0xf)
110#define LASAT_W0_SDRAMBANKSZ(v) (((v) >> 0x14) & 0xf)
111#define LASAT_W0_SDRAMBANKS(v) (((v) >> 0x18) & 0xf)
112#define LASAT_W0_L2CACHE(v) (((v) >> 0x1c) & 0xf)
113
114#define LASAT_W1_EDHAC(v) (((v)) & 0xf)
115#define LASAT_W1_HIFN(v) (((v) >> 0x04) & 0x1)
116#define LASAT_W1_ISDN(v) (((v) >> 0x05) & 0x1)
117#define LASAT_W1_IDE(v) (((v) >> 0x06) & 0x1)
118#define LASAT_W1_HDLC(v) (((v) >> 0x07) & 0x1)
119#define LASAT_W1_USVERSION(v) (((v) >> 0x08) & 0x1)
120#define LASAT_W1_4MACS(v) (((v) >> 0x09) & 0x1)
121#define LASAT_W1_EXTSERIAL(v) (((v) >> 0x0a) & 0x1)
122#define LASAT_W1_FLASHSIZE(v) (((v) >> 0x0c) & 0xf)
123#define LASAT_W1_PCISLOTS(v) (((v) >> 0x10) & 0xf)
124#define LASAT_W1_PCI1OPT(v) (((v) >> 0x14) & 0xf)
125#define LASAT_W1_PCI2OPT(v) (((v) >> 0x18) & 0xf)
126#define LASAT_W1_PCI3OPT(v) (((v) >> 0x1c) & 0xf)
127
128/* Routines specific to LASAT boards */
129
130#define LASAT_BMID_MASQUERADE2 0
131#define LASAT_BMID_MASQUERADEPRO 1
132#define LASAT_BMID_SAFEPIPE25 2
133#define LASAT_BMID_SAFEPIPE50 3
134#define LASAT_BMID_SAFEPIPE100 4
135#define LASAT_BMID_SAFEPIPE5000 5
136#define LASAT_BMID_SAFEPIPE7000 6
137#define LASAT_BMID_SAFEPIPE1000 7
138#if 0
139#define LASAT_BMID_SAFEPIPE30 7
140#define LASAT_BMID_SAFEPIPE5100 8
141#define LASAT_BMID_SAFEPIPE7100 9
142#endif
143#define LASAT_BMID_UNKNOWN 0xf
144#define LASAT_MAX_BMID_NAMES 9 /* no larger than 15! */
145
146#define LASAT_HAS_EDHAC (1 << 0)
147#define LASAT_EDHAC_FAST (1 << 1)
148#define LASAT_HAS_EADI (1 << 2)
149#define LASAT_HAS_HIFN (1 << 3)
150#define LASAT_HAS_ISDN (1 << 4)
151#define LASAT_HAS_LEASEDLINE_IF (1 << 5)
152#define LASAT_HAS_HDC (1 << 6)
153
154#define LASAT_PRID_MASQUERADE2 0
155#define LASAT_PRID_MASQUERADEPRO 1
156#define LASAT_PRID_SAFEPIPE25 2
157#define LASAT_PRID_SAFEPIPE50 3
158#define LASAT_PRID_SAFEPIPE100 4
159#define LASAT_PRID_SAFEPIPE5000 5
160#define LASAT_PRID_SAFEPIPE7000 6
161#define LASAT_PRID_SAFEPIPE30 7
162#define LASAT_PRID_SAFEPIPE5100 8
163#define LASAT_PRID_SAFEPIPE7100 9
164
165#define LASAT_PRID_SAFEPIPE1110 10
166#define LASAT_PRID_SAFEPIPE3020 11
167#define LASAT_PRID_SAFEPIPE3030 12
168#define LASAT_PRID_SAFEPIPE5020 13
169#define LASAT_PRID_SAFEPIPE5030 14
170#define LASAT_PRID_SAFEPIPE1120 15
171#define LASAT_PRID_SAFEPIPE1130 16
172#define LASAT_PRID_SAFEPIPE6010 17
173#define LASAT_PRID_SAFEPIPE6110 18
174#define LASAT_PRID_SAFEPIPE6210 19
175#define LASAT_PRID_SAFEPIPE1020 20
176#define LASAT_PRID_SAFEPIPE1040 21
177#define LASAT_PRID_SAFEPIPE1060 22
178
179struct lasat_info {
180 unsigned int li_cpu_hz;
181 unsigned int li_bus_hz;
182 unsigned int li_bmid;
183 unsigned int li_memsize;
184 unsigned int li_flash_size;
185 unsigned int li_prid;
186 unsigned char li_bmstr[16];
187 unsigned char li_namestr[32];
188 unsigned char li_typestr[16];
189 /* Info on the Flash layout */
190 unsigned int li_flash_base;
191 unsigned long li_flashpart_base[LASAT_MTD_LAST];
192 unsigned long li_flashpart_size[LASAT_MTD_LAST];
193 struct lasat_eeprom_struct li_eeprom_info;
194 unsigned int li_eeprom_upgrade_version;
195 unsigned int li_debugaccess;
196};
197
198extern struct lasat_info lasat_board_info;
199
200static inline unsigned long lasat_flash_partition_start(int partno)
201{
202 if (partno < 0 || partno >= LASAT_MTD_LAST)
203 return 0;
204
205 return lasat_board_info.li_flashpart_base[partno];
206}
207
208static inline unsigned long lasat_flash_partition_size(int partno)
209{
210 if (partno < 0 || partno >= LASAT_MTD_LAST)
211 return 0;
212
213 return lasat_board_info.li_flashpart_size[partno];
214}
215
216/* Called from setup() to initialize the global board_info struct */
217extern int lasat_init_board_info(void);
218
219/* Write the modified EEPROM info struct */
220extern void lasat_write_eeprom_info(void);
221
222#define N_MACHTYPES 2
223/* for calibration of delays */
224
225/* the lasat_ndelay function is necessary because it is used at an
226 * early stage of the boot process where ndelay is not calibrated.
227 * It is used for the bit-banging rtc and eeprom drivers */
228
229#include <linux/delay.h>
230
231/* calculating with the slowest board with 100 MHz clock */
232#define LASAT_100_DIVIDER 20
233/* All 200's run at 250 MHz clock */
234#define LASAT_200_DIVIDER 8
235
236extern unsigned int lasat_ndelay_divider;
237
238static inline void lasat_ndelay(unsigned int ns)
239{
240 __delay(ns / lasat_ndelay_divider);
241}
242
243#define IS_LASAT_200() (current_cpu_data.cputype == CPU_R5000)
244
245#endif /* !defined (_LANGUAGE_ASSEMBLY) */
246
247#define LASAT_SERVICEMODE_MAGIC_1 0xdeadbeef
248#define LASAT_SERVICEMODE_MAGIC_2 0xfedeabba
249
250/* Lasat 100 boards */
251#define LASAT_GT_BASE (KSEG1ADDR(0x14000000))
252
253/* Lasat 200 boards */
254#define Vrc5074_PHYS_BASE 0x1fa00000
255#define Vrc5074_BASE (KSEG1ADDR(Vrc5074_PHYS_BASE))
256#define PCI_WINDOW1 0x1a000000
257
258#endif /* _LASAT_H */
diff --git a/arch/mips/include/asm/lasat/lasatint.h b/arch/mips/include/asm/lasat/lasatint.h
new file mode 100644
index 000000000000..e0d2458b43d0
--- /dev/null
+++ b/arch/mips/include/asm/lasat/lasatint.h
@@ -0,0 +1,14 @@
1#ifndef __ASM_LASAT_LASATINT_H
2#define __ASM_LASAT_LASATINT_H
3
4/* lasat 100 */
5#define LASAT_INT_STATUS_REG_100 (KSEG1ADDR(0x1c880000))
6#define LASAT_INT_MASK_REG_100 (KSEG1ADDR(0x1c890000))
7#define LASATINT_MASK_SHIFT_100 0
8
9/* lasat 200 */
10#define LASAT_INT_STATUS_REG_200 (KSEG1ADDR(0x1104003c))
11#define LASAT_INT_MASK_REG_200 (KSEG1ADDR(0x1104003c))
12#define LASATINT_MASK_SHIFT_200 16
13
14#endif /* __ASM_LASAT_LASATINT_H */
diff --git a/arch/mips/include/asm/lasat/picvue.h b/arch/mips/include/asm/lasat/picvue.h
new file mode 100644
index 000000000000..42a492edc40e
--- /dev/null
+++ b/arch/mips/include/asm/lasat/picvue.h
@@ -0,0 +1,15 @@
1/* Lasat 100 */
2#define PVC_REG_100 KSEG1ADDR(0x1c820000)
3#define PVC_DATA_SHIFT_100 0
4#define PVC_DATA_M_100 0xFF
5#define PVC_E_100 (1 << 8)
6#define PVC_RW_100 (1 << 9)
7#define PVC_RS_100 (1 << 10)
8
9/* Lasat 200 */
10#define PVC_REG_200 KSEG1ADDR(0x11000000)
11#define PVC_DATA_SHIFT_200 24
12#define PVC_DATA_M_200 (0xFF << PVC_DATA_SHIFT_200)
13#define PVC_E_200 (1 << 16)
14#define PVC_RW_200 (1 << 17)
15#define PVC_RS_200 (1 << 18)
diff --git a/arch/mips/include/asm/lasat/serial.h b/arch/mips/include/asm/lasat/serial.h
new file mode 100644
index 000000000000..1c37d70579b8
--- /dev/null
+++ b/arch/mips/include/asm/lasat/serial.h
@@ -0,0 +1,13 @@
1#include <asm/lasat/lasat.h>
2
3/* Lasat 100 boards serial configuration */
4#define LASAT_BASE_BAUD_100 (7372800 / 16)
5#define LASAT_UART_REGS_BASE_100 0x1c8b0000
6#define LASAT_UART_REGS_SHIFT_100 2
7#define LASATINT_UART_100 16
8
9/* * LASAT 200 boards serial configuration */
10#define LASAT_BASE_BAUD_200 (100000000 / 16 / 12)
11#define LASAT_UART_REGS_BASE_200 (Vrc5074_PHYS_BASE + 0x0300)
12#define LASAT_UART_REGS_SHIFT_200 3
13#define LASATINT_UART_200 21
diff --git a/arch/mips/include/asm/linkage.h b/arch/mips/include/asm/linkage.h
new file mode 100644
index 000000000000..e9a940d1b0c6
--- /dev/null
+++ b/arch/mips/include/asm/linkage.h
@@ -0,0 +1,10 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#ifdef __ASSEMBLY__
5#include <asm/asm.h>
6#endif
7
8#define __weak __attribute__((weak))
9
10#endif
diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
new file mode 100644
index 000000000000..f96fd59e0845
--- /dev/null
+++ b/arch/mips/include/asm/local.h
@@ -0,0 +1,221 @@
1#ifndef _ARCH_MIPS_LOCAL_H
2#define _ARCH_MIPS_LOCAL_H
3
4#include <linux/percpu.h>
5#include <linux/bitops.h>
6#include <asm/atomic.h>
7#include <asm/cmpxchg.h>
8#include <asm/war.h>
9
10typedef struct
11{
12 atomic_long_t a;
13} local_t;
14
15#define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
16
17#define local_read(l) atomic_long_read(&(l)->a)
18#define local_set(l, i) atomic_long_set(&(l)->a, (i))
19
20#define local_add(i, l) atomic_long_add((i), (&(l)->a))
21#define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
22#define local_inc(l) atomic_long_inc(&(l)->a)
23#define local_dec(l) atomic_long_dec(&(l)->a)
24
25/*
26 * Same as above, but return the result value
27 */
28static __inline__ long local_add_return(long i, local_t * l)
29{
30 unsigned long result;
31
32 if (cpu_has_llsc && R10000_LLSC_WAR) {
33 unsigned long temp;
34
35 __asm__ __volatile__(
36 " .set mips3 \n"
37 "1:" __LL "%1, %2 # local_add_return \n"
38 " addu %0, %1, %3 \n"
39 __SC "%0, %2 \n"
40 " beqzl %0, 1b \n"
41 " addu %0, %1, %3 \n"
42 " .set mips0 \n"
43 : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
44 : "Ir" (i), "m" (l->a.counter)
45 : "memory");
46 } else if (cpu_has_llsc) {
47 unsigned long temp;
48
49 __asm__ __volatile__(
50 " .set mips3 \n"
51 "1:" __LL "%1, %2 # local_add_return \n"
52 " addu %0, %1, %3 \n"
53 __SC "%0, %2 \n"
54 " beqz %0, 1b \n"
55 " addu %0, %1, %3 \n"
56 " .set mips0 \n"
57 : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
58 : "Ir" (i), "m" (l->a.counter)
59 : "memory");
60 } else {
61 unsigned long flags;
62
63 local_irq_save(flags);
64 result = l->a.counter;
65 result += i;
66 l->a.counter = result;
67 local_irq_restore(flags);
68 }
69
70 return result;
71}
72
73static __inline__ long local_sub_return(long i, local_t * l)
74{
75 unsigned long result;
76
77 if (cpu_has_llsc && R10000_LLSC_WAR) {
78 unsigned long temp;
79
80 __asm__ __volatile__(
81 " .set mips3 \n"
82 "1:" __LL "%1, %2 # local_sub_return \n"
83 " subu %0, %1, %3 \n"
84 __SC "%0, %2 \n"
85 " beqzl %0, 1b \n"
86 " subu %0, %1, %3 \n"
87 " .set mips0 \n"
88 : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
89 : "Ir" (i), "m" (l->a.counter)
90 : "memory");
91 } else if (cpu_has_llsc) {
92 unsigned long temp;
93
94 __asm__ __volatile__(
95 " .set mips3 \n"
96 "1:" __LL "%1, %2 # local_sub_return \n"
97 " subu %0, %1, %3 \n"
98 __SC "%0, %2 \n"
99 " beqz %0, 1b \n"
100 " subu %0, %1, %3 \n"
101 " .set mips0 \n"
102 : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
103 : "Ir" (i), "m" (l->a.counter)
104 : "memory");
105 } else {
106 unsigned long flags;
107
108 local_irq_save(flags);
109 result = l->a.counter;
110 result -= i;
111 l->a.counter = result;
112 local_irq_restore(flags);
113 }
114
115 return result;
116}
117
118#define local_cmpxchg(l, o, n) \
119 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
120#define local_xchg(l, n) (xchg_local(&((l)->a.counter), (n)))
121
122/**
123 * local_add_unless - add unless the number is a given value
124 * @l: pointer of type local_t
125 * @a: the amount to add to l...
126 * @u: ...unless l is equal to u.
127 *
128 * Atomically adds @a to @l, so long as it was not @u.
129 * Returns non-zero if @l was not @u, and zero otherwise.
130 */
131#define local_add_unless(l, a, u) \
132({ \
133 long c, old; \
134 c = local_read(l); \
135 while (c != (u) && (old = local_cmpxchg((l), c, c + (a))) != c) \
136 c = old; \
137 c != (u); \
138})
139#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
140
141#define local_dec_return(l) local_sub_return(1, (l))
142#define local_inc_return(l) local_add_return(1, (l))
143
144/*
145 * local_sub_and_test - subtract value from variable and test result
146 * @i: integer value to subtract
147 * @l: pointer of type local_t
148 *
149 * Atomically subtracts @i from @l and returns
150 * true if the result is zero, or false for all
151 * other cases.
152 */
153#define local_sub_and_test(i, l) (local_sub_return((i), (l)) == 0)
154
155/*
156 * local_inc_and_test - increment and test
157 * @l: pointer of type local_t
158 *
159 * Atomically increments @l by 1
160 * and returns true if the result is zero, or false for all
161 * other cases.
162 */
163#define local_inc_and_test(l) (local_inc_return(l) == 0)
164
165/*
166 * local_dec_and_test - decrement by 1 and test
167 * @l: pointer of type local_t
168 *
169 * Atomically decrements @l by 1 and
170 * returns true if the result is 0, or false for all other
171 * cases.
172 */
173#define local_dec_and_test(l) (local_sub_return(1, (l)) == 0)
174
175/*
176 * local_add_negative - add and test if negative
177 * @l: pointer of type local_t
178 * @i: integer value to add
179 *
180 * Atomically adds @i to @l and returns true
181 * if the result is negative, or false when
182 * result is greater than or equal to zero.
183 */
184#define local_add_negative(i, l) (local_add_return(i, (l)) < 0)
185
186/* Use these for per-cpu local_t variables: on some archs they are
187 * much more efficient than these naive implementations. Note they take
188 * a variable, not an address.
189 */
190
191#define __local_inc(l) ((l)->a.counter++)
192#define __local_dec(l) ((l)->a.counter++)
193#define __local_add(i, l) ((l)->a.counter+=(i))
194#define __local_sub(i, l) ((l)->a.counter-=(i))
195
196/* Need to disable preemption for the cpu local counters otherwise we could
197 still access a variable of a previous CPU in a non atomic way. */
198#define cpu_local_wrap_v(l) \
199 ({ local_t res__; \
200 preempt_disable(); \
201 res__ = (l); \
202 preempt_enable(); \
203 res__; })
204#define cpu_local_wrap(l) \
205 ({ preempt_disable(); \
206 l; \
207 preempt_enable(); }) \
208
209#define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l)))
210#define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i)))
211#define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l)))
212#define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l)))
213#define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l)))
214#define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l)))
215
216#define __cpu_local_inc(l) cpu_local_inc(l)
217#define __cpu_local_dec(l) cpu_local_dec(l)
218#define __cpu_local_add(i, l) cpu_local_add((i), (l))
219#define __cpu_local_sub(i, l) cpu_local_sub((i), (l))
220
221#endif /* _ARCH_MIPS_LOCAL_H */
diff --git a/arch/mips/include/asm/m48t35.h b/arch/mips/include/asm/m48t35.h
new file mode 100644
index 000000000000..f44852e9a96d
--- /dev/null
+++ b/arch/mips/include/asm/m48t35.h
@@ -0,0 +1,27 @@
1/*
2 * Registers for the SGS-Thomson M48T35 Timekeeper RAM chip
3 */
4#ifndef _ASM_M48T35_H
5#define _ASM_M48T35_H
6
7#include <linux/spinlock.h>
8
9extern spinlock_t rtc_lock;
10
11struct m48t35_rtc {
12 volatile u8 pad[0x7ff8]; /* starts at 0x7ff8 */
13 volatile u8 control;
14 volatile u8 sec;
15 volatile u8 min;
16 volatile u8 hour;
17 volatile u8 day;
18 volatile u8 date;
19 volatile u8 month;
20 volatile u8 year;
21};
22
23#define M48T35_RTC_SET 0x80
24#define M48T35_RTC_STOPPED 0x80
25#define M48T35_RTC_READ 0x40
26
27#endif /* _ASM_M48T35_H */
diff --git a/arch/mips/include/asm/m48t37.h b/arch/mips/include/asm/m48t37.h
new file mode 100644
index 000000000000..cabf86264f36
--- /dev/null
+++ b/arch/mips/include/asm/m48t37.h
@@ -0,0 +1,35 @@
1/*
2 * Registers for the SGS-Thomson M48T37 Timekeeper RAM chip
3 */
4#ifndef _ASM_M48T37_H
5#define _ASM_M48T37_H
6
7#include <linux/spinlock.h>
8
9extern spinlock_t rtc_lock;
10
11struct m48t37_rtc {
12 volatile u8 pad[0x7ff0]; /* NVRAM */
13 volatile u8 flags;
14 volatile u8 century;
15 volatile u8 alarm_sec;
16 volatile u8 alarm_min;
17 volatile u8 alarm_hour;
18 volatile u8 alarm_data;
19 volatile u8 interrupts;
20 volatile u8 watchdog;
21 volatile u8 control;
22 volatile u8 sec;
23 volatile u8 min;
24 volatile u8 hour;
25 volatile u8 day;
26 volatile u8 date;
27 volatile u8 month;
28 volatile u8 year;
29};
30
31#define M48T37_RTC_SET 0x80
32#define M48T37_RTC_STOPPED 0x80
33#define M48T37_RTC_READ 0x40
34
35#endif /* _ASM_M48T37_H */
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h
new file mode 100644
index 000000000000..0d302bad4492
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1000.h
@@ -0,0 +1,1772 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Include file for Alchemy Semiconductor's Au1k CPU.
5 *
6 * Copyright 2000-2001, 2006-2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29
30 /*
31 * some definitions add by takuzo@sm.sony.co.jp and sato@sm.sony.co.jp
32 */
33
34#ifndef _AU1000_H_
35#define _AU1000_H_
36
37
38#ifndef _LANGUAGE_ASSEMBLY
39
40#include <linux/delay.h>
41#include <linux/types.h>
42
43#include <linux/io.h>
44#include <linux/irq.h>
45
46/* cpu pipeline flush */
47void static inline au_sync(void)
48{
49 __asm__ volatile ("sync");
50}
51
52void static inline au_sync_udelay(int us)
53{
54 __asm__ volatile ("sync");
55 udelay(us);
56}
57
58void static inline au_sync_delay(int ms)
59{
60 __asm__ volatile ("sync");
61 mdelay(ms);
62}
63
64void static inline au_writeb(u8 val, unsigned long reg)
65{
66 *(volatile u8 *)reg = val;
67}
68
69void static inline au_writew(u16 val, unsigned long reg)
70{
71 *(volatile u16 *)reg = val;
72}
73
74void static inline au_writel(u32 val, unsigned long reg)
75{
76 *(volatile u32 *)reg = val;
77}
78
79static inline u8 au_readb(unsigned long reg)
80{
81 return *(volatile u8 *)reg;
82}
83
84static inline u16 au_readw(unsigned long reg)
85{
86 return *(volatile u16 *)reg;
87}
88
89static inline u32 au_readl(unsigned long reg)
90{
91 return *(volatile u32 *)reg;
92}
93
94
95/* arch/mips/au1000/common/clocks.c */
96extern void set_au1x00_speed(unsigned int new_freq);
97extern unsigned int get_au1x00_speed(void);
98extern void set_au1x00_uart_baud_base(unsigned long new_baud_base);
99extern unsigned long get_au1x00_uart_baud_base(void);
100extern void set_au1x00_lcd_clock(void);
101extern unsigned int get_au1x00_lcd_clock(void);
102
103/*
104 * Every board describes its IRQ mapping with this table.
105 */
106struct au1xxx_irqmap {
107 int im_irq;
108 int im_type;
109 int im_request;
110};
111
112/*
113 * init_IRQ looks for a table with this name.
114 */
115extern struct au1xxx_irqmap au1xxx_irq_map[];
116
117#endif /* !defined (_LANGUAGE_ASSEMBLY) */
118
119/*
120 * SDRAM register offsets
121 */
122#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || \
123 defined(CONFIG_SOC_AU1100)
124#define MEM_SDMODE0 0x0000
125#define MEM_SDMODE1 0x0004
126#define MEM_SDMODE2 0x0008
127#define MEM_SDADDR0 0x000C
128#define MEM_SDADDR1 0x0010
129#define MEM_SDADDR2 0x0014
130#define MEM_SDREFCFG 0x0018
131#define MEM_SDPRECMD 0x001C
132#define MEM_SDAUTOREF 0x0020
133#define MEM_SDWRMD0 0x0024
134#define MEM_SDWRMD1 0x0028
135#define MEM_SDWRMD2 0x002C
136#define MEM_SDSLEEP 0x0030
137#define MEM_SDSMCKE 0x0034
138
139/*
140 * MEM_SDMODE register content definitions
141 */
142#define MEM_SDMODE_F (1 << 22)
143#define MEM_SDMODE_SR (1 << 21)
144#define MEM_SDMODE_BS (1 << 20)
145#define MEM_SDMODE_RS (3 << 18)
146#define MEM_SDMODE_CS (7 << 15)
147#define MEM_SDMODE_TRAS (15 << 11)
148#define MEM_SDMODE_TMRD (3 << 9)
149#define MEM_SDMODE_TWR (3 << 7)
150#define MEM_SDMODE_TRP (3 << 5)
151#define MEM_SDMODE_TRCD (3 << 3)
152#define MEM_SDMODE_TCL (7 << 0)
153
154#define MEM_SDMODE_BS_2Bank (0 << 20)
155#define MEM_SDMODE_BS_4Bank (1 << 20)
156#define MEM_SDMODE_RS_11Row (0 << 18)
157#define MEM_SDMODE_RS_12Row (1 << 18)
158#define MEM_SDMODE_RS_13Row (2 << 18)
159#define MEM_SDMODE_RS_N(N) ((N) << 18)
160#define MEM_SDMODE_CS_7Col (0 << 15)
161#define MEM_SDMODE_CS_8Col (1 << 15)
162#define MEM_SDMODE_CS_9Col (2 << 15)
163#define MEM_SDMODE_CS_10Col (3 << 15)
164#define MEM_SDMODE_CS_11Col (4 << 15)
165#define MEM_SDMODE_CS_N(N) ((N) << 15)
166#define MEM_SDMODE_TRAS_N(N) ((N) << 11)
167#define MEM_SDMODE_TMRD_N(N) ((N) << 9)
168#define MEM_SDMODE_TWR_N(N) ((N) << 7)
169#define MEM_SDMODE_TRP_N(N) ((N) << 5)
170#define MEM_SDMODE_TRCD_N(N) ((N) << 3)
171#define MEM_SDMODE_TCL_N(N) ((N) << 0)
172
173/*
174 * MEM_SDADDR register contents definitions
175 */
176#define MEM_SDADDR_E (1 << 20)
177#define MEM_SDADDR_CSBA (0x03FF << 10)
178#define MEM_SDADDR_CSMASK (0x03FF << 0)
179#define MEM_SDADDR_CSBA_N(N) ((N) & (0x03FF << 22) >> 12)
180#define MEM_SDADDR_CSMASK_N(N) ((N)&(0x03FF << 22) >> 22)
181
182/*
183 * MEM_SDREFCFG register content definitions
184 */
185#define MEM_SDREFCFG_TRC (15 << 28)
186#define MEM_SDREFCFG_TRPM (3 << 26)
187#define MEM_SDREFCFG_E (1 << 25)
188#define MEM_SDREFCFG_RE (0x1ffffff << 0)
189#define MEM_SDREFCFG_TRC_N(N) ((N) << MEM_SDREFCFG_TRC)
190#define MEM_SDREFCFG_TRPM_N(N) ((N) << MEM_SDREFCFG_TRPM)
191#define MEM_SDREFCFG_REF_N(N) (N)
192#endif
193
194/***********************************************************************/
195
196/*
197 * Au1550 SDRAM Register Offsets
198 */
199
200/***********************************************************************/
201
202#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
203#define MEM_SDMODE0 0x0800
204#define MEM_SDMODE1 0x0808
205#define MEM_SDMODE2 0x0810
206#define MEM_SDADDR0 0x0820
207#define MEM_SDADDR1 0x0828
208#define MEM_SDADDR2 0x0830
209#define MEM_SDCONFIGA 0x0840
210#define MEM_SDCONFIGB 0x0848
211#define MEM_SDSTAT 0x0850
212#define MEM_SDERRADDR 0x0858
213#define MEM_SDSTRIDE0 0x0860
214#define MEM_SDSTRIDE1 0x0868
215#define MEM_SDSTRIDE2 0x0870
216#define MEM_SDWRMD0 0x0880
217#define MEM_SDWRMD1 0x0888
218#define MEM_SDWRMD2 0x0890
219#define MEM_SDPRECMD 0x08C0
220#define MEM_SDAUTOREF 0x08C8
221#define MEM_SDSREF 0x08D0
222#define MEM_SDSLEEP MEM_SDSREF
223
224#endif
225
226/*
227 * Physical base addresses for integrated peripherals
228 */
229
230#ifdef CONFIG_SOC_AU1000
231#define MEM_PHYS_ADDR 0x14000000
232#define STATIC_MEM_PHYS_ADDR 0x14001000
233#define DMA0_PHYS_ADDR 0x14002000
234#define DMA1_PHYS_ADDR 0x14002100
235#define DMA2_PHYS_ADDR 0x14002200
236#define DMA3_PHYS_ADDR 0x14002300
237#define DMA4_PHYS_ADDR 0x14002400
238#define DMA5_PHYS_ADDR 0x14002500
239#define DMA6_PHYS_ADDR 0x14002600
240#define DMA7_PHYS_ADDR 0x14002700
241#define IC0_PHYS_ADDR 0x10400000
242#define IC1_PHYS_ADDR 0x11800000
243#define AC97_PHYS_ADDR 0x10000000
244#define USBH_PHYS_ADDR 0x10100000
245#define USBD_PHYS_ADDR 0x10200000
246#define IRDA_PHYS_ADDR 0x10300000
247#define MAC0_PHYS_ADDR 0x10500000
248#define MAC1_PHYS_ADDR 0x10510000
249#define MACEN_PHYS_ADDR 0x10520000
250#define MACDMA0_PHYS_ADDR 0x14004000
251#define MACDMA1_PHYS_ADDR 0x14004200
252#define I2S_PHYS_ADDR 0x11000000
253#define UART0_PHYS_ADDR 0x11100000
254#define UART1_PHYS_ADDR 0x11200000
255#define UART2_PHYS_ADDR 0x11300000
256#define UART3_PHYS_ADDR 0x11400000
257#define SSI0_PHYS_ADDR 0x11600000
258#define SSI1_PHYS_ADDR 0x11680000
259#define SYS_PHYS_ADDR 0x11900000
260#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
261#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
262#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
263#endif
264
265/********************************************************************/
266
267#ifdef CONFIG_SOC_AU1500
268#define MEM_PHYS_ADDR 0x14000000
269#define STATIC_MEM_PHYS_ADDR 0x14001000
270#define DMA0_PHYS_ADDR 0x14002000
271#define DMA1_PHYS_ADDR 0x14002100
272#define DMA2_PHYS_ADDR 0x14002200
273#define DMA3_PHYS_ADDR 0x14002300
274#define DMA4_PHYS_ADDR 0x14002400
275#define DMA5_PHYS_ADDR 0x14002500
276#define DMA6_PHYS_ADDR 0x14002600
277#define DMA7_PHYS_ADDR 0x14002700
278#define IC0_PHYS_ADDR 0x10400000
279#define IC1_PHYS_ADDR 0x11800000
280#define AC97_PHYS_ADDR 0x10000000
281#define USBH_PHYS_ADDR 0x10100000
282#define USBD_PHYS_ADDR 0x10200000
283#define PCI_PHYS_ADDR 0x14005000
284#define MAC0_PHYS_ADDR 0x11500000
285#define MAC1_PHYS_ADDR 0x11510000
286#define MACEN_PHYS_ADDR 0x11520000
287#define MACDMA0_PHYS_ADDR 0x14004000
288#define MACDMA1_PHYS_ADDR 0x14004200
289#define I2S_PHYS_ADDR 0x11000000
290#define UART0_PHYS_ADDR 0x11100000
291#define UART3_PHYS_ADDR 0x11400000
292#define GPIO2_PHYS_ADDR 0x11700000
293#define SYS_PHYS_ADDR 0x11900000
294#define PCI_MEM_PHYS_ADDR 0x400000000ULL
295#define PCI_IO_PHYS_ADDR 0x500000000ULL
296#define PCI_CONFIG0_PHYS_ADDR 0x600000000ULL
297#define PCI_CONFIG1_PHYS_ADDR 0x680000000ULL
298#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
299#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
300#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
301#endif
302
303/********************************************************************/
304
305#ifdef CONFIG_SOC_AU1100
306#define MEM_PHYS_ADDR 0x14000000
307#define STATIC_MEM_PHYS_ADDR 0x14001000
308#define DMA0_PHYS_ADDR 0x14002000
309#define DMA1_PHYS_ADDR 0x14002100
310#define DMA2_PHYS_ADDR 0x14002200
311#define DMA3_PHYS_ADDR 0x14002300
312#define DMA4_PHYS_ADDR 0x14002400
313#define DMA5_PHYS_ADDR 0x14002500
314#define DMA6_PHYS_ADDR 0x14002600
315#define DMA7_PHYS_ADDR 0x14002700
316#define IC0_PHYS_ADDR 0x10400000
317#define SD0_PHYS_ADDR 0x10600000
318#define SD1_PHYS_ADDR 0x10680000
319#define IC1_PHYS_ADDR 0x11800000
320#define AC97_PHYS_ADDR 0x10000000
321#define USBH_PHYS_ADDR 0x10100000
322#define USBD_PHYS_ADDR 0x10200000
323#define IRDA_PHYS_ADDR 0x10300000
324#define MAC0_PHYS_ADDR 0x10500000
325#define MACEN_PHYS_ADDR 0x10520000
326#define MACDMA0_PHYS_ADDR 0x14004000
327#define MACDMA1_PHYS_ADDR 0x14004200
328#define I2S_PHYS_ADDR 0x11000000
329#define UART0_PHYS_ADDR 0x11100000
330#define UART1_PHYS_ADDR 0x11200000
331#define UART3_PHYS_ADDR 0x11400000
332#define SSI0_PHYS_ADDR 0x11600000
333#define SSI1_PHYS_ADDR 0x11680000
334#define GPIO2_PHYS_ADDR 0x11700000
335#define SYS_PHYS_ADDR 0x11900000
336#define LCD_PHYS_ADDR 0x15000000
337#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
338#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
339#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
340#endif
341
342/***********************************************************************/
343
344#ifdef CONFIG_SOC_AU1550
345#define MEM_PHYS_ADDR 0x14000000
346#define STATIC_MEM_PHYS_ADDR 0x14001000
347#define IC0_PHYS_ADDR 0x10400000
348#define IC1_PHYS_ADDR 0x11800000
349#define USBH_PHYS_ADDR 0x14020000
350#define USBD_PHYS_ADDR 0x10200000
351#define PCI_PHYS_ADDR 0x14005000
352#define MAC0_PHYS_ADDR 0x10500000
353#define MAC1_PHYS_ADDR 0x10510000
354#define MACEN_PHYS_ADDR 0x10520000
355#define MACDMA0_PHYS_ADDR 0x14004000
356#define MACDMA1_PHYS_ADDR 0x14004200
357#define UART0_PHYS_ADDR 0x11100000
358#define UART1_PHYS_ADDR 0x11200000
359#define UART3_PHYS_ADDR 0x11400000
360#define GPIO2_PHYS_ADDR 0x11700000
361#define SYS_PHYS_ADDR 0x11900000
362#define DDMA_PHYS_ADDR 0x14002000
363#define PE_PHYS_ADDR 0x14008000
364#define PSC0_PHYS_ADDR 0x11A00000
365#define PSC1_PHYS_ADDR 0x11B00000
366#define PSC2_PHYS_ADDR 0x10A00000
367#define PSC3_PHYS_ADDR 0x10B00000
368#define PCI_MEM_PHYS_ADDR 0x400000000ULL
369#define PCI_IO_PHYS_ADDR 0x500000000ULL
370#define PCI_CONFIG0_PHYS_ADDR 0x600000000ULL
371#define PCI_CONFIG1_PHYS_ADDR 0x680000000ULL
372#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
373#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
374#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
375#endif
376
377/***********************************************************************/
378
379#ifdef CONFIG_SOC_AU1200
380#define MEM_PHYS_ADDR 0x14000000
381#define STATIC_MEM_PHYS_ADDR 0x14001000
382#define AES_PHYS_ADDR 0x10300000
383#define CIM_PHYS_ADDR 0x14004000
384#define IC0_PHYS_ADDR 0x10400000
385#define IC1_PHYS_ADDR 0x11800000
386#define USBM_PHYS_ADDR 0x14020000
387#define USBH_PHYS_ADDR 0x14020100
388#define UART0_PHYS_ADDR 0x11100000
389#define UART1_PHYS_ADDR 0x11200000
390#define GPIO2_PHYS_ADDR 0x11700000
391#define SYS_PHYS_ADDR 0x11900000
392#define DDMA_PHYS_ADDR 0x14002000
393#define PSC0_PHYS_ADDR 0x11A00000
394#define PSC1_PHYS_ADDR 0x11B00000
395#define SD0_PHYS_ADDR 0x10600000
396#define SD1_PHYS_ADDR 0x10680000
397#define LCD_PHYS_ADDR 0x15000000
398#define SWCNT_PHYS_ADDR 0x1110010C
399#define MAEFE_PHYS_ADDR 0x14012000
400#define MAEBE_PHYS_ADDR 0x14010000
401#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
402#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
403#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
404#endif
405
406/* Static Bus Controller */
407#define MEM_STCFG0 0xB4001000
408#define MEM_STTIME0 0xB4001004
409#define MEM_STADDR0 0xB4001008
410
411#define MEM_STCFG1 0xB4001010
412#define MEM_STTIME1 0xB4001014
413#define MEM_STADDR1 0xB4001018
414
415#define MEM_STCFG2 0xB4001020
416#define MEM_STTIME2 0xB4001024
417#define MEM_STADDR2 0xB4001028
418
419#define MEM_STCFG3 0xB4001030
420#define MEM_STTIME3 0xB4001034
421#define MEM_STADDR3 0xB4001038
422
423#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
424#define MEM_STNDCTL 0xB4001100
425#define MEM_STSTAT 0xB4001104
426
427#define MEM_STNAND_CMD 0x0
428#define MEM_STNAND_ADDR 0x4
429#define MEM_STNAND_DATA 0x20
430#endif
431
432/* Interrupt Controller 0 */
433#define IC0_CFG0RD 0xB0400040
434#define IC0_CFG0SET 0xB0400040
435#define IC0_CFG0CLR 0xB0400044
436
437#define IC0_CFG1RD 0xB0400048
438#define IC0_CFG1SET 0xB0400048
439#define IC0_CFG1CLR 0xB040004C
440
441#define IC0_CFG2RD 0xB0400050
442#define IC0_CFG2SET 0xB0400050
443#define IC0_CFG2CLR 0xB0400054
444
445#define IC0_REQ0INT 0xB0400054
446#define IC0_SRCRD 0xB0400058
447#define IC0_SRCSET 0xB0400058
448#define IC0_SRCCLR 0xB040005C
449#define IC0_REQ1INT 0xB040005C
450
451#define IC0_ASSIGNRD 0xB0400060
452#define IC0_ASSIGNSET 0xB0400060
453#define IC0_ASSIGNCLR 0xB0400064
454
455#define IC0_WAKERD 0xB0400068
456#define IC0_WAKESET 0xB0400068
457#define IC0_WAKECLR 0xB040006C
458
459#define IC0_MASKRD 0xB0400070
460#define IC0_MASKSET 0xB0400070
461#define IC0_MASKCLR 0xB0400074
462
463#define IC0_RISINGRD 0xB0400078
464#define IC0_RISINGCLR 0xB0400078
465#define IC0_FALLINGRD 0xB040007C
466#define IC0_FALLINGCLR 0xB040007C
467
468#define IC0_TESTBIT 0xB0400080
469
470/* Interrupt Controller 1 */
471#define IC1_CFG0RD 0xB1800040
472#define IC1_CFG0SET 0xB1800040
473#define IC1_CFG0CLR 0xB1800044
474
475#define IC1_CFG1RD 0xB1800048
476#define IC1_CFG1SET 0xB1800048
477#define IC1_CFG1CLR 0xB180004C
478
479#define IC1_CFG2RD 0xB1800050
480#define IC1_CFG2SET 0xB1800050
481#define IC1_CFG2CLR 0xB1800054
482
483#define IC1_REQ0INT 0xB1800054
484#define IC1_SRCRD 0xB1800058
485#define IC1_SRCSET 0xB1800058
486#define IC1_SRCCLR 0xB180005C
487#define IC1_REQ1INT 0xB180005C
488
489#define IC1_ASSIGNRD 0xB1800060
490#define IC1_ASSIGNSET 0xB1800060
491#define IC1_ASSIGNCLR 0xB1800064
492
493#define IC1_WAKERD 0xB1800068
494#define IC1_WAKESET 0xB1800068
495#define IC1_WAKECLR 0xB180006C
496
497#define IC1_MASKRD 0xB1800070
498#define IC1_MASKSET 0xB1800070
499#define IC1_MASKCLR 0xB1800074
500
501#define IC1_RISINGRD 0xB1800078
502#define IC1_RISINGCLR 0xB1800078
503#define IC1_FALLINGRD 0xB180007C
504#define IC1_FALLINGCLR 0xB180007C
505
506#define IC1_TESTBIT 0xB1800080
507
508/* Interrupt Configuration Modes */
509#define INTC_INT_DISABLED 0x0
510#define INTC_INT_RISE_EDGE 0x1
511#define INTC_INT_FALL_EDGE 0x2
512#define INTC_INT_RISE_AND_FALL_EDGE 0x3
513#define INTC_INT_HIGH_LEVEL 0x5
514#define INTC_INT_LOW_LEVEL 0x6
515#define INTC_INT_HIGH_AND_LOW_LEVEL 0x7
516
517/* Interrupt Numbers */
518/* Au1000 */
519#ifdef CONFIG_SOC_AU1000
520enum soc_au1000_ints {
521 AU1000_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
522 AU1000_UART0_INT = AU1000_FIRST_INT,
523 AU1000_UART1_INT, /* au1000 */
524 AU1000_UART2_INT, /* au1000 */
525 AU1000_UART3_INT,
526 AU1000_SSI0_INT, /* au1000 */
527 AU1000_SSI1_INT, /* au1000 */
528 AU1000_DMA_INT_BASE,
529
530 AU1000_TOY_INT = AU1000_FIRST_INT + 14,
531 AU1000_TOY_MATCH0_INT,
532 AU1000_TOY_MATCH1_INT,
533 AU1000_TOY_MATCH2_INT,
534 AU1000_RTC_INT,
535 AU1000_RTC_MATCH0_INT,
536 AU1000_RTC_MATCH1_INT,
537 AU1000_RTC_MATCH2_INT,
538 AU1000_IRDA_TX_INT, /* au1000 */
539 AU1000_IRDA_RX_INT, /* au1000 */
540 AU1000_USB_DEV_REQ_INT,
541 AU1000_USB_DEV_SUS_INT,
542 AU1000_USB_HOST_INT,
543 AU1000_ACSYNC_INT,
544 AU1000_MAC0_DMA_INT,
545 AU1000_MAC1_DMA_INT,
546 AU1000_I2S_UO_INT, /* au1000 */
547 AU1000_AC97C_INT,
548 AU1000_GPIO_0,
549 AU1000_GPIO_1,
550 AU1000_GPIO_2,
551 AU1000_GPIO_3,
552 AU1000_GPIO_4,
553 AU1000_GPIO_5,
554 AU1000_GPIO_6,
555 AU1000_GPIO_7,
556 AU1000_GPIO_8,
557 AU1000_GPIO_9,
558 AU1000_GPIO_10,
559 AU1000_GPIO_11,
560 AU1000_GPIO_12,
561 AU1000_GPIO_13,
562 AU1000_GPIO_14,
563 AU1000_GPIO_15,
564 AU1000_GPIO_16,
565 AU1000_GPIO_17,
566 AU1000_GPIO_18,
567 AU1000_GPIO_19,
568 AU1000_GPIO_20,
569 AU1000_GPIO_21,
570 AU1000_GPIO_22,
571 AU1000_GPIO_23,
572 AU1000_GPIO_24,
573 AU1000_GPIO_25,
574 AU1000_GPIO_26,
575 AU1000_GPIO_27,
576 AU1000_GPIO_28,
577 AU1000_GPIO_29,
578 AU1000_GPIO_30,
579 AU1000_GPIO_31,
580};
581
582#define UART0_ADDR 0xB1100000
583#define UART1_ADDR 0xB1200000
584#define UART2_ADDR 0xB1300000
585#define UART3_ADDR 0xB1400000
586
587#define USB_OHCI_BASE 0x10100000 /* phys addr for ioremap */
588#define USB_HOST_CONFIG 0xB017FFFC
589
590#define AU1000_ETH0_BASE 0xB0500000
591#define AU1000_ETH1_BASE 0xB0510000
592#define AU1000_MAC0_ENABLE 0xB0520000
593#define AU1000_MAC1_ENABLE 0xB0520004
594#define NUM_ETH_INTERFACES 2
595#endif /* CONFIG_SOC_AU1000 */
596
597/* Au1500 */
598#ifdef CONFIG_SOC_AU1500
599enum soc_au1500_ints {
600 AU1500_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
601 AU1500_UART0_INT = AU1500_FIRST_INT,
602 AU1000_PCI_INTA, /* au1500 */
603 AU1000_PCI_INTB, /* au1500 */
604 AU1500_UART3_INT,
605 AU1000_PCI_INTC, /* au1500 */
606 AU1000_PCI_INTD, /* au1500 */
607 AU1000_DMA_INT_BASE,
608
609 AU1000_TOY_INT = AU1500_FIRST_INT + 14,
610 AU1000_TOY_MATCH0_INT,
611 AU1000_TOY_MATCH1_INT,
612 AU1000_TOY_MATCH2_INT,
613 AU1000_RTC_INT,
614 AU1000_RTC_MATCH0_INT,
615 AU1000_RTC_MATCH1_INT,
616 AU1000_RTC_MATCH2_INT,
617 AU1500_PCI_ERR_INT,
618 AU1500_RESERVED_INT,
619 AU1000_USB_DEV_REQ_INT,
620 AU1000_USB_DEV_SUS_INT,
621 AU1000_USB_HOST_INT,
622 AU1000_ACSYNC_INT,
623 AU1500_MAC0_DMA_INT,
624 AU1500_MAC1_DMA_INT,
625 AU1000_AC97C_INT = AU1500_FIRST_INT + 31,
626 AU1000_GPIO_0,
627 AU1000_GPIO_1,
628 AU1000_GPIO_2,
629 AU1000_GPIO_3,
630 AU1000_GPIO_4,
631 AU1000_GPIO_5,
632 AU1000_GPIO_6,
633 AU1000_GPIO_7,
634 AU1000_GPIO_8,
635 AU1000_GPIO_9,
636 AU1000_GPIO_10,
637 AU1000_GPIO_11,
638 AU1000_GPIO_12,
639 AU1000_GPIO_13,
640 AU1000_GPIO_14,
641 AU1000_GPIO_15,
642 AU1500_GPIO_200,
643 AU1500_GPIO_201,
644 AU1500_GPIO_202,
645 AU1500_GPIO_203,
646 AU1500_GPIO_20,
647 AU1500_GPIO_204,
648 AU1500_GPIO_205,
649 AU1500_GPIO_23,
650 AU1500_GPIO_24,
651 AU1500_GPIO_25,
652 AU1500_GPIO_26,
653 AU1500_GPIO_27,
654 AU1500_GPIO_28,
655 AU1500_GPIO_206,
656 AU1500_GPIO_207,
657 AU1500_GPIO_208_215,
658};
659
660/* shortcuts */
661#define INTA AU1000_PCI_INTA
662#define INTB AU1000_PCI_INTB
663#define INTC AU1000_PCI_INTC
664#define INTD AU1000_PCI_INTD
665
666#define UART0_ADDR 0xB1100000
667#define UART3_ADDR 0xB1400000
668
669#define USB_OHCI_BASE 0x10100000 /* phys addr for ioremap */
670#define USB_HOST_CONFIG 0xB017fffc
671
672#define AU1500_ETH0_BASE 0xB1500000
673#define AU1500_ETH1_BASE 0xB1510000
674#define AU1500_MAC0_ENABLE 0xB1520000
675#define AU1500_MAC1_ENABLE 0xB1520004
676#define NUM_ETH_INTERFACES 2
677#endif /* CONFIG_SOC_AU1500 */
678
679/* Au1100 */
680#ifdef CONFIG_SOC_AU1100
681enum soc_au1100_ints {
682 AU1100_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
683 AU1100_UART0_INT,
684 AU1100_UART1_INT,
685 AU1100_SD_INT,
686 AU1100_UART3_INT,
687 AU1000_SSI0_INT,
688 AU1000_SSI1_INT,
689 AU1000_DMA_INT_BASE,
690
691 AU1000_TOY_INT = AU1100_FIRST_INT + 14,
692 AU1000_TOY_MATCH0_INT,
693 AU1000_TOY_MATCH1_INT,
694 AU1000_TOY_MATCH2_INT,
695 AU1000_RTC_INT,
696 AU1000_RTC_MATCH0_INT,
697 AU1000_RTC_MATCH1_INT,
698 AU1000_RTC_MATCH2_INT,
699 AU1000_IRDA_TX_INT,
700 AU1000_IRDA_RX_INT,
701 AU1000_USB_DEV_REQ_INT,
702 AU1000_USB_DEV_SUS_INT,
703 AU1000_USB_HOST_INT,
704 AU1000_ACSYNC_INT,
705 AU1100_MAC0_DMA_INT,
706 AU1100_GPIO_208_215,
707 AU1100_LCD_INT,
708 AU1000_AC97C_INT,
709 AU1000_GPIO_0,
710 AU1000_GPIO_1,
711 AU1000_GPIO_2,
712 AU1000_GPIO_3,
713 AU1000_GPIO_4,
714 AU1000_GPIO_5,
715 AU1000_GPIO_6,
716 AU1000_GPIO_7,
717 AU1000_GPIO_8,
718 AU1000_GPIO_9,
719 AU1000_GPIO_10,
720 AU1000_GPIO_11,
721 AU1000_GPIO_12,
722 AU1000_GPIO_13,
723 AU1000_GPIO_14,
724 AU1000_GPIO_15,
725 AU1000_GPIO_16,
726 AU1000_GPIO_17,
727 AU1000_GPIO_18,
728 AU1000_GPIO_19,
729 AU1000_GPIO_20,
730 AU1000_GPIO_21,
731 AU1000_GPIO_22,
732 AU1000_GPIO_23,
733 AU1000_GPIO_24,
734 AU1000_GPIO_25,
735 AU1000_GPIO_26,
736 AU1000_GPIO_27,
737 AU1000_GPIO_28,
738 AU1000_GPIO_29,
739 AU1000_GPIO_30,
740 AU1000_GPIO_31,
741};
742
743#define UART0_ADDR 0xB1100000
744#define UART1_ADDR 0xB1200000
745#define UART3_ADDR 0xB1400000
746
747#define USB_OHCI_BASE 0x10100000 /* phys addr for ioremap */
748#define USB_HOST_CONFIG 0xB017FFFC
749
750#define AU1100_ETH0_BASE 0xB0500000
751#define AU1100_MAC0_ENABLE 0xB0520000
752#define NUM_ETH_INTERFACES 1
753#endif /* CONFIG_SOC_AU1100 */
754
755#ifdef CONFIG_SOC_AU1550
756enum soc_au1550_ints {
757 AU1550_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
758 AU1550_UART0_INT = AU1550_FIRST_INT,
759 AU1550_PCI_INTA,
760 AU1550_PCI_INTB,
761 AU1550_DDMA_INT,
762 AU1550_CRYPTO_INT,
763 AU1550_PCI_INTC,
764 AU1550_PCI_INTD,
765 AU1550_PCI_RST_INT,
766 AU1550_UART1_INT,
767 AU1550_UART3_INT,
768 AU1550_PSC0_INT,
769 AU1550_PSC1_INT,
770 AU1550_PSC2_INT,
771 AU1550_PSC3_INT,
772 AU1000_TOY_INT,
773 AU1000_TOY_MATCH0_INT,
774 AU1000_TOY_MATCH1_INT,
775 AU1000_TOY_MATCH2_INT,
776 AU1000_RTC_INT,
777 AU1000_RTC_MATCH0_INT,
778 AU1000_RTC_MATCH1_INT,
779 AU1000_RTC_MATCH2_INT,
780
781 AU1550_NAND_INT = AU1550_FIRST_INT + 23,
782 AU1550_USB_DEV_REQ_INT,
783 AU1000_USB_DEV_REQ_INT = AU1550_USB_DEV_REQ_INT,
784 AU1550_USB_DEV_SUS_INT,
785 AU1000_USB_DEV_SUS_INT = AU1550_USB_DEV_SUS_INT,
786 AU1550_USB_HOST_INT,
787 AU1000_USB_HOST_INT = AU1550_USB_HOST_INT,
788 AU1550_MAC0_DMA_INT,
789 AU1550_MAC1_DMA_INT,
790 AU1000_GPIO_0 = AU1550_FIRST_INT + 32,
791 AU1000_GPIO_1,
792 AU1000_GPIO_2,
793 AU1000_GPIO_3,
794 AU1000_GPIO_4,
795 AU1000_GPIO_5,
796 AU1000_GPIO_6,
797 AU1000_GPIO_7,
798 AU1000_GPIO_8,
799 AU1000_GPIO_9,
800 AU1000_GPIO_10,
801 AU1000_GPIO_11,
802 AU1000_GPIO_12,
803 AU1000_GPIO_13,
804 AU1000_GPIO_14,
805 AU1000_GPIO_15,
806 AU1550_GPIO_200,
807 AU1500_GPIO_201_205, /* Logical or of GPIO201:205 */
808 AU1500_GPIO_16,
809 AU1500_GPIO_17,
810 AU1500_GPIO_20,
811 AU1500_GPIO_21,
812 AU1500_GPIO_22,
813 AU1500_GPIO_23,
814 AU1500_GPIO_24,
815 AU1500_GPIO_25,
816 AU1500_GPIO_26,
817 AU1500_GPIO_27,
818 AU1500_GPIO_28,
819 AU1500_GPIO_206,
820 AU1500_GPIO_207,
821 AU1500_GPIO_208_218, /* Logical or of GPIO208:218 */
822};
823
824/* shortcuts */
825#define INTA AU1550_PCI_INTA
826#define INTB AU1550_PCI_INTB
827#define INTC AU1550_PCI_INTC
828#define INTD AU1550_PCI_INTD
829
830#define UART0_ADDR 0xB1100000
831#define UART1_ADDR 0xB1200000
832#define UART3_ADDR 0xB1400000
833
834#define USB_OHCI_BASE 0x14020000 /* phys addr for ioremap */
835#define USB_OHCI_LEN 0x00060000
836#define USB_HOST_CONFIG 0xB4027ffc
837
838#define AU1550_ETH0_BASE 0xB0500000
839#define AU1550_ETH1_BASE 0xB0510000
840#define AU1550_MAC0_ENABLE 0xB0520000
841#define AU1550_MAC1_ENABLE 0xB0520004
842#define NUM_ETH_INTERFACES 2
843#endif /* CONFIG_SOC_AU1550 */
844
845#ifdef CONFIG_SOC_AU1200
846enum soc_au1200_ints {
847 AU1200_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
848 AU1200_UART0_INT = AU1200_FIRST_INT,
849 AU1200_SWT_INT,
850 AU1200_SD_INT,
851 AU1200_DDMA_INT,
852 AU1200_MAE_BE_INT,
853 AU1200_GPIO_200,
854 AU1200_GPIO_201,
855 AU1200_GPIO_202,
856 AU1200_UART1_INT,
857 AU1200_MAE_FE_INT,
858 AU1200_PSC0_INT,
859 AU1200_PSC1_INT,
860 AU1200_AES_INT,
861 AU1200_CAMERA_INT,
862 AU1000_TOY_INT,
863 AU1000_TOY_MATCH0_INT,
864 AU1000_TOY_MATCH1_INT,
865 AU1000_TOY_MATCH2_INT,
866 AU1000_RTC_INT,
867 AU1000_RTC_MATCH0_INT,
868 AU1000_RTC_MATCH1_INT,
869 AU1000_RTC_MATCH2_INT,
870
871 AU1200_NAND_INT = AU1200_FIRST_INT + 23,
872 AU1200_GPIO_204,
873 AU1200_GPIO_205,
874 AU1200_GPIO_206,
875 AU1200_GPIO_207,
876 AU1200_GPIO_208_215, /* Logical OR of 208:215 */
877 AU1200_USB_INT,
878 AU1000_USB_HOST_INT = AU1200_USB_INT,
879 AU1200_LCD_INT,
880 AU1200_MAE_BOTH_INT,
881 AU1000_GPIO_0,
882 AU1000_GPIO_1,
883 AU1000_GPIO_2,
884 AU1000_GPIO_3,
885 AU1000_GPIO_4,
886 AU1000_GPIO_5,
887 AU1000_GPIO_6,
888 AU1000_GPIO_7,
889 AU1000_GPIO_8,
890 AU1000_GPIO_9,
891 AU1000_GPIO_10,
892 AU1000_GPIO_11,
893 AU1000_GPIO_12,
894 AU1000_GPIO_13,
895 AU1000_GPIO_14,
896 AU1000_GPIO_15,
897 AU1000_GPIO_16,
898 AU1000_GPIO_17,
899 AU1000_GPIO_18,
900 AU1000_GPIO_19,
901 AU1000_GPIO_20,
902 AU1000_GPIO_21,
903 AU1000_GPIO_22,
904 AU1000_GPIO_23,
905 AU1000_GPIO_24,
906 AU1000_GPIO_25,
907 AU1000_GPIO_26,
908 AU1000_GPIO_27,
909 AU1000_GPIO_28,
910 AU1000_GPIO_29,
911 AU1000_GPIO_30,
912 AU1000_GPIO_31,
913};
914
915#define UART0_ADDR 0xB1100000
916#define UART1_ADDR 0xB1200000
917
918#define USB_UOC_BASE 0x14020020
919#define USB_UOC_LEN 0x20
920#define USB_OHCI_BASE 0x14020100
921#define USB_OHCI_LEN 0x100
922#define USB_EHCI_BASE 0x14020200
923#define USB_EHCI_LEN 0x100
924#define USB_UDC_BASE 0x14022000
925#define USB_UDC_LEN 0x2000
926#define USB_MSR_BASE 0xB4020000
927#define USB_MSR_MCFG 4
928#define USBMSRMCFG_OMEMEN 0
929#define USBMSRMCFG_OBMEN 1
930#define USBMSRMCFG_EMEMEN 2
931#define USBMSRMCFG_EBMEN 3
932#define USBMSRMCFG_DMEMEN 4
933#define USBMSRMCFG_DBMEN 5
934#define USBMSRMCFG_GMEMEN 6
935#define USBMSRMCFG_OHCCLKEN 16
936#define USBMSRMCFG_EHCCLKEN 17
937#define USBMSRMCFG_UDCCLKEN 18
938#define USBMSRMCFG_PHYPLLEN 19
939#define USBMSRMCFG_RDCOMB 30
940#define USBMSRMCFG_PFEN 31
941
942#endif /* CONFIG_SOC_AU1200 */
943
944#define AU1000_INTC0_INT_BASE (MIPS_CPU_IRQ_BASE + 8)
945#define AU1000_INTC0_INT_LAST (AU1000_INTC0_INT_BASE + 31)
946#define AU1000_INTC1_INT_BASE (AU1000_INTC0_INT_BASE + 32)
947#define AU1000_INTC1_INT_LAST (AU1000_INTC1_INT_BASE + 31)
948
949#define AU1000_MAX_INTR AU1000_INTC1_INT_LAST
950#define INTX 0xFF /* not valid */
951
952/* Programmable Counters 0 and 1 */
953#define SYS_BASE 0xB1900000
954#define SYS_COUNTER_CNTRL (SYS_BASE + 0x14)
955# define SYS_CNTRL_E1S (1 << 23)
956# define SYS_CNTRL_T1S (1 << 20)
957# define SYS_CNTRL_M21 (1 << 19)
958# define SYS_CNTRL_M11 (1 << 18)
959# define SYS_CNTRL_M01 (1 << 17)
960# define SYS_CNTRL_C1S (1 << 16)
961# define SYS_CNTRL_BP (1 << 14)
962# define SYS_CNTRL_EN1 (1 << 13)
963# define SYS_CNTRL_BT1 (1 << 12)
964# define SYS_CNTRL_EN0 (1 << 11)
965# define SYS_CNTRL_BT0 (1 << 10)
966# define SYS_CNTRL_E0 (1 << 8)
967# define SYS_CNTRL_E0S (1 << 7)
968# define SYS_CNTRL_32S (1 << 5)
969# define SYS_CNTRL_T0S (1 << 4)
970# define SYS_CNTRL_M20 (1 << 3)
971# define SYS_CNTRL_M10 (1 << 2)
972# define SYS_CNTRL_M00 (1 << 1)
973# define SYS_CNTRL_C0S (1 << 0)
974
975/* Programmable Counter 0 Registers */
976#define SYS_TOYTRIM (SYS_BASE + 0)
977#define SYS_TOYWRITE (SYS_BASE + 4)
978#define SYS_TOYMATCH0 (SYS_BASE + 8)
979#define SYS_TOYMATCH1 (SYS_BASE + 0xC)
980#define SYS_TOYMATCH2 (SYS_BASE + 0x10)
981#define SYS_TOYREAD (SYS_BASE + 0x40)
982
983/* Programmable Counter 1 Registers */
984#define SYS_RTCTRIM (SYS_BASE + 0x44)
985#define SYS_RTCWRITE (SYS_BASE + 0x48)
986#define SYS_RTCMATCH0 (SYS_BASE + 0x4C)
987#define SYS_RTCMATCH1 (SYS_BASE + 0x50)
988#define SYS_RTCMATCH2 (SYS_BASE + 0x54)
989#define SYS_RTCREAD (SYS_BASE + 0x58)
990
991/* I2S Controller */
992#define I2S_DATA 0xB1000000
993# define I2S_DATA_MASK 0xffffff
994#define I2S_CONFIG 0xB1000004
995# define I2S_CONFIG_XU (1 << 25)
996# define I2S_CONFIG_XO (1 << 24)
997# define I2S_CONFIG_RU (1 << 23)
998# define I2S_CONFIG_RO (1 << 22)
999# define I2S_CONFIG_TR (1 << 21)
1000# define I2S_CONFIG_TE (1 << 20)
1001# define I2S_CONFIG_TF (1 << 19)
1002# define I2S_CONFIG_RR (1 << 18)
1003# define I2S_CONFIG_RE (1 << 17)
1004# define I2S_CONFIG_RF (1 << 16)
1005# define I2S_CONFIG_PD (1 << 11)
1006# define I2S_CONFIG_LB (1 << 10)
1007# define I2S_CONFIG_IC (1 << 9)
1008# define I2S_CONFIG_FM_BIT 7
1009# define I2S_CONFIG_FM_MASK (0x3 << I2S_CONFIG_FM_BIT)
1010# define I2S_CONFIG_FM_I2S (0x0 << I2S_CONFIG_FM_BIT)
1011# define I2S_CONFIG_FM_LJ (0x1 << I2S_CONFIG_FM_BIT)
1012# define I2S_CONFIG_FM_RJ (0x2 << I2S_CONFIG_FM_BIT)
1013# define I2S_CONFIG_TN (1 << 6)
1014# define I2S_CONFIG_RN (1 << 5)
1015# define I2S_CONFIG_SZ_BIT 0
1016# define I2S_CONFIG_SZ_MASK (0x1F << I2S_CONFIG_SZ_BIT)
1017
1018#define I2S_CONTROL 0xB1000008
1019# define I2S_CONTROL_D (1 << 1)
1020# define I2S_CONTROL_CE (1 << 0)
1021
1022/* USB Host Controller */
1023#ifndef USB_OHCI_LEN
1024#define USB_OHCI_LEN 0x00100000
1025#endif
1026
1027#ifndef CONFIG_SOC_AU1200
1028
1029/* USB Device Controller */
1030#define USBD_EP0RD 0xB0200000
1031#define USBD_EP0WR 0xB0200004
1032#define USBD_EP2WR 0xB0200008
1033#define USBD_EP3WR 0xB020000C
1034#define USBD_EP4RD 0xB0200010
1035#define USBD_EP5RD 0xB0200014
1036#define USBD_INTEN 0xB0200018
1037#define USBD_INTSTAT 0xB020001C
1038# define USBDEV_INT_SOF (1 << 12)
1039# define USBDEV_INT_HF_BIT 6
1040# define USBDEV_INT_HF_MASK (0x3f << USBDEV_INT_HF_BIT)
1041# define USBDEV_INT_CMPLT_BIT 0
1042# define USBDEV_INT_CMPLT_MASK (0x3f << USBDEV_INT_CMPLT_BIT)
1043#define USBD_CONFIG 0xB0200020
1044#define USBD_EP0CS 0xB0200024
1045#define USBD_EP2CS 0xB0200028
1046#define USBD_EP3CS 0xB020002C
1047#define USBD_EP4CS 0xB0200030
1048#define USBD_EP5CS 0xB0200034
1049# define USBDEV_CS_SU (1 << 14)
1050# define USBDEV_CS_NAK (1 << 13)
1051# define USBDEV_CS_ACK (1 << 12)
1052# define USBDEV_CS_BUSY (1 << 11)
1053# define USBDEV_CS_TSIZE_BIT 1
1054# define USBDEV_CS_TSIZE_MASK (0x3ff << USBDEV_CS_TSIZE_BIT)
1055# define USBDEV_CS_STALL (1 << 0)
1056#define USBD_EP0RDSTAT 0xB0200040
1057#define USBD_EP0WRSTAT 0xB0200044
1058#define USBD_EP2WRSTAT 0xB0200048
1059#define USBD_EP3WRSTAT 0xB020004C
1060#define USBD_EP4RDSTAT 0xB0200050
1061#define USBD_EP5RDSTAT 0xB0200054
1062# define USBDEV_FSTAT_FLUSH (1 << 6)
1063# define USBDEV_FSTAT_UF (1 << 5)
1064# define USBDEV_FSTAT_OF (1 << 4)
1065# define USBDEV_FSTAT_FCNT_BIT 0
1066# define USBDEV_FSTAT_FCNT_MASK (0x0f << USBDEV_FSTAT_FCNT_BIT)
1067#define USBD_ENABLE 0xB0200058
1068# define USBDEV_ENABLE (1 << 1)
1069# define USBDEV_CE (1 << 0)
1070
1071#endif /* !CONFIG_SOC_AU1200 */
1072
1073/* Ethernet Controllers */
1074
1075/* 4 byte offsets from AU1000_ETH_BASE */
1076#define MAC_CONTROL 0x0
1077# define MAC_RX_ENABLE (1 << 2)
1078# define MAC_TX_ENABLE (1 << 3)
1079# define MAC_DEF_CHECK (1 << 5)
1080# define MAC_SET_BL(X) (((X) & 0x3) << 6)
1081# define MAC_AUTO_PAD (1 << 8)
1082# define MAC_DISABLE_RETRY (1 << 10)
1083# define MAC_DISABLE_BCAST (1 << 11)
1084# define MAC_LATE_COL (1 << 12)
1085# define MAC_HASH_MODE (1 << 13)
1086# define MAC_HASH_ONLY (1 << 15)
1087# define MAC_PASS_ALL (1 << 16)
1088# define MAC_INVERSE_FILTER (1 << 17)
1089# define MAC_PROMISCUOUS (1 << 18)
1090# define MAC_PASS_ALL_MULTI (1 << 19)
1091# define MAC_FULL_DUPLEX (1 << 20)
1092# define MAC_NORMAL_MODE 0
1093# define MAC_INT_LOOPBACK (1 << 21)
1094# define MAC_EXT_LOOPBACK (1 << 22)
1095# define MAC_DISABLE_RX_OWN (1 << 23)
1096# define MAC_BIG_ENDIAN (1 << 30)
1097# define MAC_RX_ALL (1 << 31)
1098#define MAC_ADDRESS_HIGH 0x4
1099#define MAC_ADDRESS_LOW 0x8
1100#define MAC_MCAST_HIGH 0xC
1101#define MAC_MCAST_LOW 0x10
1102#define MAC_MII_CNTRL 0x14
1103# define MAC_MII_BUSY (1 << 0)
1104# define MAC_MII_READ 0
1105# define MAC_MII_WRITE (1 << 1)
1106# define MAC_SET_MII_SELECT_REG(X) (((X) & 0x1f) << 6)
1107# define MAC_SET_MII_SELECT_PHY(X) (((X) & 0x1f) << 11)
1108#define MAC_MII_DATA 0x18
1109#define MAC_FLOW_CNTRL 0x1C
1110# define MAC_FLOW_CNTRL_BUSY (1 << 0)
1111# define MAC_FLOW_CNTRL_ENABLE (1 << 1)
1112# define MAC_PASS_CONTROL (1 << 2)
1113# define MAC_SET_PAUSE(X) (((X) & 0xffff) << 16)
1114#define MAC_VLAN1_TAG 0x20
1115#define MAC_VLAN2_TAG 0x24
1116
1117/* Ethernet Controller Enable */
1118
1119# define MAC_EN_CLOCK_ENABLE (1 << 0)
1120# define MAC_EN_RESET0 (1 << 1)
1121# define MAC_EN_TOSS (0 << 2)
1122# define MAC_EN_CACHEABLE (1 << 3)
1123# define MAC_EN_RESET1 (1 << 4)
1124# define MAC_EN_RESET2 (1 << 5)
1125# define MAC_DMA_RESET (1 << 6)
1126
1127/* Ethernet Controller DMA Channels */
1128
1129#define MAC0_TX_DMA_ADDR 0xB4004000
1130#define MAC1_TX_DMA_ADDR 0xB4004200
1131/* offsets from MAC_TX_RING_ADDR address */
1132#define MAC_TX_BUFF0_STATUS 0x0
1133# define TX_FRAME_ABORTED (1 << 0)
1134# define TX_JAB_TIMEOUT (1 << 1)
1135# define TX_NO_CARRIER (1 << 2)
1136# define TX_LOSS_CARRIER (1 << 3)
1137# define TX_EXC_DEF (1 << 4)
1138# define TX_LATE_COLL_ABORT (1 << 5)
1139# define TX_EXC_COLL (1 << 6)
1140# define TX_UNDERRUN (1 << 7)
1141# define TX_DEFERRED (1 << 8)
1142# define TX_LATE_COLL (1 << 9)
1143# define TX_COLL_CNT_MASK (0xF << 10)
1144# define TX_PKT_RETRY (1 << 31)
1145#define MAC_TX_BUFF0_ADDR 0x4
1146# define TX_DMA_ENABLE (1 << 0)
1147# define TX_T_DONE (1 << 1)
1148# define TX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3)
1149#define MAC_TX_BUFF0_LEN 0x8
1150#define MAC_TX_BUFF1_STATUS 0x10
1151#define MAC_TX_BUFF1_ADDR 0x14
1152#define MAC_TX_BUFF1_LEN 0x18
1153#define MAC_TX_BUFF2_STATUS 0x20
1154#define MAC_TX_BUFF2_ADDR 0x24
1155#define MAC_TX_BUFF2_LEN 0x28
1156#define MAC_TX_BUFF3_STATUS 0x30
1157#define MAC_TX_BUFF3_ADDR 0x34
1158#define MAC_TX_BUFF3_LEN 0x38
1159
1160#define MAC0_RX_DMA_ADDR 0xB4004100
1161#define MAC1_RX_DMA_ADDR 0xB4004300
1162/* offsets from MAC_RX_RING_ADDR */
1163#define MAC_RX_BUFF0_STATUS 0x0
1164# define RX_FRAME_LEN_MASK 0x3fff
1165# define RX_WDOG_TIMER (1 << 14)
1166# define RX_RUNT (1 << 15)
1167# define RX_OVERLEN (1 << 16)
1168# define RX_COLL (1 << 17)
1169# define RX_ETHER (1 << 18)
1170# define RX_MII_ERROR (1 << 19)
1171# define RX_DRIBBLING (1 << 20)
1172# define RX_CRC_ERROR (1 << 21)
1173# define RX_VLAN1 (1 << 22)
1174# define RX_VLAN2 (1 << 23)
1175# define RX_LEN_ERROR (1 << 24)
1176# define RX_CNTRL_FRAME (1 << 25)
1177# define RX_U_CNTRL_FRAME (1 << 26)
1178# define RX_MCAST_FRAME (1 << 27)
1179# define RX_BCAST_FRAME (1 << 28)
1180# define RX_FILTER_FAIL (1 << 29)
1181# define RX_PACKET_FILTER (1 << 30)
1182# define RX_MISSED_FRAME (1 << 31)
1183
1184# define RX_ERROR (RX_WDOG_TIMER | RX_RUNT | RX_OVERLEN | \
1185 RX_COLL | RX_MII_ERROR | RX_CRC_ERROR | \
1186 RX_LEN_ERROR | RX_U_CNTRL_FRAME | RX_MISSED_FRAME)
1187#define MAC_RX_BUFF0_ADDR 0x4
1188# define RX_DMA_ENABLE (1 << 0)
1189# define RX_T_DONE (1 << 1)
1190# define RX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3)
1191# define RX_SET_BUFF_ADDR(X) ((X) & 0xffffffc0)
1192#define MAC_RX_BUFF1_STATUS 0x10
1193#define MAC_RX_BUFF1_ADDR 0x14
1194#define MAC_RX_BUFF2_STATUS 0x20
1195#define MAC_RX_BUFF2_ADDR 0x24
1196#define MAC_RX_BUFF3_STATUS 0x30
1197#define MAC_RX_BUFF3_ADDR 0x34
1198
1199/* UARTS 0-3 */
1200#define UART_BASE UART0_ADDR
1201#ifdef CONFIG_SOC_AU1200
1202#define UART_DEBUG_BASE UART1_ADDR
1203#else
1204#define UART_DEBUG_BASE UART3_ADDR
1205#endif
1206
1207#define UART_RX 0 /* Receive buffer */
1208#define UART_TX 4 /* Transmit buffer */
1209#define UART_IER 8 /* Interrupt Enable Register */
1210#define UART_IIR 0xC /* Interrupt ID Register */
1211#define UART_FCR 0x10 /* FIFO Control Register */
1212#define UART_LCR 0x14 /* Line Control Register */
1213#define UART_MCR 0x18 /* Modem Control Register */
1214#define UART_LSR 0x1C /* Line Status Register */
1215#define UART_MSR 0x20 /* Modem Status Register */
1216#define UART_CLK 0x28 /* Baud Rate Clock Divider */
1217#define UART_MOD_CNTRL 0x100 /* Module Control */
1218
1219#define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */
1220#define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */
1221#define UART_FCR_CLEAR_XMIT 0x04 /* Clear the XMIT FIFO */
1222#define UART_FCR_DMA_SELECT 0x08 /* For DMA applications */
1223#define UART_FCR_TRIGGER_MASK 0xF0 /* Mask for the FIFO trigger range */
1224#define UART_FCR_R_TRIGGER_1 0x00 /* Mask for receive trigger set at 1 */
1225#define UART_FCR_R_TRIGGER_4 0x40 /* Mask for receive trigger set at 4 */
1226#define UART_FCR_R_TRIGGER_8 0x80 /* Mask for receive trigger set at 8 */
1227#define UART_FCR_R_TRIGGER_14 0xA0 /* Mask for receive trigger set at 14 */
1228#define UART_FCR_T_TRIGGER_0 0x00 /* Mask for transmit trigger set at 0 */
1229#define UART_FCR_T_TRIGGER_4 0x10 /* Mask for transmit trigger set at 4 */
1230#define UART_FCR_T_TRIGGER_8 0x20 /* Mask for transmit trigger set at 8 */
1231#define UART_FCR_T_TRIGGER_12 0x30 /* Mask for transmit trigger set at 12 */
1232
1233/*
1234 * These are the definitions for the Line Control Register
1235 */
1236#define UART_LCR_SBC 0x40 /* Set break control */
1237#define UART_LCR_SPAR 0x20 /* Stick parity (?) */
1238#define UART_LCR_EPAR 0x10 /* Even parity select */
1239#define UART_LCR_PARITY 0x08 /* Parity Enable */
1240#define UART_LCR_STOP 0x04 /* Stop bits: 0=1 stop bit, 1= 2 stop bits */
1241#define UART_LCR_WLEN5 0x00 /* Wordlength: 5 bits */
1242#define UART_LCR_WLEN6 0x01 /* Wordlength: 6 bits */
1243#define UART_LCR_WLEN7 0x02 /* Wordlength: 7 bits */
1244#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
1245
1246/*
1247 * These are the definitions for the Line Status Register
1248 */
1249#define UART_LSR_TEMT 0x40 /* Transmitter empty */
1250#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
1251#define UART_LSR_BI 0x10 /* Break interrupt indicator */
1252#define UART_LSR_FE 0x08 /* Frame error indicator */
1253#define UART_LSR_PE 0x04 /* Parity error indicator */
1254#define UART_LSR_OE 0x02 /* Overrun error indicator */
1255#define UART_LSR_DR 0x01 /* Receiver data ready */
1256
1257/*
1258 * These are the definitions for the Interrupt Identification Register
1259 */
1260#define UART_IIR_NO_INT 0x01 /* No interrupts pending */
1261#define UART_IIR_ID 0x06 /* Mask for the interrupt ID */
1262#define UART_IIR_MSI 0x00 /* Modem status interrupt */
1263#define UART_IIR_THRI 0x02 /* Transmitter holding register empty */
1264#define UART_IIR_RDI 0x04 /* Receiver data interrupt */
1265#define UART_IIR_RLSI 0x06 /* Receiver line status interrupt */
1266
1267/*
1268 * These are the definitions for the Interrupt Enable Register
1269 */
1270#define UART_IER_MSI 0x08 /* Enable Modem status interrupt */
1271#define UART_IER_RLSI 0x04 /* Enable receiver line status interrupt */
1272#define UART_IER_THRI 0x02 /* Enable Transmitter holding register int. */
1273#define UART_IER_RDI 0x01 /* Enable receiver data interrupt */
1274
1275/*
1276 * These are the definitions for the Modem Control Register
1277 */
1278#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
1279#define UART_MCR_OUT2 0x08 /* Out2 complement */
1280#define UART_MCR_OUT1 0x04 /* Out1 complement */
1281#define UART_MCR_RTS 0x02 /* RTS complement */
1282#define UART_MCR_DTR 0x01 /* DTR complement */
1283
1284/*
1285 * These are the definitions for the Modem Status Register
1286 */
1287#define UART_MSR_DCD 0x80 /* Data Carrier Detect */
1288#define UART_MSR_RI 0x40 /* Ring Indicator */
1289#define UART_MSR_DSR 0x20 /* Data Set Ready */
1290#define UART_MSR_CTS 0x10 /* Clear to Send */
1291#define UART_MSR_DDCD 0x08 /* Delta DCD */
1292#define UART_MSR_TERI 0x04 /* Trailing edge ring indicator */
1293#define UART_MSR_DDSR 0x02 /* Delta DSR */
1294#define UART_MSR_DCTS 0x01 /* Delta CTS */
1295#define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */
1296
1297/* SSIO */
1298#define SSI0_STATUS 0xB1600000
1299# define SSI_STATUS_BF (1 << 4)
1300# define SSI_STATUS_OF (1 << 3)
1301# define SSI_STATUS_UF (1 << 2)
1302# define SSI_STATUS_D (1 << 1)
1303# define SSI_STATUS_B (1 << 0)
1304#define SSI0_INT 0xB1600004
1305# define SSI_INT_OI (1 << 3)
1306# define SSI_INT_UI (1 << 2)
1307# define SSI_INT_DI (1 << 1)
1308#define SSI0_INT_ENABLE 0xB1600008
1309# define SSI_INTE_OIE (1 << 3)
1310# define SSI_INTE_UIE (1 << 2)
1311# define SSI_INTE_DIE (1 << 1)
1312#define SSI0_CONFIG 0xB1600020
1313# define SSI_CONFIG_AO (1 << 24)
1314# define SSI_CONFIG_DO (1 << 23)
1315# define SSI_CONFIG_ALEN_BIT 20
1316# define SSI_CONFIG_ALEN_MASK (0x7 << 20)
1317# define SSI_CONFIG_DLEN_BIT 16
1318# define SSI_CONFIG_DLEN_MASK (0x7 << 16)
1319# define SSI_CONFIG_DD (1 << 11)
1320# define SSI_CONFIG_AD (1 << 10)
1321# define SSI_CONFIG_BM_BIT 8
1322# define SSI_CONFIG_BM_MASK (0x3 << 8)
1323# define SSI_CONFIG_CE (1 << 7)
1324# define SSI_CONFIG_DP (1 << 6)
1325# define SSI_CONFIG_DL (1 << 5)
1326# define SSI_CONFIG_EP (1 << 4)
1327#define SSI0_ADATA 0xB1600024
1328# define SSI_AD_D (1 << 24)
1329# define SSI_AD_ADDR_BIT 16
1330# define SSI_AD_ADDR_MASK (0xff << 16)
1331# define SSI_AD_DATA_BIT 0
1332# define SSI_AD_DATA_MASK (0xfff << 0)
1333#define SSI0_CLKDIV 0xB1600028
1334#define SSI0_CONTROL 0xB1600100
1335# define SSI_CONTROL_CD (1 << 1)
1336# define SSI_CONTROL_E (1 << 0)
1337
1338/* SSI1 */
1339#define SSI1_STATUS 0xB1680000
1340#define SSI1_INT 0xB1680004
1341#define SSI1_INT_ENABLE 0xB1680008
1342#define SSI1_CONFIG 0xB1680020
1343#define SSI1_ADATA 0xB1680024
1344#define SSI1_CLKDIV 0xB1680028
1345#define SSI1_ENABLE 0xB1680100
1346
1347/*
1348 * Register content definitions
1349 */
1350#define SSI_STATUS_BF (1 << 4)
1351#define SSI_STATUS_OF (1 << 3)
1352#define SSI_STATUS_UF (1 << 2)
1353#define SSI_STATUS_D (1 << 1)
1354#define SSI_STATUS_B (1 << 0)
1355
1356/* SSI_INT */
1357#define SSI_INT_OI (1 << 3)
1358#define SSI_INT_UI (1 << 2)
1359#define SSI_INT_DI (1 << 1)
1360
1361/* SSI_INTEN */
1362#define SSI_INTEN_OIE (1 << 3)
1363#define SSI_INTEN_UIE (1 << 2)
1364#define SSI_INTEN_DIE (1 << 1)
1365
1366#define SSI_CONFIG_AO (1 << 24)
1367#define SSI_CONFIG_DO (1 << 23)
1368#define SSI_CONFIG_ALEN (7 << 20)
1369#define SSI_CONFIG_DLEN (15 << 16)
1370#define SSI_CONFIG_DD (1 << 11)
1371#define SSI_CONFIG_AD (1 << 10)
1372#define SSI_CONFIG_BM (3 << 8)
1373#define SSI_CONFIG_CE (1 << 7)
1374#define SSI_CONFIG_DP (1 << 6)
1375#define SSI_CONFIG_DL (1 << 5)
1376#define SSI_CONFIG_EP (1 << 4)
1377#define SSI_CONFIG_ALEN_N(N) ((N-1) << 20)
1378#define SSI_CONFIG_DLEN_N(N) ((N-1) << 16)
1379#define SSI_CONFIG_BM_HI (0 << 8)
1380#define SSI_CONFIG_BM_LO (1 << 8)
1381#define SSI_CONFIG_BM_CY (2 << 8)
1382
1383#define SSI_ADATA_D (1 << 24)
1384#define SSI_ADATA_ADDR (0xFF << 16)
1385#define SSI_ADATA_DATA 0x0FFF
1386#define SSI_ADATA_ADDR_N(N) (N << 16)
1387
1388#define SSI_ENABLE_CD (1 << 1)
1389#define SSI_ENABLE_E (1 << 0)
1390
1391/* IrDA Controller */
1392#define IRDA_BASE 0xB0300000
1393#define IR_RING_PTR_STATUS (IRDA_BASE + 0x00)
1394#define IR_RING_BASE_ADDR_H (IRDA_BASE + 0x04)
1395#define IR_RING_BASE_ADDR_L (IRDA_BASE + 0x08)
1396#define IR_RING_SIZE (IRDA_BASE + 0x0C)
1397#define IR_RING_PROMPT (IRDA_BASE + 0x10)
1398#define IR_RING_ADDR_CMPR (IRDA_BASE + 0x14)
1399#define IR_INT_CLEAR (IRDA_BASE + 0x18)
1400#define IR_CONFIG_1 (IRDA_BASE + 0x20)
1401# define IR_RX_INVERT_LED (1 << 0)
1402# define IR_TX_INVERT_LED (1 << 1)
1403# define IR_ST (1 << 2)
1404# define IR_SF (1 << 3)
1405# define IR_SIR (1 << 4)
1406# define IR_MIR (1 << 5)
1407# define IR_FIR (1 << 6)
1408# define IR_16CRC (1 << 7)
1409# define IR_TD (1 << 8)
1410# define IR_RX_ALL (1 << 9)
1411# define IR_DMA_ENABLE (1 << 10)
1412# define IR_RX_ENABLE (1 << 11)
1413# define IR_TX_ENABLE (1 << 12)
1414# define IR_LOOPBACK (1 << 14)
1415# define IR_SIR_MODE (IR_SIR | IR_DMA_ENABLE | \
1416 IR_RX_ALL | IR_RX_ENABLE | IR_SF | IR_16CRC)
1417#define IR_SIR_FLAGS (IRDA_BASE + 0x24)
1418#define IR_ENABLE (IRDA_BASE + 0x28)
1419# define IR_RX_STATUS (1 << 9)
1420# define IR_TX_STATUS (1 << 10)
1421#define IR_READ_PHY_CONFIG (IRDA_BASE + 0x2C)
1422#define IR_WRITE_PHY_CONFIG (IRDA_BASE + 0x30)
1423#define IR_MAX_PKT_LEN (IRDA_BASE + 0x34)
1424#define IR_RX_BYTE_CNT (IRDA_BASE + 0x38)
1425#define IR_CONFIG_2 (IRDA_BASE + 0x3C)
1426# define IR_MODE_INV (1 << 0)
1427# define IR_ONE_PIN (1 << 1)
1428#define IR_INTERFACE_CONFIG (IRDA_BASE + 0x40)
1429
1430/* GPIO */
1431#define SYS_PINFUNC 0xB190002C
1432# define SYS_PF_USB (1 << 15) /* 2nd USB device/host */
1433# define SYS_PF_U3 (1 << 14) /* GPIO23/U3TXD */
1434# define SYS_PF_U2 (1 << 13) /* GPIO22/U2TXD */
1435# define SYS_PF_U1 (1 << 12) /* GPIO21/U1TXD */
1436# define SYS_PF_SRC (1 << 11) /* GPIO6/SROMCKE */
1437# define SYS_PF_CK5 (1 << 10) /* GPIO3/CLK5 */
1438# define SYS_PF_CK4 (1 << 9) /* GPIO2/CLK4 */
1439# define SYS_PF_IRF (1 << 8) /* GPIO15/IRFIRSEL */
1440# define SYS_PF_UR3 (1 << 7) /* GPIO[14:9]/UART3 */
1441# define SYS_PF_I2D (1 << 6) /* GPIO8/I2SDI */
1442# define SYS_PF_I2S (1 << 5) /* I2S/GPIO[29:31] */
1443# define SYS_PF_NI2 (1 << 4) /* NI2/GPIO[24:28] */
1444# define SYS_PF_U0 (1 << 3) /* U0TXD/GPIO20 */
1445# define SYS_PF_RD (1 << 2) /* IRTXD/GPIO19 */
1446# define SYS_PF_A97 (1 << 1) /* AC97/SSL1 */
1447# define SYS_PF_S0 (1 << 0) /* SSI_0/GPIO[16:18] */
1448
1449/* Au1100 only */
1450# define SYS_PF_PC (1 << 18) /* PCMCIA/GPIO[207:204] */
1451# define SYS_PF_LCD (1 << 17) /* extern lcd/GPIO[203:200] */
1452# define SYS_PF_CS (1 << 16) /* EXTCLK0/32KHz to gpio2 */
1453# define SYS_PF_EX0 (1 << 9) /* GPIO2/clock */
1454
1455/* Au1550 only. Redefines lots of pins */
1456# define SYS_PF_PSC2_MASK (7 << 17)
1457# define SYS_PF_PSC2_AC97 0
1458# define SYS_PF_PSC2_SPI 0
1459# define SYS_PF_PSC2_I2S (1 << 17)
1460# define SYS_PF_PSC2_SMBUS (3 << 17)
1461# define SYS_PF_PSC2_GPIO (7 << 17)
1462# define SYS_PF_PSC3_MASK (7 << 20)
1463# define SYS_PF_PSC3_AC97 0
1464# define SYS_PF_PSC3_SPI 0
1465# define SYS_PF_PSC3_I2S (1 << 20)
1466# define SYS_PF_PSC3_SMBUS (3 << 20)
1467# define SYS_PF_PSC3_GPIO (7 << 20)
1468# define SYS_PF_PSC1_S1 (1 << 1)
1469# define SYS_PF_MUST_BE_SET ((1 << 5) | (1 << 2))
1470
1471/* Au1200 only */
1472#ifdef CONFIG_SOC_AU1200
1473#define SYS_PINFUNC_DMA (1 << 31)
1474#define SYS_PINFUNC_S0A (1 << 30)
1475#define SYS_PINFUNC_S1A (1 << 29)
1476#define SYS_PINFUNC_LP0 (1 << 28)
1477#define SYS_PINFUNC_LP1 (1 << 27)
1478#define SYS_PINFUNC_LD16 (1 << 26)
1479#define SYS_PINFUNC_LD8 (1 << 25)
1480#define SYS_PINFUNC_LD1 (1 << 24)
1481#define SYS_PINFUNC_LD0 (1 << 23)
1482#define SYS_PINFUNC_P1A (3 << 21)
1483#define SYS_PINFUNC_P1B (1 << 20)
1484#define SYS_PINFUNC_FS3 (1 << 19)
1485#define SYS_PINFUNC_P0A (3 << 17)
1486#define SYS_PINFUNC_CS (1 << 16)
1487#define SYS_PINFUNC_CIM (1 << 15)
1488#define SYS_PINFUNC_P1C (1 << 14)
1489#define SYS_PINFUNC_U1T (1 << 12)
1490#define SYS_PINFUNC_U1R (1 << 11)
1491#define SYS_PINFUNC_EX1 (1 << 10)
1492#define SYS_PINFUNC_EX0 (1 << 9)
1493#define SYS_PINFUNC_U0R (1 << 8)
1494#define SYS_PINFUNC_MC (1 << 7)
1495#define SYS_PINFUNC_S0B (1 << 6)
1496#define SYS_PINFUNC_S0C (1 << 5)
1497#define SYS_PINFUNC_P0B (1 << 4)
1498#define SYS_PINFUNC_U0T (1 << 3)
1499#define SYS_PINFUNC_S1B (1 << 2)
1500#endif
1501
1502#define SYS_TRIOUTRD 0xB1900100
1503#define SYS_TRIOUTCLR 0xB1900100
1504#define SYS_OUTPUTRD 0xB1900108
1505#define SYS_OUTPUTSET 0xB1900108
1506#define SYS_OUTPUTCLR 0xB190010C
1507#define SYS_PINSTATERD 0xB1900110
1508#define SYS_PININPUTEN 0xB1900110
1509
1510/* GPIO2, Au1500, Au1550 only */
1511#define GPIO2_BASE 0xB1700000
1512#define GPIO2_DIR (GPIO2_BASE + 0)
1513#define GPIO2_OUTPUT (GPIO2_BASE + 8)
1514#define GPIO2_PINSTATE (GPIO2_BASE + 0xC)
1515#define GPIO2_INTENABLE (GPIO2_BASE + 0x10)
1516#define GPIO2_ENABLE (GPIO2_BASE + 0x14)
1517
1518/* Power Management */
1519#define SYS_SCRATCH0 0xB1900018
1520#define SYS_SCRATCH1 0xB190001C
1521#define SYS_WAKEMSK 0xB1900034
1522#define SYS_ENDIAN 0xB1900038
1523#define SYS_POWERCTRL 0xB190003C
1524#define SYS_WAKESRC 0xB190005C
1525#define SYS_SLPPWR 0xB1900078
1526#define SYS_SLEEP 0xB190007C
1527
1528/* Clock Controller */
1529#define SYS_FREQCTRL0 0xB1900020
1530# define SYS_FC_FRDIV2_BIT 22
1531# define SYS_FC_FRDIV2_MASK (0xff << SYS_FC_FRDIV2_BIT)
1532# define SYS_FC_FE2 (1 << 21)
1533# define SYS_FC_FS2 (1 << 20)
1534# define SYS_FC_FRDIV1_BIT 12
1535# define SYS_FC_FRDIV1_MASK (0xff << SYS_FC_FRDIV1_BIT)
1536# define SYS_FC_FE1 (1 << 11)
1537# define SYS_FC_FS1 (1 << 10)
1538# define SYS_FC_FRDIV0_BIT 2
1539# define SYS_FC_FRDIV0_MASK (0xff << SYS_FC_FRDIV0_BIT)
1540# define SYS_FC_FE0 (1 << 1)
1541# define SYS_FC_FS0 (1 << 0)
1542#define SYS_FREQCTRL1 0xB1900024
1543# define SYS_FC_FRDIV5_BIT 22
1544# define SYS_FC_FRDIV5_MASK (0xff << SYS_FC_FRDIV5_BIT)
1545# define SYS_FC_FE5 (1 << 21)
1546# define SYS_FC_FS5 (1 << 20)
1547# define SYS_FC_FRDIV4_BIT 12
1548# define SYS_FC_FRDIV4_MASK (0xff << SYS_FC_FRDIV4_BIT)
1549# define SYS_FC_FE4 (1 << 11)
1550# define SYS_FC_FS4 (1 << 10)
1551# define SYS_FC_FRDIV3_BIT 2
1552# define SYS_FC_FRDIV3_MASK (0xff << SYS_FC_FRDIV3_BIT)
1553# define SYS_FC_FE3 (1 << 1)
1554# define SYS_FC_FS3 (1 << 0)
1555#define SYS_CLKSRC 0xB1900028
1556# define SYS_CS_ME1_BIT 27
1557# define SYS_CS_ME1_MASK (0x7 << SYS_CS_ME1_BIT)
1558# define SYS_CS_DE1 (1 << 26)
1559# define SYS_CS_CE1 (1 << 25)
1560# define SYS_CS_ME0_BIT 22
1561# define SYS_CS_ME0_MASK (0x7 << SYS_CS_ME0_BIT)
1562# define SYS_CS_DE0 (1 << 21)
1563# define SYS_CS_CE0 (1 << 20)
1564# define SYS_CS_MI2_BIT 17
1565# define SYS_CS_MI2_MASK (0x7 << SYS_CS_MI2_BIT)
1566# define SYS_CS_DI2 (1 << 16)
1567# define SYS_CS_CI2 (1 << 15)
1568#ifdef CONFIG_SOC_AU1100
1569# define SYS_CS_ML_BIT 7
1570# define SYS_CS_ML_MASK (0x7 << SYS_CS_ML_BIT)
1571# define SYS_CS_DL (1 << 6)
1572# define SYS_CS_CL (1 << 5)
1573#else
1574# define SYS_CS_MUH_BIT 12
1575# define SYS_CS_MUH_MASK (0x7 << SYS_CS_MUH_BIT)
1576# define SYS_CS_DUH (1 << 11)
1577# define SYS_CS_CUH (1 << 10)
1578# define SYS_CS_MUD_BIT 7
1579# define SYS_CS_MUD_MASK (0x7 << SYS_CS_MUD_BIT)
1580# define SYS_CS_DUD (1 << 6)
1581# define SYS_CS_CUD (1 << 5)
1582#endif
1583# define SYS_CS_MIR_BIT 2
1584# define SYS_CS_MIR_MASK (0x7 << SYS_CS_MIR_BIT)
1585# define SYS_CS_DIR (1 << 1)
1586# define SYS_CS_CIR (1 << 0)
1587
1588# define SYS_CS_MUX_AUX 0x1
1589# define SYS_CS_MUX_FQ0 0x2
1590# define SYS_CS_MUX_FQ1 0x3
1591# define SYS_CS_MUX_FQ2 0x4
1592# define SYS_CS_MUX_FQ3 0x5
1593# define SYS_CS_MUX_FQ4 0x6
1594# define SYS_CS_MUX_FQ5 0x7
1595#define SYS_CPUPLL 0xB1900060
1596#define SYS_AUXPLL 0xB1900064
1597
1598/* AC97 Controller */
1599#define AC97C_CONFIG 0xB0000000
1600# define AC97C_RECV_SLOTS_BIT 13
1601# define AC97C_RECV_SLOTS_MASK (0x3ff << AC97C_RECV_SLOTS_BIT)
1602# define AC97C_XMIT_SLOTS_BIT 3
1603# define AC97C_XMIT_SLOTS_MASK (0x3ff << AC97C_XMIT_SLOTS_BIT)
1604# define AC97C_SG (1 << 2)
1605# define AC97C_SYNC (1 << 1)
1606# define AC97C_RESET (1 << 0)
1607#define AC97C_STATUS 0xB0000004
1608# define AC97C_XU (1 << 11)
1609# define AC97C_XO (1 << 10)
1610# define AC97C_RU (1 << 9)
1611# define AC97C_RO (1 << 8)
1612# define AC97C_READY (1 << 7)
1613# define AC97C_CP (1 << 6)
1614# define AC97C_TR (1 << 5)
1615# define AC97C_TE (1 << 4)
1616# define AC97C_TF (1 << 3)
1617# define AC97C_RR (1 << 2)
1618# define AC97C_RE (1 << 1)
1619# define AC97C_RF (1 << 0)
1620#define AC97C_DATA 0xB0000008
1621#define AC97C_CMD 0xB000000C
1622# define AC97C_WD_BIT 16
1623# define AC97C_READ (1 << 7)
1624# define AC97C_INDEX_MASK 0x7f
1625#define AC97C_CNTRL 0xB0000010
1626# define AC97C_RS (1 << 1)
1627# define AC97C_CE (1 << 0)
1628
1629/* Secure Digital (SD) Controller */
1630#define SD0_XMIT_FIFO 0xB0600000
1631#define SD0_RECV_FIFO 0xB0600004
1632#define SD1_XMIT_FIFO 0xB0680000
1633#define SD1_RECV_FIFO 0xB0680004
1634
1635#if defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550)
1636/* Au1500 PCI Controller */
1637#define Au1500_CFG_BASE 0xB4005000 /* virtual, KSEG1 addr */
1638#define Au1500_PCI_CMEM (Au1500_CFG_BASE + 0)
1639#define Au1500_PCI_CFG (Au1500_CFG_BASE + 4)
1640# define PCI_ERROR ((1 << 22) | (1 << 23) | (1 << 24) | \
1641 (1 << 25) | (1 << 26) | (1 << 27))
1642#define Au1500_PCI_B2BMASK_CCH (Au1500_CFG_BASE + 8)
1643#define Au1500_PCI_B2B0_VID (Au1500_CFG_BASE + 0xC)
1644#define Au1500_PCI_B2B1_ID (Au1500_CFG_BASE + 0x10)
1645#define Au1500_PCI_MWMASK_DEV (Au1500_CFG_BASE + 0x14)
1646#define Au1500_PCI_MWBASE_REV_CCL (Au1500_CFG_BASE + 0x18)
1647#define Au1500_PCI_ERR_ADDR (Au1500_CFG_BASE + 0x1C)
1648#define Au1500_PCI_SPEC_INTACK (Au1500_CFG_BASE + 0x20)
1649#define Au1500_PCI_ID (Au1500_CFG_BASE + 0x100)
1650#define Au1500_PCI_STATCMD (Au1500_CFG_BASE + 0x104)
1651#define Au1500_PCI_CLASSREV (Au1500_CFG_BASE + 0x108)
1652#define Au1500_PCI_HDRTYPE (Au1500_CFG_BASE + 0x10C)
1653#define Au1500_PCI_MBAR (Au1500_CFG_BASE + 0x110)
1654
1655#define Au1500_PCI_HDR 0xB4005100 /* virtual, KSEG1 addr */
1656
1657/*
1658 * All of our structures, like PCI resource, have 32-bit members.
1659 * Drivers are expected to do an ioremap on the PCI MEM resource, but it's
1660 * hard to store 0x4 0000 0000 in a 32-bit type. We require a small patch
1661 * to __ioremap to check for addresses between (u32)Au1500_PCI_MEM_START and
1662 * (u32)Au1500_PCI_MEM_END and change those to the full 36-bit PCI MEM
1663 * addresses. For PCI I/O, it's simpler because we get to do the ioremap
1664 * ourselves and then adjust the device's resources.
1665 */
1666#define Au1500_EXT_CFG 0x600000000ULL
1667#define Au1500_EXT_CFG_TYPE1 0x680000000ULL
1668#define Au1500_PCI_IO_START 0x500000000ULL
1669#define Au1500_PCI_IO_END 0x5000FFFFFULL
1670#define Au1500_PCI_MEM_START 0x440000000ULL
1671#define Au1500_PCI_MEM_END 0x44FFFFFFFULL
1672
1673#define PCI_IO_START 0x00001000
1674#define PCI_IO_END 0x000FFFFF
1675#define PCI_MEM_START 0x40000000
1676#define PCI_MEM_END 0x4FFFFFFF
1677
1678#define PCI_FIRST_DEVFN (0 << 3)
1679#define PCI_LAST_DEVFN (19 << 3)
1680
1681#define IOPORT_RESOURCE_START 0x00001000 /* skip legacy probing */
1682#define IOPORT_RESOURCE_END 0xffffffff
1683#define IOMEM_RESOURCE_START 0x10000000
1684#define IOMEM_RESOURCE_END 0xffffffff
1685
1686#else /* Au1000 and Au1100 and Au1200 */
1687
1688/* Don't allow any legacy ports probing */
1689#define IOPORT_RESOURCE_START 0x10000000
1690#define IOPORT_RESOURCE_END 0xffffffff
1691#define IOMEM_RESOURCE_START 0x10000000
1692#define IOMEM_RESOURCE_END 0xffffffff
1693
1694#define PCI_IO_START 0
1695#define PCI_IO_END 0
1696#define PCI_MEM_START 0
1697#define PCI_MEM_END 0
1698#define PCI_FIRST_DEVFN 0
1699#define PCI_LAST_DEVFN 0
1700
1701#endif
1702
1703#ifndef _LANGUAGE_ASSEMBLY
1704typedef volatile struct {
1705 /* 0x0000 */ u32 toytrim;
1706 /* 0x0004 */ u32 toywrite;
1707 /* 0x0008 */ u32 toymatch0;
1708 /* 0x000C */ u32 toymatch1;
1709 /* 0x0010 */ u32 toymatch2;
1710 /* 0x0014 */ u32 cntrctrl;
1711 /* 0x0018 */ u32 scratch0;
1712 /* 0x001C */ u32 scratch1;
1713 /* 0x0020 */ u32 freqctrl0;
1714 /* 0x0024 */ u32 freqctrl1;
1715 /* 0x0028 */ u32 clksrc;
1716 /* 0x002C */ u32 pinfunc;
1717 /* 0x0030 */ u32 reserved0;
1718 /* 0x0034 */ u32 wakemsk;
1719 /* 0x0038 */ u32 endian;
1720 /* 0x003C */ u32 powerctrl;
1721 /* 0x0040 */ u32 toyread;
1722 /* 0x0044 */ u32 rtctrim;
1723 /* 0x0048 */ u32 rtcwrite;
1724 /* 0x004C */ u32 rtcmatch0;
1725 /* 0x0050 */ u32 rtcmatch1;
1726 /* 0x0054 */ u32 rtcmatch2;
1727 /* 0x0058 */ u32 rtcread;
1728 /* 0x005C */ u32 wakesrc;
1729 /* 0x0060 */ u32 cpupll;
1730 /* 0x0064 */ u32 auxpll;
1731 /* 0x0068 */ u32 reserved1;
1732 /* 0x006C */ u32 reserved2;
1733 /* 0x0070 */ u32 reserved3;
1734 /* 0x0074 */ u32 reserved4;
1735 /* 0x0078 */ u32 slppwr;
1736 /* 0x007C */ u32 sleep;
1737 /* 0x0080 */ u32 reserved5[32];
1738 /* 0x0100 */ u32 trioutrd;
1739#define trioutclr trioutrd
1740 /* 0x0104 */ u32 reserved6;
1741 /* 0x0108 */ u32 outputrd;
1742#define outputset outputrd
1743 /* 0x010C */ u32 outputclr;
1744 /* 0x0110 */ u32 pinstaterd;
1745#define pininputen pinstaterd
1746} AU1X00_SYS;
1747
1748static AU1X00_SYS * const sys = (AU1X00_SYS *)SYS_BASE;
1749
1750#endif
1751
1752/*
1753 * Processor information based on PRID.
1754 * Copied from PowerPC.
1755 */
1756#ifndef _LANGUAGE_ASSEMBLY
1757struct cpu_spec {
1758 /* CPU is matched via (PRID & prid_mask) == prid_value */
1759 unsigned int prid_mask;
1760 unsigned int prid_value;
1761
1762 char *cpu_name;
1763 unsigned char cpu_od; /* Set Config[OD] */
1764 unsigned char cpu_bclk; /* Enable BCLK switching */
1765 unsigned char cpu_pll_wo; /* sys_cpupll reg. write-only */
1766};
1767
1768extern struct cpu_spec cpu_specs[];
1769extern struct cpu_spec *cur_cpu_spec[];
1770#endif
1771
1772#endif
diff --git a/arch/mips/include/asm/mach-au1x00/au1000_dma.h b/arch/mips/include/asm/mach-au1x00/au1000_dma.h
new file mode 100644
index 000000000000..c333b4e1cd44
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1000_dma.h
@@ -0,0 +1,458 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Defines for using and allocating DMA channels on the Alchemy
4 * Au1x00 MIPS processors.
5 *
6 * Copyright 2000, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 *
29 */
30#ifndef __ASM_AU1000_DMA_H
31#define __ASM_AU1000_DMA_H
32
33#include <linux/io.h> /* need byte IO */
34#include <linux/spinlock.h> /* And spinlocks */
35#include <linux/delay.h>
36#include <asm/system.h>
37
38#define NUM_AU1000_DMA_CHANNELS 8
39
40/* DMA Channel Base Addresses */
41#define DMA_CHANNEL_BASE 0xB4002000
42#define DMA_CHANNEL_LEN 0x00000100
43
44/* DMA Channel Register Offsets */
45#define DMA_MODE_SET 0x00000000
46#define DMA_MODE_READ DMA_MODE_SET
47#define DMA_MODE_CLEAR 0x00000004
48/* DMA Mode register bits follow */
49#define DMA_DAH_MASK (0x0f << 20)
50#define DMA_DID_BIT 16
51#define DMA_DID_MASK (0x0f << DMA_DID_BIT)
52#define DMA_DS (1 << 15)
53#define DMA_BE (1 << 13)
54#define DMA_DR (1 << 12)
55#define DMA_TS8 (1 << 11)
56#define DMA_DW_BIT 9
57#define DMA_DW_MASK (0x03 << DMA_DW_BIT)
58#define DMA_DW8 (0 << DMA_DW_BIT)
59#define DMA_DW16 (1 << DMA_DW_BIT)
60#define DMA_DW32 (2 << DMA_DW_BIT)
61#define DMA_NC (1 << 8)
62#define DMA_IE (1 << 7)
63#define DMA_HALT (1 << 6)
64#define DMA_GO (1 << 5)
65#define DMA_AB (1 << 4)
66#define DMA_D1 (1 << 3)
67#define DMA_BE1 (1 << 2)
68#define DMA_D0 (1 << 1)
69#define DMA_BE0 (1 << 0)
70
71#define DMA_PERIPHERAL_ADDR 0x00000008
72#define DMA_BUFFER0_START 0x0000000C
73#define DMA_BUFFER1_START 0x00000014
74#define DMA_BUFFER0_COUNT 0x00000010
75#define DMA_BUFFER1_COUNT 0x00000018
76#define DMA_BAH_BIT 16
77#define DMA_BAH_MASK (0x0f << DMA_BAH_BIT)
78#define DMA_COUNT_BIT 0
79#define DMA_COUNT_MASK (0xffff << DMA_COUNT_BIT)
80
81/* DMA Device IDs follow */
82enum {
83 DMA_ID_UART0_TX = 0,
84 DMA_ID_UART0_RX,
85 DMA_ID_GP04,
86 DMA_ID_GP05,
87 DMA_ID_AC97C_TX,
88 DMA_ID_AC97C_RX,
89 DMA_ID_UART3_TX,
90 DMA_ID_UART3_RX,
91 DMA_ID_USBDEV_EP0_RX,
92 DMA_ID_USBDEV_EP0_TX,
93 DMA_ID_USBDEV_EP2_TX,
94 DMA_ID_USBDEV_EP3_TX,
95 DMA_ID_USBDEV_EP4_RX,
96 DMA_ID_USBDEV_EP5_RX,
97 DMA_ID_I2S_TX,
98 DMA_ID_I2S_RX,
99 DMA_NUM_DEV
100};
101
102/* DMA Device ID's for 2nd bank (AU1100) follow */
103enum {
104 DMA_ID_SD0_TX = 0,
105 DMA_ID_SD0_RX,
106 DMA_ID_SD1_TX,
107 DMA_ID_SD1_RX,
108 DMA_NUM_DEV_BANK2
109};
110
111struct dma_chan {
112 int dev_id; /* this channel is allocated if >= 0, */
113 /* free otherwise */
114 unsigned int io;
115 const char *dev_str;
116 int irq;
117 void *irq_dev;
118 unsigned int fifo_addr;
119 unsigned int mode;
120};
121
122/* These are in arch/mips/au1000/common/dma.c */
123extern struct dma_chan au1000_dma_table[];
124extern int request_au1000_dma(int dev_id,
125 const char *dev_str,
126 irq_handler_t irqhandler,
127 unsigned long irqflags,
128 void *irq_dev_id);
129extern void free_au1000_dma(unsigned int dmanr);
130extern int au1000_dma_read_proc(char *buf, char **start, off_t fpos,
131 int length, int *eof, void *data);
132extern void dump_au1000_dma_channel(unsigned int dmanr);
133extern spinlock_t au1000_dma_spin_lock;
134
135static inline struct dma_chan *get_dma_chan(unsigned int dmanr)
136{
137 if (dmanr >= NUM_AU1000_DMA_CHANNELS ||
138 au1000_dma_table[dmanr].dev_id < 0)
139 return NULL;
140 return &au1000_dma_table[dmanr];
141}
142
143static inline unsigned long claim_dma_lock(void)
144{
145 unsigned long flags;
146
147 spin_lock_irqsave(&au1000_dma_spin_lock, flags);
148 return flags;
149}
150
151static inline void release_dma_lock(unsigned long flags)
152{
153 spin_unlock_irqrestore(&au1000_dma_spin_lock, flags);
154}
155
156/*
157 * Set the DMA buffer enable bits in the mode register.
158 */
159static inline void enable_dma_buffer0(unsigned int dmanr)
160{
161 struct dma_chan *chan = get_dma_chan(dmanr);
162
163 if (!chan)
164 return;
165 au_writel(DMA_BE0, chan->io + DMA_MODE_SET);
166}
167
168static inline void enable_dma_buffer1(unsigned int dmanr)
169{
170 struct dma_chan *chan = get_dma_chan(dmanr);
171
172 if (!chan)
173 return;
174 au_writel(DMA_BE1, chan->io + DMA_MODE_SET);
175}
176static inline void enable_dma_buffers(unsigned int dmanr)
177{
178 struct dma_chan *chan = get_dma_chan(dmanr);
179
180 if (!chan)
181 return;
182 au_writel(DMA_BE0 | DMA_BE1, chan->io + DMA_MODE_SET);
183}
184
185static inline void start_dma(unsigned int dmanr)
186{
187 struct dma_chan *chan = get_dma_chan(dmanr);
188
189 if (!chan)
190 return;
191 au_writel(DMA_GO, chan->io + DMA_MODE_SET);
192}
193
194#define DMA_HALT_POLL 0x5000
195
196static inline void halt_dma(unsigned int dmanr)
197{
198 struct dma_chan *chan = get_dma_chan(dmanr);
199 int i;
200
201 if (!chan)
202 return;
203 au_writel(DMA_GO, chan->io + DMA_MODE_CLEAR);
204
205 /* Poll the halt bit */
206 for (i = 0; i < DMA_HALT_POLL; i++)
207 if (au_readl(chan->io + DMA_MODE_READ) & DMA_HALT)
208 break;
209 if (i == DMA_HALT_POLL)
210 printk(KERN_INFO "halt_dma: HALT poll expired!\n");
211}
212
213static inline void disable_dma(unsigned int dmanr)
214{
215 struct dma_chan *chan = get_dma_chan(dmanr);
216
217 if (!chan)
218 return;
219
220 halt_dma(dmanr);
221
222 /* Now we can disable the buffers */
223 au_writel(~DMA_GO, chan->io + DMA_MODE_CLEAR);
224}
225
226static inline int dma_halted(unsigned int dmanr)
227{
228 struct dma_chan *chan = get_dma_chan(dmanr);
229
230 if (!chan)
231 return 1;
232 return (au_readl(chan->io + DMA_MODE_READ) & DMA_HALT) ? 1 : 0;
233}
234
235/* Initialize a DMA channel. */
236static inline void init_dma(unsigned int dmanr)
237{
238 struct dma_chan *chan = get_dma_chan(dmanr);
239 u32 mode;
240
241 if (!chan)
242 return;
243
244 disable_dma(dmanr);
245
246 /* Set device FIFO address */
247 au_writel(CPHYSADDR(chan->fifo_addr), chan->io + DMA_PERIPHERAL_ADDR);
248
249 mode = chan->mode | (chan->dev_id << DMA_DID_BIT);
250 if (chan->irq)
251 mode |= DMA_IE;
252
253 au_writel(~mode, chan->io + DMA_MODE_CLEAR);
254 au_writel(mode, chan->io + DMA_MODE_SET);
255}
256
257/*
258 * Set mode for a specific DMA channel
259 */
260static inline void set_dma_mode(unsigned int dmanr, unsigned int mode)
261{
262 struct dma_chan *chan = get_dma_chan(dmanr);
263
264 if (!chan)
265 return;
266 /*
267 * set_dma_mode is only allowed to change endianess, direction,
268 * transfer size, device FIFO width, and coherency settings.
269 * Make sure anything else is masked off.
270 */
271 mode &= (DMA_BE | DMA_DR | DMA_TS8 | DMA_DW_MASK | DMA_NC);
272 chan->mode &= ~(DMA_BE | DMA_DR | DMA_TS8 | DMA_DW_MASK | DMA_NC);
273 chan->mode |= mode;
274}
275
276static inline unsigned int get_dma_mode(unsigned int dmanr)
277{
278 struct dma_chan *chan = get_dma_chan(dmanr);
279
280 if (!chan)
281 return 0;
282 return chan->mode;
283}
284
285static inline int get_dma_active_buffer(unsigned int dmanr)
286{
287 struct dma_chan *chan = get_dma_chan(dmanr);
288
289 if (!chan)
290 return -1;
291 return (au_readl(chan->io + DMA_MODE_READ) & DMA_AB) ? 1 : 0;
292}
293
294/*
295 * Set the device FIFO address for a specific DMA channel - only
296 * applicable to GPO4 and GPO5. All the other devices have fixed
297 * FIFO addresses.
298 */
299static inline void set_dma_fifo_addr(unsigned int dmanr, unsigned int a)
300{
301 struct dma_chan *chan = get_dma_chan(dmanr);
302
303 if (!chan)
304 return;
305
306 if (chan->mode & DMA_DS) /* second bank of device IDs */
307 return;
308
309 if (chan->dev_id != DMA_ID_GP04 && chan->dev_id != DMA_ID_GP05)
310 return;
311
312 au_writel(CPHYSADDR(a), chan->io + DMA_PERIPHERAL_ADDR);
313}
314
315/*
316 * Clear the DMA buffer done bits in the mode register.
317 */
318static inline void clear_dma_done0(unsigned int dmanr)
319{
320 struct dma_chan *chan = get_dma_chan(dmanr);
321
322 if (!chan)
323 return;
324 au_writel(DMA_D0, chan->io + DMA_MODE_CLEAR);
325}
326
327static inline void clear_dma_done1(unsigned int dmanr)
328{
329 struct dma_chan *chan = get_dma_chan(dmanr);
330
331 if (!chan)
332 return;
333 au_writel(DMA_D1, chan->io + DMA_MODE_CLEAR);
334}
335
336/*
337 * This does nothing - not applicable to Au1000 DMA.
338 */
339static inline void set_dma_page(unsigned int dmanr, char pagenr)
340{
341}
342
343/*
344 * Set Buffer 0 transfer address for specific DMA channel.
345 */
346static inline void set_dma_addr0(unsigned int dmanr, unsigned int a)
347{
348 struct dma_chan *chan = get_dma_chan(dmanr);
349
350 if (!chan)
351 return;
352 au_writel(a, chan->io + DMA_BUFFER0_START);
353}
354
355/*
356 * Set Buffer 1 transfer address for specific DMA channel.
357 */
358static inline void set_dma_addr1(unsigned int dmanr, unsigned int a)
359{
360 struct dma_chan *chan = get_dma_chan(dmanr);
361
362 if (!chan)
363 return;
364 au_writel(a, chan->io + DMA_BUFFER1_START);
365}
366
367
368/*
369 * Set Buffer 0 transfer size (max 64k) for a specific DMA channel.
370 */
371static inline void set_dma_count0(unsigned int dmanr, unsigned int count)
372{
373 struct dma_chan *chan = get_dma_chan(dmanr);
374
375 if (!chan)
376 return;
377 count &= DMA_COUNT_MASK;
378 au_writel(count, chan->io + DMA_BUFFER0_COUNT);
379}
380
381/*
382 * Set Buffer 1 transfer size (max 64k) for a specific DMA channel.
383 */
384static inline void set_dma_count1(unsigned int dmanr, unsigned int count)
385{
386 struct dma_chan *chan = get_dma_chan(dmanr);
387
388 if (!chan)
389 return;
390 count &= DMA_COUNT_MASK;
391 au_writel(count, chan->io + DMA_BUFFER1_COUNT);
392}
393
394/*
395 * Set both buffer transfer sizes (max 64k) for a specific DMA channel.
396 */
397static inline void set_dma_count(unsigned int dmanr, unsigned int count)
398{
399 struct dma_chan *chan = get_dma_chan(dmanr);
400
401 if (!chan)
402 return;
403 count &= DMA_COUNT_MASK;
404 au_writel(count, chan->io + DMA_BUFFER0_COUNT);
405 au_writel(count, chan->io + DMA_BUFFER1_COUNT);
406}
407
408/*
409 * Returns which buffer has its done bit set in the mode register.
410 * Returns -1 if neither or both done bits set.
411 */
412static inline unsigned int get_dma_buffer_done(unsigned int dmanr)
413{
414 struct dma_chan *chan = get_dma_chan(dmanr);
415
416 if (!chan)
417 return 0;
418 return au_readl(chan->io + DMA_MODE_READ) & (DMA_D0 | DMA_D1);
419}
420
421
422/*
423 * Returns the DMA channel's Buffer Done IRQ number.
424 */
425static inline int get_dma_done_irq(unsigned int dmanr)
426{
427 struct dma_chan *chan = get_dma_chan(dmanr);
428
429 if (!chan)
430 return -1;
431 return chan->irq;
432}
433
434/*
435 * Get DMA residue count. Returns the number of _bytes_ left to transfer.
436 */
437static inline int get_dma_residue(unsigned int dmanr)
438{
439 int curBufCntReg, count;
440 struct dma_chan *chan = get_dma_chan(dmanr);
441
442 if (!chan)
443 return 0;
444
445 curBufCntReg = (au_readl(chan->io + DMA_MODE_READ) & DMA_AB) ?
446 DMA_BUFFER1_COUNT : DMA_BUFFER0_COUNT;
447
448 count = au_readl(chan->io + curBufCntReg) & DMA_COUNT_MASK;
449
450 if ((chan->mode & DMA_DW_MASK) == DMA_DW16)
451 count <<= 1;
452 else if ((chan->mode & DMA_DW_MASK) == DMA_DW32)
453 count <<= 2;
454
455 return count;
456}
457
458#endif /* __ASM_AU1000_DMA_H */
diff --git a/arch/mips/include/asm/mach-au1x00/au1000_gpio.h b/arch/mips/include/asm/mach-au1x00/au1000_gpio.h
new file mode 100644
index 000000000000..d8c96fda5549
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1000_gpio.h
@@ -0,0 +1,56 @@
1/*
2 * FILE NAME au1000_gpio.h
3 *
4 * BRIEF MODULE DESCRIPTION
5 * API to Alchemy Au1xx0 GPIO device.
6 *
7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * Steve Longerbeam
9 *
10 * Copyright 2001, 2008 MontaVista Software Inc.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 */
32
33#ifndef __AU1000_GPIO_H
34#define __AU1000_GPIO_H
35
36#include <linux/ioctl.h>
37
38#define AU1000GPIO_IOC_MAGIC 'A'
39
40#define AU1000GPIO_IN _IOR(AU1000GPIO_IOC_MAGIC, 0, int)
41#define AU1000GPIO_SET _IOW(AU1000GPIO_IOC_MAGIC, 1, int)
42#define AU1000GPIO_CLEAR _IOW(AU1000GPIO_IOC_MAGIC, 2, int)
43#define AU1000GPIO_OUT _IOW(AU1000GPIO_IOC_MAGIC, 3, int)
44#define AU1000GPIO_TRISTATE _IOW(AU1000GPIO_IOC_MAGIC, 4, int)
45#define AU1000GPIO_AVAIL_MASK _IOR(AU1000GPIO_IOC_MAGIC, 5, int)
46
47#ifdef __KERNEL__
48extern u32 get_au1000_avail_gpio_mask(void);
49extern int au1000gpio_tristate(u32 data);
50extern int au1000gpio_in(u32 *data);
51extern int au1000gpio_set(u32 data);
52extern int au1000gpio_clear(u32 data);
53extern int au1000gpio_out(u32 data);
54#endif
55
56#endif
diff --git a/arch/mips/include/asm/mach-au1x00/au1100_mmc.h b/arch/mips/include/asm/mach-au1x00/au1100_mmc.h
new file mode 100644
index 000000000000..c35e20918490
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1100_mmc.h
@@ -0,0 +1,208 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Defines for using the MMC/SD controllers on the
4 * Alchemy Au1100 mips processor.
5 *
6 * Copyright (c) 2003 Embedded Edge, LLC.
7 * Author: Embedded Edge, LLC.
8 * dan@embeddededge.com or tim@embeddededge.com
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 *
30 */
31/*
32 * AU1100 MMC/SD definitions.
33 *
34 * From "AMD Alchemy Solutions Au1100 Processor Data Book - Preliminary"
35 * June, 2003
36 */
37
38#ifndef __ASM_AU1100_MMC_H
39#define __ASM_AU1100_MMC_H
40
41#include <linux/leds.h>
42
43struct au1xmmc_platform_data {
44 int(*cd_setup)(void *mmc_host, int on);
45 int(*card_inserted)(void *mmc_host);
46 int(*card_readonly)(void *mmc_host);
47 void(*set_power)(void *mmc_host, int state);
48 struct led_classdev *led;
49};
50
51#define SD0_BASE 0xB0600000
52#define SD1_BASE 0xB0680000
53
54
55/*
56 * Register offsets.
57 */
58#define SD_TXPORT (0x0000)
59#define SD_RXPORT (0x0004)
60#define SD_CONFIG (0x0008)
61#define SD_ENABLE (0x000C)
62#define SD_CONFIG2 (0x0010)
63#define SD_BLKSIZE (0x0014)
64#define SD_STATUS (0x0018)
65#define SD_DEBUG (0x001C)
66#define SD_CMD (0x0020)
67#define SD_CMDARG (0x0024)
68#define SD_RESP3 (0x0028)
69#define SD_RESP2 (0x002C)
70#define SD_RESP1 (0x0030)
71#define SD_RESP0 (0x0034)
72#define SD_TIMEOUT (0x0038)
73
74
75/*
76 * SD_TXPORT bit definitions.
77 */
78#define SD_TXPORT_TXD (0x000000ff)
79
80
81/*
82 * SD_RXPORT bit definitions.
83 */
84#define SD_RXPORT_RXD (0x000000ff)
85
86
87/*
88 * SD_CONFIG bit definitions.
89 */
90#define SD_CONFIG_DIV (0x000001ff)
91#define SD_CONFIG_DE (0x00000200)
92#define SD_CONFIG_NE (0x00000400)
93#define SD_CONFIG_TU (0x00000800)
94#define SD_CONFIG_TO (0x00001000)
95#define SD_CONFIG_RU (0x00002000)
96#define SD_CONFIG_RO (0x00004000)
97#define SD_CONFIG_I (0x00008000)
98#define SD_CONFIG_CR (0x00010000)
99#define SD_CONFIG_RAT (0x00020000)
100#define SD_CONFIG_DD (0x00040000)
101#define SD_CONFIG_DT (0x00080000)
102#define SD_CONFIG_SC (0x00100000)
103#define SD_CONFIG_RC (0x00200000)
104#define SD_CONFIG_WC (0x00400000)
105#define SD_CONFIG_xxx (0x00800000)
106#define SD_CONFIG_TH (0x01000000)
107#define SD_CONFIG_TE (0x02000000)
108#define SD_CONFIG_TA (0x04000000)
109#define SD_CONFIG_RH (0x08000000)
110#define SD_CONFIG_RA (0x10000000)
111#define SD_CONFIG_RF (0x20000000)
112#define SD_CONFIG_CD (0x40000000)
113#define SD_CONFIG_SI (0x80000000)
114
115
116/*
117 * SD_ENABLE bit definitions.
118 */
119#define SD_ENABLE_CE (0x00000001)
120#define SD_ENABLE_R (0x00000002)
121
122
123/*
124 * SD_CONFIG2 bit definitions.
125 */
126#define SD_CONFIG2_EN (0x00000001)
127#define SD_CONFIG2_FF (0x00000002)
128#define SD_CONFIG2_xx1 (0x00000004)
129#define SD_CONFIG2_DF (0x00000008)
130#define SD_CONFIG2_DC (0x00000010)
131#define SD_CONFIG2_xx2 (0x000000e0)
132#define SD_CONFIG2_WB (0x00000100)
133#define SD_CONFIG2_RW (0x00000200)
134
135
136/*
137 * SD_BLKSIZE bit definitions.
138 */
139#define SD_BLKSIZE_BS (0x000007ff)
140#define SD_BLKSIZE_BS_SHIFT (0)
141#define SD_BLKSIZE_BC (0x01ff0000)
142#define SD_BLKSIZE_BC_SHIFT (16)
143
144
145/*
146 * SD_STATUS bit definitions.
147 */
148#define SD_STATUS_DCRCW (0x00000007)
149#define SD_STATUS_xx1 (0x00000008)
150#define SD_STATUS_CB (0x00000010)
151#define SD_STATUS_DB (0x00000020)
152#define SD_STATUS_CF (0x00000040)
153#define SD_STATUS_D3 (0x00000080)
154#define SD_STATUS_xx2 (0x00000300)
155#define SD_STATUS_NE (0x00000400)
156#define SD_STATUS_TU (0x00000800)
157#define SD_STATUS_TO (0x00001000)
158#define SD_STATUS_RU (0x00002000)
159#define SD_STATUS_RO (0x00004000)
160#define SD_STATUS_I (0x00008000)
161#define SD_STATUS_CR (0x00010000)
162#define SD_STATUS_RAT (0x00020000)
163#define SD_STATUS_DD (0x00040000)
164#define SD_STATUS_DT (0x00080000)
165#define SD_STATUS_SC (0x00100000)
166#define SD_STATUS_RC (0x00200000)
167#define SD_STATUS_WC (0x00400000)
168#define SD_STATUS_xx3 (0x00800000)
169#define SD_STATUS_TH (0x01000000)
170#define SD_STATUS_TE (0x02000000)
171#define SD_STATUS_TA (0x04000000)
172#define SD_STATUS_RH (0x08000000)
173#define SD_STATUS_RA (0x10000000)
174#define SD_STATUS_RF (0x20000000)
175#define SD_STATUS_CD (0x40000000)
176#define SD_STATUS_SI (0x80000000)
177
178
179/*
180 * SD_CMD bit definitions.
181 */
182#define SD_CMD_GO (0x00000001)
183#define SD_CMD_RY (0x00000002)
184#define SD_CMD_xx1 (0x0000000c)
185#define SD_CMD_CT_MASK (0x000000f0)
186#define SD_CMD_CT_0 (0x00000000)
187#define SD_CMD_CT_1 (0x00000010)
188#define SD_CMD_CT_2 (0x00000020)
189#define SD_CMD_CT_3 (0x00000030)
190#define SD_CMD_CT_4 (0x00000040)
191#define SD_CMD_CT_5 (0x00000050)
192#define SD_CMD_CT_6 (0x00000060)
193#define SD_CMD_CT_7 (0x00000070)
194#define SD_CMD_CI (0x0000ff00)
195#define SD_CMD_CI_SHIFT (8)
196#define SD_CMD_RT_MASK (0x00ff0000)
197#define SD_CMD_RT_0 (0x00000000)
198#define SD_CMD_RT_1 (0x00010000)
199#define SD_CMD_RT_2 (0x00020000)
200#define SD_CMD_RT_3 (0x00030000)
201#define SD_CMD_RT_4 (0x00040000)
202#define SD_CMD_RT_5 (0x00050000)
203#define SD_CMD_RT_6 (0x00060000)
204#define SD_CMD_RT_1B (0x00810000)
205
206
207#endif /* __ASM_AU1100_MMC_H */
208
diff --git a/arch/mips/include/asm/mach-au1x00/au1550_spi.h b/arch/mips/include/asm/mach-au1x00/au1550_spi.h
new file mode 100644
index 000000000000..08e1958e9410
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1550_spi.h
@@ -0,0 +1,15 @@
1/*
2 * au1550_spi.h - Au1550 PSC SPI controller driver - platform data structure
3 */
4
5#ifndef _AU1550_SPI_H_
6#define _AU1550_SPI_H_
7
8struct au1550_spi_info {
9 u32 mainclk_hz; /* main input clock frequency of PSC */
10 u16 num_chipselect; /* number of chipselects supported */
11 void (*activate_cs)(struct au1550_spi_info *spi, int cs, int polarity);
12 void (*deactivate_cs)(struct au1550_spi_info *spi, int cs, int polarity);
13};
14
15#endif
diff --git a/arch/mips/include/asm/mach-au1x00/au1xxx.h b/arch/mips/include/asm/mach-au1x00/au1xxx.h
new file mode 100644
index 000000000000..1b3655090ed3
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1xxx.h
@@ -0,0 +1,43 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
8 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
10 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
12 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
13 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
14 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
16 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#ifndef _AU1XXX_H_
24#define _AU1XXX_H_
25
26#include <asm/mach-au1x00/au1000.h>
27
28#if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || \
29 defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550)
30#include <asm/mach-db1x00/db1x00.h>
31
32#elif defined(CONFIG_MIPS_PB1550)
33#include <asm/mach-pb1x00/pb1550.h>
34
35#elif defined(CONFIG_MIPS_PB1200)
36#include <asm/mach-pb1x00/pb1200.h>
37
38#elif defined(CONFIG_MIPS_DB1200)
39#include <asm/mach-db1x00/db1200.h>
40
41#endif
42
43#endif /* _AU1XXX_H_ */
diff --git a/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h b/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h
new file mode 100644
index 000000000000..44a67bf05dc1
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h
@@ -0,0 +1,386 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Include file for Alchemy Semiconductor's Au1550 Descriptor
5 * Based DMA Controller.
6 *
7 * Copyright 2004 Embedded Edge, LLC
8 * dan@embeddededge.com
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */
30
31/*
32 * Specifics for the Au1xxx Descriptor-Based DMA Controller,
33 * first seen in the AU1550 part.
34 */
35#ifndef _AU1000_DBDMA_H_
36#define _AU1000_DBDMA_H_
37
38#ifndef _LANGUAGE_ASSEMBLY
39
40/*
41 * The DMA base addresses.
42 * The channels are every 256 bytes (0x0100) from the channel 0 base.
43 * Interrupt status/enable is bits 15:0 for channels 15 to zero.
44 */
45#define DDMA_GLOBAL_BASE 0xb4003000
46#define DDMA_CHANNEL_BASE 0xb4002000
47
48typedef volatile struct dbdma_global {
49 u32 ddma_config;
50 u32 ddma_intstat;
51 u32 ddma_throttle;
52 u32 ddma_inten;
53} dbdma_global_t;
54
55/* General Configuration. */
56#define DDMA_CONFIG_AF (1 << 2)
57#define DDMA_CONFIG_AH (1 << 1)
58#define DDMA_CONFIG_AL (1 << 0)
59
60#define DDMA_THROTTLE_EN (1 << 31)
61
62/* The structure of a DMA Channel. */
63typedef volatile struct au1xxx_dma_channel {
64 u32 ddma_cfg; /* See below */
65 u32 ddma_desptr; /* 32-byte aligned pointer to descriptor */
66 u32 ddma_statptr; /* word aligned pointer to status word */
67 u32 ddma_dbell; /* A write activates channel operation */
68 u32 ddma_irq; /* If bit 0 set, interrupt pending */
69 u32 ddma_stat; /* See below */
70 u32 ddma_bytecnt; /* Byte count, valid only when chan idle */
71 /* Remainder, up to the 256 byte boundary, is reserved. */
72} au1x_dma_chan_t;
73
74#define DDMA_CFG_SED (1 << 9) /* source DMA level/edge detect */
75#define DDMA_CFG_SP (1 << 8) /* source DMA polarity */
76#define DDMA_CFG_DED (1 << 7) /* destination DMA level/edge detect */
77#define DDMA_CFG_DP (1 << 6) /* destination DMA polarity */
78#define DDMA_CFG_SYNC (1 << 5) /* Sync static bus controller */
79#define DDMA_CFG_PPR (1 << 4) /* PCI posted read/write control */
80#define DDMA_CFG_DFN (1 << 3) /* Descriptor fetch non-coherent */
81#define DDMA_CFG_SBE (1 << 2) /* Source big endian */
82#define DDMA_CFG_DBE (1 << 1) /* Destination big endian */
83#define DDMA_CFG_EN (1 << 0) /* Channel enable */
84
85/*
86 * Always set when descriptor processing done, regardless of
87 * interrupt enable state. Reflected in global intstat, don't
88 * clear this until global intstat is read/used.
89 */
90#define DDMA_IRQ_IN (1 << 0)
91
92#define DDMA_STAT_DB (1 << 2) /* Doorbell pushed */
93#define DDMA_STAT_V (1 << 1) /* Descriptor valid */
94#define DDMA_STAT_H (1 << 0) /* Channel Halted */
95
96/*
97 * "Standard" DDMA Descriptor.
98 * Must be 32-byte aligned.
99 */
100typedef volatile struct au1xxx_ddma_desc {
101 u32 dscr_cmd0; /* See below */
102 u32 dscr_cmd1; /* See below */
103 u32 dscr_source0; /* source phys address */
104 u32 dscr_source1; /* See below */
105 u32 dscr_dest0; /* Destination address */
106 u32 dscr_dest1; /* See below */
107 u32 dscr_stat; /* completion status */
108 u32 dscr_nxtptr; /* Next descriptor pointer (mostly) */
109 /*
110 * First 32 bytes are HW specific!!!
111 * Lets have some SW data following -- make sure it's 32 bytes.
112 */
113 u32 sw_status;
114 u32 sw_context;
115 u32 sw_reserved[6];
116} au1x_ddma_desc_t;
117
118#define DSCR_CMD0_V (1 << 31) /* Descriptor valid */
119#define DSCR_CMD0_MEM (1 << 30) /* mem-mem transfer */
120#define DSCR_CMD0_SID_MASK (0x1f << 25) /* Source ID */
121#define DSCR_CMD0_DID_MASK (0x1f << 20) /* Destination ID */
122#define DSCR_CMD0_SW_MASK (0x3 << 18) /* Source Width */
123#define DSCR_CMD0_DW_MASK (0x3 << 16) /* Destination Width */
124#define DSCR_CMD0_ARB (0x1 << 15) /* Set for Hi Pri */
125#define DSCR_CMD0_DT_MASK (0x3 << 13) /* Descriptor Type */
126#define DSCR_CMD0_SN (0x1 << 12) /* Source non-coherent */
127#define DSCR_CMD0_DN (0x1 << 11) /* Destination non-coherent */
128#define DSCR_CMD0_SM (0x1 << 10) /* Stride mode */
129#define DSCR_CMD0_IE (0x1 << 8) /* Interrupt Enable */
130#define DSCR_CMD0_SP (0x1 << 4) /* Status pointer select */
131#define DSCR_CMD0_CV (0x1 << 2) /* Clear Valid when done */
132#define DSCR_CMD0_ST_MASK (0x3 << 0) /* Status instruction */
133
134#define SW_STATUS_INUSE (1 << 0)
135
136/* Command 0 device IDs. */
137#ifdef CONFIG_SOC_AU1550
138#define DSCR_CMD0_UART0_TX 0
139#define DSCR_CMD0_UART0_RX 1
140#define DSCR_CMD0_UART3_TX 2
141#define DSCR_CMD0_UART3_RX 3
142#define DSCR_CMD0_DMA_REQ0 4
143#define DSCR_CMD0_DMA_REQ1 5
144#define DSCR_CMD0_DMA_REQ2 6
145#define DSCR_CMD0_DMA_REQ3 7
146#define DSCR_CMD0_USBDEV_RX0 8
147#define DSCR_CMD0_USBDEV_TX0 9
148#define DSCR_CMD0_USBDEV_TX1 10
149#define DSCR_CMD0_USBDEV_TX2 11
150#define DSCR_CMD0_USBDEV_RX3 12
151#define DSCR_CMD0_USBDEV_RX4 13
152#define DSCR_CMD0_PSC0_TX 14
153#define DSCR_CMD0_PSC0_RX 15
154#define DSCR_CMD0_PSC1_TX 16
155#define DSCR_CMD0_PSC1_RX 17
156#define DSCR_CMD0_PSC2_TX 18
157#define DSCR_CMD0_PSC2_RX 19
158#define DSCR_CMD0_PSC3_TX 20
159#define DSCR_CMD0_PSC3_RX 21
160#define DSCR_CMD0_PCI_WRITE 22
161#define DSCR_CMD0_NAND_FLASH 23
162#define DSCR_CMD0_MAC0_RX 24
163#define DSCR_CMD0_MAC0_TX 25
164#define DSCR_CMD0_MAC1_RX 26
165#define DSCR_CMD0_MAC1_TX 27
166#endif /* CONFIG_SOC_AU1550 */
167
168#ifdef CONFIG_SOC_AU1200
169#define DSCR_CMD0_UART0_TX 0
170#define DSCR_CMD0_UART0_RX 1
171#define DSCR_CMD0_UART1_TX 2
172#define DSCR_CMD0_UART1_RX 3
173#define DSCR_CMD0_DMA_REQ0 4
174#define DSCR_CMD0_DMA_REQ1 5
175#define DSCR_CMD0_MAE_BE 6
176#define DSCR_CMD0_MAE_FE 7
177#define DSCR_CMD0_SDMS_TX0 8
178#define DSCR_CMD0_SDMS_RX0 9
179#define DSCR_CMD0_SDMS_TX1 10
180#define DSCR_CMD0_SDMS_RX1 11
181#define DSCR_CMD0_AES_TX 13
182#define DSCR_CMD0_AES_RX 12
183#define DSCR_CMD0_PSC0_TX 14
184#define DSCR_CMD0_PSC0_RX 15
185#define DSCR_CMD0_PSC1_TX 16
186#define DSCR_CMD0_PSC1_RX 17
187#define DSCR_CMD0_CIM_RXA 18
188#define DSCR_CMD0_CIM_RXB 19
189#define DSCR_CMD0_CIM_RXC 20
190#define DSCR_CMD0_MAE_BOTH 21
191#define DSCR_CMD0_LCD 22
192#define DSCR_CMD0_NAND_FLASH 23
193#define DSCR_CMD0_PSC0_SYNC 24
194#define DSCR_CMD0_PSC1_SYNC 25
195#define DSCR_CMD0_CIM_SYNC 26
196#endif /* CONFIG_SOC_AU1200 */
197
198#define DSCR_CMD0_THROTTLE 30
199#define DSCR_CMD0_ALWAYS 31
200#define DSCR_NDEV_IDS 32
201/* This macro is used to find/create custom device types */
202#define DSCR_DEV2CUSTOM_ID(x, d) (((((x) & 0xFFFF) << 8) | 0x32000000) | \
203 ((d) & 0xFF))
204#define DSCR_CUSTOM2DEV_ID(x) ((x) & 0xFF)
205
206#define DSCR_CMD0_SID(x) (((x) & 0x1f) << 25)
207#define DSCR_CMD0_DID(x) (((x) & 0x1f) << 20)
208
209/* Source/Destination transfer width. */
210#define DSCR_CMD0_BYTE 0
211#define DSCR_CMD0_HALFWORD 1
212#define DSCR_CMD0_WORD 2
213
214#define DSCR_CMD0_SW(x) (((x) & 0x3) << 18)
215#define DSCR_CMD0_DW(x) (((x) & 0x3) << 16)
216
217/* DDMA Descriptor Type. */
218#define DSCR_CMD0_STANDARD 0
219#define DSCR_CMD0_LITERAL 1
220#define DSCR_CMD0_CMP_BRANCH 2
221
222#define DSCR_CMD0_DT(x) (((x) & 0x3) << 13)
223
224/* Status Instruction. */
225#define DSCR_CMD0_ST_NOCHANGE 0 /* Don't change */
226#define DSCR_CMD0_ST_CURRENT 1 /* Write current status */
227#define DSCR_CMD0_ST_CMD0 2 /* Write cmd0 with V cleared */
228#define DSCR_CMD0_ST_BYTECNT 3 /* Write remaining byte count */
229
230#define DSCR_CMD0_ST(x) (((x) & 0x3) << 0)
231
232/* Descriptor Command 1. */
233#define DSCR_CMD1_SUPTR_MASK (0xf << 28) /* upper 4 bits of src addr */
234#define DSCR_CMD1_DUPTR_MASK (0xf << 24) /* upper 4 bits of dest addr */
235#define DSCR_CMD1_FL_MASK (0x3 << 22) /* Flag bits */
236#define DSCR_CMD1_BC_MASK (0x3fffff) /* Byte count */
237
238/* Flag description. */
239#define DSCR_CMD1_FL_MEM_STRIDE0 0
240#define DSCR_CMD1_FL_MEM_STRIDE1 1
241#define DSCR_CMD1_FL_MEM_STRIDE2 2
242
243#define DSCR_CMD1_FL(x) (((x) & 0x3) << 22)
244
245/* Source1, 1-dimensional stride. */
246#define DSCR_SRC1_STS_MASK (3 << 30) /* Src xfer size */
247#define DSCR_SRC1_SAM_MASK (3 << 28) /* Src xfer movement */
248#define DSCR_SRC1_SB_MASK (0x3fff << 14) /* Block size */
249#define DSCR_SRC1_SB(x) (((x) & 0x3fff) << 14)
250#define DSCR_SRC1_SS_MASK (0x3fff << 0) /* Stride */
251#define DSCR_SRC1_SS(x) (((x) & 0x3fff) << 0)
252
253/* Dest1, 1-dimensional stride. */
254#define DSCR_DEST1_DTS_MASK (3 << 30) /* Dest xfer size */
255#define DSCR_DEST1_DAM_MASK (3 << 28) /* Dest xfer movement */
256#define DSCR_DEST1_DB_MASK (0x3fff << 14) /* Block size */
257#define DSCR_DEST1_DB(x) (((x) & 0x3fff) << 14)
258#define DSCR_DEST1_DS_MASK (0x3fff << 0) /* Stride */
259#define DSCR_DEST1_DS(x) (((x) & 0x3fff) << 0)
260
261#define DSCR_xTS_SIZE1 0
262#define DSCR_xTS_SIZE2 1
263#define DSCR_xTS_SIZE4 2
264#define DSCR_xTS_SIZE8 3
265#define DSCR_SRC1_STS(x) (((x) & 3) << 30)
266#define DSCR_DEST1_DTS(x) (((x) & 3) << 30)
267
268#define DSCR_xAM_INCREMENT 0
269#define DSCR_xAM_DECREMENT 1
270#define DSCR_xAM_STATIC 2
271#define DSCR_xAM_BURST 3
272#define DSCR_SRC1_SAM(x) (((x) & 3) << 28)
273#define DSCR_DEST1_DAM(x) (((x) & 3) << 28)
274
275/* The next descriptor pointer. */
276#define DSCR_NXTPTR_MASK (0x07ffffff)
277#define DSCR_NXTPTR(x) ((x) >> 5)
278#define DSCR_GET_NXTPTR(x) ((x) << 5)
279#define DSCR_NXTPTR_MS (1 << 27)
280
281/* The number of DBDMA channels. */
282#define NUM_DBDMA_CHANS 16
283
284/*
285 * DDMA API definitions
286 * FIXME: may not fit to this header file
287 */
288typedef struct dbdma_device_table {
289 u32 dev_id;
290 u32 dev_flags;
291 u32 dev_tsize;
292 u32 dev_devwidth;
293 u32 dev_physaddr; /* If FIFO */
294 u32 dev_intlevel;
295 u32 dev_intpolarity;
296} dbdev_tab_t;
297
298
299typedef struct dbdma_chan_config {
300 spinlock_t lock;
301
302 u32 chan_flags;
303 u32 chan_index;
304 dbdev_tab_t *chan_src;
305 dbdev_tab_t *chan_dest;
306 au1x_dma_chan_t *chan_ptr;
307 au1x_ddma_desc_t *chan_desc_base;
308 au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr;
309 void *chan_callparam;
310 void (*chan_callback)(int, void *);
311} chan_tab_t;
312
313#define DEV_FLAGS_INUSE (1 << 0)
314#define DEV_FLAGS_ANYUSE (1 << 1)
315#define DEV_FLAGS_OUT (1 << 2)
316#define DEV_FLAGS_IN (1 << 3)
317#define DEV_FLAGS_BURSTABLE (1 << 4)
318#define DEV_FLAGS_SYNC (1 << 5)
319/* end DDMA API definitions */
320
321/*
322 * External functions for drivers to use.
323 * Use this to allocate a DBDMA channel. The device IDs are one of
324 * the DSCR_CMD0 devices IDs, which is usually redefined to a more
325 * meaningful name. The 'callback' is called during DMA completion
326 * interrupt.
327 */
328extern u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
329 void (*callback)(int, void *),
330 void *callparam);
331
332#define DBDMA_MEM_CHAN DSCR_CMD0_ALWAYS
333
334/* Set the device width of an in/out FIFO. */
335u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits);
336
337/* Allocate a ring of descriptors for DBDMA. */
338u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries);
339
340/* Put buffers on source/destination descriptors. */
341u32 _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags);
342u32 _au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags);
343
344/* Get a buffer from the destination descriptor. */
345u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes);
346
347void au1xxx_dbdma_stop(u32 chanid);
348void au1xxx_dbdma_start(u32 chanid);
349void au1xxx_dbdma_reset(u32 chanid);
350u32 au1xxx_get_dma_residue(u32 chanid);
351
352void au1xxx_dbdma_chan_free(u32 chanid);
353void au1xxx_dbdma_dump(u32 chanid);
354
355u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr);
356
357u32 au1xxx_ddma_add_device(dbdev_tab_t *dev);
358extern void au1xxx_ddma_del_device(u32 devid);
359void *au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp);
360
361/*
362 * Some compatibilty macros -- needed to make changes to API
363 * without breaking existing drivers.
364 */
365#define au1xxx_dbdma_put_source(chanid, buf, nbytes) \
366 _au1xxx_dbdma_put_source(chanid, buf, nbytes, DDMA_FLAGS_IE)
367#define au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) \
368 _au1xxx_dbdma_put_source(chanid, buf, nbytes, flags)
369#define put_source_flags(chanid, buf, nbytes, flags) \
370 au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags)
371
372#define au1xxx_dbdma_put_dest(chanid, buf, nbytes) \
373 _au1xxx_dbdma_put_dest(chanid, buf, nbytes, DDMA_FLAGS_IE)
374#define au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) \
375 _au1xxx_dbdma_put_dest(chanid, buf, nbytes, flags)
376#define put_dest_flags(chanid, buf, nbytes, flags) \
377 au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags)
378
379/*
380 * Flags for the put_source/put_dest functions.
381 */
382#define DDMA_FLAGS_IE (1 << 0)
383#define DDMA_FLAGS_NOIE (1 << 1)
384
385#endif /* _LANGUAGE_ASSEMBLY */
386#endif /* _AU1000_DBDMA_H_ */
diff --git a/arch/mips/include/asm/mach-au1x00/au1xxx_ide.h b/arch/mips/include/asm/mach-au1x00/au1xxx_ide.h
new file mode 100644
index 000000000000..60638b8969ba
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1xxx_ide.h
@@ -0,0 +1,194 @@
1/*
2 * include/asm-mips/mach-au1x00/au1xxx_ide.h version 01.30.00 Aug. 02 2005
3 *
4 * BRIEF MODULE DESCRIPTION
5 * AMD Alchemy Au1xxx IDE interface routines over the Static Bus
6 *
7 * Copyright (c) 2003-2005 AMD, Personal Connectivity Solutions
8 *
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the License, or (at your option) any later
12 * version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
15 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 * POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along with
26 * this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 *
29 * Note: for more information, please refer "AMD Alchemy Au1200/Au1550 IDE
30 * Interface and Linux Device Driver" Application Note.
31 */
32
33#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
34#define DMA_WAIT_TIMEOUT 100
35#define NUM_DESCRIPTORS PRD_ENTRIES
36#else /* CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA */
37#define NUM_DESCRIPTORS 2
38#endif
39
40#ifndef AU1XXX_ATA_RQSIZE
41#define AU1XXX_ATA_RQSIZE 128
42#endif
43
44/* Disable Burstable-Support for DBDMA */
45#ifndef CONFIG_BLK_DEV_IDE_AU1XXX_BURSTABLE_ON
46#define CONFIG_BLK_DEV_IDE_AU1XXX_BURSTABLE_ON 0
47#endif
48
49#ifdef CONFIG_PM
50/*
51 * This will enable the device to be powered up when write() or read()
52 * is called. If this is not defined, the driver will return -EBUSY.
53 */
54#define WAKE_ON_ACCESS 1
55
56typedef struct {
57 spinlock_t lock; /* Used to block on state transitions */
58 au1xxx_power_dev_t *dev; /* Power Managers device structure */
59 unsigned stopped; /* Used to signal device is stopped */
60} pm_state;
61#endif
62
63typedef struct {
64 u32 tx_dev_id, rx_dev_id, target_dev_id;
65 u32 tx_chan, rx_chan;
66 void *tx_desc_head, *rx_desc_head;
67 ide_hwif_t *hwif;
68#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
69 ide_drive_t *drive;
70 struct dbdma_cmd *dma_table_cpu;
71 dma_addr_t dma_table_dma;
72#endif
73 int irq;
74 u32 regbase;
75#ifdef CONFIG_PM
76 pm_state pm;
77#endif
78} _auide_hwif;
79
80/******************************************************************************/
81/* PIO Mode timing calculation : */
82/* */
83/* Static Bus Spec ATA Spec */
84/* Tcsoe = t1 */
85/* Toecs = t9 */
86/* Twcs = t9 */
87/* Tcsh = t2i | t2 */
88/* Tcsoff = t2i | t2 */
89/* Twp = t2 */
90/* Tcsw = t1 */
91/* Tpm = 0 */
92/* Ta = t1+t2 */
93/******************************************************************************/
94
95#define TCSOE_MASK (0x07 << 29)
96#define TOECS_MASK (0x07 << 26)
97#define TWCS_MASK (0x07 << 28)
98#define TCSH_MASK (0x0F << 24)
99#define TCSOFF_MASK (0x07 << 20)
100#define TWP_MASK (0x3F << 14)
101#define TCSW_MASK (0x0F << 10)
102#define TPM_MASK (0x0F << 6)
103#define TA_MASK (0x3F << 0)
104#define TS_MASK (1 << 8)
105
106/* Timing parameters PIO mode 0 */
107#define SBC_IDE_PIO0_TCSOE (0x04 << 29)
108#define SBC_IDE_PIO0_TOECS (0x01 << 26)
109#define SBC_IDE_PIO0_TWCS (0x02 << 28)
110#define SBC_IDE_PIO0_TCSH (0x08 << 24)
111#define SBC_IDE_PIO0_TCSOFF (0x07 << 20)
112#define SBC_IDE_PIO0_TWP (0x10 << 14)
113#define SBC_IDE_PIO0_TCSW (0x04 << 10)
114#define SBC_IDE_PIO0_TPM (0x00 << 6)
115#define SBC_IDE_PIO0_TA (0x15 << 0)
116/* Timing parameters PIO mode 1 */
117#define SBC_IDE_PIO1_TCSOE (0x03 << 29)
118#define SBC_IDE_PIO1_TOECS (0x01 << 26)
119#define SBC_IDE_PIO1_TWCS (0x01 << 28)
120#define SBC_IDE_PIO1_TCSH (0x06 << 24)
121#define SBC_IDE_PIO1_TCSOFF (0x06 << 20)
122#define SBC_IDE_PIO1_TWP (0x08 << 14)
123#define SBC_IDE_PIO1_TCSW (0x03 << 10)
124#define SBC_IDE_PIO1_TPM (0x00 << 6)
125#define SBC_IDE_PIO1_TA (0x0B << 0)
126/* Timing parameters PIO mode 2 */
127#define SBC_IDE_PIO2_TCSOE (0x05 << 29)
128#define SBC_IDE_PIO2_TOECS (0x01 << 26)
129#define SBC_IDE_PIO2_TWCS (0x01 << 28)
130#define SBC_IDE_PIO2_TCSH (0x07 << 24)
131#define SBC_IDE_PIO2_TCSOFF (0x07 << 20)
132#define SBC_IDE_PIO2_TWP (0x1F << 14)
133#define SBC_IDE_PIO2_TCSW (0x05 << 10)
134#define SBC_IDE_PIO2_TPM (0x00 << 6)
135#define SBC_IDE_PIO2_TA (0x22 << 0)
136/* Timing parameters PIO mode 3 */
137#define SBC_IDE_PIO3_TCSOE (0x05 << 29)
138#define SBC_IDE_PIO3_TOECS (0x01 << 26)
139#define SBC_IDE_PIO3_TWCS (0x01 << 28)
140#define SBC_IDE_PIO3_TCSH (0x0D << 24)
141#define SBC_IDE_PIO3_TCSOFF (0x0D << 20)
142#define SBC_IDE_PIO3_TWP (0x15 << 14)
143#define SBC_IDE_PIO3_TCSW (0x05 << 10)
144#define SBC_IDE_PIO3_TPM (0x00 << 6)
145#define SBC_IDE_PIO3_TA (0x1A << 0)
146/* Timing parameters PIO mode 4 */
147#define SBC_IDE_PIO4_TCSOE (0x04 << 29)
148#define SBC_IDE_PIO4_TOECS (0x01 << 26)
149#define SBC_IDE_PIO4_TWCS (0x01 << 28)
150#define SBC_IDE_PIO4_TCSH (0x04 << 24)
151#define SBC_IDE_PIO4_TCSOFF (0x04 << 20)
152#define SBC_IDE_PIO4_TWP (0x0D << 14)
153#define SBC_IDE_PIO4_TCSW (0x03 << 10)
154#define SBC_IDE_PIO4_TPM (0x00 << 6)
155#define SBC_IDE_PIO4_TA (0x12 << 0)
156/* Timing parameters MDMA mode 0 */
157#define SBC_IDE_MDMA0_TCSOE (0x03 << 29)
158#define SBC_IDE_MDMA0_TOECS (0x01 << 26)
159#define SBC_IDE_MDMA0_TWCS (0x01 << 28)
160#define SBC_IDE_MDMA0_TCSH (0x07 << 24)
161#define SBC_IDE_MDMA0_TCSOFF (0x07 << 20)
162#define SBC_IDE_MDMA0_TWP (0x0C << 14)
163#define SBC_IDE_MDMA0_TCSW (0x03 << 10)
164#define SBC_IDE_MDMA0_TPM (0x00 << 6)
165#define SBC_IDE_MDMA0_TA (0x0F << 0)
166/* Timing parameters MDMA mode 1 */
167#define SBC_IDE_MDMA1_TCSOE (0x05 << 29)
168#define SBC_IDE_MDMA1_TOECS (0x01 << 26)
169#define SBC_IDE_MDMA1_TWCS (0x01 << 28)
170#define SBC_IDE_MDMA1_TCSH (0x05 << 24)
171#define SBC_IDE_MDMA1_TCSOFF (0x05 << 20)
172#define SBC_IDE_MDMA1_TWP (0x0F << 14)
173#define SBC_IDE_MDMA1_TCSW (0x05 << 10)
174#define SBC_IDE_MDMA1_TPM (0x00 << 6)
175#define SBC_IDE_MDMA1_TA (0x15 << 0)
176/* Timing parameters MDMA mode 2 */
177#define SBC_IDE_MDMA2_TCSOE (0x04 << 29)
178#define SBC_IDE_MDMA2_TOECS (0x01 << 26)
179#define SBC_IDE_MDMA2_TWCS (0x01 << 28)
180#define SBC_IDE_MDMA2_TCSH (0x04 << 24)
181#define SBC_IDE_MDMA2_TCSOFF (0x04 << 20)
182#define SBC_IDE_MDMA2_TWP (0x0D << 14)
183#define SBC_IDE_MDMA2_TCSW (0x04 << 10)
184#define SBC_IDE_MDMA2_TPM (0x00 << 6)
185#define SBC_IDE_MDMA2_TA (0x12 << 0)
186
187#define SBC_IDE_TIMING(mode) \
188 (SBC_IDE_##mode##_TWCS | \
189 SBC_IDE_##mode##_TCSH | \
190 SBC_IDE_##mode##_TCSOFF | \
191 SBC_IDE_##mode##_TWP | \
192 SBC_IDE_##mode##_TCSW | \
193 SBC_IDE_##mode##_TPM | \
194 SBC_IDE_##mode##_TA)
diff --git a/arch/mips/include/asm/mach-au1x00/au1xxx_psc.h b/arch/mips/include/asm/mach-au1x00/au1xxx_psc.h
new file mode 100644
index 000000000000..892b7f168eb4
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1xxx_psc.h
@@ -0,0 +1,505 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Include file for Alchemy Semiconductor's Au1k CPU.
5 *
6 * Copyright 2004 Embedded Edge, LLC
7 * dan@embeddededge.com
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29
30/* Specifics for the Au1xxx Programmable Serial Controllers, first
31 * seen in the AU1550 part.
32 */
33#ifndef _AU1000_PSC_H_
34#define _AU1000_PSC_H_
35
36/* The PSC base addresses. */
37#ifdef CONFIG_SOC_AU1550
38#define PSC0_BASE_ADDR 0xb1a00000
39#define PSC1_BASE_ADDR 0xb1b00000
40#define PSC2_BASE_ADDR 0xb0a00000
41#define PSC3_BASE_ADDR 0xb0b00000
42#endif
43
44#ifdef CONFIG_SOC_AU1200
45#define PSC0_BASE_ADDR 0xb1a00000
46#define PSC1_BASE_ADDR 0xb1b00000
47#endif
48
49/*
50 * The PSC select and control registers are common to all protocols.
51 */
52#define PSC_SEL_OFFSET 0x00000000
53#define PSC_CTRL_OFFSET 0x00000004
54
55#define PSC_SEL_CLK_MASK (3 << 4)
56#define PSC_SEL_CLK_INTCLK (0 << 4)
57#define PSC_SEL_CLK_EXTCLK (1 << 4)
58#define PSC_SEL_CLK_SERCLK (2 << 4)
59
60#define PSC_SEL_PS_MASK 0x00000007
61#define PSC_SEL_PS_DISABLED 0
62#define PSC_SEL_PS_SPIMODE 2
63#define PSC_SEL_PS_I2SMODE 3
64#define PSC_SEL_PS_AC97MODE 4
65#define PSC_SEL_PS_SMBUSMODE 5
66
67#define PSC_CTRL_DISABLE 0
68#define PSC_CTRL_SUSPEND 2
69#define PSC_CTRL_ENABLE 3
70
71/* AC97 Registers. */
72#define PSC_AC97CFG_OFFSET 0x00000008
73#define PSC_AC97MSK_OFFSET 0x0000000c
74#define PSC_AC97PCR_OFFSET 0x00000010
75#define PSC_AC97STAT_OFFSET 0x00000014
76#define PSC_AC97EVNT_OFFSET 0x00000018
77#define PSC_AC97TXRX_OFFSET 0x0000001c
78#define PSC_AC97CDC_OFFSET 0x00000020
79#define PSC_AC97RST_OFFSET 0x00000024
80#define PSC_AC97GPO_OFFSET 0x00000028
81#define PSC_AC97GPI_OFFSET 0x0000002c
82
83#define AC97_PSC_SEL (AC97_PSC_BASE + PSC_SEL_OFFSET)
84#define AC97_PSC_CTRL (AC97_PSC_BASE + PSC_CTRL_OFFSET)
85#define PSC_AC97CFG (AC97_PSC_BASE + PSC_AC97CFG_OFFSET)
86#define PSC_AC97MSK (AC97_PSC_BASE + PSC_AC97MSK_OFFSET)
87#define PSC_AC97PCR (AC97_PSC_BASE + PSC_AC97PCR_OFFSET)
88#define PSC_AC97STAT (AC97_PSC_BASE + PSC_AC97STAT_OFFSET)
89#define PSC_AC97EVNT (AC97_PSC_BASE + PSC_AC97EVNT_OFFSET)
90#define PSC_AC97TXRX (AC97_PSC_BASE + PSC_AC97TXRX_OFFSET)
91#define PSC_AC97CDC (AC97_PSC_BASE + PSC_AC97CDC_OFFSET)
92#define PSC_AC97RST (AC97_PSC_BASE + PSC_AC97RST_OFFSET)
93#define PSC_AC97GPO (AC97_PSC_BASE + PSC_AC97GPO_OFFSET)
94#define PSC_AC97GPI (AC97_PSC_BASE + PSC_AC97GPI_OFFSET)
95
96/* AC97 Config Register. */
97#define PSC_AC97CFG_RT_MASK (3 << 30)
98#define PSC_AC97CFG_RT_FIFO1 (0 << 30)
99#define PSC_AC97CFG_RT_FIFO2 (1 << 30)
100#define PSC_AC97CFG_RT_FIFO4 (2 << 30)
101#define PSC_AC97CFG_RT_FIFO8 (3 << 30)
102
103#define PSC_AC97CFG_TT_MASK (3 << 28)
104#define PSC_AC97CFG_TT_FIFO1 (0 << 28)
105#define PSC_AC97CFG_TT_FIFO2 (1 << 28)
106#define PSC_AC97CFG_TT_FIFO4 (2 << 28)
107#define PSC_AC97CFG_TT_FIFO8 (3 << 28)
108
109#define PSC_AC97CFG_DD_DISABLE (1 << 27)
110#define PSC_AC97CFG_DE_ENABLE (1 << 26)
111#define PSC_AC97CFG_SE_ENABLE (1 << 25)
112
113#define PSC_AC97CFG_LEN_MASK (0xf << 21)
114#define PSC_AC97CFG_TXSLOT_MASK (0x3ff << 11)
115#define PSC_AC97CFG_RXSLOT_MASK (0x3ff << 1)
116#define PSC_AC97CFG_GE_ENABLE (1)
117
118/* Enable slots 3-12. */
119#define PSC_AC97CFG_TXSLOT_ENA(x) (1 << (((x) - 3) + 11))
120#define PSC_AC97CFG_RXSLOT_ENA(x) (1 << (((x) - 3) + 1))
121
122/*
123 * The word length equation is ((x) * 2) + 2, so choose 'x' appropriately.
124 * The only sensible numbers are 7, 9, or possibly 11. Nah, just do the
125 * arithmetic in the macro.
126 */
127#define PSC_AC97CFG_SET_LEN(x) (((((x) - 2) / 2) & 0xf) << 21)
128#define PSC_AC97CFG_GET_LEN(x) (((((x) >> 21) & 0xf) * 2) + 2)
129
130/* AC97 Mask Register. */
131#define PSC_AC97MSK_GR (1 << 25)
132#define PSC_AC97MSK_CD (1 << 24)
133#define PSC_AC97MSK_RR (1 << 13)
134#define PSC_AC97MSK_RO (1 << 12)
135#define PSC_AC97MSK_RU (1 << 11)
136#define PSC_AC97MSK_TR (1 << 10)
137#define PSC_AC97MSK_TO (1 << 9)
138#define PSC_AC97MSK_TU (1 << 8)
139#define PSC_AC97MSK_RD (1 << 5)
140#define PSC_AC97MSK_TD (1 << 4)
141#define PSC_AC97MSK_ALLMASK (PSC_AC97MSK_GR | PSC_AC97MSK_CD | \
142 PSC_AC97MSK_RR | PSC_AC97MSK_RO | \
143 PSC_AC97MSK_RU | PSC_AC97MSK_TR | \
144 PSC_AC97MSK_TO | PSC_AC97MSK_TU | \
145 PSC_AC97MSK_RD | PSC_AC97MSK_TD)
146
147/* AC97 Protocol Control Register. */
148#define PSC_AC97PCR_RC (1 << 6)
149#define PSC_AC97PCR_RP (1 << 5)
150#define PSC_AC97PCR_RS (1 << 4)
151#define PSC_AC97PCR_TC (1 << 2)
152#define PSC_AC97PCR_TP (1 << 1)
153#define PSC_AC97PCR_TS (1 << 0)
154
155/* AC97 Status register (read only). */
156#define PSC_AC97STAT_CB (1 << 26)
157#define PSC_AC97STAT_CP (1 << 25)
158#define PSC_AC97STAT_CR (1 << 24)
159#define PSC_AC97STAT_RF (1 << 13)
160#define PSC_AC97STAT_RE (1 << 12)
161#define PSC_AC97STAT_RR (1 << 11)
162#define PSC_AC97STAT_TF (1 << 10)
163#define PSC_AC97STAT_TE (1 << 9)
164#define PSC_AC97STAT_TR (1 << 8)
165#define PSC_AC97STAT_RB (1 << 5)
166#define PSC_AC97STAT_TB (1 << 4)
167#define PSC_AC97STAT_DI (1 << 2)
168#define PSC_AC97STAT_DR (1 << 1)
169#define PSC_AC97STAT_SR (1 << 0)
170
171/* AC97 Event Register. */
172#define PSC_AC97EVNT_GR (1 << 25)
173#define PSC_AC97EVNT_CD (1 << 24)
174#define PSC_AC97EVNT_RR (1 << 13)
175#define PSC_AC97EVNT_RO (1 << 12)
176#define PSC_AC97EVNT_RU (1 << 11)
177#define PSC_AC97EVNT_TR (1 << 10)
178#define PSC_AC97EVNT_TO (1 << 9)
179#define PSC_AC97EVNT_TU (1 << 8)
180#define PSC_AC97EVNT_RD (1 << 5)
181#define PSC_AC97EVNT_TD (1 << 4)
182
183/* CODEC Command Register. */
184#define PSC_AC97CDC_RD (1 << 25)
185#define PSC_AC97CDC_ID_MASK (3 << 23)
186#define PSC_AC97CDC_INDX_MASK (0x7f << 16)
187#define PSC_AC97CDC_ID(x) (((x) & 0x03) << 23)
188#define PSC_AC97CDC_INDX(x) (((x) & 0x7f) << 16)
189
190/* AC97 Reset Control Register. */
191#define PSC_AC97RST_RST (1 << 1)
192#define PSC_AC97RST_SNC (1 << 0)
193
194/* PSC in I2S Mode. */
195typedef struct psc_i2s {
196 u32 psc_sel;
197 u32 psc_ctrl;
198 u32 psc_i2scfg;
199 u32 psc_i2smsk;
200 u32 psc_i2spcr;
201 u32 psc_i2sstat;
202 u32 psc_i2sevent;
203 u32 psc_i2stxrx;
204 u32 psc_i2sudf;
205} psc_i2s_t;
206
207#define PSC_I2SCFG_OFFSET 0x08
208#define PSC_I2SMASK_OFFSET 0x0C
209#define PSC_I2SPCR_OFFSET 0x10
210#define PSC_I2SSTAT_OFFSET 0x14
211#define PSC_I2SEVENT_OFFSET 0x18
212#define PSC_I2SRXTX_OFFSET 0x1C
213#define PSC_I2SUDF_OFFSET 0x20
214
215/* I2S Config Register. */
216#define PSC_I2SCFG_RT_MASK (3 << 30)
217#define PSC_I2SCFG_RT_FIFO1 (0 << 30)
218#define PSC_I2SCFG_RT_FIFO2 (1 << 30)
219#define PSC_I2SCFG_RT_FIFO4 (2 << 30)
220#define PSC_I2SCFG_RT_FIFO8 (3 << 30)
221
222#define PSC_I2SCFG_TT_MASK (3 << 28)
223#define PSC_I2SCFG_TT_FIFO1 (0 << 28)
224#define PSC_I2SCFG_TT_FIFO2 (1 << 28)
225#define PSC_I2SCFG_TT_FIFO4 (2 << 28)
226#define PSC_I2SCFG_TT_FIFO8 (3 << 28)
227
228#define PSC_I2SCFG_DD_DISABLE (1 << 27)
229#define PSC_I2SCFG_DE_ENABLE (1 << 26)
230#define PSC_I2SCFG_SET_WS(x) (((((x) / 2) - 1) & 0x7f) << 16)
231#define PSC_I2SCFG_WS(n) ((n & 0xFF) << 16)
232#define PSC_I2SCFG_WS_MASK (PSC_I2SCFG_WS(0x3F))
233#define PSC_I2SCFG_WI (1 << 15)
234
235#define PSC_I2SCFG_DIV_MASK (3 << 13)
236#define PSC_I2SCFG_DIV2 (0 << 13)
237#define PSC_I2SCFG_DIV4 (1 << 13)
238#define PSC_I2SCFG_DIV8 (2 << 13)
239#define PSC_I2SCFG_DIV16 (3 << 13)
240
241#define PSC_I2SCFG_BI (1 << 12)
242#define PSC_I2SCFG_BUF (1 << 11)
243#define PSC_I2SCFG_MLJ (1 << 10)
244#define PSC_I2SCFG_XM (1 << 9)
245
246/* The word length equation is simply LEN+1. */
247#define PSC_I2SCFG_SET_LEN(x) ((((x) - 1) & 0x1f) << 4)
248#define PSC_I2SCFG_GET_LEN(x) ((((x) >> 4) & 0x1f) + 1)
249
250#define PSC_I2SCFG_LB (1 << 2)
251#define PSC_I2SCFG_MLF (1 << 1)
252#define PSC_I2SCFG_MS (1 << 0)
253
254/* I2S Mask Register. */
255#define PSC_I2SMSK_RR (1 << 13)
256#define PSC_I2SMSK_RO (1 << 12)
257#define PSC_I2SMSK_RU (1 << 11)
258#define PSC_I2SMSK_TR (1 << 10)
259#define PSC_I2SMSK_TO (1 << 9)
260#define PSC_I2SMSK_TU (1 << 8)
261#define PSC_I2SMSK_RD (1 << 5)
262#define PSC_I2SMSK_TD (1 << 4)
263#define PSC_I2SMSK_ALLMASK (PSC_I2SMSK_RR | PSC_I2SMSK_RO | \
264 PSC_I2SMSK_RU | PSC_I2SMSK_TR | \
265 PSC_I2SMSK_TO | PSC_I2SMSK_TU | \
266 PSC_I2SMSK_RD | PSC_I2SMSK_TD)
267
268/* I2S Protocol Control Register. */
269#define PSC_I2SPCR_RC (1 << 6)
270#define PSC_I2SPCR_RP (1 << 5)
271#define PSC_I2SPCR_RS (1 << 4)
272#define PSC_I2SPCR_TC (1 << 2)
273#define PSC_I2SPCR_TP (1 << 1)
274#define PSC_I2SPCR_TS (1 << 0)
275
276/* I2S Status register (read only). */
277#define PSC_I2SSTAT_RF (1 << 13)
278#define PSC_I2SSTAT_RE (1 << 12)
279#define PSC_I2SSTAT_RR (1 << 11)
280#define PSC_I2SSTAT_TF (1 << 10)
281#define PSC_I2SSTAT_TE (1 << 9)
282#define PSC_I2SSTAT_TR (1 << 8)
283#define PSC_I2SSTAT_RB (1 << 5)
284#define PSC_I2SSTAT_TB (1 << 4)
285#define PSC_I2SSTAT_DI (1 << 2)
286#define PSC_I2SSTAT_DR (1 << 1)
287#define PSC_I2SSTAT_SR (1 << 0)
288
289/* I2S Event Register. */
290#define PSC_I2SEVNT_RR (1 << 13)
291#define PSC_I2SEVNT_RO (1 << 12)
292#define PSC_I2SEVNT_RU (1 << 11)
293#define PSC_I2SEVNT_TR (1 << 10)
294#define PSC_I2SEVNT_TO (1 << 9)
295#define PSC_I2SEVNT_TU (1 << 8)
296#define PSC_I2SEVNT_RD (1 << 5)
297#define PSC_I2SEVNT_TD (1 << 4)
298
299/* PSC in SPI Mode. */
300typedef struct psc_spi {
301 u32 psc_sel;
302 u32 psc_ctrl;
303 u32 psc_spicfg;
304 u32 psc_spimsk;
305 u32 psc_spipcr;
306 u32 psc_spistat;
307 u32 psc_spievent;
308 u32 psc_spitxrx;
309} psc_spi_t;
310
311/* SPI Config Register. */
312#define PSC_SPICFG_RT_MASK (3 << 30)
313#define PSC_SPICFG_RT_FIFO1 (0 << 30)
314#define PSC_SPICFG_RT_FIFO2 (1 << 30)
315#define PSC_SPICFG_RT_FIFO4 (2 << 30)
316#define PSC_SPICFG_RT_FIFO8 (3 << 30)
317
318#define PSC_SPICFG_TT_MASK (3 << 28)
319#define PSC_SPICFG_TT_FIFO1 (0 << 28)
320#define PSC_SPICFG_TT_FIFO2 (1 << 28)
321#define PSC_SPICFG_TT_FIFO4 (2 << 28)
322#define PSC_SPICFG_TT_FIFO8 (3 << 28)
323
324#define PSC_SPICFG_DD_DISABLE (1 << 27)
325#define PSC_SPICFG_DE_ENABLE (1 << 26)
326#define PSC_SPICFG_CLR_BAUD(x) ((x) & ~((0x3f) << 15))
327#define PSC_SPICFG_SET_BAUD(x) (((x) & 0x3f) << 15)
328
329#define PSC_SPICFG_SET_DIV(x) (((x) & 0x03) << 13)
330#define PSC_SPICFG_DIV2 0
331#define PSC_SPICFG_DIV4 1
332#define PSC_SPICFG_DIV8 2
333#define PSC_SPICFG_DIV16 3
334
335#define PSC_SPICFG_BI (1 << 12)
336#define PSC_SPICFG_PSE (1 << 11)
337#define PSC_SPICFG_CGE (1 << 10)
338#define PSC_SPICFG_CDE (1 << 9)
339
340#define PSC_SPICFG_CLR_LEN(x) ((x) & ~((0x1f) << 4))
341#define PSC_SPICFG_SET_LEN(x) (((x-1) & 0x1f) << 4)
342
343#define PSC_SPICFG_LB (1 << 3)
344#define PSC_SPICFG_MLF (1 << 1)
345#define PSC_SPICFG_MO (1 << 0)
346
347/* SPI Mask Register. */
348#define PSC_SPIMSK_MM (1 << 16)
349#define PSC_SPIMSK_RR (1 << 13)
350#define PSC_SPIMSK_RO (1 << 12)
351#define PSC_SPIMSK_RU (1 << 11)
352#define PSC_SPIMSK_TR (1 << 10)
353#define PSC_SPIMSK_TO (1 << 9)
354#define PSC_SPIMSK_TU (1 << 8)
355#define PSC_SPIMSK_SD (1 << 5)
356#define PSC_SPIMSK_MD (1 << 4)
357#define PSC_SPIMSK_ALLMASK (PSC_SPIMSK_MM | PSC_SPIMSK_RR | \
358 PSC_SPIMSK_RO | PSC_SPIMSK_TO | \
359 PSC_SPIMSK_TU | PSC_SPIMSK_SD | \
360 PSC_SPIMSK_MD)
361
362/* SPI Protocol Control Register. */
363#define PSC_SPIPCR_RC (1 << 6)
364#define PSC_SPIPCR_SP (1 << 5)
365#define PSC_SPIPCR_SS (1 << 4)
366#define PSC_SPIPCR_TC (1 << 2)
367#define PSC_SPIPCR_MS (1 << 0)
368
369/* SPI Status register (read only). */
370#define PSC_SPISTAT_RF (1 << 13)
371#define PSC_SPISTAT_RE (1 << 12)
372#define PSC_SPISTAT_RR (1 << 11)
373#define PSC_SPISTAT_TF (1 << 10)
374#define PSC_SPISTAT_TE (1 << 9)
375#define PSC_SPISTAT_TR (1 << 8)
376#define PSC_SPISTAT_SB (1 << 5)
377#define PSC_SPISTAT_MB (1 << 4)
378#define PSC_SPISTAT_DI (1 << 2)
379#define PSC_SPISTAT_DR (1 << 1)
380#define PSC_SPISTAT_SR (1 << 0)
381
382/* SPI Event Register. */
383#define PSC_SPIEVNT_MM (1 << 16)
384#define PSC_SPIEVNT_RR (1 << 13)
385#define PSC_SPIEVNT_RO (1 << 12)
386#define PSC_SPIEVNT_RU (1 << 11)
387#define PSC_SPIEVNT_TR (1 << 10)
388#define PSC_SPIEVNT_TO (1 << 9)
389#define PSC_SPIEVNT_TU (1 << 8)
390#define PSC_SPIEVNT_SD (1 << 5)
391#define PSC_SPIEVNT_MD (1 << 4)
392
393/* Transmit register control. */
394#define PSC_SPITXRX_LC (1 << 29)
395#define PSC_SPITXRX_SR (1 << 28)
396
397/* PSC in SMBus (I2C) Mode. */
398typedef struct psc_smb {
399 u32 psc_sel;
400 u32 psc_ctrl;
401 u32 psc_smbcfg;
402 u32 psc_smbmsk;
403 u32 psc_smbpcr;
404 u32 psc_smbstat;
405 u32 psc_smbevnt;
406 u32 psc_smbtxrx;
407 u32 psc_smbtmr;
408} psc_smb_t;
409
410/* SMBus Config Register. */
411#define PSC_SMBCFG_RT_MASK (3 << 30)
412#define PSC_SMBCFG_RT_FIFO1 (0 << 30)
413#define PSC_SMBCFG_RT_FIFO2 (1 << 30)
414#define PSC_SMBCFG_RT_FIFO4 (2 << 30)
415#define PSC_SMBCFG_RT_FIFO8 (3 << 30)
416
417#define PSC_SMBCFG_TT_MASK (3 << 28)
418#define PSC_SMBCFG_TT_FIFO1 (0 << 28)
419#define PSC_SMBCFG_TT_FIFO2 (1 << 28)
420#define PSC_SMBCFG_TT_FIFO4 (2 << 28)
421#define PSC_SMBCFG_TT_FIFO8 (3 << 28)
422
423#define PSC_SMBCFG_DD_DISABLE (1 << 27)
424#define PSC_SMBCFG_DE_ENABLE (1 << 26)
425
426#define PSC_SMBCFG_SET_DIV(x) (((x) & 0x03) << 13)
427#define PSC_SMBCFG_DIV2 0
428#define PSC_SMBCFG_DIV4 1
429#define PSC_SMBCFG_DIV8 2
430#define PSC_SMBCFG_DIV16 3
431
432#define PSC_SMBCFG_GCE (1 << 9)
433#define PSC_SMBCFG_SFM (1 << 8)
434
435#define PSC_SMBCFG_SET_SLV(x) (((x) & 0x7f) << 1)
436
437/* SMBus Mask Register. */
438#define PSC_SMBMSK_DN (1 << 30)
439#define PSC_SMBMSK_AN (1 << 29)
440#define PSC_SMBMSK_AL (1 << 28)
441#define PSC_SMBMSK_RR (1 << 13)
442#define PSC_SMBMSK_RO (1 << 12)
443#define PSC_SMBMSK_RU (1 << 11)
444#define PSC_SMBMSK_TR (1 << 10)
445#define PSC_SMBMSK_TO (1 << 9)
446#define PSC_SMBMSK_TU (1 << 8)
447#define PSC_SMBMSK_SD (1 << 5)
448#define PSC_SMBMSK_MD (1 << 4)
449#define PSC_SMBMSK_ALLMASK (PSC_SMBMSK_DN | PSC_SMBMSK_AN | \
450 PSC_SMBMSK_AL | PSC_SMBMSK_RR | \
451 PSC_SMBMSK_RO | PSC_SMBMSK_TO | \
452 PSC_SMBMSK_TU | PSC_SMBMSK_SD | \
453 PSC_SMBMSK_MD)
454
455/* SMBus Protocol Control Register. */
456#define PSC_SMBPCR_DC (1 << 2)
457#define PSC_SMBPCR_MS (1 << 0)
458
459/* SMBus Status register (read only). */
460#define PSC_SMBSTAT_BB (1 << 28)
461#define PSC_SMBSTAT_RF (1 << 13)
462#define PSC_SMBSTAT_RE (1 << 12)
463#define PSC_SMBSTAT_RR (1 << 11)
464#define PSC_SMBSTAT_TF (1 << 10)
465#define PSC_SMBSTAT_TE (1 << 9)
466#define PSC_SMBSTAT_TR (1 << 8)
467#define PSC_SMBSTAT_SB (1 << 5)
468#define PSC_SMBSTAT_MB (1 << 4)
469#define PSC_SMBSTAT_DI (1 << 2)
470#define PSC_SMBSTAT_DR (1 << 1)
471#define PSC_SMBSTAT_SR (1 << 0)
472
473/* SMBus Event Register. */
474#define PSC_SMBEVNT_DN (1 << 30)
475#define PSC_SMBEVNT_AN (1 << 29)
476#define PSC_SMBEVNT_AL (1 << 28)
477#define PSC_SMBEVNT_RR (1 << 13)
478#define PSC_SMBEVNT_RO (1 << 12)
479#define PSC_SMBEVNT_RU (1 << 11)
480#define PSC_SMBEVNT_TR (1 << 10)
481#define PSC_SMBEVNT_TO (1 << 9)
482#define PSC_SMBEVNT_TU (1 << 8)
483#define PSC_SMBEVNT_SD (1 << 5)
484#define PSC_SMBEVNT_MD (1 << 4)
485#define PSC_SMBEVNT_ALLCLR (PSC_SMBEVNT_DN | PSC_SMBEVNT_AN | \
486 PSC_SMBEVNT_AL | PSC_SMBEVNT_RR | \
487 PSC_SMBEVNT_RO | PSC_SMBEVNT_TO | \
488 PSC_SMBEVNT_TU | PSC_SMBEVNT_SD | \
489 PSC_SMBEVNT_MD)
490
491/* Transmit register control. */
492#define PSC_SMBTXRX_RSR (1 << 28)
493#define PSC_SMBTXRX_STP (1 << 29)
494#define PSC_SMBTXRX_DATAMASK 0xff
495
496/* SMBus protocol timers register. */
497#define PSC_SMBTMR_SET_TH(x) (((x) & 0x03) << 30)
498#define PSC_SMBTMR_SET_PS(x) (((x) & 0x1f) << 25)
499#define PSC_SMBTMR_SET_PU(x) (((x) & 0x1f) << 20)
500#define PSC_SMBTMR_SET_SH(x) (((x) & 0x1f) << 15)
501#define PSC_SMBTMR_SET_SU(x) (((x) & 0x1f) << 10)
502#define PSC_SMBTMR_SET_CL(x) (((x) & 0x1f) << 5)
503#define PSC_SMBTMR_SET_CH(x) (((x) & 0x1f) << 0)
504
505#endif /* _AU1000_PSC_H_ */
diff --git a/arch/mips/include/asm/mach-au1x00/gpio.h b/arch/mips/include/asm/mach-au1x00/gpio.h
new file mode 100644
index 000000000000..2dc61e009a08
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/gpio.h
@@ -0,0 +1,69 @@
1#ifndef _AU1XXX_GPIO_H_
2#define _AU1XXX_GPIO_H_
3
4#include <linux/types.h>
5
6#define AU1XXX_GPIO_BASE 200
7
8struct au1x00_gpio2 {
9 u32 dir;
10 u32 reserved;
11 u32 output;
12 u32 pinstate;
13 u32 inten;
14 u32 enable;
15};
16
17extern int au1xxx_gpio_get_value(unsigned gpio);
18extern void au1xxx_gpio_set_value(unsigned gpio, int value);
19extern int au1xxx_gpio_direction_input(unsigned gpio);
20extern int au1xxx_gpio_direction_output(unsigned gpio, int value);
21
22
23/* Wrappers for the arch-neutral GPIO API */
24
25static inline int gpio_request(unsigned gpio, const char *label)
26{
27 /* Not yet implemented */
28 return 0;
29}
30
31static inline void gpio_free(unsigned gpio)
32{
33 /* Not yet implemented */
34}
35
36static inline int gpio_direction_input(unsigned gpio)
37{
38 return au1xxx_gpio_direction_input(gpio);
39}
40
41static inline int gpio_direction_output(unsigned gpio, int value)
42{
43 return au1xxx_gpio_direction_output(gpio, value);
44}
45
46static inline int gpio_get_value(unsigned gpio)
47{
48 return au1xxx_gpio_get_value(gpio);
49}
50
51static inline void gpio_set_value(unsigned gpio, int value)
52{
53 au1xxx_gpio_set_value(gpio, value);
54}
55
56static inline int gpio_to_irq(unsigned gpio)
57{
58 return gpio;
59}
60
61static inline int irq_to_gpio(unsigned irq)
62{
63 return irq;
64}
65
66/* For cansleep */
67#include <asm-generic/gpio.h>
68
69#endif /* _AU1XXX_GPIO_H_ */
diff --git a/arch/mips/include/asm/mach-au1x00/ioremap.h b/arch/mips/include/asm/mach-au1x00/ioremap.h
new file mode 100644
index 000000000000..364cea2dc71f
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/ioremap.h
@@ -0,0 +1,42 @@
1/*
2 * include/asm-mips/mach-au1x00/ioremap.h
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9#ifndef __ASM_MACH_AU1X00_IOREMAP_H
10#define __ASM_MACH_AU1X00_IOREMAP_H
11
12#include <linux/types.h>
13
14#ifdef CONFIG_64BIT_PHYS_ADDR
15extern phys_t __fixup_bigphys_addr(phys_t, phys_t);
16#else
17static inline phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size)
18{
19 return phys_addr;
20}
21#endif
22
23/*
24 * Allow physical addresses to be fixed up to help 36-bit peripherals.
25 */
26static inline phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
27{
28 return __fixup_bigphys_addr(phys_addr, size);
29}
30
31static inline void __iomem *plat_ioremap(phys_t offset, unsigned long size,
32 unsigned long flags)
33{
34 return NULL;
35}
36
37static inline int plat_iounmap(const volatile void __iomem *addr)
38{
39 return 0;
40}
41
42#endif /* __ASM_MACH_AU1X00_IOREMAP_H */
diff --git a/arch/mips/include/asm/mach-au1x00/prom.h b/arch/mips/include/asm/mach-au1x00/prom.h
new file mode 100644
index 000000000000..e38715577c51
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/prom.h
@@ -0,0 +1,13 @@
1#ifndef __AU1X00_PROM_H
2#define __AU1X00_PROM_H
3
4extern int prom_argc;
5extern char **prom_argv;
6extern char **prom_envp;
7
8extern void prom_init_cmdline(void);
9extern char *prom_getcmdline(void);
10extern char *prom_getenv(char *envname);
11extern int prom_get_ethernet_addr(char *ethernet_addr);
12
13#endif
diff --git a/arch/mips/include/asm/mach-au1x00/war.h b/arch/mips/include/asm/mach-au1x00/war.h
new file mode 100644
index 000000000000..dd57d03d68ba
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_AU1X00_WAR_H
9#define __ASM_MIPS_MACH_AU1X00_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_AU1X00_WAR_H */
diff --git a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
new file mode 100644
index 000000000000..d008f47a28bd
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef __ASM_BCM47XX_H
20#define __ASM_BCM47XX_H
21
22/* SSB bus */
23extern struct ssb_bus ssb_bcm47xx;
24
25#endif /* __ASM_BCM47XX_H */
diff --git a/arch/mips/include/asm/mach-bcm47xx/gpio.h b/arch/mips/include/asm/mach-bcm47xx/gpio.h
new file mode 100644
index 000000000000..cfc8f4d618ce
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h
@@ -0,0 +1,59 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
7 */
8
9#ifndef __BCM47XX_GPIO_H
10#define __BCM47XX_GPIO_H
11
12#define BCM47XX_EXTIF_GPIO_LINES 5
13#define BCM47XX_CHIPCO_GPIO_LINES 16
14
15extern int bcm47xx_gpio_to_irq(unsigned gpio);
16extern int bcm47xx_gpio_get_value(unsigned gpio);
17extern void bcm47xx_gpio_set_value(unsigned gpio, int value);
18extern int bcm47xx_gpio_direction_input(unsigned gpio);
19extern int bcm47xx_gpio_direction_output(unsigned gpio, int value);
20
21static inline int gpio_request(unsigned gpio, const char *label)
22{
23 return 0;
24}
25
26static inline void gpio_free(unsigned gpio)
27{
28}
29
30static inline int gpio_to_irq(unsigned gpio)
31{
32 return bcm47xx_gpio_to_irq(gpio);
33}
34
35static inline int gpio_get_value(unsigned gpio)
36{
37 return bcm47xx_gpio_get_value(gpio);
38}
39
40static inline void gpio_set_value(unsigned gpio, int value)
41{
42 bcm47xx_gpio_set_value(gpio, value);
43}
44
45static inline int gpio_direction_input(unsigned gpio)
46{
47 return bcm47xx_gpio_direction_input(gpio);
48}
49
50static inline int gpio_direction_output(unsigned gpio, int value)
51{
52 return bcm47xx_gpio_direction_output(gpio, value);
53}
54
55
56/* cansleep wrappers */
57#include <asm-generic/gpio.h>
58
59#endif /* __BCM47XX_GPIO_H */
diff --git a/arch/mips/include/asm/mach-bcm47xx/war.h b/arch/mips/include/asm/mach-bcm47xx/war.h
new file mode 100644
index 000000000000..4a2b7986b582
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm47xx/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_BCM947XX_WAR_H
9#define __ASM_MIPS_MACH_BCM947XX_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_BCM947XX_WAR_H */
diff --git a/arch/mips/include/asm/mach-cobalt/cobalt.h b/arch/mips/include/asm/mach-cobalt/cobalt.h
new file mode 100644
index 000000000000..5b9fce73f11d
--- /dev/null
+++ b/arch/mips/include/asm/mach-cobalt/cobalt.h
@@ -0,0 +1,22 @@
1/*
2 * The Cobalt board ID information.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1997 Cobalt Microserver
9 * Copyright (C) 1997, 2003 Ralf Baechle
10 * Copyright (C) 2001, 2002, 2003 Liam Davies (ldavies@agile.tv)
11 */
12#ifndef __ASM_COBALT_H
13#define __ASM_COBALT_H
14
15extern int cobalt_board_id;
16
17#define COBALT_BRD_ID_QUBE1 0x3
18#define COBALT_BRD_ID_RAQ1 0x4
19#define COBALT_BRD_ID_QUBE2 0x5
20#define COBALT_BRD_ID_RAQ2 0x6
21
22#endif /* __ASM_COBALT_H */
diff --git a/arch/mips/include/asm/mach-cobalt/cpu-feature-overrides.h b/arch/mips/include/asm/mach-cobalt/cpu-feature-overrides.h
new file mode 100644
index 000000000000..b3314cf53194
--- /dev/null
+++ b/arch/mips/include/asm/mach-cobalt/cpu-feature-overrides.h
@@ -0,0 +1,56 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2006, 07 Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef __ASM_COBALT_CPU_FEATURE_OVERRIDES_H
9#define __ASM_COBALT_CPU_FEATURE_OVERRIDES_H
10
11
12#define cpu_has_tlb 1
13#define cpu_has_4kex 1
14#define cpu_has_3k_cache 0
15#define cpu_has_4k_cache 1
16#define cpu_has_tx39_cache 0
17#define cpu_has_fpu 1
18#define cpu_has_32fpr 1
19#define cpu_has_counter 1
20#define cpu_has_watch 0
21#define cpu_has_divec 1
22#define cpu_has_vce 0
23#define cpu_has_cache_cdex_p 0
24#define cpu_has_cache_cdex_s 0
25#define cpu_has_prefetch 0
26#define cpu_has_mcheck 0
27#define cpu_has_ejtag 0
28
29#define cpu_has_inclusive_pcaches 0
30#define cpu_dcache_line_size() 32
31#define cpu_icache_line_size() 32
32#define cpu_scache_line_size() 0
33
34#ifdef CONFIG_64BIT
35#define cpu_has_llsc 0
36#else
37#define cpu_has_llsc 1
38#endif
39
40#define cpu_has_mips16 0
41#define cpu_has_mdmx 0
42#define cpu_has_mips3d 0
43#define cpu_has_smartmips 0
44#define cpu_has_vtag_icache 0
45#define cpu_has_ic_fills_f_dc 0
46#define cpu_icache_snoops_remote_store 0
47#define cpu_has_dsp 0
48#define cpu_has_mipsmt 0
49#define cpu_has_userlocal 0
50
51#define cpu_has_mips32r1 0
52#define cpu_has_mips32r2 0
53#define cpu_has_mips64r1 0
54#define cpu_has_mips64r2 0
55
56#endif /* __ASM_COBALT_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-cobalt/irq.h b/arch/mips/include/asm/mach-cobalt/irq.h
new file mode 100644
index 000000000000..57c8c9ac5851
--- /dev/null
+++ b/arch/mips/include/asm/mach-cobalt/irq.h
@@ -0,0 +1,57 @@
1/*
2 * Cobalt IRQ definitions.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1997 Cobalt Microserver
9 * Copyright (C) 1997, 2003 Ralf Baechle
10 * Copyright (C) 2001-2003 Liam Davies (ldavies@agile.tv)
11 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
12 */
13#ifndef _ASM_COBALT_IRQ_H
14#define _ASM_COBALT_IRQ_H
15
16/*
17 * i8259 interrupts used on Cobalt:
18 *
19 * 8 - RTC
20 * 9 - PCI slot
21 * 14 - IDE0
22 * 15 - IDE1(no connector on board)
23 */
24#define I8259A_IRQ_BASE 0
25
26#define PCISLOT_IRQ (I8259A_IRQ_BASE + 9)
27
28/*
29 * CPU interrupts used on Cobalt:
30 *
31 * 0 - Software interrupt 0 (unused)
32 * 1 - Software interrupt 0 (unused)
33 * 2 - cascade GT64111
34 * 3 - ethernet or SCSI host controller
35 * 4 - ethernet
36 * 5 - 16550 UART
37 * 6 - cascade i8259
38 * 7 - CP0 counter
39 */
40#define MIPS_CPU_IRQ_BASE 16
41
42#define GT641XX_CASCADE_IRQ (MIPS_CPU_IRQ_BASE + 2)
43#define RAQ2_SCSI_IRQ (MIPS_CPU_IRQ_BASE + 3)
44#define ETH0_IRQ (MIPS_CPU_IRQ_BASE + 3)
45#define QUBE1_ETH0_IRQ (MIPS_CPU_IRQ_BASE + 4)
46#define ETH1_IRQ (MIPS_CPU_IRQ_BASE + 4)
47#define SERIAL_IRQ (MIPS_CPU_IRQ_BASE + 5)
48#define SCSI_IRQ (MIPS_CPU_IRQ_BASE + 5)
49#define I8259_CASCADE_IRQ (MIPS_CPU_IRQ_BASE + 6)
50
51#define GT641XX_IRQ_BASE 24
52
53#include <asm/irq_gt641xx.h>
54
55#define NR_IRQS (GT641XX_PCI_INT3_IRQ + 1)
56
57#endif /* _ASM_COBALT_IRQ_H */
diff --git a/arch/mips/include/asm/mach-cobalt/mach-gt64120.h b/arch/mips/include/asm/mach-cobalt/mach-gt64120.h
new file mode 100644
index 000000000000..ae9c5523c7ef
--- /dev/null
+++ b/arch/mips/include/asm/mach-cobalt/mach-gt64120.h
@@ -0,0 +1,27 @@
1/*
2 * Copyright (C) 2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef _COBALT_MACH_GT64120_H
19#define _COBALT_MACH_GT64120_H
20
21/*
22 * Cobalt uses GT64111. GT64111 is almost the same as GT64120.
23 */
24
25#define GT64120_BASE CKSEG1ADDR(GT_DEF_BASE)
26
27#endif /* _COBALT_MACH_GT64120_H */
diff --git a/arch/mips/include/asm/mach-cobalt/war.h b/arch/mips/include/asm/mach-cobalt/war.h
new file mode 100644
index 000000000000..97884fd18ac0
--- /dev/null
+++ b/arch/mips/include/asm/mach-cobalt/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_COBALT_WAR_H
9#define __ASM_MIPS_MACH_COBALT_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_COBALT_WAR_H */
diff --git a/arch/mips/include/asm/mach-db1x00/db1200.h b/arch/mips/include/asm/mach-db1x00/db1200.h
new file mode 100644
index 000000000000..27f26102b1bb
--- /dev/null
+++ b/arch/mips/include/asm/mach-db1x00/db1200.h
@@ -0,0 +1,230 @@
1/*
2 * AMD Alchemy DBAu1200 Reference Board
3 * Board register defines.
4 *
5 * ########################################################################
6 *
7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 *
20 * ########################################################################
21 *
22 *
23 */
24#ifndef __ASM_DB1200_H
25#define __ASM_DB1200_H
26
27#include <linux/types.h>
28#include <asm/mach-au1x00/au1xxx_psc.h>
29
30#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
31#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
32#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX
33#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX
34
35/*
36 * SPI and SMB are muxed on the DBAu1200 board.
37 * Refer to board documentation.
38 */
39#define SPI_PSC_BASE PSC0_BASE_ADDR
40#define SMBUS_PSC_BASE PSC0_BASE_ADDR
41/*
42 * AC'97 and I2S are muxed on the DBAu1200 board.
43 * Refer to board documentation.
44 */
45#define AC97_PSC_BASE PSC1_BASE_ADDR
46#define I2S_PSC_BASE PSC1_BASE_ADDR
47
48#define BCSR_KSEG1_ADDR 0xB9800000
49
50typedef volatile struct
51{
52 /*00*/ u16 whoami;
53 u16 reserved0;
54 /*04*/ u16 status;
55 u16 reserved1;
56 /*08*/ u16 switches;
57 u16 reserved2;
58 /*0C*/ u16 resets;
59 u16 reserved3;
60
61 /*10*/ u16 pcmcia;
62 u16 reserved4;
63 /*14*/ u16 board;
64 u16 reserved5;
65 /*18*/ u16 disk_leds;
66 u16 reserved6;
67 /*1C*/ u16 system;
68 u16 reserved7;
69
70 /*20*/ u16 intclr;
71 u16 reserved8;
72 /*24*/ u16 intset;
73 u16 reserved9;
74 /*28*/ u16 intclr_mask;
75 u16 reserved10;
76 /*2C*/ u16 intset_mask;
77 u16 reserved11;
78
79 /*30*/ u16 sig_status;
80 u16 reserved12;
81 /*34*/ u16 int_status;
82 u16 reserved13;
83 /*38*/ u16 reserved14;
84 u16 reserved15;
85 /*3C*/ u16 reserved16;
86 u16 reserved17;
87
88} BCSR;
89
90static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
91
92/*
93 * Register bit definitions for the BCSRs
94 */
95#define BCSR_WHOAMI_DCID 0x000F
96#define BCSR_WHOAMI_CPLD 0x00F0
97#define BCSR_WHOAMI_BOARD 0x0F00
98
99#define BCSR_STATUS_PCMCIA0VS 0x0003
100#define BCSR_STATUS_PCMCIA1VS 0x000C
101#define BCSR_STATUS_SWAPBOOT 0x0040
102#define BCSR_STATUS_FLASHBUSY 0x0100
103#define BCSR_STATUS_IDECBLID 0x0200
104#define BCSR_STATUS_SD0WP 0x0400
105#define BCSR_STATUS_U0RXD 0x1000
106#define BCSR_STATUS_U1RXD 0x2000
107
108#define BCSR_SWITCHES_OCTAL 0x00FF
109#define BCSR_SWITCHES_DIP_1 0x0080
110#define BCSR_SWITCHES_DIP_2 0x0040
111#define BCSR_SWITCHES_DIP_3 0x0020
112#define BCSR_SWITCHES_DIP_4 0x0010
113#define BCSR_SWITCHES_DIP_5 0x0008
114#define BCSR_SWITCHES_DIP_6 0x0004
115#define BCSR_SWITCHES_DIP_7 0x0002
116#define BCSR_SWITCHES_DIP_8 0x0001
117#define BCSR_SWITCHES_ROTARY 0x0F00
118
119#define BCSR_RESETS_ETH 0x0001
120#define BCSR_RESETS_CAMERA 0x0002
121#define BCSR_RESETS_DC 0x0004
122#define BCSR_RESETS_IDE 0x0008
123#define BCSR_RESETS_TV 0x0010
124/* Not resets but in the same register */
125#define BCSR_RESETS_PWMR1MUX 0x0800
126#define BCSR_RESETS_PCS0MUX 0x1000
127#define BCSR_RESETS_PCS1MUX 0x2000
128#define BCSR_RESETS_SPISEL 0x4000
129
130#define BCSR_PCMCIA_PC0VPP 0x0003
131#define BCSR_PCMCIA_PC0VCC 0x000C
132#define BCSR_PCMCIA_PC0DRVEN 0x0010
133#define BCSR_PCMCIA_PC0RST 0x0080
134#define BCSR_PCMCIA_PC1VPP 0x0300
135#define BCSR_PCMCIA_PC1VCC 0x0C00
136#define BCSR_PCMCIA_PC1DRVEN 0x1000
137#define BCSR_PCMCIA_PC1RST 0x8000
138
139#define BCSR_BOARD_LCDVEE 0x0001
140#define BCSR_BOARD_LCDVDD 0x0002
141#define BCSR_BOARD_LCDBL 0x0004
142#define BCSR_BOARD_CAMSNAP 0x0010
143#define BCSR_BOARD_CAMPWR 0x0020
144#define BCSR_BOARD_SD0PWR 0x0040
145
146#define BCSR_LEDS_DECIMALS 0x0003
147#define BCSR_LEDS_LED0 0x0100
148#define BCSR_LEDS_LED1 0x0200
149#define BCSR_LEDS_LED2 0x0400
150#define BCSR_LEDS_LED3 0x0800
151
152#define BCSR_SYSTEM_POWEROFF 0x4000
153#define BCSR_SYSTEM_RESET 0x8000
154
155/* Bit positions for the different interrupt sources */
156#define BCSR_INT_IDE 0x0001
157#define BCSR_INT_ETH 0x0002
158#define BCSR_INT_PC0 0x0004
159#define BCSR_INT_PC0STSCHG 0x0008
160#define BCSR_INT_PC1 0x0010
161#define BCSR_INT_PC1STSCHG 0x0020
162#define BCSR_INT_DC 0x0040
163#define BCSR_INT_FLASHBUSY 0x0080
164#define BCSR_INT_PC0INSERT 0x0100
165#define BCSR_INT_PC0EJECT 0x0200
166#define BCSR_INT_PC1INSERT 0x0400
167#define BCSR_INT_PC1EJECT 0x0800
168#define BCSR_INT_SD0INSERT 0x1000
169#define BCSR_INT_SD0EJECT 0x2000
170
171#define SMC91C111_PHYS_ADDR 0x19000300
172#define SMC91C111_INT DB1200_ETH_INT
173
174#define IDE_PHYS_ADDR 0x18800000
175#define IDE_REG_SHIFT 5
176#define IDE_PHYS_LEN (16 << IDE_REG_SHIFT)
177#define IDE_INT DB1200_IDE_INT
178#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1
179#define IDE_RQSIZE 128
180
181#define NAND_PHYS_ADDR 0x20000000
182
183/*
184 * External Interrupts for DBAu1200 as of 8/6/2004.
185 * Bit positions in the CPLD registers can be calculated by taking
186 * the interrupt define and subtracting the DB1200_INT_BEGIN value.
187 *
188 * Example: IDE bis pos is = 64 - 64
189 * ETH bit pos is = 65 - 64
190 */
191enum external_pb1200_ints {
192 DB1200_INT_BEGIN = AU1000_MAX_INTR + 1,
193
194 DB1200_IDE_INT = DB1200_INT_BEGIN,
195 DB1200_ETH_INT,
196 DB1200_PC0_INT,
197 DB1200_PC0_STSCHG_INT,
198 DB1200_PC1_INT,
199 DB1200_PC1_STSCHG_INT,
200 DB1200_DC_INT,
201 DB1200_FLASHBUSY_INT,
202 DB1200_PC0_INSERT_INT,
203 DB1200_PC0_EJECT_INT,
204 DB1200_PC1_INSERT_INT,
205 DB1200_PC1_EJECT_INT,
206 DB1200_SD0_INSERT_INT,
207 DB1200_SD0_EJECT_INT,
208
209 DB1200_INT_END = DB1200_INT_BEGIN + 15,
210};
211
212
213/*
214 * DBAu1200 specific PCMCIA defines for drivers/pcmcia/au1000_db1x00.c
215 */
216#define PCMCIA_MAX_SOCK 1
217#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
218
219/* VPP/VCC */
220#define SET_VCC_VPP(VCC, VPP, SLOT) \
221 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
222
223#define BOARD_PC0_INT DB1200_PC0_INT
224#define BOARD_PC1_INT DB1200_PC1_INT
225#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1 << (8 + (2 * SOCKET)))
226
227/* NAND chip select */
228#define NAND_CS 1
229
230#endif /* __ASM_DB1200_H */
diff --git a/arch/mips/include/asm/mach-db1x00/db1x00.h b/arch/mips/include/asm/mach-db1x00/db1x00.h
new file mode 100644
index 000000000000..1a515b8c870f
--- /dev/null
+++ b/arch/mips/include/asm/mach-db1x00/db1x00.h
@@ -0,0 +1,179 @@
1/*
2 * AMD Alchemy DBAu1x00 Reference Boards
3 *
4 * Copyright 2001, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. <source@mvista.com>
6 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
7 *
8 * ########################################################################
9 *
10 * This program is free software; you can distribute it and/or modify it
11 * under the terms of the GNU General Public License (Version 2) as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * ########################################################################
24 *
25 *
26 */
27#ifndef __ASM_DB1X00_H
28#define __ASM_DB1X00_H
29
30#include <asm/mach-au1x00/au1xxx_psc.h>
31
32#ifdef CONFIG_MIPS_DB1550
33
34#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
35#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
36#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC3_TX
37#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC3_RX
38
39#define SPI_PSC_BASE PSC0_BASE_ADDR
40#define AC97_PSC_BASE PSC1_BASE_ADDR
41#define SMBUS_PSC_BASE PSC2_BASE_ADDR
42#define I2S_PSC_BASE PSC3_BASE_ADDR
43
44#define BCSR_KSEG1_ADDR 0xAF000000
45#define NAND_PHYS_ADDR 0x20000000
46
47#else
48#define BCSR_KSEG1_ADDR 0xAE000000
49#endif
50
51/*
52 * Overlay data structure of the DBAu1x00 board registers.
53 * Registers are located at physical 0E0000xx, KSEG1 0xAE0000xx.
54 */
55typedef volatile struct
56{
57 /*00*/ unsigned short whoami;
58 unsigned short reserved0;
59 /*04*/ unsigned short status;
60 unsigned short reserved1;
61 /*08*/ unsigned short switches;
62 unsigned short reserved2;
63 /*0C*/ unsigned short resets;
64 unsigned short reserved3;
65 /*10*/ unsigned short pcmcia;
66 unsigned short reserved4;
67 /*14*/ unsigned short specific;
68 unsigned short reserved5;
69 /*18*/ unsigned short leds;
70 unsigned short reserved6;
71 /*1C*/ unsigned short swreset;
72 unsigned short reserved7;
73
74} BCSR;
75
76
77/*
78 * Register/mask bit definitions for the BCSRs
79 */
80#define BCSR_WHOAMI_DCID 0x000F
81#define BCSR_WHOAMI_CPLD 0x00F0
82#define BCSR_WHOAMI_BOARD 0x0F00
83
84#define BCSR_STATUS_PC0VS 0x0003
85#define BCSR_STATUS_PC1VS 0x000C
86#define BCSR_STATUS_PC0FI 0x0010
87#define BCSR_STATUS_PC1FI 0x0020
88#define BCSR_STATUS_FLASHBUSY 0x0100
89#define BCSR_STATUS_ROMBUSY 0x0400
90#define BCSR_STATUS_SWAPBOOT 0x2000
91#define BCSR_STATUS_FLASHDEN 0xC000
92
93#define BCSR_SWITCHES_DIP 0x00FF
94#define BCSR_SWITCHES_DIP_1 0x0080
95#define BCSR_SWITCHES_DIP_2 0x0040
96#define BCSR_SWITCHES_DIP_3 0x0020
97#define BCSR_SWITCHES_DIP_4 0x0010
98#define BCSR_SWITCHES_DIP_5 0x0008
99#define BCSR_SWITCHES_DIP_6 0x0004
100#define BCSR_SWITCHES_DIP_7 0x0002
101#define BCSR_SWITCHES_DIP_8 0x0001
102#define BCSR_SWITCHES_ROTARY 0x0F00
103
104#define BCSR_RESETS_PHY0 0x0001
105#define BCSR_RESETS_PHY1 0x0002
106#define BCSR_RESETS_DC 0x0004
107#define BCSR_RESETS_FIR_SEL 0x2000
108#define BCSR_RESETS_IRDA_MODE_MASK 0xC000
109#define BCSR_RESETS_IRDA_MODE_FULL 0x0000
110#define BCSR_RESETS_IRDA_MODE_OFF 0x4000
111#define BCSR_RESETS_IRDA_MODE_2_3 0x8000
112#define BCSR_RESETS_IRDA_MODE_1_3 0xC000
113
114#define BCSR_PCMCIA_PC0VPP 0x0003
115#define BCSR_PCMCIA_PC0VCC 0x000C
116#define BCSR_PCMCIA_PC0DRVEN 0x0010
117#define BCSR_PCMCIA_PC0RST 0x0080
118#define BCSR_PCMCIA_PC1VPP 0x0300
119#define BCSR_PCMCIA_PC1VCC 0x0C00
120#define BCSR_PCMCIA_PC1DRVEN 0x1000
121#define BCSR_PCMCIA_PC1RST 0x8000
122
123#define BCSR_BOARD_PCIM66EN 0x0001
124#define BCSR_BOARD_SD0_PWR 0x0040
125#define BCSR_BOARD_SD1_PWR 0x0080
126#define BCSR_BOARD_PCIM33 0x0100
127#define BCSR_BOARD_GPIO200RST 0x0400
128#define BCSR_BOARD_PCICFG 0x1000
129#define BCSR_BOARD_SD0_WP 0x4000
130#define BCSR_BOARD_SD1_WP 0x8000
131
132#define BCSR_LEDS_DECIMALS 0x0003
133#define BCSR_LEDS_LED0 0x0100
134#define BCSR_LEDS_LED1 0x0200
135#define BCSR_LEDS_LED2 0x0400
136#define BCSR_LEDS_LED3 0x0800
137
138#define BCSR_SWRESET_RESET 0x0080
139
140/* PCMCIA DBAu1x00 specific defines */
141#define PCMCIA_MAX_SOCK 1
142#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
143
144/* VPP/VCC */
145#define SET_VCC_VPP(VCC, VPP, SLOT)\
146 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
147
148/*
149 * NAND defines
150 *
151 * Timing values as described in databook, * ns value stripped of the
152 * lower 2 bits.
153 * These defines are here rather than an Au1550 generic file because
154 * the parts chosen on another board may be different and may require
155 * different timings.
156 */
157#define NAND_T_H (18 >> 2)
158#define NAND_T_PUL (30 >> 2)
159#define NAND_T_SU (30 >> 2)
160#define NAND_T_WH (30 >> 2)
161
162/* Bitfield shift amounts */
163#define NAND_T_H_SHIFT 0
164#define NAND_T_PUL_SHIFT 4
165#define NAND_T_SU_SHIFT 8
166#define NAND_T_WH_SHIFT 12
167
168#define NAND_TIMING (((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \
169 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \
170 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \
171 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT))
172#define NAND_CS 1
173
174/* Should be done by YAMON */
175#define NAND_STCFG 0x00400005 /* 8-bit NAND */
176#define NAND_STTIME 0x00007774 /* valid for 396 MHz SD=2 only */
177#define NAND_STADDR 0x12000FFF /* physical address 0x20000000 */
178
179#endif /* __ASM_DB1X00_H */
diff --git a/arch/mips/include/asm/mach-dec/mc146818rtc.h b/arch/mips/include/asm/mach-dec/mc146818rtc.h
new file mode 100644
index 000000000000..6724e99e43e1
--- /dev/null
+++ b/arch/mips/include/asm/mach-dec/mc146818rtc.h
@@ -0,0 +1,43 @@
1/*
2 * RTC definitions for DECstation style attached Dallas DS1287 chip.
3 *
4 * Copyright (C) 1998, 2001 by Ralf Baechle
5 * Copyright (C) 1998 by Harald Koerfgen
6 * Copyright (C) 2002, 2005 Maciej W. Rozycki
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#ifndef __ASM_MIPS_DEC_RTC_DEC_H
14#define __ASM_MIPS_DEC_RTC_DEC_H
15
16#include <linux/types.h>
17#include <asm/addrspace.h>
18#include <asm/dec/system.h>
19
20extern volatile u8 *dec_rtc_base;
21
22#define ARCH_RTC_LOCATION
23
24#define RTC_PORT(x) CPHYSADDR((long)dec_rtc_base)
25#define RTC_IO_EXTENT dec_kn_slot_size
26#define RTC_IOMAPPED 0
27#undef RTC_IRQ
28
29#define RTC_DEC_YEAR 0x3f /* Where we store the real year on DECs. */
30
31static inline unsigned char CMOS_READ(unsigned long addr)
32{
33 return dec_rtc_base[addr * 4];
34}
35
36static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
37{
38 dec_rtc_base[addr * 4] = data;
39}
40
41#define RTC_ALWAYS_BCD 0
42
43#endif /* __ASM_MIPS_DEC_RTC_DEC_H */
diff --git a/arch/mips/include/asm/mach-dec/war.h b/arch/mips/include/asm/mach-dec/war.h
new file mode 100644
index 000000000000..ca5e2ef909ad
--- /dev/null
+++ b/arch/mips/include/asm/mach-dec/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_DEC_WAR_H
9#define __ASM_MIPS_MACH_DEC_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_DEC_WAR_H */
diff --git a/arch/mips/include/asm/mach-emma2rh/irq.h b/arch/mips/include/asm/mach-emma2rh/irq.h
new file mode 100644
index 000000000000..5439eb856461
--- /dev/null
+++ b/arch/mips/include/asm/mach-emma2rh/irq.h
@@ -0,0 +1,15 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_EMMA2RH_IRQ_H
9#define __ASM_MACH_EMMA2RH_IRQ_H
10
11#define NR_IRQS 256
12
13#include_next <irq.h>
14
15#endif /* __ASM_MACH_EMMA2RH_IRQ_H */
diff --git a/arch/mips/include/asm/mach-emma2rh/war.h b/arch/mips/include/asm/mach-emma2rh/war.h
new file mode 100644
index 000000000000..b660a4c30e6a
--- /dev/null
+++ b/arch/mips/include/asm/mach-emma2rh/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_EMMA2RH_WAR_H
9#define __ASM_MIPS_MACH_EMMA2RH_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_EMMA2RH_WAR_H */
diff --git a/arch/mips/include/asm/mach-excite/cpu-feature-overrides.h b/arch/mips/include/asm/mach-excite/cpu-feature-overrides.h
new file mode 100644
index 000000000000..107104c3cd12
--- /dev/null
+++ b/arch/mips/include/asm/mach-excite/cpu-feature-overrides.h
@@ -0,0 +1,48 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2004 Thomas Koeller <thomas.koeller@baslerweb.com>
7 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
8 */
9#ifndef __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H
10#define __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H
11
12/*
13 * Basler eXcite has an RM9122 processor.
14 */
15#define cpu_has_watch 1
16#define cpu_has_mips16 0
17#define cpu_has_divec 0
18#define cpu_has_vce 0
19#define cpu_has_cache_cdex_p 0
20#define cpu_has_cache_cdex_s 0
21#define cpu_has_prefetch 1
22#define cpu_has_mcheck 0
23#define cpu_has_ejtag 0
24
25#define cpu_has_llsc 1
26#define cpu_has_vtag_icache 0
27#define cpu_has_dc_aliases 0
28#define cpu_has_ic_fills_f_dc 0
29#define cpu_has_dsp 0
30#define cpu_icache_snoops_remote_store 0
31#define cpu_has_mipsmt 0
32#define cpu_has_userlocal 0
33
34#define cpu_has_nofpuex 0
35#define cpu_has_64bits 1
36
37#define cpu_has_mips32r1 0
38#define cpu_has_mips32r2 0
39#define cpu_has_mips64r1 0
40#define cpu_has_mips64r2 0
41
42#define cpu_has_inclusive_pcaches 0
43
44#define cpu_dcache_line_size() 32
45#define cpu_icache_line_size() 32
46#define cpu_scache_line_size() 32
47
48#endif /* __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-excite/excite.h b/arch/mips/include/asm/mach-excite/excite.h
new file mode 100644
index 000000000000..4c29ba44992c
--- /dev/null
+++ b/arch/mips/include/asm/mach-excite/excite.h
@@ -0,0 +1,154 @@
1#ifndef __EXCITE_H__
2#define __EXCITE_H__
3
4#include <linux/init.h>
5#include <asm/addrspace.h>
6#include <asm/types.h>
7
8#define EXCITE_CPU_EXT_CLOCK 100000000
9
10#if !defined(__ASSEMBLY__)
11void __init excite_kgdb_init(void);
12void excite_procfs_init(void);
13extern unsigned long memsize;
14extern char modetty[];
15extern u32 unit_id;
16#endif
17
18/* Base name for XICAP devices */
19#define XICAP_NAME "xicap_gpi"
20
21/* OCD register offsets */
22#define LKB0 0x0038
23#define LKB5 0x0128
24#define LKM5 0x012C
25#define LKB7 0x0138
26#define LKM7 0x013c
27#define LKB8 0x0140
28#define LKM8 0x0144
29#define LKB9 0x0148
30#define LKM9 0x014c
31#define LKB10 0x0150
32#define LKM10 0x0154
33#define LKB11 0x0158
34#define LKM11 0x015c
35#define LKB12 0x0160
36#define LKM12 0x0164
37#define LKB13 0x0168
38#define LKM13 0x016c
39#define LDP0 0x0200
40#define LDP1 0x0210
41#define LDP2 0x0220
42#define LDP3 0x0230
43#define INTPIN0 0x0A40
44#define INTPIN1 0x0A44
45#define INTPIN2 0x0A48
46#define INTPIN3 0x0A4C
47#define INTPIN4 0x0A50
48#define INTPIN5 0x0A54
49#define INTPIN6 0x0A58
50#define INTPIN7 0x0A5C
51
52
53
54
55/* TITAN register offsets */
56#define CPRR 0x0004
57#define CPDSR 0x0008
58#define CPTC0R 0x000c
59#define CPTC1R 0x0010
60#define CPCFG0 0x0020
61#define CPCFG1 0x0024
62#define CPDST0A 0x0028
63#define CPDST0B 0x002c
64#define CPDST1A 0x0030
65#define CPDST1B 0x0034
66#define CPXDSTA 0x0038
67#define CPXDSTB 0x003c
68#define CPXCISRA 0x0048
69#define CPXCISRB 0x004c
70#define CPGIG0ER 0x0050
71#define CPGIG1ER 0x0054
72#define CPGRWL 0x0068
73#define CPURSLMT 0x00f8
74#define UACFG 0x0200
75#define UAINTS 0x0204
76#define SDRXFCIE 0x4828
77#define SDTXFCIE 0x4928
78#define INTP0Status0 0x1B00
79#define INTP0Mask0 0x1B04
80#define INTP0Set0 0x1B08
81#define INTP0Clear0 0x1B0C
82#define GXCFG 0x5000
83#define GXDMADRPFX 0x5018
84#define GXDMA_DESCADR 0x501c
85#define GXCH0TDESSTRT 0x5054
86
87/* IRQ definitions */
88#define NMICONFIG 0xac0
89#define TITAN_MSGINT 0xc4
90#define TITAN_IRQ ((TITAN_MSGINT / 0x20) + 2)
91#define FPGA0_MSGINT 0x5a
92#define FPGA0_IRQ ((FPGA0_MSGINT / 0x20) + 2)
93#define FPGA1_MSGINT 0x7b
94#define FPGA1_IRQ ((FPGA1_MSGINT / 0x20) + 2)
95#define PHY_MSGINT 0x9c
96#define PHY_IRQ ((PHY_MSGINT / 0x20) + 2)
97
98#if defined(CONFIG_BASLER_EXCITE_PROTOTYPE)
99/* Pre-release units used interrupt pin #9 */
100#define USB_IRQ 11
101#else
102/* Re-designed units use interrupt pin #1 */
103#define USB_MSGINT 0x39
104#define USB_IRQ ((USB_MSGINT / 0x20) + 2)
105#endif
106#define TIMER_IRQ 12
107
108
109/* Device address ranges */
110#define EXCITE_OFFS_OCD 0x1fffc000
111#define EXCITE_SIZE_OCD (16 * 1024)
112#define EXCITE_PHYS_OCD CPHYSADDR(EXCITE_OFFS_OCD)
113#define EXCITE_ADDR_OCD CKSEG1ADDR(EXCITE_OFFS_OCD)
114
115#define EXCITE_OFFS_SCRAM 0x1fffa000
116#define EXCITE_SIZE_SCRAM (8 << 10)
117#define EXCITE_PHYS_SCRAM CPHYSADDR(EXCITE_OFFS_SCRAM)
118#define EXCITE_ADDR_SCRAM CKSEG1ADDR(EXCITE_OFFS_SCRAM)
119
120#define EXCITE_OFFS_PCI_IO 0x1fff8000
121#define EXCITE_SIZE_PCI_IO (8 << 10)
122#define EXCITE_PHYS_PCI_IO CPHYSADDR(EXCITE_OFFS_PCI_IO)
123#define EXCITE_ADDR_PCI_IO CKSEG1ADDR(EXCITE_OFFS_PCI_IO)
124
125#define EXCITE_OFFS_TITAN 0x1fff0000
126#define EXCITE_SIZE_TITAN (32 << 10)
127#define EXCITE_PHYS_TITAN CPHYSADDR(EXCITE_OFFS_TITAN)
128#define EXCITE_ADDR_TITAN CKSEG1ADDR(EXCITE_OFFS_TITAN)
129
130#define EXCITE_OFFS_PCI_MEM 0x1ffe0000
131#define EXCITE_SIZE_PCI_MEM (64 << 10)
132#define EXCITE_PHYS_PCI_MEM CPHYSADDR(EXCITE_OFFS_PCI_MEM)
133#define EXCITE_ADDR_PCI_MEM CKSEG1ADDR(EXCITE_OFFS_PCI_MEM)
134
135#define EXCITE_OFFS_FPGA 0x1ffdc000
136#define EXCITE_SIZE_FPGA (16 << 10)
137#define EXCITE_PHYS_FPGA CPHYSADDR(EXCITE_OFFS_FPGA)
138#define EXCITE_ADDR_FPGA CKSEG1ADDR(EXCITE_OFFS_FPGA)
139
140#define EXCITE_OFFS_NAND 0x1ffd8000
141#define EXCITE_SIZE_NAND (16 << 10)
142#define EXCITE_PHYS_NAND CPHYSADDR(EXCITE_OFFS_NAND)
143#define EXCITE_ADDR_NAND CKSEG1ADDR(EXCITE_OFFS_NAND)
144
145#define EXCITE_OFFS_BOOTROM 0x1f000000
146#define EXCITE_SIZE_BOOTROM (8 << 20)
147#define EXCITE_PHYS_BOOTROM CPHYSADDR(EXCITE_OFFS_BOOTROM)
148#define EXCITE_ADDR_BOOTROM CKSEG1ADDR(EXCITE_OFFS_BOOTROM)
149
150/* FPGA address offsets */
151#define EXCITE_FPGA_DPR 0x0104 /* dual-ported ram */
152#define EXCITE_FPGA_SYSCTL 0x0200 /* system control register block */
153
154#endif /* __EXCITE_H__ */
diff --git a/arch/mips/include/asm/mach-excite/excite_fpga.h b/arch/mips/include/asm/mach-excite/excite_fpga.h
new file mode 100644
index 000000000000..0a1ef69bece7
--- /dev/null
+++ b/arch/mips/include/asm/mach-excite/excite_fpga.h
@@ -0,0 +1,80 @@
1#ifndef EXCITE_FPGA_H_INCLUDED
2#define EXCITE_FPGA_H_INCLUDED
3
4
5/**
6 * Address alignment of the individual FPGA bytes.
7 * The address arrangement of the individual bytes of the FPGA is two
8 * byte aligned at the embedded MK2 platform.
9 */
10#ifdef EXCITE_CCI_FPGA_MK2
11typedef unsigned char excite_cci_fpga_align_t __attribute__ ((aligned(2)));
12#else
13typedef unsigned char excite_cci_fpga_align_t;
14#endif
15
16
17/**
18 * Size of Dual Ported RAM.
19 */
20#define EXCITE_DPR_SIZE 263
21
22
23/**
24 * Size of Reserved Status Fields in Dual Ported RAM.
25 */
26#define EXCITE_DPR_STATUS_SIZE 7
27
28
29
30/**
31 * FPGA.
32 * Hardware register layout of the FPGA interface. The FPGA must accessed
33 * byte wise solely.
34 * @see EXCITE_CCI_DPR_MK2
35 */
36typedef struct excite_fpga {
37
38 /**
39 * Dual Ported RAM.
40 */
41 excite_cci_fpga_align_t dpr[EXCITE_DPR_SIZE];
42
43 /**
44 * Status.
45 */
46 excite_cci_fpga_align_t status[EXCITE_DPR_STATUS_SIZE];
47
48#ifdef EXCITE_CCI_FPGA_MK2
49 /**
50 * RM9000 Interrupt.
51 * Write access initiates interrupt at the RM9000 (MIPS) processor of the eXcite.
52 */
53 excite_cci_fpga_align_t rm9k_int;
54#else
55 /**
56 * MK2 Interrupt.
57 * Write access initiates interrupt at the ARM processor of the MK2.
58 */
59 excite_cci_fpga_align_t mk2_int;
60
61 excite_cci_fpga_align_t gap[0x1000-0x10f];
62
63 /**
64 * IRQ Source/Acknowledge.
65 */
66 excite_cci_fpga_align_t rm9k_irq_src;
67
68 /**
69 * IRQ Mask.
70 * Set bits enable the related interrupt.
71 */
72 excite_cci_fpga_align_t rm9k_irq_mask;
73#endif
74
75
76} excite_fpga;
77
78
79
80#endif /* ndef EXCITE_FPGA_H_INCLUDED */
diff --git a/arch/mips/include/asm/mach-excite/excite_nandflash.h b/arch/mips/include/asm/mach-excite/excite_nandflash.h
new file mode 100644
index 000000000000..c4cf6140622e
--- /dev/null
+++ b/arch/mips/include/asm/mach-excite/excite_nandflash.h
@@ -0,0 +1,7 @@
1#ifndef __EXCITE_NANDFLASH_H__
2#define __EXCITE_NANDFLASH_H__
3
4/* Resource names */
5#define EXCITE_NANDFLASH_RESOURCE_REGS "excite_nandflash_regs"
6
7#endif /* __EXCITE_NANDFLASH_H__ */
diff --git a/arch/mips/include/asm/mach-excite/rm9k_eth.h b/arch/mips/include/asm/mach-excite/rm9k_eth.h
new file mode 100644
index 000000000000..94705a46f72e
--- /dev/null
+++ b/arch/mips/include/asm/mach-excite/rm9k_eth.h
@@ -0,0 +1,23 @@
1#if !defined(__RM9K_ETH_H__)
2#define __RM9K_ETH_H__
3
4#define RM9K_GE_NAME "rm9k_ge"
5
6/* Resource names */
7#define RM9K_GE_RESOURCE_MAC "rm9k_ge_mac"
8#define RM9K_GE_RESOURCE_MSTAT "rm9k_ge_mstat"
9#define RM9K_GE_RESOURCE_PKTPROC "rm9k_ge_pktproc"
10#define RM9K_GE_RESOURCE_XDMA "rm9k_ge_xdma"
11#define RM9K_GE_RESOURCE_FIFO_RX "rm9k_ge_fifo_rx"
12#define RM9K_GE_RESOURCE_FIFO_TX "rm9k_ge_fifo_tx"
13#define RM9K_GE_RESOURCE_FIFOMEM_RX "rm9k_ge_fifo_memory_rx"
14#define RM9K_GE_RESOURCE_FIFOMEM_TX "rm9k_ge_fifo_memory_tx"
15#define RM9K_GE_RESOURCE_PHY "rm9k_ge_phy"
16#define RM9K_GE_RESOURCE_DMADESC_RX "rm9k_ge_dmadesc_rx"
17#define RM9K_GE_RESOURCE_DMADESC_TX "rm9k_ge_dmadesc_tx"
18#define RM9K_GE_RESOURCE_IRQ_MAIN "rm9k_ge_irq_main"
19#define RM9K_GE_RESOURCE_IRQ_PHY "rm9k_ge_irq_phy"
20#define RM9K_GE_RESOURCE_GPI_SLICE "rm9k_ge_gpi_slice"
21#define RM9K_GE_RESOURCE_MDIO_CHANNEL "rm9k_ge_mdio_channel"
22
23#endif /* !defined(__RM9K_ETH_H__) */
diff --git a/arch/mips/include/asm/mach-excite/rm9k_wdt.h b/arch/mips/include/asm/mach-excite/rm9k_wdt.h
new file mode 100644
index 000000000000..3fa3c08d2da7
--- /dev/null
+++ b/arch/mips/include/asm/mach-excite/rm9k_wdt.h
@@ -0,0 +1,12 @@
1#ifndef __RM9K_WDT_H__
2#define __RM9K_WDT_H__
3
4/* Device name */
5#define WDT_NAME "wdt_gpi"
6
7/* Resource names */
8#define WDT_RESOURCE_REGS "excite_watchdog_regs"
9#define WDT_RESOURCE_IRQ "excite_watchdog_irq"
10#define WDT_RESOURCE_COUNTER "excite_watchdog_counter"
11
12#endif /* __RM9K_WDT_H__ */
diff --git a/arch/mips/include/asm/mach-excite/rm9k_xicap.h b/arch/mips/include/asm/mach-excite/rm9k_xicap.h
new file mode 100644
index 000000000000..009577734a8d
--- /dev/null
+++ b/arch/mips/include/asm/mach-excite/rm9k_xicap.h
@@ -0,0 +1,16 @@
1#ifndef __EXCITE_XICAP_H__
2#define __EXCITE_XICAP_H__
3
4
5/* Resource names */
6#define XICAP_RESOURCE_FIFO_RX "xicap_fifo_rx"
7#define XICAP_RESOURCE_FIFO_TX "xicap_fifo_tx"
8#define XICAP_RESOURCE_XDMA "xicap_xdma"
9#define XICAP_RESOURCE_DMADESC "xicap_dmadesc"
10#define XICAP_RESOURCE_PKTPROC "xicap_pktproc"
11#define XICAP_RESOURCE_IRQ "xicap_irq"
12#define XICAP_RESOURCE_GPI_SLICE "xicap_gpi_slice"
13#define XICAP_RESOURCE_FIFO_BLK "xicap_fifo_blocks"
14#define XICAP_RESOURCE_PKT_STREAM "xicap_pkt_stream"
15
16#endif /* __EXCITE_XICAP_H__ */
diff --git a/arch/mips/include/asm/mach-excite/war.h b/arch/mips/include/asm/mach-excite/war.h
new file mode 100644
index 000000000000..1f82180c1598
--- /dev/null
+++ b/arch/mips/include/asm/mach-excite/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_EXCITE_WAR_H
9#define __ASM_MIPS_MACH_EXCITE_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 1
21#define ICACHE_REFILLS_WORKAROUND_WAR 1
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_EXCITE_WAR_H */
diff --git a/arch/mips/include/asm/mach-generic/cpu-feature-overrides.h b/arch/mips/include/asm/mach-generic/cpu-feature-overrides.h
new file mode 100644
index 000000000000..7c185bb06f13
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/cpu-feature-overrides.h
@@ -0,0 +1,13 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 Ralf Baechle
7 */
8#ifndef __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H
10
11/* Intentionally empty file ... */
12
13#endif /* __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-generic/dma-coherence.h b/arch/mips/include/asm/mach-generic/dma-coherence.h
new file mode 100644
index 000000000000..76e04e7feb84
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/dma-coherence.h
@@ -0,0 +1,45 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
7 *
8 */
9#ifndef __ASM_MACH_GENERIC_DMA_COHERENCE_H
10#define __ASM_MACH_GENERIC_DMA_COHERENCE_H
11
12struct device;
13
14static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
15 size_t size)
16{
17 return virt_to_phys(addr);
18}
19
20static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
21 struct page *page)
22{
23 return page_to_phys(page);
24}
25
26static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
27{
28 return dma_addr;
29}
30
31static inline void plat_unmap_dma_mem(dma_addr_t dma_addr)
32{
33}
34
35static inline int plat_device_is_coherent(struct device *dev)
36{
37#ifdef CONFIG_DMA_COHERENT
38 return 1;
39#endif
40#ifdef CONFIG_DMA_NONCOHERENT
41 return 0;
42#endif
43}
44
45#endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */
diff --git a/arch/mips/include/asm/mach-generic/floppy.h b/arch/mips/include/asm/mach-generic/floppy.h
new file mode 100644
index 000000000000..001a8ce17c17
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/floppy.h
@@ -0,0 +1,139 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1998, 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_GENERIC_FLOPPY_H
9#define __ASM_MACH_GENERIC_FLOPPY_H
10
11#include <linux/delay.h>
12#include <linux/init.h>
13#include <linux/ioport.h>
14#include <linux/sched.h>
15#include <linux/linkage.h>
16#include <linux/types.h>
17#include <linux/mm.h>
18
19#include <asm/bootinfo.h>
20#include <asm/cachectl.h>
21#include <asm/dma.h>
22#include <asm/floppy.h>
23#include <asm/io.h>
24#include <asm/irq.h>
25#include <asm/pgtable.h>
26
27/*
28 * How to access the FDC's registers.
29 */
30static inline unsigned char fd_inb(unsigned int port)
31{
32 return inb_p(port);
33}
34
35static inline void fd_outb(unsigned char value, unsigned int port)
36{
37 outb_p(value, port);
38}
39
40/*
41 * How to access the floppy DMA functions.
42 */
43static inline void fd_enable_dma(void)
44{
45 enable_dma(FLOPPY_DMA);
46}
47
48static inline void fd_disable_dma(void)
49{
50 disable_dma(FLOPPY_DMA);
51}
52
53static inline int fd_request_dma(void)
54{
55 return request_dma(FLOPPY_DMA, "floppy");
56}
57
58static inline void fd_free_dma(void)
59{
60 free_dma(FLOPPY_DMA);
61}
62
63static inline void fd_clear_dma_ff(void)
64{
65 clear_dma_ff(FLOPPY_DMA);
66}
67
68static inline void fd_set_dma_mode(char mode)
69{
70 set_dma_mode(FLOPPY_DMA, mode);
71}
72
73static inline void fd_set_dma_addr(char *addr)
74{
75 set_dma_addr(FLOPPY_DMA, (unsigned long) addr);
76}
77
78static inline void fd_set_dma_count(unsigned int count)
79{
80 set_dma_count(FLOPPY_DMA, count);
81}
82
83static inline int fd_get_dma_residue(void)
84{
85 return get_dma_residue(FLOPPY_DMA);
86}
87
88static inline void fd_enable_irq(void)
89{
90 enable_irq(FLOPPY_IRQ);
91}
92
93static inline void fd_disable_irq(void)
94{
95 disable_irq(FLOPPY_IRQ);
96}
97
98static inline int fd_request_irq(void)
99{
100 return request_irq(FLOPPY_IRQ, floppy_interrupt,
101 IRQF_DISABLED, "floppy", NULL);
102}
103
104static inline void fd_free_irq(void)
105{
106 free_irq(FLOPPY_IRQ, NULL);
107}
108
109#define fd_free_irq() free_irq(FLOPPY_IRQ, NULL);
110
111
112static inline unsigned long fd_getfdaddr1(void)
113{
114 return 0x3f0;
115}
116
117static inline unsigned long fd_dma_mem_alloc(unsigned long size)
118{
119 unsigned long mem;
120
121 mem = __get_dma_pages(GFP_KERNEL, get_order(size));
122
123 return mem;
124}
125
126static inline void fd_dma_mem_free(unsigned long addr, unsigned long size)
127{
128 free_pages(addr, get_order(size));
129}
130
131static inline unsigned long fd_drive_type(unsigned long n)
132{
133 if (n == 0)
134 return 4; /* 3,5", 1.44mb */
135
136 return 0;
137}
138
139#endif /* __ASM_MACH_GENERIC_FLOPPY_H */
diff --git a/arch/mips/include/asm/mach-generic/gpio.h b/arch/mips/include/asm/mach-generic/gpio.h
new file mode 100644
index 000000000000..b4e70208da64
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/gpio.h
@@ -0,0 +1,21 @@
1#ifndef __ASM_MACH_GENERIC_GPIO_H
2#define __ASM_MACH_GENERIC_GPIO_H
3
4#ifdef CONFIG_GPIOLIB
5#define gpio_get_value __gpio_get_value
6#define gpio_set_value __gpio_set_value
7#define gpio_cansleep __gpio_cansleep
8#else
9int gpio_request(unsigned gpio, const char *label);
10void gpio_free(unsigned gpio);
11int gpio_direction_input(unsigned gpio);
12int gpio_direction_output(unsigned gpio, int value);
13int gpio_get_value(unsigned gpio);
14void gpio_set_value(unsigned gpio, int value);
15#endif
16int gpio_to_irq(unsigned gpio);
17int irq_to_gpio(unsigned irq);
18
19#include <asm-generic/gpio.h> /* cansleep wrappers */
20
21#endif /* __ASM_MACH_GENERIC_GPIO_H */
diff --git a/arch/mips/include/asm/mach-generic/ide.h b/arch/mips/include/asm/mach-generic/ide.h
new file mode 100644
index 000000000000..73008f7bdc93
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/ide.h
@@ -0,0 +1,167 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994-1996 Linus Torvalds & authors
7 *
8 * Copied from i386; many of the especially older MIPS or ISA-based platforms
9 * are basically identical. Using this file probably implies i8259 PIC
10 * support in a system but the very least interrupt numbers 0 - 15 need to
11 * be put aside for legacy devices.
12 */
13#ifndef __ASM_MACH_GENERIC_IDE_H
14#define __ASM_MACH_GENERIC_IDE_H
15
16#ifdef __KERNEL__
17
18#include <linux/pci.h>
19#include <linux/stddef.h>
20#include <asm/processor.h>
21
22static __inline__ int ide_probe_legacy(void)
23{
24#ifdef CONFIG_PCI
25 struct pci_dev *dev;
26 /*
27 * This can be called on the ide_setup() path, super-early in
28 * boot. But the down_read() will enable local interrupts,
29 * which can cause some machines to crash. So here we detect
30 * and flag that situation and bail out early.
31 */
32 if (no_pci_devices())
33 return 0;
34 dev = pci_get_class(PCI_CLASS_BRIDGE_EISA << 8, NULL);
35 if (dev)
36 goto found;
37 dev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
38 if (dev)
39 goto found;
40 return 0;
41found:
42 pci_dev_put(dev);
43 return 1;
44#elif defined(CONFIG_EISA) || defined(CONFIG_ISA)
45 return 1;
46#else
47 return 0;
48#endif
49}
50
51/* MIPS port and memory-mapped I/O string operations. */
52static inline void __ide_flush_prologue(void)
53{
54#ifdef CONFIG_SMP
55 if (cpu_has_dc_aliases)
56 preempt_disable();
57#endif
58}
59
60static inline void __ide_flush_epilogue(void)
61{
62#ifdef CONFIG_SMP
63 if (cpu_has_dc_aliases)
64 preempt_enable();
65#endif
66}
67
68static inline void __ide_flush_dcache_range(unsigned long addr, unsigned long size)
69{
70 if (cpu_has_dc_aliases) {
71 unsigned long end = addr + size;
72
73 while (addr < end) {
74 local_flush_data_cache_page((void *)addr);
75 addr += PAGE_SIZE;
76 }
77 }
78}
79
80/*
81 * insw() and gang might be called with interrupts disabled, so we can't
82 * send IPIs for flushing due to the potencial of deadlocks, see the comment
83 * above smp_call_function() in arch/mips/kernel/smp.c. We work around the
84 * problem by disabling preemption so we know we actually perform the flush
85 * on the processor that actually has the lines to be flushed which hopefully
86 * is even better for performance anyway.
87 */
88static inline void __ide_insw(unsigned long port, void *addr,
89 unsigned int count)
90{
91 __ide_flush_prologue();
92 insw(port, addr, count);
93 __ide_flush_dcache_range((unsigned long)addr, count * 2);
94 __ide_flush_epilogue();
95}
96
97static inline void __ide_insl(unsigned long port, void *addr, unsigned int count)
98{
99 __ide_flush_prologue();
100 insl(port, addr, count);
101 __ide_flush_dcache_range((unsigned long)addr, count * 4);
102 __ide_flush_epilogue();
103}
104
105static inline void __ide_outsw(unsigned long port, const void *addr,
106 unsigned long count)
107{
108 __ide_flush_prologue();
109 outsw(port, addr, count);
110 __ide_flush_dcache_range((unsigned long)addr, count * 2);
111 __ide_flush_epilogue();
112}
113
114static inline void __ide_outsl(unsigned long port, const void *addr,
115 unsigned long count)
116{
117 __ide_flush_prologue();
118 outsl(port, addr, count);
119 __ide_flush_dcache_range((unsigned long)addr, count * 4);
120 __ide_flush_epilogue();
121}
122
123static inline void __ide_mm_insw(void __iomem *port, void *addr, u32 count)
124{
125 __ide_flush_prologue();
126 readsw(port, addr, count);
127 __ide_flush_dcache_range((unsigned long)addr, count * 2);
128 __ide_flush_epilogue();
129}
130
131static inline void __ide_mm_insl(void __iomem *port, void *addr, u32 count)
132{
133 __ide_flush_prologue();
134 readsl(port, addr, count);
135 __ide_flush_dcache_range((unsigned long)addr, count * 4);
136 __ide_flush_epilogue();
137}
138
139static inline void __ide_mm_outsw(void __iomem *port, void *addr, u32 count)
140{
141 __ide_flush_prologue();
142 writesw(port, addr, count);
143 __ide_flush_dcache_range((unsigned long)addr, count * 2);
144 __ide_flush_epilogue();
145}
146
147static inline void __ide_mm_outsl(void __iomem * port, void *addr, u32 count)
148{
149 __ide_flush_prologue();
150 writesl(port, addr, count);
151 __ide_flush_dcache_range((unsigned long)addr, count * 4);
152 __ide_flush_epilogue();
153}
154
155/* ide_insw calls insw, not __ide_insw. Why? */
156#undef insw
157#undef insl
158#undef outsw
159#undef outsl
160#define insw(port, addr, count) __ide_insw(port, addr, count)
161#define insl(port, addr, count) __ide_insl(port, addr, count)
162#define outsw(port, addr, count) __ide_outsw(port, addr, count)
163#define outsl(port, addr, count) __ide_outsl(port, addr, count)
164
165#endif /* __KERNEL__ */
166
167#endif /* __ASM_MACH_GENERIC_IDE_H */
diff --git a/arch/mips/include/asm/mach-generic/ioremap.h b/arch/mips/include/asm/mach-generic/ioremap.h
new file mode 100644
index 000000000000..b379938d47f0
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/ioremap.h
@@ -0,0 +1,34 @@
1/*
2 * include/asm-mips/mach-generic/ioremap.h
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9#ifndef __ASM_MACH_GENERIC_IOREMAP_H
10#define __ASM_MACH_GENERIC_IOREMAP_H
11
12#include <linux/types.h>
13
14/*
15 * Allow physical addresses to be fixed up to help peripherals located
16 * outside the low 32-bit range -- generic pass-through version.
17 */
18static inline phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
19{
20 return phys_addr;
21}
22
23static inline void __iomem *plat_ioremap(phys_t offset, unsigned long size,
24 unsigned long flags)
25{
26 return NULL;
27}
28
29static inline int plat_iounmap(const volatile void __iomem *addr)
30{
31 return 0;
32}
33
34#endif /* __ASM_MACH_GENERIC_IOREMAP_H */
diff --git a/arch/mips/include/asm/mach-generic/irq.h b/arch/mips/include/asm/mach-generic/irq.h
new file mode 100644
index 000000000000..70d9a25132c5
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/irq.h
@@ -0,0 +1,45 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_GENERIC_IRQ_H
9#define __ASM_MACH_GENERIC_IRQ_H
10
11#ifndef NR_IRQS
12#define NR_IRQS 128
13#endif
14
15#ifdef CONFIG_I8259
16#ifndef I8259A_IRQ_BASE
17#define I8259A_IRQ_BASE 0
18#endif
19#endif
20
21#ifdef CONFIG_IRQ_CPU
22
23#ifndef MIPS_CPU_IRQ_BASE
24#ifdef CONFIG_I8259
25#define MIPS_CPU_IRQ_BASE 16
26#else
27#define MIPS_CPU_IRQ_BASE 0
28#endif /* CONFIG_I8259 */
29#endif
30
31#ifdef CONFIG_IRQ_CPU_RM7K
32#ifndef RM7K_CPU_IRQ_BASE
33#define RM7K_CPU_IRQ_BASE (MIPS_CPU_IRQ_BASE+8)
34#endif
35#endif
36
37#ifdef CONFIG_IRQ_CPU_RM9K
38#ifndef RM9K_CPU_IRQ_BASE
39#define RM9K_CPU_IRQ_BASE (MIPS_CPU_IRQ_BASE+12)
40#endif
41#endif
42
43#endif /* CONFIG_IRQ_CPU */
44
45#endif /* __ASM_MACH_GENERIC_IRQ_H */
diff --git a/arch/mips/include/asm/mach-generic/kernel-entry-init.h b/arch/mips/include/asm/mach-generic/kernel-entry-init.h
new file mode 100644
index 000000000000..7e66505fa574
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/kernel-entry-init.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005 Embedded Alley Solutions, Inc
7 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
8 */
9#ifndef __ASM_MACH_GENERIC_KERNEL_ENTRY_H
10#define __ASM_MACH_GENERIC_KERNEL_ENTRY_H
11
12/* Intentionally empty macro, used in head.S. Override in
13 * arch/mips/mach-xxx/kernel-entry-init.h when necessary.
14 */
15.macro kernel_entry_setup
16.endm
17
18/*
19 * Do SMP slave processor setup necessary before we can savely execute C code.
20 */
21 .macro smp_slave_setup
22 .endm
23
24
25#endif /* __ASM_MACH_GENERIC_KERNEL_ENTRY_H */
diff --git a/arch/mips/include/asm/mach-generic/kmalloc.h b/arch/mips/include/asm/mach-generic/kmalloc.h
new file mode 100644
index 000000000000..b8e6deba352f
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/kmalloc.h
@@ -0,0 +1,13 @@
1#ifndef __ASM_MACH_GENERIC_KMALLOC_H
2#define __ASM_MACH_GENERIC_KMALLOC_H
3
4
5#ifndef CONFIG_DMA_COHERENT
6/*
7 * Total overkill for most systems but need as a safe default.
8 * Set this one if any device in the system might do non-coherent DMA.
9 */
10#define ARCH_KMALLOC_MINALIGN 128
11#endif
12
13#endif /* __ASM_MACH_GENERIC_KMALLOC_H */
diff --git a/arch/mips/include/asm/mach-generic/mangle-port.h b/arch/mips/include/asm/mach-generic/mangle-port.h
new file mode 100644
index 000000000000..f49dc990214b
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/mangle-port.h
@@ -0,0 +1,52 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2004 Ralf Baechle
7 */
8#ifndef __ASM_MACH_GENERIC_MANGLE_PORT_H
9#define __ASM_MACH_GENERIC_MANGLE_PORT_H
10
11#define __swizzle_addr_b(port) (port)
12#define __swizzle_addr_w(port) (port)
13#define __swizzle_addr_l(port) (port)
14#define __swizzle_addr_q(port) (port)
15
16/*
17 * Sane hardware offers swapping of PCI/ISA I/O space accesses in hardware;
18 * less sane hardware forces software to fiddle with this...
19 *
20 * Regardless, if the host bus endianness mismatches that of PCI/ISA, then
21 * you can't have the numerical value of data and byte addresses within
22 * multibyte quantities both preserved at the same time. Hence two
23 * variations of functions: non-prefixed ones that preserve the value
24 * and prefixed ones that preserve byte addresses. The latters are
25 * typically used for moving raw data between a peripheral and memory (cf.
26 * string I/O functions), hence the "__mem_" prefix.
27 */
28#if defined(CONFIG_SWAP_IO_SPACE)
29
30# define ioswabb(a, x) (x)
31# define __mem_ioswabb(a, x) (x)
32# define ioswabw(a, x) le16_to_cpu(x)
33# define __mem_ioswabw(a, x) (x)
34# define ioswabl(a, x) le32_to_cpu(x)
35# define __mem_ioswabl(a, x) (x)
36# define ioswabq(a, x) le64_to_cpu(x)
37# define __mem_ioswabq(a, x) (x)
38
39#else
40
41# define ioswabb(a, x) (x)
42# define __mem_ioswabb(a, x) (x)
43# define ioswabw(a, x) (x)
44# define __mem_ioswabw(a, x) cpu_to_le16(x)
45# define ioswabl(a, x) (x)
46# define __mem_ioswabl(a, x) cpu_to_le32(x)
47# define ioswabq(a, x) (x)
48# define __mem_ioswabq(a, x) cpu_to_le32(x)
49
50#endif
51
52#endif /* __ASM_MACH_GENERIC_MANGLE_PORT_H */
diff --git a/arch/mips/include/asm/mach-generic/mc146818rtc.h b/arch/mips/include/asm/mach-generic/mc146818rtc.h
new file mode 100644
index 000000000000..0b9a942f079d
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/mc146818rtc.h
@@ -0,0 +1,36 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2001, 03 by Ralf Baechle
7 *
8 * RTC routines for PC style attached Dallas chip.
9 */
10#ifndef __ASM_MACH_GENERIC_MC146818RTC_H
11#define __ASM_MACH_GENERIC_MC146818RTC_H
12
13#include <asm/io.h>
14
15#define RTC_PORT(x) (0x70 + (x))
16#define RTC_IRQ 8
17
18static inline unsigned char CMOS_READ(unsigned long addr)
19{
20 outb_p(addr, RTC_PORT(0));
21 return inb_p(RTC_PORT(1));
22}
23
24static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
25{
26 outb_p(addr, RTC_PORT(0));
27 outb_p(data, RTC_PORT(1));
28}
29
30#define RTC_ALWAYS_BCD 1
31
32#ifndef mc146818_decode_year
33#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1900)
34#endif
35
36#endif /* __ASM_MACH_GENERIC_MC146818RTC_H */
diff --git a/arch/mips/include/asm/mach-generic/spaces.h b/arch/mips/include/asm/mach-generic/spaces.h
new file mode 100644
index 000000000000..c9fa4b14968d
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/spaces.h
@@ -0,0 +1,85 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 1999, 2000, 03, 04 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
9 */
10#ifndef _ASM_MACH_GENERIC_SPACES_H
11#define _ASM_MACH_GENERIC_SPACES_H
12
13#include <linux/const.h>
14
15/*
16 * This gives the physical RAM offset.
17 */
18#ifndef PHYS_OFFSET
19#define PHYS_OFFSET _AC(0, UL)
20#endif
21
22#ifdef CONFIG_32BIT
23
24#define CAC_BASE _AC(0x80000000, UL)
25#define IO_BASE _AC(0xa0000000, UL)
26#define UNCAC_BASE _AC(0xa0000000, UL)
27
28#ifndef MAP_BASE
29#define MAP_BASE _AC(0xc0000000, UL)
30#endif
31
32/*
33 * Memory above this physical address will be considered highmem.
34 */
35#ifndef HIGHMEM_START
36#define HIGHMEM_START _AC(0x20000000, UL)
37#endif
38
39#endif /* CONFIG_32BIT */
40
41#ifdef CONFIG_64BIT
42
43#ifndef CAC_BASE
44#ifdef CONFIG_DMA_NONCOHERENT
45#define CAC_BASE _AC(0x9800000000000000, UL)
46#else
47#define CAC_BASE _AC(0xa800000000000000, UL)
48#endif
49#endif
50
51#ifndef IO_BASE
52#define IO_BASE _AC(0x9000000000000000, UL)
53#endif
54
55#ifndef UNCAC_BASE
56#define UNCAC_BASE _AC(0x9000000000000000, UL)
57#endif
58
59#ifndef MAP_BASE
60#define MAP_BASE _AC(0xc000000000000000, UL)
61#endif
62
63/*
64 * Memory above this physical address will be considered highmem.
65 * Fixme: 59 bits is a fictive number and makes assumptions about processors
66 * in the distant future. Nobody will care for a few years :-)
67 */
68#ifndef HIGHMEM_START
69#define HIGHMEM_START (_AC(1, UL) << _AC(59, UL))
70#endif
71
72#define TO_PHYS(x) ( ((x) & TO_PHYS_MASK))
73#define TO_CAC(x) (CAC_BASE | ((x) & TO_PHYS_MASK))
74#define TO_UNCAC(x) (UNCAC_BASE | ((x) & TO_PHYS_MASK))
75
76#endif /* CONFIG_64BIT */
77
78/*
79 * This handles the memory map.
80 */
81#ifndef PAGE_OFFSET
82#define PAGE_OFFSET (CAC_BASE + PHYS_OFFSET)
83#endif
84
85#endif /* __ASM_MACH_GENERIC_SPACES_H */
diff --git a/arch/mips/include/asm/mach-generic/topology.h b/arch/mips/include/asm/mach-generic/topology.h
new file mode 100644
index 000000000000..5428f333a02c
--- /dev/null
+++ b/arch/mips/include/asm/mach-generic/topology.h
@@ -0,0 +1 @@
#include <asm-generic/topology.h>
diff --git a/arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h
new file mode 100644
index 000000000000..9c8735158da1
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip22/cpu-feature-overrides.h
@@ -0,0 +1,44 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 07 Ralf Baechle
7 */
8#ifndef __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H
10
11/*
12 * IP22 with a variety of processors so we can't use defaults for everything.
13 */
14#define cpu_has_tlb 1
15#define cpu_has_4kex 1
16#define cpu_has_4k_cache 1
17#define cpu_has_fpu 1
18#define cpu_has_32fpr 1
19#define cpu_has_counter 1
20#define cpu_has_mips16 0
21#define cpu_has_divec 0
22#define cpu_has_cache_cdex_p 1
23#define cpu_has_prefetch 0
24#define cpu_has_mcheck 0
25#define cpu_has_ejtag 0
26
27#define cpu_has_llsc 1
28#define cpu_has_vtag_icache 0 /* Needs to change for R8000 */
29#define cpu_has_dc_aliases (PAGE_SIZE < 0x4000)
30#define cpu_has_ic_fills_f_dc 0
31
32#define cpu_has_dsp 0
33#define cpu_has_mipsmt 0
34#define cpu_has_userlocal 0
35
36#define cpu_has_nofpuex 0
37#define cpu_has_64bits 1
38
39#define cpu_has_mips32r1 0
40#define cpu_has_mips32r2 0
41#define cpu_has_mips64r1 0
42#define cpu_has_mips64r2 0
43
44#endif /* __ASM_MACH_IP22_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-ip22/ds1286.h b/arch/mips/include/asm/mach-ip22/ds1286.h
new file mode 100644
index 000000000000..f19f1eafbc71
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip22/ds1286.h
@@ -0,0 +1,18 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2001, 03 by Ralf Baechle
7 *
8 * RTC routines for PC style attached Dallas chip.
9 */
10#ifndef __ASM_MACH_IP22_DS1286_H
11#define __ASM_MACH_IP22_DS1286_H
12
13#include <asm/sgi/hpc3.h>
14
15#define rtc_read(reg) (hpc3c0->rtcregs[(reg)] & 0xff)
16#define rtc_write(data, reg) do { hpc3c0->rtcregs[(reg)] = (data); } while(0)
17
18#endif /* __ASM_MACH_IP22_DS1286_H */
diff --git a/arch/mips/include/asm/mach-ip22/spaces.h b/arch/mips/include/asm/mach-ip22/spaces.h
new file mode 100644
index 000000000000..7f9fa6f66059
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip22/spaces.h
@@ -0,0 +1,27 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 1999, 2000, 03, 04 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
9 */
10#ifndef _ASM_MACH_IP22_SPACES_H
11#define _ASM_MACH_IP22_SPACES_H
12
13
14#ifdef CONFIG_64BIT
15
16#define PAGE_OFFSET 0xffffffff80000000UL
17
18#define CAC_BASE 0xffffffff80000000
19#define IO_BASE 0xffffffffa0000000
20#define UNCAC_BASE 0xffffffffa0000000
21#define MAP_BASE 0xc000000000000000
22
23#endif /* CONFIG_64BIT */
24
25#include <asm/mach-generic/spaces.h>
26
27#endif /* __ASM_MACH_IP22_SPACES_H */
diff --git a/arch/mips/include/asm/mach-ip22/war.h b/arch/mips/include/asm/mach-ip22/war.h
new file mode 100644
index 000000000000..a44fa9656a82
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip22/war.h
@@ -0,0 +1,29 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_IP22_WAR_H
9#define __ASM_MIPS_MACH_IP22_WAR_H
10
11/*
12 * R4600 CPU modules for the Indy come with both V1.7 and V2.0 processors.
13 */
14
15#define R4600_V1_INDEX_ICACHEOP_WAR 1
16#define R4600_V1_HIT_CACHEOP_WAR 1
17#define R4600_V2_HIT_CACHEOP_WAR 1
18#define R5432_CP0_INTERRUPT_WAR 0
19#define BCM1250_M3_WAR 0
20#define SIBYTE_1956_WAR 0
21#define MIPS4K_ICACHE_REFILL_WAR 0
22#define MIPS_CACHE_SYNC_WAR 0
23#define TX49XX_ICACHE_INDEX_INV_WAR 0
24#define RM9000_CDEX_SMP_WAR 0
25#define ICACHE_REFILLS_WORKAROUND_WAR 0
26#define R10000_LLSC_WAR 0
27#define MIPS34K_MISSED_ITLB_WAR 0
28
29#endif /* __ASM_MIPS_MACH_IP22_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h
new file mode 100644
index 000000000000..7d3112b148d9
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h
@@ -0,0 +1,54 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 07 Ralf Baechle
7 */
8#ifndef __ASM_MACH_IP27_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_IP27_CPU_FEATURE_OVERRIDES_H
10
11/*
12 * IP27 only comes with R10000 family processors all using the same config
13 */
14#define cpu_has_watch 1
15#define cpu_has_mips16 0
16#define cpu_has_divec 0
17#define cpu_has_vce 0
18#define cpu_has_cache_cdex_p 0
19#define cpu_has_cache_cdex_s 0
20#define cpu_has_prefetch 1
21#define cpu_has_mcheck 0
22#define cpu_has_ejtag 0
23
24#define cpu_has_llsc 1
25#define cpu_has_vtag_icache 0
26#define cpu_has_dc_aliases 0
27#define cpu_has_ic_fills_f_dc 0
28#define cpu_has_dsp 0
29#define cpu_icache_snoops_remote_store 1
30#define cpu_has_mipsmt 0
31#define cpu_has_userlocal 0
32
33#define cpu_has_nofpuex 0
34#define cpu_has_64bits 1
35
36#define cpu_has_4kex 1
37#define cpu_has_3k_cache 0
38#define cpu_has_6k_cache 0
39#define cpu_has_4k_cache 1
40#define cpu_has_8k_cache 0
41#define cpu_has_tx39_cache 0
42
43#define cpu_has_inclusive_pcaches 1
44
45#define cpu_dcache_line_size() 32
46#define cpu_icache_line_size() 64
47#define cpu_scache_line_size() 128
48
49#define cpu_has_mips32r1 0
50#define cpu_has_mips32r2 0
51#define cpu_has_mips64r1 0
52#define cpu_has_mips64r2 0
53
54#endif /* __ASM_MACH_IP27_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-ip27/dma-coherence.h b/arch/mips/include/asm/mach-ip27/dma-coherence.h
new file mode 100644
index 000000000000..ed7e6222dc15
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/dma-coherence.h
@@ -0,0 +1,50 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
7 *
8 */
9#ifndef __ASM_MACH_IP27_DMA_COHERENCE_H
10#define __ASM_MACH_IP27_DMA_COHERENCE_H
11
12#include <asm/pci/bridge.h>
13
14#define pdev_to_baddr(pdev, addr) \
15 (BRIDGE_CONTROLLER(pdev->bus)->baddr + (addr))
16#define dev_to_baddr(dev, addr) \
17 pdev_to_baddr(to_pci_dev(dev), (addr))
18
19struct device;
20
21static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
22 size_t size)
23{
24 dma_addr_t pa = dev_to_baddr(dev, virt_to_phys(addr));
25
26 return pa;
27}
28
29static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
30{
31 dma_addr_t pa = dev_to_baddr(dev, page_to_phys(page));
32
33 return pa;
34}
35
36static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
37{
38 return dma_addr & ~(0xffUL << 56);
39}
40
41static inline void plat_unmap_dma_mem(dma_addr_t dma_addr)
42{
43}
44
45static inline int plat_device_is_coherent(struct device *dev)
46{
47 return 1; /* IP27 non-cohernet mode is unsupported */
48}
49
50#endif /* __ASM_MACH_IP27_DMA_COHERENCE_H */
diff --git a/arch/mips/include/asm/mach-ip27/irq.h b/arch/mips/include/asm/mach-ip27/irq.h
new file mode 100644
index 000000000000..cf4384bfa846
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/irq.h
@@ -0,0 +1,22 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1999, 2000, 01, 02, 03 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2001 Kanoj Sarcar
9 */
10#ifndef __ASM_MACH_IP27_IRQ_H
11#define __ASM_MACH_IP27_IRQ_H
12
13/*
14 * A hardwired interrupt number is completly stupid for this system - a
15 * large configuration might have thousands if not tenthousands of
16 * interrupts.
17 */
18#define NR_IRQS 256
19
20#include_next <irq.h>
21
22#endif /* __ASM_MACH_IP27_IRQ_H */
diff --git a/arch/mips/include/asm/mach-ip27/kernel-entry-init.h b/arch/mips/include/asm/mach-ip27/kernel-entry-init.h
new file mode 100644
index 000000000000..624d66c7f290
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/kernel-entry-init.h
@@ -0,0 +1,59 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000 Silicon Graphics, Inc.
7 * Copyright (C) 2005 Ralf Baechle <ralf@linux-mips.org>
8 */
9#ifndef __ASM_MACH_IP27_KERNEL_ENTRY_H
10#define __ASM_MACH_IP27_KERNEL_ENTRY_H
11
12#include <asm/sn/addrs.h>
13#include <asm/sn/sn0/hubni.h>
14#include <asm/sn/klkernvars.h>
15
16/*
17 * Returns the local nasid into res.
18 */
19 .macro GET_NASID_ASM res
20 dli \res, LOCAL_HUB_ADDR(NI_STATUS_REV_ID)
21 ld \res, (\res)
22 and \res, NSRI_NODEID_MASK
23 dsrl \res, NSRI_NODEID_SHFT
24 .endm
25
26/*
27 * Intentionally empty macro, used in head.S. Override in
28 * arch/mips/mach-xxx/kernel-entry-init.h when necessary.
29 */
30 .macro kernel_entry_setup
31 GET_NASID_ASM t1
32 move t2, t1 # text and data are here
33 MAPPED_KERNEL_SETUP_TLB
34 .endm
35
36/*
37 * Do SMP slave processor setup necessary before we can savely execute C code.
38 */
39 .macro smp_slave_setup
40 GET_NASID_ASM t1
41 dli t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \
42 KLDIR_OFF_POINTER + CAC_BASE
43 dsll t1, NASID_SHFT
44 or t0, t0, t1
45 ld t0, 0(t0) # t0 points to kern_vars struct
46 lh t1, KV_RO_NASID_OFFSET(t0)
47 lh t2, KV_RW_NASID_OFFSET(t0)
48 MAPPED_KERNEL_SETUP_TLB
49
50 /*
51 * We might not get launched at the address the kernel is linked to,
52 * so we jump there.
53 */
54 PTR_LA t0, 0f
55 jr t0
560:
57 .endm
58
59#endif /* __ASM_MACH_IP27_KERNEL_ENTRY_H */
diff --git a/arch/mips/include/asm/mach-ip27/kmalloc.h b/arch/mips/include/asm/mach-ip27/kmalloc.h
new file mode 100644
index 000000000000..426bd049b2d7
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/kmalloc.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_MACH_IP27_KMALLOC_H
2#define __ASM_MACH_IP27_KMALLOC_H
3
4/*
5 * All happy, no need to define ARCH_KMALLOC_MINALIGN
6 */
7
8#endif /* __ASM_MACH_IP27_KMALLOC_H */
diff --git a/arch/mips/include/asm/mach-ip27/mangle-port.h b/arch/mips/include/asm/mach-ip27/mangle-port.h
new file mode 100644
index 000000000000..f6e4912ea062
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/mangle-port.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2004 Ralf Baechle
7 */
8#ifndef __ASM_MACH_IP27_MANGLE_PORT_H
9#define __ASM_MACH_IP27_MANGLE_PORT_H
10
11#define __swizzle_addr_b(port) (port)
12#define __swizzle_addr_w(port) ((port) ^ 2)
13#define __swizzle_addr_l(port) (port)
14#define __swizzle_addr_q(port) (port)
15
16# define ioswabb(a, x) (x)
17# define __mem_ioswabb(a, x) (x)
18# define ioswabw(a, x) (x)
19# define __mem_ioswabw(a, x) cpu_to_le16(x)
20# define ioswabl(a, x) (x)
21# define __mem_ioswabl(a, x) cpu_to_le32(x)
22# define ioswabq(a, x) (x)
23# define __mem_ioswabq(a, x) cpu_to_le32(x)
24
25#endif /* __ASM_MACH_IP27_MANGLE_PORT_H */
diff --git a/arch/mips/include/asm/mach-ip27/mmzone.h b/arch/mips/include/asm/mach-ip27/mmzone.h
new file mode 100644
index 000000000000..986a3b9b59a7
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/mmzone.h
@@ -0,0 +1,36 @@
1#ifndef _ASM_MACH_MMZONE_H
2#define _ASM_MACH_MMZONE_H
3
4#include <asm/sn/addrs.h>
5#include <asm/sn/arch.h>
6#include <asm/sn/hub.h>
7
8#define pa_to_nid(addr) NASID_TO_COMPACT_NODEID(NASID_GET(addr))
9
10#define LEVELS_PER_SLICE 128
11
12struct slice_data {
13 unsigned long irq_enable_mask[2];
14 int level_to_irq[LEVELS_PER_SLICE];
15};
16
17struct hub_data {
18 kern_vars_t kern_vars;
19 DECLARE_BITMAP(h_bigwin_used, HUB_NUM_BIG_WINDOW);
20 cpumask_t h_cpus;
21 unsigned long slice_map;
22 unsigned long irq_alloc_mask[2];
23 struct slice_data slice[2];
24};
25
26struct node_data {
27 struct pglist_data pglist;
28 struct hub_data hub;
29};
30
31extern struct node_data *__node_data[];
32
33#define NODE_DATA(n) (&__node_data[(n)]->pglist)
34#define hub_data(n) (&__node_data[(n)]->hub)
35
36#endif /* _ASM_MACH_MMZONE_H */
diff --git a/arch/mips/include/asm/mach-ip27/spaces.h b/arch/mips/include/asm/mach-ip27/spaces.h
new file mode 100644
index 000000000000..b18802a0b17e
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/spaces.h
@@ -0,0 +1,30 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 99 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999 by Silicon Graphics, Inc.
9 */
10#ifndef _ASM_MACH_IP27_SPACES_H
11#define _ASM_MACH_IP27_SPACES_H
12
13/*
14 * IP27 uses the R10000's uncached attribute feature. Attribute 3 selects
15 * uncached memory addressing.
16 */
17
18#define HSPEC_BASE 0x9000000000000000
19#define IO_BASE 0x9200000000000000
20#define MSPEC_BASE 0x9400000000000000
21#define UNCAC_BASE 0x9600000000000000
22
23#define TO_MSPEC(x) (MSPEC_BASE | ((x) & TO_PHYS_MASK))
24#define TO_HSPEC(x) (HSPEC_BASE | ((x) & TO_PHYS_MASK))
25
26#define HIGHMEM_START (~0UL)
27
28#include <asm/mach-generic/spaces.h>
29
30#endif /* _ASM_MACH_IP27_SPACES_H */
diff --git a/arch/mips/include/asm/mach-ip27/topology.h b/arch/mips/include/asm/mach-ip27/topology.h
new file mode 100644
index 000000000000..7785bec732f2
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/topology.h
@@ -0,0 +1,59 @@
1#ifndef _ASM_MACH_TOPOLOGY_H
2#define _ASM_MACH_TOPOLOGY_H 1
3
4#include <asm/sn/hub.h>
5#include <asm/sn/types.h>
6#include <asm/mmzone.h>
7
8struct cpuinfo_ip27 {
9// cpuid_t p_cpuid; /* PROM assigned cpuid */
10 cnodeid_t p_nodeid; /* my node ID in compact-id-space */
11 nasid_t p_nasid; /* my node ID in numa-as-id-space */
12 unsigned char p_slice; /* Physical position on node board */
13#if 0
14 unsigned long loops_per_sec;
15 unsigned long ipi_count;
16 unsigned long irq_attempt[NR_IRQS];
17 unsigned long smp_local_irq_count;
18 unsigned long prof_multiplier;
19 unsigned long prof_counter;
20#endif
21};
22
23extern struct cpuinfo_ip27 sn_cpu_info[NR_CPUS];
24
25#define cpu_to_node(cpu) (sn_cpu_info[(cpu)].p_nodeid)
26#define parent_node(node) (node)
27#define node_to_cpumask(node) (hub_data(node)->h_cpus)
28#define node_to_first_cpu(node) (first_cpu(node_to_cpumask(node)))
29struct pci_bus;
30extern int pcibus_to_node(struct pci_bus *);
31
32#define pcibus_to_cpumask(bus) (cpu_online_map)
33
34extern unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES];
35
36#define node_distance(from, to) (__node_distances[(from)][(to)])
37
38/* sched_domains SD_NODE_INIT for SGI IP27 machines */
39#define SD_NODE_INIT (struct sched_domain) { \
40 .span = CPU_MASK_NONE, \
41 .parent = NULL, \
42 .child = NULL, \
43 .groups = NULL, \
44 .min_interval = 8, \
45 .max_interval = 32, \
46 .busy_factor = 32, \
47 .imbalance_pct = 125, \
48 .cache_nice_tries = 1, \
49 .flags = SD_LOAD_BALANCE \
50 | SD_BALANCE_EXEC \
51 | SD_WAKE_BALANCE, \
52 .last_balance = jiffies, \
53 .balance_interval = 1, \
54 .nr_balance_failed = 0, \
55}
56
57#include <asm-generic/topology.h>
58
59#endif /* _ASM_MACH_TOPOLOGY_H */
diff --git a/arch/mips/include/asm/mach-ip27/war.h b/arch/mips/include/asm/mach-ip27/war.h
new file mode 100644
index 000000000000..e2ddcc9b1fff
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip27/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_IP27_WAR_H
9#define __ASM_MIPS_MACH_IP27_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 1
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_IP27_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h
new file mode 100644
index 000000000000..9a53b326f848
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip28/cpu-feature-overrides.h
@@ -0,0 +1,50 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 Ralf Baechle
7 * 6/2004 pf
8 */
9#ifndef __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H
10#define __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H
11
12/*
13 * IP28 only comes with R10000 family processors all using the same config
14 */
15#define cpu_has_watch 1
16#define cpu_has_mips16 0
17#define cpu_has_divec 0
18#define cpu_has_vce 0
19#define cpu_has_cache_cdex_p 0
20#define cpu_has_cache_cdex_s 0
21#define cpu_has_prefetch 1
22#define cpu_has_mcheck 0
23#define cpu_has_ejtag 0
24
25#define cpu_has_llsc 1
26#define cpu_has_vtag_icache 0
27#define cpu_has_dc_aliases 0 /* see probe_pcache() */
28#define cpu_has_ic_fills_f_dc 0
29#define cpu_has_dsp 0
30#define cpu_icache_snoops_remote_store 1
31#define cpu_has_mipsmt 0
32#define cpu_has_userlocal 0
33
34#define cpu_has_nofpuex 0
35#define cpu_has_64bits 1
36
37#define cpu_has_4kex 1
38#define cpu_has_4k_cache 1
39
40#define cpu_has_inclusive_pcaches 1
41
42#define cpu_dcache_line_size() 32
43#define cpu_icache_line_size() 64
44
45#define cpu_has_mips32r1 0
46#define cpu_has_mips32r2 0
47#define cpu_has_mips64r1 0
48#define cpu_has_mips64r2 0
49
50#endif /* __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-ip28/ds1286.h b/arch/mips/include/asm/mach-ip28/ds1286.h
new file mode 100644
index 000000000000..471bb9a33e0f
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip28/ds1286.h
@@ -0,0 +1,4 @@
1#ifndef __ASM_MACH_IP28_DS1286_H
2#define __ASM_MACH_IP28_DS1286_H
3#include <asm/mach-ip22/ds1286.h>
4#endif /* __ASM_MACH_IP28_DS1286_H */
diff --git a/arch/mips/include/asm/mach-ip28/spaces.h b/arch/mips/include/asm/mach-ip28/spaces.h
new file mode 100644
index 000000000000..05aabb27e5e7
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip28/spaces.h
@@ -0,0 +1,22 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 1999, 2000, 03, 04 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
9 * 2004 pf
10 */
11#ifndef _ASM_MACH_IP28_SPACES_H
12#define _ASM_MACH_IP28_SPACES_H
13
14#define CAC_BASE 0xa800000000000000
15
16#define HIGHMEM_START (~0UL)
17
18#define PHYS_OFFSET _AC(0x20000000, UL)
19
20#include <asm/mach-generic/spaces.h>
21
22#endif /* _ASM_MACH_IP28_SPACES_H */
diff --git a/arch/mips/include/asm/mach-ip28/war.h b/arch/mips/include/asm/mach-ip28/war.h
new file mode 100644
index 000000000000..a1baafab486a
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip28/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_IP28_WAR_H
9#define __ASM_MIPS_MACH_IP28_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 1
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_IP28_WAR_H */
diff --git a/arch/mips/include/asm/mach-ip32/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ip32/cpu-feature-overrides.h
new file mode 100644
index 000000000000..6782fccebe8d
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip32/cpu-feature-overrides.h
@@ -0,0 +1,50 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005 Ilya A. Volynets-Evenbakh
7 * Copyright (C) 2005, 07 Ralf Baechle (ralf@linux-mips.org)
8 */
9#ifndef __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H
10#define __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H
11
12
13/*
14 * R5000 has an interesting "restriction": ll(d)/sc(d)
15 * instructions to XKPHYS region simply do uncached bus
16 * requests. This breaks all the atomic bitops functions.
17 * so, for 64bit IP32 kernel we just don't use ll/sc.
18 * This does not affect luserland.
19 */
20#if (defined(CONFIG_CPU_R5000) || defined(CONFIG_CPU_NEVADA)) && defined(CONFIG_64BIT)
21#define cpu_has_llsc 0
22#else
23#define cpu_has_llsc 1
24#endif
25
26/* Settings which are common for all ip32 CPUs */
27#define cpu_has_tlb 1
28#define cpu_has_4kex 1
29#define cpu_has_fpu 1
30#define cpu_has_32fpr 1
31#define cpu_has_counter 1
32#define cpu_has_mips16 0
33#define cpu_has_vce 0
34#define cpu_has_cache_cdex_s 0
35#define cpu_has_mcheck 0
36#define cpu_has_ejtag 0
37#define cpu_has_vtag_icache 0
38#define cpu_has_ic_fills_f_dc 0
39#define cpu_has_dsp 0
40#define cpu_has_4k_cache 1
41#define cpu_has_mipsmt 0
42#define cpu_has_userlocal 0
43
44
45#define cpu_has_mips32r1 0
46#define cpu_has_mips32r2 0
47#define cpu_has_mips64r1 0
48#define cpu_has_mips64r2 0
49
50#endif /* __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-ip32/dma-coherence.h b/arch/mips/include/asm/mach-ip32/dma-coherence.h
new file mode 100644
index 000000000000..a5511ebb2d53
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip32/dma-coherence.h
@@ -0,0 +1,72 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
7 *
8 */
9#ifndef __ASM_MACH_IP32_DMA_COHERENCE_H
10#define __ASM_MACH_IP32_DMA_COHERENCE_H
11
12#include <asm/ip32/crime.h>
13
14struct device;
15
16/*
17 * Few notes.
18 * 1. CPU sees memory as two chunks: 0-256M@0x0, and the rest @0x40000000+256M
19 * 2. PCI sees memory as one big chunk @0x0 (or we could use 0x40000000 for
20 * native-endian)
21 * 3. All other devices see memory as one big chunk at 0x40000000
22 * 4. Non-PCI devices will pass NULL as struct device*
23 *
24 * Thus we translate differently, depending on device.
25 */
26
27#define RAM_OFFSET_MASK 0x3fffffffUL
28
29static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
30 size_t size)
31{
32 dma_addr_t pa = virt_to_phys(addr) & RAM_OFFSET_MASK;
33
34 if (dev == NULL)
35 pa += CRIME_HI_MEM_BASE;
36
37 return pa;
38}
39
40static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
41{
42 dma_addr_t pa;
43
44 pa = page_to_phys(page) & RAM_OFFSET_MASK;
45
46 if (dev == NULL)
47 pa += CRIME_HI_MEM_BASE;
48
49 return pa;
50}
51
52/* This is almost certainly wrong but it's what dma-ip32.c used to use */
53static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
54{
55 unsigned long addr = dma_addr & RAM_OFFSET_MASK;
56
57 if (dma_addr >= 256*1024*1024)
58 addr += CRIME_HI_MEM_BASE;
59
60 return addr;
61}
62
63static inline void plat_unmap_dma_mem(dma_addr_t dma_addr)
64{
65}
66
67static inline int plat_device_is_coherent(struct device *dev)
68{
69 return 0; /* IP32 is non-cohernet */
70}
71
72#endif /* __ASM_MACH_IP32_DMA_COHERENCE_H */
diff --git a/arch/mips/include/asm/mach-ip32/kmalloc.h b/arch/mips/include/asm/mach-ip32/kmalloc.h
new file mode 100644
index 000000000000..b1e0be60f720
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip32/kmalloc.h
@@ -0,0 +1,11 @@
1#ifndef __ASM_MACH_IP32_KMALLOC_H
2#define __ASM_MACH_IP32_KMALLOC_H
3
4
5#if defined(CONFIG_CPU_R5000) || defined(CONFIG_CPU_RM7000)
6#define ARCH_KMALLOC_MINALIGN 32
7#else
8#define ARCH_KMALLOC_MINALIGN 128
9#endif
10
11#endif /* __ASM_MACH_IP32_KMALLOC_H */
diff --git a/arch/mips/include/asm/mach-ip32/mangle-port.h b/arch/mips/include/asm/mach-ip32/mangle-port.h
new file mode 100644
index 000000000000..f1d0f1756a9f
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip32/mangle-port.h
@@ -0,0 +1,26 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 Ladislav Michl
7 * Copyright (C) 2004 Ralf Baechle
8 */
9#ifndef __ASM_MACH_IP32_MANGLE_PORT_H
10#define __ASM_MACH_IP32_MANGLE_PORT_H
11
12#define __swizzle_addr_b(port) ((port) ^ 3)
13#define __swizzle_addr_w(port) ((port) ^ 2)
14#define __swizzle_addr_l(port) (port)
15#define __swizzle_addr_q(port) (port)
16
17# define ioswabb(a, x) (x)
18# define __mem_ioswabb(a, x) (x)
19# define ioswabw(a, x) (x)
20# define __mem_ioswabw(a, x) cpu_to_le16(x)
21# define ioswabl(a, x) (x)
22# define __mem_ioswabl(a, x) cpu_to_le32(x)
23# define ioswabq(a, x) (x)
24# define __mem_ioswabq(a, x) cpu_to_le32(x)
25
26#endif /* __ASM_MACH_IP32_MANGLE_PORT_H */
diff --git a/arch/mips/include/asm/mach-ip32/mc146818rtc.h b/arch/mips/include/asm/mach-ip32/mc146818rtc.h
new file mode 100644
index 000000000000..c28ba8d84076
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip32/mc146818rtc.h
@@ -0,0 +1,36 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2001, 03 by Ralf Baechle
7 * Copyright (C) 2000 Harald Koerfgen
8 *
9 * RTC routines for IP32 style attached Dallas chip.
10 */
11#ifndef __ASM_MACH_IP32_MC146818RTC_H
12#define __ASM_MACH_IP32_MC146818RTC_H
13
14#include <asm/ip32/mace.h>
15
16#define RTC_PORT(x) (0x70 + (x))
17
18static unsigned char CMOS_READ(unsigned long addr)
19{
20 return mace->isa.rtc[addr << 8];
21}
22
23static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
24{
25 mace->isa.rtc[addr << 8] = data;
26}
27
28/*
29 * FIXME: Do it right. For now just assume that noone lives in 20th century
30 * and no O2 user in 22th century ;-)
31 */
32#define mc146818_decode_year(year) ((year) + 2000)
33
34#define RTC_ALWAYS_BCD 0
35
36#endif /* __ASM_MACH_IP32_MC146818RTC_H */
diff --git a/arch/mips/include/asm/mach-ip32/war.h b/arch/mips/include/asm/mach-ip32/war.h
new file mode 100644
index 000000000000..d194056dcd7a
--- /dev/null
+++ b/arch/mips/include/asm/mach-ip32/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_IP32_WAR_H
9#define __ASM_MIPS_MACH_IP32_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 1
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_IP32_WAR_H */
diff --git a/arch/mips/include/asm/mach-jazz/dma-coherence.h b/arch/mips/include/asm/mach-jazz/dma-coherence.h
new file mode 100644
index 000000000000..d66979a124a8
--- /dev/null
+++ b/arch/mips/include/asm/mach-jazz/dma-coherence.h
@@ -0,0 +1,40 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MACH_JAZZ_DMA_COHERENCE_H
9#define __ASM_MACH_JAZZ_DMA_COHERENCE_H
10
11#include <asm/jazzdma.h>
12
13struct device;
14
15static dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)
16{
17 return vdma_alloc(virt_to_phys(addr), size);
18}
19
20static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
21{
22 return vdma_alloc(page_to_phys(page), PAGE_SIZE);
23}
24
25static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
26{
27 return vdma_log2phys(dma_addr);
28}
29
30static void plat_unmap_dma_mem(dma_addr_t dma_addr)
31{
32 vdma_free(dma_addr);
33}
34
35static inline int plat_device_is_coherent(struct device *dev)
36{
37 return 0;
38}
39
40#endif /* __ASM_MACH_JAZZ_DMA_COHERENCE_H */
diff --git a/arch/mips/include/asm/mach-jazz/floppy.h b/arch/mips/include/asm/mach-jazz/floppy.h
new file mode 100644
index 000000000000..56e9ca6ae426
--- /dev/null
+++ b/arch/mips/include/asm/mach-jazz/floppy.h
@@ -0,0 +1,135 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_JAZZ_FLOPPY_H
9#define __ASM_MACH_JAZZ_FLOPPY_H
10
11#include <linux/delay.h>
12#include <linux/init.h>
13#include <linux/linkage.h>
14#include <linux/types.h>
15#include <linux/mm.h>
16#include <asm/addrspace.h>
17#include <asm/jazz.h>
18#include <asm/jazzdma.h>
19#include <asm/pgtable.h>
20
21static inline unsigned char fd_inb(unsigned int port)
22{
23 unsigned char c;
24
25 c = *(volatile unsigned char *) port;
26 udelay(1);
27
28 return c;
29}
30
31static inline void fd_outb(unsigned char value, unsigned int port)
32{
33 *(volatile unsigned char *) port = value;
34}
35
36/*
37 * How to access the floppy DMA functions.
38 */
39static inline void fd_enable_dma(void)
40{
41 vdma_enable(JAZZ_FLOPPY_DMA);
42}
43
44static inline void fd_disable_dma(void)
45{
46 vdma_disable(JAZZ_FLOPPY_DMA);
47}
48
49static inline int fd_request_dma(void)
50{
51 return 0;
52}
53
54static inline void fd_free_dma(void)
55{
56}
57
58static inline void fd_clear_dma_ff(void)
59{
60}
61
62static inline void fd_set_dma_mode(char mode)
63{
64 vdma_set_mode(JAZZ_FLOPPY_DMA, mode);
65}
66
67static inline void fd_set_dma_addr(char *a)
68{
69 vdma_set_addr(JAZZ_FLOPPY_DMA, vdma_phys2log(CPHYSADDR((unsigned long)a)));
70}
71
72static inline void fd_set_dma_count(unsigned int count)
73{
74 vdma_set_count(JAZZ_FLOPPY_DMA, count);
75}
76
77static inline int fd_get_dma_residue(void)
78{
79 return vdma_get_residue(JAZZ_FLOPPY_DMA);
80}
81
82static inline void fd_enable_irq(void)
83{
84}
85
86static inline void fd_disable_irq(void)
87{
88}
89
90static inline int fd_request_irq(void)
91{
92 return request_irq(FLOPPY_IRQ, floppy_interrupt,
93 IRQF_DISABLED, "floppy", NULL);
94}
95
96static inline void fd_free_irq(void)
97{
98 free_irq(FLOPPY_IRQ, NULL);
99}
100
101static inline unsigned long fd_getfdaddr1(void)
102{
103 return JAZZ_FDC_BASE;
104}
105
106static inline unsigned long fd_dma_mem_alloc(unsigned long size)
107{
108 unsigned long mem;
109
110 mem = __get_dma_pages(GFP_KERNEL, get_order(size));
111 if(!mem)
112 return 0;
113 vdma_alloc(CPHYSADDR(mem), size); /* XXX error checking */
114
115 return mem;
116}
117
118static inline void fd_dma_mem_free(unsigned long addr, unsigned long size)
119{
120 vdma_free(vdma_phys2log(CPHYSADDR(addr)));
121 free_pages(addr, get_order(size));
122}
123
124static inline unsigned long fd_drive_type(unsigned long n)
125{
126 /* XXX This is wrong for machines with ED 2.88mb disk drives like the
127 Olivetti M700. Anyway, we should suck this from the ARC
128 firmware. */
129 if (n == 0)
130 return 4; /* 3,5", 1.44mb */
131
132 return 0;
133}
134
135#endif /* __ASM_MACH_JAZZ_FLOPPY_H */
diff --git a/arch/mips/include/asm/mach-jazz/mc146818rtc.h b/arch/mips/include/asm/mach-jazz/mc146818rtc.h
new file mode 100644
index 000000000000..987f727afe25
--- /dev/null
+++ b/arch/mips/include/asm/mach-jazz/mc146818rtc.h
@@ -0,0 +1,38 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2001, 03 by Ralf Baechle
7 * Copyright (C) 2007 Thomas Bogendoerfer
8 *
9 * RTC routines for Jazz style attached Dallas chip.
10 */
11#ifndef __ASM_MACH_JAZZ_MC146818RTC_H
12#define __ASM_MACH_JAZZ_MC146818RTC_H
13
14#include <linux/delay.h>
15
16#include <asm/io.h>
17#include <asm/jazz.h>
18
19#define RTC_PORT(x) (0x70 + (x))
20#define RTC_IRQ 8
21
22static inline unsigned char CMOS_READ(unsigned long addr)
23{
24 outb_p(addr, RTC_PORT(0));
25 return *(volatile char *)JAZZ_RTC_BASE;
26}
27
28static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
29{
30 outb_p(addr, RTC_PORT(0));
31 *(volatile char *)JAZZ_RTC_BASE = data;
32}
33
34#define RTC_ALWAYS_BCD 0
35
36#define mc146818_decode_year(year) ((year) + 1980)
37
38#endif /* __ASM_MACH_JAZZ_MC146818RTC_H */
diff --git a/arch/mips/include/asm/mach-jazz/war.h b/arch/mips/include/asm/mach-jazz/war.h
new file mode 100644
index 000000000000..6158ee861bfd
--- /dev/null
+++ b/arch/mips/include/asm/mach-jazz/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_JAZZ_WAR_H
9#define __ASM_MIPS_MACH_JAZZ_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_JAZZ_WAR_H */
diff --git a/arch/mips/include/asm/mach-lasat/irq.h b/arch/mips/include/asm/mach-lasat/irq.h
new file mode 100644
index 000000000000..3a282419d5f9
--- /dev/null
+++ b/arch/mips/include/asm/mach-lasat/irq.h
@@ -0,0 +1,13 @@
1#ifndef _ASM_MACH_LASAT_IRQ_H
2#define _ASM_MACH_LASAT_IRQ_H
3
4#define LASAT_CASCADE_IRQ (MIPS_CPU_IRQ_BASE + 2)
5
6#define LASAT_IRQ_BASE 8
7#define LASAT_IRQ_END 23
8
9#define NR_IRQS 24
10
11#include_next <irq.h>
12
13#endif /* _ASM_MACH_LASAT_IRQ_H */
diff --git a/arch/mips/include/asm/mach-lasat/mach-gt64120.h b/arch/mips/include/asm/mach-lasat/mach-gt64120.h
new file mode 100644
index 000000000000..1a9ad45cc135
--- /dev/null
+++ b/arch/mips/include/asm/mach-lasat/mach-gt64120.h
@@ -0,0 +1,27 @@
1/*
2 * This is a direct copy of the ev96100.h file, with a global
3 * search and replace. The numbers are the same.
4 *
5 * The reason I'm duplicating this is so that the 64120/96100
6 * defines won't be confusing in the source code.
7 */
8#ifndef _ASM_GT64120_LASAT_GT64120_DEP_H
9#define _ASM_GT64120_LASAT_GT64120_DEP_H
10
11/*
12 * GT64120 config space base address on Lasat 100
13 */
14#define GT64120_BASE (KSEG1ADDR(0x14000000))
15
16/*
17 * PCI Bus allocation
18 *
19 * (Guessing ...)
20 */
21#define GT_PCI_MEM_BASE 0x12000000UL
22#define GT_PCI_MEM_SIZE 0x02000000UL
23#define GT_PCI_IO_BASE 0x10000000UL
24#define GT_PCI_IO_SIZE 0x02000000UL
25#define GT_ISA_IO_BASE PCI_IO_BASE
26
27#endif /* _ASM_GT64120_LASAT_GT64120_DEP_H */
diff --git a/arch/mips/include/asm/mach-lasat/war.h b/arch/mips/include/asm/mach-lasat/war.h
new file mode 100644
index 000000000000..bb1e0325c9be
--- /dev/null
+++ b/arch/mips/include/asm/mach-lasat/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_LASAT_WAR_H
9#define __ASM_MIPS_MACH_LASAT_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_LASAT_WAR_H */
diff --git a/arch/mips/include/asm/mach-lemote/dma-coherence.h b/arch/mips/include/asm/mach-lemote/dma-coherence.h
new file mode 100644
index 000000000000..7e914777ebc4
--- /dev/null
+++ b/arch/mips/include/asm/mach-lemote/dma-coherence.h
@@ -0,0 +1,42 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2006, 07 Ralf Baechle <ralf@linux-mips.org>
7 * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
8 * Author: Fuxin Zhang, zhangfx@lemote.com
9 *
10 */
11#ifndef __ASM_MACH_LEMOTE_DMA_COHERENCE_H
12#define __ASM_MACH_LEMOTE_DMA_COHERENCE_H
13
14struct device;
15
16static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
17 size_t size)
18{
19 return virt_to_phys(addr) | 0x80000000;
20}
21
22static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
23 struct page *page)
24{
25 return page_to_phys(page) | 0x80000000;
26}
27
28static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
29{
30 return dma_addr & 0x7fffffff;
31}
32
33static inline void plat_unmap_dma_mem(dma_addr_t dma_addr)
34{
35}
36
37static inline int plat_device_is_coherent(struct device *dev)
38{
39 return 0;
40}
41
42#endif /* __ASM_MACH_LEMOTE_DMA_COHERENCE_H */
diff --git a/arch/mips/include/asm/mach-lemote/mc146818rtc.h b/arch/mips/include/asm/mach-lemote/mc146818rtc.h
new file mode 100644
index 000000000000..ed5147e11085
--- /dev/null
+++ b/arch/mips/include/asm/mach-lemote/mc146818rtc.h
@@ -0,0 +1,36 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2001, 03, 07 by Ralf Baechle (ralf@linux-mips.org)
7 *
8 * RTC routines for PC style attached Dallas chip.
9 */
10#ifndef __ASM_MACH_LEMOTE_MC146818RTC_H
11#define __ASM_MACH_LEMOTE_MC146818RTC_H
12
13#include <linux/io.h>
14
15#define RTC_PORT(x) (0x70 + (x))
16#define RTC_IRQ 8
17
18static inline unsigned char CMOS_READ(unsigned long addr)
19{
20 outb_p(addr, RTC_PORT(0));
21 return inb_p(RTC_PORT(1));
22}
23
24static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
25{
26 outb_p(addr, RTC_PORT(0));
27 outb_p(data, RTC_PORT(1));
28}
29
30#define RTC_ALWAYS_BCD 0
31
32#ifndef mc146818_decode_year
33#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1970)
34#endif
35
36#endif /* __ASM_MACH_LEMOTE_MC146818RTC_H */
diff --git a/arch/mips/include/asm/mach-lemote/war.h b/arch/mips/include/asm/mach-lemote/war.h
new file mode 100644
index 000000000000..05f89e0f2a11
--- /dev/null
+++ b/arch/mips/include/asm/mach-lemote/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_LEMOTE_WAR_H
9#define __ASM_MIPS_MACH_LEMOTE_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_LEMOTE_WAR_H */
diff --git a/arch/mips/include/asm/mach-malta/cpu-feature-overrides.h b/arch/mips/include/asm/mach-malta/cpu-feature-overrides.h
new file mode 100644
index 000000000000..7f3e3f9bd23a
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/cpu-feature-overrides.h
@@ -0,0 +1,72 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2004 Chris Dearman
7 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
8 */
9#ifndef __ASM_MACH_MIPS_CPU_FEATURE_OVERRIDES_H
10#define __ASM_MACH_MIPS_CPU_FEATURE_OVERRIDES_H
11
12
13/*
14 * CPU feature overrides for MIPS boards
15 */
16#ifdef CONFIG_CPU_MIPS32
17#define cpu_has_tlb 1
18#define cpu_has_4kex 1
19#define cpu_has_4k_cache 1
20/* #define cpu_has_fpu ? */
21/* #define cpu_has_32fpr ? */
22#define cpu_has_counter 1
23/* #define cpu_has_watch ? */
24#define cpu_has_divec 1
25#define cpu_has_vce 0
26/* #define cpu_has_cache_cdex_p ? */
27/* #define cpu_has_cache_cdex_s ? */
28/* #define cpu_has_prefetch ? */
29#define cpu_has_mcheck 1
30/* #define cpu_has_ejtag ? */
31#ifdef CONFIG_CPU_HAS_LLSC
32#define cpu_has_llsc 1
33#else
34#define cpu_has_llsc 0
35#endif
36/* #define cpu_has_vtag_icache ? */
37/* #define cpu_has_dc_aliases ? */
38/* #define cpu_has_ic_fills_f_dc ? */
39#define cpu_has_nofpuex 0
40/* #define cpu_has_64bits ? */
41/* #define cpu_has_64bit_zero_reg ? */
42/* #define cpu_has_inclusive_pcaches ? */
43#define cpu_icache_snoops_remote_store 1
44#endif
45
46#ifdef CONFIG_CPU_MIPS64
47#define cpu_has_tlb 1
48#define cpu_has_4kex 1
49#define cpu_has_4k_cache 1
50/* #define cpu_has_fpu ? */
51/* #define cpu_has_32fpr ? */
52#define cpu_has_counter 1
53/* #define cpu_has_watch ? */
54#define cpu_has_divec 1
55#define cpu_has_vce 0
56/* #define cpu_has_cache_cdex_p ? */
57/* #define cpu_has_cache_cdex_s ? */
58/* #define cpu_has_prefetch ? */
59#define cpu_has_mcheck 1
60/* #define cpu_has_ejtag ? */
61#define cpu_has_llsc 1
62/* #define cpu_has_vtag_icache ? */
63/* #define cpu_has_dc_aliases ? */
64/* #define cpu_has_ic_fills_f_dc ? */
65#define cpu_has_nofpuex 0
66/* #define cpu_has_64bits ? */
67/* #define cpu_has_64bit_zero_reg ? */
68/* #define cpu_has_inclusive_pcaches ? */
69#define cpu_icache_snoops_remote_store 1
70#endif
71
72#endif /* __ASM_MACH_MIPS_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-malta/irq.h b/arch/mips/include/asm/mach-malta/irq.h
new file mode 100644
index 000000000000..9b9da26683c2
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/irq.h
@@ -0,0 +1,9 @@
1#ifndef __ASM_MACH_MIPS_IRQ_H
2#define __ASM_MACH_MIPS_IRQ_H
3
4
5#define NR_IRQS 256
6
7#include_next <irq.h>
8
9#endif /* __ASM_MACH_MIPS_IRQ_H */
diff --git a/arch/mips/include/asm/mach-malta/kernel-entry-init.h b/arch/mips/include/asm/mach-malta/kernel-entry-init.h
new file mode 100644
index 000000000000..0b793e7bf67e
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/kernel-entry-init.h
@@ -0,0 +1,52 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Chris Dearman (chris@mips.com)
7 * Copyright (C) 2007 Mips Technologies, Inc.
8 */
9#ifndef __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H
10#define __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H
11
12 .macro kernel_entry_setup
13#ifdef CONFIG_MIPS_MT_SMTC
14 mfc0 t0, CP0_CONFIG
15 bgez t0, 9f
16 mfc0 t0, CP0_CONFIG, 1
17 bgez t0, 9f
18 mfc0 t0, CP0_CONFIG, 2
19 bgez t0, 9f
20 mfc0 t0, CP0_CONFIG, 3
21 and t0, 1<<2
22 bnez t0, 0f
239:
24 /* Assume we came from YAMON... */
25 PTR_LA v0, 0x9fc00534 /* YAMON print */
26 lw v0, (v0)
27 move a0, zero
28 PTR_LA a1, nonmt_processor
29 jal v0
30
31 PTR_LA v0, 0x9fc00520 /* YAMON exit */
32 lw v0, (v0)
33 li a0, 1
34 jal v0
35
361: b 1b
37
38 __INITDATA
39nonmt_processor:
40 .asciz "SMTC kernel requires the MT ASE to run\n"
41 __FINIT
420:
43#endif
44 .endm
45
46/*
47 * Do SMP slave processor setup necessary before we can safely execute C code.
48 */
49 .macro smp_slave_setup
50 .endm
51
52#endif /* __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H */
diff --git a/arch/mips/include/asm/mach-malta/mach-gt64120.h b/arch/mips/include/asm/mach-malta/mach-gt64120.h
new file mode 100644
index 000000000000..0f863148f3b6
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/mach-gt64120.h
@@ -0,0 +1,19 @@
1/*
2 * This is a direct copy of the ev96100.h file, with a global
3 * search and replace. The numbers are the same.
4 *
5 * The reason I'm duplicating this is so that the 64120/96100
6 * defines won't be confusing in the source code.
7 */
8#ifndef _ASM_MACH_MIPS_MACH_GT64120_DEP_H
9#define _ASM_MACH_MIPS_MACH_GT64120_DEP_H
10
11#define MIPS_GT_BASE 0x1be00000
12
13extern unsigned long _pcictrl_gt64120;
14/*
15 * GT64120 config space base address
16 */
17#define GT64120_BASE _pcictrl_gt64120
18
19#endif /* _ASM_MACH_MIPS_MACH_GT64120_DEP_H */
diff --git a/arch/mips/include/asm/mach-malta/mc146818rtc.h b/arch/mips/include/asm/mach-malta/mc146818rtc.h
new file mode 100644
index 000000000000..ea612f37f614
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/mc146818rtc.h
@@ -0,0 +1,48 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4 * Copyright (C) 2003 by Ralf Baechle
5 *
6 * This program is free software; you can distribute it and/or modify it
7 * under the terms of the GNU General Public License (Version 2) as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 *
19 * RTC routines for Malta style attached PIIX4 device, which contains a
20 * Motorola MC146818A-compatible Real Time Clock.
21 */
22#ifndef __ASM_MACH_MALTA_MC146818RTC_H
23#define __ASM_MACH_MALTA_MC146818RTC_H
24
25#include <asm/io.h>
26#include <asm/mips-boards/generic.h>
27#include <asm/mips-boards/malta.h>
28
29#define RTC_PORT(x) (0x70 + (x))
30#define RTC_IRQ 8
31
32static inline unsigned char CMOS_READ(unsigned long addr)
33{
34 outb(addr, MALTA_RTC_ADR_REG);
35 return inb(MALTA_RTC_DAT_REG);
36}
37
38static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
39{
40 outb(addr, MALTA_RTC_ADR_REG);
41 outb(data, MALTA_RTC_DAT_REG);
42}
43
44#define RTC_ALWAYS_BCD 0
45
46#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1900)
47
48#endif /* __ASM_MACH_MALTA_MC146818RTC_H */
diff --git a/arch/mips/include/asm/mach-malta/war.h b/arch/mips/include/asm/mach-malta/war.h
new file mode 100644
index 000000000000..7c6931d5f45f
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_MIPS_WAR_H
9#define __ASM_MIPS_MACH_MIPS_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 1
18#define MIPS_CACHE_SYNC_WAR 1
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 1
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
diff --git a/arch/mips/include/asm/mach-mipssim/cpu-feature-overrides.h b/arch/mips/include/asm/mach-mipssim/cpu-feature-overrides.h
new file mode 100644
index 000000000000..779b02205737
--- /dev/null
+++ b/arch/mips/include/asm/mach-mipssim/cpu-feature-overrides.h
@@ -0,0 +1,65 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2004 Chris Dearman
7 */
8#ifndef __ASM_MACH_SIM_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_SIM_CPU_FEATURE_OVERRIDES_H
10
11
12/*
13 * CPU feature overrides for MIPS boards
14 */
15#ifdef CONFIG_CPU_MIPS32
16#define cpu_has_tlb 1
17#define cpu_has_4kex 1
18#define cpu_has_4k_cache 1
19#define cpu_has_fpu 0
20/* #define cpu_has_32fpr ? */
21#define cpu_has_counter 1
22/* #define cpu_has_watch ? */
23#define cpu_has_divec 1
24#define cpu_has_vce 0
25/* #define cpu_has_cache_cdex_p ? */
26/* #define cpu_has_cache_cdex_s ? */
27/* #define cpu_has_prefetch ? */
28#define cpu_has_mcheck 1
29/* #define cpu_has_ejtag ? */
30#define cpu_has_llsc 1
31/* #define cpu_has_vtag_icache ? */
32/* #define cpu_has_dc_aliases ? */
33/* #define cpu_has_ic_fills_f_dc ? */
34#define cpu_has_nofpuex 0
35/* #define cpu_has_64bits ? */
36/* #define cpu_has_64bit_zero_reg ? */
37/* #define cpu_has_inclusive_pcaches ? */
38#endif
39
40#ifdef CONFIG_CPU_MIPS64
41#define cpu_has_tlb 1
42#define cpu_has_4kex 1
43#define cpu_has_4k_cache 1
44/* #define cpu_has_fpu ? */
45/* #define cpu_has_32fpr ? */
46#define cpu_has_counter 1
47/* #define cpu_has_watch ? */
48#define cpu_has_divec 1
49#define cpu_has_vce 0
50/* #define cpu_has_cache_cdex_p ? */
51/* #define cpu_has_cache_cdex_s ? */
52/* #define cpu_has_prefetch ? */
53#define cpu_has_mcheck 1
54/* #define cpu_has_ejtag ? */
55#define cpu_has_llsc 1
56/* #define cpu_has_vtag_icache ? */
57/* #define cpu_has_dc_aliases ? */
58/* #define cpu_has_ic_fills_f_dc ? */
59#define cpu_has_nofpuex 0
60/* #define cpu_has_64bits ? */
61/* #define cpu_has_64bit_zero_reg ? */
62/* #define cpu_has_inclusive_pcaches ? */
63#endif
64
65#endif /* __ASM_MACH_MIPS_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-mipssim/war.h b/arch/mips/include/asm/mach-mipssim/war.h
new file mode 100644
index 000000000000..c8a74a3515e0
--- /dev/null
+++ b/arch/mips/include/asm/mach-mipssim/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_MIPSSIM_WAR_H
9#define __ASM_MIPS_MACH_MIPSSIM_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_MIPSSIM_WAR_H */
diff --git a/arch/mips/include/asm/mach-pb1x00/mc146818rtc.h b/arch/mips/include/asm/mach-pb1x00/mc146818rtc.h
new file mode 100644
index 000000000000..622c58710e5b
--- /dev/null
+++ b/arch/mips/include/asm/mach-pb1x00/mc146818rtc.h
@@ -0,0 +1,34 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2001, 03 by Ralf Baechle
7 *
8 * RTC routines for PC style attached Dallas chip.
9 */
10#ifndef __ASM_MACH_AU1XX_MC146818RTC_H
11#define __ASM_MACH_AU1XX_MC146818RTC_H
12
13#include <asm/io.h>
14#include <asm/mach-au1x00/au1000.h>
15
16#define RTC_PORT(x) (0x0c000000 + (x))
17#define RTC_IRQ 8
18#define PB1500_RTC_ADDR 0x0c000000
19
20static inline unsigned char CMOS_READ(unsigned long offset)
21{
22 offset <<= 2;
23 return (u8)(au_readl(offset + PB1500_RTC_ADDR) & 0xff);
24}
25
26static inline void CMOS_WRITE(unsigned char data, unsigned long offset)
27{
28 offset <<= 2;
29 au_writel(data, offset + PB1500_RTC_ADDR);
30}
31
32#define RTC_ALWAYS_BCD 1
33
34#endif /* __ASM_MACH_AU1XX_MC146818RTC_H */
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1000.h b/arch/mips/include/asm/mach-pb1x00/pb1000.h
new file mode 100644
index 000000000000..6d1ff9060e44
--- /dev/null
+++ b/arch/mips/include/asm/mach-pb1x00/pb1000.h
@@ -0,0 +1,87 @@
1/*
2 * Alchemy Semi Pb1000 Referrence Board
3 *
4 * Copyright 2001, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. <source@mvista.com>
6 *
7 * ########################################################################
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 *
22 * ########################################################################
23 *
24 *
25 */
26#ifndef __ASM_PB1000_H
27#define __ASM_PB1000_H
28
29/* PCMCIA PB1000 specific defines */
30#define PCMCIA_MAX_SOCK 1
31#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
32
33#define PB1000_PCR 0xBE000000
34# define PCR_SLOT_0_VPP0 (1 << 0)
35# define PCR_SLOT_0_VPP1 (1 << 1)
36# define PCR_SLOT_0_VCC0 (1 << 2)
37# define PCR_SLOT_0_VCC1 (1 << 3)
38# define PCR_SLOT_0_RST (1 << 4)
39# define PCR_SLOT_1_VPP0 (1 << 8)
40# define PCR_SLOT_1_VPP1 (1 << 9)
41# define PCR_SLOT_1_VCC0 (1 << 10)
42# define PCR_SLOT_1_VCC1 (1 << 11)
43# define PCR_SLOT_1_RST (1 << 12)
44
45#define PB1000_MDR 0xBE000004
46# define MDR_PI (1 << 5) /* PCMCIA int latch */
47# define MDR_EPI (1 << 14) /* enable PCMCIA int */
48# define MDR_CPI (1 << 15) /* clear PCMCIA int */
49
50#define PB1000_ACR1 0xBE000008
51# define ACR1_SLOT_0_CD1 (1 << 0) /* card detect 1 */
52# define ACR1_SLOT_0_CD2 (1 << 1) /* card detect 2 */
53# define ACR1_SLOT_0_READY (1 << 2) /* ready */
54# define ACR1_SLOT_0_STATUS (1 << 3) /* status change */
55# define ACR1_SLOT_0_VS1 (1 << 4) /* voltage sense 1 */
56# define ACR1_SLOT_0_VS2 (1 << 5) /* voltage sense 2 */
57# define ACR1_SLOT_0_INPACK (1 << 6) /* inpack pin status */
58# define ACR1_SLOT_1_CD1 (1 << 8) /* card detect 1 */
59# define ACR1_SLOT_1_CD2 (1 << 9) /* card detect 2 */
60# define ACR1_SLOT_1_READY (1 << 10) /* ready */
61# define ACR1_SLOT_1_STATUS (1 << 11) /* status change */
62# define ACR1_SLOT_1_VS1 (1 << 12) /* voltage sense 1 */
63# define ACR1_SLOT_1_VS2 (1 << 13) /* voltage sense 2 */
64# define ACR1_SLOT_1_INPACK (1 << 14) /* inpack pin status */
65
66#define CPLD_AUX0 0xBE00000C
67#define CPLD_AUX1 0xBE000010
68#define CPLD_AUX2 0xBE000014
69
70/* Voltage levels */
71
72/* VPPEN1 - VPPEN0 */
73#define VPP_GND ((0 << 1) | (0 << 0))
74#define VPP_5V ((1 << 1) | (0 << 0))
75#define VPP_3V ((0 << 1) | (1 << 0))
76#define VPP_12V ((0 << 1) | (1 << 0))
77#define VPP_HIZ ((1 << 1) | (1 << 0))
78
79/* VCCEN1 - VCCEN0 */
80#define VCC_3V ((0 << 1) | (1 << 0))
81#define VCC_5V ((1 << 1) | (0 << 0))
82#define VCC_HIZ ((0 << 1) | (0 << 0))
83
84/* VPP/VCC */
85#define SET_VCC_VPP(VCC, VPP, SLOT) \
86 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
87#endif /* __ASM_PB1000_H */
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1100.h b/arch/mips/include/asm/mach-pb1x00/pb1100.h
new file mode 100644
index 000000000000..b1a60f1cbd02
--- /dev/null
+++ b/arch/mips/include/asm/mach-pb1x00/pb1100.h
@@ -0,0 +1,85 @@
1/*
2 * Alchemy Semi Pb1100 Referrence Board
3 *
4 * Copyright 2001, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. <source@mvista.com>
6 *
7 * ########################################################################
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 *
22 * ########################################################################
23 *
24 *
25 */
26#ifndef __ASM_PB1100_H
27#define __ASM_PB1100_H
28
29#define PB1100_IDENT 0xAE000000
30#define BOARD_STATUS_REG 0xAE000004
31# define PB1100_ROM_SEL (1 << 15)
32# define PB1100_ROM_SIZ (1 << 14)
33# define PB1100_SWAP_BOOT (1 << 13)
34# define PB1100_FLASH_WP (1 << 12)
35# define PB1100_ROM_H_STS (1 << 11)
36# define PB1100_ROM_L_STS (1 << 10)
37# define PB1100_FLASH_H_STS (1 << 9)
38# define PB1100_FLASH_L_STS (1 << 8)
39# define PB1100_SRAM_SIZ (1 << 7)
40# define PB1100_TSC_BUSY (1 << 6)
41# define PB1100_PCMCIA_VS_MASK (3 << 4)
42# define PB1100_RS232_CD (1 << 3)
43# define PB1100_RS232_CTS (1 << 2)
44# define PB1100_RS232_DSR (1 << 1)
45# define PB1100_RS232_RI (1 << 0)
46
47#define PB1100_IRDA_RS232 0xAE00000C
48# define PB1100_IRDA_FULL (0 << 14) /* full power */
49# define PB1100_IRDA_SHUTDOWN (1 << 14)
50# define PB1100_IRDA_TT (2 << 14) /* 2/3 power */
51# define PB1100_IRDA_OT (3 << 14) /* 1/3 power */
52# define PB1100_IRDA_FIR (1 << 13)
53
54#define PCMCIA_BOARD_REG 0xAE000010
55# define PB1100_SD_WP1_RO (1 << 15) /* read only */
56# define PB1100_SD_WP0_RO (1 << 14) /* read only */
57# define PB1100_SD_PWR1 (1 << 11) /* applies power to SD1 */
58# define PB1100_SD_PWR0 (1 << 10) /* applies power to SD0 */
59# define PB1100_SEL_SD_CONN1 (1 << 9)
60# define PB1100_SEL_SD_CONN0 (1 << 8)
61# define PC_DEASSERT_RST (1 << 7)
62# define PC_DRV_EN (1 << 4)
63
64#define PB1100_G_CONTROL 0xAE000014 /* graphics control */
65
66#define PB1100_RST_VDDI 0xAE00001C
67# define PB1100_SOFT_RESET (1 << 15) /* clear to reset the board */
68# define PB1100_VDDI_MASK 0x1F
69
70#define PB1100_LEDS 0xAE000018
71
72/*
73 * 11:8 is 4 discreet LEDs. Clearing a bit illuminates the LED.
74 * 7:0 is the LED Display's decimal points.
75 */
76#define PB1100_HEX_LED 0xAE000018
77
78/* PCMCIA Pb1100 specific defines */
79#define PCMCIA_MAX_SOCK 0
80#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
81
82/* VPP/VCC */
83#define SET_VCC_VPP(VCC, VPP) (((VCC) << 2) | ((VPP) << 0))
84
85#endif /* __ASM_PB1100_H */
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1200.h b/arch/mips/include/asm/mach-pb1x00/pb1200.h
new file mode 100644
index 000000000000..c8618df88cb5
--- /dev/null
+++ b/arch/mips/include/asm/mach-pb1x00/pb1200.h
@@ -0,0 +1,259 @@
1/*
2 * AMD Alchemy Pb1200 Referrence Board
3 * Board Registers defines.
4 *
5 * ########################################################################
6 *
7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 *
20 * ########################################################################
21 *
22 *
23 */
24#ifndef __ASM_PB1200_H
25#define __ASM_PB1200_H
26
27#include <linux/types.h>
28#include <asm/mach-au1x00/au1xxx_psc.h>
29
30#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
31#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
32#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX
33#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX
34
35/*
36 * SPI and SMB are muxed on the Pb1200 board.
37 * Refer to board documentation.
38 */
39#define SPI_PSC_BASE PSC0_BASE_ADDR
40#define SMBUS_PSC_BASE PSC0_BASE_ADDR
41/*
42 * AC97 and I2S are muxed on the Pb1200 board.
43 * Refer to board documentation.
44 */
45#define AC97_PSC_BASE PSC1_BASE_ADDR
46#define I2S_PSC_BASE PSC1_BASE_ADDR
47
48#define BCSR_KSEG1_ADDR 0xAD800000
49
50typedef volatile struct
51{
52 /*00*/ u16 whoami;
53 u16 reserved0;
54 /*04*/ u16 status;
55 u16 reserved1;
56 /*08*/ u16 switches;
57 u16 reserved2;
58 /*0C*/ u16 resets;
59 u16 reserved3;
60
61 /*10*/ u16 pcmcia;
62 u16 reserved4;
63 /*14*/ u16 board;
64 u16 reserved5;
65 /*18*/ u16 disk_leds;
66 u16 reserved6;
67 /*1C*/ u16 system;
68 u16 reserved7;
69
70 /*20*/ u16 intclr;
71 u16 reserved8;
72 /*24*/ u16 intset;
73 u16 reserved9;
74 /*28*/ u16 intclr_mask;
75 u16 reserved10;
76 /*2C*/ u16 intset_mask;
77 u16 reserved11;
78
79 /*30*/ u16 sig_status;
80 u16 reserved12;
81 /*34*/ u16 int_status;
82 u16 reserved13;
83 /*38*/ u16 reserved14;
84 u16 reserved15;
85 /*3C*/ u16 reserved16;
86 u16 reserved17;
87
88} BCSR;
89
90static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
91
92/*
93 * Register bit definitions for the BCSRs
94 */
95#define BCSR_WHOAMI_DCID 0x000F
96#define BCSR_WHOAMI_CPLD 0x00F0
97#define BCSR_WHOAMI_BOARD 0x0F00
98
99#define BCSR_STATUS_PCMCIA0VS 0x0003
100#define BCSR_STATUS_PCMCIA1VS 0x000C
101#define BCSR_STATUS_SWAPBOOT 0x0040
102#define BCSR_STATUS_FLASHBUSY 0x0100
103#define BCSR_STATUS_IDECBLID 0x0200
104#define BCSR_STATUS_SD0WP 0x0400
105#define BCSR_STATUS_SD1WP 0x0800
106#define BCSR_STATUS_U0RXD 0x1000
107#define BCSR_STATUS_U1RXD 0x2000
108
109#define BCSR_SWITCHES_OCTAL 0x00FF
110#define BCSR_SWITCHES_DIP_1 0x0080
111#define BCSR_SWITCHES_DIP_2 0x0040
112#define BCSR_SWITCHES_DIP_3 0x0020
113#define BCSR_SWITCHES_DIP_4 0x0010
114#define BCSR_SWITCHES_DIP_5 0x0008
115#define BCSR_SWITCHES_DIP_6 0x0004
116#define BCSR_SWITCHES_DIP_7 0x0002
117#define BCSR_SWITCHES_DIP_8 0x0001
118#define BCSR_SWITCHES_ROTARY 0x0F00
119
120#define BCSR_RESETS_ETH 0x0001
121#define BCSR_RESETS_CAMERA 0x0002
122#define BCSR_RESETS_DC 0x0004
123#define BCSR_RESETS_IDE 0x0008
124/* not resets but in the same register */
125#define BCSR_RESETS_WSCFSM 0x0800
126#define BCSR_RESETS_PCS0MUX 0x1000
127#define BCSR_RESETS_PCS1MUX 0x2000
128#define BCSR_RESETS_SPISEL 0x4000
129#define BCSR_RESETS_SD1MUX 0x8000
130
131#define BCSR_PCMCIA_PC0VPP 0x0003
132#define BCSR_PCMCIA_PC0VCC 0x000C
133#define BCSR_PCMCIA_PC0DRVEN 0x0010
134#define BCSR_PCMCIA_PC0RST 0x0080
135#define BCSR_PCMCIA_PC1VPP 0x0300
136#define BCSR_PCMCIA_PC1VCC 0x0C00
137#define BCSR_PCMCIA_PC1DRVEN 0x1000
138#define BCSR_PCMCIA_PC1RST 0x8000
139
140#define BCSR_BOARD_LCDVEE 0x0001
141#define BCSR_BOARD_LCDVDD 0x0002
142#define BCSR_BOARD_LCDBL 0x0004
143#define BCSR_BOARD_CAMSNAP 0x0010
144#define BCSR_BOARD_CAMPWR 0x0020
145#define BCSR_BOARD_SD0PWR 0x0040
146#define BCSR_BOARD_SD1PWR 0x0080
147
148#define BCSR_LEDS_DECIMALS 0x00FF
149#define BCSR_LEDS_LED0 0x0100
150#define BCSR_LEDS_LED1 0x0200
151#define BCSR_LEDS_LED2 0x0400
152#define BCSR_LEDS_LED3 0x0800
153
154#define BCSR_SYSTEM_VDDI 0x001F
155#define BCSR_SYSTEM_POWEROFF 0x4000
156#define BCSR_SYSTEM_RESET 0x8000
157
158/* Bit positions for the different interrupt sources */
159#define BCSR_INT_IDE 0x0001
160#define BCSR_INT_ETH 0x0002
161#define BCSR_INT_PC0 0x0004
162#define BCSR_INT_PC0STSCHG 0x0008
163#define BCSR_INT_PC1 0x0010
164#define BCSR_INT_PC1STSCHG 0x0020
165#define BCSR_INT_DC 0x0040
166#define BCSR_INT_FLASHBUSY 0x0080
167#define BCSR_INT_PC0INSERT 0x0100
168#define BCSR_INT_PC0EJECT 0x0200
169#define BCSR_INT_PC1INSERT 0x0400
170#define BCSR_INT_PC1EJECT 0x0800
171#define BCSR_INT_SD0INSERT 0x1000
172#define BCSR_INT_SD0EJECT 0x2000
173#define BCSR_INT_SD1INSERT 0x4000
174#define BCSR_INT_SD1EJECT 0x8000
175
176#define SMC91C111_PHYS_ADDR 0x0D000300
177#define SMC91C111_INT PB1200_ETH_INT
178
179#define IDE_PHYS_ADDR 0x0C800000
180#define IDE_REG_SHIFT 5
181#define IDE_PHYS_LEN (16 << IDE_REG_SHIFT)
182#define IDE_INT PB1200_IDE_INT
183#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1
184#define IDE_RQSIZE 128
185
186#define NAND_PHYS_ADDR 0x1C000000
187
188/*
189 * Timing values as described in databook, * ns value stripped of
190 * lower 2 bits.
191 * These defines are here rather than an Au1200 generic file because
192 * the parts chosen on another board may be different and may require
193 * different timings.
194 */
195#define NAND_T_H (18 >> 2)
196#define NAND_T_PUL (30 >> 2)
197#define NAND_T_SU (30 >> 2)
198#define NAND_T_WH (30 >> 2)
199
200/* Bitfield shift amounts */
201#define NAND_T_H_SHIFT 0
202#define NAND_T_PUL_SHIFT 4
203#define NAND_T_SU_SHIFT 8
204#define NAND_T_WH_SHIFT 12
205
206#define NAND_TIMING (((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \
207 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \
208 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \
209 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT))
210
211/*
212 * External Interrupts for Pb1200 as of 8/6/2004.
213 * Bit positions in the CPLD registers can be calculated by taking
214 * the interrupt define and subtracting the PB1200_INT_BEGIN value.
215 *
216 * Example: IDE bis pos is = 64 - 64
217 * ETH bit pos is = 65 - 64
218 */
219enum external_pb1200_ints {
220 PB1200_INT_BEGIN = AU1000_MAX_INTR + 1,
221
222 PB1200_IDE_INT = PB1200_INT_BEGIN,
223 PB1200_ETH_INT,
224 PB1200_PC0_INT,
225 PB1200_PC0_STSCHG_INT,
226 PB1200_PC1_INT,
227 PB1200_PC1_STSCHG_INT,
228 PB1200_DC_INT,
229 PB1200_FLASHBUSY_INT,
230 PB1200_PC0_INSERT_INT,
231 PB1200_PC0_EJECT_INT,
232 PB1200_PC1_INSERT_INT,
233 PB1200_PC1_EJECT_INT,
234 PB1200_SD0_INSERT_INT,
235 PB1200_SD0_EJECT_INT,
236 PB1200_SD1_INSERT_INT,
237 PB1200_SD1_EJECT_INT,
238
239 PB1200_INT_END = PB1200_INT_BEGIN + 15
240};
241
242/*
243 * Pb1200 specific PCMCIA defines for drivers/pcmcia/au1000_db1x00.c
244 */
245#define PCMCIA_MAX_SOCK 1
246#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
247
248/* VPP/VCC */
249#define SET_VCC_VPP(VCC, VPP, SLOT) \
250 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
251
252#define BOARD_PC0_INT PB1200_PC0_INT
253#define BOARD_PC1_INT PB1200_PC1_INT
254#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1 << (8 + (2 * SOCKET)))
255
256/* NAND chip select */
257#define NAND_CS 1
258
259#endif /* __ASM_PB1200_H */
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1500.h b/arch/mips/include/asm/mach-pb1x00/pb1500.h
new file mode 100644
index 000000000000..da51a2eb7b82
--- /dev/null
+++ b/arch/mips/include/asm/mach-pb1x00/pb1500.h
@@ -0,0 +1,49 @@
1/*
2 * Alchemy Semi Pb1500 Referrence Board
3 *
4 * Copyright 2001, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. <source@mvista.com>
6 *
7 * ########################################################################
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 *
22 * ########################################################################
23 *
24 *
25 */
26#ifndef __ASM_PB1500_H
27#define __ASM_PB1500_H
28
29#define IDENT_BOARD_REG 0xAE000000
30#define BOARD_STATUS_REG 0xAE000004
31#define PCI_BOARD_REG 0xAE000010
32#define PCMCIA_BOARD_REG 0xAE000010
33# define PC_DEASSERT_RST 0x80
34# define PC_DRV_EN 0x10
35#define PB1500_G_CONTROL 0xAE000014
36#define PB1500_RST_VDDI 0xAE00001C
37#define PB1500_LEDS 0xAE000018
38
39#define PB1500_HEX_LED 0xAF000004
40#define PB1500_HEX_LED_BLANK 0xAF000008
41
42/* PCMCIA Pb1500 specific defines */
43#define PCMCIA_MAX_SOCK 0
44#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
45
46/* VPP/VCC */
47#define SET_VCC_VPP(VCC, VPP) (((VCC) << 2) | ((VPP) << 0))
48
49#endif /* __ASM_PB1500_H */
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1550.h b/arch/mips/include/asm/mach-pb1x00/pb1550.h
new file mode 100644
index 000000000000..6704a11497db
--- /dev/null
+++ b/arch/mips/include/asm/mach-pb1x00/pb1550.h
@@ -0,0 +1,177 @@
1/*
2 * AMD Alchemy Semi PB1550 Referrence Board
3 * Board Registers defines.
4 *
5 * Copyright 2004 Embedded Edge LLC.
6 * Copyright 2005 Ralf Baechle (ralf@linux-mips.org)
7 *
8 * ########################################################################
9 *
10 * This program is free software; you can distribute it and/or modify it
11 * under the terms of the GNU General Public License (Version 2) as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * ########################################################################
24 *
25 *
26 */
27#ifndef __ASM_PB1550_H
28#define __ASM_PB1550_H
29
30#include <linux/types.h>
31#include <asm/mach-au1x00/au1xxx_psc.h>
32
33#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
34#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
35#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC3_TX
36#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC3_RX
37
38#define SPI_PSC_BASE PSC0_BASE_ADDR
39#define AC97_PSC_BASE PSC1_BASE_ADDR
40#define SMBUS_PSC_BASE PSC2_BASE_ADDR
41#define I2S_PSC_BASE PSC3_BASE_ADDR
42
43#define BCSR_PHYS_ADDR 0xAF000000
44
45typedef volatile struct
46{
47 /*00*/ u16 whoami;
48 u16 reserved0;
49 /*04*/ u16 status;
50 u16 reserved1;
51 /*08*/ u16 switches;
52 u16 reserved2;
53 /*0C*/ u16 resets;
54 u16 reserved3;
55 /*10*/ u16 pcmcia;
56 u16 reserved4;
57 /*14*/ u16 pci;
58 u16 reserved5;
59 /*18*/ u16 leds;
60 u16 reserved6;
61 /*1C*/ u16 system;
62 u16 reserved7;
63
64} BCSR;
65
66static BCSR * const bcsr = (BCSR *)BCSR_PHYS_ADDR;
67
68/*
69 * Register bit definitions for the BCSRs
70 */
71#define BCSR_WHOAMI_DCID 0x000F
72#define BCSR_WHOAMI_CPLD 0x00F0
73#define BCSR_WHOAMI_BOARD 0x0F00
74
75#define BCSR_STATUS_PCMCIA0VS 0x0003
76#define BCSR_STATUS_PCMCIA1VS 0x000C
77#define BCSR_STATUS_PCMCIA0FI 0x0010
78#define BCSR_STATUS_PCMCIA1FI 0x0020
79#define BCSR_STATUS_SWAPBOOT 0x0040
80#define BCSR_STATUS_SRAMWIDTH 0x0080
81#define BCSR_STATUS_FLASHBUSY 0x0100
82#define BCSR_STATUS_ROMBUSY 0x0200
83#define BCSR_STATUS_USBOTGID 0x0800
84#define BCSR_STATUS_U0RXD 0x1000
85#define BCSR_STATUS_U1RXD 0x2000
86#define BCSR_STATUS_U3RXD 0x8000
87
88#define BCSR_SWITCHES_OCTAL 0x00FF
89#define BCSR_SWITCHES_DIP_1 0x0080
90#define BCSR_SWITCHES_DIP_2 0x0040
91#define BCSR_SWITCHES_DIP_3 0x0020
92#define BCSR_SWITCHES_DIP_4 0x0010
93#define BCSR_SWITCHES_DIP_5 0x0008
94#define BCSR_SWITCHES_DIP_6 0x0004
95#define BCSR_SWITCHES_DIP_7 0x0002
96#define BCSR_SWITCHES_DIP_8 0x0001
97#define BCSR_SWITCHES_ROTARY 0x0F00
98
99#define BCSR_RESETS_PHY0 0x0001
100#define BCSR_RESETS_PHY1 0x0002
101#define BCSR_RESETS_DC 0x0004
102#define BCSR_RESETS_WSC 0x2000
103#define BCSR_RESETS_SPISEL 0x4000
104#define BCSR_RESETS_DMAREQ 0x8000
105
106#define BCSR_PCMCIA_PC0VPP 0x0003
107#define BCSR_PCMCIA_PC0VCC 0x000C
108#define BCSR_PCMCIA_PC0DRVEN 0x0010
109#define BCSR_PCMCIA_PC0RST 0x0080
110#define BCSR_PCMCIA_PC1VPP 0x0300
111#define BCSR_PCMCIA_PC1VCC 0x0C00
112#define BCSR_PCMCIA_PC1DRVEN 0x1000
113#define BCSR_PCMCIA_PC1RST 0x8000
114
115#define BCSR_PCI_M66EN 0x0001
116#define BCSR_PCI_M33 0x0100
117#define BCSR_PCI_EXTERNARB 0x0200
118#define BCSR_PCI_GPIO200RST 0x0400
119#define BCSR_PCI_CLKOUT 0x0800
120#define BCSR_PCI_CFGHOST 0x1000
121
122#define BCSR_LEDS_DECIMALS 0x00FF
123#define BCSR_LEDS_LED0 0x0100
124#define BCSR_LEDS_LED1 0x0200
125#define BCSR_LEDS_LED2 0x0400
126#define BCSR_LEDS_LED3 0x0800
127
128#define BCSR_SYSTEM_VDDI 0x001F
129#define BCSR_SYSTEM_POWEROFF 0x4000
130#define BCSR_SYSTEM_RESET 0x8000
131
132#define PCMCIA_MAX_SOCK 1
133#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
134
135/* VPP/VCC */
136#define SET_VCC_VPP(VCC, VPP, SLOT) \
137 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
138
139#if defined(CONFIG_MTD_PB1550_BOOT) && defined(CONFIG_MTD_PB1550_USER)
140#define PB1550_BOTH_BANKS
141#elif defined(CONFIG_MTD_PB1550_BOOT) && !defined(CONFIG_MTD_PB1550_USER)
142#define PB1550_BOOT_ONLY
143#elif !defined(CONFIG_MTD_PB1550_BOOT) && defined(CONFIG_MTD_PB1550_USER)
144#define PB1550_USER_ONLY
145#endif
146
147/*
148 * Timing values as described in databook, * ns value stripped of
149 * lower 2 bits.
150 * These defines are here rather than an SOC1550 generic file because
151 * the parts chosen on another board may be different and may require
152 * different timings.
153 */
154#define NAND_T_H (18 >> 2)
155#define NAND_T_PUL (30 >> 2)
156#define NAND_T_SU (30 >> 2)
157#define NAND_T_WH (30 >> 2)
158
159/* Bitfield shift amounts */
160#define NAND_T_H_SHIFT 0
161#define NAND_T_PUL_SHIFT 4
162#define NAND_T_SU_SHIFT 8
163#define NAND_T_WH_SHIFT 12
164
165#define NAND_TIMING (((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \
166 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \
167 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \
168 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT))
169
170#define NAND_CS 1
171
172/* Should be done by YAMON */
173#define NAND_STCFG 0x00400005 /* 8-bit NAND */
174#define NAND_STTIME 0x00007774 /* valid for 396 MHz SD=2 only */
175#define NAND_STADDR 0x12000FFF /* physical address 0x20000000 */
176
177#endif /* __ASM_PB1550_H */
diff --git a/arch/mips/include/asm/mach-pnx8550/cm.h b/arch/mips/include/asm/mach-pnx8550/cm.h
new file mode 100644
index 000000000000..bb0a56c7d011
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/cm.h
@@ -0,0 +1,43 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Clock module specific definitions
5 *
6 * Author: source@mvista.com
7 *
8 * This program is free software; you can distribute it and/or modify it
9 * under the terms of the GNU General Public License (Version 2) as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 */
21
22#ifndef __PNX8550_CM_H
23#define __PNX8550_CM_H
24
25#define PNX8550_CM_BASE 0xBBE47000
26
27#define PNX8550_CM_PLL0_CTL *(volatile unsigned long *)(PNX8550_CM_BASE + 0x000)
28#define PNX8550_CM_PLL1_CTL *(volatile unsigned long *)(PNX8550_CM_BASE + 0x004)
29#define PNX8550_CM_PLL2_CTL *(volatile unsigned long *)(PNX8550_CM_BASE + 0x008)
30#define PNX8550_CM_PLL3_CTL *(volatile unsigned long *)(PNX8550_CM_BASE + 0x00C)
31
32// Table not complete.....
33
34#define PNX8550_CM_PLL_BLOCKED_MASK 0x80000000
35#define PNX8550_CM_PLL_LOCK_MASK 0x40000000
36#define PNX8550_CM_PLL_CURRENT_ADJ_MASK 0x3c000000
37#define PNX8550_CM_PLL_N_MASK 0x01ff0000
38#define PNX8550_CM_PLL_M_MASK 0x00003f00
39#define PNX8550_CM_PLL_P_MASK 0x0000000c
40#define PNX8550_CM_PLL_PD_MASK 0x00000002
41
42
43#endif
diff --git a/arch/mips/include/asm/mach-pnx8550/glb.h b/arch/mips/include/asm/mach-pnx8550/glb.h
new file mode 100644
index 000000000000..07aa85e609bc
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/glb.h
@@ -0,0 +1,86 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * PNX8550 global definitions
5 *
6 * Author: source@mvista.com
7 *
8 * This program is free software; you can distribute it and/or modify it
9 * under the terms of the GNU General Public License (Version 2) as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 */
21
22#ifndef __PNX8550_GLB_H
23#define __PNX8550_GLB_H
24
25#define PNX8550_GLB1_BASE 0xBBE63000
26#define PNX8550_GLB2_BASE 0xBBE4d000
27#define PNX8550_RESET_BASE 0xBBE60000
28
29/* PCI Inta Output Enable Registers */
30#define PNX8550_GLB2_ENAB_INTA_O *(volatile unsigned long *)(PNX8550_GLB2_BASE + 0x050)
31
32/* Bit 1:Enable DAC Powerdown
33 0:DACs are enabled and are working normally
34 1:DACs are powerdown
35*/
36#define PNX8550_GLB_DAC_PD 0x2
37/* Bit 0:Enable of PCI inta output
38 0 = Disable PCI inta output
39 1 = Enable PCI inta output
40*/
41#define PNX8550_GLB_ENABLE_INTA_O 0x1
42
43/* PCI Direct Mappings */
44#define PNX8550_PCIMEM 0x12000000
45#define PNX8550_PCIMEM_SIZE 0x08000000
46#define PNX8550_PCIIO 0x1c000000
47#define PNX8550_PCIIO_SIZE 0x02000000 /* 32M */
48
49#define PNX8550_PORT_BASE KSEG1
50
51// GPIO def
52#define PNX8550_GPIO_BASE 0x1Be00000
53
54#define PNX8550_GPIO_DIRQ0 (PNX8550_GPIO_BASE + 0x104500)
55#define PNX8550_GPIO_MC1 (PNX8550_GPIO_BASE + 0x104004)
56#define PNX8550_GPIO_MC_31_BIT 30
57#define PNX8550_GPIO_MC_30_BIT 28
58#define PNX8550_GPIO_MC_29_BIT 26
59#define PNX8550_GPIO_MC_28_BIT 24
60#define PNX8550_GPIO_MC_27_BIT 22
61#define PNX8550_GPIO_MC_26_BIT 20
62#define PNX8550_GPIO_MC_25_BIT 18
63#define PNX8550_GPIO_MC_24_BIT 16
64#define PNX8550_GPIO_MC_23_BIT 14
65#define PNX8550_GPIO_MC_22_BIT 12
66#define PNX8550_GPIO_MC_21_BIT 10
67#define PNX8550_GPIO_MC_20_BIT 8
68#define PNX8550_GPIO_MC_19_BIT 6
69#define PNX8550_GPIO_MC_18_BIT 4
70#define PNX8550_GPIO_MC_17_BIT 2
71#define PNX8550_GPIO_MC_16_BIT 0
72
73#define PNX8550_GPIO_MODE_PRIMOP 0x1
74#define PNX8550_GPIO_MODE_NO_OPENDR 0x2
75#define PNX8550_GPIO_MODE_OPENDR 0x3
76
77// RESET module
78#define PNX8550_RST_CTL *(volatile unsigned long *)(PNX8550_RESET_BASE + 0x0)
79#define PNX8550_RST_CAUSE *(volatile unsigned long *)(PNX8550_RESET_BASE + 0x4)
80#define PNX8550_RST_EN_WATCHDOG *(volatile unsigned long *)(PNX8550_RESET_BASE + 0x8)
81
82#define PNX8550_RST_REL_MIPS_RST_N 0x8
83#define PNX8550_RST_DO_SW_RST 0x4
84#define PNX8550_RST_REL_SYS_RST_OUT 0x2
85#define PNX8550_RST_ASSERT_SYS_RST_OUT 0x1
86#endif
diff --git a/arch/mips/include/asm/mach-pnx8550/int.h b/arch/mips/include/asm/mach-pnx8550/int.h
new file mode 100644
index 000000000000..0e0668b524f4
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/int.h
@@ -0,0 +1,140 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Interrupt specific definitions
5 *
6 * Author: source@mvista.com
7 *
8 * This program is free software; you can distribute it and/or modify it
9 * under the terms of the GNU General Public License (Version 2) as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 */
21
22#ifndef __PNX8550_INT_H
23#define __PNX8550_INT_H
24
25#define PNX8550_GIC_BASE 0xBBE3E000
26
27#define PNX8550_GIC_PRIMASK_0 *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x000)
28#define PNX8550_GIC_PRIMASK_1 *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x004)
29#define PNX8550_GIC_VECTOR_0 *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x100)
30#define PNX8550_GIC_VECTOR_1 *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x104)
31#define PNX8550_GIC_PEND_1_31 *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x200)
32#define PNX8550_GIC_PEND_32_63 *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x204)
33#define PNX8550_GIC_PEND_64_70 *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x208)
34#define PNX8550_GIC_FEATURES *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x300)
35#define PNX8550_GIC_REQ(x) *(volatile unsigned long *)(PNX8550_GIC_BASE + 0x400 + (x)*4)
36#define PNX8550_GIC_MOD_ID *(volatile unsigned long *)(PNX8550_GIC_BASE + 0xFFC)
37
38// cp0 is two software + six hw exceptions
39#define PNX8550_INT_CP0_TOTINT 8
40#define PNX8550_INT_CP0_MIN 0
41#define PNX8550_INT_CP0_MAX (PNX8550_INT_CP0_MIN + PNX8550_INT_CP0_TOTINT - 1)
42
43#define MIPS_CPU_GIC_IRQ 2
44#define MIPS_CPU_TIMER_IRQ 7
45
46// GIC are 71 exceptions connected to cp0's first hardware exception
47#define PNX8550_INT_GIC_TOTINT 71
48#define PNX8550_INT_GIC_MIN (PNX8550_INT_CP0_MAX+1)
49#define PNX8550_INT_GIC_MAX (PNX8550_INT_GIC_MIN + PNX8550_INT_GIC_TOTINT - 1)
50
51#define PNX8550_INT_UNDEF (PNX8550_INT_GIC_MIN+0)
52#define PNX8550_INT_IPC_TARGET0_MIPS (PNX8550_INT_GIC_MIN+1)
53#define PNX8550_INT_IPC_TARGET1_TM32_1 (PNX8550_INT_GIC_MIN+2)
54#define PNX8550_INT_IPC_TARGET1_TM32_2 (PNX8550_INT_GIC_MIN+3)
55#define PNX8550_INT_RESERVED_4 (PNX8550_INT_GIC_MIN+4)
56#define PNX8550_INT_USB (PNX8550_INT_GIC_MIN+5)
57#define PNX8550_INT_GPIO_EQ1 (PNX8550_INT_GIC_MIN+6)
58#define PNX8550_INT_GPIO_EQ2 (PNX8550_INT_GIC_MIN+7)
59#define PNX8550_INT_GPIO_EQ3 (PNX8550_INT_GIC_MIN+8)
60#define PNX8550_INT_GPIO_EQ4 (PNX8550_INT_GIC_MIN+9)
61
62#define PNX8550_INT_GPIO_EQ5 (PNX8550_INT_GIC_MIN+10)
63#define PNX8550_INT_GPIO_EQ6 (PNX8550_INT_GIC_MIN+11)
64#define PNX8550_INT_RESERVED_12 (PNX8550_INT_GIC_MIN+12)
65#define PNX8550_INT_QVCP1 (PNX8550_INT_GIC_MIN+13)
66#define PNX8550_INT_QVCP2 (PNX8550_INT_GIC_MIN+14)
67#define PNX8550_INT_I2C1 (PNX8550_INT_GIC_MIN+15)
68#define PNX8550_INT_I2C2 (PNX8550_INT_GIC_MIN+16)
69#define PNX8550_INT_ISO_UART1 (PNX8550_INT_GIC_MIN+17)
70#define PNX8550_INT_ISO_UART2 (PNX8550_INT_GIC_MIN+18)
71#define PNX8550_INT_UART1 (PNX8550_INT_GIC_MIN+19)
72
73#define PNX8550_INT_UART2 (PNX8550_INT_GIC_MIN+20)
74#define PNX8550_INT_QNTR (PNX8550_INT_GIC_MIN+21)
75#define PNX8550_INT_RESERVED22 (PNX8550_INT_GIC_MIN+22)
76#define PNX8550_INT_T_DSC (PNX8550_INT_GIC_MIN+23)
77#define PNX8550_INT_M_DSC (PNX8550_INT_GIC_MIN+24)
78#define PNX8550_INT_RESERVED25 (PNX8550_INT_GIC_MIN+25)
79#define PNX8550_INT_2D_DRAW_ENG (PNX8550_INT_GIC_MIN+26)
80#define PNX8550_INT_MEM_BASED_SCALAR1 (PNX8550_INT_GIC_MIN+27)
81#define PNX8550_INT_VIDEO_MPEG (PNX8550_INT_GIC_MIN+28)
82#define PNX8550_INT_VIDEO_INPUT_P1 (PNX8550_INT_GIC_MIN+29)
83
84#define PNX8550_INT_VIDEO_INPUT_P2 (PNX8550_INT_GIC_MIN+30)
85#define PNX8550_INT_SPDI1 (PNX8550_INT_GIC_MIN+31)
86#define PNX8550_INT_SPDO (PNX8550_INT_GIC_MIN+32)
87#define PNX8550_INT_AUDIO_INPUT1 (PNX8550_INT_GIC_MIN+33)
88#define PNX8550_INT_AUDIO_OUTPUT1 (PNX8550_INT_GIC_MIN+34)
89#define PNX8550_INT_AUDIO_INPUT2 (PNX8550_INT_GIC_MIN+35)
90#define PNX8550_INT_AUDIO_OUTPUT2 (PNX8550_INT_GIC_MIN+36)
91#define PNX8550_INT_MEMBASED_SCALAR2 (PNX8550_INT_GIC_MIN+37)
92#define PNX8550_INT_VPK (PNX8550_INT_GIC_MIN+38)
93#define PNX8550_INT_MPEG1_MIPS (PNX8550_INT_GIC_MIN+39)
94
95#define PNX8550_INT_MPEG1_TM (PNX8550_INT_GIC_MIN+40)
96#define PNX8550_INT_MPEG2_MIPS (PNX8550_INT_GIC_MIN+41)
97#define PNX8550_INT_MPEG2_TM (PNX8550_INT_GIC_MIN+42)
98#define PNX8550_INT_TS_DMA (PNX8550_INT_GIC_MIN+43)
99#define PNX8550_INT_EDMA (PNX8550_INT_GIC_MIN+44)
100#define PNX8550_INT_TM_DEBUG1 (PNX8550_INT_GIC_MIN+45)
101#define PNX8550_INT_TM_DEBUG2 (PNX8550_INT_GIC_MIN+46)
102#define PNX8550_INT_PCI_INTA (PNX8550_INT_GIC_MIN+47)
103#define PNX8550_INT_CLOCK_MODULE (PNX8550_INT_GIC_MIN+48)
104#define PNX8550_INT_PCI_XIO_INTA_PCI (PNX8550_INT_GIC_MIN+49)
105
106#define PNX8550_INT_PCI_XIO_INTB_DMA (PNX8550_INT_GIC_MIN+50)
107#define PNX8550_INT_PCI_XIO_INTC_GPPM (PNX8550_INT_GIC_MIN+51)
108#define PNX8550_INT_PCI_XIO_INTD_GPXIO (PNX8550_INT_GIC_MIN+52)
109#define PNX8550_INT_DVD_CSS (PNX8550_INT_GIC_MIN+53)
110#define PNX8550_INT_VLD (PNX8550_INT_GIC_MIN+54)
111#define PNX8550_INT_GPIO_TSU_7_0 (PNX8550_INT_GIC_MIN+55)
112#define PNX8550_INT_GPIO_TSU_15_8 (PNX8550_INT_GIC_MIN+56)
113#define PNX8550_INT_GPIO_CTU_IR (PNX8550_INT_GIC_MIN+57)
114#define PNX8550_INT_GPIO0 (PNX8550_INT_GIC_MIN+58)
115#define PNX8550_INT_GPIO1 (PNX8550_INT_GIC_MIN+59)
116
117#define PNX8550_INT_GPIO2 (PNX8550_INT_GIC_MIN+60)
118#define PNX8550_INT_GPIO3 (PNX8550_INT_GIC_MIN+61)
119#define PNX8550_INT_GPIO4 (PNX8550_INT_GIC_MIN+62)
120#define PNX8550_INT_GPIO5 (PNX8550_INT_GIC_MIN+63)
121#define PNX8550_INT_GPIO6 (PNX8550_INT_GIC_MIN+64)
122#define PNX8550_INT_GPIO7 (PNX8550_INT_GIC_MIN+65)
123#define PNX8550_INT_PMAN_SECURITY (PNX8550_INT_GIC_MIN+66)
124#define PNX8550_INT_I2C3 (PNX8550_INT_GIC_MIN+67)
125#define PNX8550_INT_RESERVED_68 (PNX8550_INT_GIC_MIN+68)
126#define PNX8550_INT_SPDI2 (PNX8550_INT_GIC_MIN+69)
127
128#define PNX8550_INT_I2C4 (PNX8550_INT_GIC_MIN+70)
129
130// Timer are 3 exceptions connected to cp0's 7th hardware exception
131#define PNX8550_INT_TIMER_TOTINT 3
132#define PNX8550_INT_TIMER_MIN (PNX8550_INT_GIC_MAX+1)
133#define PNX8550_INT_TIMER_MAX (PNX8550_INT_TIMER_MIN + PNX8550_INT_TIMER_TOTINT - 1)
134
135#define PNX8550_INT_TIMER1 (PNX8550_INT_TIMER_MIN+0)
136#define PNX8550_INT_TIMER2 (PNX8550_INT_TIMER_MIN+1)
137#define PNX8550_INT_TIMER3 (PNX8550_INT_TIMER_MIN+2)
138#define PNX8550_INT_WATCHDOG PNX8550_INT_TIMER3
139
140#endif
diff --git a/arch/mips/include/asm/mach-pnx8550/kernel-entry-init.h b/arch/mips/include/asm/mach-pnx8550/kernel-entry-init.h
new file mode 100644
index 000000000000..bdde00c9199b
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/kernel-entry-init.h
@@ -0,0 +1,262 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005 Embedded Alley Solutions, Inc
7 */
8#ifndef __ASM_MACH_KERNEL_ENTRY_INIT_H
9#define __ASM_MACH_KERNEL_ENTRY_INIT_H
10
11#include <asm/cacheops.h>
12#include <asm/addrspace.h>
13
14#define CO_CONFIGPR_VALID 0x3F1F41FF /* valid bits to write to ConfigPR */
15#define HAZARD_CP0 nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop;
16#define CACHE_OPC 0xBC000000 /* MIPS cache instruction opcode */
17#define ICACHE_LINE_SIZE 32 /* Instruction cache line size bytes */
18#define DCACHE_LINE_SIZE 32 /* Data cache line size in bytes */
19
20#define ICACHE_SET_COUNT 256 /* Instruction cache set count */
21#define DCACHE_SET_COUNT 128 /* Data cache set count */
22
23#define ICACHE_SET_SIZE (ICACHE_SET_COUNT * ICACHE_LINE_SIZE)
24#define DCACHE_SET_SIZE (DCACHE_SET_COUNT * DCACHE_LINE_SIZE)
25
26 .macro kernel_entry_setup
27 .set push
28 .set noreorder
29 /*
30 * PNX8550 entry point, when running a non compressed
31 * kernel. When loading a zImage, the head.S code in
32 * arch/mips/zboot/pnx8550 will init the caches and,
33 * decompress the kernel, and branch to kernel_entry.
34 */
35cache_begin: li t0, (1<<28)
36 mtc0 t0, CP0_STATUS /* cp0 usable */
37 HAZARD_CP0
38
39 mtc0 zero, CP0_CAUSE
40 HAZARD_CP0
41
42
43 /* Set static virtual to phys address translation and TLB disabled */
44 mfc0 t0, CP0_CONFIG, 7
45 HAZARD_CP0
46
47 and t0, ~((1<<19) | (1<<20)) /* TLB/MAP cleared */
48 mtc0 t0, CP0_CONFIG, 7
49 HAZARD_CP0
50
51 /* CPU boots with kseg0 cache algo set to 0x2 -- uncached */
52
53 init_icache
54 nop
55 init_dcache
56 nop
57
58 cachePr4450ICReset
59 nop
60
61 cachePr4450DCReset
62 nop
63
64 /* read ConfigPR into t0 */
65 mfc0 t0, CP0_CONFIG, 7
66 HAZARD_CP0
67
68 /* enable the TLB */
69 or t0, (1<<19)
70
71 /* disable the ICACHE: at least 10x slower */
72 /* or t0, (1<<26) */
73
74 /* disable the DCACHE; CONFIG_CPU_HAS_LLSC should not be set */
75 /* or t0, (1<<27) */
76
77 and t0, CO_CONFIGPR_VALID
78
79 /* enable TLB. */
80 mtc0 t0, CP0_CONFIG, 7
81 HAZARD_CP0
82cache_end:
83 /* Setup CMEM_0 to MMIO address space, 2MB */
84 lui t0, 0x1BE0
85 addi t0, t0, 0x3
86 mtc0 $8, $22, 4
87 nop
88
89 /* Setup CMEM_1, 128MB */
90 lui t0, 0x1000
91 addi t0, t0, 0xf
92 mtc0 $8, $22, 5
93 nop
94
95
96 /* Setup CMEM_2, 32MB */
97 lui t0, 0x1C00
98 addi t0, t0, 0xb
99 mtc0 $8, $22, 6
100 nop
101
102 /* Setup CMEM_3, 0MB */
103 lui t0, 0x0
104 addi t0, t0, 0x0
105 mtc0 $8, $22, 7
106 nop
107
108 /* Enable cache */
109 mfc0 t0, CP0_CONFIG
110 HAZARD_CP0
111 and t0, t0, 0xFFFFFFF8
112 or t0, t0, 3
113 mtc0 t0, CP0_CONFIG
114 HAZARD_CP0
115 .set pop
116 .endm
117
118 .macro init_icache
119 .set push
120 .set noreorder
121
122 /* Get Cache Configuration */
123 mfc0 t3, CP0_CONFIG, 1
124 HAZARD_CP0
125
126 /* get cache Line size */
127
128 srl t1, t3, 19 /* C0_CONFIGPR_IL_SHIFT */
129 andi t1, t1, 0x7 /* C0_CONFIGPR_IL_MASK */
130 beq t1, zero, pr4450_instr_cache_invalidated /* if zero instruction cache is absent */
131 nop
132 addiu t0, t1, 1
133 ori t1, zero, 1
134 sllv t1, t1, t0
135
136 /* get max cache Index */
137 srl t2, t3, 22 /* C0_CONFIGPR_IS_SHIFT */
138 andi t2, t2, 0x7 /* C0_CONFIGPR_IS_MASK */
139 addiu t0, t2, 6
140 ori t2, zero, 1
141 sllv t2, t2, t0
142
143 /* get max cache way */
144 srl t3, t3, 16 /* C0_CONFIGPR_IA_SHIFT */
145 andi t3, t3, 0x7 /* C0_CONFIGPR_IA_MASK */
146 addiu t3, t3, 1
147
148 /* total no of cache lines */
149 multu t2, t3 /* max index * max way */
150 mflo t2
151 addiu t2, t2, -1
152
153 move t0, zero
154pr4450_next_instruction_cache_set:
155 cache Index_Invalidate_I, 0(t0)
156 addu t0, t0, t1 /* add bytes in a line */
157 bne t2, zero, pr4450_next_instruction_cache_set
158 addiu t2, t2, -1 /* reduce no of lines to invalidate by one */
159pr4450_instr_cache_invalidated:
160 .set pop
161 .endm
162
163 .macro init_dcache
164 .set push
165 .set noreorder
166 move t1, zero
167
168 /* Store Tag Information */
169 mtc0 zero, CP0_TAGLO, 0
170 HAZARD_CP0
171
172 mtc0 zero, CP0_TAGHI, 0
173 HAZARD_CP0
174
175 /* Cache size is 16384 = 512 lines x 32 bytes per line */
176 or t2, zero, (128*4)-1 /* 512 lines */
177 /* Invalidate all lines */
1782:
179 cache Index_Store_Tag_D, 0(t1)
180 addiu t2, t2, -1
181 bne t2, zero, 2b
182 addiu t1, t1, 32 /* 32 bytes in a line */
183 .set pop
184 .endm
185
186 .macro cachePr4450ICReset
187 .set push
188 .set noreorder
189
190 /* Save CP0 status reg on entry; */
191 /* disable interrupts during cache reset */
192 mfc0 t0, CP0_STATUS /* T0 = interrupt status on entry */
193 HAZARD_CP0
194
195 mtc0 zero, CP0_STATUS /* disable CPU interrupts */
196 HAZARD_CP0
197
198 or t1, zero, zero /* T1 = starting cache index (0) */
199 ori t2, zero, (256 - 1) /* T2 = inst cache set cnt - 1 */
200
201 icache_invd_loop:
202 /* 9 == register t1 */
203 .word CACHE_OPC | (9 << 21) | (Index_Invalidate_I << 16) | \
204 (0 * ICACHE_SET_SIZE) /* invalidate inst cache WAY0 */
205 .word CACHE_OPC | (9 << 21) | (Index_Invalidate_I << 16) | \
206 (1 * ICACHE_SET_SIZE) /* invalidate inst cache WAY1 */
207
208 addiu t1, t1, ICACHE_LINE_SIZE /* T1 = next cache line index */
209 bne t2, zero, icache_invd_loop /* T2 = 0 if all sets invalidated */
210 addiu t2, t2, -1 /* decrement T2 set cnt (delay slot) */
211
212 /* Initialize the latches in the instruction cache tag */
213 /* that drive the way selection tri-state bus drivers, by doing a */
214 /* dummy load while the instruction cache is still disabled. */
215 /* TODO: Is this needed ? */
216 la t1, KSEG0 /* T1 = cached memory base address */
217 lw zero, 0x0000(t1) /* (dummy read of first memory word) */
218
219 mtc0 t0, CP0_STATUS /* restore interrupt status on entry */
220 HAZARD_CP0
221 .set pop
222 .endm
223
224 .macro cachePr4450DCReset
225 .set push
226 .set noreorder
227 mfc0 t0, CP0_STATUS /* T0 = interrupt status on entry */
228 HAZARD_CP0
229 mtc0 zero, CP0_STATUS /* disable CPU interrupts */
230 HAZARD_CP0
231
232 /* Writeback/invalidate entire data cache sets/ways/lines */
233 or t1, zero, zero /* T1 = starting cache index (0) */
234 ori t2, zero, (DCACHE_SET_COUNT - 1) /* T2 = data cache set cnt - 1 */
235
236 dcache_wbinvd_loop:
237 /* 9 == register t1 */
238 .word CACHE_OPC | (9 << 21) | (Index_Writeback_Inv_D << 16) | \
239 (0 * DCACHE_SET_SIZE) /* writeback/invalidate WAY0 */
240 .word CACHE_OPC | (9 << 21) | (Index_Writeback_Inv_D << 16) | \
241 (1 * DCACHE_SET_SIZE) /* writeback/invalidate WAY1 */
242 .word CACHE_OPC | (9 << 21) | (Index_Writeback_Inv_D << 16) | \
243 (2 * DCACHE_SET_SIZE) /* writeback/invalidate WAY2 */
244 .word CACHE_OPC | (9 << 21) | (Index_Writeback_Inv_D << 16) | \
245 (3 * DCACHE_SET_SIZE) /* writeback/invalidate WAY3 */
246
247 addiu t1, t1, DCACHE_LINE_SIZE /* T1 = next data cache line index */
248 bne t2, zero, dcache_wbinvd_loop /* T2 = 0 when wbinvd entire cache */
249 addiu t2, t2, -1 /* decrement T2 set cnt (delay slot) */
250
251 /* Initialize the latches in the data cache tag that drive the way
252 selection tri-state bus drivers, by doing a dummy load while the
253 data cache is still in the disabled mode. TODO: Is this needed ? */
254 la t1, KSEG0 /* T1 = cached memory base address */
255 lw zero, 0x0000(t1) /* (dummy read of first memory word) */
256
257 mtc0 t0, CP0_STATUS /* restore interrupt status on entry */
258 HAZARD_CP0
259 .set pop
260 .endm
261
262#endif /* __ASM_MACH_KERNEL_ENTRY_INIT_H */
diff --git a/arch/mips/include/asm/mach-pnx8550/nand.h b/arch/mips/include/asm/mach-pnx8550/nand.h
new file mode 100644
index 000000000000..aefbc514ab09
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/nand.h
@@ -0,0 +1,121 @@
1#ifndef __PNX8550_NAND_H
2#define __PNX8550_NAND_H
3
4#define PNX8550_NAND_BASE_ADDR 0x10000000
5#define PNX8550_PCIXIO_BASE 0xBBE40000
6
7#define PNX8550_DMA_EXT_ADDR *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x800)
8#define PNX8550_DMA_INT_ADDR *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x804)
9#define PNX8550_DMA_TRANS_SIZE *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x808)
10#define PNX8550_DMA_CTRL *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x80c)
11#define PNX8550_XIO_SEL0 *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x814)
12#define PNX8550_GPXIO_ADDR *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x820)
13#define PNX8550_GPXIO_WR *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x824)
14#define PNX8550_GPXIO_RD *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x828)
15#define PNX8550_GPXIO_CTRL *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x82C)
16#define PNX8550_XIO_FLASH_CTRL *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0x830)
17#define PNX8550_GPXIO_INT_STATUS *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0xfb0)
18#define PNX8550_GPXIO_INT_ENABLE *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0xfb4)
19#define PNX8550_GPXIO_INT_CLEAR *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0xfb8)
20#define PNX8550_DMA_INT_STATUS *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0xfd0)
21#define PNX8550_DMA_INT_ENABLE *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0xfd4)
22#define PNX8550_DMA_INT_CLEAR *(volatile unsigned long *)(PNX8550_PCIXIO_BASE + 0xfd8)
23
24#define PNX8550_XIO_SEL0_EN_16BIT 0x00800000
25#define PNX8550_XIO_SEL0_USE_ACK 0x00400000
26#define PNX8550_XIO_SEL0_REN_HIGH 0x00100000
27#define PNX8550_XIO_SEL0_REN_LOW 0x00040000
28#define PNX8550_XIO_SEL0_WEN_HIGH 0x00010000
29#define PNX8550_XIO_SEL0_WEN_LOW 0x00004000
30#define PNX8550_XIO_SEL0_WAIT 0x00000200
31#define PNX8550_XIO_SEL0_OFFSET 0x00000020
32#define PNX8550_XIO_SEL0_TYPE_68360 0x00000000
33#define PNX8550_XIO_SEL0_TYPE_NOR 0x00000008
34#define PNX8550_XIO_SEL0_TYPE_NAND 0x00000010
35#define PNX8550_XIO_SEL0_TYPE_IDE 0x00000018
36#define PNX8550_XIO_SEL0_SIZE_8MB 0x00000000
37#define PNX8550_XIO_SEL0_SIZE_16MB 0x00000002
38#define PNX8550_XIO_SEL0_SIZE_32MB 0x00000004
39#define PNX8550_XIO_SEL0_SIZE_64MB 0x00000006
40#define PNX8550_XIO_SEL0_ENAB 0x00000001
41
42#define PNX8550_SEL0_DEFAULT ((PNX8550_XIO_SEL0_EN_16BIT) | \
43 (PNX8550_XIO_SEL0_REN_HIGH*0)| \
44 (PNX8550_XIO_SEL0_REN_LOW*2) | \
45 (PNX8550_XIO_SEL0_WEN_HIGH*0)| \
46 (PNX8550_XIO_SEL0_WEN_LOW*2) | \
47 (PNX8550_XIO_SEL0_WAIT*4) | \
48 (PNX8550_XIO_SEL0_OFFSET*0) | \
49 (PNX8550_XIO_SEL0_TYPE_NAND) | \
50 (PNX8550_XIO_SEL0_SIZE_32MB) | \
51 (PNX8550_XIO_SEL0_ENAB))
52
53#define PNX8550_GPXIO_PENDING 0x00000200
54#define PNX8550_GPXIO_DONE 0x00000100
55#define PNX8550_GPXIO_CLR_DONE 0x00000080
56#define PNX8550_GPXIO_INIT 0x00000040
57#define PNX8550_GPXIO_READ_CMD 0x00000010
58#define PNX8550_GPXIO_BEN 0x0000000F
59
60#define PNX8550_XIO_FLASH_64MB 0x00200000
61#define PNX8550_XIO_FLASH_INC_DATA 0x00100000
62#define PNX8550_XIO_FLASH_CMD_PH 0x000C0000
63#define PNX8550_XIO_FLASH_CMD_PH2 0x00080000
64#define PNX8550_XIO_FLASH_CMD_PH1 0x00040000
65#define PNX8550_XIO_FLASH_CMD_PH0 0x00000000
66#define PNX8550_XIO_FLASH_ADR_PH 0x00030000
67#define PNX8550_XIO_FLASH_ADR_PH3 0x00030000
68#define PNX8550_XIO_FLASH_ADR_PH2 0x00020000
69#define PNX8550_XIO_FLASH_ADR_PH1 0x00010000
70#define PNX8550_XIO_FLASH_ADR_PH0 0x00000000
71#define PNX8550_XIO_FLASH_CMD_B(x) ((x<<8) & 0x0000FF00)
72#define PNX8550_XIO_FLASH_CMD_A(x) (x & 0x000000FF)
73
74#define PNX8550_XIO_INT_ACK 0x00004000
75#define PNX8550_XIO_INT_COMPL 0x00002000
76#define PNX8550_XIO_INT_NONSUP 0x00000200
77#define PNX8550_XIO_INT_ABORT 0x00000004
78
79#define PNX8550_DMA_CTRL_SINGLE_DATA 0x00000400
80#define PNX8550_DMA_CTRL_SND2XIO 0x00000200
81#define PNX8550_DMA_CTRL_FIX_ADDR 0x00000100
82#define PNX8550_DMA_CTRL_BURST_8 0x00000000
83#define PNX8550_DMA_CTRL_BURST_16 0x00000020
84#define PNX8550_DMA_CTRL_BURST_32 0x00000040
85#define PNX8550_DMA_CTRL_BURST_64 0x00000060
86#define PNX8550_DMA_CTRL_BURST_128 0x00000080
87#define PNX8550_DMA_CTRL_BURST_256 0x000000A0
88#define PNX8550_DMA_CTRL_BURST_512 0x000000C0
89#define PNX8550_DMA_CTRL_BURST_NORES 0x000000E0
90#define PNX8550_DMA_CTRL_INIT_DMA 0x00000010
91#define PNX8550_DMA_CTRL_CMD_TYPE 0x0000000F
92
93/* see PCI system arch, page 100 for the full list: */
94#define PNX8550_DMA_CTRL_PCI_CMD_READ 0x00000006
95#define PNX8550_DMA_CTRL_PCI_CMD_WRITE 0x00000007
96
97#define PNX8550_DMA_INT_STAT_ACK_DONE (1<<14)
98#define PNX8550_DMA_INT_STAT_DMA_DONE (1<<12)
99#define PNX8550_DMA_INT_STAT_DMA_ERR (1<<9)
100#define PNX8550_DMA_INT_STAT_PERR5 (1<<5)
101#define PNX8550_DMA_INT_STAT_PERR4 (1<<4)
102#define PNX8550_DMA_INT_STAT_M_ABORT (1<<2)
103#define PNX8550_DMA_INT_STAT_T_ABORT (1<<1)
104
105#define PNX8550_DMA_INT_EN_ACK_DONE (1<<14)
106#define PNX8550_DMA_INT_EN_DMA_DONE (1<<12)
107#define PNX8550_DMA_INT_EN_DMA_ERR (1<<9)
108#define PNX8550_DMA_INT_EN_PERR5 (1<<5)
109#define PNX8550_DMA_INT_EN_PERR4 (1<<4)
110#define PNX8550_DMA_INT_EN_M_ABORT (1<<2)
111#define PNX8550_DMA_INT_EN_T_ABORT (1<<1)
112
113#define PNX8550_DMA_INT_CLR_ACK_DONE (1<<14)
114#define PNX8550_DMA_INT_CLR_DMA_DONE (1<<12)
115#define PNX8550_DMA_INT_CLR_DMA_ERR (1<<9)
116#define PNX8550_DMA_INT_CLR_PERR5 (1<<5)
117#define PNX8550_DMA_INT_CLR_PERR4 (1<<4)
118#define PNX8550_DMA_INT_CLR_M_ABORT (1<<2)
119#define PNX8550_DMA_INT_CLR_T_ABORT (1<<1)
120
121#endif
diff --git a/arch/mips/include/asm/mach-pnx8550/pci.h b/arch/mips/include/asm/mach-pnx8550/pci.h
new file mode 100644
index 000000000000..b921508d701b
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/pci.h
@@ -0,0 +1,185 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * PCI specific definitions
5 *
6 * Author: source@mvista.com
7 *
8 * This program is free software; you can distribute it and/or modify it
9 * under the terms of the GNU General Public License (Version 2) as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 */
21
22#ifndef __PNX8550_PCI_H
23#define __PNX8550_PCI_H
24
25#include <linux/types.h>
26#include <linux/pci.h>
27#include <linux/kernel.h>
28#include <linux/init.h>
29
30#define PCI_ACCESS_READ 0
31#define PCI_ACCESS_WRITE 1
32
33#define PCI_CMD_IOR 0x20
34#define PCI_CMD_IOW 0x30
35#define PCI_CMD_CONFIG_READ 0xa0
36#define PCI_CMD_CONFIG_WRITE 0xb0
37
38#define PCI_IO_TIMEOUT 1000
39#define PCI_IO_RETRY 5
40/* Timeout for IO and CFG accesses.
41 This is in 1/1024 th of a jiffie(=10ms)
42 i.e. approx 10us */
43#define PCI_IO_JIFFIES_TIMEOUT 40
44#define PCI_IO_JIFFIES_SHIFT 10
45
46#define PCI_BYTE_ENABLE_MASK 0x0000000f
47#define PCI_CFG_BUS_SHIFT 16
48#define PCI_CFG_FUNC_SHIFT 8
49#define PCI_CFG_REG_SHIFT 2
50
51#define PCI_BASE 0x1be00000
52#define PCI_SETUP 0x00040010
53#define PCI_DIS_REQGNT (1<<30)
54#define PCI_DIS_REQGNTA (1<<29)
55#define PCI_DIS_REQGNTB (1<<28)
56#define PCI_D2_SUPPORT (1<<27)
57#define PCI_D1_SUPPORT (1<<26)
58#define PCI_EN_TA (1<<24)
59#define PCI_EN_PCI2MMI (1<<23)
60#define PCI_EN_XIO (1<<22)
61#define PCI_BASE18_PREF (1<<21)
62#define SIZE_16M 0x3
63#define SIZE_32M 0x4
64#define SIZE_64M 0x5
65#define SIZE_128M 0x6
66#define PCI_SETUP_BASE18_SIZE(X) (X<<18)
67#define PCI_SETUP_BASE18_EN (1<<17)
68#define PCI_SETUP_BASE14_PREF (1<<16)
69#define PCI_SETUP_BASE14_SIZE(X) (X<<12)
70#define PCI_SETUP_BASE14_EN (1<<11)
71#define PCI_SETUP_BASE10_PREF (1<<10)
72#define PCI_SETUP_BASE10_SIZE(X) (X<<7)
73#define PCI_SETUP_CFGMANAGE_EN (1<<1)
74#define PCI_SETUP_PCIARB_EN (1<<0)
75
76#define PCI_CTRL 0x040014
77#define PCI_SWPB_DCS_PCI (1<<16)
78#define PCI_SWPB_PCI_PCI (1<<15)
79#define PCI_SWPB_PCI_DCS (1<<14)
80#define PCI_REG_WR_POST (1<<13)
81#define PCI_XIO_WR_POST (1<<12)
82#define PCI_PCI2_WR_POST (1<<13)
83#define PCI_PCI1_WR_POST (1<<12)
84#define PCI_SERR_SEEN (1<<11)
85#define PCI_B10_SPEC_RD (1<<6)
86#define PCI_B14_SPEC_RD (1<<5)
87#define PCI_B18_SPEC_RD (1<<4)
88#define PCI_B10_NOSUBWORD (1<<3)
89#define PCI_B14_NOSUBWORD (1<<2)
90#define PCI_B18_NOSUBWORD (1<<1)
91#define PCI_RETRY_TMREN (1<<0)
92
93#define PCI_BASE1_LO 0x040018
94#define PCI_BASE1_HI 0x04001C
95#define PCI_BASE2_LO 0x040020
96#define PCI_BASE2_HI 0x040024
97#define PCI_RDLIFETIM 0x040028
98#define PCI_GPPM_ADDR 0x04002C
99#define PCI_GPPM_WDAT 0x040030
100#define PCI_GPPM_RDAT 0x040034
101#define PCI_GPPM_CTRL 0x040038
102#define GPPM_DONE (1<<10)
103#define INIT_PCI_CYCLE (1<<9)
104#define GPPM_CMD(X) (((X)&0xf)<<4)
105#define GPPM_BYTEEN(X) ((X)&0xf)
106#define PCI_UNLOCKREG 0x04003C
107#define UNLOCK_SSID(X) (((X)&0xff)<<8)
108#define UNLOCK_SETUP(X) (((X)&0xff)<<0)
109#define UNLOCK_MAGIC 0xCA
110#define PCI_DEV_VEND_ID 0x040040
111#define DEVICE_ID(X) (((X)>>16)&0xffff)
112#define VENDOR_ID(X) (((X)&0xffff))
113#define PCI_CFG_CMDSTAT 0x040044
114#define PCI_CFG_STATUS(X) (((X)>>16)&0xffff)
115#define PCI_CFG_COMMAND(X) ((X)&0xffff)
116#define PCI_CLASS_REV 0x040048
117#define PCI_CLASSCODE(X) (((X)>>8)&0xffffff)
118#define PCI_REVID(X) ((X)&0xff)
119#define PCI_LAT_TMR 0x04004c
120#define PCI_BASE10 0x040050
121#define PCI_BASE14 0x040054
122#define PCI_BASE18 0x040058
123#define PCI_SUBSYS_ID 0x04006c
124#define PCI_CAP_PTR 0x040074
125#define PCI_CFG_MISC 0x04007c
126#define PCI_PMC 0x040080
127#define PCI_PWR_STATE 0x040084
128#define PCI_IO 0x040088
129#define PCI_SLVTUNING 0x04008C
130#define PCI_DMATUNING 0x040090
131#define PCI_DMAEADDR 0x040800
132#define PCI_DMAIADDR 0x040804
133#define PCI_DMALEN 0x040808
134#define PCI_DMACTRL 0x04080C
135#define PCI_XIOCTRL 0x040810
136#define PCI_SEL0PROF 0x040814
137#define PCI_SEL1PROF 0x040818
138#define PCI_SEL2PROF 0x04081C
139#define PCI_GPXIOADDR 0x040820
140#define PCI_NANDCTRLS 0x400830
141#define PCI_SEL3PROF 0x040834
142#define PCI_SEL4PROF 0x040838
143#define PCI_GPXIO_STAT 0x040FB0
144#define PCI_GPXIO_IMASK 0x040FB4
145#define PCI_GPXIO_ICLR 0x040FB8
146#define PCI_GPXIO_ISET 0x040FBC
147#define PCI_GPPM_STATUS 0x040FC0
148#define GPPM_DONE (1<<10)
149#define GPPM_ERR (1<<9)
150#define GPPM_MPAR_ERR (1<<8)
151#define GPPM_PAR_ERR (1<<7)
152#define GPPM_R_MABORT (1<<2)
153#define GPPM_R_TABORT (1<<1)
154#define PCI_GPPM_IMASK 0x040FC4
155#define PCI_GPPM_ICLR 0x040FC8
156#define PCI_GPPM_ISET 0x040FCC
157#define PCI_DMA_STATUS 0x040FD0
158#define PCI_DMA_IMASK 0x040FD4
159#define PCI_DMA_ICLR 0x040FD8
160#define PCI_DMA_ISET 0x040FDC
161#define PCI_ISTATUS 0x040FE0
162#define PCI_IMASK 0x040FE4
163#define PCI_ICLR 0x040FE8
164#define PCI_ISET 0x040FEC
165#define PCI_MOD_ID 0x040FFC
166
167/*
168 * PCI configuration cycle AD bus definition
169 */
170/* Type 0 */
171#define PCI_CFG_TYPE0_REG_SHF 0
172#define PCI_CFG_TYPE0_FUNC_SHF 8
173
174/* Type 1 */
175#define PCI_CFG_TYPE1_REG_SHF 0
176#define PCI_CFG_TYPE1_FUNC_SHF 8
177#define PCI_CFG_TYPE1_DEV_SHF 11
178#define PCI_CFG_TYPE1_BUS_SHF 16
179
180/*
181 * Ethernet device DP83816 definition
182 */
183#define DP83816_IRQ_ETHER 66
184
185#endif
diff --git a/arch/mips/include/asm/mach-pnx8550/uart.h b/arch/mips/include/asm/mach-pnx8550/uart.h
new file mode 100644
index 000000000000..ad7608d44874
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/uart.h
@@ -0,0 +1,30 @@
1#ifndef __IP3106_UART_H
2#define __IP3106_UART_H
3
4#include <int.h>
5
6/* early macros for kgdb use. fixme: clean this up */
7
8#define UART_BASE 0xbbe4a000 /* PNX8550 */
9
10#define PNX8550_UART_PORT0 (UART_BASE)
11#define PNX8550_UART_PORT1 (UART_BASE + 0x1000)
12
13#define PNX8550_UART_INT(x) (PNX8550_INT_GIC_MIN+19+x)
14#define IRQ_TO_UART(x) (x-PNX8550_INT_GIC_MIN-19)
15
16/* early macros needed for prom/kgdb */
17
18#define ip3106_lcr(base, port) *(volatile u32 *)(base+(port*0x1000) + 0x000)
19#define ip3106_mcr(base, port) *(volatile u32 *)(base+(port*0x1000) + 0x004)
20#define ip3106_baud(base, port) *(volatile u32 *)(base+(port*0x1000) + 0x008)
21#define ip3106_cfg(base, port) *(volatile u32 *)(base+(port*0x1000) + 0x00C)
22#define ip3106_fifo(base, port) *(volatile u32 *)(base+(port*0x1000) + 0x028)
23#define ip3106_istat(base, port) *(volatile u32 *)(base+(port*0x1000) + 0xFE0)
24#define ip3106_ien(base, port) *(volatile u32 *)(base+(port*0x1000) + 0xFE4)
25#define ip3106_iclr(base, port) *(volatile u32 *)(base+(port*0x1000) + 0xFE8)
26#define ip3106_iset(base, port) *(volatile u32 *)(base+(port*0x1000) + 0xFEC)
27#define ip3106_pd(base, port) *(volatile u32 *)(base+(port*0x1000) + 0xFF4)
28#define ip3106_mid(base, port) *(volatile u32 *)(base+(port*0x1000) + 0xFFC)
29
30#endif
diff --git a/arch/mips/include/asm/mach-pnx8550/usb.h b/arch/mips/include/asm/mach-pnx8550/usb.h
new file mode 100644
index 000000000000..483b7fc65d41
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/usb.h
@@ -0,0 +1,32 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * USB specific definitions
5 *
6 * Author: source@mvista.com
7 *
8 * This program is free software; you can distribute it and/or modify it
9 * under the terms of the GNU General Public License (Version 2) as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 */
21
22#ifndef __PNX8550_USB_H
23#define __PNX8550_USB_H
24
25/*
26 * USB Host controller
27 */
28
29#define PNX8550_USB_OHCI_OP_BASE 0x1be48000
30#define PNX8550_USB_OHCI_OP_LEN 0x1000
31
32#endif
diff --git a/arch/mips/include/asm/mach-pnx8550/war.h b/arch/mips/include/asm/mach-pnx8550/war.h
new file mode 100644
index 000000000000..d0458dd082f9
--- /dev/null
+++ b/arch/mips/include/asm/mach-pnx8550/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_PNX8550_WAR_H
9#define __ASM_MIPS_MACH_PNX8550_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_PNX8550_WAR_H */
diff --git a/arch/mips/include/asm/mach-rc32434/cpu-feature-overrides.h b/arch/mips/include/asm/mach-rc32434/cpu-feature-overrides.h
new file mode 100644
index 000000000000..f3bc7efa2608
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/cpu-feature-overrides.h
@@ -0,0 +1,81 @@
1/*
2 * IDT RC32434 specific CPU feature overrides
3 *
4 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
5 *
6 * This file was derived from: include/asm-mips/cpu-features.h
7 * Copyright (C) 2003, 2004 Ralf Baechle
8 * Copyright (C) 2004 Maciej W. Rozycki
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24 */
25#ifndef __ASM_MACH_RC32434_CPU_FEATURE_OVERRIDES_H
26#define __ASM_MACH_RC32434_CPU_FEATURE_OVERRIDES_H
27
28/*
29 * The IDT RC32434 SOC has a built-in MIPS 4Kc core.
30 */
31#define cpu_has_tlb 1
32#define cpu_has_4kex 1
33#define cpu_has_3k_cache 0
34#define cpu_has_4k_cache 1
35#define cpu_has_tx39_cache 0
36#define cpu_has_sb1_cache 0
37#define cpu_has_fpu 0
38#define cpu_has_32fpr 0
39#define cpu_has_counter 1
40#define cpu_has_watch 1
41#define cpu_has_divec 1
42#define cpu_has_vce 0
43#define cpu_has_cache_cdex_p 0
44#define cpu_has_cache_cdex_s 0
45#define cpu_has_prefetch 1
46#define cpu_has_mcheck 1
47#define cpu_has_ejtag 1
48#define cpu_has_llsc 1
49
50#define cpu_has_mips16 0
51#define cpu_has_mdmx 0
52#define cpu_has_mips3d 0
53#define cpu_has_smartmips 0
54
55#define cpu_has_vtag_icache 0
56/* #define cpu_has_dc_aliases ? */
57/* #define cpu_has_ic_fills_f_dc ? */
58/* #define cpu_has_pindexed_dcache ? */
59
60/* #define cpu_icache_snoops_remote_store ? */
61
62#define cpu_has_mips32r1 1
63#define cpu_has_mips32r2 0
64#define cpu_has_mips64r1 0
65#define cpu_has_mips64r2 0
66
67#define cpu_has_dsp 0
68#define cpu_has_mipsmt 0
69
70/* #define cpu_has_nofpuex ? */
71#define cpu_has_64bits 0
72#define cpu_has_64bit_zero_reg 0
73#define cpu_has_64bit_gp_regs 0
74#define cpu_has_64bit_addresses 0
75
76#define cpu_has_inclusive_pcaches 0
77
78#define cpu_dcache_line_size() 16
79#define cpu_icache_line_size() 16
80
81#endif /* __ASM_MACH_RC32434_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-rc32434/ddr.h b/arch/mips/include/asm/mach-rc32434/ddr.h
new file mode 100644
index 000000000000..291e2cf9dde0
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/ddr.h
@@ -0,0 +1,141 @@
1/*
2 * Definitions for the DDR registers
3 *
4 * Copyright 2002 Ryan Holm <ryan.holmQVist@idt.com>
5 * Copyright 2008 Florian Fainelli <florian@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */
28
29#ifndef _ASM_RC32434_DDR_H_
30#define _ASM_RC32434_DDR_H_
31
32#include <asm/mach-rc32434/rb.h>
33
34/* DDR register structure */
35struct ddr_ram {
36 u32 ddrbase;
37 u32 ddrmask;
38 u32 res1;
39 u32 res2;
40 u32 ddrc;
41 u32 ddrabase;
42 u32 ddramask;
43 u32 ddramap;
44 u32 ddrcust;
45 u32 ddrrdc;
46 u32 ddrspare;
47};
48
49#define DDR0_PHYS_ADDR 0x18018000
50
51/* DDR banks masks */
52#define DDR_MASK 0xffff0000
53#define DDR0_BASE_MSK DDR_MASK
54#define DDR1_BASE_MSK DDR_MASK
55
56/* DDR bank0 registers */
57#define RC32434_DDR0_ATA_BIT 5
58#define RC32434_DDR0_ATA_MSK 0x000000E0
59#define RC32434_DDR0_DBW_BIT 8
60#define RC32434_DDR0_DBW_MSK 0x00000100
61#define RC32434_DDR0_WR_BIT 9
62#define RC32434_DDR0_WR_MSK 0x00000600
63#define RC32434_DDR0_PS_BIT 11
64#define RC32434_DDR0_PS_MSK 0x00001800
65#define RC32434_DDR0_DTYPE_BIT 13
66#define RC32434_DDR0_DTYPE_MSK 0x0000e000
67#define RC32434_DDR0_RFC_BIT 16
68#define RC32434_DDR0_RFC_MSK 0x000f0000
69#define RC32434_DDR0_RP_BIT 20
70#define RC32434_DDR0_RP_MSK 0x00300000
71#define RC32434_DDR0_AP_BIT 22
72#define RC32434_DDR0_AP_MSK 0x00400000
73#define RC32434_DDR0_RCD_BIT 23
74#define RC32434_DDR0_RCD_MSK 0x01800000
75#define RC32434_DDR0_CL_BIT 25
76#define RC32434_DDR0_CL_MSK 0x06000000
77#define RC32434_DDR0_DBM_BIT 27
78#define RC32434_DDR0_DBM_MSK 0x08000000
79#define RC32434_DDR0_SDS_BIT 28
80#define RC32434_DDR0_SDS_MSK 0x10000000
81#define RC32434_DDR0_ATP_BIT 29
82#define RC32434_DDR0_ATP_MSK 0x60000000
83#define RC32434_DDR0_RE_BIT 31
84#define RC32434_DDR0_RE_MSK 0x80000000
85
86/* DDR bank C registers */
87#define RC32434_DDRC_MSK(x) BIT_TO_MASK(x)
88#define RC32434_DDRC_CES_BIT 0
89#define RC32434_DDRC_ACE_BIT 1
90
91/* Custom DDR bank registers */
92#define RC32434_DCST_MSK(x) BIT_TO_MASK(x)
93#define RC32434_DCST_CS_BIT 0
94#define RC32434_DCST_CS_MSK 0x00000003
95#define RC32434_DCST_WE_BIT 2
96#define RC32434_DCST_RAS_BIT 3
97#define RC32434_DCST_CAS_BIT 4
98#define RC32434_DSCT_CKE_BIT 5
99#define RC32434_DSCT_BA_BIT 6
100#define RC32434_DSCT_BA_MSK 0x000000c0
101
102/* DDR QSC registers */
103#define RC32434_QSC_DM_BIT 0
104#define RC32434_QSC_DM_MSK 0x00000003
105#define RC32434_QSC_DQSBS_BIT 2
106#define RC32434_QSC_DQSBS_MSK 0x000000fc
107#define RC32434_QSC_DB_BIT 8
108#define RC32434_QSC_DB_MSK 0x00000100
109#define RC32434_QSC_DBSP_BIT 9
110#define RC32434_QSC_DBSP_MSK 0x01fffe00
111#define RC32434_QSC_BDP_BIT 25
112#define RC32434_QSC_BDP_MSK 0x7e000000
113
114/* DDR LLC registers */
115#define RC32434_LLC_EAO_BIT 0
116#define RC32434_LLC_EAO_MSK 0x00000001
117#define RC32434_LLC_EO_BIT 1
118#define RC32434_LLC_EO_MSK 0x0000003e
119#define RC32434_LLC_FS_BIT 6
120#define RC32434_LLC_FS_MSK 0x000000c0
121#define RC32434_LLC_AS_BIT 8
122#define RC32434_LLC_AS_MSK 0x00000700
123#define RC32434_LLC_SP_BIT 11
124#define RC32434_LLC_SP_MSK 0x001ff800
125
126/* DDR LLFC registers */
127#define RC32434_LLFC_MSK(x) BIT_TO_MASK(x)
128#define RC32434_LLFC_MEN_BIT 0
129#define RC32434_LLFC_EAN_BIT 1
130#define RC32434_LLFC_FF_BIT 2
131
132/* DDR DLLTA registers */
133#define RC32434_DLLTA_ADDR_BIT 2
134#define RC32434_DLLTA_ADDR_MSK 0xfffffffc
135
136/* DDR DLLED registers */
137#define RC32434_DLLED_MSK(x) BIT_TO_MASK(x)
138#define RC32434_DLLED_DBE_BIT 0
139#define RC32434_DLLED_DTE_BIT 1
140
141#endif /* _ASM_RC32434_DDR_H_ */
diff --git a/arch/mips/include/asm/mach-rc32434/dma.h b/arch/mips/include/asm/mach-rc32434/dma.h
new file mode 100644
index 000000000000..5f898b5873f7
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/dma.h
@@ -0,0 +1,103 @@
1/*
2 * Copyright 2002 Integrated Device Technology, Inc.
3 * All rights reserved.
4 *
5 * DMA register definition.
6 *
7 * Author : ryan.holmQVist@idt.com
8 * Date : 20011005
9 */
10
11#ifndef __ASM_RC32434_DMA_H
12#define __ASM_RC32434_DMA_H
13
14#include <asm/mach-rc32434/rb.h>
15
16#define DMA0_BASE_ADDR 0x18040000
17
18/*
19 * DMA descriptor (in physical memory).
20 */
21
22struct dma_desc {
23 u32 control; /* Control. use DMAD_* */
24 u32 ca; /* Current Address. */
25 u32 devcs; /* Device control and status. */
26 u32 link; /* Next descriptor in chain. */
27};
28
29#define DMA_DESC_SIZ sizeof(struct dma_desc)
30#define DMA_DESC_COUNT_BIT 0
31#define DMA_DESC_COUNT_MSK 0x0003ffff
32#define DMA_DESC_DS_BIT 20
33#define DMA_DESC_DS_MSK 0x00300000
34
35#define DMA_DESC_DEV_CMD_BIT 22
36#define DMA_DESC_DEV_CMD_MSK 0x01c00000
37
38/* DMA command sizes */
39#define DMA_DESC_DEV_CMD_BYTE 0
40#define DMA_DESC_DEV_CMD_HLF_WD 1
41#define DMA_DESC_DEV_CMD_WORD 2
42#define DMA_DESC_DEV_CMD_2WORDS 3
43#define DMA_DESC_DEV_CMD_4WORDS 4
44#define DMA_DESC_DEV_CMD_6WORDS 5
45#define DMA_DESC_DEV_CMD_8WORDS 6
46#define DMA_DESC_DEV_CMD_16WORDS 7
47
48/* DMA descriptors interrupts */
49#define DMA_DESC_COF (1 << 25) /* Chain on finished */
50#define DMA_DESC_COD (1 << 26) /* Chain on done */
51#define DMA_DESC_IOF (1 << 27) /* Interrupt on finished */
52#define DMA_DESC_IOD (1 << 28) /* Interrupt on done */
53#define DMA_DESC_TERM (1 << 29) /* Terminated */
54#define DMA_DESC_DONE (1 << 30) /* Done */
55#define DMA_DESC_FINI (1 << 31) /* Finished */
56
57/*
58 * DMA register (within Internal Register Map).
59 */
60
61struct dma_reg {
62 u32 dmac; /* Control. */
63 u32 dmas; /* Status. */
64 u32 dmasm; /* Mask. */
65 u32 dmadptr; /* Descriptor pointer. */
66 u32 dmandptr; /* Next descriptor pointer. */
67};
68
69/* DMA channels specific registers */
70#define DMA_CHAN_RUN_BIT (1 << 0)
71#define DMA_CHAN_DONE_BIT (1 << 1)
72#define DMA_CHAN_MODE_BIT (1 << 2)
73#define DMA_CHAN_MODE_MSK 0x0000000c
74#define DMA_CHAN_MODE_AUTO 0
75#define DMA_CHAN_MODE_BURST 1
76#define DMA_CHAN_MODE_XFRT 2
77#define DMA_CHAN_MODE_RSVD 3
78#define DMA_CHAN_ACT_BIT (1 << 4)
79
80/* DMA status registers */
81#define DMA_STAT_FINI (1 << 0)
82#define DMA_STAT_DONE (1 << 1)
83#define DMA_STAT_CHAIN (1 << 2)
84#define DMA_STAT_ERR (1 << 3)
85#define DMA_STAT_HALT (1 << 4)
86
87/*
88 * DMA channel definitions
89 */
90
91#define DMA_CHAN_ETH_RCV 0
92#define DMA_CHAN_ETH_XMT 1
93#define DMA_CHAN_MEM_TO_FIFO 2
94#define DMA_CHAN_FIFO_TO_MEM 3
95#define DMA_CHAN_PCI_TO_MEM 4
96#define DMA_CHAN_MEM_TO_PCI 5
97#define DMA_CHAN_COUNT 6
98
99struct dma_channel {
100 struct dma_reg ch[DMA_CHAN_COUNT];
101};
102
103#endif /* __ASM_RC32434_DMA_H */
diff --git a/arch/mips/include/asm/mach-rc32434/dma_v.h b/arch/mips/include/asm/mach-rc32434/dma_v.h
new file mode 100644
index 000000000000..173a9f9146cd
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/dma_v.h
@@ -0,0 +1,52 @@
1/*
2 * Copyright 2002 Integrated Device Technology, Inc.
3 * All rights reserved.
4 *
5 * DMA register definition.
6 *
7 * Author : ryan.holmQVist@idt.com
8 * Date : 20011005
9 */
10
11#ifndef _ASM_RC32434_DMA_V_H_
12#define _ASM_RC32434_DMA_V_H_
13
14#include <asm/mach-rc32434/dma.h>
15#include <asm/mach-rc32434/rc32434.h>
16
17#define DMA_CHAN_OFFSET 0x14
18#define IS_DMA_USED(X) (((X) & \
19 (DMA_DESC_FINI | DMA_DESC_DONE | DMA_DESC_TERM)) \
20 != 0)
21#define DMA_COUNT(count) ((count) & DMA_DESC_COUNT_MSK)
22
23#define DMA_HALT_TIMEOUT 500
24
25static inline int rc32434_halt_dma(struct dma_reg *ch)
26{
27 int timeout = 1;
28 if (__raw_readl(&ch->dmac) & DMA_CHAN_RUN_BIT) {
29 __raw_writel(0, &ch->dmac);
30 for (timeout = DMA_HALT_TIMEOUT; timeout > 0; timeout--) {
31 if (__raw_readl(&ch->dmas) & DMA_STAT_HALT) {
32 __raw_writel(0, &ch->dmas);
33 break;
34 }
35 }
36 }
37
38 return timeout ? 0 : 1;
39}
40
41static inline void rc32434_start_dma(struct dma_reg *ch, u32 dma_addr)
42{
43 __raw_writel(0, &ch->dmandptr);
44 __raw_writel(dma_addr, &ch->dmadptr);
45}
46
47static inline void rc32434_chain_dma(struct dma_reg *ch, u32 dma_addr)
48{
49 __raw_writel(dma_addr, &ch->dmandptr);
50}
51
52#endif /* _ASM_RC32434_DMA_V_H_ */
diff --git a/arch/mips/include/asm/mach-rc32434/eth.h b/arch/mips/include/asm/mach-rc32434/eth.h
new file mode 100644
index 000000000000..a25cbc56173d
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/eth.h
@@ -0,0 +1,220 @@
1/*
2 * Definitions for the Ethernet registers
3 *
4 * Copyright 2002 Allend Stichter <allen.stichter@idt.com>
5 * Copyright 2008 Florian Fainelli <florian@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */
28
29#ifndef __ASM_RC32434_ETH_H
30#define __ASM_RC32434_ETH_H
31
32
33#define ETH0_BASE_ADDR 0x18060000
34
35struct eth_regs {
36 u32 ethintfc;
37 u32 ethfifott;
38 u32 etharc;
39 u32 ethhash0;
40 u32 ethhash1;
41 u32 ethu0[4]; /* Reserved. */
42 u32 ethpfs;
43 u32 ethmcp;
44 u32 eth_u1[10]; /* Reserved. */
45 u32 ethspare;
46 u32 eth_u2[42]; /* Reserved. */
47 u32 ethsal0;
48 u32 ethsah0;
49 u32 ethsal1;
50 u32 ethsah1;
51 u32 ethsal2;
52 u32 ethsah2;
53 u32 ethsal3;
54 u32 ethsah3;
55 u32 ethrbc;
56 u32 ethrpc;
57 u32 ethrupc;
58 u32 ethrfc;
59 u32 ethtbc;
60 u32 ethgpf;
61 u32 eth_u9[50]; /* Reserved. */
62 u32 ethmac1;
63 u32 ethmac2;
64 u32 ethipgt;
65 u32 ethipgr;
66 u32 ethclrt;
67 u32 ethmaxf;
68 u32 eth_u10; /* Reserved. */
69 u32 ethmtest;
70 u32 miimcfg;
71 u32 miimcmd;
72 u32 miimaddr;
73 u32 miimwtd;
74 u32 miimrdd;
75 u32 miimind;
76 u32 eth_u11; /* Reserved. */
77 u32 eth_u12; /* Reserved. */
78 u32 ethcfsa0;
79 u32 ethcfsa1;
80 u32 ethcfsa2;
81};
82
83/* Ethernet interrupt registers */
84#define ETH_INT_FC_EN (1 << 0)
85#define ETH_INT_FC_ITS (1 << 1)
86#define ETH_INT_FC_RIP (1 << 2)
87#define ETH_INT_FC_JAM (1 << 3)
88#define ETH_INT_FC_OVR (1 << 4)
89#define ETH_INT_FC_UND (1 << 5)
90#define ETH_INT_FC_IOC 0x000000c0
91
92/* Ethernet FIFO registers */
93#define ETH_FIFI_TT_TTH_BIT 0
94#define ETH_FIFO_TT_TTH 0x0000007f
95
96/* Ethernet ARC/multicast registers */
97#define ETH_ARC_PRO (1 << 0)
98#define ETH_ARC_AM (1 << 1)
99#define ETH_ARC_AFM (1 << 2)
100#define ETH_ARC_AB (1 << 3)
101
102/* Ethernet SAL registers */
103#define ETH_SAL_BYTE_5 0x000000ff
104#define ETH_SAL_BYTE_4 0x0000ff00
105#define ETH_SAL_BYTE_3 0x00ff0000
106#define ETH_SAL_BYTE_2 0xff000000
107
108/* Ethernet SAH registers */
109#define ETH_SAH_BYTE1 0x000000ff
110#define ETH_SAH_BYTE0 0x0000ff00
111
112/* Ethernet GPF register */
113#define ETH_GPF_PTV 0x0000ffff
114
115/* Ethernet PFG register */
116#define ETH_PFS_PFD (1 << 0)
117
118/* Ethernet CFSA[0-3] registers */
119#define ETH_CFSA0_CFSA4 0x000000ff
120#define ETH_CFSA0_CFSA5 0x0000ff00
121#define ETH_CFSA1_CFSA2 0x000000ff
122#define ETH_CFSA1_CFSA3 0x0000ff00
123#define ETH_CFSA1_CFSA0 0x000000ff
124#define ETH_CFSA1_CFSA1 0x0000ff00
125
126/* Ethernet MAC1 registers */
127#define ETH_MAC1_RE (1 << 0)
128#define ETH_MAC1_PAF (1 << 1)
129#define ETH_MAC1_RFC (1 << 2)
130#define ETH_MAC1_TFC (1 << 3)
131#define ETH_MAC1_LB (1 << 4)
132#define ETH_MAC1_MR (1 << 31)
133
134/* Ethernet MAC2 registers */
135#define ETH_MAC2_FD (1 << 0)
136#define ETH_MAC2_FLC (1 << 1)
137#define ETH_MAC2_HFE (1 << 2)
138#define ETH_MAC2_DC (1 << 3)
139#define ETH_MAC2_CEN (1 << 4)
140#define ETH_MAC2_PE (1 << 5)
141#define ETH_MAC2_VPE (1 << 6)
142#define ETH_MAC2_APE (1 << 7)
143#define ETH_MAC2_PPE (1 << 8)
144#define ETH_MAC2_LPE (1 << 9)
145#define ETH_MAC2_NB (1 << 12)
146#define ETH_MAC2_BP (1 << 13)
147#define ETH_MAC2_ED (1 << 14)
148
149/* Ethernet IPGT register */
150#define ETH_IPGT 0x0000007f
151
152/* Ethernet IPGR registers */
153#define ETH_IPGR_IPGR2 0x0000007f
154#define ETH_IPGR_IPGR1 0x00007f00
155
156/* Ethernet CLRT registers */
157#define ETH_CLRT_MAX_RET 0x0000000f
158#define ETH_CLRT_COL_WIN 0x00003f00
159
160/* Ethernet MAXF register */
161#define ETH_MAXF 0x0000ffff
162
163/* Ethernet test registers */
164#define ETH_TEST_REG (1 << 2)
165#define ETH_MCP_DIV 0x000000ff
166
167/* MII registers */
168#define ETH_MII_CFG_RSVD 0x0000000c
169#define ETH_MII_CMD_RD (1 << 0)
170#define ETH_MII_CMD_SCN (1 << 1)
171#define ETH_MII_REG_ADDR 0x0000001f
172#define ETH_MII_PHY_ADDR 0x00001f00
173#define ETH_MII_WTD_DATA 0x0000ffff
174#define ETH_MII_RDD_DATA 0x0000ffff
175#define ETH_MII_IND_BSY (1 << 0)
176#define ETH_MII_IND_SCN (1 << 1)
177#define ETH_MII_IND_NV (1 << 2)
178
179/*
180 * Values for the DEVCS field of the Ethernet DMA Rx and Tx descriptors.
181 */
182
183#define ETH_RX_FD (1 << 0)
184#define ETH_RX_LD (1 << 1)
185#define ETH_RX_ROK (1 << 2)
186#define ETH_RX_FM (1 << 3)
187#define ETH_RX_MP (1 << 4)
188#define ETH_RX_BP (1 << 5)
189#define ETH_RX_VLT (1 << 6)
190#define ETH_RX_CF (1 << 7)
191#define ETH_RX_OVR (1 << 8)
192#define ETH_RX_CRC (1 << 9)
193#define ETH_RX_CV (1 << 10)
194#define ETH_RX_DB (1 << 11)
195#define ETH_RX_LE (1 << 12)
196#define ETH_RX_LOR (1 << 13)
197#define ETH_RX_CES (1 << 14)
198#define ETH_RX_LEN_BIT 16
199#define ETH_RX_LEN 0xffff0000
200
201#define ETH_TX_FD (1 << 0)
202#define ETH_TX_LD (1 << 1)
203#define ETH_TX_OEN (1 << 2)
204#define ETH_TX_PEN (1 << 3)
205#define ETH_TX_CEN (1 << 4)
206#define ETH_TX_HEN (1 << 5)
207#define ETH_TX_TOK (1 << 6)
208#define ETH_TX_MP (1 << 7)
209#define ETH_TX_BP (1 << 8)
210#define ETH_TX_UND (1 << 9)
211#define ETH_TX_OF (1 << 10)
212#define ETH_TX_ED (1 << 11)
213#define ETH_TX_EC (1 << 12)
214#define ETH_TX_LC (1 << 13)
215#define ETH_TX_TD (1 << 14)
216#define ETH_TX_CRC (1 << 15)
217#define ETH_TX_LE (1 << 16)
218#define ETH_TX_CC 0x001E0000
219
220#endif /* __ASM_RC32434_ETH_H */
diff --git a/arch/mips/include/asm/mach-rc32434/gpio.h b/arch/mips/include/asm/mach-rc32434/gpio.h
new file mode 100644
index 000000000000..c8e554eafce3
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/gpio.h
@@ -0,0 +1,88 @@
1/*
2 * Copyright 2002 Integrated Device Technology, Inc.
3 * All rights reserved.
4 *
5 * GPIO register definition.
6 *
7 * Author : ryan.holmQVist@idt.com
8 * Date : 20011005
9 * Copyright (C) 2001, 2002 Ryan Holm <ryan.holmQVist@idt.com>
10 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
11 */
12
13#ifndef _RC32434_GPIO_H_
14#define _RC32434_GPIO_H_
15
16#include <linux/types.h>
17#include <asm-generic/gpio.h>
18
19#define NR_BUILTIN_GPIO 32
20
21#define gpio_get_value __gpio_get_value
22#define gpio_set_value __gpio_set_value
23#define gpio_cansleep __gpio_cansleep
24
25#define gpio_to_irq(gpio) (8 + 4 * 32 + gpio)
26#define irq_to_gpio(irq) (irq - (8 + 4 * 32))
27
28struct rb532_gpio_reg {
29 u32 gpiofunc; /* GPIO Function Register
30 * gpiofunc[x]==0 bit = gpio
31 * func[x]==1 bit = altfunc
32 */
33 u32 gpiocfg; /* GPIO Configuration Register
34 * gpiocfg[x]==0 bit = input
35 * gpiocfg[x]==1 bit = output
36 */
37 u32 gpiod; /* GPIO Data Register
38 * gpiod[x] read/write gpio pinX status
39 */
40 u32 gpioilevel; /* GPIO Interrupt Status Register
41 * interrupt level (see gpioistat)
42 */
43 u32 gpioistat; /* Gpio Interrupt Status Register
44 * istat[x] = (gpiod[x] == level[x])
45 * cleared in ISR (STICKY bits)
46 */
47 u32 gpionmien; /* GPIO Non-maskable Interrupt Enable Register */
48};
49
50/* UART GPIO signals */
51#define RC32434_UART0_SOUT (1 << 0)
52#define RC32434_UART0_SIN (1 << 1)
53#define RC32434_UART0_RTS (1 << 2)
54#define RC32434_UART0_CTS (1 << 3)
55
56/* M & P bus GPIO signals */
57#define RC32434_MP_BIT_22 (1 << 4)
58#define RC32434_MP_BIT_23 (1 << 5)
59#define RC32434_MP_BIT_24 (1 << 6)
60#define RC32434_MP_BIT_25 (1 << 7)
61
62/* CPU GPIO signals */
63#define RC32434_CPU_GPIO (1 << 8)
64
65/* Reserved GPIO signals */
66#define RC32434_AF_SPARE_6 (1 << 9)
67#define RC32434_AF_SPARE_4 (1 << 10)
68#define RC32434_AF_SPARE_3 (1 << 11)
69#define RC32434_AF_SPARE_2 (1 << 12)
70
71/* PCI messaging unit */
72#define RC32434_PCI_MSU_GPIO (1 << 13)
73
74/* NAND GPIO signals */
75#define GPIO_RDY 8
76#define GPIO_WPX 9
77#define GPIO_ALE 10
78#define GPIO_CLE 11
79
80/* Compact Flash GPIO pin */
81#define CF_GPIO_NUM 13
82
83extern void set_434_reg(unsigned reg_offs, unsigned bit, unsigned len, unsigned val);
84extern unsigned get_434_reg(unsigned reg_offs);
85extern void set_latch_u5(unsigned char or_mask, unsigned char nand_mask);
86extern unsigned char get_latch_u5(void);
87
88#endif /* _RC32434_GPIO_H_ */
diff --git a/arch/mips/include/asm/mach-rc32434/integ.h b/arch/mips/include/asm/mach-rc32434/integ.h
new file mode 100644
index 000000000000..fa65bc3d8807
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/integ.h
@@ -0,0 +1,59 @@
1/*
2 * Definitions for the Watchdog registers
3 *
4 * Copyright 2002 Ryan Holm <ryan.holmQVist@idt.com>
5 * Copyright 2008 Florian Fainelli <florian@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */
28
29#ifndef __RC32434_INTEG_H__
30#define __RC32434_INTEG_H__
31
32#include <asm/mach-rc32434/rb.h>
33
34#define INTEG0_BASE_ADDR 0x18030030
35
36struct integ {
37 u32 errcs; /* sticky use ERRCS_ */
38 u32 wtcount; /* Watchdog timer count reg. */
39 u32 wtcompare; /* Watchdog timer timeout value. */
40 u32 wtc; /* Watchdog timer control. use WTC_ */
41};
42
43/* Error counters */
44#define RC32434_ERR_WTO 0
45#define RC32434_ERR_WNE 1
46#define RC32434_ERR_UCW 2
47#define RC32434_ERR_UCR 3
48#define RC32434_ERR_UPW 4
49#define RC32434_ERR_UPR 5
50#define RC32434_ERR_UDW 6
51#define RC32434_ERR_UDR 7
52#define RC32434_ERR_SAE 8
53#define RC32434_ERR_WRE 9
54
55/* Watchdog control bits */
56#define RC32434_WTC_EN 0
57#define RC32434_WTC_TO 1
58
59#endif /* __RC32434_INTEG_H__ */
diff --git a/arch/mips/include/asm/mach-rc32434/irq.h b/arch/mips/include/asm/mach-rc32434/irq.h
new file mode 100644
index 000000000000..56738d8ec4e2
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/irq.h
@@ -0,0 +1,33 @@
1#ifndef __ASM_RC32434_IRQ_H
2#define __ASM_RC32434_IRQ_H
3
4#define NR_IRQS 256
5
6#include <asm/mach-generic/irq.h>
7#include <asm/mach-rc32434/rb.h>
8
9/* Interrupt Controller */
10#define IC_GROUP0_PEND (REGBASE + 0x38000)
11#define IC_GROUP0_MASK (REGBASE + 0x38008)
12#define IC_GROUP_OFFSET 0x0C
13
14#define NUM_INTR_GROUPS 5
15
16/* 16550 UARTs */
17#define GROUP0_IRQ_BASE 8 /* GRP2 IRQ numbers start here */
18 /* GRP3 IRQ numbers start here */
19#define GROUP1_IRQ_BASE (GROUP0_IRQ_BASE + 32)
20 /* GRP4 IRQ numbers start here */
21#define GROUP2_IRQ_BASE (GROUP1_IRQ_BASE + 32)
22 /* GRP5 IRQ numbers start here */
23#define GROUP3_IRQ_BASE (GROUP2_IRQ_BASE + 32)
24#define GROUP4_IRQ_BASE (GROUP3_IRQ_BASE + 32)
25
26#define UART0_IRQ (GROUP3_IRQ_BASE + 0)
27
28#define ETH0_DMA_RX_IRQ (GROUP1_IRQ_BASE + 0)
29#define ETH0_DMA_TX_IRQ (GROUP1_IRQ_BASE + 1)
30#define ETH0_RX_OVR_IRQ (GROUP3_IRQ_BASE + 9)
31#define ETH0_TX_UND_IRQ (GROUP3_IRQ_BASE + 10)
32
33#endif /* __ASM_RC32434_IRQ_H */
diff --git a/arch/mips/include/asm/mach-rc32434/pci.h b/arch/mips/include/asm/mach-rc32434/pci.h
new file mode 100644
index 000000000000..410638f2af74
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/pci.h
@@ -0,0 +1,481 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
8 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
10 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
12 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
13 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
14 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
16 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * Copyright 2004 IDT Inc. (rischelp@idt.com)
23 *
24 * Initial Release
25 */
26
27#ifndef _ASM_RC32434_PCI_H_
28#define _ASM_RC32434_PCI_H_
29
30#define epld_mask ((volatile unsigned char *)0xB900000d)
31
32#define PCI0_BASE_ADDR 0x18080000
33#define PCI_LBA_COUNT 4
34
35struct pci_map {
36 u32 address; /* Address. */
37 u32 control; /* Control. */
38 u32 mapping; /* mapping. */
39};
40
41struct pci_reg {
42 u32 pcic;
43 u32 pcis;
44 u32 pcism;
45 u32 pcicfga;
46 u32 pcicfgd;
47 volatile struct pci_map pcilba[PCI_LBA_COUNT];
48 u32 pcidac;
49 u32 pcidas;
50 u32 pcidasm;
51 u32 pcidad;
52 u32 pcidma8c;
53 u32 pcidma9c;
54 u32 pcitc;
55};
56
57#define PCI_MSU_COUNT 2
58
59struct pci_msu {
60 u32 pciim[PCI_MSU_COUNT];
61 u32 pciom[PCI_MSU_COUNT];
62 u32 pciid;
63 u32 pciiic;
64 u32 pciiim;
65 u32 pciiod;
66 u32 pciioic;
67 u32 pciioim;
68};
69
70/*
71 * PCI Control Register
72 */
73
74#define PCI_CTL_EN (1 << 0)
75#define PCI_CTL_TNR (1 << 1)
76#define PCI_CTL_SCE (1 << 2)
77#define PCI_CTL_IEN (1 << 3)
78#define PCI_CTL_AAA (1 << 4)
79#define PCI_CTL_EAP (1 << 5)
80#define PCI_CTL_PCIM_BIT 6
81#define PCI_CTL_PCIM 0x000001c0
82
83#define PCI_CTL_PCIM_DIS 0
84#define PCI_CTL_PCIM_TNR 1 /* Satellite - target not ready */
85#define PCI_CTL_PCIM_SUS 2 /* Satellite - suspended CPU. */
86#define PCI_CTL_PCIM_EXT 3 /* Host - external arbiter. */
87#define PCI_CTL PCIM_PRIO 4 /* Host - fixed priority arb. */
88#define PCI_CTL_PCIM_RR 5 /* Host - round robin priority. */
89#define PCI_CTL_PCIM_RSVD6 6
90#define PCI_CTL_PCIM_RSVD7 7
91
92#define PCI_CTL_IGM (1 << 9)
93
94/*
95 * PCI Status Register
96 */
97
98#define PCI_STAT_EED (1 << 0)
99#define PCI_STAT_WR (1 << 1)
100#define PCI_STAT_NMI (1 << 2)
101#define PCI_STAT_II (1 << 3)
102#define PCI_STAT_CWE (1 << 4)
103#define PCI_STAT_CRE (1 << 5)
104#define PCI_STAT_MDPE (1 << 6)
105#define PCI_STAT_STA (1 << 7)
106#define PCI_STAT_RTA (1 << 8)
107#define PCI_STAT_RMA (1 << 9)
108#define PCI_STAT_SSE (1 << 10)
109#define PCI_STAT_OSE (1 << 11)
110#define PCI_STAT_PE (1 << 12)
111#define PCI_STAT_TAE (1 << 13)
112#define PCI_STAT_RLE (1 << 14)
113#define PCI_STAT_BME (1 << 15)
114#define PCI_STAT_PRD (1 << 16)
115#define PCI_STAT_RIP (1 << 17)
116
117/*
118 * PCI Status Mask Register
119 */
120
121#define PCI_STATM_EED PCI_STAT_EED
122#define PCI_STATM_WR PCI_STAT_WR
123#define PCI_STATM_NMI PCI_STAT_NMI
124#define PCI_STATM_II PCI_STAT_II
125#define PCI_STATM_CWE PCI_STAT_CWE
126#define PCI_STATM_CRE PCI_STAT_CRE
127#define PCI_STATM_MDPE PCI_STAT_MDPE
128#define PCI_STATM_STA PCI_STAT_STA
129#define PCI_STATM_RTA PCI_STAT_RTA
130#define PCI_STATM_RMA PCI_STAT_RMA
131#define PCI_STATM_SSE PCI_STAT_SSE
132#define PCI_STATM_OSE PCI_STAT_OSE
133#define PCI_STATM_PE PCI_STAT_PE
134#define PCI_STATM_TAE PCI_STAT_TAE
135#define PCI_STATM_RLE PCI_STAT_RLE
136#define PCI_STATM_BME PCI_STAT_BME
137#define PCI_STATM_PRD PCI_STAT_PRD
138#define PCI_STATM_RIP PCI_STAT_RIP
139
140/*
141 * PCI Configuration Address Register
142 */
143#define PCI_CFGA_REG_BIT 2
144#define PCI_CFGA_REG 0x000000fc
145#define PCI_CFGA_REG_ID (0x00 >> 2) /* use PCFGID */
146#define PCI_CFGA_REG_04 (0x04 >> 2) /* use PCFG04_ */
147#define PCI_CFGA_REG_08 (0x08 >> 2) /* use PCFG08_ */
148#define PCI_CFGA_REG_0C (0x0C >> 2) /* use PCFG0C_ */
149#define PCI_CFGA_REG_PBA0 (0x10 >> 2) /* use PCIPBA_ */
150#define PCI_CFGA_REG_PBA1 (0x14 >> 2) /* use PCIPBA_ */
151#define PCI_CFGA_REG_PBA2 (0x18 >> 2) /* use PCIPBA_ */
152#define PCI_CFGA_REG_PBA3 (0x1c >> 2) /* use PCIPBA_ */
153#define PCI_CFGA_REG_SUBSYS (0x2c >> 2) /* use PCFGSS_ */
154#define PCI_CFGA_REG_3C (0x3C >> 2) /* use PCFG3C_ */
155#define PCI_CFGA_REG_PBBA0C (0x44 >> 2) /* use PCIPBAC_ */
156#define PCI_CFGA_REG_PBA0M (0x48 >> 2)
157#define PCI_CFGA_REG_PBA1C (0x4c >> 2) /* use PCIPBAC_ */
158#define PCI_CFGA_REG_PBA1M (0x50 >> 2)
159#define PCI_CFGA_REG_PBA2C (0x54 >> 2) /* use PCIPBAC_ */
160#define PCI_CFGA_REG_PBA2M (0x58 >> 2)
161#define PCI_CFGA_REG_PBA3C (0x5c >> 2) /* use PCIPBAC_ */
162#define PCI_CFGA_REG_PBA3M (0x60 >> 2)
163#define PCI_CFGA_REG_PMGT (0x64 >> 2)
164#define PCI_CFGA_FUNC_BIT 8
165#define PCI_CFGA_FUNC 0x00000700
166#define PCI_CFGA_DEV_BIT 11
167#define PCI_CFGA_DEV 0x0000f800
168#define PCI_CFGA_DEV_INTERN 0
169#define PCI_CFGA_BUS_BIT 16
170#define PCI CFGA_BUS 0x00ff0000
171#define PCI_CFGA_BUS_TYPE0 0
172#define PCI_CFGA_EN (1 << 31)
173
174/* PCI CFG04 commands */
175#define PCI_CFG04_CMD_IO_ENA (1 << 0)
176#define PCI_CFG04_CMD_MEM_ENA (1 << 1)
177#define PCI_CFG04_CMD_BM_ENA (1 << 2)
178#define PCI_CFG04_CMD_MW_INV (1 << 4)
179#define PCI_CFG04_CMD_PAR_ENA (1 << 6)
180#define PCI_CFG04_CMD_SER_ENA (1 << 8)
181#define PCI_CFG04_CMD_FAST_ENA (1 << 9)
182
183/* PCI CFG04 status fields */
184#define PCI_CFG04_STAT_BIT 16
185#define PCI_CFG04_STAT 0xffff0000
186#define PCI_CFG04_STAT_66_MHZ (1 << 21)
187#define PCI_CFG04_STAT_FBB (1 << 23)
188#define PCI_CFG04_STAT_MDPE (1 << 24)
189#define PCI_CFG04_STAT_DST (1 << 25)
190#define PCI_CFG04_STAT_STA (1 << 27)
191#define PCI_CFG04_STAT_RTA (1 << 28)
192#define PCI_CFG04_STAT_RMA (1 << 29)
193#define PCI_CFG04_STAT_SSE (1 << 30)
194#define PCI_CFG04_STAT_PE (1 << 31)
195
196#define PCI_PBA_MSI (1 << 0)
197#define PCI_PBA_P (1 << 2)
198
199/* PCI PBAC registers */
200#define PCI_PBAC_MSI (1 << 0)
201#define PCI_PBAC_P (1 << 1)
202#define PCI_PBAC_SIZE_BIT 2
203#define PCI_PBAC_SIZE 0x0000007c
204#define PCI_PBAC_SB (1 << 7)
205#define PCI_PBAC_PP (1 << 8)
206#define PCI_PBAC_MR_BIT 9
207#define PCI_PBAC_MR 0x00000600
208#define PCI_PBAC_MR_RD 0
209#define PCI_PBAC_MR_RD_LINE 1
210#define PCI_PBAC_MR_RD_MULT 2
211#define PCI_PBAC_MRL (1 << 11)
212#define PCI_PBAC_MRM (1 << 12)
213#define PCI_PBAC_TRP (1 << 13)
214
215#define PCI_CFG40_TRDY_TIM 0x000000ff
216#define PCI_CFG40_RET_LIM 0x0000ff00
217
218/*
219 * PCI Local Base Address [0|1|2|3] Register
220 */
221
222#define PCI_LBA_BADDR_BIT 0
223#define PCI_LBA_BADDR 0xffffff00
224
225/*
226 * PCI Local Base Address Control Register
227 */
228
229#define PCI_LBAC_MSI (1 << 0)
230#define PCI_LBAC_MSI_MEM 0
231#define PCI_LBAC_MSI_IO 1
232#define PCI_LBAC_SIZE_BIT 2
233#define PCI_LBAC_SIZE 0x0000007c
234#define PCI_LBAC_SB (1 << 7)
235#define PCI_LBAC_RT (1 << 8)
236#define PCI_LBAC_RT_NO_PREF 0
237#define PCI_LBAC_RT_PREF 1
238
239/*
240 * PCI Local Base Address [0|1|2|3] Mapping Register
241 */
242#define PCI_LBAM_MADDR_BIT 8
243#define PCI_LBAM_MADDR 0xffffff00
244
245/*
246 * PCI Decoupled Access Control Register
247 */
248#define PCI_DAC_DEN (1 << 0)
249
250/*
251 * PCI Decoupled Access Status Register
252 */
253#define PCI_DAS_D (1 << 0)
254#define PCI_DAS_B (1 << 1)
255#define PCI_DAS_E (1 << 2)
256#define PCI_DAS_OFE (1 << 3)
257#define PCI_DAS_OFF (1 << 4)
258#define PCI_DAS_IFE (1 << 5)
259#define PCI_DAS_IFF (1 << 6)
260
261/*
262 * PCI DMA Channel 8 Configuration Register
263 */
264#define PCI_DMA8C_MBS_BIT 0
265#define PCI_DMA8C_MBS 0x00000fff /* Maximum Burst Size. */
266#define PCI_DMA8C_OUR (1 << 12)
267
268/*
269 * PCI DMA Channel 9 Configuration Register
270 */
271#define PCI_DMA9C_MBS_BIT 0 /* Maximum Burst Size. */
272#define PCI_DMA9C_MBS 0x00000fff
273
274/*
275 * PCI to Memory(DMA Channel 8) AND Memory to PCI DMA(DMA Channel 9)Descriptors
276 */
277
278#define PCI_DMAD_PT_BIT 22 /* in DEVCMD field (descriptor) */
279#define PCI_DMAD_PT 0x00c00000 /* preferred transaction field */
280/* These are for reads (DMA channel 8) */
281#define PCI_DMAD_DEVCMD_MR 0 /* memory read */
282#define PCI_DMAD_DEVCMD_MRL 1 /* memory read line */
283#define PCI_DMAD_DEVCMD_MRM 2 /* memory read multiple */
284#define PCI_DMAD_DEVCMD_IOR 3 /* I/O read */
285/* These are for writes (DMA channel 9) */
286#define PCI_DMAD_DEVCMD_MW 0 /* memory write */
287#define PCI_DMAD_DEVCMD_MWI 1 /* memory write invalidate */
288#define PCI_DMAD_DEVCMD_IOW 3 /* I/O write */
289
290/* Swap byte field applies to both DMA channel 8 and 9 */
291#define PCI_DMAD_SB (1 << 24) /* swap byte field */
292
293
294/*
295 * PCI Target Control Register
296 */
297
298#define PCI_TC_RTIMER_BIT 0
299#define PCI_TC_RTIMER 0x000000ff
300#define PCI_TC_DTIMER_BIT 8
301#define PCI_TC_DTIMER 0x0000ff00
302#define PCI_TC_RDR (1 << 18)
303#define PCI_TC_DDT (1 << 19)
304
305/*
306 * PCI messaging unit [applies to both inbound and outbound registers ]
307 */
308#define PCI_MSU_M0 (1 << 0)
309#define PCI_MSU_M1 (1 << 1)
310#define PCI_MSU_DB (1 << 2)
311
312#define PCI_MSG_ADDR 0xB8088010
313#define PCI0_ADDR 0xB8080000
314#define rc32434_pci ((struct pci_reg *) PCI0_ADDR)
315#define rc32434_pci_msg ((struct pci_msu *) PCI_MSG_ADDR)
316
317#define PCIM_SHFT 0x6
318#define PCIM_BIT_LEN 0x7
319#define PCIM_H_EA 0x3
320#define PCIM_H_IA_FIX 0x4
321#define PCIM_H_IA_RR 0x5
322#if 0
323#define PCI_ADDR_START 0x13000000
324#endif
325
326#define PCI_ADDR_START 0x50000000
327
328#define CPUTOPCI_MEM_WIN 0x02000000
329#define CPUTOPCI_IO_WIN 0x00100000
330#define PCILBA_SIZE_SHFT 2
331#define PCILBA_SIZE_MASK 0x1F
332#define SIZE_256MB 0x1C
333#define SIZE_128MB 0x1B
334#define SIZE_64MB 0x1A
335#define SIZE_32MB 0x19
336#define SIZE_16MB 0x18
337#define SIZE_4MB 0x16
338#define SIZE_2MB 0x15
339#define SIZE_1MB 0x14
340#define KORINA_CONFIG0_ADDR 0x80000000
341#define KORINA_CONFIG1_ADDR 0x80000004
342#define KORINA_CONFIG2_ADDR 0x80000008
343#define KORINA_CONFIG3_ADDR 0x8000000C
344#define KORINA_CONFIG4_ADDR 0x80000010
345#define KORINA_CONFIG5_ADDR 0x80000014
346#define KORINA_CONFIG6_ADDR 0x80000018
347#define KORINA_CONFIG7_ADDR 0x8000001C
348#define KORINA_CONFIG8_ADDR 0x80000020
349#define KORINA_CONFIG9_ADDR 0x80000024
350#define KORINA_CONFIG10_ADDR 0x80000028
351#define KORINA_CONFIG11_ADDR 0x8000002C
352#define KORINA_CONFIG12_ADDR 0x80000030
353#define KORINA_CONFIG13_ADDR 0x80000034
354#define KORINA_CONFIG14_ADDR 0x80000038
355#define KORINA_CONFIG15_ADDR 0x8000003C
356#define KORINA_CONFIG16_ADDR 0x80000040
357#define KORINA_CONFIG17_ADDR 0x80000044
358#define KORINA_CONFIG18_ADDR 0x80000048
359#define KORINA_CONFIG19_ADDR 0x8000004C
360#define KORINA_CONFIG20_ADDR 0x80000050
361#define KORINA_CONFIG21_ADDR 0x80000054
362#define KORINA_CONFIG22_ADDR 0x80000058
363#define KORINA_CONFIG23_ADDR 0x8000005C
364#define KORINA_CONFIG24_ADDR 0x80000060
365#define KORINA_CONFIG25_ADDR 0x80000064
366#define KORINA_CMD (PCI_CFG04_CMD_IO_ENA | \
367 PCI_CFG04_CMD_MEM_ENA | \
368 PCI_CFG04_CMD_BM_ENA | \
369 PCI_CFG04_CMD_MW_INV | \
370 PCI_CFG04_CMD_PAR_ENA | \
371 PCI_CFG04_CMD_SER_ENA)
372
373#define KORINA_STAT (PCI_CFG04_STAT_MDPE | \
374 PCI_CFG04_STAT_STA | \
375 PCI_CFG04_STAT_RTA | \
376 PCI_CFG04_STAT_RMA | \
377 PCI_CFG04_STAT_SSE | \
378 PCI_CFG04_STAT_PE)
379
380#define KORINA_CNFG1 ((KORINA_STAT<<16)|KORINA_CMD)
381
382#define KORINA_REVID 0
383#define KORINA_CLASS_CODE 0
384#define KORINA_CNFG2 ((KORINA_CLASS_CODE<<8) | \
385 KORINA_REVID)
386
387#define KORINA_CACHE_LINE_SIZE 4
388#define KORINA_MASTER_LAT 0x3c
389#define KORINA_HEADER_TYPE 0
390#define KORINA_BIST 0
391
392#define KORINA_CNFG3 ((KORINA_BIST << 24) | \
393 (KORINA_HEADER_TYPE<<16) | \
394 (KORINA_MASTER_LAT<<8) | \
395 KORINA_CACHE_LINE_SIZE)
396
397#define KORINA_BAR0 0x00000008 /* 128 MB Memory */
398#define KORINA_BAR1 0x18800001 /* 1 MB IO */
399#define KORINA_BAR2 0x18000001 /* 2 MB IO window for Korina
400 internal Registers */
401#define KORINA_BAR3 0x48000008 /* Spare 128 MB Memory */
402
403#define KORINA_CNFG4 KORINA_BAR0
404#define KORINA_CNFG5 KORINA_BAR1
405#define KORINA_CNFG6 KORINA_BAR2
406#define KORINA_CNFG7 KORINA_BAR3
407
408#define KORINA_SUBSYS_VENDOR_ID 0x011d
409#define KORINA_SUBSYSTEM_ID 0x0214
410#define KORINA_CNFG8 0
411#define KORINA_CNFG9 0
412#define KORINA_CNFG10 0
413#define KORINA_CNFG11 ((KORINA_SUBSYS_VENDOR_ID<<16) | \
414 KORINA_SUBSYSTEM_ID)
415#define KORINA_INT_LINE 1
416#define KORINA_INT_PIN 1
417#define KORINA_MIN_GNT 8
418#define KORINA_MAX_LAT 0x38
419#define KORINA_CNFG12 0
420#define KORINA_CNFG13 0
421#define KORINA_CNFG14 0
422#define KORINA_CNFG15 ((KORINA_MAX_LAT<<24) | \
423 (KORINA_MIN_GNT<<16) | \
424 (KORINA_INT_PIN<<8) | \
425 KORINA_INT_LINE)
426#define KORINA_RETRY_LIMIT 0x80
427#define KORINA_TRDY_LIMIT 0x80
428#define KORINA_CNFG16 ((KORINA_RETRY_LIMIT<<8) | \
429 KORINA_TRDY_LIMIT)
430#define PCI_PBAxC_R 0x0
431#define PCI_PBAxC_RL 0x1
432#define PCI_PBAxC_RM 0x2
433#define SIZE_SHFT 2
434
435#if defined(__MIPSEB__)
436#define KORINA_PBA0C (PCI_PBAC_MRL | PCI_PBAC_SB | \
437 ((PCI_PBAxC_RM & 0x3) << PCI_PBAC_MR_BIT) | \
438 PCI_PBAC_PP | \
439 (SIZE_128MB<<SIZE_SHFT) | \
440 PCI_PBAC_P)
441#else
442#define KORINA_PBA0C (PCI_PBAC_MRL | \
443 ((PCI_PBAxC_RM & 0x3) << PCI_PBAC_MR_BIT) | \
444 PCI_PBAC_PP | \
445 (SIZE_128MB<<SIZE_SHFT) | \
446 PCI_PBAC_P)
447#endif
448#define KORINA_CNFG17 KORINA_PBA0C
449#define KORINA_PBA0M 0x0
450#define KORINA_CNFG18 KORINA_PBA0M
451
452#if defined(__MIPSEB__)
453#define KORINA_PBA1C ((SIZE_1MB<<SIZE_SHFT) | PCI_PBAC_SB | \
454 PCI_PBAC_MSI)
455#else
456#define KORINA_PBA1C ((SIZE_1MB<<SIZE_SHFT) | \
457 PCI_PBAC_MSI)
458#endif
459#define KORINA_CNFG19 KORINA_PBA1C
460#define KORINA_PBA1M 0x0
461#define KORINA_CNFG20 KORINA_PBA1M
462
463#if defined(__MIPSEB__)
464#define KORINA_PBA2C ((SIZE_2MB<<SIZE_SHFT) | PCI_PBAC_SB | \
465 PCI_PBAC_MSI)
466#else
467#define KORINA_PBA2C ((SIZE_2MB<<SIZE_SHFT) | \
468 PCI_PBAC_MSI)
469#endif
470#define KORINA_CNFG21 KORINA_PBA2C
471#define KORINA_PBA2M 0x18000000
472#define KORINA_CNFG22 KORINA_PBA2M
473#define KORINA_PBA3C 0
474#define KORINA_CNFG23 KORINA_PBA3C
475#define KORINA_PBA3M 0
476#define KORINA_CNFG24 KORINA_PBA3M
477
478#define PCITC_DTIMER_VAL 8
479#define PCITC_RTIMER_VAL 0x10
480
481#endif /* __ASM_RC32434_PCI_H */
diff --git a/arch/mips/include/asm/mach-rc32434/prom.h b/arch/mips/include/asm/mach-rc32434/prom.h
new file mode 100644
index 000000000000..660707f1bcce
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/prom.h
@@ -0,0 +1,40 @@
1/*
2 * Definitions for the PROM
3 *
4 * Copyright 2002 Ryan Holm <ryan.holmQVist@idt.com>
5 * Copyright 2008 Florian Fainelli <florian@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */
28
29#define PROM_ENTRY(x) (0xbfc00000 + ((x) * 8))
30
31#define SR_NMI 0x00180000
32#define SERIAL_SPEED_ENTRY 0x00000001
33
34#define FREQ_TAG "HZ="
35#define KMAC_TAG "kmac="
36#define MEM_TAG "mem="
37#define BOARD_TAG "board="
38
39#define BOARD_RB532 "500"
40#define BOARD_RB532A "500r5"
diff --git a/arch/mips/include/asm/mach-rc32434/rb.h b/arch/mips/include/asm/mach-rc32434/rb.h
new file mode 100644
index 000000000000..79e8ef67d0d3
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/rb.h
@@ -0,0 +1,84 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * Copyright (C) 2004 IDT Inc.
13 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
14 */
15#ifndef __ASM_RC32434_RB_H
16#define __ASM_RC32434_RB_H
17
18#include <linux/genhd.h>
19
20#define REGBASE 0x18000000
21#define IDT434_REG_BASE ((volatile void *) KSEG1ADDR(REGBASE))
22#define UART0BASE 0x58000
23#define RST (1 << 15)
24#define DEV0BASE 0x010000
25#define DEV0MASK 0x010004
26#define DEV0C 0x010008
27#define DEV0T 0x01000C
28#define DEV1BASE 0x010010
29#define DEV1MASK 0x010014
30#define DEV1C 0x010018
31#define DEV1TC 0x01001C
32#define DEV2BASE 0x010020
33#define DEV2MASK 0x010024
34#define DEV2C 0x010028
35#define DEV2TC 0x01002C
36#define DEV3BASE 0x010030
37#define DEV3MASK 0x010034
38#define DEV3C 0x010038
39#define DEV3TC 0x01003C
40#define BTCS 0x010040
41#define BTCOMPARE 0x010044
42#define GPIOBASE 0x050000
43#define GPIOCFG 0x050004
44#define GPIOD 0x050008
45#define GPIOILEVEL 0x05000C
46#define GPIOISTAT 0x050010
47#define GPIONMIEN 0x050014
48#define IMASK6 0x038038
49#define LO_WPX (1 << 0)
50#define LO_ALE (1 << 1)
51#define LO_CLE (1 << 2)
52#define LO_CEX (1 << 3)
53#define LO_FOFF (1 << 5)
54#define LO_SPICS (1 << 6)
55#define LO_ULED (1 << 7)
56
57#define BIT_TO_MASK(x) (1 << x)
58
59struct dev_reg {
60 u32 base;
61 u32 mask;
62 u32 ctl;
63 u32 timing;
64};
65
66struct korina_device {
67 char *name;
68 unsigned char mac[6];
69 struct net_device *dev;
70};
71
72struct cf_device {
73 int gpio_pin;
74 void *dev;
75 struct gendisk *gd;
76};
77
78struct mpmc_device {
79 unsigned char state;
80 spinlock_t lock;
81 void __iomem *base;
82};
83
84#endif /* __ASM_RC32434_RB_H */
diff --git a/arch/mips/include/asm/mach-rc32434/rc32434.h b/arch/mips/include/asm/mach-rc32434/rc32434.h
new file mode 100644
index 000000000000..fce25d4231fc
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/rc32434.h
@@ -0,0 +1,19 @@
1/*
2 * Definitions for IDT RC323434 CPU.
3 */
4
5#ifndef _ASM_RC32434_RC32434_H_
6#define _ASM_RC32434_RC32434_H_
7
8#include <linux/delay.h>
9#include <linux/io.h>
10
11#define IDT_CLOCK_MULT 2
12
13/* cpu pipeline flush */
14static inline void rc32434_sync(void)
15{
16 __asm__ volatile ("sync");
17}
18
19#endif /* _ASM_RC32434_RC32434_H_ */
diff --git a/arch/mips/include/asm/mach-rc32434/timer.h b/arch/mips/include/asm/mach-rc32434/timer.h
new file mode 100644
index 000000000000..e49b1d57a017
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/timer.h
@@ -0,0 +1,65 @@
1/*
2 * Definitions for timer registers
3 *
4 * Copyright 2004 Philip Rischel <rischelp@idt.com>
5 * Copyright 2008 Florian Fainelli <florian@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */
28
29#ifndef __ASM_RC32434_TIMER_H
30#define __ASM_RC32434_TIMER_H
31
32#include <asm/mach-rc32434/rb.h>
33
34#define TIMER0_BASE_ADDR 0x18028000
35#define TIMER_COUNT 3
36
37struct timer_counter {
38 u32 count;
39 u32 compare;
40 u32 ctc; /*use CTC_ */
41};
42
43struct timer {
44 struct timer_counter tim[TIMER_COUNT];
45 u32 rcount; /* use RCOUNT_ */
46 u32 rcompare; /* use RCOMPARE_ */
47 u32 rtc; /* use RTC_ */
48};
49
50#define RC32434_CTC_EN_BIT 0
51#define RC32434_CTC_TO_BIT 1
52
53/* Real time clock registers */
54#define RC32434_RTC_MSK(x) BIT_TO_MASK(x)
55#define RC32434_RTC_CE_BIT 0
56#define RC32434_RTC_TO_BIT 1
57#define RC32434_RTC_RQE_BIT 2
58
59/* Counter registers */
60#define RC32434_RCOUNT_BIT 0
61#define RC32434_RCOUNT_MSK 0x0000ffff
62#define RC32434_RCOMP_BIT 0
63#define RC32434_RCOMP_MSK 0x0000ffff
64
65#endif /* __ASM_RC32434_TIMER_H */
diff --git a/arch/mips/include/asm/mach-rc32434/war.h b/arch/mips/include/asm/mach-rc32434/war.h
new file mode 100644
index 000000000000..3ddf187e98a6
--- /dev/null
+++ b/arch/mips/include/asm/mach-rc32434/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_MIPS_WAR_H
9#define __ASM_MIPS_MACH_MIPS_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 1
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
diff --git a/arch/mips/include/asm/mach-rm/cpu-feature-overrides.h b/arch/mips/include/asm/mach-rm/cpu-feature-overrides.h
new file mode 100644
index 000000000000..ccf543363537
--- /dev/null
+++ b/arch/mips/include/asm/mach-rm/cpu-feature-overrides.h
@@ -0,0 +1,43 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 04, 07 Ralf Baechle (ralf@linux-mips.org)
7 *
8 * SNI RM200 C apparently was only shipped with R4600 V2.0 and R5000 processors.
9 */
10#ifndef __ASM_MACH_RM200_CPU_FEATURE_OVERRIDES_H
11#define __ASM_MACH_RM200_CPU_FEATURE_OVERRIDES_H
12
13#include <cpu-feature-overrides.h>
14
15#define cpu_has_tlb 1
16#define cpu_has_4kex 1
17#define cpu_has_4k_cache 1
18#define cpu_has_fpu 1
19#define cpu_has_32fpr 1
20#define cpu_has_counter 1
21#define cpu_has_watch 0
22#define cpu_has_mips16 0
23#define cpu_has_divec 0
24#define cpu_has_cache_cdex_p 1
25#define cpu_has_prefetch 0
26#define cpu_has_mcheck 0
27#define cpu_has_ejtag 0
28#define cpu_has_llsc 1
29#define cpu_has_vtag_icache 0
30#define cpu_has_dc_aliases (PAGE_SIZE < 0x4000)
31#define cpu_has_ic_fills_f_dc 0
32#define cpu_has_dsp 0
33#define cpu_has_nofpuex 0
34#define cpu_has_64bits 1
35#define cpu_has_mipsmt 0
36#define cpu_has_userlocal 0
37
38#define cpu_has_mips32r1 0
39#define cpu_has_mips32r2 0
40#define cpu_has_mips64r1 0
41#define cpu_has_mips64r2 0
42
43#endif /* __ASM_MACH_RM200_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-rm/mc146818rtc.h b/arch/mips/include/asm/mach-rm/mc146818rtc.h
new file mode 100644
index 000000000000..145bce096fe9
--- /dev/null
+++ b/arch/mips/include/asm/mach-rm/mc146818rtc.h
@@ -0,0 +1,21 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2004 by Ralf Baechle
7 *
8 * RTC routines for PC style attached Dallas chip with ARC epoch.
9 */
10#ifndef __ASM_MACH_RM_MC146818RTC_H
11#define __ASM_MACH_RM_MC146818RTC_H
12
13#ifdef CONFIG_CPU_BIG_ENDIAN
14#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1900)
15#else
16#define mc146818_decode_year(year) ((year) + 1980)
17#endif
18
19#include_next <mc146818rtc.h>
20
21#endif /* __ASM_MACH_RM_MC146818RTC_H */
diff --git a/arch/mips/include/asm/mach-rm/war.h b/arch/mips/include/asm/mach-rm/war.h
new file mode 100644
index 000000000000..948d3129a114
--- /dev/null
+++ b/arch/mips/include/asm/mach-rm/war.h
@@ -0,0 +1,29 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_RM_WAR_H
9#define __ASM_MIPS_MACH_RM_WAR_H
10
11/*
12 * The RM200C seems to have been shipped only with V2.0 R4600s
13 */
14
15#define R4600_V1_INDEX_ICACHEOP_WAR 0
16#define R4600_V1_HIT_CACHEOP_WAR 0
17#define R4600_V2_HIT_CACHEOP_WAR 1
18#define R5432_CP0_INTERRUPT_WAR 0
19#define BCM1250_M3_WAR 0
20#define SIBYTE_1956_WAR 0
21#define MIPS4K_ICACHE_REFILL_WAR 0
22#define MIPS_CACHE_SYNC_WAR 0
23#define TX49XX_ICACHE_INDEX_INV_WAR 0
24#define RM9000_CDEX_SMP_WAR 0
25#define ICACHE_REFILLS_WORKAROUND_WAR 0
26#define R10000_LLSC_WAR 0
27#define MIPS34K_MISSED_ITLB_WAR 0
28
29#endif /* __ASM_MIPS_MACH_RM_WAR_H */
diff --git a/arch/mips/include/asm/mach-sibyte/cpu-feature-overrides.h b/arch/mips/include/asm/mach-sibyte/cpu-feature-overrides.h
new file mode 100644
index 000000000000..1c1f92415b9a
--- /dev/null
+++ b/arch/mips/include/asm/mach-sibyte/cpu-feature-overrides.h
@@ -0,0 +1,47 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 04, 07 Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef __ASM_MACH_SIBYTE_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_SIBYTE_CPU_FEATURE_OVERRIDES_H
10
11/*
12 * Sibyte are MIPS64 processors wired to a specific configuration
13 */
14#define cpu_has_watch 1
15#define cpu_has_mips16 0
16#define cpu_has_divec 1
17#define cpu_has_vce 0
18#define cpu_has_cache_cdex_p 0
19#define cpu_has_cache_cdex_s 0
20#define cpu_has_prefetch 1
21#define cpu_has_mcheck 1
22#define cpu_has_ejtag 1
23
24#define cpu_has_llsc 1
25#define cpu_has_vtag_icache 1
26#define cpu_has_dc_aliases 0
27#define cpu_has_ic_fills_f_dc 0
28#define cpu_has_dsp 0
29#define cpu_has_mipsmt 0
30#define cpu_has_userlocal 0
31#define cpu_icache_snoops_remote_store 0
32
33#define cpu_has_nofpuex 0
34#define cpu_has_64bits 1
35
36#define cpu_has_mips32r1 1
37#define cpu_has_mips32r2 0
38#define cpu_has_mips64r1 1
39#define cpu_has_mips64r2 0
40
41#define cpu_has_inclusive_pcaches 0
42
43#define cpu_dcache_line_size() 32
44#define cpu_icache_line_size() 32
45#define cpu_scache_line_size() 32
46
47#endif /* __ASM_MACH_SIBYTE_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-sibyte/war.h b/arch/mips/include/asm/mach-sibyte/war.h
new file mode 100644
index 000000000000..7950ef4f032c
--- /dev/null
+++ b/arch/mips/include/asm/mach-sibyte/war.h
@@ -0,0 +1,37 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_SIBYTE_WAR_H
9#define __ASM_MIPS_MACH_SIBYTE_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15
16#if defined(CONFIG_SB1_PASS_1_WORKAROUNDS) || \
17 defined(CONFIG_SB1_PASS_2_WORKAROUNDS)
18
19#define BCM1250_M3_WAR 1
20#define SIBYTE_1956_WAR 1
21
22#else
23
24#define BCM1250_M3_WAR 0
25#define SIBYTE_1956_WAR 0
26
27#endif
28
29#define MIPS4K_ICACHE_REFILL_WAR 0
30#define MIPS_CACHE_SYNC_WAR 0
31#define TX49XX_ICACHE_INDEX_INV_WAR 0
32#define RM9000_CDEX_SMP_WAR 0
33#define ICACHE_REFILLS_WORKAROUND_WAR 0
34#define R10000_LLSC_WAR 0
35#define MIPS34K_MISSED_ITLB_WAR 0
36
37#endif /* __ASM_MIPS_MACH_SIBYTE_WAR_H */
diff --git a/arch/mips/include/asm/mach-tx39xx/ioremap.h b/arch/mips/include/asm/mach-tx39xx/ioremap.h
new file mode 100644
index 000000000000..93c6c04ffda3
--- /dev/null
+++ b/arch/mips/include/asm/mach-tx39xx/ioremap.h
@@ -0,0 +1,38 @@
1/*
2 * include/asm-mips/mach-tx39xx/ioremap.h
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9#ifndef __ASM_MACH_TX39XX_IOREMAP_H
10#define __ASM_MACH_TX39XX_IOREMAP_H
11
12#include <linux/types.h>
13
14/*
15 * Allow physical addresses to be fixed up to help peripherals located
16 * outside the low 32-bit range -- generic pass-through version.
17 */
18static inline phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
19{
20 return phys_addr;
21}
22
23static inline void __iomem *plat_ioremap(phys_t offset, unsigned long size,
24 unsigned long flags)
25{
26#define TXX9_DIRECTMAP_BASE 0xff000000ul
27 if (offset >= TXX9_DIRECTMAP_BASE &&
28 offset < TXX9_DIRECTMAP_BASE + 0xff0000)
29 return (void __iomem *)offset;
30 return NULL;
31}
32
33static inline int plat_iounmap(const volatile void __iomem *addr)
34{
35 return (unsigned long)addr >= TXX9_DIRECTMAP_BASE;
36}
37
38#endif /* __ASM_MACH_TX39XX_IOREMAP_H */
diff --git a/arch/mips/include/asm/mach-tx39xx/mangle-port.h b/arch/mips/include/asm/mach-tx39xx/mangle-port.h
new file mode 100644
index 000000000000..ef0b502fd8b7
--- /dev/null
+++ b/arch/mips/include/asm/mach-tx39xx/mangle-port.h
@@ -0,0 +1,23 @@
1#ifndef __ASM_MACH_TX39XX_MANGLE_PORT_H
2#define __ASM_MACH_TX39XX_MANGLE_PORT_H
3
4#if defined(CONFIG_TOSHIBA_JMR3927)
5extern unsigned long (*__swizzle_addr_b)(unsigned long port);
6#define NEEDS_TXX9_SWIZZLE_ADDR_B
7#else
8#define __swizzle_addr_b(port) (port)
9#endif
10#define __swizzle_addr_w(port) (port)
11#define __swizzle_addr_l(port) (port)
12#define __swizzle_addr_q(port) (port)
13
14#define ioswabb(a, x) (x)
15#define __mem_ioswabb(a, x) (x)
16#define ioswabw(a, x) le16_to_cpu(x)
17#define __mem_ioswabw(a, x) (x)
18#define ioswabl(a, x) le32_to_cpu(x)
19#define __mem_ioswabl(a, x) (x)
20#define ioswabq(a, x) le64_to_cpu(x)
21#define __mem_ioswabq(a, x) (x)
22
23#endif /* __ASM_MACH_TX39XX_MANGLE_PORT_H */
diff --git a/arch/mips/include/asm/mach-tx39xx/war.h b/arch/mips/include/asm/mach-tx39xx/war.h
new file mode 100644
index 000000000000..433814616359
--- /dev/null
+++ b/arch/mips/include/asm/mach-tx39xx/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_TX39XX_WAR_H
9#define __ASM_MIPS_MACH_TX39XX_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_TX39XX_WAR_H */
diff --git a/arch/mips/include/asm/mach-tx49xx/cpu-feature-overrides.h b/arch/mips/include/asm/mach-tx49xx/cpu-feature-overrides.h
new file mode 100644
index 000000000000..275eaf92c748
--- /dev/null
+++ b/arch/mips/include/asm/mach-tx49xx/cpu-feature-overrides.h
@@ -0,0 +1,23 @@
1#ifndef __ASM_MACH_TX49XX_CPU_FEATURE_OVERRIDES_H
2#define __ASM_MACH_TX49XX_CPU_FEATURE_OVERRIDES_H
3
4#define cpu_has_llsc 1
5#define cpu_has_64bits 1
6#define cpu_has_inclusive_pcaches 0
7
8#define cpu_has_mips16 0
9#define cpu_has_mdmx 0
10#define cpu_has_mips3d 0
11#define cpu_has_smartmips 0
12#define cpu_has_vtag_icache 0
13#define cpu_has_ic_fills_f_dc 0
14#define cpu_has_dsp 0
15#define cpu_has_mipsmt 0
16#define cpu_has_userlocal 0
17
18#define cpu_has_mips32r1 0
19#define cpu_has_mips32r2 0
20#define cpu_has_mips64r1 0
21#define cpu_has_mips64r2 0
22
23#endif /* __ASM_MACH_TX49XX_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-tx49xx/ioremap.h b/arch/mips/include/asm/mach-tx49xx/ioremap.h
new file mode 100644
index 000000000000..1e7beae72229
--- /dev/null
+++ b/arch/mips/include/asm/mach-tx49xx/ioremap.h
@@ -0,0 +1,43 @@
1/*
2 * include/asm-mips/mach-tx49xx/ioremap.h
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9#ifndef __ASM_MACH_TX49XX_IOREMAP_H
10#define __ASM_MACH_TX49XX_IOREMAP_H
11
12#include <linux/types.h>
13
14/*
15 * Allow physical addresses to be fixed up to help peripherals located
16 * outside the low 32-bit range -- generic pass-through version.
17 */
18static inline phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
19{
20 return phys_addr;
21}
22
23static inline void __iomem *plat_ioremap(phys_t offset, unsigned long size,
24 unsigned long flags)
25{
26#ifdef CONFIG_64BIT
27#define TXX9_DIRECTMAP_BASE 0xfff000000ul
28#else
29#define TXX9_DIRECTMAP_BASE 0xff000000ul
30#endif
31 if (offset >= TXX9_DIRECTMAP_BASE &&
32 offset < TXX9_DIRECTMAP_BASE + 0x400000)
33 return (void __iomem *)(unsigned long)(int)offset;
34 return NULL;
35}
36
37static inline int plat_iounmap(const volatile void __iomem *addr)
38{
39 return (unsigned long)addr >=
40 (unsigned long)(int)(TXX9_DIRECTMAP_BASE & 0xffffffff);
41}
42
43#endif /* __ASM_MACH_TX49XX_IOREMAP_H */
diff --git a/arch/mips/include/asm/mach-tx49xx/kmalloc.h b/arch/mips/include/asm/mach-tx49xx/kmalloc.h
new file mode 100644
index 000000000000..913ff196259d
--- /dev/null
+++ b/arch/mips/include/asm/mach-tx49xx/kmalloc.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_MACH_TX49XX_KMALLOC_H
2#define __ASM_MACH_TX49XX_KMALLOC_H
3
4/*
5 * All happy, no need to define ARCH_KMALLOC_MINALIGN
6 */
7
8#endif /* __ASM_MACH_TX49XX_KMALLOC_H */
diff --git a/arch/mips/include/asm/mach-tx49xx/war.h b/arch/mips/include/asm/mach-tx49xx/war.h
new file mode 100644
index 000000000000..39b5d1177c57
--- /dev/null
+++ b/arch/mips/include/asm/mach-tx49xx/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_TX49XX_WAR_H
9#define __ASM_MIPS_MACH_TX49XX_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 1
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_TX49XX_WAR_H */
diff --git a/arch/mips/include/asm/mach-vr41xx/irq.h b/arch/mips/include/asm/mach-vr41xx/irq.h
new file mode 100644
index 000000000000..862058d3f81b
--- /dev/null
+++ b/arch/mips/include/asm/mach-vr41xx/irq.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_MACH_VR41XX_IRQ_H
2#define __ASM_MACH_VR41XX_IRQ_H
3
4#include <asm/vr41xx/irq.h> /* for MIPS_CPU_IRQ_BASE */
5
6#include_next <irq.h>
7
8#endif /* __ASM_MACH_VR41XX_IRQ_H */
diff --git a/arch/mips/include/asm/mach-vr41xx/war.h b/arch/mips/include/asm/mach-vr41xx/war.h
new file mode 100644
index 000000000000..56a38926412a
--- /dev/null
+++ b/arch/mips/include/asm/mach-vr41xx/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_VR41XX_WAR_H
9#define __ASM_MIPS_MACH_VR41XX_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_VR41XX_WAR_H */
diff --git a/arch/mips/include/asm/mach-wrppmc/mach-gt64120.h b/arch/mips/include/asm/mach-wrppmc/mach-gt64120.h
new file mode 100644
index 000000000000..83746b84a5ec
--- /dev/null
+++ b/arch/mips/include/asm/mach-wrppmc/mach-gt64120.h
@@ -0,0 +1,83 @@
1/*
2 * This is a direct copy of the ev96100.h file, with a global
3 * search and replace. The numbers are the same.
4 *
5 * The reason I'm duplicating this is so that the 64120/96100
6 * defines won't be confusing in the source code.
7 */
8#ifndef __ASM_MIPS_GT64120_H
9#define __ASM_MIPS_GT64120_H
10
11/*
12 * This is the CPU physical memory map of PPMC Board:
13 *
14 * 0x00000000-0x03FFFFFF - 64MB SDRAM (SCS[0]#)
15 * 0x1C000000-0x1C000000 - LED (CS0)
16 * 0x1C800000-0x1C800007 - UART 16550 port (CS1)
17 * 0x1F000000-0x1F000000 - MailBox (CS3)
18 * 0x1FC00000-0x20000000 - 4MB Flash (BOOT CS)
19 */
20
21#define WRPPMC_SDRAM_SCS0_BASE 0x00000000
22#define WRPPMC_SDRAM_SCS0_SIZE 0x04000000
23
24#define WRPPMC_UART16550_BASE 0x1C800000
25#define WRPPMC_UART16550_CLOCK 3686400 /* 3.68MHZ */
26
27#define WRPPMC_LED_BASE 0x1C000000
28#define WRPPMC_MBOX_BASE 0x1F000000
29
30#define WRPPMC_BOOTROM_BASE 0x1FC00000
31#define WRPPMC_BOOTROM_SIZE 0x00400000 /* 4M Flash */
32
33#define WRPPMC_MIPS_TIMER_IRQ 7 /* MIPS compare/count timer interrupt */
34#define WRPPMC_UART16550_IRQ 6
35#define WRPPMC_PCI_INTA_IRQ 3
36
37/*
38 * PCI Bus I/O and Memory resources allocation
39 *
40 * NOTE: We only have PCI_0 hose interface
41 */
42#define GT_PCI_MEM_BASE 0x13000000UL
43#define GT_PCI_MEM_SIZE 0x02000000UL
44#define GT_PCI_IO_BASE 0x11000000UL
45#define GT_PCI_IO_SIZE 0x02000000UL
46
47/*
48 * PCI interrupts will come in on either the INTA or INTD interrupt lines,
49 * which are mapped to the #2 and #5 interrupt pins of the MIPS. On our
50 * boards, they all either come in on IntD or they all come in on IntA, they
51 * aren't mixed. There can be numerous PCI interrupts, so we keep a list of the
52 * "requested" interrupt numbers and go through the list whenever we get an
53 * IntA/D.
54 *
55 * Interrupts < 8 are directly wired to the processor; PCI INTA is 8 and
56 * INTD is 11.
57 */
58#define GT_TIMER 4
59#define GT_INTA 2
60#define GT_INTD 5
61
62#ifndef __ASSEMBLY__
63
64/*
65 * GT64120 internal register space base address
66 */
67extern unsigned long gt64120_base;
68
69#define GT64120_BASE (gt64120_base)
70
71/* define WRPPMC_EARLY_DEBUG to enable early output something to UART */
72#undef WRPPMC_EARLY_DEBUG
73
74#ifdef WRPPMC_EARLY_DEBUG
75extern void wrppmc_led_on(int mask);
76extern void wrppmc_led_off(int mask);
77extern void wrppmc_early_printk(const char *fmt, ...);
78#else
79#define wrppmc_early_printk(fmt, ...) do {} while (0)
80#endif /* WRPPMC_EARLY_DEBUG */
81
82#endif /* __ASSEMBLY__ */
83#endif /* __ASM_MIPS_GT64120_H */
diff --git a/arch/mips/include/asm/mach-wrppmc/war.h b/arch/mips/include/asm/mach-wrppmc/war.h
new file mode 100644
index 000000000000..ac48629bb1ce
--- /dev/null
+++ b/arch/mips/include/asm/mach-wrppmc/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_WRPPMC_WAR_H
9#define __ASM_MIPS_MACH_WRPPMC_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 1
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_WRPPMC_WAR_H */
diff --git a/arch/mips/include/asm/mach-yosemite/cpu-feature-overrides.h b/arch/mips/include/asm/mach-yosemite/cpu-feature-overrides.h
new file mode 100644
index 000000000000..470e5e9e10d6
--- /dev/null
+++ b/arch/mips/include/asm/mach-yosemite/cpu-feature-overrides.h
@@ -0,0 +1,47 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 04, 07 Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef __ASM_MACH_YOSEMITE_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_YOSEMITE_CPU_FEATURE_OVERRIDES_H
10
11/*
12 * Momentum Jaguar ATX always has the RM9000 processor.
13 */
14#define cpu_has_watch 1
15#define cpu_has_mips16 0
16#define cpu_has_divec 0
17#define cpu_has_vce 0
18#define cpu_has_cache_cdex_p 0
19#define cpu_has_cache_cdex_s 0
20#define cpu_has_prefetch 1
21#define cpu_has_mcheck 0
22#define cpu_has_ejtag 0
23
24#define cpu_has_llsc 1
25#define cpu_has_vtag_icache 0
26#define cpu_has_dc_aliases 0
27#define cpu_has_ic_fills_f_dc 0
28#define cpu_has_dsp 0
29#define cpu_has_mipsmt 0
30#define cpu_has_userlocal 0
31#define cpu_icache_snoops_remote_store 0
32
33#define cpu_has_nofpuex 0
34#define cpu_has_64bits 1
35
36#define cpu_has_inclusive_pcaches 0
37
38#define cpu_dcache_line_size() 32
39#define cpu_icache_line_size() 32
40#define cpu_scache_line_size() 32
41
42#define cpu_has_mips32r1 0
43#define cpu_has_mips32r2 0
44#define cpu_has_mips64r1 0
45#define cpu_has_mips64r2 0
46
47#endif /* __ASM_MACH_YOSEMITE_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-yosemite/war.h b/arch/mips/include/asm/mach-yosemite/war.h
new file mode 100644
index 000000000000..e5c6d53efc86
--- /dev/null
+++ b/arch/mips/include/asm/mach-yosemite/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_YOSEMITE_WAR_H
9#define __ASM_MIPS_MACH_YOSEMITE_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 1
21#define ICACHE_REFILLS_WORKAROUND_WAR 1
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_YOSEMITE_WAR_H */
diff --git a/arch/mips/include/asm/mc146818-time.h b/arch/mips/include/asm/mc146818-time.h
new file mode 100644
index 000000000000..cdc379a0a94e
--- /dev/null
+++ b/arch/mips/include/asm/mc146818-time.h
@@ -0,0 +1,119 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Machine dependent access functions for RTC registers.
7 */
8#ifndef __ASM_MC146818_TIME_H
9#define __ASM_MC146818_TIME_H
10
11#include <linux/bcd.h>
12#include <linux/mc146818rtc.h>
13#include <linux/time.h>
14
15/*
16 * For check timing call set_rtc_mmss() 500ms; used in timer interrupt.
17 */
18#define USEC_AFTER 500000
19#define USEC_BEFORE 500000
20
21/*
22 * In order to set the CMOS clock precisely, set_rtc_mmss has to be
23 * called 500 ms after the second nowtime has started, because when
24 * nowtime is written into the registers of the CMOS clock, it will
25 * jump to the next second precisely 500 ms later. Check the Motorola
26 * MC146818A or Dallas DS12887 data sheet for details.
27 *
28 * BUG: This routine does not handle hour overflow properly; it just
29 * sets the minutes. Usually you'll only notice that after reboot!
30 */
31static inline int mc146818_set_rtc_mmss(unsigned long nowtime)
32{
33 int real_seconds, real_minutes, cmos_minutes;
34 unsigned char save_control, save_freq_select;
35 int retval = 0;
36 unsigned long flags;
37
38 spin_lock_irqsave(&rtc_lock, flags);
39 save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
40 CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
41
42 save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
43 CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
44
45 cmos_minutes = CMOS_READ(RTC_MINUTES);
46 if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
47 BCD_TO_BIN(cmos_minutes);
48
49 /*
50 * since we're only adjusting minutes and seconds,
51 * don't interfere with hour overflow. This avoids
52 * messing with unknown time zones but requires your
53 * RTC not to be off by more than 15 minutes
54 */
55 real_seconds = nowtime % 60;
56 real_minutes = nowtime / 60;
57 if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
58 real_minutes += 30; /* correct for half hour time zone */
59 real_minutes %= 60;
60
61 if (abs(real_minutes - cmos_minutes) < 30) {
62 if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
63 BIN_TO_BCD(real_seconds);
64 BIN_TO_BCD(real_minutes);
65 }
66 CMOS_WRITE(real_seconds, RTC_SECONDS);
67 CMOS_WRITE(real_minutes, RTC_MINUTES);
68 } else {
69 printk(KERN_WARNING
70 "set_rtc_mmss: can't update from %d to %d\n",
71 cmos_minutes, real_minutes);
72 retval = -1;
73 }
74
75 /* The following flags have to be released exactly in this order,
76 * otherwise the DS12887 (popular MC146818A clone with integrated
77 * battery and quartz) will not reset the oscillator and will not
78 * update precisely 500 ms later. You won't find this mentioned in
79 * the Dallas Semiconductor data sheets, but who believes data
80 * sheets anyway ... -- Markus Kuhn
81 */
82 CMOS_WRITE(save_control, RTC_CONTROL);
83 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
84 spin_unlock_irqrestore(&rtc_lock, flags);
85
86 return retval;
87}
88
89static inline unsigned long mc146818_get_cmos_time(void)
90{
91 unsigned int year, mon, day, hour, min, sec;
92 unsigned long flags;
93
94 spin_lock_irqsave(&rtc_lock, flags);
95
96 do {
97 sec = CMOS_READ(RTC_SECONDS);
98 min = CMOS_READ(RTC_MINUTES);
99 hour = CMOS_READ(RTC_HOURS);
100 day = CMOS_READ(RTC_DAY_OF_MONTH);
101 mon = CMOS_READ(RTC_MONTH);
102 year = CMOS_READ(RTC_YEAR);
103 } while (sec != CMOS_READ(RTC_SECONDS));
104
105 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
106 BCD_TO_BIN(sec);
107 BCD_TO_BIN(min);
108 BCD_TO_BIN(hour);
109 BCD_TO_BIN(day);
110 BCD_TO_BIN(mon);
111 BCD_TO_BIN(year);
112 }
113 spin_unlock_irqrestore(&rtc_lock, flags);
114 year = mc146818_decode_year(year);
115
116 return mktime(year, mon, day, hour, min, sec);
117}
118
119#endif /* __ASM_MC146818_TIME_H */
diff --git a/arch/mips/include/asm/mc146818rtc.h b/arch/mips/include/asm/mc146818rtc.h
new file mode 100644
index 000000000000..68b4da6d520b
--- /dev/null
+++ b/arch/mips/include/asm/mc146818rtc.h
@@ -0,0 +1,16 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Machine dependent access functions for RTC registers.
7 *
8 * Copyright (C) 1996, 1997, 1998, 2000 Ralf Baechle
9 * Copyright (C) 2002 Maciej W. Rozycki
10 */
11#ifndef _ASM_MC146818RTC_H
12#define _ASM_MC146818RTC_H
13
14#include <mc146818rtc.h>
15
16#endif /* _ASM_MC146818RTC_H */
diff --git a/arch/mips/include/asm/mips-boards/bonito64.h b/arch/mips/include/asm/mips-boards/bonito64.h
new file mode 100644
index 000000000000..a0f04bb99c99
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/bonito64.h
@@ -0,0 +1,436 @@
1/*
2 * Bonito Register Map
3 *
4 * This file is the original bonito.h from Algorithmics with minor changes
5 * to fit into linux.
6 *
7 * Copyright (c) 1999 Algorithmics Ltd
8 *
9 * Carsten Langgaard, carstenl@mips.com
10 * Copyright (C) 2001 MIPS Technologies, Inc. All rights reserved.
11 *
12 * Algorithmics gives permission for anyone to use and modify this file
13 * without any obligation or license condition except that you retain
14 * this copyright message in any source redistribution in whole or part.
15 *
16 */
17
18/* Revision 1.48 autogenerated on 08/17/99 15:20:01 */
19/* This bonito64 version editted from bonito.h Revision 1.48 on 11/09/00 */
20
21#ifndef _ASM_MIPS_BOARDS_BONITO64_H
22#define _ASM_MIPS_BOARDS_BONITO64_H
23
24#ifdef __ASSEMBLY__
25
26/* offsets from base register */
27#define BONITO(x) (x)
28
29#elif defined(CONFIG_LEMOTE_FULONG)
30
31#define BONITO(x) (*(volatile u32 *)((char *)CKSEG1ADDR(BONITO_REG_BASE) + (x)))
32#define BONITO_IRQ_BASE 32
33
34#else
35
36/*
37 * Algorithmics Bonito64 system controller register base.
38 */
39extern unsigned long _pcictrl_bonito;
40extern unsigned long _pcictrl_bonito_pcicfg;
41
42#define BONITO(x) *(volatile u32 *)(_pcictrl_bonito + (x))
43
44#endif /* __ASSEMBLY__ */
45
46
47#define BONITO_BOOT_BASE 0x1fc00000
48#define BONITO_BOOT_SIZE 0x00100000
49#define BONITO_BOOT_TOP (BONITO_BOOT_BASE+BONITO_BOOT_SIZE-1)
50#define BONITO_FLASH_BASE 0x1c000000
51#define BONITO_FLASH_SIZE 0x03000000
52#define BONITO_FLASH_TOP (BONITO_FLASH_BASE+BONITO_FLASH_SIZE-1)
53#define BONITO_SOCKET_BASE 0x1f800000
54#define BONITO_SOCKET_SIZE 0x00400000
55#define BONITO_SOCKET_TOP (BONITO_SOCKET_BASE+BONITO_SOCKET_SIZE-1)
56#define BONITO_REG_BASE 0x1fe00000
57#define BONITO_REG_SIZE 0x00040000
58#define BONITO_REG_TOP (BONITO_REG_BASE+BONITO_REG_SIZE-1)
59#define BONITO_DEV_BASE 0x1ff00000
60#define BONITO_DEV_SIZE 0x00100000
61#define BONITO_DEV_TOP (BONITO_DEV_BASE+BONITO_DEV_SIZE-1)
62#define BONITO_PCILO_BASE 0x10000000
63#define BONITO_PCILO_SIZE 0x0c000000
64#define BONITO_PCILO_TOP (BONITO_PCILO_BASE+BONITO_PCILO_SIZE-1)
65#define BONITO_PCILO0_BASE 0x10000000
66#define BONITO_PCILO1_BASE 0x14000000
67#define BONITO_PCILO2_BASE 0x18000000
68#define BONITO_PCIHI_BASE 0x20000000
69#define BONITO_PCIHI_SIZE 0x20000000
70#define BONITO_PCIHI_TOP (BONITO_PCIHI_BASE+BONITO_PCIHI_SIZE-1)
71#define BONITO_PCIIO_BASE 0x1fd00000
72#define BONITO_PCIIO_SIZE 0x00100000
73#define BONITO_PCIIO_TOP (BONITO_PCIIO_BASE+BONITO_PCIIO_SIZE-1)
74#define BONITO_PCICFG_BASE 0x1fe80000
75#define BONITO_PCICFG_SIZE 0x00080000
76#define BONITO_PCICFG_TOP (BONITO_PCICFG_BASE+BONITO_PCICFG_SIZE-1)
77
78
79/* Bonito Register Bases */
80
81#define BONITO_PCICONFIGBASE 0x00
82#define BONITO_REGBASE 0x100
83
84
85/* PCI Configuration Registers */
86
87#define BONITO_PCI_REG(x) BONITO(BONITO_PCICONFIGBASE + (x))
88#define BONITO_PCIDID BONITO_PCI_REG(0x00)
89#define BONITO_PCICMD BONITO_PCI_REG(0x04)
90#define BONITO_PCICLASS BONITO_PCI_REG(0x08)
91#define BONITO_PCILTIMER BONITO_PCI_REG(0x0c)
92#define BONITO_PCIBASE0 BONITO_PCI_REG(0x10)
93#define BONITO_PCIBASE1 BONITO_PCI_REG(0x14)
94#define BONITO_PCIBASE2 BONITO_PCI_REG(0x18)
95#define BONITO_PCIEXPRBASE BONITO_PCI_REG(0x30)
96#define BONITO_PCIINT BONITO_PCI_REG(0x3c)
97
98#define BONITO_PCICMD_PERR_CLR 0x80000000
99#define BONITO_PCICMD_SERR_CLR 0x40000000
100#define BONITO_PCICMD_MABORT_CLR 0x20000000
101#define BONITO_PCICMD_MTABORT_CLR 0x10000000
102#define BONITO_PCICMD_TABORT_CLR 0x08000000
103#define BONITO_PCICMD_MPERR_CLR 0x01000000
104#define BONITO_PCICMD_PERRRESPEN 0x00000040
105#define BONITO_PCICMD_ASTEPEN 0x00000080
106#define BONITO_PCICMD_SERREN 0x00000100
107#define BONITO_PCILTIMER_BUSLATENCY 0x0000ff00
108#define BONITO_PCILTIMER_BUSLATENCY_SHIFT 8
109
110
111
112
113/* 1. Bonito h/w Configuration */
114/* Power on register */
115
116#define BONITO_BONPONCFG BONITO(BONITO_REGBASE + 0x00)
117
118#define BONITO_BONPONCFG_SYSCONTROLLERRD 0x00040000
119#define BONITO_BONPONCFG_ROMCS1SAMP 0x00020000
120#define BONITO_BONPONCFG_ROMCS0SAMP 0x00010000
121#define BONITO_BONPONCFG_CPUBIGEND 0x00004000
122/* Added by RPF 11-9-00 */
123#define BONITO_BONPONCFG_BURSTORDER 0x00001000
124/* --- */
125#define BONITO_BONPONCFG_CPUPARITY 0x00002000
126#define BONITO_BONPONCFG_CPUTYPE 0x00000007
127#define BONITO_BONPONCFG_CPUTYPE_SHIFT 0
128#define BONITO_BONPONCFG_PCIRESET_OUT 0x00000008
129#define BONITO_BONPONCFG_IS_ARBITER 0x00000010
130#define BONITO_BONPONCFG_ROMBOOT 0x000000c0
131#define BONITO_BONPONCFG_ROMBOOT_SHIFT 6
132
133#define BONITO_BONPONCFG_ROMBOOT_FLASH (0x0<<BONITO_BONPONCFG_ROMBOOT_SHIFT)
134#define BONITO_BONPONCFG_ROMBOOT_SOCKET (0x1<<BONITO_BONPONCFG_ROMBOOT_SHIFT)
135#define BONITO_BONPONCFG_ROMBOOT_SDRAM (0x2<<BONITO_BONPONCFG_ROMBOOT_SHIFT)
136#define BONITO_BONPONCFG_ROMBOOT_CPURESET (0x3<<BONITO_BONPONCFG_ROMBOOT_SHIFT)
137
138#define BONITO_BONPONCFG_ROMCS0WIDTH 0x00000100
139#define BONITO_BONPONCFG_ROMCS1WIDTH 0x00000200
140#define BONITO_BONPONCFG_ROMCS0FAST 0x00000400
141#define BONITO_BONPONCFG_ROMCS1FAST 0x00000800
142#define BONITO_BONPONCFG_CONFIG_DIS 0x00000020
143
144
145/* Other Bonito configuration */
146
147#define BONITO_BONGENCFG_OFFSET 0x4
148#define BONITO_BONGENCFG BONITO(BONITO_REGBASE + BONITO_BONGENCFG_OFFSET)
149
150#define BONITO_BONGENCFG_DEBUGMODE 0x00000001
151#define BONITO_BONGENCFG_SNOOPEN 0x00000002
152#define BONITO_BONGENCFG_CPUSELFRESET 0x00000004
153
154#define BONITO_BONGENCFG_FORCE_IRQA 0x00000008
155#define BONITO_BONGENCFG_IRQA_ISOUT 0x00000010
156#define BONITO_BONGENCFG_IRQA_FROM_INT1 0x00000020
157#define BONITO_BONGENCFG_BYTESWAP 0x00000040
158
159#define BONITO_BONGENCFG_UNCACHED 0x00000080
160#define BONITO_BONGENCFG_PREFETCHEN 0x00000100
161#define BONITO_BONGENCFG_WBEHINDEN 0x00000200
162#define BONITO_BONGENCFG_CACHEALG 0x00000c00
163#define BONITO_BONGENCFG_CACHEALG_SHIFT 10
164#define BONITO_BONGENCFG_PCIQUEUE 0x00001000
165#define BONITO_BONGENCFG_CACHESTOP 0x00002000
166#define BONITO_BONGENCFG_MSTRBYTESWAP 0x00004000
167#define BONITO_BONGENCFG_BUSERREN 0x00008000
168#define BONITO_BONGENCFG_NORETRYTIMEOUT 0x00010000
169#define BONITO_BONGENCFG_SHORTCOPYTIMEOUT 0x00020000
170
171/* 2. IO & IDE configuration */
172
173#define BONITO_IODEVCFG BONITO(BONITO_REGBASE + 0x08)
174
175/* 3. IO & IDE configuration */
176
177#define BONITO_SDCFG BONITO(BONITO_REGBASE + 0x0c)
178
179/* 4. PCI address map control */
180
181#define BONITO_PCIMAP BONITO(BONITO_REGBASE + 0x10)
182#define BONITO_PCIMEMBASECFG BONITO(BONITO_REGBASE + 0x14)
183#define BONITO_PCIMAP_CFG BONITO(BONITO_REGBASE + 0x18)
184
185/* 5. ICU & GPIO regs */
186
187/* GPIO Regs - r/w */
188
189#define BONITO_GPIODATA_OFFSET 0x1c
190#define BONITO_GPIODATA BONITO(BONITO_REGBASE + BONITO_GPIODATA_OFFSET)
191#define BONITO_GPIOIE BONITO(BONITO_REGBASE + 0x20)
192
193/* ICU Configuration Regs - r/w */
194
195#define BONITO_INTEDGE BONITO(BONITO_REGBASE + 0x24)
196#define BONITO_INTSTEER BONITO(BONITO_REGBASE + 0x28)
197#define BONITO_INTPOL BONITO(BONITO_REGBASE + 0x2c)
198
199/* ICU Enable Regs - IntEn & IntISR are r/o. */
200
201#define BONITO_INTENSET BONITO(BONITO_REGBASE + 0x30)
202#define BONITO_INTENCLR BONITO(BONITO_REGBASE + 0x34)
203#define BONITO_INTEN BONITO(BONITO_REGBASE + 0x38)
204#define BONITO_INTISR BONITO(BONITO_REGBASE + 0x3c)
205
206/* PCI mail boxes */
207
208#define BONITO_PCIMAIL0_OFFSET 0x40
209#define BONITO_PCIMAIL1_OFFSET 0x44
210#define BONITO_PCIMAIL2_OFFSET 0x48
211#define BONITO_PCIMAIL3_OFFSET 0x4c
212#define BONITO_PCIMAIL0 BONITO(BONITO_REGBASE + 0x40)
213#define BONITO_PCIMAIL1 BONITO(BONITO_REGBASE + 0x44)
214#define BONITO_PCIMAIL2 BONITO(BONITO_REGBASE + 0x48)
215#define BONITO_PCIMAIL3 BONITO(BONITO_REGBASE + 0x4c)
216
217
218/* 6. PCI cache */
219
220#define BONITO_PCICACHECTRL BONITO(BONITO_REGBASE + 0x50)
221#define BONITO_PCICACHETAG BONITO(BONITO_REGBASE + 0x54)
222
223#define BONITO_PCIBADADDR BONITO(BONITO_REGBASE + 0x58)
224#define BONITO_PCIMSTAT BONITO(BONITO_REGBASE + 0x5c)
225
226
227/*
228#define BONITO_PCIRDPOST BONITO(BONITO_REGBASE + 0x60)
229#define BONITO_PCIDATA BONITO(BONITO_REGBASE + 0x64)
230*/
231
232/* 7. IDE DMA & Copier */
233
234#define BONITO_CONFIGBASE 0x000
235#define BONITO_BONITOBASE 0x100
236#define BONITO_LDMABASE 0x200
237#define BONITO_COPBASE 0x300
238#define BONITO_REG_BLOCKMASK 0x300
239
240#define BONITO_LDMACTRL BONITO(BONITO_LDMABASE + 0x0)
241#define BONITO_LDMASTAT BONITO(BONITO_LDMABASE + 0x0)
242#define BONITO_LDMAADDR BONITO(BONITO_LDMABASE + 0x4)
243#define BONITO_LDMAGO BONITO(BONITO_LDMABASE + 0x8)
244#define BONITO_LDMADATA BONITO(BONITO_LDMABASE + 0xc)
245
246#define BONITO_COPCTRL BONITO(BONITO_COPBASE + 0x0)
247#define BONITO_COPSTAT BONITO(BONITO_COPBASE + 0x0)
248#define BONITO_COPPADDR BONITO(BONITO_COPBASE + 0x4)
249#define BONITO_COPDADDR BONITO(BONITO_COPBASE + 0x8)
250#define BONITO_COPGO BONITO(BONITO_COPBASE + 0xc)
251
252
253/* ###### Bit Definitions for individual Registers #### */
254
255/* Gen DMA. */
256
257#define BONITO_IDECOPDADDR_DMA_DADDR 0x0ffffffc
258#define BONITO_IDECOPDADDR_DMA_DADDR_SHIFT 2
259#define BONITO_IDECOPPADDR_DMA_PADDR 0xfffffffc
260#define BONITO_IDECOPPADDR_DMA_PADDR_SHIFT 2
261#define BONITO_IDECOPGO_DMA_SIZE 0x0000fffe
262#define BONITO_IDECOPGO_DMA_SIZE_SHIFT 0
263#define BONITO_IDECOPGO_DMA_WRITE 0x00010000
264#define BONITO_IDECOPGO_DMAWCOUNT 0x000f0000
265#define BONITO_IDECOPGO_DMAWCOUNT_SHIFT 16
266
267#define BONITO_IDECOPCTRL_DMA_STARTBIT 0x80000000
268#define BONITO_IDECOPCTRL_DMA_RSTBIT 0x40000000
269
270/* DRAM - sdCfg */
271
272#define BONITO_SDCFG_AROWBITS 0x00000003
273#define BONITO_SDCFG_AROWBITS_SHIFT 0
274#define BONITO_SDCFG_ACOLBITS 0x0000000c
275#define BONITO_SDCFG_ACOLBITS_SHIFT 2
276#define BONITO_SDCFG_ABANKBIT 0x00000010
277#define BONITO_SDCFG_ASIDES 0x00000020
278#define BONITO_SDCFG_AABSENT 0x00000040
279#define BONITO_SDCFG_AWIDTH64 0x00000080
280
281#define BONITO_SDCFG_BROWBITS 0x00000300
282#define BONITO_SDCFG_BROWBITS_SHIFT 8
283#define BONITO_SDCFG_BCOLBITS 0x00000c00
284#define BONITO_SDCFG_BCOLBITS_SHIFT 10
285#define BONITO_SDCFG_BBANKBIT 0x00001000
286#define BONITO_SDCFG_BSIDES 0x00002000
287#define BONITO_SDCFG_BABSENT 0x00004000
288#define BONITO_SDCFG_BWIDTH64 0x00008000
289
290#define BONITO_SDCFG_EXTRDDATA 0x00010000
291#define BONITO_SDCFG_EXTRASCAS 0x00020000
292#define BONITO_SDCFG_EXTPRECH 0x00040000
293#define BONITO_SDCFG_EXTRASWIDTH 0x00180000
294#define BONITO_SDCFG_EXTRASWIDTH_SHIFT 19
295/* Changed by RPF 11-9-00 */
296#define BONITO_SDCFG_DRAMMODESET 0x00200000
297/* --- */
298#define BONITO_SDCFG_DRAMEXTREGS 0x00400000
299#define BONITO_SDCFG_DRAMPARITY 0x00800000
300/* Added by RPF 11-9-00 */
301#define BONITO_SDCFG_DRAMBURSTLEN 0x03000000
302#define BONITO_SDCFG_DRAMBURSTLEN_SHIFT 24
303#define BONITO_SDCFG_DRAMMODESET_DONE 0x80000000
304/* --- */
305
306/* PCI Cache - pciCacheCtrl */
307
308#define BONITO_PCICACHECTRL_CACHECMD 0x00000007
309#define BONITO_PCICACHECTRL_CACHECMD_SHIFT 0
310#define BONITO_PCICACHECTRL_CACHECMDLINE 0x00000018
311#define BONITO_PCICACHECTRL_CACHECMDLINE_SHIFT 3
312#define BONITO_PCICACHECTRL_CMDEXEC 0x00000020
313
314#define BONITO_PCICACHECTRL_IOBCCOH_PRES 0x00000100
315#define BONITO_PCICACHECTRL_IOBCCOH_EN 0x00000200
316#define BONITO_PCICACHECTRL_CPUCOH_PRES 0x00000400
317#define BONITO_PCICACHECTRL_CPUCOH_EN 0x00000800
318
319#define BONITO_IODEVCFG_BUFFBIT_CS0 0x00000001
320#define BONITO_IODEVCFG_SPEEDBIT_CS0 0x00000002
321#define BONITO_IODEVCFG_MOREABITS_CS0 0x00000004
322
323#define BONITO_IODEVCFG_BUFFBIT_CS1 0x00000008
324#define BONITO_IODEVCFG_SPEEDBIT_CS1 0x00000010
325#define BONITO_IODEVCFG_MOREABITS_CS1 0x00000020
326
327#define BONITO_IODEVCFG_BUFFBIT_CS2 0x00000040
328#define BONITO_IODEVCFG_SPEEDBIT_CS2 0x00000080
329#define BONITO_IODEVCFG_MOREABITS_CS2 0x00000100
330
331#define BONITO_IODEVCFG_BUFFBIT_CS3 0x00000200
332#define BONITO_IODEVCFG_SPEEDBIT_CS3 0x00000400
333#define BONITO_IODEVCFG_MOREABITS_CS3 0x00000800
334
335#define BONITO_IODEVCFG_BUFFBIT_IDE 0x00001000
336#define BONITO_IODEVCFG_SPEEDBIT_IDE 0x00002000
337#define BONITO_IODEVCFG_WORDSWAPBIT_IDE 0x00004000
338#define BONITO_IODEVCFG_MODEBIT_IDE 0x00008000
339#define BONITO_IODEVCFG_DMAON_IDE 0x001f0000
340#define BONITO_IODEVCFG_DMAON_IDE_SHIFT 16
341#define BONITO_IODEVCFG_DMAOFF_IDE 0x01e00000
342#define BONITO_IODEVCFG_DMAOFF_IDE_SHIFT 21
343#define BONITO_IODEVCFG_EPROMSPLIT 0x02000000
344/* Added by RPF 11-9-00 */
345#define BONITO_IODEVCFG_CPUCLOCKPERIOD 0xfc000000
346#define BONITO_IODEVCFG_CPUCLOCKPERIOD_SHIFT 26
347/* --- */
348
349/* gpio */
350#define BONITO_GPIO_GPIOW 0x000003ff
351#define BONITO_GPIO_GPIOW_SHIFT 0
352#define BONITO_GPIO_GPIOR 0x01ff0000
353#define BONITO_GPIO_GPIOR_SHIFT 16
354#define BONITO_GPIO_GPINR 0xfe000000
355#define BONITO_GPIO_GPINR_SHIFT 25
356#define BONITO_GPIO_IOW(N) (1<<(BONITO_GPIO_GPIOW_SHIFT+(N)))
357#define BONITO_GPIO_IOR(N) (1<<(BONITO_GPIO_GPIOR_SHIFT+(N)))
358#define BONITO_GPIO_INR(N) (1<<(BONITO_GPIO_GPINR_SHIFT+(N)))
359
360/* ICU */
361#define BONITO_ICU_MBOXES 0x0000000f
362#define BONITO_ICU_MBOXES_SHIFT 0
363#define BONITO_ICU_DMARDY 0x00000010
364#define BONITO_ICU_DMAEMPTY 0x00000020
365#define BONITO_ICU_COPYRDY 0x00000040
366#define BONITO_ICU_COPYEMPTY 0x00000080
367#define BONITO_ICU_COPYERR 0x00000100
368#define BONITO_ICU_PCIIRQ 0x00000200
369#define BONITO_ICU_MASTERERR 0x00000400
370#define BONITO_ICU_SYSTEMERR 0x00000800
371#define BONITO_ICU_DRAMPERR 0x00001000
372#define BONITO_ICU_RETRYERR 0x00002000
373#define BONITO_ICU_GPIOS 0x01ff0000
374#define BONITO_ICU_GPIOS_SHIFT 16
375#define BONITO_ICU_GPINS 0x7e000000
376#define BONITO_ICU_GPINS_SHIFT 25
377#define BONITO_ICU_MBOX(N) (1<<(BONITO_ICU_MBOXES_SHIFT+(N)))
378#define BONITO_ICU_GPIO(N) (1<<(BONITO_ICU_GPIOS_SHIFT+(N)))
379#define BONITO_ICU_GPIN(N) (1<<(BONITO_ICU_GPINS_SHIFT+(N)))
380
381/* pcimap */
382
383#define BONITO_PCIMAP_PCIMAP_LO0 0x0000003f
384#define BONITO_PCIMAP_PCIMAP_LO0_SHIFT 0
385#define BONITO_PCIMAP_PCIMAP_LO1 0x00000fc0
386#define BONITO_PCIMAP_PCIMAP_LO1_SHIFT 6
387#define BONITO_PCIMAP_PCIMAP_LO2 0x0003f000
388#define BONITO_PCIMAP_PCIMAP_LO2_SHIFT 12
389#define BONITO_PCIMAP_PCIMAP_2 0x00040000
390#define BONITO_PCIMAP_WIN(WIN, ADDR) ((((ADDR)>>26) & BONITO_PCIMAP_PCIMAP_LO0) << ((WIN)*6))
391
392#define BONITO_PCIMAP_WINSIZE (1<<26)
393#define BONITO_PCIMAP_WINOFFSET(ADDR) ((ADDR) & (BONITO_PCIMAP_WINSIZE - 1))
394#define BONITO_PCIMAP_WINBASE(ADDR) ((ADDR) << 26)
395
396/* pcimembaseCfg */
397
398#define BONITO_PCIMEMBASECFG_MASK 0xf0000000
399#define BONITO_PCIMEMBASECFG_MEMBASE0_MASK 0x0000001f
400#define BONITO_PCIMEMBASECFG_MEMBASE0_MASK_SHIFT 0
401#define BONITO_PCIMEMBASECFG_MEMBASE0_TRANS 0x000003e0
402#define BONITO_PCIMEMBASECFG_MEMBASE0_TRANS_SHIFT 5
403#define BONITO_PCIMEMBASECFG_MEMBASE0_CACHED 0x00000400
404#define BONITO_PCIMEMBASECFG_MEMBASE0_IO 0x00000800
405
406#define BONITO_PCIMEMBASECFG_MEMBASE1_MASK 0x0001f000
407#define BONITO_PCIMEMBASECFG_MEMBASE1_MASK_SHIFT 12
408#define BONITO_PCIMEMBASECFG_MEMBASE1_TRANS 0x003e0000
409#define BONITO_PCIMEMBASECFG_MEMBASE1_TRANS_SHIFT 17
410#define BONITO_PCIMEMBASECFG_MEMBASE1_CACHED 0x00400000
411#define BONITO_PCIMEMBASECFG_MEMBASE1_IO 0x00800000
412
413#define BONITO_PCIMEMBASECFG_ASHIFT 23
414#define BONITO_PCIMEMBASECFG_AMASK 0x007fffff
415#define BONITO_PCIMEMBASECFGSIZE(WIN, SIZE) (((~((SIZE)-1))>>(BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK_SHIFT)) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK)
416#define BONITO_PCIMEMBASECFGBASE(WIN, BASE) (((BASE)>>(BONITO_PCIMEMBASECFG_ASHIFT-BONITO_PCIMEMBASECFG_MEMBASE##WIN##_TRANS_SHIFT)) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_TRANS)
417
418#define BONITO_PCIMEMBASECFG_SIZE(WIN, CFG) (((((~(CFG)) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK)) << (BONITO_PCIMEMBASECFG_ASHIFT - BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK_SHIFT)) | BONITO_PCIMEMBASECFG_AMASK)
419
420
421#define BONITO_PCIMEMBASECFG_ADDRMASK(WIN, CFG) ((((CFG) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK) >> BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK_SHIFT) << BONITO_PCIMEMBASECFG_ASHIFT)
422#define BONITO_PCIMEMBASECFG_ADDRMASK(WIN, CFG) ((((CFG) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK) >> BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK_SHIFT) << BONITO_PCIMEMBASECFG_ASHIFT)
423#define BONITO_PCIMEMBASECFG_ADDRTRANS(WIN, CFG) ((((CFG) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_TRANS) >> BONITO_PCIMEMBASECFG_MEMBASE##WIN##_TRANS_SHIFT) << BONITO_PCIMEMBASECFG_ASHIFT)
424
425#define BONITO_PCITOPHYS(WIN, ADDR, CFG) ( \
426 (((ADDR) & (~(BONITO_PCIMEMBASECFG_MASK))) & (~(BONITO_PCIMEMBASECFG_ADDRMASK(WIN, CFG)))) | \
427 (BONITO_PCIMEMBASECFG_ADDRTRANS(WIN, CFG)) \
428 )
429
430/* PCICmd */
431
432#define BONITO_PCICMD_MEMEN 0x00000002
433#define BONITO_PCICMD_MSTREN 0x00000004
434
435
436#endif /* _ASM_MIPS_BOARDS_BONITO64_H */
diff --git a/arch/mips/include/asm/mips-boards/generic.h b/arch/mips/include/asm/mips-boards/generic.h
new file mode 100644
index 000000000000..7f0b034dd9a5
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/generic.h
@@ -0,0 +1,104 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Defines of the MIPS boards specific address-MAP, registers, etc.
19 */
20#ifndef __ASM_MIPS_BOARDS_GENERIC_H
21#define __ASM_MIPS_BOARDS_GENERIC_H
22
23#include <asm/addrspace.h>
24#include <asm/byteorder.h>
25#include <asm/mips-boards/bonito64.h>
26
27/*
28 * Display register base.
29 */
30#define ASCII_DISPLAY_WORD_BASE 0x1f000410
31#define ASCII_DISPLAY_POS_BASE 0x1f000418
32
33
34/*
35 * Yamon Prom print address.
36 */
37#define YAMON_PROM_PRINT_ADDR 0x1fc00504
38
39
40/*
41 * Reset register.
42 */
43#define SOFTRES_REG 0x1f000500
44#define GORESET 0x42
45
46/*
47 * Revision register.
48 */
49#define MIPS_REVISION_REG 0x1fc00010
50#define MIPS_REVISION_CORID_QED_RM5261 0
51#define MIPS_REVISION_CORID_CORE_LV 1
52#define MIPS_REVISION_CORID_BONITO64 2
53#define MIPS_REVISION_CORID_CORE_20K 3
54#define MIPS_REVISION_CORID_CORE_FPGA 4
55#define MIPS_REVISION_CORID_CORE_MSC 5
56#define MIPS_REVISION_CORID_CORE_EMUL 6
57#define MIPS_REVISION_CORID_CORE_FPGA2 7
58#define MIPS_REVISION_CORID_CORE_FPGAR2 8
59#define MIPS_REVISION_CORID_CORE_FPGA3 9
60#define MIPS_REVISION_CORID_CORE_24K 10
61#define MIPS_REVISION_CORID_CORE_FPGA4 11
62#define MIPS_REVISION_CORID_CORE_FPGA5 12
63
64/**** Artificial corid defines ****/
65/*
66 * CoreEMUL with Bonito System Controller is treated like a Core20K
67 * CoreEMUL with SOC-it 101 System Controller is treated like a CoreMSC
68 */
69#define MIPS_REVISION_CORID_CORE_EMUL_BON -1
70#define MIPS_REVISION_CORID_CORE_EMUL_MSC -2
71
72#define MIPS_REVISION_CORID (((*(volatile u32 *)ioremap(MIPS_REVISION_REG, 4)) >> 10) & 0x3f)
73
74extern int mips_revision_corid;
75
76#define MIPS_REVISION_SCON_OTHER 0
77#define MIPS_REVISION_SCON_SOCITSC 1
78#define MIPS_REVISION_SCON_SOCITSCP 2
79
80/* Artificial SCON defines for MIPS_REVISION_SCON_OTHER */
81#define MIPS_REVISION_SCON_UNKNOWN -1
82#define MIPS_REVISION_SCON_GT64120 -2
83#define MIPS_REVISION_SCON_BONITO -3
84#define MIPS_REVISION_SCON_BRTL -4
85#define MIPS_REVISION_SCON_SOCIT -5
86#define MIPS_REVISION_SCON_ROCIT -6
87
88#define MIPS_REVISION_SCONID (((*(volatile u32 *)ioremap(MIPS_REVISION_REG, 4)) >> 24) & 0xff)
89
90extern int mips_revision_sconid;
91
92extern void mips_reboot_setup(void);
93
94#ifdef CONFIG_PCI
95extern void mips_pcibios_init(void);
96#else
97#define mips_pcibios_init() do { } while (0)
98#endif
99
100#ifdef CONFIG_KGDB
101extern void kgdb_config(void);
102#endif
103
104#endif /* __ASM_MIPS_BOARDS_GENERIC_H */
diff --git a/arch/mips/include/asm/mips-boards/launch.h b/arch/mips/include/asm/mips-boards/launch.h
new file mode 100644
index 000000000000..d8ae7f95a522
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/launch.h
@@ -0,0 +1,35 @@
1/*
2 *
3 */
4
5#ifndef _ASSEMBLER_
6
7struct cpulaunch {
8 unsigned long pc;
9 unsigned long gp;
10 unsigned long sp;
11 unsigned long a0;
12 unsigned long _pad[3]; /* pad to cache line size to avoid thrashing */
13 unsigned long flags;
14};
15
16#else
17
18#define LOG2CPULAUNCH 5
19#define LAUNCH_PC 0
20#define LAUNCH_GP 4
21#define LAUNCH_SP 8
22#define LAUNCH_A0 12
23#define LAUNCH_FLAGS 28
24
25#endif
26
27#define LAUNCH_FREADY 1
28#define LAUNCH_FGO 2
29#define LAUNCH_FGONE 4
30
31#define CPULAUNCH 0x00000f00
32#define NCPULAUNCH 8
33
34/* Polling period in count cycles for secondary CPU's */
35#define LAUNCHPERIOD 10000
diff --git a/arch/mips/include/asm/mips-boards/malta.h b/arch/mips/include/asm/mips-boards/malta.h
new file mode 100644
index 000000000000..c1891578fa65
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/malta.h
@@ -0,0 +1,102 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Defines of the Malta board specific address-MAP, registers, etc.
19 */
20#ifndef __ASM_MIPS_BOARDS_MALTA_H
21#define __ASM_MIPS_BOARDS_MALTA_H
22
23#include <asm/addrspace.h>
24#include <asm/io.h>
25#include <asm/mips-boards/msc01_pci.h>
26#include <asm/gt64120.h>
27
28/* Mips interrupt controller found in SOCit variations */
29#define MIPS_MSC01_IC_REG_BASE 0x1bc40000
30#define MIPS_SOCITSC_IC_REG_BASE 0x1ffa0000
31
32/*
33 * Malta I/O ports base address for the Galileo GT64120 and Algorithmics
34 * Bonito system controllers.
35 */
36#define MALTA_GT_PORT_BASE get_gt_port_base(GT_PCI0IOLD_OFS)
37#define MALTA_BONITO_PORT_BASE ((unsigned long)ioremap (0x1fd00000, 0x10000))
38#define MALTA_MSC_PORT_BASE get_msc_port_base(MSC01_PCI_SC2PIOBASL)
39
40static inline unsigned long get_gt_port_base(unsigned long reg)
41{
42 unsigned long addr;
43 addr = GT_READ(reg);
44 return (unsigned long) ioremap (((addr & 0xffff) << 21), 0x10000);
45}
46
47static inline unsigned long get_msc_port_base(unsigned long reg)
48{
49 unsigned long addr;
50 MSC_READ(reg, addr);
51 return (unsigned long) ioremap(addr, 0x10000);
52}
53
54/*
55 * GCMP Specific definitions
56 */
57#define GCMP_BASE_ADDR 0x1fbf8000
58#define GCMP_ADDRSPACE_SZ (256 * 1024)
59
60/*
61 * GIC Specific definitions
62 */
63#define GIC_BASE_ADDR 0x1bdc0000
64#define GIC_ADDRSPACE_SZ (128 * 1024)
65
66/*
67 * MSC01 BIU Specific definitions
68 * FIXME : These should be elsewhere ?
69 */
70#define MSC01_BIU_REG_BASE 0x1bc80000
71#define MSC01_BIU_ADDRSPACE_SZ (256 * 1024)
72#define MSC01_SC_CFG_OFS 0x0110
73#define MSC01_SC_CFG_GICPRES_MSK 0x00000004
74#define MSC01_SC_CFG_GICPRES_SHF 2
75#define MSC01_SC_CFG_GICENA_SHF 3
76
77/*
78 * Malta RTC-device indirect register access.
79 */
80#define MALTA_RTC_ADR_REG 0x70
81#define MALTA_RTC_DAT_REG 0x71
82
83/*
84 * Malta SMSC FDC37M817 Super I/O Controller register.
85 */
86#define SMSC_CONFIG_REG 0x3f0
87#define SMSC_DATA_REG 0x3f1
88
89#define SMSC_CONFIG_DEVNUM 0x7
90#define SMSC_CONFIG_ACTIVATE 0x30
91#define SMSC_CONFIG_ENTER 0x55
92#define SMSC_CONFIG_EXIT 0xaa
93
94#define SMSC_CONFIG_DEVNUM_FLOPPY 0
95
96#define SMSC_CONFIG_ACTIVATE_ENABLE 1
97
98#define SMSC_WRITE(x, a) outb(x, a)
99
100#define MALTA_JMPRS_REG 0x1f000210
101
102#endif /* __ASM_MIPS_BOARDS_MALTA_H */
diff --git a/arch/mips/include/asm/mips-boards/maltaint.h b/arch/mips/include/asm/mips-boards/maltaint.h
new file mode 100644
index 000000000000..cea872fc6f5c
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/maltaint.h
@@ -0,0 +1,110 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * ########################################################################
6 *
7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 *
20 * ########################################################################
21 *
22 * Defines for the Malta interrupt controller.
23 *
24 */
25#ifndef _MIPS_MALTAINT_H
26#define _MIPS_MALTAINT_H
27
28#include <irq.h>
29
30/*
31 * Interrupts 0..15 are used for Malta ISA compatible interrupts
32 */
33#define MALTA_INT_BASE 0
34
35/* CPU interrupt offsets */
36#define MIPSCPU_INT_SW0 0
37#define MIPSCPU_INT_SW1 1
38#define MIPSCPU_INT_MB0 2
39#define MIPSCPU_INT_I8259A MIPSCPU_INT_MB0
40#define MIPSCPU_INT_MB1 3
41#define MIPSCPU_INT_SMI MIPSCPU_INT_MB1
42#define MIPSCPU_INT_IPI0 MIPSCPU_INT_MB1 /* GIC IPI */
43#define MIPSCPU_INT_MB2 4
44#define MIPSCPU_INT_IPI1 MIPSCPU_INT_MB2 /* GIC IPI */
45#define MIPSCPU_INT_MB3 5
46#define MIPSCPU_INT_COREHI MIPSCPU_INT_MB3
47#define MIPSCPU_INT_MB4 6
48#define MIPSCPU_INT_CORELO MIPSCPU_INT_MB4
49
50/*
51 * Interrupts 64..127 are used for Soc-it Classic interrupts
52 */
53#define MSC01C_INT_BASE 64
54
55/* SOC-it Classic interrupt offsets */
56#define MSC01C_INT_TMR 0
57#define MSC01C_INT_PCI 1
58
59/*
60 * Interrupts 64..127 are used for Soc-it EIC interrupts
61 */
62#define MSC01E_INT_BASE 64
63
64/* SOC-it EIC interrupt offsets */
65#define MSC01E_INT_SW0 1
66#define MSC01E_INT_SW1 2
67#define MSC01E_INT_MB0 3
68#define MSC01E_INT_I8259A MSC01E_INT_MB0
69#define MSC01E_INT_MB1 4
70#define MSC01E_INT_SMI MSC01E_INT_MB1
71#define MSC01E_INT_MB2 5
72#define MSC01E_INT_MB3 6
73#define MSC01E_INT_COREHI MSC01E_INT_MB3
74#define MSC01E_INT_MB4 7
75#define MSC01E_INT_CORELO MSC01E_INT_MB4
76#define MSC01E_INT_TMR 8
77#define MSC01E_INT_PCI 9
78#define MSC01E_INT_PERFCTR 10
79#define MSC01E_INT_CPUCTR 11
80
81/* GIC's Nomenclature for Core Interrupt Pins on the Malta */
82#define GIC_CPU_INT0 0 /* Core Interrupt 2 */
83#define GIC_CPU_INT1 1 /* . */
84#define GIC_CPU_INT2 2 /* . */
85#define GIC_CPU_INT3 3 /* . */
86#define GIC_CPU_INT4 4 /* . */
87#define GIC_CPU_INT5 5 /* Core Interrupt 5 */
88
89#define GIC_EXT_INTR(x) x
90
91/* Dummy data */
92#define X 0xdead
93
94/* External Interrupts used for IPI */
95#define GIC_IPI_EXT_INTR_RESCHED_VPE0 16
96#define GIC_IPI_EXT_INTR_CALLFNC_VPE0 17
97#define GIC_IPI_EXT_INTR_RESCHED_VPE1 18
98#define GIC_IPI_EXT_INTR_CALLFNC_VPE1 19
99#define GIC_IPI_EXT_INTR_RESCHED_VPE2 20
100#define GIC_IPI_EXT_INTR_CALLFNC_VPE2 21
101#define GIC_IPI_EXT_INTR_RESCHED_VPE3 22
102#define GIC_IPI_EXT_INTR_CALLFNC_VPE3 23
103
104#define MIPS_GIC_IRQ_BASE (MIPS_CPU_IRQ_BASE + 8)
105
106#ifndef __ASSEMBLY__
107extern void maltaint_init(void);
108#endif
109
110#endif /* !(_MIPS_MALTAINT_H) */
diff --git a/arch/mips/include/asm/mips-boards/msc01_pci.h b/arch/mips/include/asm/mips-boards/msc01_pci.h
new file mode 100644
index 000000000000..e036b7dd6deb
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/msc01_pci.h
@@ -0,0 +1,258 @@
1/*
2 * PCI Register definitions for the MIPS System Controller.
3 *
4 * Copyright (C) 2002, 2005 MIPS Technologies, Inc. All rights reserved.
5 * Authors: Carsten Langgaard <carstenl@mips.com>
6 * Maciej W. Rozycki <macro@mips.com>
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#ifndef __ASM_MIPS_BOARDS_MSC01_PCI_H
13#define __ASM_MIPS_BOARDS_MSC01_PCI_H
14
15/*
16 * Register offset addresses
17 */
18
19#define MSC01_PCI_ID_OFS 0x0000
20#define MSC01_PCI_SC2PMBASL_OFS 0x0208
21#define MSC01_PCI_SC2PMMSKL_OFS 0x0218
22#define MSC01_PCI_SC2PMMAPL_OFS 0x0228
23#define MSC01_PCI_SC2PIOBASL_OFS 0x0248
24#define MSC01_PCI_SC2PIOMSKL_OFS 0x0258
25#define MSC01_PCI_SC2PIOMAPL_OFS 0x0268
26#define MSC01_PCI_P2SCMSKL_OFS 0x0308
27#define MSC01_PCI_P2SCMAPL_OFS 0x0318
28#define MSC01_PCI_INTCFG_OFS 0x0600
29#define MSC01_PCI_INTSTAT_OFS 0x0608
30#define MSC01_PCI_CFGADDR_OFS 0x0610
31#define MSC01_PCI_CFGDATA_OFS 0x0618
32#define MSC01_PCI_IACK_OFS 0x0620
33#define MSC01_PCI_HEAD0_OFS 0x2000 /* DevID, VendorID */
34#define MSC01_PCI_HEAD1_OFS 0x2008 /* Status, Command */
35#define MSC01_PCI_HEAD2_OFS 0x2010 /* Class code, RevID */
36#define MSC01_PCI_HEAD3_OFS 0x2018 /* bist, header, latency */
37#define MSC01_PCI_HEAD4_OFS 0x2020 /* BAR 0 */
38#define MSC01_PCI_HEAD5_OFS 0x2028 /* BAR 1 */
39#define MSC01_PCI_HEAD6_OFS 0x2030 /* BAR 2 */
40#define MSC01_PCI_HEAD7_OFS 0x2038 /* BAR 3 */
41#define MSC01_PCI_HEAD8_OFS 0x2040 /* BAR 4 */
42#define MSC01_PCI_HEAD9_OFS 0x2048 /* BAR 5 */
43#define MSC01_PCI_HEAD10_OFS 0x2050 /* CardBus CIS Ptr */
44#define MSC01_PCI_HEAD11_OFS 0x2058 /* SubSystem ID, -VendorID */
45#define MSC01_PCI_HEAD12_OFS 0x2060 /* ROM BAR */
46#define MSC01_PCI_HEAD13_OFS 0x2068 /* Capabilities ptr */
47#define MSC01_PCI_HEAD14_OFS 0x2070 /* reserved */
48#define MSC01_PCI_HEAD15_OFS 0x2078 /* Maxl, ming, intpin, int */
49#define MSC01_PCI_BAR0_OFS 0x2220
50#define MSC01_PCI_CFG_OFS 0x2380
51#define MSC01_PCI_SWAP_OFS 0x2388
52
53
54/*****************************************************************************
55 * Register encodings
56 ****************************************************************************/
57
58#define MSC01_PCI_ID_ID_SHF 16
59#define MSC01_PCI_ID_ID_MSK 0x00ff0000
60#define MSC01_PCI_ID_ID_HOSTBRIDGE 82
61#define MSC01_PCI_ID_MAR_SHF 8
62#define MSC01_PCI_ID_MAR_MSK 0x0000ff00
63#define MSC01_PCI_ID_MIR_SHF 0
64#define MSC01_PCI_ID_MIR_MSK 0x000000ff
65
66#define MSC01_PCI_SC2PMBASL_BAS_SHF 24
67#define MSC01_PCI_SC2PMBASL_BAS_MSK 0xff000000
68
69#define MSC01_PCI_SC2PMMSKL_MSK_SHF 24
70#define MSC01_PCI_SC2PMMSKL_MSK_MSK 0xff000000
71
72#define MSC01_PCI_SC2PMMAPL_MAP_SHF 24
73#define MSC01_PCI_SC2PMMAPL_MAP_MSK 0xff000000
74
75#define MSC01_PCI_SC2PIOBASL_BAS_SHF 24
76#define MSC01_PCI_SC2PIOBASL_BAS_MSK 0xff000000
77
78#define MSC01_PCI_SC2PIOMSKL_MSK_SHF 24
79#define MSC01_PCI_SC2PIOMSKL_MSK_MSK 0xff000000
80
81#define MSC01_PCI_SC2PIOMAPL_MAP_SHF 24
82#define MSC01_PCI_SC2PIOMAPL_MAP_MSK 0xff000000
83
84#define MSC01_PCI_P2SCMSKL_MSK_SHF 24
85#define MSC01_PCI_P2SCMSKL_MSK_MSK 0xff000000
86
87#define MSC01_PCI_P2SCMAPL_MAP_SHF 24
88#define MSC01_PCI_P2SCMAPL_MAP_MSK 0xff000000
89
90#define MSC01_PCI_INTCFG_RST_SHF 10
91#define MSC01_PCI_INTCFG_RST_MSK 0x00000400
92#define MSC01_PCI_INTCFG_RST_BIT 0x00000400
93#define MSC01_PCI_INTCFG_MWE_SHF 9
94#define MSC01_PCI_INTCFG_MWE_MSK 0x00000200
95#define MSC01_PCI_INTCFG_MWE_BIT 0x00000200
96#define MSC01_PCI_INTCFG_DTO_SHF 8
97#define MSC01_PCI_INTCFG_DTO_MSK 0x00000100
98#define MSC01_PCI_INTCFG_DTO_BIT 0x00000100
99#define MSC01_PCI_INTCFG_MA_SHF 7
100#define MSC01_PCI_INTCFG_MA_MSK 0x00000080
101#define MSC01_PCI_INTCFG_MA_BIT 0x00000080
102#define MSC01_PCI_INTCFG_TA_SHF 6
103#define MSC01_PCI_INTCFG_TA_MSK 0x00000040
104#define MSC01_PCI_INTCFG_TA_BIT 0x00000040
105#define MSC01_PCI_INTCFG_RTY_SHF 5
106#define MSC01_PCI_INTCFG_RTY_MSK 0x00000020
107#define MSC01_PCI_INTCFG_RTY_BIT 0x00000020
108#define MSC01_PCI_INTCFG_MWP_SHF 4
109#define MSC01_PCI_INTCFG_MWP_MSK 0x00000010
110#define MSC01_PCI_INTCFG_MWP_BIT 0x00000010
111#define MSC01_PCI_INTCFG_MRP_SHF 3
112#define MSC01_PCI_INTCFG_MRP_MSK 0x00000008
113#define MSC01_PCI_INTCFG_MRP_BIT 0x00000008
114#define MSC01_PCI_INTCFG_SWP_SHF 2
115#define MSC01_PCI_INTCFG_SWP_MSK 0x00000004
116#define MSC01_PCI_INTCFG_SWP_BIT 0x00000004
117#define MSC01_PCI_INTCFG_SRP_SHF 1
118#define MSC01_PCI_INTCFG_SRP_MSK 0x00000002
119#define MSC01_PCI_INTCFG_SRP_BIT 0x00000002
120#define MSC01_PCI_INTCFG_SE_SHF 0
121#define MSC01_PCI_INTCFG_SE_MSK 0x00000001
122#define MSC01_PCI_INTCFG_SE_BIT 0x00000001
123
124#define MSC01_PCI_INTSTAT_RST_SHF 10
125#define MSC01_PCI_INTSTAT_RST_MSK 0x00000400
126#define MSC01_PCI_INTSTAT_RST_BIT 0x00000400
127#define MSC01_PCI_INTSTAT_MWE_SHF 9
128#define MSC01_PCI_INTSTAT_MWE_MSK 0x00000200
129#define MSC01_PCI_INTSTAT_MWE_BIT 0x00000200
130#define MSC01_PCI_INTSTAT_DTO_SHF 8
131#define MSC01_PCI_INTSTAT_DTO_MSK 0x00000100
132#define MSC01_PCI_INTSTAT_DTO_BIT 0x00000100
133#define MSC01_PCI_INTSTAT_MA_SHF 7
134#define MSC01_PCI_INTSTAT_MA_MSK 0x00000080
135#define MSC01_PCI_INTSTAT_MA_BIT 0x00000080
136#define MSC01_PCI_INTSTAT_TA_SHF 6
137#define MSC01_PCI_INTSTAT_TA_MSK 0x00000040
138#define MSC01_PCI_INTSTAT_TA_BIT 0x00000040
139#define MSC01_PCI_INTSTAT_RTY_SHF 5
140#define MSC01_PCI_INTSTAT_RTY_MSK 0x00000020
141#define MSC01_PCI_INTSTAT_RTY_BIT 0x00000020
142#define MSC01_PCI_INTSTAT_MWP_SHF 4
143#define MSC01_PCI_INTSTAT_MWP_MSK 0x00000010
144#define MSC01_PCI_INTSTAT_MWP_BIT 0x00000010
145#define MSC01_PCI_INTSTAT_MRP_SHF 3
146#define MSC01_PCI_INTSTAT_MRP_MSK 0x00000008
147#define MSC01_PCI_INTSTAT_MRP_BIT 0x00000008
148#define MSC01_PCI_INTSTAT_SWP_SHF 2
149#define MSC01_PCI_INTSTAT_SWP_MSK 0x00000004
150#define MSC01_PCI_INTSTAT_SWP_BIT 0x00000004
151#define MSC01_PCI_INTSTAT_SRP_SHF 1
152#define MSC01_PCI_INTSTAT_SRP_MSK 0x00000002
153#define MSC01_PCI_INTSTAT_SRP_BIT 0x00000002
154#define MSC01_PCI_INTSTAT_SE_SHF 0
155#define MSC01_PCI_INTSTAT_SE_MSK 0x00000001
156#define MSC01_PCI_INTSTAT_SE_BIT 0x00000001
157
158#define MSC01_PCI_CFGADDR_BNUM_SHF 16
159#define MSC01_PCI_CFGADDR_BNUM_MSK 0x00ff0000
160#define MSC01_PCI_CFGADDR_DNUM_SHF 11
161#define MSC01_PCI_CFGADDR_DNUM_MSK 0x0000f800
162#define MSC01_PCI_CFGADDR_FNUM_SHF 8
163#define MSC01_PCI_CFGADDR_FNUM_MSK 0x00000700
164#define MSC01_PCI_CFGADDR_RNUM_SHF 2
165#define MSC01_PCI_CFGADDR_RNUM_MSK 0x000000fc
166
167#define MSC01_PCI_CFGDATA_DATA_SHF 0
168#define MSC01_PCI_CFGDATA_DATA_MSK 0xffffffff
169
170/* The defines below are ONLY valid for a MEM bar! */
171#define MSC01_PCI_BAR0_SIZE_SHF 4
172#define MSC01_PCI_BAR0_SIZE_MSK 0xfffffff0
173#define MSC01_PCI_BAR0_P_SHF 3
174#define MSC01_PCI_BAR0_P_MSK 0x00000008
175#define MSC01_PCI_BAR0_P_BIT MSC01_PCI_BAR0_P_MSK
176#define MSC01_PCI_BAR0_D_SHF 1
177#define MSC01_PCI_BAR0_D_MSK 0x00000006
178#define MSC01_PCI_BAR0_T_SHF 0
179#define MSC01_PCI_BAR0_T_MSK 0x00000001
180#define MSC01_PCI_BAR0_T_BIT MSC01_PCI_BAR0_T_MSK
181
182
183#define MSC01_PCI_CFG_RA_SHF 17
184#define MSC01_PCI_CFG_RA_MSK 0x00020000
185#define MSC01_PCI_CFG_RA_BIT MSC01_PCI_CFG_RA_MSK
186#define MSC01_PCI_CFG_G_SHF 16
187#define MSC01_PCI_CFG_G_MSK 0x00010000
188#define MSC01_PCI_CFG_G_BIT MSC01_PCI_CFG_G_MSK
189#define MSC01_PCI_CFG_EN_SHF 15
190#define MSC01_PCI_CFG_EN_MSK 0x00008000
191#define MSC01_PCI_CFG_EN_BIT MSC01_PCI_CFG_EN_MSK
192#define MSC01_PCI_CFG_MAXRTRY_SHF 0
193#define MSC01_PCI_CFG_MAXRTRY_MSK 0x00000fff
194
195#define MSC01_PCI_SWAP_IO_SHF 18
196#define MSC01_PCI_SWAP_IO_MSK 0x000c0000
197#define MSC01_PCI_SWAP_MEM_SHF 16
198#define MSC01_PCI_SWAP_MEM_MSK 0x00030000
199#define MSC01_PCI_SWAP_BAR0_SHF 0
200#define MSC01_PCI_SWAP_BAR0_MSK 0x00000003
201#define MSC01_PCI_SWAP_NOSWAP 0
202#define MSC01_PCI_SWAP_BYTESWAP 1
203
204/*
205 * MIPS System controller PCI register base.
206 *
207 * FIXME - are these macros specific to Malta and co or to the MSC? If the
208 * latter, they should be moved elsewhere.
209 */
210#define MIPS_MSC01_PCI_REG_BASE 0x1bd00000
211#define MIPS_SOCITSC_PCI_REG_BASE 0x1ff10000
212
213extern unsigned long _pcictrl_msc;
214
215#define MSC01_PCI_REG_BASE _pcictrl_msc
216
217#define MSC_WRITE(reg, data) do { *(volatile u32 *)(reg) = data; } while (0)
218#define MSC_READ(reg, data) do { data = *(volatile u32 *)(reg); } while (0)
219
220/*
221 * Registers absolute addresses
222 */
223
224#define MSC01_PCI_ID (MSC01_PCI_REG_BASE + MSC01_PCI_ID_OFS)
225#define MSC01_PCI_SC2PMBASL (MSC01_PCI_REG_BASE + MSC01_PCI_SC2PMBASL_OFS)
226#define MSC01_PCI_SC2PMMSKL (MSC01_PCI_REG_BASE + MSC01_PCI_SC2PMMSKL_OFS)
227#define MSC01_PCI_SC2PMMAPL (MSC01_PCI_REG_BASE + MSC01_PCI_SC2PMMAPL_OFS)
228#define MSC01_PCI_SC2PIOBASL (MSC01_PCI_REG_BASE + MSC01_PCI_SC2PIOBASL_OFS)
229#define MSC01_PCI_SC2PIOMSKL (MSC01_PCI_REG_BASE + MSC01_PCI_SC2PIOMSKL_OFS)
230#define MSC01_PCI_SC2PIOMAPL (MSC01_PCI_REG_BASE + MSC01_PCI_SC2PIOMAPL_OFS)
231#define MSC01_PCI_P2SCMSKL (MSC01_PCI_REG_BASE + MSC01_PCI_P2SCMSKL_OFS)
232#define MSC01_PCI_P2SCMAPL (MSC01_PCI_REG_BASE + MSC01_PCI_P2SCMAPL_OFS)
233#define MSC01_PCI_INTCFG (MSC01_PCI_REG_BASE + MSC01_PCI_INTCFG_OFS)
234#define MSC01_PCI_INTSTAT (MSC01_PCI_REG_BASE + MSC01_PCI_INTSTAT_OFS)
235#define MSC01_PCI_CFGADDR (MSC01_PCI_REG_BASE + MSC01_PCI_CFGADDR_OFS)
236#define MSC01_PCI_CFGDATA (MSC01_PCI_REG_BASE + MSC01_PCI_CFGDATA_OFS)
237#define MSC01_PCI_IACK (MSC01_PCI_REG_BASE + MSC01_PCI_IACK_OFS)
238#define MSC01_PCI_HEAD0 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD0_OFS)
239#define MSC01_PCI_HEAD1 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD1_OFS)
240#define MSC01_PCI_HEAD2 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD2_OFS)
241#define MSC01_PCI_HEAD3 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD3_OFS)
242#define MSC01_PCI_HEAD4 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD4_OFS)
243#define MSC01_PCI_HEAD5 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD5_OFS)
244#define MSC01_PCI_HEAD6 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD6_OFS)
245#define MSC01_PCI_HEAD7 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD7_OFS)
246#define MSC01_PCI_HEAD8 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD8_OFS)
247#define MSC01_PCI_HEAD9 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD9_OFS)
248#define MSC01_PCI_HEAD10 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD10_OFS)
249#define MSC01_PCI_HEAD11 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD11_OFS)
250#define MSC01_PCI_HEAD12 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD11_OFS)
251#define MSC01_PCI_HEAD13 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD11_OFS)
252#define MSC01_PCI_HEAD14 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD11_OFS)
253#define MSC01_PCI_HEAD15 (MSC01_PCI_REG_BASE + MSC01_PCI_HEAD11_OFS)
254#define MSC01_PCI_BAR0 (MSC01_PCI_REG_BASE + MSC01_PCI_BAR0_OFS)
255#define MSC01_PCI_CFG (MSC01_PCI_REG_BASE + MSC01_PCI_CFG_OFS)
256#define MSC01_PCI_SWAP (MSC01_PCI_REG_BASE + MSC01_PCI_SWAP_OFS)
257
258#endif /* __ASM_MIPS_BOARDS_MSC01_PCI_H */
diff --git a/arch/mips/include/asm/mips-boards/piix4.h b/arch/mips/include/asm/mips-boards/piix4.h
new file mode 100644
index 000000000000..2971d60f2e95
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/piix4.h
@@ -0,0 +1,80 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Register definitions for Intel PIIX4 South Bridge Device.
19 */
20#ifndef __ASM_MIPS_BOARDS_PIIX4_H
21#define __ASM_MIPS_BOARDS_PIIX4_H
22
23/************************************************************************
24 * IO register offsets
25 ************************************************************************/
26#define PIIX4_ICTLR1_ICW1 0x20
27#define PIIX4_ICTLR1_ICW2 0x21
28#define PIIX4_ICTLR1_ICW3 0x21
29#define PIIX4_ICTLR1_ICW4 0x21
30#define PIIX4_ICTLR2_ICW1 0xa0
31#define PIIX4_ICTLR2_ICW2 0xa1
32#define PIIX4_ICTLR2_ICW3 0xa1
33#define PIIX4_ICTLR2_ICW4 0xa1
34#define PIIX4_ICTLR1_OCW1 0x21
35#define PIIX4_ICTLR1_OCW2 0x20
36#define PIIX4_ICTLR1_OCW3 0x20
37#define PIIX4_ICTLR1_OCW4 0x20
38#define PIIX4_ICTLR2_OCW1 0xa1
39#define PIIX4_ICTLR2_OCW2 0xa0
40#define PIIX4_ICTLR2_OCW3 0xa0
41#define PIIX4_ICTLR2_OCW4 0xa0
42
43
44/************************************************************************
45 * Register encodings.
46 ************************************************************************/
47#define PIIX4_OCW2_NSEOI (0x1 << 5)
48#define PIIX4_OCW2_SEOI (0x3 << 5)
49#define PIIX4_OCW2_RNSEOI (0x5 << 5)
50#define PIIX4_OCW2_RAEOIS (0x4 << 5)
51#define PIIX4_OCW2_RAEOIC (0x0 << 5)
52#define PIIX4_OCW2_RSEOI (0x7 << 5)
53#define PIIX4_OCW2_SP (0x6 << 5)
54#define PIIX4_OCW2_NOP (0x2 << 5)
55
56#define PIIX4_OCW2_SEL (0x0 << 3)
57
58#define PIIX4_OCW2_ILS_0 0
59#define PIIX4_OCW2_ILS_1 1
60#define PIIX4_OCW2_ILS_2 2
61#define PIIX4_OCW2_ILS_3 3
62#define PIIX4_OCW2_ILS_4 4
63#define PIIX4_OCW2_ILS_5 5
64#define PIIX4_OCW2_ILS_6 6
65#define PIIX4_OCW2_ILS_7 7
66#define PIIX4_OCW2_ILS_8 0
67#define PIIX4_OCW2_ILS_9 1
68#define PIIX4_OCW2_ILS_10 2
69#define PIIX4_OCW2_ILS_11 3
70#define PIIX4_OCW2_ILS_12 4
71#define PIIX4_OCW2_ILS_13 5
72#define PIIX4_OCW2_ILS_14 6
73#define PIIX4_OCW2_ILS_15 7
74
75#define PIIX4_OCW3_SEL (0x1 << 3)
76
77#define PIIX4_OCW3_IRR 0x2
78#define PIIX4_OCW3_ISR 0x3
79
80#endif /* __ASM_MIPS_BOARDS_PIIX4_H */
diff --git a/arch/mips/include/asm/mips-boards/prom.h b/arch/mips/include/asm/mips-boards/prom.h
new file mode 100644
index 000000000000..a9db576a9768
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/prom.h
@@ -0,0 +1,47 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * ########################################################################
6 *
7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 *
20 * ########################################################################
21 *
22 * MIPS boards bootprom interface for the Linux kernel.
23 *
24 */
25
26#ifndef _MIPS_PROM_H
27#define _MIPS_PROM_H
28
29extern char *prom_getcmdline(void);
30extern char *prom_getenv(char *name);
31extern void prom_init_cmdline(void);
32extern void prom_meminit(void);
33extern void prom_fixup_mem_map(unsigned long start_mem, unsigned long end_mem);
34extern void mips_display_message(const char *str);
35extern void mips_display_word(unsigned int num);
36extern void mips_scroll_message(void);
37extern int get_ethernet_addr(char *ethernet_addr);
38
39/* Memory descriptor management. */
40#define PROM_MAX_PMEMBLOCKS 32
41struct prom_pmemblock {
42 unsigned long base; /* Within KSEG0. */
43 unsigned int size; /* In bytes. */
44 unsigned int type; /* free or prom memory */
45};
46
47#endif /* !(_MIPS_PROM_H) */
diff --git a/arch/mips/include/asm/mips-boards/sim.h b/arch/mips/include/asm/mips-boards/sim.h
new file mode 100644
index 000000000000..acb7c2331d98
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/sim.h
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
3 *
4 * This program is free software; you can distribute it and/or modify it
5 * under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 *
17 */
18
19#ifndef _ASM_MIPS_BOARDS_SIM_H
20#define _ASM_MIPS_BOARDS_SIM_H
21
22#define STATS_ON 1
23#define STATS_OFF 2
24#define STATS_CLEAR 3
25#define STATS_DUMP 4
26#define TRACE_ON 5
27#define TRACE_OFF 6
28
29
30#define simcfg(code) \
31({ \
32 __asm__ __volatile__( \
33 "sltiu $0,$0, %0" \
34 ::"i"(code) \
35 ); \
36})
37
38
39
40#endif
diff --git a/arch/mips/include/asm/mips-boards/simint.h b/arch/mips/include/asm/mips-boards/simint.h
new file mode 100644
index 000000000000..8ef6db76d5c1
--- /dev/null
+++ b/arch/mips/include/asm/mips-boards/simint.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
3 *
4 * This program is free software; you can distribute it and/or modify it
5 * under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */
17#ifndef _MIPS_SIMINT_H
18#define _MIPS_SIMINT_H
19
20#include <irq.h>
21
22#define SIM_INT_BASE 0
23#define MIPSCPU_INT_MB0 2
24#define MIPS_CPU_TIMER_IRQ 7
25
26
27#define MSC01E_INT_BASE 64
28
29#define MSC01E_INT_CPUCTR 11
30
31#endif
diff --git a/arch/mips/include/asm/mips_mt.h b/arch/mips/include/asm/mips_mt.h
new file mode 100644
index 000000000000..ac7935203f89
--- /dev/null
+++ b/arch/mips/include/asm/mips_mt.h
@@ -0,0 +1,26 @@
1/*
2 * Definitions and decalrations for MIPS MT support
3 * that are common between SMTC, VSMP, and/or AP/SP
4 * kernel models.
5 */
6#ifndef __ASM_MIPS_MT_H
7#define __ASM_MIPS_MT_H
8
9#include <linux/cpumask.h>
10
11/*
12 * How many VPEs and TCs is Linux allowed to use? 0 means no limit.
13 */
14extern int tclimit;
15extern int vpelimit;
16
17extern cpumask_t mt_fpu_cpumask;
18extern unsigned long mt_fpemul_threshold;
19
20extern void mips_mt_regdump(unsigned long previous_mvpcontrol_value);
21extern void mips_mt_set_cpuoptions(void);
22
23struct class;
24extern struct class *mt_class;
25
26#endif /* __ASM_MIPS_MT_H */
diff --git a/arch/mips/include/asm/mipsmtregs.h b/arch/mips/include/asm/mipsmtregs.h
new file mode 100644
index 000000000000..c9420aa97e32
--- /dev/null
+++ b/arch/mips/include/asm/mipsmtregs.h
@@ -0,0 +1,395 @@
1/*
2 * MT regs definitions, follows on from mipsregs.h
3 * Copyright (C) 2004 - 2005 MIPS Technologies, Inc. All rights reserved.
4 * Elizabeth Clarke et. al.
5 *
6 */
7#ifndef _ASM_MIPSMTREGS_H
8#define _ASM_MIPSMTREGS_H
9
10#include <asm/mipsregs.h>
11#include <asm/war.h>
12
13#ifndef __ASSEMBLY__
14
15/*
16 * C macros
17 */
18
19#define read_c0_mvpcontrol() __read_32bit_c0_register($0, 1)
20#define write_c0_mvpcontrol(val) __write_32bit_c0_register($0, 1, val)
21
22#define read_c0_mvpconf0() __read_32bit_c0_register($0, 2)
23#define read_c0_mvpconf1() __read_32bit_c0_register($0, 3)
24
25#define read_c0_vpecontrol() __read_32bit_c0_register($1, 1)
26#define write_c0_vpecontrol(val) __write_32bit_c0_register($1, 1, val)
27
28#define read_c0_vpeconf0() __read_32bit_c0_register($1, 2)
29#define write_c0_vpeconf0(val) __write_32bit_c0_register($1, 2, val)
30
31#define read_c0_tcstatus() __read_32bit_c0_register($2, 1)
32#define write_c0_tcstatus(val) __write_32bit_c0_register($2, 1, val)
33
34#define read_c0_tcbind() __read_32bit_c0_register($2, 2)
35
36#define read_c0_tccontext() __read_32bit_c0_register($2, 5)
37#define write_c0_tccontext(val) __write_32bit_c0_register($2, 5, val)
38
39#else /* Assembly */
40/*
41 * Macros for use in assembly language code
42 */
43
44#define CP0_MVPCONTROL $0, 1
45#define CP0_MVPCONF0 $0, 2
46#define CP0_MVPCONF1 $0, 3
47#define CP0_VPECONTROL $1, 1
48#define CP0_VPECONF0 $1, 2
49#define CP0_VPECONF1 $1, 3
50#define CP0_YQMASK $1, 4
51#define CP0_VPESCHEDULE $1, 5
52#define CP0_VPESCHEFBK $1, 6
53#define CP0_TCSTATUS $2, 1
54#define CP0_TCBIND $2, 2
55#define CP0_TCRESTART $2, 3
56#define CP0_TCHALT $2, 4
57#define CP0_TCCONTEXT $2, 5
58#define CP0_TCSCHEDULE $2, 6
59#define CP0_TCSCHEFBK $2, 7
60#define CP0_SRSCONF0 $6, 1
61#define CP0_SRSCONF1 $6, 2
62#define CP0_SRSCONF2 $6, 3
63#define CP0_SRSCONF3 $6, 4
64#define CP0_SRSCONF4 $6, 5
65
66#endif
67
68/* MVPControl fields */
69#define MVPCONTROL_EVP (_ULCAST_(1))
70
71#define MVPCONTROL_VPC_SHIFT 1
72#define MVPCONTROL_VPC (_ULCAST_(1) << MVPCONTROL_VPC_SHIFT)
73
74#define MVPCONTROL_STLB_SHIFT 2
75#define MVPCONTROL_STLB (_ULCAST_(1) << MVPCONTROL_STLB_SHIFT)
76
77
78/* MVPConf0 fields */
79#define MVPCONF0_PTC_SHIFT 0
80#define MVPCONF0_PTC ( _ULCAST_(0xff))
81#define MVPCONF0_PVPE_SHIFT 10
82#define MVPCONF0_PVPE ( _ULCAST_(0xf) << MVPCONF0_PVPE_SHIFT)
83#define MVPCONF0_TCA_SHIFT 15
84#define MVPCONF0_TCA ( _ULCAST_(1) << MVPCONF0_TCA_SHIFT)
85#define MVPCONF0_PTLBE_SHIFT 16
86#define MVPCONF0_PTLBE (_ULCAST_(0x3ff) << MVPCONF0_PTLBE_SHIFT)
87#define MVPCONF0_TLBS_SHIFT 29
88#define MVPCONF0_TLBS (_ULCAST_(1) << MVPCONF0_TLBS_SHIFT)
89#define MVPCONF0_M_SHIFT 31
90#define MVPCONF0_M (_ULCAST_(0x1) << MVPCONF0_M_SHIFT)
91
92
93/* config3 fields */
94#define CONFIG3_MT_SHIFT 2
95#define CONFIG3_MT (_ULCAST_(1) << CONFIG3_MT_SHIFT)
96
97
98/* VPEControl fields (per VPE) */
99#define VPECONTROL_TARGTC (_ULCAST_(0xff))
100
101#define VPECONTROL_TE_SHIFT 15
102#define VPECONTROL_TE (_ULCAST_(1) << VPECONTROL_TE_SHIFT)
103#define VPECONTROL_EXCPT_SHIFT 16
104#define VPECONTROL_EXCPT (_ULCAST_(0x7) << VPECONTROL_EXCPT_SHIFT)
105
106/* Thread Exception Codes for EXCPT field */
107#define THREX_TU 0
108#define THREX_TO 1
109#define THREX_IYQ 2
110#define THREX_GSX 3
111#define THREX_YSCH 4
112#define THREX_GSSCH 5
113
114#define VPECONTROL_GSI_SHIFT 20
115#define VPECONTROL_GSI (_ULCAST_(1) << VPECONTROL_GSI_SHIFT)
116#define VPECONTROL_YSI_SHIFT 21
117#define VPECONTROL_YSI (_ULCAST_(1) << VPECONTROL_YSI_SHIFT)
118
119/* VPEConf0 fields (per VPE) */
120#define VPECONF0_VPA_SHIFT 0
121#define VPECONF0_VPA (_ULCAST_(1) << VPECONF0_VPA_SHIFT)
122#define VPECONF0_MVP_SHIFT 1
123#define VPECONF0_MVP (_ULCAST_(1) << VPECONF0_MVP_SHIFT)
124#define VPECONF0_XTC_SHIFT 21
125#define VPECONF0_XTC (_ULCAST_(0xff) << VPECONF0_XTC_SHIFT)
126
127/* TCStatus fields (per TC) */
128#define TCSTATUS_TASID (_ULCAST_(0xff))
129#define TCSTATUS_IXMT_SHIFT 10
130#define TCSTATUS_IXMT (_ULCAST_(1) << TCSTATUS_IXMT_SHIFT)
131#define TCSTATUS_TKSU_SHIFT 11
132#define TCSTATUS_TKSU (_ULCAST_(3) << TCSTATUS_TKSU_SHIFT)
133#define TCSTATUS_A_SHIFT 13
134#define TCSTATUS_A (_ULCAST_(1) << TCSTATUS_A_SHIFT)
135#define TCSTATUS_DA_SHIFT 15
136#define TCSTATUS_DA (_ULCAST_(1) << TCSTATUS_DA_SHIFT)
137#define TCSTATUS_DT_SHIFT 20
138#define TCSTATUS_DT (_ULCAST_(1) << TCSTATUS_DT_SHIFT)
139#define TCSTATUS_TDS_SHIFT 21
140#define TCSTATUS_TDS (_ULCAST_(1) << TCSTATUS_TDS_SHIFT)
141#define TCSTATUS_TSST_SHIFT 22
142#define TCSTATUS_TSST (_ULCAST_(1) << TCSTATUS_TSST_SHIFT)
143#define TCSTATUS_RNST_SHIFT 23
144#define TCSTATUS_RNST (_ULCAST_(3) << TCSTATUS_RNST_SHIFT)
145/* Codes for RNST */
146#define TC_RUNNING 0
147#define TC_WAITING 1
148#define TC_YIELDING 2
149#define TC_GATED 3
150
151#define TCSTATUS_TMX_SHIFT 27
152#define TCSTATUS_TMX (_ULCAST_(1) << TCSTATUS_TMX_SHIFT)
153/* TCStatus TCU bits can use same definitions/offsets as CU bits in Status */
154
155/* TCBind */
156#define TCBIND_CURVPE_SHIFT 0
157#define TCBIND_CURVPE (_ULCAST_(0xf))
158
159#define TCBIND_CURTC_SHIFT 21
160
161#define TCBIND_CURTC (_ULCAST_(0xff) << TCBIND_CURTC_SHIFT)
162
163/* TCHalt */
164#define TCHALT_H (_ULCAST_(1))
165
166#ifndef __ASSEMBLY__
167
168static inline unsigned int dvpe(void)
169{
170 int res = 0;
171
172 __asm__ __volatile__(
173 " .set push \n"
174 " .set noreorder \n"
175 " .set noat \n"
176 " .set mips32r2 \n"
177 " .word 0x41610001 # dvpe $1 \n"
178 " move %0, $1 \n"
179 " ehb \n"
180 " .set pop \n"
181 : "=r" (res));
182
183 instruction_hazard();
184
185 return res;
186}
187
188static inline void __raw_evpe(void)
189{
190 __asm__ __volatile__(
191 " .set push \n"
192 " .set noreorder \n"
193 " .set noat \n"
194 " .set mips32r2 \n"
195 " .word 0x41600021 # evpe \n"
196 " ehb \n"
197 " .set pop \n");
198}
199
200/* Enable virtual processor execution if previous suggested it should be.
201 EVPE_ENABLE to force */
202
203#define EVPE_ENABLE MVPCONTROL_EVP
204
205static inline void evpe(int previous)
206{
207 if ((previous & MVPCONTROL_EVP))
208 __raw_evpe();
209}
210
211static inline unsigned int dmt(void)
212{
213 int res;
214
215 __asm__ __volatile__(
216 " .set push \n"
217 " .set mips32r2 \n"
218 " .set noat \n"
219 " .word 0x41610BC1 # dmt $1 \n"
220 " ehb \n"
221 " move %0, $1 \n"
222 " .set pop \n"
223 : "=r" (res));
224
225 instruction_hazard();
226
227 return res;
228}
229
230static inline void __raw_emt(void)
231{
232 __asm__ __volatile__(
233 " .set noreorder \n"
234 " .set mips32r2 \n"
235 " .word 0x41600be1 # emt \n"
236 " ehb \n"
237 " .set mips0 \n"
238 " .set reorder");
239}
240
241/* enable multi-threaded execution if previous suggested it should be.
242 EMT_ENABLE to force */
243
244#define EMT_ENABLE VPECONTROL_TE
245
246static inline void emt(int previous)
247{
248 if ((previous & EMT_ENABLE))
249 __raw_emt();
250}
251
252static inline void ehb(void)
253{
254 __asm__ __volatile__(
255 " .set mips32r2 \n"
256 " ehb \n"
257 " .set mips0 \n");
258}
259
260#define mftc0(rt,sel) \
261({ \
262 unsigned long __res; \
263 \
264 __asm__ __volatile__( \
265 " .set push \n" \
266 " .set mips32r2 \n" \
267 " .set noat \n" \
268 " # mftc0 $1, $" #rt ", " #sel " \n" \
269 " .word 0x41000800 | (" #rt " << 16) | " #sel " \n" \
270 " move %0, $1 \n" \
271 " .set pop \n" \
272 : "=r" (__res)); \
273 \
274 __res; \
275})
276
277#define mftgpr(rt) \
278({ \
279 unsigned long __res; \
280 \
281 __asm__ __volatile__( \
282 " .set push \n" \
283 " .set noat \n" \
284 " .set mips32r2 \n" \
285 " # mftgpr $1," #rt " \n" \
286 " .word 0x41000820 | (" #rt " << 16) \n" \
287 " move %0, $1 \n" \
288 " .set pop \n" \
289 : "=r" (__res)); \
290 \
291 __res; \
292})
293
294#define mftr(rt, u, sel) \
295({ \
296 unsigned long __res; \
297 \
298 __asm__ __volatile__( \
299 " mftr %0, " #rt ", " #u ", " #sel " \n" \
300 : "=r" (__res)); \
301 \
302 __res; \
303})
304
305#define mttgpr(rd,v) \
306do { \
307 __asm__ __volatile__( \
308 " .set push \n" \
309 " .set mips32r2 \n" \
310 " .set noat \n" \
311 " move $1, %0 \n" \
312 " # mttgpr $1, " #rd " \n" \
313 " .word 0x41810020 | (" #rd " << 11) \n" \
314 " .set pop \n" \
315 : : "r" (v)); \
316} while (0)
317
318#define mttc0(rd, sel, v) \
319({ \
320 __asm__ __volatile__( \
321 " .set push \n" \
322 " .set mips32r2 \n" \
323 " .set noat \n" \
324 " move $1, %0 \n" \
325 " # mttc0 %0," #rd ", " #sel " \n" \
326 " .word 0x41810000 | (" #rd " << 11) | " #sel " \n" \
327 " .set pop \n" \
328 : \
329 : "r" (v)); \
330})
331
332
333#define mttr(rd, u, sel, v) \
334({ \
335 __asm__ __volatile__( \
336 "mttr %0," #rd ", " #u ", " #sel \
337 : : "r" (v)); \
338})
339
340
341#define settc(tc) \
342do { \
343 write_c0_vpecontrol((read_c0_vpecontrol()&~VPECONTROL_TARGTC) | (tc)); \
344 ehb(); \
345} while (0)
346
347
348/* you *must* set the target tc (settc) before trying to use these */
349#define read_vpe_c0_vpecontrol() mftc0(1, 1)
350#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val)
351#define read_vpe_c0_vpeconf0() mftc0(1, 2)
352#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val)
353#define read_vpe_c0_count() mftc0(9, 0)
354#define write_vpe_c0_count(val) mttc0(9, 0, val)
355#define read_vpe_c0_status() mftc0(12, 0)
356#define write_vpe_c0_status(val) mttc0(12, 0, val)
357#define read_vpe_c0_cause() mftc0(13, 0)
358#define write_vpe_c0_cause(val) mttc0(13, 0, val)
359#define read_vpe_c0_config() mftc0(16, 0)
360#define write_vpe_c0_config(val) mttc0(16, 0, val)
361#define read_vpe_c0_config1() mftc0(16, 1)
362#define write_vpe_c0_config1(val) mttc0(16, 1, val)
363#define read_vpe_c0_config7() mftc0(16, 7)
364#define write_vpe_c0_config7(val) mttc0(16, 7, val)
365#define read_vpe_c0_ebase() mftc0(15, 1)
366#define write_vpe_c0_ebase(val) mttc0(15, 1, val)
367#define write_vpe_c0_compare(val) mttc0(11, 0, val)
368#define read_vpe_c0_badvaddr() mftc0(8, 0)
369#define read_vpe_c0_epc() mftc0(14, 0)
370#define write_vpe_c0_epc(val) mttc0(14, 0, val)
371
372
373/* TC */
374#define read_tc_c0_tcstatus() mftc0(2, 1)
375#define write_tc_c0_tcstatus(val) mttc0(2, 1, val)
376#define read_tc_c0_tcbind() mftc0(2, 2)
377#define write_tc_c0_tcbind(val) mttc0(2, 2, val)
378#define read_tc_c0_tcrestart() mftc0(2, 3)
379#define write_tc_c0_tcrestart(val) mttc0(2, 3, val)
380#define read_tc_c0_tchalt() mftc0(2, 4)
381#define write_tc_c0_tchalt(val) mttc0(2, 4, val)
382#define read_tc_c0_tccontext() mftc0(2, 5)
383#define write_tc_c0_tccontext(val) mttc0(2, 5, val)
384
385/* GPR */
386#define read_tc_gpr_sp() mftgpr(29)
387#define write_tc_gpr_sp(val) mttgpr(29, val)
388#define read_tc_gpr_gp() mftgpr(28)
389#define write_tc_gpr_gp(val) mttgpr(28, val)
390
391__BUILD_SET_C0(mvpcontrol)
392
393#endif /* Not __ASSEMBLY__ */
394
395#endif
diff --git a/arch/mips/include/asm/mipsprom.h b/arch/mips/include/asm/mipsprom.h
new file mode 100644
index 000000000000..146d41b67adc
--- /dev/null
+++ b/arch/mips/include/asm/mipsprom.h
@@ -0,0 +1,76 @@
1#ifndef __ASM_MIPS_PROM_H
2#define __ASM_MIPS_PROM_H
3
4#define PROM_RESET 0
5#define PROM_EXEC 1
6#define PROM_RESTART 2
7#define PROM_REINIT 3
8#define PROM_REBOOT 4
9#define PROM_AUTOBOOT 5
10#define PROM_OPEN 6
11#define PROM_READ 7
12#define PROM_WRITE 8
13#define PROM_IOCTL 9
14#define PROM_CLOSE 10
15#define PROM_GETCHAR 11
16#define PROM_PUTCHAR 12
17#define PROM_SHOWCHAR 13 /* XXX */
18#define PROM_GETS 14 /* XXX */
19#define PROM_PUTS 15 /* XXX */
20#define PROM_PRINTF 16 /* XXX */
21
22/* What are these for? */
23#define PROM_INITPROTO 17 /* XXX */
24#define PROM_PROTOENABLE 18 /* XXX */
25#define PROM_PROTODISABLE 19 /* XXX */
26#define PROM_GETPKT 20 /* XXX */
27#define PROM_PUTPKT 21 /* XXX */
28
29/* More PROM shit. Probably has to do with VME RMW cycles??? */
30#define PROM_ORW_RMW 22 /* XXX */
31#define PROM_ORH_RMW 23 /* XXX */
32#define PROM_ORB_RMW 24 /* XXX */
33#define PROM_ANDW_RMW 25 /* XXX */
34#define PROM_ANDH_RMW 26 /* XXX */
35#define PROM_ANDB_RMW 27 /* XXX */
36
37/* Cache handling stuff */
38#define PROM_FLUSHCACHE 28 /* XXX */
39#define PROM_CLEARCACHE 29 /* XXX */
40
41/* Libc alike stuff */
42#define PROM_SETJMP 30 /* XXX */
43#define PROM_LONGJMP 31 /* XXX */
44#define PROM_BEVUTLB 32 /* XXX */
45#define PROM_GETENV 33 /* XXX */
46#define PROM_SETENV 34 /* XXX */
47#define PROM_ATOB 35 /* XXX */
48#define PROM_STRCMP 36 /* XXX */
49#define PROM_STRLEN 37 /* XXX */
50#define PROM_STRCPY 38 /* XXX */
51#define PROM_STRCAT 39 /* XXX */
52
53/* Misc stuff */
54#define PROM_PARSER 40 /* XXX */
55#define PROM_RANGE 41 /* XXX */
56#define PROM_ARGVIZE 42 /* XXX */
57#define PROM_HELP 43 /* XXX */
58
59/* Entry points for some PROM commands */
60#define PROM_DUMPCMD 44 /* XXX */
61#define PROM_SETENVCMD 45 /* XXX */
62#define PROM_UNSETENVCMD 46 /* XXX */
63#define PROM_PRINTENVCMD 47 /* XXX */
64#define PROM_BEVEXCEPT 48 /* XXX */
65#define PROM_ENABLECMD 49 /* XXX */
66#define PROM_DISABLECMD 50 /* XXX */
67
68#define PROM_CLEARNOFAULT 51 /* XXX */
69#define PROM_NOTIMPLEMENT 52 /* XXX */
70
71#define PROM_NV_GET 53 /* XXX */
72#define PROM_NV_SET 54 /* XXX */
73
74extern char *prom_getenv(char *);
75
76#endif /* __ASM_MIPS_PROM_H */
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
new file mode 100644
index 000000000000..979866000da4
--- /dev/null
+++ b/arch/mips/include/asm/mipsregs.h
@@ -0,0 +1,1526 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001 by Ralf Baechle
7 * Copyright (C) 2000 Silicon Graphics, Inc.
8 * Modified for further R[236]000 support by Paul M. Antoine, 1996.
9 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
10 * Copyright (C) 2000, 07 MIPS Technologies, Inc.
11 * Copyright (C) 2003, 2004 Maciej W. Rozycki
12 */
13#ifndef _ASM_MIPSREGS_H
14#define _ASM_MIPSREGS_H
15
16#include <linux/linkage.h>
17#include <asm/hazards.h>
18#include <asm/war.h>
19
20/*
21 * The following macros are especially useful for __asm__
22 * inline assembler.
23 */
24#ifndef __STR
25#define __STR(x) #x
26#endif
27#ifndef STR
28#define STR(x) __STR(x)
29#endif
30
31/*
32 * Configure language
33 */
34#ifdef __ASSEMBLY__
35#define _ULCAST_
36#else
37#define _ULCAST_ (unsigned long)
38#endif
39
40/*
41 * Coprocessor 0 register names
42 */
43#define CP0_INDEX $0
44#define CP0_RANDOM $1
45#define CP0_ENTRYLO0 $2
46#define CP0_ENTRYLO1 $3
47#define CP0_CONF $3
48#define CP0_CONTEXT $4
49#define CP0_PAGEMASK $5
50#define CP0_WIRED $6
51#define CP0_INFO $7
52#define CP0_BADVADDR $8
53#define CP0_COUNT $9
54#define CP0_ENTRYHI $10
55#define CP0_COMPARE $11
56#define CP0_STATUS $12
57#define CP0_CAUSE $13
58#define CP0_EPC $14
59#define CP0_PRID $15
60#define CP0_CONFIG $16
61#define CP0_LLADDR $17
62#define CP0_WATCHLO $18
63#define CP0_WATCHHI $19
64#define CP0_XCONTEXT $20
65#define CP0_FRAMEMASK $21
66#define CP0_DIAGNOSTIC $22
67#define CP0_DEBUG $23
68#define CP0_DEPC $24
69#define CP0_PERFORMANCE $25
70#define CP0_ECC $26
71#define CP0_CACHEERR $27
72#define CP0_TAGLO $28
73#define CP0_TAGHI $29
74#define CP0_ERROREPC $30
75#define CP0_DESAVE $31
76
77/*
78 * R4640/R4650 cp0 register names. These registers are listed
79 * here only for completeness; without MMU these CPUs are not useable
80 * by Linux. A future ELKS port might take make Linux run on them
81 * though ...
82 */
83#define CP0_IBASE $0
84#define CP0_IBOUND $1
85#define CP0_DBASE $2
86#define CP0_DBOUND $3
87#define CP0_CALG $17
88#define CP0_IWATCH $18
89#define CP0_DWATCH $19
90
91/*
92 * Coprocessor 0 Set 1 register names
93 */
94#define CP0_S1_DERRADDR0 $26
95#define CP0_S1_DERRADDR1 $27
96#define CP0_S1_INTCONTROL $20
97
98/*
99 * Coprocessor 0 Set 2 register names
100 */
101#define CP0_S2_SRSCTL $12 /* MIPSR2 */
102
103/*
104 * Coprocessor 0 Set 3 register names
105 */
106#define CP0_S3_SRSMAP $12 /* MIPSR2 */
107
108/*
109 * TX39 Series
110 */
111#define CP0_TX39_CACHE $7
112
113/*
114 * Coprocessor 1 (FPU) register names
115 */
116#define CP1_REVISION $0
117#define CP1_STATUS $31
118
119/*
120 * FPU Status Register Values
121 */
122/*
123 * Status Register Values
124 */
125
126#define FPU_CSR_FLUSH 0x01000000 /* flush denormalised results to 0 */
127#define FPU_CSR_COND 0x00800000 /* $fcc0 */
128#define FPU_CSR_COND0 0x00800000 /* $fcc0 */
129#define FPU_CSR_COND1 0x02000000 /* $fcc1 */
130#define FPU_CSR_COND2 0x04000000 /* $fcc2 */
131#define FPU_CSR_COND3 0x08000000 /* $fcc3 */
132#define FPU_CSR_COND4 0x10000000 /* $fcc4 */
133#define FPU_CSR_COND5 0x20000000 /* $fcc5 */
134#define FPU_CSR_COND6 0x40000000 /* $fcc6 */
135#define FPU_CSR_COND7 0x80000000 /* $fcc7 */
136
137/*
138 * X the exception cause indicator
139 * E the exception enable
140 * S the sticky/flag bit
141*/
142#define FPU_CSR_ALL_X 0x0003f000
143#define FPU_CSR_UNI_X 0x00020000
144#define FPU_CSR_INV_X 0x00010000
145#define FPU_CSR_DIV_X 0x00008000
146#define FPU_CSR_OVF_X 0x00004000
147#define FPU_CSR_UDF_X 0x00002000
148#define FPU_CSR_INE_X 0x00001000
149
150#define FPU_CSR_ALL_E 0x00000f80
151#define FPU_CSR_INV_E 0x00000800
152#define FPU_CSR_DIV_E 0x00000400
153#define FPU_CSR_OVF_E 0x00000200
154#define FPU_CSR_UDF_E 0x00000100
155#define FPU_CSR_INE_E 0x00000080
156
157#define FPU_CSR_ALL_S 0x0000007c
158#define FPU_CSR_INV_S 0x00000040
159#define FPU_CSR_DIV_S 0x00000020
160#define FPU_CSR_OVF_S 0x00000010
161#define FPU_CSR_UDF_S 0x00000008
162#define FPU_CSR_INE_S 0x00000004
163
164/* rounding mode */
165#define FPU_CSR_RN 0x0 /* nearest */
166#define FPU_CSR_RZ 0x1 /* towards zero */
167#define FPU_CSR_RU 0x2 /* towards +Infinity */
168#define FPU_CSR_RD 0x3 /* towards -Infinity */
169
170
171/*
172 * Values for PageMask register
173 */
174#ifdef CONFIG_CPU_VR41XX
175
176/* Why doesn't stupidity hurt ... */
177
178#define PM_1K 0x00000000
179#define PM_4K 0x00001800
180#define PM_16K 0x00007800
181#define PM_64K 0x0001f800
182#define PM_256K 0x0007f800
183
184#else
185
186#define PM_4K 0x00000000
187#define PM_16K 0x00006000
188#define PM_64K 0x0001e000
189#define PM_256K 0x0007e000
190#define PM_1M 0x001fe000
191#define PM_4M 0x007fe000
192#define PM_16M 0x01ffe000
193#define PM_64M 0x07ffe000
194#define PM_256M 0x1fffe000
195
196#endif
197
198/*
199 * Default page size for a given kernel configuration
200 */
201#ifdef CONFIG_PAGE_SIZE_4KB
202#define PM_DEFAULT_MASK PM_4K
203#elif defined(CONFIG_PAGE_SIZE_16KB)
204#define PM_DEFAULT_MASK PM_16K
205#elif defined(CONFIG_PAGE_SIZE_64KB)
206#define PM_DEFAULT_MASK PM_64K
207#else
208#error Bad page size configuration!
209#endif
210
211
212/*
213 * Values used for computation of new tlb entries
214 */
215#define PL_4K 12
216#define PL_16K 14
217#define PL_64K 16
218#define PL_256K 18
219#define PL_1M 20
220#define PL_4M 22
221#define PL_16M 24
222#define PL_64M 26
223#define PL_256M 28
224
225/*
226 * R4x00 interrupt enable / cause bits
227 */
228#define IE_SW0 (_ULCAST_(1) << 8)
229#define IE_SW1 (_ULCAST_(1) << 9)
230#define IE_IRQ0 (_ULCAST_(1) << 10)
231#define IE_IRQ1 (_ULCAST_(1) << 11)
232#define IE_IRQ2 (_ULCAST_(1) << 12)
233#define IE_IRQ3 (_ULCAST_(1) << 13)
234#define IE_IRQ4 (_ULCAST_(1) << 14)
235#define IE_IRQ5 (_ULCAST_(1) << 15)
236
237/*
238 * R4x00 interrupt cause bits
239 */
240#define C_SW0 (_ULCAST_(1) << 8)
241#define C_SW1 (_ULCAST_(1) << 9)
242#define C_IRQ0 (_ULCAST_(1) << 10)
243#define C_IRQ1 (_ULCAST_(1) << 11)
244#define C_IRQ2 (_ULCAST_(1) << 12)
245#define C_IRQ3 (_ULCAST_(1) << 13)
246#define C_IRQ4 (_ULCAST_(1) << 14)
247#define C_IRQ5 (_ULCAST_(1) << 15)
248
249/*
250 * Bitfields in the R4xx0 cp0 status register
251 */
252#define ST0_IE 0x00000001
253#define ST0_EXL 0x00000002
254#define ST0_ERL 0x00000004
255#define ST0_KSU 0x00000018
256# define KSU_USER 0x00000010
257# define KSU_SUPERVISOR 0x00000008
258# define KSU_KERNEL 0x00000000
259#define ST0_UX 0x00000020
260#define ST0_SX 0x00000040
261#define ST0_KX 0x00000080
262#define ST0_DE 0x00010000
263#define ST0_CE 0x00020000
264
265/*
266 * Setting c0_status.co enables Hit_Writeback and Hit_Writeback_Invalidate
267 * cacheops in userspace. This bit exists only on RM7000 and RM9000
268 * processors.
269 */
270#define ST0_CO 0x08000000
271
272/*
273 * Bitfields in the R[23]000 cp0 status register.
274 */
275#define ST0_IEC 0x00000001
276#define ST0_KUC 0x00000002
277#define ST0_IEP 0x00000004
278#define ST0_KUP 0x00000008
279#define ST0_IEO 0x00000010
280#define ST0_KUO 0x00000020
281/* bits 6 & 7 are reserved on R[23]000 */
282#define ST0_ISC 0x00010000
283#define ST0_SWC 0x00020000
284#define ST0_CM 0x00080000
285
286/*
287 * Bits specific to the R4640/R4650
288 */
289#define ST0_UM (_ULCAST_(1) << 4)
290#define ST0_IL (_ULCAST_(1) << 23)
291#define ST0_DL (_ULCAST_(1) << 24)
292
293/*
294 * Enable the MIPS MDMX and DSP ASEs
295 */
296#define ST0_MX 0x01000000
297
298/*
299 * Bitfields in the TX39 family CP0 Configuration Register 3
300 */
301#define TX39_CONF_ICS_SHIFT 19
302#define TX39_CONF_ICS_MASK 0x00380000
303#define TX39_CONF_ICS_1KB 0x00000000
304#define TX39_CONF_ICS_2KB 0x00080000
305#define TX39_CONF_ICS_4KB 0x00100000
306#define TX39_CONF_ICS_8KB 0x00180000
307#define TX39_CONF_ICS_16KB 0x00200000
308
309#define TX39_CONF_DCS_SHIFT 16
310#define TX39_CONF_DCS_MASK 0x00070000
311#define TX39_CONF_DCS_1KB 0x00000000
312#define TX39_CONF_DCS_2KB 0x00010000
313#define TX39_CONF_DCS_4KB 0x00020000
314#define TX39_CONF_DCS_8KB 0x00030000
315#define TX39_CONF_DCS_16KB 0x00040000
316
317#define TX39_CONF_CWFON 0x00004000
318#define TX39_CONF_WBON 0x00002000
319#define TX39_CONF_RF_SHIFT 10
320#define TX39_CONF_RF_MASK 0x00000c00
321#define TX39_CONF_DOZE 0x00000200
322#define TX39_CONF_HALT 0x00000100
323#define TX39_CONF_LOCK 0x00000080
324#define TX39_CONF_ICE 0x00000020
325#define TX39_CONF_DCE 0x00000010
326#define TX39_CONF_IRSIZE_SHIFT 2
327#define TX39_CONF_IRSIZE_MASK 0x0000000c
328#define TX39_CONF_DRSIZE_SHIFT 0
329#define TX39_CONF_DRSIZE_MASK 0x00000003
330
331/*
332 * Status register bits available in all MIPS CPUs.
333 */
334#define ST0_IM 0x0000ff00
335#define STATUSB_IP0 8
336#define STATUSF_IP0 (_ULCAST_(1) << 8)
337#define STATUSB_IP1 9
338#define STATUSF_IP1 (_ULCAST_(1) << 9)
339#define STATUSB_IP2 10
340#define STATUSF_IP2 (_ULCAST_(1) << 10)
341#define STATUSB_IP3 11
342#define STATUSF_IP3 (_ULCAST_(1) << 11)
343#define STATUSB_IP4 12
344#define STATUSF_IP4 (_ULCAST_(1) << 12)
345#define STATUSB_IP5 13
346#define STATUSF_IP5 (_ULCAST_(1) << 13)
347#define STATUSB_IP6 14
348#define STATUSF_IP6 (_ULCAST_(1) << 14)
349#define STATUSB_IP7 15
350#define STATUSF_IP7 (_ULCAST_(1) << 15)
351#define STATUSB_IP8 0
352#define STATUSF_IP8 (_ULCAST_(1) << 0)
353#define STATUSB_IP9 1
354#define STATUSF_IP9 (_ULCAST_(1) << 1)
355#define STATUSB_IP10 2
356#define STATUSF_IP10 (_ULCAST_(1) << 2)
357#define STATUSB_IP11 3
358#define STATUSF_IP11 (_ULCAST_(1) << 3)
359#define STATUSB_IP12 4
360#define STATUSF_IP12 (_ULCAST_(1) << 4)
361#define STATUSB_IP13 5
362#define STATUSF_IP13 (_ULCAST_(1) << 5)
363#define STATUSB_IP14 6
364#define STATUSF_IP14 (_ULCAST_(1) << 6)
365#define STATUSB_IP15 7
366#define STATUSF_IP15 (_ULCAST_(1) << 7)
367#define ST0_CH 0x00040000
368#define ST0_SR 0x00100000
369#define ST0_TS 0x00200000
370#define ST0_BEV 0x00400000
371#define ST0_RE 0x02000000
372#define ST0_FR 0x04000000
373#define ST0_CU 0xf0000000
374#define ST0_CU0 0x10000000
375#define ST0_CU1 0x20000000
376#define ST0_CU2 0x40000000
377#define ST0_CU3 0x80000000
378#define ST0_XX 0x80000000 /* MIPS IV naming */
379
380/*
381 * Bitfields and bit numbers in the coprocessor 0 cause register.
382 *
383 * Refer to your MIPS R4xx0 manual, chapter 5 for explanation.
384 */
385#define CAUSEB_EXCCODE 2
386#define CAUSEF_EXCCODE (_ULCAST_(31) << 2)
387#define CAUSEB_IP 8
388#define CAUSEF_IP (_ULCAST_(255) << 8)
389#define CAUSEB_IP0 8
390#define CAUSEF_IP0 (_ULCAST_(1) << 8)
391#define CAUSEB_IP1 9
392#define CAUSEF_IP1 (_ULCAST_(1) << 9)
393#define CAUSEB_IP2 10
394#define CAUSEF_IP2 (_ULCAST_(1) << 10)
395#define CAUSEB_IP3 11
396#define CAUSEF_IP3 (_ULCAST_(1) << 11)
397#define CAUSEB_IP4 12
398#define CAUSEF_IP4 (_ULCAST_(1) << 12)
399#define CAUSEB_IP5 13
400#define CAUSEF_IP5 (_ULCAST_(1) << 13)
401#define CAUSEB_IP6 14
402#define CAUSEF_IP6 (_ULCAST_(1) << 14)
403#define CAUSEB_IP7 15
404#define CAUSEF_IP7 (_ULCAST_(1) << 15)
405#define CAUSEB_IV 23
406#define CAUSEF_IV (_ULCAST_(1) << 23)
407#define CAUSEB_CE 28
408#define CAUSEF_CE (_ULCAST_(3) << 28)
409#define CAUSEB_BD 31
410#define CAUSEF_BD (_ULCAST_(1) << 31)
411
412/*
413 * Bits in the coprocessor 0 config register.
414 */
415/* Generic bits. */
416#define CONF_CM_CACHABLE_NO_WA 0
417#define CONF_CM_CACHABLE_WA 1
418#define CONF_CM_UNCACHED 2
419#define CONF_CM_CACHABLE_NONCOHERENT 3
420#define CONF_CM_CACHABLE_CE 4
421#define CONF_CM_CACHABLE_COW 5
422#define CONF_CM_CACHABLE_CUW 6
423#define CONF_CM_CACHABLE_ACCELERATED 7
424#define CONF_CM_CMASK 7
425#define CONF_BE (_ULCAST_(1) << 15)
426
427/* Bits common to various processors. */
428#define CONF_CU (_ULCAST_(1) << 3)
429#define CONF_DB (_ULCAST_(1) << 4)
430#define CONF_IB (_ULCAST_(1) << 5)
431#define CONF_DC (_ULCAST_(7) << 6)
432#define CONF_IC (_ULCAST_(7) << 9)
433#define CONF_EB (_ULCAST_(1) << 13)
434#define CONF_EM (_ULCAST_(1) << 14)
435#define CONF_SM (_ULCAST_(1) << 16)
436#define CONF_SC (_ULCAST_(1) << 17)
437#define CONF_EW (_ULCAST_(3) << 18)
438#define CONF_EP (_ULCAST_(15)<< 24)
439#define CONF_EC (_ULCAST_(7) << 28)
440#define CONF_CM (_ULCAST_(1) << 31)
441
442/* Bits specific to the R4xx0. */
443#define R4K_CONF_SW (_ULCAST_(1) << 20)
444#define R4K_CONF_SS (_ULCAST_(1) << 21)
445#define R4K_CONF_SB (_ULCAST_(3) << 22)
446
447/* Bits specific to the R5000. */
448#define R5K_CONF_SE (_ULCAST_(1) << 12)
449#define R5K_CONF_SS (_ULCAST_(3) << 20)
450
451/* Bits specific to the RM7000. */
452#define RM7K_CONF_SE (_ULCAST_(1) << 3)
453#define RM7K_CONF_TE (_ULCAST_(1) << 12)
454#define RM7K_CONF_CLK (_ULCAST_(1) << 16)
455#define RM7K_CONF_TC (_ULCAST_(1) << 17)
456#define RM7K_CONF_SI (_ULCAST_(3) << 20)
457#define RM7K_CONF_SC (_ULCAST_(1) << 31)
458
459/* Bits specific to the R10000. */
460#define R10K_CONF_DN (_ULCAST_(3) << 3)
461#define R10K_CONF_CT (_ULCAST_(1) << 5)
462#define R10K_CONF_PE (_ULCAST_(1) << 6)
463#define R10K_CONF_PM (_ULCAST_(3) << 7)
464#define R10K_CONF_EC (_ULCAST_(15)<< 9)
465#define R10K_CONF_SB (_ULCAST_(1) << 13)
466#define R10K_CONF_SK (_ULCAST_(1) << 14)
467#define R10K_CONF_SS (_ULCAST_(7) << 16)
468#define R10K_CONF_SC (_ULCAST_(7) << 19)
469#define R10K_CONF_DC (_ULCAST_(7) << 26)
470#define R10K_CONF_IC (_ULCAST_(7) << 29)
471
472/* Bits specific to the VR41xx. */
473#define VR41_CONF_CS (_ULCAST_(1) << 12)
474#define VR41_CONF_P4K (_ULCAST_(1) << 13)
475#define VR41_CONF_BP (_ULCAST_(1) << 16)
476#define VR41_CONF_M16 (_ULCAST_(1) << 20)
477#define VR41_CONF_AD (_ULCAST_(1) << 23)
478
479/* Bits specific to the R30xx. */
480#define R30XX_CONF_FDM (_ULCAST_(1) << 19)
481#define R30XX_CONF_REV (_ULCAST_(1) << 22)
482#define R30XX_CONF_AC (_ULCAST_(1) << 23)
483#define R30XX_CONF_RF (_ULCAST_(1) << 24)
484#define R30XX_CONF_HALT (_ULCAST_(1) << 25)
485#define R30XX_CONF_FPINT (_ULCAST_(7) << 26)
486#define R30XX_CONF_DBR (_ULCAST_(1) << 29)
487#define R30XX_CONF_SB (_ULCAST_(1) << 30)
488#define R30XX_CONF_LOCK (_ULCAST_(1) << 31)
489
490/* Bits specific to the TX49. */
491#define TX49_CONF_DC (_ULCAST_(1) << 16)
492#define TX49_CONF_IC (_ULCAST_(1) << 17) /* conflict with CONF_SC */
493#define TX49_CONF_HALT (_ULCAST_(1) << 18)
494#define TX49_CONF_CWFON (_ULCAST_(1) << 27)
495
496/* Bits specific to the MIPS32/64 PRA. */
497#define MIPS_CONF_MT (_ULCAST_(7) << 7)
498#define MIPS_CONF_AR (_ULCAST_(7) << 10)
499#define MIPS_CONF_AT (_ULCAST_(3) << 13)
500#define MIPS_CONF_M (_ULCAST_(1) << 31)
501
502/*
503 * Bits in the MIPS32/64 PRA coprocessor 0 config registers 1 and above.
504 */
505#define MIPS_CONF1_FP (_ULCAST_(1) << 0)
506#define MIPS_CONF1_EP (_ULCAST_(1) << 1)
507#define MIPS_CONF1_CA (_ULCAST_(1) << 2)
508#define MIPS_CONF1_WR (_ULCAST_(1) << 3)
509#define MIPS_CONF1_PC (_ULCAST_(1) << 4)
510#define MIPS_CONF1_MD (_ULCAST_(1) << 5)
511#define MIPS_CONF1_C2 (_ULCAST_(1) << 6)
512#define MIPS_CONF1_DA (_ULCAST_(7) << 7)
513#define MIPS_CONF1_DL (_ULCAST_(7) << 10)
514#define MIPS_CONF1_DS (_ULCAST_(7) << 13)
515#define MIPS_CONF1_IA (_ULCAST_(7) << 16)
516#define MIPS_CONF1_IL (_ULCAST_(7) << 19)
517#define MIPS_CONF1_IS (_ULCAST_(7) << 22)
518#define MIPS_CONF1_TLBS (_ULCAST_(63)<< 25)
519
520#define MIPS_CONF2_SA (_ULCAST_(15)<< 0)
521#define MIPS_CONF2_SL (_ULCAST_(15)<< 4)
522#define MIPS_CONF2_SS (_ULCAST_(15)<< 8)
523#define MIPS_CONF2_SU (_ULCAST_(15)<< 12)
524#define MIPS_CONF2_TA (_ULCAST_(15)<< 16)
525#define MIPS_CONF2_TL (_ULCAST_(15)<< 20)
526#define MIPS_CONF2_TS (_ULCAST_(15)<< 24)
527#define MIPS_CONF2_TU (_ULCAST_(7) << 28)
528
529#define MIPS_CONF3_TL (_ULCAST_(1) << 0)
530#define MIPS_CONF3_SM (_ULCAST_(1) << 1)
531#define MIPS_CONF3_MT (_ULCAST_(1) << 2)
532#define MIPS_CONF3_SP (_ULCAST_(1) << 4)
533#define MIPS_CONF3_VINT (_ULCAST_(1) << 5)
534#define MIPS_CONF3_VEIC (_ULCAST_(1) << 6)
535#define MIPS_CONF3_LPA (_ULCAST_(1) << 7)
536#define MIPS_CONF3_DSP (_ULCAST_(1) << 10)
537#define MIPS_CONF3_ULRI (_ULCAST_(1) << 13)
538
539#define MIPS_CONF7_WII (_ULCAST_(1) << 31)
540
541#define MIPS_CONF7_RPS (_ULCAST_(1) << 2)
542
543
544/*
545 * Bits in the MIPS32/64 coprocessor 1 (FPU) revision register.
546 */
547#define MIPS_FPIR_S (_ULCAST_(1) << 16)
548#define MIPS_FPIR_D (_ULCAST_(1) << 17)
549#define MIPS_FPIR_PS (_ULCAST_(1) << 18)
550#define MIPS_FPIR_3D (_ULCAST_(1) << 19)
551#define MIPS_FPIR_W (_ULCAST_(1) << 20)
552#define MIPS_FPIR_L (_ULCAST_(1) << 21)
553#define MIPS_FPIR_F64 (_ULCAST_(1) << 22)
554
555#ifndef __ASSEMBLY__
556
557/*
558 * Functions to access the R10000 performance counters. These are basically
559 * mfc0 and mtc0 instructions from and to coprocessor register with a 5-bit
560 * performance counter number encoded into bits 1 ... 5 of the instruction.
561 * Only performance counters 0 to 1 actually exist, so for a non-R10000 aware
562 * disassembler these will look like an access to sel 0 or 1.
563 */
564#define read_r10k_perf_cntr(counter) \
565({ \
566 unsigned int __res; \
567 __asm__ __volatile__( \
568 "mfpc\t%0, %1" \
569 : "=r" (__res) \
570 : "i" (counter)); \
571 \
572 __res; \
573})
574
575#define write_r10k_perf_cntr(counter,val) \
576do { \
577 __asm__ __volatile__( \
578 "mtpc\t%0, %1" \
579 : \
580 : "r" (val), "i" (counter)); \
581} while (0)
582
583#define read_r10k_perf_event(counter) \
584({ \
585 unsigned int __res; \
586 __asm__ __volatile__( \
587 "mfps\t%0, %1" \
588 : "=r" (__res) \
589 : "i" (counter)); \
590 \
591 __res; \
592})
593
594#define write_r10k_perf_cntl(counter,val) \
595do { \
596 __asm__ __volatile__( \
597 "mtps\t%0, %1" \
598 : \
599 : "r" (val), "i" (counter)); \
600} while (0)
601
602
603/*
604 * Macros to access the system control coprocessor
605 */
606
607#define __read_32bit_c0_register(source, sel) \
608({ int __res; \
609 if (sel == 0) \
610 __asm__ __volatile__( \
611 "mfc0\t%0, " #source "\n\t" \
612 : "=r" (__res)); \
613 else \
614 __asm__ __volatile__( \
615 ".set\tmips32\n\t" \
616 "mfc0\t%0, " #source ", " #sel "\n\t" \
617 ".set\tmips0\n\t" \
618 : "=r" (__res)); \
619 __res; \
620})
621
622#define __read_64bit_c0_register(source, sel) \
623({ unsigned long long __res; \
624 if (sizeof(unsigned long) == 4) \
625 __res = __read_64bit_c0_split(source, sel); \
626 else if (sel == 0) \
627 __asm__ __volatile__( \
628 ".set\tmips3\n\t" \
629 "dmfc0\t%0, " #source "\n\t" \
630 ".set\tmips0" \
631 : "=r" (__res)); \
632 else \
633 __asm__ __volatile__( \
634 ".set\tmips64\n\t" \
635 "dmfc0\t%0, " #source ", " #sel "\n\t" \
636 ".set\tmips0" \
637 : "=r" (__res)); \
638 __res; \
639})
640
641#define __write_32bit_c0_register(register, sel, value) \
642do { \
643 if (sel == 0) \
644 __asm__ __volatile__( \
645 "mtc0\t%z0, " #register "\n\t" \
646 : : "Jr" ((unsigned int)(value))); \
647 else \
648 __asm__ __volatile__( \
649 ".set\tmips32\n\t" \
650 "mtc0\t%z0, " #register ", " #sel "\n\t" \
651 ".set\tmips0" \
652 : : "Jr" ((unsigned int)(value))); \
653} while (0)
654
655#define __write_64bit_c0_register(register, sel, value) \
656do { \
657 if (sizeof(unsigned long) == 4) \
658 __write_64bit_c0_split(register, sel, value); \
659 else if (sel == 0) \
660 __asm__ __volatile__( \
661 ".set\tmips3\n\t" \
662 "dmtc0\t%z0, " #register "\n\t" \
663 ".set\tmips0" \
664 : : "Jr" (value)); \
665 else \
666 __asm__ __volatile__( \
667 ".set\tmips64\n\t" \
668 "dmtc0\t%z0, " #register ", " #sel "\n\t" \
669 ".set\tmips0" \
670 : : "Jr" (value)); \
671} while (0)
672
673#define __read_ulong_c0_register(reg, sel) \
674 ((sizeof(unsigned long) == 4) ? \
675 (unsigned long) __read_32bit_c0_register(reg, sel) : \
676 (unsigned long) __read_64bit_c0_register(reg, sel))
677
678#define __write_ulong_c0_register(reg, sel, val) \
679do { \
680 if (sizeof(unsigned long) == 4) \
681 __write_32bit_c0_register(reg, sel, val); \
682 else \
683 __write_64bit_c0_register(reg, sel, val); \
684} while (0)
685
686/*
687 * On RM7000/RM9000 these are uses to access cop0 set 1 registers
688 */
689#define __read_32bit_c0_ctrl_register(source) \
690({ int __res; \
691 __asm__ __volatile__( \
692 "cfc0\t%0, " #source "\n\t" \
693 : "=r" (__res)); \
694 __res; \
695})
696
697#define __write_32bit_c0_ctrl_register(register, value) \
698do { \
699 __asm__ __volatile__( \
700 "ctc0\t%z0, " #register "\n\t" \
701 : : "Jr" ((unsigned int)(value))); \
702} while (0)
703
704/*
705 * These versions are only needed for systems with more than 38 bits of
706 * physical address space running the 32-bit kernel. That's none atm :-)
707 */
708#define __read_64bit_c0_split(source, sel) \
709({ \
710 unsigned long long __val; \
711 unsigned long __flags; \
712 \
713 local_irq_save(__flags); \
714 if (sel == 0) \
715 __asm__ __volatile__( \
716 ".set\tmips64\n\t" \
717 "dmfc0\t%M0, " #source "\n\t" \
718 "dsll\t%L0, %M0, 32\n\t" \
719 "dsrl\t%M0, %M0, 32\n\t" \
720 "dsrl\t%L0, %L0, 32\n\t" \
721 ".set\tmips0" \
722 : "=r" (__val)); \
723 else \
724 __asm__ __volatile__( \
725 ".set\tmips64\n\t" \
726 "dmfc0\t%M0, " #source ", " #sel "\n\t" \
727 "dsll\t%L0, %M0, 32\n\t" \
728 "dsrl\t%M0, %M0, 32\n\t" \
729 "dsrl\t%L0, %L0, 32\n\t" \
730 ".set\tmips0" \
731 : "=r" (__val)); \
732 local_irq_restore(__flags); \
733 \
734 __val; \
735})
736
737#define __write_64bit_c0_split(source, sel, val) \
738do { \
739 unsigned long __flags; \
740 \
741 local_irq_save(__flags); \
742 if (sel == 0) \
743 __asm__ __volatile__( \
744 ".set\tmips64\n\t" \
745 "dsll\t%L0, %L0, 32\n\t" \
746 "dsrl\t%L0, %L0, 32\n\t" \
747 "dsll\t%M0, %M0, 32\n\t" \
748 "or\t%L0, %L0, %M0\n\t" \
749 "dmtc0\t%L0, " #source "\n\t" \
750 ".set\tmips0" \
751 : : "r" (val)); \
752 else \
753 __asm__ __volatile__( \
754 ".set\tmips64\n\t" \
755 "dsll\t%L0, %L0, 32\n\t" \
756 "dsrl\t%L0, %L0, 32\n\t" \
757 "dsll\t%M0, %M0, 32\n\t" \
758 "or\t%L0, %L0, %M0\n\t" \
759 "dmtc0\t%L0, " #source ", " #sel "\n\t" \
760 ".set\tmips0" \
761 : : "r" (val)); \
762 local_irq_restore(__flags); \
763} while (0)
764
765#define read_c0_index() __read_32bit_c0_register($0, 0)
766#define write_c0_index(val) __write_32bit_c0_register($0, 0, val)
767
768#define read_c0_random() __read_32bit_c0_register($1, 0)
769#define write_c0_random(val) __write_32bit_c0_register($1, 0, val)
770
771#define read_c0_entrylo0() __read_ulong_c0_register($2, 0)
772#define write_c0_entrylo0(val) __write_ulong_c0_register($2, 0, val)
773
774#define read_c0_entrylo1() __read_ulong_c0_register($3, 0)
775#define write_c0_entrylo1(val) __write_ulong_c0_register($3, 0, val)
776
777#define read_c0_conf() __read_32bit_c0_register($3, 0)
778#define write_c0_conf(val) __write_32bit_c0_register($3, 0, val)
779
780#define read_c0_context() __read_ulong_c0_register($4, 0)
781#define write_c0_context(val) __write_ulong_c0_register($4, 0, val)
782
783#define read_c0_userlocal() __read_ulong_c0_register($4, 2)
784#define write_c0_userlocal(val) __write_ulong_c0_register($4, 2, val)
785
786#define read_c0_pagemask() __read_32bit_c0_register($5, 0)
787#define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val)
788
789#define read_c0_wired() __read_32bit_c0_register($6, 0)
790#define write_c0_wired(val) __write_32bit_c0_register($6, 0, val)
791
792#define read_c0_info() __read_32bit_c0_register($7, 0)
793
794#define read_c0_cache() __read_32bit_c0_register($7, 0) /* TX39xx */
795#define write_c0_cache(val) __write_32bit_c0_register($7, 0, val)
796
797#define read_c0_badvaddr() __read_ulong_c0_register($8, 0)
798#define write_c0_badvaddr(val) __write_ulong_c0_register($8, 0, val)
799
800#define read_c0_count() __read_32bit_c0_register($9, 0)
801#define write_c0_count(val) __write_32bit_c0_register($9, 0, val)
802
803#define read_c0_count2() __read_32bit_c0_register($9, 6) /* pnx8550 */
804#define write_c0_count2(val) __write_32bit_c0_register($9, 6, val)
805
806#define read_c0_count3() __read_32bit_c0_register($9, 7) /* pnx8550 */
807#define write_c0_count3(val) __write_32bit_c0_register($9, 7, val)
808
809#define read_c0_entryhi() __read_ulong_c0_register($10, 0)
810#define write_c0_entryhi(val) __write_ulong_c0_register($10, 0, val)
811
812#define read_c0_compare() __read_32bit_c0_register($11, 0)
813#define write_c0_compare(val) __write_32bit_c0_register($11, 0, val)
814
815#define read_c0_compare2() __read_32bit_c0_register($11, 6) /* pnx8550 */
816#define write_c0_compare2(val) __write_32bit_c0_register($11, 6, val)
817
818#define read_c0_compare3() __read_32bit_c0_register($11, 7) /* pnx8550 */
819#define write_c0_compare3(val) __write_32bit_c0_register($11, 7, val)
820
821#define read_c0_status() __read_32bit_c0_register($12, 0)
822#ifdef CONFIG_MIPS_MT_SMTC
823#define write_c0_status(val) \
824do { \
825 __write_32bit_c0_register($12, 0, val); \
826 __ehb(); \
827} while (0)
828#else
829/*
830 * Legacy non-SMTC code, which may be hazardous
831 * but which might not support EHB
832 */
833#define write_c0_status(val) __write_32bit_c0_register($12, 0, val)
834#endif /* CONFIG_MIPS_MT_SMTC */
835
836#define read_c0_cause() __read_32bit_c0_register($13, 0)
837#define write_c0_cause(val) __write_32bit_c0_register($13, 0, val)
838
839#define read_c0_epc() __read_ulong_c0_register($14, 0)
840#define write_c0_epc(val) __write_ulong_c0_register($14, 0, val)
841
842#define read_c0_prid() __read_32bit_c0_register($15, 0)
843
844#define read_c0_config() __read_32bit_c0_register($16, 0)
845#define read_c0_config1() __read_32bit_c0_register($16, 1)
846#define read_c0_config2() __read_32bit_c0_register($16, 2)
847#define read_c0_config3() __read_32bit_c0_register($16, 3)
848#define read_c0_config4() __read_32bit_c0_register($16, 4)
849#define read_c0_config5() __read_32bit_c0_register($16, 5)
850#define read_c0_config6() __read_32bit_c0_register($16, 6)
851#define read_c0_config7() __read_32bit_c0_register($16, 7)
852#define write_c0_config(val) __write_32bit_c0_register($16, 0, val)
853#define write_c0_config1(val) __write_32bit_c0_register($16, 1, val)
854#define write_c0_config2(val) __write_32bit_c0_register($16, 2, val)
855#define write_c0_config3(val) __write_32bit_c0_register($16, 3, val)
856#define write_c0_config4(val) __write_32bit_c0_register($16, 4, val)
857#define write_c0_config5(val) __write_32bit_c0_register($16, 5, val)
858#define write_c0_config6(val) __write_32bit_c0_register($16, 6, val)
859#define write_c0_config7(val) __write_32bit_c0_register($16, 7, val)
860
861/*
862 * The WatchLo register. There may be upto 8 of them.
863 */
864#define read_c0_watchlo0() __read_ulong_c0_register($18, 0)
865#define read_c0_watchlo1() __read_ulong_c0_register($18, 1)
866#define read_c0_watchlo2() __read_ulong_c0_register($18, 2)
867#define read_c0_watchlo3() __read_ulong_c0_register($18, 3)
868#define read_c0_watchlo4() __read_ulong_c0_register($18, 4)
869#define read_c0_watchlo5() __read_ulong_c0_register($18, 5)
870#define read_c0_watchlo6() __read_ulong_c0_register($18, 6)
871#define read_c0_watchlo7() __read_ulong_c0_register($18, 7)
872#define write_c0_watchlo0(val) __write_ulong_c0_register($18, 0, val)
873#define write_c0_watchlo1(val) __write_ulong_c0_register($18, 1, val)
874#define write_c0_watchlo2(val) __write_ulong_c0_register($18, 2, val)
875#define write_c0_watchlo3(val) __write_ulong_c0_register($18, 3, val)
876#define write_c0_watchlo4(val) __write_ulong_c0_register($18, 4, val)
877#define write_c0_watchlo5(val) __write_ulong_c0_register($18, 5, val)
878#define write_c0_watchlo6(val) __write_ulong_c0_register($18, 6, val)
879#define write_c0_watchlo7(val) __write_ulong_c0_register($18, 7, val)
880
881/*
882 * The WatchHi register. There may be upto 8 of them.
883 */
884#define read_c0_watchhi0() __read_32bit_c0_register($19, 0)
885#define read_c0_watchhi1() __read_32bit_c0_register($19, 1)
886#define read_c0_watchhi2() __read_32bit_c0_register($19, 2)
887#define read_c0_watchhi3() __read_32bit_c0_register($19, 3)
888#define read_c0_watchhi4() __read_32bit_c0_register($19, 4)
889#define read_c0_watchhi5() __read_32bit_c0_register($19, 5)
890#define read_c0_watchhi6() __read_32bit_c0_register($19, 6)
891#define read_c0_watchhi7() __read_32bit_c0_register($19, 7)
892
893#define write_c0_watchhi0(val) __write_32bit_c0_register($19, 0, val)
894#define write_c0_watchhi1(val) __write_32bit_c0_register($19, 1, val)
895#define write_c0_watchhi2(val) __write_32bit_c0_register($19, 2, val)
896#define write_c0_watchhi3(val) __write_32bit_c0_register($19, 3, val)
897#define write_c0_watchhi4(val) __write_32bit_c0_register($19, 4, val)
898#define write_c0_watchhi5(val) __write_32bit_c0_register($19, 5, val)
899#define write_c0_watchhi6(val) __write_32bit_c0_register($19, 6, val)
900#define write_c0_watchhi7(val) __write_32bit_c0_register($19, 7, val)
901
902#define read_c0_xcontext() __read_ulong_c0_register($20, 0)
903#define write_c0_xcontext(val) __write_ulong_c0_register($20, 0, val)
904
905#define read_c0_intcontrol() __read_32bit_c0_ctrl_register($20)
906#define write_c0_intcontrol(val) __write_32bit_c0_ctrl_register($20, val)
907
908#define read_c0_framemask() __read_32bit_c0_register($21, 0)
909#define write_c0_framemask(val) __write_32bit_c0_register($21, 0, val)
910
911/* RM9000 PerfControl performance counter control register */
912#define read_c0_perfcontrol() __read_32bit_c0_register($22, 0)
913#define write_c0_perfcontrol(val) __write_32bit_c0_register($22, 0, val)
914
915#define read_c0_diag() __read_32bit_c0_register($22, 0)
916#define write_c0_diag(val) __write_32bit_c0_register($22, 0, val)
917
918#define read_c0_diag1() __read_32bit_c0_register($22, 1)
919#define write_c0_diag1(val) __write_32bit_c0_register($22, 1, val)
920
921#define read_c0_diag2() __read_32bit_c0_register($22, 2)
922#define write_c0_diag2(val) __write_32bit_c0_register($22, 2, val)
923
924#define read_c0_diag3() __read_32bit_c0_register($22, 3)
925#define write_c0_diag3(val) __write_32bit_c0_register($22, 3, val)
926
927#define read_c0_diag4() __read_32bit_c0_register($22, 4)
928#define write_c0_diag4(val) __write_32bit_c0_register($22, 4, val)
929
930#define read_c0_diag5() __read_32bit_c0_register($22, 5)
931#define write_c0_diag5(val) __write_32bit_c0_register($22, 5, val)
932
933#define read_c0_debug() __read_32bit_c0_register($23, 0)
934#define write_c0_debug(val) __write_32bit_c0_register($23, 0, val)
935
936#define read_c0_depc() __read_ulong_c0_register($24, 0)
937#define write_c0_depc(val) __write_ulong_c0_register($24, 0, val)
938
939/*
940 * MIPS32 / MIPS64 performance counters
941 */
942#define read_c0_perfctrl0() __read_32bit_c0_register($25, 0)
943#define write_c0_perfctrl0(val) __write_32bit_c0_register($25, 0, val)
944#define read_c0_perfcntr0() __read_32bit_c0_register($25, 1)
945#define write_c0_perfcntr0(val) __write_32bit_c0_register($25, 1, val)
946#define read_c0_perfctrl1() __read_32bit_c0_register($25, 2)
947#define write_c0_perfctrl1(val) __write_32bit_c0_register($25, 2, val)
948#define read_c0_perfcntr1() __read_32bit_c0_register($25, 3)
949#define write_c0_perfcntr1(val) __write_32bit_c0_register($25, 3, val)
950#define read_c0_perfctrl2() __read_32bit_c0_register($25, 4)
951#define write_c0_perfctrl2(val) __write_32bit_c0_register($25, 4, val)
952#define read_c0_perfcntr2() __read_32bit_c0_register($25, 5)
953#define write_c0_perfcntr2(val) __write_32bit_c0_register($25, 5, val)
954#define read_c0_perfctrl3() __read_32bit_c0_register($25, 6)
955#define write_c0_perfctrl3(val) __write_32bit_c0_register($25, 6, val)
956#define read_c0_perfcntr3() __read_32bit_c0_register($25, 7)
957#define write_c0_perfcntr3(val) __write_32bit_c0_register($25, 7, val)
958
959/* RM9000 PerfCount performance counter register */
960#define read_c0_perfcount() __read_64bit_c0_register($25, 0)
961#define write_c0_perfcount(val) __write_64bit_c0_register($25, 0, val)
962
963#define read_c0_ecc() __read_32bit_c0_register($26, 0)
964#define write_c0_ecc(val) __write_32bit_c0_register($26, 0, val)
965
966#define read_c0_derraddr0() __read_ulong_c0_register($26, 1)
967#define write_c0_derraddr0(val) __write_ulong_c0_register($26, 1, val)
968
969#define read_c0_cacheerr() __read_32bit_c0_register($27, 0)
970
971#define read_c0_derraddr1() __read_ulong_c0_register($27, 1)
972#define write_c0_derraddr1(val) __write_ulong_c0_register($27, 1, val)
973
974#define read_c0_taglo() __read_32bit_c0_register($28, 0)
975#define write_c0_taglo(val) __write_32bit_c0_register($28, 0, val)
976
977#define read_c0_dtaglo() __read_32bit_c0_register($28, 2)
978#define write_c0_dtaglo(val) __write_32bit_c0_register($28, 2, val)
979
980#define read_c0_taghi() __read_32bit_c0_register($29, 0)
981#define write_c0_taghi(val) __write_32bit_c0_register($29, 0, val)
982
983#define read_c0_errorepc() __read_ulong_c0_register($30, 0)
984#define write_c0_errorepc(val) __write_ulong_c0_register($30, 0, val)
985
986/* MIPSR2 */
987#define read_c0_hwrena() __read_32bit_c0_register($7, 0)
988#define write_c0_hwrena(val) __write_32bit_c0_register($7, 0, val)
989
990#define read_c0_intctl() __read_32bit_c0_register($12, 1)
991#define write_c0_intctl(val) __write_32bit_c0_register($12, 1, val)
992
993#define read_c0_srsctl() __read_32bit_c0_register($12, 2)
994#define write_c0_srsctl(val) __write_32bit_c0_register($12, 2, val)
995
996#define read_c0_srsmap() __read_32bit_c0_register($12, 3)
997#define write_c0_srsmap(val) __write_32bit_c0_register($12, 3, val)
998
999#define read_c0_ebase() __read_32bit_c0_register($15, 1)
1000#define write_c0_ebase(val) __write_32bit_c0_register($15, 1, val)
1001
1002/*
1003 * Macros to access the floating point coprocessor control registers
1004 */
1005#define read_32bit_cp1_register(source) \
1006({ int __res; \
1007 __asm__ __volatile__( \
1008 ".set\tpush\n\t" \
1009 ".set\treorder\n\t" \
1010 "cfc1\t%0,"STR(source)"\n\t" \
1011 ".set\tpop" \
1012 : "=r" (__res)); \
1013 __res;})
1014
1015#define rddsp(mask) \
1016({ \
1017 unsigned int __res; \
1018 \
1019 __asm__ __volatile__( \
1020 " .set push \n" \
1021 " .set noat \n" \
1022 " # rddsp $1, %x1 \n" \
1023 " .word 0x7c000cb8 | (%x1 << 16) \n" \
1024 " move %0, $1 \n" \
1025 " .set pop \n" \
1026 : "=r" (__res) \
1027 : "i" (mask)); \
1028 __res; \
1029})
1030
1031#define wrdsp(val, mask) \
1032do { \
1033 __asm__ __volatile__( \
1034 " .set push \n" \
1035 " .set noat \n" \
1036 " move $1, %0 \n" \
1037 " # wrdsp $1, %x1 \n" \
1038 " .word 0x7c2004f8 | (%x1 << 11) \n" \
1039 " .set pop \n" \
1040 : \
1041 : "r" (val), "i" (mask)); \
1042} while (0)
1043
1044#if 0 /* Need DSP ASE capable assembler ... */
1045#define mflo0() ({ long mflo0; __asm__("mflo %0, $ac0" : "=r" (mflo0)); mflo0;})
1046#define mflo1() ({ long mflo1; __asm__("mflo %0, $ac1" : "=r" (mflo1)); mflo1;})
1047#define mflo2() ({ long mflo2; __asm__("mflo %0, $ac2" : "=r" (mflo2)); mflo2;})
1048#define mflo3() ({ long mflo3; __asm__("mflo %0, $ac3" : "=r" (mflo3)); mflo3;})
1049
1050#define mfhi0() ({ long mfhi0; __asm__("mfhi %0, $ac0" : "=r" (mfhi0)); mfhi0;})
1051#define mfhi1() ({ long mfhi1; __asm__("mfhi %0, $ac1" : "=r" (mfhi1)); mfhi1;})
1052#define mfhi2() ({ long mfhi2; __asm__("mfhi %0, $ac2" : "=r" (mfhi2)); mfhi2;})
1053#define mfhi3() ({ long mfhi3; __asm__("mfhi %0, $ac3" : "=r" (mfhi3)); mfhi3;})
1054
1055#define mtlo0(x) __asm__("mtlo %0, $ac0" ::"r" (x))
1056#define mtlo1(x) __asm__("mtlo %0, $ac1" ::"r" (x))
1057#define mtlo2(x) __asm__("mtlo %0, $ac2" ::"r" (x))
1058#define mtlo3(x) __asm__("mtlo %0, $ac3" ::"r" (x))
1059
1060#define mthi0(x) __asm__("mthi %0, $ac0" ::"r" (x))
1061#define mthi1(x) __asm__("mthi %0, $ac1" ::"r" (x))
1062#define mthi2(x) __asm__("mthi %0, $ac2" ::"r" (x))
1063#define mthi3(x) __asm__("mthi %0, $ac3" ::"r" (x))
1064
1065#else
1066
1067#define mfhi0() \
1068({ \
1069 unsigned long __treg; \
1070 \
1071 __asm__ __volatile__( \
1072 " .set push \n" \
1073 " .set noat \n" \
1074 " # mfhi %0, $ac0 \n" \
1075 " .word 0x00000810 \n" \
1076 " move %0, $1 \n" \
1077 " .set pop \n" \
1078 : "=r" (__treg)); \
1079 __treg; \
1080})
1081
1082#define mfhi1() \
1083({ \
1084 unsigned long __treg; \
1085 \
1086 __asm__ __volatile__( \
1087 " .set push \n" \
1088 " .set noat \n" \
1089 " # mfhi %0, $ac1 \n" \
1090 " .word 0x00200810 \n" \
1091 " move %0, $1 \n" \
1092 " .set pop \n" \
1093 : "=r" (__treg)); \
1094 __treg; \
1095})
1096
1097#define mfhi2() \
1098({ \
1099 unsigned long __treg; \
1100 \
1101 __asm__ __volatile__( \
1102 " .set push \n" \
1103 " .set noat \n" \
1104 " # mfhi %0, $ac2 \n" \
1105 " .word 0x00400810 \n" \
1106 " move %0, $1 \n" \
1107 " .set pop \n" \
1108 : "=r" (__treg)); \
1109 __treg; \
1110})
1111
1112#define mfhi3() \
1113({ \
1114 unsigned long __treg; \
1115 \
1116 __asm__ __volatile__( \
1117 " .set push \n" \
1118 " .set noat \n" \
1119 " # mfhi %0, $ac3 \n" \
1120 " .word 0x00600810 \n" \
1121 " move %0, $1 \n" \
1122 " .set pop \n" \
1123 : "=r" (__treg)); \
1124 __treg; \
1125})
1126
1127#define mflo0() \
1128({ \
1129 unsigned long __treg; \
1130 \
1131 __asm__ __volatile__( \
1132 " .set push \n" \
1133 " .set noat \n" \
1134 " # mflo %0, $ac0 \n" \
1135 " .word 0x00000812 \n" \
1136 " move %0, $1 \n" \
1137 " .set pop \n" \
1138 : "=r" (__treg)); \
1139 __treg; \
1140})
1141
1142#define mflo1() \
1143({ \
1144 unsigned long __treg; \
1145 \
1146 __asm__ __volatile__( \
1147 " .set push \n" \
1148 " .set noat \n" \
1149 " # mflo %0, $ac1 \n" \
1150 " .word 0x00200812 \n" \
1151 " move %0, $1 \n" \
1152 " .set pop \n" \
1153 : "=r" (__treg)); \
1154 __treg; \
1155})
1156
1157#define mflo2() \
1158({ \
1159 unsigned long __treg; \
1160 \
1161 __asm__ __volatile__( \
1162 " .set push \n" \
1163 " .set noat \n" \
1164 " # mflo %0, $ac2 \n" \
1165 " .word 0x00400812 \n" \
1166 " move %0, $1 \n" \
1167 " .set pop \n" \
1168 : "=r" (__treg)); \
1169 __treg; \
1170})
1171
1172#define mflo3() \
1173({ \
1174 unsigned long __treg; \
1175 \
1176 __asm__ __volatile__( \
1177 " .set push \n" \
1178 " .set noat \n" \
1179 " # mflo %0, $ac3 \n" \
1180 " .word 0x00600812 \n" \
1181 " move %0, $1 \n" \
1182 " .set pop \n" \
1183 : "=r" (__treg)); \
1184 __treg; \
1185})
1186
1187#define mthi0(x) \
1188do { \
1189 __asm__ __volatile__( \
1190 " .set push \n" \
1191 " .set noat \n" \
1192 " move $1, %0 \n" \
1193 " # mthi $1, $ac0 \n" \
1194 " .word 0x00200011 \n" \
1195 " .set pop \n" \
1196 : \
1197 : "r" (x)); \
1198} while (0)
1199
1200#define mthi1(x) \
1201do { \
1202 __asm__ __volatile__( \
1203 " .set push \n" \
1204 " .set noat \n" \
1205 " move $1, %0 \n" \
1206 " # mthi $1, $ac1 \n" \
1207 " .word 0x00200811 \n" \
1208 " .set pop \n" \
1209 : \
1210 : "r" (x)); \
1211} while (0)
1212
1213#define mthi2(x) \
1214do { \
1215 __asm__ __volatile__( \
1216 " .set push \n" \
1217 " .set noat \n" \
1218 " move $1, %0 \n" \
1219 " # mthi $1, $ac2 \n" \
1220 " .word 0x00201011 \n" \
1221 " .set pop \n" \
1222 : \
1223 : "r" (x)); \
1224} while (0)
1225
1226#define mthi3(x) \
1227do { \
1228 __asm__ __volatile__( \
1229 " .set push \n" \
1230 " .set noat \n" \
1231 " move $1, %0 \n" \
1232 " # mthi $1, $ac3 \n" \
1233 " .word 0x00201811 \n" \
1234 " .set pop \n" \
1235 : \
1236 : "r" (x)); \
1237} while (0)
1238
1239#define mtlo0(x) \
1240do { \
1241 __asm__ __volatile__( \
1242 " .set push \n" \
1243 " .set noat \n" \
1244 " move $1, %0 \n" \
1245 " # mtlo $1, $ac0 \n" \
1246 " .word 0x00200013 \n" \
1247 " .set pop \n" \
1248 : \
1249 : "r" (x)); \
1250} while (0)
1251
1252#define mtlo1(x) \
1253do { \
1254 __asm__ __volatile__( \
1255 " .set push \n" \
1256 " .set noat \n" \
1257 " move $1, %0 \n" \
1258 " # mtlo $1, $ac1 \n" \
1259 " .word 0x00200813 \n" \
1260 " .set pop \n" \
1261 : \
1262 : "r" (x)); \
1263} while (0)
1264
1265#define mtlo2(x) \
1266do { \
1267 __asm__ __volatile__( \
1268 " .set push \n" \
1269 " .set noat \n" \
1270 " move $1, %0 \n" \
1271 " # mtlo $1, $ac2 \n" \
1272 " .word 0x00201013 \n" \
1273 " .set pop \n" \
1274 : \
1275 : "r" (x)); \
1276} while (0)
1277
1278#define mtlo3(x) \
1279do { \
1280 __asm__ __volatile__( \
1281 " .set push \n" \
1282 " .set noat \n" \
1283 " move $1, %0 \n" \
1284 " # mtlo $1, $ac3 \n" \
1285 " .word 0x00201813 \n" \
1286 " .set pop \n" \
1287 : \
1288 : "r" (x)); \
1289} while (0)
1290
1291#endif
1292
1293/*
1294 * TLB operations.
1295 *
1296 * It is responsibility of the caller to take care of any TLB hazards.
1297 */
1298static inline void tlb_probe(void)
1299{
1300 __asm__ __volatile__(
1301 ".set noreorder\n\t"
1302 "tlbp\n\t"
1303 ".set reorder");
1304}
1305
1306static inline void tlb_read(void)
1307{
1308#if MIPS34K_MISSED_ITLB_WAR
1309 int res = 0;
1310
1311 __asm__ __volatile__(
1312 " .set push \n"
1313 " .set noreorder \n"
1314 " .set noat \n"
1315 " .set mips32r2 \n"
1316 " .word 0x41610001 # dvpe $1 \n"
1317 " move %0, $1 \n"
1318 " ehb \n"
1319 " .set pop \n"
1320 : "=r" (res));
1321
1322 instruction_hazard();
1323#endif
1324
1325 __asm__ __volatile__(
1326 ".set noreorder\n\t"
1327 "tlbr\n\t"
1328 ".set reorder");
1329
1330#if MIPS34K_MISSED_ITLB_WAR
1331 if ((res & _ULCAST_(1)))
1332 __asm__ __volatile__(
1333 " .set push \n"
1334 " .set noreorder \n"
1335 " .set noat \n"
1336 " .set mips32r2 \n"
1337 " .word 0x41600021 # evpe \n"
1338 " ehb \n"
1339 " .set pop \n");
1340#endif
1341}
1342
1343static inline void tlb_write_indexed(void)
1344{
1345 __asm__ __volatile__(
1346 ".set noreorder\n\t"
1347 "tlbwi\n\t"
1348 ".set reorder");
1349}
1350
1351static inline void tlb_write_random(void)
1352{
1353 __asm__ __volatile__(
1354 ".set noreorder\n\t"
1355 "tlbwr\n\t"
1356 ".set reorder");
1357}
1358
1359/*
1360 * Manipulate bits in a c0 register.
1361 */
1362#ifndef CONFIG_MIPS_MT_SMTC
1363/*
1364 * SMTC Linux requires shutting-down microthread scheduling
1365 * during CP0 register read-modify-write sequences.
1366 */
1367#define __BUILD_SET_C0(name) \
1368static inline unsigned int \
1369set_c0_##name(unsigned int set) \
1370{ \
1371 unsigned int res; \
1372 \
1373 res = read_c0_##name(); \
1374 res |= set; \
1375 write_c0_##name(res); \
1376 \
1377 return res; \
1378} \
1379 \
1380static inline unsigned int \
1381clear_c0_##name(unsigned int clear) \
1382{ \
1383 unsigned int res; \
1384 \
1385 res = read_c0_##name(); \
1386 res &= ~clear; \
1387 write_c0_##name(res); \
1388 \
1389 return res; \
1390} \
1391 \
1392static inline unsigned int \
1393change_c0_##name(unsigned int change, unsigned int new) \
1394{ \
1395 unsigned int res; \
1396 \
1397 res = read_c0_##name(); \
1398 res &= ~change; \
1399 res |= (new & change); \
1400 write_c0_##name(res); \
1401 \
1402 return res; \
1403}
1404
1405#else /* SMTC versions that manage MT scheduling */
1406
1407#include <linux/irqflags.h>
1408
1409/*
1410 * This is a duplicate of dmt() in mipsmtregs.h to avoid problems with
1411 * header file recursion.
1412 */
1413static inline unsigned int __dmt(void)
1414{
1415 int res;
1416
1417 __asm__ __volatile__(
1418 " .set push \n"
1419 " .set mips32r2 \n"
1420 " .set noat \n"
1421 " .word 0x41610BC1 # dmt $1 \n"
1422 " ehb \n"
1423 " move %0, $1 \n"
1424 " .set pop \n"
1425 : "=r" (res));
1426
1427 instruction_hazard();
1428
1429 return res;
1430}
1431
1432#define __VPECONTROL_TE_SHIFT 15
1433#define __VPECONTROL_TE (1UL << __VPECONTROL_TE_SHIFT)
1434
1435#define __EMT_ENABLE __VPECONTROL_TE
1436
1437static inline void __emt(unsigned int previous)
1438{
1439 if ((previous & __EMT_ENABLE))
1440 __asm__ __volatile__(
1441 " .set mips32r2 \n"
1442 " .word 0x41600be1 # emt \n"
1443 " ehb \n"
1444 " .set mips0 \n");
1445}
1446
1447static inline void __ehb(void)
1448{
1449 __asm__ __volatile__(
1450 " .set mips32r2 \n"
1451 " ehb \n" " .set mips0 \n");
1452}
1453
1454/*
1455 * Note that local_irq_save/restore affect TC-specific IXMT state,
1456 * not Status.IE as in non-SMTC kernel.
1457 */
1458
1459#define __BUILD_SET_C0(name) \
1460static inline unsigned int \
1461set_c0_##name(unsigned int set) \
1462{ \
1463 unsigned int res; \
1464 unsigned int omt; \
1465 unsigned long flags; \
1466 \
1467 local_irq_save(flags); \
1468 omt = __dmt(); \
1469 res = read_c0_##name(); \
1470 res |= set; \
1471 write_c0_##name(res); \
1472 __emt(omt); \
1473 local_irq_restore(flags); \
1474 \
1475 return res; \
1476} \
1477 \
1478static inline unsigned int \
1479clear_c0_##name(unsigned int clear) \
1480{ \
1481 unsigned int res; \
1482 unsigned int omt; \
1483 unsigned long flags; \
1484 \
1485 local_irq_save(flags); \
1486 omt = __dmt(); \
1487 res = read_c0_##name(); \
1488 res &= ~clear; \
1489 write_c0_##name(res); \
1490 __emt(omt); \
1491 local_irq_restore(flags); \
1492 \
1493 return res; \
1494} \
1495 \
1496static inline unsigned int \
1497change_c0_##name(unsigned int change, unsigned int new) \
1498{ \
1499 unsigned int res; \
1500 unsigned int omt; \
1501 unsigned long flags; \
1502 \
1503 local_irq_save(flags); \
1504 \
1505 omt = __dmt(); \
1506 res = read_c0_##name(); \
1507 res &= ~change; \
1508 res |= (new & change); \
1509 write_c0_##name(res); \
1510 __emt(omt); \
1511 local_irq_restore(flags); \
1512 \
1513 return res; \
1514}
1515#endif
1516
1517__BUILD_SET_C0(status)
1518__BUILD_SET_C0(cause)
1519__BUILD_SET_C0(config)
1520__BUILD_SET_C0(intcontrol)
1521__BUILD_SET_C0(intctl)
1522__BUILD_SET_C0(srsmap)
1523
1524#endif /* !__ASSEMBLY__ */
1525
1526#endif /* _ASM_MIPSREGS_H */
diff --git a/arch/mips/include/asm/mman.h b/arch/mips/include/asm/mman.h
new file mode 100644
index 000000000000..e4d6f1fb1cf7
--- /dev/null
+++ b/arch/mips/include/asm/mman.h
@@ -0,0 +1,77 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1999, 2002 by Ralf Baechle
7 */
8#ifndef _ASM_MMAN_H
9#define _ASM_MMAN_H
10
11/*
12 * Protections are chosen from these bits, OR'd together. The
13 * implementation does not necessarily support PROT_EXEC or PROT_WRITE
14 * without PROT_READ. The only guarantees are that no writing will be
15 * allowed without PROT_WRITE and no access will be allowed for PROT_NONE.
16 */
17#define PROT_NONE 0x00 /* page can not be accessed */
18#define PROT_READ 0x01 /* page can be read */
19#define PROT_WRITE 0x02 /* page can be written */
20#define PROT_EXEC 0x04 /* page can be executed */
21/* 0x08 reserved for PROT_EXEC_NOFLUSH */
22#define PROT_SEM 0x10 /* page may be used for atomic ops */
23#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
24#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
25
26/*
27 * Flags for mmap
28 */
29#define MAP_SHARED 0x001 /* Share changes */
30#define MAP_PRIVATE 0x002 /* Changes are private */
31#define MAP_TYPE 0x00f /* Mask for type of mapping */
32#define MAP_FIXED 0x010 /* Interpret addr exactly */
33
34/* not used by linux, but here to make sure we don't clash with ABI defines */
35#define MAP_RENAME 0x020 /* Assign page to file */
36#define MAP_AUTOGROW 0x040 /* File may grow by writing */
37#define MAP_LOCAL 0x080 /* Copy on fork/sproc */
38#define MAP_AUTORSRV 0x100 /* Logical swap reserved on demand */
39
40/* These are linux-specific */
41#define MAP_NORESERVE 0x0400 /* don't check for reservations */
42#define MAP_ANONYMOUS 0x0800 /* don't use a file */
43#define MAP_GROWSDOWN 0x1000 /* stack-like segment */
44#define MAP_DENYWRITE 0x2000 /* ETXTBSY */
45#define MAP_EXECUTABLE 0x4000 /* mark it as an executable */
46#define MAP_LOCKED 0x8000 /* pages are locked */
47#define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
48#define MAP_NONBLOCK 0x20000 /* do not block on IO */
49
50/*
51 * Flags for msync
52 */
53#define MS_ASYNC 0x0001 /* sync memory asynchronously */
54#define MS_INVALIDATE 0x0002 /* invalidate mappings & caches */
55#define MS_SYNC 0x0004 /* synchronous memory sync */
56
57/*
58 * Flags for mlockall
59 */
60#define MCL_CURRENT 1 /* lock all current mappings */
61#define MCL_FUTURE 2 /* lock all future mappings */
62
63#define MADV_NORMAL 0 /* no further special treatment */
64#define MADV_RANDOM 1 /* expect random page references */
65#define MADV_SEQUENTIAL 2 /* expect sequential page references */
66#define MADV_WILLNEED 3 /* will need these pages */
67#define MADV_DONTNEED 4 /* don't need these pages */
68
69/* common parameters: try to keep these consistent across architectures */
70#define MADV_REMOVE 9 /* remove these pages & resources */
71#define MADV_DONTFORK 10 /* don't inherit across fork */
72#define MADV_DOFORK 11 /* do inherit across fork */
73
74/* compatibility flags */
75#define MAP_FILE 0
76
77#endif /* _ASM_MMAN_H */
diff --git a/arch/mips/include/asm/mmu.h b/arch/mips/include/asm/mmu.h
new file mode 100644
index 000000000000..4063edd79623
--- /dev/null
+++ b/arch/mips/include/asm/mmu.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_MMU_H
2#define __ASM_MMU_H
3
4typedef unsigned long mm_context_t[NR_CPUS];
5
6#endif /* __ASM_MMU_H */
diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h
new file mode 100644
index 000000000000..d7f3eb03ad12
--- /dev/null
+++ b/arch/mips/include/asm/mmu_context.h
@@ -0,0 +1,297 @@
1/*
2 * Switch a MMU context.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1996, 1997, 1998, 1999 by Ralf Baechle
9 * Copyright (C) 1999 Silicon Graphics, Inc.
10 */
11#ifndef _ASM_MMU_CONTEXT_H
12#define _ASM_MMU_CONTEXT_H
13
14#include <linux/errno.h>
15#include <linux/sched.h>
16#include <linux/slab.h>
17#include <asm/cacheflush.h>
18#include <asm/tlbflush.h>
19#ifdef CONFIG_MIPS_MT_SMTC
20#include <asm/mipsmtregs.h>
21#include <asm/smtc.h>
22#endif /* SMTC */
23#include <asm-generic/mm_hooks.h>
24
25/*
26 * For the fast tlb miss handlers, we keep a per cpu array of pointers
27 * to the current pgd for each processor. Also, the proc. id is stuffed
28 * into the context register.
29 */
30extern unsigned long pgd_current[];
31
32#define TLBMISS_HANDLER_SETUP_PGD(pgd) \
33 pgd_current[smp_processor_id()] = (unsigned long)(pgd)
34
35#ifdef CONFIG_32BIT
36#define TLBMISS_HANDLER_SETUP() \
37 write_c0_context((unsigned long) smp_processor_id() << 25); \
38 TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
39#endif
40#ifdef CONFIG_64BIT
41#define TLBMISS_HANDLER_SETUP() \
42 write_c0_context((unsigned long) smp_processor_id() << 26); \
43 TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
44#endif
45
46#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
47
48#define ASID_INC 0x40
49#define ASID_MASK 0xfc0
50
51#elif defined(CONFIG_CPU_R8000)
52
53#define ASID_INC 0x10
54#define ASID_MASK 0xff0
55
56#elif defined(CONFIG_CPU_RM9000)
57
58#define ASID_INC 0x1
59#define ASID_MASK 0xfff
60
61/* SMTC/34K debug hack - but maybe we'll keep it */
62#elif defined(CONFIG_MIPS_MT_SMTC)
63
64#define ASID_INC 0x1
65extern unsigned long smtc_asid_mask;
66#define ASID_MASK (smtc_asid_mask)
67#define HW_ASID_MASK 0xff
68/* End SMTC/34K debug hack */
69#else /* FIXME: not correct for R6000 */
70
71#define ASID_INC 0x1
72#define ASID_MASK 0xff
73
74#endif
75
76#define cpu_context(cpu, mm) ((mm)->context[cpu])
77#define cpu_asid(cpu, mm) (cpu_context((cpu), (mm)) & ASID_MASK)
78#define asid_cache(cpu) (cpu_data[cpu].asid_cache)
79
80static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
81{
82}
83
84/*
85 * All unused by hardware upper bits will be considered
86 * as a software asid extension.
87 */
88#define ASID_VERSION_MASK ((unsigned long)~(ASID_MASK|(ASID_MASK-1)))
89#define ASID_FIRST_VERSION ((unsigned long)(~ASID_VERSION_MASK) + 1)
90
91#ifndef CONFIG_MIPS_MT_SMTC
92/* Normal, classic MIPS get_new_mmu_context */
93static inline void
94get_new_mmu_context(struct mm_struct *mm, unsigned long cpu)
95{
96 unsigned long asid = asid_cache(cpu);
97
98 if (! ((asid += ASID_INC) & ASID_MASK) ) {
99 if (cpu_has_vtag_icache)
100 flush_icache_all();
101 local_flush_tlb_all(); /* start new asid cycle */
102 if (!asid) /* fix version if needed */
103 asid = ASID_FIRST_VERSION;
104 }
105 cpu_context(cpu, mm) = asid_cache(cpu) = asid;
106}
107
108#else /* CONFIG_MIPS_MT_SMTC */
109
110#define get_new_mmu_context(mm, cpu) smtc_get_new_mmu_context((mm), (cpu))
111
112#endif /* CONFIG_MIPS_MT_SMTC */
113
114/*
115 * Initialize the context related info for a new mm_struct
116 * instance.
117 */
118static inline int
119init_new_context(struct task_struct *tsk, struct mm_struct *mm)
120{
121 int i;
122
123 for_each_online_cpu(i)
124 cpu_context(i, mm) = 0;
125
126 return 0;
127}
128
129static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
130 struct task_struct *tsk)
131{
132 unsigned int cpu = smp_processor_id();
133 unsigned long flags;
134#ifdef CONFIG_MIPS_MT_SMTC
135 unsigned long oldasid;
136 unsigned long mtflags;
137 int mytlb = (smtc_status & SMTC_TLB_SHARED) ? 0 : cpu_data[cpu].vpe_id;
138 local_irq_save(flags);
139 mtflags = dvpe();
140#else /* Not SMTC */
141 local_irq_save(flags);
142#endif /* CONFIG_MIPS_MT_SMTC */
143
144 /* Check if our ASID is of an older version and thus invalid */
145 if ((cpu_context(cpu, next) ^ asid_cache(cpu)) & ASID_VERSION_MASK)
146 get_new_mmu_context(next, cpu);
147#ifdef CONFIG_MIPS_MT_SMTC
148 /*
149 * If the EntryHi ASID being replaced happens to be
150 * the value flagged at ASID recycling time as having
151 * an extended life, clear the bit showing it being
152 * in use by this "CPU", and if that's the last bit,
153 * free up the ASID value for use and flush any old
154 * instances of it from the TLB.
155 */
156 oldasid = (read_c0_entryhi() & ASID_MASK);
157 if(smtc_live_asid[mytlb][oldasid]) {
158 smtc_live_asid[mytlb][oldasid] &= ~(0x1 << cpu);
159 if(smtc_live_asid[mytlb][oldasid] == 0)
160 smtc_flush_tlb_asid(oldasid);
161 }
162 /*
163 * Tread softly on EntryHi, and so long as we support
164 * having ASID_MASK smaller than the hardware maximum,
165 * make sure no "soft" bits become "hard"...
166 */
167 write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK)
168 | (cpu_context(cpu, next) & ASID_MASK));
169 ehb(); /* Make sure it propagates to TCStatus */
170 evpe(mtflags);
171#else
172 write_c0_entryhi(cpu_context(cpu, next));
173#endif /* CONFIG_MIPS_MT_SMTC */
174 TLBMISS_HANDLER_SETUP_PGD(next->pgd);
175
176 /*
177 * Mark current->active_mm as not "active" anymore.
178 * We don't want to mislead possible IPI tlb flush routines.
179 */
180 cpu_clear(cpu, prev->cpu_vm_mask);
181 cpu_set(cpu, next->cpu_vm_mask);
182
183 local_irq_restore(flags);
184}
185
186/*
187 * Destroy context related info for an mm_struct that is about
188 * to be put to rest.
189 */
190static inline void destroy_context(struct mm_struct *mm)
191{
192}
193
194#define deactivate_mm(tsk, mm) do { } while (0)
195
196/*
197 * After we have set current->mm to a new value, this activates
198 * the context for the new mm so we see the new mappings.
199 */
200static inline void
201activate_mm(struct mm_struct *prev, struct mm_struct *next)
202{
203 unsigned long flags;
204 unsigned int cpu = smp_processor_id();
205
206#ifdef CONFIG_MIPS_MT_SMTC
207 unsigned long oldasid;
208 unsigned long mtflags;
209 int mytlb = (smtc_status & SMTC_TLB_SHARED) ? 0 : cpu_data[cpu].vpe_id;
210#endif /* CONFIG_MIPS_MT_SMTC */
211
212 local_irq_save(flags);
213
214 /* Unconditionally get a new ASID. */
215 get_new_mmu_context(next, cpu);
216
217#ifdef CONFIG_MIPS_MT_SMTC
218 /* See comments for similar code above */
219 mtflags = dvpe();
220 oldasid = read_c0_entryhi() & ASID_MASK;
221 if(smtc_live_asid[mytlb][oldasid]) {
222 smtc_live_asid[mytlb][oldasid] &= ~(0x1 << cpu);
223 if(smtc_live_asid[mytlb][oldasid] == 0)
224 smtc_flush_tlb_asid(oldasid);
225 }
226 /* See comments for similar code above */
227 write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK) |
228 (cpu_context(cpu, next) & ASID_MASK));
229 ehb(); /* Make sure it propagates to TCStatus */
230 evpe(mtflags);
231#else
232 write_c0_entryhi(cpu_context(cpu, next));
233#endif /* CONFIG_MIPS_MT_SMTC */
234 TLBMISS_HANDLER_SETUP_PGD(next->pgd);
235
236 /* mark mmu ownership change */
237 cpu_clear(cpu, prev->cpu_vm_mask);
238 cpu_set(cpu, next->cpu_vm_mask);
239
240 local_irq_restore(flags);
241}
242
243/*
244 * If mm is currently active_mm, we can't really drop it. Instead,
245 * we will get a new one for it.
246 */
247static inline void
248drop_mmu_context(struct mm_struct *mm, unsigned cpu)
249{
250 unsigned long flags;
251#ifdef CONFIG_MIPS_MT_SMTC
252 unsigned long oldasid;
253 /* Can't use spinlock because called from TLB flush within DVPE */
254 unsigned int prevvpe;
255 int mytlb = (smtc_status & SMTC_TLB_SHARED) ? 0 : cpu_data[cpu].vpe_id;
256#endif /* CONFIG_MIPS_MT_SMTC */
257
258 local_irq_save(flags);
259
260 if (cpu_isset(cpu, mm->cpu_vm_mask)) {
261 get_new_mmu_context(mm, cpu);
262#ifdef CONFIG_MIPS_MT_SMTC
263 /* See comments for similar code above */
264 prevvpe = dvpe();
265 oldasid = (read_c0_entryhi() & ASID_MASK);
266 if (smtc_live_asid[mytlb][oldasid]) {
267 smtc_live_asid[mytlb][oldasid] &= ~(0x1 << cpu);
268 if(smtc_live_asid[mytlb][oldasid] == 0)
269 smtc_flush_tlb_asid(oldasid);
270 }
271 /* See comments for similar code above */
272 write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK)
273 | cpu_asid(cpu, mm));
274 ehb(); /* Make sure it propagates to TCStatus */
275 evpe(prevvpe);
276#else /* not CONFIG_MIPS_MT_SMTC */
277 write_c0_entryhi(cpu_asid(cpu, mm));
278#endif /* CONFIG_MIPS_MT_SMTC */
279 } else {
280 /* will get a new context next time */
281#ifndef CONFIG_MIPS_MT_SMTC
282 cpu_context(cpu, mm) = 0;
283#else /* SMTC */
284 int i;
285
286 /* SMTC shares the TLB (and ASIDs) across VPEs */
287 for_each_online_cpu(i) {
288 if((smtc_status & SMTC_TLB_SHARED)
289 || (cpu_data[i].vpe_id == cpu_data[cpu].vpe_id))
290 cpu_context(i, mm) = 0;
291 }
292#endif /* CONFIG_MIPS_MT_SMTC */
293 }
294 local_irq_restore(flags);
295}
296
297#endif /* _ASM_MMU_CONTEXT_H */
diff --git a/arch/mips/include/asm/mmzone.h b/arch/mips/include/asm/mmzone.h
new file mode 100644
index 000000000000..f53ec54c92ff
--- /dev/null
+++ b/arch/mips/include/asm/mmzone.h
@@ -0,0 +1,17 @@
1/*
2 * Written by Kanoj Sarcar (kanoj@sgi.com) Aug 99
3 * Rewritten for Linux 2.6 by Christoph Hellwig (hch@lst.de) Jan 2004
4 */
5#ifndef _ASM_MMZONE_H_
6#define _ASM_MMZONE_H_
7
8#include <asm/page.h>
9#include <mmzone.h>
10
11#ifdef CONFIG_DISCONTIGMEM
12
13#define pfn_to_nid(pfn) pa_to_nid((pfn) << PAGE_SHIFT)
14
15#endif /* CONFIG_DISCONTIGMEM */
16
17#endif /* _ASM_MMZONE_H_ */
diff --git a/arch/mips/include/asm/module.h b/arch/mips/include/asm/module.h
new file mode 100644
index 000000000000..de6d09ebbd80
--- /dev/null
+++ b/arch/mips/include/asm/module.h
@@ -0,0 +1,136 @@
1#ifndef _ASM_MODULE_H
2#define _ASM_MODULE_H
3
4#include <linux/list.h>
5#include <asm/uaccess.h>
6
7struct mod_arch_specific {
8 /* Data Bus Error exception tables */
9 struct list_head dbe_list;
10 const struct exception_table_entry *dbe_start;
11 const struct exception_table_entry *dbe_end;
12};
13
14typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */
15
16typedef struct {
17 Elf64_Addr r_offset; /* Address of relocation. */
18 Elf64_Word r_sym; /* Symbol index. */
19 Elf64_Byte r_ssym; /* Special symbol. */
20 Elf64_Byte r_type3; /* Third relocation. */
21 Elf64_Byte r_type2; /* Second relocation. */
22 Elf64_Byte r_type; /* First relocation. */
23} Elf64_Mips_Rel;
24
25typedef struct {
26 Elf64_Addr r_offset; /* Address of relocation. */
27 Elf64_Word r_sym; /* Symbol index. */
28 Elf64_Byte r_ssym; /* Special symbol. */
29 Elf64_Byte r_type3; /* Third relocation. */
30 Elf64_Byte r_type2; /* Second relocation. */
31 Elf64_Byte r_type; /* First relocation. */
32 Elf64_Sxword r_addend; /* Addend. */
33} Elf64_Mips_Rela;
34
35#ifdef CONFIG_32BIT
36
37#define Elf_Shdr Elf32_Shdr
38#define Elf_Sym Elf32_Sym
39#define Elf_Ehdr Elf32_Ehdr
40#define Elf_Addr Elf32_Addr
41
42#define Elf_Mips_Rel Elf32_Rel
43#define Elf_Mips_Rela Elf32_Rela
44
45#define ELF_MIPS_R_SYM(rel) ELF32_R_SYM(rel.r_info)
46#define ELF_MIPS_R_TYPE(rel) ELF32_R_TYPE(rel.r_info)
47
48#endif
49
50#ifdef CONFIG_64BIT
51
52#define Elf_Shdr Elf64_Shdr
53#define Elf_Sym Elf64_Sym
54#define Elf_Ehdr Elf64_Ehdr
55#define Elf_Addr Elf64_Addr
56
57#define Elf_Mips_Rel Elf64_Mips_Rel
58#define Elf_Mips_Rela Elf64_Mips_Rela
59
60#define ELF_MIPS_R_SYM(rel) (rel.r_sym)
61#define ELF_MIPS_R_TYPE(rel) (rel.r_type)
62
63#endif
64
65#ifdef CONFIG_MODULES
66/* Given an address, look for it in the exception tables. */
67const struct exception_table_entry*search_module_dbetables(unsigned long addr);
68#else
69/* Given an address, look for it in the exception tables. */
70static inline const struct exception_table_entry *
71search_module_dbetables(unsigned long addr)
72{
73 return NULL;
74}
75#endif
76
77#ifdef CONFIG_CPU_MIPS32_R1
78#define MODULE_PROC_FAMILY "MIPS32_R1 "
79#elif defined CONFIG_CPU_MIPS32_R2
80#define MODULE_PROC_FAMILY "MIPS32_R2 "
81#elif defined CONFIG_CPU_MIPS64_R1
82#define MODULE_PROC_FAMILY "MIPS64_R1 "
83#elif defined CONFIG_CPU_MIPS64_R2
84#define MODULE_PROC_FAMILY "MIPS64_R2 "
85#elif defined CONFIG_CPU_R3000
86#define MODULE_PROC_FAMILY "R3000 "
87#elif defined CONFIG_CPU_TX39XX
88#define MODULE_PROC_FAMILY "TX39XX "
89#elif defined CONFIG_CPU_VR41XX
90#define MODULE_PROC_FAMILY "VR41XX "
91#elif defined CONFIG_CPU_R4300
92#define MODULE_PROC_FAMILY "R4300 "
93#elif defined CONFIG_CPU_R4X00
94#define MODULE_PROC_FAMILY "R4X00 "
95#elif defined CONFIG_CPU_TX49XX
96#define MODULE_PROC_FAMILY "TX49XX "
97#elif defined CONFIG_CPU_R5000
98#define MODULE_PROC_FAMILY "R5000 "
99#elif defined CONFIG_CPU_R5432
100#define MODULE_PROC_FAMILY "R5432 "
101#elif defined CONFIG_CPU_R6000
102#define MODULE_PROC_FAMILY "R6000 "
103#elif defined CONFIG_CPU_NEVADA
104#define MODULE_PROC_FAMILY "NEVADA "
105#elif defined CONFIG_CPU_R8000
106#define MODULE_PROC_FAMILY "R8000 "
107#elif defined CONFIG_CPU_R10000
108#define MODULE_PROC_FAMILY "R10000 "
109#elif defined CONFIG_CPU_RM7000
110#define MODULE_PROC_FAMILY "RM7000 "
111#elif defined CONFIG_CPU_RM9000
112#define MODULE_PROC_FAMILY "RM9000 "
113#elif defined CONFIG_CPU_SB1
114#define MODULE_PROC_FAMILY "SB1 "
115#elif defined CONFIG_CPU_LOONGSON2
116#define MODULE_PROC_FAMILY "LOONGSON2 "
117#else
118#error MODULE_PROC_FAMILY undefined for your processor configuration
119#endif
120
121#ifdef CONFIG_32BIT
122#define MODULE_KERNEL_TYPE "32BIT "
123#elif defined CONFIG_64BIT
124#define MODULE_KERNEL_TYPE "64BIT "
125#endif
126
127#ifdef CONFIG_MIPS_MT_SMTC
128#define MODULE_KERNEL_SMTC "MT_SMTC "
129#else
130#define MODULE_KERNEL_SMTC ""
131#endif
132
133#define MODULE_ARCH_VERMAGIC \
134 MODULE_PROC_FAMILY MODULE_KERNEL_TYPE MODULE_KERNEL_SMTC
135
136#endif /* _ASM_MODULE_H */
diff --git a/arch/mips/include/asm/msc01_ic.h b/arch/mips/include/asm/msc01_ic.h
new file mode 100644
index 000000000000..7989b9ffc1d2
--- /dev/null
+++ b/arch/mips/include/asm/msc01_ic.h
@@ -0,0 +1,148 @@
1/*
2 * PCI Register definitions for the MIPS System Controller.
3 *
4 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef __ASM_MIPS_BOARDS_MSC01_IC_H
12#define __ASM_MIPS_BOARDS_MSC01_IC_H
13
14/*****************************************************************************
15 * Register offset addresses
16 *****************************************************************************/
17
18#define MSC01_IC_RST_OFS 0x00008 /* Software reset */
19#define MSC01_IC_ENAL_OFS 0x00100 /* Int_in enable mask 31:0 */
20#define MSC01_IC_ENAH_OFS 0x00108 /* Int_in enable mask 63:32 */
21#define MSC01_IC_DISL_OFS 0x00120 /* Int_in disable mask 31:0 */
22#define MSC01_IC_DISH_OFS 0x00128 /* Int_in disable mask 63:32 */
23#define MSC01_IC_ISBL_OFS 0x00140 /* Raw int_in 31:0 */
24#define MSC01_IC_ISBH_OFS 0x00148 /* Raw int_in 63:32 */
25#define MSC01_IC_ISAL_OFS 0x00160 /* Masked int_in 31:0 */
26#define MSC01_IC_ISAH_OFS 0x00168 /* Masked int_in 63:32 */
27#define MSC01_IC_LVL_OFS 0x00180 /* Disable priority int_out */
28#define MSC01_IC_RAMW_OFS 0x00180 /* Shadow set RAM (EI) */
29#define MSC01_IC_OSB_OFS 0x00188 /* Raw int_out */
30#define MSC01_IC_OSA_OFS 0x00190 /* Masked int_out */
31#define MSC01_IC_GENA_OFS 0x00198 /* Global HW int enable */
32#define MSC01_IC_BASE_OFS 0x001a0 /* Base address of IC_VEC */
33#define MSC01_IC_VEC_OFS 0x001b0 /* Active int's vector address */
34#define MSC01_IC_EOI_OFS 0x001c0 /* Enable lower level ints */
35#define MSC01_IC_CFG_OFS 0x001c8 /* Configuration register */
36#define MSC01_IC_TRLD_OFS 0x001d0 /* Interval timer reload val */
37#define MSC01_IC_TVAL_OFS 0x001e0 /* Interval timer current val */
38#define MSC01_IC_TCFG_OFS 0x001f0 /* Interval timer config */
39#define MSC01_IC_SUP_OFS 0x00200 /* Set up int_in line 0 */
40#define MSC01_IC_ENA_OFS 0x00800 /* Int_in enable mask 63:0 */
41#define MSC01_IC_DIS_OFS 0x00820 /* Int_in disable mask 63:0 */
42#define MSC01_IC_ISB_OFS 0x00840 /* Raw int_in 63:0 */
43#define MSC01_IC_ISA_OFS 0x00860 /* Masked int_in 63:0 */
44
45/*****************************************************************************
46 * Register field encodings
47 *****************************************************************************/
48
49#define MSC01_IC_RST_RST_SHF 0
50#define MSC01_IC_RST_RST_MSK 0x00000001
51#define MSC01_IC_RST_RST_BIT MSC01_IC_RST_RST_MSK
52#define MSC01_IC_LVL_LVL_SHF 0
53#define MSC01_IC_LVL_LVL_MSK 0x000000ff
54#define MSC01_IC_LVL_SPUR_SHF 16
55#define MSC01_IC_LVL_SPUR_MSK 0x00010000
56#define MSC01_IC_LVL_SPUR_BIT MSC01_IC_LVL_SPUR_MSK
57#define MSC01_IC_RAMW_RIPL_SHF 0
58#define MSC01_IC_RAMW_RIPL_MSK 0x0000003f
59#define MSC01_IC_RAMW_DATA_SHF 6
60#define MSC01_IC_RAMW_DATA_MSK 0x00000fc0
61#define MSC01_IC_RAMW_ADDR_SHF 25
62#define MSC01_IC_RAMW_ADDR_MSK 0x7e000000
63#define MSC01_IC_RAMW_READ_SHF 31
64#define MSC01_IC_RAMW_READ_MSK 0x80000000
65#define MSC01_IC_RAMW_READ_BIT MSC01_IC_RAMW_READ_MSK
66#define MSC01_IC_OSB_OSB_SHF 0
67#define MSC01_IC_OSB_OSB_MSK 0x000000ff
68#define MSC01_IC_OSA_OSA_SHF 0
69#define MSC01_IC_OSA_OSA_MSK 0x000000ff
70#define MSC01_IC_GENA_GENA_SHF 0
71#define MSC01_IC_GENA_GENA_MSK 0x00000001
72#define MSC01_IC_GENA_GENA_BIT MSC01_IC_GENA_GENA_MSK
73#define MSC01_IC_CFG_DIS_SHF 0
74#define MSC01_IC_CFG_DIS_MSK 0x00000001
75#define MSC01_IC_CFG_DIS_BIT MSC01_IC_CFG_DIS_MSK
76#define MSC01_IC_CFG_SHFT_SHF 8
77#define MSC01_IC_CFG_SHFT_MSK 0x00000f00
78#define MSC01_IC_TCFG_ENA_SHF 0
79#define MSC01_IC_TCFG_ENA_MSK 0x00000001
80#define MSC01_IC_TCFG_ENA_BIT MSC01_IC_TCFG_ENA_MSK
81#define MSC01_IC_TCFG_INT_SHF 8
82#define MSC01_IC_TCFG_INT_MSK 0x00000100
83#define MSC01_IC_TCFG_INT_BIT MSC01_IC_TCFG_INT_MSK
84#define MSC01_IC_TCFG_EDGE_SHF 16
85#define MSC01_IC_TCFG_EDGE_MSK 0x00010000
86#define MSC01_IC_TCFG_EDGE_BIT MSC01_IC_TCFG_EDGE_MSK
87#define MSC01_IC_SUP_PRI_SHF 0
88#define MSC01_IC_SUP_PRI_MSK 0x00000007
89#define MSC01_IC_SUP_EDGE_SHF 8
90#define MSC01_IC_SUP_EDGE_MSK 0x00000100
91#define MSC01_IC_SUP_EDGE_BIT MSC01_IC_SUP_EDGE_MSK
92#define MSC01_IC_SUP_STEP 8
93
94/*
95 * MIPS System controller interrupt register base.
96 *
97 */
98
99/*****************************************************************************
100 * Absolute register addresses
101 *****************************************************************************/
102
103#define MSC01_IC_RST (MSC01_IC_REG_BASE + MSC01_IC_RST_OFS)
104#define MSC01_IC_ENAL (MSC01_IC_REG_BASE + MSC01_IC_ENAL_OFS)
105#define MSC01_IC_ENAH (MSC01_IC_REG_BASE + MSC01_IC_ENAH_OFS)
106#define MSC01_IC_DISL (MSC01_IC_REG_BASE + MSC01_IC_DISL_OFS)
107#define MSC01_IC_DISH (MSC01_IC_REG_BASE + MSC01_IC_DISH_OFS)
108#define MSC01_IC_ISBL (MSC01_IC_REG_BASE + MSC01_IC_ISBL_OFS)
109#define MSC01_IC_ISBH (MSC01_IC_REG_BASE + MSC01_IC_ISBH_OFS)
110#define MSC01_IC_ISAL (MSC01_IC_REG_BASE + MSC01_IC_ISAL_OFS)
111#define MSC01_IC_ISAH (MSC01_IC_REG_BASE + MSC01_IC_ISAH_OFS)
112#define MSC01_IC_LVL (MSC01_IC_REG_BASE + MSC01_IC_LVL_OFS)
113#define MSC01_IC_RAMW (MSC01_IC_REG_BASE + MSC01_IC_RAMW_OFS)
114#define MSC01_IC_OSB (MSC01_IC_REG_BASE + MSC01_IC_OSB_OFS)
115#define MSC01_IC_OSA (MSC01_IC_REG_BASE + MSC01_IC_OSA_OFS)
116#define MSC01_IC_GENA (MSC01_IC_REG_BASE + MSC01_IC_GENA_OFS)
117#define MSC01_IC_BASE (MSC01_IC_REG_BASE + MSC01_IC_BASE_OFS)
118#define MSC01_IC_VEC (MSC01_IC_REG_BASE + MSC01_IC_VEC_OFS)
119#define MSC01_IC_EOI (MSC01_IC_REG_BASE + MSC01_IC_EOI_OFS)
120#define MSC01_IC_CFG (MSC01_IC_REG_BASE + MSC01_IC_CFG_OFS)
121#define MSC01_IC_TRLD (MSC01_IC_REG_BASE + MSC01_IC_TRLD_OFS)
122#define MSC01_IC_TVAL (MSC01_IC_REG_BASE + MSC01_IC_TVAL_OFS)
123#define MSC01_IC_TCFG (MSC01_IC_REG_BASE + MSC01_IC_TCFG_OFS)
124#define MSC01_IC_SUP (MSC01_IC_REG_BASE + MSC01_IC_SUP_OFS)
125#define MSC01_IC_ENA (MSC01_IC_REG_BASE + MSC01_IC_ENA_OFS)
126#define MSC01_IC_DIS (MSC01_IC_REG_BASE + MSC01_IC_DIS_OFS)
127#define MSC01_IC_ISB (MSC01_IC_REG_BASE + MSC01_IC_ISB_OFS)
128#define MSC01_IC_ISA (MSC01_IC_REG_BASE + MSC01_IC_ISA_OFS)
129
130/*
131 * Soc-it interrupts are configurable.
132 * Every board describes its IRQ mapping with this table.
133 */
134typedef struct msc_irqmap {
135 int im_irq;
136 int im_type;
137 int im_lvl;
138} msc_irqmap_t;
139
140/* im_type */
141#define MSC01_IRQ_LEVEL 0
142#define MSC01_IRQ_EDGE 1
143
144extern void __init init_msc_irqs(unsigned long icubase, unsigned int base, msc_irqmap_t *imp, int nirq);
145extern void ll_msc_irq(void);
146
147#endif /* __ASM_MIPS_BOARDS_MSC01_IC_H */
148
diff --git a/arch/mips/include/asm/msgbuf.h b/arch/mips/include/asm/msgbuf.h
new file mode 100644
index 000000000000..0d6c7f14de31
--- /dev/null
+++ b/arch/mips/include/asm/msgbuf.h
@@ -0,0 +1,47 @@
1#ifndef _ASM_MSGBUF_H
2#define _ASM_MSGBUF_H
3
4
5/*
6 * The msqid64_ds structure for the MIPS architecture.
7 * Note extra padding because this structure is passed back and forth
8 * between kernel and user space.
9 *
10 * Pad space is left for:
11 * - extension of time_t to 64-bit on 32-bitsystem to solve the y2038 problem
12 * - 2 miscellaneous unsigned long values
13 */
14
15struct msqid64_ds {
16 struct ipc64_perm msg_perm;
17#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
18 unsigned long __unused1;
19#endif
20 __kernel_time_t msg_stime; /* last msgsnd time */
21#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN)
22 unsigned long __unused1;
23#endif
24#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
25 unsigned long __unused2;
26#endif
27 __kernel_time_t msg_rtime; /* last msgrcv time */
28#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN)
29 unsigned long __unused2;
30#endif
31#if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
32 unsigned long __unused3;
33#endif
34 __kernel_time_t msg_ctime; /* last change time */
35#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN)
36 unsigned long __unused3;
37#endif
38 unsigned long msg_cbytes; /* current number of bytes on queue */
39 unsigned long msg_qnum; /* number of messages in queue */
40 unsigned long msg_qbytes; /* max number of bytes on queue */
41 __kernel_pid_t msg_lspid; /* pid of last msgsnd */
42 __kernel_pid_t msg_lrpid; /* last receive pid */
43 unsigned long __unused4;
44 unsigned long __unused5;
45};
46
47#endif /* _ASM_MSGBUF_H */
diff --git a/arch/mips/include/asm/mutex.h b/arch/mips/include/asm/mutex.h
new file mode 100644
index 000000000000..458c1f7fbc18
--- /dev/null
+++ b/arch/mips/include/asm/mutex.h
@@ -0,0 +1,9 @@
1/*
2 * Pull in the generic implementation for the mutex fastpath.
3 *
4 * TODO: implement optimized primitives instead, or leave the generic
5 * implementation in place, or pick the atomic_xchg() based generic
6 * implementation. (see asm-generic/mutex-xchg.h for details)
7 */
8
9#include <asm-generic/mutex-dec.h>
diff --git a/arch/mips/include/asm/nile4.h b/arch/mips/include/asm/nile4.h
new file mode 100644
index 000000000000..c3ca959aa4d9
--- /dev/null
+++ b/arch/mips/include/asm/nile4.h
@@ -0,0 +1,310 @@
1/*
2 * asm-mips/nile4.h -- NEC Vrc-5074 Nile 4 definitions
3 *
4 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
5 * Sony Software Development Center Europe (SDCE), Brussels
6 *
7 * This file is based on the following documentation:
8 *
9 * NEC Vrc 5074 System Controller Data Sheet, June 1998
10 */
11
12#ifndef _ASM_NILE4_H
13#define _ASM_NILE4_H
14
15#define NILE4_BASE 0xbfa00000
16#define NILE4_SIZE 0x00200000 /* 2 MB */
17
18
19 /*
20 * Physical Device Address Registers (PDARs)
21 */
22
23#define NILE4_SDRAM0 0x0000 /* SDRAM Bank 0 [R/W] */
24#define NILE4_SDRAM1 0x0008 /* SDRAM Bank 1 [R/W] */
25#define NILE4_DCS2 0x0010 /* Device Chip-Select 2 [R/W] */
26#define NILE4_DCS3 0x0018 /* Device Chip-Select 3 [R/W] */
27#define NILE4_DCS4 0x0020 /* Device Chip-Select 4 [R/W] */
28#define NILE4_DCS5 0x0028 /* Device Chip-Select 5 [R/W] */
29#define NILE4_DCS6 0x0030 /* Device Chip-Select 6 [R/W] */
30#define NILE4_DCS7 0x0038 /* Device Chip-Select 7 [R/W] */
31#define NILE4_DCS8 0x0040 /* Device Chip-Select 8 [R/W] */
32#define NILE4_PCIW0 0x0060 /* PCI Address Window 0 [R/W] */
33#define NILE4_PCIW1 0x0068 /* PCI Address Window 1 [R/W] */
34#define NILE4_INTCS 0x0070 /* Controller Internal Registers and Devices */
35 /* [R/W] */
36#define NILE4_BOOTCS 0x0078 /* Boot ROM Chip-Select [R/W] */
37
38
39 /*
40 * CPU Interface Registers
41 */
42
43#define NILE4_CPUSTAT 0x0080 /* CPU Status [R/W] */
44#define NILE4_INTCTRL 0x0088 /* Interrupt Control [R/W] */
45#define NILE4_INTSTAT0 0x0090 /* Interrupt Status 0 [R] */
46#define NILE4_INTSTAT1 0x0098 /* Interrupt Status 1 and CPU Interrupt */
47 /* Enable [R/W] */
48#define NILE4_INTCLR 0x00A0 /* Interrupt Clear [R/W] */
49#define NILE4_INTPPES 0x00A8 /* PCI Interrupt Control [R/W] */
50
51
52 /*
53 * Memory-Interface Registers
54 */
55
56#define NILE4_MEMCTRL 0x00C0 /* Memory Control */
57#define NILE4_ACSTIME 0x00C8 /* Memory Access Timing [R/W] */
58#define NILE4_CHKERR 0x00D0 /* Memory Check Error Status [R] */
59
60
61 /*
62 * PCI-Bus Registers
63 */
64
65#define NILE4_PCICTRL 0x00E0 /* PCI Control [R/W] */
66#define NILE4_PCIARB 0x00E8 /* PCI Arbiter [R/W] */
67#define NILE4_PCIINIT0 0x00F0 /* PCI Master (Initiator) 0 [R/W] */
68#define NILE4_PCIINIT1 0x00F8 /* PCI Master (Initiator) 1 [R/W] */
69#define NILE4_PCIERR 0x00B8 /* PCI Error [R/W] */
70
71
72 /*
73 * Local-Bus Registers
74 */
75
76#define NILE4_LCNFG 0x0100 /* Local Bus Configuration [R/W] */
77#define NILE4_LCST2 0x0110 /* Local Bus Chip-Select Timing 2 [R/W] */
78#define NILE4_LCST3 0x0118 /* Local Bus Chip-Select Timing 3 [R/W] */
79#define NILE4_LCST4 0x0120 /* Local Bus Chip-Select Timing 4 [R/W] */
80#define NILE4_LCST5 0x0128 /* Local Bus Chip-Select Timing 5 [R/W] */
81#define NILE4_LCST6 0x0130 /* Local Bus Chip-Select Timing 6 [R/W] */
82#define NILE4_LCST7 0x0138 /* Local Bus Chip-Select Timing 7 [R/W] */
83#define NILE4_LCST8 0x0140 /* Local Bus Chip-Select Timing 8 [R/W] */
84#define NILE4_DCSFN 0x0150 /* Device Chip-Select Muxing and Output */
85 /* Enables [R/W] */
86#define NILE4_DCSIO 0x0158 /* Device Chip-Selects As I/O Bits [R/W] */
87#define NILE4_BCST 0x0178 /* Local Boot Chip-Select Timing [R/W] */
88
89
90 /*
91 * DMA Registers
92 */
93
94#define NILE4_DMACTRL0 0x0180 /* DMA Control 0 [R/W] */
95#define NILE4_DMASRCA0 0x0188 /* DMA Source Address 0 [R/W] */
96#define NILE4_DMADESA0 0x0190 /* DMA Destination Address 0 [R/W] */
97#define NILE4_DMACTRL1 0x0198 /* DMA Control 1 [R/W] */
98#define NILE4_DMASRCA1 0x01A0 /* DMA Source Address 1 [R/W] */
99#define NILE4_DMADESA1 0x01A8 /* DMA Destination Address 1 [R/W] */
100
101
102 /*
103 * Timer Registers
104 */
105
106#define NILE4_T0CTRL 0x01C0 /* SDRAM Refresh Control [R/W] */
107#define NILE4_T0CNTR 0x01C8 /* SDRAM Refresh Counter [R/W] */
108#define NILE4_T1CTRL 0x01D0 /* CPU-Bus Read Time-Out Control [R/W] */
109#define NILE4_T1CNTR 0x01D8 /* CPU-Bus Read Time-Out Counter [R/W] */
110#define NILE4_T2CTRL 0x01E0 /* General-Purpose Timer Control [R/W] */
111#define NILE4_T2CNTR 0x01E8 /* General-Purpose Timer Counter [R/W] */
112#define NILE4_T3CTRL 0x01F0 /* Watchdog Timer Control [R/W] */
113#define NILE4_T3CNTR 0x01F8 /* Watchdog Timer Counter [R/W] */
114
115
116 /*
117 * PCI Configuration Space Registers
118 */
119
120#define NILE4_PCI_BASE 0x0200
121
122#define NILE4_VID 0x0200 /* PCI Vendor ID [R] */
123#define NILE4_DID 0x0202 /* PCI Device ID [R] */
124#define NILE4_PCICMD 0x0204 /* PCI Command [R/W] */
125#define NILE4_PCISTS 0x0206 /* PCI Status [R/W] */
126#define NILE4_REVID 0x0208 /* PCI Revision ID [R] */
127#define NILE4_CLASS 0x0209 /* PCI Class Code [R] */
128#define NILE4_CLSIZ 0x020C /* PCI Cache Line Size [R/W] */
129#define NILE4_MLTIM 0x020D /* PCI Latency Timer [R/W] */
130#define NILE4_HTYPE 0x020E /* PCI Header Type [R] */
131#define NILE4_BIST 0x020F /* BIST [R] (unimplemented) */
132#define NILE4_BARC 0x0210 /* PCI Base Address Register Control [R/W] */
133#define NILE4_BAR0 0x0218 /* PCI Base Address Register 0 [R/W] */
134#define NILE4_BAR1 0x0220 /* PCI Base Address Register 1 [R/W] */
135#define NILE4_CIS 0x0228 /* PCI Cardbus CIS Pointer [R] */
136 /* (unimplemented) */
137#define NILE4_SSVID 0x022C /* PCI Sub-System Vendor ID [R/W] */
138#define NILE4_SSID 0x022E /* PCI Sub-System ID [R/W] */
139#define NILE4_ROM 0x0230 /* Expansion ROM Base Address [R] */
140 /* (unimplemented) */
141#define NILE4_INTLIN 0x023C /* PCI Interrupt Line [R/W] */
142#define NILE4_INTPIN 0x023D /* PCI Interrupt Pin [R] */
143#define NILE4_MINGNT 0x023E /* PCI Min_Gnt [R] (unimplemented) */
144#define NILE4_MAXLAT 0x023F /* PCI Max_Lat [R] (unimplemented) */
145#define NILE4_BAR2 0x0240 /* PCI Base Address Register 2 [R/W] */
146#define NILE4_BAR3 0x0248 /* PCI Base Address Register 3 [R/W] */
147#define NILE4_BAR4 0x0250 /* PCI Base Address Register 4 [R/W] */
148#define NILE4_BAR5 0x0258 /* PCI Base Address Register 5 [R/W] */
149#define NILE4_BAR6 0x0260 /* PCI Base Address Register 6 [R/W] */
150#define NILE4_BAR7 0x0268 /* PCI Base Address Register 7 [R/W] */
151#define NILE4_BAR8 0x0270 /* PCI Base Address Register 8 [R/W] */
152#define NILE4_BARB 0x0278 /* PCI Base Address Register BOOT [R/W] */
153
154
155 /*
156 * Serial-Port Registers
157 */
158
159#define NILE4_UART_BASE 0x0300
160
161#define NILE4_UARTRBR 0x0300 /* UART Receiver Data Buffer [R] */
162#define NILE4_UARTTHR 0x0300 /* UART Transmitter Data Holding [W] */
163#define NILE4_UARTIER 0x0308 /* UART Interrupt Enable [R/W] */
164#define NILE4_UARTDLL 0x0300 /* UART Divisor Latch LSB [R/W] */
165#define NILE4_UARTDLM 0x0308 /* UART Divisor Latch MSB [R/W] */
166#define NILE4_UARTIIR 0x0310 /* UART Interrupt ID [R] */
167#define NILE4_UARTFCR 0x0310 /* UART FIFO Control [W] */
168#define NILE4_UARTLCR 0x0318 /* UART Line Control [R/W] */
169#define NILE4_UARTMCR 0x0320 /* UART Modem Control [R/W] */
170#define NILE4_UARTLSR 0x0328 /* UART Line Status [R/W] */
171#define NILE4_UARTMSR 0x0330 /* UART Modem Status [R/W] */
172#define NILE4_UARTSCR 0x0338 /* UART Scratch [R/W] */
173
174#define NILE4_UART_BASE_BAUD 520833 /* 100 MHz / 12 / 16 */
175
176
177 /*
178 * Interrupt Lines
179 */
180
181#define NILE4_INT_CPCE 0 /* CPU-Interface Parity-Error Interrupt */
182#define NILE4_INT_CNTD 1 /* CPU No-Target Decode Interrupt */
183#define NILE4_INT_MCE 2 /* Memory-Check Error Interrupt */
184#define NILE4_INT_DMA 3 /* DMA Controller Interrupt */
185#define NILE4_INT_UART 4 /* UART Interrupt */
186#define NILE4_INT_WDOG 5 /* Watchdog Timer Interrupt */
187#define NILE4_INT_GPT 6 /* General-Purpose Timer Interrupt */
188#define NILE4_INT_LBRTD 7 /* Local-Bus Ready Timer Interrupt */
189#define NILE4_INT_INTA 8 /* PCI Interrupt Signal INTA# */
190#define NILE4_INT_INTB 9 /* PCI Interrupt Signal INTB# */
191#define NILE4_INT_INTC 10 /* PCI Interrupt Signal INTC# */
192#define NILE4_INT_INTD 11 /* PCI Interrupt Signal INTD# */
193#define NILE4_INT_INTE 12 /* PCI Interrupt Signal INTE# (ISA cascade) */
194#define NILE4_INT_RESV 13 /* Reserved */
195#define NILE4_INT_PCIS 14 /* PCI SERR# Interrupt */
196#define NILE4_INT_PCIE 15 /* PCI Internal Error Interrupt */
197
198
199 /*
200 * Nile 4 Register Access
201 */
202
203static inline void nile4_sync(void)
204{
205 volatile u32 *p = (volatile u32 *)0xbfc00000;
206 (void)(*p);
207}
208
209static inline void nile4_out32(u32 offset, u32 val)
210{
211 *(volatile u32 *)(NILE4_BASE+offset) = val;
212 nile4_sync();
213}
214
215static inline u32 nile4_in32(u32 offset)
216{
217 u32 val = *(volatile u32 *)(NILE4_BASE+offset);
218 nile4_sync();
219 return val;
220}
221
222static inline void nile4_out16(u32 offset, u16 val)
223{
224 *(volatile u16 *)(NILE4_BASE+offset) = val;
225 nile4_sync();
226}
227
228static inline u16 nile4_in16(u32 offset)
229{
230 u16 val = *(volatile u16 *)(NILE4_BASE+offset);
231 nile4_sync();
232 return val;
233}
234
235static inline void nile4_out8(u32 offset, u8 val)
236{
237 *(volatile u8 *)(NILE4_BASE+offset) = val;
238 nile4_sync();
239}
240
241static inline u8 nile4_in8(u32 offset)
242{
243 u8 val = *(volatile u8 *)(NILE4_BASE+offset);
244 nile4_sync();
245 return val;
246}
247
248
249 /*
250 * Physical Device Address Registers
251 */
252
253extern void nile4_set_pdar(u32 pdar, u32 phys, u32 size, int width,
254 int on_memory_bus, int visible);
255
256
257 /*
258 * PCI Master Registers
259 */
260
261#define NILE4_PCICMD_IACK 0 /* PCI Interrupt Acknowledge */
262#define NILE4_PCICMD_IO 1 /* PCI I/O Space */
263#define NILE4_PCICMD_MEM 3 /* PCI Memory Space */
264#define NILE4_PCICMD_CFG 5 /* PCI Configuration Space */
265
266
267 /*
268 * PCI Address Spaces
269 *
270 * Note that these are multiplexed using PCIINIT[01]!
271 */
272
273#define NILE4_PCI_IO_BASE 0xa6000000
274#define NILE4_PCI_MEM_BASE 0xa8000000
275#define NILE4_PCI_CFG_BASE NILE4_PCI_MEM_BASE
276#define NILE4_PCI_IACK_BASE NILE4_PCI_IO_BASE
277
278
279extern void nile4_set_pmr(u32 pmr, u32 type, u32 addr);
280
281
282 /*
283 * Interrupt Programming
284 */
285
286#define NUM_I8259_INTERRUPTS 16
287#define NUM_NILE4_INTERRUPTS 16
288
289#define IRQ_I8259_CASCADE NILE4_INT_INTE
290#define is_i8259_irq(irq) ((irq) < NUM_I8259_INTERRUPTS)
291#define nile4_to_irq(n) ((n)+NUM_I8259_INTERRUPTS)
292#define irq_to_nile4(n) ((n)-NUM_I8259_INTERRUPTS)
293
294extern void nile4_map_irq(int nile4_irq, int cpu_irq);
295extern void nile4_map_irq_all(int cpu_irq);
296extern void nile4_enable_irq(unsigned int nile4_irq);
297extern void nile4_disable_irq(unsigned int nile4_irq);
298extern void nile4_disable_irq_all(void);
299extern u16 nile4_get_irq_stat(int cpu_irq);
300extern void nile4_enable_irq_output(int cpu_irq);
301extern void nile4_disable_irq_output(int cpu_irq);
302extern void nile4_set_pci_irq_polarity(int pci_irq, int high);
303extern void nile4_set_pci_irq_level_or_edge(int pci_irq, int level);
304extern void nile4_clear_irq(int nile4_irq);
305extern void nile4_clear_irq_mask(u32 mask);
306extern u8 nile4_i8259_iack(void);
307extern void nile4_dump_irq_status(void); /* Debug */
308
309#endif
310
diff --git a/arch/mips/include/asm/paccess.h b/arch/mips/include/asm/paccess.h
new file mode 100644
index 000000000000..c2394f8b0fe1
--- /dev/null
+++ b/arch/mips/include/asm/paccess.h
@@ -0,0 +1,112 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1998, 1999, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 *
9 * Protected memory access. Used for everything that might take revenge
10 * by sending a DBE error like accessing possibly non-existant memory or
11 * devices.
12 */
13#ifndef _ASM_PACCESS_H
14#define _ASM_PACCESS_H
15
16#include <linux/errno.h>
17
18#ifdef CONFIG_32BIT
19#define __PA_ADDR ".word"
20#endif
21#ifdef CONFIG_64BIT
22#define __PA_ADDR ".dword"
23#endif
24
25extern asmlinkage void handle_ibe(void);
26extern asmlinkage void handle_dbe(void);
27
28#define put_dbe(x, ptr) __put_dbe((x), (ptr), sizeof(*(ptr)))
29#define get_dbe(x, ptr) __get_dbe((x), (ptr), sizeof(*(ptr)))
30
31struct __large_pstruct { unsigned long buf[100]; };
32#define __mp(x) (*(struct __large_pstruct *)(x))
33
34#define __get_dbe(x, ptr, size) \
35({ \
36 long __gu_err; \
37 __typeof__(*(ptr)) __gu_val; \
38 unsigned long __gu_addr; \
39 __asm__("":"=r" (__gu_val)); \
40 __gu_addr = (unsigned long) (ptr); \
41 __asm__("":"=r" (__gu_err)); \
42 switch (size) { \
43 case 1: __get_dbe_asm("lb"); break; \
44 case 2: __get_dbe_asm("lh"); break; \
45 case 4: __get_dbe_asm("lw"); break; \
46 case 8: __get_dbe_asm("ld"); break; \
47 default: __get_dbe_unknown(); break; \
48 } \
49 x = (__typeof__(*(ptr))) __gu_val; \
50 __gu_err; \
51})
52
53#define __get_dbe_asm(insn) \
54{ \
55 __asm__ __volatile__( \
56 "1:\t" insn "\t%1,%2\n\t" \
57 "move\t%0,$0\n" \
58 "2:\n\t" \
59 ".section\t.fixup,\"ax\"\n" \
60 "3:\tli\t%0,%3\n\t" \
61 "move\t%1,$0\n\t" \
62 "j\t2b\n\t" \
63 ".previous\n\t" \
64 ".section\t__dbe_table,\"a\"\n\t" \
65 __PA_ADDR "\t1b, 3b\n\t" \
66 ".previous" \
67 :"=r" (__gu_err), "=r" (__gu_val) \
68 :"o" (__mp(__gu_addr)), "i" (-EFAULT)); \
69}
70
71extern void __get_dbe_unknown(void);
72
73#define __put_dbe(x, ptr, size) \
74({ \
75 long __pu_err; \
76 __typeof__(*(ptr)) __pu_val; \
77 long __pu_addr; \
78 __pu_val = (x); \
79 __pu_addr = (long) (ptr); \
80 __asm__("":"=r" (__pu_err)); \
81 switch (size) { \
82 case 1: __put_dbe_asm("sb"); break; \
83 case 2: __put_dbe_asm("sh"); break; \
84 case 4: __put_dbe_asm("sw"); break; \
85 case 8: __put_dbe_asm("sd"); break; \
86 default: __put_dbe_unknown(); break; \
87 } \
88 __pu_err; \
89})
90
91#define __put_dbe_asm(insn) \
92{ \
93 __asm__ __volatile__( \
94 "1:\t" insn "\t%1,%2\n\t" \
95 "move\t%0,$0\n" \
96 "2:\n\t" \
97 ".section\t.fixup,\"ax\"\n" \
98 "3:\tli\t%0,%3\n\t" \
99 "j\t2b\n\t" \
100 ".previous\n\t" \
101 ".section\t__dbe_table,\"a\"\n\t" \
102 __PA_ADDR "\t1b, 3b\n\t" \
103 ".previous" \
104 : "=r" (__pu_err) \
105 : "r" (__pu_val), "o" (__mp(__pu_addr)), "i" (-EFAULT)); \
106}
107
108extern void __put_dbe_unknown(void);
109
110extern unsigned long search_dbe_table(unsigned long addr);
111
112#endif /* _ASM_PACCESS_H */
diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
new file mode 100644
index 000000000000..fe7a88ea066e
--- /dev/null
+++ b/arch/mips/include/asm/page.h
@@ -0,0 +1,191 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 1999, 2000, 03 Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_PAGE_H
10#define _ASM_PAGE_H
11
12#include <spaces.h>
13
14/*
15 * PAGE_SHIFT determines the page size
16 */
17#ifdef CONFIG_PAGE_SIZE_4KB
18#define PAGE_SHIFT 12
19#endif
20#ifdef CONFIG_PAGE_SIZE_8KB
21#define PAGE_SHIFT 13
22#endif
23#ifdef CONFIG_PAGE_SIZE_16KB
24#define PAGE_SHIFT 14
25#endif
26#ifdef CONFIG_PAGE_SIZE_64KB
27#define PAGE_SHIFT 16
28#endif
29#define PAGE_SIZE (1UL << PAGE_SHIFT)
30#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
31
32#ifndef __ASSEMBLY__
33
34#include <linux/pfn.h>
35#include <asm/io.h>
36
37extern void build_clear_page(void);
38extern void build_copy_page(void);
39
40/*
41 * It's normally defined only for FLATMEM config but it's
42 * used in our early mem init code for all memory models.
43 * So always define it.
44 */
45#define ARCH_PFN_OFFSET PFN_UP(PHYS_OFFSET)
46
47extern void clear_page(void * page);
48extern void copy_page(void * to, void * from);
49
50extern unsigned long shm_align_mask;
51
52static inline unsigned long pages_do_alias(unsigned long addr1,
53 unsigned long addr2)
54{
55 return (addr1 ^ addr2) & shm_align_mask;
56}
57
58struct page;
59
60static inline void clear_user_page(void *addr, unsigned long vaddr,
61 struct page *page)
62{
63 extern void (*flush_data_cache_page)(unsigned long addr);
64
65 clear_page(addr);
66 if (pages_do_alias((unsigned long) addr, vaddr & PAGE_MASK))
67 flush_data_cache_page((unsigned long)addr);
68}
69
70extern void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
71 struct page *to);
72struct vm_area_struct;
73extern void copy_user_highpage(struct page *to, struct page *from,
74 unsigned long vaddr, struct vm_area_struct *vma);
75
76#define __HAVE_ARCH_COPY_USER_HIGHPAGE
77
78/*
79 * These are used to make use of C type-checking..
80 */
81#ifdef CONFIG_64BIT_PHYS_ADDR
82 #ifdef CONFIG_CPU_MIPS32
83 typedef struct { unsigned long pte_low, pte_high; } pte_t;
84 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
85 #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
86 #else
87 typedef struct { unsigned long long pte; } pte_t;
88 #define pte_val(x) ((x).pte)
89 #define __pte(x) ((pte_t) { (x) } )
90 #endif
91#else
92typedef struct { unsigned long pte; } pte_t;
93#define pte_val(x) ((x).pte)
94#define __pte(x) ((pte_t) { (x) } )
95#endif
96typedef struct page *pgtable_t;
97
98/*
99 * For 3-level pagetables we defines these ourselves, for 2-level the
100 * definitions are supplied by <asm-generic/pgtable-nopmd.h>.
101 */
102#ifdef CONFIG_64BIT
103
104typedef struct { unsigned long pmd; } pmd_t;
105#define pmd_val(x) ((x).pmd)
106#define __pmd(x) ((pmd_t) { (x) } )
107
108#endif
109
110/*
111 * Right now we don't support 4-level pagetables, so all pud-related
112 * definitions come from <asm-generic/pgtable-nopud.h>.
113 */
114
115/*
116 * Finall the top of the hierarchy, the pgd
117 */
118typedef struct { unsigned long pgd; } pgd_t;
119#define pgd_val(x) ((x).pgd)
120#define __pgd(x) ((pgd_t) { (x) } )
121
122/*
123 * Manipulate page protection bits
124 */
125typedef struct { unsigned long pgprot; } pgprot_t;
126#define pgprot_val(x) ((x).pgprot)
127#define __pgprot(x) ((pgprot_t) { (x) } )
128
129/*
130 * On R4000-style MMUs where a TLB entry is mapping a adjacent even / odd
131 * pair of pages we only have a single global bit per pair of pages. When
132 * writing to the TLB make sure we always have the bit set for both pages
133 * or none. This macro is used to access the `buddy' of the pte we're just
134 * working on.
135 */
136#define ptep_buddy(x) ((pte_t *)((unsigned long)(x) ^ sizeof(pte_t)))
137
138#endif /* !__ASSEMBLY__ */
139
140/*
141 * __pa()/__va() should be used only during mem init.
142 */
143#ifdef CONFIG_64BIT
144#define __pa(x) \
145({ \
146 unsigned long __x = (unsigned long)(x); \
147 __x < CKSEG0 ? XPHYSADDR(__x) : CPHYSADDR(__x); \
148})
149#else
150#define __pa(x) \
151 ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
152#endif
153#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - PHYS_OFFSET))
154#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0))
155
156#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
157
158#ifdef CONFIG_FLATMEM
159
160#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < max_mapnr)
161
162#elif defined(CONFIG_SPARSEMEM)
163
164/* pfn_valid is defined in linux/mmzone.h */
165
166#elif defined(CONFIG_NEED_MULTIPLE_NODES)
167
168#define pfn_valid(pfn) \
169({ \
170 unsigned long __pfn = (pfn); \
171 int __n = pfn_to_nid(__pfn); \
172 ((__n >= 0) ? (__pfn < NODE_DATA(__n)->node_start_pfn + \
173 NODE_DATA(__n)->node_spanned_pages) \
174 : 0); \
175})
176
177#endif
178
179#define virt_to_page(kaddr) pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
180#define virt_addr_valid(kaddr) pfn_valid(PFN_DOWN(virt_to_phys(kaddr)))
181
182#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
183 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
184
185#define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE)
186#define CAC_ADDR(addr) ((addr) - UNCAC_BASE + PAGE_OFFSET)
187
188#include <asm-generic/memory_model.h>
189#include <asm-generic/page.h>
190
191#endif /* _ASM_PAGE_H */
diff --git a/arch/mips/include/asm/param.h b/arch/mips/include/asm/param.h
new file mode 100644
index 000000000000..1d9bb8c5ab24
--- /dev/null
+++ b/arch/mips/include/asm/param.h
@@ -0,0 +1,31 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright 1994 - 2000, 2002 Ralf Baechle (ralf@gnu.org)
7 * Copyright 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_PARAM_H
10#define _ASM_PARAM_H
11
12#ifdef __KERNEL__
13
14# define HZ CONFIG_HZ /* Internal kernel timer frequency */
15# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
16# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
17#endif
18
19#ifndef HZ
20#define HZ 100
21#endif
22
23#define EXEC_PAGESIZE 65536
24
25#ifndef NOGROUP
26#define NOGROUP (-1)
27#endif
28
29#define MAXHOSTNAMELEN 64 /* max length of hostname */
30
31#endif /* _ASM_PARAM_H */
diff --git a/arch/mips/include/asm/parport.h b/arch/mips/include/asm/parport.h
new file mode 100644
index 000000000000..f52656826cce
--- /dev/null
+++ b/arch/mips/include/asm/parport.h
@@ -0,0 +1,15 @@
1/*
2 * Copyright (C) 1999, 2000 Tim Waugh <tim@cyberelk.demon.co.uk>
3 *
4 * This file should only be included by drivers/parport/parport_pc.c.
5 */
6#ifndef _ASM_PARPORT_H
7#define _ASM_PARPORT_H
8
9static int __devinit parport_pc_find_isa_ports(int autoirq, int autodma);
10static int __devinit parport_pc_find_nonpci_ports(int autoirq, int autodma)
11{
12 return parport_pc_find_isa_ports(autoirq, autodma);
13}
14
15#endif /* _ASM_PARPORT_H */
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
new file mode 100644
index 000000000000..5510c53b7feb
--- /dev/null
+++ b/arch/mips/include/asm/pci.h
@@ -0,0 +1,179 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 */
6#ifndef _ASM_PCI_H
7#define _ASM_PCI_H
8
9#include <linux/mm.h>
10
11#ifdef __KERNEL__
12
13/*
14 * This file essentially defines the interface between board
15 * specific PCI code and MIPS common PCI code. Should potentially put
16 * into include/asm/pci.h file.
17 */
18
19#include <linux/ioport.h>
20
21/*
22 * Each pci channel is a top-level PCI bus seem by CPU. A machine with
23 * multiple PCI channels may have multiple PCI host controllers or a
24 * single controller supporting multiple channels.
25 */
26struct pci_controller {
27 struct pci_controller *next;
28 struct pci_bus *bus;
29
30 struct pci_ops *pci_ops;
31 struct resource *mem_resource;
32 unsigned long mem_offset;
33 struct resource *io_resource;
34 unsigned long io_offset;
35 unsigned long io_map_base;
36
37 unsigned int index;
38 /* For compatibility with current (as of July 2003) pciutils
39 and XFree86. Eventually will be removed. */
40 unsigned int need_domain_info;
41
42 int iommu;
43
44 /* Optional access methods for reading/writing the bus number
45 of the PCI controller */
46 int (*get_busno)(void);
47 void (*set_busno)(int busno);
48};
49
50/*
51 * Used by boards to register their PCI busses before the actual scanning.
52 */
53extern struct pci_controller * alloc_pci_controller(void);
54extern void register_pci_controller(struct pci_controller *hose);
55
56/*
57 * board supplied pci irq fixup routine
58 */
59extern int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
60
61
62/* Can be used to override the logic in pci_scan_bus for skipping
63 already-configured bus numbers - to be used for buggy BIOSes
64 or architectures with incomplete PCI setup by the loader */
65
66extern unsigned int pcibios_assign_all_busses(void);
67
68#define pcibios_scan_all_fns(a, b) 0
69
70extern unsigned long PCIBIOS_MIN_IO;
71extern unsigned long PCIBIOS_MIN_MEM;
72
73#define PCIBIOS_MIN_CARDBUS_IO 0x4000
74
75extern void pcibios_set_master(struct pci_dev *dev);
76
77static inline void pcibios_penalize_isa_irq(int irq, int active)
78{
79 /* We don't do dynamic PCI IRQ allocation */
80}
81
82/*
83 * Dynamic DMA mapping stuff.
84 * MIPS has everything mapped statically.
85 */
86
87#include <linux/types.h>
88#include <linux/slab.h>
89#include <asm/scatterlist.h>
90#include <linux/string.h>
91#include <asm/io.h>
92
93struct pci_dev;
94
95/*
96 * The PCI address space does equal the physical memory address space. The
97 * networking and block device layers use this boolean for bounce buffer
98 * decisions. This is set if any hose does not have an IOMMU.
99 */
100extern unsigned int PCI_DMA_BUS_IS_PHYS;
101
102#ifdef CONFIG_DMA_NEED_PCI_MAP_STATE
103
104/* pci_unmap_{single,page} is not a nop, thus... */
105#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME;
106#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME;
107#define pci_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
108#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
109#define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
110#define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
111
112#else /* CONFIG_DMA_NEED_PCI_MAP_STATE */
113
114/* pci_unmap_{page,single} is a nop so... */
115#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
116#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
117#define pci_unmap_addr(PTR, ADDR_NAME) (0)
118#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
119#define pci_unmap_len(PTR, LEN_NAME) (0)
120#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
121
122#endif /* CONFIG_DMA_NEED_PCI_MAP_STATE */
123
124#ifdef CONFIG_PCI
125static inline void pci_dma_burst_advice(struct pci_dev *pdev,
126 enum pci_dma_burst_strategy *strat,
127 unsigned long *strategy_parameter)
128{
129 *strat = PCI_DMA_BURST_INFINITY;
130 *strategy_parameter = ~0UL;
131}
132#endif
133
134extern void pcibios_resource_to_bus(struct pci_dev *dev,
135 struct pci_bus_region *region, struct resource *res);
136
137extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
138 struct pci_bus_region *region);
139
140static inline struct resource *
141pcibios_select_root(struct pci_dev *pdev, struct resource *res)
142{
143 struct resource *root = NULL;
144
145 if (res->flags & IORESOURCE_IO)
146 root = &ioport_resource;
147 if (res->flags & IORESOURCE_MEM)
148 root = &iomem_resource;
149
150 return root;
151}
152
153#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
154
155static inline int pci_proc_domain(struct pci_bus *bus)
156{
157 struct pci_controller *hose = bus->sysdata;
158 return hose->need_domain_info;
159}
160
161#endif /* __KERNEL__ */
162
163/* implement the pci_ DMA API in terms of the generic device dma_ one */
164#include <asm-generic/pci-dma-compat.h>
165
166/* Do platform specific device initialization at pci_enable_device() time */
167extern int pcibios_plat_dev_init(struct pci_dev *dev);
168
169/* Chances are this interrupt is wired PC-style ... */
170static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
171{
172 return channel ? 15 : 14;
173}
174
175extern int pci_probe_only;
176
177extern char * (*pcibios_plat_setup)(char *str);
178
179#endif /* _ASM_PCI_H */
diff --git a/arch/mips/include/asm/pci/bridge.h b/arch/mips/include/asm/pci/bridge.h
new file mode 100644
index 000000000000..5f4b9d4e4114
--- /dev/null
+++ b/arch/mips/include/asm/pci/bridge.h
@@ -0,0 +1,854 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * bridge.h - bridge chip header file, derived from IRIX <sys/PCI/bridge.h>,
7 * revision 1.76.
8 *
9 * Copyright (C) 1996, 1999 Silcon Graphics, Inc.
10 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
11 */
12#ifndef _ASM_PCI_BRIDGE_H
13#define _ASM_PCI_BRIDGE_H
14
15#include <linux/types.h>
16#include <linux/pci.h>
17#include <asm/xtalk/xwidget.h> /* generic widget header */
18#include <asm/sn/types.h>
19
20/* I/O page size */
21
22#define IOPFNSHIFT 12 /* 4K per mapped page */
23
24#define IOPGSIZE (1 << IOPFNSHIFT)
25#define IOPG(x) ((x) >> IOPFNSHIFT)
26#define IOPGOFF(x) ((x) & (IOPGSIZE-1))
27
28/* Bridge RAM sizes */
29
30#define BRIDGE_ATE_RAM_SIZE 0x00000400 /* 1kB ATE RAM */
31
32#define BRIDGE_CONFIG_BASE 0x20000
33#define BRIDGE_CONFIG1_BASE 0x28000
34#define BRIDGE_CONFIG_END 0x30000
35#define BRIDGE_CONFIG_SLOT_SIZE 0x1000
36
37#define BRIDGE_SSRAM_512K 0x00080000 /* 512kB */
38#define BRIDGE_SSRAM_128K 0x00020000 /* 128kB */
39#define BRIDGE_SSRAM_64K 0x00010000 /* 64kB */
40#define BRIDGE_SSRAM_0K 0x00000000 /* 0kB */
41
42/* ========================================================================
43 * Bridge address map
44 */
45
46#ifndef __ASSEMBLY__
47
48/*
49 * All accesses to bridge hardware registers must be done
50 * using 32-bit loads and stores.
51 */
52typedef u32 bridgereg_t;
53
54typedef u64 bridge_ate_t;
55
56/* pointers to bridge ATEs
57 * are always "pointer to volatile"
58 */
59typedef volatile bridge_ate_t *bridge_ate_p;
60
61/*
62 * It is generally preferred that hardware registers on the bridge
63 * are located from C code via this structure.
64 *
65 * Generated from Bridge spec dated 04oct95
66 */
67
68typedef volatile struct bridge_s {
69 /* Local Registers 0x000000-0x00FFFF */
70
71 /* standard widget configuration 0x000000-0x000057 */
72 widget_cfg_t b_widget; /* 0x000000 */
73
74 /* helper fieldnames for accessing bridge widget */
75
76#define b_wid_id b_widget.w_id
77#define b_wid_stat b_widget.w_status
78#define b_wid_err_upper b_widget.w_err_upper_addr
79#define b_wid_err_lower b_widget.w_err_lower_addr
80#define b_wid_control b_widget.w_control
81#define b_wid_req_timeout b_widget.w_req_timeout
82#define b_wid_int_upper b_widget.w_intdest_upper_addr
83#define b_wid_int_lower b_widget.w_intdest_lower_addr
84#define b_wid_err_cmdword b_widget.w_err_cmd_word
85#define b_wid_llp b_widget.w_llp_cfg
86#define b_wid_tflush b_widget.w_tflush
87
88 /* bridge-specific widget configuration 0x000058-0x00007F */
89 bridgereg_t _pad_000058;
90 bridgereg_t b_wid_aux_err; /* 0x00005C */
91 bridgereg_t _pad_000060;
92 bridgereg_t b_wid_resp_upper; /* 0x000064 */
93 bridgereg_t _pad_000068;
94 bridgereg_t b_wid_resp_lower; /* 0x00006C */
95 bridgereg_t _pad_000070;
96 bridgereg_t b_wid_tst_pin_ctrl; /* 0x000074 */
97 bridgereg_t _pad_000078[2];
98
99 /* PMU & Map 0x000080-0x00008F */
100 bridgereg_t _pad_000080;
101 bridgereg_t b_dir_map; /* 0x000084 */
102 bridgereg_t _pad_000088[2];
103
104 /* SSRAM 0x000090-0x00009F */
105 bridgereg_t _pad_000090;
106 bridgereg_t b_ram_perr; /* 0x000094 */
107 bridgereg_t _pad_000098[2];
108
109 /* Arbitration 0x0000A0-0x0000AF */
110 bridgereg_t _pad_0000A0;
111 bridgereg_t b_arb; /* 0x0000A4 */
112 bridgereg_t _pad_0000A8[2];
113
114 /* Number In A Can 0x0000B0-0x0000BF */
115 bridgereg_t _pad_0000B0;
116 bridgereg_t b_nic; /* 0x0000B4 */
117 bridgereg_t _pad_0000B8[2];
118
119 /* PCI/GIO 0x0000C0-0x0000FF */
120 bridgereg_t _pad_0000C0;
121 bridgereg_t b_bus_timeout; /* 0x0000C4 */
122#define b_pci_bus_timeout b_bus_timeout
123
124 bridgereg_t _pad_0000C8;
125 bridgereg_t b_pci_cfg; /* 0x0000CC */
126 bridgereg_t _pad_0000D0;
127 bridgereg_t b_pci_err_upper; /* 0x0000D4 */
128 bridgereg_t _pad_0000D8;
129 bridgereg_t b_pci_err_lower; /* 0x0000DC */
130 bridgereg_t _pad_0000E0[8];
131#define b_gio_err_lower b_pci_err_lower
132#define b_gio_err_upper b_pci_err_upper
133
134 /* Interrupt 0x000100-0x0001FF */
135 bridgereg_t _pad_000100;
136 bridgereg_t b_int_status; /* 0x000104 */
137 bridgereg_t _pad_000108;
138 bridgereg_t b_int_enable; /* 0x00010C */
139 bridgereg_t _pad_000110;
140 bridgereg_t b_int_rst_stat; /* 0x000114 */
141 bridgereg_t _pad_000118;
142 bridgereg_t b_int_mode; /* 0x00011C */
143 bridgereg_t _pad_000120;
144 bridgereg_t b_int_device; /* 0x000124 */
145 bridgereg_t _pad_000128;
146 bridgereg_t b_int_host_err; /* 0x00012C */
147
148 struct {
149 bridgereg_t __pad; /* 0x0001{30,,,68} */
150 bridgereg_t addr; /* 0x0001{34,,,6C} */
151 } b_int_addr[8]; /* 0x000130 */
152
153 bridgereg_t _pad_000170[36];
154
155 /* Device 0x000200-0x0003FF */
156 struct {
157 bridgereg_t __pad; /* 0x0002{00,,,38} */
158 bridgereg_t reg; /* 0x0002{04,,,3C} */
159 } b_device[8]; /* 0x000200 */
160
161 struct {
162 bridgereg_t __pad; /* 0x0002{40,,,78} */
163 bridgereg_t reg; /* 0x0002{44,,,7C} */
164 } b_wr_req_buf[8]; /* 0x000240 */
165
166 struct {
167 bridgereg_t __pad; /* 0x0002{80,,,88} */
168 bridgereg_t reg; /* 0x0002{84,,,8C} */
169 } b_rrb_map[2]; /* 0x000280 */
170#define b_even_resp b_rrb_map[0].reg /* 0x000284 */
171#define b_odd_resp b_rrb_map[1].reg /* 0x00028C */
172
173 bridgereg_t _pad_000290;
174 bridgereg_t b_resp_status; /* 0x000294 */
175 bridgereg_t _pad_000298;
176 bridgereg_t b_resp_clear; /* 0x00029C */
177
178 bridgereg_t _pad_0002A0[24];
179
180 char _pad_000300[0x10000 - 0x000300];
181
182 /* Internal Address Translation Entry RAM 0x010000-0x0103FF */
183 union {
184 bridge_ate_t wr; /* write-only */
185 struct {
186 bridgereg_t _p_pad;
187 bridgereg_t rd; /* read-only */
188 } hi;
189 } b_int_ate_ram[128];
190
191 char _pad_010400[0x11000 - 0x010400];
192
193 /* Internal Address Translation Entry RAM LOW 0x011000-0x0113FF */
194 struct {
195 bridgereg_t _p_pad;
196 bridgereg_t rd; /* read-only */
197 } b_int_ate_ram_lo[128];
198
199 char _pad_011400[0x20000 - 0x011400];
200
201 /* PCI Device Configuration Spaces 0x020000-0x027FFF */
202 union { /* make all access sizes available. */
203 u8 c[0x1000 / 1];
204 u16 s[0x1000 / 2];
205 u32 l[0x1000 / 4];
206 u64 d[0x1000 / 8];
207 union {
208 u8 c[0x100 / 1];
209 u16 s[0x100 / 2];
210 u32 l[0x100 / 4];
211 u64 d[0x100 / 8];
212 } f[8];
213 } b_type0_cfg_dev[8]; /* 0x020000 */
214
215 /* PCI Type 1 Configuration Space 0x028000-0x028FFF */
216 union { /* make all access sizes available. */
217 u8 c[0x1000 / 1];
218 u16 s[0x1000 / 2];
219 u32 l[0x1000 / 4];
220 u64 d[0x1000 / 8];
221 } b_type1_cfg; /* 0x028000-0x029000 */
222
223 char _pad_029000[0x007000]; /* 0x029000-0x030000 */
224
225 /* PCI Interrupt Acknowledge Cycle 0x030000 */
226 union {
227 u8 c[8 / 1];
228 u16 s[8 / 2];
229 u32 l[8 / 4];
230 u64 d[8 / 8];
231 } b_pci_iack; /* 0x030000 */
232
233 u8 _pad_030007[0x04fff8]; /* 0x030008-0x07FFFF */
234
235 /* External Address Translation Entry RAM 0x080000-0x0FFFFF */
236 bridge_ate_t b_ext_ate_ram[0x10000];
237
238 /* Reserved 0x100000-0x1FFFFF */
239 char _pad_100000[0x200000-0x100000];
240
241 /* PCI/GIO Device Spaces 0x200000-0xBFFFFF */
242 union { /* make all access sizes available. */
243 u8 c[0x100000 / 1];
244 u16 s[0x100000 / 2];
245 u32 l[0x100000 / 4];
246 u64 d[0x100000 / 8];
247 } b_devio_raw[10]; /* 0x200000 */
248
249 /* b_devio macro is a bit strange; it reflects the
250 * fact that the Bridge ASIC provides 2M for the
251 * first two DevIO windows and 1M for the other six.
252 */
253#define b_devio(n) b_devio_raw[((n)<2)?(n*2):(n+2)]
254
255 /* External Flash Proms 1,0 0xC00000-0xFFFFFF */
256 union { /* make all access sizes available. */
257 u8 c[0x400000 / 1]; /* read-only */
258 u16 s[0x400000 / 2]; /* read-write */
259 u32 l[0x400000 / 4]; /* read-only */
260 u64 d[0x400000 / 8]; /* read-only */
261 } b_external_flash; /* 0xC00000 */
262} bridge_t;
263
264/*
265 * Field formats for Error Command Word and Auxillary Error Command Word
266 * of bridge.
267 */
268typedef struct bridge_err_cmdword_s {
269 union {
270 u32 cmd_word;
271 struct {
272 u32 didn:4, /* Destination ID */
273 sidn:4, /* Source ID */
274 pactyp:4, /* Packet type */
275 tnum:5, /* Trans Number */
276 coh:1, /* Coh Transacti */
277 ds:2, /* Data size */
278 gbr:1, /* GBR enable */
279 vbpm:1, /* VBPM message */
280 error:1, /* Error occurred */
281 barr:1, /* Barrier op */
282 rsvd:8;
283 } berr_st;
284 } berr_un;
285} bridge_err_cmdword_t;
286
287#define berr_field berr_un.berr_st
288#endif /* !__ASSEMBLY__ */
289
290/*
291 * The values of these macros can and should be crosschecked
292 * regularly against the offsets of the like-named fields
293 * within the "bridge_t" structure above.
294 */
295
296/* Byte offset macros for Bridge internal registers */
297
298#define BRIDGE_WID_ID WIDGET_ID
299#define BRIDGE_WID_STAT WIDGET_STATUS
300#define BRIDGE_WID_ERR_UPPER WIDGET_ERR_UPPER_ADDR
301#define BRIDGE_WID_ERR_LOWER WIDGET_ERR_LOWER_ADDR
302#define BRIDGE_WID_CONTROL WIDGET_CONTROL
303#define BRIDGE_WID_REQ_TIMEOUT WIDGET_REQ_TIMEOUT
304#define BRIDGE_WID_INT_UPPER WIDGET_INTDEST_UPPER_ADDR
305#define BRIDGE_WID_INT_LOWER WIDGET_INTDEST_LOWER_ADDR
306#define BRIDGE_WID_ERR_CMDWORD WIDGET_ERR_CMD_WORD
307#define BRIDGE_WID_LLP WIDGET_LLP_CFG
308#define BRIDGE_WID_TFLUSH WIDGET_TFLUSH
309
310#define BRIDGE_WID_AUX_ERR 0x00005C /* Aux Error Command Word */
311#define BRIDGE_WID_RESP_UPPER 0x000064 /* Response Buf Upper Addr */
312#define BRIDGE_WID_RESP_LOWER 0x00006C /* Response Buf Lower Addr */
313#define BRIDGE_WID_TST_PIN_CTRL 0x000074 /* Test pin control */
314
315#define BRIDGE_DIR_MAP 0x000084 /* Direct Map reg */
316
317#define BRIDGE_RAM_PERR 0x000094 /* SSRAM Parity Error */
318
319#define BRIDGE_ARB 0x0000A4 /* Arbitration Priority reg */
320
321#define BRIDGE_NIC 0x0000B4 /* Number In A Can */
322
323#define BRIDGE_BUS_TIMEOUT 0x0000C4 /* Bus Timeout Register */
324#define BRIDGE_PCI_BUS_TIMEOUT BRIDGE_BUS_TIMEOUT
325#define BRIDGE_PCI_CFG 0x0000CC /* PCI Type 1 Config reg */
326#define BRIDGE_PCI_ERR_UPPER 0x0000D4 /* PCI error Upper Addr */
327#define BRIDGE_PCI_ERR_LOWER 0x0000DC /* PCI error Lower Addr */
328
329#define BRIDGE_INT_STATUS 0x000104 /* Interrupt Status */
330#define BRIDGE_INT_ENABLE 0x00010C /* Interrupt Enables */
331#define BRIDGE_INT_RST_STAT 0x000114 /* Reset Intr Status */
332#define BRIDGE_INT_MODE 0x00011C /* Interrupt Mode */
333#define BRIDGE_INT_DEVICE 0x000124 /* Interrupt Device */
334#define BRIDGE_INT_HOST_ERR 0x00012C /* Host Error Field */
335
336#define BRIDGE_INT_ADDR0 0x000134 /* Host Address Reg */
337#define BRIDGE_INT_ADDR_OFF 0x000008 /* Host Addr offset (1..7) */
338#define BRIDGE_INT_ADDR(x) (BRIDGE_INT_ADDR0+(x)*BRIDGE_INT_ADDR_OFF)
339
340#define BRIDGE_DEVICE0 0x000204 /* Device 0 */
341#define BRIDGE_DEVICE_OFF 0x000008 /* Device offset (1..7) */
342#define BRIDGE_DEVICE(x) (BRIDGE_DEVICE0+(x)*BRIDGE_DEVICE_OFF)
343
344#define BRIDGE_WR_REQ_BUF0 0x000244 /* Write Request Buffer 0 */
345#define BRIDGE_WR_REQ_BUF_OFF 0x000008 /* Buffer Offset (1..7) */
346#define BRIDGE_WR_REQ_BUF(x) (BRIDGE_WR_REQ_BUF0+(x)*BRIDGE_WR_REQ_BUF_OFF)
347
348#define BRIDGE_EVEN_RESP 0x000284 /* Even Device Response Buf */
349#define BRIDGE_ODD_RESP 0x00028C /* Odd Device Response Buf */
350
351#define BRIDGE_RESP_STATUS 0x000294 /* Read Response Status reg */
352#define BRIDGE_RESP_CLEAR 0x00029C /* Read Response Clear reg */
353
354/* Byte offset macros for Bridge I/O space */
355
356#define BRIDGE_ATE_RAM 0x00010000 /* Internal Addr Xlat Ram */
357
358#define BRIDGE_TYPE0_CFG_DEV0 0x00020000 /* Type 0 Cfg, Device 0 */
359#define BRIDGE_TYPE0_CFG_SLOT_OFF 0x00001000 /* Type 0 Cfg Slot Offset (1..7) */
360#define BRIDGE_TYPE0_CFG_FUNC_OFF 0x00000100 /* Type 0 Cfg Func Offset (1..7) */
361#define BRIDGE_TYPE0_CFG_DEV(s) (BRIDGE_TYPE0_CFG_DEV0+\
362 (s)*BRIDGE_TYPE0_CFG_SLOT_OFF)
363#define BRIDGE_TYPE0_CFG_DEVF(s, f) (BRIDGE_TYPE0_CFG_DEV0+\
364 (s)*BRIDGE_TYPE0_CFG_SLOT_OFF+\
365 (f)*BRIDGE_TYPE0_CFG_FUNC_OFF)
366
367#define BRIDGE_TYPE1_CFG 0x00028000 /* Type 1 Cfg space */
368
369#define BRIDGE_PCI_IACK 0x00030000 /* PCI Interrupt Ack */
370#define BRIDGE_EXT_SSRAM 0x00080000 /* Extern SSRAM (ATE) */
371
372/* Byte offset macros for Bridge device IO spaces */
373
374#define BRIDGE_DEV_CNT 8 /* Up to 8 devices per bridge */
375#define BRIDGE_DEVIO0 0x00200000 /* Device IO 0 Addr */
376#define BRIDGE_DEVIO1 0x00400000 /* Device IO 1 Addr */
377#define BRIDGE_DEVIO2 0x00600000 /* Device IO 2 Addr */
378#define BRIDGE_DEVIO_OFF 0x00100000 /* Device IO Offset (3..7) */
379
380#define BRIDGE_DEVIO_2MB 0x00200000 /* Device IO Offset (0..1) */
381#define BRIDGE_DEVIO_1MB 0x00100000 /* Device IO Offset (2..7) */
382
383#define BRIDGE_DEVIO(x) ((x)<=1 ? BRIDGE_DEVIO0+(x)*BRIDGE_DEVIO_2MB : BRIDGE_DEVIO2+((x)-2)*BRIDGE_DEVIO_1MB)
384
385#define BRIDGE_EXTERNAL_FLASH 0x00C00000 /* External Flash PROMS */
386
387/* ========================================================================
388 * Bridge register bit field definitions
389 */
390
391/* Widget part number of bridge */
392#define BRIDGE_WIDGET_PART_NUM 0xc002
393#define XBRIDGE_WIDGET_PART_NUM 0xd002
394
395/* Manufacturer of bridge */
396#define BRIDGE_WIDGET_MFGR_NUM 0x036
397#define XBRIDGE_WIDGET_MFGR_NUM 0x024
398
399/* Revision numbers for known Bridge revisions */
400#define BRIDGE_REV_A 0x1
401#define BRIDGE_REV_B 0x2
402#define BRIDGE_REV_C 0x3
403#define BRIDGE_REV_D 0x4
404
405/* Bridge widget status register bits definition */
406
407#define BRIDGE_STAT_LLP_REC_CNT (0xFFu << 24)
408#define BRIDGE_STAT_LLP_TX_CNT (0xFF << 16)
409#define BRIDGE_STAT_FLASH_SELECT (0x1 << 6)
410#define BRIDGE_STAT_PCI_GIO_N (0x1 << 5)
411#define BRIDGE_STAT_PENDING (0x1F << 0)
412
413/* Bridge widget control register bits definition */
414#define BRIDGE_CTRL_FLASH_WR_EN (0x1ul << 31)
415#define BRIDGE_CTRL_EN_CLK50 (0x1 << 30)
416#define BRIDGE_CTRL_EN_CLK40 (0x1 << 29)
417#define BRIDGE_CTRL_EN_CLK33 (0x1 << 28)
418#define BRIDGE_CTRL_RST(n) ((n) << 24)
419#define BRIDGE_CTRL_RST_MASK (BRIDGE_CTRL_RST(0xF))
420#define BRIDGE_CTRL_RST_PIN(x) (BRIDGE_CTRL_RST(0x1 << (x)))
421#define BRIDGE_CTRL_IO_SWAP (0x1 << 23)
422#define BRIDGE_CTRL_MEM_SWAP (0x1 << 22)
423#define BRIDGE_CTRL_PAGE_SIZE (0x1 << 21)
424#define BRIDGE_CTRL_SS_PAR_BAD (0x1 << 20)
425#define BRIDGE_CTRL_SS_PAR_EN (0x1 << 19)
426#define BRIDGE_CTRL_SSRAM_SIZE(n) ((n) << 17)
427#define BRIDGE_CTRL_SSRAM_SIZE_MASK (BRIDGE_CTRL_SSRAM_SIZE(0x3))
428#define BRIDGE_CTRL_SSRAM_512K (BRIDGE_CTRL_SSRAM_SIZE(0x3))
429#define BRIDGE_CTRL_SSRAM_128K (BRIDGE_CTRL_SSRAM_SIZE(0x2))
430#define BRIDGE_CTRL_SSRAM_64K (BRIDGE_CTRL_SSRAM_SIZE(0x1))
431#define BRIDGE_CTRL_SSRAM_1K (BRIDGE_CTRL_SSRAM_SIZE(0x0))
432#define BRIDGE_CTRL_F_BAD_PKT (0x1 << 16)
433#define BRIDGE_CTRL_LLP_XBAR_CRD(n) ((n) << 12)
434#define BRIDGE_CTRL_LLP_XBAR_CRD_MASK (BRIDGE_CTRL_LLP_XBAR_CRD(0xf))
435#define BRIDGE_CTRL_CLR_RLLP_CNT (0x1 << 11)
436#define BRIDGE_CTRL_CLR_TLLP_CNT (0x1 << 10)
437#define BRIDGE_CTRL_SYS_END (0x1 << 9)
438#define BRIDGE_CTRL_MAX_TRANS(n) ((n) << 4)
439#define BRIDGE_CTRL_MAX_TRANS_MASK (BRIDGE_CTRL_MAX_TRANS(0x1f))
440#define BRIDGE_CTRL_WIDGET_ID(n) ((n) << 0)
441#define BRIDGE_CTRL_WIDGET_ID_MASK (BRIDGE_CTRL_WIDGET_ID(0xf))
442
443/* Bridge Response buffer Error Upper Register bit fields definition */
444#define BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT (20)
445#define BRIDGE_RESP_ERRUPPR_DEVNUM_MASK (0x7 << BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT)
446#define BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT (16)
447#define BRIDGE_RESP_ERRUPPR_BUFNUM_MASK (0xF << BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT)
448#define BRIDGE_RESP_ERRRUPPR_BUFMASK (0xFFFF)
449
450#define BRIDGE_RESP_ERRUPPR_BUFNUM(x) \
451 (((x) & BRIDGE_RESP_ERRUPPR_BUFNUM_MASK) >> \
452 BRIDGE_RESP_ERRUPPR_BUFNUM_SHFT)
453
454#define BRIDGE_RESP_ERRUPPR_DEVICE(x) \
455 (((x) & BRIDGE_RESP_ERRUPPR_DEVNUM_MASK) >> \
456 BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT)
457
458/* Bridge direct mapping register bits definition */
459#define BRIDGE_DIRMAP_W_ID_SHFT 20
460#define BRIDGE_DIRMAP_W_ID (0xf << BRIDGE_DIRMAP_W_ID_SHFT)
461#define BRIDGE_DIRMAP_RMF_64 (0x1 << 18)
462#define BRIDGE_DIRMAP_ADD512 (0x1 << 17)
463#define BRIDGE_DIRMAP_OFF (0x1ffff << 0)
464#define BRIDGE_DIRMAP_OFF_ADDRSHFT (31) /* lsbit of DIRMAP_OFF is xtalk address bit 31 */
465
466/* Bridge Arbitration register bits definition */
467#define BRIDGE_ARB_REQ_WAIT_TICK(x) ((x) << 16)
468#define BRIDGE_ARB_REQ_WAIT_TICK_MASK BRIDGE_ARB_REQ_WAIT_TICK(0x3)
469#define BRIDGE_ARB_REQ_WAIT_EN(x) ((x) << 8)
470#define BRIDGE_ARB_REQ_WAIT_EN_MASK BRIDGE_ARB_REQ_WAIT_EN(0xff)
471#define BRIDGE_ARB_FREEZE_GNT (1 << 6)
472#define BRIDGE_ARB_HPRI_RING_B2 (1 << 5)
473#define BRIDGE_ARB_HPRI_RING_B1 (1 << 4)
474#define BRIDGE_ARB_HPRI_RING_B0 (1 << 3)
475#define BRIDGE_ARB_LPRI_RING_B2 (1 << 2)
476#define BRIDGE_ARB_LPRI_RING_B1 (1 << 1)
477#define BRIDGE_ARB_LPRI_RING_B0 (1 << 0)
478
479/* Bridge Bus time-out register bits definition */
480#define BRIDGE_BUS_PCI_RETRY_HLD(x) ((x) << 16)
481#define BRIDGE_BUS_PCI_RETRY_HLD_MASK BRIDGE_BUS_PCI_RETRY_HLD(0x1f)
482#define BRIDGE_BUS_GIO_TIMEOUT (1 << 12)
483#define BRIDGE_BUS_PCI_RETRY_CNT(x) ((x) << 0)
484#define BRIDGE_BUS_PCI_RETRY_MASK BRIDGE_BUS_PCI_RETRY_CNT(0x3ff)
485
486/* Bridge interrupt status register bits definition */
487#define BRIDGE_ISR_MULTI_ERR (0x1u << 31)
488#define BRIDGE_ISR_PMU_ESIZE_FAULT (0x1 << 30)
489#define BRIDGE_ISR_UNEXP_RESP (0x1 << 29)
490#define BRIDGE_ISR_BAD_XRESP_PKT (0x1 << 28)
491#define BRIDGE_ISR_BAD_XREQ_PKT (0x1 << 27)
492#define BRIDGE_ISR_RESP_XTLK_ERR (0x1 << 26)
493#define BRIDGE_ISR_REQ_XTLK_ERR (0x1 << 25)
494#define BRIDGE_ISR_INVLD_ADDR (0x1 << 24)
495#define BRIDGE_ISR_UNSUPPORTED_XOP (0x1 << 23)
496#define BRIDGE_ISR_XREQ_FIFO_OFLOW (0x1 << 22)
497#define BRIDGE_ISR_LLP_REC_SNERR (0x1 << 21)
498#define BRIDGE_ISR_LLP_REC_CBERR (0x1 << 20)
499#define BRIDGE_ISR_LLP_RCTY (0x1 << 19)
500#define BRIDGE_ISR_LLP_TX_RETRY (0x1 << 18)
501#define BRIDGE_ISR_LLP_TCTY (0x1 << 17)
502#define BRIDGE_ISR_SSRAM_PERR (0x1 << 16)
503#define BRIDGE_ISR_PCI_ABORT (0x1 << 15)
504#define BRIDGE_ISR_PCI_PARITY (0x1 << 14)
505#define BRIDGE_ISR_PCI_SERR (0x1 << 13)
506#define BRIDGE_ISR_PCI_PERR (0x1 << 12)
507#define BRIDGE_ISR_PCI_MST_TIMEOUT (0x1 << 11)
508#define BRIDGE_ISR_GIO_MST_TIMEOUT BRIDGE_ISR_PCI_MST_TIMEOUT
509#define BRIDGE_ISR_PCI_RETRY_CNT (0x1 << 10)
510#define BRIDGE_ISR_XREAD_REQ_TIMEOUT (0x1 << 9)
511#define BRIDGE_ISR_GIO_B_ENBL_ERR (0x1 << 8)
512#define BRIDGE_ISR_INT_MSK (0xff << 0)
513#define BRIDGE_ISR_INT(x) (0x1 << (x))
514
515#define BRIDGE_ISR_LINK_ERROR \
516 (BRIDGE_ISR_LLP_REC_SNERR|BRIDGE_ISR_LLP_REC_CBERR| \
517 BRIDGE_ISR_LLP_RCTY|BRIDGE_ISR_LLP_TX_RETRY| \
518 BRIDGE_ISR_LLP_TCTY)
519
520#define BRIDGE_ISR_PCIBUS_PIOERR \
521 (BRIDGE_ISR_PCI_MST_TIMEOUT|BRIDGE_ISR_PCI_ABORT)
522
523#define BRIDGE_ISR_PCIBUS_ERROR \
524 (BRIDGE_ISR_PCIBUS_PIOERR|BRIDGE_ISR_PCI_PERR| \
525 BRIDGE_ISR_PCI_SERR|BRIDGE_ISR_PCI_RETRY_CNT| \
526 BRIDGE_ISR_PCI_PARITY)
527
528#define BRIDGE_ISR_XTALK_ERROR \
529 (BRIDGE_ISR_XREAD_REQ_TIMEOUT|BRIDGE_ISR_XREQ_FIFO_OFLOW|\
530 BRIDGE_ISR_UNSUPPORTED_XOP|BRIDGE_ISR_INVLD_ADDR| \
531 BRIDGE_ISR_REQ_XTLK_ERR|BRIDGE_ISR_RESP_XTLK_ERR| \
532 BRIDGE_ISR_BAD_XREQ_PKT|BRIDGE_ISR_BAD_XRESP_PKT| \
533 BRIDGE_ISR_UNEXP_RESP)
534
535#define BRIDGE_ISR_ERRORS \
536 (BRIDGE_ISR_LINK_ERROR|BRIDGE_ISR_PCIBUS_ERROR| \
537 BRIDGE_ISR_XTALK_ERROR|BRIDGE_ISR_SSRAM_PERR| \
538 BRIDGE_ISR_PMU_ESIZE_FAULT)
539
540/*
541 * List of Errors which are fatal and kill the system
542 */
543#define BRIDGE_ISR_ERROR_FATAL \
544 ((BRIDGE_ISR_XTALK_ERROR & ~BRIDGE_ISR_XREAD_REQ_TIMEOUT)|\
545 BRIDGE_ISR_PCI_SERR|BRIDGE_ISR_PCI_PARITY )
546
547#define BRIDGE_ISR_ERROR_DUMP \
548 (BRIDGE_ISR_PCIBUS_ERROR|BRIDGE_ISR_PMU_ESIZE_FAULT| \
549 BRIDGE_ISR_XTALK_ERROR|BRIDGE_ISR_SSRAM_PERR)
550
551/* Bridge interrupt enable register bits definition */
552#define BRIDGE_IMR_UNEXP_RESP BRIDGE_ISR_UNEXP_RESP
553#define BRIDGE_IMR_PMU_ESIZE_FAULT BRIDGE_ISR_PMU_ESIZE_FAULT
554#define BRIDGE_IMR_BAD_XRESP_PKT BRIDGE_ISR_BAD_XRESP_PKT
555#define BRIDGE_IMR_BAD_XREQ_PKT BRIDGE_ISR_BAD_XREQ_PKT
556#define BRIDGE_IMR_RESP_XTLK_ERR BRIDGE_ISR_RESP_XTLK_ERR
557#define BRIDGE_IMR_REQ_XTLK_ERR BRIDGE_ISR_REQ_XTLK_ERR
558#define BRIDGE_IMR_INVLD_ADDR BRIDGE_ISR_INVLD_ADDR
559#define BRIDGE_IMR_UNSUPPORTED_XOP BRIDGE_ISR_UNSUPPORTED_XOP
560#define BRIDGE_IMR_XREQ_FIFO_OFLOW BRIDGE_ISR_XREQ_FIFO_OFLOW
561#define BRIDGE_IMR_LLP_REC_SNERR BRIDGE_ISR_LLP_REC_SNERR
562#define BRIDGE_IMR_LLP_REC_CBERR BRIDGE_ISR_LLP_REC_CBERR
563#define BRIDGE_IMR_LLP_RCTY BRIDGE_ISR_LLP_RCTY
564#define BRIDGE_IMR_LLP_TX_RETRY BRIDGE_ISR_LLP_TX_RETRY
565#define BRIDGE_IMR_LLP_TCTY BRIDGE_ISR_LLP_TCTY
566#define BRIDGE_IMR_SSRAM_PERR BRIDGE_ISR_SSRAM_PERR
567#define BRIDGE_IMR_PCI_ABORT BRIDGE_ISR_PCI_ABORT
568#define BRIDGE_IMR_PCI_PARITY BRIDGE_ISR_PCI_PARITY
569#define BRIDGE_IMR_PCI_SERR BRIDGE_ISR_PCI_SERR
570#define BRIDGE_IMR_PCI_PERR BRIDGE_ISR_PCI_PERR
571#define BRIDGE_IMR_PCI_MST_TIMEOUT BRIDGE_ISR_PCI_MST_TIMEOUT
572#define BRIDGE_IMR_GIO_MST_TIMEOUT BRIDGE_ISR_GIO_MST_TIMEOUT
573#define BRIDGE_IMR_PCI_RETRY_CNT BRIDGE_ISR_PCI_RETRY_CNT
574#define BRIDGE_IMR_XREAD_REQ_TIMEOUT BRIDGE_ISR_XREAD_REQ_TIMEOUT
575#define BRIDGE_IMR_GIO_B_ENBL_ERR BRIDGE_ISR_GIO_B_ENBL_ERR
576#define BRIDGE_IMR_INT_MSK BRIDGE_ISR_INT_MSK
577#define BRIDGE_IMR_INT(x) BRIDGE_ISR_INT(x)
578
579/* Bridge interrupt reset register bits definition */
580#define BRIDGE_IRR_MULTI_CLR (0x1 << 6)
581#define BRIDGE_IRR_CRP_GRP_CLR (0x1 << 5)
582#define BRIDGE_IRR_RESP_BUF_GRP_CLR (0x1 << 4)
583#define BRIDGE_IRR_REQ_DSP_GRP_CLR (0x1 << 3)
584#define BRIDGE_IRR_LLP_GRP_CLR (0x1 << 2)
585#define BRIDGE_IRR_SSRAM_GRP_CLR (0x1 << 1)
586#define BRIDGE_IRR_PCI_GRP_CLR (0x1 << 0)
587#define BRIDGE_IRR_GIO_GRP_CLR (0x1 << 0)
588#define BRIDGE_IRR_ALL_CLR 0x7f
589
590#define BRIDGE_IRR_CRP_GRP (BRIDGE_ISR_UNEXP_RESP | \
591 BRIDGE_ISR_XREQ_FIFO_OFLOW)
592#define BRIDGE_IRR_RESP_BUF_GRP (BRIDGE_ISR_BAD_XRESP_PKT | \
593 BRIDGE_ISR_RESP_XTLK_ERR | \
594 BRIDGE_ISR_XREAD_REQ_TIMEOUT)
595#define BRIDGE_IRR_REQ_DSP_GRP (BRIDGE_ISR_UNSUPPORTED_XOP | \
596 BRIDGE_ISR_BAD_XREQ_PKT | \
597 BRIDGE_ISR_REQ_XTLK_ERR | \
598 BRIDGE_ISR_INVLD_ADDR)
599#define BRIDGE_IRR_LLP_GRP (BRIDGE_ISR_LLP_REC_SNERR | \
600 BRIDGE_ISR_LLP_REC_CBERR | \
601 BRIDGE_ISR_LLP_RCTY | \
602 BRIDGE_ISR_LLP_TX_RETRY | \
603 BRIDGE_ISR_LLP_TCTY)
604#define BRIDGE_IRR_SSRAM_GRP (BRIDGE_ISR_SSRAM_PERR | \
605 BRIDGE_ISR_PMU_ESIZE_FAULT)
606#define BRIDGE_IRR_PCI_GRP (BRIDGE_ISR_PCI_ABORT | \
607 BRIDGE_ISR_PCI_PARITY | \
608 BRIDGE_ISR_PCI_SERR | \
609 BRIDGE_ISR_PCI_PERR | \
610 BRIDGE_ISR_PCI_MST_TIMEOUT | \
611 BRIDGE_ISR_PCI_RETRY_CNT)
612
613#define BRIDGE_IRR_GIO_GRP (BRIDGE_ISR_GIO_B_ENBL_ERR | \
614 BRIDGE_ISR_GIO_MST_TIMEOUT)
615
616/* Bridge INT_DEV register bits definition */
617#define BRIDGE_INT_DEV_SHFT(n) ((n)*3)
618#define BRIDGE_INT_DEV_MASK(n) (0x7 << BRIDGE_INT_DEV_SHFT(n))
619#define BRIDGE_INT_DEV_SET(_dev, _line) (_dev << BRIDGE_INT_DEV_SHFT(_line))
620
621/* Bridge interrupt(x) register bits definition */
622#define BRIDGE_INT_ADDR_HOST 0x0003FF00
623#define BRIDGE_INT_ADDR_FLD 0x000000FF
624
625#define BRIDGE_TMO_PCI_RETRY_HLD_MASK 0x1f0000
626#define BRIDGE_TMO_GIO_TIMEOUT_MASK 0x001000
627#define BRIDGE_TMO_PCI_RETRY_CNT_MASK 0x0003ff
628
629#define BRIDGE_TMO_PCI_RETRY_CNT_MAX 0x3ff
630
631/*
632 * The NASID should be shifted by this amount and stored into the
633 * interrupt(x) register.
634 */
635#define BRIDGE_INT_ADDR_NASID_SHFT 8
636
637/*
638 * The BRIDGE_INT_ADDR_DEST_IO bit should be set to send an interrupt to
639 * memory.
640 */
641#define BRIDGE_INT_ADDR_DEST_IO (1 << 17)
642#define BRIDGE_INT_ADDR_DEST_MEM 0
643#define BRIDGE_INT_ADDR_MASK (1 << 17)
644
645/* Bridge device(x) register bits definition */
646#define BRIDGE_DEV_ERR_LOCK_EN 0x10000000
647#define BRIDGE_DEV_PAGE_CHK_DIS 0x08000000
648#define BRIDGE_DEV_FORCE_PCI_PAR 0x04000000
649#define BRIDGE_DEV_VIRTUAL_EN 0x02000000
650#define BRIDGE_DEV_PMU_WRGA_EN 0x01000000
651#define BRIDGE_DEV_DIR_WRGA_EN 0x00800000
652#define BRIDGE_DEV_DEV_SIZE 0x00400000
653#define BRIDGE_DEV_RT 0x00200000
654#define BRIDGE_DEV_SWAP_PMU 0x00100000
655#define BRIDGE_DEV_SWAP_DIR 0x00080000
656#define BRIDGE_DEV_PREF 0x00040000
657#define BRIDGE_DEV_PRECISE 0x00020000
658#define BRIDGE_DEV_COH 0x00010000
659#define BRIDGE_DEV_BARRIER 0x00008000
660#define BRIDGE_DEV_GBR 0x00004000
661#define BRIDGE_DEV_DEV_SWAP 0x00002000
662#define BRIDGE_DEV_DEV_IO_MEM 0x00001000
663#define BRIDGE_DEV_OFF_MASK 0x00000fff
664#define BRIDGE_DEV_OFF_ADDR_SHFT 20
665
666#define BRIDGE_DEV_PMU_BITS (BRIDGE_DEV_PMU_WRGA_EN | \
667 BRIDGE_DEV_SWAP_PMU)
668#define BRIDGE_DEV_D32_BITS (BRIDGE_DEV_DIR_WRGA_EN | \
669 BRIDGE_DEV_SWAP_DIR | \
670 BRIDGE_DEV_PREF | \
671 BRIDGE_DEV_PRECISE | \
672 BRIDGE_DEV_COH | \
673 BRIDGE_DEV_BARRIER)
674#define BRIDGE_DEV_D64_BITS (BRIDGE_DEV_DIR_WRGA_EN | \
675 BRIDGE_DEV_SWAP_DIR | \
676 BRIDGE_DEV_COH | \
677 BRIDGE_DEV_BARRIER)
678
679/* Bridge Error Upper register bit field definition */
680#define BRIDGE_ERRUPPR_DEVMASTER (0x1 << 20) /* Device was master */
681#define BRIDGE_ERRUPPR_PCIVDEV (0x1 << 19) /* Virtual Req value */
682#define BRIDGE_ERRUPPR_DEVNUM_SHFT (16)
683#define BRIDGE_ERRUPPR_DEVNUM_MASK (0x7 << BRIDGE_ERRUPPR_DEVNUM_SHFT)
684#define BRIDGE_ERRUPPR_DEVICE(err) (((err) >> BRIDGE_ERRUPPR_DEVNUM_SHFT) & 0x7)
685#define BRIDGE_ERRUPPR_ADDRMASK (0xFFFF)
686
687/* Bridge interrupt mode register bits definition */
688#define BRIDGE_INTMODE_CLR_PKT_EN(x) (0x1 << (x))
689
690/* this should be written to the xbow's link_control(x) register */
691#define BRIDGE_CREDIT 3
692
693/* RRB assignment register */
694#define BRIDGE_RRB_EN 0x8 /* after shifting down */
695#define BRIDGE_RRB_DEV 0x7 /* after shifting down */
696#define BRIDGE_RRB_VDEV 0x4 /* after shifting down */
697#define BRIDGE_RRB_PDEV 0x3 /* after shifting down */
698
699/* RRB status register */
700#define BRIDGE_RRB_VALID(r) (0x00010000<<(r))
701#define BRIDGE_RRB_INUSE(r) (0x00000001<<(r))
702
703/* RRB clear register */
704#define BRIDGE_RRB_CLEAR(r) (0x00000001<<(r))
705
706/* xbox system controller declarations */
707#define XBOX_BRIDGE_WID 8
708#define FLASH_PROM1_BASE 0xE00000 /* To read the xbox sysctlr status */
709#define XBOX_RPS_EXISTS 1 << 6 /* RPS bit in status register */
710#define XBOX_RPS_FAIL 1 << 4 /* RPS status bit in register */
711
712/* ========================================================================
713 */
714/*
715 * Macros for Xtalk to Bridge bus (PCI/GIO) PIO
716 * refer to section 4.2.1 of Bridge Spec for xtalk to PCI/GIO PIO mappings
717 */
718/* XTALK addresses that map into Bridge Bus addr space */
719#define BRIDGE_PIO32_XTALK_ALIAS_BASE 0x000040000000L
720#define BRIDGE_PIO32_XTALK_ALIAS_LIMIT 0x00007FFFFFFFL
721#define BRIDGE_PIO64_XTALK_ALIAS_BASE 0x000080000000L
722#define BRIDGE_PIO64_XTALK_ALIAS_LIMIT 0x0000BFFFFFFFL
723#define BRIDGE_PCIIO_XTALK_ALIAS_BASE 0x000100000000L
724#define BRIDGE_PCIIO_XTALK_ALIAS_LIMIT 0x0001FFFFFFFFL
725
726/* Ranges of PCI bus space that can be accessed via PIO from xtalk */
727#define BRIDGE_MIN_PIO_ADDR_MEM 0x00000000 /* 1G PCI memory space */
728#define BRIDGE_MAX_PIO_ADDR_MEM 0x3fffffff
729#define BRIDGE_MIN_PIO_ADDR_IO 0x00000000 /* 4G PCI IO space */
730#define BRIDGE_MAX_PIO_ADDR_IO 0xffffffff
731
732/* XTALK addresses that map into PCI addresses */
733#define BRIDGE_PCI_MEM32_BASE BRIDGE_PIO32_XTALK_ALIAS_BASE
734#define BRIDGE_PCI_MEM32_LIMIT BRIDGE_PIO32_XTALK_ALIAS_LIMIT
735#define BRIDGE_PCI_MEM64_BASE BRIDGE_PIO64_XTALK_ALIAS_BASE
736#define BRIDGE_PCI_MEM64_LIMIT BRIDGE_PIO64_XTALK_ALIAS_LIMIT
737#define BRIDGE_PCI_IO_BASE BRIDGE_PCIIO_XTALK_ALIAS_BASE
738#define BRIDGE_PCI_IO_LIMIT BRIDGE_PCIIO_XTALK_ALIAS_LIMIT
739
740/*
741 * Macros for Bridge bus (PCI/GIO) to Xtalk DMA
742 */
743/* Bridge Bus DMA addresses */
744#define BRIDGE_LOCAL_BASE 0
745#define BRIDGE_DMA_MAPPED_BASE 0x40000000
746#define BRIDGE_DMA_MAPPED_SIZE 0x40000000 /* 1G Bytes */
747#define BRIDGE_DMA_DIRECT_BASE 0x80000000
748#define BRIDGE_DMA_DIRECT_SIZE 0x80000000 /* 2G Bytes */
749
750#define PCI32_LOCAL_BASE BRIDGE_LOCAL_BASE
751
752/* PCI addresses of regions decoded by Bridge for DMA */
753#define PCI32_MAPPED_BASE BRIDGE_DMA_MAPPED_BASE
754#define PCI32_DIRECT_BASE BRIDGE_DMA_DIRECT_BASE
755
756#define IS_PCI32_LOCAL(x) ((ulong_t)(x) < PCI32_MAPPED_BASE)
757#define IS_PCI32_MAPPED(x) ((ulong_t)(x) < PCI32_DIRECT_BASE && \
758 (ulong_t)(x) >= PCI32_MAPPED_BASE)
759#define IS_PCI32_DIRECT(x) ((ulong_t)(x) >= PCI32_MAPPED_BASE)
760#define IS_PCI64(x) ((ulong_t)(x) >= PCI64_BASE)
761
762/*
763 * The GIO address space.
764 */
765/* Xtalk to GIO PIO */
766#define BRIDGE_GIO_MEM32_BASE BRIDGE_PIO32_XTALK_ALIAS_BASE
767#define BRIDGE_GIO_MEM32_LIMIT BRIDGE_PIO32_XTALK_ALIAS_LIMIT
768
769#define GIO_LOCAL_BASE BRIDGE_LOCAL_BASE
770
771/* GIO addresses of regions decoded by Bridge for DMA */
772#define GIO_MAPPED_BASE BRIDGE_DMA_MAPPED_BASE
773#define GIO_DIRECT_BASE BRIDGE_DMA_DIRECT_BASE
774
775#define IS_GIO_LOCAL(x) ((ulong_t)(x) < GIO_MAPPED_BASE)
776#define IS_GIO_MAPPED(x) ((ulong_t)(x) < GIO_DIRECT_BASE && \
777 (ulong_t)(x) >= GIO_MAPPED_BASE)
778#define IS_GIO_DIRECT(x) ((ulong_t)(x) >= GIO_MAPPED_BASE)
779
780/* PCI to xtalk mapping */
781
782/* given a DIR_OFF value and a pci/gio 32 bits direct address, determine
783 * which xtalk address is accessed
784 */
785#define BRIDGE_DIRECT_32_SEG_SIZE BRIDGE_DMA_DIRECT_SIZE
786#define BRIDGE_DIRECT_32_TO_XTALK(dir_off,adr) \
787 ((dir_off) * BRIDGE_DIRECT_32_SEG_SIZE + \
788 ((adr) & (BRIDGE_DIRECT_32_SEG_SIZE - 1)) + PHYS_RAMBASE)
789
790/* 64-bit address attribute masks */
791#define PCI64_ATTR_TARG_MASK 0xf000000000000000
792#define PCI64_ATTR_TARG_SHFT 60
793#define PCI64_ATTR_PREF 0x0800000000000000
794#define PCI64_ATTR_PREC 0x0400000000000000
795#define PCI64_ATTR_VIRTUAL 0x0200000000000000
796#define PCI64_ATTR_BAR 0x0100000000000000
797#define PCI64_ATTR_RMF_MASK 0x00ff000000000000
798#define PCI64_ATTR_RMF_SHFT 48
799
800#ifndef __ASSEMBLY__
801/* Address translation entry for mapped pci32 accesses */
802typedef union ate_u {
803 u64 ent;
804 struct ate_s {
805 u64 rmf:16;
806 u64 addr:36;
807 u64 targ:4;
808 u64 reserved:3;
809 u64 barrier:1;
810 u64 prefetch:1;
811 u64 precise:1;
812 u64 coherent:1;
813 u64 valid:1;
814 } field;
815} ate_t;
816#endif /* !__ASSEMBLY__ */
817
818#define ATE_V 0x01
819#define ATE_CO 0x02
820#define ATE_PREC 0x04
821#define ATE_PREF 0x08
822#define ATE_BAR 0x10
823
824#define ATE_PFNSHIFT 12
825#define ATE_TIDSHIFT 8
826#define ATE_RMFSHIFT 48
827
828#define mkate(xaddr, xid, attr) ((xaddr) & 0x0000fffffffff000ULL) | \
829 ((xid)<<ATE_TIDSHIFT) | \
830 (attr)
831
832#define BRIDGE_INTERNAL_ATES 128
833
834struct bridge_controller {
835 struct pci_controller pc;
836 struct resource mem;
837 struct resource io;
838 bridge_t *base;
839 nasid_t nasid;
840 unsigned int widget_id;
841 unsigned int irq_cpu;
842 dma64_addr_t baddr;
843 unsigned int pci_int[8];
844};
845
846#define BRIDGE_CONTROLLER(bus) \
847 ((struct bridge_controller *)((bus)->sysdata))
848
849extern void register_bridge_irq(unsigned int irq);
850extern int request_bridge_irq(struct bridge_controller *bc);
851
852extern struct pci_ops bridge_pci_ops;
853
854#endif /* _ASM_PCI_BRIDGE_H */
diff --git a/arch/mips/include/asm/percpu.h b/arch/mips/include/asm/percpu.h
new file mode 100644
index 000000000000..844e763e9332
--- /dev/null
+++ b/arch/mips/include/asm/percpu.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_PERCPU_H
2#define __ASM_PERCPU_H
3
4#include <asm-generic/percpu.h>
5
6#endif /* __ASM_PERCPU_H */
diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
new file mode 100644
index 000000000000..1275831dda29
--- /dev/null
+++ b/arch/mips/include/asm/pgalloc.h
@@ -0,0 +1,143 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 2001, 2003 by Ralf Baechle
7 * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_PGALLOC_H
10#define _ASM_PGALLOC_H
11
12#include <linux/highmem.h>
13#include <linux/mm.h>
14#include <linux/sched.h>
15
16static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
17 pte_t *pte)
18{
19 set_pmd(pmd, __pmd((unsigned long)pte));
20}
21
22static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
23 pgtable_t pte)
24{
25 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
26}
27#define pmd_pgtable(pmd) pmd_page(pmd)
28
29/*
30 * Initialize a new pmd table with invalid pointers.
31 */
32extern void pmd_init(unsigned long page, unsigned long pagetable);
33
34#ifdef CONFIG_64BIT
35
36static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
37{
38 set_pud(pud, __pud((unsigned long)pmd));
39}
40#endif
41
42/*
43 * Initialize a new pgd / pmd table with invalid pointers.
44 */
45extern void pgd_init(unsigned long page);
46
47static inline pgd_t *pgd_alloc(struct mm_struct *mm)
48{
49 pgd_t *ret, *init;
50
51 ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
52 if (ret) {
53 init = pgd_offset(&init_mm, 0UL);
54 pgd_init((unsigned long)ret);
55 memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
56 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
57 }
58
59 return ret;
60}
61
62static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
63{
64 free_pages((unsigned long)pgd, PGD_ORDER);
65}
66
67static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
68 unsigned long address)
69{
70 pte_t *pte;
71
72 pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, PTE_ORDER);
73
74 return pte;
75}
76
77static inline struct page *pte_alloc_one(struct mm_struct *mm,
78 unsigned long address)
79{
80 struct page *pte;
81
82 pte = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
83 if (pte) {
84 clear_highpage(pte);
85 pgtable_page_ctor(pte);
86 }
87 return pte;
88}
89
90static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
91{
92 free_pages((unsigned long)pte, PTE_ORDER);
93}
94
95static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
96{
97 pgtable_page_dtor(pte);
98 __free_pages(pte, PTE_ORDER);
99}
100
101#define __pte_free_tlb(tlb,pte) \
102do { \
103 pgtable_page_dtor(pte); \
104 tlb_remove_page((tlb), pte); \
105} while (0)
106
107#ifdef CONFIG_32BIT
108
109/*
110 * allocating and freeing a pmd is trivial: the 1-entry pmd is
111 * inside the pgd, so has no extra memory associated with it.
112 */
113#define pmd_free(mm, x) do { } while (0)
114#define __pmd_free_tlb(tlb, x) do { } while (0)
115
116#endif
117
118#ifdef CONFIG_64BIT
119
120static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
121{
122 pmd_t *pmd;
123
124 pmd = (pmd_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT, PMD_ORDER);
125 if (pmd)
126 pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
127 return pmd;
128}
129
130static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
131{
132 free_pages((unsigned long)pmd, PMD_ORDER);
133}
134
135#define __pmd_free_tlb(tlb, x) pmd_free((tlb)->mm, x)
136
137#endif
138
139#define check_pgt_cache() do { } while (0)
140
141extern void pagetable_init(void);
142
143#endif /* _ASM_PGALLOC_H */
diff --git a/arch/mips/include/asm/pgtable-32.h b/arch/mips/include/asm/pgtable-32.h
new file mode 100644
index 000000000000..55813d6150c7
--- /dev/null
+++ b/arch/mips/include/asm/pgtable-32.h
@@ -0,0 +1,234 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 2003 Ralf Baechle
7 * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_PGTABLE_32_H
10#define _ASM_PGTABLE_32_H
11
12#include <asm/addrspace.h>
13#include <asm/page.h>
14
15#include <linux/linkage.h>
16#include <asm/cachectl.h>
17#include <asm/fixmap.h>
18
19#include <asm-generic/pgtable-nopmd.h>
20
21/*
22 * - add_wired_entry() add a fixed TLB entry, and move wired register
23 */
24extern void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
25 unsigned long entryhi, unsigned long pagemask);
26
27/*
28 * - add_temporary_entry() add a temporary TLB entry. We use TLB entries
29 * starting at the top and working down. This is for populating the
30 * TLB before trap_init() puts the TLB miss handler in place. It
31 * should be used only for entries matching the actual page tables,
32 * to prevent inconsistencies.
33 */
34extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
35 unsigned long entryhi, unsigned long pagemask);
36
37
38/* Basically we have the same two-level (which is the logical three level
39 * Linux page table layout folded) page tables as the i386. Some day
40 * when we have proper page coloring support we can have a 1% quicker
41 * tlb refill handling mechanism, but for now it is a bit slower but
42 * works even with the cache aliasing problem the R4k and above have.
43 */
44
45/* PGDIR_SHIFT determines what a third-level page table entry can map */
46#define PGDIR_SHIFT (2 * PAGE_SHIFT + PTE_ORDER - PTE_T_LOG2)
47#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
48#define PGDIR_MASK (~(PGDIR_SIZE-1))
49
50/*
51 * Entries per page directory level: we use two-level, so
52 * we don't really have any PUD/PMD directory physically.
53 */
54#define __PGD_ORDER (32 - 3 * PAGE_SHIFT + PGD_T_LOG2 + PTE_T_LOG2)
55#define PGD_ORDER (__PGD_ORDER >= 0 ? __PGD_ORDER : 0)
56#define PUD_ORDER aieeee_attempt_to_allocate_pud
57#define PMD_ORDER 1
58#define PTE_ORDER 0
59
60#define PTRS_PER_PGD (USER_PTRS_PER_PGD * 2)
61#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
62
63#define USER_PTRS_PER_PGD (0x80000000UL/PGDIR_SIZE)
64#define FIRST_USER_ADDRESS 0
65
66#define VMALLOC_START MAP_BASE
67
68#define PKMAP_BASE (0xfe000000UL)
69
70#ifdef CONFIG_HIGHMEM
71# define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE)
72#else
73# define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
74#endif
75
76#ifdef CONFIG_64BIT_PHYS_ADDR
77#define pte_ERROR(e) \
78 printk("%s:%d: bad pte %016Lx.\n", __FILE__, __LINE__, pte_val(e))
79#else
80#define pte_ERROR(e) \
81 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
82#endif
83#define pgd_ERROR(e) \
84 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
85
86extern void load_pgd(unsigned long pg_dir);
87
88extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)];
89
90/*
91 * Empty pgd/pmd entries point to the invalid_pte_table.
92 */
93static inline int pmd_none(pmd_t pmd)
94{
95 return pmd_val(pmd) == (unsigned long) invalid_pte_table;
96}
97
98#define pmd_bad(pmd) (pmd_val(pmd) & ~PAGE_MASK)
99
100static inline int pmd_present(pmd_t pmd)
101{
102 return pmd_val(pmd) != (unsigned long) invalid_pte_table;
103}
104
105static inline void pmd_clear(pmd_t *pmdp)
106{
107 pmd_val(*pmdp) = ((unsigned long) invalid_pte_table);
108}
109
110#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
111#define pte_page(x) pfn_to_page(pte_pfn(x))
112#define pte_pfn(x) ((unsigned long)((x).pte_high >> 6))
113static inline pte_t
114pfn_pte(unsigned long pfn, pgprot_t prot)
115{
116 pte_t pte;
117 pte.pte_high = (pfn << 6) | (pgprot_val(prot) & 0x3f);
118 pte.pte_low = pgprot_val(prot);
119 return pte;
120}
121
122#else
123
124#define pte_page(x) pfn_to_page(pte_pfn(x))
125
126#ifdef CONFIG_CPU_VR41XX
127#define pte_pfn(x) ((unsigned long)((x).pte >> (PAGE_SHIFT + 2)))
128#define pfn_pte(pfn, prot) __pte(((pfn) << (PAGE_SHIFT + 2)) | pgprot_val(prot))
129#else
130#define pte_pfn(x) ((unsigned long)((x).pte >> PAGE_SHIFT))
131#define pfn_pte(pfn, prot) __pte(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
132#endif
133#endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */
134
135#define __pgd_offset(address) pgd_index(address)
136#define __pud_offset(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
137#define __pmd_offset(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
138
139/* to find an entry in a kernel page-table-directory */
140#define pgd_offset_k(address) pgd_offset(&init_mm, address)
141
142#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
143
144/* to find an entry in a page-table-directory */
145#define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
146
147/* Find an entry in the third-level page table.. */
148#define __pte_offset(address) \
149 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
150#define pte_offset(dir, address) \
151 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
152#define pte_offset_kernel(dir, address) \
153 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
154
155#define pte_offset_map(dir, address) \
156 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
157#define pte_offset_map_nested(dir, address) \
158 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
159#define pte_unmap(pte) ((void)(pte))
160#define pte_unmap_nested(pte) ((void)(pte))
161
162#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
163
164/* Swap entries must have VALID bit cleared. */
165#define __swp_type(x) (((x).val >> 10) & 0x1f)
166#define __swp_offset(x) ((x).val >> 15)
167#define __swp_entry(type,offset) \
168 ((swp_entry_t) { ((type) << 10) | ((offset) << 15) })
169
170/*
171 * Bits 0, 4, 8, and 9 are taken, split up 28 bits of offset into this range:
172 */
173#define PTE_FILE_MAX_BITS 28
174
175#define pte_to_pgoff(_pte) ((((_pte).pte >> 1 ) & 0x07) | \
176 (((_pte).pte >> 2 ) & 0x38) | \
177 (((_pte).pte >> 10) << 6 ))
178
179#define pgoff_to_pte(off) ((pte_t) { (((off) & 0x07) << 1 ) | \
180 (((off) & 0x38) << 2 ) | \
181 (((off) >> 6 ) << 10) | \
182 _PAGE_FILE })
183
184#else
185
186/* Swap entries must have VALID and GLOBAL bits cleared. */
187#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
188#define __swp_type(x) (((x).val >> 2) & 0x1f)
189#define __swp_offset(x) ((x).val >> 7)
190#define __swp_entry(type,offset) \
191 ((swp_entry_t) { ((type) << 2) | ((offset) << 7) })
192#else
193#define __swp_type(x) (((x).val >> 8) & 0x1f)
194#define __swp_offset(x) ((x).val >> 13)
195#define __swp_entry(type,offset) \
196 ((swp_entry_t) { ((type) << 8) | ((offset) << 13) })
197#endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */
198
199#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
200/*
201 * Bits 0 and 1 of pte_high are taken, use the rest for the page offset...
202 */
203#define PTE_FILE_MAX_BITS 30
204
205#define pte_to_pgoff(_pte) ((_pte).pte_high >> 2)
206#define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) << 2 })
207
208#else
209/*
210 * Bits 0, 4, 6, and 7 are taken, split up 28 bits of offset into this range:
211 */
212#define PTE_FILE_MAX_BITS 28
213
214#define pte_to_pgoff(_pte) ((((_pte).pte >> 1) & 0x7) | \
215 (((_pte).pte >> 2) & 0x8) | \
216 (((_pte).pte >> 8) << 4))
217
218#define pgoff_to_pte(off) ((pte_t) { (((off) & 0x7) << 1) | \
219 (((off) & 0x8) << 2) | \
220 (((off) >> 4) << 8) | \
221 _PAGE_FILE })
222#endif
223
224#endif
225
226#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
227#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_high })
228#define __swp_entry_to_pte(x) ((pte_t) { 0, (x).val })
229#else
230#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
231#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
232#endif
233
234#endif /* _ASM_PGTABLE_32_H */
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
new file mode 100644
index 000000000000..943515f0ef87
--- /dev/null
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -0,0 +1,253 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 2003 Ralf Baechle
7 * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_PGTABLE_64_H
10#define _ASM_PGTABLE_64_H
11
12#include <linux/linkage.h>
13
14#include <asm/addrspace.h>
15#include <asm/page.h>
16#include <asm/cachectl.h>
17#include <asm/fixmap.h>
18
19#include <asm-generic/pgtable-nopud.h>
20
21/*
22 * Each address space has 2 4K pages as its page directory, giving 1024
23 * (== PTRS_PER_PGD) 8 byte pointers to pmd tables. Each pmd table is a
24 * single 4K page, giving 512 (== PTRS_PER_PMD) 8 byte pointers to page
25 * tables. Each page table is also a single 4K page, giving 512 (==
26 * PTRS_PER_PTE) 8 byte ptes. Each pud entry is initialized to point to
27 * invalid_pmd_table, each pmd entry is initialized to point to
28 * invalid_pte_table, each pte is initialized to 0. When memory is low,
29 * and a pmd table or a page table allocation fails, empty_bad_pmd_table
30 * and empty_bad_page_table is returned back to higher layer code, so
31 * that the failure is recognized later on. Linux does not seem to
32 * handle these failures very well though. The empty_bad_page_table has
33 * invalid pte entries in it, to force page faults.
34 *
35 * Kernel mappings: kernel mappings are held in the swapper_pg_table.
36 * The layout is identical to userspace except it's indexed with the
37 * fault address - VMALLOC_START.
38 */
39
40/* PMD_SHIFT determines the size of the area a second-level page table can map */
41#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT + PTE_ORDER - 3))
42#define PMD_SIZE (1UL << PMD_SHIFT)
43#define PMD_MASK (~(PMD_SIZE-1))
44
45/* PGDIR_SHIFT determines what a third-level page table entry can map */
46#define PGDIR_SHIFT (PMD_SHIFT + (PAGE_SHIFT + PMD_ORDER - 3))
47#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
48#define PGDIR_MASK (~(PGDIR_SIZE-1))
49
50/*
51 * For 4kB page size we use a 3 level page tree and an 8kB pud, which
52 * permits us mapping 40 bits of virtual address space.
53 *
54 * We used to implement 41 bits by having an order 1 pmd level but that seemed
55 * rather pointless.
56 *
57 * For 8kB page size we use a 3 level page tree which permits a total of
58 * 8TB of address space. Alternatively a 33-bit / 8GB organization using
59 * two levels would be easy to implement.
60 *
61 * For 16kB page size we use a 2 level page tree which permits a total of
62 * 36 bits of virtual address space. We could add a third level but it seems
63 * like at the moment there's no need for this.
64 *
65 * For 64kB page size we use a 2 level page table tree for a total of 42 bits
66 * of virtual address space.
67 */
68#ifdef CONFIG_PAGE_SIZE_4KB
69#define PGD_ORDER 1
70#define PUD_ORDER aieeee_attempt_to_allocate_pud
71#define PMD_ORDER 0
72#define PTE_ORDER 0
73#endif
74#ifdef CONFIG_PAGE_SIZE_8KB
75#define PGD_ORDER 0
76#define PUD_ORDER aieeee_attempt_to_allocate_pud
77#define PMD_ORDER 0
78#define PTE_ORDER 0
79#endif
80#ifdef CONFIG_PAGE_SIZE_16KB
81#define PGD_ORDER 0
82#define PUD_ORDER aieeee_attempt_to_allocate_pud
83#define PMD_ORDER 0
84#define PTE_ORDER 0
85#endif
86#ifdef CONFIG_PAGE_SIZE_64KB
87#define PGD_ORDER 0
88#define PUD_ORDER aieeee_attempt_to_allocate_pud
89#define PMD_ORDER 0
90#define PTE_ORDER 0
91#endif
92
93#define PTRS_PER_PGD ((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
94#define PTRS_PER_PMD ((PAGE_SIZE << PMD_ORDER) / sizeof(pmd_t))
95#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
96
97#if PGDIR_SIZE >= TASK_SIZE
98#define USER_PTRS_PER_PGD (1)
99#else
100#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
101#endif
102#define FIRST_USER_ADDRESS 0UL
103
104#define VMALLOC_START MAP_BASE
105#define VMALLOC_END \
106 (VMALLOC_START + PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE)
107#if defined(CONFIG_MODULES) && defined(KBUILD_64BIT_SYM32) && \
108 VMALLOC_START != CKSSEG
109/* Load modules into 32bit-compatible segment. */
110#define MODULE_START CKSSEG
111#define MODULE_END (FIXADDR_START-2*PAGE_SIZE)
112extern pgd_t module_pg_dir[PTRS_PER_PGD];
113#endif
114
115#define pte_ERROR(e) \
116 printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
117#define pmd_ERROR(e) \
118 printk("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e))
119#define pgd_ERROR(e) \
120 printk("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e))
121
122extern pte_t invalid_pte_table[PTRS_PER_PTE];
123extern pte_t empty_bad_page_table[PTRS_PER_PTE];
124extern pmd_t invalid_pmd_table[PTRS_PER_PMD];
125extern pmd_t empty_bad_pmd_table[PTRS_PER_PMD];
126
127/*
128 * Empty pgd/pmd entries point to the invalid_pte_table.
129 */
130static inline int pmd_none(pmd_t pmd)
131{
132 return pmd_val(pmd) == (unsigned long) invalid_pte_table;
133}
134
135#define pmd_bad(pmd) (pmd_val(pmd) & ~PAGE_MASK)
136
137static inline int pmd_present(pmd_t pmd)
138{
139 return pmd_val(pmd) != (unsigned long) invalid_pte_table;
140}
141
142static inline void pmd_clear(pmd_t *pmdp)
143{
144 pmd_val(*pmdp) = ((unsigned long) invalid_pte_table);
145}
146
147/*
148 * Empty pud entries point to the invalid_pmd_table.
149 */
150static inline int pud_none(pud_t pud)
151{
152 return pud_val(pud) == (unsigned long) invalid_pmd_table;
153}
154
155static inline int pud_bad(pud_t pud)
156{
157 return pud_val(pud) & ~PAGE_MASK;
158}
159
160static inline int pud_present(pud_t pud)
161{
162 return pud_val(pud) != (unsigned long) invalid_pmd_table;
163}
164
165static inline void pud_clear(pud_t *pudp)
166{
167 pud_val(*pudp) = ((unsigned long) invalid_pmd_table);
168}
169
170#define pte_page(x) pfn_to_page(pte_pfn(x))
171
172#ifdef CONFIG_CPU_VR41XX
173#define pte_pfn(x) ((unsigned long)((x).pte >> (PAGE_SHIFT + 2)))
174#define pfn_pte(pfn, prot) __pte(((pfn) << (PAGE_SHIFT + 2)) | pgprot_val(prot))
175#else
176#define pte_pfn(x) ((unsigned long)((x).pte >> PAGE_SHIFT))
177#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
178#endif
179
180#define __pgd_offset(address) pgd_index(address)
181#define __pud_offset(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
182#define __pmd_offset(address) pmd_index(address)
183
184/* to find an entry in a kernel page-table-directory */
185#ifdef MODULE_START
186#define pgd_offset_k(address) \
187 ((address) >= MODULE_START ? module_pg_dir : pgd_offset(&init_mm, 0UL))
188#else
189#define pgd_offset_k(address) pgd_offset(&init_mm, 0UL)
190#endif
191
192#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
193#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
194
195/* to find an entry in a page-table-directory */
196#define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
197
198static inline unsigned long pud_page_vaddr(pud_t pud)
199{
200 return pud_val(pud);
201}
202#define pud_phys(pud) virt_to_phys((void *)pud_val(pud))
203#define pud_page(pud) (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
204
205/* Find an entry in the second-level page table.. */
206static inline pmd_t *pmd_offset(pud_t * pud, unsigned long address)
207{
208 return (pmd_t *) pud_page_vaddr(*pud) + pmd_index(address);
209}
210
211/* Find an entry in the third-level page table.. */
212#define __pte_offset(address) \
213 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
214#define pte_offset(dir, address) \
215 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
216#define pte_offset_kernel(dir, address) \
217 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
218#define pte_offset_map(dir, address) \
219 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
220#define pte_offset_map_nested(dir, address) \
221 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
222#define pte_unmap(pte) ((void)(pte))
223#define pte_unmap_nested(pte) ((void)(pte))
224
225/*
226 * Initialize a new pgd / pmd table with invalid pointers.
227 */
228extern void pgd_init(unsigned long page);
229extern void pmd_init(unsigned long page, unsigned long pagetable);
230
231/*
232 * Non-present pages: high 24 bits are offset, next 8 bits type,
233 * low 32 bits zero.
234 */
235static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
236{ pte_t pte; pte_val(pte) = (type << 32) | (offset << 40); return pte; }
237
238#define __swp_type(x) (((x).val >> 32) & 0xff)
239#define __swp_offset(x) ((x).val >> 40)
240#define __swp_entry(type, offset) ((swp_entry_t) { pte_val(mk_swap_pte((type), (offset))) })
241#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
242#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
243
244/*
245 * Bits 0, 4, 6, and 7 are taken. Let's leave bits 1, 2, 3, and 5 alone to
246 * make things easier, and only use the upper 56 bits for the page offset...
247 */
248#define PTE_FILE_MAX_BITS 56
249
250#define pte_to_pgoff(_pte) ((_pte).pte >> 8)
251#define pgoff_to_pte(off) ((pte_t) { ((off) << 8) | _PAGE_FILE })
252
253#endif /* _ASM_PGTABLE_64_H */
diff --git a/arch/mips/include/asm/pgtable-bits.h b/arch/mips/include/asm/pgtable-bits.h
new file mode 100644
index 000000000000..51b34a48c84a
--- /dev/null
+++ b/arch/mips/include/asm/pgtable-bits.h
@@ -0,0 +1,137 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 2002 by Ralf Baechle
7 * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc.
8 * Copyright (C) 2002 Maciej W. Rozycki
9 */
10#ifndef _ASM_PGTABLE_BITS_H
11#define _ASM_PGTABLE_BITS_H
12
13
14/*
15 * Note that we shift the lower 32bits of each EntryLo[01] entry
16 * 6 bits to the left. That way we can convert the PFN into the
17 * physical address by a single 'and' operation and gain 6 additional
18 * bits for storing information which isn't present in a normal
19 * MIPS page table.
20 *
21 * Similar to the Alpha port, we need to keep track of the ref
22 * and mod bits in software. We have a software "yeah you can read
23 * from this page" bit, and a hardware one which actually lets the
24 * process read from the page. On the same token we have a software
25 * writable bit and the real hardware one which actually lets the
26 * process write to the page, this keeps a mod bit via the hardware
27 * dirty bit.
28 *
29 * Certain revisions of the R4000 and R5000 have a bug where if a
30 * certain sequence occurs in the last 3 instructions of an executable
31 * page, and the following page is not mapped, the cpu can do
32 * unpredictable things. The code (when it is written) to deal with
33 * this problem will be in the update_mmu_cache() code for the r4k.
34 */
35#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
36
37#define _PAGE_PRESENT (1<<6) /* implemented in software */
38#define _PAGE_READ (1<<7) /* implemented in software */
39#define _PAGE_WRITE (1<<8) /* implemented in software */
40#define _PAGE_ACCESSED (1<<9) /* implemented in software */
41#define _PAGE_MODIFIED (1<<10) /* implemented in software */
42#define _PAGE_FILE (1<<10) /* set:pagecache unset:swap */
43
44#define _PAGE_R4KBUG (1<<0) /* workaround for r4k bug */
45#define _PAGE_GLOBAL (1<<0)
46#define _PAGE_VALID (1<<1)
47#define _PAGE_SILENT_READ (1<<1) /* synonym */
48#define _PAGE_DIRTY (1<<2) /* The MIPS dirty bit */
49#define _PAGE_SILENT_WRITE (1<<2)
50#define _CACHE_SHIFT 3
51#define _CACHE_MASK (7<<3)
52
53#else
54
55#define _PAGE_PRESENT (1<<0) /* implemented in software */
56#define _PAGE_READ (1<<1) /* implemented in software */
57#define _PAGE_WRITE (1<<2) /* implemented in software */
58#define _PAGE_ACCESSED (1<<3) /* implemented in software */
59#define _PAGE_MODIFIED (1<<4) /* implemented in software */
60#define _PAGE_FILE (1<<4) /* set:pagecache unset:swap */
61
62#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
63
64#define _PAGE_GLOBAL (1<<8)
65#define _PAGE_VALID (1<<9)
66#define _PAGE_SILENT_READ (1<<9) /* synonym */
67#define _PAGE_DIRTY (1<<10) /* The MIPS dirty bit */
68#define _PAGE_SILENT_WRITE (1<<10)
69#define _CACHE_UNCACHED (1<<11)
70#define _CACHE_MASK (1<<11)
71
72#else
73
74#define _PAGE_R4KBUG (1<<5) /* workaround for r4k bug */
75#define _PAGE_GLOBAL (1<<6)
76#define _PAGE_VALID (1<<7)
77#define _PAGE_SILENT_READ (1<<7) /* synonym */
78#define _PAGE_DIRTY (1<<8) /* The MIPS dirty bit */
79#define _PAGE_SILENT_WRITE (1<<8)
80#define _CACHE_SHIFT 9
81#define _CACHE_MASK (7<<9)
82
83#endif
84#endif /* defined(CONFIG_64BIT_PHYS_ADDR && defined(CONFIG_CPU_MIPS32) */
85
86
87/*
88 * Cache attributes
89 */
90#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
91
92#define _CACHE_CACHABLE_NONCOHERENT 0
93
94#elif defined(CONFIG_CPU_SB1)
95
96/* No penalty for being coherent on the SB1, so just
97 use it for "noncoherent" spaces, too. Shouldn't hurt. */
98
99#define _CACHE_UNCACHED (2<<_CACHE_SHIFT)
100#define _CACHE_CACHABLE_COW (5<<_CACHE_SHIFT)
101#define _CACHE_CACHABLE_NONCOHERENT (5<<_CACHE_SHIFT)
102#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT)
103
104#elif defined(CONFIG_CPU_RM9000)
105
106#define _CACHE_WT (0<<_CACHE_SHIFT)
107#define _CACHE_WTWA (1<<_CACHE_SHIFT)
108#define _CACHE_UC_B (2<<_CACHE_SHIFT)
109#define _CACHE_WB (3<<_CACHE_SHIFT)
110#define _CACHE_CWBEA (4<<_CACHE_SHIFT)
111#define _CACHE_CWB (5<<_CACHE_SHIFT)
112#define _CACHE_UCNB (6<<_CACHE_SHIFT)
113#define _CACHE_FPC (7<<_CACHE_SHIFT)
114
115#define _CACHE_UNCACHED _CACHE_UC_B
116#define _CACHE_CACHABLE_NONCOHERENT _CACHE_WB
117
118#else
119
120#define _CACHE_CACHABLE_NO_WA (0<<_CACHE_SHIFT) /* R4600 only */
121#define _CACHE_CACHABLE_WA (1<<_CACHE_SHIFT) /* R4600 only */
122#define _CACHE_UNCACHED (2<<_CACHE_SHIFT) /* R4[0246]00 */
123#define _CACHE_CACHABLE_NONCOHERENT (3<<_CACHE_SHIFT) /* R4[0246]00 */
124#define _CACHE_CACHABLE_CE (4<<_CACHE_SHIFT) /* R4[04]00MC only */
125#define _CACHE_CACHABLE_COW (5<<_CACHE_SHIFT) /* R4[04]00MC only */
126#define _CACHE_CACHABLE_COHERENT (5<<_CACHE_SHIFT) /* MIPS32R2 CMP */
127#define _CACHE_CACHABLE_CUW (6<<_CACHE_SHIFT) /* R4[04]00MC only */
128#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT) /* R10000 only */
129
130#endif
131
132#define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)
133#define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
134
135#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED | _CACHE_MASK)
136
137#endif /* _ASM_PGTABLE_BITS_H */
diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
new file mode 100644
index 000000000000..6a0edf72ffbc
--- /dev/null
+++ b/arch/mips/include/asm/pgtable.h
@@ -0,0 +1,383 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 Ralf Baechle
7 */
8#ifndef _ASM_PGTABLE_H
9#define _ASM_PGTABLE_H
10
11#ifdef CONFIG_32BIT
12#include <asm/pgtable-32.h>
13#endif
14#ifdef CONFIG_64BIT
15#include <asm/pgtable-64.h>
16#endif
17
18#include <asm/io.h>
19#include <asm/pgtable-bits.h>
20
21struct mm_struct;
22struct vm_area_struct;
23
24#define PAGE_NONE __pgprot(_PAGE_PRESENT | _CACHE_CACHABLE_NONCOHERENT)
25#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
26 _page_cachable_default)
27#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_READ | \
28 _page_cachable_default)
29#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_READ | \
30 _page_cachable_default)
31#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \
32 _PAGE_GLOBAL | _page_cachable_default)
33#define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
34 _page_cachable_default)
35#define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \
36 __WRITEABLE | _PAGE_GLOBAL | _CACHE_UNCACHED)
37
38/*
39 * MIPS can't do page protection for execute, and considers that the same like
40 * read. Also, write permissions imply read permissions. This is the closest
41 * we can get by reasonable means..
42 */
43
44/*
45 * Dummy values to fill the table in mmap.c
46 * The real values will be generated at runtime
47 */
48#define __P000 __pgprot(0)
49#define __P001 __pgprot(0)
50#define __P010 __pgprot(0)
51#define __P011 __pgprot(0)
52#define __P100 __pgprot(0)
53#define __P101 __pgprot(0)
54#define __P110 __pgprot(0)
55#define __P111 __pgprot(0)
56
57#define __S000 __pgprot(0)
58#define __S001 __pgprot(0)
59#define __S010 __pgprot(0)
60#define __S011 __pgprot(0)
61#define __S100 __pgprot(0)
62#define __S101 __pgprot(0)
63#define __S110 __pgprot(0)
64#define __S111 __pgprot(0)
65
66extern unsigned long _page_cachable_default;
67
68/*
69 * ZERO_PAGE is a global shared page that is always zero; used
70 * for zero-mapped memory areas etc..
71 */
72
73extern unsigned long empty_zero_page;
74extern unsigned long zero_page_mask;
75
76#define ZERO_PAGE(vaddr) \
77 (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
78
79extern void paging_init(void);
80
81/*
82 * Conversion functions: convert a page and protection to a page entry,
83 * and a page entry and page directory to the page they refer to.
84 */
85#define pmd_phys(pmd) virt_to_phys((void *)pmd_val(pmd))
86#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
87#define pmd_page_vaddr(pmd) pmd_val(pmd)
88
89#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
90
91#define pte_none(pte) (!(((pte).pte_low | (pte).pte_high) & ~_PAGE_GLOBAL))
92#define pte_present(pte) ((pte).pte_low & _PAGE_PRESENT)
93
94static inline void set_pte(pte_t *ptep, pte_t pte)
95{
96 ptep->pte_high = pte.pte_high;
97 smp_wmb();
98 ptep->pte_low = pte.pte_low;
99 //printk("pte_high %x pte_low %x\n", ptep->pte_high, ptep->pte_low);
100
101 if (pte.pte_low & _PAGE_GLOBAL) {
102 pte_t *buddy = ptep_buddy(ptep);
103 /*
104 * Make sure the buddy is global too (if it's !none,
105 * it better already be global)
106 */
107 if (pte_none(*buddy)) {
108 buddy->pte_low |= _PAGE_GLOBAL;
109 buddy->pte_high |= _PAGE_GLOBAL;
110 }
111 }
112}
113#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
114
115static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
116{
117 pte_t null = __pte(0);
118
119 /* Preserve global status for the pair */
120 if (ptep_buddy(ptep)->pte_low & _PAGE_GLOBAL)
121 null.pte_low = null.pte_high = _PAGE_GLOBAL;
122
123 set_pte_at(mm, addr, ptep, null);
124}
125#else
126
127#define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
128#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
129
130/*
131 * Certain architectures need to do special things when pte's
132 * within a page table are directly modified. Thus, the following
133 * hook is made available.
134 */
135static inline void set_pte(pte_t *ptep, pte_t pteval)
136{
137 *ptep = pteval;
138#if !defined(CONFIG_CPU_R3000) && !defined(CONFIG_CPU_TX39XX)
139 if (pte_val(pteval) & _PAGE_GLOBAL) {
140 pte_t *buddy = ptep_buddy(ptep);
141 /*
142 * Make sure the buddy is global too (if it's !none,
143 * it better already be global)
144 */
145 if (pte_none(*buddy))
146 pte_val(*buddy) = pte_val(*buddy) | _PAGE_GLOBAL;
147 }
148#endif
149}
150#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
151
152static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
153{
154#if !defined(CONFIG_CPU_R3000) && !defined(CONFIG_CPU_TX39XX)
155 /* Preserve global status for the pair */
156 if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL)
157 set_pte_at(mm, addr, ptep, __pte(_PAGE_GLOBAL));
158 else
159#endif
160 set_pte_at(mm, addr, ptep, __pte(0));
161}
162#endif
163
164/*
165 * (pmds are folded into puds so this doesn't get actually called,
166 * but the define is needed for a generic inline function.)
167 */
168#define set_pmd(pmdptr, pmdval) do { *(pmdptr) = (pmdval); } while(0)
169
170#ifdef CONFIG_64BIT
171/*
172 * (puds are folded into pgds so this doesn't get actually called,
173 * but the define is needed for a generic inline function.)
174 */
175#define set_pud(pudptr, pudval) do { *(pudptr) = (pudval); } while(0)
176#endif
177
178#define PGD_T_LOG2 (__builtin_ffs(sizeof(pgd_t)) - 1)
179#define PMD_T_LOG2 (__builtin_ffs(sizeof(pmd_t)) - 1)
180#define PTE_T_LOG2 (__builtin_ffs(sizeof(pte_t)) - 1)
181
182/*
183 * We used to declare this array with size but gcc 3.3 and older are not able
184 * to find that this expression is a constant, so the size is dropped.
185 */
186extern pgd_t swapper_pg_dir[];
187
188/*
189 * The following only work if pte_present() is true.
190 * Undefined behaviour if not..
191 */
192#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
193static inline int pte_write(pte_t pte) { return pte.pte_low & _PAGE_WRITE; }
194static inline int pte_dirty(pte_t pte) { return pte.pte_low & _PAGE_MODIFIED; }
195static inline int pte_young(pte_t pte) { return pte.pte_low & _PAGE_ACCESSED; }
196static inline int pte_file(pte_t pte) { return pte.pte_low & _PAGE_FILE; }
197
198static inline pte_t pte_wrprotect(pte_t pte)
199{
200 pte.pte_low &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
201 pte.pte_high &= ~_PAGE_SILENT_WRITE;
202 return pte;
203}
204
205static inline pte_t pte_mkclean(pte_t pte)
206{
207 pte.pte_low &= ~(_PAGE_MODIFIED | _PAGE_SILENT_WRITE);
208 pte.pte_high &= ~_PAGE_SILENT_WRITE;
209 return pte;
210}
211
212static inline pte_t pte_mkold(pte_t pte)
213{
214 pte.pte_low &= ~(_PAGE_ACCESSED | _PAGE_SILENT_READ);
215 pte.pte_high &= ~_PAGE_SILENT_READ;
216 return pte;
217}
218
219static inline pte_t pte_mkwrite(pte_t pte)
220{
221 pte.pte_low |= _PAGE_WRITE;
222 if (pte.pte_low & _PAGE_MODIFIED) {
223 pte.pte_low |= _PAGE_SILENT_WRITE;
224 pte.pte_high |= _PAGE_SILENT_WRITE;
225 }
226 return pte;
227}
228
229static inline pte_t pte_mkdirty(pte_t pte)
230{
231 pte.pte_low |= _PAGE_MODIFIED;
232 if (pte.pte_low & _PAGE_WRITE) {
233 pte.pte_low |= _PAGE_SILENT_WRITE;
234 pte.pte_high |= _PAGE_SILENT_WRITE;
235 }
236 return pte;
237}
238
239static inline pte_t pte_mkyoung(pte_t pte)
240{
241 pte.pte_low |= _PAGE_ACCESSED;
242 if (pte.pte_low & _PAGE_READ) {
243 pte.pte_low |= _PAGE_SILENT_READ;
244 pte.pte_high |= _PAGE_SILENT_READ;
245 }
246 return pte;
247}
248#else
249static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; }
250static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_MODIFIED; }
251static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
252static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
253
254static inline pte_t pte_wrprotect(pte_t pte)
255{
256 pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
257 return pte;
258}
259
260static inline pte_t pte_mkclean(pte_t pte)
261{
262 pte_val(pte) &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE);
263 return pte;
264}
265
266static inline pte_t pte_mkold(pte_t pte)
267{
268 pte_val(pte) &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ);
269 return pte;
270}
271
272static inline pte_t pte_mkwrite(pte_t pte)
273{
274 pte_val(pte) |= _PAGE_WRITE;
275 if (pte_val(pte) & _PAGE_MODIFIED)
276 pte_val(pte) |= _PAGE_SILENT_WRITE;
277 return pte;
278}
279
280static inline pte_t pte_mkdirty(pte_t pte)
281{
282 pte_val(pte) |= _PAGE_MODIFIED;
283 if (pte_val(pte) & _PAGE_WRITE)
284 pte_val(pte) |= _PAGE_SILENT_WRITE;
285 return pte;
286}
287
288static inline pte_t pte_mkyoung(pte_t pte)
289{
290 pte_val(pte) |= _PAGE_ACCESSED;
291 if (pte_val(pte) & _PAGE_READ)
292 pte_val(pte) |= _PAGE_SILENT_READ;
293 return pte;
294}
295#endif
296static inline int pte_special(pte_t pte) { return 0; }
297static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
298
299/*
300 * Macro to make mark a page protection value as "uncacheable". Note
301 * that "protection" is really a misnomer here as the protection value
302 * contains the memory attribute bits, dirty bits, and various other
303 * bits as well.
304 */
305#define pgprot_noncached pgprot_noncached
306
307static inline pgprot_t pgprot_noncached(pgprot_t _prot)
308{
309 unsigned long prot = pgprot_val(_prot);
310
311 prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED;
312
313 return __pgprot(prot);
314}
315
316/*
317 * Conversion functions: convert a page and protection to a page entry,
318 * and a page entry and page directory to the page they refer to.
319 */
320#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
321
322#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
323static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
324{
325 pte.pte_low &= _PAGE_CHG_MASK;
326 pte.pte_high &= ~0x3f;
327 pte.pte_low |= pgprot_val(newprot);
328 pte.pte_high |= pgprot_val(newprot) & 0x3f;
329 return pte;
330}
331#else
332static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
333{
334 return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
335}
336#endif
337
338
339extern void __update_tlb(struct vm_area_struct *vma, unsigned long address,
340 pte_t pte);
341extern void __update_cache(struct vm_area_struct *vma, unsigned long address,
342 pte_t pte);
343
344static inline void update_mmu_cache(struct vm_area_struct *vma,
345 unsigned long address, pte_t pte)
346{
347 __update_tlb(vma, address, pte);
348 __update_cache(vma, address, pte);
349}
350
351#define kern_addr_valid(addr) (1)
352
353#ifdef CONFIG_64BIT_PHYS_ADDR
354extern int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot);
355
356static inline int io_remap_pfn_range(struct vm_area_struct *vma,
357 unsigned long vaddr,
358 unsigned long pfn,
359 unsigned long size,
360 pgprot_t prot)
361{
362 phys_t phys_addr_high = fixup_bigphys_addr(pfn << PAGE_SHIFT, size);
363 return remap_pfn_range(vma, vaddr, phys_addr_high >> PAGE_SHIFT, size, prot);
364}
365#else
366#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
367 remap_pfn_range(vma, vaddr, pfn, size, prot)
368#endif
369
370#include <asm-generic/pgtable.h>
371
372/*
373 * We provide our own get_unmapped area to cope with the virtual aliasing
374 * constraints placed on us by the cache architecture.
375 */
376#define HAVE_ARCH_UNMAPPED_AREA
377
378/*
379 * No page table caches to initialise
380 */
381#define pgtable_cache_init() do { } while (0)
382
383#endif /* _ASM_PGTABLE_H */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h
new file mode 100644
index 000000000000..ebdbab973e41
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h
@@ -0,0 +1,46 @@
1/*
2 * include/asm-mips/pmc-sierra/msp71xx/gpio.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * @author Patrick Glass <patrickglass@gmail.com>
9 */
10
11#ifndef __PMC_MSP71XX_GPIO_H
12#define __PMC_MSP71XX_GPIO_H
13
14/* Max number of gpio's is 28 on chip plus 3 banks of I2C IO Expanders */
15#define ARCH_NR_GPIOS (28 + (3 * 8))
16
17/* new generic GPIO API - see Documentation/gpio.txt */
18#include <asm-generic/gpio.h>
19
20#define gpio_get_value __gpio_get_value
21#define gpio_set_value __gpio_set_value
22#define gpio_cansleep __gpio_cansleep
23
24/* Setup calls for the gpio and gpio extended */
25extern void msp71xx_init_gpio(void);
26extern void msp71xx_init_gpio_extended(void);
27extern int msp71xx_set_output_drive(unsigned gpio, int value);
28
29/* Custom output drive functionss */
30static inline int gpio_set_output_drive(unsigned gpio, int value)
31{
32 return msp71xx_set_output_drive(gpio, value);
33}
34
35/* IRQ's are not supported for gpio lines */
36static inline int gpio_to_irq(unsigned gpio)
37{
38 return -EINVAL;
39}
40
41static inline int irq_to_gpio(unsigned irq)
42{
43 return -EINVAL;
44}
45
46#endif /* __PMC_MSP71XX_GPIO_H */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_cic_int.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_cic_int.h
new file mode 100644
index 000000000000..c84bcf9570b1
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_cic_int.h
@@ -0,0 +1,151 @@
1/*
2 * Defines for the MSP interrupt controller.
3 *
4 * Copyright (C) 1999 MIPS Technologies, Inc. All rights reserved.
5 * Author: Carsten Langgaard, carstenl@mips.com
6 *
7 * ########################################################################
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 *
22 * ########################################################################
23 */
24
25#ifndef _MSP_CIC_INT_H
26#define _MSP_CIC_INT_H
27
28/*
29 * The PMC-Sierra CIC interrupts are all centrally managed by the
30 * CIC sub-system.
31 * We attempt to keep the interrupt numbers as consistent as possible
32 * across all of the MSP devices, but some differences will creep in ...
33 * The interrupts which are directly forwarded to the MIPS core interrupts
34 * are assigned interrupts in the range 0-7, interrupts cascaded through
35 * the CIC are assigned interrupts 8-39. The cascade occurs on C_IRQ4
36 * (MSP_INT_CIC). Currently we don't really distinguish between VPE1
37 * and VPE0 (or thread contexts for that matter). Will have to fix.
38 * The PER interrupts are assigned interrupts in the range 40-71.
39*/
40
41
42/*
43 * IRQs directly forwarded to the CPU
44 */
45#define MSP_MIPS_INTBASE 0
46#define MSP_INT_SW0 0 /* IRQ for swint0, C_SW0 */
47#define MSP_INT_SW1 1 /* IRQ for swint1, C_SW1 */
48#define MSP_INT_MAC0 2 /* IRQ for MAC 0, C_IRQ0 */
49#define MSP_INT_MAC1 3 /* IRQ for MAC 1, C_IRQ1 */
50#define MSP_INT_USB 4 /* IRQ for USB, C_IRQ2 */
51#define MSP_INT_SAR 5 /* IRQ for ADSL2+ SAR, C_IRQ3 */
52#define MSP_INT_CIC 6 /* IRQ for CIC block, C_IRQ4 */
53#define MSP_INT_SEC 7 /* IRQ for Sec engine, C_IRQ5 */
54
55/*
56 * IRQs cascaded on CPU interrupt 4 (CAUSE bit 12, C_IRQ4)
57 * These defines should be tied to the register definitions for the CIC
58 * interrupt routine. For now, just use hard-coded values.
59 */
60#define MSP_CIC_INTBASE (MSP_MIPS_INTBASE + 8)
61#define MSP_INT_EXT0 (MSP_CIC_INTBASE + 0)
62 /* External interrupt 0 */
63#define MSP_INT_EXT1 (MSP_CIC_INTBASE + 1)
64 /* External interrupt 1 */
65#define MSP_INT_EXT2 (MSP_CIC_INTBASE + 2)
66 /* External interrupt 2 */
67#define MSP_INT_EXT3 (MSP_CIC_INTBASE + 3)
68 /* External interrupt 3 */
69#define MSP_INT_CPUIF (MSP_CIC_INTBASE + 4)
70 /* CPU interface interrupt */
71#define MSP_INT_EXT4 (MSP_CIC_INTBASE + 5)
72 /* External interrupt 4 */
73#define MSP_INT_CIC_USB (MSP_CIC_INTBASE + 6)
74 /* Cascaded IRQ for USB */
75#define MSP_INT_MBOX (MSP_CIC_INTBASE + 7)
76 /* Sec engine mailbox IRQ */
77#define MSP_INT_EXT5 (MSP_CIC_INTBASE + 8)
78 /* External interrupt 5 */
79#define MSP_INT_TDM (MSP_CIC_INTBASE + 9)
80 /* TDM interrupt */
81#define MSP_INT_CIC_MAC0 (MSP_CIC_INTBASE + 10)
82 /* Cascaded IRQ for MAC 0 */
83#define MSP_INT_CIC_MAC1 (MSP_CIC_INTBASE + 11)
84 /* Cascaded IRQ for MAC 1 */
85#define MSP_INT_CIC_SEC (MSP_CIC_INTBASE + 12)
86 /* Cascaded IRQ for sec engine */
87#define MSP_INT_PER (MSP_CIC_INTBASE + 13)
88 /* Peripheral interrupt */
89#define MSP_INT_TIMER0 (MSP_CIC_INTBASE + 14)
90 /* SLP timer 0 */
91#define MSP_INT_TIMER1 (MSP_CIC_INTBASE + 15)
92 /* SLP timer 1 */
93#define MSP_INT_TIMER2 (MSP_CIC_INTBASE + 16)
94 /* SLP timer 2 */
95#define MSP_INT_VPE0_TIMER (MSP_CIC_INTBASE + 17)
96 /* VPE0 MIPS timer */
97#define MSP_INT_BLKCP (MSP_CIC_INTBASE + 18)
98 /* Block Copy */
99#define MSP_INT_UART0 (MSP_CIC_INTBASE + 19)
100 /* UART 0 */
101#define MSP_INT_PCI (MSP_CIC_INTBASE + 20)
102 /* PCI subsystem */
103#define MSP_INT_EXT6 (MSP_CIC_INTBASE + 21)
104 /* External interrupt 5 */
105#define MSP_INT_PCI_MSI (MSP_CIC_INTBASE + 22)
106 /* PCI Message Signal */
107#define MSP_INT_CIC_SAR (MSP_CIC_INTBASE + 23)
108 /* Cascaded ADSL2+ SAR IRQ */
109#define MSP_INT_DSL (MSP_CIC_INTBASE + 24)
110 /* ADSL2+ IRQ */
111#define MSP_INT_CIC_ERR (MSP_CIC_INTBASE + 25)
112 /* SLP error condition */
113#define MSP_INT_VPE1_TIMER (MSP_CIC_INTBASE + 26)
114 /* VPE1 MIPS timer */
115#define MSP_INT_VPE0_PC (MSP_CIC_INTBASE + 27)
116 /* VPE0 Performance counter */
117#define MSP_INT_VPE1_PC (MSP_CIC_INTBASE + 28)
118 /* VPE1 Performance counter */
119#define MSP_INT_EXT7 (MSP_CIC_INTBASE + 29)
120 /* External interrupt 5 */
121#define MSP_INT_VPE0_SW (MSP_CIC_INTBASE + 30)
122 /* VPE0 Software interrupt */
123#define MSP_INT_VPE1_SW (MSP_CIC_INTBASE + 31)
124 /* VPE0 Software interrupt */
125
126/*
127 * IRQs cascaded on CIC PER interrupt (MSP_INT_PER)
128 */
129#define MSP_PER_INTBASE (MSP_CIC_INTBASE + 32)
130/* Reserved 0-1 */
131#define MSP_INT_UART1 (MSP_PER_INTBASE + 2)
132 /* UART 1 */
133/* Reserved 3-5 */
134#define MSP_INT_2WIRE (MSP_PER_INTBASE + 6)
135 /* 2-wire */
136#define MSP_INT_TM0 (MSP_PER_INTBASE + 7)
137 /* Peripheral timer block out 0 */
138#define MSP_INT_TM1 (MSP_PER_INTBASE + 8)
139 /* Peripheral timer block out 1 */
140/* Reserved 9 */
141#define MSP_INT_SPRX (MSP_PER_INTBASE + 10)
142 /* SPI RX complete */
143#define MSP_INT_SPTX (MSP_PER_INTBASE + 11)
144 /* SPI TX complete */
145#define MSP_INT_GPIO (MSP_PER_INTBASE + 12)
146 /* GPIO */
147#define MSP_INT_PER_ERR (MSP_PER_INTBASE + 13)
148 /* Peripheral error */
149/* Reserved 14-31 */
150
151#endif /* !_MSP_CIC_INT_H */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_int.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_int.h
new file mode 100644
index 000000000000..1d9f05474820
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_int.h
@@ -0,0 +1,43 @@
1/*
2 * Defines for the MSP interrupt handlers.
3 *
4 * Copyright (C) 2005, PMC-Sierra, Inc. All rights reserved.
5 * Author: Andrew Hughes, Andrew_Hughes@pmc-sierra.com
6 *
7 * ########################################################################
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 *
22 * ########################################################################
23 */
24
25#ifndef _MSP_INT_H
26#define _MSP_INT_H
27
28/*
29 * The PMC-Sierra MSP product line has at least two different interrupt
30 * controllers, the SLP register based scheme and the CIC interrupt
31 * controller block mechanism. This file distinguishes between them
32 * so that devices see a uniform interface.
33 */
34
35#if defined(CONFIG_IRQ_MSP_SLP)
36 #include "msp_slp_int.h"
37#elif defined(CONFIG_IRQ_MSP_CIC)
38 #include "msp_cic_int.h"
39#else
40 #error "What sort of interrupt controller does *your* MSP have?"
41#endif
42
43#endif /* !_MSP_INT_H */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_pci.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_pci.h
new file mode 100644
index 000000000000..415606903617
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_pci.h
@@ -0,0 +1,205 @@
1/*
2 * Copyright (c) 2000-2006 PMC-Sierra INC.
3 *
4 * This program is free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General
6 * Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be
11 * useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
19 * 02139, USA.
20 *
21 * PMC-SIERRA INC. DISCLAIMS ANY LIABILITY OF ANY KIND
22 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
23 * SOFTWARE.
24 */
25
26#ifndef _MSP_PCI_H_
27#define _MSP_PCI_H_
28
29#define MSP_HAS_PCI(ID) (((u32)(ID) <= 0x4236) && ((u32)(ID) >= 0x4220))
30
31/*
32 * It is convenient to program the OATRAN register so that
33 * Athena virtual address space and PCI address space are
34 * the same. This is not a requirement, just a convenience.
35 *
36 * The only hard restrictions on the value of OATRAN is that
37 * OATRAN must not be programmed to allow translated memory
38 * addresses to fall within the lowest 512MB of
39 * PCI address space. This region is hardcoded
40 * for use as Athena PCI Host Controller target
41 * access memory space to the Athena's SDRAM.
42 *
43 * Note that OATRAN applies only to memory accesses, not
44 * to I/O accesses.
45 *
46 * To program OATRAN to make Athena virtual address space
47 * and PCI address space have the same values, OATRAN
48 * is to be programmed to 0xB8000000. The top seven
49 * bits of the value mimic the seven bits clipped off
50 * by the PCI Host controller.
51 *
52 * With OATRAN at the said value, when the CPU does
53 * an access to its virtual address at, say 0xB900_5000,
54 * the address appearing on the PCI bus will be
55 * 0xB900_5000.
56 * - Michael Penner
57 */
58#define MSP_PCI_OATRAN 0xB8000000UL
59
60#define MSP_PCI_SPACE_BASE (MSP_PCI_OATRAN + 0x1002000UL)
61#define MSP_PCI_SPACE_SIZE (0x3000000UL - 0x2000)
62#define MSP_PCI_SPACE_END \
63 (MSP_PCI_SPACE_BASE + MSP_PCI_SPACE_SIZE - 1)
64#define MSP_PCI_IOSPACE_BASE (MSP_PCI_OATRAN + 0x1001000UL)
65#define MSP_PCI_IOSPACE_SIZE 0x1000
66#define MSP_PCI_IOSPACE_END \
67 (MSP_PCI_IOSPACE_BASE + MSP_PCI_IOSPACE_SIZE - 1)
68
69/* IRQ for PCI status interrupts */
70#define PCI_STAT_IRQ 20
71
72#define QFLUSH_REG_1 0xB7F40000
73
74typedef volatile unsigned int pcireg;
75typedef void * volatile ppcireg;
76
77struct pci_block_copy
78{
79 pcireg unused1; /* +0x00 */
80 pcireg unused2; /* +0x04 */
81 ppcireg unused3; /* +0x08 */
82 ppcireg unused4; /* +0x0C */
83 pcireg unused5; /* +0x10 */
84 pcireg unused6; /* +0x14 */
85 pcireg unused7; /* +0x18 */
86 ppcireg unused8; /* +0x1C */
87 ppcireg unused9; /* +0x20 */
88 pcireg unusedA; /* +0x24 */
89 ppcireg unusedB; /* +0x28 */
90 ppcireg unusedC; /* +0x2C */
91};
92
93enum
94{
95 config_device_vendor, /* 0 */
96 config_status_command, /* 1 */
97 config_class_revision, /* 2 */
98 config_BIST_header_latency_cache, /* 3 */
99 config_BAR0, /* 4 */
100 config_BAR1, /* 5 */
101 config_BAR2, /* 6 */
102 config_not_used7, /* 7 */
103 config_not_used8, /* 8 */
104 config_not_used9, /* 9 */
105 config_CIS, /* 10 */
106 config_subsystem, /* 11 */
107 config_not_used12, /* 12 */
108 config_capabilities, /* 13 */
109 config_not_used14, /* 14 */
110 config_lat_grant_irq, /* 15 */
111 config_message_control,/* 16 */
112 config_message_addr, /* 17 */
113 config_message_data, /* 18 */
114 config_VPD_addr, /* 19 */
115 config_VPD_data, /* 20 */
116 config_maxregs /* 21 - number of registers */
117};
118
119struct msp_pci_regs
120{
121 pcireg hop_unused_00; /* +0x00 */
122 pcireg hop_unused_04; /* +0x04 */
123 pcireg hop_unused_08; /* +0x08 */
124 pcireg hop_unused_0C; /* +0x0C */
125 pcireg hop_unused_10; /* +0x10 */
126 pcireg hop_unused_14; /* +0x14 */
127 pcireg hop_unused_18; /* +0x18 */
128 pcireg hop_unused_1C; /* +0x1C */
129 pcireg hop_unused_20; /* +0x20 */
130 pcireg hop_unused_24; /* +0x24 */
131 pcireg hop_unused_28; /* +0x28 */
132 pcireg hop_unused_2C; /* +0x2C */
133 pcireg hop_unused_30; /* +0x30 */
134 pcireg hop_unused_34; /* +0x34 */
135 pcireg if_control; /* +0x38 */
136 pcireg oatran; /* +0x3C */
137 pcireg reset_ctl; /* +0x40 */
138 pcireg config_addr; /* +0x44 */
139 pcireg hop_unused_48; /* +0x48 */
140 pcireg msg_signaled_int_status; /* +0x4C */
141 pcireg msg_signaled_int_mask; /* +0x50 */
142 pcireg if_status; /* +0x54 */
143 pcireg if_mask; /* +0x58 */
144 pcireg hop_unused_5C; /* +0x5C */
145 pcireg hop_unused_60; /* +0x60 */
146 pcireg hop_unused_64; /* +0x64 */
147 pcireg hop_unused_68; /* +0x68 */
148 pcireg hop_unused_6C; /* +0x6C */
149 pcireg hop_unused_70; /* +0x70 */
150
151 struct pci_block_copy pci_bc[2] __attribute__((aligned(64)));
152
153 pcireg error_hdr1; /* +0xE0 */
154 pcireg error_hdr2; /* +0xE4 */
155
156 pcireg config[config_maxregs] __attribute__((aligned(256)));
157
158};
159
160#define BPCI_CFGADDR_BUSNUM_SHF 16
161#define BPCI_CFGADDR_FUNCTNUM_SHF 8
162#define BPCI_CFGADDR_REGNUM_SHF 2
163#define BPCI_CFGADDR_ENABLE (1<<31)
164
165#define BPCI_IFCONTROL_RTO (1<<20) /* Retry timeout */
166#define BPCI_IFCONTROL_HCE (1<<16) /* Host configuration enable */
167#define BPCI_IFCONTROL_CTO_SHF 12 /* Shift count for CTO bits */
168#define BPCI_IFCONTROL_SE (1<<5) /* Enable exceptions on errors */
169#define BPCI_IFCONTROL_BIST (1<<4) /* Use BIST in per. mode */
170#define BPCI_IFCONTROL_CAP (1<<3) /* Enable capabilities */
171#define BPCI_IFCONTROL_MMC_SHF 0 /* Shift count for MMC bits */
172
173#define BPCI_IFSTATUS_MGT (1<<8) /* Master Grant timeout */
174#define BPCI_IFSTATUS_MTT (1<<9) /* Master TRDY timeout */
175#define BPCI_IFSTATUS_MRT (1<<10) /* Master retry timeout */
176#define BPCI_IFSTATUS_BC0F (1<<13) /* Block copy 0 fault */
177#define BPCI_IFSTATUS_BC1F (1<<14) /* Block copy 1 fault */
178#define BPCI_IFSTATUS_PCIU (1<<15) /* PCI unable to respond */
179#define BPCI_IFSTATUS_BSIZ (1<<16) /* PCI access with illegal size */
180#define BPCI_IFSTATUS_BADD (1<<17) /* PCI access with illegal addr */
181#define BPCI_IFSTATUS_RTO (1<<18) /* Retry time out */
182#define BPCI_IFSTATUS_SER (1<<19) /* System error */
183#define BPCI_IFSTATUS_PER (1<<20) /* Parity error */
184#define BPCI_IFSTATUS_LCA (1<<21) /* Local CPU abort */
185#define BPCI_IFSTATUS_MEM (1<<22) /* Memory prot. violation */
186#define BPCI_IFSTATUS_ARB (1<<23) /* Arbiter timed out */
187#define BPCI_IFSTATUS_STA (1<<27) /* Signaled target abort */
188#define BPCI_IFSTATUS_TA (1<<28) /* Target abort */
189#define BPCI_IFSTATUS_MA (1<<29) /* Master abort */
190#define BPCI_IFSTATUS_PEI (1<<30) /* Parity error as initiator */
191#define BPCI_IFSTATUS_PET (1<<31) /* Parity error as target */
192
193#define BPCI_RESETCTL_PR (1<<0) /* True if reset asserted */
194#define BPCI_RESETCTL_RT (1<<4) /* Release time */
195#define BPCI_RESETCTL_CT (1<<8) /* Config time */
196#define BPCI_RESETCTL_PE (1<<12) /* PCI enabled */
197#define BPCI_RESETCTL_HM (1<<13) /* PCI host mode */
198#define BPCI_RESETCTL_RI (1<<14) /* PCI reset in */
199
200extern struct msp_pci_regs msp_pci_regs
201 __attribute__((section(".register")));
202extern unsigned long msp_pci_config_space
203 __attribute__((section(".register")));
204
205#endif /* !_MSP_PCI_H_ */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_prom.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_prom.h
new file mode 100644
index 000000000000..14ca7dc382a8
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_prom.h
@@ -0,0 +1,176 @@
1/*
2 * MIPS boards bootprom interface for the Linux kernel.
3 *
4 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
5 * Author: Carsten Langgaard, carstenl@mips.com
6 *
7 * ########################################################################
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 *
22 * ########################################################################
23 */
24
25#ifndef _ASM_MSP_PROM_H
26#define _ASM_MSP_PROM_H
27
28#include <linux/types.h>
29
30#define DEVICEID "deviceid"
31#define FEATURES "features"
32#define PROM_ENV "prom_env"
33#define PROM_ENV_FILE "/proc/"PROM_ENV
34#define PROM_ENV_SIZE 256
35
36#define CPU_DEVID_FAMILY 0x0000ff00
37#define CPU_DEVID_REVISION 0x000000ff
38
39#define FPGA_IS_POLO(revision) \
40 (((revision >= 0xb0) && (revision < 0xd0)))
41#define FPGA_IS_5000(revision) \
42 ((revision >= 0x80) && (revision <= 0x90))
43#define FPGA_IS_ZEUS(revision) ((revision < 0x7f))
44#define FPGA_IS_DUET(revision) \
45 (((revision >= 0xa0) && (revision < 0xb0)))
46#define FPGA_IS_MSP4200(revision) ((revision >= 0xd0))
47#define FPGA_IS_MSP7100(revision) ((revision >= 0xd0))
48
49#define MACHINE_TYPE_POLO "POLO"
50#define MACHINE_TYPE_DUET "DUET"
51#define MACHINE_TYPE_ZEUS "ZEUS"
52#define MACHINE_TYPE_MSP2000REVB "MSP2000REVB"
53#define MACHINE_TYPE_MSP5000 "MSP5000"
54#define MACHINE_TYPE_MSP4200 "MSP4200"
55#define MACHINE_TYPE_MSP7120 "MSP7120"
56#define MACHINE_TYPE_MSP7130 "MSP7130"
57#define MACHINE_TYPE_OTHER "OTHER"
58
59#define MACHINE_TYPE_POLO_FPGA "POLO-FPGA"
60#define MACHINE_TYPE_DUET_FPGA "DUET-FPGA"
61#define MACHINE_TYPE_ZEUS_FPGA "ZEUS_FPGA"
62#define MACHINE_TYPE_MSP2000REVB_FPGA "MSP2000REVB-FPGA"
63#define MACHINE_TYPE_MSP5000_FPGA "MSP5000-FPGA"
64#define MACHINE_TYPE_MSP4200_FPGA "MSP4200-FPGA"
65#define MACHINE_TYPE_MSP7100_FPGA "MSP7100-FPGA"
66#define MACHINE_TYPE_OTHER_FPGA "OTHER-FPGA"
67
68/* Device Family definitions */
69#define FAMILY_FPGA 0x0000
70#define FAMILY_ZEUS 0x1000
71#define FAMILY_POLO 0x2000
72#define FAMILY_DUET 0x4000
73#define FAMILY_TRIAD 0x5000
74#define FAMILY_MSP4200 0x4200
75#define FAMILY_MSP4200_FPGA 0x4f00
76#define FAMILY_MSP7100 0x7100
77#define FAMILY_MSP7100_FPGA 0x7f00
78
79/* Device Type definitions */
80#define TYPE_MSP7120 0x7120
81#define TYPE_MSP7130 0x7130
82
83#define ENET_KEY 'E'
84#define ENETTXD_KEY 'e'
85#define PCI_KEY 'P'
86#define PCIMUX_KEY 'p'
87#define SEC_KEY 'S'
88#define SPAD_KEY 'D'
89#define TDM_KEY 'T'
90#define ZSP_KEY 'Z'
91
92#define FEATURE_NOEXIST '-'
93#define FEATURE_EXIST '+'
94
95#define ENET_MII 'M'
96#define ENET_RMII 'R'
97
98#define ENETTXD_FALLING 'F'
99#define ENETTXD_RISING 'R'
100
101#define PCI_HOST 'H'
102#define PCI_PERIPHERAL 'P'
103
104#define PCIMUX_FULL 'F'
105#define PCIMUX_SINGLE 'S'
106
107#define SEC_DUET 'D'
108#define SEC_POLO 'P'
109#define SEC_SLOW 'S'
110#define SEC_TRIAD 'T'
111
112#define SPAD_POLO 'P'
113
114#define TDM_DUET 'D' /* DUET TDMs might exist */
115#define TDM_POLO 'P' /* POLO TDMs might exist */
116#define TDM_TRIAD 'T' /* TRIAD TDMs might exist */
117
118#define ZSP_DUET 'D' /* one DUET zsp engine */
119#define ZSP_TRIAD 'T' /* two TRIAD zsp engines */
120
121extern char *prom_getcmdline(void);
122extern char *prom_getenv(char *name);
123extern void prom_init_cmdline(void);
124extern void prom_meminit(void);
125extern void prom_fixup_mem_map(unsigned long start_mem,
126 unsigned long end_mem);
127
128#ifdef CONFIG_MTD_PMC_MSP_RAMROOT
129extern bool get_ramroot(void **start, unsigned long *size);
130#endif
131
132extern int get_ethernet_addr(char *ethaddr_name, char *ethernet_addr);
133extern unsigned long get_deviceid(void);
134extern char identify_enet(unsigned long interface_num);
135extern char identify_enetTxD(unsigned long interface_num);
136extern char identify_pci(void);
137extern char identify_sec(void);
138extern char identify_spad(void);
139extern char identify_sec(void);
140extern char identify_tdm(void);
141extern char identify_zsp(void);
142extern unsigned long identify_family(void);
143extern unsigned long identify_revision(void);
144
145/*
146 * The following macro calls prom_printf and puts the format string
147 * into an init section so it can be reclaimed.
148 */
149#define ppfinit(f, x...) \
150 do { \
151 static char _f[] __initdata = KERN_INFO f; \
152 printk(_f, ## x); \
153 } while (0)
154
155/* Memory descriptor management. */
156#define PROM_MAX_PMEMBLOCKS 7 /* 6 used */
157
158enum yamon_memtypes {
159 yamon_dontuse,
160 yamon_prom,
161 yamon_free,
162};
163
164struct prom_pmemblock {
165 unsigned long base; /* Within KSEG0. */
166 unsigned int size; /* In bytes. */
167 unsigned int type; /* free or prom memory */
168};
169
170extern int prom_argc;
171extern char **prom_argv;
172extern char **prom_envp;
173extern int *prom_vec;
174extern struct prom_pmemblock *prom_getmdesc(void);
175
176#endif /* !_ASM_MSP_PROM_H */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regops.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regops.h
new file mode 100644
index 000000000000..60a5a38dd5b2
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regops.h
@@ -0,0 +1,236 @@
1/*
2 * SMP/VPE-safe functions to access "registers" (see note).
3 *
4 * NOTES:
5* - These macros use ll/sc instructions, so it is your responsibility to
6 * ensure these are available on your platform before including this file.
7 * - The MIPS32 spec states that ll/sc results are undefined for uncached
8 * accesses. This means they can't be used on HW registers accessed
9 * through kseg1. Code which requires these macros for this purpose must
10 * front-end the registers with cached memory "registers" and have a single
11 * thread update the actual HW registers.
12 * - A maximum of 2k of code can be inserted between ll and sc. Every
13 * memory accesses between the instructions will increase the chance of
14 * sc failing and having to loop.
15 * - When using custom_read_reg32/custom_write_reg32 only perform the
16 * necessary logical operations on the register value in between these
17 * two calls. All other logic should be performed before the first call.
18 * - There is a bug on the R10000 chips which has a workaround. If you
19 * are affected by this bug, make sure to define the symbol 'R10000_LLSC_WAR'
20 * to be non-zero. If you are using this header from within linux, you may
21 * include <asm/war.h> before including this file to have this defined
22 * appropriately for you.
23 *
24 * Copyright 2005-2007 PMC-Sierra, Inc.
25 *
26 * This program is free software; you can redistribute it and/or modify it
27 * under the terms of the GNU General Public License as published by the
28 * Free Software Foundation; either version 2 of the License, or (at your
29 * option) any later version.
30 *
31 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
32 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
34 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * You should have received a copy of the GNU General Public License along
43 * with this program; if not, write to the Free Software Foundation, Inc., 675
44 * Mass Ave, Cambridge, MA 02139, USA.
45 */
46
47#ifndef __ASM_REGOPS_H__
48#define __ASM_REGOPS_H__
49
50#include <linux/types.h>
51
52#include <asm/war.h>
53
54#ifndef R10000_LLSC_WAR
55#define R10000_LLSC_WAR 0
56#endif
57
58#if R10000_LLSC_WAR == 1
59#define __beqz "beqzl "
60#else
61#define __beqz "beqz "
62#endif
63
64#ifndef _LINUX_TYPES_H
65typedef unsigned int u32;
66#endif
67
68/*
69 * Sets all the masked bits to the corresponding value bits
70 */
71static inline void set_value_reg32(volatile u32 *const addr,
72 u32 const mask,
73 u32 const value)
74{
75 u32 temp;
76
77 __asm__ __volatile__(
78 " .set push \n"
79 " .set mips3 \n"
80 "1: ll %0, %1 # set_value_reg32 \n"
81 " and %0, %2 \n"
82 " or %0, %3 \n"
83 " sc %0, %1 \n"
84 " "__beqz"%0, 1b \n"
85 " nop \n"
86 " .set pop \n"
87 : "=&r" (temp), "=m" (*addr)
88 : "ir" (~mask), "ir" (value), "m" (*addr));
89}
90
91/*
92 * Sets all the masked bits to '1'
93 */
94static inline void set_reg32(volatile u32 *const addr,
95 u32 const mask)
96{
97 u32 temp;
98
99 __asm__ __volatile__(
100 " .set push \n"
101 " .set mips3 \n"
102 "1: ll %0, %1 # set_reg32 \n"
103 " or %0, %2 \n"
104 " sc %0, %1 \n"
105 " "__beqz"%0, 1b \n"
106 " nop \n"
107 " .set pop \n"
108 : "=&r" (temp), "=m" (*addr)
109 : "ir" (mask), "m" (*addr));
110}
111
112/*
113 * Sets all the masked bits to '0'
114 */
115static inline void clear_reg32(volatile u32 *const addr,
116 u32 const mask)
117{
118 u32 temp;
119
120 __asm__ __volatile__(
121 " .set push \n"
122 " .set mips3 \n"
123 "1: ll %0, %1 # clear_reg32 \n"
124 " and %0, %2 \n"
125 " sc %0, %1 \n"
126 " "__beqz"%0, 1b \n"
127 " nop \n"
128 " .set pop \n"
129 : "=&r" (temp), "=m" (*addr)
130 : "ir" (~mask), "m" (*addr));
131}
132
133/*
134 * Toggles all masked bits from '0' to '1' and '1' to '0'
135 */
136static inline void toggle_reg32(volatile u32 *const addr,
137 u32 const mask)
138{
139 u32 temp;
140
141 __asm__ __volatile__(
142 " .set push \n"
143 " .set mips3 \n"
144 "1: ll %0, %1 # toggle_reg32 \n"
145 " xor %0, %2 \n"
146 " sc %0, %1 \n"
147 " "__beqz"%0, 1b \n"
148 " nop \n"
149 " .set pop \n"
150 : "=&r" (temp), "=m" (*addr)
151 : "ir" (mask), "m" (*addr));
152}
153
154/*
155 * Read all masked bits others are returned as '0'
156 */
157static inline u32 read_reg32(volatile u32 *const addr,
158 u32 const mask)
159{
160 u32 temp;
161
162 __asm__ __volatile__(
163 " .set push \n"
164 " .set noreorder \n"
165 " lw %0, %1 # read \n"
166 " and %0, %2 # mask \n"
167 " .set pop \n"
168 : "=&r" (temp)
169 : "m" (*addr), "ir" (mask));
170
171 return temp;
172}
173
174/*
175 * blocking_read_reg32 - Read address with blocking load
176 *
177 * Uncached writes need to be read back to ensure they reach RAM.
178 * The returned value must be 'used' to prevent from becoming a
179 * non-blocking load.
180 */
181static inline u32 blocking_read_reg32(volatile u32 *const addr)
182{
183 u32 temp;
184
185 __asm__ __volatile__(
186 " .set push \n"
187 " .set noreorder \n"
188 " lw %0, %1 # read \n"
189 " move %0, %0 # block \n"
190 " .set pop \n"
191 : "=&r" (temp)
192 : "m" (*addr));
193
194 return temp;
195}
196
197/*
198 * For special strange cases only:
199 *
200 * If you need custom processing within a ll/sc loop, use the following macros
201 * VERY CAREFULLY:
202 *
203 * u32 tmp; <-- Define a variable to hold the data
204 *
205 * custom_read_reg32(address, tmp); <-- Reads the address and put the value
206 * in the 'tmp' variable given
207 *
208 * From here on out, you are (basicly) atomic, so don't do anything too
209 * fancy!
210 * Also, this code may loop if the end of this block fails to write
211 * everything back safely due do the other CPU, so do NOT do anything
212 * with side-effects!
213 *
214 * custom_write_reg32(address, tmp); <-- Writes back 'tmp' safely.
215 */
216#define custom_read_reg32(address, tmp) \
217 __asm__ __volatile__( \
218 " .set push \n" \
219 " .set mips3 \n" \
220 "1: ll %0, %1 #custom_read_reg32 \n" \
221 " .set pop \n" \
222 : "=r" (tmp), "=m" (*address) \
223 : "m" (*address))
224
225#define custom_write_reg32(address, tmp) \
226 __asm__ __volatile__( \
227 " .set push \n" \
228 " .set mips3 \n" \
229 " sc %0, %1 #custom_write_reg32 \n" \
230 " "__beqz"%0, 1b \n" \
231 " nop \n" \
232 " .set pop \n" \
233 : "=&r" (tmp), "=m" (*address) \
234 : "0" (tmp), "m" (*address))
235
236#endif /* __ASM_REGOPS_H__ */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h
new file mode 100644
index 000000000000..603eb737b4a8
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_regs.h
@@ -0,0 +1,663 @@
1/*
2 * Defines for the address space, registers and register configuration
3 * (bit masks, access macros etc) for the PMC-Sierra line of MSP products.
4 * This file contains addess maps for all the devices in the line of
5 * products but only has register definitions and configuration masks for
6 * registers which aren't definitely associated with any device. Things
7 * like clock settings, reset access, the ELB etc. Individual device
8 * drivers will reference the appropriate XXX_BASE value defined here
9 * and have individual registers offset from that.
10 *
11 * Copyright (C) 2005-2007 PMC-Sierra, Inc. All rights reserved.
12 * Author: Andrew Hughes, Andrew_Hughes@pmc-sierra.com
13 *
14 * ########################################################################
15 *
16 * This program is free software; you can distribute it and/or modify it
17 * under the terms of the GNU General Public License (Version 2) as
18 * published by the Free Software Foundation.
19 *
20 * This program is distributed in the hope it will be useful, but WITHOUT
21 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * for more details.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
28 *
29 * ########################################################################
30 */
31
32#include <asm/addrspace.h>
33#include <linux/types.h>
34
35#ifndef _ASM_MSP_REGS_H
36#define _ASM_MSP_REGS_H
37
38/*
39 ########################################################################
40 # Address space and device base definitions #
41 ########################################################################
42 */
43
44/*
45 ***************************************************************************
46 * System Logic and Peripherals (ELB, UART0, etc) device address space *
47 ***************************************************************************
48 */
49#define MSP_SLP_BASE 0x1c000000
50 /* System Logic and Peripherals */
51#define MSP_RST_BASE (MSP_SLP_BASE + 0x10)
52 /* System reset register base */
53#define MSP_RST_SIZE 0x0C /* System reset register space */
54
55#define MSP_WTIMER_BASE (MSP_SLP_BASE + 0x04C)
56 /* watchdog timer base */
57#define MSP_ITIMER_BASE (MSP_SLP_BASE + 0x054)
58 /* internal timer base */
59#define MSP_UART0_BASE (MSP_SLP_BASE + 0x100)
60 /* UART0 controller base */
61#define MSP_BCPY_CTRL_BASE (MSP_SLP_BASE + 0x120)
62 /* Block Copy controller base */
63#define MSP_BCPY_DESC_BASE (MSP_SLP_BASE + 0x160)
64 /* Block Copy descriptor base */
65
66/*
67 ***************************************************************************
68 * PCI address space *
69 ***************************************************************************
70 */
71#define MSP_PCI_BASE 0x19000000
72
73/*
74 ***************************************************************************
75 * MSbus device address space *
76 ***************************************************************************
77 */
78#define MSP_MSB_BASE 0x18000000
79 /* MSbus address start */
80#define MSP_PER_BASE (MSP_MSB_BASE + 0x400000)
81 /* Peripheral device registers */
82#define MSP_MAC0_BASE (MSP_MSB_BASE + 0x600000)
83 /* MAC A device registers */
84#define MSP_MAC1_BASE (MSP_MSB_BASE + 0x700000)
85 /* MAC B device registers */
86#define MSP_MAC_SIZE 0xE0 /* MAC register space */
87
88#define MSP_SEC_BASE (MSP_MSB_BASE + 0x800000)
89 /* Security Engine registers */
90#define MSP_MAC2_BASE (MSP_MSB_BASE + 0x900000)
91 /* MAC C device registers */
92#define MSP_ADSL2_BASE (MSP_MSB_BASE + 0xA80000)
93 /* ADSL2 device registers */
94#define MSP_USB_BASE (MSP_MSB_BASE + 0xB40000)
95 /* USB device registers */
96#define MSP_USB_BASE_START (MSP_MSB_BASE + 0xB40100)
97 /* USB device registers */
98#define MSP_USB_BASE_END (MSP_MSB_BASE + 0xB401FF)
99 /* USB device registers */
100#define MSP_CPUIF_BASE (MSP_MSB_BASE + 0xC00000)
101 /* CPU interface registers */
102
103/* Devices within the MSbus peripheral block */
104#define MSP_UART1_BASE (MSP_PER_BASE + 0x030)
105 /* UART1 controller base */
106#define MSP_SPI_BASE (MSP_PER_BASE + 0x058)
107 /* SPI/MPI control registers */
108#define MSP_TWI_BASE (MSP_PER_BASE + 0x090)
109 /* Two-wire control registers */
110#define MSP_PTIMER_BASE (MSP_PER_BASE + 0x0F0)
111 /* Programmable timer control */
112
113/*
114 ***************************************************************************
115 * Physical Memory configuration address space *
116 ***************************************************************************
117 */
118#define MSP_MEM_CFG_BASE 0x17f00000
119
120#define MSP_MEM_INDIRECT_CTL_10 0x10
121
122/*
123 * Notes:
124 * 1) The SPI registers are split into two blocks, one offset from the
125 * MSP_SPI_BASE by 0x00 and the other offset from the MSP_SPI_BASE by
126 * 0x68. The SPI driver definitions for the register must be aware
127 * of this.
128 * 2) The block copy engine register are divided into two regions, one
129 * for the control/configuration of the engine proper and one for the
130 * values of the descriptors used in the copy process. These have
131 * different base defines (CTRL_BASE vs DESC_BASE)
132 * 3) These constants are for physical addresses which means that they
133 * work correctly with "ioremap" and friends. This means that device
134 * drivers will need to remap these addresses using ioremap and perhaps
135 * the readw/writew macros. Or they could use the regptr() macro
136 * defined below, but the readw/writew calls are the correct thing.
137 * 4) The UARTs have an additional status register offset from the base
138 * address. This register isn't used in the standard 8250 driver but
139 * may be used in other software. Consult the hardware datasheet for
140 * offset details.
141 * 5) For some unknown reason the security engine (MSP_SEC_BASE) registers
142 * start at an offset of 0x84 from the base address but the block of
143 * registers before this is reserved for the security engine. The
144 * driver will have to be aware of this but it makes the register
145 * definitions line up better with the documentation.
146 */
147
148/*
149 ########################################################################
150 # System register definitions. Not associated with a specific device #
151 ########################################################################
152 */
153
154/*
155 * This macro maps the physical register number into uncached space
156 * and (for C code) casts it into a u32 pointer so it can be dereferenced
157 * Normally these would be accessed with ioremap and readX/writeX, but
158 * these are convenient for a lot of internal kernel code.
159 */
160#ifdef __ASSEMBLER__
161 #define regptr(addr) (KSEG1ADDR(addr))
162#else
163 #define regptr(addr) ((volatile u32 *const)(KSEG1ADDR(addr)))
164#endif
165
166/*
167 ***************************************************************************
168 * System Logic and Peripherals (RESET, ELB, etc) registers *
169 ***************************************************************************
170 */
171
172/* System Control register definitions */
173#define DEV_ID_REG regptr(MSP_SLP_BASE + 0x00)
174 /* Device-ID RO */
175#define FWR_ID_REG regptr(MSP_SLP_BASE + 0x04)
176 /* Firmware-ID Register RW */
177#define SYS_ID_REG0 regptr(MSP_SLP_BASE + 0x08)
178 /* System-ID Register-0 RW */
179#define SYS_ID_REG1 regptr(MSP_SLP_BASE + 0x0C)
180 /* System-ID Register-1 RW */
181
182/* System Reset register definitions */
183#define RST_STS_REG regptr(MSP_SLP_BASE + 0x10)
184 /* System Reset Status RO */
185#define RST_SET_REG regptr(MSP_SLP_BASE + 0x14)
186 /* System Set Reset WO */
187#define RST_CLR_REG regptr(MSP_SLP_BASE + 0x18)
188 /* System Clear Reset WO */
189
190/* System Clock Registers */
191#define PCI_SLP_REG regptr(MSP_SLP_BASE + 0x1C)
192 /* PCI clock generator RW */
193#define URT_SLP_REG regptr(MSP_SLP_BASE + 0x20)
194 /* UART clock generator RW */
195/* reserved (MSP_SLP_BASE + 0x24) */
196/* reserved (MSP_SLP_BASE + 0x28) */
197#define PLL1_SLP_REG regptr(MSP_SLP_BASE + 0x2C)
198 /* PLL1 clock generator RW */
199#define PLL0_SLP_REG regptr(MSP_SLP_BASE + 0x30)
200 /* PLL0 clock generator RW */
201#define MIPS_SLP_REG regptr(MSP_SLP_BASE + 0x34)
202 /* MIPS clock generator RW */
203#define VE_SLP_REG regptr(MSP_SLP_BASE + 0x38)
204 /* Voice Eng clock generator RW */
205/* reserved (MSP_SLP_BASE + 0x3C) */
206#define MSB_SLP_REG regptr(MSP_SLP_BASE + 0x40)
207 /* MS-Bus clock generator RW */
208#define SMAC_SLP_REG regptr(MSP_SLP_BASE + 0x44)
209 /* Sec & MAC clock generator RW */
210#define PERF_SLP_REG regptr(MSP_SLP_BASE + 0x48)
211 /* Per & TDM clock generator RW */
212
213/* Interrupt Controller Registers */
214#define SLP_INT_STS_REG regptr(MSP_SLP_BASE + 0x70)
215 /* Interrupt status register RW */
216#define SLP_INT_MSK_REG regptr(MSP_SLP_BASE + 0x74)
217 /* Interrupt enable/mask RW */
218#define SE_MBOX_REG regptr(MSP_SLP_BASE + 0x78)
219 /* Security Engine mailbox RW */
220#define VE_MBOX_REG regptr(MSP_SLP_BASE + 0x7C)
221 /* Voice Engine mailbox RW */
222
223/* ELB Controller Registers */
224#define CS0_CNFG_REG regptr(MSP_SLP_BASE + 0x80)
225 /* ELB CS0 Configuration Reg */
226#define CS0_ADDR_REG regptr(MSP_SLP_BASE + 0x84)
227 /* ELB CS0 Base Address Reg */
228#define CS0_MASK_REG regptr(MSP_SLP_BASE + 0x88)
229 /* ELB CS0 Mask Register */
230#define CS0_ACCESS_REG regptr(MSP_SLP_BASE + 0x8C)
231 /* ELB CS0 access register */
232
233#define CS1_CNFG_REG regptr(MSP_SLP_BASE + 0x90)
234 /* ELB CS1 Configuration Reg */
235#define CS1_ADDR_REG regptr(MSP_SLP_BASE + 0x94)
236 /* ELB CS1 Base Address Reg */
237#define CS1_MASK_REG regptr(MSP_SLP_BASE + 0x98)
238 /* ELB CS1 Mask Register */
239#define CS1_ACCESS_REG regptr(MSP_SLP_BASE + 0x9C)
240 /* ELB CS1 access register */
241
242#define CS2_CNFG_REG regptr(MSP_SLP_BASE + 0xA0)
243 /* ELB CS2 Configuration Reg */
244#define CS2_ADDR_REG regptr(MSP_SLP_BASE + 0xA4)
245 /* ELB CS2 Base Address Reg */
246#define CS2_MASK_REG regptr(MSP_SLP_BASE + 0xA8)
247 /* ELB CS2 Mask Register */
248#define CS2_ACCESS_REG regptr(MSP_SLP_BASE + 0xAC)
249 /* ELB CS2 access register */
250
251#define CS3_CNFG_REG regptr(MSP_SLP_BASE + 0xB0)
252 /* ELB CS3 Configuration Reg */
253#define CS3_ADDR_REG regptr(MSP_SLP_BASE + 0xB4)
254 /* ELB CS3 Base Address Reg */
255#define CS3_MASK_REG regptr(MSP_SLP_BASE + 0xB8)
256 /* ELB CS3 Mask Register */
257#define CS3_ACCESS_REG regptr(MSP_SLP_BASE + 0xBC)
258 /* ELB CS3 access register */
259
260#define CS4_CNFG_REG regptr(MSP_SLP_BASE + 0xC0)
261 /* ELB CS4 Configuration Reg */
262#define CS4_ADDR_REG regptr(MSP_SLP_BASE + 0xC4)
263 /* ELB CS4 Base Address Reg */
264#define CS4_MASK_REG regptr(MSP_SLP_BASE + 0xC8)
265 /* ELB CS4 Mask Register */
266#define CS4_ACCESS_REG regptr(MSP_SLP_BASE + 0xCC)
267 /* ELB CS4 access register */
268
269#define CS5_CNFG_REG regptr(MSP_SLP_BASE + 0xD0)
270 /* ELB CS5 Configuration Reg */
271#define CS5_ADDR_REG regptr(MSP_SLP_BASE + 0xD4)
272 /* ELB CS5 Base Address Reg */
273#define CS5_MASK_REG regptr(MSP_SLP_BASE + 0xD8)
274 /* ELB CS5 Mask Register */
275#define CS5_ACCESS_REG regptr(MSP_SLP_BASE + 0xDC)
276 /* ELB CS5 access register */
277
278/* reserved 0xE0 - 0xE8 */
279#define ELB_1PC_EN_REG regptr(MSP_SLP_BASE + 0xEC)
280 /* ELB single PC card detect */
281
282/* reserved 0xF0 - 0xF8 */
283#define ELB_CLK_CFG_REG regptr(MSP_SLP_BASE + 0xFC)
284 /* SDRAM read/ELB timing Reg */
285
286/* Extended UART status registers */
287#define UART0_STATUS_REG regptr(MSP_UART0_BASE + 0x0c0)
288 /* UART Status Register 0 */
289#define UART1_STATUS_REG regptr(MSP_UART1_BASE + 0x170)
290 /* UART Status Register 1 */
291
292/* Performance monitoring registers */
293#define PERF_MON_CTRL_REG regptr(MSP_SLP_BASE + 0x140)
294 /* Performance monitor control */
295#define PERF_MON_CLR_REG regptr(MSP_SLP_BASE + 0x144)
296 /* Performance monitor clear */
297#define PERF_MON_CNTH_REG regptr(MSP_SLP_BASE + 0x148)
298 /* Perf monitor counter high */
299#define PERF_MON_CNTL_REG regptr(MSP_SLP_BASE + 0x14C)
300 /* Perf monitor counter low */
301
302/* System control registers */
303#define SYS_CTRL_REG regptr(MSP_SLP_BASE + 0x150)
304 /* System control register */
305#define SYS_ERR1_REG regptr(MSP_SLP_BASE + 0x154)
306 /* System Error status 1 */
307#define SYS_ERR2_REG regptr(MSP_SLP_BASE + 0x158)
308 /* System Error status 2 */
309#define SYS_INT_CFG_REG regptr(MSP_SLP_BASE + 0x15C)
310 /* System Interrupt config */
311
312/* Voice Engine Memory configuration */
313#define VE_MEM_REG regptr(MSP_SLP_BASE + 0x17C)
314 /* Voice engine memory config */
315
316/* CPU/SLP Error Status registers */
317#define CPU_ERR1_REG regptr(MSP_SLP_BASE + 0x180)
318 /* CPU/SLP Error status 1 */
319#define CPU_ERR2_REG regptr(MSP_SLP_BASE + 0x184)
320 /* CPU/SLP Error status 1 */
321
322#define EXTENDED_GPIO_REG regptr(MSP_SLP_BASE + 0x188)
323 /* Extended GPIO register */
324
325/* System Error registers */
326#define SLP_ERR_STS_REG regptr(MSP_SLP_BASE + 0x190)
327 /* Int status for SLP errors */
328#define SLP_ERR_MSK_REG regptr(MSP_SLP_BASE + 0x194)
329 /* Int mask for SLP errors */
330#define SLP_ELB_ERST_REG regptr(MSP_SLP_BASE + 0x198)
331 /* External ELB reset */
332#define SLP_BOOT_STS_REG regptr(MSP_SLP_BASE + 0x19C)
333 /* Boot Status */
334
335/* Extended ELB addressing */
336#define CS0_EXT_ADDR_REG regptr(MSP_SLP_BASE + 0x1A0)
337 /* CS0 Extended address */
338#define CS1_EXT_ADDR_REG regptr(MSP_SLP_BASE + 0x1A4)
339 /* CS1 Extended address */
340#define CS2_EXT_ADDR_REG regptr(MSP_SLP_BASE + 0x1A8)
341 /* CS2 Extended address */
342#define CS3_EXT_ADDR_REG regptr(MSP_SLP_BASE + 0x1AC)
343 /* CS3 Extended address */
344/* reserved 0x1B0 */
345#define CS5_EXT_ADDR_REG regptr(MSP_SLP_BASE + 0x1B4)
346 /* CS5 Extended address */
347
348/* PLL Adjustment registers */
349#define PLL_LOCK_REG regptr(MSP_SLP_BASE + 0x200)
350 /* PLL0 lock status */
351#define PLL_ARST_REG regptr(MSP_SLP_BASE + 0x204)
352 /* PLL Analog reset status */
353#define PLL0_ADJ_REG regptr(MSP_SLP_BASE + 0x208)
354 /* PLL0 Adjustment value */
355#define PLL1_ADJ_REG regptr(MSP_SLP_BASE + 0x20C)
356 /* PLL1 Adjustment value */
357
358/*
359 ***************************************************************************
360 * Peripheral Register definitions *
361 ***************************************************************************
362 */
363
364/* Peripheral status */
365#define PER_CTRL_REG regptr(MSP_PER_BASE + 0x50)
366 /* Peripheral control register */
367#define PER_STS_REG regptr(MSP_PER_BASE + 0x54)
368 /* Peripheral status register */
369
370/* SPI/MPI Registers */
371#define SMPI_TX_SZ_REG regptr(MSP_PER_BASE + 0x58)
372 /* SPI/MPI Tx Size register */
373#define SMPI_RX_SZ_REG regptr(MSP_PER_BASE + 0x5C)
374 /* SPI/MPI Rx Size register */
375#define SMPI_CTL_REG regptr(MSP_PER_BASE + 0x60)
376 /* SPI/MPI Control register */
377#define SMPI_MS_REG regptr(MSP_PER_BASE + 0x64)
378 /* SPI/MPI Chip Select reg */
379#define SMPI_CORE_DATA_REG regptr(MSP_PER_BASE + 0xC0)
380 /* SPI/MPI Core Data reg */
381#define SMPI_CORE_CTRL_REG regptr(MSP_PER_BASE + 0xC4)
382 /* SPI/MPI Core Control reg */
383#define SMPI_CORE_STAT_REG regptr(MSP_PER_BASE + 0xC8)
384 /* SPI/MPI Core Status reg */
385#define SMPI_CORE_SSEL_REG regptr(MSP_PER_BASE + 0xCC)
386 /* SPI/MPI Core Ssel reg */
387#define SMPI_FIFO_REG regptr(MSP_PER_BASE + 0xD0)
388 /* SPI/MPI Data FIFO reg */
389
390/* Peripheral Block Error Registers */
391#define PER_ERR_STS_REG regptr(MSP_PER_BASE + 0x70)
392 /* Error Bit Status Register */
393#define PER_ERR_MSK_REG regptr(MSP_PER_BASE + 0x74)
394 /* Error Bit Mask Register */
395#define PER_HDR1_REG regptr(MSP_PER_BASE + 0x78)
396 /* Error Header 1 Register */
397#define PER_HDR2_REG regptr(MSP_PER_BASE + 0x7C)
398 /* Error Header 2 Register */
399
400/* Peripheral Block Interrupt Registers */
401#define PER_INT_STS_REG regptr(MSP_PER_BASE + 0x80)
402 /* Interrupt status register */
403#define PER_INT_MSK_REG regptr(MSP_PER_BASE + 0x84)
404 /* Interrupt Mask Register */
405#define GPIO_INT_STS_REG regptr(MSP_PER_BASE + 0x88)
406 /* GPIO interrupt status reg */
407#define GPIO_INT_MSK_REG regptr(MSP_PER_BASE + 0x8C)
408 /* GPIO interrupt MASK Reg */
409
410/* POLO GPIO registers */
411#define POLO_GPIO_DAT1_REG regptr(MSP_PER_BASE + 0x0E0)
412 /* Polo GPIO[8:0] data reg */
413#define POLO_GPIO_CFG1_REG regptr(MSP_PER_BASE + 0x0E4)
414 /* Polo GPIO[7:0] config reg */
415#define POLO_GPIO_CFG2_REG regptr(MSP_PER_BASE + 0x0E8)
416 /* Polo GPIO[15:8] config reg */
417#define POLO_GPIO_OD1_REG regptr(MSP_PER_BASE + 0x0EC)
418 /* Polo GPIO[31:0] output drive */
419#define POLO_GPIO_CFG3_REG regptr(MSP_PER_BASE + 0x170)
420 /* Polo GPIO[23:16] config reg */
421#define POLO_GPIO_DAT2_REG regptr(MSP_PER_BASE + 0x174)
422 /* Polo GPIO[15:9] data reg */
423#define POLO_GPIO_DAT3_REG regptr(MSP_PER_BASE + 0x178)
424 /* Polo GPIO[23:16] data reg */
425#define POLO_GPIO_DAT4_REG regptr(MSP_PER_BASE + 0x17C)
426 /* Polo GPIO[31:24] data reg */
427#define POLO_GPIO_DAT5_REG regptr(MSP_PER_BASE + 0x180)
428 /* Polo GPIO[39:32] data reg */
429#define POLO_GPIO_DAT6_REG regptr(MSP_PER_BASE + 0x184)
430 /* Polo GPIO[47:40] data reg */
431#define POLO_GPIO_DAT7_REG regptr(MSP_PER_BASE + 0x188)
432 /* Polo GPIO[54:48] data reg */
433#define POLO_GPIO_CFG4_REG regptr(MSP_PER_BASE + 0x18C)
434 /* Polo GPIO[31:24] config reg */
435#define POLO_GPIO_CFG5_REG regptr(MSP_PER_BASE + 0x190)
436 /* Polo GPIO[39:32] config reg */
437#define POLO_GPIO_CFG6_REG regptr(MSP_PER_BASE + 0x194)
438 /* Polo GPIO[47:40] config reg */
439#define POLO_GPIO_CFG7_REG regptr(MSP_PER_BASE + 0x198)
440 /* Polo GPIO[54:48] config reg */
441#define POLO_GPIO_OD2_REG regptr(MSP_PER_BASE + 0x19C)
442 /* Polo GPIO[54:32] output drive */
443
444/* Generic GPIO registers */
445#define GPIO_DATA1_REG regptr(MSP_PER_BASE + 0x170)
446 /* GPIO[1:0] data register */
447#define GPIO_DATA2_REG regptr(MSP_PER_BASE + 0x174)
448 /* GPIO[5:2] data register */
449#define GPIO_DATA3_REG regptr(MSP_PER_BASE + 0x178)
450 /* GPIO[9:6] data register */
451#define GPIO_DATA4_REG regptr(MSP_PER_BASE + 0x17C)
452 /* GPIO[15:10] data register */
453#define GPIO_CFG1_REG regptr(MSP_PER_BASE + 0x180)
454 /* GPIO[1:0] config register */
455#define GPIO_CFG2_REG regptr(MSP_PER_BASE + 0x184)
456 /* GPIO[5:2] config register */
457#define GPIO_CFG3_REG regptr(MSP_PER_BASE + 0x188)
458 /* GPIO[9:6] config register */
459#define GPIO_CFG4_REG regptr(MSP_PER_BASE + 0x18C)
460 /* GPIO[15:10] config register */
461#define GPIO_OD_REG regptr(MSP_PER_BASE + 0x190)
462 /* GPIO[15:0] output drive */
463
464/*
465 ***************************************************************************
466 * CPU Interface register definitions *
467 ***************************************************************************
468 */
469#define PCI_FLUSH_REG regptr(MSP_CPUIF_BASE + 0x00)
470 /* PCI-SDRAM queue flush trigger */
471#define OCP_ERR1_REG regptr(MSP_CPUIF_BASE + 0x04)
472 /* OCP Error Attribute 1 */
473#define OCP_ERR2_REG regptr(MSP_CPUIF_BASE + 0x08)
474 /* OCP Error Attribute 2 */
475#define OCP_STS_REG regptr(MSP_CPUIF_BASE + 0x0C)
476 /* OCP Error Status */
477#define CPUIF_PM_REG regptr(MSP_CPUIF_BASE + 0x10)
478 /* CPU policy configuration */
479#define CPUIF_CFG_REG regptr(MSP_CPUIF_BASE + 0x10)
480 /* Misc configuration options */
481
482/* Central Interrupt Controller Registers */
483#define MSP_CIC_BASE (MSP_CPUIF_BASE + 0x8000)
484 /* Central Interrupt registers */
485#define CIC_EXT_CFG_REG regptr(MSP_CIC_BASE + 0x00)
486 /* External interrupt config */
487#define CIC_STS_REG regptr(MSP_CIC_BASE + 0x04)
488 /* CIC Interrupt Status */
489#define CIC_VPE0_MSK_REG regptr(MSP_CIC_BASE + 0x08)
490 /* VPE0 Interrupt Mask */
491#define CIC_VPE1_MSK_REG regptr(MSP_CIC_BASE + 0x0C)
492 /* VPE1 Interrupt Mask */
493#define CIC_TC0_MSK_REG regptr(MSP_CIC_BASE + 0x10)
494 /* Thread Context 0 Int Mask */
495#define CIC_TC1_MSK_REG regptr(MSP_CIC_BASE + 0x14)
496 /* Thread Context 1 Int Mask */
497#define CIC_TC2_MSK_REG regptr(MSP_CIC_BASE + 0x18)
498 /* Thread Context 2 Int Mask */
499#define CIC_TC3_MSK_REG regptr(MSP_CIC_BASE + 0x18)
500 /* Thread Context 3 Int Mask */
501#define CIC_TC4_MSK_REG regptr(MSP_CIC_BASE + 0x18)
502 /* Thread Context 4 Int Mask */
503#define CIC_PCIMSI_STS_REG regptr(MSP_CIC_BASE + 0x18)
504#define CIC_PCIMSI_MSK_REG regptr(MSP_CIC_BASE + 0x18)
505#define CIC_PCIFLSH_REG regptr(MSP_CIC_BASE + 0x18)
506#define CIC_VPE0_SWINT_REG regptr(MSP_CIC_BASE + 0x08)
507
508
509/*
510 ***************************************************************************
511 * Memory controller registers *
512 ***************************************************************************
513 */
514#define MEM_CFG1_REG regptr(MSP_MEM_CFG_BASE + 0x00)
515#define MEM_SS_ADDR regptr(MSP_MEM_CFG_BASE + 0x00)
516#define MEM_SS_DATA regptr(MSP_MEM_CFG_BASE + 0x04)
517#define MEM_SS_WRITE regptr(MSP_MEM_CFG_BASE + 0x08)
518
519/*
520 ***************************************************************************
521 * PCI controller registers *
522 ***************************************************************************
523 */
524#define PCI_BASE_REG regptr(MSP_PCI_BASE + 0x00)
525#define PCI_CONFIG_SPACE_REG regptr(MSP_PCI_BASE + 0x800)
526#define PCI_JTAG_DEVID_REG regptr(MSP_SLP_BASE + 0x13c)
527
528/*
529 ########################################################################
530 # Register content & macro definitions #
531 ########################################################################
532 */
533
534/*
535 ***************************************************************************
536 * DEV_ID defines *
537 ***************************************************************************
538 */
539#define DEV_ID_PCI_DIS (1 << 26) /* Set if PCI disabled */
540#define DEV_ID_PCI_HOST (1 << 20) /* Set if PCI host */
541#define DEV_ID_SINGLE_PC (1 << 19) /* Set if single PC Card */
542#define DEV_ID_FAMILY (0xff << 8) /* family ID code */
543#define POLO_ZEUS_SUB_FAMILY (0x7 << 16) /* sub family for Polo/Zeus */
544
545#define MSPFPGA_ID (0x00 << 8) /* you are on your own here */
546#define MSP5000_ID (0x50 << 8)
547#define MSP4F00_ID (0x4f << 8) /* FPGA version of MSP4200 */
548#define MSP4E00_ID (0x4f << 8) /* FPGA version of MSP7120 */
549#define MSP4200_ID (0x42 << 8)
550#define MSP4000_ID (0x40 << 8)
551#define MSP2XXX_ID (0x20 << 8)
552#define MSPZEUS_ID (0x10 << 8)
553
554#define MSP2004_SUB_ID (0x0 << 16)
555#define MSP2005_SUB_ID (0x1 << 16)
556#define MSP2006_SUB_ID (0x1 << 16)
557#define MSP2007_SUB_ID (0x2 << 16)
558#define MSP2010_SUB_ID (0x3 << 16)
559#define MSP2015_SUB_ID (0x4 << 16)
560#define MSP2020_SUB_ID (0x5 << 16)
561#define MSP2100_SUB_ID (0x6 << 16)
562
563/*
564 ***************************************************************************
565 * RESET defines *
566 ***************************************************************************
567 */
568#define MSP_GR_RST (0x01 << 0) /* Global reset bit */
569#define MSP_MR_RST (0x01 << 1) /* MIPS reset bit */
570#define MSP_PD_RST (0x01 << 2) /* PVC DMA reset bit */
571#define MSP_PP_RST (0x01 << 3) /* PVC reset bit */
572/* reserved */
573#define MSP_EA_RST (0x01 << 6) /* Mac A reset bit */
574#define MSP_EB_RST (0x01 << 7) /* Mac B reset bit */
575#define MSP_SE_RST (0x01 << 8) /* Security Eng reset bit */
576#define MSP_PB_RST (0x01 << 9) /* Per block reset bit */
577#define MSP_EC_RST (0x01 << 10) /* Mac C reset bit */
578#define MSP_TW_RST (0x01 << 11) /* TWI reset bit */
579#define MSP_SPI_RST (0x01 << 12) /* SPI/MPI reset bit */
580#define MSP_U1_RST (0x01 << 13) /* UART1 reset bit */
581#define MSP_U0_RST (0x01 << 14) /* UART0 reset bit */
582
583/*
584 ***************************************************************************
585 * UART defines *
586 ***************************************************************************
587 */
588#define MSP_BASE_BAUD 25000000
589#define MSP_UART_REG_LEN 0x20
590
591/*
592 ***************************************************************************
593 * ELB defines *
594 ***************************************************************************
595 */
596#define PCCARD_32 0x02 /* Set if is PCCARD 32 (Cardbus) */
597#define SINGLE_PCCARD 0x01 /* Set to enable single PC card */
598
599/*
600 ***************************************************************************
601 * CIC defines *
602 ***************************************************************************
603 */
604
605/* CIC_EXT_CFG_REG */
606#define EXT_INT_POL(eirq) (1 << (eirq + 8))
607#define EXT_INT_EDGE(eirq) (1 << eirq)
608
609#define CIC_EXT_SET_TRIGGER_LEVEL(reg, eirq) (reg &= ~EXT_INT_EDGE(eirq))
610#define CIC_EXT_SET_TRIGGER_EDGE(reg, eirq) (reg |= EXT_INT_EDGE(eirq))
611#define CIC_EXT_SET_ACTIVE_HI(reg, eirq) (reg |= EXT_INT_POL(eirq))
612#define CIC_EXT_SET_ACTIVE_LO(reg, eirq) (reg &= ~EXT_INT_POL(eirq))
613#define CIC_EXT_SET_ACTIVE_RISING CIC_EXT_SET_ACTIVE_HI
614#define CIC_EXT_SET_ACTIVE_FALLING CIC_EXT_SET_ACTIVE_LO
615
616#define CIC_EXT_IS_TRIGGER_LEVEL(reg, eirq) \
617 ((reg & EXT_INT_EDGE(eirq)) == 0)
618#define CIC_EXT_IS_TRIGGER_EDGE(reg, eirq) (reg & EXT_INT_EDGE(eirq))
619#define CIC_EXT_IS_ACTIVE_HI(reg, eirq) (reg & EXT_INT_POL(eirq))
620#define CIC_EXT_IS_ACTIVE_LO(reg, eirq) \
621 ((reg & EXT_INT_POL(eirq)) == 0)
622#define CIC_EXT_IS_ACTIVE_RISING CIC_EXT_IS_ACTIVE_HI
623#define CIC_EXT_IS_ACTIVE_FALLING CIC_EXT_IS_ACTIVE_LO
624
625/*
626 ***************************************************************************
627 * Memory Controller defines *
628 ***************************************************************************
629 */
630
631/* Indirect memory controller registers */
632#define DDRC_CFG(n) (n)
633#define DDRC_DEBUG(n) (0x04 + n)
634#define DDRC_CTL(n) (0x40 + n)
635
636/* Macro to perform DDRC indirect write */
637#define DDRC_INDIRECT_WRITE(reg, mask, value) \
638({ \
639 *MEM_SS_ADDR = (((mask) & 0xf) << 8) | ((reg) & 0xff); \
640 *MEM_SS_DATA = (value); \
641 *MEM_SS_WRITE = 1; \
642})
643
644/*
645 ***************************************************************************
646 * SPI/MPI Mode *
647 ***************************************************************************
648 */
649#define SPI_MPI_RX_BUSY 0x00008000 /* SPI/MPI Receive Busy */
650#define SPI_MPI_FIFO_EMPTY 0x00004000 /* SPI/MPI Fifo Empty */
651#define SPI_MPI_TX_BUSY 0x00002000 /* SPI/MPI Transmit Busy */
652#define SPI_MPI_FIFO_FULL 0x00001000 /* SPI/MPU FIFO full */
653
654/*
655 ***************************************************************************
656 * SPI/MPI Control Register *
657 ***************************************************************************
658 */
659#define SPI_MPI_RX_START 0x00000004 /* Start receive command */
660#define SPI_MPI_FLUSH_Q 0x00000002 /* Flush SPI/MPI Queue */
661#define SPI_MPI_TX_START 0x00000001 /* Start Transmit Command */
662
663#endif /* !_ASM_MSP_REGS_H */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/msp_slp_int.h b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_slp_int.h
new file mode 100644
index 000000000000..96d4c8ce8c83
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/msp_slp_int.h
@@ -0,0 +1,141 @@
1/*
2 * Defines for the MSP interrupt controller.
3 *
4 * Copyright (C) 1999 MIPS Technologies, Inc. All rights reserved.
5 * Author: Carsten Langgaard, carstenl@mips.com
6 *
7 * ########################################################################
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 *
22 * ########################################################################
23 */
24
25#ifndef _MSP_SLP_INT_H
26#define _MSP_SLP_INT_H
27
28/*
29 * The PMC-Sierra SLP interrupts are arranged in a 3 level cascaded
30 * hierarchical system. The first level are the direct MIPS interrupts
31 * and are assigned the interrupt range 0-7. The second level is the SLM
32 * interrupt controller and is assigned the range 8-39. The third level
33 * comprises the Peripherial block, the PCI block, the PCI MSI block and
34 * the SLP. The PCI interrupts and the SLP errors are handled by the
35 * relevant subsystems so the core interrupt code needs only concern
36 * itself with the Peripheral block. These are assigned interrupts in
37 * the range 40-71.
38 */
39
40/*
41 * IRQs directly connected to CPU
42 */
43#define MSP_MIPS_INTBASE 0
44#define MSP_INT_SW0 0 /* IRQ for swint0, C_SW0 */
45#define MSP_INT_SW1 1 /* IRQ for swint1, C_SW1 */
46#define MSP_INT_MAC0 2 /* IRQ for MAC 0, C_IRQ0 */
47#define MSP_INT_MAC1 3 /* IRQ for MAC 1, C_IRQ1 */
48#define MSP_INT_C_IRQ2 4 /* Wired off, C_IRQ2 */
49#define MSP_INT_VE 5 /* IRQ for Voice Engine, C_IRQ3 */
50#define MSP_INT_SLP 6 /* IRQ for SLM block, C_IRQ4 */
51#define MSP_INT_TIMER 7 /* IRQ for the MIPS timer, C_IRQ5 */
52
53/*
54 * IRQs cascaded on CPU interrupt 4 (CAUSE bit 12, C_IRQ4)
55 * These defines should be tied to the register definition for the SLM
56 * interrupt routine. For now, just use hard-coded values.
57 */
58#define MSP_SLP_INTBASE (MSP_MIPS_INTBASE + 8)
59#define MSP_INT_EXT0 (MSP_SLP_INTBASE + 0)
60 /* External interrupt 0 */
61#define MSP_INT_EXT1 (MSP_SLP_INTBASE + 1)
62 /* External interrupt 1 */
63#define MSP_INT_EXT2 (MSP_SLP_INTBASE + 2)
64 /* External interrupt 2 */
65#define MSP_INT_EXT3 (MSP_SLP_INTBASE + 3)
66 /* External interrupt 3 */
67/* Reserved 4-7 */
68
69/*
70 *************************************************************************
71 * DANGER/DANGER/DANGER/DANGER/DANGER/DANGER/DANGER/DANGER/DANGER/DANGER *
72 * Some MSP produces have this interrupt labelled as Voice and some are *
73 * SEC mbox ... *
74 *************************************************************************
75 */
76#define MSP_INT_SLP_VE (MSP_SLP_INTBASE + 8)
77 /* Cascaded IRQ for Voice Engine*/
78#define MSP_INT_SLP_TDM (MSP_SLP_INTBASE + 9)
79 /* TDM interrupt */
80#define MSP_INT_SLP_MAC0 (MSP_SLP_INTBASE + 10)
81 /* Cascaded IRQ for MAC 0 */
82#define MSP_INT_SLP_MAC1 (MSP_SLP_INTBASE + 11)
83 /* Cascaded IRQ for MAC 1 */
84#define MSP_INT_SEC (MSP_SLP_INTBASE + 12)
85 /* IRQ for security engine */
86#define MSP_INT_PER (MSP_SLP_INTBASE + 13)
87 /* Peripheral interrupt */
88#define MSP_INT_TIMER0 (MSP_SLP_INTBASE + 14)
89 /* SLP timer 0 */
90#define MSP_INT_TIMER1 (MSP_SLP_INTBASE + 15)
91 /* SLP timer 1 */
92#define MSP_INT_TIMER2 (MSP_SLP_INTBASE + 16)
93 /* SLP timer 2 */
94#define MSP_INT_SLP_TIMER (MSP_SLP_INTBASE + 17)
95 /* Cascaded MIPS timer */
96#define MSP_INT_BLKCP (MSP_SLP_INTBASE + 18)
97 /* Block Copy */
98#define MSP_INT_UART0 (MSP_SLP_INTBASE + 19)
99 /* UART 0 */
100#define MSP_INT_PCI (MSP_SLP_INTBASE + 20)
101 /* PCI subsystem */
102#define MSP_INT_PCI_DBELL (MSP_SLP_INTBASE + 21)
103 /* PCI doorbell */
104#define MSP_INT_PCI_MSI (MSP_SLP_INTBASE + 22)
105 /* PCI Message Signal */
106#define MSP_INT_PCI_BC0 (MSP_SLP_INTBASE + 23)
107 /* PCI Block Copy 0 */
108#define MSP_INT_PCI_BC1 (MSP_SLP_INTBASE + 24)
109 /* PCI Block Copy 1 */
110#define MSP_INT_SLP_ERR (MSP_SLP_INTBASE + 25)
111 /* SLP error condition */
112#define MSP_INT_MAC2 (MSP_SLP_INTBASE + 26)
113 /* IRQ for MAC2 */
114/* Reserved 26-31 */
115
116/*
117 * IRQs cascaded on SLP PER interrupt (MSP_INT_PER)
118 */
119#define MSP_PER_INTBASE (MSP_SLP_INTBASE + 32)
120/* Reserved 0-1 */
121#define MSP_INT_UART1 (MSP_PER_INTBASE + 2)
122 /* UART 1 */
123/* Reserved 3-5 */
124#define MSP_INT_2WIRE (MSP_PER_INTBASE + 6)
125 /* 2-wire */
126#define MSP_INT_TM0 (MSP_PER_INTBASE + 7)
127 /* Peripheral timer block out 0 */
128#define MSP_INT_TM1 (MSP_PER_INTBASE + 8)
129 /* Peripheral timer block out 1 */
130/* Reserved 9 */
131#define MSP_INT_SPRX (MSP_PER_INTBASE + 10)
132 /* SPI RX complete */
133#define MSP_INT_SPTX (MSP_PER_INTBASE + 11)
134 /* SPI TX complete */
135#define MSP_INT_GPIO (MSP_PER_INTBASE + 12)
136 /* GPIO */
137#define MSP_INT_PER_ERR (MSP_PER_INTBASE + 13)
138 /* Peripheral error */
139/* Reserved 14-31 */
140
141#endif /* !_MSP_SLP_INT_H */
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/war.h b/arch/mips/include/asm/pmc-sierra/msp71xx/war.h
new file mode 100644
index 000000000000..0bf48fc1892b
--- /dev/null
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/war.h
@@ -0,0 +1,28 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_PMC_SIERRA_WAR_H
9#define __ASM_MIPS_PMC_SIERRA_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#if defined(CONFIG_PMC_MSP7120_EVAL) || defined(CONFIG_PMC_MSP7120_GW) || \
24 defined(CONFIG_PMC_MSP7120_FPGA)
25#define MIPS34K_MISSED_ITLB_WAR 1
26#endif
27
28#endif /* __ASM_MIPS_PMC_SIERRA_WAR_H */
diff --git a/arch/mips/include/asm/pmon.h b/arch/mips/include/asm/pmon.h
new file mode 100644
index 000000000000..6ad519189ce2
--- /dev/null
+++ b/arch/mips/include/asm/pmon.h
@@ -0,0 +1,46 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2004 by Ralf Baechle
7 *
8 * The cpustart method is a PMC-Sierra's function to start the secondary CPU.
9 * Stock PMON 2000 has the smpfork, semlock and semunlock methods instead.
10 */
11#ifndef _ASM_PMON_H
12#define _ASM_PMON_H
13
14struct callvectors {
15 int (*open) (char*, int, int);
16 int (*close) (int);
17 int (*read) (int, void*, int);
18 int (*write) (int, void*, int);
19 off_t (*lseek) (int, off_t, int);
20 int (*printf) (const char*, ...);
21 void (*cacheflush) (void);
22 char* (*gets) (char*);
23 union {
24 int (*smpfork) (unsigned long cp, char *sp);
25 int (*cpustart) (long, void (*)(void), void *, long);
26 } _s;
27 int (*semlock) (int sem);
28 void (*semunlock) (int sem);
29};
30
31extern struct callvectors *debug_vectors;
32
33#define pmon_open(name, flags, mode) debug_vectors->open(name, flage, mode)
34#define pmon_close(fd) debug_vectors->close(fd)
35#define pmon_read(fd, buf, count) debug_vectors->read(fd, buf, count)
36#define pmon_write(fd, buf, count) debug_vectors->write(fd, buf, count)
37#define pmon_lseek(fd, off, whence) debug_vectors->lseek(fd, off, whence)
38#define pmon_printf(fmt...) debug_vectors->printf(fmt)
39#define pmon_cacheflush() debug_vectors->cacheflush()
40#define pmon_gets(s) debug_vectors->gets(s)
41#define pmon_cpustart(n, f, sp, gp) debug_vectors->_s.cpustart(n, f, sp, gp)
42#define pmon_smpfork(cp, sp) debug_vectors->_s.smpfork(cp, sp)
43#define pmon_semlock(sem) debug_vectors->semlock(sem)
44#define pmon_semunlock(sem) debug_vectors->semunlock(sem)
45
46#endif /* _ASM_PMON_H */
diff --git a/arch/mips/include/asm/poll.h b/arch/mips/include/asm/poll.h
new file mode 100644
index 000000000000..47b952080431
--- /dev/null
+++ b/arch/mips/include/asm/poll.h
@@ -0,0 +1,9 @@
1#ifndef __ASM_POLL_H
2#define __ASM_POLL_H
3
4#define POLLWRNORM POLLOUT
5#define POLLWRBAND 0x0100
6
7#include <asm-generic/poll.h>
8
9#endif /* __ASM_POLL_H */
diff --git a/arch/mips/include/asm/posix_types.h b/arch/mips/include/asm/posix_types.h
new file mode 100644
index 000000000000..c200102c8586
--- /dev/null
+++ b/arch/mips/include/asm/posix_types.h
@@ -0,0 +1,144 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 97, 98, 99, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_POSIX_TYPES_H
10#define _ASM_POSIX_TYPES_H
11
12#include <asm/sgidefs.h>
13
14/*
15 * This file is generally used by user-level software, so you need to
16 * be a little careful about namespace pollution etc. Also, we cannot
17 * assume GCC is being used.
18 */
19
20typedef unsigned long __kernel_ino_t;
21typedef unsigned int __kernel_mode_t;
22#if (_MIPS_SZLONG == 32)
23typedef unsigned long __kernel_nlink_t;
24#endif
25#if (_MIPS_SZLONG == 64)
26typedef unsigned int __kernel_nlink_t;
27#endif
28typedef long __kernel_off_t;
29typedef int __kernel_pid_t;
30typedef int __kernel_ipc_pid_t;
31typedef unsigned int __kernel_uid_t;
32typedef unsigned int __kernel_gid_t;
33#if (_MIPS_SZLONG == 32)
34typedef unsigned int __kernel_size_t;
35typedef int __kernel_ssize_t;
36typedef int __kernel_ptrdiff_t;
37#endif
38#if (_MIPS_SZLONG == 64)
39typedef unsigned long __kernel_size_t;
40typedef long __kernel_ssize_t;
41typedef long __kernel_ptrdiff_t;
42#endif
43typedef long __kernel_time_t;
44typedef long __kernel_suseconds_t;
45typedef long __kernel_clock_t;
46typedef int __kernel_timer_t;
47typedef int __kernel_clockid_t;
48typedef long __kernel_daddr_t;
49typedef char * __kernel_caddr_t;
50
51typedef unsigned short __kernel_uid16_t;
52typedef unsigned short __kernel_gid16_t;
53typedef unsigned int __kernel_uid32_t;
54typedef unsigned int __kernel_gid32_t;
55typedef __kernel_uid_t __kernel_old_uid_t;
56typedef __kernel_gid_t __kernel_old_gid_t;
57typedef unsigned int __kernel_old_dev_t;
58
59#ifdef __GNUC__
60typedef long long __kernel_loff_t;
61#endif
62
63typedef struct {
64#if (_MIPS_SZLONG == 32)
65 long val[2];
66#endif
67#if (_MIPS_SZLONG == 64)
68 int val[2];
69#endif
70} __kernel_fsid_t;
71
72#if defined(__KERNEL__)
73
74#undef __FD_SET
75static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
76{
77 unsigned long __tmp = __fd / __NFDBITS;
78 unsigned long __rem = __fd % __NFDBITS;
79 __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
80}
81
82#undef __FD_CLR
83static __inline__ void __FD_CLR(unsigned long __fd, __kernel_fd_set *__fdsetp)
84{
85 unsigned long __tmp = __fd / __NFDBITS;
86 unsigned long __rem = __fd % __NFDBITS;
87 __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
88}
89
90#undef __FD_ISSET
91static __inline__ int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
92{
93 unsigned long __tmp = __fd / __NFDBITS;
94 unsigned long __rem = __fd % __NFDBITS;
95 return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
96}
97
98/*
99 * This will unroll the loop for the normal constant case (8 ints,
100 * for a 256-bit fd_set)
101 */
102#undef __FD_ZERO
103static __inline__ void __FD_ZERO(__kernel_fd_set *__p)
104{
105 unsigned long *__tmp = __p->fds_bits;
106 int __i;
107
108 if (__builtin_constant_p(__FDSET_LONGS)) {
109 switch (__FDSET_LONGS) {
110 case 16:
111 __tmp[ 0] = 0; __tmp[ 1] = 0;
112 __tmp[ 2] = 0; __tmp[ 3] = 0;
113 __tmp[ 4] = 0; __tmp[ 5] = 0;
114 __tmp[ 6] = 0; __tmp[ 7] = 0;
115 __tmp[ 8] = 0; __tmp[ 9] = 0;
116 __tmp[10] = 0; __tmp[11] = 0;
117 __tmp[12] = 0; __tmp[13] = 0;
118 __tmp[14] = 0; __tmp[15] = 0;
119 return;
120
121 case 8:
122 __tmp[ 0] = 0; __tmp[ 1] = 0;
123 __tmp[ 2] = 0; __tmp[ 3] = 0;
124 __tmp[ 4] = 0; __tmp[ 5] = 0;
125 __tmp[ 6] = 0; __tmp[ 7] = 0;
126 return;
127
128 case 4:
129 __tmp[ 0] = 0; __tmp[ 1] = 0;
130 __tmp[ 2] = 0; __tmp[ 3] = 0;
131 return;
132 }
133 }
134 __i = __FDSET_LONGS;
135 while (__i) {
136 __i--;
137 *__tmp = 0;
138 __tmp++;
139 }
140}
141
142#endif /* defined(__KERNEL__) */
143
144#endif /* _ASM_POSIX_TYPES_H */
diff --git a/arch/mips/include/asm/prefetch.h b/arch/mips/include/asm/prefetch.h
new file mode 100644
index 000000000000..17850834ccb0
--- /dev/null
+++ b/arch/mips/include/asm/prefetch.h
@@ -0,0 +1,87 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
8#ifndef __ASM_PREFETCH_H
9#define __ASM_PREFETCH_H
10
11
12/*
13 * R5000 and RM5200 implements pref and prefx instructions but they're nops, so
14 * rather than wasting time we pretend these processors don't support
15 * prefetching at all.
16 *
17 * R5432 implements Load, Store, LoadStreamed, StoreStreamed, LoadRetained,
18 * StoreRetained and WriteBackInvalidate but not Pref_PrepareForStore.
19 *
20 * Hell (and the book on my shelf I can't open ...) know what the R8000 does.
21 *
22 * RM7000 version 1.0 interprets all hints as Pref_Load; version 2.0 implements
23 * Pref_PrepareForStore also.
24 *
25 * RM9000 is MIPS IV but implements prefetching like MIPS32/MIPS64; it's
26 * Pref_WriteBackInvalidate is a nop and Pref_PrepareForStore is broken in
27 * current versions due to erratum G105.
28 *
29 * VR7701 only implements the Load prefetch.
30 *
31 * Finally MIPS32 and MIPS64 implement all of the following hints.
32 */
33
34#define Pref_Load 0
35#define Pref_Store 1
36 /* 2 and 3 are reserved */
37#define Pref_LoadStreamed 4
38#define Pref_StoreStreamed 5
39#define Pref_LoadRetained 6
40#define Pref_StoreRetained 7
41 /* 8 ... 24 are reserved */
42#define Pref_WriteBackInvalidate 25
43#define Pref_PrepareForStore 30
44
45#ifdef __ASSEMBLY__
46
47 .macro __pref hint addr
48#ifdef CONFIG_CPU_HAS_PREFETCH
49 pref \hint, \addr
50#endif
51 .endm
52
53 .macro pref_load addr
54 __pref Pref_Load, \addr
55 .endm
56
57 .macro pref_store addr
58 __pref Pref_Store, \addr
59 .endm
60
61 .macro pref_load_streamed addr
62 __pref Pref_LoadStreamed, \addr
63 .endm
64
65 .macro pref_store_streamed addr
66 __pref Pref_StoreStreamed, \addr
67 .endm
68
69 .macro pref_load_retained addr
70 __pref Pref_LoadRetained, \addr
71 .endm
72
73 .macro pref_store_retained addr
74 __pref Pref_StoreRetained, \addr
75 .endm
76
77 .macro pref_wback_inv addr
78 __pref Pref_WriteBackInvalidate, \addr
79 .endm
80
81 .macro pref_prepare_for_store addr
82 __pref Pref_PrepareForStore, \addr
83 .endm
84
85#endif
86
87#endif /* __ASM_PREFETCH_H */
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
new file mode 100644
index 000000000000..18ee58e39445
--- /dev/null
+++ b/arch/mips/include/asm/processor.h
@@ -0,0 +1,283 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 Waldorf GMBH
7 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
8 * Copyright (C) 1996 Paul M. Antoine
9 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
10 */
11#ifndef _ASM_PROCESSOR_H
12#define _ASM_PROCESSOR_H
13
14#include <linux/cpumask.h>
15#include <linux/threads.h>
16
17#include <asm/cachectl.h>
18#include <asm/cpu.h>
19#include <asm/cpu-info.h>
20#include <asm/mipsregs.h>
21#include <asm/prefetch.h>
22#include <asm/system.h>
23
24/*
25 * Return current * instruction pointer ("program counter").
26 */
27#define current_text_addr() ({ __label__ _l; _l: &&_l;})
28
29/*
30 * System setup and hardware flags..
31 */
32extern void (*cpu_wait)(void);
33
34extern unsigned int vced_count, vcei_count;
35
36#ifdef CONFIG_32BIT
37/*
38 * User space process size: 2GB. This is hardcoded into a few places,
39 * so don't change it unless you know what you are doing.
40 */
41#define TASK_SIZE 0x7fff8000UL
42#define STACK_TOP TASK_SIZE
43
44/*
45 * This decides where the kernel will search for a free chunk of vm
46 * space during mmap's.
47 */
48#define TASK_UNMAPPED_BASE ((TASK_SIZE / 3) & ~(PAGE_SIZE))
49#endif
50
51#ifdef CONFIG_64BIT
52/*
53 * User space process size: 1TB. This is hardcoded into a few places,
54 * so don't change it unless you know what you are doing. TASK_SIZE
55 * is limited to 1TB by the R4000 architecture; R10000 and better can
56 * support 16TB; the architectural reserve for future expansion is
57 * 8192EB ...
58 */
59#define TASK_SIZE32 0x7fff8000UL
60#define TASK_SIZE 0x10000000000UL
61#define STACK_TOP \
62 (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE)
63
64/*
65 * This decides where the kernel will search for a free chunk of vm
66 * space during mmap's.
67 */
68#define TASK_UNMAPPED_BASE \
69 (test_thread_flag(TIF_32BIT_ADDR) ? \
70 PAGE_ALIGN(TASK_SIZE32 / 3) : PAGE_ALIGN(TASK_SIZE / 3))
71#define TASK_SIZE_OF(tsk) \
72 (test_tsk_thread_flag(tsk, TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE)
73#endif
74
75#ifdef __KERNEL__
76#define STACK_TOP_MAX TASK_SIZE
77#endif
78
79#define NUM_FPU_REGS 32
80
81typedef __u64 fpureg_t;
82
83/*
84 * It would be nice to add some more fields for emulator statistics, but there
85 * are a number of fixed offsets in offset.h and elsewhere that would have to
86 * be recalculated by hand. So the additional information will be private to
87 * the FPU emulator for now. See asm-mips/fpu_emulator.h.
88 */
89
90struct mips_fpu_struct {
91 fpureg_t fpr[NUM_FPU_REGS];
92 unsigned int fcr31;
93};
94
95#define NUM_DSP_REGS 6
96
97typedef __u32 dspreg_t;
98
99struct mips_dsp_state {
100 dspreg_t dspr[NUM_DSP_REGS];
101 unsigned int dspcontrol;
102};
103
104#define INIT_CPUMASK { \
105 {0,} \
106}
107
108struct mips3264_watch_reg_state {
109 /* The width of watchlo is 32 in a 32 bit kernel and 64 in a
110 64 bit kernel. We use unsigned long as it has the same
111 property. */
112 unsigned long watchlo[NUM_WATCH_REGS];
113 /* Only the mask and IRW bits from watchhi. */
114 u16 watchhi[NUM_WATCH_REGS];
115};
116
117union mips_watch_reg_state {
118 struct mips3264_watch_reg_state mips3264;
119};
120
121typedef struct {
122 unsigned long seg;
123} mm_segment_t;
124
125#define ARCH_MIN_TASKALIGN 8
126
127struct mips_abi;
128
129/*
130 * If you change thread_struct remember to change the #defines below too!
131 */
132struct thread_struct {
133 /* Saved main processor registers. */
134 unsigned long reg16;
135 unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
136 unsigned long reg29, reg30, reg31;
137
138 /* Saved cp0 stuff. */
139 unsigned long cp0_status;
140
141 /* Saved fpu/fpu emulator stuff. */
142 struct mips_fpu_struct fpu;
143#ifdef CONFIG_MIPS_MT_FPAFF
144 /* Emulated instruction count */
145 unsigned long emulated_fp;
146 /* Saved per-thread scheduler affinity mask */
147 cpumask_t user_cpus_allowed;
148#endif /* CONFIG_MIPS_MT_FPAFF */
149
150 /* Saved state of the DSP ASE, if available. */
151 struct mips_dsp_state dsp;
152
153 /* Saved watch register state, if available. */
154 union mips_watch_reg_state watch;
155
156 /* Other stuff associated with the thread. */
157 unsigned long cp0_badvaddr; /* Last user fault */
158 unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */
159 unsigned long error_code;
160 unsigned long trap_no;
161 unsigned long irix_trampoline; /* Wheee... */
162 unsigned long irix_oldctx;
163 struct mips_abi *abi;
164};
165
166#ifdef CONFIG_MIPS_MT_FPAFF
167#define FPAFF_INIT \
168 .emulated_fp = 0, \
169 .user_cpus_allowed = INIT_CPUMASK,
170#else
171#define FPAFF_INIT
172#endif /* CONFIG_MIPS_MT_FPAFF */
173
174#define INIT_THREAD { \
175 /* \
176 * Saved main processor registers \
177 */ \
178 .reg16 = 0, \
179 .reg17 = 0, \
180 .reg18 = 0, \
181 .reg19 = 0, \
182 .reg20 = 0, \
183 .reg21 = 0, \
184 .reg22 = 0, \
185 .reg23 = 0, \
186 .reg29 = 0, \
187 .reg30 = 0, \
188 .reg31 = 0, \
189 /* \
190 * Saved cp0 stuff \
191 */ \
192 .cp0_status = 0, \
193 /* \
194 * Saved FPU/FPU emulator stuff \
195 */ \
196 .fpu = { \
197 .fpr = {0,}, \
198 .fcr31 = 0, \
199 }, \
200 /* \
201 * FPU affinity state (null if not FPAFF) \
202 */ \
203 FPAFF_INIT \
204 /* \
205 * Saved DSP stuff \
206 */ \
207 .dsp = { \
208 .dspr = {0, }, \
209 .dspcontrol = 0, \
210 }, \
211 /* \
212 * saved watch register stuff \
213 */ \
214 .watch = {{{0,},},}, \
215 /* \
216 * Other stuff associated with the process \
217 */ \
218 .cp0_badvaddr = 0, \
219 .cp0_baduaddr = 0, \
220 .error_code = 0, \
221 .trap_no = 0, \
222 .irix_trampoline = 0, \
223 .irix_oldctx = 0, \
224}
225
226struct task_struct;
227
228/* Free all resources held by a thread. */
229#define release_thread(thread) do { } while(0)
230
231/* Prepare to copy thread state - unlazy all lazy status */
232#define prepare_to_copy(tsk) do { } while (0)
233
234extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
235
236extern unsigned long thread_saved_pc(struct task_struct *tsk);
237
238/*
239 * Do necessary setup to start up a newly executed thread.
240 */
241extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
242
243unsigned long get_wchan(struct task_struct *p);
244
245#define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + THREAD_SIZE - 32)
246#define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk) - 1)
247#define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc)
248#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
249#define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status)
250
251#define cpu_relax() barrier()
252
253/*
254 * Return_address is a replacement for __builtin_return_address(count)
255 * which on certain architectures cannot reasonably be implemented in GCC
256 * (MIPS, Alpha) or is unuseable with -fomit-frame-pointer (i386).
257 * Note that __builtin_return_address(x>=1) is forbidden because GCC
258 * aborts compilation on some CPUs. It's simply not possible to unwind
259 * some CPU's stackframes.
260 *
261 * __builtin_return_address works only for non-leaf functions. We avoid the
262 * overhead of a function call by forcing the compiler to save the return
263 * address register on the stack.
264 */
265#define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
266
267#ifdef CONFIG_CPU_HAS_PREFETCH
268
269#define ARCH_HAS_PREFETCH
270
271static inline void prefetch(const void *addr)
272{
273 __asm__ __volatile__(
274 " .set mips4 \n"
275 " pref %0, (%1) \n"
276 " .set mips0 \n"
277 :
278 : "i" (Pref_Load), "r" (addr));
279}
280
281#endif
282
283#endif /* _ASM_PROCESSOR_H */
diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h
new file mode 100644
index 000000000000..9c22571b160d
--- /dev/null
+++ b/arch/mips/include/asm/ptrace.h
@@ -0,0 +1,154 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_PTRACE_H
10#define _ASM_PTRACE_H
11
12#ifdef CONFIG_64BIT
13#define __ARCH_WANT_COMPAT_SYS_PTRACE
14#endif
15
16/* 0 - 31 are integer registers, 32 - 63 are fp registers. */
17#define FPR_BASE 32
18#define PC 64
19#define CAUSE 65
20#define BADVADDR 66
21#define MMHI 67
22#define MMLO 68
23#define FPC_CSR 69
24#define FPC_EIR 70
25#define DSP_BASE 71 /* 3 more hi / lo register pairs */
26#define DSP_CONTROL 77
27#define ACX 78
28
29/*
30 * This struct defines the way the registers are stored on the stack during a
31 * system call/exception. As usual the registers k0/k1 aren't being saved.
32 */
33struct pt_regs {
34#ifdef CONFIG_32BIT
35 /* Pad bytes for argument save space on the stack. */
36 unsigned long pad0[6];
37#endif
38
39 /* Saved main processor registers. */
40 unsigned long regs[32];
41
42 /* Saved special registers. */
43 unsigned long cp0_status;
44 unsigned long hi;
45 unsigned long lo;
46#ifdef CONFIG_CPU_HAS_SMARTMIPS
47 unsigned long acx;
48#endif
49 unsigned long cp0_badvaddr;
50 unsigned long cp0_cause;
51 unsigned long cp0_epc;
52#ifdef CONFIG_MIPS_MT_SMTC
53 unsigned long cp0_tcstatus;
54#endif /* CONFIG_MIPS_MT_SMTC */
55} __attribute__ ((aligned (8)));
56
57/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
58#define PTRACE_GETREGS 12
59#define PTRACE_SETREGS 13
60#define PTRACE_GETFPREGS 14
61#define PTRACE_SETFPREGS 15
62/* #define PTRACE_GETFPXREGS 18 */
63/* #define PTRACE_SETFPXREGS 19 */
64
65#define PTRACE_OLDSETOPTIONS 21
66
67#define PTRACE_GET_THREAD_AREA 25
68#define PTRACE_SET_THREAD_AREA 26
69
70/* Calls to trace a 64bit program from a 32bit program. */
71#define PTRACE_PEEKTEXT_3264 0xc0
72#define PTRACE_PEEKDATA_3264 0xc1
73#define PTRACE_POKETEXT_3264 0xc2
74#define PTRACE_POKEDATA_3264 0xc3
75#define PTRACE_GET_THREAD_AREA_3264 0xc4
76
77/* Read and write watchpoint registers. */
78enum pt_watch_style {
79 pt_watch_style_mips32,
80 pt_watch_style_mips64
81};
82struct mips32_watch_regs {
83 uint32_t watchlo[8];
84 /* Lower 16 bits of watchhi. */
85 uint16_t watchhi[8];
86 /* Valid mask and I R W bits.
87 * bit 0 -- 1 if W bit is usable.
88 * bit 1 -- 1 if R bit is usable.
89 * bit 2 -- 1 if I bit is usable.
90 * bits 3 - 11 -- Valid watchhi mask bits.
91 */
92 uint16_t watch_masks[8];
93 /* The number of valid watch register pairs. */
94 uint32_t num_valid;
95} __attribute__((aligned(8)));
96
97struct mips64_watch_regs {
98 uint64_t watchlo[8];
99 uint16_t watchhi[8];
100 uint16_t watch_masks[8];
101 uint32_t num_valid;
102} __attribute__((aligned(8)));
103
104struct pt_watch_regs {
105 enum pt_watch_style style;
106 union {
107 struct mips32_watch_regs mips32;
108 struct mips32_watch_regs mips64;
109 };
110};
111
112#define PTRACE_GET_WATCH_REGS 0xd0
113#define PTRACE_SET_WATCH_REGS 0xd1
114
115#ifdef __KERNEL__
116
117#include <linux/compiler.h>
118#include <linux/linkage.h>
119#include <asm/isadep.h>
120
121struct task_struct;
122
123extern int ptrace_getregs(struct task_struct *child, __s64 __user *data);
124extern int ptrace_setregs(struct task_struct *child, __s64 __user *data);
125
126extern int ptrace_getfpregs(struct task_struct *child, __u32 __user *data);
127extern int ptrace_setfpregs(struct task_struct *child, __u32 __user *data);
128
129extern int ptrace_get_watch_regs(struct task_struct *child,
130 struct pt_watch_regs __user *addr);
131extern int ptrace_set_watch_regs(struct task_struct *child,
132 struct pt_watch_regs __user *addr);
133
134/*
135 * Does the process account for user or for system time?
136 */
137#define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER)
138
139#define instruction_pointer(regs) ((regs)->cp0_epc)
140#define profile_pc(regs) instruction_pointer(regs)
141
142extern asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit);
143
144extern NORET_TYPE void die(const char *, const struct pt_regs *) ATTRIB_NORET;
145
146static inline void die_if_kernel(const char *str, const struct pt_regs *regs)
147{
148 if (unlikely(!user_mode(regs)))
149 die(str, regs);
150}
151
152#endif
153
154#endif /* _ASM_PTRACE_H */
diff --git a/arch/mips/include/asm/r4k-timer.h b/arch/mips/include/asm/r4k-timer.h
new file mode 100644
index 000000000000..a37d12b3b61c
--- /dev/null
+++ b/arch/mips/include/asm/r4k-timer.h
@@ -0,0 +1,30 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2008 by Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef __ASM_R4K_TYPES_H
9#define __ASM_R4K_TYPES_H
10
11#include <linux/compiler.h>
12
13#ifdef CONFIG_SYNC_R4K
14
15extern void synchronise_count_master(void);
16extern void synchronise_count_slave(void);
17
18#else
19
20static inline void synchronise_count_master(void)
21{
22}
23
24static inline void synchronise_count_slave(void)
25{
26}
27
28#endif
29
30#endif /* __ASM_R4K_TYPES_H */
diff --git a/arch/mips/include/asm/r4kcache.h b/arch/mips/include/asm/r4kcache.h
new file mode 100644
index 000000000000..4c140db36786
--- /dev/null
+++ b/arch/mips/include/asm/r4kcache.h
@@ -0,0 +1,443 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Inline assembly cache operations.
7 *
8 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
9 * Copyright (C) 1997 - 2002 Ralf Baechle (ralf@gnu.org)
10 * Copyright (C) 2004 Ralf Baechle (ralf@linux-mips.org)
11 */
12#ifndef _ASM_R4KCACHE_H
13#define _ASM_R4KCACHE_H
14
15#include <asm/asm.h>
16#include <asm/cacheops.h>
17#include <asm/cpu-features.h>
18#include <asm/mipsmtregs.h>
19
20/*
21 * This macro return a properly sign-extended address suitable as base address
22 * for indexed cache operations. Two issues here:
23 *
24 * - The MIPS32 and MIPS64 specs permit an implementation to directly derive
25 * the index bits from the virtual address. This breaks with tradition
26 * set by the R4000. To keep unpleasant surprises from happening we pick
27 * an address in KSEG0 / CKSEG0.
28 * - We need a properly sign extended address for 64-bit code. To get away
29 * without ifdefs we let the compiler do it by a type cast.
30 */
31#define INDEX_BASE CKSEG0
32
33#define cache_op(op,addr) \
34 __asm__ __volatile__( \
35 " .set push \n" \
36 " .set noreorder \n" \
37 " .set mips3\n\t \n" \
38 " cache %0, %1 \n" \
39 " .set pop \n" \
40 : \
41 : "i" (op), "R" (*(unsigned char *)(addr)))
42
43#ifdef CONFIG_MIPS_MT
44/*
45 * Temporary hacks for SMTC debug. Optionally force single-threaded
46 * execution during I-cache flushes.
47 */
48
49#define PROTECT_CACHE_FLUSHES 1
50
51#ifdef PROTECT_CACHE_FLUSHES
52
53extern int mt_protiflush;
54extern int mt_protdflush;
55extern void mt_cflush_lockdown(void);
56extern void mt_cflush_release(void);
57
58#define BEGIN_MT_IPROT \
59 unsigned long flags = 0; \
60 unsigned long mtflags = 0; \
61 if(mt_protiflush) { \
62 local_irq_save(flags); \
63 ehb(); \
64 mtflags = dvpe(); \
65 mt_cflush_lockdown(); \
66 }
67
68#define END_MT_IPROT \
69 if(mt_protiflush) { \
70 mt_cflush_release(); \
71 evpe(mtflags); \
72 local_irq_restore(flags); \
73 }
74
75#define BEGIN_MT_DPROT \
76 unsigned long flags = 0; \
77 unsigned long mtflags = 0; \
78 if(mt_protdflush) { \
79 local_irq_save(flags); \
80 ehb(); \
81 mtflags = dvpe(); \
82 mt_cflush_lockdown(); \
83 }
84
85#define END_MT_DPROT \
86 if(mt_protdflush) { \
87 mt_cflush_release(); \
88 evpe(mtflags); \
89 local_irq_restore(flags); \
90 }
91
92#else
93
94#define BEGIN_MT_IPROT
95#define BEGIN_MT_DPROT
96#define END_MT_IPROT
97#define END_MT_DPROT
98
99#endif /* PROTECT_CACHE_FLUSHES */
100
101#define __iflush_prologue \
102 unsigned long redundance; \
103 extern int mt_n_iflushes; \
104 BEGIN_MT_IPROT \
105 for (redundance = 0; redundance < mt_n_iflushes; redundance++) {
106
107#define __iflush_epilogue \
108 END_MT_IPROT \
109 }
110
111#define __dflush_prologue \
112 unsigned long redundance; \
113 extern int mt_n_dflushes; \
114 BEGIN_MT_DPROT \
115 for (redundance = 0; redundance < mt_n_dflushes; redundance++) {
116
117#define __dflush_epilogue \
118 END_MT_DPROT \
119 }
120
121#define __inv_dflush_prologue __dflush_prologue
122#define __inv_dflush_epilogue __dflush_epilogue
123#define __sflush_prologue {
124#define __sflush_epilogue }
125#define __inv_sflush_prologue __sflush_prologue
126#define __inv_sflush_epilogue __sflush_epilogue
127
128#else /* CONFIG_MIPS_MT */
129
130#define __iflush_prologue {
131#define __iflush_epilogue }
132#define __dflush_prologue {
133#define __dflush_epilogue }
134#define __inv_dflush_prologue {
135#define __inv_dflush_epilogue }
136#define __sflush_prologue {
137#define __sflush_epilogue }
138#define __inv_sflush_prologue {
139#define __inv_sflush_epilogue }
140
141#endif /* CONFIG_MIPS_MT */
142
143static inline void flush_icache_line_indexed(unsigned long addr)
144{
145 __iflush_prologue
146 cache_op(Index_Invalidate_I, addr);
147 __iflush_epilogue
148}
149
150static inline void flush_dcache_line_indexed(unsigned long addr)
151{
152 __dflush_prologue
153 cache_op(Index_Writeback_Inv_D, addr);
154 __dflush_epilogue
155}
156
157static inline void flush_scache_line_indexed(unsigned long addr)
158{
159 cache_op(Index_Writeback_Inv_SD, addr);
160}
161
162static inline void flush_icache_line(unsigned long addr)
163{
164 __iflush_prologue
165 cache_op(Hit_Invalidate_I, addr);
166 __iflush_epilogue
167}
168
169static inline void flush_dcache_line(unsigned long addr)
170{
171 __dflush_prologue
172 cache_op(Hit_Writeback_Inv_D, addr);
173 __dflush_epilogue
174}
175
176static inline void invalidate_dcache_line(unsigned long addr)
177{
178 __dflush_prologue
179 cache_op(Hit_Invalidate_D, addr);
180 __dflush_epilogue
181}
182
183static inline void invalidate_scache_line(unsigned long addr)
184{
185 cache_op(Hit_Invalidate_SD, addr);
186}
187
188static inline void flush_scache_line(unsigned long addr)
189{
190 cache_op(Hit_Writeback_Inv_SD, addr);
191}
192
193#define protected_cache_op(op,addr) \
194 __asm__ __volatile__( \
195 " .set push \n" \
196 " .set noreorder \n" \
197 " .set mips3 \n" \
198 "1: cache %0, (%1) \n" \
199 "2: .set pop \n" \
200 " .section __ex_table,\"a\" \n" \
201 " "STR(PTR)" 1b, 2b \n" \
202 " .previous" \
203 : \
204 : "i" (op), "r" (addr))
205
206/*
207 * The next two are for badland addresses like signal trampolines.
208 */
209static inline void protected_flush_icache_line(unsigned long addr)
210{
211 protected_cache_op(Hit_Invalidate_I, addr);
212}
213
214/*
215 * R10000 / R12000 hazard - these processors don't support the Hit_Writeback_D
216 * cacheop so we use Hit_Writeback_Inv_D which is supported by all R4000-style
217 * caches. We're talking about one cacheline unnecessarily getting invalidated
218 * here so the penalty isn't overly hard.
219 */
220static inline void protected_writeback_dcache_line(unsigned long addr)
221{
222 protected_cache_op(Hit_Writeback_Inv_D, addr);
223}
224
225static inline void protected_writeback_scache_line(unsigned long addr)
226{
227 protected_cache_op(Hit_Writeback_Inv_SD, addr);
228}
229
230/*
231 * This one is RM7000-specific
232 */
233static inline void invalidate_tcache_page(unsigned long addr)
234{
235 cache_op(Page_Invalidate_T, addr);
236}
237
238#define cache16_unroll32(base,op) \
239 __asm__ __volatile__( \
240 " .set push \n" \
241 " .set noreorder \n" \
242 " .set mips3 \n" \
243 " cache %1, 0x000(%0); cache %1, 0x010(%0) \n" \
244 " cache %1, 0x020(%0); cache %1, 0x030(%0) \n" \
245 " cache %1, 0x040(%0); cache %1, 0x050(%0) \n" \
246 " cache %1, 0x060(%0); cache %1, 0x070(%0) \n" \
247 " cache %1, 0x080(%0); cache %1, 0x090(%0) \n" \
248 " cache %1, 0x0a0(%0); cache %1, 0x0b0(%0) \n" \
249 " cache %1, 0x0c0(%0); cache %1, 0x0d0(%0) \n" \
250 " cache %1, 0x0e0(%0); cache %1, 0x0f0(%0) \n" \
251 " cache %1, 0x100(%0); cache %1, 0x110(%0) \n" \
252 " cache %1, 0x120(%0); cache %1, 0x130(%0) \n" \
253 " cache %1, 0x140(%0); cache %1, 0x150(%0) \n" \
254 " cache %1, 0x160(%0); cache %1, 0x170(%0) \n" \
255 " cache %1, 0x180(%0); cache %1, 0x190(%0) \n" \
256 " cache %1, 0x1a0(%0); cache %1, 0x1b0(%0) \n" \
257 " cache %1, 0x1c0(%0); cache %1, 0x1d0(%0) \n" \
258 " cache %1, 0x1e0(%0); cache %1, 0x1f0(%0) \n" \
259 " .set pop \n" \
260 : \
261 : "r" (base), \
262 "i" (op));
263
264#define cache32_unroll32(base,op) \
265 __asm__ __volatile__( \
266 " .set push \n" \
267 " .set noreorder \n" \
268 " .set mips3 \n" \
269 " cache %1, 0x000(%0); cache %1, 0x020(%0) \n" \
270 " cache %1, 0x040(%0); cache %1, 0x060(%0) \n" \
271 " cache %1, 0x080(%0); cache %1, 0x0a0(%0) \n" \
272 " cache %1, 0x0c0(%0); cache %1, 0x0e0(%0) \n" \
273 " cache %1, 0x100(%0); cache %1, 0x120(%0) \n" \
274 " cache %1, 0x140(%0); cache %1, 0x160(%0) \n" \
275 " cache %1, 0x180(%0); cache %1, 0x1a0(%0) \n" \
276 " cache %1, 0x1c0(%0); cache %1, 0x1e0(%0) \n" \
277 " cache %1, 0x200(%0); cache %1, 0x220(%0) \n" \
278 " cache %1, 0x240(%0); cache %1, 0x260(%0) \n" \
279 " cache %1, 0x280(%0); cache %1, 0x2a0(%0) \n" \
280 " cache %1, 0x2c0(%0); cache %1, 0x2e0(%0) \n" \
281 " cache %1, 0x300(%0); cache %1, 0x320(%0) \n" \
282 " cache %1, 0x340(%0); cache %1, 0x360(%0) \n" \
283 " cache %1, 0x380(%0); cache %1, 0x3a0(%0) \n" \
284 " cache %1, 0x3c0(%0); cache %1, 0x3e0(%0) \n" \
285 " .set pop \n" \
286 : \
287 : "r" (base), \
288 "i" (op));
289
290#define cache64_unroll32(base,op) \
291 __asm__ __volatile__( \
292 " .set push \n" \
293 " .set noreorder \n" \
294 " .set mips3 \n" \
295 " cache %1, 0x000(%0); cache %1, 0x040(%0) \n" \
296 " cache %1, 0x080(%0); cache %1, 0x0c0(%0) \n" \
297 " cache %1, 0x100(%0); cache %1, 0x140(%0) \n" \
298 " cache %1, 0x180(%0); cache %1, 0x1c0(%0) \n" \
299 " cache %1, 0x200(%0); cache %1, 0x240(%0) \n" \
300 " cache %1, 0x280(%0); cache %1, 0x2c0(%0) \n" \
301 " cache %1, 0x300(%0); cache %1, 0x340(%0) \n" \
302 " cache %1, 0x380(%0); cache %1, 0x3c0(%0) \n" \
303 " cache %1, 0x400(%0); cache %1, 0x440(%0) \n" \
304 " cache %1, 0x480(%0); cache %1, 0x4c0(%0) \n" \
305 " cache %1, 0x500(%0); cache %1, 0x540(%0) \n" \
306 " cache %1, 0x580(%0); cache %1, 0x5c0(%0) \n" \
307 " cache %1, 0x600(%0); cache %1, 0x640(%0) \n" \
308 " cache %1, 0x680(%0); cache %1, 0x6c0(%0) \n" \
309 " cache %1, 0x700(%0); cache %1, 0x740(%0) \n" \
310 " cache %1, 0x780(%0); cache %1, 0x7c0(%0) \n" \
311 " .set pop \n" \
312 : \
313 : "r" (base), \
314 "i" (op));
315
316#define cache128_unroll32(base,op) \
317 __asm__ __volatile__( \
318 " .set push \n" \
319 " .set noreorder \n" \
320 " .set mips3 \n" \
321 " cache %1, 0x000(%0); cache %1, 0x080(%0) \n" \
322 " cache %1, 0x100(%0); cache %1, 0x180(%0) \n" \
323 " cache %1, 0x200(%0); cache %1, 0x280(%0) \n" \
324 " cache %1, 0x300(%0); cache %1, 0x380(%0) \n" \
325 " cache %1, 0x400(%0); cache %1, 0x480(%0) \n" \
326 " cache %1, 0x500(%0); cache %1, 0x580(%0) \n" \
327 " cache %1, 0x600(%0); cache %1, 0x680(%0) \n" \
328 " cache %1, 0x700(%0); cache %1, 0x780(%0) \n" \
329 " cache %1, 0x800(%0); cache %1, 0x880(%0) \n" \
330 " cache %1, 0x900(%0); cache %1, 0x980(%0) \n" \
331 " cache %1, 0xa00(%0); cache %1, 0xa80(%0) \n" \
332 " cache %1, 0xb00(%0); cache %1, 0xb80(%0) \n" \
333 " cache %1, 0xc00(%0); cache %1, 0xc80(%0) \n" \
334 " cache %1, 0xd00(%0); cache %1, 0xd80(%0) \n" \
335 " cache %1, 0xe00(%0); cache %1, 0xe80(%0) \n" \
336 " cache %1, 0xf00(%0); cache %1, 0xf80(%0) \n" \
337 " .set pop \n" \
338 : \
339 : "r" (base), \
340 "i" (op));
341
342/* build blast_xxx, blast_xxx_page, blast_xxx_page_indexed */
343#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize) \
344static inline void blast_##pfx##cache##lsize(void) \
345{ \
346 unsigned long start = INDEX_BASE; \
347 unsigned long end = start + current_cpu_data.desc.waysize; \
348 unsigned long ws_inc = 1UL << current_cpu_data.desc.waybit; \
349 unsigned long ws_end = current_cpu_data.desc.ways << \
350 current_cpu_data.desc.waybit; \
351 unsigned long ws, addr; \
352 \
353 __##pfx##flush_prologue \
354 \
355 for (ws = 0; ws < ws_end; ws += ws_inc) \
356 for (addr = start; addr < end; addr += lsize * 32) \
357 cache##lsize##_unroll32(addr|ws, indexop); \
358 \
359 __##pfx##flush_epilogue \
360} \
361 \
362static inline void blast_##pfx##cache##lsize##_page(unsigned long page) \
363{ \
364 unsigned long start = page; \
365 unsigned long end = page + PAGE_SIZE; \
366 \
367 __##pfx##flush_prologue \
368 \
369 do { \
370 cache##lsize##_unroll32(start, hitop); \
371 start += lsize * 32; \
372 } while (start < end); \
373 \
374 __##pfx##flush_epilogue \
375} \
376 \
377static inline void blast_##pfx##cache##lsize##_page_indexed(unsigned long page) \
378{ \
379 unsigned long indexmask = current_cpu_data.desc.waysize - 1; \
380 unsigned long start = INDEX_BASE + (page & indexmask); \
381 unsigned long end = start + PAGE_SIZE; \
382 unsigned long ws_inc = 1UL << current_cpu_data.desc.waybit; \
383 unsigned long ws_end = current_cpu_data.desc.ways << \
384 current_cpu_data.desc.waybit; \
385 unsigned long ws, addr; \
386 \
387 __##pfx##flush_prologue \
388 \
389 for (ws = 0; ws < ws_end; ws += ws_inc) \
390 for (addr = start; addr < end; addr += lsize * 32) \
391 cache##lsize##_unroll32(addr|ws, indexop); \
392 \
393 __##pfx##flush_epilogue \
394}
395
396__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16)
397__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16)
398__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16)
399__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32)
400__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32)
401__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32)
402__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
403__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)
404__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
405
406__BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 16)
407__BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 32)
408__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 16)
409__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 32)
410__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 64)
411__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 128)
412
413/* build blast_xxx_range, protected_blast_xxx_range */
414#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \
415static inline void prot##blast_##pfx##cache##_range(unsigned long start, \
416 unsigned long end) \
417{ \
418 unsigned long lsize = cpu_##desc##_line_size(); \
419 unsigned long addr = start & ~(lsize - 1); \
420 unsigned long aend = (end - 1) & ~(lsize - 1); \
421 \
422 __##pfx##flush_prologue \
423 \
424 while (1) { \
425 prot##cache_op(hitop, addr); \
426 if (addr == aend) \
427 break; \
428 addr += lsize; \
429 } \
430 \
431 __##pfx##flush_epilogue \
432}
433
434__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_)
435__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_)
436__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_)
437__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, )
438__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, )
439/* blast_inv_dcache_range */
440__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, )
441__BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD, )
442
443#endif /* _ASM_R4KCACHE_H */
diff --git a/arch/mips/include/asm/reboot.h b/arch/mips/include/asm/reboot.h
new file mode 100644
index 000000000000..e48c0bfab257
--- /dev/null
+++ b/arch/mips/include/asm/reboot.h
@@ -0,0 +1,15 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1997, 1999, 2001, 06 by Ralf Baechle
7 * Copyright (C) 2001 MIPS Technologies, Inc.
8 */
9#ifndef _ASM_REBOOT_H
10#define _ASM_REBOOT_H
11
12extern void (*_machine_restart)(char *command);
13extern void (*_machine_halt)(void);
14
15#endif /* _ASM_REBOOT_H */
diff --git a/arch/mips/include/asm/reg.h b/arch/mips/include/asm/reg.h
new file mode 100644
index 000000000000..634b55d7e7f6
--- /dev/null
+++ b/arch/mips/include/asm/reg.h
@@ -0,0 +1,128 @@
1/*
2 * Various register offset definitions for debuggers, core file
3 * examiners and whatnot.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (C) 1995, 1999 Ralf Baechle
10 * Copyright (C) 1995, 1999 Silicon Graphics
11 */
12#ifndef __ASM_MIPS_REG_H
13#define __ASM_MIPS_REG_H
14
15
16#if defined(CONFIG_32BIT) || defined(WANT_COMPAT_REG_H)
17
18#define EF_R0 6
19#define EF_R1 7
20#define EF_R2 8
21#define EF_R3 9
22#define EF_R4 10
23#define EF_R5 11
24#define EF_R6 12
25#define EF_R7 13
26#define EF_R8 14
27#define EF_R9 15
28#define EF_R10 16
29#define EF_R11 17
30#define EF_R12 18
31#define EF_R13 19
32#define EF_R14 20
33#define EF_R15 21
34#define EF_R16 22
35#define EF_R17 23
36#define EF_R18 24
37#define EF_R19 25
38#define EF_R20 26
39#define EF_R21 27
40#define EF_R22 28
41#define EF_R23 29
42#define EF_R24 30
43#define EF_R25 31
44
45/*
46 * k0/k1 unsaved
47 */
48#define EF_R26 32
49#define EF_R27 33
50
51#define EF_R28 34
52#define EF_R29 35
53#define EF_R30 36
54#define EF_R31 37
55
56/*
57 * Saved special registers
58 */
59#define EF_LO 38
60#define EF_HI 39
61
62#define EF_CP0_EPC 40
63#define EF_CP0_BADVADDR 41
64#define EF_CP0_STATUS 42
65#define EF_CP0_CAUSE 43
66#define EF_UNUSED0 44
67
68#define EF_SIZE 180
69
70#endif
71
72#ifdef CONFIG_64BIT
73
74#define EF_R0 0
75#define EF_R1 1
76#define EF_R2 2
77#define EF_R3 3
78#define EF_R4 4
79#define EF_R5 5
80#define EF_R6 6
81#define EF_R7 7
82#define EF_R8 8
83#define EF_R9 9
84#define EF_R10 10
85#define EF_R11 11
86#define EF_R12 12
87#define EF_R13 13
88#define EF_R14 14
89#define EF_R15 15
90#define EF_R16 16
91#define EF_R17 17
92#define EF_R18 18
93#define EF_R19 19
94#define EF_R20 20
95#define EF_R21 21
96#define EF_R22 22
97#define EF_R23 23
98#define EF_R24 24
99#define EF_R25 25
100
101/*
102 * k0/k1 unsaved
103 */
104#define EF_R26 26
105#define EF_R27 27
106
107
108#define EF_R28 28
109#define EF_R29 29
110#define EF_R30 30
111#define EF_R31 31
112
113/*
114 * Saved special registers
115 */
116#define EF_LO 32
117#define EF_HI 33
118
119#define EF_CP0_EPC 34
120#define EF_CP0_BADVADDR 35
121#define EF_CP0_STATUS 36
122#define EF_CP0_CAUSE 37
123
124#define EF_SIZE 304 /* size in bytes */
125
126#endif /* CONFIG_64BIT */
127
128#endif /* __ASM_MIPS_REG_H */
diff --git a/arch/mips/include/asm/regdef.h b/arch/mips/include/asm/regdef.h
new file mode 100644
index 000000000000..7c8ecb6b9c40
--- /dev/null
+++ b/arch/mips/include/asm/regdef.h
@@ -0,0 +1,100 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1985 MIPS Computer Systems, Inc.
7 * Copyright (C) 1994, 95, 99, 2003 by Ralf Baechle
8 * Copyright (C) 1990 - 1992, 1999 Silicon Graphics, Inc.
9 */
10#ifndef _ASM_REGDEF_H
11#define _ASM_REGDEF_H
12
13#include <asm/sgidefs.h>
14
15#if _MIPS_SIM == _MIPS_SIM_ABI32
16
17/*
18 * Symbolic register names for 32 bit ABI
19 */
20#define zero $0 /* wired zero */
21#define AT $1 /* assembler temp - uppercase because of ".set at" */
22#define v0 $2 /* return value */
23#define v1 $3
24#define a0 $4 /* argument registers */
25#define a1 $5
26#define a2 $6
27#define a3 $7
28#define t0 $8 /* caller saved */
29#define t1 $9
30#define t2 $10
31#define t3 $11
32#define t4 $12
33#define t5 $13
34#define t6 $14
35#define t7 $15
36#define s0 $16 /* callee saved */
37#define s1 $17
38#define s2 $18
39#define s3 $19
40#define s4 $20
41#define s5 $21
42#define s6 $22
43#define s7 $23
44#define t8 $24 /* caller saved */
45#define t9 $25
46#define jp $25 /* PIC jump register */
47#define k0 $26 /* kernel scratch */
48#define k1 $27
49#define gp $28 /* global pointer */
50#define sp $29 /* stack pointer */
51#define fp $30 /* frame pointer */
52#define s8 $30 /* same like fp! */
53#define ra $31 /* return address */
54
55#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
56
57#if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
58
59#define zero $0 /* wired zero */
60#define AT $at /* assembler temp - uppercase because of ".set at" */
61#define v0 $2 /* return value - caller saved */
62#define v1 $3
63#define a0 $4 /* argument registers */
64#define a1 $5
65#define a2 $6
66#define a3 $7
67#define a4 $8 /* arg reg 64 bit; caller saved in 32 bit */
68#define ta0 $8
69#define a5 $9
70#define ta1 $9
71#define a6 $10
72#define ta2 $10
73#define a7 $11
74#define ta3 $11
75#define t0 $12 /* caller saved */
76#define t1 $13
77#define t2 $14
78#define t3 $15
79#define s0 $16 /* callee saved */
80#define s1 $17
81#define s2 $18
82#define s3 $19
83#define s4 $20
84#define s5 $21
85#define s6 $22
86#define s7 $23
87#define t8 $24 /* caller saved */
88#define t9 $25 /* callee address for PIC/temp */
89#define jp $25 /* PIC jump register */
90#define k0 $26 /* kernel temporary */
91#define k1 $27
92#define gp $28 /* global pointer - caller saved for PIC */
93#define sp $29 /* stack pointer */
94#define fp $30 /* frame pointer */
95#define s8 $30 /* callee saved */
96#define ra $31 /* return address */
97
98#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 */
99
100#endif /* _ASM_REGDEF_H */
diff --git a/arch/mips/include/asm/resource.h b/arch/mips/include/asm/resource.h
new file mode 100644
index 000000000000..87cb3085269c
--- /dev/null
+++ b/arch/mips/include/asm/resource.h
@@ -0,0 +1,35 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 96, 98, 99, 2000 by Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_RESOURCE_H
10#define _ASM_RESOURCE_H
11
12
13/*
14 * These five resource limit IDs have a MIPS/Linux-specific ordering,
15 * the rest comes from the generic header:
16 */
17#define RLIMIT_NOFILE 5 /* max number of open files */
18#define RLIMIT_AS 6 /* address space limit */
19#define RLIMIT_RSS 7 /* max resident set size */
20#define RLIMIT_NPROC 8 /* max number of processes */
21#define RLIMIT_MEMLOCK 9 /* max locked-in-memory address space */
22
23/*
24 * SuS says limits have to be unsigned.
25 * Which makes a ton more sense anyway,
26 * but we keep the old value on MIPS32,
27 * for compatibility:
28 */
29#ifdef CONFIG_32BIT
30# define RLIM_INFINITY 0x7fffffffUL
31#endif
32
33#include <asm-generic/resource.h>
34
35#endif /* _ASM_RESOURCE_H */
diff --git a/arch/mips/include/asm/rm9k-ocd.h b/arch/mips/include/asm/rm9k-ocd.h
new file mode 100644
index 000000000000..b0b80d9ecf96
--- /dev/null
+++ b/arch/mips/include/asm/rm9k-ocd.h
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2004 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#if !defined(_ASM_RM9K_OCD_H)
21#define _ASM_RM9K_OCD_H
22
23#include <linux/types.h>
24#include <linux/spinlock.h>
25#include <asm/io.h>
26
27extern volatile void __iomem * const ocd_base;
28extern volatile void __iomem * const titan_base;
29
30#define ocd_addr(__x__) (ocd_base + (__x__))
31#define titan_addr(__x__) (titan_base + (__x__))
32#define scram_addr(__x__) (scram_base + (__x__))
33
34/* OCD register access */
35#define ocd_readl(__offs__) __raw_readl(ocd_addr(__offs__))
36#define ocd_readw(__offs__) __raw_readw(ocd_addr(__offs__))
37#define ocd_readb(__offs__) __raw_readb(ocd_addr(__offs__))
38#define ocd_writel(__val__, __offs__) \
39 __raw_writel((__val__), ocd_addr(__offs__))
40#define ocd_writew(__val__, __offs__) \
41 __raw_writew((__val__), ocd_addr(__offs__))
42#define ocd_writeb(__val__, __offs__) \
43 __raw_writeb((__val__), ocd_addr(__offs__))
44
45/* TITAN register access - 32 bit-wide only */
46#define titan_readl(__offs__) __raw_readl(titan_addr(__offs__))
47#define titan_writel(__val__, __offs__) \
48 __raw_writel((__val__), titan_addr(__offs__))
49
50/* Protect access to shared TITAN registers */
51extern spinlock_t titan_lock;
52extern int titan_irqflags;
53#define lock_titan_regs() spin_lock_irqsave(&titan_lock, titan_irqflags)
54#define unlock_titan_regs() spin_unlock_irqrestore(&titan_lock, titan_irqflags)
55
56#endif /* !defined(_ASM_RM9K_OCD_H) */
diff --git a/arch/mips/include/asm/rtlx.h b/arch/mips/include/asm/rtlx.h
new file mode 100644
index 000000000000..4ca3063ed2ce
--- /dev/null
+++ b/arch/mips/include/asm/rtlx.h
@@ -0,0 +1,65 @@
1/*
2 * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved.
3 *
4 */
5
6#ifndef __ASM_RTLX_H_
7#define __ASM_RTLX_H_
8
9#include <irq.h>
10
11#define LX_NODE_BASE 10
12
13#define MIPS_CPU_RTLX_IRQ 0
14
15#define RTLX_VERSION 2
16#define RTLX_xID 0x12345600
17#define RTLX_ID (RTLX_xID | RTLX_VERSION)
18#define RTLX_CHANNELS 8
19
20#define RTLX_CHANNEL_STDIO 0
21#define RTLX_CHANNEL_DBG 1
22#define RTLX_CHANNEL_SYSIO 2
23
24extern int rtlx_open(int index, int can_sleep);
25extern int rtlx_release(int index);
26extern ssize_t rtlx_read(int index, void __user *buff, size_t count);
27extern ssize_t rtlx_write(int index, const void __user *buffer, size_t count);
28extern unsigned int rtlx_read_poll(int index, int can_sleep);
29extern unsigned int rtlx_write_poll(int index);
30
31enum rtlx_state {
32 RTLX_STATE_UNUSED = 0,
33 RTLX_STATE_INITIALISED,
34 RTLX_STATE_REMOTE_READY,
35 RTLX_STATE_OPENED
36};
37
38#define RTLX_BUFFER_SIZE 2048
39
40/* each channel supports read and write.
41 linux (vpe0) reads lx_buffer and writes rt_buffer
42 SP (vpe1) reads rt_buffer and writes lx_buffer
43*/
44struct rtlx_channel {
45 enum rtlx_state rt_state;
46 enum rtlx_state lx_state;
47
48 int buffer_size;
49
50 /* read and write indexes per buffer */
51 int rt_write, rt_read;
52 char *rt_buffer;
53
54 int lx_write, lx_read;
55 char *lx_buffer;
56};
57
58struct rtlx_info {
59 unsigned long id;
60 enum rtlx_state state;
61
62 struct rtlx_channel channel[RTLX_CHANNELS];
63};
64
65#endif /* __ASM_RTLX_H_ */
diff --git a/arch/mips/include/asm/scatterlist.h b/arch/mips/include/asm/scatterlist.h
new file mode 100644
index 000000000000..83d69fe17c9f
--- /dev/null
+++ b/arch/mips/include/asm/scatterlist.h
@@ -0,0 +1,28 @@
1#ifndef __ASM_SCATTERLIST_H
2#define __ASM_SCATTERLIST_H
3
4#include <asm/types.h>
5
6struct scatterlist {
7#ifdef CONFIG_DEBUG_SG
8 unsigned long sg_magic;
9#endif
10 unsigned long page_link;
11 unsigned int offset;
12 dma_addr_t dma_address;
13 unsigned int length;
14};
15
16/*
17 * These macros should be used after a pci_map_sg call has been done
18 * to get bus addresses of each of the SG entries and their lengths.
19 * You should only work with the number of sg entries pci_map_sg
20 * returns, or alternatively stop on the first sg_dma_len(sg) which
21 * is 0.
22 */
23#define sg_dma_address(sg) ((sg)->dma_address)
24#define sg_dma_len(sg) ((sg)->length)
25
26#define ISA_DMA_THRESHOLD (0x00ffffffUL)
27
28#endif /* __ASM_SCATTERLIST_H */
diff --git a/arch/mips/include/asm/seccomp.h b/arch/mips/include/asm/seccomp.h
new file mode 100644
index 000000000000..36ed44070256
--- /dev/null
+++ b/arch/mips/include/asm/seccomp.h
@@ -0,0 +1,37 @@
1#ifndef __ASM_SECCOMP_H
2
3#include <linux/thread_info.h>
4#include <linux/unistd.h>
5
6#define __NR_seccomp_read __NR_read
7#define __NR_seccomp_write __NR_write
8#define __NR_seccomp_exit __NR_exit
9#define __NR_seccomp_sigreturn __NR_rt_sigreturn
10
11/*
12 * Kludge alert:
13 *
14 * The generic seccomp code currently allows only a single compat ABI. Until
15 * this is fixed we priorize O32 as the compat ABI over N32.
16 */
17#ifdef CONFIG_MIPS32_O32
18
19#define TIF_32BIT TIF_32BIT_REGS
20
21#define __NR_seccomp_read_32 4003
22#define __NR_seccomp_write_32 4004
23#define __NR_seccomp_exit_32 4001
24#define __NR_seccomp_sigreturn_32 4193 /* rt_sigreturn */
25
26#elif defined(CONFIG_MIPS32_N32)
27
28#define TIF_32BIT _TIF_32BIT_ADDR
29
30#define __NR_seccomp_read_32 6000
31#define __NR_seccomp_write_32 6001
32#define __NR_seccomp_exit_32 6058
33#define __NR_seccomp_sigreturn_32 6211 /* rt_sigreturn */
34
35#endif /* CONFIG_MIPS32_O32 */
36
37#endif /* __ASM_SECCOMP_H */
diff --git a/arch/mips/include/asm/sections.h b/arch/mips/include/asm/sections.h
new file mode 100644
index 000000000000..b7e37262c246
--- /dev/null
+++ b/arch/mips/include/asm/sections.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_SECTIONS_H
2#define _ASM_SECTIONS_H
3
4#include <asm-generic/sections.h>
5
6#endif /* _ASM_SECTIONS_H */
diff --git a/arch/mips/include/asm/segment.h b/arch/mips/include/asm/segment.h
new file mode 100644
index 000000000000..92ac001fc483
--- /dev/null
+++ b/arch/mips/include/asm/segment.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_SEGMENT_H
2#define _ASM_SEGMENT_H
3
4/* Only here because we have some old header files that expect it.. */
5
6#endif /* _ASM_SEGMENT_H */
diff --git a/arch/mips/include/asm/sembuf.h b/arch/mips/include/asm/sembuf.h
new file mode 100644
index 000000000000..7281a4decaa0
--- /dev/null
+++ b/arch/mips/include/asm/sembuf.h
@@ -0,0 +1,22 @@
1#ifndef _ASM_SEMBUF_H
2#define _ASM_SEMBUF_H
3
4/*
5 * The semid64_ds structure for the MIPS architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 2 miscellaneous 64-bit values
11 */
12
13struct semid64_ds {
14 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
15 __kernel_time_t sem_otime; /* last semop time */
16 __kernel_time_t sem_ctime; /* last change time */
17 unsigned long sem_nsems; /* no. of semaphores in array */
18 unsigned long __unused1;
19 unsigned long __unused2;
20};
21
22#endif /* _ASM_SEMBUF_H */
diff --git a/arch/mips/include/asm/serial.h b/arch/mips/include/asm/serial.h
new file mode 100644
index 000000000000..c07ebd8eb9e7
--- /dev/null
+++ b/arch/mips/include/asm/serial.h
@@ -0,0 +1,22 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1999 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_SERIAL_H
10#define _ASM_SERIAL_H
11
12
13/*
14 * This assumes you have a 1.8432 MHz clock for your UART.
15 *
16 * It'd be nice if someone built a serial card with a 24.576 MHz
17 * clock, since the 16550A is capable of handling a top speed of 1.5
18 * megabits/second; but this requires the faster clock.
19 */
20#define BASE_BAUD (1843200 / 16)
21
22#endif /* _ASM_SERIAL_H */
diff --git a/arch/mips/include/asm/setup.h b/arch/mips/include/asm/setup.h
new file mode 100644
index 000000000000..e600cedda976
--- /dev/null
+++ b/arch/mips/include/asm/setup.h
@@ -0,0 +1,10 @@
1#ifndef _MIPS_SETUP_H
2#define _MIPS_SETUP_H
3
4#define COMMAND_LINE_SIZE 256
5
6#ifdef __KERNEL__
7extern void setup_early_printk(void);
8#endif /* __KERNEL__ */
9
10#endif /* __SETUP_H */
diff --git a/arch/mips/include/asm/sgi/gio.h b/arch/mips/include/asm/sgi/gio.h
new file mode 100644
index 000000000000..889cf028c95d
--- /dev/null
+++ b/arch/mips/include/asm/sgi/gio.h
@@ -0,0 +1,86 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * gio.h: Definitions for SGI GIO bus
7 *
8 * Copyright (C) 2002 Ladislav Michl
9 */
10
11#ifndef _SGI_GIO_H
12#define _SGI_GIO_H
13
14/*
15 * GIO bus addresses
16 *
17 * The Indigo and Indy have two GIO bus connectors. Indigo2 (all models) have
18 * three physical connectors, but only two slots, GFX and EXP0.
19 *
20 * There is 10MB of GIO address space for GIO64 slot devices
21 * slot# slot type address range size
22 * ----- --------- ----------------------- -----
23 * 0 GFX 0x1f000000 - 0x1f3fffff 4MB
24 * 1 EXP0 0x1f400000 - 0x1f5fffff 2MB
25 * 2 EXP1 0x1f600000 - 0x1f9fffff 4MB
26 *
27 * There are un-slotted devices, HPC, I/O and misc devices, which are grouped
28 * into the HPC address space.
29 * - MISC 0x1fb00000 - 0x1fbfffff 1MB
30 *
31 * Following space is reserved and unused
32 * - RESERVED 0x18000000 - 0x1effffff 112MB
33 *
34 * GIO bus IDs
35 *
36 * Each GIO bus device identifies itself to the system by answering a
37 * read with an "ID" value. IDs are either 8 or 32 bits long. IDs less
38 * than 128 are 8 bits long, with the most significant 24 bits read from
39 * the slot undefined.
40 *
41 * 32-bit IDs are divided into
42 * bits 0:6 the product ID; ranges from 0x00 to 0x7F.
43 * bit 7 0=GIO Product ID is 8 bits wide
44 * 1=GIO Product ID is 32 bits wide.
45 * bits 8:15 manufacturer version for the product.
46 * bit 16 0=GIO32 and GIO32-bis, 1=GIO64.
47 * bit 17 0=no ROM present
48 * 1=ROM present on this board AND next three words
49 * space define the ROM.
50 * bits 18:31 up to manufacturer.
51 *
52 * IDs above 0x50/0xd0 are of 3rd party boards.
53 *
54 * 8-bit IDs
55 * 0x01 XPI low cost FDDI
56 * 0x02 GTR TokenRing
57 * 0x04 Synchronous ISDN
58 * 0x05 ATM board [*]
59 * 0x06 Canon Interface
60 * 0x07 16 bit SCSI Card [*]
61 * 0x08 JPEG (Double Wide)
62 * 0x09 JPEG (Single Wide)
63 * 0x0a XPI mez. FDDI device 0
64 * 0x0b XPI mez. FDDI device 1
65 * 0x0c SMPTE 259M Video [*]
66 * 0x0d Babblefish Compression [*]
67 * 0x0e E-Plex 8-port Ethernet
68 * 0x30 Lyon Lamb IVAS
69 * 0xb8 GIO 100BaseTX Fast Ethernet (gfe)
70 *
71 * [*] Device provide 32-bit ID.
72 *
73 */
74
75#define GIO_ID(x) (x & 0x7f)
76#define GIO_32BIT_ID 0x80
77#define GIO_REV(x) ((x >> 8) & 0xff)
78#define GIO_64BIT_IFACE 0x10000
79#define GIO_ROM_PRESENT 0x20000
80#define GIO_VENDOR_CODE(x) ((x >> 18) & 0x3fff)
81
82#define GIO_SLOT_GFX_BASE 0x1f000000
83#define GIO_SLOT_EXP0_BASE 0x1f400000
84#define GIO_SLOT_EXP1_BASE 0x1f600000
85
86#endif /* _SGI_GIO_H */
diff --git a/arch/mips/include/asm/sgi/hpc3.h b/arch/mips/include/asm/sgi/hpc3.h
new file mode 100644
index 000000000000..c4729f531919
--- /dev/null
+++ b/arch/mips/include/asm/sgi/hpc3.h
@@ -0,0 +1,317 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * hpc3.h: Definitions for SGI HPC3 controller
7 *
8 * Copyright (C) 1996 David S. Miller
9 * Copyright (C) 1998 Ralf Baechle
10 */
11
12#ifndef _SGI_HPC3_H
13#define _SGI_HPC3_H
14
15#include <linux/types.h>
16#include <asm/page.h>
17
18/* An HPC DMA descriptor. */
19struct hpc_dma_desc {
20 u32 pbuf; /* physical address of data buffer */
21 u32 cntinfo; /* counter and info bits */
22#define HPCDMA_EOX 0x80000000 /* last desc in chain for tx */
23#define HPCDMA_EOR 0x80000000 /* last desc in chain for rx */
24#define HPCDMA_EOXP 0x40000000 /* end of packet for tx */
25#define HPCDMA_EORP 0x40000000 /* end of packet for rx */
26#define HPCDMA_XIE 0x20000000 /* irq generated when at end of this desc */
27#define HPCDMA_XIU 0x01000000 /* Tx buffer in use by CPU. */
28#define HPCDMA_EIPC 0x00ff0000 /* SEEQ ethernet special xternal bytecount */
29#define HPCDMA_ETXD 0x00008000 /* set to one by HPC when packet tx'd */
30#define HPCDMA_OWN 0x00004000 /* Denotes ring buffer ownership on rx */
31#define HPCDMA_BCNT 0x00003fff /* size in bytes of this dma buffer */
32
33 u32 pnext; /* paddr of next hpc_dma_desc if any */
34};
35
36/* The set of regs for each HPC3 PBUS DMA channel. */
37struct hpc3_pbus_dmacregs {
38 volatile u32 pbdma_bptr; /* pbus dma channel buffer ptr */
39 volatile u32 pbdma_dptr; /* pbus dma channel desc ptr */
40 u32 _unused0[0x1000/4 - 2]; /* padding */
41 volatile u32 pbdma_ctrl; /* pbus dma channel control register has
42 * copletely different meaning for read
43 * compared with write */
44 /* read */
45#define HPC3_PDMACTRL_INT 0x00000001 /* interrupt (cleared after read) */
46#define HPC3_PDMACTRL_ISACT 0x00000002 /* channel active */
47 /* write */
48#define HPC3_PDMACTRL_SEL 0x00000002 /* little endian transfer */
49#define HPC3_PDMACTRL_RCV 0x00000004 /* direction is receive */
50#define HPC3_PDMACTRL_FLSH 0x00000008 /* enable flush for receive DMA */
51#define HPC3_PDMACTRL_ACT 0x00000010 /* start dma transfer */
52#define HPC3_PDMACTRL_LD 0x00000020 /* load enable for ACT */
53#define HPC3_PDMACTRL_RT 0x00000040 /* Use realtime GIO bus servicing */
54#define HPC3_PDMACTRL_HW 0x0000ff00 /* DMA High-water mark */
55#define HPC3_PDMACTRL_FB 0x003f0000 /* Ptr to beginning of fifo */
56#define HPC3_PDMACTRL_FE 0x3f000000 /* Ptr to end of fifo */
57
58 u32 _unused1[0x1000/4 - 1]; /* padding */
59};
60
61/* The HPC3 SCSI registers, this does not include external ones. */
62struct hpc3_scsiregs {
63 volatile u32 cbptr; /* current dma buffer ptr, diagnostic use only */
64 volatile u32 ndptr; /* next dma descriptor ptr */
65 u32 _unused0[0x1000/4 - 2]; /* padding */
66 volatile u32 bcd; /* byte count info */
67#define HPC3_SBCD_BCNTMSK 0x00003fff /* bytes to transfer from/to memory */
68#define HPC3_SBCD_XIE 0x00004000 /* Send IRQ when done with cur buf */
69#define HPC3_SBCD_EOX 0x00008000 /* Indicates this is last buf in chain */
70
71 volatile u32 ctrl; /* control register */
72#define HPC3_SCTRL_IRQ 0x01 /* IRQ asserted, either dma done or parity */
73#define HPC3_SCTRL_ENDIAN 0x02 /* DMA endian mode, 0=big 1=little */
74#define HPC3_SCTRL_DIR 0x04 /* DMA direction, 1=dev2mem 0=mem2dev */
75#define HPC3_SCTRL_FLUSH 0x08 /* Tells HPC3 to flush scsi fifos */
76#define HPC3_SCTRL_ACTIVE 0x10 /* SCSI DMA channel is active */
77#define HPC3_SCTRL_AMASK 0x20 /* DMA active inhibits PIO */
78#define HPC3_SCTRL_CRESET 0x40 /* Resets dma channel and external controller */
79#define HPC3_SCTRL_PERR 0x80 /* Bad parity on HPC3 iface to scsi controller */
80
81 volatile u32 gfptr; /* current GIO fifo ptr */
82 volatile u32 dfptr; /* current device fifo ptr */
83 volatile u32 dconfig; /* DMA configuration register */
84#define HPC3_SDCFG_HCLK 0x00001 /* Enable DMA half clock mode */
85#define HPC3_SDCFG_D1 0x00006 /* Cycles to spend in D1 state */
86#define HPC3_SDCFG_D2 0x00038 /* Cycles to spend in D2 state */
87#define HPC3_SDCFG_D3 0x001c0 /* Cycles to spend in D3 state */
88#define HPC3_SDCFG_HWAT 0x00e00 /* DMA high water mark */
89#define HPC3_SDCFG_HW 0x01000 /* Enable 16-bit halfword DMA accesses to scsi */
90#define HPC3_SDCFG_SWAP 0x02000 /* Byte swap all DMA accesses */
91#define HPC3_SDCFG_EPAR 0x04000 /* Enable parity checking for DMA */
92#define HPC3_SDCFG_POLL 0x08000 /* hd_dreq polarity control */
93#define HPC3_SDCFG_ERLY 0x30000 /* hd_dreq behavior control bits */
94
95 volatile u32 pconfig; /* PIO configuration register */
96#define HPC3_SPCFG_P3 0x0003 /* Cycles to spend in P3 state */
97#define HPC3_SPCFG_P2W 0x001c /* Cycles to spend in P2 state for writes */
98#define HPC3_SPCFG_P2R 0x01e0 /* Cycles to spend in P2 state for reads */
99#define HPC3_SPCFG_P1 0x0e00 /* Cycles to spend in P1 state */
100#define HPC3_SPCFG_HW 0x1000 /* Enable 16-bit halfword PIO accesses to scsi */
101#define HPC3_SPCFG_SWAP 0x2000 /* Byte swap all PIO accesses */
102#define HPC3_SPCFG_EPAR 0x4000 /* Enable parity checking for PIO */
103#define HPC3_SPCFG_FUJI 0x8000 /* Fujitsu scsi controller mode for faster dma/pio */
104
105 u32 _unused1[0x1000/4 - 6]; /* padding */
106};
107
108/* SEEQ ethernet HPC3 registers, only one seeq per HPC3. */
109struct hpc3_ethregs {
110 /* Receiver registers. */
111 volatile u32 rx_cbptr; /* current dma buffer ptr, diagnostic use only */
112 volatile u32 rx_ndptr; /* next dma descriptor ptr */
113 u32 _unused0[0x1000/4 - 2]; /* padding */
114 volatile u32 rx_bcd; /* byte count info */
115#define HPC3_ERXBCD_BCNTMSK 0x00003fff /* bytes to be sent to memory */
116#define HPC3_ERXBCD_XIE 0x20000000 /* HPC3 interrupts cpu at end of this buf */
117#define HPC3_ERXBCD_EOX 0x80000000 /* flags this as end of descriptor chain */
118
119 volatile u32 rx_ctrl; /* control register */
120#define HPC3_ERXCTRL_STAT50 0x0000003f /* Receive status reg bits of Seeq8003 */
121#define HPC3_ERXCTRL_STAT6 0x00000040 /* Rdonly irq status */
122#define HPC3_ERXCTRL_STAT7 0x00000080 /* Rdonlt old/new status bit from Seeq */
123#define HPC3_ERXCTRL_ENDIAN 0x00000100 /* Endian for dma channel, little=1 big=0 */
124#define HPC3_ERXCTRL_ACTIVE 0x00000200 /* Tells if DMA transfer is in progress */
125#define HPC3_ERXCTRL_AMASK 0x00000400 /* Tells if ACTIVE inhibits PIO's to hpc3 */
126#define HPC3_ERXCTRL_RBO 0x00000800 /* Receive buffer overflow if set to 1 */
127
128 volatile u32 rx_gfptr; /* current GIO fifo ptr */
129 volatile u32 rx_dfptr; /* current device fifo ptr */
130 u32 _unused1; /* padding */
131 volatile u32 reset; /* reset register */
132#define HPC3_ERST_CRESET 0x1 /* Reset dma channel and external controller */
133#define HPC3_ERST_CLRIRQ 0x2 /* Clear channel interrupt */
134#define HPC3_ERST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */
135
136 volatile u32 dconfig; /* DMA configuration register */
137#define HPC3_EDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */
138#define HPC3_EDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */
139#define HPC3_EDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */
140#define HPC3_EDCFG_WCTRL 0x01000 /* Enable writes of desc into ex ctrl port */
141#define HPC3_EDCFG_FRXDC 0x02000 /* Clear eop stat bits upon rxdc, hw seeq fix */
142#define HPC3_EDCFG_FEOP 0x04000 /* Bad packet marker timeout enable */
143#define HPC3_EDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */
144#define HPC3_EDCFG_PTO 0x30000 /* Programmed timeout value for above two */
145
146 volatile u32 pconfig; /* PIO configuration register */
147#define HPC3_EPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */
148#define HPC3_EPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */
149#define HPC3_EPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */
150#define HPC3_EPCFG_TST 0x1000 /* Diagnistic ram test feature bit */
151
152 u32 _unused2[0x1000/4 - 8]; /* padding */
153
154 /* Transmitter registers. */
155 volatile u32 tx_cbptr; /* current dma buffer ptr, diagnostic use only */
156 volatile u32 tx_ndptr; /* next dma descriptor ptr */
157 u32 _unused3[0x1000/4 - 2]; /* padding */
158 volatile u32 tx_bcd; /* byte count info */
159#define HPC3_ETXBCD_BCNTMSK 0x00003fff /* bytes to be read from memory */
160#define HPC3_ETXBCD_ESAMP 0x10000000 /* if set, too late to add descriptor */
161#define HPC3_ETXBCD_XIE 0x20000000 /* Interrupt cpu at end of cur desc */
162#define HPC3_ETXBCD_EOP 0x40000000 /* Last byte of cur buf is end of packet */
163#define HPC3_ETXBCD_EOX 0x80000000 /* This buf is the end of desc chain */
164
165 volatile u32 tx_ctrl; /* control register */
166#define HPC3_ETXCTRL_STAT30 0x0000000f /* Rdonly copy of seeq tx stat reg */
167#define HPC3_ETXCTRL_STAT4 0x00000010 /* Indicate late collision occurred */
168#define HPC3_ETXCTRL_STAT75 0x000000e0 /* Rdonly irq status from seeq */
169#define HPC3_ETXCTRL_ENDIAN 0x00000100 /* DMA channel endian mode, 1=little 0=big */
170#define HPC3_ETXCTRL_ACTIVE 0x00000200 /* DMA tx channel is active */
171#define HPC3_ETXCTRL_AMASK 0x00000400 /* Indicates ACTIVE inhibits PIO's */
172
173 volatile u32 tx_gfptr; /* current GIO fifo ptr */
174 volatile u32 tx_dfptr; /* current device fifo ptr */
175 u32 _unused4[0x1000/4 - 4]; /* padding */
176};
177
178struct hpc3_regs {
179 /* First regs for the PBUS 8 dma channels. */
180 struct hpc3_pbus_dmacregs pbdma[8];
181
182 /* Now the HPC scsi registers, we get two scsi reg sets. */
183 struct hpc3_scsiregs scsi_chan0, scsi_chan1;
184
185 /* The SEEQ hpc3 ethernet dma/control registers. */
186 struct hpc3_ethregs ethregs;
187
188 /* Here are where the hpc3 fifo's can be directly accessed
189 * via PIO accesses. Under normal operation we never stick
190 * our grubby paws in here so it's just padding. */
191 u32 _unused0[0x18000/4];
192
193 /* HPC3 irq status regs. Due to a peculiar bug you need to
194 * look at two different register addresses to get at all of
195 * the status bits. The first reg can only reliably report
196 * bits 4:0 of the status, and the second reg can only
197 * reliably report bits 9:5 of the hpc3 irq status. I told
198 * you it was a peculiar bug. ;-)
199 */
200 volatile u32 istat0; /* Irq status, only bits <4:0> reliable. */
201#define HPC3_ISTAT_PBIMASK 0x0ff /* irq bits for pbus devs 0 --> 7 */
202#define HPC3_ISTAT_SC0MASK 0x100 /* irq bit for scsi channel 0 */
203#define HPC3_ISTAT_SC1MASK 0x200 /* irq bit for scsi channel 1 */
204
205 volatile u32 gio_misc; /* GIO misc control bits. */
206#define HPC3_GIOMISC_ERTIME 0x1 /* Enable external timer real time. */
207#define HPC3_GIOMISC_DENDIAN 0x2 /* dma descriptor endian, 1=lit 0=big */
208
209 u32 eeprom; /* EEPROM data reg. */
210#define HPC3_EEPROM_EPROT 0x01 /* Protect register enable */
211#define HPC3_EEPROM_CSEL 0x02 /* Chip select */
212#define HPC3_EEPROM_ECLK 0x04 /* EEPROM clock */
213#define HPC3_EEPROM_DATO 0x08 /* Data out */
214#define HPC3_EEPROM_DATI 0x10 /* Data in */
215
216 volatile u32 istat1; /* Irq status, only bits <9:5> reliable. */
217 volatile u32 bestat; /* Bus error interrupt status reg. */
218#define HPC3_BESTAT_BLMASK 0x000ff /* Bus lane where bad parity occurred */
219#define HPC3_BESTAT_CTYPE 0x00100 /* Bus cycle type, 0=PIO 1=DMA */
220#define HPC3_BESTAT_PIDSHIFT 9
221#define HPC3_BESTAT_PIDMASK 0x3f700 /* DMA channel parity identifier */
222
223 u32 _unused1[0x14000/4 - 5]; /* padding */
224
225 /* Now direct PIO per-HPC3 peripheral access to external regs. */
226 volatile u32 scsi0_ext[256]; /* SCSI channel 0 external regs */
227 u32 _unused2[0x7c00/4];
228 volatile u32 scsi1_ext[256]; /* SCSI channel 1 external regs */
229 u32 _unused3[0x7c00/4];
230 volatile u32 eth_ext[320]; /* Ethernet external registers */
231 u32 _unused4[0x3b00/4];
232
233 /* Per-peripheral device external registers and DMA/PIO control. */
234 volatile u32 pbus_extregs[16][256];
235 volatile u32 pbus_dmacfg[8][128];
236 /* Cycles to spend in D3 for reads */
237#define HPC3_DMACFG_D3R_MASK 0x00000001
238#define HPC3_DMACFG_D3R_SHIFT 0
239 /* Cycles to spend in D4 for reads */
240#define HPC3_DMACFG_D4R_MASK 0x0000001e
241#define HPC3_DMACFG_D4R_SHIFT 1
242 /* Cycles to spend in D5 for reads */
243#define HPC3_DMACFG_D5R_MASK 0x000001e0
244#define HPC3_DMACFG_D5R_SHIFT 5
245 /* Cycles to spend in D3 for writes */
246#define HPC3_DMACFG_D3W_MASK 0x00000200
247#define HPC3_DMACFG_D3W_SHIFT 9
248 /* Cycles to spend in D4 for writes */
249#define HPC3_DMACFG_D4W_MASK 0x00003c00
250#define HPC3_DMACFG_D4W_SHIFT 10
251 /* Cycles to spend in D5 for writes */
252#define HPC3_DMACFG_D5W_MASK 0x0003c000
253#define HPC3_DMACFG_D5W_SHIFT 14
254 /* Enable 16-bit DMA access mode */
255#define HPC3_DMACFG_DS16 0x00040000
256 /* Places halfwords on high 16 bits of bus */
257#define HPC3_DMACFG_EVENHI 0x00080000
258 /* Make this device real time */
259#define HPC3_DMACFG_RTIME 0x00200000
260 /* 5 bit burst count for DMA device */
261#define HPC3_DMACFG_BURST_MASK 0x07c00000
262#define HPC3_DMACFG_BURST_SHIFT 22
263 /* Use live pbus_dreq unsynchronized signal */
264#define HPC3_DMACFG_DRQLIVE 0x08000000
265 volatile u32 pbus_piocfg[16][64];
266 /* Cycles to spend in P2 state for reads */
267#define HPC3_PIOCFG_P2R_MASK 0x00001
268#define HPC3_PIOCFG_P2R_SHIFT 0
269 /* Cycles to spend in P3 state for reads */
270#define HPC3_PIOCFG_P3R_MASK 0x0001e
271#define HPC3_PIOCFG_P3R_SHIFT 1
272 /* Cycles to spend in P4 state for reads */
273#define HPC3_PIOCFG_P4R_MASK 0x001e0
274#define HPC3_PIOCFG_P4R_SHIFT 5
275 /* Cycles to spend in P2 state for writes */
276#define HPC3_PIOCFG_P2W_MASK 0x00200
277#define HPC3_PIOCFG_P2W_SHIFT 9
278 /* Cycles to spend in P3 state for writes */
279#define HPC3_PIOCFG_P3W_MASK 0x03c00
280#define HPC3_PIOCFG_P3W_SHIFT 10
281 /* Cycles to spend in P4 state for writes */
282#define HPC3_PIOCFG_P4W_MASK 0x3c000
283#define HPC3_PIOCFG_P4W_SHIFT 14
284 /* Enable 16-bit PIO accesses */
285#define HPC3_PIOCFG_DS16 0x40000
286 /* Place even address bits in bits <15:8> */
287#define HPC3_PIOCFG_EVENHI 0x80000
288
289 /* PBUS PROM control regs. */
290 volatile u32 pbus_promwe; /* PROM write enable register */
291#define HPC3_PROM_WENAB 0x1 /* Enable writes to the PROM */
292
293 u32 _unused5[0x0800/4 - 1];
294 volatile u32 pbus_promswap; /* Chip select swap reg */
295#define HPC3_PROM_SWAP 0x1 /* invert GIO addr bit to select prom0 or prom1 */
296
297 u32 _unused6[0x0800/4 - 1];
298 volatile u32 pbus_gout; /* PROM general purpose output reg */
299#define HPC3_PROM_STAT 0x1 /* General purpose status bit in gout */
300
301 u32 _unused7[0x1000/4 - 1];
302 volatile u32 rtcregs[14]; /* Dallas clock registers */
303 u32 _unused8[50];
304 volatile u32 bbram[8192-50-14]; /* Battery backed ram */
305};
306
307/*
308 * It is possible to have two HPC3's within the address space on
309 * one machine, though only having one is more likely on an Indy.
310 */
311extern struct hpc3_regs *hpc3c0, *hpc3c1;
312#define HPC3_CHIP0_BASE 0x1fb80000 /* physical */
313#define HPC3_CHIP1_BASE 0x1fb00000 /* physical */
314
315extern void sgihpc_init(void);
316
317#endif /* _SGI_HPC3_H */
diff --git a/arch/mips/include/asm/sgi/ioc.h b/arch/mips/include/asm/sgi/ioc.h
new file mode 100644
index 000000000000..343ed15f8dc4
--- /dev/null
+++ b/arch/mips/include/asm/sgi/ioc.h
@@ -0,0 +1,200 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * ioc.h: Definitions for SGI I/O Controller
7 *
8 * Copyright (C) 1996 David S. Miller
9 * Copyright (C) 1997, 1998, 1999, 2000 Ralf Baechle
10 * Copyright (C) 2001, 2003 Ladislav Michl
11 */
12
13#ifndef _SGI_IOC_H
14#define _SGI_IOC_H
15
16#include <linux/types.h>
17#include <asm/sgi/pi1.h>
18
19/*
20 * All registers are 8-bit wide alligned on 32-bit boundary. Bad things
21 * happen if you try word access them. You have been warned.
22 */
23
24struct sgioc_uart_regs {
25 u8 _ctrl1[3];
26 volatile u8 ctrl1;
27 u8 _data1[3];
28 volatile u8 data1;
29 u8 _ctrl2[3];
30 volatile u8 ctrl2;
31 u8 _data2[3];
32 volatile u8 data2;
33};
34
35struct sgioc_keyb_regs {
36 u8 _data[3];
37 volatile u8 data;
38 u8 _command[3];
39 volatile u8 command;
40};
41
42struct sgint_regs {
43 u8 _istat0[3];
44 volatile u8 istat0; /* Interrupt status zero */
45#define SGINT_ISTAT0_FFULL 0x01
46#define SGINT_ISTAT0_SCSI0 0x02
47#define SGINT_ISTAT0_SCSI1 0x04
48#define SGINT_ISTAT0_ENET 0x08
49#define SGINT_ISTAT0_GFXDMA 0x10
50#define SGINT_ISTAT0_PPORT 0x20
51#define SGINT_ISTAT0_HPC2 0x40
52#define SGINT_ISTAT0_LIO2 0x80
53 u8 _imask0[3];
54 volatile u8 imask0; /* Interrupt mask zero */
55 u8 _istat1[3];
56 volatile u8 istat1; /* Interrupt status one */
57#define SGINT_ISTAT1_ISDNI 0x01
58#define SGINT_ISTAT1_PWR 0x02
59#define SGINT_ISTAT1_ISDNH 0x04
60#define SGINT_ISTAT1_LIO3 0x08
61#define SGINT_ISTAT1_HPC3 0x10
62#define SGINT_ISTAT1_AFAIL 0x20
63#define SGINT_ISTAT1_VIDEO 0x40
64#define SGINT_ISTAT1_GIO2 0x80
65 u8 _imask1[3];
66 volatile u8 imask1; /* Interrupt mask one */
67 u8 _vmeistat[3];
68 volatile u8 vmeistat; /* VME interrupt status */
69 u8 _cmeimask0[3];
70 volatile u8 cmeimask0; /* VME interrupt mask zero */
71 u8 _cmeimask1[3];
72 volatile u8 cmeimask1; /* VME interrupt mask one */
73 u8 _cmepol[3];
74 volatile u8 cmepol; /* VME polarity */
75 u8 _tclear[3];
76 volatile u8 tclear;
77 u8 _errstat[3];
78 volatile u8 errstat; /* Error status reg, reserved on INT2 */
79 u32 _unused0[2];
80 u8 _tcnt0[3];
81 volatile u8 tcnt0; /* counter 0 */
82 u8 _tcnt1[3];
83 volatile u8 tcnt1; /* counter 1 */
84 u8 _tcnt2[3];
85 volatile u8 tcnt2; /* counter 2 */
86 u8 _tcword[3];
87 volatile u8 tcword; /* control word */
88#define SGINT_TCWORD_BCD 0x01 /* Use BCD mode for counters */
89#define SGINT_TCWORD_MMASK 0x0e /* Mode bitmask. */
90#define SGINT_TCWORD_MITC 0x00 /* IRQ on terminal count (doesn't work) */
91#define SGINT_TCWORD_MOS 0x02 /* One-shot IRQ mode. */
92#define SGINT_TCWORD_MRGEN 0x04 /* Normal rate generation */
93#define SGINT_TCWORD_MSWGEN 0x06 /* Square wave generator mode */
94#define SGINT_TCWORD_MSWST 0x08 /* Software strobe */
95#define SGINT_TCWORD_MHWST 0x0a /* Hardware strobe */
96#define SGINT_TCWORD_CMASK 0x30 /* Command mask */
97#define SGINT_TCWORD_CLAT 0x00 /* Latch command */
98#define SGINT_TCWORD_CLSB 0x10 /* LSB read/write */
99#define SGINT_TCWORD_CMSB 0x20 /* MSB read/write */
100#define SGINT_TCWORD_CALL 0x30 /* Full counter read/write */
101#define SGINT_TCWORD_CNT0 0x00 /* Select counter zero */
102#define SGINT_TCWORD_CNT1 0x40 /* Select counter one */
103#define SGINT_TCWORD_CNT2 0x80 /* Select counter two */
104#define SGINT_TCWORD_CRBCK 0xc0 /* Readback command */
105};
106
107/*
108 * The timer is the good old 8254. Unlike in PCs it's clocked at exactly 1MHz
109 */
110#define SGINT_TIMER_CLOCK 1000000
111
112/*
113 * This is the constant we're using for calibrating the counter.
114 */
115#define SGINT_TCSAMP_COUNTER ((SGINT_TIMER_CLOCK / HZ) + 255)
116
117/* We need software copies of these because they are write only. */
118extern u8 sgi_ioc_reset, sgi_ioc_write;
119
120struct sgioc_regs {
121 struct pi1_regs pport;
122 u32 _unused0[2];
123 struct sgioc_uart_regs uart;
124 struct sgioc_keyb_regs kbdmouse;
125 u8 _gcsel[3];
126 volatile u8 gcsel;
127 u8 _genctrl[3];
128 volatile u8 genctrl;
129 u8 _panel[3];
130 volatile u8 panel;
131#define SGIOC_PANEL_POWERON 0x01
132#define SGIOC_PANEL_POWERINTR 0x02
133#define SGIOC_PANEL_VOLDNINTR 0x10
134#define SGIOC_PANEL_VOLDNHOLD 0x20
135#define SGIOC_PANEL_VOLUPINTR 0x40
136#define SGIOC_PANEL_VOLUPHOLD 0x80
137 u32 _unused1;
138 u8 _sysid[3];
139 volatile u8 sysid;
140#define SGIOC_SYSID_FULLHOUSE 0x01
141#define SGIOC_SYSID_BOARDREV(x) (((x) & 0x1e) >> 1)
142#define SGIOC_SYSID_CHIPREV(x) (((x) & 0xe0) >> 5)
143 u32 _unused2;
144 u8 _read[3];
145 volatile u8 read;
146 u32 _unused3;
147 u8 _dmasel[3];
148 volatile u8 dmasel;
149#define SGIOC_DMASEL_SCLK10MHZ 0x00 /* use 10MHZ serial clock */
150#define SGIOC_DMASEL_ISDNB 0x01 /* enable isdn B */
151#define SGIOC_DMASEL_ISDNA 0x02 /* enable isdn A */
152#define SGIOC_DMASEL_PPORT 0x04 /* use parallel DMA */
153#define SGIOC_DMASEL_SCLK667MHZ 0x10 /* use 6.67MHZ serial clock */
154#define SGIOC_DMASEL_SCLKEXT 0x20 /* use external serial clock */
155 u32 _unused4;
156 u8 _reset[3];
157 volatile u8 reset;
158#define SGIOC_RESET_PPORT 0x01 /* 0=parport reset, 1=nornal */
159#define SGIOC_RESET_KBDMOUSE 0x02 /* 0=kbdmouse reset, 1=normal */
160#define SGIOC_RESET_EISA 0x04 /* 0=eisa reset, 1=normal */
161#define SGIOC_RESET_ISDN 0x08 /* 0=isdn reset, 1=normal */
162#define SGIOC_RESET_LC0OFF 0x10 /* guiness: turn led off (red, else green) */
163#define SGIOC_RESET_LC1OFF 0x20 /* guiness: turn led off (green, else amber) */
164 u32 _unused5;
165 u8 _write[3];
166 volatile u8 write;
167#define SGIOC_WRITE_NTHRESH 0x01 /* use 4.5db threshhold */
168#define SGIOC_WRITE_TPSPEED 0x02 /* use 100ohm TP speed */
169#define SGIOC_WRITE_EPSEL 0x04 /* force cable mode: 1=AUI 0=TP */
170#define SGIOC_WRITE_EASEL 0x08 /* 1=autoselect 0=manual cable selection */
171#define SGIOC_WRITE_U1AMODE 0x10 /* 1=PC 0=MAC UART mode */
172#define SGIOC_WRITE_U0AMODE 0x20 /* 1=PC 0=MAC UART mode */
173#define SGIOC_WRITE_MLO 0x40 /* 1=4.75V 0=+5V */
174#define SGIOC_WRITE_MHI 0x80 /* 1=5.25V 0=+5V */
175 u32 _unused6;
176 struct sgint_regs int3;
177 u32 _unused7[16];
178 volatile u32 extio; /* FullHouse only */
179#define EXTIO_S0_IRQ_3 0x8000 /* S0: vid.vsync */
180#define EXTIO_S0_IRQ_2 0x4000 /* S0: gfx.fifofull */
181#define EXTIO_S0_IRQ_1 0x2000 /* S0: gfx.int */
182#define EXTIO_S0_RETRACE 0x1000
183#define EXTIO_SG_IRQ_3 0x0800 /* SG: vid.vsync */
184#define EXTIO_SG_IRQ_2 0x0400 /* SG: gfx.fifofull */
185#define EXTIO_SG_IRQ_1 0x0200 /* SG: gfx.int */
186#define EXTIO_SG_RETRACE 0x0100
187#define EXTIO_GIO_33MHZ 0x0080
188#define EXTIO_EISA_BUSERR 0x0040
189#define EXTIO_MC_BUSERR 0x0020
190#define EXTIO_HPC3_BUSERR 0x0010
191#define EXTIO_S0_STAT_1 0x0008
192#define EXTIO_S0_STAT_0 0x0004
193#define EXTIO_SG_STAT_1 0x0002
194#define EXTIO_SG_STAT_0 0x0001
195};
196
197extern struct sgioc_regs *sgioc;
198extern struct sgint_regs *sgint;
199
200#endif
diff --git a/arch/mips/include/asm/sgi/ip22.h b/arch/mips/include/asm/sgi/ip22.h
new file mode 100644
index 000000000000..c0501f91719b
--- /dev/null
+++ b/arch/mips/include/asm/sgi/ip22.h
@@ -0,0 +1,78 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * ip22.h: Definitions for SGI IP22 machines
7 *
8 * Copyright (C) 1996 David S. Miller
9 * Copyright (C) 1997, 1998, 1999, 2000 Ralf Baechle
10 */
11
12#ifndef _SGI_IP22_H
13#define _SGI_IP22_H
14
15/*
16 * These are the virtual IRQ numbers, we divide all IRQ's into
17 * 'spaces', the 'space' determines where and how to enable/disable
18 * that particular IRQ on an SGI machine. HPC DMA and MC DMA interrupts
19 * are not supported this way. Driver is supposed to allocate HPC/MC
20 * interrupt as shareable and then look to proper status bit (see
21 * HAL2 driver). This will prevent many complications, trust me ;-)
22 */
23
24#include <irq.h>
25#include <asm/sgi/ioc.h>
26
27#define SGINT_EISA 0 /* 16 EISA irq levels (Indigo2) */
28#define SGINT_CPU MIPS_CPU_IRQ_BASE /* MIPS CPU define 8 interrupt sources */
29#define SGINT_LOCAL0 (SGINT_CPU+8) /* 8 local0 irq levels */
30#define SGINT_LOCAL1 (SGINT_CPU+16) /* 8 local1 irq levels */
31#define SGINT_LOCAL2 (SGINT_CPU+24) /* 8 local2 vectored irq levels */
32#define SGINT_LOCAL3 (SGINT_CPU+32) /* 8 local3 vectored irq levels */
33#define SGINT_END (SGINT_CPU+40) /* End of 'spaces' */
34
35/*
36 * Individual interrupt definitions for the Indy and Indigo2
37 */
38
39#define SGI_SOFT_0_IRQ SGINT_CPU + 0
40#define SGI_SOFT_1_IRQ SGINT_CPU + 1
41#define SGI_LOCAL_0_IRQ SGINT_CPU + 2
42#define SGI_LOCAL_1_IRQ SGINT_CPU + 3
43#define SGI_8254_0_IRQ SGINT_CPU + 4
44#define SGI_8254_1_IRQ SGINT_CPU + 5
45#define SGI_BUSERR_IRQ SGINT_CPU + 6
46#define SGI_TIMER_IRQ SGINT_CPU + 7
47
48#define SGI_FIFO_IRQ SGINT_LOCAL0 + 0 /* FIFO full */
49#define SGI_GIO_0_IRQ SGI_FIFO_IRQ /* GIO-0 */
50#define SGI_WD93_0_IRQ SGINT_LOCAL0 + 1 /* 1st onboard WD93 */
51#define SGI_WD93_1_IRQ SGINT_LOCAL0 + 2 /* 2nd onboard WD93 */
52#define SGI_ENET_IRQ SGINT_LOCAL0 + 3 /* onboard ethernet */
53#define SGI_MCDMA_IRQ SGINT_LOCAL0 + 4 /* MC DMA done */
54#define SGI_PARPORT_IRQ SGINT_LOCAL0 + 5 /* Parallel port */
55#define SGI_GIO_1_IRQ SGINT_LOCAL0 + 6 /* GE / GIO-1 / 2nd-HPC */
56#define SGI_MAP_0_IRQ SGINT_LOCAL0 + 7 /* Mappable interrupt 0 */
57
58#define SGI_GPL0_IRQ SGINT_LOCAL1 + 0 /* General Purpose LOCAL1_N<0> */
59#define SGI_PANEL_IRQ SGINT_LOCAL1 + 1 /* front panel */
60#define SGI_GPL2_IRQ SGINT_LOCAL1 + 2 /* General Purpose LOCAL1_N<2> */
61#define SGI_MAP_1_IRQ SGINT_LOCAL1 + 3 /* Mappable interrupt 1 */
62#define SGI_HPCDMA_IRQ SGINT_LOCAL1 + 4 /* HPC DMA done */
63#define SGI_ACFAIL_IRQ SGINT_LOCAL1 + 5 /* AC fail */
64#define SGI_VINO_IRQ SGINT_LOCAL1 + 6 /* Indy VINO */
65#define SGI_GIO_2_IRQ SGINT_LOCAL1 + 7 /* Vert retrace / GIO-2 */
66
67/* Mapped interrupts. These interrupts may be mapped to either 0, or 1 */
68#define SGI_VERT_IRQ SGINT_LOCAL2 + 0 /* INT3: newport vertical status */
69#define SGI_EISA_IRQ SGINT_LOCAL2 + 3 /* EISA interrupts */
70#define SGI_KEYBD_IRQ SGINT_LOCAL2 + 4 /* keyboard */
71#define SGI_SERIAL_IRQ SGINT_LOCAL2 + 5 /* onboard serial */
72
73#define ip22_is_fullhouse() (sgioc->sysid & SGIOC_SYSID_FULLHOUSE)
74
75extern unsigned short ip22_eeprom_read(unsigned int *ctrl, int reg);
76extern unsigned short ip22_nvram_read(int reg);
77
78#endif
diff --git a/arch/mips/include/asm/sgi/mc.h b/arch/mips/include/asm/sgi/mc.h
new file mode 100644
index 000000000000..1576c2394de8
--- /dev/null
+++ b/arch/mips/include/asm/sgi/mc.h
@@ -0,0 +1,231 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * mc.h: Definitions for SGI Memory Controller
7 *
8 * Copyright (C) 1996 David S. Miller
9 * Copyright (C) 1999 Ralf Baechle
10 * Copyright (C) 1999 Silicon Graphics, Inc.
11 */
12
13#ifndef _SGI_MC_H
14#define _SGI_MC_H
15
16struct sgimc_regs {
17 u32 _unused0;
18 volatile u32 cpuctrl0; /* CPU control register 0, readwrite */
19#define SGIMC_CCTRL0_REFS 0x0000000f /* REFS mask */
20#define SGIMC_CCTRL0_EREFRESH 0x00000010 /* Memory refresh enable */
21#define SGIMC_CCTRL0_EPERRGIO 0x00000020 /* GIO parity error enable */
22#define SGIMC_CCTRL0_EPERRMEM 0x00000040 /* Main mem parity error enable */
23#define SGIMC_CCTRL0_EPERRCPU 0x00000080 /* CPU bus parity error enable */
24#define SGIMC_CCTRL0_WDOG 0x00000100 /* Watchdog timer enable */
25#define SGIMC_CCTRL0_SYSINIT 0x00000200 /* System init bit */
26#define SGIMC_CCTRL0_GFXRESET 0x00000400 /* Graphics interface reset */
27#define SGIMC_CCTRL0_EISALOCK 0x00000800 /* Lock CPU from memory for EISA */
28#define SGIMC_CCTRL0_EPERRSCMD 0x00001000 /* SysCMD bus parity error enable */
29#define SGIMC_CCTRL0_IENAB 0x00002000 /* Allow interrupts from MC */
30#define SGIMC_CCTRL0_ESNOOP 0x00004000 /* Snooping I/O enable */
31#define SGIMC_CCTRL0_EPROMWR 0x00008000 /* Prom writes from cpu enable */
32#define SGIMC_CCTRL0_WRESETPMEM 0x00010000 /* Perform warm reset, preserves mem */
33#define SGIMC_CCTRL0_LENDIAN 0x00020000 /* Put MC in little-endian mode */
34#define SGIMC_CCTRL0_WRESETDMEM 0x00040000 /* Warm reset, destroys mem contents */
35#define SGIMC_CCTRL0_CMEMBADPAR 0x02000000 /* Generate bad perr from cpu to mem */
36#define SGIMC_CCTRL0_R4KNOCHKPARR 0x04000000 /* Don't chk parity on mem data reads */
37#define SGIMC_CCTRL0_GIOBTOB 0x08000000 /* Allow GIO back to back writes */
38 u32 _unused1;
39 volatile u32 cpuctrl1; /* CPU control register 1, readwrite */
40#define SGIMC_CCTRL1_EGIOTIMEO 0x00000010 /* GIO bus timeout enable */
41#define SGIMC_CCTRL1_FIXEDEHPC 0x00001000 /* Fixed HPC endianness */
42#define SGIMC_CCTRL1_LITTLEHPC 0x00002000 /* Little endian HPC */
43#define SGIMC_CCTRL1_FIXEDEEXP0 0x00004000 /* Fixed EXP0 endianness */
44#define SGIMC_CCTRL1_LITTLEEXP0 0x00008000 /* Little endian EXP0 */
45#define SGIMC_CCTRL1_FIXEDEEXP1 0x00010000 /* Fixed EXP1 endianness */
46#define SGIMC_CCTRL1_LITTLEEXP1 0x00020000 /* Little endian EXP1 */
47
48 u32 _unused2;
49 volatile u32 watchdogt; /* Watchdog reg rdonly, write clears */
50
51 u32 _unused3;
52 volatile u32 systemid; /* MC system ID register, readonly */
53#define SGIMC_SYSID_MASKREV 0x0000000f /* Revision of MC controller */
54#define SGIMC_SYSID_EPRESENT 0x00000010 /* Indicates presence of EISA bus */
55
56 u32 _unused4[3];
57 volatile u32 divider; /* Divider reg for RPSS */
58
59 u32 _unused5;
60 u32 eeprom; /* EEPROM byte reg for r4k */
61#define SGIMC_EEPROM_PRE 0x00000001 /* eeprom chip PRE pin assertion */
62#define SGIMC_EEPROM_CSEL 0x00000002 /* Active high, eeprom chip select */
63#define SGIMC_EEPROM_SECLOCK 0x00000004 /* EEPROM serial clock */
64#define SGIMC_EEPROM_SDATAO 0x00000008 /* Serial EEPROM data-out */
65#define SGIMC_EEPROM_SDATAI 0x00000010 /* Serial EEPROM data-in */
66
67 u32 _unused6[3];
68 volatile u32 rcntpre; /* Preload refresh counter */
69
70 u32 _unused7;
71 volatile u32 rcounter; /* Readonly refresh counter */
72
73 u32 _unused8[13];
74 volatile u32 giopar; /* Parameter word for GIO64 */
75#define SGIMC_GIOPAR_HPC64 0x00000001 /* HPC talks to GIO using 64-bits */
76#define SGIMC_GIOPAR_GFX64 0x00000002 /* GFX talks to GIO using 64-bits */
77#define SGIMC_GIOPAR_EXP064 0x00000004 /* EXP(slot0) talks using 64-bits */
78#define SGIMC_GIOPAR_EXP164 0x00000008 /* EXP(slot1) talks using 64-bits */
79#define SGIMC_GIOPAR_EISA64 0x00000010 /* EISA bus talks 64-bits to GIO */
80#define SGIMC_GIOPAR_HPC264 0x00000020 /* 2nd HPX talks 64-bits to GIO */
81#define SGIMC_GIOPAR_RTIMEGFX 0x00000040 /* GFX device has realtime attr */
82#define SGIMC_GIOPAR_RTIMEEXP0 0x00000080 /* EXP(slot0) has realtime attr */
83#define SGIMC_GIOPAR_RTIMEEXP1 0x00000100 /* EXP(slot1) has realtime attr */
84#define SGIMC_GIOPAR_MASTEREISA 0x00000200 /* EISA bus can act as bus master */
85#define SGIMC_GIOPAR_ONEBUS 0x00000400 /* Exists one GIO64 pipelined bus */
86#define SGIMC_GIOPAR_MASTERGFX 0x00000800 /* GFX can act as a bus master */
87#define SGIMC_GIOPAR_MASTEREXP0 0x00001000 /* EXP(slot0) can bus master */
88#define SGIMC_GIOPAR_MASTEREXP1 0x00002000 /* EXP(slot1) can bus master */
89#define SGIMC_GIOPAR_PLINEEXP0 0x00004000 /* EXP(slot0) has pipeline attr */
90#define SGIMC_GIOPAR_PLINEEXP1 0x00008000 /* EXP(slot1) has pipeline attr */
91
92 u32 _unused9;
93 volatile u32 cputp; /* CPU bus arb time period */
94
95 u32 _unused10[3];
96 volatile u32 lbursttp; /* Time period for long bursts */
97
98 /* MC chip can drive up to 4 bank 4 SIMMs each. All SIMMs in bank must
99 * be the same size. The size encoding for supported SIMMs is bellow */
100 u32 _unused11[9];
101 volatile u32 mconfig0; /* Memory config register zero */
102 u32 _unused12;
103 volatile u32 mconfig1; /* Memory config register one */
104#define SGIMC_MCONFIG_BASEADDR 0x000000ff /* Base address of bank*/
105#define SGIMC_MCONFIG_RMASK 0x00001f00 /* Ram config bitmask */
106#define SGIMC_MCONFIG_BVALID 0x00002000 /* Bank is valid */
107#define SGIMC_MCONFIG_SBANKS 0x00004000 /* Number of subbanks */
108
109 u32 _unused13;
110 volatile u32 cmacc; /* Mem access config for CPU */
111 u32 _unused14;
112 volatile u32 gmacc; /* Mem access config for GIO */
113
114 /* This define applies to both cmacc and gmacc registers above. */
115#define SGIMC_MACC_ALIASBIG 0x20000000 /* 512MB home for alias */
116
117 /* Error address/status regs from GIO and CPU perspectives. */
118 u32 _unused15;
119 volatile u32 cerr; /* Error address reg for CPU */
120 u32 _unused16;
121 volatile u32 cstat; /* Status reg for CPU */
122#define SGIMC_CSTAT_RD 0x00000100 /* read parity error */
123#define SGIMC_CSTAT_PAR 0x00000200 /* CPU parity error */
124#define SGIMC_CSTAT_ADDR 0x00000400 /* memory bus error bad addr */
125#define SGIMC_CSTAT_SYSAD_PAR 0x00000800 /* sysad parity error */
126#define SGIMC_CSTAT_SYSCMD_PAR 0x00001000 /* syscmd parity error */
127#define SGIMC_CSTAT_BAD_DATA 0x00002000 /* bad data identifier */
128#define SGIMC_CSTAT_PAR_MASK 0x00001f00 /* parity error mask */
129#define SGIMC_CSTAT_RD_PAR (SGIMC_CSTAT_RD | SGIMC_CSTAT_PAR)
130
131 u32 _unused17;
132 volatile u32 gerr; /* Error address reg for GIO */
133 u32 _unused18;
134 volatile u32 gstat; /* Status reg for GIO */
135#define SGIMC_GSTAT_RD 0x00000100 /* read parity error */
136#define SGIMC_GSTAT_WR 0x00000200 /* write parity error */
137#define SGIMC_GSTAT_TIME 0x00000400 /* GIO bus timed out */
138#define SGIMC_GSTAT_PROM 0x00000800 /* write to PROM when PROM_EN not set */
139#define SGIMC_GSTAT_ADDR 0x00001000 /* parity error on addr cycle */
140#define SGIMC_GSTAT_BC 0x00002000 /* parity error on byte count cycle */
141#define SGIMC_GSTAT_PIO_RD 0x00004000 /* read data parity on pio */
142#define SGIMC_GSTAT_PIO_WR 0x00008000 /* write data parity on pio */
143
144 /* Special hard bus locking registers. */
145 u32 _unused19;
146 volatile u32 syssembit; /* Uni-bit system semaphore */
147 u32 _unused20;
148 volatile u32 mlock; /* Global GIO memory access lock */
149 u32 _unused21;
150 volatile u32 elock; /* Locks EISA from GIO accesses */
151
152 /* GIO dma control registers. */
153 u32 _unused22[15];
154 volatile u32 gio_dma_trans; /* DMA mask to translation GIO addrs */
155 u32 _unused23;
156 volatile u32 gio_dma_sbits; /* DMA GIO addr substitution bits */
157 u32 _unused24;
158 volatile u32 dma_intr_cause; /* DMA IRQ cause indicator bits */
159 u32 _unused25;
160 volatile u32 dma_ctrl; /* Main DMA control reg */
161
162 /* DMA TLB entry 0 */
163 u32 _unused26[5];
164 volatile u32 dtlb_hi0;
165 u32 _unused27;
166 volatile u32 dtlb_lo0;
167
168 /* DMA TLB entry 1 */
169 u32 _unused28;
170 volatile u32 dtlb_hi1;
171 u32 _unused29;
172 volatile u32 dtlb_lo1;
173
174 /* DMA TLB entry 2 */
175 u32 _unused30;
176 volatile u32 dtlb_hi2;
177 u32 _unused31;
178 volatile u32 dtlb_lo2;
179
180 /* DMA TLB entry 3 */
181 u32 _unused32;
182 volatile u32 dtlb_hi3;
183 u32 _unused33;
184 volatile u32 dtlb_lo3;
185
186 u32 _unused34[0x0392];
187
188 u32 _unused35;
189 volatile u32 rpsscounter; /* Chirps at 100ns */
190
191 u32 _unused36[0x1000/4-2*4];
192
193 u32 _unused37;
194 volatile u32 maddronly; /* Address DMA goes at */
195 u32 _unused38;
196 volatile u32 maddrpdeflts; /* Same as above, plus set defaults */
197 u32 _unused39;
198 volatile u32 dmasz; /* DMA count */
199 u32 _unused40;
200 volatile u32 ssize; /* DMA stride size */
201 u32 _unused41;
202 volatile u32 gmaddronly; /* Set GIO DMA but don't start trans */
203 u32 _unused42;
204 volatile u32 dmaddnpgo; /* Set GIO DMA addr + start transfer */
205 u32 _unused43;
206 volatile u32 dmamode; /* DMA mode config bit settings */
207 u32 _unused44;
208 volatile u32 dmaccount; /* Zoom and byte count for DMA */
209 u32 _unused45;
210 volatile u32 dmastart; /* Pedal to the metal. */
211 u32 _unused46;
212 volatile u32 dmarunning; /* DMA op is in progress */
213 u32 _unused47;
214 volatile u32 maddrdefstart; /* Set dma addr, defaults, and kick it */
215};
216
217extern struct sgimc_regs *sgimc;
218#define SGIMC_BASE 0x1fa00000 /* physical */
219
220/* Base location of the two ram banks found in IP2[0268] machines. */
221#define SGIMC_SEG0_BADDR 0x08000000
222#define SGIMC_SEG1_BADDR 0x20000000
223
224/* Maximum size of the above banks are per machine. */
225#define SGIMC_SEG0_SIZE_ALL 0x10000000 /* 256MB */
226#define SGIMC_SEG1_SIZE_IP20_IP22 0x08000000 /* 128MB */
227#define SGIMC_SEG1_SIZE_IP26_IP28 0x20000000 /* 512MB */
228
229extern void sgimc_init(void);
230
231#endif /* _SGI_MC_H */
diff --git a/arch/mips/include/asm/sgi/pi1.h b/arch/mips/include/asm/sgi/pi1.h
new file mode 100644
index 000000000000..c9506915dc5c
--- /dev/null
+++ b/arch/mips/include/asm/sgi/pi1.h
@@ -0,0 +1,71 @@
1/*
2 * pi1.h: Definitions for SGI PI1 parallel port
3 */
4
5#ifndef _SGI_PI1_H
6#define _SGI_PI1_H
7
8struct pi1_regs {
9 u8 _data[3];
10 volatile u8 data;
11 u8 _ctrl[3];
12 volatile u8 ctrl;
13#define PI1_CTRL_STROBE_N 0x01
14#define PI1_CTRL_AFD_N 0x02
15#define PI1_CTRL_INIT_N 0x04
16#define PI1_CTRL_SLIN_N 0x08
17#define PI1_CTRL_IRQ_ENA 0x10
18#define PI1_CTRL_DIR 0x20
19#define PI1_CTRL_SEL 0x40
20 u8 _status[3];
21 volatile u8 status;
22#define PI1_STAT_DEVID 0x03 /* bits 0-1 */
23#define PI1_STAT_NOINK 0x04 /* SGI MODE only */
24#define PI1_STAT_ERROR 0x08
25#define PI1_STAT_ONLINE 0x10
26#define PI1_STAT_PE 0x20
27#define PI1_STAT_ACK 0x40
28#define PI1_STAT_BUSY 0x80
29 u8 _dmactrl[3];
30 volatile u8 dmactrl;
31#define PI1_DMACTRL_FIFO_EMPTY 0x01 /* fifo empty R/O */
32#define PI1_DMACTRL_ABORT 0x02 /* reset DMA and internal fifo W/O */
33#define PI1_DMACTRL_STDMODE 0x00 /* bits 2-3 */
34#define PI1_DMACTRL_SGIMODE 0x04 /* bits 2-3 */
35#define PI1_DMACTRL_RICOHMODE 0x08 /* bits 2-3 */
36#define PI1_DMACTRL_HPMODE 0x0c /* bits 2-3 */
37#define PI1_DMACTRL_BLKMODE 0x10 /* block mode */
38#define PI1_DMACTRL_FIFO_CLEAR 0x20 /* clear fifo W/O */
39#define PI1_DMACTRL_READ 0x40 /* read */
40#define PI1_DMACTRL_RUN 0x80 /* pedal to the metal */
41 u8 _intstat[3];
42 volatile u8 intstat;
43#define PI1_INTSTAT_ACK 0x04
44#define PI1_INTSTAT_FEMPTY 0x08
45#define PI1_INTSTAT_NOINK 0x10
46#define PI1_INTSTAT_ONLINE 0x20
47#define PI1_INTSTAT_ERR 0x40
48#define PI1_INTSTAT_PE 0x80
49 u8 _intmask[3];
50 volatile u8 intmask; /* enabled low, reset high*/
51#define PI1_INTMASK_ACK 0x04
52#define PI1_INTMASK_FIFO_EMPTY 0x08
53#define PI1_INTMASK_NOINK 0x10
54#define PI1_INTMASK_ONLINE 0x20
55#define PI1_INTMASK_ERR 0x40
56#define PI1_INTMASK_PE 0x80
57 u8 _timer1[3];
58 volatile u8 timer1;
59#define PI1_TIME1 0x27
60 u8 _timer2[3];
61 volatile u8 timer2;
62#define PI1_TIME2 0x13
63 u8 _timer3[3];
64 volatile u8 timer3;
65#define PI1_TIME3 0x10
66 u8 _timer4[3];
67 volatile u8 timer4;
68#define PI1_TIME4 0x00
69};
70
71#endif
diff --git a/arch/mips/include/asm/sgi/seeq.h b/arch/mips/include/asm/sgi/seeq.h
new file mode 100644
index 000000000000..af0ffd76899d
--- /dev/null
+++ b/arch/mips/include/asm/sgi/seeq.h
@@ -0,0 +1,21 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 by Ralf Baechle
7 */
8#ifndef __ASM_SGI_SEEQ_H
9#define __ASM_SGI_SEEQ_H
10
11#include <linux/if_ether.h>
12
13#include <asm/sgi/hpc3.h>
14
15struct sgiseeq_platform_data {
16 struct hpc3_regs *hpc;
17 unsigned int irq;
18 unsigned char mac[ETH_ALEN];
19};
20
21#endif /* __ASM_SGI_SEEQ_H */
diff --git a/arch/mips/include/asm/sgi/sgi.h b/arch/mips/include/asm/sgi/sgi.h
new file mode 100644
index 000000000000..645cea7c0f8e
--- /dev/null
+++ b/arch/mips/include/asm/sgi/sgi.h
@@ -0,0 +1,47 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * sgi.h: Definitions specific to SGI machines.
7 *
8 * Copyright (C) 1996 David S. Miller (dm@sgi.com)
9 */
10#ifndef _ASM_SGI_SGI_H
11#define _ASM_SGI_SGI_H
12
13/* UP=UniProcessor MP=MultiProcessor(capable) */
14enum sgi_mach {
15 ip4, /* R2k UP */
16 ip5, /* R2k MP */
17 ip6, /* R3k UP */
18 ip7, /* R3k MP */
19 ip9, /* R3k UP */
20 ip12, /* R3kA UP, Indigo */
21 ip15, /* R3kA MP */
22 ip17, /* R4K UP */
23 ip19, /* R4K MP */
24 ip20, /* R4K UP, Indigo */
25 ip21, /* TFP MP */
26 ip22, /* R4x00 UP, Indigo2 */
27 ip25, /* R10k MP */
28 ip26, /* TFP UP, Indigo2 */
29 ip27, /* R10k MP, R12k MP, Origin */
30 ip28, /* R10k UP, Indigo2 */
31 ip30, /* Octane */
32 ip32, /* O2 */
33};
34
35extern enum sgi_mach sgimach;
36extern void sgi_sysinit(void);
37
38/* Many I/O space registers are byte sized and are contained within
39 * one byte per word, specifically the MSB, this macro helps out.
40 */
41#ifdef __MIPSEL__
42#define SGI_MSB(regaddr) (regaddr)
43#else
44#define SGI_MSB(regaddr) ((regaddr) | 0x3)
45#endif
46
47#endif /* _ASM_SGI_SGI_H */
diff --git a/arch/mips/include/asm/sgi/wd.h b/arch/mips/include/asm/sgi/wd.h
new file mode 100644
index 000000000000..0d6c3a4da891
--- /dev/null
+++ b/arch/mips/include/asm/sgi/wd.h
@@ -0,0 +1,20 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 by Ralf Baechle
7 */
8#ifndef __ASM_SGI_WD_H
9#define __ASM_SGI_WD_H
10
11#include <asm/sgi/hpc3.h>
12
13struct sgiwd93_platform_data {
14 unsigned int unit;
15 unsigned int irq;
16 struct hpc3_scsiregs *hregs;
17 unsigned char *wdregs;
18};
19
20#endif /* __ASM_SGI_WD_H */
diff --git a/arch/mips/include/asm/sgialib.h b/arch/mips/include/asm/sgialib.h
new file mode 100644
index 000000000000..bfce5c786f1c
--- /dev/null
+++ b/arch/mips/include/asm/sgialib.h
@@ -0,0 +1,124 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * SGI ARCS firmware interface library for the Linux kernel.
7 *
8 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
9 * Copyright (C) 2001, 2002 Ralf Baechle (ralf@gnu.org)
10 */
11#ifndef _ASM_SGIALIB_H
12#define _ASM_SGIALIB_H
13
14#include <asm/sgiarcs.h>
15
16extern struct linux_romvec *romvec;
17extern int prom_argc;
18
19extern LONG *_prom_argv, *_prom_envp;
20
21/* A 32-bit ARC PROM pass arguments and environment as 32-bit pointer.
22 These macros take care of sign extension. */
23#define prom_argv(index) ((char *) (long) _prom_argv[(index)])
24#define prom_argc(index) ((char *) (long) _prom_argc[(index)])
25
26extern int prom_flags;
27
28#define PROM_FLAG_ARCS 1
29#define PROM_FLAG_USE_AS_CONSOLE 2
30#define PROM_FLAG_DONT_FREE_TEMP 4
31
32/* Simple char-by-char console I/O. */
33extern void prom_putchar(char c);
34extern char prom_getchar(void);
35
36/* Memory descriptor management. */
37#define PROM_MAX_PMEMBLOCKS 32
38struct prom_pmemblock {
39 LONG base; /* Within KSEG0 or XKPHYS. */
40 ULONG size; /* In bytes. */
41 ULONG type; /* free or prom memory */
42};
43
44/* Get next memory descriptor after CURR, returns first descriptor
45 * in chain is CURR is NULL.
46 */
47extern struct linux_mdesc *prom_getmdesc(struct linux_mdesc *curr);
48#define PROM_NULL_MDESC ((struct linux_mdesc *) 0)
49
50/* Called by prom_init to setup the physical memory pmemblock
51 * array.
52 */
53extern void prom_meminit(void);
54extern void prom_fixup_mem_map(unsigned long start_mem, unsigned long end_mem);
55
56/* PROM device tree library routines. */
57#define PROM_NULL_COMPONENT ((pcomponent *) 0)
58
59/* Get sibling component of THIS. */
60extern pcomponent *ArcGetPeer(pcomponent *this);
61
62/* Get child component of THIS. */
63extern pcomponent *ArcGetChild(pcomponent *this);
64
65/* Get parent component of CHILD. */
66extern pcomponent *prom_getparent(pcomponent *child);
67
68/* Copy component opaque data of component THIS into BUFFER
69 * if component THIS has opaque data. Returns success or
70 * failure status.
71 */
72extern long prom_getcdata(void *buffer, pcomponent *this);
73
74/* Other misc. component routines. */
75extern pcomponent *prom_childadd(pcomponent *this, pcomponent *tmp, void *data);
76extern long prom_delcomponent(pcomponent *this);
77extern pcomponent *prom_componentbypath(char *path);
78
79/* This is called at prom_init time to identify the
80 * ARC architecture we are running on
81 */
82extern void prom_identify_arch(void);
83
84/* Environment variable routines. */
85extern PCHAR ArcGetEnvironmentVariable(PCHAR name);
86extern LONG ArcSetEnvironmentVariable(PCHAR name, PCHAR value);
87
88/* ARCS command line acquisition and parsing. */
89extern char *prom_getcmdline(void);
90extern void prom_init_cmdline(void);
91
92/* Acquiring info about the current time, etc. */
93extern struct linux_tinfo *prom_gettinfo(void);
94extern unsigned long prom_getrtime(void);
95
96/* File operations. */
97extern long prom_getvdirent(unsigned long fd, struct linux_vdirent *ent, unsigned long num, unsigned long *cnt);
98extern long prom_open(char *name, enum linux_omode md, unsigned long *fd);
99extern long prom_close(unsigned long fd);
100extern LONG ArcRead(ULONG fd, PVOID buf, ULONG num, PULONG cnt);
101extern long prom_getrstatus(unsigned long fd);
102extern LONG ArcWrite(ULONG fd, PVOID buf, ULONG num, PULONG cnt);
103extern long prom_seek(unsigned long fd, struct linux_bigint *off, enum linux_seekmode sm);
104extern long prom_mount(char *name, enum linux_mountops op);
105extern long prom_getfinfo(unsigned long fd, struct linux_finfo *buf);
106extern long prom_setfinfo(unsigned long fd, unsigned long flags, unsigned long msk);
107
108/* Running stand-along programs. */
109extern long prom_load(char *name, unsigned long end, unsigned long *pc, unsigned long *eaddr);
110extern long prom_invoke(unsigned long pc, unsigned long sp, long argc, char **argv, char **envp);
111extern long prom_exec(char *name, long argc, char **argv, char **envp);
112
113/* Misc. routines. */
114extern VOID prom_halt(VOID) __attribute__((noreturn));
115extern VOID prom_powerdown(VOID) __attribute__((noreturn));
116extern VOID prom_restart(VOID) __attribute__((noreturn));
117extern VOID ArcReboot(VOID) __attribute__((noreturn));
118extern VOID ArcEnterInteractiveMode(VOID) __attribute__((noreturn));
119extern long prom_cfgsave(VOID);
120extern struct linux_sysid *prom_getsysid(VOID);
121extern VOID ArcFlushAllCaches(VOID);
122extern DISPLAY_STATUS *ArcGetDisplayStatus(ULONG FileID);
123
124#endif /* _ASM_SGIALIB_H */
diff --git a/arch/mips/include/asm/sgiarcs.h b/arch/mips/include/asm/sgiarcs.h
new file mode 100644
index 000000000000..721327f88601
--- /dev/null
+++ b/arch/mips/include/asm/sgiarcs.h
@@ -0,0 +1,548 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * ARC firmware interface defines.
7 *
8 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
9 * Copyright (C) 1999, 2001 Ralf Baechle (ralf@gnu.org)
10 * Copyright (C) 1999 Silicon Graphics, Inc.
11 */
12#ifndef _ASM_SGIARCS_H
13#define _ASM_SGIARCS_H
14
15#include <asm/types.h>
16#include <asm/fw/arc/types.h>
17
18/* Various ARCS error codes. */
19#define PROM_ESUCCESS 0x00
20#define PROM_E2BIG 0x01
21#define PROM_EACCESS 0x02
22#define PROM_EAGAIN 0x03
23#define PROM_EBADF 0x04
24#define PROM_EBUSY 0x05
25#define PROM_EFAULT 0x06
26#define PROM_EINVAL 0x07
27#define PROM_EIO 0x08
28#define PROM_EISDIR 0x09
29#define PROM_EMFILE 0x0a
30#define PROM_EMLINK 0x0b
31#define PROM_ENAMETOOLONG 0x0c
32#define PROM_ENODEV 0x0d
33#define PROM_ENOENT 0x0e
34#define PROM_ENOEXEC 0x0f
35#define PROM_ENOMEM 0x10
36#define PROM_ENOSPC 0x11
37#define PROM_ENOTDIR 0x12
38#define PROM_ENOTTY 0x13
39#define PROM_ENXIO 0x14
40#define PROM_EROFS 0x15
41/* SGI ARCS specific errno's. */
42#define PROM_EADDRNOTAVAIL 0x1f
43#define PROM_ETIMEDOUT 0x20
44#define PROM_ECONNABORTED 0x21
45#define PROM_ENOCONNECT 0x22
46
47/* Device classes, types, and identifiers for prom
48 * device inventory queries.
49 */
50enum linux_devclass {
51 system, processor, cache, adapter, controller, peripheral, memory
52};
53
54enum linux_devtypes {
55 /* Generic stuff. */
56 Arc, Cpu, Fpu,
57
58 /* Primary insn and data caches. */
59 picache, pdcache,
60
61 /* Secondary insn, data, and combined caches. */
62 sicache, sdcache, sccache,
63
64 memdev, eisa_adapter, tc_adapter, scsi_adapter, dti_adapter,
65 multifunc_adapter, dsk_controller, tp_controller, cdrom_controller,
66 worm_controller, serial_controller, net_controller, disp_controller,
67 parallel_controller, ptr_controller, kbd_controller, audio_controller,
68 misc_controller, disk_peripheral, flpy_peripheral, tp_peripheral,
69 modem_peripheral, monitor_peripheral, printer_peripheral,
70 ptr_peripheral, kbd_peripheral, term_peripheral, line_peripheral,
71 net_peripheral, misc_peripheral, anon
72};
73
74enum linux_identifier {
75 bogus, ronly, removable, consin, consout, input, output
76};
77
78/* A prom device tree component. */
79struct linux_component {
80 enum linux_devclass class; /* node class */
81 enum linux_devtypes type; /* node type */
82 enum linux_identifier iflags; /* node flags */
83 USHORT vers; /* node version */
84 USHORT rev; /* node revision */
85 ULONG key; /* completely magic */
86 ULONG amask; /* XXX affinity mask??? */
87 ULONG cdsize; /* size of configuration data */
88 ULONG ilen; /* length of string identifier */
89 _PULONG iname; /* string identifier */
90};
91typedef struct linux_component pcomponent;
92
93struct linux_sysid {
94 char vend[8], prod[8];
95};
96
97/* ARCS prom memory descriptors. */
98enum arcs_memtypes {
99 arcs_eblock, /* exception block */
100 arcs_rvpage, /* ARCS romvec page */
101 arcs_fcontig, /* Contiguous and free */
102 arcs_free, /* Generic free memory */
103 arcs_bmem, /* Borken memory, don't use */
104 arcs_prog, /* A loaded program resides here */
105 arcs_atmp, /* ARCS temporary storage area, wish Sparc OpenBoot told this */
106 arcs_aperm, /* ARCS permanent storage... */
107};
108
109/* ARC has slightly different types than ARCS */
110enum arc_memtypes {
111 arc_eblock, /* exception block */
112 arc_rvpage, /* romvec page */
113 arc_free, /* Generic free memory */
114 arc_bmem, /* Borken memory, don't use */
115 arc_prog, /* A loaded program resides here */
116 arc_atmp, /* temporary storage area */
117 arc_aperm, /* permanent storage */
118 arc_fcontig, /* Contiguous and free */
119};
120
121union linux_memtypes {
122 enum arcs_memtypes arcs;
123 enum arc_memtypes arc;
124};
125
126struct linux_mdesc {
127 union linux_memtypes type;
128 ULONG base;
129 ULONG pages;
130};
131
132/* Time of day descriptor. */
133struct linux_tinfo {
134 unsigned short yr;
135 unsigned short mnth;
136 unsigned short day;
137 unsigned short hr;
138 unsigned short min;
139 unsigned short sec;
140 unsigned short msec;
141};
142
143/* ARCS virtual dirents. */
144struct linux_vdirent {
145 ULONG namelen;
146 unsigned char attr;
147 char fname[32]; /* XXX imperical, should be a define */
148};
149
150/* Other stuff for files. */
151enum linux_omode {
152 rdonly, wronly, rdwr, wronly_creat, rdwr_creat,
153 wronly_ssede, rdwr_ssede, dirent, dirent_creat
154};
155
156enum linux_seekmode {
157 absolute, relative
158};
159
160enum linux_mountops {
161 media_load, media_unload
162};
163
164/* This prom has a bolixed design. */
165struct linux_bigint {
166#ifdef __MIPSEL__
167 u32 lo;
168 s32 hi;
169#else /* !(__MIPSEL__) */
170 s32 hi;
171 u32 lo;
172#endif
173};
174
175struct linux_finfo {
176 struct linux_bigint begin;
177 struct linux_bigint end;
178 struct linux_bigint cur;
179 enum linux_devtypes dtype;
180 unsigned long namelen;
181 unsigned char attr;
182 char name[32]; /* XXX imperical, should be define */
183};
184
185/* This describes the vector containing function pointers to the ARC
186 firmware functions. */
187struct linux_romvec {
188 LONG load; /* Load an executable image. */
189 LONG invoke; /* Invoke a standalong image. */
190 LONG exec; /* Load and begin execution of a
191 standalone image. */
192 LONG halt; /* Halt the machine. */
193 LONG pdown; /* Power down the machine. */
194 LONG restart; /* XXX soft reset??? */
195 LONG reboot; /* Reboot the machine. */
196 LONG imode; /* Enter PROM interactive mode. */
197 LONG _unused1; /* Was ReturnFromMain(). */
198
199 /* PROM device tree interface. */
200 LONG next_component;
201 LONG child_component;
202 LONG parent_component;
203 LONG component_data;
204 LONG child_add;
205 LONG comp_del;
206 LONG component_by_path;
207
208 /* Misc. stuff. */
209 LONG cfg_save;
210 LONG get_sysid;
211
212 /* Probing for memory. */
213 LONG get_mdesc;
214 LONG _unused2; /* was Signal() */
215
216 LONG get_tinfo;
217 LONG get_rtime;
218
219 /* File type operations. */
220 LONG get_vdirent;
221 LONG open;
222 LONG close;
223 LONG read;
224 LONG get_rstatus;
225 LONG write;
226 LONG seek;
227 LONG mount;
228
229 /* Dealing with firmware environment variables. */
230 LONG get_evar;
231 LONG set_evar;
232
233 LONG get_finfo;
234 LONG set_finfo;
235
236 /* Miscellaneous. */
237 LONG cache_flush;
238 LONG TestUnicodeCharacter; /* ARC; not sure if ARCS too */
239 LONG GetDisplayStatus;
240};
241
242/* The SGI ARCS parameter block is in a fixed location for standalone
243 * programs to access PROM facilities easily.
244 */
245typedef struct _SYSTEM_PARAMETER_BLOCK {
246 ULONG magic; /* magic cookie */
247#define PROMBLOCK_MAGIC 0x53435241
248
249 ULONG len; /* length of parm block */
250 USHORT ver; /* ARCS firmware version */
251 USHORT rev; /* ARCS firmware revision */
252 _PLONG rs_block; /* Restart block. */
253 _PLONG dbg_block; /* Debug block. */
254 _PLONG gevect; /* XXX General vector??? */
255 _PLONG utlbvect; /* XXX UTLB vector??? */
256 ULONG rveclen; /* Size of romvec struct. */
257 _PVOID romvec; /* Function interface. */
258 ULONG pveclen; /* Length of private vector. */
259 _PVOID pvector; /* Private vector. */
260 ULONG adap_cnt; /* Adapter count. */
261 ULONG adap_typ0; /* First adapter type. */
262 ULONG adap_vcnt0; /* Adapter 0 vector count. */
263 _PVOID adap_vector; /* Adapter 0 vector ptr. */
264 ULONG adap_typ1; /* Second adapter type. */
265 ULONG adap_vcnt1; /* Adapter 1 vector count. */
266 _PVOID adap_vector1; /* Adapter 1 vector ptr. */
267 /* More adapter vectors go here... */
268} SYSTEM_PARAMETER_BLOCK, *PSYSTEM_PARAMETER_BLOCK;
269
270#define PROMBLOCK ((PSYSTEM_PARAMETER_BLOCK) (int)0xA0001000)
271#define ROMVECTOR ((struct linux_romvec *) (long)(PROMBLOCK)->romvec)
272
273/* Cache layout parameter block. */
274union linux_cache_key {
275 struct param {
276#ifdef __MIPSEL__
277 unsigned short size;
278 unsigned char lsize;
279 unsigned char bsize;
280#else /* !(__MIPSEL__) */
281 unsigned char bsize;
282 unsigned char lsize;
283 unsigned short size;
284#endif
285 } info;
286 unsigned long allinfo;
287};
288
289/* Configuration data. */
290struct linux_cdata {
291 char *name;
292 int mlen;
293 enum linux_devtypes type;
294};
295
296/* Common SGI ARCS firmware file descriptors. */
297#define SGIPROM_STDIN 0
298#define SGIPROM_STDOUT 1
299
300/* Common SGI ARCS firmware file types. */
301#define SGIPROM_ROFILE 0x01 /* read-only file */
302#define SGIPROM_HFILE 0x02 /* hidden file */
303#define SGIPROM_SFILE 0x04 /* System file */
304#define SGIPROM_AFILE 0x08 /* Archive file */
305#define SGIPROM_DFILE 0x10 /* Directory file */
306#define SGIPROM_DELFILE 0x20 /* Deleted file */
307
308/* SGI ARCS boot record information. */
309struct sgi_partition {
310 unsigned char flag;
311#define SGIPART_UNUSED 0x00
312#define SGIPART_ACTIVE 0x80
313
314 unsigned char shead, ssect, scyl; /* unused */
315 unsigned char systype; /* OS type, Irix or NT */
316 unsigned char ehead, esect, ecyl; /* unused */
317 unsigned char rsect0, rsect1, rsect2, rsect3;
318 unsigned char tsect0, tsect1, tsect2, tsect3;
319};
320
321#define SGIBBLOCK_MAGIC 0xaa55
322#define SGIBBLOCK_MAXPART 0x0004
323
324struct sgi_bootblock {
325 unsigned char _unused[446];
326 struct sgi_partition partitions[SGIBBLOCK_MAXPART];
327 unsigned short magic;
328};
329
330/* BIOS parameter block. */
331struct sgi_bparm_block {
332 unsigned short bytes_sect; /* bytes per sector */
333 unsigned char sect_clust; /* sectors per cluster */
334 unsigned short sect_resv; /* reserved sectors */
335 unsigned char nfats; /* # of allocation tables */
336 unsigned short nroot_dirents; /* # of root directory entries */
337 unsigned short sect_volume; /* sectors in volume */
338 unsigned char media_type; /* media descriptor */
339 unsigned short sect_fat; /* sectors per allocation table */
340 unsigned short sect_track; /* sectors per track */
341 unsigned short nheads; /* # of heads */
342 unsigned short nhsects; /* # of hidden sectors */
343};
344
345struct sgi_bsector {
346 unsigned char jmpinfo[3];
347 unsigned char manuf_name[8];
348 struct sgi_bparm_block info;
349};
350
351/* Debugging block used with SGI symmon symbolic debugger. */
352#define SMB_DEBUG_MAGIC 0xfeeddead
353struct linux_smonblock {
354 unsigned long magic;
355 void (*handler)(void); /* Breakpoint routine. */
356 unsigned long dtable_base; /* Base addr of dbg table. */
357 int (*printf)(const char *fmt, ...);
358 unsigned long btable_base; /* Breakpoint table. */
359 unsigned long mpflushreqs; /* SMP cache flush request list. */
360 unsigned long ntab; /* Name table. */
361 unsigned long stab; /* Symbol table. */
362 int smax; /* Max # of symbols. */
363};
364
365/*
366 * Macros for calling a 32-bit ARC implementation from 64-bit code
367 */
368
369#if defined(CONFIG_64BIT) && defined(CONFIG_ARC32)
370
371#define __arc_clobbers \
372 "$2", "$3" /* ... */, "$8", "$9", "$10", "$11", \
373 "$12", "$13", "$14", "$15", "$16", "$24", "$25", "$31"
374
375#define ARC_CALL0(dest) \
376({ long __res; \
377 long __vec = (long) romvec->dest; \
378 __asm__ __volatile__( \
379 "dsubu\t$29, 32\n\t" \
380 "jalr\t%1\n\t" \
381 "daddu\t$29, 32\n\t" \
382 "move\t%0, $2" \
383 : "=r" (__res), "=r" (__vec) \
384 : "1" (__vec) \
385 : __arc_clobbers, "$4", "$5", "$6", "$7"); \
386 (unsigned long) __res; \
387})
388
389#define ARC_CALL1(dest, a1) \
390({ long __res; \
391 register signed int __a1 __asm__("$4") = (int) (long) (a1); \
392 long __vec = (long) romvec->dest; \
393 __asm__ __volatile__( \
394 "dsubu\t$29, 32\n\t" \
395 "jalr\t%1\n\t" \
396 "daddu\t$29, 32\n\t" \
397 "move\t%0, $2" \
398 : "=r" (__res), "=r" (__vec) \
399 : "1" (__vec), "r" (__a1) \
400 : __arc_clobbers, "$5", "$6", "$7"); \
401 (unsigned long) __res; \
402})
403
404#define ARC_CALL2(dest, a1, a2) \
405({ long __res; \
406 register signed int __a1 __asm__("$4") = (int) (long) (a1); \
407 register signed int __a2 __asm__("$5") = (int) (long) (a2); \
408 long __vec = (long) romvec->dest; \
409 __asm__ __volatile__( \
410 "dsubu\t$29, 32\n\t" \
411 "jalr\t%1\n\t" \
412 "daddu\t$29, 32\n\t" \
413 "move\t%0, $2" \
414 : "=r" (__res), "=r" (__vec) \
415 : "1" (__vec), "r" (__a1), "r" (__a2) \
416 : __arc_clobbers, "$6", "$7"); \
417 __res; \
418})
419
420#define ARC_CALL3(dest, a1, a2, a3) \
421({ long __res; \
422 register signed int __a1 __asm__("$4") = (int) (long) (a1); \
423 register signed int __a2 __asm__("$5") = (int) (long) (a2); \
424 register signed int __a3 __asm__("$6") = (int) (long) (a3); \
425 long __vec = (long) romvec->dest; \
426 __asm__ __volatile__( \
427 "dsubu\t$29, 32\n\t" \
428 "jalr\t%1\n\t" \
429 "daddu\t$29, 32\n\t" \
430 "move\t%0, $2" \
431 : "=r" (__res), "=r" (__vec) \
432 : "1" (__vec), "r" (__a1), "r" (__a2), "r" (__a3) \
433 : __arc_clobbers, "$7"); \
434 __res; \
435})
436
437#define ARC_CALL4(dest, a1, a2, a3, a4) \
438({ long __res; \
439 register signed int __a1 __asm__("$4") = (int) (long) (a1); \
440 register signed int __a2 __asm__("$5") = (int) (long) (a2); \
441 register signed int __a3 __asm__("$6") = (int) (long) (a3); \
442 register signed int __a4 __asm__("$7") = (int) (long) (a4); \
443 long __vec = (long) romvec->dest; \
444 __asm__ __volatile__( \
445 "dsubu\t$29, 32\n\t" \
446 "jalr\t%1\n\t" \
447 "daddu\t$29, 32\n\t" \
448 "move\t%0, $2" \
449 : "=r" (__res), "=r" (__vec) \
450 : "1" (__vec), "r" (__a1), "r" (__a2), "r" (__a3), \
451 "r" (__a4) \
452 : __arc_clobbers); \
453 __res; \
454})
455
456#define ARC_CALL5(dest, a1, a2, a3, a4, a5) \
457({ long __res; \
458 register signed int __a1 __asm__("$4") = (int) (long) (a1); \
459 register signed int __a2 __asm__("$5") = (int) (long) (a2); \
460 register signed int __a3 __asm__("$6") = (int) (long) (a3); \
461 register signed int __a4 __asm__("$7") = (int) (long) (a4); \
462 register signed int __a5 = (int) (long) (a5); \
463 long __vec = (long) romvec->dest; \
464 __asm__ __volatile__( \
465 "dsubu\t$29, 32\n\t" \
466 "sw\t%7, 16($29)\n\t" \
467 "jalr\t%1\n\t" \
468 "daddu\t$29, 32\n\t" \
469 "move\t%0, $2" \
470 : "=r" (__res), "=r" (__vec) \
471 : "1" (__vec), \
472 "r" (__a1), "r" (__a2), "r" (__a3), "r" (__a4), \
473 "r" (__a5) \
474 : __arc_clobbers); \
475 __res; \
476})
477
478#endif /* defined(CONFIG_64BIT) && defined(CONFIG_ARC32) */
479
480#if (defined(CONFIG_32BIT) && defined(CONFIG_ARC32)) || \
481 (defined(CONFIG_64BIT) && defined(CONFIG_ARC64))
482
483#define ARC_CALL0(dest) \
484({ long __res; \
485 long (*__vec)(void) = (void *) romvec->dest; \
486 \
487 __res = __vec(); \
488 __res; \
489})
490
491#define ARC_CALL1(dest, a1) \
492({ long __res; \
493 long __a1 = (long) (a1); \
494 long (*__vec)(long) = (void *) romvec->dest; \
495 \
496 __res = __vec(__a1); \
497 __res; \
498})
499
500#define ARC_CALL2(dest, a1, a2) \
501({ long __res; \
502 long __a1 = (long) (a1); \
503 long __a2 = (long) (a2); \
504 long (*__vec)(long, long) = (void *) romvec->dest; \
505 \
506 __res = __vec(__a1, __a2); \
507 __res; \
508})
509
510#define ARC_CALL3(dest, a1, a2, a3) \
511({ long __res; \
512 long __a1 = (long) (a1); \
513 long __a2 = (long) (a2); \
514 long __a3 = (long) (a3); \
515 long (*__vec)(long, long, long) = (void *) romvec->dest; \
516 \
517 __res = __vec(__a1, __a2, __a3); \
518 __res; \
519})
520
521#define ARC_CALL4(dest, a1, a2, a3, a4) \
522({ long __res; \
523 long __a1 = (long) (a1); \
524 long __a2 = (long) (a2); \
525 long __a3 = (long) (a3); \
526 long __a4 = (long) (a4); \
527 long (*__vec)(long, long, long, long) = (void *) romvec->dest; \
528 \
529 __res = __vec(__a1, __a2, __a3, __a4); \
530 __res; \
531})
532
533#define ARC_CALL5(dest, a1, a2, a3, a4, a5) \
534({ long __res; \
535 long __a1 = (long) (a1); \
536 long __a2 = (long) (a2); \
537 long __a3 = (long) (a3); \
538 long __a4 = (long) (a4); \
539 long __a5 = (long) (a5); \
540 long (*__vec)(long, long, long, long, long); \
541 __vec = (void *) romvec->dest; \
542 \
543 __res = __vec(__a1, __a2, __a3, __a4, __a5); \
544 __res; \
545})
546#endif /* both kernel and ARC either 32-bit or 64-bit */
547
548#endif /* _ASM_SGIARCS_H */
diff --git a/arch/mips/include/asm/sgidefs.h b/arch/mips/include/asm/sgidefs.h
new file mode 100644
index 000000000000..876442fcfb32
--- /dev/null
+++ b/arch/mips/include/asm/sgidefs.h
@@ -0,0 +1,44 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1999, 2001 Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
9 */
10#ifndef __ASM_SGIDEFS_H
11#define __ASM_SGIDEFS_H
12
13/*
14 * Using a Linux compiler for building Linux seems logic but not to
15 * everybody.
16 */
17#ifndef __linux__
18#error Use a Linux compiler or give up.
19#endif
20
21/*
22 * Definitions for the ISA levels
23 *
24 * With the introduction of MIPS32 / MIPS64 instruction sets definitions
25 * MIPS ISAs are no longer subsets of each other. Therefore comparisons
26 * on these symbols except with == may result in unexpected results and
27 * are forbidden!
28 */
29#define _MIPS_ISA_MIPS1 1
30#define _MIPS_ISA_MIPS2 2
31#define _MIPS_ISA_MIPS3 3
32#define _MIPS_ISA_MIPS4 4
33#define _MIPS_ISA_MIPS5 5
34#define _MIPS_ISA_MIPS32 6
35#define _MIPS_ISA_MIPS64 7
36
37/*
38 * Subprogram calling convention
39 */
40#define _MIPS_SIM_ABI32 1
41#define _MIPS_SIM_NABI32 2
42#define _MIPS_SIM_ABI64 3
43
44#endif /* __ASM_SGIDEFS_H */
diff --git a/arch/mips/include/asm/shmbuf.h b/arch/mips/include/asm/shmbuf.h
new file mode 100644
index 000000000000..f994438277bf
--- /dev/null
+++ b/arch/mips/include/asm/shmbuf.h
@@ -0,0 +1,38 @@
1#ifndef _ASM_SHMBUF_H
2#define _ASM_SHMBUF_H
3
4/*
5 * The shmid64_ds structure for the MIPS architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 2 miscellaneous 32-bit rsp. 64-bit values
11 */
12
13struct shmid64_ds {
14 struct ipc64_perm shm_perm; /* operation perms */
15 size_t shm_segsz; /* size of segment (bytes) */
16 __kernel_time_t shm_atime; /* last attach time */
17 __kernel_time_t shm_dtime; /* last detach time */
18 __kernel_time_t shm_ctime; /* last change time */
19 __kernel_pid_t shm_cpid; /* pid of creator */
20 __kernel_pid_t shm_lpid; /* pid of last operator */
21 unsigned long shm_nattch; /* no. of current attaches */
22 unsigned long __unused1;
23 unsigned long __unused2;
24};
25
26struct shminfo64 {
27 unsigned long shmmax;
28 unsigned long shmmin;
29 unsigned long shmmni;
30 unsigned long shmseg;
31 unsigned long shmall;
32 unsigned long __unused1;
33 unsigned long __unused2;
34 unsigned long __unused3;
35 unsigned long __unused4;
36};
37
38#endif /* _ASM_SHMBUF_H */
diff --git a/arch/mips/include/asm/shmparam.h b/arch/mips/include/asm/shmparam.h
new file mode 100644
index 000000000000..09290720751c
--- /dev/null
+++ b/arch/mips/include/asm/shmparam.h
@@ -0,0 +1,13 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 */
6#ifndef _ASM_SHMPARAM_H
7#define _ASM_SHMPARAM_H
8
9#define __ARCH_FORCE_SHMLBA 1
10
11#define SHMLBA 0x40000 /* attach addr a multiple of this */
12
13#endif /* _ASM_SHMPARAM_H */
diff --git a/arch/mips/include/asm/sibyte/bcm1480_int.h b/arch/mips/include/asm/sibyte/bcm1480_int.h
new file mode 100644
index 000000000000..6109557c14e9
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/bcm1480_int.h
@@ -0,0 +1,312 @@
1/* *********************************************************************
2 * BCM1280/BCM1480 Board Support Package
3 *
4 * Interrupt Mapper definitions File: bcm1480_int.h
5 *
6 * This module contains constants for manipulating the
7 * BCM1255/BCM1280/BCM1455/BCM1480's interrupt mapper and
8 * definitions for the interrupt sources.
9 *
10 * BCM1480 specification level: 1X55_1X80-UM100-D4 (11/24/03)
11 *
12 *********************************************************************
13 *
14 * Copyright 2000,2001,2002,2003
15 * Broadcom Corporation. All rights reserved.
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
31 ********************************************************************* */
32
33
34#ifndef _BCM1480_INT_H
35#define _BCM1480_INT_H
36
37#include "sb1250_defs.h"
38
39/* *********************************************************************
40 * Interrupt Mapper Constants
41 ********************************************************************* */
42
43/*
44 * The interrupt mapper deals with 128-bit logical registers that are
45 * implemented as pairs of 64-bit registers, with the "low" 64 bits in
46 * a register that has an address 0x1000 higher(!) than the
47 * corresponding "high" register.
48 *
49 * For appropriate registers, bit 0 of the "high" register is a
50 * cascade bit that summarizes (as a bit-OR) the 64 bits of the "low"
51 * register.
52 */
53
54/*
55 * This entire file uses _BCM1480_ in all the symbols because it is
56 * entirely BCM1480 specific.
57 */
58
59/*
60 * Interrupt sources (Table 22)
61 */
62
63#define K_BCM1480_INT_SOURCES 128
64
65#define _BCM1480_INT_HIGH(k) (k)
66#define _BCM1480_INT_LOW(k) ((k)+64)
67
68#define K_BCM1480_INT_ADDR_TRAP _BCM1480_INT_HIGH(1)
69#define K_BCM1480_INT_GPIO_0 _BCM1480_INT_HIGH(4)
70#define K_BCM1480_INT_GPIO_1 _BCM1480_INT_HIGH(5)
71#define K_BCM1480_INT_GPIO_2 _BCM1480_INT_HIGH(6)
72#define K_BCM1480_INT_GPIO_3 _BCM1480_INT_HIGH(7)
73#define K_BCM1480_INT_PCI_INTA _BCM1480_INT_HIGH(8)
74#define K_BCM1480_INT_PCI_INTB _BCM1480_INT_HIGH(9)
75#define K_BCM1480_INT_PCI_INTC _BCM1480_INT_HIGH(10)
76#define K_BCM1480_INT_PCI_INTD _BCM1480_INT_HIGH(11)
77#define K_BCM1480_INT_CYCLE_CP0 _BCM1480_INT_HIGH(12)
78#define K_BCM1480_INT_CYCLE_CP1 _BCM1480_INT_HIGH(13)
79#define K_BCM1480_INT_CYCLE_CP2 _BCM1480_INT_HIGH(14)
80#define K_BCM1480_INT_CYCLE_CP3 _BCM1480_INT_HIGH(15)
81#define K_BCM1480_INT_TIMER_0 _BCM1480_INT_HIGH(20)
82#define K_BCM1480_INT_TIMER_1 _BCM1480_INT_HIGH(21)
83#define K_BCM1480_INT_TIMER_2 _BCM1480_INT_HIGH(22)
84#define K_BCM1480_INT_TIMER_3 _BCM1480_INT_HIGH(23)
85#define K_BCM1480_INT_DM_CH_0 _BCM1480_INT_HIGH(28)
86#define K_BCM1480_INT_DM_CH_1 _BCM1480_INT_HIGH(29)
87#define K_BCM1480_INT_DM_CH_2 _BCM1480_INT_HIGH(30)
88#define K_BCM1480_INT_DM_CH_3 _BCM1480_INT_HIGH(31)
89#define K_BCM1480_INT_MAC_0 _BCM1480_INT_HIGH(36)
90#define K_BCM1480_INT_MAC_0_CH1 _BCM1480_INT_HIGH(37)
91#define K_BCM1480_INT_MAC_1 _BCM1480_INT_HIGH(38)
92#define K_BCM1480_INT_MAC_1_CH1 _BCM1480_INT_HIGH(39)
93#define K_BCM1480_INT_MAC_2 _BCM1480_INT_HIGH(40)
94#define K_BCM1480_INT_MAC_2_CH1 _BCM1480_INT_HIGH(41)
95#define K_BCM1480_INT_MAC_3 _BCM1480_INT_HIGH(42)
96#define K_BCM1480_INT_MAC_3_CH1 _BCM1480_INT_HIGH(43)
97#define K_BCM1480_INT_PMI_LOW _BCM1480_INT_HIGH(52)
98#define K_BCM1480_INT_PMI_HIGH _BCM1480_INT_HIGH(53)
99#define K_BCM1480_INT_PMO_LOW _BCM1480_INT_HIGH(54)
100#define K_BCM1480_INT_PMO_HIGH _BCM1480_INT_HIGH(55)
101#define K_BCM1480_INT_MBOX_0_0 _BCM1480_INT_HIGH(56)
102#define K_BCM1480_INT_MBOX_0_1 _BCM1480_INT_HIGH(57)
103#define K_BCM1480_INT_MBOX_0_2 _BCM1480_INT_HIGH(58)
104#define K_BCM1480_INT_MBOX_0_3 _BCM1480_INT_HIGH(59)
105#define K_BCM1480_INT_MBOX_1_0 _BCM1480_INT_HIGH(60)
106#define K_BCM1480_INT_MBOX_1_1 _BCM1480_INT_HIGH(61)
107#define K_BCM1480_INT_MBOX_1_2 _BCM1480_INT_HIGH(62)
108#define K_BCM1480_INT_MBOX_1_3 _BCM1480_INT_HIGH(63)
109
110#define K_BCM1480_INT_BAD_ECC _BCM1480_INT_LOW(1)
111#define K_BCM1480_INT_COR_ECC _BCM1480_INT_LOW(2)
112#define K_BCM1480_INT_IO_BUS _BCM1480_INT_LOW(3)
113#define K_BCM1480_INT_PERF_CNT _BCM1480_INT_LOW(4)
114#define K_BCM1480_INT_SW_PERF_CNT _BCM1480_INT_LOW(5)
115#define K_BCM1480_INT_TRACE_FREEZE _BCM1480_INT_LOW(6)
116#define K_BCM1480_INT_SW_TRACE_FREEZE _BCM1480_INT_LOW(7)
117#define K_BCM1480_INT_WATCHDOG_TIMER_0 _BCM1480_INT_LOW(8)
118#define K_BCM1480_INT_WATCHDOG_TIMER_1 _BCM1480_INT_LOW(9)
119#define K_BCM1480_INT_WATCHDOG_TIMER_2 _BCM1480_INT_LOW(10)
120#define K_BCM1480_INT_WATCHDOG_TIMER_3 _BCM1480_INT_LOW(11)
121#define K_BCM1480_INT_PCI_ERROR _BCM1480_INT_LOW(16)
122#define K_BCM1480_INT_PCI_RESET _BCM1480_INT_LOW(17)
123#define K_BCM1480_INT_NODE_CONTROLLER _BCM1480_INT_LOW(18)
124#define K_BCM1480_INT_HOST_BRIDGE _BCM1480_INT_LOW(19)
125#define K_BCM1480_INT_PORT_0_FATAL _BCM1480_INT_LOW(20)
126#define K_BCM1480_INT_PORT_0_NONFATAL _BCM1480_INT_LOW(21)
127#define K_BCM1480_INT_PORT_1_FATAL _BCM1480_INT_LOW(22)
128#define K_BCM1480_INT_PORT_1_NONFATAL _BCM1480_INT_LOW(23)
129#define K_BCM1480_INT_PORT_2_FATAL _BCM1480_INT_LOW(24)
130#define K_BCM1480_INT_PORT_2_NONFATAL _BCM1480_INT_LOW(25)
131#define K_BCM1480_INT_LDT_SMI _BCM1480_INT_LOW(32)
132#define K_BCM1480_INT_LDT_NMI _BCM1480_INT_LOW(33)
133#define K_BCM1480_INT_LDT_INIT _BCM1480_INT_LOW(34)
134#define K_BCM1480_INT_LDT_STARTUP _BCM1480_INT_LOW(35)
135#define K_BCM1480_INT_LDT_EXT _BCM1480_INT_LOW(36)
136#define K_BCM1480_INT_SMB_0 _BCM1480_INT_LOW(40)
137#define K_BCM1480_INT_SMB_1 _BCM1480_INT_LOW(41)
138#define K_BCM1480_INT_PCMCIA _BCM1480_INT_LOW(42)
139#define K_BCM1480_INT_UART_0 _BCM1480_INT_LOW(44)
140#define K_BCM1480_INT_UART_1 _BCM1480_INT_LOW(45)
141#define K_BCM1480_INT_UART_2 _BCM1480_INT_LOW(46)
142#define K_BCM1480_INT_UART_3 _BCM1480_INT_LOW(47)
143#define K_BCM1480_INT_GPIO_4 _BCM1480_INT_LOW(52)
144#define K_BCM1480_INT_GPIO_5 _BCM1480_INT_LOW(53)
145#define K_BCM1480_INT_GPIO_6 _BCM1480_INT_LOW(54)
146#define K_BCM1480_INT_GPIO_7 _BCM1480_INT_LOW(55)
147#define K_BCM1480_INT_GPIO_8 _BCM1480_INT_LOW(56)
148#define K_BCM1480_INT_GPIO_9 _BCM1480_INT_LOW(57)
149#define K_BCM1480_INT_GPIO_10 _BCM1480_INT_LOW(58)
150#define K_BCM1480_INT_GPIO_11 _BCM1480_INT_LOW(59)
151#define K_BCM1480_INT_GPIO_12 _BCM1480_INT_LOW(60)
152#define K_BCM1480_INT_GPIO_13 _BCM1480_INT_LOW(61)
153#define K_BCM1480_INT_GPIO_14 _BCM1480_INT_LOW(62)
154#define K_BCM1480_INT_GPIO_15 _BCM1480_INT_LOW(63)
155
156/*
157 * Mask values for each interrupt
158 */
159
160#define _BCM1480_INT_MASK(w, n) _SB_MAKEMASK(w, ((n) & 0x3F))
161#define _BCM1480_INT_MASK1(n) _SB_MAKEMASK1(((n) & 0x3F))
162#define _BCM1480_INT_OFFSET(n) (((n) & 0x40) << 6)
163
164#define M_BCM1480_INT_CASCADE _BCM1480_INT_MASK1(_BCM1480_INT_HIGH(0))
165
166#define M_BCM1480_INT_ADDR_TRAP _BCM1480_INT_MASK1(K_BCM1480_INT_ADDR_TRAP)
167#define M_BCM1480_INT_GPIO_0 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_0)
168#define M_BCM1480_INT_GPIO_1 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_1)
169#define M_BCM1480_INT_GPIO_2 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_2)
170#define M_BCM1480_INT_GPIO_3 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_3)
171#define M_BCM1480_INT_PCI_INTA _BCM1480_INT_MASK1(K_BCM1480_INT_PCI_INTA)
172#define M_BCM1480_INT_PCI_INTB _BCM1480_INT_MASK1(K_BCM1480_INT_PCI_INTB)
173#define M_BCM1480_INT_PCI_INTC _BCM1480_INT_MASK1(K_BCM1480_INT_PCI_INTC)
174#define M_BCM1480_INT_PCI_INTD _BCM1480_INT_MASK1(K_BCM1480_INT_PCI_INTD)
175#define M_BCM1480_INT_CYCLE_CP0 _BCM1480_INT_MASK1(K_BCM1480_INT_CYCLE_CP0)
176#define M_BCM1480_INT_CYCLE_CP1 _BCM1480_INT_MASK1(K_BCM1480_INT_CYCLE_CP1)
177#define M_BCM1480_INT_CYCLE_CP2 _BCM1480_INT_MASK1(K_BCM1480_INT_CYCLE_CP2)
178#define M_BCM1480_INT_CYCLE_CP3 _BCM1480_INT_MASK1(K_BCM1480_INT_CYCLE_CP3)
179#define M_BCM1480_INT_TIMER_0 _BCM1480_INT_MASK1(K_BCM1480_INT_TIMER_0)
180#define M_BCM1480_INT_TIMER_1 _BCM1480_INT_MASK1(K_BCM1480_INT_TIMER_1)
181#define M_BCM1480_INT_TIMER_2 _BCM1480_INT_MASK1(K_BCM1480_INT_TIMER_2)
182#define M_BCM1480_INT_TIMER_3 _BCM1480_INT_MASK1(K_BCM1480_INT_TIMER_3)
183#define M_BCM1480_INT_DM_CH_0 _BCM1480_INT_MASK1(K_BCM1480_INT_DM_CH_0)
184#define M_BCM1480_INT_DM_CH_1 _BCM1480_INT_MASK1(K_BCM1480_INT_DM_CH_1)
185#define M_BCM1480_INT_DM_CH_2 _BCM1480_INT_MASK1(K_BCM1480_INT_DM_CH_2)
186#define M_BCM1480_INT_DM_CH_3 _BCM1480_INT_MASK1(K_BCM1480_INT_DM_CH_3)
187#define M_BCM1480_INT_MAC_0 _BCM1480_INT_MASK1(K_BCM1480_INT_MAC_0)
188#define M_BCM1480_INT_MAC_0_CH1 _BCM1480_INT_MASK1(K_BCM1480_INT_MAC_0_CH1)
189#define M_BCM1480_INT_MAC_1 _BCM1480_INT_MASK1(K_BCM1480_INT_MAC_1)
190#define M_BCM1480_INT_MAC_1_CH1 _BCM1480_INT_MASK1(K_BCM1480_INT_MAC_1_CH1)
191#define M_BCM1480_INT_MAC_2 _BCM1480_INT_MASK1(K_BCM1480_INT_MAC_2)
192#define M_BCM1480_INT_MAC_2_CH1 _BCM1480_INT_MASK1(K_BCM1480_INT_MAC_2_CH1)
193#define M_BCM1480_INT_MAC_3 _BCM1480_INT_MASK1(K_BCM1480_INT_MAC_3)
194#define M_BCM1480_INT_MAC_3_CH1 _BCM1480_INT_MASK1(K_BCM1480_INT_MAC_3_CH1)
195#define M_BCM1480_INT_PMI_LOW _BCM1480_INT_MASK1(K_BCM1480_INT_PMI_LOW)
196#define M_BCM1480_INT_PMI_HIGH _BCM1480_INT_MASK1(K_BCM1480_INT_PMI_HIGH)
197#define M_BCM1480_INT_PMO_LOW _BCM1480_INT_MASK1(K_BCM1480_INT_PMO_LOW)
198#define M_BCM1480_INT_PMO_HIGH _BCM1480_INT_MASK1(K_BCM1480_INT_PMO_HIGH)
199#define M_BCM1480_INT_MBOX_ALL _BCM1480_INT_MASK(8, K_BCM1480_INT_MBOX_0_0)
200#define M_BCM1480_INT_MBOX_0_0 _BCM1480_INT_MASK1(K_BCM1480_INT_MBOX_0_0)
201#define M_BCM1480_INT_MBOX_0_1 _BCM1480_INT_MASK1(K_BCM1480_INT_MBOX_0_1)
202#define M_BCM1480_INT_MBOX_0_2 _BCM1480_INT_MASK1(K_BCM1480_INT_MBOX_0_2)
203#define M_BCM1480_INT_MBOX_0_3 _BCM1480_INT_MASK1(K_BCM1480_INT_MBOX_0_3)
204#define M_BCM1480_INT_MBOX_1_0 _BCM1480_INT_MASK1(K_BCM1480_INT_MBOX_1_0)
205#define M_BCM1480_INT_MBOX_1_1 _BCM1480_INT_MASK1(K_BCM1480_INT_MBOX_1_1)
206#define M_BCM1480_INT_MBOX_1_2 _BCM1480_INT_MASK1(K_BCM1480_INT_MBOX_1_2)
207#define M_BCM1480_INT_MBOX_1_3 _BCM1480_INT_MASK1(K_BCM1480_INT_MBOX_1_3)
208#define M_BCM1480_INT_BAD_ECC _BCM1480_INT_MASK1(K_BCM1480_INT_BAD_ECC)
209#define M_BCM1480_INT_COR_ECC _BCM1480_INT_MASK1(K_BCM1480_INT_COR_ECC)
210#define M_BCM1480_INT_IO_BUS _BCM1480_INT_MASK1(K_BCM1480_INT_IO_BUS)
211#define M_BCM1480_INT_PERF_CNT _BCM1480_INT_MASK1(K_BCM1480_INT_PERF_CNT)
212#define M_BCM1480_INT_SW_PERF_CNT _BCM1480_INT_MASK1(K_BCM1480_INT_SW_PERF_CNT)
213#define M_BCM1480_INT_TRACE_FREEZE _BCM1480_INT_MASK1(K_BCM1480_INT_TRACE_FREEZE)
214#define M_BCM1480_INT_SW_TRACE_FREEZE _BCM1480_INT_MASK1(K_BCM1480_INT_SW_TRACE_FREEZE)
215#define M_BCM1480_INT_WATCHDOG_TIMER_0 _BCM1480_INT_MASK1(K_BCM1480_INT_WATCHDOG_TIMER_0)
216#define M_BCM1480_INT_WATCHDOG_TIMER_1 _BCM1480_INT_MASK1(K_BCM1480_INT_WATCHDOG_TIMER_1)
217#define M_BCM1480_INT_WATCHDOG_TIMER_2 _BCM1480_INT_MASK1(K_BCM1480_INT_WATCHDOG_TIMER_2)
218#define M_BCM1480_INT_WATCHDOG_TIMER_3 _BCM1480_INT_MASK1(K_BCM1480_INT_WATCHDOG_TIMER_3)
219#define M_BCM1480_INT_PCI_ERROR _BCM1480_INT_MASK1(K_BCM1480_INT_PCI_ERROR)
220#define M_BCM1480_INT_PCI_RESET _BCM1480_INT_MASK1(K_BCM1480_INT_PCI_RESET)
221#define M_BCM1480_INT_NODE_CONTROLLER _BCM1480_INT_MASK1(K_BCM1480_INT_NODE_CONTROLLER)
222#define M_BCM1480_INT_HOST_BRIDGE _BCM1480_INT_MASK1(K_BCM1480_INT_HOST_BRIDGE)
223#define M_BCM1480_INT_PORT_0_FATAL _BCM1480_INT_MASK1(K_BCM1480_INT_PORT_0_FATAL)
224#define M_BCM1480_INT_PORT_0_NONFATAL _BCM1480_INT_MASK1(K_BCM1480_INT_PORT_0_NONFATAL)
225#define M_BCM1480_INT_PORT_1_FATAL _BCM1480_INT_MASK1(K_BCM1480_INT_PORT_1_FATAL)
226#define M_BCM1480_INT_PORT_1_NONFATAL _BCM1480_INT_MASK1(K_BCM1480_INT_PORT_1_NONFATAL)
227#define M_BCM1480_INT_PORT_2_FATAL _BCM1480_INT_MASK1(K_BCM1480_INT_PORT_2_FATAL)
228#define M_BCM1480_INT_PORT_2_NONFATAL _BCM1480_INT_MASK1(K_BCM1480_INT_PORT_2_NONFATAL)
229#define M_BCM1480_INT_LDT_SMI _BCM1480_INT_MASK1(K_BCM1480_INT_LDT_SMI)
230#define M_BCM1480_INT_LDT_NMI _BCM1480_INT_MASK1(K_BCM1480_INT_LDT_NMI)
231#define M_BCM1480_INT_LDT_INIT _BCM1480_INT_MASK1(K_BCM1480_INT_LDT_INIT)
232#define M_BCM1480_INT_LDT_STARTUP _BCM1480_INT_MASK1(K_BCM1480_INT_LDT_STARTUP)
233#define M_BCM1480_INT_LDT_EXT _BCM1480_INT_MASK1(K_BCM1480_INT_LDT_EXT)
234#define M_BCM1480_INT_SMB_0 _BCM1480_INT_MASK1(K_BCM1480_INT_SMB_0)
235#define M_BCM1480_INT_SMB_1 _BCM1480_INT_MASK1(K_BCM1480_INT_SMB_1)
236#define M_BCM1480_INT_PCMCIA _BCM1480_INT_MASK1(K_BCM1480_INT_PCMCIA)
237#define M_BCM1480_INT_UART_0 _BCM1480_INT_MASK1(K_BCM1480_INT_UART_0)
238#define M_BCM1480_INT_UART_1 _BCM1480_INT_MASK1(K_BCM1480_INT_UART_1)
239#define M_BCM1480_INT_UART_2 _BCM1480_INT_MASK1(K_BCM1480_INT_UART_2)
240#define M_BCM1480_INT_UART_3 _BCM1480_INT_MASK1(K_BCM1480_INT_UART_3)
241#define M_BCM1480_INT_GPIO_4 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_4)
242#define M_BCM1480_INT_GPIO_5 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_5)
243#define M_BCM1480_INT_GPIO_6 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_6)
244#define M_BCM1480_INT_GPIO_7 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_7)
245#define M_BCM1480_INT_GPIO_8 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_8)
246#define M_BCM1480_INT_GPIO_9 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_9)
247#define M_BCM1480_INT_GPIO_10 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_10)
248#define M_BCM1480_INT_GPIO_11 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_11)
249#define M_BCM1480_INT_GPIO_12 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_12)
250#define M_BCM1480_INT_GPIO_13 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_13)
251#define M_BCM1480_INT_GPIO_14 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_14)
252#define M_BCM1480_INT_GPIO_15 _BCM1480_INT_MASK1(K_BCM1480_INT_GPIO_15)
253
254/*
255 * Interrupt mappings (Table 18)
256 */
257
258#define K_BCM1480_INT_MAP_I0 0 /* interrupt pins on processor */
259#define K_BCM1480_INT_MAP_I1 1
260#define K_BCM1480_INT_MAP_I2 2
261#define K_BCM1480_INT_MAP_I3 3
262#define K_BCM1480_INT_MAP_I4 4
263#define K_BCM1480_INT_MAP_I5 5
264#define K_BCM1480_INT_MAP_NMI 6 /* nonmaskable */
265#define K_BCM1480_INT_MAP_DINT 7 /* debug interrupt */
266
267/*
268 * Interrupt LDT Set Register (Table 19)
269 */
270
271#define S_BCM1480_INT_HT_INTMSG 0
272#define M_BCM1480_INT_HT_INTMSG _SB_MAKEMASK(3, S_BCM1480_INT_HT_INTMSG)
273#define V_BCM1480_INT_HT_INTMSG(x) _SB_MAKEVALUE(x, S_BCM1480_INT_HT_INTMSG)
274#define G_BCM1480_INT_HT_INTMSG(x) _SB_GETVALUE(x, S_BCM1480_INT_HT_INTMSG, M_BCM1480_INT_HT_INTMSG)
275
276#define K_BCM1480_INT_HT_INTMSG_FIXED 0
277#define K_BCM1480_INT_HT_INTMSG_ARBITRATED 1
278#define K_BCM1480_INT_HT_INTMSG_SMI 2
279#define K_BCM1480_INT_HT_INTMSG_NMI 3
280#define K_BCM1480_INT_HT_INTMSG_INIT 4
281#define K_BCM1480_INT_HT_INTMSG_STARTUP 5
282#define K_BCM1480_INT_HT_INTMSG_EXTINT 6
283#define K_BCM1480_INT_HT_INTMSG_RESERVED 7
284
285#define M_BCM1480_INT_HT_TRIGGERMODE _SB_MAKEMASK1(3)
286#define V_BCM1480_INT_HT_EDGETRIGGER 0
287#define V_BCM1480_INT_HT_LEVELTRIGGER M_BCM1480_INT_HT_TRIGGERMODE
288
289#define M_BCM1480_INT_HT_DESTMODE _SB_MAKEMASK1(4)
290#define V_BCM1480_INT_HT_PHYSICALDEST 0
291#define V_BCM1480_INT_HT_LOGICALDEST M_BCM1480_INT_HT_DESTMODE
292
293#define S_BCM1480_INT_HT_INTDEST 5
294#define M_BCM1480_INT_HT_INTDEST _SB_MAKEMASK(8, S_BCM1480_INT_HT_INTDEST)
295#define V_BCM1480_INT_HT_INTDEST(x) _SB_MAKEVALUE(x, S_BCM1480_INT_HT_INTDEST)
296#define G_BCM1480_INT_HT_INTDEST(x) _SB_GETVALUE(x, S_BCM1480_INT_HT_INTDEST, M_BCM1480_INT_HT_INTDEST)
297
298#define S_BCM1480_INT_HT_VECTOR 13
299#define M_BCM1480_INT_HT_VECTOR _SB_MAKEMASK(8, S_BCM1480_INT_HT_VECTOR)
300#define V_BCM1480_INT_HT_VECTOR(x) _SB_MAKEVALUE(x, S_BCM1480_INT_HT_VECTOR)
301#define G_BCM1480_INT_HT_VECTOR(x) _SB_GETVALUE(x, S_BCM1480_INT_HT_VECTOR, M_BCM1480_INT_HT_VECTOR)
302
303/*
304 * Vector prefix (Table 4-7)
305 */
306
307#define M_BCM1480_HTVECT_RAISE_INTLDT_HIGH 0x00
308#define M_BCM1480_HTVECT_RAISE_MBOX_0 0x40
309#define M_BCM1480_HTVECT_RAISE_INTLDT_LO 0x80
310#define M_BCM1480_HTVECT_RAISE_MBOX_1 0xC0
311
312#endif /* _BCM1480_INT_H */
diff --git a/arch/mips/include/asm/sibyte/bcm1480_l2c.h b/arch/mips/include/asm/sibyte/bcm1480_l2c.h
new file mode 100644
index 000000000000..fd75817f7ac4
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/bcm1480_l2c.h
@@ -0,0 +1,176 @@
1/* *********************************************************************
2 * BCM1280/BCM1480 Board Support Package
3 *
4 * L2 Cache constants and macros File: bcm1480_l2c.h
5 *
6 * This module contains constants useful for manipulating the
7 * level 2 cache.
8 *
9 * BCM1400 specification level: 1280-UM100-D2 (11/14/03)
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _BCM1480_L2C_H
34#define _BCM1480_L2C_H
35
36#include "sb1250_defs.h"
37
38/*
39 * Format of level 2 cache management address (Table 55)
40 */
41
42#define S_BCM1480_L2C_MGMT_INDEX 5
43#define M_BCM1480_L2C_MGMT_INDEX _SB_MAKEMASK(12, S_BCM1480_L2C_MGMT_INDEX)
44#define V_BCM1480_L2C_MGMT_INDEX(x) _SB_MAKEVALUE(x, S_BCM1480_L2C_MGMT_INDEX)
45#define G_BCM1480_L2C_MGMT_INDEX(x) _SB_GETVALUE(x, S_BCM1480_L2C_MGMT_INDEX, M_BCM1480_L2C_MGMT_INDEX)
46
47#define S_BCM1480_L2C_MGMT_WAY 17
48#define M_BCM1480_L2C_MGMT_WAY _SB_MAKEMASK(3, S_BCM1480_L2C_MGMT_WAY)
49#define V_BCM1480_L2C_MGMT_WAY(x) _SB_MAKEVALUE(x, S_BCM1480_L2C_MGMT_WAY)
50#define G_BCM1480_L2C_MGMT_WAY(x) _SB_GETVALUE(x, S_BCM1480_L2C_MGMT_WAY, M_BCM1480_L2C_MGMT_WAY)
51
52#define M_BCM1480_L2C_MGMT_DIRTY _SB_MAKEMASK1(20)
53#define M_BCM1480_L2C_MGMT_VALID _SB_MAKEMASK1(21)
54
55#define S_BCM1480_L2C_MGMT_ECC_DIAG 22
56#define M_BCM1480_L2C_MGMT_ECC_DIAG _SB_MAKEMASK(2, S_BCM1480_L2C_MGMT_ECC_DIAG)
57#define V_BCM1480_L2C_MGMT_ECC_DIAG(x) _SB_MAKEVALUE(x, S_BCM1480_L2C_MGMT_ECC_DIAG)
58#define G_BCM1480_L2C_MGMT_ECC_DIAG(x) _SB_GETVALUE(x, S_BCM1480_L2C_MGMT_ECC_DIAG, M_BCM1480_L2C_MGMT_ECC_DIAG)
59
60#define A_BCM1480_L2C_MGMT_TAG_BASE 0x00D0000000
61
62#define BCM1480_L2C_ENTRIES_PER_WAY 4096
63#define BCM1480_L2C_NUM_WAYS 8
64
65
66/*
67 * Level 2 Cache Tag register (Table 59)
68 */
69
70#define S_BCM1480_L2C_TAG_MBZ 0
71#define M_BCM1480_L2C_TAG_MBZ _SB_MAKEMASK(5, S_BCM1480_L2C_TAG_MBZ)
72
73#define S_BCM1480_L2C_TAG_INDEX 5
74#define M_BCM1480_L2C_TAG_INDEX _SB_MAKEMASK(12, S_BCM1480_L2C_TAG_INDEX)
75#define V_BCM1480_L2C_TAG_INDEX(x) _SB_MAKEVALUE(x, S_BCM1480_L2C_TAG_INDEX)
76#define G_BCM1480_L2C_TAG_INDEX(x) _SB_GETVALUE(x, S_BCM1480_L2C_TAG_INDEX, M_BCM1480_L2C_TAG_INDEX)
77
78/* Note that index bit 16 is also tag bit 40 */
79#define S_BCM1480_L2C_TAG_TAG 17
80#define M_BCM1480_L2C_TAG_TAG _SB_MAKEMASK(23, S_BCM1480_L2C_TAG_TAG)
81#define V_BCM1480_L2C_TAG_TAG(x) _SB_MAKEVALUE(x, S_BCM1480_L2C_TAG_TAG)
82#define G_BCM1480_L2C_TAG_TAG(x) _SB_GETVALUE(x, S_BCM1480_L2C_TAG_TAG, M_BCM1480_L2C_TAG_TAG)
83
84#define S_BCM1480_L2C_TAG_ECC 40
85#define M_BCM1480_L2C_TAG_ECC _SB_MAKEMASK(6, S_BCM1480_L2C_TAG_ECC)
86#define V_BCM1480_L2C_TAG_ECC(x) _SB_MAKEVALUE(x, S_BCM1480_L2C_TAG_ECC)
87#define G_BCM1480_L2C_TAG_ECC(x) _SB_GETVALUE(x, S_BCM1480_L2C_TAG_ECC, M_BCM1480_L2C_TAG_ECC)
88
89#define S_BCM1480_L2C_TAG_WAY 46
90#define M_BCM1480_L2C_TAG_WAY _SB_MAKEMASK(3, S_BCM1480_L2C_TAG_WAY)
91#define V_BCM1480_L2C_TAG_WAY(x) _SB_MAKEVALUE(x, S_BCM1480_L2C_TAG_WAY)
92#define G_BCM1480_L2C_TAG_WAY(x) _SB_GETVALUE(x, S_BCM1480_L2C_TAG_WAY, M_BCM1480_L2C_TAG_WAY)
93
94#define M_BCM1480_L2C_TAG_DIRTY _SB_MAKEMASK1(49)
95#define M_BCM1480_L2C_TAG_VALID _SB_MAKEMASK1(50)
96
97#define S_BCM1480_L2C_DATA_ECC 51
98#define M_BCM1480_L2C_DATA_ECC _SB_MAKEMASK(10, S_BCM1480_L2C_DATA_ECC)
99#define V_BCM1480_L2C_DATA_ECC(x) _SB_MAKEVALUE(x, S_BCM1480_L2C_DATA_ECC)
100#define G_BCM1480_L2C_DATA_ECC(x) _SB_GETVALUE(x, S_BCM1480_L2C_DATA_ECC, M_BCM1480_L2C_DATA_ECC)
101
102
103/*
104 * L2 Misc0 Value Register (Table 60)
105 */
106
107#define S_BCM1480_L2C_MISC0_WAY_REMOTE 0
108#define M_BCM1480_L2C_MISC0_WAY_REMOTE _SB_MAKEMASK(8, S_BCM1480_L2C_MISC0_WAY_REMOTE)
109#define G_BCM1480_L2C_MISC0_WAY_REMOTE(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC0_WAY_REMOTE, M_BCM1480_L2C_MISC0_WAY_REMOTE)
110
111#define S_BCM1480_L2C_MISC0_WAY_LOCAL 8
112#define M_BCM1480_L2C_MISC0_WAY_LOCAL _SB_MAKEMASK(8, S_BCM1480_L2C_MISC0_WAY_LOCAL)
113#define G_BCM1480_L2C_MISC0_WAY_LOCAL(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC0_WAY_LOCAL, M_BCM1480_L2C_MISC0_WAY_LOCAL)
114
115#define S_BCM1480_L2C_MISC0_WAY_ENABLE 16
116#define M_BCM1480_L2C_MISC0_WAY_ENABLE _SB_MAKEMASK(8, S_BCM1480_L2C_MISC0_WAY_ENABLE)
117#define G_BCM1480_L2C_MISC0_WAY_ENABLE(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC0_WAY_ENABLE, M_BCM1480_L2C_MISC0_WAY_ENABLE)
118
119#define S_BCM1480_L2C_MISC0_CACHE_DISABLE 24
120#define M_BCM1480_L2C_MISC0_CACHE_DISABLE _SB_MAKEMASK(2, S_BCM1480_L2C_MISC0_CACHE_DISABLE)
121#define G_BCM1480_L2C_MISC0_CACHE_DISABLE(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC0_CACHE_DISABLE, M_BCM1480_L2C_MISC0_CACHE_DISABLE)
122
123#define S_BCM1480_L2C_MISC0_CACHE_QUAD 26
124#define M_BCM1480_L2C_MISC0_CACHE_QUAD _SB_MAKEMASK(2, S_BCM1480_L2C_MISC0_CACHE_QUAD)
125#define G_BCM1480_L2C_MISC0_CACHE_QUAD(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC0_CACHE_QUAD, M_BCM1480_L2C_MISC0_CACHE_QUAD)
126
127#define S_BCM1480_L2C_MISC0_MC_PRIORITY 30
128#define M_BCM1480_L2C_MISC0_MC_PRIORITY _SB_MAKEMASK1(S_BCM1480_L2C_MISC0_MC_PRIORITY)
129
130#define S_BCM1480_L2C_MISC0_ECC_CLEANUP 31
131#define M_BCM1480_L2C_MISC0_ECC_CLEANUP _SB_MAKEMASK1(S_BCM1480_L2C_MISC0_ECC_CLEANUP)
132
133
134/*
135 * L2 Misc1 Value Register (Table 60)
136 */
137
138#define S_BCM1480_L2C_MISC1_WAY_AGENT_0 0
139#define M_BCM1480_L2C_MISC1_WAY_AGENT_0 _SB_MAKEMASK(8, S_BCM1480_L2C_MISC1_WAY_AGENT_0)
140#define G_BCM1480_L2C_MISC1_WAY_AGENT_0(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC1_WAY_AGENT_0, M_BCM1480_L2C_MISC1_WAY_AGENT_0)
141
142#define S_BCM1480_L2C_MISC1_WAY_AGENT_1 8
143#define M_BCM1480_L2C_MISC1_WAY_AGENT_1 _SB_MAKEMASK(8, S_BCM1480_L2C_MISC1_WAY_AGENT_1)
144#define G_BCM1480_L2C_MISC1_WAY_AGENT_1(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC1_WAY_AGENT_1, M_BCM1480_L2C_MISC1_WAY_AGENT_1)
145
146#define S_BCM1480_L2C_MISC1_WAY_AGENT_2 16
147#define M_BCM1480_L2C_MISC1_WAY_AGENT_2 _SB_MAKEMASK(8, S_BCM1480_L2C_MISC1_WAY_AGENT_2)
148#define G_BCM1480_L2C_MISC1_WAY_AGENT_2(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC1_WAY_AGENT_2, M_BCM1480_L2C_MISC1_WAY_AGENT_2)
149
150#define S_BCM1480_L2C_MISC1_WAY_AGENT_3 24
151#define M_BCM1480_L2C_MISC1_WAY_AGENT_3 _SB_MAKEMASK(8, S_BCM1480_L2C_MISC1_WAY_AGENT_3)
152#define G_BCM1480_L2C_MISC1_WAY_AGENT_3(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC1_WAY_AGENT_3, M_BCM1480_L2C_MISC1_WAY_AGENT_3)
153
154#define S_BCM1480_L2C_MISC1_WAY_AGENT_4 32
155#define M_BCM1480_L2C_MISC1_WAY_AGENT_4 _SB_MAKEMASK(8, S_BCM1480_L2C_MISC1_WAY_AGENT_4)
156#define G_BCM1480_L2C_MISC1_WAY_AGENT_4(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC1_WAY_AGENT_4, M_BCM1480_L2C_MISC1_WAY_AGENT_4)
157
158
159/*
160 * L2 Misc2 Value Register (Table 60)
161 */
162
163#define S_BCM1480_L2C_MISC2_WAY_AGENT_8 0
164#define M_BCM1480_L2C_MISC2_WAY_AGENT_8 _SB_MAKEMASK(8, S_BCM1480_L2C_MISC2_WAY_AGENT_8)
165#define G_BCM1480_L2C_MISC2_WAY_AGENT_8(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC2_WAY_AGENT_8, M_BCM1480_L2C_MISC2_WAY_AGENT_8)
166
167#define S_BCM1480_L2C_MISC2_WAY_AGENT_9 8
168#define M_BCM1480_L2C_MISC2_WAY_AGENT_9 _SB_MAKEMASK(8, S_BCM1480_L2C_MISC2_WAY_AGENT_9)
169#define G_BCM1480_L2C_MISC2_WAY_AGENT_9(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC2_WAY_AGENT_9, M_BCM1480_L2C_MISC2_WAY_AGENT_9)
170
171#define S_BCM1480_L2C_MISC2_WAY_AGENT_A 16
172#define M_BCM1480_L2C_MISC2_WAY_AGENT_A _SB_MAKEMASK(8, S_BCM1480_L2C_MISC2_WAY_AGENT_A)
173#define G_BCM1480_L2C_MISC2_WAY_AGENT_A(x) _SB_GETVALUE(x, S_BCM1480_L2C_MISC2_WAY_AGENT_A, M_BCM1480_L2C_MISC2_WAY_AGENT_A)
174
175
176#endif /* _BCM1480_L2C_H */
diff --git a/arch/mips/include/asm/sibyte/bcm1480_mc.h b/arch/mips/include/asm/sibyte/bcm1480_mc.h
new file mode 100644
index 000000000000..f26a41a82b59
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/bcm1480_mc.h
@@ -0,0 +1,984 @@
1/* *********************************************************************
2 * BCM1280/BCM1480 Board Support Package
3 *
4 * Memory Controller constants File: bcm1480_mc.h
5 *
6 * This module contains constants and macros useful for
7 * programming the memory controller.
8 *
9 * BCM1400 specification level: 1280-UM100-D1 (11/14/03 Review Copy)
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _BCM1480_MC_H
34#define _BCM1480_MC_H
35
36#include "sb1250_defs.h"
37
38/*
39 * Memory Channel Configuration Register (Table 81)
40 */
41
42#define S_BCM1480_MC_INTLV0 0
43#define M_BCM1480_MC_INTLV0 _SB_MAKEMASK(6, S_BCM1480_MC_INTLV0)
44#define V_BCM1480_MC_INTLV0(x) _SB_MAKEVALUE(x, S_BCM1480_MC_INTLV0)
45#define G_BCM1480_MC_INTLV0(x) _SB_GETVALUE(x, S_BCM1480_MC_INTLV0, M_BCM1480_MC_INTLV0)
46#define V_BCM1480_MC_INTLV0_DEFAULT V_BCM1480_MC_INTLV0(0)
47
48#define S_BCM1480_MC_INTLV1 8
49#define M_BCM1480_MC_INTLV1 _SB_MAKEMASK(6, S_BCM1480_MC_INTLV1)
50#define V_BCM1480_MC_INTLV1(x) _SB_MAKEVALUE(x, S_BCM1480_MC_INTLV1)
51#define G_BCM1480_MC_INTLV1(x) _SB_GETVALUE(x, S_BCM1480_MC_INTLV1, M_BCM1480_MC_INTLV1)
52#define V_BCM1480_MC_INTLV1_DEFAULT V_BCM1480_MC_INTLV1(0)
53
54#define S_BCM1480_MC_INTLV2 16
55#define M_BCM1480_MC_INTLV2 _SB_MAKEMASK(6, S_BCM1480_MC_INTLV2)
56#define V_BCM1480_MC_INTLV2(x) _SB_MAKEVALUE(x, S_BCM1480_MC_INTLV2)
57#define G_BCM1480_MC_INTLV2(x) _SB_GETVALUE(x, S_BCM1480_MC_INTLV2, M_BCM1480_MC_INTLV2)
58#define V_BCM1480_MC_INTLV2_DEFAULT V_BCM1480_MC_INTLV2(0)
59
60#define S_BCM1480_MC_CS_MODE 32
61#define M_BCM1480_MC_CS_MODE _SB_MAKEMASK(8, S_BCM1480_MC_CS_MODE)
62#define V_BCM1480_MC_CS_MODE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS_MODE)
63#define G_BCM1480_MC_CS_MODE(x) _SB_GETVALUE(x, S_BCM1480_MC_CS_MODE, M_BCM1480_MC_CS_MODE)
64#define V_BCM1480_MC_CS_MODE_DEFAULT V_BCM1480_MC_CS_MODE(0)
65
66#define V_BCM1480_MC_CONFIG_DEFAULT (V_BCM1480_MC_INTLV0_DEFAULT | \
67 V_BCM1480_MC_INTLV1_DEFAULT | \
68 V_BCM1480_MC_INTLV2_DEFAULT | \
69 V_BCM1480_MC_CS_MODE_DEFAULT)
70
71#define K_BCM1480_MC_CS01_MODE 0x03
72#define K_BCM1480_MC_CS02_MODE 0x05
73#define K_BCM1480_MC_CS0123_MODE 0x0F
74#define K_BCM1480_MC_CS0246_MODE 0x55
75#define K_BCM1480_MC_CS0145_MODE 0x33
76#define K_BCM1480_MC_CS0167_MODE 0xC3
77#define K_BCM1480_MC_CSFULL_MODE 0xFF
78
79/*
80 * Chip Select Start Address Register (Table 82)
81 */
82
83#define S_BCM1480_MC_CS0_START 0
84#define M_BCM1480_MC_CS0_START _SB_MAKEMASK(12, S_BCM1480_MC_CS0_START)
85#define V_BCM1480_MC_CS0_START(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS0_START)
86#define G_BCM1480_MC_CS0_START(x) _SB_GETVALUE(x, S_BCM1480_MC_CS0_START, M_BCM1480_MC_CS0_START)
87
88#define S_BCM1480_MC_CS1_START 16
89#define M_BCM1480_MC_CS1_START _SB_MAKEMASK(12, S_BCM1480_MC_CS1_START)
90#define V_BCM1480_MC_CS1_START(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS1_START)
91#define G_BCM1480_MC_CS1_START(x) _SB_GETVALUE(x, S_BCM1480_MC_CS1_START, M_BCM1480_MC_CS1_START)
92
93#define S_BCM1480_MC_CS2_START 32
94#define M_BCM1480_MC_CS2_START _SB_MAKEMASK(12, S_BCM1480_MC_CS2_START)
95#define V_BCM1480_MC_CS2_START(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS2_START)
96#define G_BCM1480_MC_CS2_START(x) _SB_GETVALUE(x, S_BCM1480_MC_CS2_START, M_BCM1480_MC_CS2_START)
97
98#define S_BCM1480_MC_CS3_START 48
99#define M_BCM1480_MC_CS3_START _SB_MAKEMASK(12, S_BCM1480_MC_CS3_START)
100#define V_BCM1480_MC_CS3_START(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS3_START)
101#define G_BCM1480_MC_CS3_START(x) _SB_GETVALUE(x, S_BCM1480_MC_CS3_START, M_BCM1480_MC_CS3_START)
102
103/*
104 * Chip Select End Address Register (Table 83)
105 */
106
107#define S_BCM1480_MC_CS0_END 0
108#define M_BCM1480_MC_CS0_END _SB_MAKEMASK(12, S_BCM1480_MC_CS0_END)
109#define V_BCM1480_MC_CS0_END(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS0_END)
110#define G_BCM1480_MC_CS0_END(x) _SB_GETVALUE(x, S_BCM1480_MC_CS0_END, M_BCM1480_MC_CS0_END)
111
112#define S_BCM1480_MC_CS1_END 16
113#define M_BCM1480_MC_CS1_END _SB_MAKEMASK(12, S_BCM1480_MC_CS1_END)
114#define V_BCM1480_MC_CS1_END(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS1_END)
115#define G_BCM1480_MC_CS1_END(x) _SB_GETVALUE(x, S_BCM1480_MC_CS1_END, M_BCM1480_MC_CS1_END)
116
117#define S_BCM1480_MC_CS2_END 32
118#define M_BCM1480_MC_CS2_END _SB_MAKEMASK(12, S_BCM1480_MC_CS2_END)
119#define V_BCM1480_MC_CS2_END(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS2_END)
120#define G_BCM1480_MC_CS2_END(x) _SB_GETVALUE(x, S_BCM1480_MC_CS2_END, M_BCM1480_MC_CS2_END)
121
122#define S_BCM1480_MC_CS3_END 48
123#define M_BCM1480_MC_CS3_END _SB_MAKEMASK(12, S_BCM1480_MC_CS3_END)
124#define V_BCM1480_MC_CS3_END(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS3_END)
125#define G_BCM1480_MC_CS3_END(x) _SB_GETVALUE(x, S_BCM1480_MC_CS3_END, M_BCM1480_MC_CS3_END)
126
127/*
128 * Row Address Bit Select Register 0 (Table 84)
129 */
130
131#define S_BCM1480_MC_ROW00 0
132#define M_BCM1480_MC_ROW00 _SB_MAKEMASK(6, S_BCM1480_MC_ROW00)
133#define V_BCM1480_MC_ROW00(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW00)
134#define G_BCM1480_MC_ROW00(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW00, M_BCM1480_MC_ROW00)
135
136#define S_BCM1480_MC_ROW01 8
137#define M_BCM1480_MC_ROW01 _SB_MAKEMASK(6, S_BCM1480_MC_ROW01)
138#define V_BCM1480_MC_ROW01(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW01)
139#define G_BCM1480_MC_ROW01(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW01, M_BCM1480_MC_ROW01)
140
141#define S_BCM1480_MC_ROW02 16
142#define M_BCM1480_MC_ROW02 _SB_MAKEMASK(6, S_BCM1480_MC_ROW02)
143#define V_BCM1480_MC_ROW02(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW02)
144#define G_BCM1480_MC_ROW02(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW02, M_BCM1480_MC_ROW02)
145
146#define S_BCM1480_MC_ROW03 24
147#define M_BCM1480_MC_ROW03 _SB_MAKEMASK(6, S_BCM1480_MC_ROW03)
148#define V_BCM1480_MC_ROW03(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW03)
149#define G_BCM1480_MC_ROW03(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW03, M_BCM1480_MC_ROW03)
150
151#define S_BCM1480_MC_ROW04 32
152#define M_BCM1480_MC_ROW04 _SB_MAKEMASK(6, S_BCM1480_MC_ROW04)
153#define V_BCM1480_MC_ROW04(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW04)
154#define G_BCM1480_MC_ROW04(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW04, M_BCM1480_MC_ROW04)
155
156#define S_BCM1480_MC_ROW05 40
157#define M_BCM1480_MC_ROW05 _SB_MAKEMASK(6, S_BCM1480_MC_ROW05)
158#define V_BCM1480_MC_ROW05(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW05)
159#define G_BCM1480_MC_ROW05(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW05, M_BCM1480_MC_ROW05)
160
161#define S_BCM1480_MC_ROW06 48
162#define M_BCM1480_MC_ROW06 _SB_MAKEMASK(6, S_BCM1480_MC_ROW06)
163#define V_BCM1480_MC_ROW06(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW06)
164#define G_BCM1480_MC_ROW06(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW06, M_BCM1480_MC_ROW06)
165
166#define S_BCM1480_MC_ROW07 56
167#define M_BCM1480_MC_ROW07 _SB_MAKEMASK(6, S_BCM1480_MC_ROW07)
168#define V_BCM1480_MC_ROW07(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW07)
169#define G_BCM1480_MC_ROW07(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW07, M_BCM1480_MC_ROW07)
170
171/*
172 * Row Address Bit Select Register 1 (Table 85)
173 */
174
175#define S_BCM1480_MC_ROW08 0
176#define M_BCM1480_MC_ROW08 _SB_MAKEMASK(6, S_BCM1480_MC_ROW08)
177#define V_BCM1480_MC_ROW08(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW08)
178#define G_BCM1480_MC_ROW08(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW08, M_BCM1480_MC_ROW08)
179
180#define S_BCM1480_MC_ROW09 8
181#define M_BCM1480_MC_ROW09 _SB_MAKEMASK(6, S_BCM1480_MC_ROW09)
182#define V_BCM1480_MC_ROW09(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW09)
183#define G_BCM1480_MC_ROW09(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW09, M_BCM1480_MC_ROW09)
184
185#define S_BCM1480_MC_ROW10 16
186#define M_BCM1480_MC_ROW10 _SB_MAKEMASK(6, S_BCM1480_MC_ROW10)
187#define V_BCM1480_MC_ROW10(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW10)
188#define G_BCM1480_MC_ROW10(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW10, M_BCM1480_MC_ROW10)
189
190#define S_BCM1480_MC_ROW11 24
191#define M_BCM1480_MC_ROW11 _SB_MAKEMASK(6, S_BCM1480_MC_ROW11)
192#define V_BCM1480_MC_ROW11(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW11)
193#define G_BCM1480_MC_ROW11(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW11, M_BCM1480_MC_ROW11)
194
195#define S_BCM1480_MC_ROW12 32
196#define M_BCM1480_MC_ROW12 _SB_MAKEMASK(6, S_BCM1480_MC_ROW12)
197#define V_BCM1480_MC_ROW12(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW12)
198#define G_BCM1480_MC_ROW12(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW12, M_BCM1480_MC_ROW12)
199
200#define S_BCM1480_MC_ROW13 40
201#define M_BCM1480_MC_ROW13 _SB_MAKEMASK(6, S_BCM1480_MC_ROW13)
202#define V_BCM1480_MC_ROW13(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW13)
203#define G_BCM1480_MC_ROW13(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW13, M_BCM1480_MC_ROW13)
204
205#define S_BCM1480_MC_ROW14 48
206#define M_BCM1480_MC_ROW14 _SB_MAKEMASK(6, S_BCM1480_MC_ROW14)
207#define V_BCM1480_MC_ROW14(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ROW14)
208#define G_BCM1480_MC_ROW14(x) _SB_GETVALUE(x, S_BCM1480_MC_ROW14, M_BCM1480_MC_ROW14)
209
210#define K_BCM1480_MC_ROWX_BIT_SPACING 8
211
212/*
213 * Column Address Bit Select Register 0 (Table 86)
214 */
215
216#define S_BCM1480_MC_COL00 0
217#define M_BCM1480_MC_COL00 _SB_MAKEMASK(6, S_BCM1480_MC_COL00)
218#define V_BCM1480_MC_COL00(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL00)
219#define G_BCM1480_MC_COL00(x) _SB_GETVALUE(x, S_BCM1480_MC_COL00, M_BCM1480_MC_COL00)
220
221#define S_BCM1480_MC_COL01 8
222#define M_BCM1480_MC_COL01 _SB_MAKEMASK(6, S_BCM1480_MC_COL01)
223#define V_BCM1480_MC_COL01(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL01)
224#define G_BCM1480_MC_COL01(x) _SB_GETVALUE(x, S_BCM1480_MC_COL01, M_BCM1480_MC_COL01)
225
226#define S_BCM1480_MC_COL02 16
227#define M_BCM1480_MC_COL02 _SB_MAKEMASK(6, S_BCM1480_MC_COL02)
228#define V_BCM1480_MC_COL02(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL02)
229#define G_BCM1480_MC_COL02(x) _SB_GETVALUE(x, S_BCM1480_MC_COL02, M_BCM1480_MC_COL02)
230
231#define S_BCM1480_MC_COL03 24
232#define M_BCM1480_MC_COL03 _SB_MAKEMASK(6, S_BCM1480_MC_COL03)
233#define V_BCM1480_MC_COL03(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL03)
234#define G_BCM1480_MC_COL03(x) _SB_GETVALUE(x, S_BCM1480_MC_COL03, M_BCM1480_MC_COL03)
235
236#define S_BCM1480_MC_COL04 32
237#define M_BCM1480_MC_COL04 _SB_MAKEMASK(6, S_BCM1480_MC_COL04)
238#define V_BCM1480_MC_COL04(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL04)
239#define G_BCM1480_MC_COL04(x) _SB_GETVALUE(x, S_BCM1480_MC_COL04, M_BCM1480_MC_COL04)
240
241#define S_BCM1480_MC_COL05 40
242#define M_BCM1480_MC_COL05 _SB_MAKEMASK(6, S_BCM1480_MC_COL05)
243#define V_BCM1480_MC_COL05(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL05)
244#define G_BCM1480_MC_COL05(x) _SB_GETVALUE(x, S_BCM1480_MC_COL05, M_BCM1480_MC_COL05)
245
246#define S_BCM1480_MC_COL06 48
247#define M_BCM1480_MC_COL06 _SB_MAKEMASK(6, S_BCM1480_MC_COL06)
248#define V_BCM1480_MC_COL06(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL06)
249#define G_BCM1480_MC_COL06(x) _SB_GETVALUE(x, S_BCM1480_MC_COL06, M_BCM1480_MC_COL06)
250
251#define S_BCM1480_MC_COL07 56
252#define M_BCM1480_MC_COL07 _SB_MAKEMASK(6, S_BCM1480_MC_COL07)
253#define V_BCM1480_MC_COL07(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL07)
254#define G_BCM1480_MC_COL07(x) _SB_GETVALUE(x, S_BCM1480_MC_COL07, M_BCM1480_MC_COL07)
255
256/*
257 * Column Address Bit Select Register 1 (Table 87)
258 */
259
260#define S_BCM1480_MC_COL08 0
261#define M_BCM1480_MC_COL08 _SB_MAKEMASK(6, S_BCM1480_MC_COL08)
262#define V_BCM1480_MC_COL08(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL08)
263#define G_BCM1480_MC_COL08(x) _SB_GETVALUE(x, S_BCM1480_MC_COL08, M_BCM1480_MC_COL08)
264
265#define S_BCM1480_MC_COL09 8
266#define M_BCM1480_MC_COL09 _SB_MAKEMASK(6, S_BCM1480_MC_COL09)
267#define V_BCM1480_MC_COL09(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL09)
268#define G_BCM1480_MC_COL09(x) _SB_GETVALUE(x, S_BCM1480_MC_COL09, M_BCM1480_MC_COL09)
269
270#define S_BCM1480_MC_COL10 16 /* not a valid position, must be prog as 0 */
271
272#define S_BCM1480_MC_COL11 24
273#define M_BCM1480_MC_COL11 _SB_MAKEMASK(6, S_BCM1480_MC_COL11)
274#define V_BCM1480_MC_COL11(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL11)
275#define G_BCM1480_MC_COL11(x) _SB_GETVALUE(x, S_BCM1480_MC_COL11, M_BCM1480_MC_COL11)
276
277#define S_BCM1480_MC_COL12 32
278#define M_BCM1480_MC_COL12 _SB_MAKEMASK(6, S_BCM1480_MC_COL12)
279#define V_BCM1480_MC_COL12(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL12)
280#define G_BCM1480_MC_COL12(x) _SB_GETVALUE(x, S_BCM1480_MC_COL12, M_BCM1480_MC_COL12)
281
282#define S_BCM1480_MC_COL13 40
283#define M_BCM1480_MC_COL13 _SB_MAKEMASK(6, S_BCM1480_MC_COL13)
284#define V_BCM1480_MC_COL13(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL13)
285#define G_BCM1480_MC_COL13(x) _SB_GETVALUE(x, S_BCM1480_MC_COL13, M_BCM1480_MC_COL13)
286
287#define S_BCM1480_MC_COL14 48
288#define M_BCM1480_MC_COL14 _SB_MAKEMASK(6, S_BCM1480_MC_COL14)
289#define V_BCM1480_MC_COL14(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COL14)
290#define G_BCM1480_MC_COL14(x) _SB_GETVALUE(x, S_BCM1480_MC_COL14, M_BCM1480_MC_COL14)
291
292#define K_BCM1480_MC_COLX_BIT_SPACING 8
293
294/*
295 * CS0 and CS1 Bank Address Bit Select Register (Table 88)
296 */
297
298#define S_BCM1480_MC_CS01_BANK0 0
299#define M_BCM1480_MC_CS01_BANK0 _SB_MAKEMASK(6, S_BCM1480_MC_CS01_BANK0)
300#define V_BCM1480_MC_CS01_BANK0(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS01_BANK0)
301#define G_BCM1480_MC_CS01_BANK0(x) _SB_GETVALUE(x, S_BCM1480_MC_CS01_BANK0, M_BCM1480_MC_CS01_BANK0)
302
303#define S_BCM1480_MC_CS01_BANK1 8
304#define M_BCM1480_MC_CS01_BANK1 _SB_MAKEMASK(6, S_BCM1480_MC_CS01_BANK1)
305#define V_BCM1480_MC_CS01_BANK1(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS01_BANK1)
306#define G_BCM1480_MC_CS01_BANK1(x) _SB_GETVALUE(x, S_BCM1480_MC_CS01_BANK1, M_BCM1480_MC_CS01_BANK1)
307
308#define S_BCM1480_MC_CS01_BANK2 16
309#define M_BCM1480_MC_CS01_BANK2 _SB_MAKEMASK(6, S_BCM1480_MC_CS01_BANK2)
310#define V_BCM1480_MC_CS01_BANK2(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS01_BANK2)
311#define G_BCM1480_MC_CS01_BANK2(x) _SB_GETVALUE(x, S_BCM1480_MC_CS01_BANK2, M_BCM1480_MC_CS01_BANK2)
312
313/*
314 * CS2 and CS3 Bank Address Bit Select Register (Table 89)
315 */
316
317#define S_BCM1480_MC_CS23_BANK0 0
318#define M_BCM1480_MC_CS23_BANK0 _SB_MAKEMASK(6, S_BCM1480_MC_CS23_BANK0)
319#define V_BCM1480_MC_CS23_BANK0(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS23_BANK0)
320#define G_BCM1480_MC_CS23_BANK0(x) _SB_GETVALUE(x, S_BCM1480_MC_CS23_BANK0, M_BCM1480_MC_CS23_BANK0)
321
322#define S_BCM1480_MC_CS23_BANK1 8
323#define M_BCM1480_MC_CS23_BANK1 _SB_MAKEMASK(6, S_BCM1480_MC_CS23_BANK1)
324#define V_BCM1480_MC_CS23_BANK1(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS23_BANK1)
325#define G_BCM1480_MC_CS23_BANK1(x) _SB_GETVALUE(x, S_BCM1480_MC_CS23_BANK1, M_BCM1480_MC_CS23_BANK1)
326
327#define S_BCM1480_MC_CS23_BANK2 16
328#define M_BCM1480_MC_CS23_BANK2 _SB_MAKEMASK(6, S_BCM1480_MC_CS23_BANK2)
329#define V_BCM1480_MC_CS23_BANK2(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS23_BANK2)
330#define G_BCM1480_MC_CS23_BANK2(x) _SB_GETVALUE(x, S_BCM1480_MC_CS23_BANK2, M_BCM1480_MC_CS23_BANK2)
331
332#define K_BCM1480_MC_CSXX_BANKX_BIT_SPACING 8
333
334/*
335 * DRAM Command Register (Table 90)
336 */
337
338#define S_BCM1480_MC_COMMAND 0
339#define M_BCM1480_MC_COMMAND _SB_MAKEMASK(4, S_BCM1480_MC_COMMAND)
340#define V_BCM1480_MC_COMMAND(x) _SB_MAKEVALUE(x, S_BCM1480_MC_COMMAND)
341#define G_BCM1480_MC_COMMAND(x) _SB_GETVALUE(x, S_BCM1480_MC_COMMAND, M_BCM1480_MC_COMMAND)
342
343#define K_BCM1480_MC_COMMAND_EMRS 0
344#define K_BCM1480_MC_COMMAND_MRS 1
345#define K_BCM1480_MC_COMMAND_PRE 2
346#define K_BCM1480_MC_COMMAND_AR 3
347#define K_BCM1480_MC_COMMAND_SETRFSH 4
348#define K_BCM1480_MC_COMMAND_CLRRFSH 5
349#define K_BCM1480_MC_COMMAND_SETPWRDN 6
350#define K_BCM1480_MC_COMMAND_CLRPWRDN 7
351
352#if SIBYTE_HDR_FEATURE(1480, PASS2)
353#define K_BCM1480_MC_COMMAND_EMRS2 8
354#define K_BCM1480_MC_COMMAND_EMRS3 9
355#define K_BCM1480_MC_COMMAND_ENABLE_MCLK 10
356#define K_BCM1480_MC_COMMAND_DISABLE_MCLK 11
357#endif
358
359#define V_BCM1480_MC_COMMAND_EMRS V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_EMRS)
360#define V_BCM1480_MC_COMMAND_MRS V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_MRS)
361#define V_BCM1480_MC_COMMAND_PRE V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_PRE)
362#define V_BCM1480_MC_COMMAND_AR V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_AR)
363#define V_BCM1480_MC_COMMAND_SETRFSH V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_SETRFSH)
364#define V_BCM1480_MC_COMMAND_CLRRFSH V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_CLRRFSH)
365#define V_BCM1480_MC_COMMAND_SETPWRDN V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_SETPWRDN)
366#define V_BCM1480_MC_COMMAND_CLRPWRDN V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_CLRPWRDN)
367
368#if SIBYTE_HDR_FEATURE(1480, PASS2)
369#define V_BCM1480_MC_COMMAND_EMRS2 V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_EMRS2)
370#define V_BCM1480_MC_COMMAND_EMRS3 V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_EMRS3)
371#define V_BCM1480_MC_COMMAND_ENABLE_MCLK V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_ENABLE_MCLK)
372#define V_BCM1480_MC_COMMAND_DISABLE_MCLK V_BCM1480_MC_COMMAND(K_BCM1480_MC_COMMAND_DISABLE_MCLK)
373#endif
374
375#define S_BCM1480_MC_CS0 4
376#define M_BCM1480_MC_CS0 _SB_MAKEMASK1(4)
377#define M_BCM1480_MC_CS1 _SB_MAKEMASK1(5)
378#define M_BCM1480_MC_CS2 _SB_MAKEMASK1(6)
379#define M_BCM1480_MC_CS3 _SB_MAKEMASK1(7)
380#define M_BCM1480_MC_CS4 _SB_MAKEMASK1(8)
381#define M_BCM1480_MC_CS5 _SB_MAKEMASK1(9)
382#define M_BCM1480_MC_CS6 _SB_MAKEMASK1(10)
383#define M_BCM1480_MC_CS7 _SB_MAKEMASK1(11)
384
385#define M_BCM1480_MC_CS _SB_MAKEMASK(8, S_BCM1480_MC_CS0)
386#define V_BCM1480_MC_CS(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CS0)
387#define G_BCM1480_MC_CS(x) _SB_GETVALUE(x, S_BCM1480_MC_CS0, M_BCM1480_MC_CS0)
388
389#define M_BCM1480_MC_CMD_ACTIVE _SB_MAKEMASK1(16)
390
391/*
392 * DRAM Mode Register (Table 91)
393 */
394
395#define S_BCM1480_MC_EMODE 0
396#define M_BCM1480_MC_EMODE _SB_MAKEMASK(15, S_BCM1480_MC_EMODE)
397#define V_BCM1480_MC_EMODE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_EMODE)
398#define G_BCM1480_MC_EMODE(x) _SB_GETVALUE(x, S_BCM1480_MC_EMODE, M_BCM1480_MC_EMODE)
399#define V_BCM1480_MC_EMODE_DEFAULT V_BCM1480_MC_EMODE(0)
400
401#define S_BCM1480_MC_MODE 16
402#define M_BCM1480_MC_MODE _SB_MAKEMASK(15, S_BCM1480_MC_MODE)
403#define V_BCM1480_MC_MODE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_MODE)
404#define G_BCM1480_MC_MODE(x) _SB_GETVALUE(x, S_BCM1480_MC_MODE, M_BCM1480_MC_MODE)
405#define V_BCM1480_MC_MODE_DEFAULT V_BCM1480_MC_MODE(0)
406
407#define S_BCM1480_MC_DRAM_TYPE 32
408#define M_BCM1480_MC_DRAM_TYPE _SB_MAKEMASK(4, S_BCM1480_MC_DRAM_TYPE)
409#define V_BCM1480_MC_DRAM_TYPE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DRAM_TYPE)
410#define G_BCM1480_MC_DRAM_TYPE(x) _SB_GETVALUE(x, S_BCM1480_MC_DRAM_TYPE, M_BCM1480_MC_DRAM_TYPE)
411
412#define K_BCM1480_MC_DRAM_TYPE_JEDEC 0
413#define K_BCM1480_MC_DRAM_TYPE_FCRAM 1
414
415#if SIBYTE_HDR_FEATURE(1480, PASS2)
416#define K_BCM1480_MC_DRAM_TYPE_DDR2 2
417#endif
418
419#define K_BCM1480_MC_DRAM_TYPE_DDR2_PASS1 0
420
421#define V_BCM1480_MC_DRAM_TYPE_JEDEC V_BCM1480_MC_DRAM_TYPE(K_BCM1480_MC_DRAM_TYPE_JEDEC)
422#define V_BCM1480_MC_DRAM_TYPE_FCRAM V_BCM1480_MC_DRAM_TYPE(K_BCM1480_MC_DRAM_TYPE_FCRAM)
423
424#if SIBYTE_HDR_FEATURE(1480, PASS2)
425#define V_BCM1480_MC_DRAM_TYPE_DDR2 V_BCM1480_MC_DRAM_TYPE(K_BCM1480_MC_DRAM_TYPE_DDR2)
426#endif
427
428#define M_BCM1480_MC_GANGED _SB_MAKEMASK1(36)
429#define M_BCM1480_MC_BY9_INTF _SB_MAKEMASK1(37)
430#define M_BCM1480_MC_FORCE_ECC64 _SB_MAKEMASK1(38)
431#define M_BCM1480_MC_ECC_DISABLE _SB_MAKEMASK1(39)
432
433#define S_BCM1480_MC_PG_POLICY 40
434#define M_BCM1480_MC_PG_POLICY _SB_MAKEMASK(2, S_BCM1480_MC_PG_POLICY)
435#define V_BCM1480_MC_PG_POLICY(x) _SB_MAKEVALUE(x, S_BCM1480_MC_PG_POLICY)
436#define G_BCM1480_MC_PG_POLICY(x) _SB_GETVALUE(x, S_BCM1480_MC_PG_POLICY, M_BCM1480_MC_PG_POLICY)
437
438#define K_BCM1480_MC_PG_POLICY_CLOSED 0
439#define K_BCM1480_MC_PG_POLICY_CAS_TIME_CHK 1
440
441#define V_BCM1480_MC_PG_POLICY_CLOSED V_BCM1480_MC_PG_POLICY(K_BCM1480_MC_PG_POLICY_CLOSED)
442#define V_BCM1480_MC_PG_POLICY_CAS_TIME_CHK V_BCM1480_MC_PG_POLICY(K_BCM1480_MC_PG_POLICY_CAS_TIME_CHK)
443
444#if SIBYTE_HDR_FEATURE(1480, PASS2)
445#define M_BCM1480_MC_2T_CMD _SB_MAKEMASK1(42)
446#define M_BCM1480_MC_ECC_COR_DIS _SB_MAKEMASK1(43)
447#endif
448
449#define V_BCM1480_MC_DRAMMODE_DEFAULT V_BCM1480_MC_EMODE_DEFAULT | V_BCM1480_MC_MODE_DEFAULT | V_BCM1480_MC_DRAM_TYPE_JEDEC | \
450 V_BCM1480_MC_PG_POLICY(K_BCM1480_MC_PG_POLICY_CAS_TIME_CHK)
451
452/*
453 * Memory Clock Configuration Register (Table 92)
454 */
455
456#define S_BCM1480_MC_CLK_RATIO 0
457#define M_BCM1480_MC_CLK_RATIO _SB_MAKEMASK(6, S_BCM1480_MC_CLK_RATIO)
458#define V_BCM1480_MC_CLK_RATIO(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CLK_RATIO)
459#define G_BCM1480_MC_CLK_RATIO(x) _SB_GETVALUE(x, S_BCM1480_MC_CLK_RATIO, M_BCM1480_MC_CLK_RATIO)
460
461#define V_BCM1480_MC_CLK_RATIO_DEFAULT V_BCM1480_MC_CLK_RATIO(10)
462
463#define S_BCM1480_MC_REF_RATE 8
464#define M_BCM1480_MC_REF_RATE _SB_MAKEMASK(8, S_BCM1480_MC_REF_RATE)
465#define V_BCM1480_MC_REF_RATE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_REF_RATE)
466#define G_BCM1480_MC_REF_RATE(x) _SB_GETVALUE(x, S_BCM1480_MC_REF_RATE, M_BCM1480_MC_REF_RATE)
467
468#define K_BCM1480_MC_REF_RATE_100MHz 0x31
469#define K_BCM1480_MC_REF_RATE_200MHz 0x62
470#define K_BCM1480_MC_REF_RATE_400MHz 0xC4
471
472#define V_BCM1480_MC_REF_RATE_100MHz V_BCM1480_MC_REF_RATE(K_BCM1480_MC_REF_RATE_100MHz)
473#define V_BCM1480_MC_REF_RATE_200MHz V_BCM1480_MC_REF_RATE(K_BCM1480_MC_REF_RATE_200MHz)
474#define V_BCM1480_MC_REF_RATE_400MHz V_BCM1480_MC_REF_RATE(K_BCM1480_MC_REF_RATE_400MHz)
475#define V_BCM1480_MC_REF_RATE_DEFAULT V_BCM1480_MC_REF_RATE_400MHz
476
477#if SIBYTE_HDR_FEATURE(1480, PASS2)
478#define M_BCM1480_MC_AUTO_REF_DIS _SB_MAKEMASK1(16)
479#endif
480
481/*
482 * ODT Register (Table 99)
483 */
484
485#if SIBYTE_HDR_FEATURE(1480, PASS2)
486#define M_BCM1480_MC_RD_ODT0_CS0 _SB_MAKEMASK1(0)
487#define M_BCM1480_MC_RD_ODT0_CS2 _SB_MAKEMASK1(1)
488#define M_BCM1480_MC_RD_ODT0_CS4 _SB_MAKEMASK1(2)
489#define M_BCM1480_MC_RD_ODT0_CS6 _SB_MAKEMASK1(3)
490#define M_BCM1480_MC_WR_ODT0_CS0 _SB_MAKEMASK1(4)
491#define M_BCM1480_MC_WR_ODT0_CS2 _SB_MAKEMASK1(5)
492#define M_BCM1480_MC_WR_ODT0_CS4 _SB_MAKEMASK1(6)
493#define M_BCM1480_MC_WR_ODT0_CS6 _SB_MAKEMASK1(7)
494#define M_BCM1480_MC_RD_ODT2_CS0 _SB_MAKEMASK1(8)
495#define M_BCM1480_MC_RD_ODT2_CS2 _SB_MAKEMASK1(9)
496#define M_BCM1480_MC_RD_ODT2_CS4 _SB_MAKEMASK1(10)
497#define M_BCM1480_MC_RD_ODT2_CS6 _SB_MAKEMASK1(11)
498#define M_BCM1480_MC_WR_ODT2_CS0 _SB_MAKEMASK1(12)
499#define M_BCM1480_MC_WR_ODT2_CS2 _SB_MAKEMASK1(13)
500#define M_BCM1480_MC_WR_ODT2_CS4 _SB_MAKEMASK1(14)
501#define M_BCM1480_MC_WR_ODT2_CS6 _SB_MAKEMASK1(15)
502#define M_BCM1480_MC_RD_ODT4_CS0 _SB_MAKEMASK1(16)
503#define M_BCM1480_MC_RD_ODT4_CS2 _SB_MAKEMASK1(17)
504#define M_BCM1480_MC_RD_ODT4_CS4 _SB_MAKEMASK1(18)
505#define M_BCM1480_MC_RD_ODT4_CS6 _SB_MAKEMASK1(19)
506#define M_BCM1480_MC_WR_ODT4_CS0 _SB_MAKEMASK1(20)
507#define M_BCM1480_MC_WR_ODT4_CS2 _SB_MAKEMASK1(21)
508#define M_BCM1480_MC_WR_ODT4_CS4 _SB_MAKEMASK1(22)
509#define M_BCM1480_MC_WR_ODT4_CS6 _SB_MAKEMASK1(23)
510#define M_BCM1480_MC_RD_ODT6_CS0 _SB_MAKEMASK1(24)
511#define M_BCM1480_MC_RD_ODT6_CS2 _SB_MAKEMASK1(25)
512#define M_BCM1480_MC_RD_ODT6_CS4 _SB_MAKEMASK1(26)
513#define M_BCM1480_MC_RD_ODT6_CS6 _SB_MAKEMASK1(27)
514#define M_BCM1480_MC_WR_ODT6_CS0 _SB_MAKEMASK1(28)
515#define M_BCM1480_MC_WR_ODT6_CS2 _SB_MAKEMASK1(29)
516#define M_BCM1480_MC_WR_ODT6_CS4 _SB_MAKEMASK1(30)
517#define M_BCM1480_MC_WR_ODT6_CS6 _SB_MAKEMASK1(31)
518
519#define M_BCM1480_MC_CS_ODD_ODT_EN _SB_MAKEMASK1(32)
520
521#define S_BCM1480_MC_ODT0 0
522#define M_BCM1480_MC_ODT0 _SB_MAKEMASK(8, S_BCM1480_MC_ODT0)
523#define V_BCM1480_MC_ODT0(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ODT0)
524
525#define S_BCM1480_MC_ODT2 8
526#define M_BCM1480_MC_ODT2 _SB_MAKEMASK(8, S_BCM1480_MC_ODT2)
527#define V_BCM1480_MC_ODT2(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ODT2)
528
529#define S_BCM1480_MC_ODT4 16
530#define M_BCM1480_MC_ODT4 _SB_MAKEMASK(8, S_BCM1480_MC_ODT4)
531#define V_BCM1480_MC_ODT4(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ODT4)
532
533#define S_BCM1480_MC_ODT6 24
534#define M_BCM1480_MC_ODT6 _SB_MAKEMASK(8, S_BCM1480_MC_ODT6)
535#define V_BCM1480_MC_ODT6(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ODT6)
536#endif
537
538/*
539 * Memory DLL Configuration Register (Table 93)
540 */
541
542#define S_BCM1480_MC_ADDR_COARSE_ADJ 0
543#define M_BCM1480_MC_ADDR_COARSE_ADJ _SB_MAKEMASK(6, S_BCM1480_MC_ADDR_COARSE_ADJ)
544#define V_BCM1480_MC_ADDR_COARSE_ADJ(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ADDR_COARSE_ADJ)
545#define G_BCM1480_MC_ADDR_COARSE_ADJ(x) _SB_GETVALUE(x, S_BCM1480_MC_ADDR_COARSE_ADJ, M_BCM1480_MC_ADDR_COARSE_ADJ)
546#define V_BCM1480_MC_ADDR_COARSE_ADJ_DEFAULT V_BCM1480_MC_ADDR_COARSE_ADJ(0x0)
547
548#if SIBYTE_HDR_FEATURE(1480, PASS2)
549#define S_BCM1480_MC_ADDR_FREQ_RANGE 8
550#define M_BCM1480_MC_ADDR_FREQ_RANGE _SB_MAKEMASK(4, S_BCM1480_MC_ADDR_FREQ_RANGE)
551#define V_BCM1480_MC_ADDR_FREQ_RANGE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ADDR_FREQ_RANGE)
552#define G_BCM1480_MC_ADDR_FREQ_RANGE(x) _SB_GETVALUE(x, S_BCM1480_MC_ADDR_FREQ_RANGE, M_BCM1480_MC_ADDR_FREQ_RANGE)
553#define V_BCM1480_MC_ADDR_FREQ_RANGE_DEFAULT V_BCM1480_MC_ADDR_FREQ_RANGE(0x4)
554#endif
555
556#define S_BCM1480_MC_ADDR_FINE_ADJ 8
557#define M_BCM1480_MC_ADDR_FINE_ADJ _SB_MAKEMASK(4, S_BCM1480_MC_ADDR_FINE_ADJ)
558#define V_BCM1480_MC_ADDR_FINE_ADJ(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ADDR_FINE_ADJ)
559#define G_BCM1480_MC_ADDR_FINE_ADJ(x) _SB_GETVALUE(x, S_BCM1480_MC_ADDR_FINE_ADJ, M_BCM1480_MC_ADDR_FINE_ADJ)
560#define V_BCM1480_MC_ADDR_FINE_ADJ_DEFAULT V_BCM1480_MC_ADDR_FINE_ADJ(0x8)
561
562#define S_BCM1480_MC_DQI_COARSE_ADJ 16
563#define M_BCM1480_MC_DQI_COARSE_ADJ _SB_MAKEMASK(6, S_BCM1480_MC_DQI_COARSE_ADJ)
564#define V_BCM1480_MC_DQI_COARSE_ADJ(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DQI_COARSE_ADJ)
565#define G_BCM1480_MC_DQI_COARSE_ADJ(x) _SB_GETVALUE(x, S_BCM1480_MC_DQI_COARSE_ADJ, M_BCM1480_MC_DQI_COARSE_ADJ)
566#define V_BCM1480_MC_DQI_COARSE_ADJ_DEFAULT V_BCM1480_MC_DQI_COARSE_ADJ(0x0)
567
568#if SIBYTE_HDR_FEATURE(1480, PASS2)
569#define S_BCM1480_MC_DQI_FREQ_RANGE 24
570#define M_BCM1480_MC_DQI_FREQ_RANGE _SB_MAKEMASK(4, S_BCM1480_MC_DQI_FREQ_RANGE)
571#define V_BCM1480_MC_DQI_FREQ_RANGE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DQI_FREQ_RANGE)
572#define G_BCM1480_MC_DQI_FREQ_RANGE(x) _SB_GETVALUE(x, S_BCM1480_MC_DQI_FREQ_RANGE, M_BCM1480_MC_DQI_FREQ_RANGE)
573#define V_BCM1480_MC_DQI_FREQ_RANGE_DEFAULT V_BCM1480_MC_DQI_FREQ_RANGE(0x4)
574#endif
575
576#define S_BCM1480_MC_DQI_FINE_ADJ 24
577#define M_BCM1480_MC_DQI_FINE_ADJ _SB_MAKEMASK(4, S_BCM1480_MC_DQI_FINE_ADJ)
578#define V_BCM1480_MC_DQI_FINE_ADJ(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DQI_FINE_ADJ)
579#define G_BCM1480_MC_DQI_FINE_ADJ(x) _SB_GETVALUE(x, S_BCM1480_MC_DQI_FINE_ADJ, M_BCM1480_MC_DQI_FINE_ADJ)
580#define V_BCM1480_MC_DQI_FINE_ADJ_DEFAULT V_BCM1480_MC_DQI_FINE_ADJ(0x8)
581
582#define S_BCM1480_MC_DQO_COARSE_ADJ 32
583#define M_BCM1480_MC_DQO_COARSE_ADJ _SB_MAKEMASK(6, S_BCM1480_MC_DQO_COARSE_ADJ)
584#define V_BCM1480_MC_DQO_COARSE_ADJ(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DQO_COARSE_ADJ)
585#define G_BCM1480_MC_DQO_COARSE_ADJ(x) _SB_GETVALUE(x, S_BCM1480_MC_DQO_COARSE_ADJ, M_BCM1480_MC_DQO_COARSE_ADJ)
586#define V_BCM1480_MC_DQO_COARSE_ADJ_DEFAULT V_BCM1480_MC_DQO_COARSE_ADJ(0x0)
587
588#if SIBYTE_HDR_FEATURE(1480, PASS2)
589#define S_BCM1480_MC_DQO_FREQ_RANGE 40
590#define M_BCM1480_MC_DQO_FREQ_RANGE _SB_MAKEMASK(4, S_BCM1480_MC_DQO_FREQ_RANGE)
591#define V_BCM1480_MC_DQO_FREQ_RANGE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DQO_FREQ_RANGE)
592#define G_BCM1480_MC_DQO_FREQ_RANGE(x) _SB_GETVALUE(x, S_BCM1480_MC_DQO_FREQ_RANGE, M_BCM1480_MC_DQO_FREQ_RANGE)
593#define V_BCM1480_MC_DQO_FREQ_RANGE_DEFAULT V_BCM1480_MC_DQO_FREQ_RANGE(0x4)
594#endif
595
596#define S_BCM1480_MC_DQO_FINE_ADJ 40
597#define M_BCM1480_MC_DQO_FINE_ADJ _SB_MAKEMASK(4, S_BCM1480_MC_DQO_FINE_ADJ)
598#define V_BCM1480_MC_DQO_FINE_ADJ(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DQO_FINE_ADJ)
599#define G_BCM1480_MC_DQO_FINE_ADJ(x) _SB_GETVALUE(x, S_BCM1480_MC_DQO_FINE_ADJ, M_BCM1480_MC_DQO_FINE_ADJ)
600#define V_BCM1480_MC_DQO_FINE_ADJ_DEFAULT V_BCM1480_MC_DQO_FINE_ADJ(0x8)
601
602#if SIBYTE_HDR_FEATURE(1480, PASS2)
603#define S_BCM1480_MC_DLL_PDSEL 44
604#define M_BCM1480_MC_DLL_PDSEL _SB_MAKEMASK(2, S_BCM1480_MC_DLL_PDSEL)
605#define V_BCM1480_MC_DLL_PDSEL(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DLL_PDSEL)
606#define G_BCM1480_MC_DLL_PDSEL(x) _SB_GETVALUE(x, S_BCM1480_MC_DLL_PDSEL, M_BCM1480_MC_DLL_PDSEL)
607#define V_BCM1480_MC_DLL_DEFAULT_PDSEL V_BCM1480_MC_DLL_PDSEL(0x0)
608
609#define M_BCM1480_MC_DLL_REGBYPASS _SB_MAKEMASK1(46)
610#define M_BCM1480_MC_DQO_SHIFT _SB_MAKEMASK1(47)
611#endif
612
613#define S_BCM1480_MC_DLL_DEFAULT 48
614#define M_BCM1480_MC_DLL_DEFAULT _SB_MAKEMASK(6, S_BCM1480_MC_DLL_DEFAULT)
615#define V_BCM1480_MC_DLL_DEFAULT(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DLL_DEFAULT)
616#define G_BCM1480_MC_DLL_DEFAULT(x) _SB_GETVALUE(x, S_BCM1480_MC_DLL_DEFAULT, M_BCM1480_MC_DLL_DEFAULT)
617#define V_BCM1480_MC_DLL_DEFAULT_DEFAULT V_BCM1480_MC_DLL_DEFAULT(0x10)
618
619#if SIBYTE_HDR_FEATURE(1480, PASS2)
620#define S_BCM1480_MC_DLL_REGCTRL 54
621#define M_BCM1480_MC_DLL_REGCTRL _SB_MAKEMASK(2, S_BCM1480_MC_DLL_REGCTRL)
622#define V_BCM1480_MC_DLL_REGCTRL(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DLL_REGCTRL)
623#define G_BCM1480_MC_DLL_REGCTRL(x) _SB_GETVALUE(x, S_BCM1480_MC_DLL_REGCTRL, M_BCM1480_MC_DLL_REGCTRL)
624#define V_BCM1480_MC_DLL_DEFAULT_REGCTRL V_BCM1480_MC_DLL_REGCTRL(0x0)
625#endif
626
627#if SIBYTE_HDR_FEATURE(1480, PASS2)
628#define S_BCM1480_MC_DLL_FREQ_RANGE 56
629#define M_BCM1480_MC_DLL_FREQ_RANGE _SB_MAKEMASK(4, S_BCM1480_MC_DLL_FREQ_RANGE)
630#define V_BCM1480_MC_DLL_FREQ_RANGE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DLL_FREQ_RANGE)
631#define G_BCM1480_MC_DLL_FREQ_RANGE(x) _SB_GETVALUE(x, S_BCM1480_MC_DLL_FREQ_RANGE, M_BCM1480_MC_DLL_FREQ_RANGE)
632#define V_BCM1480_MC_DLL_FREQ_RANGE_DEFAULT V_BCM1480_MC_DLL_FREQ_RANGE(0x4)
633#endif
634
635#define S_BCM1480_MC_DLL_STEP_SIZE 56
636#define M_BCM1480_MC_DLL_STEP_SIZE _SB_MAKEMASK(4, S_BCM1480_MC_DLL_STEP_SIZE)
637#define V_BCM1480_MC_DLL_STEP_SIZE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DLL_STEP_SIZE)
638#define G_BCM1480_MC_DLL_STEP_SIZE(x) _SB_GETVALUE(x, S_BCM1480_MC_DLL_STEP_SIZE, M_BCM1480_MC_DLL_STEP_SIZE)
639#define V_BCM1480_MC_DLL_STEP_SIZE_DEFAULT V_BCM1480_MC_DLL_STEP_SIZE(0x8)
640
641#if SIBYTE_HDR_FEATURE(1480, PASS2)
642#define S_BCM1480_MC_DLL_BGCTRL 60
643#define M_BCM1480_MC_DLL_BGCTRL _SB_MAKEMASK(2, S_BCM1480_MC_DLL_BGCTRL)
644#define V_BCM1480_MC_DLL_BGCTRL(x) _SB_MAKEVALUE(x, S_BCM1480_MC_DLL_BGCTRL)
645#define G_BCM1480_MC_DLL_BGCTRL(x) _SB_GETVALUE(x, S_BCM1480_MC_DLL_BGCTRL, M_BCM1480_MC_DLL_BGCTRL)
646#define V_BCM1480_MC_DLL_DEFAULT_BGCTRL V_BCM1480_MC_DLL_BGCTRL(0x0)
647#endif
648
649#define M_BCM1480_MC_DLL_BYPASS _SB_MAKEMASK1(63)
650
651/*
652 * Memory Drive Configuration Register (Table 94)
653 */
654
655#define S_BCM1480_MC_RTT_BYP_PULLDOWN 0
656#define M_BCM1480_MC_RTT_BYP_PULLDOWN _SB_MAKEMASK(3, S_BCM1480_MC_RTT_BYP_PULLDOWN)
657#define V_BCM1480_MC_RTT_BYP_PULLDOWN(x) _SB_MAKEVALUE(x, S_BCM1480_MC_RTT_BYP_PULLDOWN)
658#define G_BCM1480_MC_RTT_BYP_PULLDOWN(x) _SB_GETVALUE(x, S_BCM1480_MC_RTT_BYP_PULLDOWN, M_BCM1480_MC_RTT_BYP_PULLDOWN)
659
660#define S_BCM1480_MC_RTT_BYP_PULLUP 6
661#define M_BCM1480_MC_RTT_BYP_PULLUP _SB_MAKEMASK(3, S_BCM1480_MC_RTT_BYP_PULLUP)
662#define V_BCM1480_MC_RTT_BYP_PULLUP(x) _SB_MAKEVALUE(x, S_BCM1480_MC_RTT_BYP_PULLUP)
663#define G_BCM1480_MC_RTT_BYP_PULLUP(x) _SB_GETVALUE(x, S_BCM1480_MC_RTT_BYP_PULLUP, M_BCM1480_MC_RTT_BYP_PULLUP)
664
665#define M_BCM1480_MC_RTT_BYPASS _SB_MAKEMASK1(8)
666#define M_BCM1480_MC_RTT_COMP_MOV_AVG _SB_MAKEMASK1(9)
667
668#define S_BCM1480_MC_PVT_BYP_C1_PULLDOWN 10
669#define M_BCM1480_MC_PVT_BYP_C1_PULLDOWN _SB_MAKEMASK(4, S_BCM1480_MC_PVT_BYP_C1_PULLDOWN)
670#define V_BCM1480_MC_PVT_BYP_C1_PULLDOWN(x) _SB_MAKEVALUE(x, S_BCM1480_MC_PVT_BYP_C1_PULLDOWN)
671#define G_BCM1480_MC_PVT_BYP_C1_PULLDOWN(x) _SB_GETVALUE(x, S_BCM1480_MC_PVT_BYP_C1_PULLDOWN, M_BCM1480_MC_PVT_BYP_C1_PULLDOWN)
672
673#define S_BCM1480_MC_PVT_BYP_C1_PULLUP 15
674#define M_BCM1480_MC_PVT_BYP_C1_PULLUP _SB_MAKEMASK(4, S_BCM1480_MC_PVT_BYP_C1_PULLUP)
675#define V_BCM1480_MC_PVT_BYP_C1_PULLUP(x) _SB_MAKEVALUE(x, S_BCM1480_MC_PVT_BYP_C1_PULLUP)
676#define G_BCM1480_MC_PVT_BYP_C1_PULLUP(x) _SB_GETVALUE(x, S_BCM1480_MC_PVT_BYP_C1_PULLUP, M_BCM1480_MC_PVT_BYP_C1_PULLUP)
677
678#define S_BCM1480_MC_PVT_BYP_C2_PULLDOWN 20
679#define M_BCM1480_MC_PVT_BYP_C2_PULLDOWN _SB_MAKEMASK(4, S_BCM1480_MC_PVT_BYP_C2_PULLDOWN)
680#define V_BCM1480_MC_PVT_BYP_C2_PULLDOWN(x) _SB_MAKEVALUE(x, S_BCM1480_MC_PVT_BYP_C2_PULLDOWN)
681#define G_BCM1480_MC_PVT_BYP_C2_PULLDOWN(x) _SB_GETVALUE(x, S_BCM1480_MC_PVT_BYP_C2_PULLDOWN, M_BCM1480_MC_PVT_BYP_C2_PULLDOWN)
682
683#define S_BCM1480_MC_PVT_BYP_C2_PULLUP 25
684#define M_BCM1480_MC_PVT_BYP_C2_PULLUP _SB_MAKEMASK(4, S_BCM1480_MC_PVT_BYP_C2_PULLUP)
685#define V_BCM1480_MC_PVT_BYP_C2_PULLUP(x) _SB_MAKEVALUE(x, S_BCM1480_MC_PVT_BYP_C2_PULLUP)
686#define G_BCM1480_MC_PVT_BYP_C2_PULLUP(x) _SB_GETVALUE(x, S_BCM1480_MC_PVT_BYP_C2_PULLUP, M_BCM1480_MC_PVT_BYP_C2_PULLUP)
687
688#define M_BCM1480_MC_PVT_BYPASS _SB_MAKEMASK1(30)
689#define M_BCM1480_MC_PVT_COMP_MOV_AVG _SB_MAKEMASK1(31)
690
691#define M_BCM1480_MC_CLK_CLASS _SB_MAKEMASK1(34)
692#define M_BCM1480_MC_DATA_CLASS _SB_MAKEMASK1(35)
693#define M_BCM1480_MC_ADDR_CLASS _SB_MAKEMASK1(36)
694
695#define M_BCM1480_MC_DQ_ODT_75 _SB_MAKEMASK1(37)
696#define M_BCM1480_MC_DQ_ODT_150 _SB_MAKEMASK1(38)
697#define M_BCM1480_MC_DQS_ODT_75 _SB_MAKEMASK1(39)
698#define M_BCM1480_MC_DQS_ODT_150 _SB_MAKEMASK1(40)
699#define M_BCM1480_MC_DQS_DIFF _SB_MAKEMASK1(41)
700
701/*
702 * ECC Test Data Register (Table 95)
703 */
704
705#define S_BCM1480_MC_DATA_INVERT 0
706#define M_DATA_ECC_INVERT _SB_MAKEMASK(64, S_BCM1480_MC_ECC_INVERT)
707
708/*
709 * ECC Test ECC Register (Table 96)
710 */
711
712#define S_BCM1480_MC_ECC_INVERT 0
713#define M_BCM1480_MC_ECC_INVERT _SB_MAKEMASK(8, S_BCM1480_MC_ECC_INVERT)
714
715/*
716 * SDRAM Timing Register (Table 97)
717 */
718
719#define S_BCM1480_MC_tRCD 0
720#define M_BCM1480_MC_tRCD _SB_MAKEMASK(4, S_BCM1480_MC_tRCD)
721#define V_BCM1480_MC_tRCD(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tRCD)
722#define G_BCM1480_MC_tRCD(x) _SB_GETVALUE(x, S_BCM1480_MC_tRCD, M_BCM1480_MC_tRCD)
723#define K_BCM1480_MC_tRCD_DEFAULT 3
724#define V_BCM1480_MC_tRCD_DEFAULT V_BCM1480_MC_tRCD(K_BCM1480_MC_tRCD_DEFAULT)
725
726#define S_BCM1480_MC_tCL 4
727#define M_BCM1480_MC_tCL _SB_MAKEMASK(4, S_BCM1480_MC_tCL)
728#define V_BCM1480_MC_tCL(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tCL)
729#define G_BCM1480_MC_tCL(x) _SB_GETVALUE(x, S_BCM1480_MC_tCL, M_BCM1480_MC_tCL)
730#define K_BCM1480_MC_tCL_DEFAULT 2
731#define V_BCM1480_MC_tCL_DEFAULT V_BCM1480_MC_tCL(K_BCM1480_MC_tCL_DEFAULT)
732
733#define M_BCM1480_MC_tCrDh _SB_MAKEMASK1(8)
734
735#define S_BCM1480_MC_tWR 9
736#define M_BCM1480_MC_tWR _SB_MAKEMASK(3, S_BCM1480_MC_tWR)
737#define V_BCM1480_MC_tWR(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tWR)
738#define G_BCM1480_MC_tWR(x) _SB_GETVALUE(x, S_BCM1480_MC_tWR, M_BCM1480_MC_tWR)
739#define K_BCM1480_MC_tWR_DEFAULT 2
740#define V_BCM1480_MC_tWR_DEFAULT V_BCM1480_MC_tWR(K_BCM1480_MC_tWR_DEFAULT)
741
742#define S_BCM1480_MC_tCwD 12
743#define M_BCM1480_MC_tCwD _SB_MAKEMASK(4, S_BCM1480_MC_tCwD)
744#define V_BCM1480_MC_tCwD(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tCwD)
745#define G_BCM1480_MC_tCwD(x) _SB_GETVALUE(x, S_BCM1480_MC_tCwD, M_BCM1480_MC_tCwD)
746#define K_BCM1480_MC_tCwD_DEFAULT 1
747#define V_BCM1480_MC_tCwD_DEFAULT V_BCM1480_MC_tCwD(K_BCM1480_MC_tCwD_DEFAULT)
748
749#define S_BCM1480_MC_tRP 16
750#define M_BCM1480_MC_tRP _SB_MAKEMASK(4, S_BCM1480_MC_tRP)
751#define V_BCM1480_MC_tRP(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tRP)
752#define G_BCM1480_MC_tRP(x) _SB_GETVALUE(x, S_BCM1480_MC_tRP, M_BCM1480_MC_tRP)
753#define K_BCM1480_MC_tRP_DEFAULT 4
754#define V_BCM1480_MC_tRP_DEFAULT V_BCM1480_MC_tRP(K_BCM1480_MC_tRP_DEFAULT)
755
756#define S_BCM1480_MC_tRRD 20
757#define M_BCM1480_MC_tRRD _SB_MAKEMASK(4, S_BCM1480_MC_tRRD)
758#define V_BCM1480_MC_tRRD(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tRRD)
759#define G_BCM1480_MC_tRRD(x) _SB_GETVALUE(x, S_BCM1480_MC_tRRD, M_BCM1480_MC_tRRD)
760#define K_BCM1480_MC_tRRD_DEFAULT 2
761#define V_BCM1480_MC_tRRD_DEFAULT V_BCM1480_MC_tRRD(K_BCM1480_MC_tRRD_DEFAULT)
762
763#define S_BCM1480_MC_tRCw 24
764#define M_BCM1480_MC_tRCw _SB_MAKEMASK(5, S_BCM1480_MC_tRCw)
765#define V_BCM1480_MC_tRCw(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tRCw)
766#define G_BCM1480_MC_tRCw(x) _SB_GETVALUE(x, S_BCM1480_MC_tRCw, M_BCM1480_MC_tRCw)
767#define K_BCM1480_MC_tRCw_DEFAULT 10
768#define V_BCM1480_MC_tRCw_DEFAULT V_BCM1480_MC_tRCw(K_BCM1480_MC_tRCw_DEFAULT)
769
770#define S_BCM1480_MC_tRCr 32
771#define M_BCM1480_MC_tRCr _SB_MAKEMASK(5, S_BCM1480_MC_tRCr)
772#define V_BCM1480_MC_tRCr(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tRCr)
773#define G_BCM1480_MC_tRCr(x) _SB_GETVALUE(x, S_BCM1480_MC_tRCr, M_BCM1480_MC_tRCr)
774#define K_BCM1480_MC_tRCr_DEFAULT 9
775#define V_BCM1480_MC_tRCr_DEFAULT V_BCM1480_MC_tRCr(K_BCM1480_MC_tRCr_DEFAULT)
776
777#if SIBYTE_HDR_FEATURE(1480, PASS2)
778#define S_BCM1480_MC_tFAW 40
779#define M_BCM1480_MC_tFAW _SB_MAKEMASK(6, S_BCM1480_MC_tFAW)
780#define V_BCM1480_MC_tFAW(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tFAW)
781#define G_BCM1480_MC_tFAW(x) _SB_GETVALUE(x, S_BCM1480_MC_tFAW, M_BCM1480_MC_tFAW)
782#define K_BCM1480_MC_tFAW_DEFAULT 0
783#define V_BCM1480_MC_tFAW_DEFAULT V_BCM1480_MC_tFAW(K_BCM1480_MC_tFAW_DEFAULT)
784#endif
785
786#define S_BCM1480_MC_tRFC 48
787#define M_BCM1480_MC_tRFC _SB_MAKEMASK(7, S_BCM1480_MC_tRFC)
788#define V_BCM1480_MC_tRFC(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tRFC)
789#define G_BCM1480_MC_tRFC(x) _SB_GETVALUE(x, S_BCM1480_MC_tRFC, M_BCM1480_MC_tRFC)
790#define K_BCM1480_MC_tRFC_DEFAULT 12
791#define V_BCM1480_MC_tRFC_DEFAULT V_BCM1480_MC_tRFC(K_BCM1480_MC_tRFC_DEFAULT)
792
793#define S_BCM1480_MC_tFIFO 56
794#define M_BCM1480_MC_tFIFO _SB_MAKEMASK(2, S_BCM1480_MC_tFIFO)
795#define V_BCM1480_MC_tFIFO(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tFIFO)
796#define G_BCM1480_MC_tFIFO(x) _SB_GETVALUE(x, S_BCM1480_MC_tFIFO, M_BCM1480_MC_tFIFO)
797#define K_BCM1480_MC_tFIFO_DEFAULT 0
798#define V_BCM1480_MC_tFIFO_DEFAULT V_BCM1480_MC_tFIFO(K_BCM1480_MC_tFIFO_DEFAULT)
799
800#define S_BCM1480_MC_tW2R 58
801#define M_BCM1480_MC_tW2R _SB_MAKEMASK(2, S_BCM1480_MC_tW2R)
802#define V_BCM1480_MC_tW2R(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tW2R)
803#define G_BCM1480_MC_tW2R(x) _SB_GETVALUE(x, S_BCM1480_MC_tW2R, M_BCM1480_MC_tW2R)
804#define K_BCM1480_MC_tW2R_DEFAULT 1
805#define V_BCM1480_MC_tW2R_DEFAULT V_BCM1480_MC_tW2R(K_BCM1480_MC_tW2R_DEFAULT)
806
807#define S_BCM1480_MC_tR2W 60
808#define M_BCM1480_MC_tR2W _SB_MAKEMASK(2, S_BCM1480_MC_tR2W)
809#define V_BCM1480_MC_tR2W(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tR2W)
810#define G_BCM1480_MC_tR2W(x) _SB_GETVALUE(x, S_BCM1480_MC_tR2W, M_BCM1480_MC_tR2W)
811#define K_BCM1480_MC_tR2W_DEFAULT 0
812#define V_BCM1480_MC_tR2W_DEFAULT V_BCM1480_MC_tR2W(K_BCM1480_MC_tR2W_DEFAULT)
813
814#define M_BCM1480_MC_tR2R _SB_MAKEMASK1(62)
815
816#define V_BCM1480_MC_TIMING_DEFAULT (M_BCM1480_MC_tR2R | \
817 V_BCM1480_MC_tFIFO_DEFAULT | \
818 V_BCM1480_MC_tR2W_DEFAULT | \
819 V_BCM1480_MC_tW2R_DEFAULT | \
820 V_BCM1480_MC_tRFC_DEFAULT | \
821 V_BCM1480_MC_tRCr_DEFAULT | \
822 V_BCM1480_MC_tRCw_DEFAULT | \
823 V_BCM1480_MC_tRRD_DEFAULT | \
824 V_BCM1480_MC_tRP_DEFAULT | \
825 V_BCM1480_MC_tCwD_DEFAULT | \
826 V_BCM1480_MC_tWR_DEFAULT | \
827 M_BCM1480_MC_tCrDh | \
828 V_BCM1480_MC_tCL_DEFAULT | \
829 V_BCM1480_MC_tRCD_DEFAULT)
830
831/*
832 * SDRAM Timing Register 2
833 */
834
835#if SIBYTE_HDR_FEATURE(1480, PASS2)
836
837#define S_BCM1480_MC_tAL 0
838#define M_BCM1480_MC_tAL _SB_MAKEMASK(4, S_BCM1480_MC_tAL)
839#define V_BCM1480_MC_tAL(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tAL)
840#define G_BCM1480_MC_tAL(x) _SB_GETVALUE(x, S_BCM1480_MC_tAL, M_BCM1480_MC_tAL)
841#define K_BCM1480_MC_tAL_DEFAULT 0
842#define V_BCM1480_MC_tAL_DEFAULT V_BCM1480_MC_tAL(K_BCM1480_MC_tAL_DEFAULT)
843
844#define S_BCM1480_MC_tRTP 4
845#define M_BCM1480_MC_tRTP _SB_MAKEMASK(3, S_BCM1480_MC_tRTP)
846#define V_BCM1480_MC_tRTP(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tRTP)
847#define G_BCM1480_MC_tRTP(x) _SB_GETVALUE(x, S_BCM1480_MC_tRTP, M_BCM1480_MC_tRTP)
848#define K_BCM1480_MC_tRTP_DEFAULT 2
849#define V_BCM1480_MC_tRTP_DEFAULT V_BCM1480_MC_tRTP(K_BCM1480_MC_tRTP_DEFAULT)
850
851#define S_BCM1480_MC_tW2W 8
852#define M_BCM1480_MC_tW2W _SB_MAKEMASK(2, S_BCM1480_MC_tW2W)
853#define V_BCM1480_MC_tW2W(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tW2W)
854#define G_BCM1480_MC_tW2W(x) _SB_GETVALUE(x, S_BCM1480_MC_tW2W, M_BCM1480_MC_tW2W)
855#define K_BCM1480_MC_tW2W_DEFAULT 0
856#define V_BCM1480_MC_tW2W_DEFAULT V_BCM1480_MC_tW2W(K_BCM1480_MC_tW2W_DEFAULT)
857
858#define S_BCM1480_MC_tRAP 12
859#define M_BCM1480_MC_tRAP _SB_MAKEMASK(4, S_BCM1480_MC_tRAP)
860#define V_BCM1480_MC_tRAP(x) _SB_MAKEVALUE(x, S_BCM1480_MC_tRAP)
861#define G_BCM1480_MC_tRAP(x) _SB_GETVALUE(x, S_BCM1480_MC_tRAP, M_BCM1480_MC_tRAP)
862#define K_BCM1480_MC_tRAP_DEFAULT 0
863#define V_BCM1480_MC_tRAP_DEFAULT V_BCM1480_MC_tRAP(K_BCM1480_MC_tRAP_DEFAULT)
864
865#endif
866
867
868
869/*
870 * Global Registers: single instances per BCM1480
871 */
872
873/*
874 * Global Configuration Register (Table 99)
875 */
876
877#define S_BCM1480_MC_BLK_SET_MARK 8
878#define M_BCM1480_MC_BLK_SET_MARK _SB_MAKEMASK(4, S_BCM1480_MC_BLK_SET_MARK)
879#define V_BCM1480_MC_BLK_SET_MARK(x) _SB_MAKEVALUE(x, S_BCM1480_MC_BLK_SET_MARK)
880#define G_BCM1480_MC_BLK_SET_MARK(x) _SB_GETVALUE(x, S_BCM1480_MC_BLK_SET_MARK, M_BCM1480_MC_BLK_SET_MARK)
881
882#define S_BCM1480_MC_BLK_CLR_MARK 12
883#define M_BCM1480_MC_BLK_CLR_MARK _SB_MAKEMASK(4, S_BCM1480_MC_BLK_CLR_MARK)
884#define V_BCM1480_MC_BLK_CLR_MARK(x) _SB_MAKEVALUE(x, S_BCM1480_MC_BLK_CLR_MARK)
885#define G_BCM1480_MC_BLK_CLR_MARK(x) _SB_GETVALUE(x, S_BCM1480_MC_BLK_CLR_MARK, M_BCM1480_MC_BLK_CLR_MARK)
886
887#define M_BCM1480_MC_PKT_PRIORITY _SB_MAKEMASK1(16)
888
889#define S_BCM1480_MC_MAX_AGE 20
890#define M_BCM1480_MC_MAX_AGE _SB_MAKEMASK(4, S_BCM1480_MC_MAX_AGE)
891#define V_BCM1480_MC_MAX_AGE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_MAX_AGE)
892#define G_BCM1480_MC_MAX_AGE(x) _SB_GETVALUE(x, S_BCM1480_MC_MAX_AGE, M_BCM1480_MC_MAX_AGE)
893
894#define M_BCM1480_MC_BERR_DISABLE _SB_MAKEMASK1(29)
895#define M_BCM1480_MC_FORCE_SEQ _SB_MAKEMASK1(30)
896#define M_BCM1480_MC_VGEN _SB_MAKEMASK1(32)
897
898#define S_BCM1480_MC_SLEW 33
899#define M_BCM1480_MC_SLEW _SB_MAKEMASK(2, S_BCM1480_MC_SLEW)
900#define V_BCM1480_MC_SLEW(x) _SB_MAKEVALUE(x, S_BCM1480_MC_SLEW)
901#define G_BCM1480_MC_SLEW(x) _SB_GETVALUE(x, S_BCM1480_MC_SLEW, M_BCM1480_MC_SLEW)
902
903#define M_BCM1480_MC_SSTL_VOLTAGE _SB_MAKEMASK1(35)
904
905/*
906 * Global Channel Interleave Register (Table 100)
907 */
908
909#define S_BCM1480_MC_INTLV0 0
910#define M_BCM1480_MC_INTLV0 _SB_MAKEMASK(6, S_BCM1480_MC_INTLV0)
911#define V_BCM1480_MC_INTLV0(x) _SB_MAKEVALUE(x, S_BCM1480_MC_INTLV0)
912#define G_BCM1480_MC_INTLV0(x) _SB_GETVALUE(x, S_BCM1480_MC_INTLV0, M_BCM1480_MC_INTLV0)
913
914#define S_BCM1480_MC_INTLV1 8
915#define M_BCM1480_MC_INTLV1 _SB_MAKEMASK(6, S_BCM1480_MC_INTLV1)
916#define V_BCM1480_MC_INTLV1(x) _SB_MAKEVALUE(x, S_BCM1480_MC_INTLV1)
917#define G_BCM1480_MC_INTLV1(x) _SB_GETVALUE(x, S_BCM1480_MC_INTLV1, M_BCM1480_MC_INTLV1)
918
919#define S_BCM1480_MC_INTLV_MODE 16
920#define M_BCM1480_MC_INTLV_MODE _SB_MAKEMASK(3, S_BCM1480_MC_INTLV_MODE)
921#define V_BCM1480_MC_INTLV_MODE(x) _SB_MAKEVALUE(x, S_BCM1480_MC_INTLV_MODE)
922#define G_BCM1480_MC_INTLV_MODE(x) _SB_GETVALUE(x, S_BCM1480_MC_INTLV_MODE, M_BCM1480_MC_INTLV_MODE)
923
924#define K_BCM1480_MC_INTLV_MODE_NONE 0x0
925#define K_BCM1480_MC_INTLV_MODE_01 0x1
926#define K_BCM1480_MC_INTLV_MODE_23 0x2
927#define K_BCM1480_MC_INTLV_MODE_01_23 0x3
928#define K_BCM1480_MC_INTLV_MODE_0123 0x4
929
930#define V_BCM1480_MC_INTLV_MODE_NONE V_BCM1480_MC_INTLV_MODE(K_BCM1480_MC_INTLV_MODE_NONE)
931#define V_BCM1480_MC_INTLV_MODE_01 V_BCM1480_MC_INTLV_MODE(K_BCM1480_MC_INTLV_MODE_01)
932#define V_BCM1480_MC_INTLV_MODE_23 V_BCM1480_MC_INTLV_MODE(K_BCM1480_MC_INTLV_MODE_23)
933#define V_BCM1480_MC_INTLV_MODE_01_23 V_BCM1480_MC_INTLV_MODE(K_BCM1480_MC_INTLV_MODE_01_23)
934#define V_BCM1480_MC_INTLV_MODE_0123 V_BCM1480_MC_INTLV_MODE(K_BCM1480_MC_INTLV_MODE_0123)
935
936/*
937 * ECC Status Register
938 */
939
940#define S_BCM1480_MC_ECC_ERR_ADDR 0
941#define M_BCM1480_MC_ECC_ERR_ADDR _SB_MAKEMASK(37, S_BCM1480_MC_ECC_ERR_ADDR)
942#define V_BCM1480_MC_ECC_ERR_ADDR(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ECC_ERR_ADDR)
943#define G_BCM1480_MC_ECC_ERR_ADDR(x) _SB_GETVALUE(x, S_BCM1480_MC_ECC_ERR_ADDR, M_BCM1480_MC_ECC_ERR_ADDR)
944
945#if SIBYTE_HDR_FEATURE(1480, PASS2)
946#define M_BCM1480_MC_ECC_ERR_RMW _SB_MAKEMASK1(60)
947#endif
948
949#define M_BCM1480_MC_ECC_MULT_ERR_DET _SB_MAKEMASK1(61)
950#define M_BCM1480_MC_ECC_UERR_DET _SB_MAKEMASK1(62)
951#define M_BCM1480_MC_ECC_CERR_DET _SB_MAKEMASK1(63)
952
953/*
954 * Global ECC Address Register (Table 102)
955 */
956
957#define S_BCM1480_MC_ECC_CORR_ADDR 0
958#define M_BCM1480_MC_ECC_CORR_ADDR _SB_MAKEMASK(37, S_BCM1480_MC_ECC_CORR_ADDR)
959#define V_BCM1480_MC_ECC_CORR_ADDR(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ECC_CORR_ADDR)
960#define G_BCM1480_MC_ECC_CORR_ADDR(x) _SB_GETVALUE(x, S_BCM1480_MC_ECC_CORR_ADDR, M_BCM1480_MC_ECC_CORR_ADDR)
961
962/*
963 * Global ECC Correction Register (Table 103)
964 */
965
966#define S_BCM1480_MC_ECC_CORRECT 0
967#define M_BCM1480_MC_ECC_CORRECT _SB_MAKEMASK(64, S_BCM1480_MC_ECC_CORRECT)
968#define V_BCM1480_MC_ECC_CORRECT(x) _SB_MAKEVALUE(x, S_BCM1480_MC_ECC_CORRECT)
969#define G_BCM1480_MC_ECC_CORRECT(x) _SB_GETVALUE(x, S_BCM1480_MC_ECC_CORRECT, M_BCM1480_MC_ECC_CORRECT)
970
971/*
972 * Global ECC Performance Counters Control Register (Table 104)
973 */
974
975#define S_BCM1480_MC_CHANNEL_SELECT 0
976#define M_BCM1480_MC_CHANNEL_SELECT _SB_MAKEMASK(4, S_BCM1480_MC_CHANNEL_SELECT)
977#define V_BCM1480_MC_CHANNEL_SELECT(x) _SB_MAKEVALUE(x, S_BCM1480_MC_CHANNEL_SELECT)
978#define G_BCM1480_MC_CHANNEL_SELECT(x) _SB_GETVALUE(x, S_BCM1480_MC_CHANNEL_SELECT, M_BCM1480_MC_CHANNEL_SELECT)
979#define K_BCM1480_MC_CHANNEL_SELECT_0 0x1
980#define K_BCM1480_MC_CHANNEL_SELECT_1 0x2
981#define K_BCM1480_MC_CHANNEL_SELECT_2 0x4
982#define K_BCM1480_MC_CHANNEL_SELECT_3 0x8
983
984#endif /* _BCM1480_MC_H */
diff --git a/arch/mips/include/asm/sibyte/bcm1480_regs.h b/arch/mips/include/asm/sibyte/bcm1480_regs.h
new file mode 100644
index 000000000000..b4077bb72611
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/bcm1480_regs.h
@@ -0,0 +1,902 @@
1/* *********************************************************************
2 * BCM1255/BCM1280/BCM1455/BCM1480 Board Support Package
3 *
4 * Register Definitions File: bcm1480_regs.h
5 *
6 * This module contains the addresses of the on-chip peripherals
7 * on the BCM1280 and BCM1480.
8 *
9 * BCM1480 specification level: 1X55_1X80-UM100-D4 (11/24/03)
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32#ifndef _BCM1480_REGS_H
33#define _BCM1480_REGS_H
34
35#include "sb1250_defs.h"
36
37/* *********************************************************************
38 * Pull in the BCM1250's registers since a great deal of the 1480's
39 * functions are the same as the BCM1250.
40 ********************************************************************* */
41
42#include "sb1250_regs.h"
43
44
45/* *********************************************************************
46 * Some general notes:
47 *
48 * Register addresses are grouped by function and follow the order
49 * of the User Manual.
50 *
51 * For the most part, when there is more than one peripheral
52 * of the same type on the SOC, the constants below will be
53 * offsets from the base of each peripheral. For example,
54 * the MAC registers are described as offsets from the first
55 * MAC register, and there will be a MAC_REGISTER() macro
56 * to calculate the base address of a given MAC.
57 *
58 * The information in this file is based on the BCM1X55/BCM1X80
59 * User Manual, Document 1X55_1X80-UM100-R, 22/12/03.
60 *
61 * This file is basically a "what's new" header file. Since the
62 * BCM1250 and the new BCM1480 (and derivatives) share many common
63 * features, this file contains only what's new or changed from
64 * the 1250. (above, you can see that we include the 1250 symbols
65 * to get the base functionality).
66 *
67 * In software, be sure to use the correct symbols, particularly
68 * for blocks that are different between the two chip families.
69 * All BCM1480-specific symbols have _BCM1480_ in their names,
70 * and all BCM1250-specific and "base" functions that are common in
71 * both chips have no special names (this is for compatibility with
72 * older include files). Therefore, if you're working with the
73 * SCD, which is very different on each chip, A_SCD_xxx implies
74 * the BCM1250 version and A_BCM1480_SCD_xxx implies the BCM1480
75 * version.
76 ********************************************************************* */
77
78
79/* *********************************************************************
80 * Memory Controller Registers (Section 6)
81 ********************************************************************* */
82
83#define A_BCM1480_MC_BASE_0 0x0010050000
84#define A_BCM1480_MC_BASE_1 0x0010051000
85#define A_BCM1480_MC_BASE_2 0x0010052000
86#define A_BCM1480_MC_BASE_3 0x0010053000
87#define BCM1480_MC_REGISTER_SPACING 0x1000
88
89#define A_BCM1480_MC_BASE(ctlid) (A_BCM1480_MC_BASE_0+(ctlid)*BCM1480_MC_REGISTER_SPACING)
90#define A_BCM1480_MC_REGISTER(ctlid, reg) (A_BCM1480_MC_BASE(ctlid)+(reg))
91
92#define R_BCM1480_MC_CONFIG 0x0000000100
93#define R_BCM1480_MC_CS_START 0x0000000120
94#define R_BCM1480_MC_CS_END 0x0000000140
95#define S_BCM1480_MC_CS_STARTEND 24
96
97#define R_BCM1480_MC_CS01_ROW0 0x0000000180
98#define R_BCM1480_MC_CS01_ROW1 0x00000001A0
99#define R_BCM1480_MC_CS23_ROW0 0x0000000200
100#define R_BCM1480_MC_CS23_ROW1 0x0000000220
101#define R_BCM1480_MC_CS01_COL0 0x0000000280
102#define R_BCM1480_MC_CS01_COL1 0x00000002A0
103#define R_BCM1480_MC_CS23_COL0 0x0000000300
104#define R_BCM1480_MC_CS23_COL1 0x0000000320
105
106#define R_BCM1480_MC_CSX_BASE 0x0000000180
107#define R_BCM1480_MC_CSX_ROW0 0x0000000000 /* relative to CSX_BASE */
108#define R_BCM1480_MC_CSX_ROW1 0x0000000020 /* relative to CSX_BASE */
109#define R_BCM1480_MC_CSX_COL0 0x0000000100 /* relative to CSX_BASE */
110#define R_BCM1480_MC_CSX_COL1 0x0000000120 /* relative to CSX_BASE */
111#define BCM1480_MC_CSX_SPACING 0x0000000080 /* CS23 relative to CS01 */
112
113#define R_BCM1480_MC_CS01_BA 0x0000000380
114#define R_BCM1480_MC_CS23_BA 0x00000003A0
115#define R_BCM1480_MC_DRAMCMD 0x0000000400
116#define R_BCM1480_MC_DRAMMODE 0x0000000420
117#define R_BCM1480_MC_CLOCK_CFG 0x0000000440
118#define R_BCM1480_MC_MCLK_CFG R_BCM1480_MC_CLOCK_CFG
119#define R_BCM1480_MC_TEST_DATA 0x0000000480
120#define R_BCM1480_MC_TEST_ECC 0x00000004A0
121#define R_BCM1480_MC_TIMING1 0x00000004C0
122#define R_BCM1480_MC_TIMING2 0x00000004E0
123#define R_BCM1480_MC_DLL_CFG 0x0000000500
124#define R_BCM1480_MC_DRIVE_CFG 0x0000000520
125
126#if SIBYTE_HDR_FEATURE(1480, PASS2)
127#define R_BCM1480_MC_ODT 0x0000000460
128#define R_BCM1480_MC_ECC_STATUS 0x0000000540
129#endif
130
131/* Global registers (single instance) */
132#define A_BCM1480_MC_GLB_CONFIG 0x0010054100
133#define A_BCM1480_MC_GLB_INTLV 0x0010054120
134#define A_BCM1480_MC_GLB_ECC_STATUS 0x0010054140
135#define A_BCM1480_MC_GLB_ECC_ADDR 0x0010054160
136#define A_BCM1480_MC_GLB_ECC_CORRECT 0x0010054180
137#define A_BCM1480_MC_GLB_PERF_CNT_CONTROL 0x00100541A0
138
139/* *********************************************************************
140 * L2 Cache Control Registers (Section 5)
141 ********************************************************************* */
142
143#define A_BCM1480_L2_BASE 0x0010040000
144
145#define A_BCM1480_L2_READ_TAG 0x0010040018
146#define A_BCM1480_L2_ECC_TAG 0x0010040038
147#define A_BCM1480_L2_MISC0_VALUE 0x0010040058
148#define A_BCM1480_L2_MISC1_VALUE 0x0010040078
149#define A_BCM1480_L2_MISC2_VALUE 0x0010040098
150#define A_BCM1480_L2_MISC_CONFIG 0x0010040040 /* x040 */
151#define A_BCM1480_L2_CACHE_DISABLE 0x0010040060 /* x060 */
152#define A_BCM1480_L2_MAKECACHEDISABLE(x) (A_BCM1480_L2_CACHE_DISABLE | (((x)&0xF) << 12))
153#define A_BCM1480_L2_WAY_ENABLE_3_0 0x0010040080 /* x080 */
154#define A_BCM1480_L2_WAY_ENABLE_7_4 0x00100400A0 /* x0A0 */
155#define A_BCM1480_L2_MAKE_WAY_ENABLE_LO(x) (A_BCM1480_L2_WAY_ENABLE_3_0 | (((x)&0xF) << 12))
156#define A_BCM1480_L2_MAKE_WAY_ENABLE_HI(x) (A_BCM1480_L2_WAY_ENABLE_7_4 | (((x)&0xF) << 12))
157#define A_BCM1480_L2_MAKE_WAY_DISABLE_LO(x) (A_BCM1480_L2_WAY_ENABLE_3_0 | (((~x)&0xF) << 12))
158#define A_BCM1480_L2_MAKE_WAY_DISABLE_HI(x) (A_BCM1480_L2_WAY_ENABLE_7_4 | (((~x)&0xF) << 12))
159#define A_BCM1480_L2_WAY_LOCAL_3_0 0x0010040100 /* x100 */
160#define A_BCM1480_L2_WAY_LOCAL_7_4 0x0010040120 /* x120 */
161#define A_BCM1480_L2_WAY_REMOTE_3_0 0x0010040140 /* x140 */
162#define A_BCM1480_L2_WAY_REMOTE_7_4 0x0010040160 /* x160 */
163#define A_BCM1480_L2_WAY_AGENT_3_0 0x00100400C0 /* xxC0 */
164#define A_BCM1480_L2_WAY_AGENT_7_4 0x00100400E0 /* xxE0 */
165#define A_BCM1480_L2_WAY_ENABLE(A, banks) (A | (((~(banks))&0x0F) << 8))
166#define A_BCM1480_L2_BANK_BASE 0x00D0300000
167#define A_BCM1480_L2_BANK_ADDRESS(b) (A_BCM1480_L2_BANK_BASE | (((b)&0x7)<<17))
168#define A_BCM1480_L2_MGMT_TAG_BASE 0x00D0000000
169
170
171/* *********************************************************************
172 * PCI-X Interface Registers (Section 7)
173 ********************************************************************* */
174
175#define A_BCM1480_PCI_BASE 0x0010061400
176
177#define A_BCM1480_PCI_RESET 0x0010061400
178#define A_BCM1480_PCI_DLL 0x0010061500
179
180#define A_BCM1480_PCI_TYPE00_HEADER 0x002E000000
181
182/* *********************************************************************
183 * Ethernet MAC Registers (Section 11) and DMA Registers (Section 10.6)
184 ********************************************************************* */
185
186/* No register changes with Rev.C BCM1250, but one additional MAC */
187
188#define A_BCM1480_MAC_BASE_2 0x0010066000
189
190#ifndef A_MAC_BASE_2
191#define A_MAC_BASE_2 A_BCM1480_MAC_BASE_2
192#endif
193
194#define A_BCM1480_MAC_BASE_3 0x0010067000
195#define A_MAC_BASE_3 A_BCM1480_MAC_BASE_3
196
197#define R_BCM1480_MAC_DMA_OODPKTLOST 0x00000038
198
199#ifndef R_MAC_DMA_OODPKTLOST
200#define R_MAC_DMA_OODPKTLOST R_BCM1480_MAC_DMA_OODPKTLOST
201#endif
202
203
204/* *********************************************************************
205 * DUART Registers (Section 14)
206 ********************************************************************* */
207
208/* No significant differences from BCM1250, two DUARTs */
209
210/* Conventions, per user manual:
211 * DUART generic, channels A,B,C,D
212 * DUART0 implementing channels A,B
213 * DUART1 inplementing channels C,D
214 */
215
216#define BCM1480_DUART_NUM_PORTS 4
217
218#define A_BCM1480_DUART0 0x0010060000
219#define A_BCM1480_DUART1 0x0010060400
220#define A_BCM1480_DUART(chan) ((((chan)&2) == 0)? A_BCM1480_DUART0 : A_BCM1480_DUART1)
221
222#define BCM1480_DUART_CHANREG_SPACING 0x100
223#define A_BCM1480_DUART_CHANREG(chan, reg) \
224 (A_BCM1480_DUART(chan) + \
225 BCM1480_DUART_CHANREG_SPACING * (((chan) & 1) + 1) + (reg))
226#define A_BCM1480_DUART_CTRLREG(chan, reg) \
227 (A_BCM1480_DUART(chan) + \
228 BCM1480_DUART_CHANREG_SPACING * 3 + (reg))
229
230#define DUART_IMRISR_SPACING 0x20
231#define DUART_INCHNG_SPACING 0x10
232
233#define R_BCM1480_DUART_IMRREG(chan) \
234 (R_DUART_IMR_A + ((chan) & 1) * DUART_IMRISR_SPACING)
235#define R_BCM1480_DUART_ISRREG(chan) \
236 (R_DUART_ISR_A + ((chan) & 1) * DUART_IMRISR_SPACING)
237#define R_BCM1480_DUART_INCHREG(chan) \
238 (R_DUART_IN_CHNG_A + ((chan) & 1) * DUART_INCHNG_SPACING)
239
240#define A_BCM1480_DUART_IMRREG(chan) \
241 (A_BCM1480_DUART_CTRLREG((chan), R_BCM1480_DUART_IMRREG(chan)))
242#define A_BCM1480_DUART_ISRREG(chan) \
243 (A_BCM1480_DUART_CTRLREG((chan), R_BCM1480_DUART_ISRREG(chan)))
244
245#define A_BCM1480_DUART_IN_PORT(chan) \
246 (A_BCM1480_DUART_CTRLREG((chan), R_DUART_IN_PORT))
247
248/*
249 * These constants are the absolute addresses.
250 */
251
252#define A_BCM1480_DUART_MODE_REG_1_C 0x0010060400
253#define A_BCM1480_DUART_MODE_REG_2_C 0x0010060410
254#define A_BCM1480_DUART_STATUS_C 0x0010060420
255#define A_BCM1480_DUART_CLK_SEL_C 0x0010060430
256#define A_BCM1480_DUART_FULL_CTL_C 0x0010060440
257#define A_BCM1480_DUART_CMD_C 0x0010060450
258#define A_BCM1480_DUART_RX_HOLD_C 0x0010060460
259#define A_BCM1480_DUART_TX_HOLD_C 0x0010060470
260#define A_BCM1480_DUART_OPCR_C 0x0010060480
261#define A_BCM1480_DUART_AUX_CTRL_C 0x0010060490
262
263#define A_BCM1480_DUART_MODE_REG_1_D 0x0010060500
264#define A_BCM1480_DUART_MODE_REG_2_D 0x0010060510
265#define A_BCM1480_DUART_STATUS_D 0x0010060520
266#define A_BCM1480_DUART_CLK_SEL_D 0x0010060530
267#define A_BCM1480_DUART_FULL_CTL_D 0x0010060540
268#define A_BCM1480_DUART_CMD_D 0x0010060550
269#define A_BCM1480_DUART_RX_HOLD_D 0x0010060560
270#define A_BCM1480_DUART_TX_HOLD_D 0x0010060570
271#define A_BCM1480_DUART_OPCR_D 0x0010060580
272#define A_BCM1480_DUART_AUX_CTRL_D 0x0010060590
273
274#define A_BCM1480_DUART_INPORT_CHNG_CD 0x0010060600
275#define A_BCM1480_DUART_AUX_CTRL_CD 0x0010060610
276#define A_BCM1480_DUART_ISR_C 0x0010060620
277#define A_BCM1480_DUART_IMR_C 0x0010060630
278#define A_BCM1480_DUART_ISR_D 0x0010060640
279#define A_BCM1480_DUART_IMR_D 0x0010060650
280#define A_BCM1480_DUART_OUT_PORT_CD 0x0010060660
281#define A_BCM1480_DUART_OPCR_CD 0x0010060670
282#define A_BCM1480_DUART_IN_PORT_CD 0x0010060680
283#define A_BCM1480_DUART_ISR_CD 0x0010060690
284#define A_BCM1480_DUART_IMR_CD 0x00100606A0
285#define A_BCM1480_DUART_SET_OPR_CD 0x00100606B0
286#define A_BCM1480_DUART_CLEAR_OPR_CD 0x00100606C0
287#define A_BCM1480_DUART_INPORT_CHNG_C 0x00100606D0
288#define A_BCM1480_DUART_INPORT_CHNG_D 0x00100606E0
289
290
291/* *********************************************************************
292 * Generic Bus Registers (Section 15) and PCMCIA Registers (Section 16)
293 ********************************************************************* */
294
295#define A_BCM1480_IO_PCMCIA_CFG_B 0x0010061A58
296#define A_BCM1480_IO_PCMCIA_STATUS_B 0x0010061A68
297
298/* *********************************************************************
299 * GPIO Registers (Section 17)
300 ********************************************************************* */
301
302/* One additional GPIO register, placed _before_ the BCM1250's GPIO block base */
303
304#define A_BCM1480_GPIO_INT_ADD_TYPE 0x0010061A78
305#define R_BCM1480_GPIO_INT_ADD_TYPE (-8)
306
307#define A_GPIO_INT_ADD_TYPE A_BCM1480_GPIO_INT_ADD_TYPE
308#define R_GPIO_INT_ADD_TYPE R_BCM1480_GPIO_INT_ADD_TYPE
309
310/* *********************************************************************
311 * SMBus Registers (Section 18)
312 ********************************************************************* */
313
314/* No changes from BCM1250 */
315
316/* *********************************************************************
317 * Timer Registers (Sections 4.6)
318 ********************************************************************* */
319
320/* BCM1480 has two additional watchdogs */
321
322/* Watchdog timers */
323
324#define A_BCM1480_SCD_WDOG_2 0x0010022050
325#define A_BCM1480_SCD_WDOG_3 0x0010022150
326
327#define BCM1480_SCD_NUM_WDOGS 4
328
329#define A_BCM1480_SCD_WDOG_BASE(w) (A_BCM1480_SCD_WDOG_0+((w)&2)*0x1000 + ((w)&1)*0x100)
330#define A_BCM1480_SCD_WDOG_REGISTER(w, r) (A_BCM1480_SCD_WDOG_BASE(w) + (r))
331
332#define A_BCM1480_SCD_WDOG_INIT_2 0x0010022050
333#define A_BCM1480_SCD_WDOG_CNT_2 0x0010022058
334#define A_BCM1480_SCD_WDOG_CFG_2 0x0010022060
335
336#define A_BCM1480_SCD_WDOG_INIT_3 0x0010022150
337#define A_BCM1480_SCD_WDOG_CNT_3 0x0010022158
338#define A_BCM1480_SCD_WDOG_CFG_3 0x0010022160
339
340/* BCM1480 has two additional compare registers */
341
342#define A_BCM1480_SCD_ZBBUS_CYCLE_COUNT A_SCD_ZBBUS_CYCLE_COUNT
343#define A_BCM1480_SCD_ZBBUS_CYCLE_CP_BASE 0x0010020C00
344#define A_BCM1480_SCD_ZBBUS_CYCLE_CP0 A_SCD_ZBBUS_CYCLE_CP0
345#define A_BCM1480_SCD_ZBBUS_CYCLE_CP1 A_SCD_ZBBUS_CYCLE_CP1
346#define A_BCM1480_SCD_ZBBUS_CYCLE_CP2 0x0010020C10
347#define A_BCM1480_SCD_ZBBUS_CYCLE_CP3 0x0010020C18
348
349/* *********************************************************************
350 * System Control Registers (Section 4.2)
351 ********************************************************************* */
352
353/* Scratch register in different place */
354
355#define A_BCM1480_SCD_SCRATCH 0x100200A0
356
357/* *********************************************************************
358 * System Address Trap Registers (Section 4.9)
359 ********************************************************************* */
360
361/* No changes from BCM1250 */
362
363/* *********************************************************************
364 * System Interrupt Mapper Registers (Sections 4.3-4.5)
365 ********************************************************************* */
366
367#define A_BCM1480_IMR_CPU0_BASE 0x0010020000
368#define A_BCM1480_IMR_CPU1_BASE 0x0010022000
369#define A_BCM1480_IMR_CPU2_BASE 0x0010024000
370#define A_BCM1480_IMR_CPU3_BASE 0x0010026000
371#define BCM1480_IMR_REGISTER_SPACING 0x2000
372#define BCM1480_IMR_REGISTER_SPACING_SHIFT 13
373
374#define A_BCM1480_IMR_MAPPER(cpu) (A_BCM1480_IMR_CPU0_BASE+(cpu)*BCM1480_IMR_REGISTER_SPACING)
375#define A_BCM1480_IMR_REGISTER(cpu, reg) (A_BCM1480_IMR_MAPPER(cpu)+(reg))
376
377/* Most IMR registers are 128 bits, implemented as non-contiguous
378 64-bit registers high (_H) and low (_L) */
379#define BCM1480_IMR_HL_SPACING 0x1000
380
381#define R_BCM1480_IMR_INTERRUPT_DIAG_H 0x0010
382#define R_BCM1480_IMR_LDT_INTERRUPT_H 0x0018
383#define R_BCM1480_IMR_LDT_INTERRUPT_CLR_H 0x0020
384#define R_BCM1480_IMR_INTERRUPT_MASK_H 0x0028
385#define R_BCM1480_IMR_INTERRUPT_TRACE_H 0x0038
386#define R_BCM1480_IMR_INTERRUPT_SOURCE_STATUS_H 0x0040
387#define R_BCM1480_IMR_LDT_INTERRUPT_SET 0x0048
388#define R_BCM1480_IMR_MAILBOX_0_CPU 0x00C0
389#define R_BCM1480_IMR_MAILBOX_0_SET_CPU 0x00C8
390#define R_BCM1480_IMR_MAILBOX_0_CLR_CPU 0x00D0
391#define R_BCM1480_IMR_MAILBOX_1_CPU 0x00E0
392#define R_BCM1480_IMR_MAILBOX_1_SET_CPU 0x00E8
393#define R_BCM1480_IMR_MAILBOX_1_CLR_CPU 0x00F0
394#define R_BCM1480_IMR_INTERRUPT_STATUS_BASE_H 0x0100
395#define BCM1480_IMR_INTERRUPT_STATUS_COUNT 8
396#define R_BCM1480_IMR_INTERRUPT_MAP_BASE_H 0x0200
397#define BCM1480_IMR_INTERRUPT_MAP_COUNT 64
398
399#define R_BCM1480_IMR_INTERRUPT_DIAG_L 0x1010
400#define R_BCM1480_IMR_LDT_INTERRUPT_L 0x1018
401#define R_BCM1480_IMR_LDT_INTERRUPT_CLR_L 0x1020
402#define R_BCM1480_IMR_INTERRUPT_MASK_L 0x1028
403#define R_BCM1480_IMR_INTERRUPT_TRACE_L 0x1038
404#define R_BCM1480_IMR_INTERRUPT_SOURCE_STATUS_L 0x1040
405#define R_BCM1480_IMR_INTERRUPT_STATUS_BASE_L 0x1100
406#define R_BCM1480_IMR_INTERRUPT_MAP_BASE_L 0x1200
407
408#define A_BCM1480_IMR_ALIAS_MAILBOX_CPU0_BASE 0x0010028000
409#define A_BCM1480_IMR_ALIAS_MAILBOX_CPU1_BASE 0x0010028100
410#define A_BCM1480_IMR_ALIAS_MAILBOX_CPU2_BASE 0x0010028200
411#define A_BCM1480_IMR_ALIAS_MAILBOX_CPU3_BASE 0x0010028300
412#define BCM1480_IMR_ALIAS_MAILBOX_SPACING 0100
413
414#define A_BCM1480_IMR_ALIAS_MAILBOX(cpu) (A_BCM1480_IMR_ALIAS_MAILBOX_CPU0_BASE + \
415 (cpu)*BCM1480_IMR_ALIAS_MAILBOX_SPACING)
416#define A_BCM1480_IMR_ALIAS_MAILBOX_REGISTER(cpu, reg) (A_BCM1480_IMR_ALIAS_MAILBOX(cpu)+(reg))
417
418#define R_BCM1480_IMR_ALIAS_MAILBOX_0 0x0000 /* 0x0x0 */
419#define R_BCM1480_IMR_ALIAS_MAILBOX_0_SET 0x0008 /* 0x0x8 */
420
421/*
422 * these macros work together to build the address of a mailbox
423 * register, e.g., A_BCM1480_MAILBOX_REGISTER(0,R_BCM1480_IMR_MAILBOX_SET,2)
424 * for mbox_0_set_cpu2 returns 0x00100240C8
425 */
426#define R_BCM1480_IMR_MAILBOX_CPU 0x00
427#define R_BCM1480_IMR_MAILBOX_SET 0x08
428#define R_BCM1480_IMR_MAILBOX_CLR 0x10
429#define R_BCM1480_IMR_MAILBOX_NUM_SPACING 0x20
430#define A_BCM1480_MAILBOX_REGISTER(num, reg, cpu) \
431 (A_BCM1480_IMR_CPU0_BASE + \
432 (num * R_BCM1480_IMR_MAILBOX_NUM_SPACING) + \
433 (cpu * BCM1480_IMR_REGISTER_SPACING) + \
434 (R_BCM1480_IMR_MAILBOX_0_CPU + reg))
435
436/* *********************************************************************
437 * System Performance Counter Registers (Section 4.7)
438 ********************************************************************* */
439
440/* BCM1480 has four more performance counter registers, and two control
441 registers. */
442
443#define A_BCM1480_SCD_PERF_CNT_BASE 0x00100204C0
444
445#define A_BCM1480_SCD_PERF_CNT_CFG0 0x00100204C0
446#define A_BCM1480_SCD_PERF_CNT_CFG_0 A_BCM1480_SCD_PERF_CNT_CFG0
447#define A_BCM1480_SCD_PERF_CNT_CFG1 0x00100204C8
448#define A_BCM1480_SCD_PERF_CNT_CFG_1 A_BCM1480_SCD_PERF_CNT_CFG1
449
450#define A_BCM1480_SCD_PERF_CNT_0 A_SCD_PERF_CNT_0
451#define A_BCM1480_SCD_PERF_CNT_1 A_SCD_PERF_CNT_1
452#define A_BCM1480_SCD_PERF_CNT_2 A_SCD_PERF_CNT_2
453#define A_BCM1480_SCD_PERF_CNT_3 A_SCD_PERF_CNT_3
454
455#define A_BCM1480_SCD_PERF_CNT_4 0x00100204F0
456#define A_BCM1480_SCD_PERF_CNT_5 0x00100204F8
457#define A_BCM1480_SCD_PERF_CNT_6 0x0010020500
458#define A_BCM1480_SCD_PERF_CNT_7 0x0010020508
459
460#define BCM1480_SCD_NUM_PERF_CNT 8
461#define BCM1480_SCD_PERF_CNT_SPACING 8
462#define A_BCM1480_SCD_PERF_CNT(n) (A_SCD_PERF_CNT_0+(n*BCM1480_SCD_PERF_CNT_SPACING))
463
464/* *********************************************************************
465 * System Bus Watcher Registers (Section 4.8)
466 ********************************************************************* */
467
468
469/* Same as 1250 except BUS_ERR_STATUS_DEBUG is in a different place. */
470
471#define A_BCM1480_BUS_ERR_STATUS_DEBUG 0x00100208D8
472
473/* *********************************************************************
474 * System Debug Controller Registers (Section 19)
475 ********************************************************************* */
476
477/* Same as 1250 */
478
479/* *********************************************************************
480 * System Trace Unit Registers (Sections 4.10)
481 ********************************************************************* */
482
483/* Same as 1250 */
484
485/* *********************************************************************
486 * Data Mover DMA Registers (Section 10.7)
487 ********************************************************************* */
488
489/* Same as 1250 */
490
491
492/* *********************************************************************
493 * HyperTransport Interface Registers (Section 8)
494 ********************************************************************* */
495
496#define BCM1480_HT_NUM_PORTS 3
497#define BCM1480_HT_PORT_SPACING 0x800
498#define A_BCM1480_HT_PORT_HEADER(x) (A_BCM1480_HT_PORT0_HEADER + ((x)*BCM1480_HT_PORT_SPACING))
499
500#define A_BCM1480_HT_PORT0_HEADER 0x00FE000000
501#define A_BCM1480_HT_PORT1_HEADER 0x00FE000800
502#define A_BCM1480_HT_PORT2_HEADER 0x00FE001000
503#define A_BCM1480_HT_TYPE00_HEADER 0x00FE002000
504
505
506/* *********************************************************************
507 * Node Controller Registers (Section 9)
508 ********************************************************************* */
509
510#define A_BCM1480_NC_BASE 0x00DFBD0000
511
512#define A_BCM1480_NC_RLD_FIELD 0x00DFBD0000
513#define A_BCM1480_NC_RLD_TRIGGER 0x00DFBD0020
514#define A_BCM1480_NC_RLD_BAD_ERROR 0x00DFBD0040
515#define A_BCM1480_NC_RLD_COR_ERROR 0x00DFBD0060
516#define A_BCM1480_NC_RLD_ECC_STATUS 0x00DFBD0080
517#define A_BCM1480_NC_RLD_WAY_ENABLE 0x00DFBD00A0
518#define A_BCM1480_NC_RLD_RANDOM_LFSR 0x00DFBD00C0
519
520#define A_BCM1480_NC_INTERRUPT_STATUS 0x00DFBD00E0
521#define A_BCM1480_NC_INTERRUPT_ENABLE 0x00DFBD0100
522#define A_BCM1480_NC_TIMEOUT_COUNTER 0x00DFBD0120
523#define A_BCM1480_NC_TIMEOUT_COUNTER_SEL 0x00DFBD0140
524
525#define A_BCM1480_NC_CREDIT_STATUS_REG0 0x00DFBD0200
526#define A_BCM1480_NC_CREDIT_STATUS_REG1 0x00DFBD0220
527#define A_BCM1480_NC_CREDIT_STATUS_REG2 0x00DFBD0240
528#define A_BCM1480_NC_CREDIT_STATUS_REG3 0x00DFBD0260
529#define A_BCM1480_NC_CREDIT_STATUS_REG4 0x00DFBD0280
530#define A_BCM1480_NC_CREDIT_STATUS_REG5 0x00DFBD02A0
531#define A_BCM1480_NC_CREDIT_STATUS_REG6 0x00DFBD02C0
532#define A_BCM1480_NC_CREDIT_STATUS_REG7 0x00DFBD02E0
533#define A_BCM1480_NC_CREDIT_STATUS_REG8 0x00DFBD0300
534#define A_BCM1480_NC_CREDIT_STATUS_REG9 0x00DFBD0320
535#define A_BCM1480_NC_CREDIT_STATUS_REG10 0x00DFBE0000
536#define A_BCM1480_NC_CREDIT_STATUS_REG11 0x00DFBE0020
537#define A_BCM1480_NC_CREDIT_STATUS_REG12 0x00DFBE0040
538
539#define A_BCM1480_NC_SR_TIMEOUT_COUNTER 0x00DFBE0060
540#define A_BCM1480_NC_SR_TIMEOUT_COUNTER_SEL 0x00DFBE0080
541
542
543/* *********************************************************************
544 * H&R Block Configuration Registers (Section 12.4)
545 ********************************************************************* */
546
547#define A_BCM1480_HR_BASE_0 0x00DF820000
548#define A_BCM1480_HR_BASE_1 0x00DF8A0000
549#define A_BCM1480_HR_BASE_2 0x00DF920000
550#define BCM1480_HR_REGISTER_SPACING 0x80000
551
552#define A_BCM1480_HR_BASE(idx) (A_BCM1480_HR_BASE_0 + ((idx)*BCM1480_HR_REGISTER_SPACING))
553#define A_BCM1480_HR_REGISTER(idx, reg) (A_BCM1480_HR_BASE(idx) + (reg))
554
555#define R_BCM1480_HR_CFG 0x0000000000
556
557#define R_BCM1480_HR_MAPPING 0x0000010010
558
559#define BCM1480_HR_RULE_SPACING 0x0000000010
560#define BCM1480_HR_NUM_RULES 16
561#define BCM1480_HR_OP_OFFSET 0x0000000100
562#define BCM1480_HR_TYPE_OFFSET 0x0000000108
563#define R_BCM1480_HR_RULE_OP(idx) (BCM1480_HR_OP_OFFSET + ((idx)*BCM1480_HR_RULE_SPACING))
564#define R_BCM1480_HR_RULE_TYPE(idx) (BCM1480_HR_TYPE_OFFSET + ((idx)*BCM1480_HR_RULE_SPACING))
565
566#define BCM1480_HR_LEAF_SPACING 0x0000000010
567#define BCM1480_HR_NUM_LEAVES 10
568#define BCM1480_HR_LEAF_OFFSET 0x0000000300
569#define R_BCM1480_HR_HA_LEAF0(idx) (BCM1480_HR_LEAF_OFFSET + ((idx)*BCM1480_HR_LEAF_SPACING))
570
571#define R_BCM1480_HR_EX_LEAF0 0x00000003A0
572
573#define BCM1480_HR_PATH_SPACING 0x0000000010
574#define BCM1480_HR_NUM_PATHS 16
575#define BCM1480_HR_PATH_OFFSET 0x0000000600
576#define R_BCM1480_HR_PATH(idx) (BCM1480_HR_PATH_OFFSET + ((idx)*BCM1480_HR_PATH_SPACING))
577
578#define R_BCM1480_HR_PATH_DEFAULT 0x0000000700
579
580#define BCM1480_HR_ROUTE_SPACING 8
581#define BCM1480_HR_NUM_ROUTES 512
582#define BCM1480_HR_ROUTE_OFFSET 0x0000001000
583#define R_BCM1480_HR_RT_WORD(idx) (BCM1480_HR_ROUTE_OFFSET + ((idx)*BCM1480_HR_ROUTE_SPACING))
584
585
586/* checked to here - ehs */
587/* *********************************************************************
588 * Packet Manager DMA Registers (Section 12.5)
589 ********************************************************************* */
590
591#define A_BCM1480_PM_BASE 0x0010056000
592
593#define A_BCM1480_PMI_LCL_0 0x0010058000
594#define A_BCM1480_PMO_LCL_0 0x001005C000
595#define A_BCM1480_PMI_OFFSET_0 (A_BCM1480_PMI_LCL_0 - A_BCM1480_PM_BASE)
596#define A_BCM1480_PMO_OFFSET_0 (A_BCM1480_PMO_LCL_0 - A_BCM1480_PM_BASE)
597
598#define BCM1480_PM_LCL_REGISTER_SPACING 0x100
599#define BCM1480_PM_NUM_CHANNELS 32
600
601#define A_BCM1480_PMI_LCL_BASE(idx) (A_BCM1480_PMI_LCL_0 + ((idx)*BCM1480_PM_LCL_REGISTER_SPACING))
602#define A_BCM1480_PMI_LCL_REGISTER(idx, reg) (A_BCM1480_PMI_LCL_BASE(idx) + (reg))
603#define A_BCM1480_PMO_LCL_BASE(idx) (A_BCM1480_PMO_LCL_0 + ((idx)*BCM1480_PM_LCL_REGISTER_SPACING))
604#define A_BCM1480_PMO_LCL_REGISTER(idx, reg) (A_BCM1480_PMO_LCL_BASE(idx) + (reg))
605
606#define BCM1480_PM_INT_PACKING 8
607#define BCM1480_PM_INT_FUNCTION_SPACING 0x40
608#define BCM1480_PM_INT_NUM_FUNCTIONS 3
609
610/*
611 * DMA channel registers relative to A_BCM1480_PMI_LCL_BASE(n) and A_BCM1480_PMO_LCL_BASE(n)
612 */
613
614#define R_BCM1480_PM_BASE_SIZE 0x0000000000
615#define R_BCM1480_PM_CNT 0x0000000008
616#define R_BCM1480_PM_PFCNT 0x0000000010
617#define R_BCM1480_PM_LAST 0x0000000018
618#define R_BCM1480_PM_PFINDX 0x0000000020
619#define R_BCM1480_PM_INT_WMK 0x0000000028
620#define R_BCM1480_PM_CONFIG0 0x0000000030
621#define R_BCM1480_PM_LOCALDEBUG 0x0000000078
622#define R_BCM1480_PM_CACHEABILITY 0x0000000080 /* PMI only */
623#define R_BCM1480_PM_INT_CNFG 0x0000000088
624#define R_BCM1480_PM_DESC_MERGE_TIMER 0x0000000090
625#define R_BCM1480_PM_LOCALDEBUG_PIB 0x00000000F8 /* PMI only */
626#define R_BCM1480_PM_LOCALDEBUG_POB 0x00000000F8 /* PMO only */
627
628/*
629 * Global Registers (Not Channelized)
630 */
631
632#define A_BCM1480_PMI_GLB_0 0x0010056000
633#define A_BCM1480_PMO_GLB_0 0x0010057000
634
635/*
636 * PM to TX Mapping Register relative to A_BCM1480_PMI_GLB_0 and A_BCM1480_PMO_GLB_0
637 */
638
639#define R_BCM1480_PM_PMO_MAPPING 0x00000008C8 /* PMO only */
640
641#define A_BCM1480_PM_PMO_MAPPING (A_BCM1480_PMO_GLB_0 + R_BCM1480_PM_PMO_MAPPING)
642
643/*
644 * Interrupt mapping registers
645 */
646
647
648#define A_BCM1480_PMI_INT_0 0x0010056800
649#define A_BCM1480_PMI_INT(q) (A_BCM1480_PMI_INT_0 + ((q>>8)<<8))
650#define A_BCM1480_PMI_INT_OFFSET_0 (A_BCM1480_PMI_INT_0 - A_BCM1480_PM_BASE)
651#define A_BCM1480_PMO_INT_0 0x0010057800
652#define A_BCM1480_PMO_INT(q) (A_BCM1480_PMO_INT_0 + ((q>>8)<<8))
653#define A_BCM1480_PMO_INT_OFFSET_0 (A_BCM1480_PMO_INT_0 - A_BCM1480_PM_BASE)
654
655/*
656 * Interrupt registers relative to A_BCM1480_PMI_INT_0 and A_BCM1480_PMO_INT_0
657 */
658
659#define R_BCM1480_PM_INT_ST 0x0000000000
660#define R_BCM1480_PM_INT_MSK 0x0000000040
661#define R_BCM1480_PM_INT_CLR 0x0000000080
662#define R_BCM1480_PM_MRGD_INT 0x00000000C0
663
664/*
665 * Debug registers (global)
666 */
667
668#define A_BCM1480_PM_GLOBALDEBUGMODE_PMI 0x0010056000
669#define A_BCM1480_PM_GLOBALDEBUG_PID 0x00100567F8
670#define A_BCM1480_PM_GLOBALDEBUG_PIB 0x0010056FF8
671#define A_BCM1480_PM_GLOBALDEBUGMODE_PMO 0x0010057000
672#define A_BCM1480_PM_GLOBALDEBUG_POD 0x00100577F8
673#define A_BCM1480_PM_GLOBALDEBUG_POB 0x0010057FF8
674
675/* *********************************************************************
676 * Switch performance counters
677 ********************************************************************* */
678
679#define A_BCM1480_SWPERF_CFG 0xdfb91800
680#define A_BCM1480_SWPERF_CNT0 0xdfb91880
681#define A_BCM1480_SWPERF_CNT1 0xdfb91888
682#define A_BCM1480_SWPERF_CNT2 0xdfb91890
683#define A_BCM1480_SWPERF_CNT3 0xdfb91898
684
685
686/* *********************************************************************
687 * Switch Trace Unit
688 ********************************************************************* */
689
690#define A_BCM1480_SWTRC_MATCH_CONTROL_0 0xDFB91000
691#define A_BCM1480_SWTRC_MATCH_DATA_VALUE_0 0xDFB91100
692#define A_BCM1480_SWTRC_MATCH_DATA_MASK_0 0xDFB91108
693#define A_BCM1480_SWTRC_MATCH_TAG_VALUE_0 0xDFB91200
694#define A_BCM1480_SWTRC_MATCH_TAG_MAKS_0 0xDFB91208
695#define A_BCM1480_SWTRC_EVENT_0 0xDFB91300
696#define A_BCM1480_SWTRC_SEQUENCE_0 0xDFB91400
697
698#define A_BCM1480_SWTRC_CFG 0xDFB91500
699#define A_BCM1480_SWTRC_READ 0xDFB91508
700
701#define A_BCM1480_SWDEBUG_SCHEDSTOP 0xDFB92000
702
703#define A_BCM1480_SWTRC_MATCH_CONTROL(x) (A_BCM1480_SWTRC_MATCH_CONTROL_0 + ((x)*8))
704#define A_BCM1480_SWTRC_EVENT(x) (A_BCM1480_SWTRC_EVENT_0 + ((x)*8))
705#define A_BCM1480_SWTRC_SEQUENCE(x) (A_BCM1480_SWTRC_SEQUENCE_0 + ((x)*8))
706
707#define A_BCM1480_SWTRC_MATCH_DATA_VALUE(x) (A_BCM1480_SWTRC_MATCH_DATA_VALUE_0 + ((x)*16))
708#define A_BCM1480_SWTRC_MATCH_DATA_MASK(x) (A_BCM1480_SWTRC_MATCH_DATA_MASK_0 + ((x)*16))
709#define A_BCM1480_SWTRC_MATCH_TAG_VALUE(x) (A_BCM1480_SWTRC_MATCH_TAG_VALUE_0 + ((x)*16))
710#define A_BCM1480_SWTRC_MATCH_TAG_MASK(x) (A_BCM1480_SWTRC_MATCH_TAG_MASK_0 + ((x)*16))
711
712
713
714/* *********************************************************************
715 * High-Speed Port Registers (Section 13)
716 ********************************************************************* */
717
718#define A_BCM1480_HSP_BASE_0 0x00DF810000
719#define A_BCM1480_HSP_BASE_1 0x00DF890000
720#define A_BCM1480_HSP_BASE_2 0x00DF910000
721#define BCM1480_HSP_REGISTER_SPACING 0x80000
722
723#define A_BCM1480_HSP_BASE(idx) (A_BCM1480_HSP_BASE_0 + ((idx)*BCM1480_HSP_REGISTER_SPACING))
724#define A_BCM1480_HSP_REGISTER(idx, reg) (A_BCM1480_HSP_BASE(idx) + (reg))
725
726#define R_BCM1480_HSP_RX_SPI4_CFG_0 0x0000000000
727#define R_BCM1480_HSP_RX_SPI4_CFG_1 0x0000000008
728#define R_BCM1480_HSP_RX_SPI4_DESKEW_OVERRIDE 0x0000000010
729#define R_BCM1480_HSP_RX_SPI4_DESKEW_DATAPATH 0x0000000018
730#define R_BCM1480_HSP_RX_SPI4_PORT_INT_EN 0x0000000020
731#define R_BCM1480_HSP_RX_SPI4_PORT_INT_STATUS 0x0000000028
732
733#define R_BCM1480_HSP_RX_SPI4_CALENDAR_0 0x0000000200
734#define R_BCM1480_HSP_RX_SPI4_CALENDAR_1 0x0000000208
735
736#define R_BCM1480_HSP_RX_PLL_CNFG 0x0000000800
737#define R_BCM1480_HSP_RX_CALIBRATION 0x0000000808
738#define R_BCM1480_HSP_RX_TEST 0x0000000810
739#define R_BCM1480_HSP_RX_DIAG_DETAILS 0x0000000818
740#define R_BCM1480_HSP_RX_DIAG_CRC_0 0x0000000820
741#define R_BCM1480_HSP_RX_DIAG_CRC_1 0x0000000828
742#define R_BCM1480_HSP_RX_DIAG_HTCMD 0x0000000830
743#define R_BCM1480_HSP_RX_DIAG_PKTCTL 0x0000000838
744
745#define R_BCM1480_HSP_RX_VIS_FLCTRL_COUNTER 0x0000000870
746
747#define R_BCM1480_HSP_RX_PKT_RAMALLOC_0 0x0000020020
748#define R_BCM1480_HSP_RX_PKT_RAMALLOC_1 0x0000020028
749#define R_BCM1480_HSP_RX_PKT_RAMALLOC_2 0x0000020030
750#define R_BCM1480_HSP_RX_PKT_RAMALLOC_3 0x0000020038
751#define R_BCM1480_HSP_RX_PKT_RAMALLOC_4 0x0000020040
752#define R_BCM1480_HSP_RX_PKT_RAMALLOC_5 0x0000020048
753#define R_BCM1480_HSP_RX_PKT_RAMALLOC_6 0x0000020050
754#define R_BCM1480_HSP_RX_PKT_RAMALLOC_7 0x0000020058
755#define R_BCM1480_HSP_RX_PKT_RAMALLOC(idx) (R_BCM1480_HSP_RX_PKT_RAMALLOC_0 + 8*(idx))
756
757/* XXX Following registers were shuffled. Renamed/renumbered per errata. */
758#define R_BCM1480_HSP_RX_HT_RAMALLOC_0 0x0000020078
759#define R_BCM1480_HSP_RX_HT_RAMALLOC_1 0x0000020080
760#define R_BCM1480_HSP_RX_HT_RAMALLOC_2 0x0000020088
761#define R_BCM1480_HSP_RX_HT_RAMALLOC_3 0x0000020090
762#define R_BCM1480_HSP_RX_HT_RAMALLOC_4 0x0000020098
763#define R_BCM1480_HSP_RX_HT_RAMALLOC_5 0x00000200A0
764
765#define R_BCM1480_HSP_RX_SPI_WATERMARK_0 0x00000200B0
766#define R_BCM1480_HSP_RX_SPI_WATERMARK_1 0x00000200B8
767#define R_BCM1480_HSP_RX_SPI_WATERMARK_2 0x00000200C0
768#define R_BCM1480_HSP_RX_SPI_WATERMARK_3 0x00000200C8
769#define R_BCM1480_HSP_RX_SPI_WATERMARK_4 0x00000200D0
770#define R_BCM1480_HSP_RX_SPI_WATERMARK_5 0x00000200D8
771#define R_BCM1480_HSP_RX_SPI_WATERMARK_6 0x00000200E0
772#define R_BCM1480_HSP_RX_SPI_WATERMARK_7 0x00000200E8
773#define R_BCM1480_HSP_RX_SPI_WATERMARK(idx) (R_BCM1480_HSP_RX_SPI_WATERMARK_0 + 8*(idx))
774
775#define R_BCM1480_HSP_RX_VIS_CMDQ_0 0x00000200F0
776#define R_BCM1480_HSP_RX_VIS_CMDQ_1 0x00000200F8
777#define R_BCM1480_HSP_RX_VIS_CMDQ_2 0x0000020100
778#define R_BCM1480_HSP_RX_RAM_READCTL 0x0000020108
779#define R_BCM1480_HSP_RX_RAM_READWINDOW 0x0000020110
780#define R_BCM1480_HSP_RX_RF_READCTL 0x0000020118
781#define R_BCM1480_HSP_RX_RF_READWINDOW 0x0000020120
782
783#define R_BCM1480_HSP_TX_SPI4_CFG_0 0x0000040000
784#define R_BCM1480_HSP_TX_SPI4_CFG_1 0x0000040008
785#define R_BCM1480_HSP_TX_SPI4_TRAINING_FMT 0x0000040010
786
787#define R_BCM1480_HSP_TX_PKT_RAMALLOC_0 0x0000040020
788#define R_BCM1480_HSP_TX_PKT_RAMALLOC_1 0x0000040028
789#define R_BCM1480_HSP_TX_PKT_RAMALLOC_2 0x0000040030
790#define R_BCM1480_HSP_TX_PKT_RAMALLOC_3 0x0000040038
791#define R_BCM1480_HSP_TX_PKT_RAMALLOC_4 0x0000040040
792#define R_BCM1480_HSP_TX_PKT_RAMALLOC_5 0x0000040048
793#define R_BCM1480_HSP_TX_PKT_RAMALLOC_6 0x0000040050
794#define R_BCM1480_HSP_TX_PKT_RAMALLOC_7 0x0000040058
795#define R_BCM1480_HSP_TX_PKT_RAMALLOC(idx) (R_BCM1480_HSP_TX_PKT_RAMALLOC_0 + 8*(idx))
796#define R_BCM1480_HSP_TX_NPC_RAMALLOC 0x0000040078
797#define R_BCM1480_HSP_TX_RSP_RAMALLOC 0x0000040080
798#define R_BCM1480_HSP_TX_PC_RAMALLOC 0x0000040088
799#define R_BCM1480_HSP_TX_HTCC_RAMALLOC_0 0x0000040090
800#define R_BCM1480_HSP_TX_HTCC_RAMALLOC_1 0x0000040098
801#define R_BCM1480_HSP_TX_HTCC_RAMALLOC_2 0x00000400A0
802
803#define R_BCM1480_HSP_TX_PKT_RXPHITCNT_0 0x00000400B0
804#define R_BCM1480_HSP_TX_PKT_RXPHITCNT_1 0x00000400B8
805#define R_BCM1480_HSP_TX_PKT_RXPHITCNT_2 0x00000400C0
806#define R_BCM1480_HSP_TX_PKT_RXPHITCNT_3 0x00000400C8
807#define R_BCM1480_HSP_TX_PKT_RXPHITCNT(idx) (R_BCM1480_HSP_TX_PKT_RXPHITCNT_0 + 8*(idx))
808#define R_BCM1480_HSP_TX_HTIO_RXPHITCNT 0x00000400D0
809#define R_BCM1480_HSP_TX_HTCC_RXPHITCNT 0x00000400D8
810
811#define R_BCM1480_HSP_TX_PKT_TXPHITCNT_0 0x00000400E0
812#define R_BCM1480_HSP_TX_PKT_TXPHITCNT_1 0x00000400E8
813#define R_BCM1480_HSP_TX_PKT_TXPHITCNT_2 0x00000400F0
814#define R_BCM1480_HSP_TX_PKT_TXPHITCNT_3 0x00000400F8
815#define R_BCM1480_HSP_TX_PKT_TXPHITCNT(idx) (R_BCM1480_HSP_TX_PKT_TXPHITCNT_0 + 8*(idx))
816#define R_BCM1480_HSP_TX_HTIO_TXPHITCNT 0x0000040100
817#define R_BCM1480_HSP_TX_HTCC_TXPHITCNT 0x0000040108
818
819#define R_BCM1480_HSP_TX_SPI4_CALENDAR_0 0x0000040200
820#define R_BCM1480_HSP_TX_SPI4_CALENDAR_1 0x0000040208
821
822#define R_BCM1480_HSP_TX_PLL_CNFG 0x0000040800
823#define R_BCM1480_HSP_TX_CALIBRATION 0x0000040808
824#define R_BCM1480_HSP_TX_TEST 0x0000040810
825
826#define R_BCM1480_HSP_TX_VIS_CMDQ_0 0x0000040840
827#define R_BCM1480_HSP_TX_VIS_CMDQ_1 0x0000040848
828#define R_BCM1480_HSP_TX_VIS_CMDQ_2 0x0000040850
829#define R_BCM1480_HSP_TX_RAM_READCTL 0x0000040860
830#define R_BCM1480_HSP_TX_RAM_READWINDOW 0x0000040868
831#define R_BCM1480_HSP_TX_RF_READCTL 0x0000040870
832#define R_BCM1480_HSP_TX_RF_READWINDOW 0x0000040878
833
834#define R_BCM1480_HSP_TX_SPI4_PORT_INT_STATUS 0x0000040880
835#define R_BCM1480_HSP_TX_SPI4_PORT_INT_EN 0x0000040888
836
837#define R_BCM1480_HSP_TX_NEXT_ADDR_BASE 0x000040400
838#define R_BCM1480_HSP_TX_NEXT_ADDR_REGISTER(x) (R_BCM1480_HSP_TX_NEXT_ADDR_BASE+ 8*(x))
839
840
841
842/* *********************************************************************
843 * Physical Address Map (Table 10 and Figure 7)
844 ********************************************************************* */
845
846#define A_BCM1480_PHYS_MEMORY_0 _SB_MAKE64(0x0000000000)
847#define A_BCM1480_PHYS_MEMORY_SIZE _SB_MAKE64((256*1024*1024))
848#define A_BCM1480_PHYS_SYSTEM_CTL _SB_MAKE64(0x0010000000)
849#define A_BCM1480_PHYS_IO_SYSTEM _SB_MAKE64(0x0010060000)
850#define A_BCM1480_PHYS_GENBUS _SB_MAKE64(0x0010090000)
851#define A_BCM1480_PHYS_GENBUS_END _SB_MAKE64(0x0028000000)
852#define A_BCM1480_PHYS_PCI_MISC_MATCH_BYTES _SB_MAKE64(0x0028000000)
853#define A_BCM1480_PHYS_PCI_IACK_MATCH_BYTES _SB_MAKE64(0x0029000000)
854#define A_BCM1480_PHYS_PCI_IO_MATCH_BYTES _SB_MAKE64(0x002C000000)
855#define A_BCM1480_PHYS_PCI_CFG_MATCH_BYTES _SB_MAKE64(0x002E000000)
856#define A_BCM1480_PHYS_PCI_OMAP_MATCH_BYTES _SB_MAKE64(0x002F000000)
857#define A_BCM1480_PHYS_PCI_MEM_MATCH_BYTES _SB_MAKE64(0x0030000000)
858#define A_BCM1480_PHYS_HT_MEM_MATCH_BYTES _SB_MAKE64(0x0040000000)
859#define A_BCM1480_PHYS_HT_MEM_MATCH_BITS _SB_MAKE64(0x0060000000)
860#define A_BCM1480_PHYS_MEMORY_1 _SB_MAKE64(0x0080000000)
861#define A_BCM1480_PHYS_MEMORY_2 _SB_MAKE64(0x0090000000)
862#define A_BCM1480_PHYS_PCI_MISC_MATCH_BITS _SB_MAKE64(0x00A8000000)
863#define A_BCM1480_PHYS_PCI_IACK_MATCH_BITS _SB_MAKE64(0x00A9000000)
864#define A_BCM1480_PHYS_PCI_IO_MATCH_BITS _SB_MAKE64(0x00AC000000)
865#define A_BCM1480_PHYS_PCI_CFG_MATCH_BITS _SB_MAKE64(0x00AE000000)
866#define A_BCM1480_PHYS_PCI_OMAP_MATCH_BITS _SB_MAKE64(0x00AF000000)
867#define A_BCM1480_PHYS_PCI_MEM_MATCH_BITS _SB_MAKE64(0x00B0000000)
868#define A_BCM1480_PHYS_MEMORY_3 _SB_MAKE64(0x00C0000000)
869#define A_BCM1480_PHYS_L2_CACHE_TEST _SB_MAKE64(0x00D0000000)
870#define A_BCM1480_PHYS_HT_SPECIAL_MATCH_BYTES _SB_MAKE64(0x00D8000000)
871#define A_BCM1480_PHYS_HT_IO_MATCH_BYTES _SB_MAKE64(0x00DC000000)
872#define A_BCM1480_PHYS_HT_CFG_MATCH_BYTES _SB_MAKE64(0x00DE000000)
873#define A_BCM1480_PHYS_HS_SUBSYS _SB_MAKE64(0x00DF000000)
874#define A_BCM1480_PHYS_HT_SPECIAL_MATCH_BITS _SB_MAKE64(0x00F8000000)
875#define A_BCM1480_PHYS_HT_IO_MATCH_BITS _SB_MAKE64(0x00FC000000)
876#define A_BCM1480_PHYS_HT_CFG_MATCH_BITS _SB_MAKE64(0x00FE000000)
877#define A_BCM1480_PHYS_MEMORY_EXP _SB_MAKE64(0x0100000000)
878#define A_BCM1480_PHYS_MEMORY_EXP_SIZE _SB_MAKE64((508*1024*1024*1024))
879#define A_BCM1480_PHYS_PCI_UPPER _SB_MAKE64(0x1000000000)
880#define A_BCM1480_PHYS_HT_UPPER_MATCH_BYTES _SB_MAKE64(0x2000000000)
881#define A_BCM1480_PHYS_HT_UPPER_MATCH_BITS _SB_MAKE64(0x3000000000)
882#define A_BCM1480_PHYS_HT_NODE_ALIAS _SB_MAKE64(0x4000000000)
883#define A_BCM1480_PHYS_HT_FULLACCESS _SB_MAKE64(0xF000000000)
884
885
886/* *********************************************************************
887 * L2 Cache as RAM (Table 54)
888 ********************************************************************* */
889
890#define A_BCM1480_PHYS_L2CACHE_WAY_SIZE _SB_MAKE64(0x0000020000)
891#define BCM1480_PHYS_L2CACHE_NUM_WAYS 8
892#define A_BCM1480_PHYS_L2CACHE_TOTAL_SIZE _SB_MAKE64(0x0000100000)
893#define A_BCM1480_PHYS_L2CACHE_WAY0 _SB_MAKE64(0x00D0300000)
894#define A_BCM1480_PHYS_L2CACHE_WAY1 _SB_MAKE64(0x00D0320000)
895#define A_BCM1480_PHYS_L2CACHE_WAY2 _SB_MAKE64(0x00D0340000)
896#define A_BCM1480_PHYS_L2CACHE_WAY3 _SB_MAKE64(0x00D0360000)
897#define A_BCM1480_PHYS_L2CACHE_WAY4 _SB_MAKE64(0x00D0380000)
898#define A_BCM1480_PHYS_L2CACHE_WAY5 _SB_MAKE64(0x00D03A0000)
899#define A_BCM1480_PHYS_L2CACHE_WAY6 _SB_MAKE64(0x00D03C0000)
900#define A_BCM1480_PHYS_L2CACHE_WAY7 _SB_MAKE64(0x00D03E0000)
901
902#endif /* _BCM1480_REGS_H */
diff --git a/arch/mips/include/asm/sibyte/bcm1480_scd.h b/arch/mips/include/asm/sibyte/bcm1480_scd.h
new file mode 100644
index 000000000000..25ef24cbb92a
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/bcm1480_scd.h
@@ -0,0 +1,406 @@
1/* *********************************************************************
2 * BCM1280/BCM1400 Board Support Package
3 *
4 * SCD Constants and Macros File: bcm1480_scd.h
5 *
6 * This module contains constants and macros useful for
7 * manipulating the System Control and Debug module.
8 *
9 * BCM1400 specification level: 1X55_1X80-UM100-R (12/18/03)
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003,2004,2005
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32#ifndef _BCM1480_SCD_H
33#define _BCM1480_SCD_H
34
35#include "sb1250_defs.h"
36
37/* *********************************************************************
38 * Pull in the BCM1250's SCD since lots of stuff is the same.
39 ********************************************************************* */
40
41#include "sb1250_scd.h"
42
43/* *********************************************************************
44 * Some general notes:
45 *
46 * This file is basically a "what's new" header file. Since the
47 * BCM1250 and the new BCM1480 (and derivatives) share many common
48 * features, this file contains only what's new or changed from
49 * the 1250. (above, you can see that we include the 1250 symbols
50 * to get the base functionality).
51 *
52 * In software, be sure to use the correct symbols, particularly
53 * for blocks that are different between the two chip families.
54 * All BCM1480-specific symbols have _BCM1480_ in their names,
55 * and all BCM1250-specific and "base" functions that are common in
56 * both chips have no special names (this is for compatibility with
57 * older include files). Therefore, if you're working with the
58 * SCD, which is very different on each chip, A_SCD_xxx implies
59 * the BCM1250 version and A_BCM1480_SCD_xxx implies the BCM1480
60 * version.
61 ********************************************************************* */
62
63/* *********************************************************************
64 * System control/debug registers
65 ********************************************************************* */
66
67/*
68 * System Identification and Revision Register (Table 12)
69 * Register: SCD_SYSTEM_REVISION
70 * This register is field compatible with the 1250.
71 */
72
73/*
74 * New part definitions
75 */
76
77#define K_SYS_PART_BCM1480 0x1406
78#define K_SYS_PART_BCM1280 0x1206
79#define K_SYS_PART_BCM1455 0x1407
80#define K_SYS_PART_BCM1255 0x1257
81#define K_SYS_PART_BCM1158 0x1156
82
83/*
84 * Manufacturing Information Register (Table 14)
85 * Register: SCD_SYSTEM_MANUF
86 */
87
88/*
89 * System Configuration Register (Table 15)
90 * Register: SCD_SYSTEM_CFG
91 * Entire register is different from 1250, all new constants below
92 */
93
94#define M_BCM1480_SYS_RESERVED0 _SB_MAKEMASK1(0)
95#define M_BCM1480_SYS_HT_MINRSTCNT _SB_MAKEMASK1(1)
96#define M_BCM1480_SYS_RESERVED2 _SB_MAKEMASK1(2)
97#define M_BCM1480_SYS_RESERVED3 _SB_MAKEMASK1(3)
98#define M_BCM1480_SYS_RESERVED4 _SB_MAKEMASK1(4)
99#define M_BCM1480_SYS_IOB_DIV _SB_MAKEMASK1(5)
100
101#define S_BCM1480_SYS_PLL_DIV _SB_MAKE64(6)
102#define M_BCM1480_SYS_PLL_DIV _SB_MAKEMASK(5, S_BCM1480_SYS_PLL_DIV)
103#define V_BCM1480_SYS_PLL_DIV(x) _SB_MAKEVALUE(x, S_BCM1480_SYS_PLL_DIV)
104#define G_BCM1480_SYS_PLL_DIV(x) _SB_GETVALUE(x, S_BCM1480_SYS_PLL_DIV, M_BCM1480_SYS_PLL_DIV)
105
106#define S_BCM1480_SYS_SW_DIV _SB_MAKE64(11)
107#define M_BCM1480_SYS_SW_DIV _SB_MAKEMASK(5, S_BCM1480_SYS_SW_DIV)
108#define V_BCM1480_SYS_SW_DIV(x) _SB_MAKEVALUE(x, S_BCM1480_SYS_SW_DIV)
109#define G_BCM1480_SYS_SW_DIV(x) _SB_GETVALUE(x, S_BCM1480_SYS_SW_DIV, M_BCM1480_SYS_SW_DIV)
110
111#define M_BCM1480_SYS_PCMCIA_ENABLE _SB_MAKEMASK1(16)
112#define M_BCM1480_SYS_DUART1_ENABLE _SB_MAKEMASK1(17)
113
114#define S_BCM1480_SYS_BOOT_MODE _SB_MAKE64(18)
115#define M_BCM1480_SYS_BOOT_MODE _SB_MAKEMASK(2, S_BCM1480_SYS_BOOT_MODE)
116#define V_BCM1480_SYS_BOOT_MODE(x) _SB_MAKEVALUE(x, S_BCM1480_SYS_BOOT_MODE)
117#define G_BCM1480_SYS_BOOT_MODE(x) _SB_GETVALUE(x, S_BCM1480_SYS_BOOT_MODE, M_BCM1480_SYS_BOOT_MODE)
118#define K_BCM1480_SYS_BOOT_MODE_ROM32 0
119#define K_BCM1480_SYS_BOOT_MODE_ROM8 1
120#define K_BCM1480_SYS_BOOT_MODE_SMBUS_SMALL 2
121#define K_BCM1480_SYS_BOOT_MODE_SMBUS_BIG 3
122#define M_BCM1480_SYS_BOOT_MODE_SMBUS _SB_MAKEMASK1(19)
123
124#define M_BCM1480_SYS_PCI_HOST _SB_MAKEMASK1(20)
125#define M_BCM1480_SYS_PCI_ARBITER _SB_MAKEMASK1(21)
126#define M_BCM1480_SYS_BIG_ENDIAN _SB_MAKEMASK1(22)
127#define M_BCM1480_SYS_GENCLK_EN _SB_MAKEMASK1(23)
128#define M_BCM1480_SYS_GEN_PARITY_EN _SB_MAKEMASK1(24)
129#define M_BCM1480_SYS_RESERVED25 _SB_MAKEMASK1(25)
130
131#define S_BCM1480_SYS_CONFIG 26
132#define M_BCM1480_SYS_CONFIG _SB_MAKEMASK(6, S_BCM1480_SYS_CONFIG)
133#define V_BCM1480_SYS_CONFIG(x) _SB_MAKEVALUE(x, S_BCM1480_SYS_CONFIG)
134#define G_BCM1480_SYS_CONFIG(x) _SB_GETVALUE(x, S_BCM1480_SYS_CONFIG, M_BCM1480_SYS_CONFIG)
135
136#define M_BCM1480_SYS_RESERVED32 _SB_MAKEMASK(32, 15)
137
138#define S_BCM1480_SYS_NODEID 47
139#define M_BCM1480_SYS_NODEID _SB_MAKEMASK(4, S_BCM1480_SYS_NODEID)
140#define V_BCM1480_SYS_NODEID(x) _SB_MAKEVALUE(x, S_BCM1480_SYS_NODEID)
141#define G_BCM1480_SYS_NODEID(x) _SB_GETVALUE(x, S_BCM1480_SYS_NODEID, M_BCM1480_SYS_NODEID)
142
143#define M_BCM1480_SYS_CCNUMA_EN _SB_MAKEMASK1(51)
144#define M_BCM1480_SYS_CPU_RESET_0 _SB_MAKEMASK1(52)
145#define M_BCM1480_SYS_CPU_RESET_1 _SB_MAKEMASK1(53)
146#define M_BCM1480_SYS_CPU_RESET_2 _SB_MAKEMASK1(54)
147#define M_BCM1480_SYS_CPU_RESET_3 _SB_MAKEMASK1(55)
148#define S_BCM1480_SYS_DISABLECPU0 56
149#define M_BCM1480_SYS_DISABLECPU0 _SB_MAKEMASK1(S_BCM1480_SYS_DISABLECPU0)
150#define S_BCM1480_SYS_DISABLECPU1 57
151#define M_BCM1480_SYS_DISABLECPU1 _SB_MAKEMASK1(S_BCM1480_SYS_DISABLECPU1)
152#define S_BCM1480_SYS_DISABLECPU2 58
153#define M_BCM1480_SYS_DISABLECPU2 _SB_MAKEMASK1(S_BCM1480_SYS_DISABLECPU2)
154#define S_BCM1480_SYS_DISABLECPU3 59
155#define M_BCM1480_SYS_DISABLECPU3 _SB_MAKEMASK1(S_BCM1480_SYS_DISABLECPU3)
156
157#define M_BCM1480_SYS_SB_SOFTRES _SB_MAKEMASK1(60)
158#define M_BCM1480_SYS_EXT_RESET _SB_MAKEMASK1(61)
159#define M_BCM1480_SYS_SYSTEM_RESET _SB_MAKEMASK1(62)
160#define M_BCM1480_SYS_SW_FLAG _SB_MAKEMASK1(63)
161
162/*
163 * Scratch Register (Table 16)
164 * Register: SCD_SYSTEM_SCRATCH
165 * Same as BCM1250
166 */
167
168
169/*
170 * Mailbox Registers (Table 17)
171 * Registers: SCD_MBOX_{0,1}_CPU_x
172 * Same as BCM1250
173 */
174
175
176/*
177 * See bcm1480_int.h for interrupt mapper registers.
178 */
179
180
181/*
182 * Watchdog Timer Initial Count Registers (Table 23)
183 * Registers: SCD_WDOG_INIT_CNT_x
184 *
185 * The watchdogs are almost the same as the 1250, except
186 * the configuration register has more bits to control the
187 * other CPUs.
188 */
189
190
191/*
192 * Watchdog Timer Configuration Registers (Table 25)
193 * Registers: SCD_WDOG_CFG_x
194 */
195
196#define M_BCM1480_SCD_WDOG_ENABLE _SB_MAKEMASK1(0)
197
198#define S_BCM1480_SCD_WDOG_RESET_TYPE 2
199#define M_BCM1480_SCD_WDOG_RESET_TYPE _SB_MAKEMASK(5, S_BCM1480_SCD_WDOG_RESET_TYPE)
200#define V_BCM1480_SCD_WDOG_RESET_TYPE(x) _SB_MAKEVALUE(x, S_BCM1480_SCD_WDOG_RESET_TYPE)
201#define G_BCM1480_SCD_WDOG_RESET_TYPE(x) _SB_GETVALUE(x, S_BCM1480_SCD_WDOG_RESET_TYPE, M_BCM1480_SCD_WDOG_RESET_TYPE)
202
203#define K_BCM1480_SCD_WDOG_RESET_FULL 0 /* actually, (x & 1) == 0 */
204#define K_BCM1480_SCD_WDOG_RESET_SOFT 1
205#define K_BCM1480_SCD_WDOG_RESET_CPU0 3
206#define K_BCM1480_SCD_WDOG_RESET_CPU1 5
207#define K_BCM1480_SCD_WDOG_RESET_CPU2 9
208#define K_BCM1480_SCD_WDOG_RESET_CPU3 17
209#define K_BCM1480_SCD_WDOG_RESET_ALL_CPUS 31
210
211
212#define M_BCM1480_SCD_WDOG_HAS_RESET _SB_MAKEMASK1(8)
213
214/*
215 * General Timer Initial Count Registers (Table 26)
216 * Registers: SCD_TIMER_INIT_x
217 *
218 * The timer registers are the same as the BCM1250
219 */
220
221
222/*
223 * ZBbus Count Register (Table 29)
224 * Register: ZBBUS_CYCLE_COUNT
225 *
226 * Same as BCM1250
227 */
228
229/*
230 * ZBbus Compare Registers (Table 30)
231 * Registers: ZBBUS_CYCLE_CPx
232 *
233 * Same as BCM1250
234 */
235
236
237/*
238 * System Performance Counter Configuration Register (Table 31)
239 * Register: PERF_CNT_CFG_0
240 *
241 * SPC_CFG_SRC[0-3] is the same as the 1250.
242 * SPC_CFG_SRC[4-7] only exist on the 1480
243 * The clear/enable bits are in different locations on the 1250 and 1480.
244 */
245
246#define S_SPC_CFG_SRC4 32
247#define M_SPC_CFG_SRC4 _SB_MAKEMASK(8, S_SPC_CFG_SRC4)
248#define V_SPC_CFG_SRC4(x) _SB_MAKEVALUE(x, S_SPC_CFG_SRC4)
249#define G_SPC_CFG_SRC4(x) _SB_GETVALUE(x, S_SPC_CFG_SRC4, M_SPC_CFG_SRC4)
250
251#define S_SPC_CFG_SRC5 40
252#define M_SPC_CFG_SRC5 _SB_MAKEMASK(8, S_SPC_CFG_SRC5)
253#define V_SPC_CFG_SRC5(x) _SB_MAKEVALUE(x, S_SPC_CFG_SRC5)
254#define G_SPC_CFG_SRC5(x) _SB_GETVALUE(x, S_SPC_CFG_SRC5, M_SPC_CFG_SRC5)
255
256#define S_SPC_CFG_SRC6 48
257#define M_SPC_CFG_SRC6 _SB_MAKEMASK(8, S_SPC_CFG_SRC6)
258#define V_SPC_CFG_SRC6(x) _SB_MAKEVALUE(x, S_SPC_CFG_SRC6)
259#define G_SPC_CFG_SRC6(x) _SB_GETVALUE(x, S_SPC_CFG_SRC6, M_SPC_CFG_SRC6)
260
261#define S_SPC_CFG_SRC7 56
262#define M_SPC_CFG_SRC7 _SB_MAKEMASK(8, S_SPC_CFG_SRC7)
263#define V_SPC_CFG_SRC7(x) _SB_MAKEVALUE(x, S_SPC_CFG_SRC7)
264#define G_SPC_CFG_SRC7(x) _SB_GETVALUE(x, S_SPC_CFG_SRC7, M_SPC_CFG_SRC7)
265
266/*
267 * System Performance Counter Control Register (Table 32)
268 * Register: PERF_CNT_CFG_1
269 * BCM1480 specific
270 */
271#define M_BCM1480_SPC_CFG_CLEAR _SB_MAKEMASK1(0)
272#define M_BCM1480_SPC_CFG_ENABLE _SB_MAKEMASK1(1)
273#if SIBYTE_HDR_FEATURE_CHIP(1480)
274#define M_SPC_CFG_CLEAR M_BCM1480_SPC_CFG_CLEAR
275#define M_SPC_CFG_ENABLE M_BCM1480_SPC_CFG_ENABLE
276#endif
277
278/*
279 * System Performance Counters (Table 33)
280 * Registers: PERF_CNT_x
281 */
282
283#define S_BCM1480_SPC_CNT_COUNT 0
284#define M_BCM1480_SPC_CNT_COUNT _SB_MAKEMASK(40, S_BCM1480_SPC_CNT_COUNT)
285#define V_BCM1480_SPC_CNT_COUNT(x) _SB_MAKEVALUE(x, S_BCM1480_SPC_CNT_COUNT)
286#define G_BCM1480_SPC_CNT_COUNT(x) _SB_GETVALUE(x, S_BCM1480_SPC_CNT_COUNT, M_BCM1480_SPC_CNT_COUNT)
287
288#define M_BCM1480_SPC_CNT_OFLOW _SB_MAKEMASK1(40)
289
290
291/*
292 * Bus Watcher Error Status Register (Tables 36, 37)
293 * Registers: BUS_ERR_STATUS, BUS_ERR_STATUS_DEBUG
294 * Same as BCM1250.
295 */
296
297/*
298 * Bus Watcher Error Data Registers (Table 38)
299 * Registers: BUS_ERR_DATA_x
300 * Same as BCM1250.
301 */
302
303/*
304 * Bus Watcher L2 ECC Counter Register (Table 39)
305 * Register: BUS_L2_ERRORS
306 * Same as BCM1250.
307 */
308
309
310/*
311 * Bus Watcher Memory and I/O Error Counter Register (Table 40)
312 * Register: BUS_MEM_IO_ERRORS
313 * Same as BCM1250.
314 */
315
316
317/*
318 * Address Trap Registers
319 *
320 * Register layout same as BCM1250, almost. The bus agents
321 * are different, and the address trap configuration bits are
322 * slightly different.
323 */
324
325#define M_BCM1480_ATRAP_INDEX _SB_MAKEMASK(4, 0)
326#define M_BCM1480_ATRAP_ADDRESS _SB_MAKEMASK(40, 0)
327
328#define S_BCM1480_ATRAP_CFG_CNT 0
329#define M_BCM1480_ATRAP_CFG_CNT _SB_MAKEMASK(3, S_BCM1480_ATRAP_CFG_CNT)
330#define V_BCM1480_ATRAP_CFG_CNT(x) _SB_MAKEVALUE(x, S_BCM1480_ATRAP_CFG_CNT)
331#define G_BCM1480_ATRAP_CFG_CNT(x) _SB_GETVALUE(x, S_BCM1480_ATRAP_CFG_CNT, M_BCM1480_ATRAP_CFG_CNT)
332
333#define M_BCM1480_ATRAP_CFG_WRITE _SB_MAKEMASK1(3)
334#define M_BCM1480_ATRAP_CFG_ALL _SB_MAKEMASK1(4)
335#define M_BCM1480_ATRAP_CFG_INV _SB_MAKEMASK1(5)
336#define M_BCM1480_ATRAP_CFG_USESRC _SB_MAKEMASK1(6)
337#define M_BCM1480_ATRAP_CFG_SRCINV _SB_MAKEMASK1(7)
338
339#define S_BCM1480_ATRAP_CFG_AGENTID 8
340#define M_BCM1480_ATRAP_CFG_AGENTID _SB_MAKEMASK(4, S_BCM1480_ATRAP_CFG_AGENTID)
341#define V_BCM1480_ATRAP_CFG_AGENTID(x) _SB_MAKEVALUE(x, S_BCM1480_ATRAP_CFG_AGENTID)
342#define G_BCM1480_ATRAP_CFG_AGENTID(x) _SB_GETVALUE(x, S_BCM1480_ATRAP_CFG_AGENTID, M_BCM1480_ATRAP_CFG_AGENTID)
343
344
345#define K_BCM1480_BUS_AGENT_CPU0 0
346#define K_BCM1480_BUS_AGENT_CPU1 1
347#define K_BCM1480_BUS_AGENT_NC 2
348#define K_BCM1480_BUS_AGENT_IOB 3
349#define K_BCM1480_BUS_AGENT_SCD 4
350#define K_BCM1480_BUS_AGENT_L2C 6
351#define K_BCM1480_BUS_AGENT_MC 7
352#define K_BCM1480_BUS_AGENT_CPU2 8
353#define K_BCM1480_BUS_AGENT_CPU3 9
354#define K_BCM1480_BUS_AGENT_PM 10
355
356#define S_BCM1480_ATRAP_CFG_CATTR 12
357#define M_BCM1480_ATRAP_CFG_CATTR _SB_MAKEMASK(2, S_BCM1480_ATRAP_CFG_CATTR)
358#define V_BCM1480_ATRAP_CFG_CATTR(x) _SB_MAKEVALUE(x, S_BCM1480_ATRAP_CFG_CATTR)
359#define G_BCM1480_ATRAP_CFG_CATTR(x) _SB_GETVALUE(x, S_BCM1480_ATRAP_CFG_CATTR, M_BCM1480_ATRAP_CFG_CATTR)
360
361#define K_BCM1480_ATRAP_CFG_CATTR_IGNORE 0
362#define K_BCM1480_ATRAP_CFG_CATTR_UNC 1
363#define K_BCM1480_ATRAP_CFG_CATTR_NONCOH 2
364#define K_BCM1480_ATRAP_CFG_CATTR_COHERENT 3
365
366#define M_BCM1480_ATRAP_CFG_CATTRINV _SB_MAKEMASK1(14)
367
368
369/*
370 * Trace Event Registers (Table 47)
371 * Same as BCM1250.
372 */
373
374/*
375 * Trace Sequence Control Registers (Table 48)
376 * Registers: TRACE_SEQUENCE_x
377 *
378 * Same as BCM1250 except for two new fields.
379 */
380
381
382#define M_BCM1480_SCD_TRSEQ_TID_MATCH_EN _SB_MAKEMASK1(25)
383
384#define S_BCM1480_SCD_TRSEQ_SWFUNC 26
385#define M_BCM1480_SCD_TRSEQ_SWFUNC _SB_MAKEMASK(2, S_BCM1480_SCD_TRSEQ_SWFUNC)
386#define V_BCM1480_SCD_TRSEQ_SWFUNC(x) _SB_MAKEVALUE(x, S_BCM1480_SCD_TRSEQ_SWFUNC)
387#define G_BCM1480_SCD_TRSEQ_SWFUNC(x) _SB_GETVALUE(x, S_BCM1480_SCD_TRSEQ_SWFUNC, M_BCM1480_SCD_TRSEQ_SWFUNC)
388
389/*
390 * Trace Control Register (Table 49)
391 * Register: TRACE_CFG
392 *
393 * BCM1480 changes to this register (other than location of the CUR_ADDR field)
394 * are defined below.
395 */
396
397#define S_BCM1480_SCD_TRACE_CFG_MODE 16
398#define M_BCM1480_SCD_TRACE_CFG_MODE _SB_MAKEMASK(2, S_BCM1480_SCD_TRACE_CFG_MODE)
399#define V_BCM1480_SCD_TRACE_CFG_MODE(x) _SB_MAKEVALUE(x, S_BCM1480_SCD_TRACE_CFG_MODE)
400#define G_BCM1480_SCD_TRACE_CFG_MODE(x) _SB_GETVALUE(x, S_BCM1480_SCD_TRACE_CFG_MODE, M_BCM1480_SCD_TRACE_CFG_MODE)
401
402#define K_BCM1480_SCD_TRACE_CFG_MODE_BLOCKERS 0
403#define K_BCM1480_SCD_TRACE_CFG_MODE_BYTEEN_INT 1
404#define K_BCM1480_SCD_TRACE_CFG_MODE_FLOW_ID 2
405
406#endif /* _BCM1480_SCD_H */
diff --git a/arch/mips/include/asm/sibyte/bigsur.h b/arch/mips/include/asm/sibyte/bigsur.h
new file mode 100644
index 000000000000..ebefe797fc1d
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/bigsur.h
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 2000,2001,2002,2003,2004 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18#ifndef __ASM_SIBYTE_BIGSUR_H
19#define __ASM_SIBYTE_BIGSUR_H
20
21#include <asm/sibyte/sb1250.h>
22#include <asm/sibyte/bcm1480_int.h>
23
24#ifdef CONFIG_SIBYTE_BIGSUR
25#define SIBYTE_BOARD_NAME "BCM91x80A/B (BigSur)"
26#define SIBYTE_HAVE_PCMCIA 1
27#define SIBYTE_HAVE_IDE 1
28#endif
29
30/* Generic bus chip selects */
31#define LEDS_CS 3
32#define LEDS_PHYS 0x100a0000
33
34#ifdef SIBYTE_HAVE_IDE
35#define IDE_CS 4
36#define IDE_PHYS 0x100b0000
37#define K_GPIO_GB_IDE 4
38#define K_INT_GB_IDE (K_INT_GPIO_0 + K_GPIO_GB_IDE)
39#endif
40
41#ifdef SIBYTE_HAVE_PCMCIA
42#define PCMCIA_CS 6
43#define PCMCIA_PHYS 0x11000000
44#define K_GPIO_PC_READY 9
45#define K_INT_PC_READY (K_INT_GPIO_0 + K_GPIO_PC_READY)
46#endif
47
48#endif /* __ASM_SIBYTE_BIGSUR_H */
49
diff --git a/arch/mips/include/asm/sibyte/board.h b/arch/mips/include/asm/sibyte/board.h
new file mode 100644
index 000000000000..25372ae0e814
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/board.h
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2000,2001,2002,2003,2004 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef _SIBYTE_BOARD_H
20#define _SIBYTE_BOARD_H
21
22#if defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_CRHONE) || \
23 defined(CONFIG_SIBYTE_CRHINE) || defined(CONFIG_SIBYTE_LITTLESUR)
24#include <asm/sibyte/swarm.h>
25#endif
26
27#if defined(CONFIG_SIBYTE_SENTOSA) || defined(CONFIG_SIBYTE_RHONE)
28#include <asm/sibyte/sentosa.h>
29#endif
30
31#ifdef CONFIG_SIBYTE_CARMEL
32#include <asm/sibyte/carmel.h>
33#endif
34
35#ifdef CONFIG_SIBYTE_BIGSUR
36#include <asm/sibyte/bigsur.h>
37#endif
38
39#ifdef __ASSEMBLY__
40
41#ifdef LEDS_PHYS
42#define setleds(t0, t1, c0, c1, c2, c3) \
43 li t0, (LEDS_PHYS|0xa0000000); \
44 li t1, c0; \
45 sb t1, 0x18(t0); \
46 li t1, c1; \
47 sb t1, 0x10(t0); \
48 li t1, c2; \
49 sb t1, 0x08(t0); \
50 li t1, c3; \
51 sb t1, 0x00(t0)
52#else
53#define setleds(t0, t1, c0, c1, c2, c3)
54#endif /* LEDS_PHYS */
55
56#else
57
58void swarm_setup(void);
59
60#ifdef LEDS_PHYS
61extern void setleds(char *str);
62#else
63#define setleds(s) do { } while (0)
64#endif /* LEDS_PHYS */
65
66#endif /* __ASSEMBLY__ */
67
68#endif /* _SIBYTE_BOARD_H */
diff --git a/arch/mips/include/asm/sibyte/carmel.h b/arch/mips/include/asm/sibyte/carmel.h
new file mode 100644
index 000000000000..11cad71323e8
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/carmel.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2002 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18#ifndef __ASM_SIBYTE_CARMEL_H
19#define __ASM_SIBYTE_CARMEL_H
20
21#include <asm/sibyte/sb1250.h>
22#include <asm/sibyte/sb1250_int.h>
23
24#define SIBYTE_BOARD_NAME "Carmel"
25
26#define GPIO_PHY_INTERRUPT 2
27#define GPIO_NONMASKABLE_INT 3
28#define GPIO_CF_INSERTED 6
29#define GPIO_MONTEREY_RESET 7
30#define GPIO_QUADUART_INT 8
31#define GPIO_CF_INT 9
32#define GPIO_FPGA_CCLK 10
33#define GPIO_FPGA_DOUT 11
34#define GPIO_FPGA_DIN 12
35#define GPIO_FPGA_PGM 13
36#define GPIO_FPGA_DONE 14
37#define GPIO_FPGA_INIT 15
38
39#define LEDS_CS 2
40#define LEDS_PHYS 0x100C0000
41#define MLEDS_CS 3
42#define MLEDS_PHYS 0x100A0000
43#define UART_CS 4
44#define UART_PHYS 0x100D0000
45#define ARAVALI_CS 5
46#define ARAVALI_PHYS 0x11000000
47#define IDE_CS 6
48#define IDE_PHYS 0x100B0000
49#define ARAVALI2_CS 7
50#define ARAVALI2_PHYS 0x100E0000
51
52#if defined(CONFIG_SIBYTE_CARMEL)
53#define K_GPIO_GB_IDE 9
54#define K_INT_GB_IDE (K_INT_GPIO_0 + K_GPIO_GB_IDE)
55#endif
56
57
58#endif /* __ASM_SIBYTE_CARMEL_H */
diff --git a/arch/mips/include/asm/sibyte/sb1250.h b/arch/mips/include/asm/sibyte/sb1250.h
new file mode 100644
index 000000000000..80c1a052662a
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250.h
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef _ASM_SIBYTE_SB1250_H
20#define _ASM_SIBYTE_SB1250_H
21
22/*
23 * yymmddpp: year, month, day, patch.
24 * should sync with Makefile EXTRAVERSION
25 */
26#define SIBYTE_RELEASE 0x02111403
27
28#define SB1250_NR_IRQS 64
29
30#define BCM1480_NR_IRQS 128
31#define BCM1480_NR_IRQS_HALF 64
32
33#define SB1250_DUART_MINOR_BASE 64
34
35#ifndef __ASSEMBLY__
36
37#include <asm/addrspace.h>
38
39/* For revision/pass information */
40#include <asm/sibyte/sb1250_scd.h>
41#include <asm/sibyte/bcm1480_scd.h>
42extern unsigned int sb1_pass;
43extern unsigned int soc_pass;
44extern unsigned int soc_type;
45extern unsigned int periph_rev;
46extern unsigned int zbbus_mhz;
47
48extern void sb1250_time_init(void);
49extern void sb1250_mask_irq(int cpu, int irq);
50extern void sb1250_unmask_irq(int cpu, int irq);
51
52extern void bcm1480_time_init(void);
53extern void bcm1480_mask_irq(int cpu, int irq);
54extern void bcm1480_unmask_irq(int cpu, int irq);
55
56#define AT_spin \
57 __asm__ __volatile__ ( \
58 ".set noat\n" \
59 "li $at, 0\n" \
60 "1: beqz $at, 1b\n" \
61 ".set at\n" \
62 )
63
64#endif
65
66#define IOADDR(a) ((void __iomem *)(IO_BASE + (a)))
67
68#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_defs.h b/arch/mips/include/asm/sibyte/sb1250_defs.h
new file mode 100644
index 000000000000..09365f9111fa
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_defs.h
@@ -0,0 +1,259 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * Global constants and macros File: sb1250_defs.h
5 *
6 * This file contains macros and definitions used by the other
7 * include files.
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32#ifndef _SB1250_DEFS_H
33#define _SB1250_DEFS_H
34
35/*
36 * These headers require ANSI C89 string concatenation, and GCC or other
37 * 'long long' (64-bit integer) support.
38 */
39#if !defined(__STDC__) && !defined(_MSC_VER)
40#error SiByte headers require ANSI C89 support
41#endif
42
43
44/* *********************************************************************
45 * Macros for feature tests, used to enable include file features
46 * for chip features only present in certain chip revisions.
47 *
48 * SIBYTE_HDR_FEATURES may be defined to be the mask value chip/revision
49 * which is to be exposed by the headers. If undefined, it defaults to
50 * "all features."
51 *
52 * Use like:
53 *
54 * #define SIBYTE_HDR_FEATURES SIBYTE_HDR_FMASK_112x_PASS1
55 *
56 * Generate defines only for that revision of chip.
57 *
58 * #if SIBYTE_HDR_FEATURE(chip,pass)
59 *
60 * True if header features for that revision or later of
61 * that particular chip type are enabled in SIBYTE_HDR_FEATURES.
62 * (Use this to bracket #defines for features present in a given
63 * revision and later.)
64 *
65 * Note that there is no implied ordering between chip types.
66 *
67 * Note also that 'chip' and 'pass' must textually exactly
68 * match the defines below. So, for example,
69 * SIBYTE_HDR_FEATURE(112x, PASS1) is OK, but
70 * SIBYTE_HDR_FEATURE(1120, pass1) is not (for two reasons).
71 *
72 * #if SIBYTE_HDR_FEATURE_UP_TO(chip,pass)
73 *
74 * Same as SIBYTE_HDR_FEATURE, but true for the named revision
75 * and earlier revisions of the named chip type.
76 *
77 * #if SIBYTE_HDR_FEATURE_EXACT(chip,pass)
78 *
79 * Same as SIBYTE_HDR_FEATURE, but only true for the named
80 * revision of the named chip type. (Note that this CANNOT
81 * be used to verify that you're compiling only for that
82 * particular chip/revision. It will be true any time this
83 * chip/revision is included in SIBYTE_HDR_FEATURES.)
84 *
85 * #if SIBYTE_HDR_FEATURE_CHIP(chip)
86 *
87 * True if header features for (any revision of) that chip type
88 * are enabled in SIBYTE_HDR_FEATURES. (Use this to bracket
89 * #defines for features specific to a given chip type.)
90 *
91 * Mask values currently include room for additional revisions of each
92 * chip type, but can be renumbered at will. Note that they MUST fit
93 * into 31 bits and may not include C type constructs, for safe use in
94 * CPP conditionals. Bit positions within chip types DO indicate
95 * ordering, so be careful when adding support for new minor revs.
96 ********************************************************************* */
97
98#define SIBYTE_HDR_FMASK_1250_ALL 0x000000ff
99#define SIBYTE_HDR_FMASK_1250_PASS1 0x00000001
100#define SIBYTE_HDR_FMASK_1250_PASS2 0x00000002
101#define SIBYTE_HDR_FMASK_1250_PASS3 0x00000004
102
103#define SIBYTE_HDR_FMASK_112x_ALL 0x00000f00
104#define SIBYTE_HDR_FMASK_112x_PASS1 0x00000100
105
106#define SIBYTE_HDR_FMASK_1480_ALL 0x0000f000
107#define SIBYTE_HDR_FMASK_1480_PASS1 0x00001000
108#define SIBYTE_HDR_FMASK_1480_PASS2 0x00002000
109
110/* Bit mask for chip/revision. (use _ALL for all revisions of a chip). */
111#define SIBYTE_HDR_FMASK(chip, pass) \
112 (SIBYTE_HDR_FMASK_ ## chip ## _ ## pass)
113#define SIBYTE_HDR_FMASK_ALLREVS(chip) \
114 (SIBYTE_HDR_FMASK_ ## chip ## _ALL)
115
116/* Default constant value for all chips, all revisions */
117#define SIBYTE_HDR_FMASK_ALL \
118 (SIBYTE_HDR_FMASK_1250_ALL | SIBYTE_HDR_FMASK_112x_ALL \
119 | SIBYTE_HDR_FMASK_1480_ALL)
120
121/* This one is used for the "original" BCM1250/BCM112x chips. We use this
122 to weed out constants and macros that do not exist on later chips like
123 the BCM1480 */
124#define SIBYTE_HDR_FMASK_1250_112x_ALL \
125 (SIBYTE_HDR_FMASK_1250_ALL | SIBYTE_HDR_FMASK_112x_ALL)
126#define SIBYTE_HDR_FMASK_1250_112x SIBYTE_HDR_FMASK_1250_112x_ALL
127
128#ifndef SIBYTE_HDR_FEATURES
129#define SIBYTE_HDR_FEATURES SIBYTE_HDR_FMASK_ALL
130#endif
131
132
133/* Bit mask for revisions of chip exclusively before the named revision. */
134#define SIBYTE_HDR_FMASK_BEFORE(chip, pass) \
135 ((SIBYTE_HDR_FMASK(chip, pass) - 1) & SIBYTE_HDR_FMASK_ALLREVS(chip))
136
137/* Bit mask for revisions of chip exclusively after the named revision. */
138#define SIBYTE_HDR_FMASK_AFTER(chip, pass) \
139 (~(SIBYTE_HDR_FMASK(chip, pass) \
140 | (SIBYTE_HDR_FMASK(chip, pass) - 1)) & SIBYTE_HDR_FMASK_ALLREVS(chip))
141
142
143/* True if header features enabled for (any revision of) that chip type. */
144#define SIBYTE_HDR_FEATURE_CHIP(chip) \
145 (!! (SIBYTE_HDR_FMASK_ALLREVS(chip) & SIBYTE_HDR_FEATURES))
146
147/* True for all versions of the BCM1250 and BCM1125, but not true for
148 anything else */
149#define SIBYTE_HDR_FEATURE_1250_112x \
150 (SIBYTE_HDR_FEATURE_CHIP(1250) || SIBYTE_HDR_FEATURE_CHIP(112x))
151/* (!! (SIBYTE_HDR_FEATURES & SIBYHTE_HDR_FMASK_1250_112x)) */
152
153/* True if header features enabled for that rev or later, inclusive. */
154#define SIBYTE_HDR_FEATURE(chip, pass) \
155 (!! ((SIBYTE_HDR_FMASK(chip, pass) \
156 | SIBYTE_HDR_FMASK_AFTER(chip, pass)) & SIBYTE_HDR_FEATURES))
157
158/* True if header features enabled for exactly that rev. */
159#define SIBYTE_HDR_FEATURE_EXACT(chip, pass) \
160 (!! (SIBYTE_HDR_FMASK(chip, pass) & SIBYTE_HDR_FEATURES))
161
162/* True if header features enabled for that rev or before, inclusive. */
163#define SIBYTE_HDR_FEATURE_UP_TO(chip, pass) \
164 (!! ((SIBYTE_HDR_FMASK(chip, pass) \
165 | SIBYTE_HDR_FMASK_BEFORE(chip, pass)) & SIBYTE_HDR_FEATURES))
166
167
168/* *********************************************************************
169 * Naming schemes for constants in these files:
170 *
171 * M_xxx MASK constant (identifies bits in a register).
172 * For multi-bit fields, all bits in the field will
173 * be set.
174 *
175 * K_xxx "Code" constant (value for data in a multi-bit
176 * field). The value is right justified.
177 *
178 * V_xxx "Value" constant. This is the same as the
179 * corresponding "K_xxx" constant, except it is
180 * shifted to the correct position in the register.
181 *
182 * S_xxx SHIFT constant. This is the number of bits that
183 * a field value (code) needs to be shifted
184 * (towards the left) to put the value in the right
185 * position for the register.
186 *
187 * A_xxx ADDRESS constant. This will be a physical
188 * address. Use the PHYS_TO_K1 macro to generate
189 * a K1SEG address.
190 *
191 * R_xxx RELATIVE offset constant. This is an offset from
192 * an A_xxx constant (usually the first register in
193 * a group).
194 *
195 * G_xxx(X) GET value. This macro obtains a multi-bit field
196 * from a register, masks it, and shifts it to
197 * the bottom of the register (retrieving a K_xxx
198 * value, for example).
199 *
200 * V_xxx(X) VALUE. This macro computes the value of a
201 * K_xxx constant shifted to the correct position
202 * in the register.
203 ********************************************************************* */
204
205
206
207
208/*
209 * Cast to 64-bit number. Presumably the syntax is different in
210 * assembly language.
211 *
212 * Note: you'll need to define uint32_t and uint64_t in your headers.
213 */
214
215#if !defined(__ASSEMBLY__)
216#define _SB_MAKE64(x) ((uint64_t)(x))
217#define _SB_MAKE32(x) ((uint32_t)(x))
218#else
219#define _SB_MAKE64(x) (x)
220#define _SB_MAKE32(x) (x)
221#endif
222
223
224/*
225 * Make a mask for 1 bit at position 'n'
226 */
227
228#define _SB_MAKEMASK1(n) (_SB_MAKE64(1) << _SB_MAKE64(n))
229#define _SB_MAKEMASK1_32(n) (_SB_MAKE32(1) << _SB_MAKE32(n))
230
231/*
232 * Make a mask for 'v' bits at position 'n'
233 */
234
235#define _SB_MAKEMASK(v, n) (_SB_MAKE64((_SB_MAKE64(1)<<(v))-1) << _SB_MAKE64(n))
236#define _SB_MAKEMASK_32(v, n) (_SB_MAKE32((_SB_MAKE32(1)<<(v))-1) << _SB_MAKE32(n))
237
238/*
239 * Make a value at 'v' at bit position 'n'
240 */
241
242#define _SB_MAKEVALUE(v, n) (_SB_MAKE64(v) << _SB_MAKE64(n))
243#define _SB_MAKEVALUE_32(v, n) (_SB_MAKE32(v) << _SB_MAKE32(n))
244
245#define _SB_GETVALUE(v, n, m) ((_SB_MAKE64(v) & _SB_MAKE64(m)) >> _SB_MAKE64(n))
246#define _SB_GETVALUE_32(v, n, m) ((_SB_MAKE32(v) & _SB_MAKE32(m)) >> _SB_MAKE32(n))
247
248/*
249 * Macros to read/write on-chip registers
250 * XXX should we do the PHYS_TO_K1 here?
251 */
252
253
254#if defined(__mips64) && !defined(__ASSEMBLY__)
255#define SBWRITECSR(csr, val) *((volatile uint64_t *) PHYS_TO_K1(csr)) = (val)
256#define SBREADCSR(csr) (*((volatile uint64_t *) PHYS_TO_K1(csr)))
257#endif /* __ASSEMBLY__ */
258
259#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_dma.h b/arch/mips/include/asm/sibyte/sb1250_dma.h
new file mode 100644
index 000000000000..bad56171d747
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_dma.h
@@ -0,0 +1,594 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * DMA definitions File: sb1250_dma.h
5 *
6 * This module contains constants and macros useful for
7 * programming the SB1250's DMA controllers, both the data mover
8 * and the Ethernet DMA.
9 *
10 * SB1250 specification level: User's manual 10/21/02
11 * BCM1280 specification level: User's manual 11/24/03
12 *
13 *********************************************************************
14 *
15 * Copyright 2000,2001,2002,2003
16 * Broadcom Corporation. All rights reserved.
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License as
20 * published by the Free Software Foundation; either version 2 of
21 * the License, or (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 * MA 02111-1307 USA
32 ********************************************************************* */
33
34
35#ifndef _SB1250_DMA_H
36#define _SB1250_DMA_H
37
38
39#include "sb1250_defs.h"
40
41/* *********************************************************************
42 * DMA Registers
43 ********************************************************************* */
44
45/*
46 * Ethernet and Serial DMA Configuration Register 0 (Table 7-4)
47 * Registers: DMA_CONFIG0_MAC_x_RX_CH_0
48 * Registers: DMA_CONFIG0_MAC_x_TX_CH_0
49 * Registers: DMA_CONFIG0_SER_x_RX
50 * Registers: DMA_CONFIG0_SER_x_TX
51 */
52
53
54#define M_DMA_DROP _SB_MAKEMASK1(0)
55
56#define M_DMA_CHAIN_SEL _SB_MAKEMASK1(1)
57#define M_DMA_RESERVED1 _SB_MAKEMASK1(2)
58
59#define S_DMA_DESC_TYPE _SB_MAKE64(1)
60#define M_DMA_DESC_TYPE _SB_MAKEMASK(2, S_DMA_DESC_TYPE)
61#define V_DMA_DESC_TYPE(x) _SB_MAKEVALUE(x, S_DMA_DESC_TYPE)
62#define G_DMA_DESC_TYPE(x) _SB_GETVALUE(x, S_DMA_DESC_TYPE, M_DMA_DESC_TYPE)
63
64#define K_DMA_DESC_TYPE_RING_AL 0
65#define K_DMA_DESC_TYPE_CHAIN_AL 1
66
67#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
68#define K_DMA_DESC_TYPE_RING_UAL_WI 2
69#define K_DMA_DESC_TYPE_RING_UAL_RMW 3
70#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
71
72#define M_DMA_EOP_INT_EN _SB_MAKEMASK1(3)
73#define M_DMA_HWM_INT_EN _SB_MAKEMASK1(4)
74#define M_DMA_LWM_INT_EN _SB_MAKEMASK1(5)
75#define M_DMA_TBX_EN _SB_MAKEMASK1(6)
76#define M_DMA_TDX_EN _SB_MAKEMASK1(7)
77
78#define S_DMA_INT_PKTCNT _SB_MAKE64(8)
79#define M_DMA_INT_PKTCNT _SB_MAKEMASK(8, S_DMA_INT_PKTCNT)
80#define V_DMA_INT_PKTCNT(x) _SB_MAKEVALUE(x, S_DMA_INT_PKTCNT)
81#define G_DMA_INT_PKTCNT(x) _SB_GETVALUE(x, S_DMA_INT_PKTCNT, M_DMA_INT_PKTCNT)
82
83#define S_DMA_RINGSZ _SB_MAKE64(16)
84#define M_DMA_RINGSZ _SB_MAKEMASK(16, S_DMA_RINGSZ)
85#define V_DMA_RINGSZ(x) _SB_MAKEVALUE(x, S_DMA_RINGSZ)
86#define G_DMA_RINGSZ(x) _SB_GETVALUE(x, S_DMA_RINGSZ, M_DMA_RINGSZ)
87
88#define S_DMA_HIGH_WATERMARK _SB_MAKE64(32)
89#define M_DMA_HIGH_WATERMARK _SB_MAKEMASK(16, S_DMA_HIGH_WATERMARK)
90#define V_DMA_HIGH_WATERMARK(x) _SB_MAKEVALUE(x, S_DMA_HIGH_WATERMARK)
91#define G_DMA_HIGH_WATERMARK(x) _SB_GETVALUE(x, S_DMA_HIGH_WATERMARK, M_DMA_HIGH_WATERMARK)
92
93#define S_DMA_LOW_WATERMARK _SB_MAKE64(48)
94#define M_DMA_LOW_WATERMARK _SB_MAKEMASK(16, S_DMA_LOW_WATERMARK)
95#define V_DMA_LOW_WATERMARK(x) _SB_MAKEVALUE(x, S_DMA_LOW_WATERMARK)
96#define G_DMA_LOW_WATERMARK(x) _SB_GETVALUE(x, S_DMA_LOW_WATERMARK, M_DMA_LOW_WATERMARK)
97
98/*
99 * Ethernet and Serial DMA Configuration Register 1 (Table 7-5)
100 * Registers: DMA_CONFIG1_MAC_x_RX_CH_0
101 * Registers: DMA_CONFIG1_DMA_x_TX_CH_0
102 * Registers: DMA_CONFIG1_SER_x_RX
103 * Registers: DMA_CONFIG1_SER_x_TX
104 */
105
106#define M_DMA_HDR_CF_EN _SB_MAKEMASK1(0)
107#define M_DMA_ASIC_XFR_EN _SB_MAKEMASK1(1)
108#define M_DMA_PRE_ADDR_EN _SB_MAKEMASK1(2)
109#define M_DMA_FLOW_CTL_EN _SB_MAKEMASK1(3)
110#define M_DMA_NO_DSCR_UPDT _SB_MAKEMASK1(4)
111#define M_DMA_L2CA _SB_MAKEMASK1(5)
112
113#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
114#define M_DMA_RX_XTRA_STATUS _SB_MAKEMASK1(6)
115#define M_DMA_TX_CPU_PAUSE _SB_MAKEMASK1(6)
116#define M_DMA_TX_FC_PAUSE_EN _SB_MAKEMASK1(7)
117#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
118
119#define M_DMA_MBZ1 _SB_MAKEMASK(6, 15)
120
121#define S_DMA_HDR_SIZE _SB_MAKE64(21)
122#define M_DMA_HDR_SIZE _SB_MAKEMASK(9, S_DMA_HDR_SIZE)
123#define V_DMA_HDR_SIZE(x) _SB_MAKEVALUE(x, S_DMA_HDR_SIZE)
124#define G_DMA_HDR_SIZE(x) _SB_GETVALUE(x, S_DMA_HDR_SIZE, M_DMA_HDR_SIZE)
125
126#define M_DMA_MBZ2 _SB_MAKEMASK(5, 32)
127
128#define S_DMA_ASICXFR_SIZE _SB_MAKE64(37)
129#define M_DMA_ASICXFR_SIZE _SB_MAKEMASK(9, S_DMA_ASICXFR_SIZE)
130#define V_DMA_ASICXFR_SIZE(x) _SB_MAKEVALUE(x, S_DMA_ASICXFR_SIZE)
131#define G_DMA_ASICXFR_SIZE(x) _SB_GETVALUE(x, S_DMA_ASICXFR_SIZE, M_DMA_ASICXFR_SIZE)
132
133#define S_DMA_INT_TIMEOUT _SB_MAKE64(48)
134#define M_DMA_INT_TIMEOUT _SB_MAKEMASK(16, S_DMA_INT_TIMEOUT)
135#define V_DMA_INT_TIMEOUT(x) _SB_MAKEVALUE(x, S_DMA_INT_TIMEOUT)
136#define G_DMA_INT_TIMEOUT(x) _SB_GETVALUE(x, S_DMA_INT_TIMEOUT, M_DMA_INT_TIMEOUT)
137
138/*
139 * Ethernet and Serial DMA Descriptor base address (Table 7-6)
140 */
141
142#define M_DMA_DSCRBASE_MBZ _SB_MAKEMASK(4, 0)
143
144
145/*
146 * ASIC Mode Base Address (Table 7-7)
147 */
148
149#define M_DMA_ASIC_BASE_MBZ _SB_MAKEMASK(20, 0)
150
151/*
152 * DMA Descriptor Count Registers (Table 7-8)
153 */
154
155/* No bitfields */
156
157
158/*
159 * Current Descriptor Address Register (Table 7-11)
160 */
161
162#define S_DMA_CURDSCR_ADDR _SB_MAKE64(0)
163#define M_DMA_CURDSCR_ADDR _SB_MAKEMASK(40, S_DMA_CURDSCR_ADDR)
164#define S_DMA_CURDSCR_COUNT _SB_MAKE64(40)
165#define M_DMA_CURDSCR_COUNT _SB_MAKEMASK(16, S_DMA_CURDSCR_COUNT)
166
167#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
168#define M_DMA_TX_CH_PAUSE_ON _SB_MAKEMASK1(56)
169#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
170
171/*
172 * Receive Packet Drop Registers
173 */
174#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
175#define S_DMA_OODLOST_RX _SB_MAKE64(0)
176#define M_DMA_OODLOST_RX _SB_MAKEMASK(16, S_DMA_OODLOST_RX)
177#define G_DMA_OODLOST_RX(x) _SB_GETVALUE(x, S_DMA_OODLOST_RX, M_DMA_OODLOST_RX)
178
179#define S_DMA_EOP_COUNT_RX _SB_MAKE64(16)
180#define M_DMA_EOP_COUNT_RX _SB_MAKEMASK(8, S_DMA_EOP_COUNT_RX)
181#define G_DMA_EOP_COUNT_RX(x) _SB_GETVALUE(x, S_DMA_EOP_COUNT_RX, M_DMA_EOP_COUNT_RX)
182#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
183
184/* *********************************************************************
185 * DMA Descriptors
186 ********************************************************************* */
187
188/*
189 * Descriptor doubleword "A" (Table 7-12)
190 */
191
192#define S_DMA_DSCRA_OFFSET _SB_MAKE64(0)
193#define M_DMA_DSCRA_OFFSET _SB_MAKEMASK(5, S_DMA_DSCRA_OFFSET)
194#define V_DMA_DSCRA_OFFSET(x) _SB_MAKEVALUE(x, S_DMA_DSCRA_OFFSET)
195#define G_DMA_DSCRA_OFFSET(x) _SB_GETVALUE(x, S_DMA_DSCRA_OFFSET, M_DMA_DSCRA_OFFSET)
196
197/* Note: Don't shift the address over, just mask it with the mask below */
198#define S_DMA_DSCRA_A_ADDR _SB_MAKE64(5)
199#define M_DMA_DSCRA_A_ADDR _SB_MAKEMASK(35, S_DMA_DSCRA_A_ADDR)
200
201#define M_DMA_DSCRA_A_ADDR_OFFSET (M_DMA_DSCRA_OFFSET | M_DMA_DSCRA_A_ADDR)
202
203#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
204#define S_DMA_DSCRA_A_ADDR_UA _SB_MAKE64(0)
205#define M_DMA_DSCRA_A_ADDR_UA _SB_MAKEMASK(40, S_DMA_DSCRA_A_ADDR_UA)
206#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
207
208#define S_DMA_DSCRA_A_SIZE _SB_MAKE64(40)
209#define M_DMA_DSCRA_A_SIZE _SB_MAKEMASK(9, S_DMA_DSCRA_A_SIZE)
210#define V_DMA_DSCRA_A_SIZE(x) _SB_MAKEVALUE(x, S_DMA_DSCRA_A_SIZE)
211#define G_DMA_DSCRA_A_SIZE(x) _SB_GETVALUE(x, S_DMA_DSCRA_A_SIZE, M_DMA_DSCRA_A_SIZE)
212
213#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
214#define S_DMA_DSCRA_DSCR_CNT _SB_MAKE64(40)
215#define M_DMA_DSCRA_DSCR_CNT _SB_MAKEMASK(8, S_DMA_DSCRA_DSCR_CNT)
216#define G_DMA_DSCRA_DSCR_CNT(x) _SB_GETVALUE(x, S_DMA_DSCRA_DSCR_CNT, M_DMA_DSCRA_DSCR_CNT)
217#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
218
219#define M_DMA_DSCRA_INTERRUPT _SB_MAKEMASK1(49)
220#define M_DMA_DSCRA_OFFSETB _SB_MAKEMASK1(50)
221
222#define S_DMA_DSCRA_STATUS _SB_MAKE64(51)
223#define M_DMA_DSCRA_STATUS _SB_MAKEMASK(13, S_DMA_DSCRA_STATUS)
224#define V_DMA_DSCRA_STATUS(x) _SB_MAKEVALUE(x, S_DMA_DSCRA_STATUS)
225#define G_DMA_DSCRA_STATUS(x) _SB_GETVALUE(x, S_DMA_DSCRA_STATUS, M_DMA_DSCRA_STATUS)
226
227/*
228 * Descriptor doubleword "B" (Table 7-13)
229 */
230
231
232#define S_DMA_DSCRB_OPTIONS _SB_MAKE64(0)
233#define M_DMA_DSCRB_OPTIONS _SB_MAKEMASK(4, S_DMA_DSCRB_OPTIONS)
234#define V_DMA_DSCRB_OPTIONS(x) _SB_MAKEVALUE(x, S_DMA_DSCRB_OPTIONS)
235#define G_DMA_DSCRB_OPTIONS(x) _SB_GETVALUE(x, S_DMA_DSCRB_OPTIONS, M_DMA_DSCRB_OPTIONS)
236
237#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
238#define S_DMA_DSCRB_A_SIZE _SB_MAKE64(8)
239#define M_DMA_DSCRB_A_SIZE _SB_MAKEMASK(14, S_DMA_DSCRB_A_SIZE)
240#define V_DMA_DSCRB_A_SIZE(x) _SB_MAKEVALUE(x, S_DMA_DSCRB_A_SIZE)
241#define G_DMA_DSCRB_A_SIZE(x) _SB_GETVALUE(x, S_DMA_DSCRB_A_SIZE, M_DMA_DSCRB_A_SIZE)
242#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
243
244#define R_DMA_DSCRB_ADDR _SB_MAKE64(0x10)
245
246/* Note: Don't shift the address over, just mask it with the mask below */
247#define S_DMA_DSCRB_B_ADDR _SB_MAKE64(5)
248#define M_DMA_DSCRB_B_ADDR _SB_MAKEMASK(35, S_DMA_DSCRB_B_ADDR)
249
250#define S_DMA_DSCRB_B_SIZE _SB_MAKE64(40)
251#define M_DMA_DSCRB_B_SIZE _SB_MAKEMASK(9, S_DMA_DSCRB_B_SIZE)
252#define V_DMA_DSCRB_B_SIZE(x) _SB_MAKEVALUE(x, S_DMA_DSCRB_B_SIZE)
253#define G_DMA_DSCRB_B_SIZE(x) _SB_GETVALUE(x, S_DMA_DSCRB_B_SIZE, M_DMA_DSCRB_B_SIZE)
254
255#define M_DMA_DSCRB_B_VALID _SB_MAKEMASK1(49)
256
257#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
258#define S_DMA_DSCRB_PKT_SIZE_MSB _SB_MAKE64(48)
259#define M_DMA_DSCRB_PKT_SIZE_MSB _SB_MAKEMASK(2, S_DMA_DSCRB_PKT_SIZE_MSB)
260#define V_DMA_DSCRB_PKT_SIZE_MSB(x) _SB_MAKEVALUE(x, S_DMA_DSCRB_PKT_SIZE_MSB)
261#define G_DMA_DSCRB_PKT_SIZE_MSB(x) _SB_GETVALUE(x, S_DMA_DSCRB_PKT_SIZE_MSB, M_DMA_DSCRB_PKT_SIZE_MSB)
262#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
263
264#define S_DMA_DSCRB_PKT_SIZE _SB_MAKE64(50)
265#define M_DMA_DSCRB_PKT_SIZE _SB_MAKEMASK(14, S_DMA_DSCRB_PKT_SIZE)
266#define V_DMA_DSCRB_PKT_SIZE(x) _SB_MAKEVALUE(x, S_DMA_DSCRB_PKT_SIZE)
267#define G_DMA_DSCRB_PKT_SIZE(x) _SB_GETVALUE(x, S_DMA_DSCRB_PKT_SIZE, M_DMA_DSCRB_PKT_SIZE)
268
269/*
270 * from pass2 some bits in dscr_b are also used for rx status
271 */
272#define S_DMA_DSCRB_STATUS _SB_MAKE64(0)
273#define M_DMA_DSCRB_STATUS _SB_MAKEMASK(1, S_DMA_DSCRB_STATUS)
274#define V_DMA_DSCRB_STATUS(x) _SB_MAKEVALUE(x, S_DMA_DSCRB_STATUS)
275#define G_DMA_DSCRB_STATUS(x) _SB_GETVALUE(x, S_DMA_DSCRB_STATUS, M_DMA_DSCRB_STATUS)
276
277/*
278 * Ethernet Descriptor Status Bits (Table 7-15)
279 */
280
281#define M_DMA_ETHRX_BADIP4CS _SB_MAKEMASK1(51)
282#define M_DMA_ETHRX_DSCRERR _SB_MAKEMASK1(52)
283
284#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
285/* Note: This bit is in the DSCR_B options field */
286#define M_DMA_ETHRX_BADTCPCS _SB_MAKEMASK1(0)
287#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
288
289#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
290/* Note: These bits are in the DSCR_B options field */
291#define M_DMA_ETH_VLAN_FLAG _SB_MAKEMASK1(1)
292#define M_DMA_ETH_CRC_FLAG _SB_MAKEMASK1(2)
293#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
294
295#define S_DMA_ETHRX_RXCH 53
296#define M_DMA_ETHRX_RXCH _SB_MAKEMASK(2, S_DMA_ETHRX_RXCH)
297#define V_DMA_ETHRX_RXCH(x) _SB_MAKEVALUE(x, S_DMA_ETHRX_RXCH)
298#define G_DMA_ETHRX_RXCH(x) _SB_GETVALUE(x, S_DMA_ETHRX_RXCH, M_DMA_ETHRX_RXCH)
299
300#define S_DMA_ETHRX_PKTTYPE 55
301#define M_DMA_ETHRX_PKTTYPE _SB_MAKEMASK(3, S_DMA_ETHRX_PKTTYPE)
302#define V_DMA_ETHRX_PKTTYPE(x) _SB_MAKEVALUE(x, S_DMA_ETHRX_PKTTYPE)
303#define G_DMA_ETHRX_PKTTYPE(x) _SB_GETVALUE(x, S_DMA_ETHRX_PKTTYPE, M_DMA_ETHRX_PKTTYPE)
304
305#define K_DMA_ETHRX_PKTTYPE_IPV4 0
306#define K_DMA_ETHRX_PKTTYPE_ARPV4 1
307#define K_DMA_ETHRX_PKTTYPE_802 2
308#define K_DMA_ETHRX_PKTTYPE_OTHER 3
309#define K_DMA_ETHRX_PKTTYPE_USER0 4
310#define K_DMA_ETHRX_PKTTYPE_USER1 5
311#define K_DMA_ETHRX_PKTTYPE_USER2 6
312#define K_DMA_ETHRX_PKTTYPE_USER3 7
313
314#define M_DMA_ETHRX_MATCH_HASH _SB_MAKEMASK1(58)
315#define M_DMA_ETHRX_MATCH_EXACT _SB_MAKEMASK1(59)
316#define M_DMA_ETHRX_BCAST _SB_MAKEMASK1(60)
317#define M_DMA_ETHRX_MCAST _SB_MAKEMASK1(61)
318#define M_DMA_ETHRX_BAD _SB_MAKEMASK1(62)
319#define M_DMA_ETHRX_SOP _SB_MAKEMASK1(63)
320
321/*
322 * Ethernet Transmit Status Bits (Table 7-16)
323 */
324
325#define M_DMA_ETHTX_SOP _SB_MAKEMASK1(63)
326
327/*
328 * Ethernet Transmit Options (Table 7-17)
329 */
330
331#define K_DMA_ETHTX_NOTSOP _SB_MAKE64(0x00)
332#define K_DMA_ETHTX_APPENDCRC _SB_MAKE64(0x01)
333#define K_DMA_ETHTX_REPLACECRC _SB_MAKE64(0x02)
334#define K_DMA_ETHTX_APPENDCRC_APPENDPAD _SB_MAKE64(0x03)
335#define K_DMA_ETHTX_APPENDVLAN_REPLACECRC _SB_MAKE64(0x04)
336#define K_DMA_ETHTX_REMOVEVLAN_REPLACECRC _SB_MAKE64(0x05)
337#define K_DMA_ETHTX_REPLACEVLAN_REPLACECRC _SB_MAKE64(0x6)
338#define K_DMA_ETHTX_NOMODS _SB_MAKE64(0x07)
339#define K_DMA_ETHTX_RESERVED1 _SB_MAKE64(0x08)
340#define K_DMA_ETHTX_REPLACESADDR_APPENDCRC _SB_MAKE64(0x09)
341#define K_DMA_ETHTX_REPLACESADDR_REPLACECRC _SB_MAKE64(0x0A)
342#define K_DMA_ETHTX_REPLACESADDR_APPENDCRC_APPENDPAD _SB_MAKE64(0x0B)
343#define K_DMA_ETHTX_REPLACESADDR_APPENDVLAN_REPLACECRC _SB_MAKE64(0x0C)
344#define K_DMA_ETHTX_REPLACESADDR_REMOVEVLAN_REPLACECRC _SB_MAKE64(0x0D)
345#define K_DMA_ETHTX_REPLACESADDR_REPLACEVLAN_REPLACECRC _SB_MAKE64(0x0E)
346#define K_DMA_ETHTX_RESERVED2 _SB_MAKE64(0x0F)
347
348/*
349 * Serial Receive Options (Table 7-18)
350 */
351#define M_DMA_SERRX_CRC_ERROR _SB_MAKEMASK1(56)
352#define M_DMA_SERRX_ABORT _SB_MAKEMASK1(57)
353#define M_DMA_SERRX_OCTET_ERROR _SB_MAKEMASK1(58)
354#define M_DMA_SERRX_LONGFRAME_ERROR _SB_MAKEMASK1(59)
355#define M_DMA_SERRX_SHORTFRAME_ERROR _SB_MAKEMASK1(60)
356#define M_DMA_SERRX_OVERRUN_ERROR _SB_MAKEMASK1(61)
357#define M_DMA_SERRX_GOOD _SB_MAKEMASK1(62)
358#define M_DMA_SERRX_SOP _SB_MAKEMASK1(63)
359
360/*
361 * Serial Transmit Status Bits (Table 7-20)
362 */
363
364#define M_DMA_SERTX_FLAG _SB_MAKEMASK1(63)
365
366/*
367 * Serial Transmit Options (Table 7-21)
368 */
369
370#define K_DMA_SERTX_RESERVED _SB_MAKEMASK1(0)
371#define K_DMA_SERTX_APPENDCRC _SB_MAKEMASK1(1)
372#define K_DMA_SERTX_APPENDPAD _SB_MAKEMASK1(2)
373#define K_DMA_SERTX_ABORT _SB_MAKEMASK1(3)
374
375
376/* *********************************************************************
377 * Data Mover Registers
378 ********************************************************************* */
379
380/*
381 * Data Mover Descriptor Base Address Register (Table 7-22)
382 * Register: DM_DSCR_BASE_0
383 * Register: DM_DSCR_BASE_1
384 * Register: DM_DSCR_BASE_2
385 * Register: DM_DSCR_BASE_3
386 */
387
388#define M_DM_DSCR_BASE_MBZ _SB_MAKEMASK(4, 0)
389
390/* Note: Just mask the base address and then OR it in. */
391#define S_DM_DSCR_BASE_ADDR _SB_MAKE64(4)
392#define M_DM_DSCR_BASE_ADDR _SB_MAKEMASK(36, S_DM_DSCR_BASE_ADDR)
393
394#define S_DM_DSCR_BASE_RINGSZ _SB_MAKE64(40)
395#define M_DM_DSCR_BASE_RINGSZ _SB_MAKEMASK(16, S_DM_DSCR_BASE_RINGSZ)
396#define V_DM_DSCR_BASE_RINGSZ(x) _SB_MAKEVALUE(x, S_DM_DSCR_BASE_RINGSZ)
397#define G_DM_DSCR_BASE_RINGSZ(x) _SB_GETVALUE(x, S_DM_DSCR_BASE_RINGSZ, M_DM_DSCR_BASE_RINGSZ)
398
399#define S_DM_DSCR_BASE_PRIORITY _SB_MAKE64(56)
400#define M_DM_DSCR_BASE_PRIORITY _SB_MAKEMASK(3, S_DM_DSCR_BASE_PRIORITY)
401#define V_DM_DSCR_BASE_PRIORITY(x) _SB_MAKEVALUE(x, S_DM_DSCR_BASE_PRIORITY)
402#define G_DM_DSCR_BASE_PRIORITY(x) _SB_GETVALUE(x, S_DM_DSCR_BASE_PRIORITY, M_DM_DSCR_BASE_PRIORITY)
403
404#define K_DM_DSCR_BASE_PRIORITY_1 0
405#define K_DM_DSCR_BASE_PRIORITY_2 1
406#define K_DM_DSCR_BASE_PRIORITY_4 2
407#define K_DM_DSCR_BASE_PRIORITY_8 3
408#define K_DM_DSCR_BASE_PRIORITY_16 4
409
410#define M_DM_DSCR_BASE_ACTIVE _SB_MAKEMASK1(59)
411#define M_DM_DSCR_BASE_INTERRUPT _SB_MAKEMASK1(60)
412#define M_DM_DSCR_BASE_RESET _SB_MAKEMASK1(61) /* write register */
413#define M_DM_DSCR_BASE_ERROR _SB_MAKEMASK1(61) /* read register */
414#define M_DM_DSCR_BASE_ABORT _SB_MAKEMASK1(62)
415#define M_DM_DSCR_BASE_ENABL _SB_MAKEMASK1(63)
416
417/*
418 * Data Mover Descriptor Count Register (Table 7-25)
419 */
420
421/* no bitfields */
422
423/*
424 * Data Mover Current Descriptor Address (Table 7-24)
425 * Register: DM_CUR_DSCR_ADDR_0
426 * Register: DM_CUR_DSCR_ADDR_1
427 * Register: DM_CUR_DSCR_ADDR_2
428 * Register: DM_CUR_DSCR_ADDR_3
429 */
430
431#define S_DM_CUR_DSCR_DSCR_ADDR _SB_MAKE64(0)
432#define M_DM_CUR_DSCR_DSCR_ADDR _SB_MAKEMASK(40, S_DM_CUR_DSCR_DSCR_ADDR)
433
434#define S_DM_CUR_DSCR_DSCR_COUNT _SB_MAKE64(48)
435#define M_DM_CUR_DSCR_DSCR_COUNT _SB_MAKEMASK(16, S_DM_CUR_DSCR_DSCR_COUNT)
436#define V_DM_CUR_DSCR_DSCR_COUNT(r) _SB_MAKEVALUE(r, S_DM_CUR_DSCR_DSCR_COUNT)
437#define G_DM_CUR_DSCR_DSCR_COUNT(r) _SB_GETVALUE(r, S_DM_CUR_DSCR_DSCR_COUNT,\
438 M_DM_CUR_DSCR_DSCR_COUNT)
439
440
441#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
442/*
443 * Data Mover Channel Partial Result Registers
444 * Register: DM_PARTIAL_0
445 * Register: DM_PARTIAL_1
446 * Register: DM_PARTIAL_2
447 * Register: DM_PARTIAL_3
448 */
449#define S_DM_PARTIAL_CRC_PARTIAL _SB_MAKE64(0)
450#define M_DM_PARTIAL_CRC_PARTIAL _SB_MAKEMASK(32, S_DM_PARTIAL_CRC_PARTIAL)
451#define V_DM_PARTIAL_CRC_PARTIAL(r) _SB_MAKEVALUE(r, S_DM_PARTIAL_CRC_PARTIAL)
452#define G_DM_PARTIAL_CRC_PARTIAL(r) _SB_GETVALUE(r, S_DM_PARTIAL_CRC_PARTIAL,\
453 M_DM_PARTIAL_CRC_PARTIAL)
454
455#define S_DM_PARTIAL_TCPCS_PARTIAL _SB_MAKE64(32)
456#define M_DM_PARTIAL_TCPCS_PARTIAL _SB_MAKEMASK(16, S_DM_PARTIAL_TCPCS_PARTIAL)
457#define V_DM_PARTIAL_TCPCS_PARTIAL(r) _SB_MAKEVALUE(r, S_DM_PARTIAL_TCPCS_PARTIAL)
458#define G_DM_PARTIAL_TCPCS_PARTIAL(r) _SB_GETVALUE(r, S_DM_PARTIAL_TCPCS_PARTIAL,\
459 M_DM_PARTIAL_TCPCS_PARTIAL)
460
461#define M_DM_PARTIAL_ODD_BYTE _SB_MAKEMASK1(48)
462#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
463
464
465#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
466/*
467 * Data Mover CRC Definition Registers
468 * Register: CRC_DEF_0
469 * Register: CRC_DEF_1
470 */
471#define S_CRC_DEF_CRC_INIT _SB_MAKE64(0)
472#define M_CRC_DEF_CRC_INIT _SB_MAKEMASK(32, S_CRC_DEF_CRC_INIT)
473#define V_CRC_DEF_CRC_INIT(r) _SB_MAKEVALUE(r, S_CRC_DEF_CRC_INIT)
474#define G_CRC_DEF_CRC_INIT(r) _SB_GETVALUE(r, S_CRC_DEF_CRC_INIT,\
475 M_CRC_DEF_CRC_INIT)
476
477#define S_CRC_DEF_CRC_POLY _SB_MAKE64(32)
478#define M_CRC_DEF_CRC_POLY _SB_MAKEMASK(32, S_CRC_DEF_CRC_POLY)
479#define V_CRC_DEF_CRC_POLY(r) _SB_MAKEVALUE(r, S_CRC_DEF_CRC_POLY)
480#define G_CRC_DEF_CRC_POLY(r) _SB_GETVALUE(r, S_CRC_DEF_CRC_POLY,\
481 M_CRC_DEF_CRC_POLY)
482#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
483
484
485#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
486/*
487 * Data Mover CRC/Checksum Definition Registers
488 * Register: CTCP_DEF_0
489 * Register: CTCP_DEF_1
490 */
491#define S_CTCP_DEF_CRC_TXOR _SB_MAKE64(0)
492#define M_CTCP_DEF_CRC_TXOR _SB_MAKEMASK(32, S_CTCP_DEF_CRC_TXOR)
493#define V_CTCP_DEF_CRC_TXOR(r) _SB_MAKEVALUE(r, S_CTCP_DEF_CRC_TXOR)
494#define G_CTCP_DEF_CRC_TXOR(r) _SB_GETVALUE(r, S_CTCP_DEF_CRC_TXOR,\
495 M_CTCP_DEF_CRC_TXOR)
496
497#define S_CTCP_DEF_TCPCS_INIT _SB_MAKE64(32)
498#define M_CTCP_DEF_TCPCS_INIT _SB_MAKEMASK(16, S_CTCP_DEF_TCPCS_INIT)
499#define V_CTCP_DEF_TCPCS_INIT(r) _SB_MAKEVALUE(r, S_CTCP_DEF_TCPCS_INIT)
500#define G_CTCP_DEF_TCPCS_INIT(r) _SB_GETVALUE(r, S_CTCP_DEF_TCPCS_INIT,\
501 M_CTCP_DEF_TCPCS_INIT)
502
503#define S_CTCP_DEF_CRC_WIDTH _SB_MAKE64(48)
504#define M_CTCP_DEF_CRC_WIDTH _SB_MAKEMASK(2, S_CTCP_DEF_CRC_WIDTH)
505#define V_CTCP_DEF_CRC_WIDTH(r) _SB_MAKEVALUE(r, S_CTCP_DEF_CRC_WIDTH)
506#define G_CTCP_DEF_CRC_WIDTH(r) _SB_GETVALUE(r, S_CTCP_DEF_CRC_WIDTH,\
507 M_CTCP_DEF_CRC_WIDTH)
508
509#define K_CTCP_DEF_CRC_WIDTH_4 0
510#define K_CTCP_DEF_CRC_WIDTH_2 1
511#define K_CTCP_DEF_CRC_WIDTH_1 2
512
513#define M_CTCP_DEF_CRC_BIT_ORDER _SB_MAKEMASK1(50)
514#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
515
516
517/*
518 * Data Mover Descriptor Doubleword "A" (Table 7-26)
519 */
520
521#define S_DM_DSCRA_DST_ADDR _SB_MAKE64(0)
522#define M_DM_DSCRA_DST_ADDR _SB_MAKEMASK(40, S_DM_DSCRA_DST_ADDR)
523
524#define M_DM_DSCRA_UN_DEST _SB_MAKEMASK1(40)
525#define M_DM_DSCRA_UN_SRC _SB_MAKEMASK1(41)
526#define M_DM_DSCRA_INTERRUPT _SB_MAKEMASK1(42)
527#if SIBYTE_HDR_FEATURE_UP_TO(1250, PASS1)
528#define M_DM_DSCRA_THROTTLE _SB_MAKEMASK1(43)
529#endif /* up to 1250 PASS1 */
530
531#define S_DM_DSCRA_DIR_DEST _SB_MAKE64(44)
532#define M_DM_DSCRA_DIR_DEST _SB_MAKEMASK(2, S_DM_DSCRA_DIR_DEST)
533#define V_DM_DSCRA_DIR_DEST(x) _SB_MAKEVALUE(x, S_DM_DSCRA_DIR_DEST)
534#define G_DM_DSCRA_DIR_DEST(x) _SB_GETVALUE(x, S_DM_DSCRA_DIR_DEST, M_DM_DSCRA_DIR_DEST)
535
536#define K_DM_DSCRA_DIR_DEST_INCR 0
537#define K_DM_DSCRA_DIR_DEST_DECR 1
538#define K_DM_DSCRA_DIR_DEST_CONST 2
539
540#define V_DM_DSCRA_DIR_DEST_INCR _SB_MAKEVALUE(K_DM_DSCRA_DIR_DEST_INCR, S_DM_DSCRA_DIR_DEST)
541#define V_DM_DSCRA_DIR_DEST_DECR _SB_MAKEVALUE(K_DM_DSCRA_DIR_DEST_DECR, S_DM_DSCRA_DIR_DEST)
542#define V_DM_DSCRA_DIR_DEST_CONST _SB_MAKEVALUE(K_DM_DSCRA_DIR_DEST_CONST, S_DM_DSCRA_DIR_DEST)
543
544#define S_DM_DSCRA_DIR_SRC _SB_MAKE64(46)
545#define M_DM_DSCRA_DIR_SRC _SB_MAKEMASK(2, S_DM_DSCRA_DIR_SRC)
546#define V_DM_DSCRA_DIR_SRC(x) _SB_MAKEVALUE(x, S_DM_DSCRA_DIR_SRC)
547#define G_DM_DSCRA_DIR_SRC(x) _SB_GETVALUE(x, S_DM_DSCRA_DIR_SRC, M_DM_DSCRA_DIR_SRC)
548
549#define K_DM_DSCRA_DIR_SRC_INCR 0
550#define K_DM_DSCRA_DIR_SRC_DECR 1
551#define K_DM_DSCRA_DIR_SRC_CONST 2
552
553#define V_DM_DSCRA_DIR_SRC_INCR _SB_MAKEVALUE(K_DM_DSCRA_DIR_SRC_INCR, S_DM_DSCRA_DIR_SRC)
554#define V_DM_DSCRA_DIR_SRC_DECR _SB_MAKEVALUE(K_DM_DSCRA_DIR_SRC_DECR, S_DM_DSCRA_DIR_SRC)
555#define V_DM_DSCRA_DIR_SRC_CONST _SB_MAKEVALUE(K_DM_DSCRA_DIR_SRC_CONST, S_DM_DSCRA_DIR_SRC)
556
557
558#define M_DM_DSCRA_ZERO_MEM _SB_MAKEMASK1(48)
559#define M_DM_DSCRA_PREFETCH _SB_MAKEMASK1(49)
560#define M_DM_DSCRA_L2C_DEST _SB_MAKEMASK1(50)
561#define M_DM_DSCRA_L2C_SRC _SB_MAKEMASK1(51)
562
563#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
564#define M_DM_DSCRA_RD_BKOFF _SB_MAKEMASK1(52)
565#define M_DM_DSCRA_WR_BKOFF _SB_MAKEMASK1(53)
566#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
567
568#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
569#define M_DM_DSCRA_TCPCS_EN _SB_MAKEMASK1(54)
570#define M_DM_DSCRA_TCPCS_RES _SB_MAKEMASK1(55)
571#define M_DM_DSCRA_TCPCS_AP _SB_MAKEMASK1(56)
572#define M_DM_DSCRA_CRC_EN _SB_MAKEMASK1(57)
573#define M_DM_DSCRA_CRC_RES _SB_MAKEMASK1(58)
574#define M_DM_DSCRA_CRC_AP _SB_MAKEMASK1(59)
575#define M_DM_DSCRA_CRC_DFN _SB_MAKEMASK1(60)
576#define M_DM_DSCRA_CRC_XBIT _SB_MAKEMASK1(61)
577#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
578
579#define M_DM_DSCRA_RESERVED2 _SB_MAKEMASK(3, 61)
580
581/*
582 * Data Mover Descriptor Doubleword "B" (Table 7-25)
583 */
584
585#define S_DM_DSCRB_SRC_ADDR _SB_MAKE64(0)
586#define M_DM_DSCRB_SRC_ADDR _SB_MAKEMASK(40, S_DM_DSCRB_SRC_ADDR)
587
588#define S_DM_DSCRB_SRC_LENGTH _SB_MAKE64(40)
589#define M_DM_DSCRB_SRC_LENGTH _SB_MAKEMASK(20, S_DM_DSCRB_SRC_LENGTH)
590#define V_DM_DSCRB_SRC_LENGTH(x) _SB_MAKEVALUE(x, S_DM_DSCRB_SRC_LENGTH)
591#define G_DM_DSCRB_SRC_LENGTH(x) _SB_GETVALUE(x, S_DM_DSCRB_SRC_LENGTH, M_DM_DSCRB_SRC_LENGTH)
592
593
594#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_genbus.h b/arch/mips/include/asm/sibyte/sb1250_genbus.h
new file mode 100644
index 000000000000..94e9c7c8e783
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_genbus.h
@@ -0,0 +1,474 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * Generic Bus Constants File: sb1250_genbus.h
5 *
6 * This module contains constants and macros useful for
7 * manipulating the SB1250's Generic Bus interface
8 *
9 * SB1250 specification level: User's manual 10/21/02
10 * BCM1280 specification level: User's Manual 11/14/03
11 *
12 *********************************************************************
13 *
14 * Copyright 2000, 2001, 2002, 2003
15 * Broadcom Corporation. All rights reserved.
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
31 ********************************************************************* */
32
33
34#ifndef _SB1250_GENBUS_H
35#define _SB1250_GENBUS_H
36
37#include "sb1250_defs.h"
38
39/*
40 * Generic Bus Region Configuration Registers (Table 11-4)
41 */
42
43#define S_IO_RDY_ACTIVE 0
44#define M_IO_RDY_ACTIVE _SB_MAKEMASK1(S_IO_RDY_ACTIVE)
45
46#define S_IO_ENA_RDY 1
47#define M_IO_ENA_RDY _SB_MAKEMASK1(S_IO_ENA_RDY)
48
49#define S_IO_WIDTH_SEL 2
50#define M_IO_WIDTH_SEL _SB_MAKEMASK(2, S_IO_WIDTH_SEL)
51#define K_IO_WIDTH_SEL_1 0
52#define K_IO_WIDTH_SEL_2 1
53#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) \
54 || SIBYTE_HDR_FEATURE_CHIP(1480)
55#define K_IO_WIDTH_SEL_1L 2
56#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
57#define K_IO_WIDTH_SEL_4 3
58#define V_IO_WIDTH_SEL(x) _SB_MAKEVALUE(x, S_IO_WIDTH_SEL)
59#define G_IO_WIDTH_SEL(x) _SB_GETVALUE(x, S_IO_WIDTH_SEL, M_IO_WIDTH_SEL)
60
61#define S_IO_PARITY_ENA 4
62#define M_IO_PARITY_ENA _SB_MAKEMASK1(S_IO_PARITY_ENA)
63#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) \
64 || SIBYTE_HDR_FEATURE_CHIP(1480)
65#define S_IO_BURST_EN 5
66#define M_IO_BURST_EN _SB_MAKEMASK1(S_IO_BURST_EN)
67#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
68#define S_IO_PARITY_ODD 6
69#define M_IO_PARITY_ODD _SB_MAKEMASK1(S_IO_PARITY_ODD)
70#define S_IO_NONMUX 7
71#define M_IO_NONMUX _SB_MAKEMASK1(S_IO_NONMUX)
72
73#define S_IO_TIMEOUT 8
74#define M_IO_TIMEOUT _SB_MAKEMASK(8, S_IO_TIMEOUT)
75#define V_IO_TIMEOUT(x) _SB_MAKEVALUE(x, S_IO_TIMEOUT)
76#define G_IO_TIMEOUT(x) _SB_GETVALUE(x, S_IO_TIMEOUT, M_IO_TIMEOUT)
77
78/*
79 * Generic Bus Region Size register (Table 11-5)
80 */
81
82#define S_IO_MULT_SIZE 0
83#define M_IO_MULT_SIZE _SB_MAKEMASK(12, S_IO_MULT_SIZE)
84#define V_IO_MULT_SIZE(x) _SB_MAKEVALUE(x, S_IO_MULT_SIZE)
85#define G_IO_MULT_SIZE(x) _SB_GETVALUE(x, S_IO_MULT_SIZE, M_IO_MULT_SIZE)
86
87#define S_IO_REGSIZE 16 /* # bits to shift size for this reg */
88
89/*
90 * Generic Bus Region Address (Table 11-6)
91 */
92
93#define S_IO_START_ADDR 0
94#define M_IO_START_ADDR _SB_MAKEMASK(14, S_IO_START_ADDR)
95#define V_IO_START_ADDR(x) _SB_MAKEVALUE(x, S_IO_START_ADDR)
96#define G_IO_START_ADDR(x) _SB_GETVALUE(x, S_IO_START_ADDR, M_IO_START_ADDR)
97
98#define S_IO_ADDRBASE 16 /* # bits to shift addr for this reg */
99
100#define M_IO_BLK_CACHE _SB_MAKEMASK1(15)
101
102
103/*
104 * Generic Bus Timing 0 Registers (Table 11-7)
105 */
106
107#define S_IO_ALE_WIDTH 0
108#define M_IO_ALE_WIDTH _SB_MAKEMASK(3, S_IO_ALE_WIDTH)
109#define V_IO_ALE_WIDTH(x) _SB_MAKEVALUE(x, S_IO_ALE_WIDTH)
110#define G_IO_ALE_WIDTH(x) _SB_GETVALUE(x, S_IO_ALE_WIDTH, M_IO_ALE_WIDTH)
111
112#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) \
113 || SIBYTE_HDR_FEATURE_CHIP(1480)
114#define M_IO_EARLY_CS _SB_MAKEMASK1(3)
115#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
116
117#define S_IO_ALE_TO_CS 4
118#define M_IO_ALE_TO_CS _SB_MAKEMASK(2, S_IO_ALE_TO_CS)
119#define V_IO_ALE_TO_CS(x) _SB_MAKEVALUE(x, S_IO_ALE_TO_CS)
120#define G_IO_ALE_TO_CS(x) _SB_GETVALUE(x, S_IO_ALE_TO_CS, M_IO_ALE_TO_CS)
121
122#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) \
123 || SIBYTE_HDR_FEATURE_CHIP(1480)
124#define S_IO_BURST_WIDTH _SB_MAKE64(6)
125#define M_IO_BURST_WIDTH _SB_MAKEMASK(2, S_IO_BURST_WIDTH)
126#define V_IO_BURST_WIDTH(x) _SB_MAKEVALUE(x, S_IO_BURST_WIDTH)
127#define G_IO_BURST_WIDTH(x) _SB_GETVALUE(x, S_IO_BURST_WIDTH, M_IO_BURST_WIDTH)
128#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
129
130#define S_IO_CS_WIDTH 8
131#define M_IO_CS_WIDTH _SB_MAKEMASK(5, S_IO_CS_WIDTH)
132#define V_IO_CS_WIDTH(x) _SB_MAKEVALUE(x, S_IO_CS_WIDTH)
133#define G_IO_CS_WIDTH(x) _SB_GETVALUE(x, S_IO_CS_WIDTH, M_IO_CS_WIDTH)
134
135#define S_IO_RDY_SMPLE 13
136#define M_IO_RDY_SMPLE _SB_MAKEMASK(3, S_IO_RDY_SMPLE)
137#define V_IO_RDY_SMPLE(x) _SB_MAKEVALUE(x, S_IO_RDY_SMPLE)
138#define G_IO_RDY_SMPLE(x) _SB_GETVALUE(x, S_IO_RDY_SMPLE, M_IO_RDY_SMPLE)
139
140
141/*
142 * Generic Bus Timing 1 Registers (Table 11-8)
143 */
144
145#define S_IO_ALE_TO_WRITE 0
146#define M_IO_ALE_TO_WRITE _SB_MAKEMASK(3, S_IO_ALE_TO_WRITE)
147#define V_IO_ALE_TO_WRITE(x) _SB_MAKEVALUE(x, S_IO_ALE_TO_WRITE)
148#define G_IO_ALE_TO_WRITE(x) _SB_GETVALUE(x, S_IO_ALE_TO_WRITE, M_IO_ALE_TO_WRITE)
149
150#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) \
151 || SIBYTE_HDR_FEATURE_CHIP(1480)
152#define M_IO_RDY_SYNC _SB_MAKEMASK1(3)
153#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
154
155#define S_IO_WRITE_WIDTH 4
156#define M_IO_WRITE_WIDTH _SB_MAKEMASK(4, S_IO_WRITE_WIDTH)
157#define V_IO_WRITE_WIDTH(x) _SB_MAKEVALUE(x, S_IO_WRITE_WIDTH)
158#define G_IO_WRITE_WIDTH(x) _SB_GETVALUE(x, S_IO_WRITE_WIDTH, M_IO_WRITE_WIDTH)
159
160#define S_IO_IDLE_CYCLE 8
161#define M_IO_IDLE_CYCLE _SB_MAKEMASK(4, S_IO_IDLE_CYCLE)
162#define V_IO_IDLE_CYCLE(x) _SB_MAKEVALUE(x, S_IO_IDLE_CYCLE)
163#define G_IO_IDLE_CYCLE(x) _SB_GETVALUE(x, S_IO_IDLE_CYCLE, M_IO_IDLE_CYCLE)
164
165#define S_IO_OE_TO_CS 12
166#define M_IO_OE_TO_CS _SB_MAKEMASK(2, S_IO_OE_TO_CS)
167#define V_IO_OE_TO_CS(x) _SB_MAKEVALUE(x, S_IO_OE_TO_CS)
168#define G_IO_OE_TO_CS(x) _SB_GETVALUE(x, S_IO_OE_TO_CS, M_IO_OE_TO_CS)
169
170#define S_IO_CS_TO_OE 14
171#define M_IO_CS_TO_OE _SB_MAKEMASK(2, S_IO_CS_TO_OE)
172#define V_IO_CS_TO_OE(x) _SB_MAKEVALUE(x, S_IO_CS_TO_OE)
173#define G_IO_CS_TO_OE(x) _SB_GETVALUE(x, S_IO_CS_TO_OE, M_IO_CS_TO_OE)
174
175/*
176 * Generic Bus Interrupt Status Register (Table 11-9)
177 */
178
179#define M_IO_CS_ERR_INT _SB_MAKEMASK(0, 8)
180#define M_IO_CS0_ERR_INT _SB_MAKEMASK1(0)
181#define M_IO_CS1_ERR_INT _SB_MAKEMASK1(1)
182#define M_IO_CS2_ERR_INT _SB_MAKEMASK1(2)
183#define M_IO_CS3_ERR_INT _SB_MAKEMASK1(3)
184#define M_IO_CS4_ERR_INT _SB_MAKEMASK1(4)
185#define M_IO_CS5_ERR_INT _SB_MAKEMASK1(5)
186#define M_IO_CS6_ERR_INT _SB_MAKEMASK1(6)
187#define M_IO_CS7_ERR_INT _SB_MAKEMASK1(7)
188
189#define M_IO_RD_PAR_INT _SB_MAKEMASK1(9)
190#define M_IO_TIMEOUT_INT _SB_MAKEMASK1(10)
191#define M_IO_ILL_ADDR_INT _SB_MAKEMASK1(11)
192#define M_IO_MULT_CS_INT _SB_MAKEMASK1(12)
193#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
194#define M_IO_COH_ERR _SB_MAKEMASK1(14)
195#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
196
197
198/*
199 * Generic Bus Output Drive Control Register 0 (Table 14-18)
200 */
201
202#define S_IO_SLEW0 0
203#define M_IO_SLEW0 _SB_MAKEMASK(2, S_IO_SLEW0)
204#define V_IO_SLEW0(x) _SB_MAKEVALUE(x, S_IO_SLEW0)
205#define G_IO_SLEW0(x) _SB_GETVALUE(x, S_IO_SLEW0, M_IO_SLEW0)
206
207#define S_IO_DRV_A 2
208#define M_IO_DRV_A _SB_MAKEMASK(2, S_IO_DRV_A)
209#define V_IO_DRV_A(x) _SB_MAKEVALUE(x, S_IO_DRV_A)
210#define G_IO_DRV_A(x) _SB_GETVALUE(x, S_IO_DRV_A, M_IO_DRV_A)
211
212#define S_IO_DRV_B 6
213#define M_IO_DRV_B _SB_MAKEMASK(2, S_IO_DRV_B)
214#define V_IO_DRV_B(x) _SB_MAKEVALUE(x, S_IO_DRV_B)
215#define G_IO_DRV_B(x) _SB_GETVALUE(x, S_IO_DRV_B, M_IO_DRV_B)
216
217#define S_IO_DRV_C 10
218#define M_IO_DRV_C _SB_MAKEMASK(2, S_IO_DRV_C)
219#define V_IO_DRV_C(x) _SB_MAKEVALUE(x, S_IO_DRV_C)
220#define G_IO_DRV_C(x) _SB_GETVALUE(x, S_IO_DRV_C, M_IO_DRV_C)
221
222#define S_IO_DRV_D 14
223#define M_IO_DRV_D _SB_MAKEMASK(2, S_IO_DRV_D)
224#define V_IO_DRV_D(x) _SB_MAKEVALUE(x, S_IO_DRV_D)
225#define G_IO_DRV_D(x) _SB_GETVALUE(x, S_IO_DRV_D, M_IO_DRV_D)
226
227/*
228 * Generic Bus Output Drive Control Register 1 (Table 14-19)
229 */
230
231#define S_IO_DRV_E 2
232#define M_IO_DRV_E _SB_MAKEMASK(2, S_IO_DRV_E)
233#define V_IO_DRV_E(x) _SB_MAKEVALUE(x, S_IO_DRV_E)
234#define G_IO_DRV_E(x) _SB_GETVALUE(x, S_IO_DRV_E, M_IO_DRV_E)
235
236#define S_IO_DRV_F 6
237#define M_IO_DRV_F _SB_MAKEMASK(2, S_IO_DRV_F)
238#define V_IO_DRV_F(x) _SB_MAKEVALUE(x, S_IO_DRV_F)
239#define G_IO_DRV_F(x) _SB_GETVALUE(x, S_IO_DRV_F, M_IO_DRV_F)
240
241#define S_IO_SLEW1 8
242#define M_IO_SLEW1 _SB_MAKEMASK(2, S_IO_SLEW1)
243#define V_IO_SLEW1(x) _SB_MAKEVALUE(x, S_IO_SLEW1)
244#define G_IO_SLEW1(x) _SB_GETVALUE(x, S_IO_SLEW1, M_IO_SLEW1)
245
246#define S_IO_DRV_G 10
247#define M_IO_DRV_G _SB_MAKEMASK(2, S_IO_DRV_G)
248#define V_IO_DRV_G(x) _SB_MAKEVALUE(x, S_IO_DRV_G)
249#define G_IO_DRV_G(x) _SB_GETVALUE(x, S_IO_DRV_G, M_IO_DRV_G)
250
251#define S_IO_SLEW2 12
252#define M_IO_SLEW2 _SB_MAKEMASK(2, S_IO_SLEW2)
253#define V_IO_SLEW2(x) _SB_MAKEVALUE(x, S_IO_SLEW2)
254#define G_IO_SLEW2(x) _SB_GETVALUE(x, S_IO_SLEW2, M_IO_SLEW2)
255
256#define S_IO_DRV_H 14
257#define M_IO_DRV_H _SB_MAKEMASK(2, S_IO_DRV_H)
258#define V_IO_DRV_H(x) _SB_MAKEVALUE(x, S_IO_DRV_H)
259#define G_IO_DRV_H(x) _SB_GETVALUE(x, S_IO_DRV_H, M_IO_DRV_H)
260
261/*
262 * Generic Bus Output Drive Control Register 2 (Table 14-20)
263 */
264
265#define S_IO_DRV_J 2
266#define M_IO_DRV_J _SB_MAKEMASK(2, S_IO_DRV_J)
267#define V_IO_DRV_J(x) _SB_MAKEVALUE(x, S_IO_DRV_J)
268#define G_IO_DRV_J(x) _SB_GETVALUE(x, S_IO_DRV_J, M_IO_DRV_J)
269
270#define S_IO_DRV_K 6
271#define M_IO_DRV_K _SB_MAKEMASK(2, S_IO_DRV_K)
272#define V_IO_DRV_K(x) _SB_MAKEVALUE(x, S_IO_DRV_K)
273#define G_IO_DRV_K(x) _SB_GETVALUE(x, S_IO_DRV_K, M_IO_DRV_K)
274
275#define S_IO_DRV_L 10
276#define M_IO_DRV_L _SB_MAKEMASK(2, S_IO_DRV_L)
277#define V_IO_DRV_L(x) _SB_MAKEVALUE(x, S_IO_DRV_L)
278#define G_IO_DRV_L(x) _SB_GETVALUE(x, S_IO_DRV_L, M_IO_DRV_L)
279
280#define S_IO_DRV_M 14
281#define M_IO_DRV_M _SB_MAKEMASK(2, S_IO_DRV_M)
282#define V_IO_DRV_M(x) _SB_MAKEVALUE(x, S_IO_DRV_M)
283#define G_IO_DRV_M(x) _SB_GETVALUE(x, S_IO_DRV_M, M_IO_DRV_M)
284
285/*
286 * Generic Bus Output Drive Control Register 3 (Table 14-21)
287 */
288
289#define S_IO_SLEW3 0
290#define M_IO_SLEW3 _SB_MAKEMASK(2, S_IO_SLEW3)
291#define V_IO_SLEW3(x) _SB_MAKEVALUE(x, S_IO_SLEW3)
292#define G_IO_SLEW3(x) _SB_GETVALUE(x, S_IO_SLEW3, M_IO_SLEW3)
293
294#define S_IO_DRV_N 2
295#define M_IO_DRV_N _SB_MAKEMASK(2, S_IO_DRV_N)
296#define V_IO_DRV_N(x) _SB_MAKEVALUE(x, S_IO_DRV_N)
297#define G_IO_DRV_N(x) _SB_GETVALUE(x, S_IO_DRV_N, M_IO_DRV_N)
298
299#define S_IO_DRV_P 6
300#define M_IO_DRV_P _SB_MAKEMASK(2, S_IO_DRV_P)
301#define V_IO_DRV_P(x) _SB_MAKEVALUE(x, S_IO_DRV_P)
302#define G_IO_DRV_P(x) _SB_GETVALUE(x, S_IO_DRV_P, M_IO_DRV_P)
303
304#define S_IO_DRV_Q 10
305#define M_IO_DRV_Q _SB_MAKEMASK(2, S_IO_DRV_Q)
306#define V_IO_DRV_Q(x) _SB_MAKEVALUE(x, S_IO_DRV_Q)
307#define G_IO_DRV_Q(x) _SB_GETVALUE(x, S_IO_DRV_Q, M_IO_DRV_Q)
308
309#define S_IO_DRV_R 14
310#define M_IO_DRV_R _SB_MAKEMASK(2, S_IO_DRV_R)
311#define V_IO_DRV_R(x) _SB_MAKEVALUE(x, S_IO_DRV_R)
312#define G_IO_DRV_R(x) _SB_GETVALUE(x, S_IO_DRV_R, M_IO_DRV_R)
313
314
315/*
316 * PCMCIA configuration register (Table 12-6)
317 */
318
319#define M_PCMCIA_CFG_ATTRMEM _SB_MAKEMASK1(0)
320#define M_PCMCIA_CFG_3VEN _SB_MAKEMASK1(1)
321#define M_PCMCIA_CFG_5VEN _SB_MAKEMASK1(2)
322#define M_PCMCIA_CFG_VPPEN _SB_MAKEMASK1(3)
323#define M_PCMCIA_CFG_RESET _SB_MAKEMASK1(4)
324#define M_PCMCIA_CFG_APWRONEN _SB_MAKEMASK1(5)
325#define M_PCMCIA_CFG_CDMASK _SB_MAKEMASK1(6)
326#define M_PCMCIA_CFG_WPMASK _SB_MAKEMASK1(7)
327#define M_PCMCIA_CFG_RDYMASK _SB_MAKEMASK1(8)
328#define M_PCMCIA_CFG_PWRCTL _SB_MAKEMASK1(9)
329
330#if SIBYTE_HDR_FEATURE_CHIP(1480)
331#define S_PCMCIA_MODE 16
332#define M_PCMCIA_MODE _SB_MAKEMASK(3, S_PCMCIA_MODE)
333#define V_PCMCIA_MODE(x) _SB_MAKEVALUE(x, S_PCMCIA_MODE)
334#define G_PCMCIA_MODE(x) _SB_GETVALUE(x, S_PCMCIA_MODE, M_PCMCIA_MODE)
335
336#define K_PCMCIA_MODE_PCMA_NOB 0 /* standard PCMCIA "A", no "B" */
337#define K_PCMCIA_MODE_IDEA_NOB 1 /* IDE "A", no "B" */
338#define K_PCMCIA_MODE_PCMIOA_NOB 2 /* PCMCIA with I/O "A", no "B" */
339#define K_PCMCIA_MODE_PCMA_PCMB 4 /* standard PCMCIA "A", standard PCMCIA "B" */
340#define K_PCMCIA_MODE_IDEA_PCMB 5 /* IDE "A", standard PCMCIA "B" */
341#define K_PCMCIA_MODE_PCMA_IDEB 6 /* standard PCMCIA "A", IDE "B" */
342#define K_PCMCIA_MODE_IDEA_IDEB 7 /* IDE "A", IDE "B" */
343#endif
344
345
346/*
347 * PCMCIA status register (Table 12-7)
348 */
349
350#define M_PCMCIA_STATUS_CD1 _SB_MAKEMASK1(0)
351#define M_PCMCIA_STATUS_CD2 _SB_MAKEMASK1(1)
352#define M_PCMCIA_STATUS_VS1 _SB_MAKEMASK1(2)
353#define M_PCMCIA_STATUS_VS2 _SB_MAKEMASK1(3)
354#define M_PCMCIA_STATUS_WP _SB_MAKEMASK1(4)
355#define M_PCMCIA_STATUS_RDY _SB_MAKEMASK1(5)
356#define M_PCMCIA_STATUS_3VEN _SB_MAKEMASK1(6)
357#define M_PCMCIA_STATUS_5VEN _SB_MAKEMASK1(7)
358#define M_PCMCIA_STATUS_CDCHG _SB_MAKEMASK1(8)
359#define M_PCMCIA_STATUS_WPCHG _SB_MAKEMASK1(9)
360#define M_PCMCIA_STATUS_RDYCHG _SB_MAKEMASK1(10)
361
362/*
363 * GPIO Interrupt Type Register (table 13-3)
364 */
365
366#define K_GPIO_INTR_DISABLE 0
367#define K_GPIO_INTR_EDGE 1
368#define K_GPIO_INTR_LEVEL 2
369#define K_GPIO_INTR_SPLIT 3
370
371#define S_GPIO_INTR_TYPEX(n) (((n)/2)*2)
372#define M_GPIO_INTR_TYPEX(n) _SB_MAKEMASK(2, S_GPIO_INTR_TYPEX(n))
373#define V_GPIO_INTR_TYPEX(n, x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPEX(n))
374#define G_GPIO_INTR_TYPEX(n, x) _SB_GETVALUE(x, S_GPIO_INTR_TYPEX(n), M_GPIO_INTR_TYPEX(n))
375
376#define S_GPIO_INTR_TYPE0 0
377#define M_GPIO_INTR_TYPE0 _SB_MAKEMASK(2, S_GPIO_INTR_TYPE0)
378#define V_GPIO_INTR_TYPE0(x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPE0)
379#define G_GPIO_INTR_TYPE0(x) _SB_GETVALUE(x, S_GPIO_INTR_TYPE0, M_GPIO_INTR_TYPE0)
380
381#define S_GPIO_INTR_TYPE2 2
382#define M_GPIO_INTR_TYPE2 _SB_MAKEMASK(2, S_GPIO_INTR_TYPE2)
383#define V_GPIO_INTR_TYPE2(x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPE2)
384#define G_GPIO_INTR_TYPE2(x) _SB_GETVALUE(x, S_GPIO_INTR_TYPE2, M_GPIO_INTR_TYPE2)
385
386#define S_GPIO_INTR_TYPE4 4
387#define M_GPIO_INTR_TYPE4 _SB_MAKEMASK(2, S_GPIO_INTR_TYPE4)
388#define V_GPIO_INTR_TYPE4(x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPE4)
389#define G_GPIO_INTR_TYPE4(x) _SB_GETVALUE(x, S_GPIO_INTR_TYPE4, M_GPIO_INTR_TYPE4)
390
391#define S_GPIO_INTR_TYPE6 6
392#define M_GPIO_INTR_TYPE6 _SB_MAKEMASK(2, S_GPIO_INTR_TYPE6)
393#define V_GPIO_INTR_TYPE6(x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPE6)
394#define G_GPIO_INTR_TYPE6(x) _SB_GETVALUE(x, S_GPIO_INTR_TYPE6, M_GPIO_INTR_TYPE6)
395
396#define S_GPIO_INTR_TYPE8 8
397#define M_GPIO_INTR_TYPE8 _SB_MAKEMASK(2, S_GPIO_INTR_TYPE8)
398#define V_GPIO_INTR_TYPE8(x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPE8)
399#define G_GPIO_INTR_TYPE8(x) _SB_GETVALUE(x, S_GPIO_INTR_TYPE8, M_GPIO_INTR_TYPE8)
400
401#define S_GPIO_INTR_TYPE10 10
402#define M_GPIO_INTR_TYPE10 _SB_MAKEMASK(2, S_GPIO_INTR_TYPE10)
403#define V_GPIO_INTR_TYPE10(x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPE10)
404#define G_GPIO_INTR_TYPE10(x) _SB_GETVALUE(x, S_GPIO_INTR_TYPE10, M_GPIO_INTR_TYPE10)
405
406#define S_GPIO_INTR_TYPE12 12
407#define M_GPIO_INTR_TYPE12 _SB_MAKEMASK(2, S_GPIO_INTR_TYPE12)
408#define V_GPIO_INTR_TYPE12(x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPE12)
409#define G_GPIO_INTR_TYPE12(x) _SB_GETVALUE(x, S_GPIO_INTR_TYPE12, M_GPIO_INTR_TYPE12)
410
411#define S_GPIO_INTR_TYPE14 14
412#define M_GPIO_INTR_TYPE14 _SB_MAKEMASK(2, S_GPIO_INTR_TYPE14)
413#define V_GPIO_INTR_TYPE14(x) _SB_MAKEVALUE(x, S_GPIO_INTR_TYPE14)
414#define G_GPIO_INTR_TYPE14(x) _SB_GETVALUE(x, S_GPIO_INTR_TYPE14, M_GPIO_INTR_TYPE14)
415
416#if SIBYTE_HDR_FEATURE_CHIP(1480)
417
418/*
419 * GPIO Interrupt Additional Type Register
420 */
421
422#define K_GPIO_INTR_BOTHEDGE 0
423#define K_GPIO_INTR_RISEEDGE 1
424#define K_GPIO_INTR_UNPRED1 2
425#define K_GPIO_INTR_UNPRED2 3
426
427#define S_GPIO_INTR_ATYPEX(n) (((n)/2)*2)
428#define M_GPIO_INTR_ATYPEX(n) _SB_MAKEMASK(2, S_GPIO_INTR_ATYPEX(n))
429#define V_GPIO_INTR_ATYPEX(n, x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPEX(n))
430#define G_GPIO_INTR_ATYPEX(n, x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPEX(n), M_GPIO_INTR_ATYPEX(n))
431
432#define S_GPIO_INTR_ATYPE0 0
433#define M_GPIO_INTR_ATYPE0 _SB_MAKEMASK(2, S_GPIO_INTR_ATYPE0)
434#define V_GPIO_INTR_ATYPE0(x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPE0)
435#define G_GPIO_INTR_ATYPE0(x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPE0, M_GPIO_INTR_ATYPE0)
436
437#define S_GPIO_INTR_ATYPE2 2
438#define M_GPIO_INTR_ATYPE2 _SB_MAKEMASK(2, S_GPIO_INTR_ATYPE2)
439#define V_GPIO_INTR_ATYPE2(x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPE2)
440#define G_GPIO_INTR_ATYPE2(x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPE2, M_GPIO_INTR_ATYPE2)
441
442#define S_GPIO_INTR_ATYPE4 4
443#define M_GPIO_INTR_ATYPE4 _SB_MAKEMASK(2, S_GPIO_INTR_ATYPE4)
444#define V_GPIO_INTR_ATYPE4(x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPE4)
445#define G_GPIO_INTR_ATYPE4(x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPE4, M_GPIO_INTR_ATYPE4)
446
447#define S_GPIO_INTR_ATYPE6 6
448#define M_GPIO_INTR_ATYPE6 _SB_MAKEMASK(2, S_GPIO_INTR_ATYPE6)
449#define V_GPIO_INTR_ATYPE6(x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPE6)
450#define G_GPIO_INTR_ATYPE6(x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPE6, M_GPIO_INTR_ATYPE6)
451
452#define S_GPIO_INTR_ATYPE8 8
453#define M_GPIO_INTR_ATYPE8 _SB_MAKEMASK(2, S_GPIO_INTR_ATYPE8)
454#define V_GPIO_INTR_ATYPE8(x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPE8)
455#define G_GPIO_INTR_ATYPE8(x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPE8, M_GPIO_INTR_ATYPE8)
456
457#define S_GPIO_INTR_ATYPE10 10
458#define M_GPIO_INTR_ATYPE10 _SB_MAKEMASK(2, S_GPIO_INTR_ATYPE10)
459#define V_GPIO_INTR_ATYPE10(x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPE10)
460#define G_GPIO_INTR_ATYPE10(x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPE10, M_GPIO_INTR_ATYPE10)
461
462#define S_GPIO_INTR_ATYPE12 12
463#define M_GPIO_INTR_ATYPE12 _SB_MAKEMASK(2, S_GPIO_INTR_ATYPE12)
464#define V_GPIO_INTR_ATYPE12(x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPE12)
465#define G_GPIO_INTR_ATYPE12(x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPE12, M_GPIO_INTR_ATYPE12)
466
467#define S_GPIO_INTR_ATYPE14 14
468#define M_GPIO_INTR_ATYPE14 _SB_MAKEMASK(2, S_GPIO_INTR_ATYPE14)
469#define V_GPIO_INTR_ATYPE14(x) _SB_MAKEVALUE(x, S_GPIO_INTR_ATYPE14)
470#define G_GPIO_INTR_ATYPE14(x) _SB_GETVALUE(x, S_GPIO_INTR_ATYPE14, M_GPIO_INTR_ATYPE14)
471#endif
472
473
474#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_int.h b/arch/mips/include/asm/sibyte/sb1250_int.h
new file mode 100644
index 000000000000..f2850b4bcfd4
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_int.h
@@ -0,0 +1,248 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * Interrupt Mapper definitions File: sb1250_int.h
5 *
6 * This module contains constants for manipulating the SB1250's
7 * interrupt mapper and definitions for the interrupt sources.
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000, 2001, 2002, 2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _SB1250_INT_H
34#define _SB1250_INT_H
35
36#include "sb1250_defs.h"
37
38/* *********************************************************************
39 * Interrupt Mapper Constants
40 ********************************************************************* */
41
42/*
43 * Interrupt sources (Table 4-8, UM 0.2)
44 *
45 * First, the interrupt numbers.
46 */
47
48#define K_INT_SOURCES 64
49
50#define K_INT_WATCHDOG_TIMER_0 0
51#define K_INT_WATCHDOG_TIMER_1 1
52#define K_INT_TIMER_0 2
53#define K_INT_TIMER_1 3
54#define K_INT_TIMER_2 4
55#define K_INT_TIMER_3 5
56#define K_INT_SMB_0 6
57#define K_INT_SMB_1 7
58#define K_INT_UART_0 8
59#define K_INT_UART_1 9
60#define K_INT_SER_0 10
61#define K_INT_SER_1 11
62#define K_INT_PCMCIA 12
63#define K_INT_ADDR_TRAP 13
64#define K_INT_PERF_CNT 14
65#define K_INT_TRACE_FREEZE 15
66#define K_INT_BAD_ECC 16
67#define K_INT_COR_ECC 17
68#define K_INT_IO_BUS 18
69#define K_INT_MAC_0 19
70#define K_INT_MAC_1 20
71#define K_INT_MAC_2 21
72#define K_INT_DM_CH_0 22
73#define K_INT_DM_CH_1 23
74#define K_INT_DM_CH_2 24
75#define K_INT_DM_CH_3 25
76#define K_INT_MBOX_0 26
77#define K_INT_MBOX_1 27
78#define K_INT_MBOX_2 28
79#define K_INT_MBOX_3 29
80#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
81#define K_INT_CYCLE_CP0_INT 30
82#define K_INT_CYCLE_CP1_INT 31
83#endif /* 1250 PASS2 || 112x PASS1 */
84#define K_INT_GPIO_0 32
85#define K_INT_GPIO_1 33
86#define K_INT_GPIO_2 34
87#define K_INT_GPIO_3 35
88#define K_INT_GPIO_4 36
89#define K_INT_GPIO_5 37
90#define K_INT_GPIO_6 38
91#define K_INT_GPIO_7 39
92#define K_INT_GPIO_8 40
93#define K_INT_GPIO_9 41
94#define K_INT_GPIO_10 42
95#define K_INT_GPIO_11 43
96#define K_INT_GPIO_12 44
97#define K_INT_GPIO_13 45
98#define K_INT_GPIO_14 46
99#define K_INT_GPIO_15 47
100#define K_INT_LDT_FATAL 48
101#define K_INT_LDT_NONFATAL 49
102#define K_INT_LDT_SMI 50
103#define K_INT_LDT_NMI 51
104#define K_INT_LDT_INIT 52
105#define K_INT_LDT_STARTUP 53
106#define K_INT_LDT_EXT 54
107#define K_INT_PCI_ERROR 55
108#define K_INT_PCI_INTA 56
109#define K_INT_PCI_INTB 57
110#define K_INT_PCI_INTC 58
111#define K_INT_PCI_INTD 59
112#define K_INT_SPARE_2 60
113#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
114#define K_INT_MAC_0_CH1 61
115#define K_INT_MAC_1_CH1 62
116#define K_INT_MAC_2_CH1 63
117#endif /* 1250 PASS2 || 112x PASS1 */
118
119/*
120 * Mask values for each interrupt
121 */
122
123#define M_INT_WATCHDOG_TIMER_0 _SB_MAKEMASK1(K_INT_WATCHDOG_TIMER_0)
124#define M_INT_WATCHDOG_TIMER_1 _SB_MAKEMASK1(K_INT_WATCHDOG_TIMER_1)
125#define M_INT_TIMER_0 _SB_MAKEMASK1(K_INT_TIMER_0)
126#define M_INT_TIMER_1 _SB_MAKEMASK1(K_INT_TIMER_1)
127#define M_INT_TIMER_2 _SB_MAKEMASK1(K_INT_TIMER_2)
128#define M_INT_TIMER_3 _SB_MAKEMASK1(K_INT_TIMER_3)
129#define M_INT_SMB_0 _SB_MAKEMASK1(K_INT_SMB_0)
130#define M_INT_SMB_1 _SB_MAKEMASK1(K_INT_SMB_1)
131#define M_INT_UART_0 _SB_MAKEMASK1(K_INT_UART_0)
132#define M_INT_UART_1 _SB_MAKEMASK1(K_INT_UART_1)
133#define M_INT_SER_0 _SB_MAKEMASK1(K_INT_SER_0)
134#define M_INT_SER_1 _SB_MAKEMASK1(K_INT_SER_1)
135#define M_INT_PCMCIA _SB_MAKEMASK1(K_INT_PCMCIA)
136#define M_INT_ADDR_TRAP _SB_MAKEMASK1(K_INT_ADDR_TRAP)
137#define M_INT_PERF_CNT _SB_MAKEMASK1(K_INT_PERF_CNT)
138#define M_INT_TRACE_FREEZE _SB_MAKEMASK1(K_INT_TRACE_FREEZE)
139#define M_INT_BAD_ECC _SB_MAKEMASK1(K_INT_BAD_ECC)
140#define M_INT_COR_ECC _SB_MAKEMASK1(K_INT_COR_ECC)
141#define M_INT_IO_BUS _SB_MAKEMASK1(K_INT_IO_BUS)
142#define M_INT_MAC_0 _SB_MAKEMASK1(K_INT_MAC_0)
143#define M_INT_MAC_1 _SB_MAKEMASK1(K_INT_MAC_1)
144#define M_INT_MAC_2 _SB_MAKEMASK1(K_INT_MAC_2)
145#define M_INT_DM_CH_0 _SB_MAKEMASK1(K_INT_DM_CH_0)
146#define M_INT_DM_CH_1 _SB_MAKEMASK1(K_INT_DM_CH_1)
147#define M_INT_DM_CH_2 _SB_MAKEMASK1(K_INT_DM_CH_2)
148#define M_INT_DM_CH_3 _SB_MAKEMASK1(K_INT_DM_CH_3)
149#define M_INT_MBOX_0 _SB_MAKEMASK1(K_INT_MBOX_0)
150#define M_INT_MBOX_1 _SB_MAKEMASK1(K_INT_MBOX_1)
151#define M_INT_MBOX_2 _SB_MAKEMASK1(K_INT_MBOX_2)
152#define M_INT_MBOX_3 _SB_MAKEMASK1(K_INT_MBOX_3)
153#define M_INT_MBOX_ALL _SB_MAKEMASK(4, K_INT_MBOX_0)
154#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
155#define M_INT_CYCLE_CP0_INT _SB_MAKEMASK1(K_INT_CYCLE_CP0_INT)
156#define M_INT_CYCLE_CP1_INT _SB_MAKEMASK1(K_INT_CYCLE_CP1_INT)
157#endif /* 1250 PASS2 || 112x PASS1 */
158#define M_INT_GPIO_0 _SB_MAKEMASK1(K_INT_GPIO_0)
159#define M_INT_GPIO_1 _SB_MAKEMASK1(K_INT_GPIO_1)
160#define M_INT_GPIO_2 _SB_MAKEMASK1(K_INT_GPIO_2)
161#define M_INT_GPIO_3 _SB_MAKEMASK1(K_INT_GPIO_3)
162#define M_INT_GPIO_4 _SB_MAKEMASK1(K_INT_GPIO_4)
163#define M_INT_GPIO_5 _SB_MAKEMASK1(K_INT_GPIO_5)
164#define M_INT_GPIO_6 _SB_MAKEMASK1(K_INT_GPIO_6)
165#define M_INT_GPIO_7 _SB_MAKEMASK1(K_INT_GPIO_7)
166#define M_INT_GPIO_8 _SB_MAKEMASK1(K_INT_GPIO_8)
167#define M_INT_GPIO_9 _SB_MAKEMASK1(K_INT_GPIO_9)
168#define M_INT_GPIO_10 _SB_MAKEMASK1(K_INT_GPIO_10)
169#define M_INT_GPIO_11 _SB_MAKEMASK1(K_INT_GPIO_11)
170#define M_INT_GPIO_12 _SB_MAKEMASK1(K_INT_GPIO_12)
171#define M_INT_GPIO_13 _SB_MAKEMASK1(K_INT_GPIO_13)
172#define M_INT_GPIO_14 _SB_MAKEMASK1(K_INT_GPIO_14)
173#define M_INT_GPIO_15 _SB_MAKEMASK1(K_INT_GPIO_15)
174#define M_INT_LDT_FATAL _SB_MAKEMASK1(K_INT_LDT_FATAL)
175#define M_INT_LDT_NONFATAL _SB_MAKEMASK1(K_INT_LDT_NONFATAL)
176#define M_INT_LDT_SMI _SB_MAKEMASK1(K_INT_LDT_SMI)
177#define M_INT_LDT_NMI _SB_MAKEMASK1(K_INT_LDT_NMI)
178#define M_INT_LDT_INIT _SB_MAKEMASK1(K_INT_LDT_INIT)
179#define M_INT_LDT_STARTUP _SB_MAKEMASK1(K_INT_LDT_STARTUP)
180#define M_INT_LDT_EXT _SB_MAKEMASK1(K_INT_LDT_EXT)
181#define M_INT_PCI_ERROR _SB_MAKEMASK1(K_INT_PCI_ERROR)
182#define M_INT_PCI_INTA _SB_MAKEMASK1(K_INT_PCI_INTA)
183#define M_INT_PCI_INTB _SB_MAKEMASK1(K_INT_PCI_INTB)
184#define M_INT_PCI_INTC _SB_MAKEMASK1(K_INT_PCI_INTC)
185#define M_INT_PCI_INTD _SB_MAKEMASK1(K_INT_PCI_INTD)
186#define M_INT_SPARE_2 _SB_MAKEMASK1(K_INT_SPARE_2)
187#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
188#define M_INT_MAC_0_CH1 _SB_MAKEMASK1(K_INT_MAC_0_CH1)
189#define M_INT_MAC_1_CH1 _SB_MAKEMASK1(K_INT_MAC_1_CH1)
190#define M_INT_MAC_2_CH1 _SB_MAKEMASK1(K_INT_MAC_2_CH1)
191#endif /* 1250 PASS2 || 112x PASS1 */
192
193/*
194 * Interrupt mappings
195 */
196
197#define K_INT_MAP_I0 0 /* interrupt pins on processor */
198#define K_INT_MAP_I1 1
199#define K_INT_MAP_I2 2
200#define K_INT_MAP_I3 3
201#define K_INT_MAP_I4 4
202#define K_INT_MAP_I5 5
203#define K_INT_MAP_NMI 6 /* nonmaskable */
204#define K_INT_MAP_DINT 7 /* debug interrupt */
205
206/*
207 * LDT Interrupt Set Register (table 4-5)
208 */
209
210#define S_INT_LDT_INTMSG 0
211#define M_INT_LDT_INTMSG _SB_MAKEMASK(3, S_INT_LDT_INTMSG)
212#define V_INT_LDT_INTMSG(x) _SB_MAKEVALUE(x, S_INT_LDT_INTMSG)
213#define G_INT_LDT_INTMSG(x) _SB_GETVALUE(x, S_INT_LDT_INTMSG, M_INT_LDT_INTMSG)
214
215#define K_INT_LDT_INTMSG_FIXED 0
216#define K_INT_LDT_INTMSG_ARBITRATED 1
217#define K_INT_LDT_INTMSG_SMI 2
218#define K_INT_LDT_INTMSG_NMI 3
219#define K_INT_LDT_INTMSG_INIT 4
220#define K_INT_LDT_INTMSG_STARTUP 5
221#define K_INT_LDT_INTMSG_EXTINT 6
222#define K_INT_LDT_INTMSG_RESERVED 7
223
224#define M_INT_LDT_EDGETRIGGER 0
225#define M_INT_LDT_LEVELTRIGGER _SB_MAKEMASK1(3)
226
227#define M_INT_LDT_PHYSICALDEST 0
228#define M_INT_LDT_LOGICALDEST _SB_MAKEMASK1(4)
229
230#define S_INT_LDT_INTDEST 5
231#define M_INT_LDT_INTDEST _SB_MAKEMASK(10, S_INT_LDT_INTDEST)
232#define V_INT_LDT_INTDEST(x) _SB_MAKEVALUE(x, S_INT_LDT_INTDEST)
233#define G_INT_LDT_INTDEST(x) _SB_GETVALUE(x, S_INT_LDT_INTDEST, M_INT_LDT_INTDEST)
234
235#define S_INT_LDT_VECTOR 13
236#define M_INT_LDT_VECTOR _SB_MAKEMASK(8, S_INT_LDT_VECTOR)
237#define V_INT_LDT_VECTOR(x) _SB_MAKEVALUE(x, S_INT_LDT_VECTOR)
238#define G_INT_LDT_VECTOR(x) _SB_GETVALUE(x, S_INT_LDT_VECTOR, M_INT_LDT_VECTOR)
239
240/*
241 * Vector format (Table 4-6)
242 */
243
244#define M_LDTVECT_RAISEINT 0x00
245#define M_LDTVECT_RAISEMBOX 0x40
246
247
248#endif /* 1250/112x */
diff --git a/arch/mips/include/asm/sibyte/sb1250_l2c.h b/arch/mips/include/asm/sibyte/sb1250_l2c.h
new file mode 100644
index 000000000000..6554dcf05cfe
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_l2c.h
@@ -0,0 +1,131 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * L2 Cache constants and macros File: sb1250_l2c.h
5 *
6 * This module contains constants useful for manipulating the
7 * level 2 cache.
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _SB1250_L2C_H
34#define _SB1250_L2C_H
35
36#include "sb1250_defs.h"
37
38/*
39 * Level 2 Cache Tag register (Table 5-3)
40 */
41
42#define S_L2C_TAG_MBZ 0
43#define M_L2C_TAG_MBZ _SB_MAKEMASK(5, S_L2C_TAG_MBZ)
44
45#define S_L2C_TAG_INDEX 5
46#define M_L2C_TAG_INDEX _SB_MAKEMASK(12, S_L2C_TAG_INDEX)
47#define V_L2C_TAG_INDEX(x) _SB_MAKEVALUE(x, S_L2C_TAG_INDEX)
48#define G_L2C_TAG_INDEX(x) _SB_GETVALUE(x, S_L2C_TAG_INDEX, M_L2C_TAG_INDEX)
49
50#define S_L2C_TAG_TAG 17
51#define M_L2C_TAG_TAG _SB_MAKEMASK(23, S_L2C_TAG_TAG)
52#define V_L2C_TAG_TAG(x) _SB_MAKEVALUE(x, S_L2C_TAG_TAG)
53#define G_L2C_TAG_TAG(x) _SB_GETVALUE(x, S_L2C_TAG_TAG, M_L2C_TAG_TAG)
54
55#define S_L2C_TAG_ECC 40
56#define M_L2C_TAG_ECC _SB_MAKEMASK(6, S_L2C_TAG_ECC)
57#define V_L2C_TAG_ECC(x) _SB_MAKEVALUE(x, S_L2C_TAG_ECC)
58#define G_L2C_TAG_ECC(x) _SB_GETVALUE(x, S_L2C_TAG_ECC, M_L2C_TAG_ECC)
59
60#define S_L2C_TAG_WAY 46
61#define M_L2C_TAG_WAY _SB_MAKEMASK(2, S_L2C_TAG_WAY)
62#define V_L2C_TAG_WAY(x) _SB_MAKEVALUE(x, S_L2C_TAG_WAY)
63#define G_L2C_TAG_WAY(x) _SB_GETVALUE(x, S_L2C_TAG_WAY, M_L2C_TAG_WAY)
64
65#define M_L2C_TAG_DIRTY _SB_MAKEMASK1(48)
66#define M_L2C_TAG_VALID _SB_MAKEMASK1(49)
67
68/*
69 * Format of level 2 cache management address (table 5-2)
70 */
71
72#define S_L2C_MGMT_INDEX 5
73#define M_L2C_MGMT_INDEX _SB_MAKEMASK(12, S_L2C_MGMT_INDEX)
74#define V_L2C_MGMT_INDEX(x) _SB_MAKEVALUE(x, S_L2C_MGMT_INDEX)
75#define G_L2C_MGMT_INDEX(x) _SB_GETVALUE(x, S_L2C_MGMT_INDEX, M_L2C_MGMT_INDEX)
76
77#define S_L2C_MGMT_QUADRANT 15
78#define M_L2C_MGMT_QUADRANT _SB_MAKEMASK(2, S_L2C_MGMT_QUADRANT)
79#define V_L2C_MGMT_QUADRANT(x) _SB_MAKEVALUE(x, S_L2C_MGMT_QUADRANT)
80#define G_L2C_MGMT_QUADRANT(x) _SB_GETVALUE(x, S_L2C_MGMT_QUADRANT, M_L2C_MGMT_QUADRANT)
81
82#define S_L2C_MGMT_HALF 16
83#define M_L2C_MGMT_HALF _SB_MAKEMASK(1, S_L2C_MGMT_HALF)
84
85#define S_L2C_MGMT_WAY 17
86#define M_L2C_MGMT_WAY _SB_MAKEMASK(2, S_L2C_MGMT_WAY)
87#define V_L2C_MGMT_WAY(x) _SB_MAKEVALUE(x, S_L2C_MGMT_WAY)
88#define G_L2C_MGMT_WAY(x) _SB_GETVALUE(x, S_L2C_MGMT_WAY, M_L2C_MGMT_WAY)
89
90#define S_L2C_MGMT_ECC_DIAG 21
91#define M_L2C_MGMT_ECC_DIAG _SB_MAKEMASK(2, S_L2C_MGMT_ECC_DIAG)
92#define V_L2C_MGMT_ECC_DIAG(x) _SB_MAKEVALUE(x, S_L2C_MGMT_ECC_DIAG)
93#define G_L2C_MGMT_ECC_DIAG(x) _SB_GETVALUE(x, S_L2C_MGMT_ECC_DIAG, M_L2C_MGMT_ECC_DIAG)
94
95#define S_L2C_MGMT_TAG 23
96#define M_L2C_MGMT_TAG _SB_MAKEMASK(4, S_L2C_MGMT_TAG)
97#define V_L2C_MGMT_TAG(x) _SB_MAKEVALUE(x, S_L2C_MGMT_TAG)
98#define G_L2C_MGMT_TAG(x) _SB_GETVALUE(x, S_L2C_MGMT_TAG, M_L2C_MGMT_TAG)
99
100#define M_L2C_MGMT_DIRTY _SB_MAKEMASK1(19)
101#define M_L2C_MGMT_VALID _SB_MAKEMASK1(20)
102
103#define A_L2C_MGMT_TAG_BASE 0x00D0000000
104
105#define L2C_ENTRIES_PER_WAY 4096
106#define L2C_NUM_WAYS 4
107
108
109#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1)
110/*
111 * L2 Read Misc. register (A_L2_READ_MISC)
112 */
113#define S_L2C_MISC_NO_WAY 10
114#define M_L2C_MISC_NO_WAY _SB_MAKEMASK(4, S_L2C_MISC_NO_WAY)
115#define V_L2C_MISC_NO_WAY(x) _SB_MAKEVALUE(x, S_L2C_MISC_NO_WAY)
116#define G_L2C_MISC_NO_WAY(x) _SB_GETVALUE(x, S_L2C_MISC_NO_WAY, M_L2C_MISC_NO_WAY)
117
118#define M_L2C_MISC_ECC_CLEANUP_DIS _SB_MAKEMASK1(9)
119#define M_L2C_MISC_MC_PRIO_LOW _SB_MAKEMASK1(8)
120#define M_L2C_MISC_SOFT_DISABLE_T _SB_MAKEMASK1(7)
121#define M_L2C_MISC_SOFT_DISABLE_B _SB_MAKEMASK1(6)
122#define M_L2C_MISC_SOFT_DISABLE_R _SB_MAKEMASK1(5)
123#define M_L2C_MISC_SOFT_DISABLE_L _SB_MAKEMASK1(4)
124#define M_L2C_MISC_SCACHE_DISABLE_T _SB_MAKEMASK1(3)
125#define M_L2C_MISC_SCACHE_DISABLE_B _SB_MAKEMASK1(2)
126#define M_L2C_MISC_SCACHE_DISABLE_R _SB_MAKEMASK1(1)
127#define M_L2C_MISC_SCACHE_DISABLE_L _SB_MAKEMASK1(0)
128#endif /* 1250 PASS3 || 112x PASS1 */
129
130
131#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_ldt.h b/arch/mips/include/asm/sibyte/sb1250_ldt.h
new file mode 100644
index 000000000000..081e8b1c4ad0
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_ldt.h
@@ -0,0 +1,423 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * LDT constants File: sb1250_ldt.h
5 *
6 * This module contains constants and macros to describe
7 * the LDT interface on the SB1250.
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000, 2001, 2002, 2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _SB1250_LDT_H
34#define _SB1250_LDT_H
35
36#include "sb1250_defs.h"
37
38#define K_LDT_VENDOR_SIBYTE 0x166D
39#define K_LDT_DEVICE_SB1250 0x0002
40
41/*
42 * LDT Interface Type 1 (bridge) configuration header
43 */
44
45#define R_LDT_TYPE1_DEVICEID 0x0000
46#define R_LDT_TYPE1_CMDSTATUS 0x0004
47#define R_LDT_TYPE1_CLASSREV 0x0008
48#define R_LDT_TYPE1_DEVHDR 0x000C
49#define R_LDT_TYPE1_BAR0 0x0010 /* not used */
50#define R_LDT_TYPE1_BAR1 0x0014 /* not used */
51
52#define R_LDT_TYPE1_BUSID 0x0018 /* bus ID register */
53#define R_LDT_TYPE1_SECSTATUS 0x001C /* secondary status / I/O base/limit */
54#define R_LDT_TYPE1_MEMLIMIT 0x0020
55#define R_LDT_TYPE1_PREFETCH 0x0024
56#define R_LDT_TYPE1_PREF_BASE 0x0028
57#define R_LDT_TYPE1_PREF_LIMIT 0x002C
58#define R_LDT_TYPE1_IOLIMIT 0x0030
59#define R_LDT_TYPE1_CAPPTR 0x0034
60#define R_LDT_TYPE1_ROMADDR 0x0038
61#define R_LDT_TYPE1_BRCTL 0x003C
62#define R_LDT_TYPE1_CMD 0x0040
63#define R_LDT_TYPE1_LINKCTRL 0x0044
64#define R_LDT_TYPE1_LINKFREQ 0x0048
65#define R_LDT_TYPE1_RESERVED1 0x004C
66#define R_LDT_TYPE1_SRICMD 0x0050
67#define R_LDT_TYPE1_SRITXNUM 0x0054
68#define R_LDT_TYPE1_SRIRXNUM 0x0058
69#define R_LDT_TYPE1_ERRSTATUS 0x0068
70#define R_LDT_TYPE1_SRICTRL 0x006C
71#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
72#define R_LDT_TYPE1_ADDSTATUS 0x0070
73#endif /* 1250 PASS2 || 112x PASS1 */
74#define R_LDT_TYPE1_TXBUFCNT 0x00C8
75#define R_LDT_TYPE1_EXPCRC 0x00DC
76#define R_LDT_TYPE1_RXCRC 0x00F0
77
78
79/*
80 * LDT Device ID register
81 */
82
83#define S_LDT_DEVICEID_VENDOR 0
84#define M_LDT_DEVICEID_VENDOR _SB_MAKEMASK_32(16, S_LDT_DEVICEID_VENDOR)
85#define V_LDT_DEVICEID_VENDOR(x) _SB_MAKEVALUE_32(x, S_LDT_DEVICEID_VENDOR)
86#define G_LDT_DEVICEID_VENDOR(x) _SB_GETVALUE_32(x, S_LDT_DEVICEID_VENDOR, M_LDT_DEVICEID_VENDOR)
87
88#define S_LDT_DEVICEID_DEVICEID 16
89#define M_LDT_DEVICEID_DEVICEID _SB_MAKEMASK_32(16, S_LDT_DEVICEID_DEVICEID)
90#define V_LDT_DEVICEID_DEVICEID(x) _SB_MAKEVALUE_32(x, S_LDT_DEVICEID_DEVICEID)
91#define G_LDT_DEVICEID_DEVICEID(x) _SB_GETVALUE_32(x, S_LDT_DEVICEID_DEVICEID, M_LDT_DEVICEID_DEVICEID)
92
93
94/*
95 * LDT Command Register (Table 8-13)
96 */
97
98#define M_LDT_CMD_IOSPACE_EN _SB_MAKEMASK1_32(0)
99#define M_LDT_CMD_MEMSPACE_EN _SB_MAKEMASK1_32(1)
100#define M_LDT_CMD_MASTER_EN _SB_MAKEMASK1_32(2)
101#define M_LDT_CMD_SPECCYC_EN _SB_MAKEMASK1_32(3)
102#define M_LDT_CMD_MEMWRINV_EN _SB_MAKEMASK1_32(4)
103#define M_LDT_CMD_VGAPALSNP_EN _SB_MAKEMASK1_32(5)
104#define M_LDT_CMD_PARERRRESP _SB_MAKEMASK1_32(6)
105#define M_LDT_CMD_WAITCYCCTRL _SB_MAKEMASK1_32(7)
106#define M_LDT_CMD_SERR_EN _SB_MAKEMASK1_32(8)
107#define M_LDT_CMD_FASTB2B_EN _SB_MAKEMASK1_32(9)
108
109/*
110 * LDT class and revision registers
111 */
112
113#define S_LDT_CLASSREV_REV 0
114#define M_LDT_CLASSREV_REV _SB_MAKEMASK_32(8, S_LDT_CLASSREV_REV)
115#define V_LDT_CLASSREV_REV(x) _SB_MAKEVALUE_32(x, S_LDT_CLASSREV_REV)
116#define G_LDT_CLASSREV_REV(x) _SB_GETVALUE_32(x, S_LDT_CLASSREV_REV, M_LDT_CLASSREV_REV)
117
118#define S_LDT_CLASSREV_CLASS 8
119#define M_LDT_CLASSREV_CLASS _SB_MAKEMASK_32(24, S_LDT_CLASSREV_CLASS)
120#define V_LDT_CLASSREV_CLASS(x) _SB_MAKEVALUE_32(x, S_LDT_CLASSREV_CLASS)
121#define G_LDT_CLASSREV_CLASS(x) _SB_GETVALUE_32(x, S_LDT_CLASSREV_CLASS, M_LDT_CLASSREV_CLASS)
122
123#define K_LDT_REV 0x01
124#define K_LDT_CLASS 0x060000
125
126/*
127 * Device Header (offset 0x0C)
128 */
129
130#define S_LDT_DEVHDR_CLINESZ 0
131#define M_LDT_DEVHDR_CLINESZ _SB_MAKEMASK_32(8, S_LDT_DEVHDR_CLINESZ)
132#define V_LDT_DEVHDR_CLINESZ(x) _SB_MAKEVALUE_32(x, S_LDT_DEVHDR_CLINESZ)
133#define G_LDT_DEVHDR_CLINESZ(x) _SB_GETVALUE_32(x, S_LDT_DEVHDR_CLINESZ, M_LDT_DEVHDR_CLINESZ)
134
135#define S_LDT_DEVHDR_LATTMR 8
136#define M_LDT_DEVHDR_LATTMR _SB_MAKEMASK_32(8, S_LDT_DEVHDR_LATTMR)
137#define V_LDT_DEVHDR_LATTMR(x) _SB_MAKEVALUE_32(x, S_LDT_DEVHDR_LATTMR)
138#define G_LDT_DEVHDR_LATTMR(x) _SB_GETVALUE_32(x, S_LDT_DEVHDR_LATTMR, M_LDT_DEVHDR_LATTMR)
139
140#define S_LDT_DEVHDR_HDRTYPE 16
141#define M_LDT_DEVHDR_HDRTYPE _SB_MAKEMASK_32(8, S_LDT_DEVHDR_HDRTYPE)
142#define V_LDT_DEVHDR_HDRTYPE(x) _SB_MAKEVALUE_32(x, S_LDT_DEVHDR_HDRTYPE)
143#define G_LDT_DEVHDR_HDRTYPE(x) _SB_GETVALUE_32(x, S_LDT_DEVHDR_HDRTYPE, M_LDT_DEVHDR_HDRTYPE)
144
145#define K_LDT_DEVHDR_HDRTYPE_TYPE1 1
146
147#define S_LDT_DEVHDR_BIST 24
148#define M_LDT_DEVHDR_BIST _SB_MAKEMASK_32(8, S_LDT_DEVHDR_BIST)
149#define V_LDT_DEVHDR_BIST(x) _SB_MAKEVALUE_32(x, S_LDT_DEVHDR_BIST)
150#define G_LDT_DEVHDR_BIST(x) _SB_GETVALUE_32(x, S_LDT_DEVHDR_BIST, M_LDT_DEVHDR_BIST)
151
152
153
154/*
155 * LDT Status Register (Table 8-14). Note that these constants
156 * assume you've read the command and status register
157 * together (32-bit read at offset 0x04)
158 *
159 * These bits also apply to the secondary status
160 * register (Table 8-15), offset 0x1C
161 */
162
163#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
164#define M_LDT_STATUS_VGAEN _SB_MAKEMASK1_32(3)
165#endif /* 1250 PASS2 || 112x PASS1 */
166#define M_LDT_STATUS_CAPLIST _SB_MAKEMASK1_32(20)
167#define M_LDT_STATUS_66MHZCAP _SB_MAKEMASK1_32(21)
168#define M_LDT_STATUS_RESERVED2 _SB_MAKEMASK1_32(22)
169#define M_LDT_STATUS_FASTB2BCAP _SB_MAKEMASK1_32(23)
170#define M_LDT_STATUS_MSTRDPARERR _SB_MAKEMASK1_32(24)
171
172#define S_LDT_STATUS_DEVSELTIMING 25
173#define M_LDT_STATUS_DEVSELTIMING _SB_MAKEMASK_32(2, S_LDT_STATUS_DEVSELTIMING)
174#define V_LDT_STATUS_DEVSELTIMING(x) _SB_MAKEVALUE_32(x, S_LDT_STATUS_DEVSELTIMING)
175#define G_LDT_STATUS_DEVSELTIMING(x) _SB_GETVALUE_32(x, S_LDT_STATUS_DEVSELTIMING, M_LDT_STATUS_DEVSELTIMING)
176
177#define M_LDT_STATUS_SIGDTGTABORT _SB_MAKEMASK1_32(27)
178#define M_LDT_STATUS_RCVDTGTABORT _SB_MAKEMASK1_32(28)
179#define M_LDT_STATUS_RCVDMSTRABORT _SB_MAKEMASK1_32(29)
180#define M_LDT_STATUS_SIGDSERR _SB_MAKEMASK1_32(30)
181#define M_LDT_STATUS_DETPARERR _SB_MAKEMASK1_32(31)
182
183/*
184 * Bridge Control Register (Table 8-16). Note that these
185 * constants assume you've read the register as a 32-bit
186 * read (offset 0x3C)
187 */
188
189#define M_LDT_BRCTL_PARERRRESP_EN _SB_MAKEMASK1_32(16)
190#define M_LDT_BRCTL_SERR_EN _SB_MAKEMASK1_32(17)
191#define M_LDT_BRCTL_ISA_EN _SB_MAKEMASK1_32(18)
192#define M_LDT_BRCTL_VGA_EN _SB_MAKEMASK1_32(19)
193#define M_LDT_BRCTL_MSTRABORTMODE _SB_MAKEMASK1_32(21)
194#define M_LDT_BRCTL_SECBUSRESET _SB_MAKEMASK1_32(22)
195#define M_LDT_BRCTL_FASTB2B_EN _SB_MAKEMASK1_32(23)
196#define M_LDT_BRCTL_PRIDISCARD _SB_MAKEMASK1_32(24)
197#define M_LDT_BRCTL_SECDISCARD _SB_MAKEMASK1_32(25)
198#define M_LDT_BRCTL_DISCARDSTAT _SB_MAKEMASK1_32(26)
199#define M_LDT_BRCTL_DISCARDSERR_EN _SB_MAKEMASK1_32(27)
200
201/*
202 * LDT Command Register (Table 8-17). Note that these constants
203 * assume you've read the command and status register together
204 * 32-bit read at offset 0x40
205 */
206
207#define M_LDT_CMD_WARMRESET _SB_MAKEMASK1_32(16)
208#define M_LDT_CMD_DOUBLEENDED _SB_MAKEMASK1_32(17)
209
210#define S_LDT_CMD_CAPTYPE 29
211#define M_LDT_CMD_CAPTYPE _SB_MAKEMASK_32(3, S_LDT_CMD_CAPTYPE)
212#define V_LDT_CMD_CAPTYPE(x) _SB_MAKEVALUE_32(x, S_LDT_CMD_CAPTYPE)
213#define G_LDT_CMD_CAPTYPE(x) _SB_GETVALUE_32(x, S_LDT_CMD_CAPTYPE, M_LDT_CMD_CAPTYPE)
214
215/*
216 * LDT link control register (Table 8-18), and (Table 8-19)
217 */
218
219#define M_LDT_LINKCTRL_CAPSYNCFLOOD_EN _SB_MAKEMASK1_32(1)
220#define M_LDT_LINKCTRL_CRCSTARTTEST _SB_MAKEMASK1_32(2)
221#define M_LDT_LINKCTRL_CRCFORCEERR _SB_MAKEMASK1_32(3)
222#define M_LDT_LINKCTRL_LINKFAIL _SB_MAKEMASK1_32(4)
223#define M_LDT_LINKCTRL_INITDONE _SB_MAKEMASK1_32(5)
224#define M_LDT_LINKCTRL_EOC _SB_MAKEMASK1_32(6)
225#define M_LDT_LINKCTRL_XMITOFF _SB_MAKEMASK1_32(7)
226
227#define S_LDT_LINKCTRL_CRCERR 8
228#define M_LDT_LINKCTRL_CRCERR _SB_MAKEMASK_32(4, S_LDT_LINKCTRL_CRCERR)
229#define V_LDT_LINKCTRL_CRCERR(x) _SB_MAKEVALUE_32(x, S_LDT_LINKCTRL_CRCERR)
230#define G_LDT_LINKCTRL_CRCERR(x) _SB_GETVALUE_32(x, S_LDT_LINKCTRL_CRCERR, M_LDT_LINKCTRL_CRCERR)
231
232#define S_LDT_LINKCTRL_MAXIN 16
233#define M_LDT_LINKCTRL_MAXIN _SB_MAKEMASK_32(3, S_LDT_LINKCTRL_MAXIN)
234#define V_LDT_LINKCTRL_MAXIN(x) _SB_MAKEVALUE_32(x, S_LDT_LINKCTRL_MAXIN)
235#define G_LDT_LINKCTRL_MAXIN(x) _SB_GETVALUE_32(x, S_LDT_LINKCTRL_MAXIN, M_LDT_LINKCTRL_MAXIN)
236
237#define M_LDT_LINKCTRL_DWFCLN _SB_MAKEMASK1_32(19)
238
239#define S_LDT_LINKCTRL_MAXOUT 20
240#define M_LDT_LINKCTRL_MAXOUT _SB_MAKEMASK_32(3, S_LDT_LINKCTRL_MAXOUT)
241#define V_LDT_LINKCTRL_MAXOUT(x) _SB_MAKEVALUE_32(x, S_LDT_LINKCTRL_MAXOUT)
242#define G_LDT_LINKCTRL_MAXOUT(x) _SB_GETVALUE_32(x, S_LDT_LINKCTRL_MAXOUT, M_LDT_LINKCTRL_MAXOUT)
243
244#define M_LDT_LINKCTRL_DWFCOUT _SB_MAKEMASK1_32(23)
245
246#define S_LDT_LINKCTRL_WIDTHIN 24
247#define M_LDT_LINKCTRL_WIDTHIN _SB_MAKEMASK_32(3, S_LDT_LINKCTRL_WIDTHIN)
248#define V_LDT_LINKCTRL_WIDTHIN(x) _SB_MAKEVALUE_32(x, S_LDT_LINKCTRL_WIDTHIN)
249#define G_LDT_LINKCTRL_WIDTHIN(x) _SB_GETVALUE_32(x, S_LDT_LINKCTRL_WIDTHIN, M_LDT_LINKCTRL_WIDTHIN)
250
251#define M_LDT_LINKCTRL_DWFCLIN_EN _SB_MAKEMASK1_32(27)
252
253#define S_LDT_LINKCTRL_WIDTHOUT 28
254#define M_LDT_LINKCTRL_WIDTHOUT _SB_MAKEMASK_32(3, S_LDT_LINKCTRL_WIDTHOUT)
255#define V_LDT_LINKCTRL_WIDTHOUT(x) _SB_MAKEVALUE_32(x, S_LDT_LINKCTRL_WIDTHOUT)
256#define G_LDT_LINKCTRL_WIDTHOUT(x) _SB_GETVALUE_32(x, S_LDT_LINKCTRL_WIDTHOUT, M_LDT_LINKCTRL_WIDTHOUT)
257
258#define M_LDT_LINKCTRL_DWFCOUT_EN _SB_MAKEMASK1_32(31)
259
260/*
261 * LDT Link frequency register (Table 8-20) offset 0x48
262 */
263
264#define S_LDT_LINKFREQ_FREQ 8
265#define M_LDT_LINKFREQ_FREQ _SB_MAKEMASK_32(4, S_LDT_LINKFREQ_FREQ)
266#define V_LDT_LINKFREQ_FREQ(x) _SB_MAKEVALUE_32(x, S_LDT_LINKFREQ_FREQ)
267#define G_LDT_LINKFREQ_FREQ(x) _SB_GETVALUE_32(x, S_LDT_LINKFREQ_FREQ, M_LDT_LINKFREQ_FREQ)
268
269#define K_LDT_LINKFREQ_200MHZ 0
270#define K_LDT_LINKFREQ_300MHZ 1
271#define K_LDT_LINKFREQ_400MHZ 2
272#define K_LDT_LINKFREQ_500MHZ 3
273#define K_LDT_LINKFREQ_600MHZ 4
274#define K_LDT_LINKFREQ_800MHZ 5
275#define K_LDT_LINKFREQ_1000MHZ 6
276
277/*
278 * LDT SRI Command Register (Table 8-21). Note that these constants
279 * assume you've read the command and status register together
280 * 32-bit read at offset 0x50
281 */
282
283#define M_LDT_SRICMD_SIPREADY _SB_MAKEMASK1_32(16)
284#define M_LDT_SRICMD_SYNCPTRCTL _SB_MAKEMASK1_32(17)
285#define M_LDT_SRICMD_REDUCESYNCZERO _SB_MAKEMASK1_32(18)
286#if SIBYTE_HDR_FEATURE_UP_TO(1250, PASS1)
287#define M_LDT_SRICMD_DISSTARVATIONCNT _SB_MAKEMASK1_32(19) /* PASS1 */
288#endif /* up to 1250 PASS1 */
289#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
290#define M_LDT_SRICMD_DISMULTTXVLD _SB_MAKEMASK1_32(19)
291#define M_LDT_SRICMD_EXPENDIAN _SB_MAKEMASK1_32(26)
292#endif /* 1250 PASS2 || 112x PASS1 */
293
294
295#define S_LDT_SRICMD_RXMARGIN 20
296#define M_LDT_SRICMD_RXMARGIN _SB_MAKEMASK_32(5, S_LDT_SRICMD_RXMARGIN)
297#define V_LDT_SRICMD_RXMARGIN(x) _SB_MAKEVALUE_32(x, S_LDT_SRICMD_RXMARGIN)
298#define G_LDT_SRICMD_RXMARGIN(x) _SB_GETVALUE_32(x, S_LDT_SRICMD_RXMARGIN, M_LDT_SRICMD_RXMARGIN)
299
300#define M_LDT_SRICMD_LDTPLLCOMPAT _SB_MAKEMASK1_32(25)
301
302#define S_LDT_SRICMD_TXINITIALOFFSET 28
303#define M_LDT_SRICMD_TXINITIALOFFSET _SB_MAKEMASK_32(3, S_LDT_SRICMD_TXINITIALOFFSET)
304#define V_LDT_SRICMD_TXINITIALOFFSET(x) _SB_MAKEVALUE_32(x, S_LDT_SRICMD_TXINITIALOFFSET)
305#define G_LDT_SRICMD_TXINITIALOFFSET(x) _SB_GETVALUE_32(x, S_LDT_SRICMD_TXINITIALOFFSET, M_LDT_SRICMD_TXINITIALOFFSET)
306
307#define M_LDT_SRICMD_LINKFREQDIRECT _SB_MAKEMASK1_32(31)
308
309/*
310 * LDT Error control and status register (Table 8-22) (Table 8-23)
311 */
312
313#define M_LDT_ERRCTL_PROTFATAL_EN _SB_MAKEMASK1_32(0)
314#define M_LDT_ERRCTL_PROTNONFATAL_EN _SB_MAKEMASK1_32(1)
315#define M_LDT_ERRCTL_PROTSYNCFLOOD_EN _SB_MAKEMASK1_32(2)
316#define M_LDT_ERRCTL_OVFFATAL_EN _SB_MAKEMASK1_32(3)
317#define M_LDT_ERRCTL_OVFNONFATAL_EN _SB_MAKEMASK1_32(4)
318#define M_LDT_ERRCTL_OVFSYNCFLOOD_EN _SB_MAKEMASK1_32(5)
319#define M_LDT_ERRCTL_EOCNXAFATAL_EN _SB_MAKEMASK1_32(6)
320#define M_LDT_ERRCTL_EOCNXANONFATAL_EN _SB_MAKEMASK1_32(7)
321#define M_LDT_ERRCTL_EOCNXASYNCFLOOD_EN _SB_MAKEMASK1_32(8)
322#define M_LDT_ERRCTL_CRCFATAL_EN _SB_MAKEMASK1_32(9)
323#define M_LDT_ERRCTL_CRCNONFATAL_EN _SB_MAKEMASK1_32(10)
324#define M_LDT_ERRCTL_SERRFATAL_EN _SB_MAKEMASK1_32(11)
325#define M_LDT_ERRCTL_SRCTAGFATAL_EN _SB_MAKEMASK1_32(12)
326#define M_LDT_ERRCTL_SRCTAGNONFATAL_EN _SB_MAKEMASK1_32(13)
327#define M_LDT_ERRCTL_SRCTAGSYNCFLOOD_EN _SB_MAKEMASK1_32(14)
328#define M_LDT_ERRCTL_MAPNXAFATAL_EN _SB_MAKEMASK1_32(15)
329#define M_LDT_ERRCTL_MAPNXANONFATAL_EN _SB_MAKEMASK1_32(16)
330#define M_LDT_ERRCTL_MAPNXASYNCFLOOD_EN _SB_MAKEMASK1_32(17)
331
332#define M_LDT_ERRCTL_PROTOERR _SB_MAKEMASK1_32(24)
333#define M_LDT_ERRCTL_OVFERR _SB_MAKEMASK1_32(25)
334#define M_LDT_ERRCTL_EOCNXAERR _SB_MAKEMASK1_32(26)
335#define M_LDT_ERRCTL_SRCTAGERR _SB_MAKEMASK1_32(27)
336#define M_LDT_ERRCTL_MAPNXAERR _SB_MAKEMASK1_32(28)
337
338/*
339 * SRI Control register (Table 8-24, 8-25) Offset 0x6C
340 */
341
342#define S_LDT_SRICTRL_NEEDRESP 0
343#define M_LDT_SRICTRL_NEEDRESP _SB_MAKEMASK_32(2, S_LDT_SRICTRL_NEEDRESP)
344#define V_LDT_SRICTRL_NEEDRESP(x) _SB_MAKEVALUE_32(x, S_LDT_SRICTRL_NEEDRESP)
345#define G_LDT_SRICTRL_NEEDRESP(x) _SB_GETVALUE_32(x, S_LDT_SRICTRL_NEEDRESP, M_LDT_SRICTRL_NEEDRESP)
346
347#define S_LDT_SRICTRL_NEEDNPREQ 2
348#define M_LDT_SRICTRL_NEEDNPREQ _SB_MAKEMASK_32(2, S_LDT_SRICTRL_NEEDNPREQ)
349#define V_LDT_SRICTRL_NEEDNPREQ(x) _SB_MAKEVALUE_32(x, S_LDT_SRICTRL_NEEDNPREQ)
350#define G_LDT_SRICTRL_NEEDNPREQ(x) _SB_GETVALUE_32(x, S_LDT_SRICTRL_NEEDNPREQ, M_LDT_SRICTRL_NEEDNPREQ)
351
352#define S_LDT_SRICTRL_NEEDPREQ 4
353#define M_LDT_SRICTRL_NEEDPREQ _SB_MAKEMASK_32(2, S_LDT_SRICTRL_NEEDPREQ)
354#define V_LDT_SRICTRL_NEEDPREQ(x) _SB_MAKEVALUE_32(x, S_LDT_SRICTRL_NEEDPREQ)
355#define G_LDT_SRICTRL_NEEDPREQ(x) _SB_GETVALUE_32(x, S_LDT_SRICTRL_NEEDPREQ, M_LDT_SRICTRL_NEEDPREQ)
356
357#define S_LDT_SRICTRL_WANTRESP 8
358#define M_LDT_SRICTRL_WANTRESP _SB_MAKEMASK_32(2, S_LDT_SRICTRL_WANTRESP)
359#define V_LDT_SRICTRL_WANTRESP(x) _SB_MAKEVALUE_32(x, S_LDT_SRICTRL_WANTRESP)
360#define G_LDT_SRICTRL_WANTRESP(x) _SB_GETVALUE_32(x, S_LDT_SRICTRL_WANTRESP, M_LDT_SRICTRL_WANTRESP)
361
362#define S_LDT_SRICTRL_WANTNPREQ 10
363#define M_LDT_SRICTRL_WANTNPREQ _SB_MAKEMASK_32(2, S_LDT_SRICTRL_WANTNPREQ)
364#define V_LDT_SRICTRL_WANTNPREQ(x) _SB_MAKEVALUE_32(x, S_LDT_SRICTRL_WANTNPREQ)
365#define G_LDT_SRICTRL_WANTNPREQ(x) _SB_GETVALUE_32(x, S_LDT_SRICTRL_WANTNPREQ, M_LDT_SRICTRL_WANTNPREQ)
366
367#define S_LDT_SRICTRL_WANTPREQ 12
368#define M_LDT_SRICTRL_WANTPREQ _SB_MAKEMASK_32(2, S_LDT_SRICTRL_WANTPREQ)
369#define V_LDT_SRICTRL_WANTPREQ(x) _SB_MAKEVALUE_32(x, S_LDT_SRICTRL_WANTPREQ)
370#define G_LDT_SRICTRL_WANTPREQ(x) _SB_GETVALUE_32(x, S_LDT_SRICTRL_WANTPREQ, M_LDT_SRICTRL_WANTPREQ)
371
372#define S_LDT_SRICTRL_BUFRELSPACE 16
373#define M_LDT_SRICTRL_BUFRELSPACE _SB_MAKEMASK_32(4, S_LDT_SRICTRL_BUFRELSPACE)
374#define V_LDT_SRICTRL_BUFRELSPACE(x) _SB_MAKEVALUE_32(x, S_LDT_SRICTRL_BUFRELSPACE)
375#define G_LDT_SRICTRL_BUFRELSPACE(x) _SB_GETVALUE_32(x, S_LDT_SRICTRL_BUFRELSPACE, M_LDT_SRICTRL_BUFRELSPACE)
376
377/*
378 * LDT SRI Transmit Buffer Count register (Table 8-26)
379 */
380
381#define S_LDT_TXBUFCNT_PCMD 0
382#define M_LDT_TXBUFCNT_PCMD _SB_MAKEMASK_32(4, S_LDT_TXBUFCNT_PCMD)
383#define V_LDT_TXBUFCNT_PCMD(x) _SB_MAKEVALUE_32(x, S_LDT_TXBUFCNT_PCMD)
384#define G_LDT_TXBUFCNT_PCMD(x) _SB_GETVALUE_32(x, S_LDT_TXBUFCNT_PCMD, M_LDT_TXBUFCNT_PCMD)
385
386#define S_LDT_TXBUFCNT_PDATA 4
387#define M_LDT_TXBUFCNT_PDATA _SB_MAKEMASK_32(4, S_LDT_TXBUFCNT_PDATA)
388#define V_LDT_TXBUFCNT_PDATA(x) _SB_MAKEVALUE_32(x, S_LDT_TXBUFCNT_PDATA)
389#define G_LDT_TXBUFCNT_PDATA(x) _SB_GETVALUE_32(x, S_LDT_TXBUFCNT_PDATA, M_LDT_TXBUFCNT_PDATA)
390
391#define S_LDT_TXBUFCNT_NPCMD 8
392#define M_LDT_TXBUFCNT_NPCMD _SB_MAKEMASK_32(4, S_LDT_TXBUFCNT_NPCMD)
393#define V_LDT_TXBUFCNT_NPCMD(x) _SB_MAKEVALUE_32(x, S_LDT_TXBUFCNT_NPCMD)
394#define G_LDT_TXBUFCNT_NPCMD(x) _SB_GETVALUE_32(x, S_LDT_TXBUFCNT_NPCMD, M_LDT_TXBUFCNT_NPCMD)
395
396#define S_LDT_TXBUFCNT_NPDATA 12
397#define M_LDT_TXBUFCNT_NPDATA _SB_MAKEMASK_32(4, S_LDT_TXBUFCNT_NPDATA)
398#define V_LDT_TXBUFCNT_NPDATA(x) _SB_MAKEVALUE_32(x, S_LDT_TXBUFCNT_NPDATA)
399#define G_LDT_TXBUFCNT_NPDATA(x) _SB_GETVALUE_32(x, S_LDT_TXBUFCNT_NPDATA, M_LDT_TXBUFCNT_NPDATA)
400
401#define S_LDT_TXBUFCNT_RCMD 16
402#define M_LDT_TXBUFCNT_RCMD _SB_MAKEMASK_32(4, S_LDT_TXBUFCNT_RCMD)
403#define V_LDT_TXBUFCNT_RCMD(x) _SB_MAKEVALUE_32(x, S_LDT_TXBUFCNT_RCMD)
404#define G_LDT_TXBUFCNT_RCMD(x) _SB_GETVALUE_32(x, S_LDT_TXBUFCNT_RCMD, M_LDT_TXBUFCNT_RCMD)
405
406#define S_LDT_TXBUFCNT_RDATA 20
407#define M_LDT_TXBUFCNT_RDATA _SB_MAKEMASK_32(4, S_LDT_TXBUFCNT_RDATA)
408#define V_LDT_TXBUFCNT_RDATA(x) _SB_MAKEVALUE_32(x, S_LDT_TXBUFCNT_RDATA)
409#define G_LDT_TXBUFCNT_RDATA(x) _SB_GETVALUE_32(x, S_LDT_TXBUFCNT_RDATA, M_LDT_TXBUFCNT_RDATA)
410
411#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
412/*
413 * Additional Status Register
414 */
415
416#define S_LDT_ADDSTATUS_TGTDONE 0
417#define M_LDT_ADDSTATUS_TGTDONE _SB_MAKEMASK_32(8, S_LDT_ADDSTATUS_TGTDONE)
418#define V_LDT_ADDSTATUS_TGTDONE(x) _SB_MAKEVALUE_32(x, S_LDT_ADDSTATUS_TGTDONE)
419#define G_LDT_ADDSTATUS_TGTDONE(x) _SB_GETVALUE_32(x, S_LDT_ADDSTATUS_TGTDONE, M_LDT_ADDSTATUS_TGTDONE)
420#endif /* 1250 PASS2 || 112x PASS1 */
421
422#endif
423
diff --git a/arch/mips/include/asm/sibyte/sb1250_mac.h b/arch/mips/include/asm/sibyte/sb1250_mac.h
new file mode 100644
index 000000000000..b6faf08ca81d
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_mac.h
@@ -0,0 +1,656 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * MAC constants and macros File: sb1250_mac.h
5 *
6 * This module contains constants and macros for the SB1250's
7 * ethernet controllers.
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _SB1250_MAC_H
34#define _SB1250_MAC_H
35
36#include "sb1250_defs.h"
37
38/* *********************************************************************
39 * Ethernet MAC Registers
40 ********************************************************************* */
41
42/*
43 * MAC Configuration Register (Table 9-13)
44 * Register: MAC_CFG_0
45 * Register: MAC_CFG_1
46 * Register: MAC_CFG_2
47 */
48
49
50#define M_MAC_RESERVED0 _SB_MAKEMASK1(0)
51#define M_MAC_TX_HOLD_SOP_EN _SB_MAKEMASK1(1)
52#define M_MAC_RETRY_EN _SB_MAKEMASK1(2)
53#define M_MAC_RET_DRPREQ_EN _SB_MAKEMASK1(3)
54#define M_MAC_RET_UFL_EN _SB_MAKEMASK1(4)
55#define M_MAC_BURST_EN _SB_MAKEMASK1(5)
56
57#define S_MAC_TX_PAUSE _SB_MAKE64(6)
58#define M_MAC_TX_PAUSE_CNT _SB_MAKEMASK(3, S_MAC_TX_PAUSE)
59#define V_MAC_TX_PAUSE_CNT(x) _SB_MAKEVALUE(x, S_MAC_TX_PAUSE)
60
61#define K_MAC_TX_PAUSE_CNT_512 0
62#define K_MAC_TX_PAUSE_CNT_1K 1
63#define K_MAC_TX_PAUSE_CNT_2K 2
64#define K_MAC_TX_PAUSE_CNT_4K 3
65#define K_MAC_TX_PAUSE_CNT_8K 4
66#define K_MAC_TX_PAUSE_CNT_16K 5
67#define K_MAC_TX_PAUSE_CNT_32K 6
68#define K_MAC_TX_PAUSE_CNT_64K 7
69
70#define V_MAC_TX_PAUSE_CNT_512 V_MAC_TX_PAUSE_CNT(K_MAC_TX_PAUSE_CNT_512)
71#define V_MAC_TX_PAUSE_CNT_1K V_MAC_TX_PAUSE_CNT(K_MAC_TX_PAUSE_CNT_1K)
72#define V_MAC_TX_PAUSE_CNT_2K V_MAC_TX_PAUSE_CNT(K_MAC_TX_PAUSE_CNT_2K)
73#define V_MAC_TX_PAUSE_CNT_4K V_MAC_TX_PAUSE_CNT(K_MAC_TX_PAUSE_CNT_4K)
74#define V_MAC_TX_PAUSE_CNT_8K V_MAC_TX_PAUSE_CNT(K_MAC_TX_PAUSE_CNT_8K)
75#define V_MAC_TX_PAUSE_CNT_16K V_MAC_TX_PAUSE_CNT(K_MAC_TX_PAUSE_CNT_16K)
76#define V_MAC_TX_PAUSE_CNT_32K V_MAC_TX_PAUSE_CNT(K_MAC_TX_PAUSE_CNT_32K)
77#define V_MAC_TX_PAUSE_CNT_64K V_MAC_TX_PAUSE_CNT(K_MAC_TX_PAUSE_CNT_64K)
78
79#define M_MAC_RESERVED1 _SB_MAKEMASK(8, 9)
80
81#define M_MAC_AP_STAT_EN _SB_MAKEMASK1(17)
82
83#if SIBYTE_HDR_FEATURE_CHIP(1480)
84#define M_MAC_TIMESTAMP _SB_MAKEMASK1(18)
85#endif
86#define M_MAC_DRP_ERRPKT_EN _SB_MAKEMASK1(19)
87#define M_MAC_DRP_FCSERRPKT_EN _SB_MAKEMASK1(20)
88#define M_MAC_DRP_CODEERRPKT_EN _SB_MAKEMASK1(21)
89#define M_MAC_DRP_DRBLERRPKT_EN _SB_MAKEMASK1(22)
90#define M_MAC_DRP_RNTPKT_EN _SB_MAKEMASK1(23)
91#define M_MAC_DRP_OSZPKT_EN _SB_MAKEMASK1(24)
92#define M_MAC_DRP_LENERRPKT_EN _SB_MAKEMASK1(25)
93
94#define M_MAC_RESERVED3 _SB_MAKEMASK(6, 26)
95
96#define M_MAC_BYPASS_SEL _SB_MAKEMASK1(32)
97#define M_MAC_HDX_EN _SB_MAKEMASK1(33)
98
99#define S_MAC_SPEED_SEL _SB_MAKE64(34)
100#define M_MAC_SPEED_SEL _SB_MAKEMASK(2, S_MAC_SPEED_SEL)
101#define V_MAC_SPEED_SEL(x) _SB_MAKEVALUE(x, S_MAC_SPEED_SEL)
102#define G_MAC_SPEED_SEL(x) _SB_GETVALUE(x, S_MAC_SPEED_SEL, M_MAC_SPEED_SEL)
103
104#define K_MAC_SPEED_SEL_10MBPS 0
105#define K_MAC_SPEED_SEL_100MBPS 1
106#define K_MAC_SPEED_SEL_1000MBPS 2
107#define K_MAC_SPEED_SEL_RESERVED 3
108
109#define V_MAC_SPEED_SEL_10MBPS V_MAC_SPEED_SEL(K_MAC_SPEED_SEL_10MBPS)
110#define V_MAC_SPEED_SEL_100MBPS V_MAC_SPEED_SEL(K_MAC_SPEED_SEL_100MBPS)
111#define V_MAC_SPEED_SEL_1000MBPS V_MAC_SPEED_SEL(K_MAC_SPEED_SEL_1000MBPS)
112#define V_MAC_SPEED_SEL_RESERVED V_MAC_SPEED_SEL(K_MAC_SPEED_SEL_RESERVED)
113
114#define M_MAC_TX_CLK_EDGE_SEL _SB_MAKEMASK1(36)
115#define M_MAC_LOOPBACK_SEL _SB_MAKEMASK1(37)
116#define M_MAC_FAST_SYNC _SB_MAKEMASK1(38)
117#define M_MAC_SS_EN _SB_MAKEMASK1(39)
118
119#define S_MAC_BYPASS_CFG _SB_MAKE64(40)
120#define M_MAC_BYPASS_CFG _SB_MAKEMASK(2, S_MAC_BYPASS_CFG)
121#define V_MAC_BYPASS_CFG(x) _SB_MAKEVALUE(x, S_MAC_BYPASS_CFG)
122#define G_MAC_BYPASS_CFG(x) _SB_GETVALUE(x, S_MAC_BYPASS_CFG, M_MAC_BYPASS_CFG)
123
124#define K_MAC_BYPASS_GMII 0
125#define K_MAC_BYPASS_ENCODED 1
126#define K_MAC_BYPASS_SOP 2
127#define K_MAC_BYPASS_EOP 3
128
129#define M_MAC_BYPASS_16 _SB_MAKEMASK1(42)
130#define M_MAC_BYPASS_FCS_CHK _SB_MAKEMASK1(43)
131
132#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
133#define M_MAC_RX_CH_SEL_MSB _SB_MAKEMASK1(44)
134#endif /* 1250 PASS2 || 112x PASS1 || 1480*/
135
136#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
137#define M_MAC_SPLIT_CH_SEL _SB_MAKEMASK1(45)
138#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
139
140#define S_MAC_BYPASS_IFG _SB_MAKE64(46)
141#define M_MAC_BYPASS_IFG _SB_MAKEMASK(8, S_MAC_BYPASS_IFG)
142#define V_MAC_BYPASS_IFG(x) _SB_MAKEVALUE(x, S_MAC_BYPASS_IFG)
143#define G_MAC_BYPASS_IFG(x) _SB_GETVALUE(x, S_MAC_BYPASS_IFG, M_MAC_BYPASS_IFG)
144
145#define K_MAC_FC_CMD_DISABLED 0
146#define K_MAC_FC_CMD_ENABLED 1
147#define K_MAC_FC_CMD_ENAB_FALSECARR 2
148
149#define V_MAC_FC_CMD_DISABLED V_MAC_FC_CMD(K_MAC_FC_CMD_DISABLED)
150#define V_MAC_FC_CMD_ENABLED V_MAC_FC_CMD(K_MAC_FC_CMD_ENABLED)
151#define V_MAC_FC_CMD_ENAB_FALSECARR V_MAC_FC_CMD(K_MAC_FC_CMD_ENAB_FALSECARR)
152
153#define M_MAC_FC_SEL _SB_MAKEMASK1(54)
154
155#define S_MAC_FC_CMD _SB_MAKE64(55)
156#define M_MAC_FC_CMD _SB_MAKEMASK(2, S_MAC_FC_CMD)
157#define V_MAC_FC_CMD(x) _SB_MAKEVALUE(x, S_MAC_FC_CMD)
158#define G_MAC_FC_CMD(x) _SB_GETVALUE(x, S_MAC_FC_CMD, M_MAC_FC_CMD)
159
160#define S_MAC_RX_CH_SEL _SB_MAKE64(57)
161#define M_MAC_RX_CH_SEL _SB_MAKEMASK(7, S_MAC_RX_CH_SEL)
162#define V_MAC_RX_CH_SEL(x) _SB_MAKEVALUE(x, S_MAC_RX_CH_SEL)
163#define G_MAC_RX_CH_SEL(x) _SB_GETVALUE(x, S_MAC_RX_CH_SEL, M_MAC_RX_CH_SEL)
164
165
166/*
167 * MAC Enable Registers
168 * Register: MAC_ENABLE_0
169 * Register: MAC_ENABLE_1
170 * Register: MAC_ENABLE_2
171 */
172
173#define M_MAC_RXDMA_EN0 _SB_MAKEMASK1(0)
174#define M_MAC_RXDMA_EN1 _SB_MAKEMASK1(1)
175#define M_MAC_TXDMA_EN0 _SB_MAKEMASK1(4)
176#define M_MAC_TXDMA_EN1 _SB_MAKEMASK1(5)
177
178#define M_MAC_PORT_RESET _SB_MAKEMASK1(8)
179
180#if (SIBYTE_HDR_FEATURE_CHIP(1250) || SIBYTE_HDR_FEATURE_CHIP(112x))
181#define M_MAC_RX_ENABLE _SB_MAKEMASK1(10)
182#define M_MAC_TX_ENABLE _SB_MAKEMASK1(11)
183#define M_MAC_BYP_RX_ENABLE _SB_MAKEMASK1(12)
184#define M_MAC_BYP_TX_ENABLE _SB_MAKEMASK1(13)
185#endif
186
187/*
188 * MAC reset information register (1280/1255)
189 */
190#if SIBYTE_HDR_FEATURE_CHIP(1480)
191#define M_MAC_RX_CH0_PAUSE_ON _SB_MAKEMASK1(8)
192#define M_MAC_RX_CH1_PAUSE_ON _SB_MAKEMASK1(16)
193#define M_MAC_TX_CH0_PAUSE_ON _SB_MAKEMASK1(24)
194#define M_MAC_TX_CH1_PAUSE_ON _SB_MAKEMASK1(32)
195#endif
196
197/*
198 * MAC DMA Control Register
199 * Register: MAC_TXD_CTL_0
200 * Register: MAC_TXD_CTL_1
201 * Register: MAC_TXD_CTL_2
202 */
203
204#define S_MAC_TXD_WEIGHT0 _SB_MAKE64(0)
205#define M_MAC_TXD_WEIGHT0 _SB_MAKEMASK(4, S_MAC_TXD_WEIGHT0)
206#define V_MAC_TXD_WEIGHT0(x) _SB_MAKEVALUE(x, S_MAC_TXD_WEIGHT0)
207#define G_MAC_TXD_WEIGHT0(x) _SB_GETVALUE(x, S_MAC_TXD_WEIGHT0, M_MAC_TXD_WEIGHT0)
208
209#define S_MAC_TXD_WEIGHT1 _SB_MAKE64(4)
210#define M_MAC_TXD_WEIGHT1 _SB_MAKEMASK(4, S_MAC_TXD_WEIGHT1)
211#define V_MAC_TXD_WEIGHT1(x) _SB_MAKEVALUE(x, S_MAC_TXD_WEIGHT1)
212#define G_MAC_TXD_WEIGHT1(x) _SB_GETVALUE(x, S_MAC_TXD_WEIGHT1, M_MAC_TXD_WEIGHT1)
213
214/*
215 * MAC Fifo Threshhold registers (Table 9-14)
216 * Register: MAC_THRSH_CFG_0
217 * Register: MAC_THRSH_CFG_1
218 * Register: MAC_THRSH_CFG_2
219 */
220
221#define S_MAC_TX_WR_THRSH _SB_MAKE64(0)
222#if SIBYTE_HDR_FEATURE_UP_TO(1250, PASS1)
223/* XXX: Can't enable, as it has the same name as a pass2+ define below. */
224/* #define M_MAC_TX_WR_THRSH _SB_MAKEMASK(6, S_MAC_TX_WR_THRSH) */
225#endif /* up to 1250 PASS1 */
226#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
227#define M_MAC_TX_WR_THRSH _SB_MAKEMASK(7, S_MAC_TX_WR_THRSH)
228#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
229#define V_MAC_TX_WR_THRSH(x) _SB_MAKEVALUE(x, S_MAC_TX_WR_THRSH)
230#define G_MAC_TX_WR_THRSH(x) _SB_GETVALUE(x, S_MAC_TX_WR_THRSH, M_MAC_TX_WR_THRSH)
231
232#define S_MAC_TX_RD_THRSH _SB_MAKE64(8)
233#if SIBYTE_HDR_FEATURE_UP_TO(1250, PASS1)
234/* XXX: Can't enable, as it has the same name as a pass2+ define below. */
235/* #define M_MAC_TX_RD_THRSH _SB_MAKEMASK(6, S_MAC_TX_RD_THRSH) */
236#endif /* up to 1250 PASS1 */
237#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
238#define M_MAC_TX_RD_THRSH _SB_MAKEMASK(7, S_MAC_TX_RD_THRSH)
239#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
240#define V_MAC_TX_RD_THRSH(x) _SB_MAKEVALUE(x, S_MAC_TX_RD_THRSH)
241#define G_MAC_TX_RD_THRSH(x) _SB_GETVALUE(x, S_MAC_TX_RD_THRSH, M_MAC_TX_RD_THRSH)
242
243#define S_MAC_TX_RL_THRSH _SB_MAKE64(16)
244#define M_MAC_TX_RL_THRSH _SB_MAKEMASK(4, S_MAC_TX_RL_THRSH)
245#define V_MAC_TX_RL_THRSH(x) _SB_MAKEVALUE(x, S_MAC_TX_RL_THRSH)
246#define G_MAC_TX_RL_THRSH(x) _SB_GETVALUE(x, S_MAC_TX_RL_THRSH, M_MAC_TX_RL_THRSH)
247
248#define S_MAC_RX_PL_THRSH _SB_MAKE64(24)
249#define M_MAC_RX_PL_THRSH _SB_MAKEMASK(6, S_MAC_RX_PL_THRSH)
250#define V_MAC_RX_PL_THRSH(x) _SB_MAKEVALUE(x, S_MAC_RX_PL_THRSH)
251#define G_MAC_RX_PL_THRSH(x) _SB_GETVALUE(x, S_MAC_RX_PL_THRSH, M_MAC_RX_PL_THRSH)
252
253#define S_MAC_RX_RD_THRSH _SB_MAKE64(32)
254#define M_MAC_RX_RD_THRSH _SB_MAKEMASK(6, S_MAC_RX_RD_THRSH)
255#define V_MAC_RX_RD_THRSH(x) _SB_MAKEVALUE(x, S_MAC_RX_RD_THRSH)
256#define G_MAC_RX_RD_THRSH(x) _SB_GETVALUE(x, S_MAC_RX_RD_THRSH, M_MAC_RX_RD_THRSH)
257
258#define S_MAC_RX_RL_THRSH _SB_MAKE64(40)
259#define M_MAC_RX_RL_THRSH _SB_MAKEMASK(6, S_MAC_RX_RL_THRSH)
260#define V_MAC_RX_RL_THRSH(x) _SB_MAKEVALUE(x, S_MAC_RX_RL_THRSH)
261#define G_MAC_RX_RL_THRSH(x) _SB_GETVALUE(x, S_MAC_RX_RL_THRSH, M_MAC_RX_RL_THRSH)
262
263#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
264#define S_MAC_ENC_FC_THRSH _SB_MAKE64(56)
265#define M_MAC_ENC_FC_THRSH _SB_MAKEMASK(6, S_MAC_ENC_FC_THRSH)
266#define V_MAC_ENC_FC_THRSH(x) _SB_MAKEVALUE(x, S_MAC_ENC_FC_THRSH)
267#define G_MAC_ENC_FC_THRSH(x) _SB_GETVALUE(x, S_MAC_ENC_FC_THRSH, M_MAC_ENC_FC_THRSH)
268#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
269
270/*
271 * MAC Frame Configuration Registers (Table 9-15)
272 * Register: MAC_FRAME_CFG_0
273 * Register: MAC_FRAME_CFG_1
274 * Register: MAC_FRAME_CFG_2
275 */
276
277/* XXXCGD: ??? Unused in pass2? */
278#define S_MAC_IFG_RX _SB_MAKE64(0)
279#define M_MAC_IFG_RX _SB_MAKEMASK(6, S_MAC_IFG_RX)
280#define V_MAC_IFG_RX(x) _SB_MAKEVALUE(x, S_MAC_IFG_RX)
281#define G_MAC_IFG_RX(x) _SB_GETVALUE(x, S_MAC_IFG_RX, M_MAC_IFG_RX)
282
283#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
284#define S_MAC_PRE_LEN _SB_MAKE64(0)
285#define M_MAC_PRE_LEN _SB_MAKEMASK(6, S_MAC_PRE_LEN)
286#define V_MAC_PRE_LEN(x) _SB_MAKEVALUE(x, S_MAC_PRE_LEN)
287#define G_MAC_PRE_LEN(x) _SB_GETVALUE(x, S_MAC_PRE_LEN, M_MAC_PRE_LEN)
288#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
289
290#define S_MAC_IFG_TX _SB_MAKE64(6)
291#define M_MAC_IFG_TX _SB_MAKEMASK(6, S_MAC_IFG_TX)
292#define V_MAC_IFG_TX(x) _SB_MAKEVALUE(x, S_MAC_IFG_TX)
293#define G_MAC_IFG_TX(x) _SB_GETVALUE(x, S_MAC_IFG_TX, M_MAC_IFG_TX)
294
295#define S_MAC_IFG_THRSH _SB_MAKE64(12)
296#define M_MAC_IFG_THRSH _SB_MAKEMASK(6, S_MAC_IFG_THRSH)
297#define V_MAC_IFG_THRSH(x) _SB_MAKEVALUE(x, S_MAC_IFG_THRSH)
298#define G_MAC_IFG_THRSH(x) _SB_GETVALUE(x, S_MAC_IFG_THRSH, M_MAC_IFG_THRSH)
299
300#define S_MAC_BACKOFF_SEL _SB_MAKE64(18)
301#define M_MAC_BACKOFF_SEL _SB_MAKEMASK(4, S_MAC_BACKOFF_SEL)
302#define V_MAC_BACKOFF_SEL(x) _SB_MAKEVALUE(x, S_MAC_BACKOFF_SEL)
303#define G_MAC_BACKOFF_SEL(x) _SB_GETVALUE(x, S_MAC_BACKOFF_SEL, M_MAC_BACKOFF_SEL)
304
305#define S_MAC_LFSR_SEED _SB_MAKE64(22)
306#define M_MAC_LFSR_SEED _SB_MAKEMASK(8, S_MAC_LFSR_SEED)
307#define V_MAC_LFSR_SEED(x) _SB_MAKEVALUE(x, S_MAC_LFSR_SEED)
308#define G_MAC_LFSR_SEED(x) _SB_GETVALUE(x, S_MAC_LFSR_SEED, M_MAC_LFSR_SEED)
309
310#define S_MAC_SLOT_SIZE _SB_MAKE64(30)
311#define M_MAC_SLOT_SIZE _SB_MAKEMASK(10, S_MAC_SLOT_SIZE)
312#define V_MAC_SLOT_SIZE(x) _SB_MAKEVALUE(x, S_MAC_SLOT_SIZE)
313#define G_MAC_SLOT_SIZE(x) _SB_GETVALUE(x, S_MAC_SLOT_SIZE, M_MAC_SLOT_SIZE)
314
315#define S_MAC_MIN_FRAMESZ _SB_MAKE64(40)
316#define M_MAC_MIN_FRAMESZ _SB_MAKEMASK(8, S_MAC_MIN_FRAMESZ)
317#define V_MAC_MIN_FRAMESZ(x) _SB_MAKEVALUE(x, S_MAC_MIN_FRAMESZ)
318#define G_MAC_MIN_FRAMESZ(x) _SB_GETVALUE(x, S_MAC_MIN_FRAMESZ, M_MAC_MIN_FRAMESZ)
319
320#define S_MAC_MAX_FRAMESZ _SB_MAKE64(48)
321#define M_MAC_MAX_FRAMESZ _SB_MAKEMASK(16, S_MAC_MAX_FRAMESZ)
322#define V_MAC_MAX_FRAMESZ(x) _SB_MAKEVALUE(x, S_MAC_MAX_FRAMESZ)
323#define G_MAC_MAX_FRAMESZ(x) _SB_GETVALUE(x, S_MAC_MAX_FRAMESZ, M_MAC_MAX_FRAMESZ)
324
325/*
326 * These constants are used to configure the fields within the Frame
327 * Configuration Register.
328 */
329
330#define K_MAC_IFG_RX_10 _SB_MAKE64(0) /* See table 176, not used */
331#define K_MAC_IFG_RX_100 _SB_MAKE64(0)
332#define K_MAC_IFG_RX_1000 _SB_MAKE64(0)
333
334#define K_MAC_IFG_TX_10 _SB_MAKE64(20)
335#define K_MAC_IFG_TX_100 _SB_MAKE64(20)
336#define K_MAC_IFG_TX_1000 _SB_MAKE64(8)
337
338#define K_MAC_IFG_THRSH_10 _SB_MAKE64(4)
339#define K_MAC_IFG_THRSH_100 _SB_MAKE64(4)
340#define K_MAC_IFG_THRSH_1000 _SB_MAKE64(0)
341
342#define K_MAC_SLOT_SIZE_10 _SB_MAKE64(0)
343#define K_MAC_SLOT_SIZE_100 _SB_MAKE64(0)
344#define K_MAC_SLOT_SIZE_1000 _SB_MAKE64(0)
345
346#define V_MAC_IFG_RX_10 V_MAC_IFG_RX(K_MAC_IFG_RX_10)
347#define V_MAC_IFG_RX_100 V_MAC_IFG_RX(K_MAC_IFG_RX_100)
348#define V_MAC_IFG_RX_1000 V_MAC_IFG_RX(K_MAC_IFG_RX_1000)
349
350#define V_MAC_IFG_TX_10 V_MAC_IFG_TX(K_MAC_IFG_TX_10)
351#define V_MAC_IFG_TX_100 V_MAC_IFG_TX(K_MAC_IFG_TX_100)
352#define V_MAC_IFG_TX_1000 V_MAC_IFG_TX(K_MAC_IFG_TX_1000)
353
354#define V_MAC_IFG_THRSH_10 V_MAC_IFG_THRSH(K_MAC_IFG_THRSH_10)
355#define V_MAC_IFG_THRSH_100 V_MAC_IFG_THRSH(K_MAC_IFG_THRSH_100)
356#define V_MAC_IFG_THRSH_1000 V_MAC_IFG_THRSH(K_MAC_IFG_THRSH_1000)
357
358#define V_MAC_SLOT_SIZE_10 V_MAC_SLOT_SIZE(K_MAC_SLOT_SIZE_10)
359#define V_MAC_SLOT_SIZE_100 V_MAC_SLOT_SIZE(K_MAC_SLOT_SIZE_100)
360#define V_MAC_SLOT_SIZE_1000 V_MAC_SLOT_SIZE(K_MAC_SLOT_SIZE_1000)
361
362#define K_MAC_MIN_FRAMESZ_FIFO _SB_MAKE64(9)
363#define K_MAC_MIN_FRAMESZ_DEFAULT _SB_MAKE64(64)
364#define K_MAC_MAX_FRAMESZ_DEFAULT _SB_MAKE64(1518)
365#define K_MAC_MAX_FRAMESZ_JUMBO _SB_MAKE64(9216)
366
367#define V_MAC_MIN_FRAMESZ_FIFO V_MAC_MIN_FRAMESZ(K_MAC_MIN_FRAMESZ_FIFO)
368#define V_MAC_MIN_FRAMESZ_DEFAULT V_MAC_MIN_FRAMESZ(K_MAC_MIN_FRAMESZ_DEFAULT)
369#define V_MAC_MAX_FRAMESZ_DEFAULT V_MAC_MAX_FRAMESZ(K_MAC_MAX_FRAMESZ_DEFAULT)
370#define V_MAC_MAX_FRAMESZ_JUMBO V_MAC_MAX_FRAMESZ(K_MAC_MAX_FRAMESZ_JUMBO)
371
372/*
373 * MAC VLAN Tag Registers (Table 9-16)
374 * Register: MAC_VLANTAG_0
375 * Register: MAC_VLANTAG_1
376 * Register: MAC_VLANTAG_2
377 */
378
379#define S_MAC_VLAN_TAG _SB_MAKE64(0)
380#define M_MAC_VLAN_TAG _SB_MAKEMASK(32, S_MAC_VLAN_TAG)
381#define V_MAC_VLAN_TAG(x) _SB_MAKEVALUE(x, S_MAC_VLAN_TAG)
382#define G_MAC_VLAN_TAG(x) _SB_GETVALUE(x, S_MAC_VLAN_TAG, M_MAC_VLAN_TAG)
383
384#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1)
385#define S_MAC_TX_PKT_OFFSET _SB_MAKE64(32)
386#define M_MAC_TX_PKT_OFFSET _SB_MAKEMASK(8, S_MAC_TX_PKT_OFFSET)
387#define V_MAC_TX_PKT_OFFSET(x) _SB_MAKEVALUE(x, S_MAC_TX_PKT_OFFSET)
388#define G_MAC_TX_PKT_OFFSET(x) _SB_GETVALUE(x, S_MAC_TX_PKT_OFFSET, M_MAC_TX_PKT_OFFSET)
389
390#define S_MAC_TX_CRC_OFFSET _SB_MAKE64(40)
391#define M_MAC_TX_CRC_OFFSET _SB_MAKEMASK(8, S_MAC_TX_CRC_OFFSET)
392#define V_MAC_TX_CRC_OFFSET(x) _SB_MAKEVALUE(x, S_MAC_TX_CRC_OFFSET)
393#define G_MAC_TX_CRC_OFFSET(x) _SB_GETVALUE(x, S_MAC_TX_CRC_OFFSET, M_MAC_TX_CRC_OFFSET)
394
395#define M_MAC_CH_BASE_FC_EN _SB_MAKEMASK1(48)
396#endif /* 1250 PASS3 || 112x PASS1 */
397
398/*
399 * MAC Status Registers (Table 9-17)
400 * Also used for the MAC Interrupt Mask Register (Table 9-18)
401 * Register: MAC_STATUS_0
402 * Register: MAC_STATUS_1
403 * Register: MAC_STATUS_2
404 * Register: MAC_INT_MASK_0
405 * Register: MAC_INT_MASK_1
406 * Register: MAC_INT_MASK_2
407 */
408
409/*
410 * Use these constants to shift the appropriate channel
411 * into the CH0 position so the same tests can be used
412 * on each channel.
413 */
414
415#define S_MAC_RX_CH0 _SB_MAKE64(0)
416#define S_MAC_RX_CH1 _SB_MAKE64(8)
417#define S_MAC_TX_CH0 _SB_MAKE64(16)
418#define S_MAC_TX_CH1 _SB_MAKE64(24)
419
420#define S_MAC_TXCHANNELS _SB_MAKE64(16) /* this is 1st TX chan */
421#define S_MAC_CHANWIDTH _SB_MAKE64(8) /* bits between channels */
422
423/*
424 * These are the same as RX channel 0. The idea here
425 * is that you'll use one of the "S_" things above
426 * and pass just the six bits to a DMA-channel-specific ISR
427 */
428#define M_MAC_INT_CHANNEL _SB_MAKEMASK(8, 0)
429#define M_MAC_INT_EOP_COUNT _SB_MAKEMASK1(0)
430#define M_MAC_INT_EOP_TIMER _SB_MAKEMASK1(1)
431#define M_MAC_INT_EOP_SEEN _SB_MAKEMASK1(2)
432#define M_MAC_INT_HWM _SB_MAKEMASK1(3)
433#define M_MAC_INT_LWM _SB_MAKEMASK1(4)
434#define M_MAC_INT_DSCR _SB_MAKEMASK1(5)
435#define M_MAC_INT_ERR _SB_MAKEMASK1(6)
436#define M_MAC_INT_DZERO _SB_MAKEMASK1(7) /* only for TX channels */
437#define M_MAC_INT_DROP _SB_MAKEMASK1(7) /* only for RX channels */
438
439/*
440 * In the following definitions we use ch (0/1) and txrx (TX=1, RX=0, see
441 * also DMA_TX/DMA_RX in sb_regs.h).
442 */
443#define S_MAC_STATUS_CH_OFFSET(ch, txrx) _SB_MAKE64(((ch) + 2 * (txrx)) * S_MAC_CHANWIDTH)
444
445#define M_MAC_STATUS_CHANNEL(ch, txrx) _SB_MAKEVALUE(_SB_MAKEMASK(8, 0), S_MAC_STATUS_CH_OFFSET(ch, txrx))
446#define M_MAC_STATUS_EOP_COUNT(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_EOP_COUNT, S_MAC_STATUS_CH_OFFSET(ch, txrx))
447#define M_MAC_STATUS_EOP_TIMER(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_EOP_TIMER, S_MAC_STATUS_CH_OFFSET(ch, txrx))
448#define M_MAC_STATUS_EOP_SEEN(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_EOP_SEEN, S_MAC_STATUS_CH_OFFSET(ch, txrx))
449#define M_MAC_STATUS_HWM(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_HWM, S_MAC_STATUS_CH_OFFSET(ch, txrx))
450#define M_MAC_STATUS_LWM(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_LWM, S_MAC_STATUS_CH_OFFSET(ch, txrx))
451#define M_MAC_STATUS_DSCR(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_DSCR, S_MAC_STATUS_CH_OFFSET(ch, txrx))
452#define M_MAC_STATUS_ERR(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_ERR, S_MAC_STATUS_CH_OFFSET(ch, txrx))
453#define M_MAC_STATUS_DZERO(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_DZERO, S_MAC_STATUS_CH_OFFSET(ch, txrx))
454#define M_MAC_STATUS_DROP(ch, txrx) _SB_MAKEVALUE(M_MAC_INT_DROP, S_MAC_STATUS_CH_OFFSET(ch, txrx))
455#define M_MAC_STATUS_OTHER_ERR _SB_MAKEVALUE(_SB_MAKEMASK(7, 0), 40)
456
457
458#define M_MAC_RX_UNDRFL _SB_MAKEMASK1(40)
459#define M_MAC_RX_OVRFL _SB_MAKEMASK1(41)
460#define M_MAC_TX_UNDRFL _SB_MAKEMASK1(42)
461#define M_MAC_TX_OVRFL _SB_MAKEMASK1(43)
462#define M_MAC_LTCOL_ERR _SB_MAKEMASK1(44)
463#define M_MAC_EXCOL_ERR _SB_MAKEMASK1(45)
464#define M_MAC_CNTR_OVRFL_ERR _SB_MAKEMASK1(46)
465#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
466#define M_MAC_SPLIT_EN _SB_MAKEMASK1(47) /* interrupt mask only */
467#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
468
469#define S_MAC_COUNTER_ADDR _SB_MAKE64(47)
470#define M_MAC_COUNTER_ADDR _SB_MAKEMASK(5, S_MAC_COUNTER_ADDR)
471#define V_MAC_COUNTER_ADDR(x) _SB_MAKEVALUE(x, S_MAC_COUNTER_ADDR)
472#define G_MAC_COUNTER_ADDR(x) _SB_GETVALUE(x, S_MAC_COUNTER_ADDR, M_MAC_COUNTER_ADDR)
473
474#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
475#define M_MAC_TX_PAUSE_ON _SB_MAKEMASK1(52)
476#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
477
478/*
479 * MAC Fifo Pointer Registers (Table 9-19) [Debug register]
480 * Register: MAC_FIFO_PTRS_0
481 * Register: MAC_FIFO_PTRS_1
482 * Register: MAC_FIFO_PTRS_2
483 */
484
485#define S_MAC_TX_WRPTR _SB_MAKE64(0)
486#define M_MAC_TX_WRPTR _SB_MAKEMASK(6, S_MAC_TX_WRPTR)
487#define V_MAC_TX_WRPTR(x) _SB_MAKEVALUE(x, S_MAC_TX_WRPTR)
488#define G_MAC_TX_WRPTR(x) _SB_GETVALUE(x, S_MAC_TX_WRPTR, M_MAC_TX_WRPTR)
489
490#define S_MAC_TX_RDPTR _SB_MAKE64(8)
491#define M_MAC_TX_RDPTR _SB_MAKEMASK(6, S_MAC_TX_RDPTR)
492#define V_MAC_TX_RDPTR(x) _SB_MAKEVALUE(x, S_MAC_TX_RDPTR)
493#define G_MAC_TX_RDPTR(x) _SB_GETVALUE(x, S_MAC_TX_RDPTR, M_MAC_TX_RDPTR)
494
495#define S_MAC_RX_WRPTR _SB_MAKE64(16)
496#define M_MAC_RX_WRPTR _SB_MAKEMASK(6, S_MAC_RX_WRPTR)
497#define V_MAC_RX_WRPTR(x) _SB_MAKEVALUE(x, S_MAC_RX_WRPTR)
498#define G_MAC_RX_WRPTR(x) _SB_GETVALUE(x, S_MAC_RX_WRPTR, M_MAC_TX_WRPTR)
499
500#define S_MAC_RX_RDPTR _SB_MAKE64(24)
501#define M_MAC_RX_RDPTR _SB_MAKEMASK(6, S_MAC_RX_RDPTR)
502#define V_MAC_RX_RDPTR(x) _SB_MAKEVALUE(x, S_MAC_RX_RDPTR)
503#define G_MAC_RX_RDPTR(x) _SB_GETVALUE(x, S_MAC_RX_RDPTR, M_MAC_TX_RDPTR)
504
505/*
506 * MAC Fifo End Of Packet Count Registers (Table 9-20) [Debug register]
507 * Register: MAC_EOPCNT_0
508 * Register: MAC_EOPCNT_1
509 * Register: MAC_EOPCNT_2
510 */
511
512#define S_MAC_TX_EOP_COUNTER _SB_MAKE64(0)
513#define M_MAC_TX_EOP_COUNTER _SB_MAKEMASK(6, S_MAC_TX_EOP_COUNTER)
514#define V_MAC_TX_EOP_COUNTER(x) _SB_MAKEVALUE(x, S_MAC_TX_EOP_COUNTER)
515#define G_MAC_TX_EOP_COUNTER(x) _SB_GETVALUE(x, S_MAC_TX_EOP_COUNTER, M_MAC_TX_EOP_COUNTER)
516
517#define S_MAC_RX_EOP_COUNTER _SB_MAKE64(8)
518#define M_MAC_RX_EOP_COUNTER _SB_MAKEMASK(6, S_MAC_RX_EOP_COUNTER)
519#define V_MAC_RX_EOP_COUNTER(x) _SB_MAKEVALUE(x, S_MAC_RX_EOP_COUNTER)
520#define G_MAC_RX_EOP_COUNTER(x) _SB_GETVALUE(x, S_MAC_RX_EOP_COUNTER, M_MAC_RX_EOP_COUNTER)
521
522/*
523 * MAC Recieve Address Filter Exact Match Registers (Table 9-21)
524 * Registers: MAC_ADDR0_0 through MAC_ADDR7_0
525 * Registers: MAC_ADDR0_1 through MAC_ADDR7_1
526 * Registers: MAC_ADDR0_2 through MAC_ADDR7_2
527 */
528
529/* No bitfields */
530
531/*
532 * MAC Receive Address Filter Mask Registers
533 * Registers: MAC_ADDRMASK0_0 and MAC_ADDRMASK0_1
534 * Registers: MAC_ADDRMASK1_0 and MAC_ADDRMASK1_1
535 * Registers: MAC_ADDRMASK2_0 and MAC_ADDRMASK2_1
536 */
537
538/* No bitfields */
539
540/*
541 * MAC Recieve Address Filter Hash Match Registers (Table 9-22)
542 * Registers: MAC_HASH0_0 through MAC_HASH7_0
543 * Registers: MAC_HASH0_1 through MAC_HASH7_1
544 * Registers: MAC_HASH0_2 through MAC_HASH7_2
545 */
546
547/* No bitfields */
548
549/*
550 * MAC Transmit Source Address Registers (Table 9-23)
551 * Register: MAC_ETHERNET_ADDR_0
552 * Register: MAC_ETHERNET_ADDR_1
553 * Register: MAC_ETHERNET_ADDR_2
554 */
555
556/* No bitfields */
557
558/*
559 * MAC Packet Type Configuration Register
560 * Register: MAC_TYPE_CFG_0
561 * Register: MAC_TYPE_CFG_1
562 * Register: MAC_TYPE_CFG_2
563 */
564
565#define S_TYPECFG_TYPESIZE _SB_MAKE64(16)
566
567#define S_TYPECFG_TYPE0 _SB_MAKE64(0)
568#define M_TYPECFG_TYPE0 _SB_MAKEMASK(16, S_TYPECFG_TYPE0)
569#define V_TYPECFG_TYPE0(x) _SB_MAKEVALUE(x, S_TYPECFG_TYPE0)
570#define G_TYPECFG_TYPE0(x) _SB_GETVALUE(x, S_TYPECFG_TYPE0, M_TYPECFG_TYPE0)
571
572#define S_TYPECFG_TYPE1 _SB_MAKE64(0)
573#define M_TYPECFG_TYPE1 _SB_MAKEMASK(16, S_TYPECFG_TYPE1)
574#define V_TYPECFG_TYPE1(x) _SB_MAKEVALUE(x, S_TYPECFG_TYPE1)
575#define G_TYPECFG_TYPE1(x) _SB_GETVALUE(x, S_TYPECFG_TYPE1, M_TYPECFG_TYPE1)
576
577#define S_TYPECFG_TYPE2 _SB_MAKE64(0)
578#define M_TYPECFG_TYPE2 _SB_MAKEMASK(16, S_TYPECFG_TYPE2)
579#define V_TYPECFG_TYPE2(x) _SB_MAKEVALUE(x, S_TYPECFG_TYPE2)
580#define G_TYPECFG_TYPE2(x) _SB_GETVALUE(x, S_TYPECFG_TYPE2, M_TYPECFG_TYPE2)
581
582#define S_TYPECFG_TYPE3 _SB_MAKE64(0)
583#define M_TYPECFG_TYPE3 _SB_MAKEMASK(16, S_TYPECFG_TYPE3)
584#define V_TYPECFG_TYPE3(x) _SB_MAKEVALUE(x, S_TYPECFG_TYPE3)
585#define G_TYPECFG_TYPE3(x) _SB_GETVALUE(x, S_TYPECFG_TYPE3, M_TYPECFG_TYPE3)
586
587/*
588 * MAC Receive Address Filter Control Registers (Table 9-24)
589 * Register: MAC_ADFILTER_CFG_0
590 * Register: MAC_ADFILTER_CFG_1
591 * Register: MAC_ADFILTER_CFG_2
592 */
593
594#define M_MAC_ALLPKT_EN _SB_MAKEMASK1(0)
595#define M_MAC_UCAST_EN _SB_MAKEMASK1(1)
596#define M_MAC_UCAST_INV _SB_MAKEMASK1(2)
597#define M_MAC_MCAST_EN _SB_MAKEMASK1(3)
598#define M_MAC_MCAST_INV _SB_MAKEMASK1(4)
599#define M_MAC_BCAST_EN _SB_MAKEMASK1(5)
600#define M_MAC_DIRECT_INV _SB_MAKEMASK1(6)
601#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
602#define M_MAC_ALLMCAST_EN _SB_MAKEMASK1(7)
603#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
604
605#define S_MAC_IPHDR_OFFSET _SB_MAKE64(8)
606#define M_MAC_IPHDR_OFFSET _SB_MAKEMASK(8, S_MAC_IPHDR_OFFSET)
607#define V_MAC_IPHDR_OFFSET(x) _SB_MAKEVALUE(x, S_MAC_IPHDR_OFFSET)
608#define G_MAC_IPHDR_OFFSET(x) _SB_GETVALUE(x, S_MAC_IPHDR_OFFSET, M_MAC_IPHDR_OFFSET)
609
610#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
611#define S_MAC_RX_CRC_OFFSET _SB_MAKE64(16)
612#define M_MAC_RX_CRC_OFFSET _SB_MAKEMASK(8, S_MAC_RX_CRC_OFFSET)
613#define V_MAC_RX_CRC_OFFSET(x) _SB_MAKEVALUE(x, S_MAC_RX_CRC_OFFSET)
614#define G_MAC_RX_CRC_OFFSET(x) _SB_GETVALUE(x, S_MAC_RX_CRC_OFFSET, M_MAC_RX_CRC_OFFSET)
615
616#define S_MAC_RX_PKT_OFFSET _SB_MAKE64(24)
617#define M_MAC_RX_PKT_OFFSET _SB_MAKEMASK(8, S_MAC_RX_PKT_OFFSET)
618#define V_MAC_RX_PKT_OFFSET(x) _SB_MAKEVALUE(x, S_MAC_RX_PKT_OFFSET)
619#define G_MAC_RX_PKT_OFFSET(x) _SB_GETVALUE(x, S_MAC_RX_PKT_OFFSET, M_MAC_RX_PKT_OFFSET)
620
621#define M_MAC_FWDPAUSE_EN _SB_MAKEMASK1(32)
622#define M_MAC_VLAN_DET_EN _SB_MAKEMASK1(33)
623
624#define S_MAC_RX_CH_MSN_SEL _SB_MAKE64(34)
625#define M_MAC_RX_CH_MSN_SEL _SB_MAKEMASK(8, S_MAC_RX_CH_MSN_SEL)
626#define V_MAC_RX_CH_MSN_SEL(x) _SB_MAKEVALUE(x, S_MAC_RX_CH_MSN_SEL)
627#define G_MAC_RX_CH_MSN_SEL(x) _SB_GETVALUE(x, S_MAC_RX_CH_MSN_SEL, M_MAC_RX_CH_MSN_SEL)
628#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
629
630/*
631 * MAC Receive Channel Select Registers (Table 9-25)
632 */
633
634/* no bitfields */
635
636/*
637 * MAC MII Management Interface Registers (Table 9-26)
638 * Register: MAC_MDIO_0
639 * Register: MAC_MDIO_1
640 * Register: MAC_MDIO_2
641 */
642
643#define S_MAC_MDC 0
644#define S_MAC_MDIO_DIR 1
645#define S_MAC_MDIO_OUT 2
646#define S_MAC_GENC 3
647#define S_MAC_MDIO_IN 4
648
649#define M_MAC_MDC _SB_MAKEMASK1(S_MAC_MDC)
650#define M_MAC_MDIO_DIR _SB_MAKEMASK1(S_MAC_MDIO_DIR)
651#define M_MAC_MDIO_DIR_INPUT _SB_MAKEMASK1(S_MAC_MDIO_DIR)
652#define M_MAC_MDIO_OUT _SB_MAKEMASK1(S_MAC_MDIO_OUT)
653#define M_MAC_GENC _SB_MAKEMASK1(S_MAC_GENC)
654#define M_MAC_MDIO_IN _SB_MAKEMASK1(S_MAC_MDIO_IN)
655
656#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_mc.h b/arch/mips/include/asm/sibyte/sb1250_mc.h
new file mode 100644
index 000000000000..1eb1b5a88736
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_mc.h
@@ -0,0 +1,550 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * Memory Controller constants File: sb1250_mc.h
5 *
6 * This module contains constants and macros useful for
7 * programming the memory controller.
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000, 2001, 2002, 2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _SB1250_MC_H
34#define _SB1250_MC_H
35
36#include "sb1250_defs.h"
37
38/*
39 * Memory Channel Config Register (table 6-14)
40 */
41
42#define S_MC_RESERVED0 0
43#define M_MC_RESERVED0 _SB_MAKEMASK(8, S_MC_RESERVED0)
44
45#define S_MC_CHANNEL_SEL 8
46#define M_MC_CHANNEL_SEL _SB_MAKEMASK(8, S_MC_CHANNEL_SEL)
47#define V_MC_CHANNEL_SEL(x) _SB_MAKEVALUE(x, S_MC_CHANNEL_SEL)
48#define G_MC_CHANNEL_SEL(x) _SB_GETVALUE(x, S_MC_CHANNEL_SEL, M_MC_CHANNEL_SEL)
49
50#define S_MC_BANK0_MAP 16
51#define M_MC_BANK0_MAP _SB_MAKEMASK(4, S_MC_BANK0_MAP)
52#define V_MC_BANK0_MAP(x) _SB_MAKEVALUE(x, S_MC_BANK0_MAP)
53#define G_MC_BANK0_MAP(x) _SB_GETVALUE(x, S_MC_BANK0_MAP, M_MC_BANK0_MAP)
54
55#define K_MC_BANK0_MAP_DEFAULT 0x00
56#define V_MC_BANK0_MAP_DEFAULT V_MC_BANK0_MAP(K_MC_BANK0_MAP_DEFAULT)
57
58#define S_MC_BANK1_MAP 20
59#define M_MC_BANK1_MAP _SB_MAKEMASK(4, S_MC_BANK1_MAP)
60#define V_MC_BANK1_MAP(x) _SB_MAKEVALUE(x, S_MC_BANK1_MAP)
61#define G_MC_BANK1_MAP(x) _SB_GETVALUE(x, S_MC_BANK1_MAP, M_MC_BANK1_MAP)
62
63#define K_MC_BANK1_MAP_DEFAULT 0x08
64#define V_MC_BANK1_MAP_DEFAULT V_MC_BANK1_MAP(K_MC_BANK1_MAP_DEFAULT)
65
66#define S_MC_BANK2_MAP 24
67#define M_MC_BANK2_MAP _SB_MAKEMASK(4, S_MC_BANK2_MAP)
68#define V_MC_BANK2_MAP(x) _SB_MAKEVALUE(x, S_MC_BANK2_MAP)
69#define G_MC_BANK2_MAP(x) _SB_GETVALUE(x, S_MC_BANK2_MAP, M_MC_BANK2_MAP)
70
71#define K_MC_BANK2_MAP_DEFAULT 0x09
72#define V_MC_BANK2_MAP_DEFAULT V_MC_BANK2_MAP(K_MC_BANK2_MAP_DEFAULT)
73
74#define S_MC_BANK3_MAP 28
75#define M_MC_BANK3_MAP _SB_MAKEMASK(4, S_MC_BANK3_MAP)
76#define V_MC_BANK3_MAP(x) _SB_MAKEVALUE(x, S_MC_BANK3_MAP)
77#define G_MC_BANK3_MAP(x) _SB_GETVALUE(x, S_MC_BANK3_MAP, M_MC_BANK3_MAP)
78
79#define K_MC_BANK3_MAP_DEFAULT 0x0C
80#define V_MC_BANK3_MAP_DEFAULT V_MC_BANK3_MAP(K_MC_BANK3_MAP_DEFAULT)
81
82#define M_MC_RESERVED1 _SB_MAKEMASK(8, 32)
83
84#define S_MC_QUEUE_SIZE 40
85#define M_MC_QUEUE_SIZE _SB_MAKEMASK(4, S_MC_QUEUE_SIZE)
86#define V_MC_QUEUE_SIZE(x) _SB_MAKEVALUE(x, S_MC_QUEUE_SIZE)
87#define G_MC_QUEUE_SIZE(x) _SB_GETVALUE(x, S_MC_QUEUE_SIZE, M_MC_QUEUE_SIZE)
88#define V_MC_QUEUE_SIZE_DEFAULT V_MC_QUEUE_SIZE(0x0A)
89
90#define S_MC_AGE_LIMIT 44
91#define M_MC_AGE_LIMIT _SB_MAKEMASK(4, S_MC_AGE_LIMIT)
92#define V_MC_AGE_LIMIT(x) _SB_MAKEVALUE(x, S_MC_AGE_LIMIT)
93#define G_MC_AGE_LIMIT(x) _SB_GETVALUE(x, S_MC_AGE_LIMIT, M_MC_AGE_LIMIT)
94#define V_MC_AGE_LIMIT_DEFAULT V_MC_AGE_LIMIT(8)
95
96#define S_MC_WR_LIMIT 48
97#define M_MC_WR_LIMIT _SB_MAKEMASK(4, S_MC_WR_LIMIT)
98#define V_MC_WR_LIMIT(x) _SB_MAKEVALUE(x, S_MC_WR_LIMIT)
99#define G_MC_WR_LIMIT(x) _SB_GETVALUE(x, S_MC_WR_LIMIT, M_MC_WR_LIMIT)
100#define V_MC_WR_LIMIT_DEFAULT V_MC_WR_LIMIT(5)
101
102#define M_MC_IOB1HIGHPRIORITY _SB_MAKEMASK1(52)
103
104#define M_MC_RESERVED2 _SB_MAKEMASK(3, 53)
105
106#define S_MC_CS_MODE 56
107#define M_MC_CS_MODE _SB_MAKEMASK(4, S_MC_CS_MODE)
108#define V_MC_CS_MODE(x) _SB_MAKEVALUE(x, S_MC_CS_MODE)
109#define G_MC_CS_MODE(x) _SB_GETVALUE(x, S_MC_CS_MODE, M_MC_CS_MODE)
110
111#define K_MC_CS_MODE_MSB_CS 0
112#define K_MC_CS_MODE_INTLV_CS 15
113#define K_MC_CS_MODE_MIXED_CS_10 12
114#define K_MC_CS_MODE_MIXED_CS_30 6
115#define K_MC_CS_MODE_MIXED_CS_32 3
116
117#define V_MC_CS_MODE_MSB_CS V_MC_CS_MODE(K_MC_CS_MODE_MSB_CS)
118#define V_MC_CS_MODE_INTLV_CS V_MC_CS_MODE(K_MC_CS_MODE_INTLV_CS)
119#define V_MC_CS_MODE_MIXED_CS_10 V_MC_CS_MODE(K_MC_CS_MODE_MIXED_CS_10)
120#define V_MC_CS_MODE_MIXED_CS_30 V_MC_CS_MODE(K_MC_CS_MODE_MIXED_CS_30)
121#define V_MC_CS_MODE_MIXED_CS_32 V_MC_CS_MODE(K_MC_CS_MODE_MIXED_CS_32)
122
123#define M_MC_ECC_DISABLE _SB_MAKEMASK1(60)
124#define M_MC_BERR_DISABLE _SB_MAKEMASK1(61)
125#define M_MC_FORCE_SEQ _SB_MAKEMASK1(62)
126#define M_MC_DEBUG _SB_MAKEMASK1(63)
127
128#define V_MC_CONFIG_DEFAULT V_MC_WR_LIMIT_DEFAULT | V_MC_AGE_LIMIT_DEFAULT | \
129 V_MC_BANK0_MAP_DEFAULT | V_MC_BANK1_MAP_DEFAULT | \
130 V_MC_BANK2_MAP_DEFAULT | V_MC_BANK3_MAP_DEFAULT | V_MC_CHANNEL_SEL(0) | \
131 M_MC_IOB1HIGHPRIORITY | V_MC_QUEUE_SIZE_DEFAULT
132
133
134/*
135 * Memory clock config register (Table 6-15)
136 *
137 * Note: this field has been updated to be consistent with the errata to 0.2
138 */
139
140#define S_MC_CLK_RATIO 0
141#define M_MC_CLK_RATIO _SB_MAKEMASK(4, S_MC_CLK_RATIO)
142#define V_MC_CLK_RATIO(x) _SB_MAKEVALUE(x, S_MC_CLK_RATIO)
143#define G_MC_CLK_RATIO(x) _SB_GETVALUE(x, S_MC_CLK_RATIO, M_MC_CLK_RATIO)
144
145#define K_MC_CLK_RATIO_2X 4
146#define K_MC_CLK_RATIO_25X 5
147#define K_MC_CLK_RATIO_3X 6
148#define K_MC_CLK_RATIO_35X 7
149#define K_MC_CLK_RATIO_4X 8
150#define K_MC_CLK_RATIO_45X 9
151
152#define V_MC_CLK_RATIO_2X V_MC_CLK_RATIO(K_MC_CLK_RATIO_2X)
153#define V_MC_CLK_RATIO_25X V_MC_CLK_RATIO(K_MC_CLK_RATIO_25X)
154#define V_MC_CLK_RATIO_3X V_MC_CLK_RATIO(K_MC_CLK_RATIO_3X)
155#define V_MC_CLK_RATIO_35X V_MC_CLK_RATIO(K_MC_CLK_RATIO_35X)
156#define V_MC_CLK_RATIO_4X V_MC_CLK_RATIO(K_MC_CLK_RATIO_4X)
157#define V_MC_CLK_RATIO_45X V_MC_CLK_RATIO(K_MC_CLK_RATIO_45X)
158#define V_MC_CLK_RATIO_DEFAULT V_MC_CLK_RATIO_25X
159
160#define S_MC_REF_RATE 8
161#define M_MC_REF_RATE _SB_MAKEMASK(8, S_MC_REF_RATE)
162#define V_MC_REF_RATE(x) _SB_MAKEVALUE(x, S_MC_REF_RATE)
163#define G_MC_REF_RATE(x) _SB_GETVALUE(x, S_MC_REF_RATE, M_MC_REF_RATE)
164
165#define K_MC_REF_RATE_100MHz 0x62
166#define K_MC_REF_RATE_133MHz 0x81
167#define K_MC_REF_RATE_200MHz 0xC4
168
169#define V_MC_REF_RATE_100MHz V_MC_REF_RATE(K_MC_REF_RATE_100MHz)
170#define V_MC_REF_RATE_133MHz V_MC_REF_RATE(K_MC_REF_RATE_133MHz)
171#define V_MC_REF_RATE_200MHz V_MC_REF_RATE(K_MC_REF_RATE_200MHz)
172#define V_MC_REF_RATE_DEFAULT V_MC_REF_RATE_100MHz
173
174#define S_MC_CLOCK_DRIVE 16
175#define M_MC_CLOCK_DRIVE _SB_MAKEMASK(4, S_MC_CLOCK_DRIVE)
176#define V_MC_CLOCK_DRIVE(x) _SB_MAKEVALUE(x, S_MC_CLOCK_DRIVE)
177#define G_MC_CLOCK_DRIVE(x) _SB_GETVALUE(x, S_MC_CLOCK_DRIVE, M_MC_CLOCK_DRIVE)
178#define V_MC_CLOCK_DRIVE_DEFAULT V_MC_CLOCK_DRIVE(0xF)
179
180#define S_MC_DATA_DRIVE 20
181#define M_MC_DATA_DRIVE _SB_MAKEMASK(4, S_MC_DATA_DRIVE)
182#define V_MC_DATA_DRIVE(x) _SB_MAKEVALUE(x, S_MC_DATA_DRIVE)
183#define G_MC_DATA_DRIVE(x) _SB_GETVALUE(x, S_MC_DATA_DRIVE, M_MC_DATA_DRIVE)
184#define V_MC_DATA_DRIVE_DEFAULT V_MC_DATA_DRIVE(0x0)
185
186#define S_MC_ADDR_DRIVE 24
187#define M_MC_ADDR_DRIVE _SB_MAKEMASK(4, S_MC_ADDR_DRIVE)
188#define V_MC_ADDR_DRIVE(x) _SB_MAKEVALUE(x, S_MC_ADDR_DRIVE)
189#define G_MC_ADDR_DRIVE(x) _SB_GETVALUE(x, S_MC_ADDR_DRIVE, M_MC_ADDR_DRIVE)
190#define V_MC_ADDR_DRIVE_DEFAULT V_MC_ADDR_DRIVE(0x0)
191
192#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1)
193#define M_MC_REF_DISABLE _SB_MAKEMASK1(30)
194#endif /* 1250 PASS3 || 112x PASS1 */
195
196#define M_MC_DLL_BYPASS _SB_MAKEMASK1(31)
197
198#define S_MC_DQI_SKEW 32
199#define M_MC_DQI_SKEW _SB_MAKEMASK(8, S_MC_DQI_SKEW)
200#define V_MC_DQI_SKEW(x) _SB_MAKEVALUE(x, S_MC_DQI_SKEW)
201#define G_MC_DQI_SKEW(x) _SB_GETVALUE(x, S_MC_DQI_SKEW, M_MC_DQI_SKEW)
202#define V_MC_DQI_SKEW_DEFAULT V_MC_DQI_SKEW(0)
203
204#define S_MC_DQO_SKEW 40
205#define M_MC_DQO_SKEW _SB_MAKEMASK(8, S_MC_DQO_SKEW)
206#define V_MC_DQO_SKEW(x) _SB_MAKEVALUE(x, S_MC_DQO_SKEW)
207#define G_MC_DQO_SKEW(x) _SB_GETVALUE(x, S_MC_DQO_SKEW, M_MC_DQO_SKEW)
208#define V_MC_DQO_SKEW_DEFAULT V_MC_DQO_SKEW(0)
209
210#define S_MC_ADDR_SKEW 48
211#define M_MC_ADDR_SKEW _SB_MAKEMASK(8, S_MC_ADDR_SKEW)
212#define V_MC_ADDR_SKEW(x) _SB_MAKEVALUE(x, S_MC_ADDR_SKEW)
213#define G_MC_ADDR_SKEW(x) _SB_GETVALUE(x, S_MC_ADDR_SKEW, M_MC_ADDR_SKEW)
214#define V_MC_ADDR_SKEW_DEFAULT V_MC_ADDR_SKEW(0x0F)
215
216#define S_MC_DLL_DEFAULT 56
217#define M_MC_DLL_DEFAULT _SB_MAKEMASK(8, S_MC_DLL_DEFAULT)
218#define V_MC_DLL_DEFAULT(x) _SB_MAKEVALUE(x, S_MC_DLL_DEFAULT)
219#define G_MC_DLL_DEFAULT(x) _SB_GETVALUE(x, S_MC_DLL_DEFAULT, M_MC_DLL_DEFAULT)
220#define V_MC_DLL_DEFAULT_DEFAULT V_MC_DLL_DEFAULT(0x10)
221
222#define V_MC_CLKCONFIG_DEFAULT V_MC_DLL_DEFAULT_DEFAULT | \
223 V_MC_ADDR_SKEW_DEFAULT | \
224 V_MC_DQO_SKEW_DEFAULT | \
225 V_MC_DQI_SKEW_DEFAULT | \
226 V_MC_ADDR_DRIVE_DEFAULT | \
227 V_MC_DATA_DRIVE_DEFAULT | \
228 V_MC_CLOCK_DRIVE_DEFAULT | \
229 V_MC_REF_RATE_DEFAULT
230
231
232
233/*
234 * DRAM Command Register (Table 6-13)
235 */
236
237#define S_MC_COMMAND 0
238#define M_MC_COMMAND _SB_MAKEMASK(4, S_MC_COMMAND)
239#define V_MC_COMMAND(x) _SB_MAKEVALUE(x, S_MC_COMMAND)
240#define G_MC_COMMAND(x) _SB_GETVALUE(x, S_MC_COMMAND, M_MC_COMMAND)
241
242#define K_MC_COMMAND_EMRS 0
243#define K_MC_COMMAND_MRS 1
244#define K_MC_COMMAND_PRE 2
245#define K_MC_COMMAND_AR 3
246#define K_MC_COMMAND_SETRFSH 4
247#define K_MC_COMMAND_CLRRFSH 5
248#define K_MC_COMMAND_SETPWRDN 6
249#define K_MC_COMMAND_CLRPWRDN 7
250
251#define V_MC_COMMAND_EMRS V_MC_COMMAND(K_MC_COMMAND_EMRS)
252#define V_MC_COMMAND_MRS V_MC_COMMAND(K_MC_COMMAND_MRS)
253#define V_MC_COMMAND_PRE V_MC_COMMAND(K_MC_COMMAND_PRE)
254#define V_MC_COMMAND_AR V_MC_COMMAND(K_MC_COMMAND_AR)
255#define V_MC_COMMAND_SETRFSH V_MC_COMMAND(K_MC_COMMAND_SETRFSH)
256#define V_MC_COMMAND_CLRRFSH V_MC_COMMAND(K_MC_COMMAND_CLRRFSH)
257#define V_MC_COMMAND_SETPWRDN V_MC_COMMAND(K_MC_COMMAND_SETPWRDN)
258#define V_MC_COMMAND_CLRPWRDN V_MC_COMMAND(K_MC_COMMAND_CLRPWRDN)
259
260#define M_MC_CS0 _SB_MAKEMASK1(4)
261#define M_MC_CS1 _SB_MAKEMASK1(5)
262#define M_MC_CS2 _SB_MAKEMASK1(6)
263#define M_MC_CS3 _SB_MAKEMASK1(7)
264
265/*
266 * DRAM Mode Register (Table 6-14)
267 */
268
269#define S_MC_EMODE 0
270#define M_MC_EMODE _SB_MAKEMASK(15, S_MC_EMODE)
271#define V_MC_EMODE(x) _SB_MAKEVALUE(x, S_MC_EMODE)
272#define G_MC_EMODE(x) _SB_GETVALUE(x, S_MC_EMODE, M_MC_EMODE)
273#define V_MC_EMODE_DEFAULT V_MC_EMODE(0)
274
275#define S_MC_MODE 16
276#define M_MC_MODE _SB_MAKEMASK(15, S_MC_MODE)
277#define V_MC_MODE(x) _SB_MAKEVALUE(x, S_MC_MODE)
278#define G_MC_MODE(x) _SB_GETVALUE(x, S_MC_MODE, M_MC_MODE)
279#define V_MC_MODE_DEFAULT V_MC_MODE(0x22)
280
281#define S_MC_DRAM_TYPE 32
282#define M_MC_DRAM_TYPE _SB_MAKEMASK(3, S_MC_DRAM_TYPE)
283#define V_MC_DRAM_TYPE(x) _SB_MAKEVALUE(x, S_MC_DRAM_TYPE)
284#define G_MC_DRAM_TYPE(x) _SB_GETVALUE(x, S_MC_DRAM_TYPE, M_MC_DRAM_TYPE)
285
286#define K_MC_DRAM_TYPE_JEDEC 0
287#define K_MC_DRAM_TYPE_FCRAM 1
288#define K_MC_DRAM_TYPE_SGRAM 2
289
290#define V_MC_DRAM_TYPE_JEDEC V_MC_DRAM_TYPE(K_MC_DRAM_TYPE_JEDEC)
291#define V_MC_DRAM_TYPE_FCRAM V_MC_DRAM_TYPE(K_MC_DRAM_TYPE_FCRAM)
292#define V_MC_DRAM_TYPE_SGRAM V_MC_DRAM_TYPE(K_MC_DRAM_TYPE_SGRAM)
293
294#define M_MC_EXTERNALDECODE _SB_MAKEMASK1(35)
295
296#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1)
297#define M_MC_PRE_ON_A8 _SB_MAKEMASK1(36)
298#define M_MC_RAM_WITH_A13 _SB_MAKEMASK1(37)
299#endif /* 1250 PASS3 || 112x PASS1 */
300
301
302
303/*
304 * SDRAM Timing Register (Table 6-15)
305 */
306
307#define M_MC_w2rIDLE_TWOCYCLES _SB_MAKEMASK1(60)
308#define M_MC_r2wIDLE_TWOCYCLES _SB_MAKEMASK1(61)
309#define M_MC_r2rIDLE_TWOCYCLES _SB_MAKEMASK1(62)
310
311#define S_MC_tFIFO 56
312#define M_MC_tFIFO _SB_MAKEMASK(4, S_MC_tFIFO)
313#define V_MC_tFIFO(x) _SB_MAKEVALUE(x, S_MC_tFIFO)
314#define G_MC_tFIFO(x) _SB_GETVALUE(x, S_MC_tFIFO, M_MC_tFIFO)
315#define K_MC_tFIFO_DEFAULT 1
316#define V_MC_tFIFO_DEFAULT V_MC_tFIFO(K_MC_tFIFO_DEFAULT)
317
318#define S_MC_tRFC 52
319#define M_MC_tRFC _SB_MAKEMASK(4, S_MC_tRFC)
320#define V_MC_tRFC(x) _SB_MAKEVALUE(x, S_MC_tRFC)
321#define G_MC_tRFC(x) _SB_GETVALUE(x, S_MC_tRFC, M_MC_tRFC)
322#define K_MC_tRFC_DEFAULT 12
323#define V_MC_tRFC_DEFAULT V_MC_tRFC(K_MC_tRFC_DEFAULT)
324
325#if SIBYTE_HDR_FEATURE(1250, PASS3)
326#define M_MC_tRFC_PLUS16 _SB_MAKEMASK1(51) /* 1250C3 and later. */
327#endif
328
329#define S_MC_tCwCr 40
330#define M_MC_tCwCr _SB_MAKEMASK(4, S_MC_tCwCr)
331#define V_MC_tCwCr(x) _SB_MAKEVALUE(x, S_MC_tCwCr)
332#define G_MC_tCwCr(x) _SB_GETVALUE(x, S_MC_tCwCr, M_MC_tCwCr)
333#define K_MC_tCwCr_DEFAULT 4
334#define V_MC_tCwCr_DEFAULT V_MC_tCwCr(K_MC_tCwCr_DEFAULT)
335
336#define S_MC_tRCr 28
337#define M_MC_tRCr _SB_MAKEMASK(4, S_MC_tRCr)
338#define V_MC_tRCr(x) _SB_MAKEVALUE(x, S_MC_tRCr)
339#define G_MC_tRCr(x) _SB_GETVALUE(x, S_MC_tRCr, M_MC_tRCr)
340#define K_MC_tRCr_DEFAULT 9
341#define V_MC_tRCr_DEFAULT V_MC_tRCr(K_MC_tRCr_DEFAULT)
342
343#define S_MC_tRCw 24
344#define M_MC_tRCw _SB_MAKEMASK(4, S_MC_tRCw)
345#define V_MC_tRCw(x) _SB_MAKEVALUE(x, S_MC_tRCw)
346#define G_MC_tRCw(x) _SB_GETVALUE(x, S_MC_tRCw, M_MC_tRCw)
347#define K_MC_tRCw_DEFAULT 10
348#define V_MC_tRCw_DEFAULT V_MC_tRCw(K_MC_tRCw_DEFAULT)
349
350#define S_MC_tRRD 20
351#define M_MC_tRRD _SB_MAKEMASK(4, S_MC_tRRD)
352#define V_MC_tRRD(x) _SB_MAKEVALUE(x, S_MC_tRRD)
353#define G_MC_tRRD(x) _SB_GETVALUE(x, S_MC_tRRD, M_MC_tRRD)
354#define K_MC_tRRD_DEFAULT 2
355#define V_MC_tRRD_DEFAULT V_MC_tRRD(K_MC_tRRD_DEFAULT)
356
357#define S_MC_tRP 16
358#define M_MC_tRP _SB_MAKEMASK(4, S_MC_tRP)
359#define V_MC_tRP(x) _SB_MAKEVALUE(x, S_MC_tRP)
360#define G_MC_tRP(x) _SB_GETVALUE(x, S_MC_tRP, M_MC_tRP)
361#define K_MC_tRP_DEFAULT 4
362#define V_MC_tRP_DEFAULT V_MC_tRP(K_MC_tRP_DEFAULT)
363
364#define S_MC_tCwD 8
365#define M_MC_tCwD _SB_MAKEMASK(4, S_MC_tCwD)
366#define V_MC_tCwD(x) _SB_MAKEVALUE(x, S_MC_tCwD)
367#define G_MC_tCwD(x) _SB_GETVALUE(x, S_MC_tCwD, M_MC_tCwD)
368#define K_MC_tCwD_DEFAULT 1
369#define V_MC_tCwD_DEFAULT V_MC_tCwD(K_MC_tCwD_DEFAULT)
370
371#define M_tCrDh _SB_MAKEMASK1(7)
372#define M_MC_tCrDh M_tCrDh
373
374#define S_MC_tCrD 4
375#define M_MC_tCrD _SB_MAKEMASK(3, S_MC_tCrD)
376#define V_MC_tCrD(x) _SB_MAKEVALUE(x, S_MC_tCrD)
377#define G_MC_tCrD(x) _SB_GETVALUE(x, S_MC_tCrD, M_MC_tCrD)
378#define K_MC_tCrD_DEFAULT 2
379#define V_MC_tCrD_DEFAULT V_MC_tCrD(K_MC_tCrD_DEFAULT)
380
381#define S_MC_tRCD 0
382#define M_MC_tRCD _SB_MAKEMASK(4, S_MC_tRCD)
383#define V_MC_tRCD(x) _SB_MAKEVALUE(x, S_MC_tRCD)
384#define G_MC_tRCD(x) _SB_GETVALUE(x, S_MC_tRCD, M_MC_tRCD)
385#define K_MC_tRCD_DEFAULT 3
386#define V_MC_tRCD_DEFAULT V_MC_tRCD(K_MC_tRCD_DEFAULT)
387
388#define V_MC_TIMING_DEFAULT V_MC_tFIFO(K_MC_tFIFO_DEFAULT) | \
389 V_MC_tRFC(K_MC_tRFC_DEFAULT) | \
390 V_MC_tCwCr(K_MC_tCwCr_DEFAULT) | \
391 V_MC_tRCr(K_MC_tRCr_DEFAULT) | \
392 V_MC_tRCw(K_MC_tRCw_DEFAULT) | \
393 V_MC_tRRD(K_MC_tRRD_DEFAULT) | \
394 V_MC_tRP(K_MC_tRP_DEFAULT) | \
395 V_MC_tCwD(K_MC_tCwD_DEFAULT) | \
396 V_MC_tCrD(K_MC_tCrD_DEFAULT) | \
397 V_MC_tRCD(K_MC_tRCD_DEFAULT) | \
398 M_MC_r2rIDLE_TWOCYCLES
399
400/*
401 * Errata says these are not the default
402 * M_MC_w2rIDLE_TWOCYCLES | \
403 * M_MC_r2wIDLE_TWOCYCLES | \
404 */
405
406
407/*
408 * Chip Select Start Address Register (Table 6-17)
409 */
410
411#define S_MC_CS0_START 0
412#define M_MC_CS0_START _SB_MAKEMASK(16, S_MC_CS0_START)
413#define V_MC_CS0_START(x) _SB_MAKEVALUE(x, S_MC_CS0_START)
414#define G_MC_CS0_START(x) _SB_GETVALUE(x, S_MC_CS0_START, M_MC_CS0_START)
415
416#define S_MC_CS1_START 16
417#define M_MC_CS1_START _SB_MAKEMASK(16, S_MC_CS1_START)
418#define V_MC_CS1_START(x) _SB_MAKEVALUE(x, S_MC_CS1_START)
419#define G_MC_CS1_START(x) _SB_GETVALUE(x, S_MC_CS1_START, M_MC_CS1_START)
420
421#define S_MC_CS2_START 32
422#define M_MC_CS2_START _SB_MAKEMASK(16, S_MC_CS2_START)
423#define V_MC_CS2_START(x) _SB_MAKEVALUE(x, S_MC_CS2_START)
424#define G_MC_CS2_START(x) _SB_GETVALUE(x, S_MC_CS2_START, M_MC_CS2_START)
425
426#define S_MC_CS3_START 48
427#define M_MC_CS3_START _SB_MAKEMASK(16, S_MC_CS3_START)
428#define V_MC_CS3_START(x) _SB_MAKEVALUE(x, S_MC_CS3_START)
429#define G_MC_CS3_START(x) _SB_GETVALUE(x, S_MC_CS3_START, M_MC_CS3_START)
430
431/*
432 * Chip Select End Address Register (Table 6-18)
433 */
434
435#define S_MC_CS0_END 0
436#define M_MC_CS0_END _SB_MAKEMASK(16, S_MC_CS0_END)
437#define V_MC_CS0_END(x) _SB_MAKEVALUE(x, S_MC_CS0_END)
438#define G_MC_CS0_END(x) _SB_GETVALUE(x, S_MC_CS0_END, M_MC_CS0_END)
439
440#define S_MC_CS1_END 16
441#define M_MC_CS1_END _SB_MAKEMASK(16, S_MC_CS1_END)
442#define V_MC_CS1_END(x) _SB_MAKEVALUE(x, S_MC_CS1_END)
443#define G_MC_CS1_END(x) _SB_GETVALUE(x, S_MC_CS1_END, M_MC_CS1_END)
444
445#define S_MC_CS2_END 32
446#define M_MC_CS2_END _SB_MAKEMASK(16, S_MC_CS2_END)
447#define V_MC_CS2_END(x) _SB_MAKEVALUE(x, S_MC_CS2_END)
448#define G_MC_CS2_END(x) _SB_GETVALUE(x, S_MC_CS2_END, M_MC_CS2_END)
449
450#define S_MC_CS3_END 48
451#define M_MC_CS3_END _SB_MAKEMASK(16, S_MC_CS3_END)
452#define V_MC_CS3_END(x) _SB_MAKEVALUE(x, S_MC_CS3_END)
453#define G_MC_CS3_END(x) _SB_GETVALUE(x, S_MC_CS3_END, M_MC_CS3_END)
454
455/*
456 * Chip Select Interleave Register (Table 6-19)
457 */
458
459#define S_MC_INTLV_RESERVED 0
460#define M_MC_INTLV_RESERVED _SB_MAKEMASK(5, S_MC_INTLV_RESERVED)
461
462#define S_MC_INTERLEAVE 7
463#define M_MC_INTERLEAVE _SB_MAKEMASK(18, S_MC_INTERLEAVE)
464#define V_MC_INTERLEAVE(x) _SB_MAKEVALUE(x, S_MC_INTERLEAVE)
465
466#define S_MC_INTLV_MBZ 25
467#define M_MC_INTLV_MBZ _SB_MAKEMASK(39, S_MC_INTLV_MBZ)
468
469/*
470 * Row Address Bits Register (Table 6-20)
471 */
472
473#define S_MC_RAS_RESERVED 0
474#define M_MC_RAS_RESERVED _SB_MAKEMASK(5, S_MC_RAS_RESERVED)
475
476#define S_MC_RAS_SELECT 12
477#define M_MC_RAS_SELECT _SB_MAKEMASK(25, S_MC_RAS_SELECT)
478#define V_MC_RAS_SELECT(x) _SB_MAKEVALUE(x, S_MC_RAS_SELECT)
479
480#define S_MC_RAS_MBZ 37
481#define M_MC_RAS_MBZ _SB_MAKEMASK(27, S_MC_RAS_MBZ)
482
483
484/*
485 * Column Address Bits Register (Table 6-21)
486 */
487
488#define S_MC_CAS_RESERVED 0
489#define M_MC_CAS_RESERVED _SB_MAKEMASK(5, S_MC_CAS_RESERVED)
490
491#define S_MC_CAS_SELECT 5
492#define M_MC_CAS_SELECT _SB_MAKEMASK(18, S_MC_CAS_SELECT)
493#define V_MC_CAS_SELECT(x) _SB_MAKEVALUE(x, S_MC_CAS_SELECT)
494
495#define S_MC_CAS_MBZ 23
496#define M_MC_CAS_MBZ _SB_MAKEMASK(41, S_MC_CAS_MBZ)
497
498
499/*
500 * Bank Address Address Bits Register (Table 6-22)
501 */
502
503#define S_MC_BA_RESERVED 0
504#define M_MC_BA_RESERVED _SB_MAKEMASK(5, S_MC_BA_RESERVED)
505
506#define S_MC_BA_SELECT 5
507#define M_MC_BA_SELECT _SB_MAKEMASK(20, S_MC_BA_SELECT)
508#define V_MC_BA_SELECT(x) _SB_MAKEVALUE(x, S_MC_BA_SELECT)
509
510#define S_MC_BA_MBZ 25
511#define M_MC_BA_MBZ _SB_MAKEMASK(39, S_MC_BA_MBZ)
512
513/*
514 * Chip Select Attribute Register (Table 6-23)
515 */
516
517#define K_MC_CS_ATTR_CLOSED 0
518#define K_MC_CS_ATTR_CASCHECK 1
519#define K_MC_CS_ATTR_HINT 2
520#define K_MC_CS_ATTR_OPEN 3
521
522#define S_MC_CS0_PAGE 0
523#define M_MC_CS0_PAGE _SB_MAKEMASK(2, S_MC_CS0_PAGE)
524#define V_MC_CS0_PAGE(x) _SB_MAKEVALUE(x, S_MC_CS0_PAGE)
525#define G_MC_CS0_PAGE(x) _SB_GETVALUE(x, S_MC_CS0_PAGE, M_MC_CS0_PAGE)
526
527#define S_MC_CS1_PAGE 16
528#define M_MC_CS1_PAGE _SB_MAKEMASK(2, S_MC_CS1_PAGE)
529#define V_MC_CS1_PAGE(x) _SB_MAKEVALUE(x, S_MC_CS1_PAGE)
530#define G_MC_CS1_PAGE(x) _SB_GETVALUE(x, S_MC_CS1_PAGE, M_MC_CS1_PAGE)
531
532#define S_MC_CS2_PAGE 32
533#define M_MC_CS2_PAGE _SB_MAKEMASK(2, S_MC_CS2_PAGE)
534#define V_MC_CS2_PAGE(x) _SB_MAKEVALUE(x, S_MC_CS2_PAGE)
535#define G_MC_CS2_PAGE(x) _SB_GETVALUE(x, S_MC_CS2_PAGE, M_MC_CS2_PAGE)
536
537#define S_MC_CS3_PAGE 48
538#define M_MC_CS3_PAGE _SB_MAKEMASK(2, S_MC_CS3_PAGE)
539#define V_MC_CS3_PAGE(x) _SB_MAKEVALUE(x, S_MC_CS3_PAGE)
540#define G_MC_CS3_PAGE(x) _SB_GETVALUE(x, S_MC_CS3_PAGE, M_MC_CS3_PAGE)
541
542/*
543 * ECC Test ECC Register (Table 6-25)
544 */
545
546#define S_MC_ECC_INVERT 0
547#define M_MC_ECC_INVERT _SB_MAKEMASK(8, S_MC_ECC_INVERT)
548
549
550#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_regs.h b/arch/mips/include/asm/sibyte/sb1250_regs.h
new file mode 100644
index 000000000000..8f53ec817a5e
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_regs.h
@@ -0,0 +1,893 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * Register Definitions File: sb1250_regs.h
5 *
6 * This module contains the addresses of the on-chip peripherals
7 * on the SB1250.
8 *
9 * SB1250 specification level: 01/02/2002
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _SB1250_REGS_H
34#define _SB1250_REGS_H
35
36#include "sb1250_defs.h"
37
38
39/* *********************************************************************
40 * Some general notes:
41 *
42 * For the most part, when there is more than one peripheral
43 * of the same type on the SOC, the constants below will be
44 * offsets from the base of each peripheral. For example,
45 * the MAC registers are described as offsets from the first
46 * MAC register, and there will be a MAC_REGISTER() macro
47 * to calculate the base address of a given MAC.
48 *
49 * The information in this file is based on the SB1250 SOC
50 * manual version 0.2, July 2000.
51 ********************************************************************* */
52
53
54/* *********************************************************************
55 * Memory Controller Registers
56 ********************************************************************* */
57
58/*
59 * XXX: can't remove MC base 0 if 112x, since it's used by other macros,
60 * since there is one reg there (but it could get its addr/offset constant).
61 */
62
63#if SIBYTE_HDR_FEATURE_1250_112x /* This MC only on 1250 & 112x */
64#define A_MC_BASE_0 0x0010051000
65#define A_MC_BASE_1 0x0010052000
66#define MC_REGISTER_SPACING 0x1000
67
68#define A_MC_BASE(ctlid) ((ctlid)*MC_REGISTER_SPACING+A_MC_BASE_0)
69#define A_MC_REGISTER(ctlid, reg) (A_MC_BASE(ctlid)+(reg))
70
71#define R_MC_CONFIG 0x0000000100
72#define R_MC_DRAMCMD 0x0000000120
73#define R_MC_DRAMMODE 0x0000000140
74#define R_MC_TIMING1 0x0000000160
75#define R_MC_TIMING2 0x0000000180
76#define R_MC_CS_START 0x00000001A0
77#define R_MC_CS_END 0x00000001C0
78#define R_MC_CS_INTERLEAVE 0x00000001E0
79#define S_MC_CS_STARTEND 16
80
81#define R_MC_CSX_BASE 0x0000000200
82#define R_MC_CSX_ROW 0x0000000000 /* relative to CSX_BASE, above */
83#define R_MC_CSX_COL 0x0000000020 /* relative to CSX_BASE, above */
84#define R_MC_CSX_BA 0x0000000040 /* relative to CSX_BASE, above */
85#define MC_CSX_SPACING 0x0000000060 /* relative to CSX_BASE, above */
86
87#define R_MC_CS0_ROW 0x0000000200
88#define R_MC_CS0_COL 0x0000000220
89#define R_MC_CS0_BA 0x0000000240
90#define R_MC_CS1_ROW 0x0000000260
91#define R_MC_CS1_COL 0x0000000280
92#define R_MC_CS1_BA 0x00000002A0
93#define R_MC_CS2_ROW 0x00000002C0
94#define R_MC_CS2_COL 0x00000002E0
95#define R_MC_CS2_BA 0x0000000300
96#define R_MC_CS3_ROW 0x0000000320
97#define R_MC_CS3_COL 0x0000000340
98#define R_MC_CS3_BA 0x0000000360
99#define R_MC_CS_ATTR 0x0000000380
100#define R_MC_TEST_DATA 0x0000000400
101#define R_MC_TEST_ECC 0x0000000420
102#define R_MC_MCLK_CFG 0x0000000500
103
104#endif /* 1250 & 112x */
105
106/* *********************************************************************
107 * L2 Cache Control Registers
108 ********************************************************************* */
109
110#if SIBYTE_HDR_FEATURE_1250_112x /* This L2C only on 1250/112x */
111
112#define A_L2_READ_TAG 0x0010040018
113#define A_L2_ECC_TAG 0x0010040038
114#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1)
115#define A_L2_READ_MISC 0x0010040058
116#endif /* 1250 PASS3 || 112x PASS1 */
117#define A_L2_WAY_DISABLE 0x0010041000
118#define A_L2_MAKEDISABLE(x) (A_L2_WAY_DISABLE | (((~(x))&0x0F) << 8))
119#define A_L2_MGMT_TAG_BASE 0x00D0000000
120
121#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
122#define A_L2_CACHE_DISABLE 0x0010042000
123#define A_L2_MAKECACHEDISABLE(x) (A_L2_CACHE_DISABLE | (((x)&0x0F) << 8))
124#define A_L2_MISC_CONFIG 0x0010043000
125#endif /* 1250 PASS2 || 112x PASS1 */
126
127/* Backward-compatibility definitions. */
128/* XXX: discourage people from using these constants. */
129#define A_L2_READ_ADDRESS A_L2_READ_TAG
130#define A_L2_EEC_ADDRESS A_L2_ECC_TAG
131
132#endif
133
134
135/* *********************************************************************
136 * PCI Interface Registers
137 ********************************************************************* */
138
139#if SIBYTE_HDR_FEATURE_1250_112x /* This PCI/HT only on 1250/112x */
140#define A_PCI_TYPE00_HEADER 0x00DE000000
141#define A_PCI_TYPE01_HEADER 0x00DE000800
142#endif
143
144
145/* *********************************************************************
146 * Ethernet DMA and MACs
147 ********************************************************************* */
148
149#define A_MAC_BASE_0 0x0010064000
150#define A_MAC_BASE_1 0x0010065000
151#if SIBYTE_HDR_FEATURE_CHIP(1250)
152#define A_MAC_BASE_2 0x0010066000
153#endif /* 1250 */
154
155#define MAC_SPACING 0x1000
156#define MAC_DMA_TXRX_SPACING 0x0400
157#define MAC_DMA_CHANNEL_SPACING 0x0100
158#define DMA_RX 0
159#define DMA_TX 1
160#define MAC_NUM_DMACHAN 2 /* channels per direction */
161
162/* XXX: not correct; depends on SOC type. */
163#define MAC_NUM_PORTS 3
164
165#define A_MAC_CHANNEL_BASE(macnum) \
166 (A_MAC_BASE_0 + \
167 MAC_SPACING*(macnum))
168
169#define A_MAC_REGISTER(macnum,reg) \
170 (A_MAC_BASE_0 + \
171 MAC_SPACING*(macnum) + (reg))
172
173
174#define R_MAC_DMA_CHANNELS 0x800 /* Relative to A_MAC_CHANNEL_BASE */
175
176#define A_MAC_DMA_CHANNEL_BASE(macnum, txrx, chan) \
177 ((A_MAC_CHANNEL_BASE(macnum)) + \
178 R_MAC_DMA_CHANNELS + \
179 (MAC_DMA_TXRX_SPACING*(txrx)) + \
180 (MAC_DMA_CHANNEL_SPACING*(chan)))
181
182#define R_MAC_DMA_CHANNEL_BASE(txrx, chan) \
183 (R_MAC_DMA_CHANNELS + \
184 (MAC_DMA_TXRX_SPACING*(txrx)) + \
185 (MAC_DMA_CHANNEL_SPACING*(chan)))
186
187#define A_MAC_DMA_REGISTER(macnum, txrx, chan, reg) \
188 (A_MAC_DMA_CHANNEL_BASE(macnum, txrx, chan) + \
189 (reg))
190
191#define R_MAC_DMA_REGISTER(txrx, chan, reg) \
192 (R_MAC_DMA_CHANNEL_BASE(txrx, chan) + \
193 (reg))
194
195/*
196 * DMA channel registers, relative to A_MAC_DMA_CHANNEL_BASE
197 */
198
199#define R_MAC_DMA_CONFIG0 0x00000000
200#define R_MAC_DMA_CONFIG1 0x00000008
201#define R_MAC_DMA_DSCR_BASE 0x00000010
202#define R_MAC_DMA_DSCR_CNT 0x00000018
203#define R_MAC_DMA_CUR_DSCRA 0x00000020
204#define R_MAC_DMA_CUR_DSCRB 0x00000028
205#define R_MAC_DMA_CUR_DSCRADDR 0x00000030
206#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1)
207#define R_MAC_DMA_OODPKTLOST_RX 0x00000038 /* rx only */
208#endif /* 1250 PASS3 || 112x PASS1 */
209
210/*
211 * RMON Counters
212 */
213
214#define R_MAC_RMON_TX_BYTES 0x00000000
215#define R_MAC_RMON_COLLISIONS 0x00000008
216#define R_MAC_RMON_LATE_COL 0x00000010
217#define R_MAC_RMON_EX_COL 0x00000018
218#define R_MAC_RMON_FCS_ERROR 0x00000020
219#define R_MAC_RMON_TX_ABORT 0x00000028
220/* Counter #6 (0x30) now reserved */
221#define R_MAC_RMON_TX_BAD 0x00000038
222#define R_MAC_RMON_TX_GOOD 0x00000040
223#define R_MAC_RMON_TX_RUNT 0x00000048
224#define R_MAC_RMON_TX_OVERSIZE 0x00000050
225#define R_MAC_RMON_RX_BYTES 0x00000080
226#define R_MAC_RMON_RX_MCAST 0x00000088
227#define R_MAC_RMON_RX_BCAST 0x00000090
228#define R_MAC_RMON_RX_BAD 0x00000098
229#define R_MAC_RMON_RX_GOOD 0x000000A0
230#define R_MAC_RMON_RX_RUNT 0x000000A8
231#define R_MAC_RMON_RX_OVERSIZE 0x000000B0
232#define R_MAC_RMON_RX_FCS_ERROR 0x000000B8
233#define R_MAC_RMON_RX_LENGTH_ERROR 0x000000C0
234#define R_MAC_RMON_RX_CODE_ERROR 0x000000C8
235#define R_MAC_RMON_RX_ALIGN_ERROR 0x000000D0
236
237/* Updated to spec 0.2 */
238#define R_MAC_CFG 0x00000100
239#define R_MAC_THRSH_CFG 0x00000108
240#define R_MAC_VLANTAG 0x00000110
241#define R_MAC_FRAMECFG 0x00000118
242#define R_MAC_EOPCNT 0x00000120
243#define R_MAC_FIFO_PTRS 0x00000128
244#define R_MAC_ADFILTER_CFG 0x00000200
245#define R_MAC_ETHERNET_ADDR 0x00000208
246#define R_MAC_PKT_TYPE 0x00000210
247#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
248#define R_MAC_ADMASK0 0x00000218
249#define R_MAC_ADMASK1 0x00000220
250#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
251#define R_MAC_HASH_BASE 0x00000240
252#define R_MAC_ADDR_BASE 0x00000280
253#define R_MAC_CHLO0_BASE 0x00000300
254#define R_MAC_CHUP0_BASE 0x00000320
255#define R_MAC_ENABLE 0x00000400
256#define R_MAC_STATUS 0x00000408
257#define R_MAC_INT_MASK 0x00000410
258#define R_MAC_TXD_CTL 0x00000420
259#define R_MAC_MDIO 0x00000428
260#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
261#define R_MAC_STATUS1 0x00000430
262#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
263#define R_MAC_DEBUG_STATUS 0x00000448
264
265#define MAC_HASH_COUNT 8
266#define MAC_ADDR_COUNT 8
267#define MAC_CHMAP_COUNT 4
268
269
270/* *********************************************************************
271 * DUART Registers
272 ********************************************************************* */
273
274
275#if SIBYTE_HDR_FEATURE_1250_112x /* This MC only on 1250 & 112x */
276#define R_DUART_NUM_PORTS 2
277
278#define A_DUART 0x0010060000
279
280#define DUART_CHANREG_SPACING 0x100
281
282#define A_DUART_CHANREG(chan, reg) \
283 (A_DUART + DUART_CHANREG_SPACING * ((chan) + 1) + (reg))
284#endif /* 1250 & 112x */
285
286#define R_DUART_MODE_REG_1 0x000
287#define R_DUART_MODE_REG_2 0x010
288#define R_DUART_STATUS 0x020
289#define R_DUART_CLK_SEL 0x030
290#define R_DUART_CMD 0x050
291#define R_DUART_RX_HOLD 0x060
292#define R_DUART_TX_HOLD 0x070
293
294#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
295#define R_DUART_FULL_CTL 0x040
296#define R_DUART_OPCR_X 0x080
297#define R_DUART_AUXCTL_X 0x090
298#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
299
300
301/*
302 * The IMR and ISR can't be addressed with A_DUART_CHANREG,
303 * so use these macros instead.
304 */
305
306#if SIBYTE_HDR_FEATURE_1250_112x /* This MC only on 1250 & 112x */
307#define DUART_IMRISR_SPACING 0x20
308#define DUART_INCHNG_SPACING 0x10
309
310#define A_DUART_CTRLREG(reg) \
311 (A_DUART + DUART_CHANREG_SPACING * 3 + (reg))
312
313#define R_DUART_IMRREG(chan) \
314 (R_DUART_IMR_A + (chan) * DUART_IMRISR_SPACING)
315#define R_DUART_ISRREG(chan) \
316 (R_DUART_ISR_A + (chan) * DUART_IMRISR_SPACING)
317#define R_DUART_INCHREG(chan) \
318 (R_DUART_IN_CHNG_A + (chan) * DUART_INCHNG_SPACING)
319
320#define A_DUART_IMRREG(chan) A_DUART_CTRLREG(R_DUART_IMRREG(chan))
321#define A_DUART_ISRREG(chan) A_DUART_CTRLREG(R_DUART_ISRREG(chan))
322#define A_DUART_INCHREG(chan) A_DUART_CTRLREG(R_DUART_INCHREG(chan))
323#endif /* 1250 & 112x */
324
325#define R_DUART_AUX_CTRL 0x010
326#define R_DUART_ISR_A 0x020
327#define R_DUART_IMR_A 0x030
328#define R_DUART_ISR_B 0x040
329#define R_DUART_IMR_B 0x050
330#define R_DUART_OUT_PORT 0x060
331#define R_DUART_OPCR 0x070
332#define R_DUART_IN_PORT 0x080
333
334#define R_DUART_SET_OPR 0x0B0
335#define R_DUART_CLEAR_OPR 0x0C0
336#define R_DUART_IN_CHNG_A 0x0D0
337#define R_DUART_IN_CHNG_B 0x0E0
338
339
340/*
341 * These constants are the absolute addresses.
342 */
343
344#define A_DUART_MODE_REG_1_A 0x0010060100
345#define A_DUART_MODE_REG_2_A 0x0010060110
346#define A_DUART_STATUS_A 0x0010060120
347#define A_DUART_CLK_SEL_A 0x0010060130
348#define A_DUART_CMD_A 0x0010060150
349#define A_DUART_RX_HOLD_A 0x0010060160
350#define A_DUART_TX_HOLD_A 0x0010060170
351
352#define A_DUART_MODE_REG_1_B 0x0010060200
353#define A_DUART_MODE_REG_2_B 0x0010060210
354#define A_DUART_STATUS_B 0x0010060220
355#define A_DUART_CLK_SEL_B 0x0010060230
356#define A_DUART_CMD_B 0x0010060250
357#define A_DUART_RX_HOLD_B 0x0010060260
358#define A_DUART_TX_HOLD_B 0x0010060270
359
360#define A_DUART_INPORT_CHNG 0x0010060300
361#define A_DUART_AUX_CTRL 0x0010060310
362#define A_DUART_ISR_A 0x0010060320
363#define A_DUART_IMR_A 0x0010060330
364#define A_DUART_ISR_B 0x0010060340
365#define A_DUART_IMR_B 0x0010060350
366#define A_DUART_OUT_PORT 0x0010060360
367#define A_DUART_OPCR 0x0010060370
368#define A_DUART_IN_PORT 0x0010060380
369#define A_DUART_ISR 0x0010060390
370#define A_DUART_IMR 0x00100603A0
371#define A_DUART_SET_OPR 0x00100603B0
372#define A_DUART_CLEAR_OPR 0x00100603C0
373#define A_DUART_INPORT_CHNG_A 0x00100603D0
374#define A_DUART_INPORT_CHNG_B 0x00100603E0
375
376#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
377#define A_DUART_FULL_CTL_A 0x0010060140
378#define A_DUART_FULL_CTL_B 0x0010060240
379
380#define A_DUART_OPCR_A 0x0010060180
381#define A_DUART_OPCR_B 0x0010060280
382
383#define A_DUART_INPORT_CHNG_DEBUG 0x00100603F0
384#endif /* 1250 PASS2 || 112x PASS1 */
385
386
387/* *********************************************************************
388 * Synchronous Serial Registers
389 ********************************************************************* */
390
391
392#if SIBYTE_HDR_FEATURE_1250_112x /* sync serial only on 1250/112x */
393
394#define A_SER_BASE_0 0x0010060400
395#define A_SER_BASE_1 0x0010060800
396#define SER_SPACING 0x400
397
398#define SER_DMA_TXRX_SPACING 0x80
399
400#define SER_NUM_PORTS 2
401
402#define A_SER_CHANNEL_BASE(sernum) \
403 (A_SER_BASE_0 + \
404 SER_SPACING*(sernum))
405
406#define A_SER_REGISTER(sernum,reg) \
407 (A_SER_BASE_0 + \
408 SER_SPACING*(sernum) + (reg))
409
410
411#define R_SER_DMA_CHANNELS 0 /* Relative to A_SER_BASE_x */
412
413#define A_SER_DMA_CHANNEL_BASE(sernum,txrx) \
414 ((A_SER_CHANNEL_BASE(sernum)) + \
415 R_SER_DMA_CHANNELS + \
416 (SER_DMA_TXRX_SPACING*(txrx)))
417
418#define A_SER_DMA_REGISTER(sernum, txrx, reg) \
419 (A_SER_DMA_CHANNEL_BASE(sernum, txrx) + \
420 (reg))
421
422
423/*
424 * DMA channel registers, relative to A_SER_DMA_CHANNEL_BASE
425 */
426
427#define R_SER_DMA_CONFIG0 0x00000000
428#define R_SER_DMA_CONFIG1 0x00000008
429#define R_SER_DMA_DSCR_BASE 0x00000010
430#define R_SER_DMA_DSCR_CNT 0x00000018
431#define R_SER_DMA_CUR_DSCRA 0x00000020
432#define R_SER_DMA_CUR_DSCRB 0x00000028
433#define R_SER_DMA_CUR_DSCRADDR 0x00000030
434
435#define R_SER_DMA_CONFIG0_RX 0x00000000
436#define R_SER_DMA_CONFIG1_RX 0x00000008
437#define R_SER_DMA_DSCR_BASE_RX 0x00000010
438#define R_SER_DMA_DSCR_COUNT_RX 0x00000018
439#define R_SER_DMA_CUR_DSCR_A_RX 0x00000020
440#define R_SER_DMA_CUR_DSCR_B_RX 0x00000028
441#define R_SER_DMA_CUR_DSCR_ADDR_RX 0x00000030
442
443#define R_SER_DMA_CONFIG0_TX 0x00000080
444#define R_SER_DMA_CONFIG1_TX 0x00000088
445#define R_SER_DMA_DSCR_BASE_TX 0x00000090
446#define R_SER_DMA_DSCR_COUNT_TX 0x00000098
447#define R_SER_DMA_CUR_DSCR_A_TX 0x000000A0
448#define R_SER_DMA_CUR_DSCR_B_TX 0x000000A8
449#define R_SER_DMA_CUR_DSCR_ADDR_TX 0x000000B0
450
451#define R_SER_MODE 0x00000100
452#define R_SER_MINFRM_SZ 0x00000108
453#define R_SER_MAXFRM_SZ 0x00000110
454#define R_SER_ADDR 0x00000118
455#define R_SER_USR0_ADDR 0x00000120
456#define R_SER_USR1_ADDR 0x00000128
457#define R_SER_USR2_ADDR 0x00000130
458#define R_SER_USR3_ADDR 0x00000138
459#define R_SER_CMD 0x00000140
460#define R_SER_TX_RD_THRSH 0x00000160
461#define R_SER_TX_WR_THRSH 0x00000168
462#define R_SER_RX_RD_THRSH 0x00000170
463#define R_SER_LINE_MODE 0x00000178
464#define R_SER_DMA_ENABLE 0x00000180
465#define R_SER_INT_MASK 0x00000190
466#define R_SER_STATUS 0x00000188
467#define R_SER_STATUS_DEBUG 0x000001A8
468#define R_SER_RX_TABLE_BASE 0x00000200
469#define SER_RX_TABLE_COUNT 16
470#define R_SER_TX_TABLE_BASE 0x00000300
471#define SER_TX_TABLE_COUNT 16
472
473/* RMON Counters */
474#define R_SER_RMON_TX_BYTE_LO 0x000001C0
475#define R_SER_RMON_TX_BYTE_HI 0x000001C8
476#define R_SER_RMON_RX_BYTE_LO 0x000001D0
477#define R_SER_RMON_RX_BYTE_HI 0x000001D8
478#define R_SER_RMON_TX_UNDERRUN 0x000001E0
479#define R_SER_RMON_RX_OVERFLOW 0x000001E8
480#define R_SER_RMON_RX_ERRORS 0x000001F0
481#define R_SER_RMON_RX_BADADDR 0x000001F8
482
483#endif /* 1250/112x */
484
485/* *********************************************************************
486 * Generic Bus Registers
487 ********************************************************************* */
488
489#define IO_EXT_CFG_COUNT 8
490
491#define A_IO_EXT_BASE 0x0010061000
492#define A_IO_EXT_REG(r) (A_IO_EXT_BASE + (r))
493
494#define A_IO_EXT_CFG_BASE 0x0010061000
495#define A_IO_EXT_MULT_SIZE_BASE 0x0010061100
496#define A_IO_EXT_START_ADDR_BASE 0x0010061200
497#define A_IO_EXT_TIME_CFG0_BASE 0x0010061600
498#define A_IO_EXT_TIME_CFG1_BASE 0x0010061700
499
500#define IO_EXT_REGISTER_SPACING 8
501#define A_IO_EXT_CS_BASE(cs) (A_IO_EXT_CFG_BASE+IO_EXT_REGISTER_SPACING*(cs))
502#define R_IO_EXT_REG(reg, cs) ((cs)*IO_EXT_REGISTER_SPACING + (reg))
503
504#define R_IO_EXT_CFG 0x0000
505#define R_IO_EXT_MULT_SIZE 0x0100
506#define R_IO_EXT_START_ADDR 0x0200
507#define R_IO_EXT_TIME_CFG0 0x0600
508#define R_IO_EXT_TIME_CFG1 0x0700
509
510
511#define A_IO_INTERRUPT_STATUS 0x0010061A00
512#define A_IO_INTERRUPT_DATA0 0x0010061A10
513#define A_IO_INTERRUPT_DATA1 0x0010061A18
514#define A_IO_INTERRUPT_DATA2 0x0010061A20
515#define A_IO_INTERRUPT_DATA3 0x0010061A28
516#define A_IO_INTERRUPT_ADDR0 0x0010061A30
517#define A_IO_INTERRUPT_ADDR1 0x0010061A40
518#define A_IO_INTERRUPT_PARITY 0x0010061A50
519#define A_IO_PCMCIA_CFG 0x0010061A60
520#define A_IO_PCMCIA_STATUS 0x0010061A70
521#define A_IO_DRIVE_0 0x0010061300
522#define A_IO_DRIVE_1 0x0010061308
523#define A_IO_DRIVE_2 0x0010061310
524#define A_IO_DRIVE_3 0x0010061318
525#define A_IO_DRIVE_BASE A_IO_DRIVE_0
526#define IO_DRIVE_REGISTER_SPACING 8
527#define R_IO_DRIVE(x) ((x)*IO_DRIVE_REGISTER_SPACING)
528#define A_IO_DRIVE(x) (A_IO_DRIVE_BASE + R_IO_DRIVE(x))
529
530#define R_IO_INTERRUPT_STATUS 0x0A00
531#define R_IO_INTERRUPT_DATA0 0x0A10
532#define R_IO_INTERRUPT_DATA1 0x0A18
533#define R_IO_INTERRUPT_DATA2 0x0A20
534#define R_IO_INTERRUPT_DATA3 0x0A28
535#define R_IO_INTERRUPT_ADDR0 0x0A30
536#define R_IO_INTERRUPT_ADDR1 0x0A40
537#define R_IO_INTERRUPT_PARITY 0x0A50
538#define R_IO_PCMCIA_CFG 0x0A60
539#define R_IO_PCMCIA_STATUS 0x0A70
540
541/* *********************************************************************
542 * GPIO Registers
543 ********************************************************************* */
544
545#define A_GPIO_CLR_EDGE 0x0010061A80
546#define A_GPIO_INT_TYPE 0x0010061A88
547#define A_GPIO_INPUT_INVERT 0x0010061A90
548#define A_GPIO_GLITCH 0x0010061A98
549#define A_GPIO_READ 0x0010061AA0
550#define A_GPIO_DIRECTION 0x0010061AA8
551#define A_GPIO_PIN_CLR 0x0010061AB0
552#define A_GPIO_PIN_SET 0x0010061AB8
553
554#define A_GPIO_BASE 0x0010061A80
555
556#define R_GPIO_CLR_EDGE 0x00
557#define R_GPIO_INT_TYPE 0x08
558#define R_GPIO_INPUT_INVERT 0x10
559#define R_GPIO_GLITCH 0x18
560#define R_GPIO_READ 0x20
561#define R_GPIO_DIRECTION 0x28
562#define R_GPIO_PIN_CLR 0x30
563#define R_GPIO_PIN_SET 0x38
564
565/* *********************************************************************
566 * SMBus Registers
567 ********************************************************************* */
568
569#define A_SMB_XTRA_0 0x0010060000
570#define A_SMB_XTRA_1 0x0010060008
571#define A_SMB_FREQ_0 0x0010060010
572#define A_SMB_FREQ_1 0x0010060018
573#define A_SMB_STATUS_0 0x0010060020
574#define A_SMB_STATUS_1 0x0010060028
575#define A_SMB_CMD_0 0x0010060030
576#define A_SMB_CMD_1 0x0010060038
577#define A_SMB_START_0 0x0010060040
578#define A_SMB_START_1 0x0010060048
579#define A_SMB_DATA_0 0x0010060050
580#define A_SMB_DATA_1 0x0010060058
581#define A_SMB_CONTROL_0 0x0010060060
582#define A_SMB_CONTROL_1 0x0010060068
583#define A_SMB_PEC_0 0x0010060070
584#define A_SMB_PEC_1 0x0010060078
585
586#define A_SMB_0 0x0010060000
587#define A_SMB_1 0x0010060008
588#define SMB_REGISTER_SPACING 0x8
589#define A_SMB_BASE(idx) (A_SMB_0+(idx)*SMB_REGISTER_SPACING)
590#define A_SMB_REGISTER(idx, reg) (A_SMB_BASE(idx)+(reg))
591
592#define R_SMB_XTRA 0x0000000000
593#define R_SMB_FREQ 0x0000000010
594#define R_SMB_STATUS 0x0000000020
595#define R_SMB_CMD 0x0000000030
596#define R_SMB_START 0x0000000040
597#define R_SMB_DATA 0x0000000050
598#define R_SMB_CONTROL 0x0000000060
599#define R_SMB_PEC 0x0000000070
600
601/* *********************************************************************
602 * Timer Registers
603 ********************************************************************* */
604
605/*
606 * Watchdog timers
607 */
608
609#define A_SCD_WDOG_0 0x0010020050
610#define A_SCD_WDOG_1 0x0010020150
611#define SCD_WDOG_SPACING 0x100
612#define SCD_NUM_WDOGS 2
613#define A_SCD_WDOG_BASE(w) (A_SCD_WDOG_0+SCD_WDOG_SPACING*(w))
614#define A_SCD_WDOG_REGISTER(w, r) (A_SCD_WDOG_BASE(w) + (r))
615
616#define R_SCD_WDOG_INIT 0x0000000000
617#define R_SCD_WDOG_CNT 0x0000000008
618#define R_SCD_WDOG_CFG 0x0000000010
619
620#define A_SCD_WDOG_INIT_0 0x0010020050
621#define A_SCD_WDOG_CNT_0 0x0010020058
622#define A_SCD_WDOG_CFG_0 0x0010020060
623
624#define A_SCD_WDOG_INIT_1 0x0010020150
625#define A_SCD_WDOG_CNT_1 0x0010020158
626#define A_SCD_WDOG_CFG_1 0x0010020160
627
628/*
629 * Generic timers
630 */
631
632#define A_SCD_TIMER_0 0x0010020070
633#define A_SCD_TIMER_1 0x0010020078
634#define A_SCD_TIMER_2 0x0010020170
635#define A_SCD_TIMER_3 0x0010020178
636#define SCD_NUM_TIMERS 4
637#define A_SCD_TIMER_BASE(w) (A_SCD_TIMER_0+0x08*((w)&1)+0x100*(((w)&2)>>1))
638#define A_SCD_TIMER_REGISTER(w, r) (A_SCD_TIMER_BASE(w) + (r))
639
640#define R_SCD_TIMER_INIT 0x0000000000
641#define R_SCD_TIMER_CNT 0x0000000010
642#define R_SCD_TIMER_CFG 0x0000000020
643
644#define A_SCD_TIMER_INIT_0 0x0010020070
645#define A_SCD_TIMER_CNT_0 0x0010020080
646#define A_SCD_TIMER_CFG_0 0x0010020090
647
648#define A_SCD_TIMER_INIT_1 0x0010020078
649#define A_SCD_TIMER_CNT_1 0x0010020088
650#define A_SCD_TIMER_CFG_1 0x0010020098
651
652#define A_SCD_TIMER_INIT_2 0x0010020170
653#define A_SCD_TIMER_CNT_2 0x0010020180
654#define A_SCD_TIMER_CFG_2 0x0010020190
655
656#define A_SCD_TIMER_INIT_3 0x0010020178
657#define A_SCD_TIMER_CNT_3 0x0010020188
658#define A_SCD_TIMER_CFG_3 0x0010020198
659
660#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
661#define A_SCD_SCRATCH 0x0010020C10
662#endif /* 1250 PASS2 || 112x PASS1 */
663
664#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
665#define A_SCD_ZBBUS_CYCLE_COUNT 0x0010030000
666#define A_SCD_ZBBUS_CYCLE_CP0 0x0010020C00
667#define A_SCD_ZBBUS_CYCLE_CP1 0x0010020C08
668#endif
669
670/* *********************************************************************
671 * System Control Registers
672 ********************************************************************* */
673
674#define A_SCD_SYSTEM_REVISION 0x0010020000
675#define A_SCD_SYSTEM_CFG 0x0010020008
676#define A_SCD_SYSTEM_MANUF 0x0010038000
677
678/* *********************************************************************
679 * System Address Trap Registers
680 ********************************************************************* */
681
682#define A_ADDR_TRAP_INDEX 0x00100200B0
683#define A_ADDR_TRAP_REG 0x00100200B8
684#define A_ADDR_TRAP_UP_0 0x0010020400
685#define A_ADDR_TRAP_UP_1 0x0010020408
686#define A_ADDR_TRAP_UP_2 0x0010020410
687#define A_ADDR_TRAP_UP_3 0x0010020418
688#define A_ADDR_TRAP_DOWN_0 0x0010020420
689#define A_ADDR_TRAP_DOWN_1 0x0010020428
690#define A_ADDR_TRAP_DOWN_2 0x0010020430
691#define A_ADDR_TRAP_DOWN_3 0x0010020438
692#define A_ADDR_TRAP_CFG_0 0x0010020440
693#define A_ADDR_TRAP_CFG_1 0x0010020448
694#define A_ADDR_TRAP_CFG_2 0x0010020450
695#define A_ADDR_TRAP_CFG_3 0x0010020458
696#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
697#define A_ADDR_TRAP_REG_DEBUG 0x0010020460
698#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
699
700#define ADDR_TRAP_SPACING 8
701#define NUM_ADDR_TRAP 4
702#define A_ADDR_TRAP_UP(n) (A_ADDR_TRAP_UP_0 + ((n) * ADDR_TRAP_SPACING))
703#define A_ADDR_TRAP_DOWN(n) (A_ADDR_TRAP_DOWN_0 + ((n) * ADDR_TRAP_SPACING))
704#define A_ADDR_TRAP_CFG(n) (A_ADDR_TRAP_CFG_0 + ((n) * ADDR_TRAP_SPACING))
705
706
707/* *********************************************************************
708 * System Interrupt Mapper Registers
709 ********************************************************************* */
710
711#define A_IMR_CPU0_BASE 0x0010020000
712#define A_IMR_CPU1_BASE 0x0010022000
713#define IMR_REGISTER_SPACING 0x2000
714#define IMR_REGISTER_SPACING_SHIFT 13
715
716#define A_IMR_MAPPER(cpu) (A_IMR_CPU0_BASE+(cpu)*IMR_REGISTER_SPACING)
717#define A_IMR_REGISTER(cpu, reg) (A_IMR_MAPPER(cpu)+(reg))
718
719#define R_IMR_INTERRUPT_DIAG 0x0010
720#define R_IMR_INTERRUPT_LDT 0x0018
721#define R_IMR_INTERRUPT_MASK 0x0028
722#define R_IMR_INTERRUPT_TRACE 0x0038
723#define R_IMR_INTERRUPT_SOURCE_STATUS 0x0040
724#define R_IMR_LDT_INTERRUPT_SET 0x0048
725#define R_IMR_LDT_INTERRUPT 0x0018
726#define R_IMR_LDT_INTERRUPT_CLR 0x0020
727#define R_IMR_MAILBOX_CPU 0x00c0
728#define R_IMR_ALIAS_MAILBOX_CPU 0x1000
729#define R_IMR_MAILBOX_SET_CPU 0x00C8
730#define R_IMR_ALIAS_MAILBOX_SET_CPU 0x1008
731#define R_IMR_MAILBOX_CLR_CPU 0x00D0
732#define R_IMR_INTERRUPT_STATUS_BASE 0x0100
733#define R_IMR_INTERRUPT_STATUS_COUNT 7
734#define R_IMR_INTERRUPT_MAP_BASE 0x0200
735#define R_IMR_INTERRUPT_MAP_COUNT 64
736
737/*
738 * these macros work together to build the address of a mailbox
739 * register, e.g., A_MAILBOX_REGISTER(R_IMR_MAILBOX_SET_CPU,1)
740 * for mbox_0_set_cpu2 returns 0x00100240C8
741 */
742#define A_MAILBOX_REGISTER(reg,cpu) \
743 (A_IMR_CPU0_BASE + (cpu * IMR_REGISTER_SPACING) + reg)
744
745/* *********************************************************************
746 * System Performance Counter Registers
747 ********************************************************************* */
748
749#define A_SCD_PERF_CNT_CFG 0x00100204C0
750#define A_SCD_PERF_CNT_0 0x00100204D0
751#define A_SCD_PERF_CNT_1 0x00100204D8
752#define A_SCD_PERF_CNT_2 0x00100204E0
753#define A_SCD_PERF_CNT_3 0x00100204E8
754
755#define SCD_NUM_PERF_CNT 4
756#define SCD_PERF_CNT_SPACING 8
757#define A_SCD_PERF_CNT(n) (A_SCD_PERF_CNT_0+(n*SCD_PERF_CNT_SPACING))
758
759/* *********************************************************************
760 * System Bus Watcher Registers
761 ********************************************************************* */
762
763#define A_SCD_BUS_ERR_STATUS 0x0010020880
764#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
765#define A_SCD_BUS_ERR_STATUS_DEBUG 0x00100208D0
766#define A_BUS_ERR_STATUS_DEBUG 0x00100208D0
767#endif /* 1250 PASS2 || 112x PASS1 */
768#define A_BUS_ERR_DATA_0 0x00100208A0
769#define A_BUS_ERR_DATA_1 0x00100208A8
770#define A_BUS_ERR_DATA_2 0x00100208B0
771#define A_BUS_ERR_DATA_3 0x00100208B8
772#define A_BUS_L2_ERRORS 0x00100208C0
773#define A_BUS_MEM_IO_ERRORS 0x00100208C8
774
775/* *********************************************************************
776 * System Debug Controller Registers
777 ********************************************************************* */
778
779#define A_SCD_JTAG_BASE 0x0010000000
780
781/* *********************************************************************
782 * System Trace Buffer Registers
783 ********************************************************************* */
784
785#define A_SCD_TRACE_CFG 0x0010020A00
786#define A_SCD_TRACE_READ 0x0010020A08
787#define A_SCD_TRACE_EVENT_0 0x0010020A20
788#define A_SCD_TRACE_EVENT_1 0x0010020A28
789#define A_SCD_TRACE_EVENT_2 0x0010020A30
790#define A_SCD_TRACE_EVENT_3 0x0010020A38
791#define A_SCD_TRACE_SEQUENCE_0 0x0010020A40
792#define A_SCD_TRACE_SEQUENCE_1 0x0010020A48
793#define A_SCD_TRACE_SEQUENCE_2 0x0010020A50
794#define A_SCD_TRACE_SEQUENCE_3 0x0010020A58
795#define A_SCD_TRACE_EVENT_4 0x0010020A60
796#define A_SCD_TRACE_EVENT_5 0x0010020A68
797#define A_SCD_TRACE_EVENT_6 0x0010020A70
798#define A_SCD_TRACE_EVENT_7 0x0010020A78
799#define A_SCD_TRACE_SEQUENCE_4 0x0010020A80
800#define A_SCD_TRACE_SEQUENCE_5 0x0010020A88
801#define A_SCD_TRACE_SEQUENCE_6 0x0010020A90
802#define A_SCD_TRACE_SEQUENCE_7 0x0010020A98
803
804#define TRACE_REGISTER_SPACING 8
805#define TRACE_NUM_REGISTERS 8
806#define A_SCD_TRACE_EVENT(n) (((n) & 4) ? \
807 (A_SCD_TRACE_EVENT_4 + (((n) & 3) * TRACE_REGISTER_SPACING)) : \
808 (A_SCD_TRACE_EVENT_0 + ((n) * TRACE_REGISTER_SPACING)))
809#define A_SCD_TRACE_SEQUENCE(n) (((n) & 4) ? \
810 (A_SCD_TRACE_SEQUENCE_4 + (((n) & 3) * TRACE_REGISTER_SPACING)) : \
811 (A_SCD_TRACE_SEQUENCE_0 + ((n) * TRACE_REGISTER_SPACING)))
812
813/* *********************************************************************
814 * System Generic DMA Registers
815 ********************************************************************* */
816
817#define A_DM_0 0x0010020B00
818#define A_DM_1 0x0010020B20
819#define A_DM_2 0x0010020B40
820#define A_DM_3 0x0010020B60
821#define DM_REGISTER_SPACING 0x20
822#define DM_NUM_CHANNELS 4
823#define A_DM_BASE(idx) (A_DM_0 + ((idx) * DM_REGISTER_SPACING))
824#define A_DM_REGISTER(idx, reg) (A_DM_BASE(idx) + (reg))
825
826#define R_DM_DSCR_BASE 0x0000000000
827#define R_DM_DSCR_COUNT 0x0000000008
828#define R_DM_CUR_DSCR_ADDR 0x0000000010
829#define R_DM_DSCR_BASE_DEBUG 0x0000000018
830
831#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1)
832#define A_DM_PARTIAL_0 0x0010020ba0
833#define A_DM_PARTIAL_1 0x0010020ba8
834#define A_DM_PARTIAL_2 0x0010020bb0
835#define A_DM_PARTIAL_3 0x0010020bb8
836#define DM_PARTIAL_REGISTER_SPACING 0x8
837#define A_DM_PARTIAL(idx) (A_DM_PARTIAL_0 + ((idx) * DM_PARTIAL_REGISTER_SPACING))
838#endif /* 1250 PASS3 || 112x PASS1 */
839
840#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1)
841#define A_DM_CRC_0 0x0010020b80
842#define A_DM_CRC_1 0x0010020b90
843#define DM_CRC_REGISTER_SPACING 0x10
844#define DM_CRC_NUM_CHANNELS 2
845#define A_DM_CRC_BASE(idx) (A_DM_CRC_0 + ((idx) * DM_CRC_REGISTER_SPACING))
846#define A_DM_CRC_REGISTER(idx, reg) (A_DM_CRC_BASE(idx) + (reg))
847
848#define R_CRC_DEF_0 0x00
849#define R_CTCP_DEF_0 0x08
850#endif /* 1250 PASS3 || 112x PASS1 */
851
852/* *********************************************************************
853 * Physical Address Map
854 ********************************************************************* */
855
856#if SIBYTE_HDR_FEATURE_1250_112x
857#define A_PHYS_MEMORY_0 _SB_MAKE64(0x0000000000)
858#define A_PHYS_MEMORY_SIZE _SB_MAKE64((256*1024*1024))
859#define A_PHYS_SYSTEM_CTL _SB_MAKE64(0x0010000000)
860#define A_PHYS_IO_SYSTEM _SB_MAKE64(0x0010060000)
861#define A_PHYS_GENBUS _SB_MAKE64(0x0010090000)
862#define A_PHYS_GENBUS_END _SB_MAKE64(0x0040000000)
863#define A_PHYS_LDTPCI_IO_MATCH_BYTES_32 _SB_MAKE64(0x0040000000)
864#define A_PHYS_LDTPCI_IO_MATCH_BITS_32 _SB_MAKE64(0x0060000000)
865#define A_PHYS_MEMORY_1 _SB_MAKE64(0x0080000000)
866#define A_PHYS_MEMORY_2 _SB_MAKE64(0x0090000000)
867#define A_PHYS_MEMORY_3 _SB_MAKE64(0x00C0000000)
868#define A_PHYS_L2_CACHE_TEST _SB_MAKE64(0x00D0000000)
869#define A_PHYS_LDT_SPECIAL_MATCH_BYTES _SB_MAKE64(0x00D8000000)
870#define A_PHYS_LDTPCI_IO_MATCH_BYTES _SB_MAKE64(0x00DC000000)
871#define A_PHYS_LDTPCI_CFG_MATCH_BYTES _SB_MAKE64(0x00DE000000)
872#define A_PHYS_LDT_SPECIAL_MATCH_BITS _SB_MAKE64(0x00F8000000)
873#define A_PHYS_LDTPCI_IO_MATCH_BITS _SB_MAKE64(0x00FC000000)
874#define A_PHYS_LDTPCI_CFG_MATCH_BITS _SB_MAKE64(0x00FE000000)
875#define A_PHYS_MEMORY_EXP _SB_MAKE64(0x0100000000)
876#define A_PHYS_MEMORY_EXP_SIZE _SB_MAKE64((508*1024*1024*1024))
877#define A_PHYS_LDT_EXP _SB_MAKE64(0x8000000000)
878#define A_PHYS_PCI_FULLACCESS_BYTES _SB_MAKE64(0xF000000000)
879#define A_PHYS_PCI_FULLACCESS_BITS _SB_MAKE64(0xF100000000)
880#define A_PHYS_RESERVED _SB_MAKE64(0xF200000000)
881#define A_PHYS_RESERVED_SPECIAL_LDT _SB_MAKE64(0xFD00000000)
882
883#define A_PHYS_L2CACHE_WAY_SIZE _SB_MAKE64(0x0000020000)
884#define PHYS_L2CACHE_NUM_WAYS 4
885#define A_PHYS_L2CACHE_TOTAL_SIZE _SB_MAKE64(0x0000080000)
886#define A_PHYS_L2CACHE_WAY0 _SB_MAKE64(0x00D0180000)
887#define A_PHYS_L2CACHE_WAY1 _SB_MAKE64(0x00D01A0000)
888#define A_PHYS_L2CACHE_WAY2 _SB_MAKE64(0x00D01C0000)
889#define A_PHYS_L2CACHE_WAY3 _SB_MAKE64(0x00D01E0000)
890#endif
891
892
893#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_scd.h b/arch/mips/include/asm/sibyte/sb1250_scd.h
new file mode 100644
index 000000000000..e49c3e89b5ee
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_scd.h
@@ -0,0 +1,654 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * SCD Constants and Macros File: sb1250_scd.h
5 *
6 * This module contains constants and macros useful for
7 * manipulating the System Control and Debug module on the 1250.
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003,2004,2005
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32#ifndef _SB1250_SCD_H
33#define _SB1250_SCD_H
34
35#include "sb1250_defs.h"
36
37/* *********************************************************************
38 * System control/debug registers
39 ********************************************************************* */
40
41/*
42 * System Revision Register (Table 4-1)
43 */
44
45#define M_SYS_RESERVED _SB_MAKEMASK(8, 0)
46
47#define S_SYS_REVISION _SB_MAKE64(8)
48#define M_SYS_REVISION _SB_MAKEMASK(8, S_SYS_REVISION)
49#define V_SYS_REVISION(x) _SB_MAKEVALUE(x, S_SYS_REVISION)
50#define G_SYS_REVISION(x) _SB_GETVALUE(x, S_SYS_REVISION, M_SYS_REVISION)
51
52#define K_SYS_REVISION_BCM1250_PASS1 0x01
53
54#define K_SYS_REVISION_BCM1250_PASS2 0x03
55#define K_SYS_REVISION_BCM1250_A1 0x03 /* Pass 2.0 WB */
56#define K_SYS_REVISION_BCM1250_A2 0x04 /* Pass 2.0 FC */
57#define K_SYS_REVISION_BCM1250_A3 0x05 /* Pass 2.1 FC */
58#define K_SYS_REVISION_BCM1250_A4 0x06 /* Pass 2.1 WB */
59#define K_SYS_REVISION_BCM1250_A6 0x07 /* OR 0x04 (A2) w/WID != 0 */
60#define K_SYS_REVISION_BCM1250_A8 0x0b /* A8/A10 */
61#define K_SYS_REVISION_BCM1250_A9 0x08
62#define K_SYS_REVISION_BCM1250_A10 K_SYS_REVISION_BCM1250_A8
63
64#define K_SYS_REVISION_BCM1250_PASS2_2 0x10
65#define K_SYS_REVISION_BCM1250_B0 K_SYS_REVISION_BCM1250_B1
66#define K_SYS_REVISION_BCM1250_B1 0x10
67#define K_SYS_REVISION_BCM1250_B2 0x11
68
69#define K_SYS_REVISION_BCM1250_C0 0x20
70#define K_SYS_REVISION_BCM1250_C1 0x21
71#define K_SYS_REVISION_BCM1250_C2 0x22
72#define K_SYS_REVISION_BCM1250_C3 0x23
73
74#if SIBYTE_HDR_FEATURE_CHIP(1250)
75/* XXX: discourage people from using these constants. */
76#define K_SYS_REVISION_PASS1 K_SYS_REVISION_BCM1250_PASS1
77#define K_SYS_REVISION_PASS2 K_SYS_REVISION_BCM1250_PASS2
78#define K_SYS_REVISION_PASS2_2 K_SYS_REVISION_BCM1250_PASS2_2
79#define K_SYS_REVISION_PASS3 K_SYS_REVISION_BCM1250_PASS3
80#define K_SYS_REVISION_BCM1250_PASS3 K_SYS_REVISION_BCM1250_C0
81#endif /* 1250 */
82
83#define K_SYS_REVISION_BCM112x_A1 0x20
84#define K_SYS_REVISION_BCM112x_A2 0x21
85#define K_SYS_REVISION_BCM112x_A3 0x22
86#define K_SYS_REVISION_BCM112x_A4 0x23
87#define K_SYS_REVISION_BCM112x_B0 0x30
88
89#define K_SYS_REVISION_BCM1480_S0 0x01
90#define K_SYS_REVISION_BCM1480_A1 0x02
91#define K_SYS_REVISION_BCM1480_A2 0x03
92#define K_SYS_REVISION_BCM1480_A3 0x04
93#define K_SYS_REVISION_BCM1480_B0 0x11
94
95/*Cache size - 23:20 of revision register*/
96#define S_SYS_L2C_SIZE _SB_MAKE64(20)
97#define M_SYS_L2C_SIZE _SB_MAKEMASK(4, S_SYS_L2C_SIZE)
98#define V_SYS_L2C_SIZE(x) _SB_MAKEVALUE(x, S_SYS_L2C_SIZE)
99#define G_SYS_L2C_SIZE(x) _SB_GETVALUE(x, S_SYS_L2C_SIZE, M_SYS_L2C_SIZE)
100
101#define K_SYS_L2C_SIZE_1MB 0
102#define K_SYS_L2C_SIZE_512KB 5
103#define K_SYS_L2C_SIZE_256KB 2
104#define K_SYS_L2C_SIZE_128KB 1
105
106#define K_SYS_L2C_SIZE_BCM1250 K_SYS_L2C_SIZE_512KB
107#define K_SYS_L2C_SIZE_BCM1125 K_SYS_L2C_SIZE_256KB
108#define K_SYS_L2C_SIZE_BCM1122 K_SYS_L2C_SIZE_128KB
109
110
111/* Number of CPU cores, bits 27:24 of revision register*/
112#define S_SYS_NUM_CPUS _SB_MAKE64(24)
113#define M_SYS_NUM_CPUS _SB_MAKEMASK(4, S_SYS_NUM_CPUS)
114#define V_SYS_NUM_CPUS(x) _SB_MAKEVALUE(x, S_SYS_NUM_CPUS)
115#define G_SYS_NUM_CPUS(x) _SB_GETVALUE(x, S_SYS_NUM_CPUS, M_SYS_NUM_CPUS)
116
117
118/* XXX: discourage people from using these constants. */
119#define S_SYS_PART _SB_MAKE64(16)
120#define M_SYS_PART _SB_MAKEMASK(16, S_SYS_PART)
121#define V_SYS_PART(x) _SB_MAKEVALUE(x, S_SYS_PART)
122#define G_SYS_PART(x) _SB_GETVALUE(x, S_SYS_PART, M_SYS_PART)
123
124/* XXX: discourage people from using these constants. */
125#define K_SYS_PART_SB1250 0x1250
126#define K_SYS_PART_BCM1120 0x1121
127#define K_SYS_PART_BCM1125 0x1123
128#define K_SYS_PART_BCM1125H 0x1124
129#define K_SYS_PART_BCM1122 0x1113
130
131
132/* The "peripheral set" (SOC type) is the low 4 bits of the "part" field. */
133#define S_SYS_SOC_TYPE _SB_MAKE64(16)
134#define M_SYS_SOC_TYPE _SB_MAKEMASK(4, S_SYS_SOC_TYPE)
135#define V_SYS_SOC_TYPE(x) _SB_MAKEVALUE(x, S_SYS_SOC_TYPE)
136#define G_SYS_SOC_TYPE(x) _SB_GETVALUE(x, S_SYS_SOC_TYPE, M_SYS_SOC_TYPE)
137
138#define K_SYS_SOC_TYPE_BCM1250 0x0
139#define K_SYS_SOC_TYPE_BCM1120 0x1
140#define K_SYS_SOC_TYPE_BCM1250_ALT 0x2 /* 1250pass2 w/ 1/4 L2. */
141#define K_SYS_SOC_TYPE_BCM1125 0x3
142#define K_SYS_SOC_TYPE_BCM1125H 0x4
143#define K_SYS_SOC_TYPE_BCM1250_ALT2 0x5 /* 1250pass2 w/ 1/2 L2. */
144#define K_SYS_SOC_TYPE_BCM1x80 0x6
145#define K_SYS_SOC_TYPE_BCM1x55 0x7
146
147/*
148 * Calculate correct SOC type given a copy of system revision register.
149 *
150 * (For the assembler version, sysrev and dest may be the same register.
151 * Also, it clobbers AT.)
152 */
153#ifdef __ASSEMBLER__
154#define SYS_SOC_TYPE(dest, sysrev) \
155 .set push ; \
156 .set reorder ; \
157 dsrl dest, sysrev, S_SYS_SOC_TYPE ; \
158 andi dest, dest, (M_SYS_SOC_TYPE >> S_SYS_SOC_TYPE); \
159 beq dest, K_SYS_SOC_TYPE_BCM1250_ALT, 991f ; \
160 beq dest, K_SYS_SOC_TYPE_BCM1250_ALT2, 991f ; \
161 b 992f ; \
162991: li dest, K_SYS_SOC_TYPE_BCM1250 ; \
163992: \
164 .set pop
165#else
166#define SYS_SOC_TYPE(sysrev) \
167 ((G_SYS_SOC_TYPE(sysrev) == K_SYS_SOC_TYPE_BCM1250_ALT \
168 || G_SYS_SOC_TYPE(sysrev) == K_SYS_SOC_TYPE_BCM1250_ALT2) \
169 ? K_SYS_SOC_TYPE_BCM1250 : G_SYS_SOC_TYPE(sysrev))
170#endif
171
172#define S_SYS_WID _SB_MAKE64(32)
173#define M_SYS_WID _SB_MAKEMASK(32, S_SYS_WID)
174#define V_SYS_WID(x) _SB_MAKEVALUE(x, S_SYS_WID)
175#define G_SYS_WID(x) _SB_GETVALUE(x, S_SYS_WID, M_SYS_WID)
176
177/*
178 * System Manufacturing Register
179 * Register: SCD_SYSTEM_MANUF
180 */
181
182#if SIBYTE_HDR_FEATURE_1250_112x
183/* Wafer ID: bits 31:0 */
184#define S_SYS_WAFERID1_200 _SB_MAKE64(0)
185#define M_SYS_WAFERID1_200 _SB_MAKEMASK(32, S_SYS_WAFERID1_200)
186#define V_SYS_WAFERID1_200(x) _SB_MAKEVALUE(x, S_SYS_WAFERID1_200)
187#define G_SYS_WAFERID1_200(x) _SB_GETVALUE(x, S_SYS_WAFERID1_200, M_SYS_WAFERID1_200)
188
189#define S_SYS_BIN _SB_MAKE64(32)
190#define M_SYS_BIN _SB_MAKEMASK(4, S_SYS_BIN)
191#define V_SYS_BIN(x) _SB_MAKEVALUE(x, S_SYS_BIN)
192#define G_SYS_BIN(x) _SB_GETVALUE(x, S_SYS_BIN, M_SYS_BIN)
193
194/* Wafer ID: bits 39:36 */
195#define S_SYS_WAFERID2_200 _SB_MAKE64(36)
196#define M_SYS_WAFERID2_200 _SB_MAKEMASK(4, S_SYS_WAFERID2_200)
197#define V_SYS_WAFERID2_200(x) _SB_MAKEVALUE(x, S_SYS_WAFERID2_200)
198#define G_SYS_WAFERID2_200(x) _SB_GETVALUE(x, S_SYS_WAFERID2_200, M_SYS_WAFERID2_200)
199
200/* Wafer ID: bits 39:0 */
201#define S_SYS_WAFERID_300 _SB_MAKE64(0)
202#define M_SYS_WAFERID_300 _SB_MAKEMASK(40, S_SYS_WAFERID_300)
203#define V_SYS_WAFERID_300(x) _SB_MAKEVALUE(x, S_SYS_WAFERID_300)
204#define G_SYS_WAFERID_300(x) _SB_GETVALUE(x, S_SYS_WAFERID_300, M_SYS_WAFERID_300)
205
206#define S_SYS_XPOS _SB_MAKE64(40)
207#define M_SYS_XPOS _SB_MAKEMASK(6, S_SYS_XPOS)
208#define V_SYS_XPOS(x) _SB_MAKEVALUE(x, S_SYS_XPOS)
209#define G_SYS_XPOS(x) _SB_GETVALUE(x, S_SYS_XPOS, M_SYS_XPOS)
210
211#define S_SYS_YPOS _SB_MAKE64(46)
212#define M_SYS_YPOS _SB_MAKEMASK(6, S_SYS_YPOS)
213#define V_SYS_YPOS(x) _SB_MAKEVALUE(x, S_SYS_YPOS)
214#define G_SYS_YPOS(x) _SB_GETVALUE(x, S_SYS_YPOS, M_SYS_YPOS)
215#endif
216
217
218/*
219 * System Config Register (Table 4-2)
220 * Register: SCD_SYSTEM_CFG
221 */
222
223#if SIBYTE_HDR_FEATURE_1250_112x
224#define M_SYS_LDT_PLL_BYP _SB_MAKEMASK1(3)
225#define M_SYS_PCI_SYNC_TEST_MODE _SB_MAKEMASK1(4)
226#define M_SYS_IOB0_DIV _SB_MAKEMASK1(5)
227#define M_SYS_IOB1_DIV _SB_MAKEMASK1(6)
228
229#define S_SYS_PLL_DIV _SB_MAKE64(7)
230#define M_SYS_PLL_DIV _SB_MAKEMASK(5, S_SYS_PLL_DIV)
231#define V_SYS_PLL_DIV(x) _SB_MAKEVALUE(x, S_SYS_PLL_DIV)
232#define G_SYS_PLL_DIV(x) _SB_GETVALUE(x, S_SYS_PLL_DIV, M_SYS_PLL_DIV)
233
234#define M_SYS_SER0_ENABLE _SB_MAKEMASK1(12)
235#define M_SYS_SER0_RSTB_EN _SB_MAKEMASK1(13)
236#define M_SYS_SER1_ENABLE _SB_MAKEMASK1(14)
237#define M_SYS_SER1_RSTB_EN _SB_MAKEMASK1(15)
238#define M_SYS_PCMCIA_ENABLE _SB_MAKEMASK1(16)
239
240#define S_SYS_BOOT_MODE _SB_MAKE64(17)
241#define M_SYS_BOOT_MODE _SB_MAKEMASK(2, S_SYS_BOOT_MODE)
242#define V_SYS_BOOT_MODE(x) _SB_MAKEVALUE(x, S_SYS_BOOT_MODE)
243#define G_SYS_BOOT_MODE(x) _SB_GETVALUE(x, S_SYS_BOOT_MODE, M_SYS_BOOT_MODE)
244#define K_SYS_BOOT_MODE_ROM32 0
245#define K_SYS_BOOT_MODE_ROM8 1
246#define K_SYS_BOOT_MODE_SMBUS_SMALL 2
247#define K_SYS_BOOT_MODE_SMBUS_BIG 3
248
249#define M_SYS_PCI_HOST _SB_MAKEMASK1(19)
250#define M_SYS_PCI_ARBITER _SB_MAKEMASK1(20)
251#define M_SYS_SOUTH_ON_LDT _SB_MAKEMASK1(21)
252#define M_SYS_BIG_ENDIAN _SB_MAKEMASK1(22)
253#define M_SYS_GENCLK_EN _SB_MAKEMASK1(23)
254#define M_SYS_LDT_TEST_EN _SB_MAKEMASK1(24)
255#define M_SYS_GEN_PARITY_EN _SB_MAKEMASK1(25)
256
257#define S_SYS_CONFIG 26
258#define M_SYS_CONFIG _SB_MAKEMASK(6, S_SYS_CONFIG)
259#define V_SYS_CONFIG(x) _SB_MAKEVALUE(x, S_SYS_CONFIG)
260#define G_SYS_CONFIG(x) _SB_GETVALUE(x, S_SYS_CONFIG, M_SYS_CONFIG)
261
262/* The following bits are writeable by JTAG only. */
263
264#define M_SYS_CLKSTOP _SB_MAKEMASK1(32)
265#define M_SYS_CLKSTEP _SB_MAKEMASK1(33)
266
267#define S_SYS_CLKCOUNT 34
268#define M_SYS_CLKCOUNT _SB_MAKEMASK(8, S_SYS_CLKCOUNT)
269#define V_SYS_CLKCOUNT(x) _SB_MAKEVALUE(x, S_SYS_CLKCOUNT)
270#define G_SYS_CLKCOUNT(x) _SB_GETVALUE(x, S_SYS_CLKCOUNT, M_SYS_CLKCOUNT)
271
272#define M_SYS_PLL_BYPASS _SB_MAKEMASK1(42)
273
274#define S_SYS_PLL_IREF 43
275#define M_SYS_PLL_IREF _SB_MAKEMASK(2, S_SYS_PLL_IREF)
276
277#define S_SYS_PLL_VCO 45
278#define M_SYS_PLL_VCO _SB_MAKEMASK(2, S_SYS_PLL_VCO)
279
280#define S_SYS_PLL_VREG 47
281#define M_SYS_PLL_VREG _SB_MAKEMASK(2, S_SYS_PLL_VREG)
282
283#define M_SYS_MEM_RESET _SB_MAKEMASK1(49)
284#define M_SYS_L2C_RESET _SB_MAKEMASK1(50)
285#define M_SYS_IO_RESET_0 _SB_MAKEMASK1(51)
286#define M_SYS_IO_RESET_1 _SB_MAKEMASK1(52)
287#define M_SYS_SCD_RESET _SB_MAKEMASK1(53)
288
289/* End of bits writable by JTAG only. */
290
291#define M_SYS_CPU_RESET_0 _SB_MAKEMASK1(54)
292#define M_SYS_CPU_RESET_1 _SB_MAKEMASK1(55)
293
294#define M_SYS_UNICPU0 _SB_MAKEMASK1(56)
295#define M_SYS_UNICPU1 _SB_MAKEMASK1(57)
296
297#define M_SYS_SB_SOFTRES _SB_MAKEMASK1(58)
298#define M_SYS_EXT_RESET _SB_MAKEMASK1(59)
299#define M_SYS_SYSTEM_RESET _SB_MAKEMASK1(60)
300
301#define M_SYS_MISR_MODE _SB_MAKEMASK1(61)
302#define M_SYS_MISR_RESET _SB_MAKEMASK1(62)
303
304#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1)
305#define M_SYS_SW_FLAG _SB_MAKEMASK1(63)
306#endif /* 1250 PASS2 || 112x PASS1 */
307
308#endif
309
310
311/*
312 * Mailbox Registers (Table 4-3)
313 * Registers: SCD_MBOX_CPU_x
314 */
315
316#define S_MBOX_INT_3 0
317#define M_MBOX_INT_3 _SB_MAKEMASK(16, S_MBOX_INT_3)
318#define S_MBOX_INT_2 16
319#define M_MBOX_INT_2 _SB_MAKEMASK(16, S_MBOX_INT_2)
320#define S_MBOX_INT_1 32
321#define M_MBOX_INT_1 _SB_MAKEMASK(16, S_MBOX_INT_1)
322#define S_MBOX_INT_0 48
323#define M_MBOX_INT_0 _SB_MAKEMASK(16, S_MBOX_INT_0)
324
325/*
326 * Watchdog Registers (Table 4-8) (Table 4-9) (Table 4-10)
327 * Registers: SCD_WDOG_INIT_CNT_x
328 */
329
330#define V_SCD_WDOG_FREQ 1000000
331
332#define S_SCD_WDOG_INIT 0
333#define M_SCD_WDOG_INIT _SB_MAKEMASK(23, S_SCD_WDOG_INIT)
334
335#define S_SCD_WDOG_CNT 0
336#define M_SCD_WDOG_CNT _SB_MAKEMASK(23, S_SCD_WDOG_CNT)
337
338#define S_SCD_WDOG_ENABLE 0
339#define M_SCD_WDOG_ENABLE _SB_MAKEMASK1(S_SCD_WDOG_ENABLE)
340
341#define S_SCD_WDOG_RESET_TYPE 2
342#define M_SCD_WDOG_RESET_TYPE _SB_MAKEMASK(3, S_SCD_WDOG_RESET_TYPE)
343#define V_SCD_WDOG_RESET_TYPE(x) _SB_MAKEVALUE(x, S_SCD_WDOG_RESET_TYPE)
344#define G_SCD_WDOG_RESET_TYPE(x) _SB_GETVALUE(x, S_SCD_WDOG_RESET_TYPE, M_SCD_WDOG_RESET_TYPE)
345
346#define K_SCD_WDOG_RESET_FULL 0 /* actually, (x & 1) == 0 */
347#define K_SCD_WDOG_RESET_SOFT 1
348#define K_SCD_WDOG_RESET_CPU0 3
349#define K_SCD_WDOG_RESET_CPU1 5
350#define K_SCD_WDOG_RESET_BOTH_CPUS 7
351
352/* This feature is present in 1250 C0 and later, but *not* in 112x A revs. */
353#if SIBYTE_HDR_FEATURE(1250, PASS3)
354#define S_SCD_WDOG_HAS_RESET 8
355#define M_SCD_WDOG_HAS_RESET _SB_MAKEMASK1(S_SCD_WDOG_HAS_RESET)
356#endif
357
358
359/*
360 * Timer Registers (Table 4-11) (Table 4-12) (Table 4-13)
361 */
362
363#define V_SCD_TIMER_FREQ 1000000
364
365#define S_SCD_TIMER_INIT 0
366#define M_SCD_TIMER_INIT _SB_MAKEMASK(23, S_SCD_TIMER_INIT)
367#define V_SCD_TIMER_INIT(x) _SB_MAKEVALUE(x, S_SCD_TIMER_INIT)
368#define G_SCD_TIMER_INIT(x) _SB_GETVALUE(x, S_SCD_TIMER_INIT, M_SCD_TIMER_INIT)
369
370#define V_SCD_TIMER_WIDTH 23
371#define S_SCD_TIMER_CNT 0
372#define M_SCD_TIMER_CNT _SB_MAKEMASK(V_SCD_TIMER_WIDTH, S_SCD_TIMER_CNT)
373#define V_SCD_TIMER_CNT(x) _SB_MAKEVALUE(x, S_SCD_TIMER_CNT)
374#define G_SCD_TIMER_CNT(x) _SB_GETVALUE(x, S_SCD_TIMER_CNT, M_SCD_TIMER_CNT)
375
376#define M_SCD_TIMER_ENABLE _SB_MAKEMASK1(0)
377#define M_SCD_TIMER_MODE _SB_MAKEMASK1(1)
378#define M_SCD_TIMER_MODE_CONTINUOUS M_SCD_TIMER_MODE
379
380/*
381 * System Performance Counters
382 */
383
384#define S_SPC_CFG_SRC0 0
385#define M_SPC_CFG_SRC0 _SB_MAKEMASK(8, S_SPC_CFG_SRC0)
386#define V_SPC_CFG_SRC0(x) _SB_MAKEVALUE(x, S_SPC_CFG_SRC0)
387#define G_SPC_CFG_SRC0(x) _SB_GETVALUE(x, S_SPC_CFG_SRC0, M_SPC_CFG_SRC0)
388
389#define S_SPC_CFG_SRC1 8
390#define M_SPC_CFG_SRC1 _SB_MAKEMASK(8, S_SPC_CFG_SRC1)
391#define V_SPC_CFG_SRC1(x) _SB_MAKEVALUE(x, S_SPC_CFG_SRC1)
392#define G_SPC_CFG_SRC1(x) _SB_GETVALUE(x, S_SPC_CFG_SRC1, M_SPC_CFG_SRC1)
393
394#define S_SPC_CFG_SRC2 16
395#define M_SPC_CFG_SRC2 _SB_MAKEMASK(8, S_SPC_CFG_SRC2)
396#define V_SPC_CFG_SRC2(x) _SB_MAKEVALUE(x, S_SPC_CFG_SRC2)
397#define G_SPC_CFG_SRC2(x) _SB_GETVALUE(x, S_SPC_CFG_SRC2, M_SPC_CFG_SRC2)
398
399#define S_SPC_CFG_SRC3 24
400#define M_SPC_CFG_SRC3 _SB_MAKEMASK(8, S_SPC_CFG_SRC3)
401#define V_SPC_CFG_SRC3(x) _SB_MAKEVALUE(x, S_SPC_CFG_SRC3)
402#define G_SPC_CFG_SRC3(x) _SB_GETVALUE(x, S_SPC_CFG_SRC3, M_SPC_CFG_SRC3)
403
404#if SIBYTE_HDR_FEATURE_1250_112x
405#define M_SPC_CFG_CLEAR _SB_MAKEMASK1(32)
406#define M_SPC_CFG_ENABLE _SB_MAKEMASK1(33)
407#endif
408
409
410/*
411 * Bus Watcher
412 */
413
414#define S_SCD_BERR_TID 8
415#define M_SCD_BERR_TID _SB_MAKEMASK(10, S_SCD_BERR_TID)
416#define V_SCD_BERR_TID(x) _SB_MAKEVALUE(x, S_SCD_BERR_TID)
417#define G_SCD_BERR_TID(x) _SB_GETVALUE(x, S_SCD_BERR_TID, M_SCD_BERR_TID)
418
419#define S_SCD_BERR_RID 18
420#define M_SCD_BERR_RID _SB_MAKEMASK(4, S_SCD_BERR_RID)
421#define V_SCD_BERR_RID(x) _SB_MAKEVALUE(x, S_SCD_BERR_RID)
422#define G_SCD_BERR_RID(x) _SB_GETVALUE(x, S_SCD_BERR_RID, M_SCD_BERR_RID)
423
424#define S_SCD_BERR_DCODE 22
425#define M_SCD_BERR_DCODE _SB_MAKEMASK(3, S_SCD_BERR_DCODE)
426#define V_SCD_BERR_DCODE(x) _SB_MAKEVALUE(x, S_SCD_BERR_DCODE)
427#define G_SCD_BERR_DCODE(x) _SB_GETVALUE(x, S_SCD_BERR_DCODE, M_SCD_BERR_DCODE)
428
429#define M_SCD_BERR_MULTERRS _SB_MAKEMASK1(30)
430
431
432#define S_SCD_L2ECC_CORR_D 0
433#define M_SCD_L2ECC_CORR_D _SB_MAKEMASK(8, S_SCD_L2ECC_CORR_D)
434#define V_SCD_L2ECC_CORR_D(x) _SB_MAKEVALUE(x, S_SCD_L2ECC_CORR_D)
435#define G_SCD_L2ECC_CORR_D(x) _SB_GETVALUE(x, S_SCD_L2ECC_CORR_D, M_SCD_L2ECC_CORR_D)
436
437#define S_SCD_L2ECC_BAD_D 8
438#define M_SCD_L2ECC_BAD_D _SB_MAKEMASK(8, S_SCD_L2ECC_BAD_D)
439#define V_SCD_L2ECC_BAD_D(x) _SB_MAKEVALUE(x, S_SCD_L2ECC_BAD_D)
440#define G_SCD_L2ECC_BAD_D(x) _SB_GETVALUE(x, S_SCD_L2ECC_BAD_D, M_SCD_L2ECC_BAD_D)
441
442#define S_SCD_L2ECC_CORR_T 16
443#define M_SCD_L2ECC_CORR_T _SB_MAKEMASK(8, S_SCD_L2ECC_CORR_T)
444#define V_SCD_L2ECC_CORR_T(x) _SB_MAKEVALUE(x, S_SCD_L2ECC_CORR_T)
445#define G_SCD_L2ECC_CORR_T(x) _SB_GETVALUE(x, S_SCD_L2ECC_CORR_T, M_SCD_L2ECC_CORR_T)
446
447#define S_SCD_L2ECC_BAD_T 24
448#define M_SCD_L2ECC_BAD_T _SB_MAKEMASK(8, S_SCD_L2ECC_BAD_T)
449#define V_SCD_L2ECC_BAD_T(x) _SB_MAKEVALUE(x, S_SCD_L2ECC_BAD_T)
450#define G_SCD_L2ECC_BAD_T(x) _SB_GETVALUE(x, S_SCD_L2ECC_BAD_T, M_SCD_L2ECC_BAD_T)
451
452#define S_SCD_MEM_ECC_CORR 0
453#define M_SCD_MEM_ECC_CORR _SB_MAKEMASK(8, S_SCD_MEM_ECC_CORR)
454#define V_SCD_MEM_ECC_CORR(x) _SB_MAKEVALUE(x, S_SCD_MEM_ECC_CORR)
455#define G_SCD_MEM_ECC_CORR(x) _SB_GETVALUE(x, S_SCD_MEM_ECC_CORR, M_SCD_MEM_ECC_CORR)
456
457#define S_SCD_MEM_ECC_BAD 8
458#define M_SCD_MEM_ECC_BAD _SB_MAKEMASK(8, S_SCD_MEM_ECC_BAD)
459#define V_SCD_MEM_ECC_BAD(x) _SB_MAKEVALUE(x, S_SCD_MEM_ECC_BAD)
460#define G_SCD_MEM_ECC_BAD(x) _SB_GETVALUE(x, S_SCD_MEM_ECC_BAD, M_SCD_MEM_ECC_BAD)
461
462#define S_SCD_MEM_BUSERR 16
463#define M_SCD_MEM_BUSERR _SB_MAKEMASK(8, S_SCD_MEM_BUSERR)
464#define V_SCD_MEM_BUSERR(x) _SB_MAKEVALUE(x, S_SCD_MEM_BUSERR)
465#define G_SCD_MEM_BUSERR(x) _SB_GETVALUE(x, S_SCD_MEM_BUSERR, M_SCD_MEM_BUSERR)
466
467
468/*
469 * Address Trap Registers
470 */
471
472#if SIBYTE_HDR_FEATURE_1250_112x
473#define M_ATRAP_INDEX _SB_MAKEMASK(4, 0)
474#define M_ATRAP_ADDRESS _SB_MAKEMASK(40, 0)
475
476#define S_ATRAP_CFG_CNT 0
477#define M_ATRAP_CFG_CNT _SB_MAKEMASK(3, S_ATRAP_CFG_CNT)
478#define V_ATRAP_CFG_CNT(x) _SB_MAKEVALUE(x, S_ATRAP_CFG_CNT)
479#define G_ATRAP_CFG_CNT(x) _SB_GETVALUE(x, S_ATRAP_CFG_CNT, M_ATRAP_CFG_CNT)
480
481#define M_ATRAP_CFG_WRITE _SB_MAKEMASK1(3)
482#define M_ATRAP_CFG_ALL _SB_MAKEMASK1(4)
483#define M_ATRAP_CFG_INV _SB_MAKEMASK1(5)
484#define M_ATRAP_CFG_USESRC _SB_MAKEMASK1(6)
485#define M_ATRAP_CFG_SRCINV _SB_MAKEMASK1(7)
486
487#define S_ATRAP_CFG_AGENTID 8
488#define M_ATRAP_CFG_AGENTID _SB_MAKEMASK(4, S_ATRAP_CFG_AGENTID)
489#define V_ATRAP_CFG_AGENTID(x) _SB_MAKEVALUE(x, S_ATRAP_CFG_AGENTID)
490#define G_ATRAP_CFG_AGENTID(x) _SB_GETVALUE(x, S_ATRAP_CFG_AGENTID, M_ATRAP_CFG_AGENTID)
491
492#define K_BUS_AGENT_CPU0 0
493#define K_BUS_AGENT_CPU1 1
494#define K_BUS_AGENT_IOB0 2
495#define K_BUS_AGENT_IOB1 3
496#define K_BUS_AGENT_SCD 4
497#define K_BUS_AGENT_L2C 6
498#define K_BUS_AGENT_MC 7
499
500#define S_ATRAP_CFG_CATTR 12
501#define M_ATRAP_CFG_CATTR _SB_MAKEMASK(3, S_ATRAP_CFG_CATTR)
502#define V_ATRAP_CFG_CATTR(x) _SB_MAKEVALUE(x, S_ATRAP_CFG_CATTR)
503#define G_ATRAP_CFG_CATTR(x) _SB_GETVALUE(x, S_ATRAP_CFG_CATTR, M_ATRAP_CFG_CATTR)
504
505#define K_ATRAP_CFG_CATTR_IGNORE 0
506#define K_ATRAP_CFG_CATTR_UNC 1
507#define K_ATRAP_CFG_CATTR_CACHEABLE 2
508#define K_ATRAP_CFG_CATTR_NONCOH 3
509#define K_ATRAP_CFG_CATTR_COHERENT 4
510#define K_ATRAP_CFG_CATTR_NOTUNC 5
511#define K_ATRAP_CFG_CATTR_NOTNONCOH 6
512#define K_ATRAP_CFG_CATTR_NOTCOHERENT 7
513
514#endif /* 1250/112x */
515
516/*
517 * Trace Buffer Config register
518 */
519
520#define M_SCD_TRACE_CFG_RESET _SB_MAKEMASK1(0)
521#define M_SCD_TRACE_CFG_START_READ _SB_MAKEMASK1(1)
522#define M_SCD_TRACE_CFG_START _SB_MAKEMASK1(2)
523#define M_SCD_TRACE_CFG_STOP _SB_MAKEMASK1(3)
524#define M_SCD_TRACE_CFG_FREEZE _SB_MAKEMASK1(4)
525#define M_SCD_TRACE_CFG_FREEZE_FULL _SB_MAKEMASK1(5)
526#define M_SCD_TRACE_CFG_DEBUG_FULL _SB_MAKEMASK1(6)
527#define M_SCD_TRACE_CFG_FULL _SB_MAKEMASK1(7)
528#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
529#define M_SCD_TRACE_CFG_FORCECNT _SB_MAKEMASK1(8)
530#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
531
532/*
533 * This field is the same on the 1250/112x and 1480, just located in
534 * a slightly different place in the register.
535 */
536#if SIBYTE_HDR_FEATURE_1250_112x
537#define S_SCD_TRACE_CFG_CUR_ADDR 10
538#else
539#if SIBYTE_HDR_FEATURE_CHIP(1480)
540#define S_SCD_TRACE_CFG_CUR_ADDR 24
541#endif /* 1480 */
542#endif /* 1250/112x */
543
544#define M_SCD_TRACE_CFG_CUR_ADDR _SB_MAKEMASK(8, S_SCD_TRACE_CFG_CUR_ADDR)
545#define V_SCD_TRACE_CFG_CUR_ADDR(x) _SB_MAKEVALUE(x, S_SCD_TRACE_CFG_CUR_ADDR)
546#define G_SCD_TRACE_CFG_CUR_ADDR(x) _SB_GETVALUE(x, S_SCD_TRACE_CFG_CUR_ADDR, M_SCD_TRACE_CFG_CUR_ADDR)
547
548/*
549 * Trace Event registers
550 */
551
552#define S_SCD_TREVT_ADDR_MATCH 0
553#define M_SCD_TREVT_ADDR_MATCH _SB_MAKEMASK(4, S_SCD_TREVT_ADDR_MATCH)
554#define V_SCD_TREVT_ADDR_MATCH(x) _SB_MAKEVALUE(x, S_SCD_TREVT_ADDR_MATCH)
555#define G_SCD_TREVT_ADDR_MATCH(x) _SB_GETVALUE(x, S_SCD_TREVT_ADDR_MATCH, M_SCD_TREVT_ADDR_MATCH)
556
557#define M_SCD_TREVT_REQID_MATCH _SB_MAKEMASK1(4)
558#define M_SCD_TREVT_DATAID_MATCH _SB_MAKEMASK1(5)
559#define M_SCD_TREVT_RESPID_MATCH _SB_MAKEMASK1(6)
560#define M_SCD_TREVT_INTERRUPT _SB_MAKEMASK1(7)
561#define M_SCD_TREVT_DEBUG_PIN _SB_MAKEMASK1(9)
562#define M_SCD_TREVT_WRITE _SB_MAKEMASK1(10)
563#define M_SCD_TREVT_READ _SB_MAKEMASK1(11)
564
565#define S_SCD_TREVT_REQID 12
566#define M_SCD_TREVT_REQID _SB_MAKEMASK(4, S_SCD_TREVT_REQID)
567#define V_SCD_TREVT_REQID(x) _SB_MAKEVALUE(x, S_SCD_TREVT_REQID)
568#define G_SCD_TREVT_REQID(x) _SB_GETVALUE(x, S_SCD_TREVT_REQID, M_SCD_TREVT_REQID)
569
570#define S_SCD_TREVT_RESPID 16
571#define M_SCD_TREVT_RESPID _SB_MAKEMASK(4, S_SCD_TREVT_RESPID)
572#define V_SCD_TREVT_RESPID(x) _SB_MAKEVALUE(x, S_SCD_TREVT_RESPID)
573#define G_SCD_TREVT_RESPID(x) _SB_GETVALUE(x, S_SCD_TREVT_RESPID, M_SCD_TREVT_RESPID)
574
575#define S_SCD_TREVT_DATAID 20
576#define M_SCD_TREVT_DATAID _SB_MAKEMASK(4, S_SCD_TREVT_DATAID)
577#define V_SCD_TREVT_DATAID(x) _SB_MAKEVALUE(x, S_SCD_TREVT_DATAID)
578#define G_SCD_TREVT_DATAID(x) _SB_GETVALUE(x, S_SCD_TREVT_DATAID, M_SCD_TREVT_DATID)
579
580#define S_SCD_TREVT_COUNT 24
581#define M_SCD_TREVT_COUNT _SB_MAKEMASK(8, S_SCD_TREVT_COUNT)
582#define V_SCD_TREVT_COUNT(x) _SB_MAKEVALUE(x, S_SCD_TREVT_COUNT)
583#define G_SCD_TREVT_COUNT(x) _SB_GETVALUE(x, S_SCD_TREVT_COUNT, M_SCD_TREVT_COUNT)
584
585/*
586 * Trace Sequence registers
587 */
588
589#define S_SCD_TRSEQ_EVENT4 0
590#define M_SCD_TRSEQ_EVENT4 _SB_MAKEMASK(4, S_SCD_TRSEQ_EVENT4)
591#define V_SCD_TRSEQ_EVENT4(x) _SB_MAKEVALUE(x, S_SCD_TRSEQ_EVENT4)
592#define G_SCD_TRSEQ_EVENT4(x) _SB_GETVALUE(x, S_SCD_TRSEQ_EVENT4, M_SCD_TRSEQ_EVENT4)
593
594#define S_SCD_TRSEQ_EVENT3 4
595#define M_SCD_TRSEQ_EVENT3 _SB_MAKEMASK(4, S_SCD_TRSEQ_EVENT3)
596#define V_SCD_TRSEQ_EVENT3(x) _SB_MAKEVALUE(x, S_SCD_TRSEQ_EVENT3)
597#define G_SCD_TRSEQ_EVENT3(x) _SB_GETVALUE(x, S_SCD_TRSEQ_EVENT3, M_SCD_TRSEQ_EVENT3)
598
599#define S_SCD_TRSEQ_EVENT2 8
600#define M_SCD_TRSEQ_EVENT2 _SB_MAKEMASK(4, S_SCD_TRSEQ_EVENT2)
601#define V_SCD_TRSEQ_EVENT2(x) _SB_MAKEVALUE(x, S_SCD_TRSEQ_EVENT2)
602#define G_SCD_TRSEQ_EVENT2(x) _SB_GETVALUE(x, S_SCD_TRSEQ_EVENT2, M_SCD_TRSEQ_EVENT2)
603
604#define S_SCD_TRSEQ_EVENT1 12
605#define M_SCD_TRSEQ_EVENT1 _SB_MAKEMASK(4, S_SCD_TRSEQ_EVENT1)
606#define V_SCD_TRSEQ_EVENT1(x) _SB_MAKEVALUE(x, S_SCD_TRSEQ_EVENT1)
607#define G_SCD_TRSEQ_EVENT1(x) _SB_GETVALUE(x, S_SCD_TRSEQ_EVENT1, M_SCD_TRSEQ_EVENT1)
608
609#define K_SCD_TRSEQ_E0 0
610#define K_SCD_TRSEQ_E1 1
611#define K_SCD_TRSEQ_E2 2
612#define K_SCD_TRSEQ_E3 3
613#define K_SCD_TRSEQ_E0_E1 4
614#define K_SCD_TRSEQ_E1_E2 5
615#define K_SCD_TRSEQ_E2_E3 6
616#define K_SCD_TRSEQ_E0_E1_E2 7
617#define K_SCD_TRSEQ_E0_E1_E2_E3 8
618#define K_SCD_TRSEQ_E0E1 9
619#define K_SCD_TRSEQ_E0E1E2 10
620#define K_SCD_TRSEQ_E0E1E2E3 11
621#define K_SCD_TRSEQ_E0E1_E2 12
622#define K_SCD_TRSEQ_E0E1_E2E3 13
623#define K_SCD_TRSEQ_E0E1_E2_E3 14
624#define K_SCD_TRSEQ_IGNORED 15
625
626#define K_SCD_TRSEQ_TRIGGER_ALL (V_SCD_TRSEQ_EVENT1(K_SCD_TRSEQ_IGNORED) | \
627 V_SCD_TRSEQ_EVENT2(K_SCD_TRSEQ_IGNORED) | \
628 V_SCD_TRSEQ_EVENT3(K_SCD_TRSEQ_IGNORED) | \
629 V_SCD_TRSEQ_EVENT4(K_SCD_TRSEQ_IGNORED))
630
631#define S_SCD_TRSEQ_FUNCTION 16
632#define M_SCD_TRSEQ_FUNCTION _SB_MAKEMASK(4, S_SCD_TRSEQ_FUNCTION)
633#define V_SCD_TRSEQ_FUNCTION(x) _SB_MAKEVALUE(x, S_SCD_TRSEQ_FUNCTION)
634#define G_SCD_TRSEQ_FUNCTION(x) _SB_GETVALUE(x, S_SCD_TRSEQ_FUNCTION, M_SCD_TRSEQ_FUNCTION)
635
636#define K_SCD_TRSEQ_FUNC_NOP 0
637#define K_SCD_TRSEQ_FUNC_START 1
638#define K_SCD_TRSEQ_FUNC_STOP 2
639#define K_SCD_TRSEQ_FUNC_FREEZE 3
640
641#define V_SCD_TRSEQ_FUNC_NOP V_SCD_TRSEQ_FUNCTION(K_SCD_TRSEQ_FUNC_NOP)
642#define V_SCD_TRSEQ_FUNC_START V_SCD_TRSEQ_FUNCTION(K_SCD_TRSEQ_FUNC_START)
643#define V_SCD_TRSEQ_FUNC_STOP V_SCD_TRSEQ_FUNCTION(K_SCD_TRSEQ_FUNC_STOP)
644#define V_SCD_TRSEQ_FUNC_FREEZE V_SCD_TRSEQ_FUNCTION(K_SCD_TRSEQ_FUNC_FREEZE)
645
646#define M_SCD_TRSEQ_ASAMPLE _SB_MAKEMASK1(18)
647#define M_SCD_TRSEQ_DSAMPLE _SB_MAKEMASK1(19)
648#define M_SCD_TRSEQ_DEBUGPIN _SB_MAKEMASK1(20)
649#define M_SCD_TRSEQ_DEBUGCPU _SB_MAKEMASK1(21)
650#define M_SCD_TRSEQ_CLEARUSE _SB_MAKEMASK1(22)
651#define M_SCD_TRSEQ_ALLD_A _SB_MAKEMASK1(23)
652#define M_SCD_TRSEQ_ALL_A _SB_MAKEMASK1(24)
653
654#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_smbus.h b/arch/mips/include/asm/sibyte/sb1250_smbus.h
new file mode 100644
index 000000000000..04769923cf1e
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_smbus.h
@@ -0,0 +1,204 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * SMBUS Constants File: sb1250_smbus.h
5 *
6 * This module contains constants and macros useful for
7 * manipulating the SB1250's SMbus devices.
8 *
9 * SB1250 specification level: 10/21/02
10 * BCM1280 specification level: 11/24/03
11 *
12 *********************************************************************
13 *
14 * Copyright 2000,2001,2002,2003
15 * Broadcom Corporation. All rights reserved.
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
31 ********************************************************************* */
32
33
34#ifndef _SB1250_SMBUS_H
35#define _SB1250_SMBUS_H
36
37#include "sb1250_defs.h"
38
39/*
40 * SMBus Clock Frequency Register (Table 14-2)
41 */
42
43#define S_SMB_FREQ_DIV 0
44#define M_SMB_FREQ_DIV _SB_MAKEMASK(13, S_SMB_FREQ_DIV)
45#define V_SMB_FREQ_DIV(x) _SB_MAKEVALUE(x, S_SMB_FREQ_DIV)
46
47#define K_SMB_FREQ_400KHZ 0x1F
48#define K_SMB_FREQ_100KHZ 0x7D
49#define K_SMB_FREQ_10KHZ 1250
50
51#define S_SMB_CMD 0
52#define M_SMB_CMD _SB_MAKEMASK(8, S_SMB_CMD)
53#define V_SMB_CMD(x) _SB_MAKEVALUE(x, S_SMB_CMD)
54
55/*
56 * SMBus control register (Table 14-4)
57 */
58
59#define M_SMB_ERR_INTR _SB_MAKEMASK1(0)
60#define M_SMB_FINISH_INTR _SB_MAKEMASK1(1)
61
62#define S_SMB_DATA_OUT 4
63#define M_SMB_DATA_OUT _SB_MAKEMASK1(S_SMB_DATA_OUT)
64#define V_SMB_DATA_OUT(x) _SB_MAKEVALUE(x, S_SMB_DATA_OUT)
65
66#define M_SMB_DATA_DIR _SB_MAKEMASK1(5)
67#define M_SMB_DATA_DIR_OUTPUT M_SMB_DATA_DIR
68#define M_SMB_CLK_OUT _SB_MAKEMASK1(6)
69#define M_SMB_DIRECT_ENABLE _SB_MAKEMASK1(7)
70
71/*
72 * SMBus status registers (Table 14-5)
73 */
74
75#define M_SMB_BUSY _SB_MAKEMASK1(0)
76#define M_SMB_ERROR _SB_MAKEMASK1(1)
77#define M_SMB_ERROR_TYPE _SB_MAKEMASK1(2)
78
79#if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
80#define S_SMB_SCL_IN 5
81#define M_SMB_SCL_IN _SB_MAKEMASK1(S_SMB_SCL_IN)
82#define V_SMB_SCL_IN(x) _SB_MAKEVALUE(x, S_SMB_SCL_IN)
83#define G_SMB_SCL_IN(x) _SB_GETVALUE(x, S_SMB_SCL_IN, M_SMB_SCL_IN)
84#endif /* 1250 PASS3 || 112x PASS1 || 1480 */
85
86#define S_SMB_REF 6
87#define M_SMB_REF _SB_MAKEMASK1(S_SMB_REF)
88#define V_SMB_REF(x) _SB_MAKEVALUE(x, S_SMB_REF)
89#define G_SMB_REF(x) _SB_GETVALUE(x, S_SMB_REF, M_SMB_REF)
90
91#define S_SMB_DATA_IN 7
92#define M_SMB_DATA_IN _SB_MAKEMASK1(S_SMB_DATA_IN)
93#define V_SMB_DATA_IN(x) _SB_MAKEVALUE(x, S_SMB_DATA_IN)
94#define G_SMB_DATA_IN(x) _SB_GETVALUE(x, S_SMB_DATA_IN, M_SMB_DATA_IN)
95
96/*
97 * SMBus Start/Command registers (Table 14-9)
98 */
99
100#define S_SMB_ADDR 0
101#define M_SMB_ADDR _SB_MAKEMASK(7, S_SMB_ADDR)
102#define V_SMB_ADDR(x) _SB_MAKEVALUE(x, S_SMB_ADDR)
103#define G_SMB_ADDR(x) _SB_GETVALUE(x, S_SMB_ADDR, M_SMB_ADDR)
104
105#define M_SMB_QDATA _SB_MAKEMASK1(7)
106
107#define S_SMB_TT 8
108#define M_SMB_TT _SB_MAKEMASK(3, S_SMB_TT)
109#define V_SMB_TT(x) _SB_MAKEVALUE(x, S_SMB_TT)
110#define G_SMB_TT(x) _SB_GETVALUE(x, S_SMB_TT, M_SMB_TT)
111
112#define K_SMB_TT_WR1BYTE 0
113#define K_SMB_TT_WR2BYTE 1
114#define K_SMB_TT_WR3BYTE 2
115#define K_SMB_TT_CMD_RD1BYTE 3
116#define K_SMB_TT_CMD_RD2BYTE 4
117#define K_SMB_TT_RD1BYTE 5
118#define K_SMB_TT_QUICKCMD 6
119#define K_SMB_TT_EEPROMREAD 7
120
121#define V_SMB_TT_WR1BYTE V_SMB_TT(K_SMB_TT_WR1BYTE)
122#define V_SMB_TT_WR2BYTE V_SMB_TT(K_SMB_TT_WR2BYTE)
123#define V_SMB_TT_WR3BYTE V_SMB_TT(K_SMB_TT_WR3BYTE)
124#define V_SMB_TT_CMD_RD1BYTE V_SMB_TT(K_SMB_TT_CMD_RD1BYTE)
125#define V_SMB_TT_CMD_RD2BYTE V_SMB_TT(K_SMB_TT_CMD_RD2BYTE)
126#define V_SMB_TT_RD1BYTE V_SMB_TT(K_SMB_TT_RD1BYTE)
127#define V_SMB_TT_QUICKCMD V_SMB_TT(K_SMB_TT_QUICKCMD)
128#define V_SMB_TT_EEPROMREAD V_SMB_TT(K_SMB_TT_EEPROMREAD)
129
130#define M_SMB_PEC _SB_MAKEMASK1(15)
131
132/*
133 * SMBus Data Register (Table 14-6) and SMBus Extra Register (Table 14-7)
134 */
135
136#define S_SMB_LB 0
137#define M_SMB_LB _SB_MAKEMASK(8, S_SMB_LB)
138#define V_SMB_LB(x) _SB_MAKEVALUE(x, S_SMB_LB)
139
140#define S_SMB_MB 8
141#define M_SMB_MB _SB_MAKEMASK(8, S_SMB_MB)
142#define V_SMB_MB(x) _SB_MAKEVALUE(x, S_SMB_MB)
143
144
145/*
146 * SMBus Packet Error Check register (Table 14-8)
147 */
148
149#define S_SPEC_PEC 0
150#define M_SPEC_PEC _SB_MAKEMASK(8, S_SPEC_PEC)
151#define V_SPEC_MB(x) _SB_MAKEVALUE(x, S_SPEC_PEC)
152
153
154#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
155
156#define S_SMB_CMDH 8
157#define M_SMB_CMDH _SB_MAKEMASK(8, S_SMB_CMDH)
158#define V_SMB_CMDH(x) _SB_MAKEVALUE(x, S_SMB_CMDH)
159
160#define M_SMB_EXTEND _SB_MAKEMASK1(14)
161
162#define S_SMB_DFMT 8
163#define M_SMB_DFMT _SB_MAKEMASK(3, S_SMB_DFMT)
164#define V_SMB_DFMT(x) _SB_MAKEVALUE(x, S_SMB_DFMT)
165#define G_SMB_DFMT(x) _SB_GETVALUE(x, S_SMB_DFMT, M_SMB_DFMT)
166
167#define K_SMB_DFMT_1BYTE 0
168#define K_SMB_DFMT_2BYTE 1
169#define K_SMB_DFMT_3BYTE 2
170#define K_SMB_DFMT_4BYTE 3
171#define K_SMB_DFMT_NODATA 4
172#define K_SMB_DFMT_CMD4BYTE 5
173#define K_SMB_DFMT_CMD5BYTE 6
174#define K_SMB_DFMT_RESERVED 7
175
176#define V_SMB_DFMT_1BYTE V_SMB_DFMT(K_SMB_DFMT_1BYTE)
177#define V_SMB_DFMT_2BYTE V_SMB_DFMT(K_SMB_DFMT_2BYTE)
178#define V_SMB_DFMT_3BYTE V_SMB_DFMT(K_SMB_DFMT_3BYTE)
179#define V_SMB_DFMT_4BYTE V_SMB_DFMT(K_SMB_DFMT_4BYTE)
180#define V_SMB_DFMT_NODATA V_SMB_DFMT(K_SMB_DFMT_NODATA)
181#define V_SMB_DFMT_CMD4BYTE V_SMB_DFMT(K_SMB_DFMT_CMD4BYTE)
182#define V_SMB_DFMT_CMD5BYTE V_SMB_DFMT(K_SMB_DFMT_CMD5BYTE)
183#define V_SMB_DFMT_RESERVED V_SMB_DFMT(K_SMB_DFMT_RESERVED)
184
185#define S_SMB_AFMT 11
186#define M_SMB_AFMT _SB_MAKEMASK(2, S_SMB_AFMT)
187#define V_SMB_AFMT(x) _SB_MAKEVALUE(x, S_SMB_AFMT)
188#define G_SMB_AFMT(x) _SB_GETVALUE(x, S_SMB_AFMT, M_SMB_AFMT)
189
190#define K_SMB_AFMT_NONE 0
191#define K_SMB_AFMT_ADDR 1
192#define K_SMB_AFMT_ADDR_CMD1BYTE 2
193#define K_SMB_AFMT_ADDR_CMD2BYTE 3
194
195#define V_SMB_AFMT_NONE V_SMB_AFMT(K_SMB_AFMT_NONE)
196#define V_SMB_AFMT_ADDR V_SMB_AFMT(K_SMB_AFMT_ADDR)
197#define V_SMB_AFMT_ADDR_CMD1BYTE V_SMB_AFMT(K_SMB_AFMT_ADDR_CMD1BYTE)
198#define V_SMB_AFMT_ADDR_CMD2BYTE V_SMB_AFMT(K_SMB_AFMT_ADDR_CMD2BYTE)
199
200#define M_SMB_DIR _SB_MAKEMASK1(13)
201
202#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
203
204#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_syncser.h b/arch/mips/include/asm/sibyte/sb1250_syncser.h
new file mode 100644
index 000000000000..d4b8558e0bf1
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_syncser.h
@@ -0,0 +1,146 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * Synchronous Serial Constants File: sb1250_syncser.h
5 *
6 * This module contains constants and macros useful for
7 * manipulating the SB1250's Synchronous Serial
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _SB1250_SYNCSER_H
34#define _SB1250_SYNCSER_H
35
36#include "sb1250_defs.h"
37
38/*
39 * Serial Mode Configuration Register
40 */
41
42#define M_SYNCSER_CRC_MODE _SB_MAKEMASK1(0)
43#define M_SYNCSER_MSB_FIRST _SB_MAKEMASK1(1)
44
45#define S_SYNCSER_FLAG_NUM 2
46#define M_SYNCSER_FLAG_NUM _SB_MAKEMASK(4, S_SYNCSER_FLAG_NUM)
47#define V_SYNCSER_FLAG_NUM _SB_MAKEVALUE(x, S_SYNCSER_FLAG_NUM)
48
49#define M_SYNCSER_FLAG_EN _SB_MAKEMASK1(6)
50#define M_SYNCSER_HDLC_EN _SB_MAKEMASK1(7)
51#define M_SYNCSER_LOOP_MODE _SB_MAKEMASK1(8)
52#define M_SYNCSER_LOOPBACK _SB_MAKEMASK1(9)
53
54/*
55 * Serial Clock Source and Line Interface Mode Register
56 */
57
58#define M_SYNCSER_RXCLK_INV _SB_MAKEMASK1(0)
59#define M_SYNCSER_RXCLK_EXT _SB_MAKEMASK1(1)
60
61#define S_SYNCSER_RXSYNC_DLY 2
62#define M_SYNCSER_RXSYNC_DLY _SB_MAKEMASK(2, S_SYNCSER_RXSYNC_DLY)
63#define V_SYNCSER_RXSYNC_DLY(x) _SB_MAKEVALUE(x, S_SYNCSER_RXSYNC_DLY)
64
65#define M_SYNCSER_RXSYNC_LOW _SB_MAKEMASK1(4)
66#define M_SYNCSER_RXSTRB_LOW _SB_MAKEMASK1(5)
67
68#define M_SYNCSER_RXSYNC_EDGE _SB_MAKEMASK1(6)
69#define M_SYNCSER_RXSYNC_INT _SB_MAKEMASK1(7)
70
71#define M_SYNCSER_TXCLK_INV _SB_MAKEMASK1(8)
72#define M_SYNCSER_TXCLK_EXT _SB_MAKEMASK1(9)
73
74#define S_SYNCSER_TXSYNC_DLY 10
75#define M_SYNCSER_TXSYNC_DLY _SB_MAKEMASK(2, S_SYNCSER_TXSYNC_DLY)
76#define V_SYNCSER_TXSYNC_DLY(x) _SB_MAKEVALUE(x, S_SYNCSER_TXSYNC_DLY)
77
78#define M_SYNCSER_TXSYNC_LOW _SB_MAKEMASK1(12)
79#define M_SYNCSER_TXSTRB_LOW _SB_MAKEMASK1(13)
80
81#define M_SYNCSER_TXSYNC_EDGE _SB_MAKEMASK1(14)
82#define M_SYNCSER_TXSYNC_INT _SB_MAKEMASK1(15)
83
84/*
85 * Serial Command Register
86 */
87
88#define M_SYNCSER_CMD_RX_EN _SB_MAKEMASK1(0)
89#define M_SYNCSER_CMD_TX_EN _SB_MAKEMASK1(1)
90#define M_SYNCSER_CMD_RX_RESET _SB_MAKEMASK1(2)
91#define M_SYNCSER_CMD_TX_RESET _SB_MAKEMASK1(3)
92#define M_SYNCSER_CMD_TX_PAUSE _SB_MAKEMASK1(5)
93
94/*
95 * Serial DMA Enable Register
96 */
97
98#define M_SYNCSER_DMA_RX_EN _SB_MAKEMASK1(0)
99#define M_SYNCSER_DMA_TX_EN _SB_MAKEMASK1(4)
100
101/*
102 * Serial Status Register
103 */
104
105#define M_SYNCSER_RX_CRCERR _SB_MAKEMASK1(0)
106#define M_SYNCSER_RX_ABORT _SB_MAKEMASK1(1)
107#define M_SYNCSER_RX_OCTET _SB_MAKEMASK1(2)
108#define M_SYNCSER_RX_LONGFRM _SB_MAKEMASK1(3)
109#define M_SYNCSER_RX_SHORTFRM _SB_MAKEMASK1(4)
110#define M_SYNCSER_RX_OVERRUN _SB_MAKEMASK1(5)
111#define M_SYNCSER_RX_SYNC_ERR _SB_MAKEMASK1(6)
112#define M_SYNCSER_TX_CRCERR _SB_MAKEMASK1(8)
113#define M_SYNCSER_TX_UNDERRUN _SB_MAKEMASK1(9)
114#define M_SYNCSER_TX_SYNC_ERR _SB_MAKEMASK1(10)
115#define M_SYNCSER_TX_PAUSE_COMPLETE _SB_MAKEMASK1(11)
116#define M_SYNCSER_RX_EOP_COUNT _SB_MAKEMASK1(16)
117#define M_SYNCSER_RX_EOP_TIMER _SB_MAKEMASK1(17)
118#define M_SYNCSER_RX_EOP_SEEN _SB_MAKEMASK1(18)
119#define M_SYNCSER_RX_HWM _SB_MAKEMASK1(19)
120#define M_SYNCSER_RX_LWM _SB_MAKEMASK1(20)
121#define M_SYNCSER_RX_DSCR _SB_MAKEMASK1(21)
122#define M_SYNCSER_RX_DERR _SB_MAKEMASK1(22)
123#define M_SYNCSER_TX_EOP_COUNT _SB_MAKEMASK1(24)
124#define M_SYNCSER_TX_EOP_TIMER _SB_MAKEMASK1(25)
125#define M_SYNCSER_TX_EOP_SEEN _SB_MAKEMASK1(26)
126#define M_SYNCSER_TX_HWM _SB_MAKEMASK1(27)
127#define M_SYNCSER_TX_LWM _SB_MAKEMASK1(28)
128#define M_SYNCSER_TX_DSCR _SB_MAKEMASK1(29)
129#define M_SYNCSER_TX_DERR _SB_MAKEMASK1(30)
130#define M_SYNCSER_TX_DZERO _SB_MAKEMASK1(31)
131
132/*
133 * Sequencer Table Entry format
134 */
135
136#define M_SYNCSER_SEQ_LAST _SB_MAKEMASK1(0)
137#define M_SYNCSER_SEQ_BYTE _SB_MAKEMASK1(1)
138
139#define S_SYNCSER_SEQ_COUNT 2
140#define M_SYNCSER_SEQ_COUNT _SB_MAKEMASK(4, S_SYNCSER_SEQ_COUNT)
141#define V_SYNCSER_SEQ_COUNT(x) _SB_MAKEVALUE(x, S_SYNCSER_SEQ_COUNT)
142
143#define M_SYNCSER_SEQ_ENABLE _SB_MAKEMASK1(6)
144#define M_SYNCSER_SEQ_STROBE _SB_MAKEMASK1(7)
145
146#endif
diff --git a/arch/mips/include/asm/sibyte/sb1250_uart.h b/arch/mips/include/asm/sibyte/sb1250_uart.h
new file mode 100644
index 000000000000..d835bf280140
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sb1250_uart.h
@@ -0,0 +1,362 @@
1/* *********************************************************************
2 * SB1250 Board Support Package
3 *
4 * UART Constants File: sb1250_uart.h
5 *
6 * This module contains constants and macros useful for
7 * manipulating the SB1250's UARTs
8 *
9 * SB1250 specification level: User's manual 1/02/02
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 ********************************************************************* */
31
32
33#ifndef _SB1250_UART_H
34#define _SB1250_UART_H
35
36#include "sb1250_defs.h"
37
38/* **********************************************************************
39 * DUART Registers
40 ********************************************************************** */
41
42/*
43 * DUART Mode Register #1 (Table 10-3)
44 * Register: DUART_MODE_REG_1_A
45 * Register: DUART_MODE_REG_1_B
46 */
47
48#define S_DUART_BITS_PER_CHAR 0
49#define M_DUART_BITS_PER_CHAR _SB_MAKEMASK(2, S_DUART_BITS_PER_CHAR)
50#define V_DUART_BITS_PER_CHAR(x) _SB_MAKEVALUE(x, S_DUART_BITS_PER_CHAR)
51
52#define K_DUART_BITS_PER_CHAR_RSV0 0
53#define K_DUART_BITS_PER_CHAR_RSV1 1
54#define K_DUART_BITS_PER_CHAR_7 2
55#define K_DUART_BITS_PER_CHAR_8 3
56
57#define V_DUART_BITS_PER_CHAR_RSV0 V_DUART_BITS_PER_CHAR(K_DUART_BITS_PER_CHAR_RSV0)
58#define V_DUART_BITS_PER_CHAR_RSV1 V_DUART_BITS_PER_CHAR(K_DUART_BITS_PER_CHAR_RSV1)
59#define V_DUART_BITS_PER_CHAR_7 V_DUART_BITS_PER_CHAR(K_DUART_BITS_PER_CHAR_7)
60#define V_DUART_BITS_PER_CHAR_8 V_DUART_BITS_PER_CHAR(K_DUART_BITS_PER_CHAR_8)
61
62
63#define M_DUART_PARITY_TYPE_EVEN 0x00
64#define M_DUART_PARITY_TYPE_ODD _SB_MAKEMASK1(2)
65
66#define S_DUART_PARITY_MODE 3
67#define M_DUART_PARITY_MODE _SB_MAKEMASK(2, S_DUART_PARITY_MODE)
68#define V_DUART_PARITY_MODE(x) _SB_MAKEVALUE(x, S_DUART_PARITY_MODE)
69
70#define K_DUART_PARITY_MODE_ADD 0
71#define K_DUART_PARITY_MODE_ADD_FIXED 1
72#define K_DUART_PARITY_MODE_NONE 2
73
74#define V_DUART_PARITY_MODE_ADD V_DUART_PARITY_MODE(K_DUART_PARITY_MODE_ADD)
75#define V_DUART_PARITY_MODE_ADD_FIXED V_DUART_PARITY_MODE(K_DUART_PARITY_MODE_ADD_FIXED)
76#define V_DUART_PARITY_MODE_NONE V_DUART_PARITY_MODE(K_DUART_PARITY_MODE_NONE)
77
78#define M_DUART_TX_IRQ_SEL_TXRDY 0
79#define M_DUART_TX_IRQ_SEL_TXEMPT _SB_MAKEMASK1(5)
80
81#define M_DUART_RX_IRQ_SEL_RXRDY 0
82#define M_DUART_RX_IRQ_SEL_RXFULL _SB_MAKEMASK1(6)
83
84#define M_DUART_RX_RTS_ENA _SB_MAKEMASK1(7)
85
86/*
87 * DUART Mode Register #2 (Table 10-4)
88 * Register: DUART_MODE_REG_2_A
89 * Register: DUART_MODE_REG_2_B
90 */
91
92#define M_DUART_MODE_RESERVED1 _SB_MAKEMASK(3, 0) /* ignored */
93
94#define M_DUART_STOP_BIT_LEN_2 _SB_MAKEMASK1(3)
95#define M_DUART_STOP_BIT_LEN_1 0
96
97#define M_DUART_TX_CTS_ENA _SB_MAKEMASK1(4)
98
99
100#define M_DUART_MODE_RESERVED2 _SB_MAKEMASK1(5) /* must be zero */
101
102#define S_DUART_CHAN_MODE 6
103#define M_DUART_CHAN_MODE _SB_MAKEMASK(2, S_DUART_CHAN_MODE)
104#define V_DUART_CHAN_MODE(x) _SB_MAKEVALUE(x, S_DUART_CHAN_MODE)
105
106#define K_DUART_CHAN_MODE_NORMAL 0
107#define K_DUART_CHAN_MODE_LCL_LOOP 2
108#define K_DUART_CHAN_MODE_REM_LOOP 3
109
110#define V_DUART_CHAN_MODE_NORMAL V_DUART_CHAN_MODE(K_DUART_CHAN_MODE_NORMAL)
111#define V_DUART_CHAN_MODE_LCL_LOOP V_DUART_CHAN_MODE(K_DUART_CHAN_MODE_LCL_LOOP)
112#define V_DUART_CHAN_MODE_REM_LOOP V_DUART_CHAN_MODE(K_DUART_CHAN_MODE_REM_LOOP)
113
114/*
115 * DUART Command Register (Table 10-5)
116 * Register: DUART_CMD_A
117 * Register: DUART_CMD_B
118 */
119
120#define M_DUART_RX_EN _SB_MAKEMASK1(0)
121#define M_DUART_RX_DIS _SB_MAKEMASK1(1)
122#define M_DUART_TX_EN _SB_MAKEMASK1(2)
123#define M_DUART_TX_DIS _SB_MAKEMASK1(3)
124
125#define S_DUART_MISC_CMD 4
126#define M_DUART_MISC_CMD _SB_MAKEMASK(3, S_DUART_MISC_CMD)
127#define V_DUART_MISC_CMD(x) _SB_MAKEVALUE(x, S_DUART_MISC_CMD)
128
129#define K_DUART_MISC_CMD_NOACTION0 0
130#define K_DUART_MISC_CMD_NOACTION1 1
131#define K_DUART_MISC_CMD_RESET_RX 2
132#define K_DUART_MISC_CMD_RESET_TX 3
133#define K_DUART_MISC_CMD_NOACTION4 4
134#define K_DUART_MISC_CMD_RESET_BREAK_INT 5
135#define K_DUART_MISC_CMD_START_BREAK 6
136#define K_DUART_MISC_CMD_STOP_BREAK 7
137
138#define V_DUART_MISC_CMD_NOACTION0 V_DUART_MISC_CMD(K_DUART_MISC_CMD_NOACTION0)
139#define V_DUART_MISC_CMD_NOACTION1 V_DUART_MISC_CMD(K_DUART_MISC_CMD_NOACTION1)
140#define V_DUART_MISC_CMD_RESET_RX V_DUART_MISC_CMD(K_DUART_MISC_CMD_RESET_RX)
141#define V_DUART_MISC_CMD_RESET_TX V_DUART_MISC_CMD(K_DUART_MISC_CMD_RESET_TX)
142#define V_DUART_MISC_CMD_NOACTION4 V_DUART_MISC_CMD(K_DUART_MISC_CMD_NOACTION4)
143#define V_DUART_MISC_CMD_RESET_BREAK_INT V_DUART_MISC_CMD(K_DUART_MISC_CMD_RESET_BREAK_INT)
144#define V_DUART_MISC_CMD_START_BREAK V_DUART_MISC_CMD(K_DUART_MISC_CMD_START_BREAK)
145#define V_DUART_MISC_CMD_STOP_BREAK V_DUART_MISC_CMD(K_DUART_MISC_CMD_STOP_BREAK)
146
147#define M_DUART_CMD_RESERVED _SB_MAKEMASK1(7)
148
149/*
150 * DUART Status Register (Table 10-6)
151 * Register: DUART_STATUS_A
152 * Register: DUART_STATUS_B
153 * READ-ONLY
154 */
155
156#define M_DUART_RX_RDY _SB_MAKEMASK1(0)
157#define M_DUART_RX_FFUL _SB_MAKEMASK1(1)
158#define M_DUART_TX_RDY _SB_MAKEMASK1(2)
159#define M_DUART_TX_EMT _SB_MAKEMASK1(3)
160#define M_DUART_OVRUN_ERR _SB_MAKEMASK1(4)
161#define M_DUART_PARITY_ERR _SB_MAKEMASK1(5)
162#define M_DUART_FRM_ERR _SB_MAKEMASK1(6)
163#define M_DUART_RCVD_BRK _SB_MAKEMASK1(7)
164
165/*
166 * DUART Baud Rate Register (Table 10-7)
167 * Register: DUART_CLK_SEL_A
168 * Register: DUART_CLK_SEL_B
169 */
170
171#define M_DUART_CLK_COUNTER _SB_MAKEMASK(12, 0)
172#define V_DUART_BAUD_RATE(x) (100000000/((x)*20)-1)
173
174/*
175 * DUART Data Registers (Table 10-8 and 10-9)
176 * Register: DUART_RX_HOLD_A
177 * Register: DUART_RX_HOLD_B
178 * Register: DUART_TX_HOLD_A
179 * Register: DUART_TX_HOLD_B
180 */
181
182#define M_DUART_RX_DATA _SB_MAKEMASK(8, 0)
183#define M_DUART_TX_DATA _SB_MAKEMASK(8, 0)
184
185/*
186 * DUART Input Port Register (Table 10-10)
187 * Register: DUART_IN_PORT
188 */
189
190#define M_DUART_IN_PIN0_VAL _SB_MAKEMASK1(0)
191#define M_DUART_IN_PIN1_VAL _SB_MAKEMASK1(1)
192#define M_DUART_IN_PIN2_VAL _SB_MAKEMASK1(2)
193#define M_DUART_IN_PIN3_VAL _SB_MAKEMASK1(3)
194#define M_DUART_IN_PIN4_VAL _SB_MAKEMASK1(4)
195#define M_DUART_IN_PIN5_VAL _SB_MAKEMASK1(5)
196#define M_DUART_RIN0_PIN _SB_MAKEMASK1(6)
197#define M_DUART_RIN1_PIN _SB_MAKEMASK1(7)
198
199/*
200 * DUART Input Port Change Status Register (Tables 10-11, 10-12, and 10-13)
201 * Register: DUART_INPORT_CHNG
202 */
203
204#define S_DUART_IN_PIN_VAL 0
205#define M_DUART_IN_PIN_VAL _SB_MAKEMASK(4, S_DUART_IN_PIN_VAL)
206
207#define S_DUART_IN_PIN_CHNG 4
208#define M_DUART_IN_PIN_CHNG _SB_MAKEMASK(4, S_DUART_IN_PIN_CHNG)
209
210
211/*
212 * DUART Output port control register (Table 10-14)
213 * Register: DUART_OPCR
214 */
215
216#define M_DUART_OPCR_RESERVED0 _SB_MAKEMASK1(0) /* must be zero */
217#define M_DUART_OPC2_SEL _SB_MAKEMASK1(1)
218#define M_DUART_OPCR_RESERVED1 _SB_MAKEMASK1(2) /* must be zero */
219#define M_DUART_OPC3_SEL _SB_MAKEMASK1(3)
220#define M_DUART_OPCR_RESERVED2 _SB_MAKEMASK(4, 4) /* must be zero */
221
222/*
223 * DUART Aux Control Register (Table 10-15)
224 * Register: DUART_AUX_CTRL
225 */
226
227#define M_DUART_IP0_CHNG_ENA _SB_MAKEMASK1(0)
228#define M_DUART_IP1_CHNG_ENA _SB_MAKEMASK1(1)
229#define M_DUART_IP2_CHNG_ENA _SB_MAKEMASK1(2)
230#define M_DUART_IP3_CHNG_ENA _SB_MAKEMASK1(3)
231#define M_DUART_ACR_RESERVED _SB_MAKEMASK(4, 4)
232
233#define M_DUART_CTS_CHNG_ENA _SB_MAKEMASK1(0)
234#define M_DUART_CIN_CHNG_ENA _SB_MAKEMASK1(2)
235
236/*
237 * DUART Interrupt Status Register (Table 10-16)
238 * Register: DUART_ISR
239 */
240
241#define M_DUART_ISR_TX_A _SB_MAKEMASK1(0)
242
243#define S_DUART_ISR_RX_A 1
244#define M_DUART_ISR_RX_A _SB_MAKEMASK1(S_DUART_ISR_RX_A)
245#define V_DUART_ISR_RX_A(x) _SB_MAKEVALUE(x, S_DUART_ISR_RX_A)
246#define G_DUART_ISR_RX_A(x) _SB_GETVALUE(x, S_DUART_ISR_RX_A, M_DUART_ISR_RX_A)
247
248#define M_DUART_ISR_BRK_A _SB_MAKEMASK1(2)
249#define M_DUART_ISR_IN_A _SB_MAKEMASK1(3)
250#define M_DUART_ISR_ALL_A _SB_MAKEMASK(4, 0)
251
252#define M_DUART_ISR_TX_B _SB_MAKEMASK1(4)
253#define M_DUART_ISR_RX_B _SB_MAKEMASK1(5)
254#define M_DUART_ISR_BRK_B _SB_MAKEMASK1(6)
255#define M_DUART_ISR_IN_B _SB_MAKEMASK1(7)
256#define M_DUART_ISR_ALL_B _SB_MAKEMASK(4, 4)
257
258/*
259 * DUART Channel A Interrupt Status Register (Table 10-17)
260 * DUART Channel B Interrupt Status Register (Table 10-18)
261 * Register: DUART_ISR_A
262 * Register: DUART_ISR_B
263 */
264
265#define M_DUART_ISR_TX _SB_MAKEMASK1(0)
266#define M_DUART_ISR_RX _SB_MAKEMASK1(1)
267#define M_DUART_ISR_BRK _SB_MAKEMASK1(2)
268#define M_DUART_ISR_IN _SB_MAKEMASK1(3)
269#define M_DUART_ISR_ALL _SB_MAKEMASK(4, 0)
270#define M_DUART_ISR_RESERVED _SB_MAKEMASK(4, 4)
271
272/*
273 * DUART Interrupt Mask Register (Table 10-19)
274 * Register: DUART_IMR
275 */
276
277#define M_DUART_IMR_TX_A _SB_MAKEMASK1(0)
278#define M_DUART_IMR_RX_A _SB_MAKEMASK1(1)
279#define M_DUART_IMR_BRK_A _SB_MAKEMASK1(2)
280#define M_DUART_IMR_IN_A _SB_MAKEMASK1(3)
281#define M_DUART_IMR_ALL_A _SB_MAKEMASK(4, 0)
282
283#define M_DUART_IMR_TX_B _SB_MAKEMASK1(4)
284#define M_DUART_IMR_RX_B _SB_MAKEMASK1(5)
285#define M_DUART_IMR_BRK_B _SB_MAKEMASK1(6)
286#define M_DUART_IMR_IN_B _SB_MAKEMASK1(7)
287#define M_DUART_IMR_ALL_B _SB_MAKEMASK(4, 4)
288
289/*
290 * DUART Channel A Interrupt Mask Register (Table 10-20)
291 * DUART Channel B Interrupt Mask Register (Table 10-21)
292 * Register: DUART_IMR_A
293 * Register: DUART_IMR_B
294 */
295
296#define M_DUART_IMR_TX _SB_MAKEMASK1(0)
297#define M_DUART_IMR_RX _SB_MAKEMASK1(1)
298#define M_DUART_IMR_BRK _SB_MAKEMASK1(2)
299#define M_DUART_IMR_IN _SB_MAKEMASK1(3)
300#define M_DUART_IMR_ALL _SB_MAKEMASK(4, 0)
301#define M_DUART_IMR_RESERVED _SB_MAKEMASK(4, 4)
302
303
304/*
305 * DUART Output Port Set Register (Table 10-22)
306 * Register: DUART_SET_OPR
307 */
308
309#define M_DUART_SET_OPR0 _SB_MAKEMASK1(0)
310#define M_DUART_SET_OPR1 _SB_MAKEMASK1(1)
311#define M_DUART_SET_OPR2 _SB_MAKEMASK1(2)
312#define M_DUART_SET_OPR3 _SB_MAKEMASK1(3)
313#define M_DUART_OPSR_RESERVED _SB_MAKEMASK(4, 4)
314
315/*
316 * DUART Output Port Clear Register (Table 10-23)
317 * Register: DUART_CLEAR_OPR
318 */
319
320#define M_DUART_CLR_OPR0 _SB_MAKEMASK1(0)
321#define M_DUART_CLR_OPR1 _SB_MAKEMASK1(1)
322#define M_DUART_CLR_OPR2 _SB_MAKEMASK1(2)
323#define M_DUART_CLR_OPR3 _SB_MAKEMASK1(3)
324#define M_DUART_OPCR_RESERVED _SB_MAKEMASK(4, 4)
325
326/*
327 * DUART Output Port RTS Register (Table 10-24)
328 * Register: DUART_OUT_PORT
329 */
330
331#define M_DUART_OUT_PIN_SET0 _SB_MAKEMASK1(0)
332#define M_DUART_OUT_PIN_SET1 _SB_MAKEMASK1(1)
333#define M_DUART_OUT_PIN_CLR0 _SB_MAKEMASK1(2)
334#define M_DUART_OUT_PIN_CLR1 _SB_MAKEMASK1(3)
335#define M_DUART_OPRR_RESERVED _SB_MAKEMASK(4, 4)
336
337#define M_DUART_OUT_PIN_SET(chan) \
338 (chan == 0 ? M_DUART_OUT_PIN_SET0 : M_DUART_OUT_PIN_SET1)
339#define M_DUART_OUT_PIN_CLR(chan) \
340 (chan == 0 ? M_DUART_OUT_PIN_CLR0 : M_DUART_OUT_PIN_CLR1)
341
342#if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
343/*
344 * Full Interrupt Control Register
345 */
346
347#define S_DUART_SIG_FULL _SB_MAKE64(0)
348#define M_DUART_SIG_FULL _SB_MAKEMASK(4, S_DUART_SIG_FULL)
349#define V_DUART_SIG_FULL(x) _SB_MAKEVALUE(x, S_DUART_SIG_FULL)
350#define G_DUART_SIG_FULL(x) _SB_GETVALUE(x, S_DUART_SIG_FULL, M_DUART_SIG_FULL)
351
352#define S_DUART_INT_TIME _SB_MAKE64(4)
353#define M_DUART_INT_TIME _SB_MAKEMASK(4, S_DUART_INT_TIME)
354#define V_DUART_INT_TIME(x) _SB_MAKEVALUE(x, S_DUART_INT_TIME)
355#define G_DUART_INT_TIME(x) _SB_GETVALUE(x, S_DUART_INT_TIME, M_DUART_INT_TIME)
356#endif /* 1250 PASS2 || 112x PASS1 || 1480 */
357
358
359/* ********************************************************************** */
360
361
362#endif
diff --git a/arch/mips/include/asm/sibyte/sentosa.h b/arch/mips/include/asm/sibyte/sentosa.h
new file mode 100644
index 000000000000..64c47874f32d
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/sentosa.h
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) 2000, 2001 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18#ifndef __ASM_SIBYTE_SENTOSA_H
19#define __ASM_SIBYTE_SENTOSA_H
20
21#include <asm/sibyte/sb1250.h>
22#include <asm/sibyte/sb1250_int.h>
23
24#ifdef CONFIG_SIBYTE_SENTOSA
25#define SIBYTE_BOARD_NAME "BCM91250E (Sentosa)"
26#endif
27#ifdef CONFIG_SIBYTE_RHONE
28#define SIBYTE_BOARD_NAME "BCM91125E (Rhone)"
29#endif
30
31/* Generic bus chip selects */
32#ifdef CONFIG_SIBYTE_RHONE
33#define LEDS_CS 6
34#define LEDS_PHYS 0x1d0a0000
35#endif
36
37/* GPIOs */
38#define K_GPIO_DBG_LED 0
39
40#endif /* __ASM_SIBYTE_SENTOSA_H */
diff --git a/arch/mips/include/asm/sibyte/swarm.h b/arch/mips/include/asm/sibyte/swarm.h
new file mode 100644
index 000000000000..114d9d29ca9d
--- /dev/null
+++ b/arch/mips/include/asm/sibyte/swarm.h
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18#ifndef __ASM_SIBYTE_SWARM_H
19#define __ASM_SIBYTE_SWARM_H
20
21#include <asm/sibyte/sb1250.h>
22#include <asm/sibyte/sb1250_int.h>
23
24#ifdef CONFIG_SIBYTE_SWARM
25#define SIBYTE_BOARD_NAME "BCM91250A (SWARM)"
26#define SIBYTE_HAVE_PCMCIA 1
27#define SIBYTE_HAVE_IDE 1
28#endif
29#ifdef CONFIG_SIBYTE_LITTLESUR
30#define SIBYTE_BOARD_NAME "BCM91250C2 (LittleSur)"
31#define SIBYTE_HAVE_PCMCIA 0
32#define SIBYTE_HAVE_IDE 1
33#define SIBYTE_DEFAULT_CONSOLE "cfe0"
34#endif
35#ifdef CONFIG_SIBYTE_CRHONE
36#define SIBYTE_BOARD_NAME "BCM91125C (CRhone)"
37#define SIBYTE_HAVE_PCMCIA 0
38#define SIBYTE_HAVE_IDE 0
39#endif
40#ifdef CONFIG_SIBYTE_CRHINE
41#define SIBYTE_BOARD_NAME "BCM91120C (CRhine)"
42#define SIBYTE_HAVE_PCMCIA 0
43#define SIBYTE_HAVE_IDE 0
44#endif
45
46/* Generic bus chip selects */
47#define LEDS_CS 3
48#define LEDS_PHYS 0x100a0000
49
50#ifdef SIBYTE_HAVE_IDE
51#define IDE_CS 4
52#define IDE_PHYS 0x100b0000
53#define K_GPIO_GB_IDE 4
54#define K_INT_GB_IDE (K_INT_GPIO_0 + K_GPIO_GB_IDE)
55#endif
56
57#ifdef SIBYTE_HAVE_PCMCIA
58#define PCMCIA_CS 6
59#define PCMCIA_PHYS 0x11000000
60#define K_GPIO_PC_READY 9
61#define K_INT_PC_READY (K_INT_GPIO_0 + K_GPIO_PC_READY)
62#endif
63
64#endif /* __ASM_SIBYTE_SWARM_H */
diff --git a/arch/mips/include/asm/sigcontext.h b/arch/mips/include/asm/sigcontext.h
new file mode 100644
index 000000000000..9ce0607d7a4e
--- /dev/null
+++ b/arch/mips/include/asm/sigcontext.h
@@ -0,0 +1,100 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1999 by Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_SIGCONTEXT_H
10#define _ASM_SIGCONTEXT_H
11
12#include <asm/sgidefs.h>
13
14#if _MIPS_SIM == _MIPS_SIM_ABI32
15
16/*
17 * Keep this struct definition in sync with the sigcontext fragment
18 * in arch/mips/tools/offset.c
19 */
20struct sigcontext {
21 unsigned int sc_regmask; /* Unused */
22 unsigned int sc_status; /* Unused */
23 unsigned long long sc_pc;
24 unsigned long long sc_regs[32];
25 unsigned long long sc_fpregs[32];
26 unsigned int sc_acx; /* Was sc_ownedfp */
27 unsigned int sc_fpc_csr;
28 unsigned int sc_fpc_eir; /* Unused */
29 unsigned int sc_used_math;
30 unsigned int sc_dsp; /* dsp status, was sc_ssflags */
31 unsigned long long sc_mdhi;
32 unsigned long long sc_mdlo;
33 unsigned long sc_hi1; /* Was sc_cause */
34 unsigned long sc_lo1; /* Was sc_badvaddr */
35 unsigned long sc_hi2; /* Was sc_sigset[4] */
36 unsigned long sc_lo2;
37 unsigned long sc_hi3;
38 unsigned long sc_lo3;
39};
40
41#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
42
43#if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
44
45#include <linux/posix_types.h>
46/*
47 * Keep this struct definition in sync with the sigcontext fragment
48 * in arch/mips/tools/offset.c
49 *
50 * Warning: this structure illdefined with sc_badvaddr being just an unsigned
51 * int so it was changed to unsigned long in 2.6.0-test1. This may break
52 * binary compatibility - no prisoners.
53 * DSP ASE in 2.6.12-rc4. Turn sc_mdhi and sc_mdlo into an array of four
54 * entries, add sc_dsp and sc_reserved for padding. No prisoners.
55 */
56struct sigcontext {
57 __u64 sc_regs[32];
58 __u64 sc_fpregs[32];
59 __u64 sc_mdhi;
60 __u64 sc_hi1;
61 __u64 sc_hi2;
62 __u64 sc_hi3;
63 __u64 sc_mdlo;
64 __u64 sc_lo1;
65 __u64 sc_lo2;
66 __u64 sc_lo3;
67 __u64 sc_pc;
68 __u32 sc_fpc_csr;
69 __u32 sc_used_math;
70 __u32 sc_dsp;
71 __u32 sc_reserved;
72};
73
74#ifdef __KERNEL__
75
76struct sigcontext32 {
77 __u32 sc_regmask; /* Unused */
78 __u32 sc_status; /* Unused */
79 __u64 sc_pc;
80 __u64 sc_regs[32];
81 __u64 sc_fpregs[32];
82 __u32 sc_acx; /* Only MIPS32; was sc_ownedfp */
83 __u32 sc_fpc_csr;
84 __u32 sc_fpc_eir; /* Unused */
85 __u32 sc_used_math;
86 __u32 sc_dsp; /* dsp status, was sc_ssflags */
87 __u64 sc_mdhi;
88 __u64 sc_mdlo;
89 __u32 sc_hi1; /* Was sc_cause */
90 __u32 sc_lo1; /* Was sc_badvaddr */
91 __u32 sc_hi2; /* Was sc_sigset[4] */
92 __u32 sc_lo2;
93 __u32 sc_hi3;
94 __u32 sc_lo3;
95};
96#endif /* __KERNEL__ */
97
98#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 */
99
100#endif /* _ASM_SIGCONTEXT_H */
diff --git a/arch/mips/include/asm/siginfo.h b/arch/mips/include/asm/siginfo.h
new file mode 100644
index 000000000000..96e28f18dad1
--- /dev/null
+++ b/arch/mips/include/asm/siginfo.h
@@ -0,0 +1,130 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 1999, 2001, 2003 Ralf Baechle
7 * Copyright (C) 2000, 2001 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_SIGINFO_H
10#define _ASM_SIGINFO_H
11
12
13#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2*sizeof(int))
14#undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */
15
16#define HAVE_ARCH_SIGINFO_T
17
18/*
19 * We duplicate the generic versions - <asm-generic/siginfo.h> is just borked
20 * by design ...
21 */
22#define HAVE_ARCH_COPY_SIGINFO
23struct siginfo;
24
25/*
26 * Careful to keep union _sifields from shifting ...
27 */
28#ifdef CONFIG_32BIT
29#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
30#endif
31#ifdef CONFIG_64BIT
32#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
33#endif
34
35#include <asm-generic/siginfo.h>
36
37typedef struct siginfo {
38 int si_signo;
39 int si_code;
40 int si_errno;
41 int __pad0[SI_MAX_SIZE / sizeof(int) - SI_PAD_SIZE - 3];
42
43 union {
44 int _pad[SI_PAD_SIZE];
45
46 /* kill() */
47 struct {
48 pid_t _pid; /* sender's pid */
49 __ARCH_SI_UID_T _uid; /* sender's uid */
50 } _kill;
51
52 /* POSIX.1b timers */
53 struct {
54 timer_t _tid; /* timer id */
55 int _overrun; /* overrun count */
56 char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
57 sigval_t _sigval; /* same as below */
58 int _sys_private; /* not to be passed to user */
59 } _timer;
60
61 /* POSIX.1b signals */
62 struct {
63 pid_t _pid; /* sender's pid */
64 __ARCH_SI_UID_T _uid; /* sender's uid */
65 sigval_t _sigval;
66 } _rt;
67
68 /* SIGCHLD */
69 struct {
70 pid_t _pid; /* which child */
71 __ARCH_SI_UID_T _uid; /* sender's uid */
72 int _status; /* exit code */
73 clock_t _utime;
74 clock_t _stime;
75 } _sigchld;
76
77 /* IRIX SIGCHLD */
78 struct {
79 pid_t _pid; /* which child */
80 clock_t _utime;
81 int _status; /* exit code */
82 clock_t _stime;
83 } _irix_sigchld;
84
85 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
86 struct {
87 void __user *_addr; /* faulting insn/memory ref. */
88#ifdef __ARCH_SI_TRAPNO
89 int _trapno; /* TRAP # which caused the signal */
90#endif
91 } _sigfault;
92
93 /* SIGPOLL, SIGXFSZ (To do ...) */
94 struct {
95 __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
96 int _fd;
97 } _sigpoll;
98 } _sifields;
99} siginfo_t;
100
101/*
102 * si_code values
103 * Again these have been choosen to be IRIX compatible.
104 */
105#undef SI_ASYNCIO
106#undef SI_TIMER
107#undef SI_MESGQ
108#define SI_ASYNCIO -2 /* sent by AIO completion */
109#define SI_TIMER __SI_CODE(__SI_TIMER, -3) /* sent by timer expiration */
110#define SI_MESGQ __SI_CODE(__SI_MESGQ, -4) /* sent by real time mesq state change */
111
112#ifdef __KERNEL__
113
114/*
115 * Duplicated here because of <asm-generic/siginfo.h> braindamage ...
116 */
117#include <linux/string.h>
118
119static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
120{
121 if (from->si_code < 0)
122 memcpy(to, from, sizeof(*to));
123 else
124 /* _sigchld is currently the largest know union member */
125 memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld));
126}
127
128#endif
129
130#endif /* _ASM_SIGINFO_H */
diff --git a/arch/mips/include/asm/signal.h b/arch/mips/include/asm/signal.h
new file mode 100644
index 000000000000..bee5153aca48
--- /dev/null
+++ b/arch/mips/include/asm/signal.h
@@ -0,0 +1,139 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 96, 97, 98, 99, 2003 by Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_SIGNAL_H
10#define _ASM_SIGNAL_H
11
12#include <linux/types.h>
13
14#define _NSIG 128
15#define _NSIG_BPW (sizeof(unsigned long) * 8)
16#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
17
18typedef struct {
19 unsigned long sig[_NSIG_WORDS];
20} sigset_t;
21
22typedef unsigned long old_sigset_t; /* at least 32 bits */
23
24#define SIGHUP 1 /* Hangup (POSIX). */
25#define SIGINT 2 /* Interrupt (ANSI). */
26#define SIGQUIT 3 /* Quit (POSIX). */
27#define SIGILL 4 /* Illegal instruction (ANSI). */
28#define SIGTRAP 5 /* Trace trap (POSIX). */
29#define SIGIOT 6 /* IOT trap (4.2 BSD). */
30#define SIGABRT SIGIOT /* Abort (ANSI). */
31#define SIGEMT 7
32#define SIGFPE 8 /* Floating-point exception (ANSI). */
33#define SIGKILL 9 /* Kill, unblockable (POSIX). */
34#define SIGBUS 10 /* BUS error (4.2 BSD). */
35#define SIGSEGV 11 /* Segmentation violation (ANSI). */
36#define SIGSYS 12
37#define SIGPIPE 13 /* Broken pipe (POSIX). */
38#define SIGALRM 14 /* Alarm clock (POSIX). */
39#define SIGTERM 15 /* Termination (ANSI). */
40#define SIGUSR1 16 /* User-defined signal 1 (POSIX). */
41#define SIGUSR2 17 /* User-defined signal 2 (POSIX). */
42#define SIGCHLD 18 /* Child status has changed (POSIX). */
43#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
44#define SIGPWR 19 /* Power failure restart (System V). */
45#define SIGWINCH 20 /* Window size change (4.3 BSD, Sun). */
46#define SIGURG 21 /* Urgent condition on socket (4.2 BSD). */
47#define SIGIO 22 /* I/O now possible (4.2 BSD). */
48#define SIGPOLL SIGIO /* Pollable event occurred (System V). */
49#define SIGSTOP 23 /* Stop, unblockable (POSIX). */
50#define SIGTSTP 24 /* Keyboard stop (POSIX). */
51#define SIGCONT 25 /* Continue (POSIX). */
52#define SIGTTIN 26 /* Background read from tty (POSIX). */
53#define SIGTTOU 27 /* Background write to tty (POSIX). */
54#define SIGVTALRM 28 /* Virtual alarm clock (4.2 BSD). */
55#define SIGPROF 29 /* Profiling alarm clock (4.2 BSD). */
56#define SIGXCPU 30 /* CPU limit exceeded (4.2 BSD). */
57#define SIGXFSZ 31 /* File size limit exceeded (4.2 BSD). */
58
59/* These should not be considered constants from userland. */
60#define SIGRTMIN 32
61#define SIGRTMAX _NSIG
62
63/*
64 * SA_FLAGS values:
65 *
66 * SA_ONSTACK indicates that a registered stack_t will be used.
67 * SA_RESTART flag to get restarting signals (which were the default long ago)
68 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
69 * SA_RESETHAND clears the handler when the signal is delivered.
70 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
71 * SA_NODEFER prevents the current signal from being masked in the handler.
72 *
73 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
74 * Unix names RESETHAND and NODEFER respectively.
75 */
76#define SA_ONSTACK 0x08000000
77#define SA_RESETHAND 0x80000000
78#define SA_RESTART 0x10000000
79#define SA_SIGINFO 0x00000008
80#define SA_NODEFER 0x40000000
81#define SA_NOCLDWAIT 0x00010000
82#define SA_NOCLDSTOP 0x00000001
83
84#define SA_NOMASK SA_NODEFER
85#define SA_ONESHOT SA_RESETHAND
86
87#define SA_RESTORER 0x04000000 /* Only for o32 */
88
89/*
90 * sigaltstack controls
91 */
92#define SS_ONSTACK 1
93#define SS_DISABLE 2
94
95#define MINSIGSTKSZ 2048
96#define SIGSTKSZ 8192
97
98#ifdef __KERNEL__
99
100#ifdef CONFIG_TRAD_SIGNALS
101#define sig_uses_siginfo(ka) ((ka)->sa.sa_flags & SA_SIGINFO)
102#else
103#define sig_uses_siginfo(ka) (1)
104#endif
105
106#endif /* __KERNEL__ */
107
108#define SIG_BLOCK 1 /* for blocking signals */
109#define SIG_UNBLOCK 2 /* for unblocking signals */
110#define SIG_SETMASK 3 /* for setting the signal mask */
111
112#include <asm-generic/signal.h>
113
114struct sigaction {
115 unsigned int sa_flags;
116 __sighandler_t sa_handler;
117 sigset_t sa_mask;
118};
119
120struct k_sigaction {
121 struct sigaction sa;
122};
123
124/* IRIX compatible stack_t */
125typedef struct sigaltstack {
126 void __user *ss_sp;
127 size_t ss_size;
128 int ss_flags;
129} stack_t;
130
131#ifdef __KERNEL__
132#include <asm/sigcontext.h>
133#include <asm/siginfo.h>
134
135#define ptrace_signal_deliver(regs, cookie) do { } while (0)
136
137#endif /* __KERNEL__ */
138
139#endif /* _ASM_SIGNAL_H */
diff --git a/arch/mips/include/asm/sim.h b/arch/mips/include/asm/sim.h
new file mode 100644
index 000000000000..0cd719fabb51
--- /dev/null
+++ b/arch/mips/include/asm/sim.h
@@ -0,0 +1,82 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1999, 2000, 2003 Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_SIM_H
10#define _ASM_SIM_H
11
12
13#include <asm/asm-offsets.h>
14
15#define __str2(x) #x
16#define __str(x) __str2(x)
17
18#ifdef CONFIG_32BIT
19
20#define save_static_function(symbol) \
21__asm__( \
22 ".text\n\t" \
23 ".globl\t" #symbol "\n\t" \
24 ".align\t2\n\t" \
25 ".type\t" #symbol ", @function\n\t" \
26 ".ent\t" #symbol ", 0\n" \
27 #symbol":\n\t" \
28 ".frame\t$29, 0, $31\n\t" \
29 "sw\t$16,"__str(PT_R16)"($29)\t\t\t# save_static_function\n\t" \
30 "sw\t$17,"__str(PT_R17)"($29)\n\t" \
31 "sw\t$18,"__str(PT_R18)"($29)\n\t" \
32 "sw\t$19,"__str(PT_R19)"($29)\n\t" \
33 "sw\t$20,"__str(PT_R20)"($29)\n\t" \
34 "sw\t$21,"__str(PT_R21)"($29)\n\t" \
35 "sw\t$22,"__str(PT_R22)"($29)\n\t" \
36 "sw\t$23,"__str(PT_R23)"($29)\n\t" \
37 "sw\t$30,"__str(PT_R30)"($29)\n\t" \
38 "j\t_" #symbol "\n\t" \
39 ".end\t" #symbol "\n\t" \
40 ".size\t" #symbol",. - " #symbol)
41
42#define nabi_no_regargs
43
44#endif /* CONFIG_32BIT */
45
46#ifdef CONFIG_64BIT
47
48#define save_static_function(symbol) \
49__asm__( \
50 ".text\n\t" \
51 ".globl\t" #symbol "\n\t" \
52 ".align\t2\n\t" \
53 ".type\t" #symbol ", @function\n\t" \
54 ".ent\t" #symbol ", 0\n" \
55 #symbol":\n\t" \
56 ".frame\t$29, 0, $31\n\t" \
57 "sd\t$16,"__str(PT_R16)"($29)\t\t\t# save_static_function\n\t" \
58 "sd\t$17,"__str(PT_R17)"($29)\n\t" \
59 "sd\t$18,"__str(PT_R18)"($29)\n\t" \
60 "sd\t$19,"__str(PT_R19)"($29)\n\t" \
61 "sd\t$20,"__str(PT_R20)"($29)\n\t" \
62 "sd\t$21,"__str(PT_R21)"($29)\n\t" \
63 "sd\t$22,"__str(PT_R22)"($29)\n\t" \
64 "sd\t$23,"__str(PT_R23)"($29)\n\t" \
65 "sd\t$30,"__str(PT_R30)"($29)\n\t" \
66 "j\t_" #symbol "\n\t" \
67 ".end\t" #symbol "\n\t" \
68 ".size\t" #symbol",. - " #symbol)
69
70#define nabi_no_regargs \
71 unsigned long __dummy0, \
72 unsigned long __dummy1, \
73 unsigned long __dummy2, \
74 unsigned long __dummy3, \
75 unsigned long __dummy4, \
76 unsigned long __dummy5, \
77 unsigned long __dummy6, \
78 unsigned long __dummy7,
79
80#endif /* CONFIG_64BIT */
81
82#endif /* _ASM_SIM_H */
diff --git a/arch/mips/include/asm/smp-ops.h b/arch/mips/include/asm/smp-ops.h
new file mode 100644
index 000000000000..43c207e72a63
--- /dev/null
+++ b/arch/mips/include/asm/smp-ops.h
@@ -0,0 +1,57 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General
3 * Public License. See the file "COPYING" in the main directory of this
4 * archive for more details.
5 *
6 * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
7 * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
8 * Copyright (C) 2000, 2001, 2002 Ralf Baechle
9 * Copyright (C) 2000, 2001 Broadcom Corporation
10 */
11#ifndef __ASM_SMP_OPS_H
12#define __ASM_SMP_OPS_H
13
14#ifdef CONFIG_SMP
15
16#include <linux/cpumask.h>
17
18struct plat_smp_ops {
19 void (*send_ipi_single)(int cpu, unsigned int action);
20 void (*send_ipi_mask)(cpumask_t mask, unsigned int action);
21 void (*init_secondary)(void);
22 void (*smp_finish)(void);
23 void (*cpus_done)(void);
24 void (*boot_secondary)(int cpu, struct task_struct *idle);
25 void (*smp_setup)(void);
26 void (*prepare_cpus)(unsigned int max_cpus);
27};
28
29extern void register_smp_ops(struct plat_smp_ops *ops);
30
31static inline void plat_smp_setup(void)
32{
33 extern struct plat_smp_ops *mp_ops; /* private */
34
35 mp_ops->smp_setup();
36}
37
38#else /* !CONFIG_SMP */
39
40struct plat_smp_ops;
41
42static inline void plat_smp_setup(void)
43{
44 /* UP, nothing to do ... */
45}
46
47static inline void register_smp_ops(struct plat_smp_ops *ops)
48{
49}
50
51#endif /* !CONFIG_SMP */
52
53extern struct plat_smp_ops up_smp_ops;
54extern struct plat_smp_ops cmp_smp_ops;
55extern struct plat_smp_ops vsmp_smp_ops;
56
57#endif /* __ASM_SMP_OPS_H */
diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h
new file mode 100644
index 000000000000..0ff5b523ea77
--- /dev/null
+++ b/arch/mips/include/asm/smp.h
@@ -0,0 +1,63 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General
3 * Public License. See the file "COPYING" in the main directory of this
4 * archive for more details.
5 *
6 * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
7 * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
8 * Copyright (C) 2000, 2001, 2002 Ralf Baechle
9 * Copyright (C) 2000, 2001 Broadcom Corporation
10 */
11#ifndef __ASM_SMP_H
12#define __ASM_SMP_H
13
14#include <linux/bitops.h>
15#include <linux/linkage.h>
16#include <linux/threads.h>
17#include <linux/cpumask.h>
18
19#include <asm/atomic.h>
20#include <asm/smp-ops.h>
21
22extern int smp_num_siblings;
23extern cpumask_t cpu_sibling_map[];
24
25#define raw_smp_processor_id() (current_thread_info()->cpu)
26
27/* Map from cpu id to sequential logical cpu number. This will only
28 not be idempotent when cpus failed to come on-line. */
29extern int __cpu_number_map[NR_CPUS];
30#define cpu_number_map(cpu) __cpu_number_map[cpu]
31
32/* The reverse map from sequential logical cpu number to cpu id. */
33extern int __cpu_logical_map[NR_CPUS];
34#define cpu_logical_map(cpu) __cpu_logical_map[cpu]
35
36#define NO_PROC_ID (-1)
37
38#define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
39#define SMP_CALL_FUNCTION 0x2
40
41extern cpumask_t phys_cpu_present_map;
42#define cpu_possible_map phys_cpu_present_map
43
44extern void asmlinkage smp_bootstrap(void);
45
46/*
47 * this function sends a 'reschedule' IPI to another CPU.
48 * it goes straight through and wastes no time serializing
49 * anything. Worst case is that we lose a reschedule ...
50 */
51static inline void smp_send_reschedule(int cpu)
52{
53 extern struct plat_smp_ops *mp_ops; /* private */
54
55 mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF);
56}
57
58extern asmlinkage void smp_call_function_interrupt(void);
59
60extern void arch_send_call_function_single_ipi(int cpu);
61extern void arch_send_call_function_ipi(cpumask_t mask);
62
63#endif /* __ASM_SMP_H */
diff --git a/arch/mips/include/asm/smtc.h b/arch/mips/include/asm/smtc.h
new file mode 100644
index 000000000000..ea60bf08dcb0
--- /dev/null
+++ b/arch/mips/include/asm/smtc.h
@@ -0,0 +1,71 @@
1#ifndef _ASM_SMTC_MT_H
2#define _ASM_SMTC_MT_H
3
4/*
5 * Definitions for SMTC multitasking on MIPS MT cores
6 */
7
8#include <asm/mips_mt.h>
9#include <asm/smtc_ipi.h>
10
11/*
12 * System-wide SMTC status information
13 */
14
15extern unsigned int smtc_status;
16
17#define SMTC_TLB_SHARED 0x00000001
18#define SMTC_MTC_ACTIVE 0x00000002
19
20/*
21 * TLB/ASID Management information
22 */
23
24#define MAX_SMTC_TLBS 2
25#define MAX_SMTC_ASIDS 256
26#if NR_CPUS <= 8
27typedef char asiduse;
28#else
29#if NR_CPUS <= 16
30typedef short asiduse;
31#else
32typedef long asiduse;
33#endif
34#endif
35
36extern asiduse smtc_live_asid[MAX_SMTC_TLBS][MAX_SMTC_ASIDS];
37
38struct mm_struct;
39struct task_struct;
40
41void smtc_get_new_mmu_context(struct mm_struct *mm, unsigned long cpu);
42void self_ipi(struct smtc_ipi *);
43void smtc_flush_tlb_asid(unsigned long asid);
44extern int smtc_build_cpu_map(int startslot);
45extern void smtc_prepare_cpus(int cpus);
46extern void smtc_smp_finish(void);
47extern void smtc_boot_secondary(int cpu, struct task_struct *t);
48extern void smtc_cpus_done(void);
49
50
51/*
52 * Sharing the TLB between multiple VPEs means that the
53 * "random" index selection function is not allowed to
54 * select the current value of the Index register. To
55 * avoid additional TLB pressure, the Index registers
56 * are "parked" with an non-Valid value.
57 */
58
59#define PARKED_INDEX ((unsigned int)0x80000000)
60
61/*
62 * Define low-level interrupt mask for IPIs, if necessary.
63 * By default, use SW interrupt 1, which requires no external
64 * hardware support, but which works only for single-core
65 * MIPS MT systems.
66 */
67#ifndef MIPS_CPU_IPI_IRQ
68#define MIPS_CPU_IPI_IRQ 1
69#endif
70
71#endif /* _ASM_SMTC_MT_H */
diff --git a/arch/mips/include/asm/smtc_ipi.h b/arch/mips/include/asm/smtc_ipi.h
new file mode 100644
index 000000000000..8ce517574340
--- /dev/null
+++ b/arch/mips/include/asm/smtc_ipi.h
@@ -0,0 +1,128 @@
1/*
2 * Definitions used in MIPS MT SMTC "Interprocessor Interrupt" code.
3 */
4#ifndef __ASM_SMTC_IPI_H
5#define __ASM_SMTC_IPI_H
6
7#include <linux/spinlock.h>
8
9//#define SMTC_IPI_DEBUG
10
11#ifdef SMTC_IPI_DEBUG
12#include <asm/mipsregs.h>
13#include <asm/mipsmtregs.h>
14#endif /* SMTC_IPI_DEBUG */
15
16/*
17 * An IPI "message"
18 */
19
20struct smtc_ipi {
21 struct smtc_ipi *flink;
22 int type;
23 void *arg;
24 int dest;
25#ifdef SMTC_IPI_DEBUG
26 int sender;
27 long stamp;
28#endif /* SMTC_IPI_DEBUG */
29};
30
31/*
32 * Defined IPI Types
33 */
34
35#define LINUX_SMP_IPI 1
36#define SMTC_CLOCK_TICK 2
37#define IRQ_AFFINITY_IPI 3
38
39/*
40 * A queue of IPI messages
41 */
42
43struct smtc_ipi_q {
44 struct smtc_ipi *head;
45 spinlock_t lock;
46 struct smtc_ipi *tail;
47 int depth;
48};
49
50static inline void smtc_ipi_nq(struct smtc_ipi_q *q, struct smtc_ipi *p)
51{
52 unsigned long flags;
53
54 spin_lock_irqsave(&q->lock, flags);
55 if (q->head == NULL)
56 q->head = q->tail = p;
57 else
58 q->tail->flink = p;
59 p->flink = NULL;
60 q->tail = p;
61 q->depth++;
62#ifdef SMTC_IPI_DEBUG
63 p->sender = read_c0_tcbind();
64 p->stamp = read_c0_count();
65#endif /* SMTC_IPI_DEBUG */
66 spin_unlock_irqrestore(&q->lock, flags);
67}
68
69static inline struct smtc_ipi *__smtc_ipi_dq(struct smtc_ipi_q *q)
70{
71 struct smtc_ipi *p;
72
73 if (q->head == NULL)
74 p = NULL;
75 else {
76 p = q->head;
77 q->head = q->head->flink;
78 q->depth--;
79 /* Arguably unnecessary, but leaves queue cleaner */
80 if (q->head == NULL)
81 q->tail = NULL;
82 }
83
84 return p;
85}
86
87static inline struct smtc_ipi *smtc_ipi_dq(struct smtc_ipi_q *q)
88{
89 unsigned long flags;
90 struct smtc_ipi *p;
91
92 spin_lock_irqsave(&q->lock, flags);
93 p = __smtc_ipi_dq(q);
94 spin_unlock_irqrestore(&q->lock, flags);
95
96 return p;
97}
98
99static inline void smtc_ipi_req(struct smtc_ipi_q *q, struct smtc_ipi *p)
100{
101 unsigned long flags;
102
103 spin_lock_irqsave(&q->lock, flags);
104 if (q->head == NULL) {
105 q->head = q->tail = p;
106 p->flink = NULL;
107 } else {
108 p->flink = q->head;
109 q->head = p;
110 }
111 q->depth++;
112 spin_unlock_irqrestore(&q->lock, flags);
113}
114
115static inline int smtc_ipi_qdepth(struct smtc_ipi_q *q)
116{
117 unsigned long flags;
118 int retval;
119
120 spin_lock_irqsave(&q->lock, flags);
121 retval = q->depth;
122 spin_unlock_irqrestore(&q->lock, flags);
123 return retval;
124}
125
126extern void smtc_send_ipi(int cpu, int type, unsigned int action);
127
128#endif /* __ASM_SMTC_IPI_H */
diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
new file mode 100644
index 000000000000..25da651f1f5f
--- /dev/null
+++ b/arch/mips/include/asm/smtc_proc.h
@@ -0,0 +1,23 @@
1/*
2 * Definitions for SMTC /proc entries
3 * Copyright(C) 2005 MIPS Technologies Inc.
4 */
5#ifndef __ASM_SMTC_PROC_H
6#define __ASM_SMTC_PROC_H
7
8/*
9 * per-"CPU" statistics
10 */
11
12struct smtc_cpu_proc {
13 unsigned long timerints;
14 unsigned long selfipis;
15};
16
17extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
18
19/* Count of number of recoveries of "stolen" FPU access rights on 34K */
20
21extern atomic_t smtc_fpu_recoveries;
22
23#endif /* __ASM_SMTC_PROC_H */
diff --git a/arch/mips/include/asm/smvp.h b/arch/mips/include/asm/smvp.h
new file mode 100644
index 000000000000..0d0e80a39e8a
--- /dev/null
+++ b/arch/mips/include/asm/smvp.h
@@ -0,0 +1,19 @@
1#ifndef _ASM_SMVP_H
2#define _ASM_SMVP_H
3
4/*
5 * Definitions for SMVP multitasking on MIPS MT cores
6 */
7struct task_struct;
8
9extern void smvp_smp_setup(void);
10extern void smvp_smp_finish(void);
11extern void smvp_boot_secondary(int cpu, struct task_struct *t);
12extern void smvp_init_secondary(void);
13extern void smvp_smp_finish(void);
14extern void smvp_cpus_done(void);
15extern void smvp_prepare_cpus(unsigned int max_cpus);
16
17/* This is platform specific */
18extern void smvp_send_ipi(int cpu, unsigned int action);
19#endif /* _ASM_SMVP_H */
diff --git a/arch/mips/include/asm/sn/addrs.h b/arch/mips/include/asm/sn/addrs.h
new file mode 100644
index 000000000000..fec9bdd34913
--- /dev/null
+++ b/arch/mips/include/asm/sn/addrs.h
@@ -0,0 +1,430 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc.
7 * Copyright (C) 1999, 2000 by Ralf Baechle
8 */
9#ifndef _ASM_SN_ADDRS_H
10#define _ASM_SN_ADDRS_H
11
12
13#ifndef __ASSEMBLY__
14#include <linux/types.h>
15#endif /* !__ASSEMBLY__ */
16
17#include <asm/addrspace.h>
18#include <asm/sn/kldir.h>
19
20#if defined(CONFIG_SGI_IP27)
21#include <asm/sn/sn0/addrs.h>
22#elif defined(CONFIG_SGI_IP35)
23#include <asm/sn/sn1/addrs.h>
24#endif
25
26
27#ifndef __ASSEMBLY__
28
29#define PS_UINT_CAST (unsigned long)
30#define UINT64_CAST (unsigned long)
31
32#define HUBREG_CAST (volatile hubreg_t *)
33
34#else /* __ASSEMBLY__ */
35
36#define PS_UINT_CAST
37#define UINT64_CAST
38#define HUBREG_CAST
39
40#endif /* __ASSEMBLY__ */
41
42
43#define NASID_GET_META(_n) ((_n) >> NASID_LOCAL_BITS)
44#ifdef CONFIG_SGI_IP27
45#define NASID_GET_LOCAL(_n) ((_n) & 0xf)
46#endif
47#define NASID_MAKE(_m, _l) (((_m) << NASID_LOCAL_BITS) | (_l))
48
49#define NODE_ADDRSPACE_MASK (NODE_ADDRSPACE_SIZE - 1)
50#define TO_NODE_ADDRSPACE(_pa) (UINT64_CAST (_pa) & NODE_ADDRSPACE_MASK)
51
52#define CHANGE_ADDR_NASID(_pa, _nasid) \
53 ((UINT64_CAST(_pa) & ~NASID_MASK) | \
54 (UINT64_CAST(_nasid) << NASID_SHFT))
55
56
57/*
58 * The following macros are used to index to the beginning of a specific
59 * node's address space.
60 */
61
62#define NODE_OFFSET(_n) (UINT64_CAST (_n) << NODE_SIZE_BITS)
63
64#define NODE_CAC_BASE(_n) (CAC_BASE + NODE_OFFSET(_n))
65#define NODE_HSPEC_BASE(_n) (HSPEC_BASE + NODE_OFFSET(_n))
66#define NODE_IO_BASE(_n) (IO_BASE + NODE_OFFSET(_n))
67#define NODE_MSPEC_BASE(_n) (MSPEC_BASE + NODE_OFFSET(_n))
68#define NODE_UNCAC_BASE(_n) (UNCAC_BASE + NODE_OFFSET(_n))
69
70#define TO_NODE(_n, _x) (NODE_OFFSET(_n) | ((_x) ))
71#define TO_NODE_CAC(_n, _x) (NODE_CAC_BASE(_n) | ((_x) & TO_PHYS_MASK))
72#define TO_NODE_UNCAC(_n, _x) (NODE_UNCAC_BASE(_n) | ((_x) & TO_PHYS_MASK))
73#define TO_NODE_MSPEC(_n, _x) (NODE_MSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))
74#define TO_NODE_HSPEC(_n, _x) (NODE_HSPEC_BASE(_n) | ((_x) & TO_PHYS_MASK))
75
76
77#define RAW_NODE_SWIN_BASE(nasid, widget) \
78 (NODE_IO_BASE(nasid) + (UINT64_CAST(widget) << SWIN_SIZE_BITS))
79
80#define WIDGETID_GET(addr) ((unsigned char)((addr >> SWIN_SIZE_BITS) & 0xff))
81
82/*
83 * The following definitions pertain to the IO special address
84 * space. They define the location of the big and little windows
85 * of any given node.
86 */
87
88#define SWIN_SIZE_BITS 24
89#define SWIN_SIZE (UINT64_CAST 1 << 24)
90#define SWIN_SIZEMASK (SWIN_SIZE - 1)
91#define SWIN_WIDGET_MASK 0xF
92
93/*
94 * Convert smallwindow address to xtalk address.
95 *
96 * 'addr' can be physical or virtual address, but will be converted
97 * to Xtalk address in the range 0 -> SWINZ_SIZEMASK
98 */
99#define SWIN_WIDGETADDR(addr) ((addr) & SWIN_SIZEMASK)
100#define SWIN_WIDGETNUM(addr) (((addr) >> SWIN_SIZE_BITS) & SWIN_WIDGET_MASK)
101/*
102 * Verify if addr belongs to small window address on node with "nasid"
103 *
104 *
105 * NOTE: "addr" is expected to be XKPHYS address, and NOT physical
106 * address
107 *
108 *
109 */
110#define NODE_SWIN_ADDR(nasid, addr) \
111 (((addr) >= NODE_SWIN_BASE(nasid, 0)) && \
112 ((addr) < (NODE_SWIN_BASE(nasid, HUB_NUM_WIDGET) + SWIN_SIZE)\
113 ))
114
115/*
116 * The following define the major position-independent aliases used
117 * in SN.
118 * UALIAS -- 256MB in size, reads in the UALIAS result in
119 * uncached references to the memory of the reader's node.
120 * CPU_UALIAS -- 128kb in size, the bottom part of UALIAS is flipped
121 * depending on which CPU does the access to provide
122 * all CPUs with unique uncached memory at low addresses.
123 * LBOOT -- 256MB in size, reads in the LBOOT area result in
124 * uncached references to the local hub's boot prom and
125 * other directory-bus connected devices.
126 * IALIAS -- 8MB in size, reads in the IALIAS result in uncached
127 * references to the local hub's registers.
128 */
129
130#define UALIAS_BASE HSPEC_BASE
131#define UALIAS_SIZE 0x10000000 /* 256 Megabytes */
132#define UALIAS_LIMIT (UALIAS_BASE + UALIAS_SIZE)
133
134/*
135 * The bottom of ualias space is flipped depending on whether you're
136 * processor 0 or 1 within a node.
137 */
138#ifdef CONFIG_SGI_IP27
139#define UALIAS_FLIP_BASE UALIAS_BASE
140#define UALIAS_FLIP_SIZE 0x20000
141#define UALIAS_FLIP_BIT 0x10000
142#define UALIAS_FLIP_ADDR(_x) (cputoslice(smp_processor_id()) ? \
143 (_x) ^ UALIAS_FLIP_BIT : (_x))
144
145#define LBOOT_BASE (HSPEC_BASE + 0x10000000)
146#define LBOOT_SIZE 0x10000000
147#define LBOOT_LIMIT (LBOOT_BASE + LBOOT_SIZE)
148#define LBOOT_STRIDE 0 /* IP27 has only one CPU PROM */
149
150#endif
151
152#define HUB_REGISTER_WIDGET 1
153#define IALIAS_BASE NODE_SWIN_BASE(0, HUB_REGISTER_WIDGET)
154#define IALIAS_SIZE 0x800000 /* 8 Megabytes */
155#define IS_IALIAS(_a) (((_a) >= IALIAS_BASE) && \
156 ((_a) < (IALIAS_BASE + IALIAS_SIZE)))
157
158/*
159 * Macro for referring to Hub's RBOOT space
160 */
161
162#ifdef CONFIG_SGI_IP27
163#define RBOOT_SIZE 0x10000000 /* 256 Megabytes */
164#define NODE_RBOOT_BASE(_n) (NODE_HSPEC_BASE(_n) + 0x30000000)
165#define NODE_RBOOT_LIMIT(_n) (NODE_RBOOT_BASE(_n) + RBOOT_SIZE)
166
167#endif
168
169/*
170 * Macros for referring the Hub's back door space
171 *
172 * These macros correctly process addresses in any node's space.
173 * WARNING: They won't work in assembler.
174 *
175 * BDDIR_ENTRY_LO returns the address of the low double-word of the dir
176 * entry corresponding to a physical (Cac or Uncac) address.
177 * BDDIR_ENTRY_HI returns the address of the high double-word of the entry.
178 * BDPRT_ENTRY returns the address of the double-word protection entry
179 * corresponding to the page containing the physical address.
180 * BDPRT_ENTRY_S Stores the value into the protection entry.
181 * BDPRT_ENTRY_L Load the value from the protection entry.
182 * BDECC_ENTRY returns the address of the ECC byte corresponding to a
183 * double-word at a specified physical address.
184 * BDECC_ENTRY_H returns the address of the two ECC bytes corresponding to a
185 * quad-word at a specified physical address.
186 */
187#define NODE_BDOOR_BASE(_n) (NODE_HSPEC_BASE(_n) + (NODE_ADDRSPACE_SIZE/2))
188
189#define NODE_BDECC_BASE(_n) (NODE_BDOOR_BASE(_n))
190#define NODE_BDDIR_BASE(_n) (NODE_BDOOR_BASE(_n) + (NODE_ADDRSPACE_SIZE/4))
191#ifdef CONFIG_SGI_IP27
192#define BDDIR_ENTRY_LO(_pa) ((HSPEC_BASE + \
193 NODE_ADDRSPACE_SIZE * 3 / 4 + \
194 0x200) | \
195 UINT64_CAST(_pa) & NASID_MASK | \
196 UINT64_CAST(_pa) >> 2 & BDDIR_UPPER_MASK | \
197 UINT64_CAST(_pa) >> 3 & 0x1f << 4)
198
199#define BDDIR_ENTRY_HI(_pa) ((HSPEC_BASE + \
200 NODE_ADDRSPACE_SIZE * 3 / 4 + \
201 0x208) | \
202 UINT64_CAST(_pa) & NASID_MASK | \
203 UINT64_CAST(_pa) >> 2 & BDDIR_UPPER_MASK | \
204 UINT64_CAST(_pa) >> 3 & 0x1f << 4)
205
206#define BDPRT_ENTRY(_pa, _rgn) ((HSPEC_BASE + \
207 NODE_ADDRSPACE_SIZE * 3 / 4) | \
208 UINT64_CAST(_pa) & NASID_MASK | \
209 UINT64_CAST(_pa) >> 2 & BDDIR_UPPER_MASK | \
210 (_rgn) << 3)
211#define BDPRT_ENTRY_ADDR(_pa, _rgn) (BDPRT_ENTRY((_pa), (_rgn)))
212#define BDPRT_ENTRY_S(_pa, _rgn, _val) (*(__psunsigned_t *)BDPRT_ENTRY((_pa), (_rgn))=(_val))
213#define BDPRT_ENTRY_L(_pa, _rgn) (*(__psunsigned_t *)BDPRT_ENTRY((_pa), (_rgn)))
214
215#define BDECC_ENTRY(_pa) ((HSPEC_BASE + \
216 NODE_ADDRSPACE_SIZE / 2) | \
217 UINT64_CAST(_pa) & NASID_MASK | \
218 UINT64_CAST(_pa) >> 2 & BDECC_UPPER_MASK | \
219 UINT64_CAST(_pa) >> 3 & 3)
220
221/*
222 * Macro to convert a back door directory or protection address into the
223 * raw physical address of the associated cache line or protection page.
224 */
225#define BDADDR_IS_DIR(_ba) ((UINT64_CAST (_ba) & 0x200) != 0)
226#define BDADDR_IS_PRT(_ba) ((UINT64_CAST (_ba) & 0x200) == 0)
227
228#define BDDIR_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \
229 (UINT64_CAST(_ba) & BDDIR_UPPER_MASK)<<2 | \
230 (UINT64_CAST(_ba) & 0x1f << 4) << 3)
231
232#define BDPRT_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \
233 (UINT64_CAST(_ba) & BDDIR_UPPER_MASK)<<2)
234
235#define BDECC_TO_MEM(_ba) (UINT64_CAST (_ba) & NASID_MASK | \
236 (UINT64_CAST(_ba) & BDECC_UPPER_MASK)<<2 | \
237 (UINT64_CAST(_ba) & 3) << 3)
238#endif /* CONFIG_SGI_IP27 */
239
240
241/*
242 * The following macros produce the correct base virtual address for
243 * the hub registers. The LOCAL_HUB_* macros produce the appropriate
244 * address for the local registers. The REMOTE_HUB_* macro produce
245 * the address for the specified hub's registers. The intent is
246 * that the appropriate PI, MD, NI, or II register would be substituted
247 * for _x.
248 */
249
250/*
251 * WARNING:
252 * When certain Hub chip workaround are defined, it's not sufficient
253 * to dereference the *_HUB_ADDR() macros. You should instead use
254 * HUB_L() and HUB_S() if you must deal with pointers to hub registers.
255 * Otherwise, the recommended approach is to use *_HUB_L() and *_HUB_S().
256 * They're always safe.
257 */
258#define LOCAL_HUB_ADDR(_x) (HUBREG_CAST (IALIAS_BASE + (_x)))
259#define REMOTE_HUB_ADDR(_n, _x) (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + \
260 0x800000 + (_x)))
261#ifdef CONFIG_SGI_IP27
262#define REMOTE_HUB_PI_ADDR(_n, _sn, _x) (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + \
263 0x800000 + (_x)))
264#endif /* CONFIG_SGI_IP27 */
265
266#ifndef __ASSEMBLY__
267
268#define HUB_L(_a) *(_a)
269#define HUB_S(_a, _d) *(_a) = (_d)
270
271#define LOCAL_HUB_L(_r) HUB_L(LOCAL_HUB_ADDR(_r))
272#define LOCAL_HUB_S(_r, _d) HUB_S(LOCAL_HUB_ADDR(_r), (_d))
273#define REMOTE_HUB_L(_n, _r) HUB_L(REMOTE_HUB_ADDR((_n), (_r)))
274#define REMOTE_HUB_S(_n, _r, _d) HUB_S(REMOTE_HUB_ADDR((_n), (_r)), (_d))
275#define REMOTE_HUB_PI_L(_n, _sn, _r) HUB_L(REMOTE_HUB_PI_ADDR((_n), (_sn), (_r)))
276#define REMOTE_HUB_PI_S(_n, _sn, _r, _d) HUB_S(REMOTE_HUB_PI_ADDR((_n), (_sn), (_r)), (_d))
277
278#endif /* !__ASSEMBLY__ */
279
280/*
281 * The following macros are used to get to a hub/bridge register, given
282 * the base of the register space.
283 */
284#define HUB_REG_PTR(_base, _off) \
285 (HUBREG_CAST((__psunsigned_t)(_base) + (__psunsigned_t)(_off)))
286
287#define HUB_REG_PTR_L(_base, _off) \
288 HUB_L(HUB_REG_PTR((_base), (_off)))
289
290#define HUB_REG_PTR_S(_base, _off, _data) \
291 HUB_S(HUB_REG_PTR((_base), (_off)), (_data))
292
293/*
294 * Software structure locations -- permanently fixed
295 * See diagram in kldir.h
296 */
297
298#define PHYS_RAMBASE 0x0
299#define K0_RAMBASE PHYS_TO_K0(PHYS_RAMBASE)
300
301#define EX_HANDLER_OFFSET(slice) ((slice) << 16)
302#define EX_HANDLER_ADDR(nasid, slice) \
303 PHYS_TO_K0(NODE_OFFSET(nasid) | EX_HANDLER_OFFSET(slice))
304#define EX_HANDLER_SIZE 0x0400
305
306#define EX_FRAME_OFFSET(slice) ((slice) << 16 | 0x400)
307#define EX_FRAME_ADDR(nasid, slice) \
308 PHYS_TO_K0(NODE_OFFSET(nasid) | EX_FRAME_OFFSET(slice))
309#define EX_FRAME_SIZE 0x0c00
310
311#define ARCS_SPB_OFFSET 0x1000
312#define ARCS_SPB_ADDR(nasid) \
313 PHYS_TO_K0(NODE_OFFSET(nasid) | ARCS_SPB_OFFSET)
314#define ARCS_SPB_SIZE 0x0400
315
316#define KLDIR_OFFSET 0x2000
317#define KLDIR_ADDR(nasid) \
318 TO_NODE_UNCAC((nasid), KLDIR_OFFSET)
319#define KLDIR_SIZE 0x0400
320
321
322/*
323 * Software structure locations -- indirected through KLDIR
324 * See diagram in kldir.h
325 *
326 * Important: All low memory structures must only be accessed
327 * uncached, except for the symmon stacks.
328 */
329
330#define KLI_LAUNCH 0 /* Dir. entries */
331#define KLI_KLCONFIG 1
332#define KLI_NMI 2
333#define KLI_GDA 3
334#define KLI_FREEMEM 4
335#define KLI_SYMMON_STK 5
336#define KLI_PI_ERROR 6
337#define KLI_KERN_VARS 7
338#define KLI_KERN_XP 8
339#define KLI_KERN_PARTID 9
340
341#ifndef __ASSEMBLY__
342
343#define KLD_BASE(nasid) ((kldir_ent_t *) KLDIR_ADDR(nasid))
344#define KLD_LAUNCH(nasid) (KLD_BASE(nasid) + KLI_LAUNCH)
345#define KLD_NMI(nasid) (KLD_BASE(nasid) + KLI_NMI)
346#define KLD_KLCONFIG(nasid) (KLD_BASE(nasid) + KLI_KLCONFIG)
347#define KLD_PI_ERROR(nasid) (KLD_BASE(nasid) + KLI_PI_ERROR)
348#define KLD_GDA(nasid) (KLD_BASE(nasid) + KLI_GDA)
349#define KLD_SYMMON_STK(nasid) (KLD_BASE(nasid) + KLI_SYMMON_STK)
350#define KLD_FREEMEM(nasid) (KLD_BASE(nasid) + KLI_FREEMEM)
351#define KLD_KERN_VARS(nasid) (KLD_BASE(nasid) + KLI_KERN_VARS)
352#define KLD_KERN_XP(nasid) (KLD_BASE(nasid) + KLI_KERN_XP)
353#define KLD_KERN_PARTID(nasid) (KLD_BASE(nasid) + KLI_KERN_PARTID)
354
355#define LAUNCH_OFFSET(nasid, slice) \
356 (KLD_LAUNCH(nasid)->offset + \
357 KLD_LAUNCH(nasid)->stride * (slice))
358#define LAUNCH_ADDR(nasid, slice) \
359 TO_NODE_UNCAC((nasid), LAUNCH_OFFSET(nasid, slice))
360#define LAUNCH_SIZE(nasid) KLD_LAUNCH(nasid)->size
361
362#define NMI_OFFSET(nasid, slice) \
363 (KLD_NMI(nasid)->offset + \
364 KLD_NMI(nasid)->stride * (slice))
365#define NMI_ADDR(nasid, slice) \
366 TO_NODE_UNCAC((nasid), NMI_OFFSET(nasid, slice))
367#define NMI_SIZE(nasid) KLD_NMI(nasid)->size
368
369#define KLCONFIG_OFFSET(nasid) KLD_KLCONFIG(nasid)->offset
370#define KLCONFIG_ADDR(nasid) \
371 TO_NODE_UNCAC((nasid), KLCONFIG_OFFSET(nasid))
372#define KLCONFIG_SIZE(nasid) KLD_KLCONFIG(nasid)->size
373
374#define GDA_ADDR(nasid) KLD_GDA(nasid)->pointer
375#define GDA_SIZE(nasid) KLD_GDA(nasid)->size
376
377#define SYMMON_STK_OFFSET(nasid, slice) \
378 (KLD_SYMMON_STK(nasid)->offset + \
379 KLD_SYMMON_STK(nasid)->stride * (slice))
380#define SYMMON_STK_STRIDE(nasid) KLD_SYMMON_STK(nasid)->stride
381
382#define SYMMON_STK_ADDR(nasid, slice) \
383 TO_NODE_CAC((nasid), SYMMON_STK_OFFSET(nasid, slice))
384
385#define SYMMON_STK_SIZE(nasid) KLD_SYMMON_STK(nasid)->stride
386
387#define SYMMON_STK_END(nasid) (SYMMON_STK_ADDR(nasid, 0) + KLD_SYMMON_STK(nasid)->size)
388
389/* loading symmon 4k below UNIX. the arcs loader needs the topaddr for a
390 * relocatable program
391 */
392#define UNIX_DEBUG_LOADADDR 0x300000
393#define SYMMON_LOADADDR(nasid) \
394 TO_NODE(nasid, PHYS_TO_K0(UNIX_DEBUG_LOADADDR - 0x1000))
395
396#define FREEMEM_OFFSET(nasid) KLD_FREEMEM(nasid)->offset
397#define FREEMEM_ADDR(nasid) SYMMON_STK_END(nasid)
398/*
399 * XXX
400 * Fix this. FREEMEM_ADDR should be aware of if symmon is loaded.
401 * Also, it should take into account what prom thinks to be a safe
402 * address
403 PHYS_TO_K0(NODE_OFFSET(nasid) + FREEMEM_OFFSET(nasid))
404 */
405#define FREEMEM_SIZE(nasid) KLD_FREEMEM(nasid)->size
406
407#define PI_ERROR_OFFSET(nasid) KLD_PI_ERROR(nasid)->offset
408#define PI_ERROR_ADDR(nasid) \
409 TO_NODE_UNCAC((nasid), PI_ERROR_OFFSET(nasid))
410#define PI_ERROR_SIZE(nasid) KLD_PI_ERROR(nasid)->size
411
412#define NODE_OFFSET_TO_K0(_nasid, _off) \
413 PHYS_TO_K0((NODE_OFFSET(_nasid) + (_off)) | CAC_BASE)
414#define NODE_OFFSET_TO_K1(_nasid, _off) \
415 TO_UNCAC((NODE_OFFSET(_nasid) + (_off)) | UNCAC_BASE)
416#define K0_TO_NODE_OFFSET(_k0addr) \
417 ((__psunsigned_t)(_k0addr) & NODE_ADDRSPACE_MASK)
418
419#define KERN_VARS_ADDR(nasid) KLD_KERN_VARS(nasid)->pointer
420#define KERN_VARS_SIZE(nasid) KLD_KERN_VARS(nasid)->size
421
422#define KERN_XP_ADDR(nasid) KLD_KERN_XP(nasid)->pointer
423#define KERN_XP_SIZE(nasid) KLD_KERN_XP(nasid)->size
424
425#define GPDA_ADDR(nasid) TO_NODE_CAC(nasid, GPDA_OFFSET)
426
427#endif /* !__ASSEMBLY__ */
428
429
430#endif /* _ASM_SN_ADDRS_H */
diff --git a/arch/mips/include/asm/sn/agent.h b/arch/mips/include/asm/sn/agent.h
new file mode 100644
index 000000000000..ac4ea85c3a5c
--- /dev/null
+++ b/arch/mips/include/asm/sn/agent.h
@@ -0,0 +1,46 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * This file has definitions for the hub and snac interfaces.
7 *
8 * Copyright (C) 1992 - 1997, 1999, 2000 Silcon Graphics, Inc.
9 * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
10 */
11#ifndef _ASM_SGI_SN_AGENT_H
12#define _ASM_SGI_SN_AGENT_H
13
14#include <linux/topology.h>
15#include <asm/sn/addrs.h>
16#include <asm/sn/arch.h>
17
18#if defined(CONFIG_SGI_IP27)
19#include <asm/sn/sn0/hub.h>
20#elif defined(CONFIG_SGI_IP35)
21#include <asm/sn/sn1/hub.h>
22#endif /* !CONFIG_SGI_IP27 && !CONFIG_SGI_IP35 */
23
24/*
25 * NIC register macros
26 */
27
28#if defined(CONFIG_SGI_IP27)
29#define HUB_NIC_ADDR(_cpuid) \
30 REMOTE_HUB_ADDR(COMPACT_TO_NASID_NODEID(cpu_to_node(_cpuid)), \
31 MD_MLAN_CTL)
32#endif
33
34#define SET_HUB_NIC(_my_cpuid, _val) \
35 (HUB_S(HUB_NIC_ADDR(_my_cpuid), (_val)))
36
37#define SET_MY_HUB_NIC(_v) \
38 SET_HUB_NIC(cpuid(), (_v))
39
40#define GET_HUB_NIC(_my_cpuid) \
41 (HUB_L(HUB_NIC_ADDR(_my_cpuid)))
42
43#define GET_MY_HUB_NIC() \
44 GET_HUB_NIC(cpuid())
45
46#endif /* _ASM_SGI_SN_AGENT_H */
diff --git a/arch/mips/include/asm/sn/arch.h b/arch/mips/include/asm/sn/arch.h
new file mode 100644
index 000000000000..bd75945e10ff
--- /dev/null
+++ b/arch/mips/include/asm/sn/arch.h
@@ -0,0 +1,64 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * SGI specific setup.
7 *
8 * Copyright (C) 1995 - 1997, 1999 Silcon Graphics, Inc.
9 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
10 */
11#ifndef _ASM_SN_ARCH_H
12#define _ASM_SN_ARCH_H
13
14#include <linux/types.h>
15#include <asm/sn/types.h>
16#ifdef CONFIG_SGI_IP27
17#include <asm/sn/sn0/arch.h>
18#endif
19
20typedef u64 hubreg_t;
21
22#define cputonasid(cpu) (sn_cpu_info[(cpu)].p_nasid)
23#define cputoslice(cpu) (sn_cpu_info[(cpu)].p_slice)
24#define makespnum(_nasid, _slice) \
25 (((_nasid) << CPUS_PER_NODE_SHFT) | (_slice))
26
27#define INVALID_NASID (nasid_t)-1
28#define INVALID_CNODEID (cnodeid_t)-1
29#define INVALID_PNODEID (pnodeid_t)-1
30#define INVALID_MODULE (moduleid_t)-1
31#define INVALID_PARTID (partid_t)-1
32
33extern nasid_t get_nasid(void);
34extern cnodeid_t get_cpu_cnode(cpuid_t);
35extern int get_cpu_slice(cpuid_t);
36
37/*
38 * NO ONE should access these arrays directly. The only reason we refer to
39 * them here is to avoid the procedure call that would be required in the
40 * macros below. (Really want private data members here :-)
41 */
42extern cnodeid_t nasid_to_compact_node[MAX_NASIDS];
43extern nasid_t compact_to_nasid_node[MAX_COMPACT_NODES];
44
45/*
46 * These macros are used by various parts of the kernel to convert
47 * between the three different kinds of node numbering. At least some
48 * of them may change to procedure calls in the future, but the macros
49 * will continue to work. Don't use the arrays above directly.
50 */
51
52#define NASID_TO_REGION(nnode) \
53 ((nnode) >> \
54 (is_fine_dirmode() ? NASID_TO_FINEREG_SHFT : NASID_TO_COARSEREG_SHFT))
55
56extern cnodeid_t nasid_to_compact_node[MAX_NASIDS];
57extern nasid_t compact_to_nasid_node[MAX_COMPACT_NODES];
58extern cnodeid_t cpuid_to_compact_node[MAXCPUS];
59
60#define NASID_TO_COMPACT_NODEID(nnode) (nasid_to_compact_node[nnode])
61#define COMPACT_TO_NASID_NODEID(cnode) (compact_to_nasid_node[cnode])
62#define CPUID_TO_COMPACT_NODEID(cpu) (cpuid_to_compact_node[(cpu)])
63
64#endif /* _ASM_SN_ARCH_H */
diff --git a/arch/mips/include/asm/sn/fru.h b/arch/mips/include/asm/sn/fru.h
new file mode 100644
index 000000000000..b3e3606723b7
--- /dev/null
+++ b/arch/mips/include/asm/sn/fru.h
@@ -0,0 +1,44 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/SN0/sn0_fru.h>
7 *
8 * Copyright (C) 1992 - 1997, 1999 Silcon Graphics, Inc.
9 * Copyright (C) 1999, 2006 Ralf Baechle (ralf@linux-mips)
10 */
11#ifndef __ASM_SN_FRU_H
12#define __ASM_SN_FRU_H
13
14#define MAX_DIMMS 8 /* max # of dimm banks */
15#define MAX_PCIDEV 8 /* max # of pci devices on a pci bus */
16
17typedef unsigned char confidence_t;
18
19typedef struct kf_mem_s {
20 confidence_t km_confidence; /* confidence level that the memory is bad
21 * is this necessary ?
22 */
23 confidence_t km_dimm[MAX_DIMMS];
24 /* confidence level that dimm[i] is bad
25 *I think this is the right number
26 */
27
28} kf_mem_t;
29
30typedef struct kf_cpu_s {
31 confidence_t kc_confidence; /* confidence level that cpu is bad */
32 confidence_t kc_icache; /* confidence level that instr. cache is bad */
33 confidence_t kc_dcache; /* confidence level that data cache is bad */
34 confidence_t kc_scache; /* confidence level that sec. cache is bad */
35 confidence_t kc_sysbus; /* confidence level that sysad/cmd/state bus is bad */
36} kf_cpu_t;
37
38typedef struct kf_pci_bus_s {
39 confidence_t kpb_belief; /* confidence level that the pci bus is bad */
40 confidence_t kpb_pcidev_belief[MAX_PCIDEV];
41 /* confidence level that the pci dev is bad */
42} kf_pci_bus_t;
43
44#endif /* __ASM_SN_FRU_H */
diff --git a/arch/mips/include/asm/sn/gda.h b/arch/mips/include/asm/sn/gda.h
new file mode 100644
index 000000000000..9cb6ff770915
--- /dev/null
+++ b/arch/mips/include/asm/sn/gda.h
@@ -0,0 +1,107 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/gda.h>.
7 *
8 * Copyright (C) 1992 - 1997, 2000 Silicon Graphics, Inc.
9 *
10 * gda.h -- Contains the data structure for the global data area,
11 * The GDA contains information communicated between the
12 * PROM, SYMMON, and the kernel.
13 */
14#ifndef _ASM_SN_GDA_H
15#define _ASM_SN_GDA_H
16
17#include <asm/sn/addrs.h>
18
19#define GDA_MAGIC 0x58464552
20
21/*
22 * GDA Version History
23 *
24 * Version # | Change
25 * -------------+-------------------------------------------------------
26 * 1 | Initial SN0 version
27 * 2 | Prom sets g_partid field to the partition number. 0 IS
28 * | a valid partition #.
29 */
30
31#define GDA_VERSION 2 /* Current GDA version # */
32
33#define G_MAGICOFF 0
34#define G_VERSIONOFF 4
35#define G_PROMOPOFF 6
36#define G_MASTEROFF 8
37#define G_VDSOFF 12
38#define G_HKDNORMOFF 16
39#define G_HKDUTLBOFF 24
40#define G_HKDXUTLBOFF 32
41#define G_PARTIDOFF 40
42#define G_TABLEOFF 128
43
44#ifndef __ASSEMBLY__
45
46typedef struct gda {
47 u32 g_magic; /* GDA magic number */
48 u16 g_version; /* Version of this structure */
49 u16 g_masterid; /* The NASID:CPUNUM of the master cpu */
50 u32 g_promop; /* Passes requests from the kernel to prom */
51 u32 g_vds; /* Store the virtual dipswitches here */
52 void **g_hooked_norm;/* ptr to pda loc for norm hndlr */
53 void **g_hooked_utlb;/* ptr to pda loc for utlb hndlr */
54 void **g_hooked_xtlb;/* ptr to pda loc for xtlb hndlr */
55 int g_partid; /* partition id */
56 int g_symmax; /* Max symbols in name table. */
57 void *g_dbstab; /* Address of idbg symbol table */
58 char *g_nametab; /* Address of idbg name table */
59 void *g_ktext_repmask;
60 /* Pointer to a mask of nodes with copies
61 * of the kernel. */
62 char g_padding[56]; /* pad out to 128 bytes */
63 nasid_t g_nasidtable[MAX_COMPACT_NODES]; /* NASID of each node,
64 * indexed by cnodeid.
65 */
66} gda_t;
67
68#define GDA ((gda_t*) GDA_ADDR(get_nasid()))
69
70#endif /* !__ASSEMBLY__ */
71/*
72 * Define: PART_GDA_VERSION
73 * Purpose: Define the minimum version of the GDA required, lower
74 * revisions assume GDA is NOT set up, and read partition
75 * information from the board info.
76 */
77#define PART_GDA_VERSION 2
78
79/*
80 * The following requests can be sent to the PROM during startup.
81 */
82
83#define PROMOP_MAGIC 0x0ead0000
84#define PROMOP_MAGIC_MASK 0x0fff0000
85
86#define PROMOP_BIST_SHIFT 11
87#define PROMOP_BIST_MASK (0x3 << 11)
88
89#define PROMOP_REG PI_ERR_STACK_ADDR_A
90
91#define PROMOP_INVALID (PROMOP_MAGIC | 0x00)
92#define PROMOP_HALT (PROMOP_MAGIC | 0x10)
93#define PROMOP_POWERDOWN (PROMOP_MAGIC | 0x20)
94#define PROMOP_RESTART (PROMOP_MAGIC | 0x30)
95#define PROMOP_REBOOT (PROMOP_MAGIC | 0x40)
96#define PROMOP_IMODE (PROMOP_MAGIC | 0x50)
97
98#define PROMOP_CMD_MASK 0x00f0
99#define PROMOP_OPTIONS_MASK 0xfff0
100
101#define PROMOP_SKIP_DIAGS 0x0100 /* don't bother running diags */
102#define PROMOP_SKIP_MEMINIT 0x0200 /* don't bother initing memory */
103#define PROMOP_SKIP_DEVINIT 0x0400 /* don't bother initing devices */
104#define PROMOP_BIST1 0x0800 /* keep track of which BIST ran */
105#define PROMOP_BIST2 0x1000 /* keep track of which BIST ran */
106
107#endif /* _ASM_SN_GDA_H */
diff --git a/arch/mips/include/asm/sn/hub.h b/arch/mips/include/asm/sn/hub.h
new file mode 100644
index 000000000000..1992d9254a08
--- /dev/null
+++ b/arch/mips/include/asm/sn/hub.h
@@ -0,0 +1,16 @@
1#ifndef __ASM_SN_HUB_H
2#define __ASM_SN_HUB_H
3
4#include <linux/types.h>
5#include <linux/cpumask.h>
6#include <asm/sn/types.h>
7#include <asm/sn/io.h>
8#include <asm/sn/klkernvars.h>
9#include <asm/xtalk/xtalk.h>
10
11/* ip27-hubio.c */
12extern unsigned long hub_pio_map(cnodeid_t cnode, xwidgetnum_t widget,
13 unsigned long xtalk_addr, size_t size);
14extern void hub_pio_init(cnodeid_t cnode);
15
16#endif /* __ASM_SN_HUB_H */
diff --git a/arch/mips/include/asm/sn/intr.h b/arch/mips/include/asm/sn/intr.h
new file mode 100644
index 000000000000..6718b644b970
--- /dev/null
+++ b/arch/mips/include/asm/sn/intr.h
@@ -0,0 +1,129 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1992 - 1997 Silicon Graphics, Inc.
7 */
8#ifndef __ASM_SN_INTR_H
9#define __ASM_SN_INTR_H
10
11/* Number of interrupt levels associated with each interrupt register. */
12#define N_INTPEND_BITS 64
13
14#define INT_PEND0_BASELVL 0
15#define INT_PEND1_BASELVL 64
16
17#define N_INTPENDJUNK_BITS 8
18#define INTPENDJUNK_CLRBIT 0x80
19
20/*
21 * Macros to manipulate the interrupt register on the calling hub chip.
22 */
23
24#define LOCAL_HUB_SEND_INTR(level) \
25 LOCAL_HUB_S(PI_INT_PEND_MOD, (0x100 | (level)))
26#define REMOTE_HUB_SEND_INTR(hub, level) \
27 REMOTE_HUB_S((hub), PI_INT_PEND_MOD, (0x100 | (level)))
28
29/*
30 * When clearing the interrupt, make sure this clear does make it
31 * to the hub. Otherwise we could end up losing interrupts.
32 * We do an uncached load of the int_pend0 register to ensure this.
33 */
34
35#define LOCAL_HUB_CLR_INTR(level) \
36do { \
37 LOCAL_HUB_S(PI_INT_PEND_MOD, (level)); \
38 LOCAL_HUB_L(PI_INT_PEND0); \
39} while (0);
40
41#define REMOTE_HUB_CLR_INTR(hub, level) \
42do { \
43 nasid_t __hub = (hub); \
44 \
45 REMOTE_HUB_S(__hub, PI_INT_PEND_MOD, (level)); \
46 REMOTE_HUB_L(__hub, PI_INT_PEND0); \
47} while (0);
48
49/*
50 * Hard-coded interrupt levels:
51 */
52
53/*
54 * L0 = SW1
55 * L1 = SW2
56 * L2 = INT_PEND0
57 * L3 = INT_PEND1
58 * L4 = RTC
59 * L5 = Profiling Timer
60 * L6 = Hub Errors
61 * L7 = Count/Compare (T5 counters)
62 */
63
64
65/*
66 * INT_PEND0 hard-coded bits.
67 */
68
69/*
70 * INT_PEND0 bits determined by hardware:
71 */
72#define RESERVED_INTR 0 /* What is this bit? */
73#define GFX_INTR_A 1
74#define GFX_INTR_B 2
75#define PG_MIG_INTR 3
76#define UART_INTR 4
77#define CC_PEND_A 5
78#define CC_PEND_B 6
79
80/*
81 * INT_PEND0 used by the kernel for itself ...
82 */
83#define CPU_RESCHED_A_IRQ 7
84#define CPU_RESCHED_B_IRQ 8
85#define CPU_CALL_A_IRQ 9
86#define CPU_CALL_B_IRQ 10
87#define MSC_MESG_INTR 11
88#define BASE_PCI_IRQ 12
89
90/*
91 * INT_PEND0 again, bits determined by hardware / hardcoded:
92 */
93#define SDISK_INTR 63 /* SABLE name */
94#define IP_PEND0_6_63 63 /* What is this bit? */
95
96/*
97 * INT_PEND1 hard-coded bits:
98 */
99#define NI_BRDCAST_ERR_A 39
100#define NI_BRDCAST_ERR_B 40
101
102#define LLP_PFAIL_INTR_A 41 /* see ml/SN/SN0/sysctlr.c */
103#define LLP_PFAIL_INTR_B 42
104
105#define TLB_INTR_A 43 /* used for tlb flush random */
106#define TLB_INTR_B 44
107
108#define IP27_INTR_0 45 /* Reserved for PROM use */
109#define IP27_INTR_1 46 /* do not use in Kernel */
110#define IP27_INTR_2 47
111#define IP27_INTR_3 48
112#define IP27_INTR_4 49
113#define IP27_INTR_5 50
114#define IP27_INTR_6 51
115#define IP27_INTR_7 52
116
117#define BRIDGE_ERROR_INTR 53 /* Setup by PROM to catch */
118 /* Bridge Errors */
119#define DEBUG_INTR_A 54
120#define DEBUG_INTR_B 55 /* Used by symmon to stop all cpus */
121#define IO_ERROR_INTR 57 /* Setup by PROM */
122#define CLK_ERR_INTR 58
123#define COR_ERR_INTR_A 59
124#define COR_ERR_INTR_B 60
125#define MD_COR_ERR_INTR 61
126#define NI_ERROR_INTR 62
127#define MSC_PANIC_INTR 63
128
129#endif /* __ASM_SN_INTR_H */
diff --git a/arch/mips/include/asm/sn/io.h b/arch/mips/include/asm/sn/io.h
new file mode 100644
index 000000000000..24c6775fbb0f
--- /dev/null
+++ b/arch/mips/include/asm/sn/io.h
@@ -0,0 +1,59 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000, 2003 Ralf Baechle
7 * Copyright (C) 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_SN_IO_H
10#define _ASM_SN_IO_H
11
12#if defined(CONFIG_SGI_IP27)
13#include <asm/sn/sn0/hubio.h>
14#endif
15
16
17#define IIO_ITTE_BASE 0x400160 /* base of translation table entries */
18#define IIO_ITTE(bigwin) (IIO_ITTE_BASE + 8*(bigwin))
19
20#define IIO_ITTE_OFFSET_BITS 5 /* size of offset field */
21#define IIO_ITTE_OFFSET_MASK ((1<<IIO_ITTE_OFFSET_BITS)-1)
22#define IIO_ITTE_OFFSET_SHIFT 0
23
24#define IIO_ITTE_WIDGET_BITS 4 /* size of widget field */
25#define IIO_ITTE_WIDGET_MASK ((1<<IIO_ITTE_WIDGET_BITS)-1)
26#define IIO_ITTE_WIDGET_SHIFT 8
27
28#define IIO_ITTE_IOSP 1 /* I/O Space bit */
29#define IIO_ITTE_IOSP_MASK 1
30#define IIO_ITTE_IOSP_SHIFT 12
31#define HUB_PIO_MAP_TO_MEM 0
32#define HUB_PIO_MAP_TO_IO 1
33
34#define IIO_ITTE_INVALID_WIDGET 3 /* an invalid widget */
35
36#define IIO_ITTE_PUT(nasid, bigwin, io_or_mem, widget, addr) \
37 REMOTE_HUB_S((nasid), IIO_ITTE(bigwin), \
38 (((((addr) >> BWIN_SIZE_BITS) & \
39 IIO_ITTE_OFFSET_MASK) << IIO_ITTE_OFFSET_SHIFT) | \
40 (io_or_mem << IIO_ITTE_IOSP_SHIFT) | \
41 (((widget) & IIO_ITTE_WIDGET_MASK) << IIO_ITTE_WIDGET_SHIFT)))
42
43#define IIO_ITTE_DISABLE(nasid, bigwin) \
44 IIO_ITTE_PUT((nasid), HUB_PIO_MAP_TO_MEM, \
45 (bigwin), IIO_ITTE_INVALID_WIDGET, 0)
46
47#define IIO_ITTE_GET(nasid, bigwin) REMOTE_HUB_ADDR((nasid), IIO_ITTE(bigwin))
48
49/*
50 * Macro which takes the widget number, and returns the
51 * IO PRB address of that widget.
52 * value _x is expected to be a widget number in the range
53 * 0, 8 - 0xF
54 */
55#define IIO_IOPRB(_x) (IIO_IOPRB_0 + ( ( (_x) < HUB_WIDGET_ID_MIN ? \
56 (_x) : \
57 (_x) - (HUB_WIDGET_ID_MIN-1)) << 3) )
58
59#endif /* _ASM_SN_IO_H */
diff --git a/arch/mips/include/asm/sn/ioc3.h b/arch/mips/include/asm/sn/ioc3.h
new file mode 100644
index 000000000000..099677774d71
--- /dev/null
+++ b/arch/mips/include/asm/sn/ioc3.h
@@ -0,0 +1,663 @@
1/*
2 * Copyright (C) 1999, 2000 Ralf Baechle
3 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
4 */
5#ifndef _IOC3_H
6#define _IOC3_H
7
8#include <linux/types.h>
9
10/* SUPERIO uart register map */
11typedef volatile struct ioc3_uartregs {
12 union {
13 volatile u8 rbr; /* read only, DLAB == 0 */
14 volatile u8 thr; /* write only, DLAB == 0 */
15 volatile u8 dll; /* DLAB == 1 */
16 } u1;
17 union {
18 volatile u8 ier; /* DLAB == 0 */
19 volatile u8 dlm; /* DLAB == 1 */
20 } u2;
21 union {
22 volatile u8 iir; /* read only */
23 volatile u8 fcr; /* write only */
24 } u3;
25 volatile u8 iu_lcr;
26 volatile u8 iu_mcr;
27 volatile u8 iu_lsr;
28 volatile u8 iu_msr;
29 volatile u8 iu_scr;
30} ioc3_uregs_t;
31
32#define iu_rbr u1.rbr
33#define iu_thr u1.thr
34#define iu_dll u1.dll
35#define iu_ier u2.ier
36#define iu_dlm u2.dlm
37#define iu_iir u3.iir
38#define iu_fcr u3.fcr
39
40struct ioc3_sioregs {
41 volatile u8 fill[0x141]; /* starts at 0x141 */
42
43 volatile u8 uartc;
44 volatile u8 kbdcg;
45
46 volatile u8 fill0[0x150 - 0x142 - 1];
47
48 volatile u8 pp_data;
49 volatile u8 pp_dsr;
50 volatile u8 pp_dcr;
51
52 volatile u8 fill1[0x158 - 0x152 - 1];
53
54 volatile u8 pp_fifa;
55 volatile u8 pp_cfgb;
56 volatile u8 pp_ecr;
57
58 volatile u8 fill2[0x168 - 0x15a - 1];
59
60 volatile u8 rtcad;
61 volatile u8 rtcdat;
62
63 volatile u8 fill3[0x170 - 0x169 - 1];
64
65 struct ioc3_uartregs uartb; /* 0x20170 */
66 struct ioc3_uartregs uarta; /* 0x20178 */
67};
68
69/* Register layout of IOC3 in configuration space. */
70struct ioc3 {
71 volatile u32 pad0[7]; /* 0x00000 */
72 volatile u32 sio_ir; /* 0x0001c */
73 volatile u32 sio_ies; /* 0x00020 */
74 volatile u32 sio_iec; /* 0x00024 */
75 volatile u32 sio_cr; /* 0x00028 */
76 volatile u32 int_out; /* 0x0002c */
77 volatile u32 mcr; /* 0x00030 */
78
79 /* General Purpose I/O registers */
80 volatile u32 gpcr_s; /* 0x00034 */
81 volatile u32 gpcr_c; /* 0x00038 */
82 volatile u32 gpdr; /* 0x0003c */
83 volatile u32 gppr_0; /* 0x00040 */
84 volatile u32 gppr_1; /* 0x00044 */
85 volatile u32 gppr_2; /* 0x00048 */
86 volatile u32 gppr_3; /* 0x0004c */
87 volatile u32 gppr_4; /* 0x00050 */
88 volatile u32 gppr_5; /* 0x00054 */
89 volatile u32 gppr_6; /* 0x00058 */
90 volatile u32 gppr_7; /* 0x0005c */
91 volatile u32 gppr_8; /* 0x00060 */
92 volatile u32 gppr_9; /* 0x00064 */
93 volatile u32 gppr_10; /* 0x00068 */
94 volatile u32 gppr_11; /* 0x0006c */
95 volatile u32 gppr_12; /* 0x00070 */
96 volatile u32 gppr_13; /* 0x00074 */
97 volatile u32 gppr_14; /* 0x00078 */
98 volatile u32 gppr_15; /* 0x0007c */
99
100 /* Parallel Port Registers */
101 volatile u32 ppbr_h_a; /* 0x00080 */
102 volatile u32 ppbr_l_a; /* 0x00084 */
103 volatile u32 ppcr_a; /* 0x00088 */
104 volatile u32 ppcr; /* 0x0008c */
105 volatile u32 ppbr_h_b; /* 0x00090 */
106 volatile u32 ppbr_l_b; /* 0x00094 */
107 volatile u32 ppcr_b; /* 0x00098 */
108
109 /* Keyboard and Mouse Registers */
110 volatile u32 km_csr; /* 0x0009c */
111 volatile u32 k_rd; /* 0x000a0 */
112 volatile u32 m_rd; /* 0x000a4 */
113 volatile u32 k_wd; /* 0x000a8 */
114 volatile u32 m_wd; /* 0x000ac */
115
116 /* Serial Port Registers */
117 volatile u32 sbbr_h; /* 0x000b0 */
118 volatile u32 sbbr_l; /* 0x000b4 */
119 volatile u32 sscr_a; /* 0x000b8 */
120 volatile u32 stpir_a; /* 0x000bc */
121 volatile u32 stcir_a; /* 0x000c0 */
122 volatile u32 srpir_a; /* 0x000c4 */
123 volatile u32 srcir_a; /* 0x000c8 */
124 volatile u32 srtr_a; /* 0x000cc */
125 volatile u32 shadow_a; /* 0x000d0 */
126 volatile u32 sscr_b; /* 0x000d4 */
127 volatile u32 stpir_b; /* 0x000d8 */
128 volatile u32 stcir_b; /* 0x000dc */
129 volatile u32 srpir_b; /* 0x000e0 */
130 volatile u32 srcir_b; /* 0x000e4 */
131 volatile u32 srtr_b; /* 0x000e8 */
132 volatile u32 shadow_b; /* 0x000ec */
133
134 /* Ethernet Registers */
135 volatile u32 emcr; /* 0x000f0 */
136 volatile u32 eisr; /* 0x000f4 */
137 volatile u32 eier; /* 0x000f8 */
138 volatile u32 ercsr; /* 0x000fc */
139 volatile u32 erbr_h; /* 0x00100 */
140 volatile u32 erbr_l; /* 0x00104 */
141 volatile u32 erbar; /* 0x00108 */
142 volatile u32 ercir; /* 0x0010c */
143 volatile u32 erpir; /* 0x00110 */
144 volatile u32 ertr; /* 0x00114 */
145 volatile u32 etcsr; /* 0x00118 */
146 volatile u32 ersr; /* 0x0011c */
147 volatile u32 etcdc; /* 0x00120 */
148 volatile u32 ebir; /* 0x00124 */
149 volatile u32 etbr_h; /* 0x00128 */
150 volatile u32 etbr_l; /* 0x0012c */
151 volatile u32 etcir; /* 0x00130 */
152 volatile u32 etpir; /* 0x00134 */
153 volatile u32 emar_h; /* 0x00138 */
154 volatile u32 emar_l; /* 0x0013c */
155 volatile u32 ehar_h; /* 0x00140 */
156 volatile u32 ehar_l; /* 0x00144 */
157 volatile u32 micr; /* 0x00148 */
158 volatile u32 midr_r; /* 0x0014c */
159 volatile u32 midr_w; /* 0x00150 */
160 volatile u32 pad1[(0x20000 - 0x00154) / 4];
161
162 /* SuperIO Registers XXX */
163 struct ioc3_sioregs sregs; /* 0x20000 */
164 volatile u32 pad2[(0x40000 - 0x20180) / 4];
165
166 /* SSRAM Diagnostic Access */
167 volatile u32 ssram[(0x80000 - 0x40000) / 4];
168
169 /* Bytebus device offsets
170 0x80000 - Access to the generic devices selected with DEV0
171 0x9FFFF bytebus DEV_SEL_0
172 0xA0000 - Access to the generic devices selected with DEV1
173 0xBFFFF bytebus DEV_SEL_1
174 0xC0000 - Access to the generic devices selected with DEV2
175 0xDFFFF bytebus DEV_SEL_2
176 0xE0000 - Access to the generic devices selected with DEV3
177 0xFFFFF bytebus DEV_SEL_3 */
178};
179
180/*
181 * Ethernet RX Buffer
182 */
183struct ioc3_erxbuf {
184 u32 w0; /* first word (valid,bcnt,cksum) */
185 u32 err; /* second word various errors */
186 /* next comes n bytes of padding */
187 /* then the received ethernet frame itself */
188};
189
190#define ERXBUF_IPCKSUM_MASK 0x0000ffff
191#define ERXBUF_BYTECNT_MASK 0x07ff0000
192#define ERXBUF_BYTECNT_SHIFT 16
193#define ERXBUF_V 0x80000000
194
195#define ERXBUF_CRCERR 0x00000001 /* aka RSV15 */
196#define ERXBUF_FRAMERR 0x00000002 /* aka RSV14 */
197#define ERXBUF_CODERR 0x00000004 /* aka RSV13 */
198#define ERXBUF_INVPREAMB 0x00000008 /* aka RSV18 */
199#define ERXBUF_LOLEN 0x00007000 /* aka RSV2_0 */
200#define ERXBUF_HILEN 0x03ff0000 /* aka RSV12_3 */
201#define ERXBUF_MULTICAST 0x04000000 /* aka RSV16 */
202#define ERXBUF_BROADCAST 0x08000000 /* aka RSV17 */
203#define ERXBUF_LONGEVENT 0x10000000 /* aka RSV19 */
204#define ERXBUF_BADPKT 0x20000000 /* aka RSV20 */
205#define ERXBUF_GOODPKT 0x40000000 /* aka RSV21 */
206#define ERXBUF_CARRIER 0x80000000 /* aka RSV22 */
207
208/*
209 * Ethernet TX Descriptor
210 */
211#define ETXD_DATALEN 104
212struct ioc3_etxd {
213 u32 cmd; /* command field */
214 u32 bufcnt; /* buffer counts field */
215 u64 p1; /* buffer pointer 1 */
216 u64 p2; /* buffer pointer 2 */
217 u8 data[ETXD_DATALEN]; /* opt. tx data */
218};
219
220#define ETXD_BYTECNT_MASK 0x000007ff /* total byte count */
221#define ETXD_INTWHENDONE 0x00001000 /* intr when done */
222#define ETXD_D0V 0x00010000 /* data 0 valid */
223#define ETXD_B1V 0x00020000 /* buf 1 valid */
224#define ETXD_B2V 0x00040000 /* buf 2 valid */
225#define ETXD_DOCHECKSUM 0x00080000 /* insert ip cksum */
226#define ETXD_CHKOFF_MASK 0x07f00000 /* cksum byte offset */
227#define ETXD_CHKOFF_SHIFT 20
228
229#define ETXD_D0CNT_MASK 0x0000007f
230#define ETXD_B1CNT_MASK 0x0007ff00
231#define ETXD_B1CNT_SHIFT 8
232#define ETXD_B2CNT_MASK 0x7ff00000
233#define ETXD_B2CNT_SHIFT 20
234
235/*
236 * Bytebus device space
237 */
238#define IOC3_BYTEBUS_DEV0 0x80000L
239#define IOC3_BYTEBUS_DEV1 0xa0000L
240#define IOC3_BYTEBUS_DEV2 0xc0000L
241#define IOC3_BYTEBUS_DEV3 0xe0000L
242
243/* ------------------------------------------------------------------------- */
244
245/* Superio Registers (PIO Access) */
246#define IOC3_SIO_BASE 0x20000
247#define IOC3_SIO_UARTC (IOC3_SIO_BASE+0x141) /* UART Config */
248#define IOC3_SIO_KBDCG (IOC3_SIO_BASE+0x142) /* KBD Config */
249#define IOC3_SIO_PP_BASE (IOC3_SIO_BASE+PP_BASE) /* Parallel Port */
250#define IOC3_SIO_RTC_BASE (IOC3_SIO_BASE+0x168) /* Real Time Clock */
251#define IOC3_SIO_UB_BASE (IOC3_SIO_BASE+UARTB_BASE) /* UART B */
252#define IOC3_SIO_UA_BASE (IOC3_SIO_BASE+UARTA_BASE) /* UART A */
253
254/* SSRAM Diagnostic Access */
255#define IOC3_SSRAM IOC3_RAM_OFF /* base of SSRAM diagnostic access */
256#define IOC3_SSRAM_LEN 0x40000 /* 256kb (address space size, may not be fully populated) */
257#define IOC3_SSRAM_DM 0x0000ffff /* data mask */
258#define IOC3_SSRAM_PM 0x00010000 /* parity mask */
259
260/* bitmasks for PCI_SCR */
261#define PCI_SCR_PAR_RESP_EN 0x00000040 /* enb PCI parity checking */
262#define PCI_SCR_SERR_EN 0x00000100 /* enable the SERR# driver */
263#define PCI_SCR_DROP_MODE_EN 0x00008000 /* drop pios on parity err */
264#define PCI_SCR_RX_SERR (0x1 << 16)
265#define PCI_SCR_DROP_MODE (0x1 << 17)
266#define PCI_SCR_SIG_PAR_ERR (0x1 << 24)
267#define PCI_SCR_SIG_TAR_ABRT (0x1 << 27)
268#define PCI_SCR_RX_TAR_ABRT (0x1 << 28)
269#define PCI_SCR_SIG_MST_ABRT (0x1 << 29)
270#define PCI_SCR_SIG_SERR (0x1 << 30)
271#define PCI_SCR_PAR_ERR (0x1 << 31)
272
273/* bitmasks for IOC3_KM_CSR */
274#define KM_CSR_K_WRT_PEND 0x00000001 /* kbd port xmitting or resetting */
275#define KM_CSR_M_WRT_PEND 0x00000002 /* mouse port xmitting or resetting */
276#define KM_CSR_K_LCB 0x00000004 /* Line Cntrl Bit for last KBD write */
277#define KM_CSR_M_LCB 0x00000008 /* same for mouse */
278#define KM_CSR_K_DATA 0x00000010 /* state of kbd data line */
279#define KM_CSR_K_CLK 0x00000020 /* state of kbd clock line */
280#define KM_CSR_K_PULL_DATA 0x00000040 /* pull kbd data line low */
281#define KM_CSR_K_PULL_CLK 0x00000080 /* pull kbd clock line low */
282#define KM_CSR_M_DATA 0x00000100 /* state of ms data line */
283#define KM_CSR_M_CLK 0x00000200 /* state of ms clock line */
284#define KM_CSR_M_PULL_DATA 0x00000400 /* pull ms data line low */
285#define KM_CSR_M_PULL_CLK 0x00000800 /* pull ms clock line low */
286#define KM_CSR_EMM_MODE 0x00001000 /* emulation mode */
287#define KM_CSR_SIM_MODE 0x00002000 /* clock X8 */
288#define KM_CSR_K_SM_IDLE 0x00004000 /* Keyboard is idle */
289#define KM_CSR_M_SM_IDLE 0x00008000 /* Mouse is idle */
290#define KM_CSR_K_TO 0x00010000 /* Keyboard trying to send/receive */
291#define KM_CSR_M_TO 0x00020000 /* Mouse trying to send/receive */
292#define KM_CSR_K_TO_EN 0x00040000 /* KM_CSR_K_TO + KM_CSR_K_TO_EN = cause
293 SIO_IR to assert */
294#define KM_CSR_M_TO_EN 0x00080000 /* KM_CSR_M_TO + KM_CSR_M_TO_EN = cause
295 SIO_IR to assert */
296#define KM_CSR_K_CLAMP_ONE 0x00100000 /* Pull K_CLK low after rec. one char */
297#define KM_CSR_M_CLAMP_ONE 0x00200000 /* Pull M_CLK low after rec. one char */
298#define KM_CSR_K_CLAMP_THREE 0x00400000 /* Pull K_CLK low after rec. three chars */
299#define KM_CSR_M_CLAMP_THREE 0x00800000 /* Pull M_CLK low after rec. three char */
300
301/* bitmasks for IOC3_K_RD and IOC3_M_RD */
302#define KM_RD_DATA_2 0x000000ff /* 3rd char recvd since last read */
303#define KM_RD_DATA_2_SHIFT 0
304#define KM_RD_DATA_1 0x0000ff00 /* 2nd char recvd since last read */
305#define KM_RD_DATA_1_SHIFT 8
306#define KM_RD_DATA_0 0x00ff0000 /* 1st char recvd since last read */
307#define KM_RD_DATA_0_SHIFT 16
308#define KM_RD_FRAME_ERR_2 0x01000000 /* framing or parity error in byte 2 */
309#define KM_RD_FRAME_ERR_1 0x02000000 /* same for byte 1 */
310#define KM_RD_FRAME_ERR_0 0x04000000 /* same for byte 0 */
311
312#define KM_RD_KBD_MSE 0x08000000 /* 0 if from kbd, 1 if from mouse */
313#define KM_RD_OFLO 0x10000000 /* 4th char recvd before this read */
314#define KM_RD_VALID_2 0x20000000 /* DATA_2 valid */
315#define KM_RD_VALID_1 0x40000000 /* DATA_1 valid */
316#define KM_RD_VALID_0 0x80000000 /* DATA_0 valid */
317#define KM_RD_VALID_ALL (KM_RD_VALID_0|KM_RD_VALID_1|KM_RD_VALID_2)
318
319/* bitmasks for IOC3_K_WD & IOC3_M_WD */
320#define KM_WD_WRT_DATA 0x000000ff /* write to keyboard/mouse port */
321#define KM_WD_WRT_DATA_SHIFT 0
322
323/* bitmasks for serial RX status byte */
324#define RXSB_OVERRUN 0x01 /* char(s) lost */
325#define RXSB_PAR_ERR 0x02 /* parity error */
326#define RXSB_FRAME_ERR 0x04 /* framing error */
327#define RXSB_BREAK 0x08 /* break character */
328#define RXSB_CTS 0x10 /* state of CTS */
329#define RXSB_DCD 0x20 /* state of DCD */
330#define RXSB_MODEM_VALID 0x40 /* DCD, CTS and OVERRUN are valid */
331#define RXSB_DATA_VALID 0x80 /* data byte, FRAME_ERR PAR_ERR & BREAK valid */
332
333/* bitmasks for serial TX control byte */
334#define TXCB_INT_WHEN_DONE 0x20 /* interrupt after this byte is sent */
335#define TXCB_INVALID 0x00 /* byte is invalid */
336#define TXCB_VALID 0x40 /* byte is valid */
337#define TXCB_MCR 0x80 /* data<7:0> to modem control register */
338#define TXCB_DELAY 0xc0 /* delay data<7:0> mSec */
339
340/* bitmasks for IOC3_SBBR_L */
341#define SBBR_L_SIZE 0x00000001 /* 0 == 1KB rings, 1 == 4KB rings */
342#define SBBR_L_BASE 0xfffff000 /* lower serial ring base addr */
343
344/* bitmasks for IOC3_SSCR_<A:B> */
345#define SSCR_RX_THRESHOLD 0x000001ff /* hiwater mark */
346#define SSCR_TX_TIMER_BUSY 0x00010000 /* TX timer in progress */
347#define SSCR_HFC_EN 0x00020000 /* hardware flow control enabled */
348#define SSCR_RX_RING_DCD 0x00040000 /* post RX record on delta-DCD */
349#define SSCR_RX_RING_CTS 0x00080000 /* post RX record on delta-CTS */
350#define SSCR_HIGH_SPD 0x00100000 /* 4X speed */
351#define SSCR_DIAG 0x00200000 /* bypass clock divider for sim */
352#define SSCR_RX_DRAIN 0x08000000 /* drain RX buffer to memory */
353#define SSCR_DMA_EN 0x10000000 /* enable ring buffer DMA */
354#define SSCR_DMA_PAUSE 0x20000000 /* pause DMA */
355#define SSCR_PAUSE_STATE 0x40000000 /* sets when PAUSE takes effect */
356#define SSCR_RESET 0x80000000 /* reset DMA channels */
357
358/* all producer/comsumer pointers are the same bitfield */
359#define PROD_CONS_PTR_4K 0x00000ff8 /* for 4K buffers */
360#define PROD_CONS_PTR_1K 0x000003f8 /* for 1K buffers */
361#define PROD_CONS_PTR_OFF 3
362
363/* bitmasks for IOC3_SRCIR_<A:B> */
364#define SRCIR_ARM 0x80000000 /* arm RX timer */
365
366/* bitmasks for IOC3_SRPIR_<A:B> */
367#define SRPIR_BYTE_CNT 0x07000000 /* bytes in packer */
368#define SRPIR_BYTE_CNT_SHIFT 24
369
370/* bitmasks for IOC3_STCIR_<A:B> */
371#define STCIR_BYTE_CNT 0x0f000000 /* bytes in unpacker */
372#define STCIR_BYTE_CNT_SHIFT 24
373
374/* bitmasks for IOC3_SHADOW_<A:B> */
375#define SHADOW_DR 0x00000001 /* data ready */
376#define SHADOW_OE 0x00000002 /* overrun error */
377#define SHADOW_PE 0x00000004 /* parity error */
378#define SHADOW_FE 0x00000008 /* framing error */
379#define SHADOW_BI 0x00000010 /* break interrupt */
380#define SHADOW_THRE 0x00000020 /* transmit holding register empty */
381#define SHADOW_TEMT 0x00000040 /* transmit shift register empty */
382#define SHADOW_RFCE 0x00000080 /* char in RX fifo has an error */
383#define SHADOW_DCTS 0x00010000 /* delta clear to send */
384#define SHADOW_DDCD 0x00080000 /* delta data carrier detect */
385#define SHADOW_CTS 0x00100000 /* clear to send */
386#define SHADOW_DCD 0x00800000 /* data carrier detect */
387#define SHADOW_DTR 0x01000000 /* data terminal ready */
388#define SHADOW_RTS 0x02000000 /* request to send */
389#define SHADOW_OUT1 0x04000000 /* 16550 OUT1 bit */
390#define SHADOW_OUT2 0x08000000 /* 16550 OUT2 bit */
391#define SHADOW_LOOP 0x10000000 /* loopback enabled */
392
393/* bitmasks for IOC3_SRTR_<A:B> */
394#define SRTR_CNT 0x00000fff /* reload value for RX timer */
395#define SRTR_CNT_VAL 0x0fff0000 /* current value of RX timer */
396#define SRTR_CNT_VAL_SHIFT 16
397#define SRTR_HZ 16000 /* SRTR clock frequency */
398
399/* bitmasks for IOC3_SIO_IR, IOC3_SIO_IEC and IOC3_SIO_IES */
400#define SIO_IR_SA_TX_MT 0x00000001 /* Serial port A TX empty */
401#define SIO_IR_SA_RX_FULL 0x00000002 /* port A RX buf full */
402#define SIO_IR_SA_RX_HIGH 0x00000004 /* port A RX hiwat */
403#define SIO_IR_SA_RX_TIMER 0x00000008 /* port A RX timeout */
404#define SIO_IR_SA_DELTA_DCD 0x00000010 /* port A delta DCD */
405#define SIO_IR_SA_DELTA_CTS 0x00000020 /* port A delta CTS */
406#define SIO_IR_SA_INT 0x00000040 /* port A pass-thru intr */
407#define SIO_IR_SA_TX_EXPLICIT 0x00000080 /* port A explicit TX thru */
408#define SIO_IR_SA_MEMERR 0x00000100 /* port A PCI error */
409#define SIO_IR_SB_TX_MT 0x00000200 /* */
410#define SIO_IR_SB_RX_FULL 0x00000400 /* */
411#define SIO_IR_SB_RX_HIGH 0x00000800 /* */
412#define SIO_IR_SB_RX_TIMER 0x00001000 /* */
413#define SIO_IR_SB_DELTA_DCD 0x00002000 /* */
414#define SIO_IR_SB_DELTA_CTS 0x00004000 /* */
415#define SIO_IR_SB_INT 0x00008000 /* */
416#define SIO_IR_SB_TX_EXPLICIT 0x00010000 /* */
417#define SIO_IR_SB_MEMERR 0x00020000 /* */
418#define SIO_IR_PP_INT 0x00040000 /* P port pass-thru intr */
419#define SIO_IR_PP_INTA 0x00080000 /* PP context A thru */
420#define SIO_IR_PP_INTB 0x00100000 /* PP context B thru */
421#define SIO_IR_PP_MEMERR 0x00200000 /* PP PCI error */
422#define SIO_IR_KBD_INT 0x00400000 /* kbd/mouse intr */
423#define SIO_IR_RT_INT 0x08000000 /* RT output pulse */
424#define SIO_IR_GEN_INT1 0x10000000 /* RT input pulse */
425#define SIO_IR_GEN_INT_SHIFT 28
426
427/* per device interrupt masks */
428#define SIO_IR_SA (SIO_IR_SA_TX_MT | SIO_IR_SA_RX_FULL | \
429 SIO_IR_SA_RX_HIGH | SIO_IR_SA_RX_TIMER | \
430 SIO_IR_SA_DELTA_DCD | SIO_IR_SA_DELTA_CTS | \
431 SIO_IR_SA_INT | SIO_IR_SA_TX_EXPLICIT | \
432 SIO_IR_SA_MEMERR)
433#define SIO_IR_SB (SIO_IR_SB_TX_MT | SIO_IR_SB_RX_FULL | \
434 SIO_IR_SB_RX_HIGH | SIO_IR_SB_RX_TIMER | \
435 SIO_IR_SB_DELTA_DCD | SIO_IR_SB_DELTA_CTS | \
436 SIO_IR_SB_INT | SIO_IR_SB_TX_EXPLICIT | \
437 SIO_IR_SB_MEMERR)
438#define SIO_IR_PP (SIO_IR_PP_INT | SIO_IR_PP_INTA | \
439 SIO_IR_PP_INTB | SIO_IR_PP_MEMERR)
440#define SIO_IR_RT (SIO_IR_RT_INT | SIO_IR_GEN_INT1)
441
442/* macro to load pending interrupts */
443#define IOC3_PENDING_INTRS(mem) (PCI_INW(&((mem)->sio_ir)) & \
444 PCI_INW(&((mem)->sio_ies_ro)))
445
446/* bitmasks for SIO_CR */
447#define SIO_CR_SIO_RESET 0x00000001 /* reset the SIO */
448#define SIO_CR_SER_A_BASE 0x000000fe /* DMA poll addr port A */
449#define SIO_CR_SER_A_BASE_SHIFT 1
450#define SIO_CR_SER_B_BASE 0x00007f00 /* DMA poll addr port B */
451#define SIO_CR_SER_B_BASE_SHIFT 8
452#define SIO_SR_CMD_PULSE 0x00078000 /* byte bus strobe length */
453#define SIO_CR_CMD_PULSE_SHIFT 15
454#define SIO_CR_ARB_DIAG 0x00380000 /* cur !enet PCI requet (ro) */
455#define SIO_CR_ARB_DIAG_TXA 0x00000000
456#define SIO_CR_ARB_DIAG_RXA 0x00080000
457#define SIO_CR_ARB_DIAG_TXB 0x00100000
458#define SIO_CR_ARB_DIAG_RXB 0x00180000
459#define SIO_CR_ARB_DIAG_PP 0x00200000
460#define SIO_CR_ARB_DIAG_IDLE 0x00400000 /* 0 -> active request (ro) */
461
462/* bitmasks for INT_OUT */
463#define INT_OUT_COUNT 0x0000ffff /* pulse interval timer */
464#define INT_OUT_MODE 0x00070000 /* mode mask */
465#define INT_OUT_MODE_0 0x00000000 /* set output to 0 */
466#define INT_OUT_MODE_1 0x00040000 /* set output to 1 */
467#define INT_OUT_MODE_1PULSE 0x00050000 /* send 1 pulse */
468#define INT_OUT_MODE_PULSES 0x00060000 /* send 1 pulse every interval */
469#define INT_OUT_MODE_SQW 0x00070000 /* toggle output every interval */
470#define INT_OUT_DIAG 0x40000000 /* diag mode */
471#define INT_OUT_INT_OUT 0x80000000 /* current state of INT_OUT */
472
473/* time constants for INT_OUT */
474#define INT_OUT_NS_PER_TICK (30 * 260) /* 30 ns PCI clock, divisor=260 */
475#define INT_OUT_TICKS_PER_PULSE 3 /* outgoing pulse lasts 3 ticks */
476#define INT_OUT_US_TO_COUNT(x) /* convert uS to a count value */ \
477 (((x) * 10 + INT_OUT_NS_PER_TICK / 200) * \
478 100 / INT_OUT_NS_PER_TICK - 1)
479#define INT_OUT_COUNT_TO_US(x) /* convert count value to uS */ \
480 (((x) + 1) * INT_OUT_NS_PER_TICK / 1000)
481#define INT_OUT_MIN_TICKS 3 /* min period is width of pulse in "ticks" */
482#define INT_OUT_MAX_TICKS INT_OUT_COUNT /* largest possible count */
483
484/* bitmasks for GPCR */
485#define GPCR_DIR 0x000000ff /* tristate pin input or output */
486#define GPCR_DIR_PIN(x) (1<<(x)) /* access one of the DIR bits */
487#define GPCR_EDGE 0x000f0000 /* extint edge or level sensitive */
488#define GPCR_EDGE_PIN(x) (1<<((x)+15)) /* access one of the EDGE bits */
489
490/* values for GPCR */
491#define GPCR_INT_OUT_EN 0x00100000 /* enable INT_OUT to pin 0 */
492#define GPCR_MLAN_EN 0x00200000 /* enable MCR to pin 8 */
493#define GPCR_DIR_SERA_XCVR 0x00000080 /* Port A Transceiver select enable */
494#define GPCR_DIR_SERB_XCVR 0x00000040 /* Port B Transceiver select enable */
495#define GPCR_DIR_PHY_RST 0x00000020 /* ethernet PHY reset enable */
496
497/* defs for some of the generic I/O pins */
498#define GPCR_PHY_RESET 0x20 /* pin is output to PHY reset */
499#define GPCR_UARTB_MODESEL 0x40 /* pin is output to port B mode sel */
500#define GPCR_UARTA_MODESEL 0x80 /* pin is output to port A mode sel */
501
502#define GPPR_PHY_RESET_PIN 5 /* GIO pin controlling phy reset */
503#define GPPR_UARTB_MODESEL_PIN 6 /* GIO pin controlling uart b mode select */
504#define GPPR_UARTA_MODESEL_PIN 7 /* GIO pin controlling uart a mode select */
505
506#define EMCR_DUPLEX 0x00000001
507#define EMCR_PROMISC 0x00000002
508#define EMCR_PADEN 0x00000004
509#define EMCR_RXOFF_MASK 0x000001f8
510#define EMCR_RXOFF_SHIFT 3
511#define EMCR_RAMPAR 0x00000200
512#define EMCR_BADPAR 0x00000800
513#define EMCR_BUFSIZ 0x00001000
514#define EMCR_TXDMAEN 0x00002000
515#define EMCR_TXEN 0x00004000
516#define EMCR_RXDMAEN 0x00008000
517#define EMCR_RXEN 0x00010000
518#define EMCR_LOOPBACK 0x00020000
519#define EMCR_ARB_DIAG 0x001c0000
520#define EMCR_ARB_DIAG_IDLE 0x00200000
521#define EMCR_RST 0x80000000
522
523#define EISR_RXTIMERINT 0x00000001
524#define EISR_RXTHRESHINT 0x00000002
525#define EISR_RXOFLO 0x00000004
526#define EISR_RXBUFOFLO 0x00000008
527#define EISR_RXMEMERR 0x00000010
528#define EISR_RXPARERR 0x00000020
529#define EISR_TXEMPTY 0x00010000
530#define EISR_TXRTRY 0x00020000
531#define EISR_TXEXDEF 0x00040000
532#define EISR_TXLCOL 0x00080000
533#define EISR_TXGIANT 0x00100000
534#define EISR_TXBUFUFLO 0x00200000
535#define EISR_TXEXPLICIT 0x00400000
536#define EISR_TXCOLLWRAP 0x00800000
537#define EISR_TXDEFERWRAP 0x01000000
538#define EISR_TXMEMERR 0x02000000
539#define EISR_TXPARERR 0x04000000
540
541#define ERCSR_THRESH_MASK 0x000001ff /* enet RX threshold */
542#define ERCSR_RX_TMR 0x40000000 /* simulation only */
543#define ERCSR_DIAG_OFLO 0x80000000 /* simulation only */
544
545#define ERBR_ALIGNMENT 4096
546#define ERBR_L_RXRINGBASE_MASK 0xfffff000
547
548#define ERBAR_BARRIER_BIT 0x0100
549#define ERBAR_RXBARR_MASK 0xffff0000
550#define ERBAR_RXBARR_SHIFT 16
551
552#define ERCIR_RXCONSUME_MASK 0x00000fff
553
554#define ERPIR_RXPRODUCE_MASK 0x00000fff
555#define ERPIR_ARM 0x80000000
556
557#define ERTR_CNT_MASK 0x000007ff
558
559#define ETCSR_IPGT_MASK 0x0000007f
560#define ETCSR_IPGR1_MASK 0x00007f00
561#define ETCSR_IPGR1_SHIFT 8
562#define ETCSR_IPGR2_MASK 0x007f0000
563#define ETCSR_IPGR2_SHIFT 16
564#define ETCSR_NOTXCLK 0x80000000
565
566#define ETCDC_COLLCNT_MASK 0x0000ffff
567#define ETCDC_DEFERCNT_MASK 0xffff0000
568#define ETCDC_DEFERCNT_SHIFT 16
569
570#define ETBR_ALIGNMENT (64*1024)
571#define ETBR_L_RINGSZ_MASK 0x00000001
572#define ETBR_L_RINGSZ128 0
573#define ETBR_L_RINGSZ512 1
574#define ETBR_L_TXRINGBASE_MASK 0xffffc000
575
576#define ETCIR_TXCONSUME_MASK 0x0000ffff
577#define ETCIR_IDLE 0x80000000
578
579#define ETPIR_TXPRODUCE_MASK 0x0000ffff
580
581#define EBIR_TXBUFPROD_MASK 0x0000001f
582#define EBIR_TXBUFCONS_MASK 0x00001f00
583#define EBIR_TXBUFCONS_SHIFT 8
584#define EBIR_RXBUFPROD_MASK 0x007fc000
585#define EBIR_RXBUFPROD_SHIFT 14
586#define EBIR_RXBUFCONS_MASK 0xff800000
587#define EBIR_RXBUFCONS_SHIFT 23
588
589#define MICR_REGADDR_MASK 0x0000001f
590#define MICR_PHYADDR_MASK 0x000003e0
591#define MICR_PHYADDR_SHIFT 5
592#define MICR_READTRIG 0x00000400
593#define MICR_BUSY 0x00000800
594
595#define MIDR_DATA_MASK 0x0000ffff
596
597#define ERXBUF_IPCKSUM_MASK 0x0000ffff
598#define ERXBUF_BYTECNT_MASK 0x07ff0000
599#define ERXBUF_BYTECNT_SHIFT 16
600#define ERXBUF_V 0x80000000
601
602#define ERXBUF_CRCERR 0x00000001 /* aka RSV15 */
603#define ERXBUF_FRAMERR 0x00000002 /* aka RSV14 */
604#define ERXBUF_CODERR 0x00000004 /* aka RSV13 */
605#define ERXBUF_INVPREAMB 0x00000008 /* aka RSV18 */
606#define ERXBUF_LOLEN 0x00007000 /* aka RSV2_0 */
607#define ERXBUF_HILEN 0x03ff0000 /* aka RSV12_3 */
608#define ERXBUF_MULTICAST 0x04000000 /* aka RSV16 */
609#define ERXBUF_BROADCAST 0x08000000 /* aka RSV17 */
610#define ERXBUF_LONGEVENT 0x10000000 /* aka RSV19 */
611#define ERXBUF_BADPKT 0x20000000 /* aka RSV20 */
612#define ERXBUF_GOODPKT 0x40000000 /* aka RSV21 */
613#define ERXBUF_CARRIER 0x80000000 /* aka RSV22 */
614
615#define ETXD_BYTECNT_MASK 0x000007ff /* total byte count */
616#define ETXD_INTWHENDONE 0x00001000 /* intr when done */
617#define ETXD_D0V 0x00010000 /* data 0 valid */
618#define ETXD_B1V 0x00020000 /* buf 1 valid */
619#define ETXD_B2V 0x00040000 /* buf 2 valid */
620#define ETXD_DOCHECKSUM 0x00080000 /* insert ip cksum */
621#define ETXD_CHKOFF_MASK 0x07f00000 /* cksum byte offset */
622#define ETXD_CHKOFF_SHIFT 20
623
624#define ETXD_D0CNT_MASK 0x0000007f
625#define ETXD_B1CNT_MASK 0x0007ff00
626#define ETXD_B1CNT_SHIFT 8
627#define ETXD_B2CNT_MASK 0x7ff00000
628#define ETXD_B2CNT_SHIFT 20
629
630typedef enum ioc3_subdevs_e {
631 ioc3_subdev_ether,
632 ioc3_subdev_generic,
633 ioc3_subdev_nic,
634 ioc3_subdev_kbms,
635 ioc3_subdev_ttya,
636 ioc3_subdev_ttyb,
637 ioc3_subdev_ecpp,
638 ioc3_subdev_rt,
639 ioc3_nsubdevs
640} ioc3_subdev_t;
641
642/* subdevice disable bits,
643 * from the standard INFO_LBL_SUBDEVS
644 */
645#define IOC3_SDB_ETHER (1<<ioc3_subdev_ether)
646#define IOC3_SDB_GENERIC (1<<ioc3_subdev_generic)
647#define IOC3_SDB_NIC (1<<ioc3_subdev_nic)
648#define IOC3_SDB_KBMS (1<<ioc3_subdev_kbms)
649#define IOC3_SDB_TTYA (1<<ioc3_subdev_ttya)
650#define IOC3_SDB_TTYB (1<<ioc3_subdev_ttyb)
651#define IOC3_SDB_ECPP (1<<ioc3_subdev_ecpp)
652#define IOC3_SDB_RT (1<<ioc3_subdev_rt)
653
654#define IOC3_ALL_SUBDEVS ((1<<ioc3_nsubdevs)-1)
655
656#define IOC3_SDB_SERIAL (IOC3_SDB_TTYA|IOC3_SDB_TTYB)
657
658#define IOC3_STD_SUBDEVS IOC3_ALL_SUBDEVS
659
660#define IOC3_INTA_SUBDEVS IOC3_SDB_ETHER
661#define IOC3_INTB_SUBDEVS (IOC3_SDB_GENERIC|IOC3_SDB_KBMS|IOC3_SDB_SERIAL|IOC3_SDB_ECPP|IOC3_SDB_RT)
662
663#endif /* _IOC3_H */
diff --git a/arch/mips/include/asm/sn/klconfig.h b/arch/mips/include/asm/sn/klconfig.h
new file mode 100644
index 000000000000..09e590daca17
--- /dev/null
+++ b/arch/mips/include/asm/sn/klconfig.h
@@ -0,0 +1,898 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/klconfig.h>.
7 *
8 * Copyright (C) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 1999, 2000 by Ralf Baechle
10 */
11#ifndef _ASM_SN_KLCONFIG_H
12#define _ASM_SN_KLCONFIG_H
13
14/*
15 * The KLCONFIG structures store info about the various BOARDs found
16 * during Hardware Discovery. In addition, it stores info about the
17 * components found on the BOARDs.
18 */
19
20/*
21 * WARNING:
22 * Certain assembly language routines (notably xxxxx.s) in the IP27PROM
23 * will depend on the format of the data structures in this file. In
24 * most cases, rearranging the fields can seriously break things.
25 * Adding fields in the beginning or middle can also break things.
26 * Add fields if necessary, to the end of a struct in such a way
27 * that offsets of existing fields do not change.
28 */
29
30#include <linux/types.h>
31#include <asm/sn/types.h>
32
33#if defined(CONFIG_SGI_IP27)
34
35#include <asm/sn/sn0/addrs.h>
36//#include <sys/SN/router.h>
37// XXX Stolen from <sys/SN/router.h>:
38#define MAX_ROUTER_PORTS (6) /* Max. number of ports on a router */
39#include <asm/sn/fru.h>
40//#include <sys/graph.h>
41//#include <sys/xtalk/xbow.h>
42
43#elif defined(CONFIG_SGI_IP35)
44
45#include <asm/sn/sn1/addrs.h>
46#include <sys/sn/router.h>
47#include <sys/graph.h>
48#include <asm/xtalk/xbow.h>
49
50#endif /* !CONFIG_SGI_IP27 && !CONFIG_SGI_IP35 */
51
52#if defined(CONFIG_SGI_IP27) || defined(CONFIG_SGI_IP35)
53#include <asm/sn/agent.h>
54#include <asm/fw/arc/types.h>
55#include <asm/fw/arc/hinv.h>
56#if defined(CONFIG_SGI_IP35)
57// The hack file has to be before vector and after sn0_fru....
58#include <asm/hack.h>
59#include <asm/sn/vector.h>
60#include <asm/xtalk/xtalk.h>
61#endif /* CONFIG_SGI_IP35 */
62#endif /* CONFIG_SGI_IP27 || CONFIG_SGI_IP35 */
63
64typedef u64 nic_t;
65
66#define KLCFGINFO_MAGIC 0xbeedbabe
67
68typedef s32 klconf_off_t;
69
70/*
71 * Some IMPORTANT OFFSETS. These are the offsets on all NODES.
72 */
73#define MAX_MODULE_ID 255
74#define SIZE_PAD 4096 /* 4k padding for structures */
75/*
76 * 1 NODE brd, 2 Router brd (1 8p, 1 meta), 6 Widgets,
77 * 2 Midplanes assuming no pci card cages
78 */
79#define MAX_SLOTS_PER_NODE (1 + 2 + 6 + 2)
80
81/* XXX if each node is guranteed to have some memory */
82
83#define MAX_PCI_DEVS 8
84
85/* lboard_t->brd_flags fields */
86/* All bits in this field are currently used. Try the pad fields if
87 you need more flag bits */
88
89#define ENABLE_BOARD 0x01
90#define FAILED_BOARD 0x02
91#define DUPLICATE_BOARD 0x04 /* Boards like midplanes/routers which
92 are discovered twice. Use one of them */
93#define VISITED_BOARD 0x08 /* Used for compact hub numbering. */
94#define LOCAL_MASTER_IO6 0x10 /* master io6 for that node */
95#define GLOBAL_MASTER_IO6 0x20
96#define THIRD_NIC_PRESENT 0x40 /* for future use */
97#define SECOND_NIC_PRESENT 0x80 /* addons like MIO are present */
98
99/* klinfo->flags fields */
100
101#define KLINFO_ENABLE 0x01 /* This component is enabled */
102#define KLINFO_FAILED 0x02 /* This component failed */
103#define KLINFO_DEVICE 0x04 /* This component is a device */
104#define KLINFO_VISITED 0x08 /* This component has been visited */
105#define KLINFO_CONTROLLER 0x10 /* This component is a device controller */
106#define KLINFO_INSTALL 0x20 /* Install a driver */
107#define KLINFO_HEADLESS 0x40 /* Headless (or hubless) component */
108#define IS_CONSOLE_IOC3(i) ((((klinfo_t *)i)->flags) & KLINFO_INSTALL)
109
110#define GB2 0x80000000
111
112#define MAX_RSV_PTRS 32
113
114/* Structures to manage various data storage areas */
115/* The numbers must be contiguous since the array index i
116 is used in the code to allocate various areas.
117*/
118
119#define BOARD_STRUCT 0
120#define COMPONENT_STRUCT 1
121#define ERRINFO_STRUCT 2
122#define KLMALLOC_TYPE_MAX (ERRINFO_STRUCT + 1)
123#define DEVICE_STRUCT 3
124
125
126typedef struct console_s {
127 unsigned long uart_base;
128 unsigned long config_base;
129 unsigned long memory_base;
130 short baud;
131 short flag;
132 int type;
133 nasid_t nasid;
134 char wid;
135 char npci;
136 nic_t baseio_nic;
137} console_t;
138
139typedef struct klc_malloc_hdr {
140 klconf_off_t km_base;
141 klconf_off_t km_limit;
142 klconf_off_t km_current;
143} klc_malloc_hdr_t;
144
145/* Functions/macros needed to use this structure */
146
147typedef struct kl_config_hdr {
148 u64 ch_magic; /* set this to KLCFGINFO_MAGIC */
149 u32 ch_version; /* structure version number */
150 klconf_off_t ch_malloc_hdr_off; /* offset of ch_malloc_hdr */
151 klconf_off_t ch_cons_off; /* offset of ch_cons */
152 klconf_off_t ch_board_info; /* the link list of boards */
153 console_t ch_cons_info; /* address info of the console */
154 klc_malloc_hdr_t ch_malloc_hdr[KLMALLOC_TYPE_MAX];
155 confidence_t ch_sw_belief; /* confidence that software is bad*/
156 confidence_t ch_sn0net_belief; /* confidence that sn0net is bad */
157} kl_config_hdr_t;
158
159
160#define KL_CONFIG_HDR(_nasid) ((kl_config_hdr_t *)(KLCONFIG_ADDR(_nasid)))
161#define KL_CONFIG_INFO_OFFSET(_nasid) \
162 (KL_CONFIG_HDR(_nasid)->ch_board_info)
163#define KL_CONFIG_INFO_SET_OFFSET(_nasid, _off) \
164 (KL_CONFIG_HDR(_nasid)->ch_board_info = (_off))
165
166#define KL_CONFIG_INFO(_nasid) \
167 (lboard_t *)((KL_CONFIG_HDR(_nasid)->ch_board_info) ? \
168 NODE_OFFSET_TO_K1((_nasid), KL_CONFIG_HDR(_nasid)->ch_board_info) : \
169 0)
170#define KL_CONFIG_MAGIC(_nasid) (KL_CONFIG_HDR(_nasid)->ch_magic)
171
172#define KL_CONFIG_CHECK_MAGIC(_nasid) \
173 (KL_CONFIG_HDR(_nasid)->ch_magic == KLCFGINFO_MAGIC)
174
175#define KL_CONFIG_HDR_INIT_MAGIC(_nasid) \
176 (KL_CONFIG_HDR(_nasid)->ch_magic = KLCFGINFO_MAGIC)
177
178/* --- New Macros for the changed kl_config_hdr_t structure --- */
179
180#define PTR_CH_MALLOC_HDR(_k) ((klc_malloc_hdr_t *)\
181 ((unsigned long)_k + (_k->ch_malloc_hdr_off)))
182
183#define KL_CONFIG_CH_MALLOC_HDR(_n) PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n))
184
185#define PTR_CH_CONS_INFO(_k) ((console_t *)\
186 ((unsigned long)_k + (_k->ch_cons_off)))
187
188#define KL_CONFIG_CH_CONS_INFO(_n) PTR_CH_CONS_INFO(KL_CONFIG_HDR(_n))
189
190/* ------------------------------------------------------------- */
191
192#define KL_CONFIG_INFO_START(_nasid) \
193 (klconf_off_t)(KLCONFIG_OFFSET(_nasid) + sizeof(kl_config_hdr_t))
194
195#define KL_CONFIG_BOARD_NASID(_brd) ((_brd)->brd_nasid)
196#define KL_CONFIG_BOARD_SET_NEXT(_brd, _off) ((_brd)->brd_next = (_off))
197
198#define KL_CONFIG_DUPLICATE_BOARD(_brd) ((_brd)->brd_flags & DUPLICATE_BOARD)
199
200#define XBOW_PORT_TYPE_HUB(_xbowp, _link) \
201 ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_HUB)
202#define XBOW_PORT_TYPE_IO(_xbowp, _link) \
203 ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_IO)
204
205#define XBOW_PORT_IS_ENABLED(_xbowp, _link) \
206 ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_ENABLE)
207#define XBOW_PORT_NASID(_xbowp, _link) \
208 ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_nasid)
209
210#define XBOW_PORT_IO 0x1
211#define XBOW_PORT_HUB 0x2
212#define XBOW_PORT_ENABLE 0x4
213
214#define SN0_PORT_FENCE_SHFT 0
215#define SN0_PORT_FENCE_MASK (1 << SN0_PORT_FENCE_SHFT)
216
217/*
218 * The KLCONFIG area is organized as a LINKED LIST of BOARDs. A BOARD
219 * can be either 'LOCAL' or 'REMOTE'. LOCAL means it is attached to
220 * the LOCAL/current NODE. REMOTE means it is attached to a different
221 * node.(TBD - Need a way to treat ROUTER boards.)
222 *
223 * There are 2 different structures to represent these boards -
224 * lboard - Local board, rboard - remote board. These 2 structures
225 * can be arbitrarily mixed in the LINKED LIST of BOARDs. (Refer
226 * Figure below). The first byte of the rboard or lboard structure
227 * is used to find out its type - no unions are used.
228 * If it is a lboard, then the config info of this board will be found
229 * on the local node. (LOCAL NODE BASE + offset value gives pointer to
230 * the structure.
231 * If it is a rboard, the local structure contains the node number
232 * and the offset of the beginning of the LINKED LIST on the remote node.
233 * The details of the hardware on a remote node can be built locally,
234 * if required, by reading the LINKED LIST on the remote node and
235 * ignoring all the rboards on that node.
236 *
237 * The local node uses the REMOTE NODE NUMBER + OFFSET to point to the
238 * First board info on the remote node. The remote node list is
239 * traversed as the local list, using the REMOTE BASE ADDRESS and not
240 * the local base address and ignoring all rboard values.
241 *
242 *
243 KLCONFIG
244
245 +------------+ +------------+ +------------+ +------------+
246 | lboard | +-->| lboard | +-->| rboard | +-->| lboard |
247 +------------+ | +------------+ | +------------+ | +------------+
248 | board info | | | board info | | |errinfo,bptr| | | board info |
249 +------------+ | +------------+ | +------------+ | +------------+
250 | offset |--+ | offset |--+ | offset |--+ |offset=NULL |
251 +------------+ +------------+ +------------+ +------------+
252
253
254 +------------+
255 | board info |
256 +------------+ +--------------------------------+
257 | compt 1 |------>| type, rev, diaginfo, size ... | (CPU)
258 +------------+ +--------------------------------+
259 | compt 2 |--+
260 +------------+ | +--------------------------------+
261 | ... | +--->| type, rev, diaginfo, size ... | (MEM_BANK)
262 +------------+ +--------------------------------+
263 | errinfo |--+
264 +------------+ | +--------------------------------+
265 +--->|r/l brd errinfo,compt err flags |
266 +--------------------------------+
267
268 *
269 * Each BOARD consists of COMPONENTs and the BOARD structure has
270 * pointers (offsets) to its COMPONENT structure.
271 * The COMPONENT structure has version info, size and speed info, revision,
272 * error info and the NIC info. This structure can accommodate any
273 * BOARD with arbitrary COMPONENT composition.
274 *
275 * The ERRORINFO part of each BOARD has error information
276 * that describes errors about the BOARD itself. It also has flags to
277 * indicate the COMPONENT(s) on the board that have errors. The error
278 * information specific to the COMPONENT is present in the respective
279 * COMPONENT structure.
280 *
281 * The ERRORINFO structure is also treated like a COMPONENT, ie. the
282 * BOARD has pointers(offset) to the ERRORINFO structure. The rboard
283 * structure also has a pointer to the ERRORINFO structure. This is
284 * the place to store ERRORINFO about a REMOTE NODE, if the HUB on
285 * that NODE is not working or if the REMOTE MEMORY is BAD. In cases where
286 * only the CPU of the REMOTE NODE is disabled, the ERRORINFO pointer can
287 * be a NODE NUMBER, REMOTE OFFSET combination, pointing to error info
288 * which is present on the REMOTE NODE.(TBD)
289 * REMOTE ERRINFO can be stored on any of the nearest nodes
290 * or on all the nearest nodes.(TBD)
291 * Like BOARD structures, REMOTE ERRINFO structures can be built locally
292 * using the rboard errinfo pointer.
293 *
294 * In order to get useful information from this Data organization, a set of
295 * interface routines are provided (TBD). The important thing to remember while
296 * manipulating the structures, is that, the NODE number information should
297 * be used. If the NODE is non-zero (remote) then each offset should
298 * be added to the REMOTE BASE ADDR else it should be added to the LOCAL BASE ADDR.
299 * This includes offsets for BOARDS, COMPONENTS and ERRORINFO.
300 *
301 * Note that these structures do not provide much info about connectivity.
302 * That info will be part of HWGRAPH, which is an extension of the cfg_t
303 * data structure. (ref IP27prom/cfg.h) It has to be extended to include
304 * the IO part of the Network(TBD).
305 *
306 * The data structures below define the above concepts.
307 */
308
309/*
310 * Values for CPU types
311 */
312#define KL_CPU_R4000 0x1 /* Standard R4000 */
313#define KL_CPU_TFP 0x2 /* TFP processor */
314#define KL_CPU_R10000 0x3 /* R10000 (T5) */
315#define KL_CPU_NONE (-1) /* no cpu present in slot */
316
317/*
318 * IP27 BOARD classes
319 */
320
321#define KLCLASS_MASK 0xf0
322#define KLCLASS_NONE 0x00
323#define KLCLASS_NODE 0x10 /* CPU, Memory and HUB board */
324#define KLCLASS_CPU KLCLASS_NODE
325#define KLCLASS_IO 0x20 /* BaseIO, 4 ch SCSI, ethernet, FDDI
326 and the non-graphics widget boards */
327#define KLCLASS_ROUTER 0x30 /* Router board */
328#define KLCLASS_MIDPLANE 0x40 /* We need to treat this as a board
329 so that we can record error info */
330#define KLCLASS_GFX 0x50 /* graphics boards */
331
332#define KLCLASS_PSEUDO_GFX 0x60 /* HDTV type cards that use a gfx
333 * hw ifc to xtalk and are not gfx
334 * class for sw purposes */
335
336#define KLCLASS_MAX 7 /* Bump this if a new CLASS is added */
337#define KLTYPE_MAX 10 /* Bump this if a new CLASS is added */
338
339#define KLCLASS_UNKNOWN 0xf0
340
341#define KLCLASS(_x) ((_x) & KLCLASS_MASK)
342
343/*
344 * IP27 board types
345 */
346
347#define KLTYPE_MASK 0x0f
348#define KLTYPE_NONE 0x00
349#define KLTYPE_EMPTY 0x00
350
351#define KLTYPE_WEIRDCPU (KLCLASS_CPU | 0x0)
352#define KLTYPE_IP27 (KLCLASS_CPU | 0x1) /* 2 CPUs(R10K) per board */
353
354#define KLTYPE_WEIRDIO (KLCLASS_IO | 0x0)
355#define KLTYPE_BASEIO (KLCLASS_IO | 0x1) /* IOC3, SuperIO, Bridge, SCSI */
356#define KLTYPE_IO6 KLTYPE_BASEIO /* Additional name */
357#define KLTYPE_4CHSCSI (KLCLASS_IO | 0x2)
358#define KLTYPE_MSCSI KLTYPE_4CHSCSI /* Additional name */
359#define KLTYPE_ETHERNET (KLCLASS_IO | 0x3)
360#define KLTYPE_MENET KLTYPE_ETHERNET /* Additional name */
361#define KLTYPE_FDDI (KLCLASS_IO | 0x4)
362#define KLTYPE_UNUSED (KLCLASS_IO | 0x5) /* XXX UNUSED */
363#define KLTYPE_HAROLD (KLCLASS_IO | 0x6) /* PCI SHOE BOX */
364#define KLTYPE_PCI KLTYPE_HAROLD
365#define KLTYPE_VME (KLCLASS_IO | 0x7) /* Any 3rd party VME card */
366#define KLTYPE_MIO (KLCLASS_IO | 0x8)
367#define KLTYPE_FC (KLCLASS_IO | 0x9)
368#define KLTYPE_LINC (KLCLASS_IO | 0xA)
369#define KLTYPE_TPU (KLCLASS_IO | 0xB) /* Tensor Processing Unit */
370#define KLTYPE_GSN_A (KLCLASS_IO | 0xC) /* Main GSN board */
371#define KLTYPE_GSN_B (KLCLASS_IO | 0xD) /* Auxiliary GSN board */
372
373#define KLTYPE_GFX (KLCLASS_GFX | 0x0) /* unknown graphics type */
374#define KLTYPE_GFX_KONA (KLCLASS_GFX | 0x1) /* KONA graphics on IP27 */
375#define KLTYPE_GFX_MGRA (KLCLASS_GFX | 0x3) /* MGRAS graphics on IP27 */
376
377#define KLTYPE_WEIRDROUTER (KLCLASS_ROUTER | 0x0)
378#define KLTYPE_ROUTER (KLCLASS_ROUTER | 0x1)
379#define KLTYPE_ROUTER2 KLTYPE_ROUTER /* Obsolete! */
380#define KLTYPE_NULL_ROUTER (KLCLASS_ROUTER | 0x2)
381#define KLTYPE_META_ROUTER (KLCLASS_ROUTER | 0x3)
382
383#define KLTYPE_WEIRDMIDPLANE (KLCLASS_MIDPLANE | 0x0)
384#define KLTYPE_MIDPLANE8 (KLCLASS_MIDPLANE | 0x1) /* 8 slot backplane */
385#define KLTYPE_MIDPLANE KLTYPE_MIDPLANE8
386#define KLTYPE_PBRICK_XBOW (KLCLASS_MIDPLANE | 0x2)
387
388#define KLTYPE_IOBRICK (KLCLASS_IOBRICK | 0x0)
389#define KLTYPE_IBRICK (KLCLASS_IOBRICK | 0x1)
390#define KLTYPE_PBRICK (KLCLASS_IOBRICK | 0x2)
391#define KLTYPE_XBRICK (KLCLASS_IOBRICK | 0x3)
392
393#define KLTYPE_PBRICK_BRIDGE KLTYPE_PBRICK
394
395/* The value of type should be more than 8 so that hinv prints
396 * out the board name from the NIC string. For values less than
397 * 8 the name of the board needs to be hard coded in a few places.
398 * When bringup started nic names had not standardized and so we
399 * had to hard code. (For people interested in history.)
400 */
401#define KLTYPE_XTHD (KLCLASS_PSEUDO_GFX | 0x9)
402
403#define KLTYPE_UNKNOWN (KLCLASS_UNKNOWN | 0xf)
404
405#define KLTYPE(_x) ((_x) & KLTYPE_MASK)
406#define IS_MIO_PRESENT(l) ((l->brd_type == KLTYPE_BASEIO) && \
407 (l->brd_flags & SECOND_NIC_PRESENT))
408#define IS_MIO_IOC3(l, n) (IS_MIO_PRESENT(l) && (n > 2))
409
410/*
411 * board structures
412 */
413
414#define MAX_COMPTS_PER_BRD 24
415
416#define LOCAL_BOARD 1
417#define REMOTE_BOARD 2
418
419#define LBOARD_STRUCT_VERSION 2
420
421typedef struct lboard_s {
422 klconf_off_t brd_next; /* Next BOARD */
423 unsigned char struct_type; /* type of structure, local or remote */
424 unsigned char brd_type; /* type+class */
425 unsigned char brd_sversion; /* version of this structure */
426 unsigned char brd_brevision; /* board revision */
427 unsigned char brd_promver; /* board prom version, if any */
428 unsigned char brd_flags; /* Enabled, Disabled etc */
429 unsigned char brd_slot; /* slot number */
430 unsigned short brd_debugsw; /* Debug switches */
431 moduleid_t brd_module; /* module to which it belongs */
432 partid_t brd_partition; /* Partition number */
433 unsigned short brd_diagval; /* diagnostic value */
434 unsigned short brd_diagparm; /* diagnostic parameter */
435 unsigned char brd_inventory; /* inventory history */
436 unsigned char brd_numcompts; /* Number of components */
437 nic_t brd_nic; /* Number in CAN */
438 nasid_t brd_nasid; /* passed parameter */
439 klconf_off_t brd_compts[MAX_COMPTS_PER_BRD]; /* pointers to COMPONENTS */
440 klconf_off_t brd_errinfo; /* Board's error information */
441 struct lboard_s *brd_parent; /* Logical parent for this brd */
442 vertex_hdl_t brd_graph_link; /* vertex hdl to connect extern compts */
443 confidence_t brd_confidence; /* confidence that the board is bad */
444 nasid_t brd_owner; /* who owns this board */
445 unsigned char brd_nic_flags; /* To handle 8 more NICs */
446 char brd_name[32];
447} lboard_t;
448
449
450/*
451 * Make sure we pass back the calias space address for local boards.
452 * klconfig board traversal and error structure extraction defines.
453 */
454
455#define BOARD_SLOT(_brd) ((_brd)->brd_slot)
456
457#define KLCF_CLASS(_brd) KLCLASS((_brd)->brd_type)
458#define KLCF_TYPE(_brd) KLTYPE((_brd)->brd_type)
459#define KLCF_REMOTE(_brd) (((_brd)->struct_type & LOCAL_BOARD) ? 0 : 1)
460#define KLCF_NUM_COMPS(_brd) ((_brd)->brd_numcompts)
461#define KLCF_MODULE_ID(_brd) ((_brd)->brd_module)
462
463#define KLCF_NEXT(_brd) \
464 ((_brd)->brd_next ? \
465 (lboard_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), (_brd)->brd_next)):\
466 NULL)
467#define KLCF_COMP(_brd, _ndx) \
468 (klinfo_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), \
469 (_brd)->brd_compts[(_ndx)]))
470
471#define KLCF_COMP_ERROR(_brd, _comp) \
472 (NODE_OFFSET_TO_K1(NASID_GET(_brd), (_comp)->errinfo))
473
474#define KLCF_COMP_TYPE(_comp) ((_comp)->struct_type)
475#define KLCF_BRIDGE_W_ID(_comp) ((_comp)->physid) /* Widget ID */
476
477
478
479/*
480 * Generic info structure. This stores common info about a
481 * component.
482 */
483
484typedef struct klinfo_s { /* Generic info */
485 unsigned char struct_type; /* type of this structure */
486 unsigned char struct_version; /* version of this structure */
487 unsigned char flags; /* Enabled, disabled etc */
488 unsigned char revision; /* component revision */
489 unsigned short diagval; /* result of diagnostics */
490 unsigned short diagparm; /* diagnostic parameter */
491 unsigned char inventory; /* previous inventory status */
492 nic_t nic; /* MUst be aligned properly */
493 unsigned char physid; /* physical id of component */
494 unsigned int virtid; /* virtual id as seen by system */
495 unsigned char widid; /* Widget id - if applicable */
496 nasid_t nasid; /* node number - from parent */
497 char pad1; /* pad out structure. */
498 char pad2; /* pad out structure. */
499 COMPONENT *arcs_compt; /* ptr to the arcs struct for ease*/
500 klconf_off_t errinfo; /* component specific errors */
501 unsigned short pad3; /* pci fields have moved over to */
502 unsigned short pad4; /* klbri_t */
503} klinfo_t ;
504
505#define KLCONFIG_INFO_ENABLED(_i) ((_i)->flags & KLINFO_ENABLE)
506/*
507 * Component structures.
508 * Following are the currently identified components:
509 * CPU, HUB, MEM_BANK,
510 * XBOW(consists of 16 WIDGETs, each of which can be HUB or GRAPHICS or BRIDGE)
511 * BRIDGE, IOC3, SuperIO, SCSI, FDDI
512 * ROUTER
513 * GRAPHICS
514 */
515#define KLSTRUCT_UNKNOWN 0
516#define KLSTRUCT_CPU 1
517#define KLSTRUCT_HUB 2
518#define KLSTRUCT_MEMBNK 3
519#define KLSTRUCT_XBOW 4
520#define KLSTRUCT_BRI 5
521#define KLSTRUCT_IOC3 6
522#define KLSTRUCT_PCI 7
523#define KLSTRUCT_VME 8
524#define KLSTRUCT_ROU 9
525#define KLSTRUCT_GFX 10
526#define KLSTRUCT_SCSI 11
527#define KLSTRUCT_FDDI 12
528#define KLSTRUCT_MIO 13
529#define KLSTRUCT_DISK 14
530#define KLSTRUCT_TAPE 15
531#define KLSTRUCT_CDROM 16
532#define KLSTRUCT_HUB_UART 17
533#define KLSTRUCT_IOC3ENET 18
534#define KLSTRUCT_IOC3UART 19
535#define KLSTRUCT_UNUSED 20 /* XXX UNUSED */
536#define KLSTRUCT_IOC3PCKM 21
537#define KLSTRUCT_RAD 22
538#define KLSTRUCT_HUB_TTY 23
539#define KLSTRUCT_IOC3_TTY 24
540
541/* Early Access IO proms are compatible
542 only with KLSTRUCT values upto 24. */
543
544#define KLSTRUCT_FIBERCHANNEL 25
545#define KLSTRUCT_MOD_SERIAL_NUM 26
546#define KLSTRUCT_IOC3MS 27
547#define KLSTRUCT_TPU 28
548#define KLSTRUCT_GSN_A 29
549#define KLSTRUCT_GSN_B 30
550#define KLSTRUCT_XTHD 31
551
552/*
553 * These are the indices of various components within a lboard structure.
554 */
555
556#define IP27_CPU0_INDEX 0
557#define IP27_CPU1_INDEX 1
558#define IP27_HUB_INDEX 2
559#define IP27_MEM_INDEX 3
560
561#define BASEIO_BRIDGE_INDEX 0
562#define BASEIO_IOC3_INDEX 1
563#define BASEIO_SCSI1_INDEX 2
564#define BASEIO_SCSI2_INDEX 3
565
566#define MIDPLANE_XBOW_INDEX 0
567#define ROUTER_COMPONENT_INDEX 0
568
569#define CH4SCSI_BRIDGE_INDEX 0
570
571/* Info holders for various hardware components */
572
573typedef u64 *pci_t;
574typedef u64 *vmeb_t;
575typedef u64 *vmed_t;
576typedef u64 *fddi_t;
577typedef u64 *scsi_t;
578typedef u64 *mio_t;
579typedef u64 *graphics_t;
580typedef u64 *router_t;
581
582/*
583 * The port info in ip27_cfg area translates to a lboart_t in the
584 * KLCONFIG area. But since KLCONFIG does not use pointers, lboart_t
585 * is stored in terms of a nasid and a offset from start of KLCONFIG
586 * area on that nasid.
587 */
588typedef struct klport_s {
589 nasid_t port_nasid;
590 unsigned char port_flag;
591 klconf_off_t port_offset;
592} klport_t;
593
594typedef struct klcpu_s { /* CPU */
595 klinfo_t cpu_info;
596 unsigned short cpu_prid; /* Processor PRID value */
597 unsigned short cpu_fpirr; /* FPU IRR value */
598 unsigned short cpu_speed; /* Speed in MHZ */
599 unsigned short cpu_scachesz; /* secondary cache size in MB */
600 unsigned short cpu_scachespeed;/* secondary cache speed in MHz */
601} klcpu_t ;
602
603#define CPU_STRUCT_VERSION 2
604
605typedef struct klhub_s { /* HUB */
606 klinfo_t hub_info;
607 unsigned int hub_flags; /* PCFG_HUB_xxx flags */
608 klport_t hub_port; /* hub is connected to this */
609 nic_t hub_box_nic; /* nic of containing box */
610 klconf_off_t hub_mfg_nic; /* MFG NIC string */
611 u64 hub_speed; /* Speed of hub in HZ */
612} klhub_t ;
613
614typedef struct klhub_uart_s { /* HUB */
615 klinfo_t hubuart_info;
616 unsigned int hubuart_flags; /* PCFG_HUB_xxx flags */
617 nic_t hubuart_box_nic; /* nic of containing box */
618} klhub_uart_t ;
619
620#define MEMORY_STRUCT_VERSION 2
621
622typedef struct klmembnk_s { /* MEMORY BANK */
623 klinfo_t membnk_info;
624 short membnk_memsz; /* Total memory in megabytes */
625 short membnk_dimm_select; /* bank to physical addr mapping*/
626 short membnk_bnksz[MD_MEM_BANKS]; /* Memory bank sizes */
627 short membnk_attr;
628} klmembnk_t ;
629
630#define KLCONFIG_MEMBNK_SIZE(_info, _bank) \
631 ((_info)->membnk_bnksz[(_bank)])
632
633
634#define MEMBNK_PREMIUM 1
635#define KLCONFIG_MEMBNK_PREMIUM(_info, _bank) \
636 ((_info)->membnk_attr & (MEMBNK_PREMIUM << (_bank)))
637
638#define MAX_SERIAL_NUM_SIZE 10
639
640typedef struct klmod_serial_num_s {
641 klinfo_t snum_info;
642 union {
643 char snum_str[MAX_SERIAL_NUM_SIZE];
644 unsigned long long snum_int;
645 } snum;
646} klmod_serial_num_t;
647
648/* Macros needed to access serial number structure in lboard_t.
649 Hard coded values are necessary since we cannot treat
650 serial number struct as a component without losing compatibility
651 between prom versions. */
652
653#define GET_SNUM_COMP(_l) ((klmod_serial_num_t *)\
654 KLCF_COMP(_l, _l->brd_numcompts))
655
656#define MAX_XBOW_LINKS 16
657
658typedef struct klxbow_s { /* XBOW */
659 klinfo_t xbow_info ;
660 klport_t xbow_port_info[MAX_XBOW_LINKS] ; /* Module number */
661 int xbow_master_hub_link;
662 /* type of brd connected+component struct ptr+flags */
663} klxbow_t ;
664
665#define MAX_PCI_SLOTS 8
666
667typedef struct klpci_device_s {
668 s32 pci_device_id; /* 32 bits of vendor/device ID. */
669 s32 pci_device_pad; /* 32 bits of padding. */
670} klpci_device_t;
671
672#define BRIDGE_STRUCT_VERSION 2
673
674typedef struct klbri_s { /* BRIDGE */
675 klinfo_t bri_info ;
676 unsigned char bri_eprominfo ; /* IO6prom connected to bridge */
677 unsigned char bri_bustype ; /* PCI/VME BUS bridge/GIO */
678 pci_t pci_specific ; /* PCI Board config info */
679 klpci_device_t bri_devices[MAX_PCI_DEVS] ; /* PCI IDs */
680 klconf_off_t bri_mfg_nic ;
681} klbri_t ;
682
683#define MAX_IOC3_TTY 2
684
685typedef struct klioc3_s { /* IOC3 */
686 klinfo_t ioc3_info ;
687 unsigned char ioc3_ssram ; /* Info about ssram */
688 unsigned char ioc3_nvram ; /* Info about nvram */
689 klinfo_t ioc3_superio ; /* Info about superio */
690 klconf_off_t ioc3_tty_off ;
691 klinfo_t ioc3_enet ;
692 klconf_off_t ioc3_enet_off ;
693 klconf_off_t ioc3_kbd_off ;
694} klioc3_t ;
695
696#define MAX_VME_SLOTS 8
697
698typedef struct klvmeb_s { /* VME BRIDGE - PCI CTLR */
699 klinfo_t vmeb_info ;
700 vmeb_t vmeb_specific ;
701 klconf_off_t vmeb_brdinfo[MAX_VME_SLOTS] ; /* VME Board config info */
702} klvmeb_t ;
703
704typedef struct klvmed_s { /* VME DEVICE - VME BOARD */
705 klinfo_t vmed_info ;
706 vmed_t vmed_specific ;
707 klconf_off_t vmed_brdinfo[MAX_VME_SLOTS] ; /* VME Board config info */
708} klvmed_t ;
709
710#define ROUTER_VECTOR_VERS 2
711
712/* XXX - Don't we need the number of ports here?!? */
713typedef struct klrou_s { /* ROUTER */
714 klinfo_t rou_info ;
715 unsigned int rou_flags ; /* PCFG_ROUTER_xxx flags */
716 nic_t rou_box_nic ; /* nic of the containing module */
717 klport_t rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */
718 klconf_off_t rou_mfg_nic ; /* MFG NIC string */
719 u64 rou_vector; /* vector from master node */
720} klrou_t ;
721
722/*
723 * Graphics Controller/Device
724 *
725 * (IP27/IO6) Prom versions 6.13 (and 6.5.1 kernels) and earlier
726 * used a couple different structures to store graphics information.
727 * For compatibility reasons, the newer data structure preserves some
728 * of the layout so that fields that are used in the old versions remain
729 * in the same place (with the same info). Determination of what version
730 * of this structure we have is done by checking the cookie field.
731 */
732#define KLGFX_COOKIE 0x0c0de000
733
734typedef struct klgfx_s { /* GRAPHICS Device */
735 klinfo_t gfx_info;
736 klconf_off_t old_gndevs; /* for compatibility with older proms */
737 klconf_off_t old_gdoff0; /* for compatibility with older proms */
738 unsigned int cookie; /* for compatibility with older proms */
739 unsigned int moduleslot;
740 struct klgfx_s *gfx_next_pipe;
741 graphics_t gfx_specific;
742 klconf_off_t pad0; /* for compatibility with older proms */
743 klconf_off_t gfx_mfg_nic;
744} klgfx_t;
745
746typedef struct klxthd_s {
747 klinfo_t xthd_info ;
748 klconf_off_t xthd_mfg_nic ; /* MFG NIC string */
749} klxthd_t ;
750
751typedef struct kltpu_s { /* TPU board */
752 klinfo_t tpu_info ;
753 klconf_off_t tpu_mfg_nic ; /* MFG NIC string */
754} kltpu_t ;
755
756typedef struct klgsn_s { /* GSN board */
757 klinfo_t gsn_info ;
758 klconf_off_t gsn_mfg_nic ; /* MFG NIC string */
759} klgsn_t ;
760
761#define MAX_SCSI_DEVS 16
762
763/*
764 * NOTE: THis is the max sized kl* structure and is used in klmalloc.c
765 * to allocate space of type COMPONENT. Make sure that if the size of
766 * any other component struct becomes more than this, then redefine
767 * that as the size to be klmalloced.
768 */
769
770typedef struct klscsi_s { /* SCSI Controller */
771 klinfo_t scsi_info ;
772 scsi_t scsi_specific ;
773 unsigned char scsi_numdevs ;
774 klconf_off_t scsi_devinfo[MAX_SCSI_DEVS] ;
775} klscsi_t ;
776
777typedef struct klscdev_s { /* SCSI device */
778 klinfo_t scdev_info ;
779 struct scsidisk_data *scdev_cfg ; /* driver fills up this */
780} klscdev_t ;
781
782typedef struct klttydev_s { /* TTY device */
783 klinfo_t ttydev_info ;
784 struct terminal_data *ttydev_cfg ; /* driver fills up this */
785} klttydev_t ;
786
787typedef struct klenetdev_s { /* ENET device */
788 klinfo_t enetdev_info ;
789 struct net_data *enetdev_cfg ; /* driver fills up this */
790} klenetdev_t ;
791
792typedef struct klkbddev_s { /* KBD device */
793 klinfo_t kbddev_info ;
794 struct keyboard_data *kbddev_cfg ; /* driver fills up this */
795} klkbddev_t ;
796
797typedef struct klmsdev_s { /* mouse device */
798 klinfo_t msdev_info ;
799 void *msdev_cfg ;
800} klmsdev_t ;
801
802#define MAX_FDDI_DEVS 10 /* XXX Is this true */
803
804typedef struct klfddi_s { /* FDDI */
805 klinfo_t fddi_info ;
806 fddi_t fddi_specific ;
807 klconf_off_t fddi_devinfo[MAX_FDDI_DEVS] ;
808} klfddi_t ;
809
810typedef struct klmio_s { /* MIO */
811 klinfo_t mio_info ;
812 mio_t mio_specific ;
813} klmio_t ;
814
815
816typedef union klcomp_s {
817 klcpu_t kc_cpu;
818 klhub_t kc_hub;
819 klmembnk_t kc_mem;
820 klxbow_t kc_xbow;
821 klbri_t kc_bri;
822 klioc3_t kc_ioc3;
823 klvmeb_t kc_vmeb;
824 klvmed_t kc_vmed;
825 klrou_t kc_rou;
826 klgfx_t kc_gfx;
827 klscsi_t kc_scsi;
828 klscdev_t kc_scsi_dev;
829 klfddi_t kc_fddi;
830 klmio_t kc_mio;
831 klmod_serial_num_t kc_snum ;
832} klcomp_t;
833
834typedef union kldev_s { /* for device structure allocation */
835 klscdev_t kc_scsi_dev ;
836 klttydev_t kc_tty_dev ;
837 klenetdev_t kc_enet_dev ;
838 klkbddev_t kc_kbd_dev ;
839} kldev_t ;
840
841/* Data structure interface routines. TBD */
842
843/* Include launch info in this file itself? TBD */
844
845/*
846 * TBD - Can the ARCS and device driver related info also be included in the
847 * KLCONFIG area. On the IO4PROM, prom device driver info is part of cfgnode_t
848 * structure, viz private to the IO4prom.
849 */
850
851/*
852 * TBD - Allocation issues.
853 *
854 * Do we need to Mark off sepatate heaps for lboard_t, rboard_t, component,
855 * errinfo and allocate from them, or have a single heap and allocate all
856 * structures from it. Debug is easier in the former method since we can
857 * dump all similar structs in one command, but there will be lots of holes,
858 * in memory and max limits are needed for number of structures.
859 * Another way to make it organized, is to have a union of all components
860 * and allocate a aligned chunk of memory greater than the biggest
861 * component.
862 */
863
864typedef union {
865 lboard_t *lbinfo ;
866} biptr_t ;
867
868
869#define BRI_PER_XBOW 6
870#define PCI_PER_BRI 8
871#define DEV_PER_PCI 16
872
873
874/* Virtual dipswitch values (starting from switch "7"): */
875
876#define VDS_NOGFX 0x8000 /* Don't enable gfx and autoboot */
877#define VDS_NOMP 0x100 /* Don't start slave processors */
878#define VDS_MANUMODE 0x80 /* Manufacturing mode */
879#define VDS_NOARB 0x40 /* No bootmaster arbitration */
880#define VDS_PODMODE 0x20 /* Go straight to POD mode */
881#define VDS_NO_DIAGS 0x10 /* Don't run any diags after BM arb */
882#define VDS_DEFAULTS 0x08 /* Use default environment values */
883#define VDS_NOMEMCLEAR 0x04 /* Don't run mem cfg code */
884#define VDS_2ND_IO4 0x02 /* Boot from the second IO4 */
885#define VDS_DEBUG_PROM 0x01 /* Print PROM debugging messages */
886
887/* external declarations of Linux kernel functions. */
888
889extern lboard_t *find_lboard(lboard_t *start, unsigned char type);
890extern klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char type);
891extern klinfo_t *find_first_component(lboard_t *brd, unsigned char type);
892extern klcpu_t *nasid_slice_to_cpuinfo(nasid_t, int);
893extern lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_class);
894
895
896extern klcpu_t *sn_get_cpuinfo(cpuid_t cpu);
897
898#endif /* _ASM_SN_KLCONFIG_H */
diff --git a/arch/mips/include/asm/sn/kldir.h b/arch/mips/include/asm/sn/kldir.h
new file mode 100644
index 000000000000..1327e12e9645
--- /dev/null
+++ b/arch/mips/include/asm/sn/kldir.h
@@ -0,0 +1,217 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/kldir.h>, revision 1.21.
7 *
8 * Copyright (C) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 1999, 2000 by Ralf Baechle
10 */
11#ifndef _ASM_SN_KLDIR_H
12#define _ASM_SN_KLDIR_H
13
14
15/*
16 * The kldir memory area resides at a fixed place in each node's memory and
17 * provides pointers to most other IP27 memory areas. This allows us to
18 * resize and/or relocate memory areas at a later time without breaking all
19 * firmware and kernels that use them. Indices in the array are
20 * permanently dedicated to areas listed below. Some memory areas (marked
21 * below) reside at a permanently fixed location, but are included in the
22 * directory for completeness.
23 */
24
25#define KLDIR_MAGIC 0x434d5f53505f5357
26
27/*
28 * The upper portion of the memory map applies during boot
29 * only and is overwritten by IRIX/SYMMON.
30 *
31 * MEMORY MAP PER NODE
32 *
33 * 0x2000000 (32M) +-----------------------------------------+
34 * | IO6 BUFFERS FOR FLASH ENET IOC3 |
35 * 0x1F80000 (31.5M) +-----------------------------------------+
36 * | IO6 TEXT/DATA/BSS/stack |
37 * 0x1C00000 (30M) +-----------------------------------------+
38 * | IO6 PROM DEBUG TEXT/DATA/BSS/stack |
39 * 0x0800000 (28M) +-----------------------------------------+
40 * | IP27 PROM TEXT/DATA/BSS/stack |
41 * 0x1B00000 (27M) +-----------------------------------------+
42 * | IP27 CFG |
43 * 0x1A00000 (26M) +-----------------------------------------+
44 * | Graphics PROM |
45 * 0x1800000 (24M) +-----------------------------------------+
46 * | 3rd Party PROM drivers |
47 * 0x1600000 (22M) +-----------------------------------------+
48 * | |
49 * | Free |
50 * | |
51 * +-----------------------------------------+
52 * | UNIX DEBUG Version |
53 * 0x190000 (2M--) +-----------------------------------------+
54 * | SYMMON |
55 * | (For UNIX Debug only) |
56 * 0x34000 (208K) +-----------------------------------------+
57 * | SYMMON STACK [NUM_CPU_PER_NODE] |
58 * | (For UNIX Debug only) |
59 * 0x25000 (148K) +-----------------------------------------+
60 * | KLCONFIG - II (temp) |
61 * | |
62 * | ---------------------------- |
63 * | |
64 * | UNIX NON-DEBUG Version |
65 * 0x19000 (100K) +-----------------------------------------+
66 *
67 *
68 * The lower portion of the memory map contains information that is
69 * permanent and is used by the IP27PROM, IO6PROM and IRIX.
70 *
71 * 0x19000 (100K) +-----------------------------------------+
72 * | |
73 * | PI Error Spools (32K) |
74 * | |
75 * 0x12000 (72K) +-----------------------------------------+
76 * | Unused |
77 * 0x11c00 (71K) +-----------------------------------------+
78 * | CPU 1 NMI Eframe area |
79 * 0x11a00 (70.5K) +-----------------------------------------+
80 * | CPU 0 NMI Eframe area |
81 * 0x11800 (70K) +-----------------------------------------+
82 * | CPU 1 NMI Register save area |
83 * 0x11600 (69.5K) +-----------------------------------------+
84 * | CPU 0 NMI Register save area |
85 * 0x11400 (69K) +-----------------------------------------+
86 * | GDA (1k) |
87 * 0x11000 (68K) +-----------------------------------------+
88 * | Early cache Exception stack |
89 * | and/or |
90 * | kernel/io6prom nmi registers |
91 * 0x10800 (66k) +-----------------------------------------+
92 * | cache error eframe |
93 * 0x10400 (65K) +-----------------------------------------+
94 * | Exception Handlers (UALIAS copy) |
95 * 0x10000 (64K) +-----------------------------------------+
96 * | |
97 * | |
98 * | KLCONFIG - I (permanent) (48K) |
99 * | |
100 * | |
101 * | |
102 * 0x4000 (16K) +-----------------------------------------+
103 * | NMI Handler (Protected Page) |
104 * 0x3000 (12K) +-----------------------------------------+
105 * | ARCS PVECTORS (master node only) |
106 * 0x2c00 (11K) +-----------------------------------------+
107 * | ARCS TVECTORS (master node only) |
108 * 0x2800 (10K) +-----------------------------------------+
109 * | LAUNCH [NUM_CPU] |
110 * 0x2400 (9K) +-----------------------------------------+
111 * | Low memory directory (KLDIR) |
112 * 0x2000 (8K) +-----------------------------------------+
113 * | ARCS SPB (1K) |
114 * 0x1000 (4K) +-----------------------------------------+
115 * | Early cache Exception stack |
116 * | and/or |
117 * | kernel/io6prom nmi registers |
118 * 0x800 (2k) +-----------------------------------------+
119 * | cache error eframe |
120 * 0x400 (1K) +-----------------------------------------+
121 * | Exception Handlers |
122 * 0x0 (0K) +-----------------------------------------+
123 */
124
125#ifdef __ASSEMBLY__
126#define KLDIR_OFF_MAGIC 0x00
127#define KLDIR_OFF_OFFSET 0x08
128#define KLDIR_OFF_POINTER 0x10
129#define KLDIR_OFF_SIZE 0x18
130#define KLDIR_OFF_COUNT 0x20
131#define KLDIR_OFF_STRIDE 0x28
132#endif /* __ASSEMBLY__ */
133
134/*
135 * This is defined here because IP27_SYMMON_STK_SIZE must be at least what
136 * we define here. Since it's set up in the prom. We can't redefine it later
137 * and expect more space to be allocated. The way to find out the true size
138 * of the symmon stacks is to divide SYMMON_STK_SIZE by SYMMON_STK_STRIDE
139 * for a particular node.
140 */
141#define SYMMON_STACK_SIZE 0x8000
142
143#if defined(PROM)
144
145/*
146 * These defines are prom version dependent. No code other than the IP27
147 * prom should attempt to use these values.
148 */
149#define IP27_LAUNCH_OFFSET 0x2400
150#define IP27_LAUNCH_SIZE 0x400
151#define IP27_LAUNCH_COUNT 2
152#define IP27_LAUNCH_STRIDE 0x200
153
154#define IP27_KLCONFIG_OFFSET 0x4000
155#define IP27_KLCONFIG_SIZE 0xc000
156#define IP27_KLCONFIG_COUNT 1
157#define IP27_KLCONFIG_STRIDE 0
158
159#define IP27_NMI_OFFSET 0x3000
160#define IP27_NMI_SIZE 0x40
161#define IP27_NMI_COUNT 2
162#define IP27_NMI_STRIDE 0x40
163
164#define IP27_PI_ERROR_OFFSET 0x12000
165#define IP27_PI_ERROR_SIZE 0x4000
166#define IP27_PI_ERROR_COUNT 1
167#define IP27_PI_ERROR_STRIDE 0
168
169#define IP27_SYMMON_STK_OFFSET 0x25000
170#define IP27_SYMMON_STK_SIZE 0xe000
171#define IP27_SYMMON_STK_COUNT 2
172/* IP27_SYMMON_STK_STRIDE must be >= SYMMON_STACK_SIZE */
173#define IP27_SYMMON_STK_STRIDE 0x7000
174
175#define IP27_FREEMEM_OFFSET 0x19000
176#define IP27_FREEMEM_SIZE -1
177#define IP27_FREEMEM_COUNT 1
178#define IP27_FREEMEM_STRIDE 0
179
180#endif /* PROM */
181/*
182 * There will be only one of these in a partition so the IO6 must set it up.
183 */
184#define IO6_GDA_OFFSET 0x11000
185#define IO6_GDA_SIZE 0x400
186#define IO6_GDA_COUNT 1
187#define IO6_GDA_STRIDE 0
188
189/*
190 * save area of kernel nmi regs in the prom format
191 */
192#define IP27_NMI_KREGS_OFFSET 0x11400
193#define IP27_NMI_KREGS_CPU_SIZE 0x200
194/*
195 * save area of kernel nmi regs in eframe format
196 */
197#define IP27_NMI_EFRAME_OFFSET 0x11800
198#define IP27_NMI_EFRAME_SIZE 0x200
199
200#define KLDIR_ENT_SIZE 0x40
201#define KLDIR_MAX_ENTRIES (0x400 / 0x40)
202
203#ifndef __ASSEMBLY__
204typedef struct kldir_ent_s {
205 u64 magic; /* Indicates validity of entry */
206 off_t offset; /* Offset from start of node space */
207 unsigned long pointer; /* Pointer to area in some cases */
208 size_t size; /* Size in bytes */
209 u64 count; /* Repeat count if array, 1 if not */
210 size_t stride; /* Stride if array, 0 if not */
211 char rsvd[16]; /* Pad entry to 0x40 bytes */
212 /* NOTE: These 16 bytes are used in the Partition KLDIR
213 entry to store partition info. Refer to klpart.h for this. */
214} kldir_ent_t;
215#endif /* !__ASSEMBLY__ */
216
217#endif /* _ASM_SN_KLDIR_H */
diff --git a/arch/mips/include/asm/sn/klkernvars.h b/arch/mips/include/asm/sn/klkernvars.h
new file mode 100644
index 000000000000..5de4c5e8ab30
--- /dev/null
+++ b/arch/mips/include/asm/sn/klkernvars.h
@@ -0,0 +1,29 @@
1/*
2 * File ported from IRIX to Linux by Kanoj Sarcar, 06/08/00.
3 * Copyright 2000 Silicon Graphics, Inc.
4 */
5#ifndef __ASM_SN_KLKERNVARS_H
6#define __ASM_SN_KLKERNVARS_H
7
8#define KV_MAGIC_OFFSET 0x0
9#define KV_RO_NASID_OFFSET 0x4
10#define KV_RW_NASID_OFFSET 0x6
11
12#define KV_MAGIC 0x5f4b565f
13
14#ifndef __ASSEMBLY__
15
16#include <asm/sn/types.h>
17
18typedef struct kern_vars_s {
19 int kv_magic;
20 nasid_t kv_ro_nasid;
21 nasid_t kv_rw_nasid;
22 unsigned long kv_ro_baseaddr;
23 unsigned long kv_rw_baseaddr;
24} kern_vars_t;
25
26#endif /* !__ASSEMBLY__ */
27
28#endif /* __ASM_SN_KLKERNVARS_H */
29
diff --git a/arch/mips/include/asm/sn/launch.h b/arch/mips/include/asm/sn/launch.h
new file mode 100644
index 000000000000..b7c2226312c6
--- /dev/null
+++ b/arch/mips/include/asm/sn/launch.h
@@ -0,0 +1,106 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1992 - 1997, 2000 Silicon Graphics, Inc.
7 * Copyright (C) 2000 by Colin Ngam
8 */
9#ifndef _ASM_SN_LAUNCH_H
10#define _ASM_SN_LAUNCH_H
11
12#include <asm/sn/types.h>
13#include <asm/sn/addrs.h>
14
15/*
16 * The launch data structure resides at a fixed place in each node's memory
17 * and is used to communicate between the master processor and the slave
18 * processors.
19 *
20 * The master stores launch parameters in the launch structure
21 * corresponding to a target processor that is in a slave loop, then sends
22 * an interrupt to the slave processor. The slave calls the desired
23 * function, then returns to the slave loop. The master may poll or wait
24 * for the slaves to finish.
25 *
26 * There is an array of launch structures, one per CPU on the node. One
27 * interrupt level is used per local CPU.
28 */
29
30#define LAUNCH_MAGIC 0xaddbead2addbead3
31#ifdef CONFIG_SGI_IP27
32#define LAUNCH_SIZEOF 0x100
33#define LAUNCH_PADSZ 0xa0
34#endif
35
36#define LAUNCH_OFF_MAGIC 0x00 /* Struct offsets for assembly */
37#define LAUNCH_OFF_BUSY 0x08
38#define LAUNCH_OFF_CALL 0x10
39#define LAUNCH_OFF_CALLC 0x18
40#define LAUNCH_OFF_CALLPARM 0x20
41#define LAUNCH_OFF_STACK 0x28
42#define LAUNCH_OFF_GP 0x30
43#define LAUNCH_OFF_BEVUTLB 0x38
44#define LAUNCH_OFF_BEVNORMAL 0x40
45#define LAUNCH_OFF_BEVECC 0x48
46
47#define LAUNCH_STATE_DONE 0 /* Return value of LAUNCH_POLL */
48#define LAUNCH_STATE_SENT 1
49#define LAUNCH_STATE_RECD 2
50
51/*
52 * The launch routine is called only if the complement address is correct.
53 *
54 * Before control is transferred to a routine, the complement address
55 * is zeroed (invalidated) to prevent an accidental call from a spurious
56 * interrupt.
57 *
58 * The slave_launch routine turns on the BUSY flag, and the slave loop
59 * clears the BUSY flag after control is returned to it.
60 */
61
62#ifndef __ASSEMBLY__
63
64typedef int launch_state_t;
65typedef void (*launch_proc_t)(u64 call_parm);
66
67typedef struct launch_s {
68 volatile u64 magic; /* Magic number */
69 volatile u64 busy; /* Slave currently active */
70 volatile launch_proc_t call_addr; /* Func. for slave to call */
71 volatile u64 call_addr_c; /* 1's complement of call_addr*/
72 volatile u64 call_parm; /* Single parm passed to call*/
73 volatile void *stack_addr; /* Stack pointer for slave function */
74 volatile void *gp_addr; /* Global pointer for slave func. */
75 volatile char *bevutlb;/* Address of bev utlb ex handler */
76 volatile char *bevnormal;/*Address of bev normal ex handler */
77 volatile char *bevecc;/* Address of bev cache err handler */
78 volatile char pad[160]; /* Pad to LAUNCH_SIZEOF */
79} launch_t;
80
81/*
82 * PROM entry points for launch routines are determined by IPxxprom/start.s
83 */
84
85#define LAUNCH_SLAVE (*(void (*)(int nasid, int cpu, \
86 launch_proc_t call_addr, \
87 u64 call_parm, \
88 void *stack_addr, \
89 void *gp_addr)) \
90 IP27PROM_LAUNCHSLAVE)
91
92#define LAUNCH_WAIT (*(void (*)(int nasid, int cpu, int timeout_msec)) \
93 IP27PROM_WAITSLAVE)
94
95#define LAUNCH_POLL (*(launch_state_t (*)(int nasid, int cpu)) \
96 IP27PROM_POLLSLAVE)
97
98#define LAUNCH_LOOP (*(void (*)(void)) \
99 IP27PROM_SLAVELOOP)
100
101#define LAUNCH_FLASH (*(void (*)(void)) \
102 IP27PROM_FLASHLEDS)
103
104#endif /* !__ASSEMBLY__ */
105
106#endif /* _ASM_SN_LAUNCH_H */
diff --git a/arch/mips/include/asm/sn/mapped_kernel.h b/arch/mips/include/asm/sn/mapped_kernel.h
new file mode 100644
index 000000000000..721496a0bb92
--- /dev/null
+++ b/arch/mips/include/asm/sn/mapped_kernel.h
@@ -0,0 +1,54 @@
1/*
2 * File created by Kanoj Sarcar 06/06/00.
3 * Copyright 2000 Silicon Graphics, Inc.
4 */
5#ifndef __ASM_SN_MAPPED_KERNEL_H
6#define __ASM_SN_MAPPED_KERNEL_H
7
8#include <linux/mmzone.h>
9
10/*
11 * Note on how mapped kernels work: the text and data section is
12 * compiled at cksseg segment (LOADADDR = 0xc001c000), and the
13 * init/setup/data section gets a 16M virtual address bump in the
14 * ld.script file (so that tlblo0 and tlblo1 maps the sections).
15 * The vmlinux.64 section addresses are put in the xkseg range
16 * using the change-addresses makefile option. Use elfdump -of
17 * on IRIX to see where the sections go. The Origin loader loads
18 * the two sections contiguously in physical memory. The loader
19 * sets the entry point into kernel_entry using a xkphys address,
20 * but instead of using 0xa800000001160000, it uses the address
21 * 0xa800000000160000, which is where it physically loaded that
22 * code. So no jumps can be done before we have switched to using
23 * cksseg addresses.
24 */
25#include <asm/addrspace.h>
26
27#define REP_BASE CAC_BASE
28
29#ifdef CONFIG_MAPPED_KERNEL
30
31#define MAPPED_ADDR_RO_TO_PHYS(x) (x - REP_BASE)
32#define MAPPED_ADDR_RW_TO_PHYS(x) (x - REP_BASE - 16777216)
33
34#define MAPPED_KERN_RO_PHYSBASE(n) (hub_data(n)->kern_vars.kv_ro_baseaddr)
35#define MAPPED_KERN_RW_PHYSBASE(n) (hub_data(n)->kern_vars.kv_rw_baseaddr)
36
37#define MAPPED_KERN_RO_TO_PHYS(x) \
38 ((unsigned long)MAPPED_ADDR_RO_TO_PHYS(x) | \
39 MAPPED_KERN_RO_PHYSBASE(get_compact_nodeid()))
40#define MAPPED_KERN_RW_TO_PHYS(x) \
41 ((unsigned long)MAPPED_ADDR_RW_TO_PHYS(x) | \
42 MAPPED_KERN_RW_PHYSBASE(get_compact_nodeid()))
43
44#else /* CONFIG_MAPPED_KERNEL */
45
46#define MAPPED_KERN_RO_TO_PHYS(x) (x - REP_BASE)
47#define MAPPED_KERN_RW_TO_PHYS(x) (x - REP_BASE)
48
49#endif /* CONFIG_MAPPED_KERNEL */
50
51#define MAPPED_KERN_RO_TO_K0(x) PHYS_TO_K0(MAPPED_KERN_RO_TO_PHYS(x))
52#define MAPPED_KERN_RW_TO_K0(x) PHYS_TO_K0(MAPPED_KERN_RW_TO_PHYS(x))
53
54#endif /* __ASM_SN_MAPPED_KERNEL_H */
diff --git a/arch/mips/include/asm/sn/nmi.h b/arch/mips/include/asm/sn/nmi.h
new file mode 100644
index 000000000000..6b7b0b5f3729
--- /dev/null
+++ b/arch/mips/include/asm/sn/nmi.h
@@ -0,0 +1,125 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1992 - 1997 Silicon Graphics, Inc.
7 */
8#ifndef __ASM_SN_NMI_H
9#define __ASM_SN_NMI_H
10
11#ident "$Revision: 1.5 $"
12
13#include <asm/sn/addrs.h>
14
15/*
16 * The launch data structure resides at a fixed place in each node's memory
17 * and is used to communicate between the master processor and the slave
18 * processors.
19 *
20 * The master stores launch parameters in the launch structure
21 * corresponding to a target processor that is in a slave loop, then sends
22 * an interrupt to the slave processor. The slave calls the desired
23 * function, followed by an optional rendezvous function, then returns to
24 * the slave loop. The master does not wait for the slaves before
25 * returning.
26 *
27 * There is an array of launch structures, one per CPU on the node. One
28 * interrupt level is used per CPU.
29 */
30
31#define NMI_MAGIC 0x48414d4d455201
32#define NMI_SIZEOF 0x40
33
34#define NMI_OFF_MAGIC 0x00 /* Struct offsets for assembly */
35#define NMI_OFF_FLAGS 0x08
36#define NMI_OFF_CALL 0x10
37#define NMI_OFF_CALLC 0x18
38#define NMI_OFF_CALLPARM 0x20
39#define NMI_OFF_GMASTER 0x28
40
41/*
42 * The NMI routine is called only if the complement address is
43 * correct.
44 *
45 * Before control is transferred to a routine, the complement address
46 * is zeroed (invalidated) to prevent an accidental call from a spurious
47 * interrupt.
48 *
49 */
50
51#ifndef __ASSEMBLY__
52
53typedef struct nmi_s {
54 volatile unsigned long magic; /* Magic number */
55 volatile unsigned long flags; /* Combination of flags above */
56 volatile void *call_addr; /* Routine for slave to call */
57 volatile void *call_addr_c; /* 1's complement of address */
58 volatile void *call_parm; /* Single parm passed to call */
59 volatile unsigned long gmaster; /* Flag true only on global master*/
60} nmi_t;
61
62#endif /* !__ASSEMBLY__ */
63
64/* Following definitions are needed both in the prom & the kernel
65 * to identify the format of the nmi cpu register save area in the
66 * low memory on each node.
67 */
68#ifndef __ASSEMBLY__
69
70struct reg_struct {
71 unsigned long gpr[32];
72 unsigned long sr;
73 unsigned long cause;
74 unsigned long epc;
75 unsigned long badva;
76 unsigned long error_epc;
77 unsigned long cache_err;
78 unsigned long nmi_sr;
79};
80
81#endif /* !__ASSEMBLY__ */
82
83/* These are the assembly language offsets into the reg_struct structure */
84
85#define R0_OFF 0x0
86#define R1_OFF 0x8
87#define R2_OFF 0x10
88#define R3_OFF 0x18
89#define R4_OFF 0x20
90#define R5_OFF 0x28
91#define R6_OFF 0x30
92#define R7_OFF 0x38
93#define R8_OFF 0x40
94#define R9_OFF 0x48
95#define R10_OFF 0x50
96#define R11_OFF 0x58
97#define R12_OFF 0x60
98#define R13_OFF 0x68
99#define R14_OFF 0x70
100#define R15_OFF 0x78
101#define R16_OFF 0x80
102#define R17_OFF 0x88
103#define R18_OFF 0x90
104#define R19_OFF 0x98
105#define R20_OFF 0xa0
106#define R21_OFF 0xa8
107#define R22_OFF 0xb0
108#define R23_OFF 0xb8
109#define R24_OFF 0xc0
110#define R25_OFF 0xc8
111#define R26_OFF 0xd0
112#define R27_OFF 0xd8
113#define R28_OFF 0xe0
114#define R29_OFF 0xe8
115#define R30_OFF 0xf0
116#define R31_OFF 0xf8
117#define SR_OFF 0x100
118#define CAUSE_OFF 0x108
119#define EPC_OFF 0x110
120#define BADVA_OFF 0x118
121#define ERROR_EPC_OFF 0x120
122#define CACHE_ERR_OFF 0x128
123#define NMISR_OFF 0x130
124
125#endif /* __ASM_SN_NMI_H */
diff --git a/arch/mips/include/asm/sn/sn0/addrs.h b/arch/mips/include/asm/sn/sn0/addrs.h
new file mode 100644
index 000000000000..b06190093bbc
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn0/addrs.h
@@ -0,0 +1,288 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/SN0/addrs.h>, revision 1.126.
7 *
8 * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
9 * Copyright (C) 1999 by Ralf Baechle
10 */
11#ifndef _ASM_SN_SN0_ADDRS_H
12#define _ASM_SN_SN0_ADDRS_H
13
14
15/*
16 * SN0 (on a T5) Address map
17 *
18 * This file contains a set of definitions and macros which are used
19 * to reference into the major address spaces (CAC, HSPEC, IO, MSPEC,
20 * and UNCAC) used by the SN0 architecture. It also contains addresses
21 * for "major" statically locatable PROM/Kernel data structures, such as
22 * the partition table, the configuration data structure, etc.
23 * We make an implicit assumption that the processor using this file
24 * follows the R10K's provisions for specifying uncached attributes;
25 * should this change, the base registers may very well become processor-
26 * dependent.
27 *
28 * For more information on the address spaces, see the "Local Resources"
29 * chapter of the Hub specification.
30 *
31 * NOTE: This header file is included both by C and by assembler source
32 * files. Please bracket any language-dependent definitions
33 * appropriately.
34 */
35
36/*
37 * Some of the macros here need to be casted to appropriate types when used
38 * from C. They definitely must not be casted from assembly language so we
39 * use some new ANSI preprocessor stuff to paste these on where needed.
40 */
41
42/*
43 * The following couple of definitions will eventually need to be variables,
44 * since the amount of address space assigned to each node depends on
45 * whether the system is running in N-mode (more nodes with less memory)
46 * or M-mode (fewer nodes with more memory). We expect that it will
47 * be a while before we need to make this decision dynamically, though,
48 * so for now we just use defines bracketed by an ifdef.
49 */
50
51#ifdef CONFIG_SGI_SN_N_MODE
52
53#define NODE_SIZE_BITS 31
54#define BWIN_SIZE_BITS 28
55
56#define NASID_BITS 9
57#define NASID_BITMASK (0x1ffLL)
58#define NASID_SHFT 31
59#define NASID_META_BITS 5
60#define NASID_LOCAL_BITS 4
61
62#define BDDIR_UPPER_MASK (UINT64_CAST 0x7ffff << 10)
63#define BDECC_UPPER_MASK (UINT64_CAST 0x3ffffff << 3)
64
65#else /* !defined(CONFIG_SGI_SN_N_MODE), assume that M-mode is desired */
66
67#define NODE_SIZE_BITS 32
68#define BWIN_SIZE_BITS 29
69
70#define NASID_BITMASK (0xffLL)
71#define NASID_BITS 8
72#define NASID_SHFT 32
73#define NASID_META_BITS 4
74#define NASID_LOCAL_BITS 4
75
76#define BDDIR_UPPER_MASK (UINT64_CAST 0xfffff << 10)
77#define BDECC_UPPER_MASK (UINT64_CAST 0x7ffffff << 3)
78
79#endif /* !defined(CONFIG_SGI_SN_N_MODE) */
80
81#define NODE_ADDRSPACE_SIZE (UINT64_CAST 1 << NODE_SIZE_BITS)
82
83#define NASID_MASK (UINT64_CAST NASID_BITMASK << NASID_SHFT)
84#define NASID_GET(_pa) (int) ((UINT64_CAST (_pa) >> \
85 NASID_SHFT) & NASID_BITMASK)
86
87#if !defined(__ASSEMBLY__)
88
89#define NODE_SWIN_BASE(nasid, widget) \
90 ((widget == 0) ? NODE_BWIN_BASE((nasid), SWIN0_BIGWIN) \
91 : RAW_NODE_SWIN_BASE(nasid, widget))
92#else /* __ASSEMBLY__ */
93#define NODE_SWIN_BASE(nasid, widget) \
94 (NODE_IO_BASE(nasid) + (UINT64_CAST(widget) << SWIN_SIZE_BITS))
95#endif /* __ASSEMBLY__ */
96
97/*
98 * The following definitions pertain to the IO special address
99 * space. They define the location of the big and little windows
100 * of any given node.
101 */
102
103#define BWIN_INDEX_BITS 3
104#define BWIN_SIZE (UINT64_CAST 1 << BWIN_SIZE_BITS)
105#define BWIN_SIZEMASK (BWIN_SIZE - 1)
106#define BWIN_WIDGET_MASK 0x7
107#define NODE_BWIN_BASE0(nasid) (NODE_IO_BASE(nasid) + BWIN_SIZE)
108#define NODE_BWIN_BASE(nasid, bigwin) (NODE_BWIN_BASE0(nasid) + \
109 (UINT64_CAST(bigwin) << BWIN_SIZE_BITS))
110
111#define BWIN_WIDGETADDR(addr) ((addr) & BWIN_SIZEMASK)
112#define BWIN_WINDOWNUM(addr) (((addr) >> BWIN_SIZE_BITS) & BWIN_WIDGET_MASK)
113/*
114 * Verify if addr belongs to large window address of node with "nasid"
115 *
116 *
117 * NOTE: "addr" is expected to be XKPHYS address, and NOT physical
118 * address
119 *
120 *
121 */
122
123#define NODE_BWIN_ADDR(nasid, addr) \
124 (((addr) >= NODE_BWIN_BASE0(nasid)) && \
125 ((addr) < (NODE_BWIN_BASE(nasid, HUB_NUM_BIG_WINDOW) + \
126 BWIN_SIZE)))
127
128/*
129 * The following define the major position-independent aliases used
130 * in SN0.
131 * CALIAS -- Varies in size, points to the first n bytes of memory
132 * on the reader's node.
133 */
134
135#define CALIAS_BASE CAC_BASE
136
137
138
139#define BRIDGE_REG_PTR(_base, _off) ((volatile bridgereg_t *) \
140 ((__psunsigned_t)(_base) + (__psunsigned_t)(_off)))
141
142#define SN0_WIDGET_BASE(_nasid, _wid) (NODE_SWIN_BASE((_nasid), (_wid)))
143
144/* Turn on sable logging for the processors whose bits are set. */
145#define SABLE_LOG_TRIGGER(_map)
146
147#ifndef __ASSEMBLY__
148#define KERN_NMI_ADDR(nasid, slice) \
149 TO_NODE_UNCAC((nasid), IP27_NMI_KREGS_OFFSET + \
150 (IP27_NMI_KREGS_CPU_SIZE * (slice)))
151#endif /* !__ASSEMBLY__ */
152
153#ifdef PROM
154
155#define MISC_PROM_BASE PHYS_TO_K0(0x01300000)
156#define MISC_PROM_SIZE 0x200000
157
158#define DIAG_BASE PHYS_TO_K0(0x01500000)
159#define DIAG_SIZE 0x300000
160
161#define ROUTE_BASE PHYS_TO_K0(0x01800000)
162#define ROUTE_SIZE 0x200000
163
164#define IP27PROM_FLASH_HDR PHYS_TO_K0(0x01300000)
165#define IP27PROM_FLASH_DATA PHYS_TO_K0(0x01301000)
166#define IP27PROM_CORP_MAX 32
167#define IP27PROM_CORP PHYS_TO_K0(0x01800000)
168#define IP27PROM_CORP_SIZE 0x10000
169#define IP27PROM_CORP_STK PHYS_TO_K0(0x01810000)
170#define IP27PROM_CORP_STKSIZE 0x2000
171#define IP27PROM_DECOMP_BUF PHYS_TO_K0(0x01900000)
172#define IP27PROM_DECOMP_SIZE 0xfff00
173
174#define IP27PROM_BASE PHYS_TO_K0(0x01a00000)
175#define IP27PROM_BASE_MAPPED (UNCAC_BASE | 0x1fc00000)
176#define IP27PROM_SIZE_MAX 0x100000
177
178#define IP27PROM_PCFG PHYS_TO_K0(0x01b00000)
179#define IP27PROM_PCFG_SIZE 0xd0000
180#define IP27PROM_ERRDMP PHYS_TO_K1(0x01bd0000)
181#define IP27PROM_ERRDMP_SIZE 0xf000
182
183#define IP27PROM_INIT_START PHYS_TO_K1(0x01bd0000)
184#define IP27PROM_CONSOLE PHYS_TO_K1(0x01bdf000)
185#define IP27PROM_CONSOLE_SIZE 0x200
186#define IP27PROM_NETUART PHYS_TO_K1(0x01bdf200)
187#define IP27PROM_NETUART_SIZE 0x100
188#define IP27PROM_UNUSED1 PHYS_TO_K1(0x01bdf300)
189#define IP27PROM_UNUSED1_SIZE 0x500
190#define IP27PROM_ELSC_BASE_A PHYS_TO_K0(0x01bdf800)
191#define IP27PROM_ELSC_BASE_B PHYS_TO_K0(0x01bdfc00)
192#define IP27PROM_STACK_A PHYS_TO_K0(0x01be0000)
193#define IP27PROM_STACK_B PHYS_TO_K0(0x01bf0000)
194#define IP27PROM_STACK_SHFT 16
195#define IP27PROM_STACK_SIZE (1 << IP27PROM_STACK_SHFT)
196#define IP27PROM_INIT_END PHYS_TO_K0(0x01c00000)
197
198#define SLAVESTACK_BASE PHYS_TO_K0(0x01580000)
199#define SLAVESTACK_SIZE 0x40000
200
201#define ENETBUFS_BASE PHYS_TO_K0(0x01f80000)
202#define ENETBUFS_SIZE 0x20000
203
204#define IO6PROM_BASE PHYS_TO_K0(0x01c00000)
205#define IO6PROM_SIZE 0x400000
206#define IO6PROM_BASE_MAPPED (UNCAC_BASE | 0x11c00000)
207#define IO6DPROM_BASE PHYS_TO_K0(0x01c00000)
208#define IO6DPROM_SIZE 0x200000
209
210#define NODEBUGUNIX_ADDR PHYS_TO_K0(0x00019000)
211#define DEBUGUNIX_ADDR PHYS_TO_K0(0x00100000)
212
213#define IP27PROM_INT_LAUNCH 10 /* and 11 */
214#define IP27PROM_INT_NETUART 12 /* through 17 */
215
216#endif /* PROM */
217
218/*
219 * needed by symmon so it needs to be outside #if PROM
220 */
221#define IP27PROM_ELSC_SHFT 10
222#define IP27PROM_ELSC_SIZE (1 << IP27PROM_ELSC_SHFT)
223
224/*
225 * This address is used by IO6PROM to build MemoryDescriptors of
226 * free memory. This address is important since unix gets loaded
227 * at this address, and this memory has to be FREE if unix is to
228 * be loaded.
229 */
230
231#define FREEMEM_BASE PHYS_TO_K0(0x2000000)
232
233#define IO6PROM_STACK_SHFT 14 /* stack per cpu */
234#define IO6PROM_STACK_SIZE (1 << IO6PROM_STACK_SHFT)
235
236/*
237 * IP27 PROM vectors
238 */
239
240#define IP27PROM_ENTRY PHYS_TO_COMPATK1(0x1fc00000)
241#define IP27PROM_RESTART PHYS_TO_COMPATK1(0x1fc00008)
242#define IP27PROM_SLAVELOOP PHYS_TO_COMPATK1(0x1fc00010)
243#define IP27PROM_PODMODE PHYS_TO_COMPATK1(0x1fc00018)
244#define IP27PROM_IOC3UARTPOD PHYS_TO_COMPATK1(0x1fc00020)
245#define IP27PROM_FLASHLEDS PHYS_TO_COMPATK1(0x1fc00028)
246#define IP27PROM_REPOD PHYS_TO_COMPATK1(0x1fc00030)
247#define IP27PROM_LAUNCHSLAVE PHYS_TO_COMPATK1(0x1fc00038)
248#define IP27PROM_WAITSLAVE PHYS_TO_COMPATK1(0x1fc00040)
249#define IP27PROM_POLLSLAVE PHYS_TO_COMPATK1(0x1fc00048)
250
251#define KL_UART_BASE LOCAL_HUB_ADDR(MD_UREG0_0) /* base of UART regs */
252#define KL_UART_CMD LOCAL_HUB_ADDR(MD_UREG0_0) /* UART command reg */
253#define KL_UART_DATA LOCAL_HUB_ADDR(MD_UREG0_1) /* UART data reg */
254#define KL_I2C_REG MD_UREG0_0 /* I2C reg */
255
256#ifndef __ASSEMBLY__
257
258/* Address 0x400 to 0x1000 ualias points to cache error eframe + misc
259 * CACHE_ERR_SP_PTR could either contain an address to the stack, or
260 * the stack could start at CACHE_ERR_SP_PTR
261 */
262#if defined(HUB_ERR_STS_WAR)
263#define CACHE_ERR_EFRAME 0x480
264#else /* HUB_ERR_STS_WAR */
265#define CACHE_ERR_EFRAME 0x400
266#endif /* HUB_ERR_STS_WAR */
267
268#define CACHE_ERR_ECCFRAME (CACHE_ERR_EFRAME + EF_SIZE)
269#define CACHE_ERR_SP_PTR (0x1000 - 32) /* why -32? TBD */
270#define CACHE_ERR_IBASE_PTR (0x1000 - 40)
271#define CACHE_ERR_SP (CACHE_ERR_SP_PTR - 16)
272#define CACHE_ERR_AREA_SIZE (ARCS_SPB_OFFSET - CACHE_ERR_EFRAME)
273
274#endif /* !__ASSEMBLY__ */
275
276#define _ARCSPROM
277
278#if defined(HUB_ERR_STS_WAR)
279
280#define ERR_STS_WAR_REGISTER IIO_IIBUSERR
281#define ERR_STS_WAR_ADDR LOCAL_HUB_ADDR(IIO_IIBUSERR)
282#define ERR_STS_WAR_PHYSADDR TO_PHYS((__psunsigned_t)ERR_STS_WAR_ADDR)
283 /* Used to match addr in error reg. */
284#define OLD_ERR_STS_WAR_OFFSET ((MD_MEM_BANKS * MD_BANK_SIZE) - 0x100)
285
286#endif /* HUB_ERR_STS_WAR */
287
288#endif /* _ASM_SN_SN0_ADDRS_H */
diff --git a/arch/mips/include/asm/sn/sn0/arch.h b/arch/mips/include/asm/sn/sn0/arch.h
new file mode 100644
index 000000000000..f734f2007f24
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn0/arch.h
@@ -0,0 +1,72 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * SGI IP27 specific setup.
7 *
8 * Copyright (C) 1995 - 1997, 1999 Silcon Graphics, Inc.
9 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
10 */
11#ifndef _ASM_SN_SN0_ARCH_H
12#define _ASM_SN_SN0_ARCH_H
13
14
15#ifndef SN0XXL /* 128 cpu SMP max */
16/*
17 * This is the maximum number of nodes that can be part of a kernel.
18 * Effectively, it's the maximum number of compact node ids (cnodeid_t).
19 */
20#define MAX_COMPACT_NODES 64
21
22/*
23 * MAXCPUS refers to the maximum number of CPUs in a single kernel.
24 * This is not necessarily the same as MAXNODES * CPUS_PER_NODE
25 */
26#define MAXCPUS 128
27
28#else /* SN0XXL system */
29
30#define MAX_COMPACT_NODES 128
31#define MAXCPUS 256
32
33#endif /* SN0XXL */
34
35/*
36 * This is the maximum number of NASIDS that can be present in a system.
37 * (Highest NASID plus one.)
38 */
39#define MAX_NASIDS 256
40
41/*
42 * MAX_REGIONS refers to the maximum number of hardware partitioned regions.
43 */
44#define MAX_REGIONS 64
45#define MAX_NONPREMIUM_REGIONS 16
46#define MAX_PREMIUM_REGIONS MAX_REGIONS
47
48/*
49 * MAX_PARITIONS refers to the maximum number of logically defined
50 * partitions the system can support.
51 */
52#define MAX_PARTITIONS MAX_REGIONS
53
54#define NASID_MASK_BYTES ((MAX_NASIDS + 7) / 8)
55
56/*
57 * Slot constants for SN0
58 */
59#ifdef CONFIG_SGI_SN_N_MODE
60#define MAX_MEM_SLOTS 16 /* max slots per node */
61#else /* !CONFIG_SGI_SN_N_MODE, assume CONFIG_SGI_SN_M_MODE */
62#define MAX_MEM_SLOTS 32 /* max slots per node */
63#endif /* CONFIG_SGI_SN_M_MODE */
64
65#define SLOT_SHIFT (27)
66#define SLOT_MIN_MEM_SIZE (32*1024*1024)
67
68#define CPUS_PER_NODE 2 /* CPUs on a single hub */
69#define CPUS_PER_NODE_SHFT 1 /* Bits to shift in the node number */
70#define CPUS_PER_SUBNODE 2 /* CPUs on a single hub PI */
71
72#endif /* _ASM_SN_SN0_ARCH_H */
diff --git a/arch/mips/include/asm/sn/sn0/hub.h b/arch/mips/include/asm/sn/sn0/hub.h
new file mode 100644
index 000000000000..3e228f8e7969
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn0/hub.h
@@ -0,0 +1,40 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
7 * Copyright (C) 1999 by Ralf Baechle
8 */
9#ifndef _ASM_SN_SN0_HUB_H
10#define _ASM_SN_SN0_HUB_H
11
12/* The secret password; used to release protection */
13#define HUB_PASSWORD 0x53474972756c6573ull
14
15#define CHIPID_HUB 0
16#define CHIPID_ROUTER 1
17
18#define HUB_REV_1_0 1
19#define HUB_REV_2_0 2
20#define HUB_REV_2_1 3
21#define HUB_REV_2_2 4
22#define HUB_REV_2_3 5
23#define HUB_REV_2_4 6
24
25#define MAX_HUB_PATH 80
26
27#include <asm/sn/sn0/addrs.h>
28#include <asm/sn/sn0/hubpi.h>
29#include <asm/sn/sn0/hubmd.h>
30#include <asm/sn/sn0/hubio.h>
31#include <asm/sn/sn0/hubni.h>
32//#include <asm/sn/sn0/hubcore.h>
33
34/* Translation of uncached attributes */
35#define UATTR_HSPEC 0
36#define UATTR_IO 1
37#define UATTR_MSPEC 2
38#define UATTR_UNCAC 3
39
40#endif /* _ASM_SN_SN0_HUB_H */
diff --git a/arch/mips/include/asm/sn/sn0/hubio.h b/arch/mips/include/asm/sn/sn0/hubio.h
new file mode 100644
index 000000000000..d0c29d4de084
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn0/hubio.h
@@ -0,0 +1,972 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/SN0/hubio.h>, Revision 1.80.
7 *
8 * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
9 * Copyright (C) 1999 by Ralf Baechle
10 */
11#ifndef _ASM_SGI_SN_SN0_HUBIO_H
12#define _ASM_SGI_SN_SN0_HUBIO_H
13
14/*
15 * Hub I/O interface registers
16 *
17 * All registers in this file are subject to change until Hub chip tapeout.
18 * In general, the longer software name should be used when available.
19 */
20
21/*
22 * Slightly friendlier names for some common registers.
23 * The hardware definitions follow.
24 */
25#define IIO_WIDGET IIO_WID /* Widget identification */
26#define IIO_WIDGET_STAT IIO_WSTAT /* Widget status register */
27#define IIO_WIDGET_CTRL IIO_WCR /* Widget control register */
28#define IIO_WIDGET_TOUT IIO_WRTO /* Widget request timeout */
29#define IIO_WIDGET_FLUSH IIO_WTFR /* Widget target flush */
30#define IIO_PROTECT IIO_ILAPR /* IO interface protection */
31#define IIO_PROTECT_OVRRD IIO_ILAPO /* IO protect override */
32#define IIO_OUTWIDGET_ACCESS IIO_IOWA /* Outbound widget access */
33#define IIO_INWIDGET_ACCESS IIO_IIWA /* Inbound widget access */
34#define IIO_INDEV_ERR_MASK IIO_IIDEM /* Inbound device error mask */
35#define IIO_LLP_CSR IIO_ILCSR /* LLP control and status */
36#define IIO_LLP_LOG IIO_ILLR /* LLP log */
37#define IIO_XTALKCC_TOUT IIO_IXCC /* Xtalk credit count timeout*/
38#define IIO_XTALKTT_TOUT IIO_IXTT /* Xtalk tail timeout */
39#define IIO_IO_ERR_CLR IIO_IECLR /* IO error clear */
40#define IIO_BTE_CRB_CNT IIO_IBCN /* IO BTE CRB count */
41
42#define IIO_LLP_CSR_IS_UP 0x00002000
43#define IIO_LLP_CSR_LLP_STAT_MASK 0x00003000
44#define IIO_LLP_CSR_LLP_STAT_SHFT 12
45
46/* key to IIO_PROTECT_OVRRD */
47#define IIO_PROTECT_OVRRD_KEY 0x53474972756c6573ull /* "SGIrules" */
48
49/* BTE register names */
50#define IIO_BTE_STAT_0 IIO_IBLS_0 /* Also BTE length/status 0 */
51#define IIO_BTE_SRC_0 IIO_IBSA_0 /* Also BTE source address 0 */
52#define IIO_BTE_DEST_0 IIO_IBDA_0 /* Also BTE dest. address 0 */
53#define IIO_BTE_CTRL_0 IIO_IBCT_0 /* Also BTE control/terminate 0 */
54#define IIO_BTE_NOTIFY_0 IIO_IBNA_0 /* Also BTE notification 0 */
55#define IIO_BTE_INT_0 IIO_IBIA_0 /* Also BTE interrupt 0 */
56#define IIO_BTE_OFF_0 0 /* Base offset from BTE 0 regs. */
57#define IIO_BTE_OFF_1 IIO_IBLS_1 - IIO_IBLS_0 /* Offset from base to BTE 1 */
58
59/* BTE register offsets from base */
60#define BTEOFF_STAT 0
61#define BTEOFF_SRC (IIO_BTE_SRC_0 - IIO_BTE_STAT_0)
62#define BTEOFF_DEST (IIO_BTE_DEST_0 - IIO_BTE_STAT_0)
63#define BTEOFF_CTRL (IIO_BTE_CTRL_0 - IIO_BTE_STAT_0)
64#define BTEOFF_NOTIFY (IIO_BTE_NOTIFY_0 - IIO_BTE_STAT_0)
65#define BTEOFF_INT (IIO_BTE_INT_0 - IIO_BTE_STAT_0)
66
67
68/*
69 * The following definitions use the names defined in the IO interface
70 * document for ease of reference. When possible, software should
71 * generally use the longer but clearer names defined above.
72 */
73
74#define IIO_BASE 0x400000
75#define IIO_BASE_BTE0 0x410000
76#define IIO_BASE_BTE1 0x420000
77#define IIO_BASE_PERF 0x430000
78#define IIO_PERF_CNT 0x430008
79
80#define IO_PERF_SETS 32
81
82#define IIO_WID 0x400000 /* Widget identification */
83#define IIO_WSTAT 0x400008 /* Widget status */
84#define IIO_WCR 0x400020 /* Widget control */
85
86#define IIO_WSTAT_ECRAZY (1ULL << 32) /* Hub gone crazy */
87#define IIO_WSTAT_TXRETRY (1ULL << 9) /* Hub Tx Retry timeout */
88#define IIO_WSTAT_TXRETRY_MASK (0x7F)
89#define IIO_WSTAT_TXRETRY_SHFT (16)
90#define IIO_WSTAT_TXRETRY_CNT(w) (((w) >> IIO_WSTAT_TXRETRY_SHFT) & \
91 IIO_WSTAT_TXRETRY_MASK)
92
93#define IIO_ILAPR 0x400100 /* Local Access Protection */
94#define IIO_ILAPO 0x400108 /* Protection override */
95#define IIO_IOWA 0x400110 /* outbound widget access */
96#define IIO_IIWA 0x400118 /* inbound widget access */
97#define IIO_IIDEM 0x400120 /* Inbound Device Error Mask */
98#define IIO_ILCSR 0x400128 /* LLP control and status */
99#define IIO_ILLR 0x400130 /* LLP Log */
100#define IIO_IIDSR 0x400138 /* Interrupt destination */
101
102#define IIO_IIBUSERR 0x1400208 /* Reads here cause a bus error. */
103
104/* IO Interrupt Destination Register */
105#define IIO_IIDSR_SENT_SHIFT 28
106#define IIO_IIDSR_SENT_MASK 0x10000000
107#define IIO_IIDSR_ENB_SHIFT 24
108#define IIO_IIDSR_ENB_MASK 0x01000000
109#define IIO_IIDSR_NODE_SHIFT 8
110#define IIO_IIDSR_NODE_MASK 0x0000ff00
111#define IIO_IIDSR_LVL_SHIFT 0
112#define IIO_IIDSR_LVL_MASK 0x0000003f
113
114
115/* GFX Flow Control Node/Widget Register */
116#define IIO_IGFX_0 0x400140 /* gfx node/widget register 0 */
117#define IIO_IGFX_1 0x400148 /* gfx node/widget register 1 */
118#define IIO_IGFX_W_NUM_BITS 4 /* size of widget num field */
119#define IIO_IGFX_W_NUM_MASK ((1<<IIO_IGFX_W_NUM_BITS)-1)
120#define IIO_IGFX_W_NUM_SHIFT 0
121#define IIO_IGFX_N_NUM_BITS 9 /* size of node num field */
122#define IIO_IGFX_N_NUM_MASK ((1<<IIO_IGFX_N_NUM_BITS)-1)
123#define IIO_IGFX_N_NUM_SHIFT 4
124#define IIO_IGFX_P_NUM_BITS 1 /* size of processor num field */
125#define IIO_IGFX_P_NUM_MASK ((1<<IIO_IGFX_P_NUM_BITS)-1)
126#define IIO_IGFX_P_NUM_SHIFT 16
127#define IIO_IGFX_VLD_BITS 1 /* size of valid field */
128#define IIO_IGFX_VLD_MASK ((1<<IIO_IGFX_VLD_BITS)-1)
129#define IIO_IGFX_VLD_SHIFT 20
130#define IIO_IGFX_INIT(widget, node, cpu, valid) (\
131 (((widget) & IIO_IGFX_W_NUM_MASK) << IIO_IGFX_W_NUM_SHIFT) | \
132 (((node) & IIO_IGFX_N_NUM_MASK) << IIO_IGFX_N_NUM_SHIFT) | \
133 (((cpu) & IIO_IGFX_P_NUM_MASK) << IIO_IGFX_P_NUM_SHIFT) | \
134 (((valid) & IIO_IGFX_VLD_MASK) << IIO_IGFX_VLD_SHIFT) )
135
136/* Scratch registers (not all bits available) */
137#define IIO_SCRATCH_REG0 0x400150
138#define IIO_SCRATCH_REG1 0x400158
139#define IIO_SCRATCH_MASK 0x0000000f00f11fff
140
141#define IIO_SCRATCH_BIT0_0 0x0000000800000000
142#define IIO_SCRATCH_BIT0_1 0x0000000400000000
143#define IIO_SCRATCH_BIT0_2 0x0000000200000000
144#define IIO_SCRATCH_BIT0_3 0x0000000100000000
145#define IIO_SCRATCH_BIT0_4 0x0000000000800000
146#define IIO_SCRATCH_BIT0_5 0x0000000000400000
147#define IIO_SCRATCH_BIT0_6 0x0000000000200000
148#define IIO_SCRATCH_BIT0_7 0x0000000000100000
149#define IIO_SCRATCH_BIT0_8 0x0000000000010000
150#define IIO_SCRATCH_BIT0_9 0x0000000000001000
151#define IIO_SCRATCH_BIT0_R 0x0000000000000fff
152
153/* IO Translation Table Entries */
154#define IIO_NUM_ITTES 7 /* ITTEs numbered 0..6 */
155 /* Hw manuals number them 1..7! */
156
157/*
158 * As a permanent workaround for a bug in the PI side of the hub, we've
159 * redefined big window 7 as small window 0.
160 */
161#define HUB_NUM_BIG_WINDOW IIO_NUM_ITTES - 1
162
163/*
164 * Use the top big window as a surrogate for the first small window
165 */
166#define SWIN0_BIGWIN HUB_NUM_BIG_WINDOW
167
168#define ILCSR_WARM_RESET 0x100
169/*
170 * The IO LLP control status register and widget control register
171 */
172#ifndef __ASSEMBLY__
173
174typedef union hubii_wid_u {
175 u64 wid_reg_value;
176 struct {
177 u64 wid_rsvd: 32, /* unused */
178 wid_rev_num: 4, /* revision number */
179 wid_part_num: 16, /* the widget type: hub=c101 */
180 wid_mfg_num: 11, /* Manufacturer id (IBM) */
181 wid_rsvd1: 1; /* Reserved */
182 } wid_fields_s;
183} hubii_wid_t;
184
185
186typedef union hubii_wcr_u {
187 u64 wcr_reg_value;
188 struct {
189 u64 wcr_rsvd: 41, /* unused */
190 wcr_e_thresh: 5, /* elasticity threshold */
191 wcr_dir_con: 1, /* widget direct connect */
192 wcr_f_bad_pkt: 1, /* Force bad llp pkt enable */
193 wcr_xbar_crd: 3, /* LLP crossbar credit */
194 wcr_rsvd1: 8, /* Reserved */
195 wcr_tag_mode: 1, /* Tag mode */
196 wcr_widget_id: 4; /* LLP crossbar credit */
197 } wcr_fields_s;
198} hubii_wcr_t;
199
200#define iwcr_dir_con wcr_fields_s.wcr_dir_con
201
202typedef union hubii_wstat_u {
203 u64 reg_value;
204 struct {
205 u64 rsvd1: 31,
206 crazy: 1, /* Crazy bit */
207 rsvd2: 8,
208 llp_tx_cnt: 8, /* LLP Xmit retry counter */
209 rsvd3: 6,
210 tx_max_rtry: 1, /* LLP Retry Timeout Signal */
211 rsvd4: 2,
212 xt_tail_to: 1, /* Xtalk Tail Timeout */
213 xt_crd_to: 1, /* Xtalk Credit Timeout */
214 pending: 4; /* Pending Requests */
215 } wstat_fields_s;
216} hubii_wstat_t;
217
218
219typedef union hubii_ilcsr_u {
220 u64 icsr_reg_value;
221 struct {
222 u64 icsr_rsvd: 22, /* unused */
223 icsr_max_burst: 10, /* max burst */
224 icsr_rsvd4: 6, /* reserved */
225 icsr_max_retry: 10, /* max retry */
226 icsr_rsvd3: 2, /* reserved */
227 icsr_lnk_stat: 2, /* link status */
228 icsr_bm8: 1, /* Bit mode 8 */
229 icsr_llp_en: 1, /* LLP enable bit */
230 icsr_rsvd2: 1, /* reserver */
231 icsr_wrm_reset: 1, /* Warm reset bit */
232 icsr_rsvd1: 2, /* Data ready offset */
233 icsr_null_to: 6; /* Null timeout */
234
235 } icsr_fields_s;
236} hubii_ilcsr_t;
237
238
239typedef union hubii_iowa_u {
240 u64 iowa_reg_value;
241 struct {
242 u64 iowa_rsvd: 48, /* unused */
243 iowa_wxoac: 8, /* xtalk widget access bits */
244 iowa_rsvd1: 7, /* xtalk widget access bits */
245 iowa_w0oac: 1; /* xtalk widget access bits */
246 } iowa_fields_s;
247} hubii_iowa_t;
248
249typedef union hubii_iiwa_u {
250 u64 iiwa_reg_value;
251 struct {
252 u64 iiwa_rsvd: 48, /* unused */
253 iiwa_wxiac: 8, /* hub wid access bits */
254 iiwa_rsvd1: 7, /* reserved */
255 iiwa_w0iac: 1; /* hub wid0 access */
256 } iiwa_fields_s;
257} hubii_iiwa_t;
258
259typedef union hubii_illr_u {
260 u64 illr_reg_value;
261 struct {
262 u64 illr_rsvd: 32, /* unused */
263 illr_cb_cnt: 16, /* checkbit error count */
264 illr_sn_cnt: 16; /* sequence number count */
265 } illr_fields_s;
266} hubii_illr_t;
267
268/* The structures below are defined to extract and modify the ii
269performance registers */
270
271/* io_perf_sel allows the caller to specify what tests will be
272 performed */
273typedef union io_perf_sel {
274 u64 perf_sel_reg;
275 struct {
276 u64 perf_rsvd : 48,
277 perf_icct : 8,
278 perf_ippr1 : 4,
279 perf_ippr0 : 4;
280 } perf_sel_bits;
281} io_perf_sel_t;
282
283/* io_perf_cnt is to extract the count from the hub registers. Due to
284 hardware problems there is only one counter, not two. */
285
286typedef union io_perf_cnt {
287 u64 perf_cnt;
288 struct {
289 u64 perf_rsvd1 : 32,
290 perf_rsvd2 : 12,
291 perf_cnt : 20;
292 } perf_cnt_bits;
293} io_perf_cnt_t;
294
295#endif /* !__ASSEMBLY__ */
296
297
298#define LNK_STAT_WORKING 0x2
299
300#define IIO_LLP_CB_MAX 0xffff
301#define IIO_LLP_SN_MAX 0xffff
302
303/* IO PRB Entries */
304#define IIO_NUM_IPRBS (9)
305#define IIO_IOPRB_0 0x400198 /* PRB entry 0 */
306#define IIO_IOPRB_8 0x4001a0 /* PRB entry 8 */
307#define IIO_IOPRB_9 0x4001a8 /* PRB entry 9 */
308#define IIO_IOPRB_A 0x4001b0 /* PRB entry a */
309#define IIO_IOPRB_B 0x4001b8 /* PRB entry b */
310#define IIO_IOPRB_C 0x4001c0 /* PRB entry c */
311#define IIO_IOPRB_D 0x4001c8 /* PRB entry d */
312#define IIO_IOPRB_E 0x4001d0 /* PRB entry e */
313#define IIO_IOPRB_F 0x4001d8 /* PRB entry f */
314
315
316#define IIO_IXCC 0x4001e0 /* Crosstalk credit count timeout */
317#define IIO_IXTCC IIO_IXCC
318#define IIO_IMEM 0x4001e8 /* Miscellaneous Enable Mask */
319#define IIO_IXTT 0x4001f0 /* Crosstalk tail timeout */
320#define IIO_IECLR 0x4001f8 /* IO error clear */
321#define IIO_IBCN 0x400200 /* IO BTE CRB count */
322
323/*
324 * IIO_IMEM Register fields.
325 */
326#define IIO_IMEM_W0ESD 0x1 /* Widget 0 shut down due to error */
327#define IIO_IMEM_B0ESD (1 << 4) /* BTE 0 shut down due to error */
328#define IIO_IMEM_B1ESD (1 << 8) /* BTE 1 Shut down due to error */
329
330/* PIO Read address Table Entries */
331#define IIO_IPCA 0x400300 /* PRB Counter adjust */
332#define IIO_NUM_PRTES 8 /* Total number of PRB table entries */
333#define IIO_PRTE_0 0x400308 /* PIO Read address table entry 0 */
334#define IIO_PRTE(_x) (IIO_PRTE_0 + (8 * (_x)))
335#define IIO_WIDPRTE(x) IIO_PRTE(((x) - 8)) /* widget ID to its PRTE num */
336#define IIO_IPDR 0x400388 /* PIO table entry deallocation */
337#define IIO_ICDR 0x400390 /* CRB Entry Deallocation */
338#define IIO_IFDR 0x400398 /* IOQ FIFO Depth */
339#define IIO_IIAP 0x4003a0 /* IIQ Arbitration Parameters */
340#define IIO_IMMR IIO_IIAP
341#define IIO_ICMR 0x4003a8 /* CRB Management Register */
342#define IIO_ICCR 0x4003b0 /* CRB Control Register */
343#define IIO_ICTO 0x4003b8 /* CRB Time Out Register */
344#define IIO_ICTP 0x4003c0 /* CRB Time Out Prescalar */
345
346
347/*
348 * ICMR register fields
349 */
350#define IIO_ICMR_PC_VLD_SHFT 36
351#define IIO_ICMR_PC_VLD_MASK (0x7fffUL << IIO_ICMR_PC_VLD_SHFT)
352
353#define IIO_ICMR_CRB_VLD_SHFT 20
354#define IIO_ICMR_CRB_VLD_MASK (0x7fffUL << IIO_ICMR_CRB_VLD_SHFT)
355
356#define IIO_ICMR_FC_CNT_SHFT 16
357#define IIO_ICMR_FC_CNT_MASK (0xf << IIO_ICMR_FC_CNT_SHFT)
358
359#define IIO_ICMR_C_CNT_SHFT 4
360#define IIO_ICMR_C_CNT_MASK (0xf << IIO_ICMR_C_CNT_SHFT)
361
362#define IIO_ICMR_P_CNT_SHFT 0
363#define IIO_ICMR_P_CNT_MASK (0xf << IIO_ICMR_P_CNT_SHFT)
364
365#define IIO_ICMR_PRECISE (1UL << 52)
366#define IIO_ICMR_CLR_RPPD (1UL << 13)
367#define IIO_ICMR_CLR_RQPD (1UL << 12)
368
369/*
370 * IIO PIO Deallocation register field masks : (IIO_IPDR)
371 */
372#define IIO_IPDR_PND (1 << 4)
373
374/*
375 * IIO CRB deallocation register field masks: (IIO_ICDR)
376 */
377#define IIO_ICDR_PND (1 << 4)
378
379/*
380 * IIO CRB control register Fields: IIO_ICCR
381 */
382#define IIO_ICCR_PENDING (0x10000)
383#define IIO_ICCR_CMD_MASK (0xFF)
384#define IIO_ICCR_CMD_SHFT (7)
385#define IIO_ICCR_CMD_NOP (0x0) /* No Op */
386#define IIO_ICCR_CMD_WAKE (0x100) /* Reactivate CRB entry and process */
387#define IIO_ICCR_CMD_TIMEOUT (0x200) /* Make CRB timeout & mark invalid */
388#define IIO_ICCR_CMD_EJECT (0x400) /* Contents of entry written to memory
389 * via a WB
390 */
391#define IIO_ICCR_CMD_FLUSH (0x800)
392
393/*
394 * CRB manipulation macros
395 * The CRB macros are slightly complicated, since there are up to
396 * four registers associated with each CRB entry.
397 */
398#define IIO_NUM_CRBS 15 /* Number of CRBs */
399#define IIO_NUM_NORMAL_CRBS 12 /* Number of regular CRB entries */
400#define IIO_NUM_PC_CRBS 4 /* Number of partial cache CRBs */
401#define IIO_ICRB_OFFSET 8
402#define IIO_ICRB_0 0x400400
403/* XXX - This is now tuneable:
404 #define IIO_FIRST_PC_ENTRY 12
405 */
406
407#define IIO_ICRB_A(_x) (IIO_ICRB_0 + (4 * IIO_ICRB_OFFSET * (_x)))
408#define IIO_ICRB_B(_x) (IIO_ICRB_A(_x) + 1*IIO_ICRB_OFFSET)
409#define IIO_ICRB_C(_x) (IIO_ICRB_A(_x) + 2*IIO_ICRB_OFFSET)
410#define IIO_ICRB_D(_x) (IIO_ICRB_A(_x) + 3*IIO_ICRB_OFFSET)
411
412/* XXX - IBUE register coming for Hub 2 */
413
414/*
415 *
416 * CRB Register description.
417 *
418 * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
419 * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
420 * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
421 * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
422 * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
423 *
424 * Many of the fields in CRB are status bits used by hardware
425 * for implementation of the protocol. It's very dangerous to
426 * mess around with the CRB registers.
427 *
428 * It's OK to read the CRB registers and try to make sense out of the
429 * fields in CRB.
430 *
431 * Updating CRB requires all activities in Hub IIO to be quiesced.
432 * otherwise, a write to CRB could corrupt other CRB entries.
433 * CRBs are here only as a back door peek to hub IIO's status.
434 * Quiescing implies no dmas no PIOs
435 * either directly from the cpu or from sn0net.
436 * this is not something that can be done easily. So, AVOID updating
437 * CRBs.
438 */
439
440/*
441 * Fields in CRB Register A
442 */
443#ifndef __ASSEMBLY__
444typedef union icrba_u {
445 u64 reg_value;
446 struct {
447 u64 resvd: 6,
448 stall_bte0: 1, /* Stall BTE 0 */
449 stall_bte1: 1, /* Stall BTE 1 */
450 error: 1, /* CRB has an error */
451 ecode: 3, /* Error Code */
452 lnetuce: 1, /* SN0net Uncorrectable error */
453 mark: 1, /* CRB Has been marked */
454 xerr: 1, /* Error bit set in xtalk header */
455 sidn: 4, /* SIDN field from xtalk */
456 tnum: 5, /* TNUM field in xtalk */
457 addr: 38, /* Address of request */
458 valid: 1, /* Valid status */
459 iow: 1; /* IO Write operation */
460 } icrba_fields_s;
461} icrba_t;
462
463/* This is an alternate typedef for the HUB1 CRB A in order to allow
464 runtime selection of the format based on the REV_ID field of the
465 NI_STATUS_REV_ID register. */
466typedef union h1_icrba_u {
467 u64 reg_value;
468
469 struct {
470 u64 resvd: 6,
471 unused: 1, /* Unused but RW!! */
472 error: 1, /* CRB has an error */
473 ecode: 4, /* Error Code */
474 lnetuce: 1, /* SN0net Uncorrectable error */
475 mark: 1, /* CRB Has been marked */
476 xerr: 1, /* Error bit set in xtalk header */
477 sidn: 4, /* SIDN field from xtalk */
478 tnum: 5, /* TNUM field in xtalk */
479 addr: 38, /* Address of request */
480 valid: 1, /* Valid status */
481 iow: 1; /* IO Write operation */
482 } h1_icrba_fields_s;
483} h1_icrba_t;
484
485/* XXX - Is this still right? Check the spec. */
486#define ICRBN_A_CERR_SHFT 54
487#define ICRBN_A_ERR_MASK 0x3ff
488
489#endif /* !__ASSEMBLY__ */
490
491#define IIO_ICRB_ADDR_SHFT 2 /* Shift to get proper address */
492
493/*
494 * values for "ecode" field
495 */
496#define IIO_ICRB_ECODE_DERR 0 /* Directory error due to IIO access */
497#define IIO_ICRB_ECODE_PERR 1 /* Poison error on IO access */
498#define IIO_ICRB_ECODE_WERR 2 /* Write error by IIO access
499 * e.g. WINV to a Read only line.
500 */
501#define IIO_ICRB_ECODE_AERR 3 /* Access error caused by IIO access */
502#define IIO_ICRB_ECODE_PWERR 4 /* Error on partial write */
503#define IIO_ICRB_ECODE_PRERR 5 /* Error on partial read */
504#define IIO_ICRB_ECODE_TOUT 6 /* CRB timeout before deallocating */
505#define IIO_ICRB_ECODE_XTERR 7 /* Incoming xtalk pkt had error bit */
506
507
508
509/*
510 * Fields in CRB Register B
511 */
512#ifndef __ASSEMBLY__
513typedef union icrbb_u {
514 u64 reg_value;
515 struct {
516 u64 rsvd1: 5,
517 btenum: 1, /* BTE to which entry belongs to */
518 cohtrans: 1, /* Coherent transaction */
519 xtsize: 2, /* Xtalk operation size
520 * 0: Double Word
521 * 1: 32 Bytes.
522 * 2: 128 Bytes,
523 * 3: Reserved.
524 */
525 srcnode: 9, /* Source Node ID */
526 srcinit: 2, /* Source Initiator:
527 * See below for field values.
528 */
529 useold: 1, /* Use OLD command for processing */
530 imsgtype: 2, /* Incoming message type
531 * see below for field values
532 */
533 imsg: 8, /* Incoming message */
534 initator: 3, /* Initiator of original request
535 * See below for field values.
536 */
537 reqtype: 5, /* Identifies type of request
538 * See below for field values.
539 */
540 rsvd2: 7,
541 ackcnt: 11, /* Invalidate ack count */
542 resp: 1, /* data response given to processor */
543 ack: 1, /* indicates data ack received */
544 hold: 1, /* entry is gathering inval acks */
545 wb_pend:1, /* waiting for writeback to complete */
546 intvn: 1, /* Intervention */
547 stall_ib: 1, /* Stall Ibuf (from crosstalk) */
548 stall_intr: 1; /* Stall internal interrupts */
549 } icrbb_field_s;
550} icrbb_t;
551
552/* This is an alternate typedef for the HUB1 CRB B in order to allow
553 runtime selection of the format based on the REV_ID field of the
554 NI_STATUS_REV_ID register. */
555typedef union h1_icrbb_u {
556 u64 reg_value;
557 struct {
558 u64 rsvd1: 5,
559 btenum: 1, /* BTE to which entry belongs to */
560 cohtrans: 1, /* Coherent transaction */
561 xtsize: 2, /* Xtalk operation size
562 * 0: Double Word
563 * 1: 32 Bytes.
564 * 2: 128 Bytes,
565 * 3: Reserved.
566 */
567 srcnode: 9, /* Source Node ID */
568 srcinit: 2, /* Source Initiator:
569 * See below for field values.
570 */
571 useold: 1, /* Use OLD command for processing */
572 imsgtype: 2, /* Incoming message type
573 * see below for field values
574 */
575 imsg: 8, /* Incoming message */
576 initator: 3, /* Initiator of original request
577 * See below for field values.
578 */
579 rsvd2: 1,
580 pcache: 1, /* entry belongs to partial cache */
581 reqtype: 5, /* Identifies type of request
582 * See below for field values.
583 */
584 stl_ib: 1, /* stall Ibus coming from xtalk */
585 stl_intr: 1, /* Stall internal interrupts */
586 stl_bte0: 1, /* Stall BTE 0 */
587 stl_bte1: 1, /* Stall BTE 1 */
588 intrvn: 1, /* Req was target of intervention */
589 ackcnt: 11, /* Invalidate ack count */
590 resp: 1, /* data response given to processor */
591 ack: 1, /* indicates data ack received */
592 hold: 1, /* entry is gathering inval acks */
593 wb_pend:1, /* waiting for writeback to complete */
594 sleep: 1, /* xtalk req sleeping till IO-sync */
595 pnd_reply: 1, /* replies not issed due to IOQ full */
596 pnd_req: 1; /* reqs not issued due to IOQ full */
597 } h1_icrbb_field_s;
598} h1_icrbb_t;
599
600
601#define b_imsgtype icrbb_field_s.imsgtype
602#define b_btenum icrbb_field_s.btenum
603#define b_cohtrans icrbb_field_s.cohtrans
604#define b_xtsize icrbb_field_s.xtsize
605#define b_srcnode icrbb_field_s.srcnode
606#define b_srcinit icrbb_field_s.srcinit
607#define b_imsgtype icrbb_field_s.imsgtype
608#define b_imsg icrbb_field_s.imsg
609#define b_initiator icrbb_field_s.initiator
610
611#endif /* !__ASSEMBLY__ */
612
613/*
614 * values for field xtsize
615 */
616#define IIO_ICRB_XTSIZE_DW 0 /* Xtalk operation size is 8 bytes */
617#define IIO_ICRB_XTSIZE_32 1 /* Xtalk operation size is 32 bytes */
618#define IIO_ICRB_XTSIZE_128 2 /* Xtalk operation size is 128 bytes */
619
620/*
621 * values for field srcinit
622 */
623#define IIO_ICRB_PROC0 0 /* Source of request is Proc 0 */
624#define IIO_ICRB_PROC1 1 /* Source of request is Proc 1 */
625#define IIO_ICRB_GB_REQ 2 /* Source is Guranteed BW request */
626#define IIO_ICRB_IO_REQ 3 /* Source is Normal IO request */
627
628/*
629 * Values for field imsgtype
630 */
631#define IIO_ICRB_IMSGT_XTALK 0 /* Incoming Meessage from Xtalk */
632#define IIO_ICRB_IMSGT_BTE 1 /* Incoming message from BTE */
633#define IIO_ICRB_IMSGT_SN0NET 2 /* Incoming message from SN0 net */
634#define IIO_ICRB_IMSGT_CRB 3 /* Incoming message from CRB ??? */
635
636/*
637 * values for field initiator.
638 */
639#define IIO_ICRB_INIT_XTALK 0 /* Message originated in xtalk */
640#define IIO_ICRB_INIT_BTE0 0x1 /* Message originated in BTE 0 */
641#define IIO_ICRB_INIT_SN0NET 0x2 /* Message originated in SN0net */
642#define IIO_ICRB_INIT_CRB 0x3 /* Message originated in CRB ? */
643#define IIO_ICRB_INIT_BTE1 0x5 /* MEssage originated in BTE 1 */
644
645/*
646 * Values for field reqtype.
647 */
648/* XXX - Need to fix this for Hub 2 */
649#define IIO_ICRB_REQ_DWRD 0 /* Request type double word */
650#define IIO_ICRB_REQ_QCLRD 1 /* Request is Qrtr Caceh line Rd */
651#define IIO_ICRB_REQ_BLKRD 2 /* Request is block read */
652#define IIO_ICRB_REQ_RSHU 6 /* Request is BTE block read */
653#define IIO_ICRB_REQ_REXU 7 /* request is BTE Excl Read */
654#define IIO_ICRB_REQ_RDEX 8 /* Request is Read Exclusive */
655#define IIO_ICRB_REQ_WINC 9 /* Request is Write Invalidate */
656#define IIO_ICRB_REQ_BWINV 10 /* Request is BTE Winv */
657#define IIO_ICRB_REQ_PIORD 11 /* Request is PIO read */
658#define IIO_ICRB_REQ_PIOWR 12 /* Request is PIO Write */
659#define IIO_ICRB_REQ_PRDM 13 /* Request is Fetch&Op */
660#define IIO_ICRB_REQ_PWRM 14 /* Request is Store &Op */
661#define IIO_ICRB_REQ_PTPWR 15 /* Request is Peer to peer */
662#define IIO_ICRB_REQ_WB 16 /* Request is Write back */
663#define IIO_ICRB_REQ_DEX 17 /* Retained DEX Cache line */
664
665/*
666 * Fields in CRB Register C
667 */
668
669#ifndef __ASSEMBLY__
670
671typedef union icrbc_s {
672 u64 reg_value;
673 struct {
674 u64 rsvd: 6,
675 sleep: 1,
676 pricnt: 4, /* Priority count sent with Read req */
677 pripsc: 4, /* Priority Pre scalar */
678 bteop: 1, /* BTE Operation */
679 push_be: 34, /* Push address Byte enable
680 * Holds push addr, if CRB is for BTE
681 * If CRB belongs to Partial cache,
682 * this contains byte enables bits
683 * ([47:46] = 0)
684 */
685 suppl: 11, /* Supplemental field */
686 barrop: 1, /* Barrier Op bit set in xtalk req */
687 doresp: 1, /* Xtalk req needs a response */
688 gbr: 1; /* GBR bit set in xtalk packet */
689 } icrbc_field_s;
690} icrbc_t;
691
692#define c_pricnt icrbc_field_s.pricnt
693#define c_pripsc icrbc_field_s.pripsc
694#define c_bteop icrbc_field_s.bteop
695#define c_bteaddr icrbc_field_s.push_be /* push_be field has 2 names */
696#define c_benable icrbc_field_s.push_be /* push_be field has 2 names */
697#define c_suppl icrbc_field_s.suppl
698#define c_barrop icrbc_field_s.barrop
699#define c_doresp icrbc_field_s.doresp
700#define c_gbr icrbc_field_s.gbr
701#endif /* !__ASSEMBLY__ */
702
703/*
704 * Fields in CRB Register D
705 */
706
707#ifndef __ASSEMBLY__
708typedef union icrbd_s {
709 u64 reg_value;
710 struct {
711 u64 rsvd: 38,
712 toutvld: 1, /* Timeout in progress for this CRB */
713 ctxtvld: 1, /* Context field below is valid */
714 rsvd2: 1,
715 context: 15, /* Bit vector:
716 * Has a bit set for each CRB entry
717 * which needs to be deallocated
718 * before this CRB entry is processed.
719 * Set only for barrier operations.
720 */
721 timeout: 8; /* Timeout Upper 8 bits */
722 } icrbd_field_s;
723} icrbd_t;
724
725#define icrbd_toutvld icrbd_field_s.toutvld
726#define icrbd_ctxtvld icrbd_field_s.ctxtvld
727#define icrbd_context icrbd_field_s.context
728
729
730typedef union hubii_ifdr_u {
731 u64 hi_ifdr_value;
732 struct {
733 u64 ifdr_rsvd: 49,
734 ifdr_maxrp: 7,
735 ifdr_rsvd1: 1,
736 ifdr_maxrq: 7;
737 } hi_ifdr_fields;
738} hubii_ifdr_t;
739
740#endif /* !__ASSEMBLY__ */
741
742/*
743 * Hardware designed names for the BTE control registers.
744 */
745#define IIO_IBLS_0 0x410000 /* BTE length/status 0 */
746#define IIO_IBSA_0 0x410008 /* BTE source address 0 */
747#define IIO_IBDA_0 0x410010 /* BTE destination address 0 */
748#define IIO_IBCT_0 0x410018 /* BTE control/terminate 0 */
749#define IIO_IBNA_0 0x410020 /* BTE notification address 0 */
750#define IIO_IBNR_0 IIO_IBNA_0
751#define IIO_IBIA_0 0x410028 /* BTE interrupt address 0 */
752
753#define IIO_IBLS_1 0x420000 /* BTE length/status 1 */
754#define IIO_IBSA_1 0x420008 /* BTE source address 1 */
755#define IIO_IBDA_1 0x420010 /* BTE destination address 1 */
756#define IIO_IBCT_1 0x420018 /* BTE control/terminate 1 */
757#define IIO_IBNA_1 0x420020 /* BTE notification address 1 */
758#define IIO_IBNR_1 IIO_IBNA_1
759#define IIO_IBIA_1 0x420028 /* BTE interrupt address 1 */
760
761/*
762 * More miscellaneous registers
763 */
764#define IIO_IPCR 0x430000 /* Performance Control */
765#define IIO_IPPR 0x430008 /* Performance Profiling */
766
767/*
768 * IO Error Clear register bit field definitions
769 */
770#define IECLR_BTE1 (1 << 18) /* clear bte error 1 ??? */
771#define IECLR_BTE0 (1 << 17) /* clear bte error 0 ??? */
772#define IECLR_CRAZY (1 << 16) /* clear crazy bit in wstat reg */
773#define IECLR_PRB_F (1 << 15) /* clear err bit in PRB_F reg */
774#define IECLR_PRB_E (1 << 14) /* clear err bit in PRB_E reg */
775#define IECLR_PRB_D (1 << 13) /* clear err bit in PRB_D reg */
776#define IECLR_PRB_C (1 << 12) /* clear err bit in PRB_C reg */
777#define IECLR_PRB_B (1 << 11) /* clear err bit in PRB_B reg */
778#define IECLR_PRB_A (1 << 10) /* clear err bit in PRB_A reg */
779#define IECLR_PRB_9 (1 << 9) /* clear err bit in PRB_9 reg */
780#define IECLR_PRB_8 (1 << 8) /* clear err bit in PRB_8 reg */
781#define IECLR_PRB_0 (1 << 0) /* clear err bit in PRB_0 reg */
782
783/*
784 * IO PIO Read Table Entry format
785 */
786
787#ifndef __ASSEMBLY__
788
789typedef union iprte_a {
790 u64 entry;
791 struct {
792 u64 rsvd1 : 7, /* Reserved field */
793 valid : 1, /* Maps to a timeout entry */
794 rsvd2 : 1,
795 srcnode : 9, /* Node which did this PIO */
796 initiator : 2, /* If T5A or T5B or IO */
797 rsvd3 : 3,
798 addr : 38, /* Physical address of PIO */
799 rsvd4 : 3;
800 } iprte_fields;
801} iprte_a_t;
802
803#define iprte_valid iprte_fields.valid
804#define iprte_timeout iprte_fields.timeout
805#define iprte_srcnode iprte_fields.srcnode
806#define iprte_init iprte_fields.initiator
807#define iprte_addr iprte_fields.addr
808
809#endif /* !__ASSEMBLY__ */
810
811#define IPRTE_ADDRSHFT 3
812
813/*
814 * Hub IIO PRB Register format.
815 */
816
817#ifndef __ASSEMBLY__
818/*
819 * Note: Fields bnakctr, anakctr, xtalkctrmode, ovflow fields are
820 * "Status" fields, and should only be used in case of clean up after errors.
821 */
822
823typedef union iprb_u {
824 u64 reg_value;
825 struct {
826 u64 rsvd1: 15,
827 error: 1, /* Widget rcvd wr resp pkt w/ error */
828 ovflow: 5, /* Over flow count. perf measurement */
829 fire_and_forget: 1, /* Launch Write without response */
830 mode: 2, /* Widget operation Mode */
831 rsvd2: 2,
832 bnakctr: 14,
833 rsvd3: 2,
834 anakctr: 14,
835 xtalkctr: 8;
836 } iprb_fields_s;
837} iprb_t;
838
839#define iprb_regval reg_value
840
841#define iprb_error iprb_fields_s.error
842#define iprb_ovflow iprb_fields_s.ovflow
843#define iprb_ff iprb_fields_s.fire_and_forget
844#define iprb_mode iprb_fields_s.mode
845#define iprb_bnakctr iprb_fields_s.bnakctr
846#define iprb_anakctr iprb_fields_s.anakctr
847#define iprb_xtalkctr iprb_fields_s.xtalkctr
848
849#endif /* !__ASSEMBLY__ */
850
851/*
852 * values for mode field in iprb_t.
853 * For details of the meanings of NAK and Accept, refer the PIO flow
854 * document
855 */
856#define IPRB_MODE_NORMAL (0)
857#define IPRB_MODE_COLLECT_A (1) /* PRB in collect A mode */
858#define IPRB_MODE_SERVICE_A (2) /* NAK B and Accept A */
859#define IPRB_MODE_SERVICE_B (3) /* NAK A and Accept B */
860
861/*
862 * IO CRB entry C_A to E_A : Partial (cache) CRBS
863 */
864#ifndef __ASSEMBLY__
865typedef union icrbp_a {
866 u64 ip_reg; /* the entire register value */
867 struct {
868 u64 error: 1, /* 63, error occurred */
869 ln_uce: 1, /* 62: uncorrectable memory */
870 ln_ae: 1, /* 61: protection violation */
871 ln_werr:1, /* 60: write access error */
872 ln_aerr:1, /* 59: sn0net: Address error */
873 ln_perr:1, /* 58: sn0net: poison error */
874 timeout:1, /* 57: CRB timed out */
875 l_bdpkt:1, /* 56: truncated pkt on sn0net */
876 c_bdpkt:1, /* 55: truncated pkt on xtalk */
877 c_err: 1, /* 54: incoming xtalk req, err set*/
878 rsvd1: 12, /* 53-42: reserved */
879 valid: 1, /* 41: Valid status */
880 sidn: 4, /* 40-37: SIDN field of xtalk rqst */
881 tnum: 5, /* 36-32: TNUM of xtalk request */
882 bo: 1, /* 31: barrier op set in xtalk rqst*/
883 resprqd:1, /* 30: xtalk rqst requires response*/
884 gbr: 1, /* 29: gbr bit set in xtalk rqst */
885 size: 2, /* 28-27: size of xtalk request */
886 excl: 4, /* 26-23: exclusive bit(s) */
887 stall: 3, /* 22-20: stall (xtalk, bte 0/1) */
888 intvn: 1, /* 19: rqst target of intervention*/
889 resp: 1, /* 18: Data response given to t5 */
890 ack: 1, /* 17: Data ack received. */
891 hold: 1, /* 16: crb gathering invalidate acks*/
892 wb: 1, /* 15: writeback pending. */
893 ack_cnt:11, /* 14-04: counter of invalidate acks*/
894 tscaler:4; /* 03-00: Timeout prescaler */
895 } ip_fmt;
896} icrbp_a_t;
897
898#endif /* !__ASSEMBLY__ */
899
900/*
901 * A couple of defines to go with the above structure.
902 */
903#define ICRBP_A_CERR_SHFT 54
904#define ICRBP_A_ERR_MASK 0x3ff
905
906#ifndef __ASSEMBLY__
907typedef union hubii_idsr {
908 u64 iin_reg;
909 struct {
910 u64 rsvd1 : 35,
911 isent : 1,
912 rsvd2 : 3,
913 ienable: 1,
914 rsvd : 7,
915 node : 9,
916 rsvd4 : 1,
917 level : 7;
918 } iin_fmt;
919} hubii_idsr_t;
920#endif /* !__ASSEMBLY__ */
921
922/*
923 * IO BTE Length/Status (IIO_IBLS) register bit field definitions
924 */
925#define IBLS_BUSY (0x1 << 20)
926#define IBLS_ERROR_SHFT 16
927#define IBLS_ERROR (0x1 << IBLS_ERROR_SHFT)
928#define IBLS_LENGTH_MASK 0xffff
929
930/*
931 * IO BTE Control/Terminate register (IBCT) register bit field definitions
932 */
933#define IBCT_POISON (0x1 << 8)
934#define IBCT_NOTIFY (0x1 << 4)
935#define IBCT_ZFIL_MODE (0x1 << 0)
936
937/*
938 * IO BTE Interrupt Address Register (IBIA) register bit field definitions
939 */
940#define IBIA_LEVEL_SHFT 16
941#define IBIA_LEVEL_MASK (0x7f << IBIA_LEVEL_SHFT)
942#define IBIA_NODE_ID_SHFT 0
943#define IBIA_NODE_ID_MASK (0x1ff)
944
945/*
946 * Miscellaneous hub constants
947 */
948
949/* Number of widgets supported by hub */
950#define HUB_NUM_WIDGET 9
951#define HUB_WIDGET_ID_MIN 0x8
952#define HUB_WIDGET_ID_MAX 0xf
953
954#define HUB_WIDGET_PART_NUM 0xc101
955#define MAX_HUBS_PER_XBOW 2
956
957/*
958 * Get a hub's widget id from widget control register
959 */
960#define IIO_WCR_WID_GET(nasid) (REMOTE_HUB_L(nasid, III_WCR) & 0xf)
961#define IIO_WST_ERROR_MASK (UINT64_CAST 1 << 32) /* Widget status error */
962
963/*
964 * Number of credits Hub widget has while sending req/response to
965 * xbow.
966 * Value of 3 is required by Xbow 1.1
967 * We may be able to increase this to 4 with Xbow 1.2.
968 */
969#define HUBII_XBOW_CREDIT 3
970#define HUBII_XBOW_REV2_CREDIT 4
971
972#endif /* _ASM_SGI_SN_SN0_HUBIO_H */
diff --git a/arch/mips/include/asm/sn/sn0/hubmd.h b/arch/mips/include/asm/sn/sn0/hubmd.h
new file mode 100644
index 000000000000..14c225d80664
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn0/hubmd.h
@@ -0,0 +1,789 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/SN0/hubmd.h>, revision 1.59.
7 *
8 * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
9 * Copyright (C) 1999 by Ralf Baechle
10 */
11#ifndef _ASM_SN_SN0_HUBMD_H
12#define _ASM_SN_SN0_HUBMD_H
13
14
15/*
16 * Hub Memory/Directory interface registers
17 */
18#define CACHE_SLINE_SIZE 128 /* Secondary cache line size on SN0 */
19
20#define MAX_REGIONS 64
21
22/* Hardware page size and shift */
23
24#define MD_PAGE_SIZE 4096 /* Page size in bytes */
25#define MD_PAGE_NUM_SHFT 12 /* Address to page number shift */
26
27/* Register offsets from LOCAL_HUB or REMOTE_HUB */
28
29#define MD_BASE 0x200000
30#define MD_BASE_PERF 0x210000
31#define MD_BASE_JUNK 0x220000
32
33#define MD_IO_PROTECT 0x200000 /* MD and core register protection */
34#define MD_IO_PROT_OVRRD 0x200008 /* Clear my bit in MD_IO_PROTECT */
35#define MD_HSPEC_PROTECT 0x200010 /* BDDIR, LBOOT, RBOOT protection */
36#define MD_MEMORY_CONFIG 0x200018 /* Memory/Directory DIMM control */
37#define MD_REFRESH_CONTROL 0x200020 /* Memory/Directory refresh ctrl */
38#define MD_FANDOP_CAC_STAT 0x200028 /* Fetch-and-op cache status */
39#define MD_MIG_DIFF_THRESH 0x200030 /* Page migr. count diff thresh. */
40#define MD_MIG_VALUE_THRESH 0x200038 /* Page migr. count abs. thresh. */
41#define MD_MIG_CANDIDATE 0x200040 /* Latest page migration candidate */
42#define MD_MIG_CANDIDATE_CLR 0x200048 /* Clear page migration candidate */
43#define MD_DIR_ERROR 0x200050 /* Directory DIMM error */
44#define MD_DIR_ERROR_CLR 0x200058 /* Directory DIMM error clear */
45#define MD_PROTOCOL_ERROR 0x200060 /* Directory protocol error */
46#define MD_PROTOCOL_ERROR_CLR 0x200068 /* Directory protocol error clear */
47#define MD_MEM_ERROR 0x200070 /* Memory DIMM error */
48#define MD_MEM_ERROR_CLR 0x200078 /* Memory DIMM error clear */
49#define MD_MISC_ERROR 0x200080 /* Miscellaneous MD error */
50#define MD_MISC_ERROR_CLR 0x200088 /* Miscellaneous MD error clear */
51#define MD_MEM_DIMM_INIT 0x200090 /* Memory DIMM mode initization. */
52#define MD_DIR_DIMM_INIT 0x200098 /* Directory DIMM mode init. */
53#define MD_MOQ_SIZE 0x2000a0 /* MD outgoing queue size */
54#define MD_MLAN_CTL 0x2000a8 /* NIC (Microlan) control register */
55
56#define MD_PERF_SEL 0x210000 /* Select perf monitor events */
57#define MD_PERF_CNT0 0x210010 /* Performance counter 0 */
58#define MD_PERF_CNT1 0x210018 /* Performance counter 1 */
59#define MD_PERF_CNT2 0x210020 /* Performance counter 2 */
60#define MD_PERF_CNT3 0x210028 /* Performance counter 3 */
61#define MD_PERF_CNT4 0x210030 /* Performance counter 4 */
62#define MD_PERF_CNT5 0x210038 /* Performance counter 5 */
63
64#define MD_UREG0_0 0x220000 /* uController/UART 0 register */
65#define MD_UREG0_1 0x220008 /* uController/UART 0 register */
66#define MD_UREG0_2 0x220010 /* uController/UART 0 register */
67#define MD_UREG0_3 0x220018 /* uController/UART 0 register */
68#define MD_UREG0_4 0x220020 /* uController/UART 0 register */
69#define MD_UREG0_5 0x220028 /* uController/UART 0 register */
70#define MD_UREG0_6 0x220030 /* uController/UART 0 register */
71#define MD_UREG0_7 0x220038 /* uController/UART 0 register */
72
73#define MD_SLOTID_USTAT 0x220048 /* Hub slot ID & UART/uCtlr status */
74#define MD_LED0 0x220050 /* Eight-bit LED for CPU A */
75#define MD_LED1 0x220058 /* Eight-bit LED for CPU B */
76
77#define MD_UREG1_0 0x220080 /* uController/UART 1 register */
78#define MD_UREG1_1 0x220088 /* uController/UART 1 register */
79#define MD_UREG1_2 0x220090 /* uController/UART 1 register */
80#define MD_UREG1_3 0x220098 /* uController/UART 1 register */
81#define MD_UREG1_4 0x2200a0 /* uController/UART 1 register */
82#define MD_UREG1_5 0x2200a8 /* uController/UART 1 register */
83#define MD_UREG1_6 0x2200b0 /* uController/UART 1 register */
84#define MD_UREG1_7 0x2200b8 /* uController/UART 1 register */
85#define MD_UREG1_8 0x2200c0 /* uController/UART 1 register */
86#define MD_UREG1_9 0x2200c8 /* uController/UART 1 register */
87#define MD_UREG1_10 0x2200d0 /* uController/UART 1 register */
88#define MD_UREG1_11 0x2200d8 /* uController/UART 1 register */
89#define MD_UREG1_12 0x2200e0 /* uController/UART 1 register */
90#define MD_UREG1_13 0x2200e8 /* uController/UART 1 register */
91#define MD_UREG1_14 0x2200f0 /* uController/UART 1 register */
92#define MD_UREG1_15 0x2200f8 /* uController/UART 1 register */
93
94#ifdef CONFIG_SGI_SN_N_MODE
95#define MD_MEM_BANKS 4 /* 4 banks of memory max in N mode */
96#else
97#define MD_MEM_BANKS 8 /* 8 banks of memory max in M mode */
98#endif
99
100/*
101 * MD_MEMORY_CONFIG fields
102 *
103 * MD_SIZE_xxx are useful for representing the size of a SIMM or bank
104 * (SIMM pair). They correspond to the values needed for the bit
105 * triplets (MMC_BANK_MASK) in the MD_MEMORY_CONFIG register for bank size.
106 * Bits not used by the MD are used by software.
107 */
108
109#define MD_SIZE_EMPTY 0 /* Valid in MEMORY_CONFIG */
110#define MD_SIZE_8MB 1
111#define MD_SIZE_16MB 2
112#define MD_SIZE_32MB 3 /* Broken in Hub 1 */
113#define MD_SIZE_64MB 4 /* Valid in MEMORY_CONFIG */
114#define MD_SIZE_128MB 5 /* Valid in MEMORY_CONFIG */
115#define MD_SIZE_256MB 6
116#define MD_SIZE_512MB 7 /* Valid in MEMORY_CONFIG */
117#define MD_SIZE_1GB 8
118#define MD_SIZE_2GB 9
119#define MD_SIZE_4GB 10
120
121#define MD_SIZE_BYTES(size) ((size) == 0 ? 0 : 0x400000L << (size))
122#define MD_SIZE_MBYTES(size) ((size) == 0 ? 0 : 4 << (size))
123
124#define MMC_FPROM_CYC_SHFT 49 /* Have to use UINT64_CAST, instead */
125#define MMC_FPROM_CYC_MASK (UINT64_CAST 31 << 49) /* of 'L' suffix, */
126#define MMC_FPROM_WR_SHFT 44 /* for assembler */
127#define MMC_FPROM_WR_MASK (UINT64_CAST 31 << 44)
128#define MMC_UCTLR_CYC_SHFT 39
129#define MMC_UCTLR_CYC_MASK (UINT64_CAST 31 << 39)
130#define MMC_UCTLR_WR_SHFT 34
131#define MMC_UCTLR_WR_MASK (UINT64_CAST 31 << 34)
132#define MMC_DIMM0_SEL_SHFT 32
133#define MMC_DIMM0_SEL_MASK (UINT64_CAST 3 << 32)
134#define MMC_IO_PROT_EN_SHFT 31
135#define MMC_IO_PROT_EN_MASK (UINT64_CAST 1 << 31)
136#define MMC_IO_PROT (UINT64_CAST 1 << 31)
137#define MMC_ARB_MLSS_SHFT 30
138#define MMC_ARB_MLSS_MASK (UINT64_CAST 1 << 30)
139#define MMC_ARB_MLSS (UINT64_CAST 1 << 30)
140#define MMC_IGNORE_ECC_SHFT 29
141#define MMC_IGNORE_ECC_MASK (UINT64_CAST 1 << 29)
142#define MMC_IGNORE_ECC (UINT64_CAST 1 << 29)
143#define MMC_DIR_PREMIUM_SHFT 28
144#define MMC_DIR_PREMIUM_MASK (UINT64_CAST 1 << 28)
145#define MMC_DIR_PREMIUM (UINT64_CAST 1 << 28)
146#define MMC_REPLY_GUAR_SHFT 24
147#define MMC_REPLY_GUAR_MASK (UINT64_CAST 15 << 24)
148#define MMC_BANK_SHFT(_b) ((_b) * 3)
149#define MMC_BANK_MASK(_b) (UINT64_CAST 7 << MMC_BANK_SHFT(_b))
150#define MMC_BANK_ALL_MASK 0xffffff
151#define MMC_RESET_DEFAULTS (UINT64_CAST 0x0f << MMC_FPROM_CYC_SHFT | \
152 UINT64_CAST 0x07 << MMC_FPROM_WR_SHFT | \
153 UINT64_CAST 0x1f << MMC_UCTLR_CYC_SHFT | \
154 UINT64_CAST 0x0f << MMC_UCTLR_WR_SHFT | \
155 MMC_IGNORE_ECC | MMC_DIR_PREMIUM | \
156 UINT64_CAST 0x0f << MMC_REPLY_GUAR_SHFT | \
157 MMC_BANK_ALL_MASK)
158
159/* MD_REFRESH_CONTROL fields */
160
161#define MRC_ENABLE_SHFT 63
162#define MRC_ENABLE_MASK (UINT64_CAST 1 << 63)
163#define MRC_ENABLE (UINT64_CAST 1 << 63)
164#define MRC_COUNTER_SHFT 12
165#define MRC_COUNTER_MASK (UINT64_CAST 0xfff << 12)
166#define MRC_CNT_THRESH_MASK 0xfff
167#define MRC_RESET_DEFAULTS (UINT64_CAST 0x400)
168
169/* MD_MEM_DIMM_INIT and MD_DIR_DIMM_INIT fields */
170
171#define MDI_SELECT_SHFT 32
172#define MDI_SELECT_MASK (UINT64_CAST 0x0f << 32)
173#define MDI_DIMM_MODE_MASK (UINT64_CAST 0xfff)
174
175/* MD_MOQ_SIZE fields */
176
177#define MMS_RP_SIZE_SHFT 8
178#define MMS_RP_SIZE_MASK (UINT64_CAST 0x3f << 8)
179#define MMS_RQ_SIZE_SHFT 0
180#define MMS_RQ_SIZE_MASK (UINT64_CAST 0x1f)
181#define MMS_RESET_DEFAULTS (0x32 << 8 | 0x12)
182
183/* MD_FANDOP_CAC_STAT fields */
184
185#define MFC_VALID_SHFT 63
186#define MFC_VALID_MASK (UINT64_CAST 1 << 63)
187#define MFC_VALID (UINT64_CAST 1 << 63)
188#define MFC_ADDR_SHFT 6
189#define MFC_ADDR_MASK (UINT64_CAST 0x3ffffff)
190
191/* MD_MLAN_CTL fields */
192
193#define MLAN_PHI1_SHFT 27
194#define MLAN_PHI1_MASK (UINT64_CAST 0x7f << 27)
195#define MLAN_PHI0_SHFT 20
196#define MLAN_PHI0_MASK (UINT64_CAST 0x7f << 27)
197#define MLAN_PULSE_SHFT 10
198#define MLAN_PULSE_MASK (UINT64_CAST 0x3ff << 10)
199#define MLAN_SAMPLE_SHFT 2
200#define MLAN_SAMPLE_MASK (UINT64_CAST 0xff << 2)
201#define MLAN_DONE_SHFT 1
202#define MLAN_DONE_MASK 2
203#define MLAN_DONE (UINT64_CAST 0x02)
204#define MLAN_RD_DATA (UINT64_CAST 0x01)
205#define MLAN_RESET_DEFAULTS (UINT64_CAST 0x31 << MLAN_PHI1_SHFT | \
206 UINT64_CAST 0x31 << MLAN_PHI0_SHFT)
207
208/* MD_SLOTID_USTAT bit definitions */
209
210#define MSU_CORECLK_TST_SHFT 7 /* You don't wanna know */
211#define MSU_CORECLK_TST_MASK (UINT64_CAST 1 << 7)
212#define MSU_CORECLK_TST (UINT64_CAST 1 << 7)
213#define MSU_CORECLK_SHFT 6 /* You don't wanna know */
214#define MSU_CORECLK_MASK (UINT64_CAST 1 << 6)
215#define MSU_CORECLK (UINT64_CAST 1 << 6)
216#define MSU_NETSYNC_SHFT 5 /* You don't wanna know */
217#define MSU_NETSYNC_MASK (UINT64_CAST 1 << 5)
218#define MSU_NETSYNC (UINT64_CAST 1 << 5)
219#define MSU_FPROMRDY_SHFT 4 /* Flash PROM ready bit */
220#define MSU_FPROMRDY_MASK (UINT64_CAST 1 << 4)
221#define MSU_FPROMRDY (UINT64_CAST 1 << 4)
222#define MSU_I2CINTR_SHFT 3 /* I2C interrupt bit */
223#define MSU_I2CINTR_MASK (UINT64_CAST 1 << 3)
224#define MSU_I2CINTR (UINT64_CAST 1 << 3)
225#define MSU_SLOTID_MASK 0xff
226#define MSU_SN0_SLOTID_SHFT 0 /* Slot ID */
227#define MSU_SN0_SLOTID_MASK (UINT64_CAST 7)
228#define MSU_SN00_SLOTID_SHFT 7
229#define MSU_SN00_SLOTID_MASK (UINT64_CAST 0x80)
230
231#define MSU_PIMM_PSC_SHFT 4
232#define MSU_PIMM_PSC_MASK (0xf << MSU_PIMM_PSC_SHFT)
233
234/* MD_MIG_DIFF_THRESH bit definitions */
235
236#define MD_MIG_DIFF_THRES_VALID_MASK (UINT64_CAST 0x1 << 63)
237#define MD_MIG_DIFF_THRES_VALID_SHFT 63
238#define MD_MIG_DIFF_THRES_VALUE_MASK (UINT64_CAST 0xfffff)
239
240/* MD_MIG_VALUE_THRESH bit definitions */
241
242#define MD_MIG_VALUE_THRES_VALID_MASK (UINT64_CAST 0x1 << 63)
243#define MD_MIG_VALUE_THRES_VALID_SHFT 63
244#define MD_MIG_VALUE_THRES_VALUE_MASK (UINT64_CAST 0xfffff)
245
246/* MD_MIG_CANDIDATE bit definitions */
247
248#define MD_MIG_CANDIDATE_VALID_MASK (UINT64_CAST 0x1 << 63)
249#define MD_MIG_CANDIDATE_VALID_SHFT 63
250#define MD_MIG_CANDIDATE_TYPE_MASK (UINT64_CAST 0x1 << 30)
251#define MD_MIG_CANDIDATE_TYPE_SHFT 30
252#define MD_MIG_CANDIDATE_OVERRUN_MASK (UINT64_CAST 0x1 << 29)
253#define MD_MIG_CANDIDATE_OVERRUN_SHFT 29
254#define MD_MIG_CANDIDATE_INITIATOR_MASK (UINT64_CAST 0x7ff << 18)
255#define MD_MIG_CANDIDATE_INITIATOR_SHFT 18
256#define MD_MIG_CANDIDATE_NODEID_MASK (UINT64_CAST 0x1ff << 20)
257#define MD_MIG_CANDIDATE_NODEID_SHFT 20
258#define MD_MIG_CANDIDATE_ADDR_MASK (UINT64_CAST 0x3ffff)
259#define MD_MIG_CANDIDATE_ADDR_SHFT 14 /* The address starts at bit 14 */
260
261/* Other MD definitions */
262
263#define MD_BANK_SHFT 29 /* log2(512 MB) */
264#define MD_BANK_MASK (UINT64_CAST 7 << 29)
265#define MD_BANK_SIZE (UINT64_CAST 1 << MD_BANK_SHFT) /* 512 MB */
266#define MD_BANK_OFFSET(_b) (UINT64_CAST (_b) << MD_BANK_SHFT)
267
268/*
269 * The following definitions cover the bit field definitions for the
270 * various MD registers. For multi-bit registers, we define both
271 * a shift amount and a mask value. By convention, if you want to
272 * isolate a field, you should mask the field and then shift it down,
273 * since this makes the masks useful without a shift.
274 */
275
276/* Directory entry states for both premium and standard SIMMs. */
277
278#define MD_DIR_SHARED (UINT64_CAST 0x0) /* 000 */
279#define MD_DIR_POISONED (UINT64_CAST 0x1) /* 001 */
280#define MD_DIR_EXCLUSIVE (UINT64_CAST 0x2) /* 010 */
281#define MD_DIR_BUSY_SHARED (UINT64_CAST 0x3) /* 011 */
282#define MD_DIR_BUSY_EXCL (UINT64_CAST 0x4) /* 100 */
283#define MD_DIR_WAIT (UINT64_CAST 0x5) /* 101 */
284#define MD_DIR_UNOWNED (UINT64_CAST 0x7) /* 111 */
285
286/*
287 * The MD_DIR_FORCE_ECC bit can be added directory entry write data
288 * to forcing the ECC to be written as-is instead of recalculated.
289 */
290
291#define MD_DIR_FORCE_ECC (UINT64_CAST 1 << 63)
292
293/*
294 * Premium SIMM directory entry shifts and masks. Each is valid only in the
295 * context(s) indicated, where A, B, and C indicate the directory entry format
296 * as shown, and low and/or high indicates which double-word of the entry.
297 *
298 * Format A: STATE = shared, FINE = 1
299 * Format B: STATE = shared, FINE = 0
300 * Format C: STATE != shared (FINE must be 0)
301 */
302
303#define MD_PDIR_MASK 0xffffffffffff /* Whole entry */
304#define MD_PDIR_ECC_SHFT 0 /* ABC low or high */
305#define MD_PDIR_ECC_MASK 0x7f
306#define MD_PDIR_PRIO_SHFT 8 /* ABC low */
307#define MD_PDIR_PRIO_MASK (0xf << 8)
308#define MD_PDIR_AX_SHFT 7 /* ABC low */
309#define MD_PDIR_AX_MASK (1 << 7)
310#define MD_PDIR_AX (1 << 7)
311#define MD_PDIR_FINE_SHFT 12 /* ABC low */
312#define MD_PDIR_FINE_MASK (1 << 12)
313#define MD_PDIR_FINE (1 << 12)
314#define MD_PDIR_OCT_SHFT 13 /* A low */
315#define MD_PDIR_OCT_MASK (7 << 13)
316#define MD_PDIR_STATE_SHFT 13 /* BC low */
317#define MD_PDIR_STATE_MASK (7 << 13)
318#define MD_PDIR_ONECNT_SHFT 16 /* BC low */
319#define MD_PDIR_ONECNT_MASK (0x3f << 16)
320#define MD_PDIR_PTR_SHFT 22 /* C low */
321#define MD_PDIR_PTR_MASK (UINT64_CAST 0x7ff << 22)
322#define MD_PDIR_VECMSB_SHFT 22 /* AB low */
323#define MD_PDIR_VECMSB_BITMASK 0x3ffffff
324#define MD_PDIR_VECMSB_BITSHFT 27
325#define MD_PDIR_VECMSB_MASK (UINT64_CAST MD_PDIR_VECMSB_BITMASK << 22)
326#define MD_PDIR_CWOFF_SHFT 7 /* C high */
327#define MD_PDIR_CWOFF_MASK (7 << 7)
328#define MD_PDIR_VECLSB_SHFT 10 /* AB high */
329#define MD_PDIR_VECLSB_BITMASK (UINT64_CAST 0x3fffffffff)
330#define MD_PDIR_VECLSB_BITSHFT 0
331#define MD_PDIR_VECLSB_MASK (MD_PDIR_VECLSB_BITMASK << 10)
332
333/*
334 * Directory initialization values
335 */
336
337#define MD_PDIR_INIT_LO (MD_DIR_UNOWNED << MD_PDIR_STATE_SHFT | \
338 MD_PDIR_AX)
339#define MD_PDIR_INIT_HI 0
340#define MD_PDIR_INIT_PROT (MD_PROT_RW << MD_PPROT_IO_SHFT | \
341 MD_PROT_RW << MD_PPROT_SHFT)
342
343/*
344 * Standard SIMM directory entry shifts and masks. Each is valid only in the
345 * context(s) indicated, where A and C indicate the directory entry format
346 * as shown, and low and/or high indicates which double-word of the entry.
347 *
348 * Format A: STATE == shared
349 * Format C: STATE != shared
350 */
351
352#define MD_SDIR_MASK 0xffff /* Whole entry */
353#define MD_SDIR_ECC_SHFT 0 /* AC low or high */
354#define MD_SDIR_ECC_MASK 0x1f
355#define MD_SDIR_PRIO_SHFT 6 /* AC low */
356#define MD_SDIR_PRIO_MASK (1 << 6)
357#define MD_SDIR_AX_SHFT 5 /* AC low */
358#define MD_SDIR_AX_MASK (1 << 5)
359#define MD_SDIR_AX (1 << 5)
360#define MD_SDIR_STATE_SHFT 7 /* AC low */
361#define MD_SDIR_STATE_MASK (7 << 7)
362#define MD_SDIR_PTR_SHFT 10 /* C low */
363#define MD_SDIR_PTR_MASK (0x3f << 10)
364#define MD_SDIR_CWOFF_SHFT 5 /* C high */
365#define MD_SDIR_CWOFF_MASK (7 << 5)
366#define MD_SDIR_VECMSB_SHFT 11 /* A low */
367#define MD_SDIR_VECMSB_BITMASK 0x1f
368#define MD_SDIR_VECMSB_BITSHFT 7
369#define MD_SDIR_VECMSB_MASK (MD_SDIR_VECMSB_BITMASK << 11)
370#define MD_SDIR_VECLSB_SHFT 5 /* A high */
371#define MD_SDIR_VECLSB_BITMASK 0x7ff
372#define MD_SDIR_VECLSB_BITSHFT 0
373#define MD_SDIR_VECLSB_MASK (MD_SDIR_VECLSB_BITMASK << 5)
374
375/*
376 * Directory initialization values
377 */
378
379#define MD_SDIR_INIT_LO (MD_DIR_UNOWNED << MD_SDIR_STATE_SHFT | \
380 MD_SDIR_AX)
381#define MD_SDIR_INIT_HI 0
382#define MD_SDIR_INIT_PROT (MD_PROT_RW << MD_SPROT_SHFT)
383
384/* Protection and migration field values */
385
386#define MD_PROT_RW (UINT64_CAST 0x6)
387#define MD_PROT_RO (UINT64_CAST 0x3)
388#define MD_PROT_NO (UINT64_CAST 0x0)
389#define MD_PROT_BAD (UINT64_CAST 0x5)
390
391/* Premium SIMM protection entry shifts and masks. */
392
393#define MD_PPROT_SHFT 0 /* Prot. field */
394#define MD_PPROT_MASK 7
395#define MD_PPROT_MIGMD_SHFT 3 /* Migration mode */
396#define MD_PPROT_MIGMD_MASK (3 << 3)
397#define MD_PPROT_REFCNT_SHFT 5 /* Reference count */
398#define MD_PPROT_REFCNT_WIDTH 0x7ffff
399#define MD_PPROT_REFCNT_MASK (MD_PPROT_REFCNT_WIDTH << 5)
400
401#define MD_PPROT_IO_SHFT 45 /* I/O Prot field */
402#define MD_PPROT_IO_MASK (UINT64_CAST 7 << 45)
403
404/* Standard SIMM protection entry shifts and masks. */
405
406#define MD_SPROT_SHFT 0 /* Prot. field */
407#define MD_SPROT_MASK 7
408#define MD_SPROT_MIGMD_SHFT 3 /* Migration mode */
409#define MD_SPROT_MIGMD_MASK (3 << 3)
410#define MD_SPROT_REFCNT_SHFT 5 /* Reference count */
411#define MD_SPROT_REFCNT_WIDTH 0x7ff
412#define MD_SPROT_REFCNT_MASK (MD_SPROT_REFCNT_WIDTH << 5)
413
414/* Migration modes used in protection entries */
415
416#define MD_PROT_MIGMD_IREL (UINT64_CAST 0x3 << 3)
417#define MD_PROT_MIGMD_IABS (UINT64_CAST 0x2 << 3)
418#define MD_PROT_MIGMD_PREL (UINT64_CAST 0x1 << 3)
419#define MD_PROT_MIGMD_OFF (UINT64_CAST 0x0 << 3)
420
421
422/*
423 * Operations on page migration threshold register
424 */
425
426#ifndef __ASSEMBLY__
427
428/*
429 * LED register macros
430 */
431
432#define CPU_LED_ADDR(_nasid, _slice) \
433 (private.p_sn00 ? \
434 REMOTE_HUB_ADDR((_nasid), MD_UREG1_0 + ((_slice) << 5)) : \
435 REMOTE_HUB_ADDR((_nasid), MD_LED0 + ((_slice) << 3)))
436
437#define SET_CPU_LEDS(_nasid, _slice, _val) \
438 (HUB_S(CPU_LED_ADDR(_nasid, _slice), (_val)))
439
440#define SET_MY_LEDS(_v) \
441 SET_CPU_LEDS(get_nasid(), get_slice(), (_v))
442
443/*
444 * Operations on Memory/Directory DIMM control register
445 */
446
447#define DIRTYPE_PREMIUM 1
448#define DIRTYPE_STANDARD 0
449#define MD_MEMORY_CONFIG_DIR_TYPE_GET(region) (\
450 (REMOTE_HUB_L(region, MD_MEMORY_CONFIG) & MMC_DIR_PREMIUM_MASK) >> \
451 MMC_DIR_PREMIUM_SHFT)
452
453
454/*
455 * Operations on page migration count difference and absolute threshold
456 * registers
457 */
458
459#define MD_MIG_DIFF_THRESH_GET(region) ( \
460 REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) & \
461 MD_MIG_DIFF_THRES_VALUE_MASK)
462
463#define MD_MIG_DIFF_THRESH_SET(region, value) ( \
464 REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH, \
465 MD_MIG_DIFF_THRES_VALID_MASK | (value)))
466
467#define MD_MIG_DIFF_THRESH_DISABLE(region) ( \
468 REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH, \
469 REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) \
470 & ~MD_MIG_DIFF_THRES_VALID_MASK))
471
472#define MD_MIG_DIFF_THRESH_ENABLE(region) ( \
473 REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH, \
474 REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) \
475 | MD_MIG_DIFF_THRES_VALID_MASK))
476
477#define MD_MIG_DIFF_THRESH_IS_ENABLED(region) ( \
478 REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) & \
479 MD_MIG_DIFF_THRES_VALID_MASK)
480
481#define MD_MIG_VALUE_THRESH_GET(region) ( \
482 REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) & \
483 MD_MIG_VALUE_THRES_VALUE_MASK)
484
485#define MD_MIG_VALUE_THRESH_SET(region, value) ( \
486 REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH, \
487 MD_MIG_VALUE_THRES_VALID_MASK | (value)))
488
489#define MD_MIG_VALUE_THRESH_DISABLE(region) ( \
490 REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH, \
491 REMOTE_HUB_L(region, MD_MIG_VALUE_THRESH) \
492 & ~MD_MIG_VALUE_THRES_VALID_MASK))
493
494#define MD_MIG_VALUE_THRESH_ENABLE(region) ( \
495 REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH, \
496 REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) \
497 | MD_MIG_VALUE_THRES_VALID_MASK))
498
499#define MD_MIG_VALUE_THRESH_IS_ENABLED(region) ( \
500 REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) & \
501 MD_MIG_VALUE_THRES_VALID_MASK)
502
503/*
504 * Operations on page migration candidate register
505 */
506
507#define MD_MIG_CANDIDATE_GET(my_region_id) ( \
508 REMOTE_HUB_L((my_region_id), MD_MIG_CANDIDATE_CLR))
509
510#define MD_MIG_CANDIDATE_HWPFN(value) ((value) & MD_MIG_CANDIDATE_ADDR_MASK)
511
512#define MD_MIG_CANDIDATE_NODEID(value) ( \
513 ((value) & MD_MIG_CANDIDATE_NODEID_MASK) >> MD_MIG_CANDIDATE_NODEID_SHFT)
514
515#define MD_MIG_CANDIDATE_TYPE(value) ( \
516 ((value) & MD_MIG_CANDIDATE_TYPE_MASK) >> MD_MIG_CANDIDATE_TYPE_SHFT)
517
518#define MD_MIG_CANDIDATE_VALID(value) ( \
519 ((value) & MD_MIG_CANDIDATE_VALID_MASK) >> MD_MIG_CANDIDATE_VALID_SHFT)
520
521/*
522 * Macros to retrieve fields in the protection entry
523 */
524
525/* for Premium SIMM */
526#define MD_PPROT_REFCNT_GET(value) ( \
527 ((value) & MD_PPROT_REFCNT_MASK) >> MD_PPROT_REFCNT_SHFT)
528
529#define MD_PPROT_MIGMD_GET(value) ( \
530 ((value) & MD_PPROT_MIGMD_MASK) >> MD_PPROT_MIGMD_SHFT)
531
532/* for Standard SIMM */
533#define MD_SPROT_REFCNT_GET(value) ( \
534 ((value) & MD_SPROT_REFCNT_MASK) >> MD_SPROT_REFCNT_SHFT)
535
536#define MD_SPROT_MIGMD_GET(value) ( \
537 ((value) & MD_SPROT_MIGMD_MASK) >> MD_SPROT_MIGMD_SHFT)
538
539/*
540 * Format of dir_error, mem_error, protocol_error and misc_error registers
541 */
542
543struct dir_error_reg {
544 u64 uce_vld: 1, /* 63: valid directory uce */
545 ae_vld: 1, /* 62: valid dir prot ecc error */
546 ce_vld: 1, /* 61: valid correctable ECC err*/
547 rsvd1: 19, /* 60-42: reserved */
548 bad_prot: 3, /* 41-39: encoding, bad access rights*/
549 bad_syn: 7, /* 38-32: bad dir syndrome */
550 rsvd2: 2, /* 31-30: reserved */
551 hspec_addr:27, /* 29-03: bddir space bad entry */
552 uce_ovr: 1, /* 2: multiple dir uce's */
553 ae_ovr: 1, /* 1: multiple prot ecc errs*/
554 ce_ovr: 1; /* 0: multiple correctable errs */
555};
556
557typedef union md_dir_error {
558 u64 derr_reg; /* the entire register */
559 struct dir_error_reg derr_fmt; /* the register format */
560} md_dir_error_t;
561
562
563struct mem_error_reg {
564 u64 uce_vld: 1, /* 63: valid memory uce */
565 ce_vld: 1, /* 62: valid correctable ECC err*/
566 rsvd1: 22, /* 61-40: reserved */
567 bad_syn: 8, /* 39-32: bad mem ecc syndrome */
568 address: 29, /* 31-03: bad entry pointer */
569 rsvd2: 1, /* 2: reserved */
570 uce_ovr: 1, /* 1: multiple mem uce's */
571 ce_ovr: 1; /* 0: multiple correctable errs */
572};
573
574
575typedef union md_mem_error {
576 u64 merr_reg; /* the entire register */
577 struct mem_error_reg merr_fmt; /* format of the mem_error reg */
578} md_mem_error_t;
579
580
581struct proto_error_reg {
582 u64 valid: 1, /* 63: valid protocol error */
583 rsvd1: 2, /* 62-61: reserved */
584 initiator:11, /* 60-50: id of request initiator*/
585 backoff: 2, /* 49-48: backoff control */
586 msg_type: 8, /* 47-40: type of request */
587 access: 2, /* 39-38: access rights of initiator*/
588 priority: 1, /* 37: priority level of requestor*/
589 dir_state: 4, /* 36-33: state of directory */
590 pointer_me:1, /* 32: initiator same as dir ptr */
591 address: 29, /* 31-03: request address */
592 rsvd2: 2, /* 02-01: reserved */
593 overrun: 1; /* 0: multiple protocol errs */
594};
595
596typedef union md_proto_error {
597 u64 perr_reg; /* the entire register */
598 struct proto_error_reg perr_fmt; /* format of the register */
599} md_proto_error_t;
600
601
602struct md_sdir_high_fmt {
603 unsigned short sd_hi_bvec : 11,
604 sd_hi_ecc : 5;
605};
606
607
608typedef union md_sdir_high {
609 /* The 16 bits of standard directory, upper word */
610 unsigned short sd_hi_val;
611 struct md_sdir_high_fmt sd_hi_fmt;
612}md_sdir_high_t;
613
614
615struct md_sdir_low_shared_fmt {
616 /* The meaning of lower directory, shared */
617 unsigned short sds_lo_bvec : 5,
618 sds_lo_unused: 1,
619 sds_lo_state : 3,
620 sds_lo_prio : 1,
621 sds_lo_ax : 1,
622 sds_lo_ecc : 5;
623};
624
625struct md_sdir_low_exclusive_fmt {
626 /* The meaning of lower directory, exclusive */
627 unsigned short sde_lo_ptr : 6,
628 sde_lo_state : 3,
629 sde_lo_prio : 1,
630 sde_lo_ax : 1,
631 sde_lo_ecc : 5;
632};
633
634
635typedef union md_sdir_low {
636 /* The 16 bits of standard directory, lower word */
637 unsigned short sd_lo_val;
638 struct md_sdir_low_exclusive_fmt sde_lo_fmt;
639 struct md_sdir_low_shared_fmt sds_lo_fmt;
640}md_sdir_low_t;
641
642
643
644struct md_pdir_high_fmt {
645 u64 pd_hi_unused : 16,
646 pd_hi_bvec : 38,
647 pd_hi_unused1 : 3,
648 pd_hi_ecc : 7;
649};
650
651
652typedef union md_pdir_high {
653 /* The 48 bits of standard directory, upper word */
654 u64 pd_hi_val;
655 struct md_pdir_high_fmt pd_hi_fmt;
656}md_pdir_high_t;
657
658
659struct md_pdir_low_shared_fmt {
660 /* The meaning of lower directory, shared */
661 u64 pds_lo_unused : 16,
662 pds_lo_bvec : 26,
663 pds_lo_cnt : 6,
664 pds_lo_state : 3,
665 pds_lo_ste : 1,
666 pds_lo_prio : 4,
667 pds_lo_ax : 1,
668 pds_lo_ecc : 7;
669};
670
671struct md_pdir_low_exclusive_fmt {
672 /* The meaning of lower directory, exclusive */
673 u64 pde_lo_unused : 31,
674 pde_lo_ptr : 11,
675 pde_lo_unused1 : 6,
676 pde_lo_state : 3,
677 pde_lo_ste : 1,
678 pde_lo_prio : 4,
679 pde_lo_ax : 1,
680 pde_lo_ecc : 7;
681};
682
683
684typedef union md_pdir_loent {
685 /* The 48 bits of premium directory, lower word */
686 u64 pd_lo_val;
687 struct md_pdir_low_exclusive_fmt pde_lo_fmt;
688 struct md_pdir_low_shared_fmt pds_lo_fmt;
689}md_pdir_low_t;
690
691
692/*
693 * the following two "union" definitions and two
694 * "struct" definitions are used in vmdump.c to
695 * represent directory memory information.
696 */
697
698typedef union md_dir_high {
699 md_sdir_high_t md_sdir_high;
700 md_pdir_high_t md_pdir_high;
701} md_dir_high_t;
702
703typedef union md_dir_low {
704 md_sdir_low_t md_sdir_low;
705 md_pdir_low_t md_pdir_low;
706} md_dir_low_t;
707
708typedef struct bddir_entry {
709 md_dir_low_t md_dir_low;
710 md_dir_high_t md_dir_high;
711} bddir_entry_t;
712
713typedef struct dir_mem_entry {
714 u64 prcpf[MAX_REGIONS];
715 bddir_entry_t directory_words[MD_PAGE_SIZE/CACHE_SLINE_SIZE];
716} dir_mem_entry_t;
717
718
719
720typedef union md_perf_sel {
721 u64 perf_sel_reg;
722 struct {
723 u64 perf_rsvd : 60,
724 perf_en : 1,
725 perf_sel : 3;
726 } perf_sel_bits;
727} md_perf_sel_t;
728
729typedef union md_perf_cnt {
730 u64 perf_cnt;
731 struct {
732 u64 perf_rsvd : 44,
733 perf_cnt : 20;
734 } perf_cnt_bits;
735} md_perf_cnt_t;
736
737
738#endif /* !__ASSEMBLY__ */
739
740
741#define DIR_ERROR_VALID_MASK 0xe000000000000000
742#define DIR_ERROR_VALID_SHFT 61
743#define DIR_ERROR_VALID_UCE 0x8000000000000000
744#define DIR_ERROR_VALID_AE 0x4000000000000000
745#define DIR_ERROR_VALID_CE 0x2000000000000000
746
747#define MEM_ERROR_VALID_MASK 0xc000000000000000
748#define MEM_ERROR_VALID_SHFT 62
749#define MEM_ERROR_VALID_UCE 0x8000000000000000
750#define MEM_ERROR_VALID_CE 0x4000000000000000
751
752#define PROTO_ERROR_VALID_MASK 0x8000000000000000
753
754#define MISC_ERROR_VALID_MASK 0x3ff
755
756/*
757 * Mask for hspec address that is stored in the dir error register.
758 * This represents bits 29 through 3.
759 */
760#define DIR_ERR_HSPEC_MASK 0x3ffffff8
761#define ERROR_HSPEC_MASK 0x3ffffff8
762#define ERROR_HSPEC_SHFT 3
763#define ERROR_ADDR_MASK 0xfffffff8
764#define ERROR_ADDR_SHFT 3
765
766/*
767 * MD_MISC_ERROR register defines.
768 */
769
770#define MMCE_VALID_MASK 0x3ff
771#define MMCE_ILL_MSG_SHFT 8
772#define MMCE_ILL_MSG_MASK (UINT64_CAST 0x03 << MMCE_ILL_MSG_SHFT)
773#define MMCE_ILL_REV_SHFT 6
774#define MMCE_ILL_REV_MASK (UINT64_CAST 0x03 << MMCE_ILL_REV_SHFT)
775#define MMCE_LONG_PACK_SHFT 4
776#define MMCE_LONG_PACK_MASK (UINT64_CAST 0x03 << MMCE_lONG_PACK_SHFT)
777#define MMCE_SHORT_PACK_SHFT 2
778#define MMCE_SHORT_PACK_MASK (UINT64_CAST 0x03 << MMCE_SHORT_PACK_SHFT)
779#define MMCE_BAD_DATA_SHFT 0
780#define MMCE_BAD_DATA_MASK (UINT64_CAST 0x03 << MMCE_BAD_DATA_SHFT)
781
782
783#define MD_PERF_COUNTERS 6
784#define MD_PERF_SETS 6
785
786#define MEM_DIMM_MASK 0xe0000000
787#define MEM_DIMM_SHFT 29
788
789#endif /* _ASM_SN_SN0_HUBMD_H */
diff --git a/arch/mips/include/asm/sn/sn0/hubni.h b/arch/mips/include/asm/sn/sn0/hubni.h
new file mode 100644
index 000000000000..b40d3ef97a12
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn0/hubni.h
@@ -0,0 +1,255 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/SN0/hubni.h>, Revision 1.27.
7 *
8 * Copyright (C) 1992-1997, 1999 Silicon Graphics, Inc.
9 * Copyright (C) 1999 by Ralf Baechle
10 */
11#ifndef _ASM_SGI_SN0_HUBNI_H
12#define _ASM_SGI_SN0_HUBNI_H
13
14#ifndef __ASSEMBLY__
15#include <linux/types.h>
16#endif
17
18/*
19 * Hub Network Interface registers
20 *
21 * All registers in this file are subject to change until Hub chip tapeout.
22 */
23
24#define NI_BASE 0x600000
25#define NI_BASE_TABLES 0x630000
26
27#define NI_STATUS_REV_ID 0x600000 /* Hub network status, rev, and ID */
28#define NI_PORT_RESET 0x600008 /* Reset the network interface */
29#define NI_PROTECTION 0x600010 /* NI register access permissions */
30#define NI_GLOBAL_PARMS 0x600018 /* LLP parameters */
31#define NI_SCRATCH_REG0 0x600100 /* Scratch register 0 (64 bits) */
32#define NI_SCRATCH_REG1 0x600108 /* Scratch register 1 (64 bits) */
33#define NI_DIAG_PARMS 0x600110 /* Parameters for diags */
34
35#define NI_VECTOR_PARMS 0x600200 /* Vector PIO routing parameters */
36#define NI_VECTOR 0x600208 /* Vector PIO route */
37#define NI_VECTOR_DATA 0x600210 /* Vector PIO data */
38#define NI_VECTOR_STATUS 0x600300 /* Vector PIO return status */
39#define NI_RETURN_VECTOR 0x600308 /* Vector PIO return vector */
40#define NI_VECTOR_READ_DATA 0x600310 /* Vector PIO read data */
41#define NI_VECTOR_CLEAR 0x600380 /* Vector PIO read & clear status */
42
43#define NI_IO_PROTECT 0x600400 /* PIO protection bits */
44#define NI_IO_PROT_OVRRD 0x600408 /* PIO protection bit override */
45
46#define NI_AGE_CPU0_MEMORY 0x600500 /* CPU 0 memory age control */
47#define NI_AGE_CPU0_PIO 0x600508 /* CPU 0 PIO age control */
48#define NI_AGE_CPU1_MEMORY 0x600510 /* CPU 1 memory age control */
49#define NI_AGE_CPU1_PIO 0x600518 /* CPU 1 PIO age control */
50#define NI_AGE_GBR_MEMORY 0x600520 /* GBR memory age control */
51#define NI_AGE_GBR_PIO 0x600528 /* GBR PIO age control */
52#define NI_AGE_IO_MEMORY 0x600530 /* IO memory age control */
53#define NI_AGE_IO_PIO 0x600538 /* IO PIO age control */
54#define NI_AGE_REG_MIN NI_AGE_CPU0_MEMORY
55#define NI_AGE_REG_MAX NI_AGE_IO_PIO
56
57#define NI_PORT_PARMS 0x608000 /* LLP Parameters */
58#define NI_PORT_ERROR 0x608008 /* LLP Errors */
59#define NI_PORT_ERROR_CLEAR 0x608088 /* Clear the error bits */
60
61#define NI_META_TABLE0 0x638000 /* First meta routing table entry */
62#define NI_META_TABLE(_x) (NI_META_TABLE0 + (8 * (_x)))
63#define NI_META_ENTRIES 32
64
65#define NI_LOCAL_TABLE0 0x638100 /* First local routing table entry */
66#define NI_LOCAL_TABLE(_x) (NI_LOCAL_TABLE0 + (8 * (_x)))
67#define NI_LOCAL_ENTRIES 16
68
69/*
70 * NI_STATUS_REV_ID mask and shift definitions
71 * Have to use UINT64_CAST instead of 'L' suffix, for assembler.
72 */
73
74#define NSRI_8BITMODE_SHFT 30
75#define NSRI_8BITMODE_MASK (UINT64_CAST 0x1 << 30)
76#define NSRI_LINKUP_SHFT 29
77#define NSRI_LINKUP_MASK (UINT64_CAST 0x1 << 29)
78#define NSRI_DOWNREASON_SHFT 28 /* 0=failed, 1=never came */
79#define NSRI_DOWNREASON_MASK (UINT64_CAST 0x1 << 28) /* out of reset. */
80#define NSRI_MORENODES_SHFT 18
81#define NSRI_MORENODES_MASK (UINT64_CAST 1 << 18) /* Max. # of nodes */
82#define MORE_MEMORY 0
83#define MORE_NODES 1
84#define NSRI_REGIONSIZE_SHFT 17
85#define NSRI_REGIONSIZE_MASK (UINT64_CAST 1 << 17) /* Granularity */
86#define REGIONSIZE_FINE 1
87#define REGIONSIZE_COARSE 0
88#define NSRI_NODEID_SHFT 8
89#define NSRI_NODEID_MASK (UINT64_CAST 0x1ff << 8)/* Node (Hub) ID */
90#define NSRI_REV_SHFT 4
91#define NSRI_REV_MASK (UINT64_CAST 0xf << 4) /* Chip Revision */
92#define NSRI_CHIPID_SHFT 0
93#define NSRI_CHIPID_MASK (UINT64_CAST 0xf) /* Chip type ID */
94
95/*
96 * In fine mode, each node is a region. In coarse mode, there are
97 * eight nodes per region.
98 */
99#define NASID_TO_FINEREG_SHFT 0
100#define NASID_TO_COARSEREG_SHFT 3
101
102/* NI_PORT_RESET mask definitions */
103
104#define NPR_PORTRESET (UINT64_CAST 1 << 7) /* Send warm reset */
105#define NPR_LINKRESET (UINT64_CAST 1 << 1) /* Send link reset */
106#define NPR_LOCALRESET (UINT64_CAST 1) /* Reset entire hub */
107
108/* NI_PROTECTION mask and shift definitions */
109
110#define NPROT_RESETOK (UINT64_CAST 1)
111
112/* NI_GLOBAL_PARMS mask and shift definitions */
113
114#define NGP_MAXRETRY_SHFT 48 /* Maximum retries */
115#define NGP_MAXRETRY_MASK (UINT64_CAST 0x3ff << 48)
116#define NGP_TAILTOWRAP_SHFT 32 /* Tail timeout wrap */
117#define NGP_TAILTOWRAP_MASK (UINT64_CAST 0xffff << 32)
118
119#define NGP_CREDITTOVAL_SHFT 16 /* Tail timeout wrap */
120#define NGP_CREDITTOVAL_MASK (UINT64_CAST 0xf << 16)
121#define NGP_TAILTOVAL_SHFT 4 /* Tail timeout value */
122#define NGP_TAILTOVAL_MASK (UINT64_CAST 0xf << 4)
123
124/* NI_DIAG_PARMS mask and shift definitions */
125
126#define NDP_PORTTORESET (UINT64_CAST 1 << 18) /* Port tmout reset */
127#define NDP_LLP8BITMODE (UINT64_CAST 1 << 12) /* LLP 8-bit mode */
128#define NDP_PORTDISABLE (UINT64_CAST 1 << 6) /* Port disable */
129#define NDP_SENDERROR (UINT64_CAST 1) /* Send data error */
130
131/*
132 * NI_VECTOR_PARMS mask and shift definitions.
133 * TYPE may be any of the first four PIOTYPEs defined under NI_VECTOR_STATUS.
134 */
135
136#define NVP_PIOID_SHFT 40
137#define NVP_PIOID_MASK (UINT64_CAST 0x3ff << 40)
138#define NVP_WRITEID_SHFT 32
139#define NVP_WRITEID_MASK (UINT64_CAST 0xff << 32)
140#define NVP_ADDRESS_MASK (UINT64_CAST 0xffff8) /* Bits 19:3 */
141#define NVP_TYPE_SHFT 0
142#define NVP_TYPE_MASK (UINT64_CAST 0x3)
143
144/* NI_VECTOR_STATUS mask and shift definitions */
145
146#define NVS_VALID (UINT64_CAST 1 << 63)
147#define NVS_OVERRUN (UINT64_CAST 1 << 62)
148#define NVS_TARGET_SHFT 51
149#define NVS_TARGET_MASK (UINT64_CAST 0x3ff << 51)
150#define NVS_PIOID_SHFT 40
151#define NVS_PIOID_MASK (UINT64_CAST 0x3ff << 40)
152#define NVS_WRITEID_SHFT 32
153#define NVS_WRITEID_MASK (UINT64_CAST 0xff << 32)
154#define NVS_ADDRESS_MASK (UINT64_CAST 0xfffffff8) /* Bits 31:3 */
155#define NVS_TYPE_SHFT 0
156#define NVS_TYPE_MASK (UINT64_CAST 0x7)
157#define NVS_ERROR_MASK (UINT64_CAST 0x4) /* bit set means error */
158
159
160#define PIOTYPE_READ 0 /* VECTOR_PARMS and VECTOR_STATUS */
161#define PIOTYPE_WRITE 1 /* VECTOR_PARMS and VECTOR_STATUS */
162#define PIOTYPE_UNDEFINED 2 /* VECTOR_PARMS and VECTOR_STATUS */
163#define PIOTYPE_EXCHANGE 3 /* VECTOR_PARMS and VECTOR_STATUS */
164#define PIOTYPE_ADDR_ERR 4 /* VECTOR_STATUS only */
165#define PIOTYPE_CMD_ERR 5 /* VECTOR_STATUS only */
166#define PIOTYPE_PROT_ERR 6 /* VECTOR_STATUS only */
167#define PIOTYPE_UNKNOWN 7 /* VECTOR_STATUS only */
168
169/* NI_AGE_XXX mask and shift definitions */
170
171#define NAGE_VCH_SHFT 10
172#define NAGE_VCH_MASK (UINT64_CAST 3 << 10)
173#define NAGE_CC_SHFT 8
174#define NAGE_CC_MASK (UINT64_CAST 3 << 8)
175#define NAGE_AGE_SHFT 0
176#define NAGE_AGE_MASK (UINT64_CAST 0xff)
177#define NAGE_MASK (NAGE_VCH_MASK | NAGE_CC_MASK | NAGE_AGE_MASK)
178
179#define VCHANNEL_A 0
180#define VCHANNEL_B 1
181#define VCHANNEL_ANY 2
182
183/* NI_PORT_PARMS mask and shift definitions */
184
185#define NPP_NULLTO_SHFT 10
186#define NPP_NULLTO_MASK (UINT64_CAST 0x3f << 16)
187#define NPP_MAXBURST_SHFT 0
188#define NPP_MAXBURST_MASK (UINT64_CAST 0x3ff)
189#define NPP_RESET_DFLT_HUB20 ((UINT64_CAST 1 << NPP_NULLTO_SHFT) | \
190 (UINT64_CAST 0x3f0 << NPP_MAXBURST_SHFT))
191#define NPP_RESET_DEFAULTS ((UINT64_CAST 6 << NPP_NULLTO_SHFT) | \
192 (UINT64_CAST 0x3f0 << NPP_MAXBURST_SHFT))
193
194
195/* NI_PORT_ERROR mask and shift definitions */
196
197#define NPE_LINKRESET (UINT64_CAST 1 << 37)
198#define NPE_INTERNALERROR (UINT64_CAST 1 << 36)
199#define NPE_BADMESSAGE (UINT64_CAST 1 << 35)
200#define NPE_BADDEST (UINT64_CAST 1 << 34)
201#define NPE_FIFOOVERFLOW (UINT64_CAST 1 << 33)
202#define NPE_CREDITTO_SHFT 28
203#define NPE_CREDITTO_MASK (UINT64_CAST 0xf << 28)
204#define NPE_TAILTO_SHFT 24
205#define NPE_TAILTO_MASK (UINT64_CAST 0xf << 24)
206#define NPE_RETRYCOUNT_SHFT 16
207#define NPE_RETRYCOUNT_MASK (UINT64_CAST 0xff << 16)
208#define NPE_CBERRCOUNT_SHFT 8
209#define NPE_CBERRCOUNT_MASK (UINT64_CAST 0xff << 8)
210#define NPE_SNERRCOUNT_SHFT 0
211#define NPE_SNERRCOUNT_MASK (UINT64_CAST 0xff << 0)
212#define NPE_MASK 0x3effffffff
213
214#define NPE_COUNT_MAX 0xff
215
216#define NPE_FATAL_ERRORS (NPE_LINKRESET | NPE_INTERNALERROR | \
217 NPE_BADMESSAGE | NPE_BADDEST | \
218 NPE_FIFOOVERFLOW | NPE_CREDITTO_MASK | \
219 NPE_TAILTO_MASK)
220
221/* NI_META_TABLE mask and shift definitions */
222
223#define NMT_EXIT_PORT_MASK (UINT64_CAST 0xf)
224
225/* NI_LOCAL_TABLE mask and shift definitions */
226
227#define NLT_EXIT_PORT_MASK (UINT64_CAST 0xf)
228
229#ifndef __ASSEMBLY__
230
231typedef union hubni_port_error_u {
232 u64 nipe_reg_value;
233 struct {
234 u64 nipe_rsvd: 26, /* unused */
235 nipe_lnk_reset: 1, /* link reset */
236 nipe_intl_err: 1, /* internal error */
237 nipe_bad_msg: 1, /* bad message */
238 nipe_bad_dest: 1, /* bad dest */
239 nipe_fifo_ovfl: 1, /* fifo overflow */
240 nipe_rsvd1: 1, /* unused */
241 nipe_credit_to: 4, /* credit timeout */
242 nipe_tail_to: 4, /* tail timeout */
243 nipe_retry_cnt: 8, /* retry error count */
244 nipe_cb_cnt: 8, /* checkbit error count */
245 nipe_sn_cnt: 8; /* sequence number count */
246 } nipe_fields_s;
247} hubni_port_error_t;
248
249#define NI_LLP_RETRY_MAX 0xff
250#define NI_LLP_CB_MAX 0xff
251#define NI_LLP_SN_MAX 0xff
252
253#endif /* !__ASSEMBLY__ */
254
255#endif /* _ASM_SGI_SN0_HUBNI_H */
diff --git a/arch/mips/include/asm/sn/sn0/hubpi.h b/arch/mips/include/asm/sn/sn0/hubpi.h
new file mode 100644
index 000000000000..e39f5f9da040
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn0/hubpi.h
@@ -0,0 +1,409 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/SN0/hubpi.h>, revision 1.28.
7 *
8 * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
9 * Copyright (C) 1999 by Ralf Baechle
10 */
11#ifndef _ASM_SN_SN0_HUBPI_H
12#define _ASM_SN_SN0_HUBPI_H
13
14#include <linux/types.h>
15
16/*
17 * Hub I/O interface registers
18 *
19 * All registers in this file are subject to change until Hub chip tapeout.
20 * All register "addresses" are actually offsets. Use the LOCAL_HUB
21 * or REMOTE_HUB macros to synthesize an actual address
22 */
23
24#define PI_BASE 0x000000
25
26/* General protection and control registers */
27
28#define PI_CPU_PROTECT 0x000000 /* CPU Protection */
29#define PI_PROT_OVERRD 0x000008 /* Clear CPU Protection bit */
30#define PI_IO_PROTECT 0x000010 /* Interrupt Pending Protection */
31#define PI_REGION_PRESENT 0x000018 /* Indicates whether region exists */
32#define PI_CPU_NUM 0x000020 /* CPU Number ID */
33#define PI_CALIAS_SIZE 0x000028 /* Cached Alias Size */
34#define PI_MAX_CRB_TIMEOUT 0x000030 /* Maximum Timeout for CRB */
35#define PI_CRB_SFACTOR 0x000038 /* Scale factor for CRB timeout */
36
37/* CALIAS values */
38#define PI_CALIAS_SIZE_0 0
39#define PI_CALIAS_SIZE_4K 1
40#define PI_CALIAS_SIZE_8K 2
41#define PI_CALIAS_SIZE_16K 3
42#define PI_CALIAS_SIZE_32K 4
43#define PI_CALIAS_SIZE_64K 5
44#define PI_CALIAS_SIZE_128K 6
45#define PI_CALIAS_SIZE_256K 7
46#define PI_CALIAS_SIZE_512K 8
47#define PI_CALIAS_SIZE_1M 9
48#define PI_CALIAS_SIZE_2M 10
49#define PI_CALIAS_SIZE_4M 11
50#define PI_CALIAS_SIZE_8M 12
51#define PI_CALIAS_SIZE_16M 13
52#define PI_CALIAS_SIZE_32M 14
53#define PI_CALIAS_SIZE_64M 15
54
55/* Processor control and status checking */
56
57#define PI_CPU_PRESENT_A 0x000040 /* CPU Present A */
58#define PI_CPU_PRESENT_B 0x000048 /* CPU Present B */
59#define PI_CPU_ENABLE_A 0x000050 /* CPU Enable A */
60#define PI_CPU_ENABLE_B 0x000058 /* CPU Enable B */
61#define PI_REPLY_LEVEL 0x000060 /* Reply Level */
62#define PI_HARDRESET_BIT 0x020068 /* Bit cleared by s/w on SR */
63#define PI_NMI_A 0x000070 /* NMI to CPU A */
64#define PI_NMI_B 0x000078 /* NMI to CPU B */
65#define PI_NMI_OFFSET (PI_NMI_B - PI_NMI_A)
66#define PI_SOFTRESET 0x000080 /* Softreset (to both CPUs) */
67
68/* Regular Interrupt register checking. */
69
70#define PI_INT_PEND_MOD 0x000090 /* Write to set pending ints */
71#define PI_INT_PEND0 0x000098 /* Read to get pending ints */
72#define PI_INT_PEND1 0x0000a0 /* Read to get pending ints */
73#define PI_INT_MASK0_A 0x0000a8 /* Interrupt Mask 0 for CPU A */
74#define PI_INT_MASK1_A 0x0000b0 /* Interrupt Mask 1 for CPU A */
75#define PI_INT_MASK0_B 0x0000b8 /* Interrupt Mask 0 for CPU B */
76#define PI_INT_MASK1_B 0x0000c0 /* Interrupt Mask 1 for CPU B */
77
78#define PI_INT_MASK_OFFSET 0x10 /* Offset from A to B */
79
80/* Crosscall interrupts */
81
82#define PI_CC_PEND_SET_A 0x0000c8 /* CC Interrupt Pending Set, CPU A */
83#define PI_CC_PEND_SET_B 0x0000d0 /* CC Interrupt Pending Set, CPU B */
84#define PI_CC_PEND_CLR_A 0x0000d8 /* CC Interrupt Pending Clr, CPU A */
85#define PI_CC_PEND_CLR_B 0x0000e0 /* CC Interrupt Pending Clr, CPU B */
86#define PI_CC_MASK 0x0000e8 /* CC Interrupt mask */
87
88#define PI_INT_SET_OFFSET 0x08 /* Offset from A to B */
89
90/* Realtime Counter and Profiler control registers */
91
92#define PI_RT_COUNT 0x030100 /* Real Time Counter */
93#define PI_RT_COMPARE_A 0x000108 /* Real Time Compare A */
94#define PI_RT_COMPARE_B 0x000110 /* Real Time Compare B */
95#define PI_PROFILE_COMPARE 0x000118 /* L5 int to both cpus when == RTC */
96#define PI_RT_PEND_A 0x000120 /* Set if RT int for A pending */
97#define PI_RT_PEND_B 0x000128 /* Set if RT int for B pending */
98#define PI_PROF_PEND_A 0x000130 /* Set if Prof int for A pending */
99#define PI_PROF_PEND_B 0x000138 /* Set if Prof int for B pending */
100#define PI_RT_EN_A 0x000140 /* RT int for CPU A enable */
101#define PI_RT_EN_B 0x000148 /* RT int for CPU B enable */
102#define PI_PROF_EN_A 0x000150 /* PROF int for CPU A enable */
103#define PI_PROF_EN_B 0x000158 /* PROF int for CPU B enable */
104#define PI_RT_LOCAL_CTRL 0x000160 /* RT control register */
105#define PI_RT_FILTER_CTRL 0x000168 /* GCLK Filter control register */
106
107#define PI_COUNT_OFFSET 0x08 /* A to B offset for all counts */
108
109/* Built-In Self Test support */
110
111#define PI_BIST_WRITE_DATA 0x000200 /* BIST write data */
112#define PI_BIST_READ_DATA 0x000208 /* BIST read data */
113#define PI_BIST_COUNT_TARG 0x000210 /* BIST Count and Target */
114#define PI_BIST_READY 0x000218 /* BIST Ready indicator */
115#define PI_BIST_SHIFT_LOAD 0x000220 /* BIST control */
116#define PI_BIST_SHIFT_UNLOAD 0x000228 /* BIST control */
117#define PI_BIST_ENTER_RUN 0x000230 /* BIST control */
118
119/* Graphics control registers */
120
121#define PI_GFX_PAGE_A 0x000300 /* Graphics page A */
122#define PI_GFX_CREDIT_CNTR_A 0x000308 /* Graphics credit counter A */
123#define PI_GFX_BIAS_A 0x000310 /* Graphics bias A */
124#define PI_GFX_INT_CNTR_A 0x000318 /* Graphics interrupt counter A */
125#define PI_GFX_INT_CMP_A 0x000320 /* Graphics interrupt comparator A */
126#define PI_GFX_PAGE_B 0x000328 /* Graphics page B */
127#define PI_GFX_CREDIT_CNTR_B 0x000330 /* Graphics credit counter B */
128#define PI_GFX_BIAS_B 0x000338 /* Graphics bias B */
129#define PI_GFX_INT_CNTR_B 0x000340 /* Graphics interrupt counter B */
130#define PI_GFX_INT_CMP_B 0x000348 /* Graphics interrupt comparator B */
131
132#define PI_GFX_OFFSET (PI_GFX_PAGE_B - PI_GFX_PAGE_A)
133#define PI_GFX_PAGE_ENABLE 0x0000010000000000LL
134
135/* Error and timeout registers */
136#define PI_ERR_INT_PEND 0x000400 /* Error Interrupt Pending */
137#define PI_ERR_INT_MASK_A 0x000408 /* Error Interrupt mask for CPU A */
138#define PI_ERR_INT_MASK_B 0x000410 /* Error Interrupt mask for CPU B */
139#define PI_ERR_STACK_ADDR_A 0x000418 /* Error stack address for CPU A */
140#define PI_ERR_STACK_ADDR_B 0x000420 /* Error stack address for CPU B */
141#define PI_ERR_STACK_SIZE 0x000428 /* Error Stack Size */
142#define PI_ERR_STATUS0_A 0x000430 /* Error Status 0A */
143#define PI_ERR_STATUS0_A_RCLR 0x000438 /* Error Status 0A clear on read */
144#define PI_ERR_STATUS1_A 0x000440 /* Error Status 1A */
145#define PI_ERR_STATUS1_A_RCLR 0x000448 /* Error Status 1A clear on read */
146#define PI_ERR_STATUS0_B 0x000450 /* Error Status 0B */
147#define PI_ERR_STATUS0_B_RCLR 0x000458 /* Error Status 0B clear on read */
148#define PI_ERR_STATUS1_B 0x000460 /* Error Status 1B */
149#define PI_ERR_STATUS1_B_RCLR 0x000468 /* Error Status 1B clear on read */
150#define PI_SPOOL_CMP_A 0x000470 /* Spool compare for CPU A */
151#define PI_SPOOL_CMP_B 0x000478 /* Spool compare for CPU B */
152#define PI_CRB_TIMEOUT_A 0x000480 /* Timed out CRB entries for A */
153#define PI_CRB_TIMEOUT_B 0x000488 /* Timed out CRB entries for B */
154#define PI_SYSAD_ERRCHK_EN 0x000490 /* Enables SYSAD error checking */
155#define PI_BAD_CHECK_BIT_A 0x000498 /* Force SYSAD check bit error */
156#define PI_BAD_CHECK_BIT_B 0x0004a0 /* Force SYSAD check bit error */
157#define PI_NACK_CNT_A 0x0004a8 /* Consecutive NACK counter */
158#define PI_NACK_CNT_B 0x0004b0 /* " " for CPU B */
159#define PI_NACK_CMP 0x0004b8 /* NACK count compare */
160#define PI_STACKADDR_OFFSET (PI_ERR_STACK_ADDR_B - PI_ERR_STACK_ADDR_A)
161#define PI_ERRSTAT_OFFSET (PI_ERR_STATUS0_B - PI_ERR_STATUS0_A)
162#define PI_RDCLR_OFFSET (PI_ERR_STATUS0_A_RCLR - PI_ERR_STATUS0_A)
163
164/* Bits in PI_ERR_INT_PEND */
165#define PI_ERR_SPOOL_CMP_B 0x00000001 /* Spool end hit high water */
166#define PI_ERR_SPOOL_CMP_A 0x00000002
167#define PI_ERR_SPUR_MSG_B 0x00000004 /* Spurious message intr. */
168#define PI_ERR_SPUR_MSG_A 0x00000008
169#define PI_ERR_WRB_TERR_B 0x00000010 /* WRB TERR */
170#define PI_ERR_WRB_TERR_A 0x00000020
171#define PI_ERR_WRB_WERR_B 0x00000040 /* WRB WERR */
172#define PI_ERR_WRB_WERR_A 0x00000080
173#define PI_ERR_SYSSTATE_B 0x00000100 /* SysState parity error */
174#define PI_ERR_SYSSTATE_A 0x00000200
175#define PI_ERR_SYSAD_DATA_B 0x00000400 /* SysAD data parity error */
176#define PI_ERR_SYSAD_DATA_A 0x00000800
177#define PI_ERR_SYSAD_ADDR_B 0x00001000 /* SysAD addr parity error */
178#define PI_ERR_SYSAD_ADDR_A 0x00002000
179#define PI_ERR_SYSCMD_DATA_B 0x00004000 /* SysCmd data parity error */
180#define PI_ERR_SYSCMD_DATA_A 0x00008000
181#define PI_ERR_SYSCMD_ADDR_B 0x00010000 /* SysCmd addr parity error */
182#define PI_ERR_SYSCMD_ADDR_A 0x00020000
183#define PI_ERR_BAD_SPOOL_B 0x00040000 /* Error spooling to memory */
184#define PI_ERR_BAD_SPOOL_A 0x00080000
185#define PI_ERR_UNCAC_UNCORR_B 0x00100000 /* Uncached uncorrectable */
186#define PI_ERR_UNCAC_UNCORR_A 0x00200000
187#define PI_ERR_SYSSTATE_TAG_B 0x00400000 /* SysState tag parity error */
188#define PI_ERR_SYSSTATE_TAG_A 0x00800000
189#define PI_ERR_MD_UNCORR 0x01000000 /* Must be cleared in MD */
190
191#define PI_ERR_CLEAR_ALL_A 0x00aaaaaa
192#define PI_ERR_CLEAR_ALL_B 0x00555555
193
194
195/*
196 * The following three macros define all possible error int pends.
197 */
198
199#define PI_FATAL_ERR_CPU_A (PI_ERR_SYSSTATE_TAG_A | \
200 PI_ERR_BAD_SPOOL_A | \
201 PI_ERR_SYSCMD_ADDR_A | \
202 PI_ERR_SYSCMD_DATA_A | \
203 PI_ERR_SYSAD_ADDR_A | \
204 PI_ERR_SYSAD_DATA_A | \
205 PI_ERR_SYSSTATE_A)
206
207#define PI_MISC_ERR_CPU_A (PI_ERR_UNCAC_UNCORR_A | \
208 PI_ERR_WRB_WERR_A | \
209 PI_ERR_WRB_TERR_A | \
210 PI_ERR_SPUR_MSG_A | \
211 PI_ERR_SPOOL_CMP_A)
212
213#define PI_FATAL_ERR_CPU_B (PI_ERR_SYSSTATE_TAG_B | \
214 PI_ERR_BAD_SPOOL_B | \
215 PI_ERR_SYSCMD_ADDR_B | \
216 PI_ERR_SYSCMD_DATA_B | \
217 PI_ERR_SYSAD_ADDR_B | \
218 PI_ERR_SYSAD_DATA_B | \
219 PI_ERR_SYSSTATE_B)
220
221#define PI_MISC_ERR_CPU_B (PI_ERR_UNCAC_UNCORR_B | \
222 PI_ERR_WRB_WERR_B | \
223 PI_ERR_WRB_TERR_B | \
224 PI_ERR_SPUR_MSG_B | \
225 PI_ERR_SPOOL_CMP_B)
226
227#define PI_ERR_GENERIC (PI_ERR_MD_UNCORR)
228
229/*
230 * Error types for PI_ERR_STATUS0_[AB] and error stack:
231 * Use the write types if WRBRRB is 1 else use the read types
232 */
233
234/* Fields in PI_ERR_STATUS0_[AB] */
235#define PI_ERR_ST0_TYPE_MASK 0x0000000000000007
236#define PI_ERR_ST0_TYPE_SHFT 0
237#define PI_ERR_ST0_REQNUM_MASK 0x0000000000000038
238#define PI_ERR_ST0_REQNUM_SHFT 3
239#define PI_ERR_ST0_SUPPL_MASK 0x000000000001ffc0
240#define PI_ERR_ST0_SUPPL_SHFT 6
241#define PI_ERR_ST0_CMD_MASK 0x0000000001fe0000
242#define PI_ERR_ST0_CMD_SHFT 17
243#define PI_ERR_ST0_ADDR_MASK 0x3ffffffffe000000
244#define PI_ERR_ST0_ADDR_SHFT 25
245#define PI_ERR_ST0_OVERRUN_MASK 0x4000000000000000
246#define PI_ERR_ST0_OVERRUN_SHFT 62
247#define PI_ERR_ST0_VALID_MASK 0x8000000000000000
248#define PI_ERR_ST0_VALID_SHFT 63
249
250/* Fields in PI_ERR_STATUS1_[AB] */
251#define PI_ERR_ST1_SPOOL_MASK 0x00000000001fffff
252#define PI_ERR_ST1_SPOOL_SHFT 0
253#define PI_ERR_ST1_TOUTCNT_MASK 0x000000001fe00000
254#define PI_ERR_ST1_TOUTCNT_SHFT 21
255#define PI_ERR_ST1_INVCNT_MASK 0x0000007fe0000000
256#define PI_ERR_ST1_INVCNT_SHFT 29
257#define PI_ERR_ST1_CRBNUM_MASK 0x0000038000000000
258#define PI_ERR_ST1_CRBNUM_SHFT 39
259#define PI_ERR_ST1_WRBRRB_MASK 0x0000040000000000
260#define PI_ERR_ST1_WRBRRB_SHFT 42
261#define PI_ERR_ST1_CRBSTAT_MASK 0x001ff80000000000
262#define PI_ERR_ST1_CRBSTAT_SHFT 43
263#define PI_ERR_ST1_MSGSRC_MASK 0xffe0000000000000
264#define PI_ERR_ST1_MSGSRC_SHFT 53
265
266/* Fields in the error stack */
267#define PI_ERR_STK_TYPE_MASK 0x0000000000000003
268#define PI_ERR_STK_TYPE_SHFT 0
269#define PI_ERR_STK_SUPPL_MASK 0x0000000000000038
270#define PI_ERR_STK_SUPPL_SHFT 3
271#define PI_ERR_STK_REQNUM_MASK 0x00000000000001c0
272#define PI_ERR_STK_REQNUM_SHFT 6
273#define PI_ERR_STK_CRBNUM_MASK 0x0000000000000e00
274#define PI_ERR_STK_CRBNUM_SHFT 9
275#define PI_ERR_STK_WRBRRB_MASK 0x0000000000001000
276#define PI_ERR_STK_WRBRRB_SHFT 12
277#define PI_ERR_STK_CRBSTAT_MASK 0x00000000007fe000
278#define PI_ERR_STK_CRBSTAT_SHFT 13
279#define PI_ERR_STK_CMD_MASK 0x000000007f800000
280#define PI_ERR_STK_CMD_SHFT 23
281#define PI_ERR_STK_ADDR_MASK 0xffffffff80000000
282#define PI_ERR_STK_ADDR_SHFT 31
283
284/* Error type in the error status or stack on Read CRBs */
285#define PI_ERR_RD_PRERR 1
286#define PI_ERR_RD_DERR 2
287#define PI_ERR_RD_TERR 3
288
289/* Error type in the error status or stack on Write CRBs */
290#define PI_ERR_WR_WERR 0
291#define PI_ERR_WR_PWERR 1
292#define PI_ERR_WR_TERR 3
293
294/* Read or Write CRB in error status or stack */
295#define PI_ERR_RRB 0
296#define PI_ERR_WRB 1
297#define PI_ERR_ANY_CRB 2
298
299/* Address masks in the error status and error stack are not the same */
300#define ERR_STK_ADDR_SHFT 7
301#define ERR_STAT0_ADDR_SHFT 3
302
303#define PI_MIN_STACK_SIZE 4096 /* For figuring out the size to set */
304#define PI_STACK_SIZE_SHFT 12 /* 4k */
305
306#define ERR_STACK_SIZE_BYTES(_sz) \
307 ((_sz) ? (PI_MIN_STACK_SIZE << ((_sz) - 1)) : 0)
308
309#ifndef __ASSEMBLY__
310/*
311 * format of error stack and error status registers.
312 */
313
314struct err_stack_format {
315 u64 sk_addr : 33, /* address */
316 sk_cmd : 8, /* message command */
317 sk_crb_sts : 10, /* status from RRB or WRB */
318 sk_rw_rb : 1, /* RRB == 0, WRB == 1 */
319 sk_crb_num : 3, /* WRB (0 to 7) or RRB (0 to 4) */
320 sk_t5_req : 3, /* RRB T5 request number */
321 sk_suppl : 3, /* lowest 3 bit of supplemental */
322 sk_err_type: 3; /* error type */
323};
324
325typedef union pi_err_stack {
326 u64 pi_stk_word;
327 struct err_stack_format pi_stk_fmt;
328} pi_err_stack_t;
329
330struct err_status0_format {
331 u64 s0_valid : 1, /* Valid */
332 s0_ovr_run : 1, /* Overrun, spooled to memory */
333 s0_addr : 37, /* address */
334 s0_cmd : 8, /* message command */
335 s0_supl : 11, /* message supplemental field */
336 s0_t5_req : 3, /* RRB T5 request number */
337 s0_err_type: 3; /* error type */
338};
339
340typedef union pi_err_stat0 {
341 u64 pi_stat0_word;
342 struct err_status0_format pi_stat0_fmt;
343} pi_err_stat0_t;
344
345struct err_status1_format {
346 u64 s1_src : 11, /* message source */
347 s1_crb_sts : 10, /* status from RRB or WRB */
348 s1_rw_rb : 1, /* RRB == 0, WRB == 1 */
349 s1_crb_num : 3, /* WRB (0 to 7) or RRB (0 to 4) */
350 s1_inval_cnt:10, /* signed invalidate counter RRB */
351 s1_to_cnt : 8, /* crb timeout counter */
352 s1_spl_cnt : 21; /* number spooled to memory */
353};
354
355typedef union pi_err_stat1 {
356 u64 pi_stat1_word;
357 struct err_status1_format pi_stat1_fmt;
358} pi_err_stat1_t;
359
360typedef u64 rtc_time_t;
361
362#endif /* !__ASSEMBLY__ */
363
364
365/* Bits in PI_SYSAD_ERRCHK_EN */
366#define PI_SYSAD_ERRCHK_ECCGEN 0x01 /* Enable ECC generation */
367#define PI_SYSAD_ERRCHK_QUALGEN 0x02 /* Enable data quality signal gen. */
368#define PI_SYSAD_ERRCHK_SADP 0x04 /* Enable SysAD parity checking */
369#define PI_SYSAD_ERRCHK_CMDP 0x08 /* Enable SysCmd parity checking */
370#define PI_SYSAD_ERRCHK_STATE 0x10 /* Enable SysState parity checking */
371#define PI_SYSAD_ERRCHK_QUAL 0x20 /* Enable data quality checking */
372#define PI_SYSAD_CHECK_ALL 0x3f /* Generate and check all signals. */
373
374/* Interrupt pending bits on R10000 */
375
376#define HUB_IP_PEND0 0x0400
377#define HUB_IP_PEND1_CC 0x0800
378#define HUB_IP_RT 0x1000
379#define HUB_IP_PROF 0x2000
380#define HUB_IP_ERROR 0x4000
381#define HUB_IP_MASK 0x7c00
382
383/* PI_RT_LOCAL_CTRL mask and shift definitions */
384
385#define PRLC_USE_INT_SHFT 16
386#define PRLC_USE_INT_MASK (UINT64_CAST 1 << 16)
387#define PRLC_USE_INT (UINT64_CAST 1 << 16)
388#define PRLC_GCLK_SHFT 15
389#define PRLC_GCLK_MASK (UINT64_CAST 1 << 15)
390#define PRLC_GCLK (UINT64_CAST 1 << 15)
391#define PRLC_GCLK_COUNT_SHFT 8
392#define PRLC_GCLK_COUNT_MASK (UINT64_CAST 0x7f << 8)
393#define PRLC_MAX_COUNT_SHFT 1
394#define PRLC_MAX_COUNT_MASK (UINT64_CAST 0x7f << 1)
395#define PRLC_GCLK_EN_SHFT 0
396#define PRLC_GCLK_EN_MASK (UINT64_CAST 1)
397#define PRLC_GCLK_EN (UINT64_CAST 1)
398
399/* PI_RT_FILTER_CTRL mask and shift definitions */
400
401/*
402 * Bits for NACK_CNT_A/B and NACK_CMP
403 */
404#define PI_NACK_CNT_EN_SHFT 20
405#define PI_NACK_CNT_EN_MASK 0x100000
406#define PI_NACK_CNT_MASK 0x0fffff
407#define PI_NACK_CNT_MAX 0x0fffff
408
409#endif /* _ASM_SN_SN0_HUBPI_H */
diff --git a/arch/mips/include/asm/sn/sn0/ip27.h b/arch/mips/include/asm/sn/sn0/ip27.h
new file mode 100644
index 000000000000..3c97e0855c8d
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn0/ip27.h
@@ -0,0 +1,85 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Derived from IRIX <sys/SN/SN0/IP27.h>.
7 *
8 * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
9 * Copyright (C) 1999, 2006 by Ralf Baechle
10 */
11#ifndef _ASM_SN_SN0_IP27_H
12#define _ASM_SN_SN0_IP27_H
13
14#include <asm/mipsregs.h>
15
16/*
17 * Simple definitions for the masks which remove SW bits from pte.
18 */
19
20#define TLBLO_HWBITSHIFT 0 /* Shift value, for masking */
21
22#ifndef __ASSEMBLY__
23
24#define CAUSE_BERRINTR IE_IRQ5
25
26#define ECCF_CACHE_ERR 0
27#define ECCF_TAGLO 1
28#define ECCF_ECC 2
29#define ECCF_ERROREPC 3
30#define ECCF_PADDR 4
31#define ECCF_SIZE (5 * sizeof(long))
32
33#endif /* !__ASSEMBLY__ */
34
35#ifdef __ASSEMBLY__
36
37/*
38 * KL_GET_CPUNUM (similar to EV_GET_SPNUM for EVEREST platform) reads
39 * the processor number of the calling processor. The proc parameters
40 * must be a register.
41 */
42#define KL_GET_CPUNUM(proc) \
43 dli proc, LOCAL_HUB(0); \
44 ld proc, PI_CPU_NUM(proc)
45
46#endif /* __ASSEMBLY__ */
47
48/*
49 * R10000 status register interrupt bit mask usage for IP27.
50 */
51#define SRB_SWTIMO IE_SW0 /* 0x0100 */
52#define SRB_NET IE_SW1 /* 0x0200 */
53#define SRB_DEV0 IE_IRQ0 /* 0x0400 */
54#define SRB_DEV1 IE_IRQ1 /* 0x0800 */
55#define SRB_TIMOCLK IE_IRQ2 /* 0x1000 */
56#define SRB_PROFCLK IE_IRQ3 /* 0x2000 */
57#define SRB_ERR IE_IRQ4 /* 0x4000 */
58#define SRB_SCHEDCLK IE_IRQ5 /* 0x8000 */
59
60#define SR_IBIT_HI SRB_DEV0
61#define SR_IBIT_PROF SRB_PROFCLK
62
63#define SRB_SWTIMO_IDX 0
64#define SRB_NET_IDX 1
65#define SRB_DEV0_IDX 2
66#define SRB_DEV1_IDX 3
67#define SRB_TIMOCLK_IDX 4
68#define SRB_PROFCLK_IDX 5
69#define SRB_ERR_IDX 6
70#define SRB_SCHEDCLK_IDX 7
71
72#define NUM_CAUSE_INTRS 8
73
74#define SCACHE_LINESIZE 128
75#define SCACHE_LINEMASK (SCACHE_LINESIZE - 1)
76
77#include <asm/sn/addrs.h>
78
79#define LED_CYCLE_MASK 0x0f
80#define LED_CYCLE_SHFT 4
81
82#define SEND_NMI(_nasid, _slice) \
83 REMOTE_HUB_S((_nasid), (PI_NMI_A + ((_slice) * PI_NMI_OFFSET)), 1)
84
85#endif /* _ASM_SN_SN0_IP27_H */
diff --git a/arch/mips/include/asm/sn/sn_private.h b/arch/mips/include/asm/sn/sn_private.h
new file mode 100644
index 000000000000..1a2c3025bf28
--- /dev/null
+++ b/arch/mips/include/asm/sn/sn_private.h
@@ -0,0 +1,19 @@
1#ifndef __ASM_SN_SN_PRIVATE_H
2#define __ASM_SN_SN_PRIVATE_H
3
4#include <asm/sn/types.h>
5
6extern nasid_t master_nasid;
7
8extern void cpu_node_probe(void);
9extern cnodeid_t get_compact_nodeid(void);
10extern void hub_rtc_init(cnodeid_t);
11extern void cpu_time_init(void);
12extern void per_cpu_init(void);
13extern void install_cpu_nmi_handler(int slice);
14extern void install_ipi(void);
15extern void setup_replication_mask(void);
16extern void replicate_kernel_text(void);
17extern pfn_t node_getfirstfree(cnodeid_t);
18
19#endif /* __ASM_SN_SN_PRIVATE_H */
diff --git a/arch/mips/include/asm/sn/types.h b/arch/mips/include/asm/sn/types.h
new file mode 100644
index 000000000000..74d0bb260b86
--- /dev/null
+++ b/arch/mips/include/asm/sn/types.h
@@ -0,0 +1,26 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1999 Silicon Graphics, Inc.
7 * Copyright (C) 1999 by Ralf Baechle
8 */
9#ifndef _ASM_SN_TYPES_H
10#define _ASM_SN_TYPES_H
11
12#include <linux/types.h>
13
14typedef unsigned long cpuid_t;
15typedef unsigned long cnodemask_t;
16typedef signed short nasid_t; /* node id in numa-as-id space */
17typedef signed short cnodeid_t; /* node id in compact-id space */
18typedef signed char partid_t; /* partition ID type */
19typedef signed short moduleid_t; /* user-visible module number type */
20typedef signed short cmoduleid_t; /* kernel compact module id type */
21typedef unsigned char clusterid_t; /* Clusterid of the cell */
22typedef unsigned long pfn_t;
23
24typedef dev_t vertex_hdl_t; /* hardware graph vertex handle */
25
26#endif /* _ASM_SN_TYPES_H */
diff --git a/arch/mips/include/asm/sni.h b/arch/mips/include/asm/sni.h
new file mode 100644
index 000000000000..8c1eb02c6d16
--- /dev/null
+++ b/arch/mips/include/asm/sni.h
@@ -0,0 +1,244 @@
1/*
2 * SNI specific definitions
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1997, 1998 by Ralf Baechle
9 * Copyright (C) 2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
10 */
11#ifndef __ASM_SNI_H
12#define __ASM_SNI_H
13
14extern unsigned int sni_brd_type;
15
16#define SNI_BRD_10 2
17#define SNI_BRD_10NEW 3
18#define SNI_BRD_TOWER_OASIC 4
19#define SNI_BRD_MINITOWER 5
20#define SNI_BRD_PCI_TOWER 6
21#define SNI_BRD_RM200 7
22#define SNI_BRD_PCI_MTOWER 8
23#define SNI_BRD_PCI_DESKTOP 9
24#define SNI_BRD_PCI_TOWER_CPLUS 10
25#define SNI_BRD_PCI_MTOWER_CPLUS 11
26
27/* RM400 cpu types */
28#define SNI_CPU_M8021 0x01
29#define SNI_CPU_M8030 0x04
30#define SNI_CPU_M8031 0x06
31#define SNI_CPU_M8034 0x0f
32#define SNI_CPU_M8037 0x07
33#define SNI_CPU_M8040 0x05
34#define SNI_CPU_M8043 0x09
35#define SNI_CPU_M8050 0x0b
36#define SNI_CPU_M8053 0x0d
37
38#define SNI_PORT_BASE CKSEG1ADDR(0xb4000000)
39
40#ifndef __MIPSEL__
41/*
42 * ASIC PCI registers for big endian configuration.
43 */
44#define PCIMT_UCONF CKSEG1ADDR(0xbfff0004)
45#define PCIMT_IOADTIMEOUT2 CKSEG1ADDR(0xbfff000c)
46#define PCIMT_IOMEMCONF CKSEG1ADDR(0xbfff0014)
47#define PCIMT_IOMMU CKSEG1ADDR(0xbfff001c)
48#define PCIMT_IOADTIMEOUT1 CKSEG1ADDR(0xbfff0024)
49#define PCIMT_DMAACCESS CKSEG1ADDR(0xbfff002c)
50#define PCIMT_DMAHIT CKSEG1ADDR(0xbfff0034)
51#define PCIMT_ERRSTATUS CKSEG1ADDR(0xbfff003c)
52#define PCIMT_ERRADDR CKSEG1ADDR(0xbfff0044)
53#define PCIMT_SYNDROME CKSEG1ADDR(0xbfff004c)
54#define PCIMT_ITPEND CKSEG1ADDR(0xbfff0054)
55#define IT_INT2 0x01
56#define IT_INTD 0x02
57#define IT_INTC 0x04
58#define IT_INTB 0x08
59#define IT_INTA 0x10
60#define IT_EISA 0x20
61#define IT_SCSI 0x40
62#define IT_ETH 0x80
63#define PCIMT_IRQSEL CKSEG1ADDR(0xbfff005c)
64#define PCIMT_TESTMEM CKSEG1ADDR(0xbfff0064)
65#define PCIMT_ECCREG CKSEG1ADDR(0xbfff006c)
66#define PCIMT_CONFIG_ADDRESS CKSEG1ADDR(0xbfff0074)
67#define PCIMT_ASIC_ID CKSEG1ADDR(0xbfff007c) /* read */
68#define PCIMT_SOFT_RESET CKSEG1ADDR(0xbfff007c) /* write */
69#define PCIMT_PIA_OE CKSEG1ADDR(0xbfff0084)
70#define PCIMT_PIA_DATAOUT CKSEG1ADDR(0xbfff008c)
71#define PCIMT_PIA_DATAIN CKSEG1ADDR(0xbfff0094)
72#define PCIMT_CACHECONF CKSEG1ADDR(0xbfff009c)
73#define PCIMT_INVSPACE CKSEG1ADDR(0xbfff00a4)
74#else
75/*
76 * ASIC PCI registers for little endian configuration.
77 */
78#define PCIMT_UCONF CKSEG1ADDR(0xbfff0000)
79#define PCIMT_IOADTIMEOUT2 CKSEG1ADDR(0xbfff0008)
80#define PCIMT_IOMEMCONF CKSEG1ADDR(0xbfff0010)
81#define PCIMT_IOMMU CKSEG1ADDR(0xbfff0018)
82#define PCIMT_IOADTIMEOUT1 CKSEG1ADDR(0xbfff0020)
83#define PCIMT_DMAACCESS CKSEG1ADDR(0xbfff0028)
84#define PCIMT_DMAHIT CKSEG1ADDR(0xbfff0030)
85#define PCIMT_ERRSTATUS CKSEG1ADDR(0xbfff0038)
86#define PCIMT_ERRADDR CKSEG1ADDR(0xbfff0040)
87#define PCIMT_SYNDROME CKSEG1ADDR(0xbfff0048)
88#define PCIMT_ITPEND CKSEG1ADDR(0xbfff0050)
89#define IT_INT2 0x01
90#define IT_INTD 0x02
91#define IT_INTC 0x04
92#define IT_INTB 0x08
93#define IT_INTA 0x10
94#define IT_EISA 0x20
95#define IT_SCSI 0x40
96#define IT_ETH 0x80
97#define PCIMT_IRQSEL CKSEG1ADDR(0xbfff0058)
98#define PCIMT_TESTMEM CKSEG1ADDR(0xbfff0060)
99#define PCIMT_ECCREG CKSEG1ADDR(0xbfff0068)
100#define PCIMT_CONFIG_ADDRESS CKSEG1ADDR(0xbfff0070)
101#define PCIMT_ASIC_ID CKSEG1ADDR(0xbfff0078) /* read */
102#define PCIMT_SOFT_RESET CKSEG1ADDR(0xbfff0078) /* write */
103#define PCIMT_PIA_OE CKSEG1ADDR(0xbfff0080)
104#define PCIMT_PIA_DATAOUT CKSEG1ADDR(0xbfff0088)
105#define PCIMT_PIA_DATAIN CKSEG1ADDR(0xbfff0090)
106#define PCIMT_CACHECONF CKSEG1ADDR(0xbfff0098)
107#define PCIMT_INVSPACE CKSEG1ADDR(0xbfff00a0)
108#endif
109
110#define PCIMT_PCI_CONF CKSEG1ADDR(0xbfff0100)
111
112/*
113 * Data port for the PCI bus in IO space
114 */
115#define PCIMT_CONFIG_DATA 0x0cfc
116
117/*
118 * Board specific registers
119 */
120#define PCIMT_CSMSR CKSEG1ADDR(0xbfd00000)
121#define PCIMT_CSSWITCH CKSEG1ADDR(0xbfd10000)
122#define PCIMT_CSITPEND CKSEG1ADDR(0xbfd20000)
123#define PCIMT_AUTO_PO_EN CKSEG1ADDR(0xbfd30000)
124#define PCIMT_CLR_TEMP CKSEG1ADDR(0xbfd40000)
125#define PCIMT_AUTO_PO_DIS CKSEG1ADDR(0xbfd50000)
126#define PCIMT_EXMSR CKSEG1ADDR(0xbfd60000)
127#define PCIMT_UNUSED1 CKSEG1ADDR(0xbfd70000)
128#define PCIMT_CSWCSM CKSEG1ADDR(0xbfd80000)
129#define PCIMT_UNUSED2 CKSEG1ADDR(0xbfd90000)
130#define PCIMT_CSLED CKSEG1ADDR(0xbfda0000)
131#define PCIMT_CSMAPISA CKSEG1ADDR(0xbfdb0000)
132#define PCIMT_CSRSTBP CKSEG1ADDR(0xbfdc0000)
133#define PCIMT_CLRPOFF CKSEG1ADDR(0xbfdd0000)
134#define PCIMT_CSTIMER CKSEG1ADDR(0xbfde0000)
135#define PCIMT_PWDN CKSEG1ADDR(0xbfdf0000)
136
137/*
138 * A20R based boards
139 */
140#define A20R_PT_CLOCK_BASE CKSEG1ADDR(0xbc040000)
141#define A20R_PT_TIM0_ACK CKSEG1ADDR(0xbc050000)
142#define A20R_PT_TIM1_ACK CKSEG1ADDR(0xbc060000)
143
144#define SNI_A20R_IRQ_BASE MIPS_CPU_IRQ_BASE
145#define SNI_A20R_IRQ_TIMER (SNI_A20R_IRQ_BASE+5)
146
147#define SNI_PCIT_INT_REG CKSEG1ADDR(0xbfff000c)
148
149#define SNI_PCIT_INT_START 24
150#define SNI_PCIT_INT_END 30
151
152#define PCIT_IRQ_ETHERNET (MIPS_CPU_IRQ_BASE + 5)
153#define PCIT_IRQ_INTA (SNI_PCIT_INT_START + 0)
154#define PCIT_IRQ_INTB (SNI_PCIT_INT_START + 1)
155#define PCIT_IRQ_INTC (SNI_PCIT_INT_START + 2)
156#define PCIT_IRQ_INTD (SNI_PCIT_INT_START + 3)
157#define PCIT_IRQ_SCSI0 (SNI_PCIT_INT_START + 4)
158#define PCIT_IRQ_SCSI1 (SNI_PCIT_INT_START + 5)
159
160
161/*
162 * Interrupt 0-16 are EISA interrupts. Interrupts from 16 on are assigned
163 * to the other interrupts generated by ASIC PCI.
164 *
165 * INT2 is a wired-or of the push button interrupt, high temperature interrupt
166 * ASIC PCI interrupt.
167 */
168#define PCIMT_KEYBOARD_IRQ 1
169#define PCIMT_IRQ_INT2 24
170#define PCIMT_IRQ_INTD 25
171#define PCIMT_IRQ_INTC 26
172#define PCIMT_IRQ_INTB 27
173#define PCIMT_IRQ_INTA 28
174#define PCIMT_IRQ_EISA 29
175#define PCIMT_IRQ_SCSI 30
176
177#define PCIMT_IRQ_ETHERNET (MIPS_CPU_IRQ_BASE+6)
178
179#if 0
180#define PCIMT_IRQ_TEMPERATURE 24
181#define PCIMT_IRQ_EISA_NMI 25
182#define PCIMT_IRQ_POWER_OFF 26
183#define PCIMT_IRQ_BUTTON 27
184#endif
185
186/*
187 * Base address for the mapped 16mb EISA bus segment.
188 */
189#define PCIMT_EISA_BASE CKSEG1ADDR(0xb0000000)
190
191/* PCI EISA Interrupt acknowledge */
192#define PCIMT_INT_ACKNOWLEDGE CKSEG1ADDR(0xba000000)
193
194/*
195 * SNI ID PROM
196 *
197 * SNI_IDPROM_MEMSIZE Memsize in 16MB quantities
198 * SNI_IDPROM_BRDTYPE Board Type
199 * SNI_IDPROM_CPUTYPE CPU Type on RM400
200 */
201#ifdef CONFIG_CPU_BIG_ENDIAN
202#define __SNI_END 0
203#endif
204#ifdef CONFIG_CPU_LITTLE_ENDIAN
205#define __SNI_END 3
206#endif
207#define SNI_IDPROM_BASE CKSEG1ADDR(0x1ff00000)
208#define SNI_IDPROM_MEMSIZE (SNI_IDPROM_BASE + (0x28 ^ __SNI_END))
209#define SNI_IDPROM_BRDTYPE (SNI_IDPROM_BASE + (0x29 ^ __SNI_END))
210#define SNI_IDPROM_CPUTYPE (SNI_IDPROM_BASE + (0x30 ^ __SNI_END))
211
212#define SNI_IDPROM_SIZE 0x1000
213
214/* board specific init functions */
215extern void sni_a20r_init(void);
216extern void sni_pcit_init(void);
217extern void sni_rm200_init(void);
218extern void sni_pcimt_init(void);
219
220/* board specific irq init functions */
221extern void sni_a20r_irq_init(void);
222extern void sni_pcit_irq_init(void);
223extern void sni_pcit_cplus_irq_init(void);
224extern void sni_rm200_irq_init(void);
225extern void sni_pcimt_irq_init(void);
226
227/* timer inits */
228extern void sni_cpu_time_init(void);
229
230/* eisa init for RM200/400 */
231#ifdef CONFIG_EISA
232extern int sni_eisa_root_init(void);
233#else
234static inline int sni_eisa_root_init(void)
235{
236 return 0;
237}
238#endif
239
240/* common irq stuff */
241extern void (*sni_hwint)(void);
242extern struct irqaction sni_isa_irq;
243
244#endif /* __ASM_SNI_H */
diff --git a/arch/mips/include/asm/socket.h b/arch/mips/include/asm/socket.h
new file mode 100644
index 000000000000..facc2d7a87ca
--- /dev/null
+++ b/arch/mips/include/asm/socket.h
@@ -0,0 +1,117 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1997, 1999, 2000, 2001 Ralf Baechle
7 * Copyright (C) 2000, 2001 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_SOCKET_H
10#define _ASM_SOCKET_H
11
12#include <asm/sockios.h>
13
14/*
15 * For setsockopt(2)
16 *
17 * This defines are ABI conformant as far as Linux supports these ...
18 */
19#define SOL_SOCKET 0xffff
20
21#define SO_DEBUG 0x0001 /* Record debugging information. */
22#define SO_REUSEADDR 0x0004 /* Allow reuse of local addresses. */
23#define SO_KEEPALIVE 0x0008 /* Keep connections alive and send
24 SIGPIPE when they die. */
25#define SO_DONTROUTE 0x0010 /* Don't do local routing. */
26#define SO_BROADCAST 0x0020 /* Allow transmission of
27 broadcast messages. */
28#define SO_LINGER 0x0080 /* Block on close of a reliable
29 socket to transmit pending data. */
30#define SO_OOBINLINE 0x0100 /* Receive out-of-band data in-band. */
31#if 0
32To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */
33#endif
34
35#define SO_TYPE 0x1008 /* Compatible name for SO_STYLE. */
36#define SO_STYLE SO_TYPE /* Synonym */
37#define SO_ERROR 0x1007 /* get error status and clear */
38#define SO_SNDBUF 0x1001 /* Send buffer size. */
39#define SO_RCVBUF 0x1002 /* Receive buffer. */
40#define SO_SNDLOWAT 0x1003 /* send low-water mark */
41#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
42#define SO_SNDTIMEO 0x1005 /* send timeout */
43#define SO_RCVTIMEO 0x1006 /* receive timeout */
44#define SO_ACCEPTCONN 0x1009
45
46/* linux-specific, might as well be the same as on i386 */
47#define SO_NO_CHECK 11
48#define SO_PRIORITY 12
49#define SO_BSDCOMPAT 14
50
51#define SO_PASSCRED 17
52#define SO_PEERCRED 18
53
54/* Security levels - as per NRL IPv6 - don't actually do anything */
55#define SO_SECURITY_AUTHENTICATION 22
56#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
57#define SO_SECURITY_ENCRYPTION_NETWORK 24
58
59#define SO_BINDTODEVICE 25
60
61/* Socket filtering */
62#define SO_ATTACH_FILTER 26
63#define SO_DETACH_FILTER 27
64
65#define SO_PEERNAME 28
66#define SO_TIMESTAMP 29
67#define SCM_TIMESTAMP SO_TIMESTAMP
68
69#define SO_PEERSEC 30
70#define SO_SNDBUFFORCE 31
71#define SO_RCVBUFFORCE 33
72#define SO_PASSSEC 34
73#define SO_TIMESTAMPNS 35
74#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
75
76#define SO_MARK 36
77
78#ifdef __KERNEL__
79
80/** sock_type - Socket types
81 *
82 * Please notice that for binary compat reasons MIPS has to
83 * override the enum sock_type in include/linux/net.h, so
84 * we define ARCH_HAS_SOCKET_TYPES here.
85 *
86 * @SOCK_DGRAM - datagram (conn.less) socket
87 * @SOCK_STREAM - stream (connection) socket
88 * @SOCK_RAW - raw socket
89 * @SOCK_RDM - reliably-delivered message
90 * @SOCK_SEQPACKET - sequential packet socket
91 * @SOCK_PACKET - linux specific way of getting packets at the dev level.
92 * For writing rarp and other similar things on the user level.
93 */
94enum sock_type {
95 SOCK_DGRAM = 1,
96 SOCK_STREAM = 2,
97 SOCK_RAW = 3,
98 SOCK_RDM = 4,
99 SOCK_SEQPACKET = 5,
100 SOCK_DCCP = 6,
101 SOCK_PACKET = 10,
102};
103
104#define SOCK_MAX (SOCK_PACKET + 1)
105/* Mask which covers at least up to SOCK_MASK-1. The
106 * * remaining bits are used as flags. */
107#define SOCK_TYPE_MASK 0xf
108
109/* Flags for socket, socketpair, paccept */
110#define SOCK_CLOEXEC O_CLOEXEC
111#define SOCK_NONBLOCK O_NONBLOCK
112
113#define ARCH_HAS_SOCKET_TYPES 1
114
115#endif /* __KERNEL__ */
116
117#endif /* _ASM_SOCKET_H */
diff --git a/arch/mips/include/asm/sockios.h b/arch/mips/include/asm/sockios.h
new file mode 100644
index 000000000000..ed1a5f78d22f
--- /dev/null
+++ b/arch/mips/include/asm/sockios.h
@@ -0,0 +1,26 @@
1/*
2 * Socket-level I/O control calls.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1995 by Ralf Baechle
9 */
10#ifndef _ASM_SOCKIOS_H
11#define _ASM_SOCKIOS_H
12
13#include <asm/ioctl.h>
14
15/* Socket-level I/O control calls. */
16#define FIOGETOWN _IOR('f', 123, int)
17#define FIOSETOWN _IOW('f', 124, int)
18
19#define SIOCATMARK _IOR('s', 7, int)
20#define SIOCSPGRP _IOW('s', 8, pid_t)
21#define SIOCGPGRP _IOR('s', 9, pid_t)
22
23#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
24#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
25
26#endif /* _ASM_SOCKIOS_H */
diff --git a/arch/mips/include/asm/sparsemem.h b/arch/mips/include/asm/sparsemem.h
new file mode 100644
index 000000000000..795ac6c23203
--- /dev/null
+++ b/arch/mips/include/asm/sparsemem.h
@@ -0,0 +1,14 @@
1#ifndef _MIPS_SPARSEMEM_H
2#define _MIPS_SPARSEMEM_H
3#ifdef CONFIG_SPARSEMEM
4
5/*
6 * SECTION_SIZE_BITS 2^N: how big each section will be
7 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space
8 */
9#define SECTION_SIZE_BITS 28
10#define MAX_PHYSMEM_BITS 35
11
12#endif /* CONFIG_SPARSEMEM */
13#endif /* _MIPS_SPARSEMEM_H */
14
diff --git a/arch/mips/include/asm/spinlock.h b/arch/mips/include/asm/spinlock.h
new file mode 100644
index 000000000000..5d98a3cb85b7
--- /dev/null
+++ b/arch/mips/include/asm/spinlock.h
@@ -0,0 +1,487 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1999, 2000, 06 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_SPINLOCK_H
10#define _ASM_SPINLOCK_H
11
12#include <linux/compiler.h>
13
14#include <asm/barrier.h>
15#include <asm/war.h>
16
17/*
18 * Your basic SMP spinlocks, allowing only a single CPU anywhere
19 *
20 * Simple spin lock operations. There are two variants, one clears IRQ's
21 * on the local processor, one does not.
22 *
23 * These are fair FIFO ticket locks
24 *
25 * (the type definitions are in asm/spinlock_types.h)
26 */
27
28
29/*
30 * Ticket locks are conceptually two parts, one indicating the current head of
31 * the queue, and the other indicating the current tail. The lock is acquired
32 * by atomically noting the tail and incrementing it by one (thus adding
33 * ourself to the queue and noting our position), then waiting until the head
34 * becomes equal to the the initial value of the tail.
35 */
36
37static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
38{
39 unsigned int counters = ACCESS_ONCE(lock->lock);
40
41 return ((counters >> 14) ^ counters) & 0x1fff;
42}
43
44#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
45#define __raw_spin_unlock_wait(x) \
46 while (__raw_spin_is_locked(x)) { cpu_relax(); }
47
48static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
49{
50 unsigned int counters = ACCESS_ONCE(lock->lock);
51
52 return (((counters >> 14) - counters) & 0x1fff) > 1;
53}
54
55static inline void __raw_spin_lock(raw_spinlock_t *lock)
56{
57 int my_ticket;
58 int tmp;
59
60 if (R10000_LLSC_WAR) {
61 __asm__ __volatile__ (
62 " .set push # __raw_spin_lock \n"
63 " .set noreorder \n"
64 " \n"
65 "1: ll %[ticket], %[ticket_ptr] \n"
66 " addiu %[my_ticket], %[ticket], 0x4000 \n"
67 " sc %[my_ticket], %[ticket_ptr] \n"
68 " beqzl %[my_ticket], 1b \n"
69 " nop \n"
70 " srl %[my_ticket], %[ticket], 14 \n"
71 " andi %[my_ticket], %[my_ticket], 0x1fff \n"
72 " andi %[ticket], %[ticket], 0x1fff \n"
73 " bne %[ticket], %[my_ticket], 4f \n"
74 " subu %[ticket], %[my_ticket], %[ticket] \n"
75 "2: \n"
76 " .subsection 2 \n"
77 "4: andi %[ticket], %[ticket], 0x1fff \n"
78 "5: sll %[ticket], 5 \n"
79 " \n"
80 "6: bnez %[ticket], 6b \n"
81 " subu %[ticket], 1 \n"
82 " \n"
83 " lw %[ticket], %[ticket_ptr] \n"
84 " andi %[ticket], %[ticket], 0x1fff \n"
85 " beq %[ticket], %[my_ticket], 2b \n"
86 " subu %[ticket], %[my_ticket], %[ticket] \n"
87 " b 5b \n"
88 " subu %[ticket], %[ticket], 1 \n"
89 " .previous \n"
90 " .set pop \n"
91 : [ticket_ptr] "+m" (lock->lock),
92 [ticket] "=&r" (tmp),
93 [my_ticket] "=&r" (my_ticket));
94 } else {
95 __asm__ __volatile__ (
96 " .set push # __raw_spin_lock \n"
97 " .set noreorder \n"
98 " \n"
99 " ll %[ticket], %[ticket_ptr] \n"
100 "1: addiu %[my_ticket], %[ticket], 0x4000 \n"
101 " sc %[my_ticket], %[ticket_ptr] \n"
102 " beqz %[my_ticket], 3f \n"
103 " nop \n"
104 " srl %[my_ticket], %[ticket], 14 \n"
105 " andi %[my_ticket], %[my_ticket], 0x1fff \n"
106 " andi %[ticket], %[ticket], 0x1fff \n"
107 " bne %[ticket], %[my_ticket], 4f \n"
108 " subu %[ticket], %[my_ticket], %[ticket] \n"
109 "2: \n"
110 " .subsection 2 \n"
111 "3: b 1b \n"
112 " ll %[ticket], %[ticket_ptr] \n"
113 " \n"
114 "4: andi %[ticket], %[ticket], 0x1fff \n"
115 "5: sll %[ticket], 5 \n"
116 " \n"
117 "6: bnez %[ticket], 6b \n"
118 " subu %[ticket], 1 \n"
119 " \n"
120 " lw %[ticket], %[ticket_ptr] \n"
121 " andi %[ticket], %[ticket], 0x1fff \n"
122 " beq %[ticket], %[my_ticket], 2b \n"
123 " subu %[ticket], %[my_ticket], %[ticket] \n"
124 " b 5b \n"
125 " subu %[ticket], %[ticket], 1 \n"
126 " .previous \n"
127 " .set pop \n"
128 : [ticket_ptr] "+m" (lock->lock),
129 [ticket] "=&r" (tmp),
130 [my_ticket] "=&r" (my_ticket));
131 }
132
133 smp_llsc_mb();
134}
135
136static inline void __raw_spin_unlock(raw_spinlock_t *lock)
137{
138 int tmp;
139
140 smp_llsc_mb();
141
142 if (R10000_LLSC_WAR) {
143 __asm__ __volatile__ (
144 " # __raw_spin_unlock \n"
145 "1: ll %[ticket], %[ticket_ptr] \n"
146 " addiu %[ticket], %[ticket], 1 \n"
147 " ori %[ticket], %[ticket], 0x2000 \n"
148 " xori %[ticket], %[ticket], 0x2000 \n"
149 " sc %[ticket], %[ticket_ptr] \n"
150 " beqzl %[ticket], 2f \n"
151 : [ticket_ptr] "+m" (lock->lock),
152 [ticket] "=&r" (tmp));
153 } else {
154 __asm__ __volatile__ (
155 " .set push # __raw_spin_unlock \n"
156 " .set noreorder \n"
157 " \n"
158 " ll %[ticket], %[ticket_ptr] \n"
159 "1: addiu %[ticket], %[ticket], 1 \n"
160 " ori %[ticket], %[ticket], 0x2000 \n"
161 " xori %[ticket], %[ticket], 0x2000 \n"
162 " sc %[ticket], %[ticket_ptr] \n"
163 " beqz %[ticket], 2f \n"
164 " nop \n"
165 " \n"
166 " .subsection 2 \n"
167 "2: b 1b \n"
168 " ll %[ticket], %[ticket_ptr] \n"
169 " .previous \n"
170 " .set pop \n"
171 : [ticket_ptr] "+m" (lock->lock),
172 [ticket] "=&r" (tmp));
173 }
174}
175
176static inline unsigned int __raw_spin_trylock(raw_spinlock_t *lock)
177{
178 int tmp, tmp2, tmp3;
179
180 if (R10000_LLSC_WAR) {
181 __asm__ __volatile__ (
182 " .set push # __raw_spin_trylock \n"
183 " .set noreorder \n"
184 " \n"
185 "1: ll %[ticket], %[ticket_ptr] \n"
186 " srl %[my_ticket], %[ticket], 14 \n"
187 " andi %[my_ticket], %[my_ticket], 0x1fff \n"
188 " andi %[now_serving], %[ticket], 0x1fff \n"
189 " bne %[my_ticket], %[now_serving], 3f \n"
190 " addiu %[ticket], %[ticket], 0x4000 \n"
191 " sc %[ticket], %[ticket_ptr] \n"
192 " beqzl %[ticket], 1b \n"
193 " li %[ticket], 1 \n"
194 "2: \n"
195 " .subsection 2 \n"
196 "3: b 2b \n"
197 " li %[ticket], 0 \n"
198 " .previous \n"
199 " .set pop \n"
200 : [ticket_ptr] "+m" (lock->lock),
201 [ticket] "=&r" (tmp),
202 [my_ticket] "=&r" (tmp2),
203 [now_serving] "=&r" (tmp3));
204 } else {
205 __asm__ __volatile__ (
206 " .set push # __raw_spin_trylock \n"
207 " .set noreorder \n"
208 " \n"
209 " ll %[ticket], %[ticket_ptr] \n"
210 "1: srl %[my_ticket], %[ticket], 14 \n"
211 " andi %[my_ticket], %[my_ticket], 0x1fff \n"
212 " andi %[now_serving], %[ticket], 0x1fff \n"
213 " bne %[my_ticket], %[now_serving], 3f \n"
214 " addiu %[ticket], %[ticket], 0x4000 \n"
215 " sc %[ticket], %[ticket_ptr] \n"
216 " beqz %[ticket], 4f \n"
217 " li %[ticket], 1 \n"
218 "2: \n"
219 " .subsection 2 \n"
220 "3: b 2b \n"
221 " li %[ticket], 0 \n"
222 "4: b 1b \n"
223 " ll %[ticket], %[ticket_ptr] \n"
224 " .previous \n"
225 " .set pop \n"
226 : [ticket_ptr] "+m" (lock->lock),
227 [ticket] "=&r" (tmp),
228 [my_ticket] "=&r" (tmp2),
229 [now_serving] "=&r" (tmp3));
230 }
231
232 smp_llsc_mb();
233
234 return tmp;
235}
236
237/*
238 * Read-write spinlocks, allowing multiple readers but only one writer.
239 *
240 * NOTE! it is quite common to have readers in interrupts but no interrupt
241 * writers. For those circumstances we can "mix" irq-safe locks - any writer
242 * needs to get a irq-safe write-lock, but readers can get non-irqsafe
243 * read-locks.
244 */
245
246/*
247 * read_can_lock - would read_trylock() succeed?
248 * @lock: the rwlock in question.
249 */
250#define __raw_read_can_lock(rw) ((rw)->lock >= 0)
251
252/*
253 * write_can_lock - would write_trylock() succeed?
254 * @lock: the rwlock in question.
255 */
256#define __raw_write_can_lock(rw) (!(rw)->lock)
257
258static inline void __raw_read_lock(raw_rwlock_t *rw)
259{
260 unsigned int tmp;
261
262 if (R10000_LLSC_WAR) {
263 __asm__ __volatile__(
264 " .set noreorder # __raw_read_lock \n"
265 "1: ll %1, %2 \n"
266 " bltz %1, 1b \n"
267 " addu %1, 1 \n"
268 " sc %1, %0 \n"
269 " beqzl %1, 1b \n"
270 " nop \n"
271 " .set reorder \n"
272 : "=m" (rw->lock), "=&r" (tmp)
273 : "m" (rw->lock)
274 : "memory");
275 } else {
276 __asm__ __volatile__(
277 " .set noreorder # __raw_read_lock \n"
278 "1: ll %1, %2 \n"
279 " bltz %1, 2f \n"
280 " addu %1, 1 \n"
281 " sc %1, %0 \n"
282 " beqz %1, 1b \n"
283 " nop \n"
284 " .subsection 2 \n"
285 "2: ll %1, %2 \n"
286 " bltz %1, 2b \n"
287 " addu %1, 1 \n"
288 " b 1b \n"
289 " nop \n"
290 " .previous \n"
291 " .set reorder \n"
292 : "=m" (rw->lock), "=&r" (tmp)
293 : "m" (rw->lock)
294 : "memory");
295 }
296
297 smp_llsc_mb();
298}
299
300/* Note the use of sub, not subu which will make the kernel die with an
301 overflow exception if we ever try to unlock an rwlock that is already
302 unlocked or is being held by a writer. */
303static inline void __raw_read_unlock(raw_rwlock_t *rw)
304{
305 unsigned int tmp;
306
307 smp_llsc_mb();
308
309 if (R10000_LLSC_WAR) {
310 __asm__ __volatile__(
311 "1: ll %1, %2 # __raw_read_unlock \n"
312 " sub %1, 1 \n"
313 " sc %1, %0 \n"
314 " beqzl %1, 1b \n"
315 : "=m" (rw->lock), "=&r" (tmp)
316 : "m" (rw->lock)
317 : "memory");
318 } else {
319 __asm__ __volatile__(
320 " .set noreorder # __raw_read_unlock \n"
321 "1: ll %1, %2 \n"
322 " sub %1, 1 \n"
323 " sc %1, %0 \n"
324 " beqz %1, 2f \n"
325 " nop \n"
326 " .subsection 2 \n"
327 "2: b 1b \n"
328 " nop \n"
329 " .previous \n"
330 " .set reorder \n"
331 : "=m" (rw->lock), "=&r" (tmp)
332 : "m" (rw->lock)
333 : "memory");
334 }
335}
336
337static inline void __raw_write_lock(raw_rwlock_t *rw)
338{
339 unsigned int tmp;
340
341 if (R10000_LLSC_WAR) {
342 __asm__ __volatile__(
343 " .set noreorder # __raw_write_lock \n"
344 "1: ll %1, %2 \n"
345 " bnez %1, 1b \n"
346 " lui %1, 0x8000 \n"
347 " sc %1, %0 \n"
348 " beqzl %1, 1b \n"
349 " nop \n"
350 " .set reorder \n"
351 : "=m" (rw->lock), "=&r" (tmp)
352 : "m" (rw->lock)
353 : "memory");
354 } else {
355 __asm__ __volatile__(
356 " .set noreorder # __raw_write_lock \n"
357 "1: ll %1, %2 \n"
358 " bnez %1, 2f \n"
359 " lui %1, 0x8000 \n"
360 " sc %1, %0 \n"
361 " beqz %1, 2f \n"
362 " nop \n"
363 " .subsection 2 \n"
364 "2: ll %1, %2 \n"
365 " bnez %1, 2b \n"
366 " lui %1, 0x8000 \n"
367 " b 1b \n"
368 " nop \n"
369 " .previous \n"
370 " .set reorder \n"
371 : "=m" (rw->lock), "=&r" (tmp)
372 : "m" (rw->lock)
373 : "memory");
374 }
375
376 smp_llsc_mb();
377}
378
379static inline void __raw_write_unlock(raw_rwlock_t *rw)
380{
381 smp_mb();
382
383 __asm__ __volatile__(
384 " # __raw_write_unlock \n"
385 " sw $0, %0 \n"
386 : "=m" (rw->lock)
387 : "m" (rw->lock)
388 : "memory");
389}
390
391static inline int __raw_read_trylock(raw_rwlock_t *rw)
392{
393 unsigned int tmp;
394 int ret;
395
396 if (R10000_LLSC_WAR) {
397 __asm__ __volatile__(
398 " .set noreorder # __raw_read_trylock \n"
399 " li %2, 0 \n"
400 "1: ll %1, %3 \n"
401 " bltz %1, 2f \n"
402 " addu %1, 1 \n"
403 " sc %1, %0 \n"
404 " .set reorder \n"
405 " beqzl %1, 1b \n"
406 " nop \n"
407 __WEAK_LLSC_MB
408 " li %2, 1 \n"
409 "2: \n"
410 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
411 : "m" (rw->lock)
412 : "memory");
413 } else {
414 __asm__ __volatile__(
415 " .set noreorder # __raw_read_trylock \n"
416 " li %2, 0 \n"
417 "1: ll %1, %3 \n"
418 " bltz %1, 2f \n"
419 " addu %1, 1 \n"
420 " sc %1, %0 \n"
421 " beqz %1, 1b \n"
422 " nop \n"
423 " .set reorder \n"
424 __WEAK_LLSC_MB
425 " li %2, 1 \n"
426 "2: \n"
427 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
428 : "m" (rw->lock)
429 : "memory");
430 }
431
432 return ret;
433}
434
435static inline int __raw_write_trylock(raw_rwlock_t *rw)
436{
437 unsigned int tmp;
438 int ret;
439
440 if (R10000_LLSC_WAR) {
441 __asm__ __volatile__(
442 " .set noreorder # __raw_write_trylock \n"
443 " li %2, 0 \n"
444 "1: ll %1, %3 \n"
445 " bnez %1, 2f \n"
446 " lui %1, 0x8000 \n"
447 " sc %1, %0 \n"
448 " beqzl %1, 1b \n"
449 " nop \n"
450 __WEAK_LLSC_MB
451 " li %2, 1 \n"
452 " .set reorder \n"
453 "2: \n"
454 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
455 : "m" (rw->lock)
456 : "memory");
457 } else {
458 __asm__ __volatile__(
459 " .set noreorder # __raw_write_trylock \n"
460 " li %2, 0 \n"
461 "1: ll %1, %3 \n"
462 " bnez %1, 2f \n"
463 " lui %1, 0x8000 \n"
464 " sc %1, %0 \n"
465 " beqz %1, 3f \n"
466 " li %2, 1 \n"
467 "2: \n"
468 __WEAK_LLSC_MB
469 " .subsection 2 \n"
470 "3: b 1b \n"
471 " li %2, 0 \n"
472 " .previous \n"
473 " .set reorder \n"
474 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
475 : "m" (rw->lock)
476 : "memory");
477 }
478
479 return ret;
480}
481
482
483#define _raw_spin_relax(lock) cpu_relax()
484#define _raw_read_relax(lock) cpu_relax()
485#define _raw_write_relax(lock) cpu_relax()
486
487#endif /* _ASM_SPINLOCK_H */
diff --git a/arch/mips/include/asm/spinlock_types.h b/arch/mips/include/asm/spinlock_types.h
new file mode 100644
index 000000000000..adeedaa116c1
--- /dev/null
+++ b/arch/mips/include/asm/spinlock_types.h
@@ -0,0 +1,25 @@
1#ifndef _ASM_SPINLOCK_TYPES_H
2#define _ASM_SPINLOCK_TYPES_H
3
4#ifndef __LINUX_SPINLOCK_TYPES_H
5# error "please don't include this file directly"
6#endif
7
8typedef struct {
9 /*
10 * bits 0..13: serving_now
11 * bits 14 : junk data
12 * bits 15..28: ticket
13 */
14 unsigned int lock;
15} raw_spinlock_t;
16
17#define __RAW_SPIN_LOCK_UNLOCKED { 0 }
18
19typedef struct {
20 volatile unsigned int lock;
21} raw_rwlock_t;
22
23#define __RAW_RW_LOCK_UNLOCKED { 0 }
24
25#endif
diff --git a/arch/mips/include/asm/stackframe.h b/arch/mips/include/asm/stackframe.h
new file mode 100644
index 000000000000..4c37c4e5f72e
--- /dev/null
+++ b/arch/mips/include/asm/stackframe.h
@@ -0,0 +1,574 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 99, 2001 Ralf Baechle
7 * Copyright (C) 1994, 1995, 1996 Paul M. Antoine.
8 * Copyright (C) 1999 Silicon Graphics, Inc.
9 * Copyright (C) 2007 Maciej W. Rozycki
10 */
11#ifndef _ASM_STACKFRAME_H
12#define _ASM_STACKFRAME_H
13
14#include <linux/threads.h>
15
16#include <asm/asm.h>
17#include <asm/asmmacro.h>
18#include <asm/mipsregs.h>
19#include <asm/asm-offsets.h>
20
21/*
22 * For SMTC kernel, global IE should be left set, and interrupts
23 * controlled exclusively via IXMT.
24 */
25#ifdef CONFIG_MIPS_MT_SMTC
26#define STATMASK 0x1e
27#elif defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
28#define STATMASK 0x3f
29#else
30#define STATMASK 0x1f
31#endif
32
33#ifdef CONFIG_MIPS_MT_SMTC
34#include <asm/mipsmtregs.h>
35#endif /* CONFIG_MIPS_MT_SMTC */
36
37 .macro SAVE_AT
38 .set push
39 .set noat
40 LONG_S $1, PT_R1(sp)
41 .set pop
42 .endm
43
44 .macro SAVE_TEMP
45#ifdef CONFIG_CPU_HAS_SMARTMIPS
46 mflhxu v1
47 LONG_S v1, PT_LO(sp)
48 mflhxu v1
49 LONG_S v1, PT_HI(sp)
50 mflhxu v1
51 LONG_S v1, PT_ACX(sp)
52#else
53 mfhi v1
54 LONG_S v1, PT_HI(sp)
55 mflo v1
56 LONG_S v1, PT_LO(sp)
57#endif
58#ifdef CONFIG_32BIT
59 LONG_S $8, PT_R8(sp)
60 LONG_S $9, PT_R9(sp)
61#endif
62 LONG_S $10, PT_R10(sp)
63 LONG_S $11, PT_R11(sp)
64 LONG_S $12, PT_R12(sp)
65 LONG_S $13, PT_R13(sp)
66 LONG_S $14, PT_R14(sp)
67 LONG_S $15, PT_R15(sp)
68 LONG_S $24, PT_R24(sp)
69 .endm
70
71 .macro SAVE_STATIC
72 LONG_S $16, PT_R16(sp)
73 LONG_S $17, PT_R17(sp)
74 LONG_S $18, PT_R18(sp)
75 LONG_S $19, PT_R19(sp)
76 LONG_S $20, PT_R20(sp)
77 LONG_S $21, PT_R21(sp)
78 LONG_S $22, PT_R22(sp)
79 LONG_S $23, PT_R23(sp)
80 LONG_S $30, PT_R30(sp)
81 .endm
82
83#ifdef CONFIG_SMP
84#ifdef CONFIG_MIPS_MT_SMTC
85#define PTEBASE_SHIFT 19 /* TCBIND */
86#else
87#define PTEBASE_SHIFT 23 /* CONTEXT */
88#endif
89 .macro get_saved_sp /* SMP variation */
90#ifdef CONFIG_MIPS_MT_SMTC
91 mfc0 k0, CP0_TCBIND
92#else
93 MFC0 k0, CP0_CONTEXT
94#endif
95#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
96 lui k1, %hi(kernelsp)
97#else
98 lui k1, %highest(kernelsp)
99 daddiu k1, %higher(kernelsp)
100 dsll k1, 16
101 daddiu k1, %hi(kernelsp)
102 dsll k1, 16
103#endif
104 LONG_SRL k0, PTEBASE_SHIFT
105 LONG_ADDU k1, k0
106 LONG_L k1, %lo(kernelsp)(k1)
107 .endm
108
109 .macro set_saved_sp stackp temp temp2
110#ifdef CONFIG_MIPS_MT_SMTC
111 mfc0 \temp, CP0_TCBIND
112#else
113 MFC0 \temp, CP0_CONTEXT
114#endif
115 LONG_SRL \temp, PTEBASE_SHIFT
116 LONG_S \stackp, kernelsp(\temp)
117 .endm
118#else
119 .macro get_saved_sp /* Uniprocessor variation */
120#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
121 lui k1, %hi(kernelsp)
122#else
123 lui k1, %highest(kernelsp)
124 daddiu k1, %higher(kernelsp)
125 dsll k1, k1, 16
126 daddiu k1, %hi(kernelsp)
127 dsll k1, k1, 16
128#endif
129 LONG_L k1, %lo(kernelsp)(k1)
130 .endm
131
132 .macro set_saved_sp stackp temp temp2
133 LONG_S \stackp, kernelsp
134 .endm
135#endif
136
137 .macro SAVE_SOME
138 .set push
139 .set noat
140 .set reorder
141 mfc0 k0, CP0_STATUS
142 sll k0, 3 /* extract cu0 bit */
143 .set noreorder
144 bltz k0, 8f
145 move k1, sp
146 .set reorder
147 /* Called from user mode, new stack. */
148 get_saved_sp
149#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
1508: move k0, sp
151 PTR_SUBU sp, k1, PT_SIZE
152#else
153 .set at=k0
1548: PTR_SUBU k1, PT_SIZE
155 .set noat
156 move k0, sp
157 move sp, k1
158#endif
159 LONG_S k0, PT_R29(sp)
160 LONG_S $3, PT_R3(sp)
161 /*
162 * You might think that you don't need to save $0,
163 * but the FPU emulator and gdb remote debug stub
164 * need it to operate correctly
165 */
166 LONG_S $0, PT_R0(sp)
167 mfc0 v1, CP0_STATUS
168 LONG_S $2, PT_R2(sp)
169 LONG_S v1, PT_STATUS(sp)
170#ifdef CONFIG_MIPS_MT_SMTC
171 /*
172 * Ideally, these instructions would be shuffled in
173 * to cover the pipeline delay.
174 */
175 .set mips32
176 mfc0 v1, CP0_TCSTATUS
177 .set mips0
178 LONG_S v1, PT_TCSTATUS(sp)
179#endif /* CONFIG_MIPS_MT_SMTC */
180 LONG_S $4, PT_R4(sp)
181 mfc0 v1, CP0_CAUSE
182 LONG_S $5, PT_R5(sp)
183 LONG_S v1, PT_CAUSE(sp)
184 LONG_S $6, PT_R6(sp)
185 MFC0 v1, CP0_EPC
186 LONG_S $7, PT_R7(sp)
187#ifdef CONFIG_64BIT
188 LONG_S $8, PT_R8(sp)
189 LONG_S $9, PT_R9(sp)
190#endif
191 LONG_S v1, PT_EPC(sp)
192 LONG_S $25, PT_R25(sp)
193 LONG_S $28, PT_R28(sp)
194 LONG_S $31, PT_R31(sp)
195 ori $28, sp, _THREAD_MASK
196 xori $28, _THREAD_MASK
197 .set pop
198 .endm
199
200 .macro SAVE_ALL
201 SAVE_SOME
202 SAVE_AT
203 SAVE_TEMP
204 SAVE_STATIC
205 .endm
206
207 .macro RESTORE_AT
208 .set push
209 .set noat
210 LONG_L $1, PT_R1(sp)
211 .set pop
212 .endm
213
214 .macro RESTORE_TEMP
215#ifdef CONFIG_CPU_HAS_SMARTMIPS
216 LONG_L $24, PT_ACX(sp)
217 mtlhx $24
218 LONG_L $24, PT_HI(sp)
219 mtlhx $24
220 LONG_L $24, PT_LO(sp)
221 mtlhx $24
222#else
223 LONG_L $24, PT_LO(sp)
224 mtlo $24
225 LONG_L $24, PT_HI(sp)
226 mthi $24
227#endif
228#ifdef CONFIG_32BIT
229 LONG_L $8, PT_R8(sp)
230 LONG_L $9, PT_R9(sp)
231#endif
232 LONG_L $10, PT_R10(sp)
233 LONG_L $11, PT_R11(sp)
234 LONG_L $12, PT_R12(sp)
235 LONG_L $13, PT_R13(sp)
236 LONG_L $14, PT_R14(sp)
237 LONG_L $15, PT_R15(sp)
238 LONG_L $24, PT_R24(sp)
239 .endm
240
241 .macro RESTORE_STATIC
242 LONG_L $16, PT_R16(sp)
243 LONG_L $17, PT_R17(sp)
244 LONG_L $18, PT_R18(sp)
245 LONG_L $19, PT_R19(sp)
246 LONG_L $20, PT_R20(sp)
247 LONG_L $21, PT_R21(sp)
248 LONG_L $22, PT_R22(sp)
249 LONG_L $23, PT_R23(sp)
250 LONG_L $30, PT_R30(sp)
251 .endm
252
253#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
254
255 .macro RESTORE_SOME
256 .set push
257 .set reorder
258 .set noat
259 mfc0 a0, CP0_STATUS
260 li v1, 0xff00
261 ori a0, STATMASK
262 xori a0, STATMASK
263 mtc0 a0, CP0_STATUS
264 and a0, v1
265 LONG_L v0, PT_STATUS(sp)
266 nor v1, $0, v1
267 and v0, v1
268 or v0, a0
269 mtc0 v0, CP0_STATUS
270 LONG_L $31, PT_R31(sp)
271 LONG_L $28, PT_R28(sp)
272 LONG_L $25, PT_R25(sp)
273 LONG_L $7, PT_R7(sp)
274 LONG_L $6, PT_R6(sp)
275 LONG_L $5, PT_R5(sp)
276 LONG_L $4, PT_R4(sp)
277 LONG_L $3, PT_R3(sp)
278 LONG_L $2, PT_R2(sp)
279 .set pop
280 .endm
281
282 .macro RESTORE_SP_AND_RET
283 .set push
284 .set noreorder
285 LONG_L k0, PT_EPC(sp)
286 LONG_L sp, PT_R29(sp)
287 jr k0
288 rfe
289 .set pop
290 .endm
291
292#else
293 .macro RESTORE_SOME
294 .set push
295 .set reorder
296 .set noat
297#ifdef CONFIG_MIPS_MT_SMTC
298 .set mips32r2
299 /*
300 * We need to make sure the read-modify-write
301 * of Status below isn't perturbed by an interrupt
302 * or cross-TC access, so we need to do at least a DMT,
303 * protected by an interrupt-inhibit. But setting IXMT
304 * also creates a few-cycle window where an IPI could
305 * be queued and not be detected before potentially
306 * returning to a WAIT or user-mode loop. It must be
307 * replayed.
308 *
309 * We're in the middle of a context switch, and
310 * we can't dispatch it directly without trashing
311 * some registers, so we'll try to detect this unlikely
312 * case and program a software interrupt in the VPE,
313 * as would be done for a cross-VPE IPI. To accomodate
314 * the handling of that case, we're doing a DVPE instead
315 * of just a DMT here to protect against other threads.
316 * This is a lot of cruft to cover a tiny window.
317 * If you can find a better design, implement it!
318 *
319 */
320 mfc0 v0, CP0_TCSTATUS
321 ori v0, TCSTATUS_IXMT
322 mtc0 v0, CP0_TCSTATUS
323 _ehb
324 DVPE 5 # dvpe a1
325 jal mips_ihb
326#endif /* CONFIG_MIPS_MT_SMTC */
327 mfc0 a0, CP0_STATUS
328 ori a0, STATMASK
329 xori a0, STATMASK
330 mtc0 a0, CP0_STATUS
331 li v1, 0xff00
332 and a0, v1
333 LONG_L v0, PT_STATUS(sp)
334 nor v1, $0, v1
335 and v0, v1
336 or v0, a0
337 mtc0 v0, CP0_STATUS
338#ifdef CONFIG_MIPS_MT_SMTC
339/*
340 * Only after EXL/ERL have been restored to status can we
341 * restore TCStatus.IXMT.
342 */
343 LONG_L v1, PT_TCSTATUS(sp)
344 _ehb
345 mfc0 a0, CP0_TCSTATUS
346 andi v1, TCSTATUS_IXMT
347 bnez v1, 0f
348
349/*
350 * We'd like to detect any IPIs queued in the tiny window
351 * above and request an software interrupt to service them
352 * when we ERET.
353 *
354 * Computing the offset into the IPIQ array of the executing
355 * TC's IPI queue in-line would be tedious. We use part of
356 * the TCContext register to hold 16 bits of offset that we
357 * can add in-line to find the queue head.
358 */
359 mfc0 v0, CP0_TCCONTEXT
360 la a2, IPIQ
361 srl v0, v0, 16
362 addu a2, a2, v0
363 LONG_L v0, 0(a2)
364 beqz v0, 0f
365/*
366 * If we have a queue, provoke dispatch within the VPE by setting C_SW1
367 */
368 mfc0 v0, CP0_CAUSE
369 ori v0, v0, C_SW1
370 mtc0 v0, CP0_CAUSE
3710:
372 /*
373 * This test should really never branch but
374 * let's be prudent here. Having atomized
375 * the shared register modifications, we can
376 * now EVPE, and must do so before interrupts
377 * are potentially re-enabled.
378 */
379 andi a1, a1, MVPCONTROL_EVP
380 beqz a1, 1f
381 evpe
3821:
383 /* We know that TCStatua.IXMT should be set from above */
384 xori a0, a0, TCSTATUS_IXMT
385 or a0, a0, v1
386 mtc0 a0, CP0_TCSTATUS
387 _ehb
388
389 .set mips0
390#endif /* CONFIG_MIPS_MT_SMTC */
391 LONG_L v1, PT_EPC(sp)
392 MTC0 v1, CP0_EPC
393 LONG_L $31, PT_R31(sp)
394 LONG_L $28, PT_R28(sp)
395 LONG_L $25, PT_R25(sp)
396#ifdef CONFIG_64BIT
397 LONG_L $8, PT_R8(sp)
398 LONG_L $9, PT_R9(sp)
399#endif
400 LONG_L $7, PT_R7(sp)
401 LONG_L $6, PT_R6(sp)
402 LONG_L $5, PT_R5(sp)
403 LONG_L $4, PT_R4(sp)
404 LONG_L $3, PT_R3(sp)
405 LONG_L $2, PT_R2(sp)
406 .set pop
407 .endm
408
409 .macro RESTORE_SP_AND_RET
410 LONG_L sp, PT_R29(sp)
411 .set mips3
412 eret
413 .set mips0
414 .endm
415
416#endif
417
418 .macro RESTORE_SP
419 LONG_L sp, PT_R29(sp)
420 .endm
421
422 .macro RESTORE_ALL
423 RESTORE_TEMP
424 RESTORE_STATIC
425 RESTORE_AT
426 RESTORE_SOME
427 RESTORE_SP
428 .endm
429
430 .macro RESTORE_ALL_AND_RET
431 RESTORE_TEMP
432 RESTORE_STATIC
433 RESTORE_AT
434 RESTORE_SOME
435 RESTORE_SP_AND_RET
436 .endm
437
438/*
439 * Move to kernel mode and disable interrupts.
440 * Set cp0 enable bit as sign that we're running on the kernel stack
441 */
442 .macro CLI
443#if !defined(CONFIG_MIPS_MT_SMTC)
444 mfc0 t0, CP0_STATUS
445 li t1, ST0_CU0 | STATMASK
446 or t0, t1
447 xori t0, STATMASK
448 mtc0 t0, CP0_STATUS
449#else /* CONFIG_MIPS_MT_SMTC */
450 /*
451 * For SMTC, we need to set privilege
452 * and disable interrupts only for the
453 * current TC, using the TCStatus register.
454 */
455 mfc0 t0, CP0_TCSTATUS
456 /* Fortunately CU 0 is in the same place in both registers */
457 /* Set TCU0, TMX, TKSU (for later inversion) and IXMT */
458 li t1, ST0_CU0 | 0x08001c00
459 or t0, t1
460 /* Clear TKSU, leave IXMT */
461 xori t0, 0x00001800
462 mtc0 t0, CP0_TCSTATUS
463 _ehb
464 /* We need to leave the global IE bit set, but clear EXL...*/
465 mfc0 t0, CP0_STATUS
466 ori t0, ST0_EXL | ST0_ERL
467 xori t0, ST0_EXL | ST0_ERL
468 mtc0 t0, CP0_STATUS
469#endif /* CONFIG_MIPS_MT_SMTC */
470 irq_disable_hazard
471 .endm
472
473/*
474 * Move to kernel mode and enable interrupts.
475 * Set cp0 enable bit as sign that we're running on the kernel stack
476 */
477 .macro STI
478#if !defined(CONFIG_MIPS_MT_SMTC)
479 mfc0 t0, CP0_STATUS
480 li t1, ST0_CU0 | STATMASK
481 or t0, t1
482 xori t0, STATMASK & ~1
483 mtc0 t0, CP0_STATUS
484#else /* CONFIG_MIPS_MT_SMTC */
485 /*
486 * For SMTC, we need to set privilege
487 * and enable interrupts only for the
488 * current TC, using the TCStatus register.
489 */
490 _ehb
491 mfc0 t0, CP0_TCSTATUS
492 /* Fortunately CU 0 is in the same place in both registers */
493 /* Set TCU0, TKSU (for later inversion) and IXMT */
494 li t1, ST0_CU0 | 0x08001c00
495 or t0, t1
496 /* Clear TKSU *and* IXMT */
497 xori t0, 0x00001c00
498 mtc0 t0, CP0_TCSTATUS
499 _ehb
500 /* We need to leave the global IE bit set, but clear EXL...*/
501 mfc0 t0, CP0_STATUS
502 ori t0, ST0_EXL
503 xori t0, ST0_EXL
504 mtc0 t0, CP0_STATUS
505 /* irq_enable_hazard below should expand to EHB for 24K/34K cpus */
506#endif /* CONFIG_MIPS_MT_SMTC */
507 irq_enable_hazard
508 .endm
509
510/*
511 * Just move to kernel mode and leave interrupts as they are. Note
512 * for the R3000 this means copying the previous enable from IEp.
513 * Set cp0 enable bit as sign that we're running on the kernel stack
514 */
515 .macro KMODE
516#ifdef CONFIG_MIPS_MT_SMTC
517 /*
518 * This gets baroque in SMTC. We want to
519 * protect the non-atomic clearing of EXL
520 * with DMT/EMT, but we don't want to take
521 * an interrupt while DMT is still in effect.
522 */
523
524 /* KMODE gets invoked from both reorder and noreorder code */
525 .set push
526 .set mips32r2
527 .set noreorder
528 mfc0 v0, CP0_TCSTATUS
529 andi v1, v0, TCSTATUS_IXMT
530 ori v0, TCSTATUS_IXMT
531 mtc0 v0, CP0_TCSTATUS
532 _ehb
533 DMT 2 # dmt v0
534 /*
535 * We don't know a priori if ra is "live"
536 */
537 move t0, ra
538 jal mips_ihb
539 nop /* delay slot */
540 move ra, t0
541#endif /* CONFIG_MIPS_MT_SMTC */
542 mfc0 t0, CP0_STATUS
543 li t1, ST0_CU0 | (STATMASK & ~1)
544#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
545 andi t2, t0, ST0_IEP
546 srl t2, 2
547 or t0, t2
548#endif
549 or t0, t1
550 xori t0, STATMASK & ~1
551 mtc0 t0, CP0_STATUS
552#ifdef CONFIG_MIPS_MT_SMTC
553 _ehb
554 andi v0, v0, VPECONTROL_TE
555 beqz v0, 2f
556 nop /* delay slot */
557 emt
5582:
559 mfc0 v0, CP0_TCSTATUS
560 /* Clear IXMT, then OR in previous value */
561 ori v0, TCSTATUS_IXMT
562 xori v0, TCSTATUS_IXMT
563 or v0, v1, v0
564 mtc0 v0, CP0_TCSTATUS
565 /*
566 * irq_disable_hazard below should expand to EHB
567 * on 24K/34K CPUS
568 */
569 .set pop
570#endif /* CONFIG_MIPS_MT_SMTC */
571 irq_disable_hazard
572 .endm
573
574#endif /* _ASM_STACKFRAME_H */
diff --git a/arch/mips/include/asm/stacktrace.h b/arch/mips/include/asm/stacktrace.h
new file mode 100644
index 000000000000..0bf82818aa53
--- /dev/null
+++ b/arch/mips/include/asm/stacktrace.h
@@ -0,0 +1,48 @@
1#ifndef _ASM_STACKTRACE_H
2#define _ASM_STACKTRACE_H
3
4#include <asm/ptrace.h>
5
6#ifdef CONFIG_KALLSYMS
7extern int raw_show_trace;
8extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
9 unsigned long pc, unsigned long *ra);
10#else
11#define raw_show_trace 1
12static inline unsigned long unwind_stack(struct task_struct *task,
13 unsigned long *sp, unsigned long pc, unsigned long *ra)
14{
15 return 0;
16}
17#endif
18
19static __always_inline void prepare_frametrace(struct pt_regs *regs)
20{
21#ifndef CONFIG_KALLSYMS
22 /*
23 * Remove any garbage that may be in regs (specially func
24 * addresses) to avoid show_raw_backtrace() to report them
25 */
26 memset(regs, 0, sizeof(*regs));
27#endif
28 __asm__ __volatile__(
29 ".set push\n\t"
30 ".set noat\n\t"
31#ifdef CONFIG_64BIT
32 "1: dla $1, 1b\n\t"
33 "sd $1, %0\n\t"
34 "sd $29, %1\n\t"
35 "sd $31, %2\n\t"
36#else
37 "1: la $1, 1b\n\t"
38 "sw $1, %0\n\t"
39 "sw $29, %1\n\t"
40 "sw $31, %2\n\t"
41#endif
42 ".set pop\n\t"
43 : "=m" (regs->cp0_epc),
44 "=m" (regs->regs[29]), "=m" (regs->regs[31])
45 : : "memory");
46}
47
48#endif /* _ASM_STACKTRACE_H */
diff --git a/arch/mips/include/asm/stat.h b/arch/mips/include/asm/stat.h
new file mode 100644
index 000000000000..6e00f751ab6d
--- /dev/null
+++ b/arch/mips/include/asm/stat.h
@@ -0,0 +1,132 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1999, 2000 Ralf Baechle
7 * Copyright (C) 2000 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_STAT_H
10#define _ASM_STAT_H
11
12#include <linux/types.h>
13
14#include <asm/sgidefs.h>
15
16#if (_MIPS_SIM == _MIPS_SIM_ABI32) || (_MIPS_SIM == _MIPS_SIM_NABI32)
17
18struct stat {
19 unsigned st_dev;
20 long st_pad1[3]; /* Reserved for network id */
21 ino_t st_ino;
22 mode_t st_mode;
23 nlink_t st_nlink;
24 uid_t st_uid;
25 gid_t st_gid;
26 unsigned st_rdev;
27 long st_pad2[2];
28 off_t st_size;
29 long st_pad3;
30 /*
31 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
32 * but we don't have it under Linux.
33 */
34 time_t st_atime;
35 long st_atime_nsec;
36 time_t st_mtime;
37 long st_mtime_nsec;
38 time_t st_ctime;
39 long st_ctime_nsec;
40 long st_blksize;
41 long st_blocks;
42 long st_pad4[14];
43};
44
45/*
46 * This matches struct stat64 in glibc2.1, hence the absolutely insane
47 * amounts of padding around dev_t's. The memory layout is the same as of
48 * struct stat of the 64-bit kernel.
49 */
50
51struct stat64 {
52 unsigned long st_dev;
53 unsigned long st_pad0[3]; /* Reserved for st_dev expansion */
54
55 unsigned long long st_ino;
56
57 mode_t st_mode;
58 nlink_t st_nlink;
59
60 uid_t st_uid;
61 gid_t st_gid;
62
63 unsigned long st_rdev;
64 unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
65
66 long long st_size;
67
68 /*
69 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
70 * but we don't have it under Linux.
71 */
72 time_t st_atime;
73 unsigned long st_atime_nsec; /* Reserved for st_atime expansion */
74
75 time_t st_mtime;
76 unsigned long st_mtime_nsec; /* Reserved for st_mtime expansion */
77
78 time_t st_ctime;
79 unsigned long st_ctime_nsec; /* Reserved for st_ctime expansion */
80
81 unsigned long st_blksize;
82 unsigned long st_pad2;
83
84 long long st_blocks;
85};
86
87#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
88
89#if _MIPS_SIM == _MIPS_SIM_ABI64
90
91/* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
92struct stat {
93 unsigned int st_dev;
94 unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
95
96 unsigned long st_ino;
97
98 mode_t st_mode;
99 nlink_t st_nlink;
100
101 uid_t st_uid;
102 gid_t st_gid;
103
104 unsigned int st_rdev;
105 unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
106
107 off_t st_size;
108
109 /*
110 * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
111 * but we don't have it under Linux.
112 */
113 unsigned int st_atime;
114 unsigned int st_atime_nsec;
115
116 unsigned int st_mtime;
117 unsigned int st_mtime_nsec;
118
119 unsigned int st_ctime;
120 unsigned int st_ctime_nsec;
121
122 unsigned int st_blksize;
123 unsigned int st_pad2;
124
125 unsigned long st_blocks;
126};
127
128#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
129
130#define STAT_HAVE_NSEC 1
131
132#endif /* _ASM_STAT_H */
diff --git a/arch/mips/include/asm/statfs.h b/arch/mips/include/asm/statfs.h
new file mode 100644
index 000000000000..c3ddf973c1c0
--- /dev/null
+++ b/arch/mips/include/asm/statfs.h
@@ -0,0 +1,96 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1999 by Ralf Baechle
7 */
8#ifndef _ASM_STATFS_H
9#define _ASM_STATFS_H
10
11#include <linux/posix_types.h>
12#include <asm/sgidefs.h>
13
14#ifndef __KERNEL_STRICT_NAMES
15
16#include <linux/types.h>
17
18typedef __kernel_fsid_t fsid_t;
19
20#endif
21
22struct statfs {
23 long f_type;
24#define f_fstyp f_type
25 long f_bsize;
26 long f_frsize; /* Fragment size - unsupported */
27 long f_blocks;
28 long f_bfree;
29 long f_files;
30 long f_ffree;
31 long f_bavail;
32
33 /* Linux specials */
34 __kernel_fsid_t f_fsid;
35 long f_namelen;
36 long f_spare[6];
37};
38
39#if (_MIPS_SIM == _MIPS_SIM_ABI32) || (_MIPS_SIM == _MIPS_SIM_NABI32)
40
41/*
42 * Unlike the traditional version the LFAPI version has none of the ABI junk
43 */
44struct statfs64 {
45 __u32 f_type;
46 __u32 f_bsize;
47 __u32 f_frsize; /* Fragment size - unsupported */
48 __u32 __pad;
49 __u64 f_blocks;
50 __u64 f_bfree;
51 __u64 f_files;
52 __u64 f_ffree;
53 __u64 f_bavail;
54 __kernel_fsid_t f_fsid;
55 __u32 f_namelen;
56 __u32 f_spare[6];
57};
58
59#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
60
61#if _MIPS_SIM == _MIPS_SIM_ABI64
62
63struct statfs64 { /* Same as struct statfs */
64 long f_type;
65 long f_bsize;
66 long f_frsize; /* Fragment size - unsupported */
67 long f_blocks;
68 long f_bfree;
69 long f_files;
70 long f_ffree;
71 long f_bavail;
72
73 /* Linux specials */
74 __kernel_fsid_t f_fsid;
75 long f_namelen;
76 long f_spare[6];
77};
78
79struct compat_statfs64 {
80 __u32 f_type;
81 __u32 f_bsize;
82 __u32 f_frsize; /* Fragment size - unsupported */
83 __u32 __pad;
84 __u64 f_blocks;
85 __u64 f_bfree;
86 __u64 f_files;
87 __u64 f_ffree;
88 __u64 f_bavail;
89 __kernel_fsid_t f_fsid;
90 __u32 f_namelen;
91 __u32 f_spare[6];
92};
93
94#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
95
96#endif /* _ASM_STATFS_H */
diff --git a/arch/mips/include/asm/string.h b/arch/mips/include/asm/string.h
new file mode 100644
index 000000000000..436e3ad352d9
--- /dev/null
+++ b/arch/mips/include/asm/string.h
@@ -0,0 +1,143 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 1994, 95, 96, 97, 98, 2000, 01 Ralf Baechle
7 * Copyright (c) 2000 by Silicon Graphics, Inc.
8 * Copyright (c) 2001 MIPS Technologies, Inc.
9 */
10#ifndef _ASM_STRING_H
11#define _ASM_STRING_H
12
13
14/*
15 * Most of the inline functions are rather naive implementations so I just
16 * didn't bother updating them for 64-bit ...
17 */
18#ifdef CONFIG_32BIT
19
20#ifndef IN_STRING_C
21
22#define __HAVE_ARCH_STRCPY
23static __inline__ char *strcpy(char *__dest, __const__ char *__src)
24{
25 char *__xdest = __dest;
26
27 __asm__ __volatile__(
28 ".set\tnoreorder\n\t"
29 ".set\tnoat\n"
30 "1:\tlbu\t$1,(%1)\n\t"
31 "addiu\t%1,1\n\t"
32 "sb\t$1,(%0)\n\t"
33 "bnez\t$1,1b\n\t"
34 "addiu\t%0,1\n\t"
35 ".set\tat\n\t"
36 ".set\treorder"
37 : "=r" (__dest), "=r" (__src)
38 : "0" (__dest), "1" (__src)
39 : "memory");
40
41 return __xdest;
42}
43
44#define __HAVE_ARCH_STRNCPY
45static __inline__ char *strncpy(char *__dest, __const__ char *__src, size_t __n)
46{
47 char *__xdest = __dest;
48
49 if (__n == 0)
50 return __xdest;
51
52 __asm__ __volatile__(
53 ".set\tnoreorder\n\t"
54 ".set\tnoat\n"
55 "1:\tlbu\t$1,(%1)\n\t"
56 "subu\t%2,1\n\t"
57 "sb\t$1,(%0)\n\t"
58 "beqz\t$1,2f\n\t"
59 "addiu\t%0,1\n\t"
60 "bnez\t%2,1b\n\t"
61 "addiu\t%1,1\n"
62 "2:\n\t"
63 ".set\tat\n\t"
64 ".set\treorder"
65 : "=r" (__dest), "=r" (__src), "=r" (__n)
66 : "0" (__dest), "1" (__src), "2" (__n)
67 : "memory");
68
69 return __xdest;
70}
71
72#define __HAVE_ARCH_STRCMP
73static __inline__ int strcmp(__const__ char *__cs, __const__ char *__ct)
74{
75 int __res;
76
77 __asm__ __volatile__(
78 ".set\tnoreorder\n\t"
79 ".set\tnoat\n\t"
80 "lbu\t%2,(%0)\n"
81 "1:\tlbu\t$1,(%1)\n\t"
82 "addiu\t%0,1\n\t"
83 "bne\t$1,%2,2f\n\t"
84 "addiu\t%1,1\n\t"
85 "bnez\t%2,1b\n\t"
86 "lbu\t%2,(%0)\n\t"
87#if defined(CONFIG_CPU_R3000)
88 "nop\n\t"
89#endif
90 "move\t%2,$1\n"
91 "2:\tsubu\t%2,$1\n"
92 "3:\t.set\tat\n\t"
93 ".set\treorder"
94 : "=r" (__cs), "=r" (__ct), "=r" (__res)
95 : "0" (__cs), "1" (__ct));
96
97 return __res;
98}
99
100#endif /* !defined(IN_STRING_C) */
101
102#define __HAVE_ARCH_STRNCMP
103static __inline__ int
104strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count)
105{
106 int __res;
107
108 __asm__ __volatile__(
109 ".set\tnoreorder\n\t"
110 ".set\tnoat\n"
111 "1:\tlbu\t%3,(%0)\n\t"
112 "beqz\t%2,2f\n\t"
113 "lbu\t$1,(%1)\n\t"
114 "subu\t%2,1\n\t"
115 "bne\t$1,%3,3f\n\t"
116 "addiu\t%0,1\n\t"
117 "bnez\t%3,1b\n\t"
118 "addiu\t%1,1\n"
119 "2:\n\t"
120#if defined(CONFIG_CPU_R3000)
121 "nop\n\t"
122#endif
123 "move\t%3,$1\n"
124 "3:\tsubu\t%3,$1\n\t"
125 ".set\tat\n\t"
126 ".set\treorder"
127 : "=r" (__cs), "=r" (__ct), "=r" (__count), "=r" (__res)
128 : "0" (__cs), "1" (__ct), "2" (__count));
129
130 return __res;
131}
132#endif /* CONFIG_32BIT */
133
134#define __HAVE_ARCH_MEMSET
135extern void *memset(void *__s, int __c, size_t __count);
136
137#define __HAVE_ARCH_MEMCPY
138extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
139
140#define __HAVE_ARCH_MEMMOVE
141extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
142
143#endif /* _ASM_STRING_H */
diff --git a/arch/mips/include/asm/suspend.h b/arch/mips/include/asm/suspend.h
new file mode 100644
index 000000000000..2562f8f9be0e
--- /dev/null
+++ b/arch/mips/include/asm/suspend.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_SUSPEND_H
2#define __ASM_SUSPEND_H
3
4/* Somewhen... Maybe :-) */
5
6#endif /* __ASM_SUSPEND_H */
diff --git a/arch/mips/include/asm/sysmips.h b/arch/mips/include/asm/sysmips.h
new file mode 100644
index 000000000000..4f47b7d6a5f7
--- /dev/null
+++ b/arch/mips/include/asm/sysmips.h
@@ -0,0 +1,25 @@
1/*
2 * Definitions for the MIPS sysmips(2) call
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1995 by Ralf Baechle
9 */
10#ifndef _ASM_SYSMIPS_H
11#define _ASM_SYSMIPS_H
12
13/*
14 * Commands for the sysmips(2) call
15 *
16 * sysmips(2) is deprecated - though some existing software uses it.
17 * We only support the following commands.
18 */
19#define SETNAME 1 /* set hostname */
20#define FLUSH_CACHE 3 /* writeback and invalidate caches */
21#define MIPS_FIXADE 7 /* control address error fixing */
22#define MIPS_RDNVRAM 10 /* read NVRAM */
23#define MIPS_ATOMIC_SET 2001 /* atomically set variable */
24
25#endif /* _ASM_SYSMIPS_H */
diff --git a/arch/mips/include/asm/system.h b/arch/mips/include/asm/system.h
new file mode 100644
index 000000000000..cd30f83235bb
--- /dev/null
+++ b/arch/mips/include/asm/system.h
@@ -0,0 +1,222 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003, 06 by Ralf Baechle
7 * Copyright (C) 1996 by Paul M. Antoine
8 * Copyright (C) 1999 Silicon Graphics
9 * Kevin D. Kissell, kevink@mips.org and Carsten Langgaard, carstenl@mips.com
10 * Copyright (C) 2000 MIPS Technologies, Inc.
11 */
12#ifndef _ASM_SYSTEM_H
13#define _ASM_SYSTEM_H
14
15#include <linux/types.h>
16#include <linux/irqflags.h>
17
18#include <asm/addrspace.h>
19#include <asm/barrier.h>
20#include <asm/cmpxchg.h>
21#include <asm/cpu-features.h>
22#include <asm/dsp.h>
23#include <asm/watch.h>
24#include <asm/war.h>
25
26
27/*
28 * switch_to(n) should switch tasks to task nr n, first
29 * checking that n isn't the current task, in which case it does nothing.
30 */
31extern asmlinkage void *resume(void *last, void *next, void *next_ti);
32
33struct task_struct;
34
35#ifdef CONFIG_MIPS_MT_FPAFF
36
37/*
38 * Handle the scheduler resume end of FPU affinity management. We do this
39 * inline to try to keep the overhead down. If we have been forced to run on
40 * a "CPU" with an FPU because of a previous high level of FP computation,
41 * but did not actually use the FPU during the most recent time-slice (CU1
42 * isn't set), we undo the restriction on cpus_allowed.
43 *
44 * We're not calling set_cpus_allowed() here, because we have no need to
45 * force prompt migration - we're already switching the current CPU to a
46 * different thread.
47 */
48
49#define __mips_mt_fpaff_switch_to(prev) \
50do { \
51 struct thread_info *__prev_ti = task_thread_info(prev); \
52 \
53 if (cpu_has_fpu && \
54 test_ti_thread_flag(__prev_ti, TIF_FPUBOUND) && \
55 (!(KSTK_STATUS(prev) & ST0_CU1))) { \
56 clear_ti_thread_flag(__prev_ti, TIF_FPUBOUND); \
57 prev->cpus_allowed = prev->thread.user_cpus_allowed; \
58 } \
59 next->thread.emulated_fp = 0; \
60} while(0)
61
62#else
63#define __mips_mt_fpaff_switch_to(prev) do { (void) (prev); } while (0)
64#endif
65
66#define switch_to(prev, next, last) \
67do { \
68 __mips_mt_fpaff_switch_to(prev); \
69 if (cpu_has_dsp) \
70 __save_dsp(prev); \
71 (last) = resume(prev, next, task_thread_info(next)); \
72} while (0)
73
74#define finish_arch_switch(prev) \
75do { \
76 if (cpu_has_dsp) \
77 __restore_dsp(current); \
78 if (cpu_has_userlocal) \
79 write_c0_userlocal(current_thread_info()->tp_value); \
80 __restore_watch(); \
81} while (0)
82
83static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
84{
85 __u32 retval;
86
87 if (cpu_has_llsc && R10000_LLSC_WAR) {
88 unsigned long dummy;
89
90 __asm__ __volatile__(
91 " .set mips3 \n"
92 "1: ll %0, %3 # xchg_u32 \n"
93 " .set mips0 \n"
94 " move %2, %z4 \n"
95 " .set mips3 \n"
96 " sc %2, %1 \n"
97 " beqzl %2, 1b \n"
98 " .set mips0 \n"
99 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
100 : "R" (*m), "Jr" (val)
101 : "memory");
102 } else if (cpu_has_llsc) {
103 unsigned long dummy;
104
105 __asm__ __volatile__(
106 " .set mips3 \n"
107 "1: ll %0, %3 # xchg_u32 \n"
108 " .set mips0 \n"
109 " move %2, %z4 \n"
110 " .set mips3 \n"
111 " sc %2, %1 \n"
112 " beqz %2, 2f \n"
113 " .subsection 2 \n"
114 "2: b 1b \n"
115 " .previous \n"
116 " .set mips0 \n"
117 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
118 : "R" (*m), "Jr" (val)
119 : "memory");
120 } else {
121 unsigned long flags;
122
123 raw_local_irq_save(flags);
124 retval = *m;
125 *m = val;
126 raw_local_irq_restore(flags); /* implies memory barrier */
127 }
128
129 smp_llsc_mb();
130
131 return retval;
132}
133
134#ifdef CONFIG_64BIT
135static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
136{
137 __u64 retval;
138
139 if (cpu_has_llsc && R10000_LLSC_WAR) {
140 unsigned long dummy;
141
142 __asm__ __volatile__(
143 " .set mips3 \n"
144 "1: lld %0, %3 # xchg_u64 \n"
145 " move %2, %z4 \n"
146 " scd %2, %1 \n"
147 " beqzl %2, 1b \n"
148 " .set mips0 \n"
149 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
150 : "R" (*m), "Jr" (val)
151 : "memory");
152 } else if (cpu_has_llsc) {
153 unsigned long dummy;
154
155 __asm__ __volatile__(
156 " .set mips3 \n"
157 "1: lld %0, %3 # xchg_u64 \n"
158 " move %2, %z4 \n"
159 " scd %2, %1 \n"
160 " beqz %2, 2f \n"
161 " .subsection 2 \n"
162 "2: b 1b \n"
163 " .previous \n"
164 " .set mips0 \n"
165 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
166 : "R" (*m), "Jr" (val)
167 : "memory");
168 } else {
169 unsigned long flags;
170
171 raw_local_irq_save(flags);
172 retval = *m;
173 *m = val;
174 raw_local_irq_restore(flags); /* implies memory barrier */
175 }
176
177 smp_llsc_mb();
178
179 return retval;
180}
181#else
182extern __u64 __xchg_u64_unsupported_on_32bit_kernels(volatile __u64 * m, __u64 val);
183#define __xchg_u64 __xchg_u64_unsupported_on_32bit_kernels
184#endif
185
186/* This function doesn't exist, so you'll get a linker error
187 if something tries to do an invalid xchg(). */
188extern void __xchg_called_with_bad_pointer(void);
189
190static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
191{
192 switch (size) {
193 case 4:
194 return __xchg_u32(ptr, x);
195 case 8:
196 return __xchg_u64(ptr, x);
197 }
198 __xchg_called_with_bad_pointer();
199 return x;
200}
201
202#define xchg(ptr, x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
203
204extern void set_handler(unsigned long offset, void *addr, unsigned long len);
205extern void set_uncached_handler(unsigned long offset, void *addr, unsigned long len);
206
207typedef void (*vi_handler_t)(void);
208extern void *set_vi_handler(int n, vi_handler_t addr);
209
210extern void *set_except_vector(int n, void *addr);
211extern unsigned long ebase;
212extern void per_cpu_trap_init(void);
213
214/*
215 * See include/asm-ia64/system.h; prevents deadlock on SMP
216 * systems.
217 */
218#define __ARCH_WANT_UNLOCKED_CTXSW
219
220extern unsigned long arch_align_stack(unsigned long sp);
221
222#endif /* _ASM_SYSTEM_H */
diff --git a/arch/mips/include/asm/termbits.h b/arch/mips/include/asm/termbits.h
new file mode 100644
index 000000000000..c83c68444e86
--- /dev/null
+++ b/arch/mips/include/asm/termbits.h
@@ -0,0 +1,226 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 96, 99, 2001, 06 Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
9 */
10#ifndef _ASM_TERMBITS_H
11#define _ASM_TERMBITS_H
12
13#include <linux/posix_types.h>
14
15typedef unsigned char cc_t;
16typedef unsigned int speed_t;
17typedef unsigned int tcflag_t;
18
19/*
20 * The ABI says nothing about NCC but seems to use NCCS as
21 * replacement for it in struct termio
22 */
23#define NCCS 23
24struct termios {
25 tcflag_t c_iflag; /* input mode flags */
26 tcflag_t c_oflag; /* output mode flags */
27 tcflag_t c_cflag; /* control mode flags */
28 tcflag_t c_lflag; /* local mode flags */
29 cc_t c_line; /* line discipline */
30 cc_t c_cc[NCCS]; /* control characters */
31};
32
33struct termios2 {
34 tcflag_t c_iflag; /* input mode flags */
35 tcflag_t c_oflag; /* output mode flags */
36 tcflag_t c_cflag; /* control mode flags */
37 tcflag_t c_lflag; /* local mode flags */
38 cc_t c_line; /* line discipline */
39 cc_t c_cc[NCCS]; /* control characters */
40 speed_t c_ispeed; /* input speed */
41 speed_t c_ospeed; /* output speed */
42};
43
44struct ktermios {
45 tcflag_t c_iflag; /* input mode flags */
46 tcflag_t c_oflag; /* output mode flags */
47 tcflag_t c_cflag; /* control mode flags */
48 tcflag_t c_lflag; /* local mode flags */
49 cc_t c_line; /* line discipline */
50 cc_t c_cc[NCCS]; /* control characters */
51 speed_t c_ispeed; /* input speed */
52 speed_t c_ospeed; /* output speed */
53};
54
55/* c_cc characters */
56#define VINTR 0 /* Interrupt character [ISIG]. */
57#define VQUIT 1 /* Quit character [ISIG]. */
58#define VERASE 2 /* Erase character [ICANON]. */
59#define VKILL 3 /* Kill-line character [ICANON]. */
60#define VMIN 4 /* Minimum number of bytes read at once [!ICANON]. */
61#define VTIME 5 /* Time-out value (tenths of a second) [!ICANON]. */
62#define VEOL2 6 /* Second EOL character [ICANON]. */
63#define VSWTC 7 /* ??? */
64#define VSWTCH VSWTC
65#define VSTART 8 /* Start (X-ON) character [IXON, IXOFF]. */
66#define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF]. */
67#define VSUSP 10 /* Suspend character [ISIG]. */
68#if 0
69/*
70 * VDSUSP is not supported
71 */
72#define VDSUSP 11 /* Delayed suspend character [ISIG]. */
73#endif
74#define VREPRINT 12 /* Reprint-line character [ICANON]. */
75#define VDISCARD 13 /* Discard character [IEXTEN]. */
76#define VWERASE 14 /* Word-erase character [ICANON]. */
77#define VLNEXT 15 /* Literal-next character [IEXTEN]. */
78#define VEOF 16 /* End-of-file character [ICANON]. */
79#define VEOL 17 /* End-of-line character [ICANON]. */
80
81/* c_iflag bits */
82#define IGNBRK 0000001 /* Ignore break condition. */
83#define BRKINT 0000002 /* Signal interrupt on break. */
84#define IGNPAR 0000004 /* Ignore characters with parity errors. */
85#define PARMRK 0000010 /* Mark parity and framing errors. */
86#define INPCK 0000020 /* Enable input parity check. */
87#define ISTRIP 0000040 /* Strip 8th bit off characters. */
88#define INLCR 0000100 /* Map NL to CR on input. */
89#define IGNCR 0000200 /* Ignore CR. */
90#define ICRNL 0000400 /* Map CR to NL on input. */
91#define IUCLC 0001000 /* Map upper case to lower case on input. */
92#define IXON 0002000 /* Enable start/stop output control. */
93#define IXANY 0004000 /* Any character will restart after stop. */
94#define IXOFF 0010000 /* Enable start/stop input control. */
95#define IMAXBEL 0020000 /* Ring bell when input queue is full. */
96#define IUTF8 0040000 /* Input is UTF-8 */
97
98/* c_oflag bits */
99#define OPOST 0000001 /* Perform output processing. */
100#define OLCUC 0000002 /* Map lower case to upper case on output. */
101#define ONLCR 0000004 /* Map NL to CR-NL on output. */
102#define OCRNL 0000010
103#define ONOCR 0000020
104#define ONLRET 0000040
105#define OFILL 0000100
106#define OFDEL 0000200
107#define NLDLY 0000400
108#define NL0 0000000
109#define NL1 0000400
110#define CRDLY 0003000
111#define CR0 0000000
112#define CR1 0001000
113#define CR2 0002000
114#define CR3 0003000
115#define TABDLY 0014000
116#define TAB0 0000000
117#define TAB1 0004000
118#define TAB2 0010000
119#define TAB3 0014000
120#define XTABS 0014000
121#define BSDLY 0020000
122#define BS0 0000000
123#define BS1 0020000
124#define VTDLY 0040000
125#define VT0 0000000
126#define VT1 0040000
127#define FFDLY 0100000
128#define FF0 0000000
129#define FF1 0100000
130/*
131#define PAGEOUT ???
132#define WRAP ???
133 */
134
135/* c_cflag bit meaning */
136#define CBAUD 0010017
137#define B0 0000000 /* hang up */
138#define B50 0000001
139#define B75 0000002
140#define B110 0000003
141#define B134 0000004
142#define B150 0000005
143#define B200 0000006
144#define B300 0000007
145#define B600 0000010
146#define B1200 0000011
147#define B1800 0000012
148#define B2400 0000013
149#define B4800 0000014
150#define B9600 0000015
151#define B19200 0000016
152#define B38400 0000017
153#define EXTA B19200
154#define EXTB B38400
155#define CSIZE 0000060 /* Number of bits per byte (mask). */
156#define CS5 0000000 /* 5 bits per byte. */
157#define CS6 0000020 /* 6 bits per byte. */
158#define CS7 0000040 /* 7 bits per byte. */
159#define CS8 0000060 /* 8 bits per byte. */
160#define CSTOPB 0000100 /* Two stop bits instead of one. */
161#define CREAD 0000200 /* Enable receiver. */
162#define PARENB 0000400 /* Parity enable. */
163#define PARODD 0001000 /* Odd parity instead of even. */
164#define HUPCL 0002000 /* Hang up on last close. */
165#define CLOCAL 0004000 /* Ignore modem status lines. */
166#define CBAUDEX 0010000
167#define BOTHER 0010000
168#define B57600 0010001
169#define B115200 0010002
170#define B230400 0010003
171#define B460800 0010004
172#define B500000 0010005
173#define B576000 0010006
174#define B921600 0010007
175#define B1000000 0010010
176#define B1152000 0010011
177#define B1500000 0010012
178#define B2000000 0010013
179#define B2500000 0010014
180#define B3000000 0010015
181#define B3500000 0010016
182#define B4000000 0010017
183#define CIBAUD 002003600000 /* input baud rate */
184#define CMSPAR 010000000000 /* mark or space (stick) parity */
185#define CRTSCTS 020000000000 /* flow control */
186
187#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
188
189/* c_lflag bits */
190#define ISIG 0000001 /* Enable signals. */
191#define ICANON 0000002 /* Do erase and kill processing. */
192#define XCASE 0000004
193#define ECHO 0000010 /* Enable echo. */
194#define ECHOE 0000020 /* Visual erase for ERASE. */
195#define ECHOK 0000040 /* Echo NL after KILL. */
196#define ECHONL 0000100 /* Echo NL even if ECHO is off. */
197#define NOFLSH 0000200 /* Disable flush after interrupt. */
198#define IEXTEN 0000400 /* Enable DISCARD and LNEXT. */
199#define ECHOCTL 0001000 /* Echo control characters as ^X. */
200#define ECHOPRT 0002000 /* Hardcopy visual erase. */
201#define ECHOKE 0004000 /* Visual erase for KILL. */
202#define FLUSHO 0020000
203#define PENDIN 0040000 /* Retype pending input (state). */
204#define TOSTOP 0100000 /* Send SIGTTOU for background output. */
205#define ITOSTOP TOSTOP
206
207/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
208#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
209
210/* tcflow() and TCXONC use these */
211#define TCOOFF 0 /* Suspend output. */
212#define TCOON 1 /* Restart suspended output. */
213#define TCIOFF 2 /* Send a STOP character. */
214#define TCION 3 /* Send a START character. */
215
216/* tcflush() and TCFLSH use these */
217#define TCIFLUSH 0 /* Discard data received but not yet read. */
218#define TCOFLUSH 1 /* Discard data written but not yet sent. */
219#define TCIOFLUSH 2 /* Discard all pending data. */
220
221/* tcsetattr uses these */
222#define TCSANOW TCSETS /* Change immediately. */
223#define TCSADRAIN TCSETSW /* Change when pending output is written. */
224#define TCSAFLUSH TCSETSF /* Flush pending input before changing. */
225
226#endif /* _ASM_TERMBITS_H */
diff --git a/arch/mips/include/asm/termios.h b/arch/mips/include/asm/termios.h
new file mode 100644
index 000000000000..a275661fa7e1
--- /dev/null
+++ b/arch/mips/include/asm/termios.h
@@ -0,0 +1,132 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1996, 2000, 2001 by Ralf Baechle
7 * Copyright (C) 2000, 2001 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_TERMIOS_H
10#define _ASM_TERMIOS_H
11
12#include <asm/termbits.h>
13#include <asm/ioctls.h>
14
15struct sgttyb {
16 char sg_ispeed;
17 char sg_ospeed;
18 char sg_erase;
19 char sg_kill;
20 int sg_flags; /* SGI special - int, not short */
21};
22
23struct tchars {
24 char t_intrc;
25 char t_quitc;
26 char t_startc;
27 char t_stopc;
28 char t_eofc;
29 char t_brkc;
30};
31
32struct ltchars {
33 char t_suspc; /* stop process signal */
34 char t_dsuspc; /* delayed stop process signal */
35 char t_rprntc; /* reprint line */
36 char t_flushc; /* flush output (toggles) */
37 char t_werasc; /* word erase */
38 char t_lnextc; /* literal next character */
39};
40
41/* TIOCGSIZE, TIOCSSIZE not defined yet. Only needed for SunOS source
42 compatibility anyway ... */
43
44struct winsize {
45 unsigned short ws_row;
46 unsigned short ws_col;
47 unsigned short ws_xpixel;
48 unsigned short ws_ypixel;
49};
50
51#define NCC 8
52struct termio {
53 unsigned short c_iflag; /* input mode flags */
54 unsigned short c_oflag; /* output mode flags */
55 unsigned short c_cflag; /* control mode flags */
56 unsigned short c_lflag; /* local mode flags */
57 char c_line; /* line discipline */
58 unsigned char c_cc[NCCS]; /* control characters */
59};
60
61#ifdef __KERNEL__
62#include <linux/module.h>
63
64/*
65 * intr=^C quit=^\ erase=del kill=^U
66 * vmin=\1 vtime=\0 eol2=\0 swtc=\0
67 * start=^Q stop=^S susp=^Z vdsusp=
68 * reprint=^R discard=^U werase=^W lnext=^V
69 * eof=^D eol=\0
70 */
71#define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0"
72#endif
73
74/* modem lines */
75#define TIOCM_LE 0x001 /* line enable */
76#define TIOCM_DTR 0x002 /* data terminal ready */
77#define TIOCM_RTS 0x004 /* request to send */
78#define TIOCM_ST 0x010 /* secondary transmit */
79#define TIOCM_SR 0x020 /* secondary receive */
80#define TIOCM_CTS 0x040 /* clear to send */
81#define TIOCM_CAR 0x100 /* carrier detect */
82#define TIOCM_CD TIOCM_CAR
83#define TIOCM_RNG 0x200 /* ring */
84#define TIOCM_RI TIOCM_RNG
85#define TIOCM_DSR 0x400 /* data set ready */
86#define TIOCM_OUT1 0x2000
87#define TIOCM_OUT2 0x4000
88#define TIOCM_LOOP 0x8000
89
90#ifdef __KERNEL__
91
92#include <linux/string.h>
93
94/*
95 * Translate a "termio" structure into a "termios". Ugh.
96 */
97#define user_termio_to_kernel_termios(termios, termio) \
98({ \
99 unsigned short tmp; \
100 get_user(tmp, &(termio)->c_iflag); \
101 (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
102 get_user(tmp, &(termio)->c_oflag); \
103 (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
104 get_user(tmp, &(termio)->c_cflag); \
105 (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
106 get_user(tmp, &(termio)->c_lflag); \
107 (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
108 get_user((termios)->c_line, &(termio)->c_line); \
109 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
110})
111
112/*
113 * Translate a "termios" structure into a "termio". Ugh.
114 */
115#define kernel_termios_to_user_termio(termio, termios) \
116({ \
117 put_user((termios)->c_iflag, &(termio)->c_iflag); \
118 put_user((termios)->c_oflag, &(termio)->c_oflag); \
119 put_user((termios)->c_cflag, &(termio)->c_cflag); \
120 put_user((termios)->c_lflag, &(termio)->c_lflag); \
121 put_user((termios)->c_line, &(termio)->c_line); \
122 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
123})
124
125#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2))
126#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
127#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
128#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
129
130#endif /* defined(__KERNEL__) */
131
132#endif /* _ASM_TERMIOS_H */
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
new file mode 100644
index 000000000000..3f76de73c943
--- /dev/null
+++ b/arch/mips/include/asm/thread_info.h
@@ -0,0 +1,153 @@
1/* thread_info.h: MIPS low-level thread information
2 *
3 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
4 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
5 */
6
7#ifndef _ASM_THREAD_INFO_H
8#define _ASM_THREAD_INFO_H
9
10#ifdef __KERNEL__
11
12
13#ifndef __ASSEMBLY__
14
15#include <asm/processor.h>
16
17/*
18 * low level task data that entry.S needs immediate access to
19 * - this struct should fit entirely inside of one cache line
20 * - this struct shares the supervisor stack pages
21 * - if the contents of this structure are changed, the assembly constants
22 * must also be changed
23 */
24struct thread_info {
25 struct task_struct *task; /* main task structure */
26 struct exec_domain *exec_domain; /* execution domain */
27 unsigned long flags; /* low level flags */
28 unsigned long tp_value; /* thread pointer */
29 __u32 cpu; /* current CPU */
30 int preempt_count; /* 0 => preemptable, <0 => BUG */
31
32 mm_segment_t addr_limit; /* thread address space:
33 0-0xBFFFFFFF for user-thead
34 0-0xFFFFFFFF for kernel-thread
35 */
36 struct restart_block restart_block;
37 struct pt_regs *regs;
38};
39
40/*
41 * macros/functions for gaining access to the thread information structure
42 *
43 * preempt_count needs to be 1 initially, until the scheduler is functional.
44 */
45#define INIT_THREAD_INFO(tsk) \
46{ \
47 .task = &tsk, \
48 .exec_domain = &default_exec_domain, \
49 .flags = _TIF_FIXADE, \
50 .cpu = 0, \
51 .preempt_count = 1, \
52 .addr_limit = KERNEL_DS, \
53 .restart_block = { \
54 .fn = do_no_restart_syscall, \
55 }, \
56}
57
58#define init_thread_info (init_thread_union.thread_info)
59#define init_stack (init_thread_union.stack)
60
61/* How to get the thread information struct from C. */
62register struct thread_info *__current_thread_info __asm__("$28");
63#define current_thread_info() __current_thread_info
64
65/* thread information allocation */
66#if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_32BIT)
67#define THREAD_SIZE_ORDER (1)
68#endif
69#if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_64BIT)
70#define THREAD_SIZE_ORDER (2)
71#endif
72#ifdef CONFIG_PAGE_SIZE_8KB
73#define THREAD_SIZE_ORDER (1)
74#endif
75#ifdef CONFIG_PAGE_SIZE_16KB
76#define THREAD_SIZE_ORDER (0)
77#endif
78#ifdef CONFIG_PAGE_SIZE_64KB
79#define THREAD_SIZE_ORDER (0)
80#endif
81
82#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
83#define THREAD_MASK (THREAD_SIZE - 1UL)
84
85#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
86
87#ifdef CONFIG_DEBUG_STACK_USAGE
88#define alloc_thread_info(tsk) \
89({ \
90 struct thread_info *ret; \
91 \
92 ret = kzalloc(THREAD_SIZE, GFP_KERNEL); \
93 \
94 ret; \
95})
96#else
97#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
98#endif
99
100#define free_thread_info(info) kfree(info)
101
102#endif /* !__ASSEMBLY__ */
103
104#define PREEMPT_ACTIVE 0x10000000
105
106/*
107 * thread information flags
108 * - these are process state flags that various assembly files may need to
109 * access
110 * - pending work-to-be-done flags are in LSW
111 * - other flags in MSW
112 */
113#define TIF_SIGPENDING 1 /* signal pending */
114#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
115#define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
116#define TIF_SECCOMP 4 /* secure computing */
117#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
118#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
119#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
120#define TIF_MEMDIE 18
121#define TIF_FREEZE 19
122#define TIF_FIXADE 20 /* Fix address errors in software */
123#define TIF_LOGADE 21 /* Log address errors to syslog */
124#define TIF_32BIT_REGS 22 /* also implies 16/32 fprs */
125#define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
126#define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
127#define TIF_LOAD_WATCH 25 /* If set, load watch registers */
128#define TIF_SYSCALL_TRACE 31 /* syscall trace active */
129
130#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
131#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
132#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
133#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
134#define _TIF_SECCOMP (1<<TIF_SECCOMP)
135#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
136#define _TIF_USEDFPU (1<<TIF_USEDFPU)
137#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
138#define _TIF_FREEZE (1<<TIF_FREEZE)
139#define _TIF_FIXADE (1<<TIF_FIXADE)
140#define _TIF_LOGADE (1<<TIF_LOGADE)
141#define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS)
142#define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
143#define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
144#define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
145
146/* work to do on interrupt/exception return */
147#define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP)
148/* work to do on any return to u-space */
149#define _TIF_ALLWORK_MASK (0x8000ffff & ~_TIF_SECCOMP)
150
151#endif /* __KERNEL__ */
152
153#endif /* _ASM_THREAD_INFO_H */
diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
new file mode 100644
index 000000000000..d3bd5c5aa2ec
--- /dev/null
+++ b/arch/mips/include/asm/time.h
@@ -0,0 +1,79 @@
1/*
2 * Copyright (C) 2001, 2002, MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 * Copyright (c) 2003 Maciej W. Rozycki
5 *
6 * include/asm-mips/time.h
7 * header file for the new style time.c file and time services.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14#ifndef _ASM_TIME_H
15#define _ASM_TIME_H
16
17#include <linux/rtc.h>
18#include <linux/spinlock.h>
19#include <linux/clockchips.h>
20#include <linux/clocksource.h>
21
22extern spinlock_t rtc_lock;
23
24/*
25 * RTC ops. By default, they point to weak no-op RTC functions.
26 * rtc_mips_set_time - reverse the above translation and set time to RTC.
27 * rtc_mips_set_mmss - similar to rtc_set_time, but only min and sec need
28 * to be set. Used by RTC sync-up.
29 */
30extern int rtc_mips_set_time(unsigned long);
31extern int rtc_mips_set_mmss(unsigned long);
32
33/*
34 * board specific routines required by time_init().
35 */
36extern void plat_time_init(void);
37
38/*
39 * mips_hpt_frequency - must be set if you intend to use an R4k-compatible
40 * counter as a timer interrupt source.
41 */
42extern unsigned int mips_hpt_frequency;
43
44/*
45 * The performance counter IRQ on MIPS is a close relative to the timer IRQ
46 * so it lives here.
47 */
48extern int (*perf_irq)(void);
49
50/*
51 * Initialize the calling CPU's compare interrupt as clockevent device
52 */
53#ifdef CONFIG_CEVT_R4K
54extern int mips_clockevent_init(void);
55extern unsigned int __weak get_c0_compare_int(void);
56#else
57static inline int mips_clockevent_init(void)
58{
59 return -ENXIO;
60}
61#endif
62
63/*
64 * Initialize the count register as a clocksource
65 */
66#ifdef CONFIG_CEVT_R4K
67extern int init_mips_clocksource(void);
68#else
69static inline int init_mips_clocksource(void)
70{
71 return 0;
72}
73#endif
74
75extern void clocksource_set_clock(struct clocksource *cs, unsigned int clock);
76extern void clockevent_set_clock(struct clock_event_device *cd,
77 unsigned int clock);
78
79#endif /* _ASM_TIME_H */
diff --git a/arch/mips/include/asm/timex.h b/arch/mips/include/asm/timex.h
new file mode 100644
index 000000000000..6529704aa73a
--- /dev/null
+++ b/arch/mips/include/asm/timex.h
@@ -0,0 +1,43 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 1999, 2003 by Ralf Baechle
7 */
8#ifndef _ASM_TIMEX_H
9#define _ASM_TIMEX_H
10
11#ifdef __KERNEL__
12
13#include <asm/mipsregs.h>
14
15/*
16 * This is the clock rate of the i8253 PIT. A MIPS system may not have
17 * a PIT by the symbol is used all over the kernel including some APIs.
18 * So keeping it defined to the number for the PIT is the only sane thing
19 * for now.
20 */
21#define CLOCK_TICK_RATE 1193182
22
23/*
24 * Standard way to access the cycle counter.
25 * Currently only used on SMP for scheduling.
26 *
27 * Only the low 32 bits are available as a continuously counting entity.
28 * But this only means we'll force a reschedule every 8 seconds or so,
29 * which isn't an evil thing.
30 *
31 * We know that all SMP capable CPUs have cycle counters.
32 */
33
34typedef unsigned int cycles_t;
35
36static inline cycles_t get_cycles(void)
37{
38 return 0;
39}
40
41#endif /* __KERNEL__ */
42
43#endif /* _ASM_TIMEX_H */
diff --git a/arch/mips/include/asm/titan_dep.h b/arch/mips/include/asm/titan_dep.h
new file mode 100644
index 000000000000..fee1908c65d2
--- /dev/null
+++ b/arch/mips/include/asm/titan_dep.h
@@ -0,0 +1,231 @@
1/*
2 * Copyright 2003 PMC-Sierra
3 * Author: Manish Lachwani (lachwani@pmc-sierra.com)
4 *
5 * Board specific definititions for the PMC-Sierra Yosemite
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#ifndef __TITAN_DEP_H__
14#define __TITAN_DEP_H__
15
16#include <asm/addrspace.h> /* for KSEG1ADDR() */
17#include <asm/byteorder.h> /* for cpu_to_le32() */
18
19#define TITAN_READ(ofs) \
20 (*(volatile u32 *)(ocd_base+(ofs)))
21#define TITAN_READ_16(ofs) \
22 (*(volatile u16 *)(ocd_base+(ofs)))
23#define TITAN_READ_8(ofs) \
24 (*(volatile u8 *)(ocd_base+(ofs)))
25
26#define TITAN_WRITE(ofs, data) \
27 do { *(volatile u32 *)(ocd_base+(ofs)) = (data); } while (0)
28#define TITAN_WRITE_16(ofs, data) \
29 do { *(volatile u16 *)(ocd_base+(ofs)) = (data); } while (0)
30#define TITAN_WRITE_8(ofs, data) \
31 do { *(volatile u8 *)(ocd_base+(ofs)) = (data); } while (0)
32
33/*
34 * PCI specific defines
35 */
36#define TITAN_PCI_0_CONFIG_ADDRESS 0x780
37#define TITAN_PCI_0_CONFIG_DATA 0x784
38
39/*
40 * HT specific defines
41 */
42#define RM9000x2_HTLINK_REG 0xbb000644
43#define RM9000x2_BASE_ADDR 0xbb000000
44
45#define OCD_BASE 0xfb000000UL
46#define OCD_SIZE 0x3000UL
47
48extern unsigned long ocd_base;
49
50/*
51 * OCD Registers
52 */
53#define RM9000x2_OCD_LKB5 0x0128 /* Ethernet */
54#define RM9000x2_OCD_LKM5 0x012c
55
56#define RM9000x2_OCD_LKB7 0x0138 /* HT Region 0 */
57#define RM9000x2_OCD_LKM7 0x013c
58#define RM9000x2_OCD_LKB8 0x0140 /* HT Region 1 */
59#define RM9000x2_OCD_LKM8 0x0144
60
61#define RM9000x2_OCD_LKB9 0x0148 /* Local Bus */
62#define RM9000x2_OCD_LKM9 0x014c
63#define RM9000x2_OCD_LKB10 0x0150
64#define RM9000x2_OCD_LKM10 0x0154
65#define RM9000x2_OCD_LKB11 0x0158
66#define RM9000x2_OCD_LKM11 0x015c
67#define RM9000x2_OCD_LKB12 0x0160
68#define RM9000x2_OCD_LKM12 0x0164
69
70#define RM9000x2_OCD_LKB13 0x0168 /* Scratch RAM */
71#define RM9000x2_OCD_LKM13 0x016c
72
73#define RM9000x2_OCD_LPD0 0x0200 /* Local Bus */
74#define RM9000x2_OCD_LPD1 0x0210
75#define RM9000x2_OCD_LPD2 0x0220
76#define RM9000x2_OCD_LPD3 0x0230
77
78#define RM9000x2_OCD_HTDVID 0x0600 /* HT Device Header */
79#define RM9000x2_OCD_HTSC 0x0604
80#define RM9000x2_OCD_HTCCR 0x0608
81#define RM9000x2_OCD_HTBHL 0x060c
82#define RM9000x2_OCD_HTBAR0 0x0610
83#define RM9000x2_OCD_HTBAR1 0x0614
84#define RM9000x2_OCD_HTBAR2 0x0618
85#define RM9000x2_OCD_HTBAR3 0x061c
86#define RM9000x2_OCD_HTBAR4 0x0620
87#define RM9000x2_OCD_HTBAR5 0x0624
88#define RM9000x2_OCD_HTCBCPT 0x0628
89#define RM9000x2_OCD_HTSDVID 0x062c
90#define RM9000x2_OCD_HTXRA 0x0630
91#define RM9000x2_OCD_HTCAP1 0x0634
92#define RM9000x2_OCD_HTIL 0x063c
93
94#define RM9000x2_OCD_HTLCC 0x0640 /* HT Capability Block */
95#define RM9000x2_OCD_HTLINK 0x0644
96#define RM9000x2_OCD_HTFQREV 0x0648
97
98#define RM9000x2_OCD_HTERCTL 0x0668 /* HT Controller */
99#define RM9000x2_OCD_HTRXDB 0x066c
100#define RM9000x2_OCD_HTIMPED 0x0670
101#define RM9000x2_OCD_HTSWIMP 0x0674
102#define RM9000x2_OCD_HTCAL 0x0678
103
104#define RM9000x2_OCD_HTBAA30 0x0680
105#define RM9000x2_OCD_HTBAA54 0x0684
106#define RM9000x2_OCD_HTMASK0 0x0688
107#define RM9000x2_OCD_HTMASK1 0x068c
108#define RM9000x2_OCD_HTMASK2 0x0690
109#define RM9000x2_OCD_HTMASK3 0x0694
110#define RM9000x2_OCD_HTMASK4 0x0698
111#define RM9000x2_OCD_HTMASK5 0x069c
112
113#define RM9000x2_OCD_HTIFCTL 0x06a0
114#define RM9000x2_OCD_HTPLL 0x06a4
115
116#define RM9000x2_OCD_HTSRI 0x06b0
117#define RM9000x2_OCD_HTRXNUM 0x06b4
118#define RM9000x2_OCD_HTTXNUM 0x06b8
119
120#define RM9000x2_OCD_HTTXCNT 0x06c8
121
122#define RM9000x2_OCD_HTERROR 0x06d8
123#define RM9000x2_OCD_HTRCRCE 0x06dc
124#define RM9000x2_OCD_HTEOI 0x06e0
125
126#define RM9000x2_OCD_CRCR 0x06f0
127
128#define RM9000x2_OCD_HTCFGA 0x06f8
129#define RM9000x2_OCD_HTCFGD 0x06fc
130
131#define RM9000x2_OCD_INTMSG 0x0a00
132
133#define RM9000x2_OCD_INTPIN0 0x0a40
134#define RM9000x2_OCD_INTPIN1 0x0a44
135#define RM9000x2_OCD_INTPIN2 0x0a48
136#define RM9000x2_OCD_INTPIN3 0x0a4c
137#define RM9000x2_OCD_INTPIN4 0x0a50
138#define RM9000x2_OCD_INTPIN5 0x0a54
139#define RM9000x2_OCD_INTPIN6 0x0a58
140#define RM9000x2_OCD_INTPIN7 0x0a5c
141#define RM9000x2_OCD_SEM 0x0a60
142#define RM9000x2_OCD_SEMSET 0x0a64
143#define RM9000x2_OCD_SEMCLR 0x0a68
144
145#define RM9000x2_OCD_TKT 0x0a70
146#define RM9000x2_OCD_TKTINC 0x0a74
147
148#define RM9000x2_OCD_NMICONFIG 0x0ac0 /* Interrupts */
149#define RM9000x2_OCD_INTP0PRI 0x1a80
150#define RM9000x2_OCD_INTP1PRI 0x1a80
151#define RM9000x2_OCD_INTP0STATUS0 0x1b00
152#define RM9000x2_OCD_INTP0MASK0 0x1b04
153#define RM9000x2_OCD_INTP0SET0 0x1b08
154#define RM9000x2_OCD_INTP0CLEAR0 0x1b0c
155#define RM9000x2_OCD_INTP0STATUS1 0x1b10
156#define RM9000x2_OCD_INTP0MASK1 0x1b14
157#define RM9000x2_OCD_INTP0SET1 0x1b18
158#define RM9000x2_OCD_INTP0CLEAR1 0x1b1c
159#define RM9000x2_OCD_INTP0STATUS2 0x1b20
160#define RM9000x2_OCD_INTP0MASK2 0x1b24
161#define RM9000x2_OCD_INTP0SET2 0x1b28
162#define RM9000x2_OCD_INTP0CLEAR2 0x1b2c
163#define RM9000x2_OCD_INTP0STATUS3 0x1b30
164#define RM9000x2_OCD_INTP0MASK3 0x1b34
165#define RM9000x2_OCD_INTP0SET3 0x1b38
166#define RM9000x2_OCD_INTP0CLEAR3 0x1b3c
167#define RM9000x2_OCD_INTP0STATUS4 0x1b40
168#define RM9000x2_OCD_INTP0MASK4 0x1b44
169#define RM9000x2_OCD_INTP0SET4 0x1b48
170#define RM9000x2_OCD_INTP0CLEAR4 0x1b4c
171#define RM9000x2_OCD_INTP0STATUS5 0x1b50
172#define RM9000x2_OCD_INTP0MASK5 0x1b54
173#define RM9000x2_OCD_INTP0SET5 0x1b58
174#define RM9000x2_OCD_INTP0CLEAR5 0x1b5c
175#define RM9000x2_OCD_INTP0STATUS6 0x1b60
176#define RM9000x2_OCD_INTP0MASK6 0x1b64
177#define RM9000x2_OCD_INTP0SET6 0x1b68
178#define RM9000x2_OCD_INTP0CLEAR6 0x1b6c
179#define RM9000x2_OCD_INTP0STATUS7 0x1b70
180#define RM9000x2_OCD_INTP0MASK7 0x1b74
181#define RM9000x2_OCD_INTP0SET7 0x1b78
182#define RM9000x2_OCD_INTP0CLEAR7 0x1b7c
183#define RM9000x2_OCD_INTP1STATUS0 0x2b00
184#define RM9000x2_OCD_INTP1MASK0 0x2b04
185#define RM9000x2_OCD_INTP1SET0 0x2b08
186#define RM9000x2_OCD_INTP1CLEAR0 0x2b0c
187#define RM9000x2_OCD_INTP1STATUS1 0x2b10
188#define RM9000x2_OCD_INTP1MASK1 0x2b14
189#define RM9000x2_OCD_INTP1SET1 0x2b18
190#define RM9000x2_OCD_INTP1CLEAR1 0x2b1c
191#define RM9000x2_OCD_INTP1STATUS2 0x2b20
192#define RM9000x2_OCD_INTP1MASK2 0x2b24
193#define RM9000x2_OCD_INTP1SET2 0x2b28
194#define RM9000x2_OCD_INTP1CLEAR2 0x2b2c
195#define RM9000x2_OCD_INTP1STATUS3 0x2b30
196#define RM9000x2_OCD_INTP1MASK3 0x2b34
197#define RM9000x2_OCD_INTP1SET3 0x2b38
198#define RM9000x2_OCD_INTP1CLEAR3 0x2b3c
199#define RM9000x2_OCD_INTP1STATUS4 0x2b40
200#define RM9000x2_OCD_INTP1MASK4 0x2b44
201#define RM9000x2_OCD_INTP1SET4 0x2b48
202#define RM9000x2_OCD_INTP1CLEAR4 0x2b4c
203#define RM9000x2_OCD_INTP1STATUS5 0x2b50
204#define RM9000x2_OCD_INTP1MASK5 0x2b54
205#define RM9000x2_OCD_INTP1SET5 0x2b58
206#define RM9000x2_OCD_INTP1CLEAR5 0x2b5c
207#define RM9000x2_OCD_INTP1STATUS6 0x2b60
208#define RM9000x2_OCD_INTP1MASK6 0x2b64
209#define RM9000x2_OCD_INTP1SET6 0x2b68
210#define RM9000x2_OCD_INTP1CLEAR6 0x2b6c
211#define RM9000x2_OCD_INTP1STATUS7 0x2b70
212#define RM9000x2_OCD_INTP1MASK7 0x2b74
213#define RM9000x2_OCD_INTP1SET7 0x2b78
214#define RM9000x2_OCD_INTP1CLEAR7 0x2b7c
215
216#define OCD_READ(reg) (*(volatile unsigned int *)(ocd_base + (reg)))
217#define OCD_WRITE(reg, val) \
218 do { *(volatile unsigned int *)(ocd_base + (reg)) = (val); } while (0)
219
220/*
221 * Hypertransport specific macros
222 */
223#define RM9K_WRITE(ofs, data) *(volatile u_int32_t *)(RM9000x2_BASE_ADDR+ofs) = data
224#define RM9K_WRITE_8(ofs, data) *(volatile u8 *)(RM9000x2_BASE_ADDR+ofs) = data
225#define RM9K_WRITE_16(ofs, data) *(volatile u16 *)(RM9000x2_BASE_ADDR+ofs) = data
226
227#define RM9K_READ(ofs, val) *(val) = *(volatile u_int32_t *)(RM9000x2_BASE_ADDR+ofs)
228#define RM9K_READ_8(ofs, val) *(val) = *(volatile u8 *)(RM9000x2_BASE_ADDR+ofs)
229#define RM9K_READ_16(ofs, val) *(val) = *(volatile u16 *)(RM9000x2_BASE_ADDR+ofs)
230
231#endif
diff --git a/arch/mips/include/asm/tlb.h b/arch/mips/include/asm/tlb.h
new file mode 100644
index 000000000000..80d9dfcf1e88
--- /dev/null
+++ b/arch/mips/include/asm/tlb.h
@@ -0,0 +1,23 @@
1#ifndef __ASM_TLB_H
2#define __ASM_TLB_H
3
4/*
5 * MIPS doesn't need any special per-pte or per-vma handling, except
6 * we need to flush cache for area to be unmapped.
7 */
8#define tlb_start_vma(tlb, vma) \
9 do { \
10 if (!tlb->fullmm) \
11 flush_cache_range(vma, vma->vm_start, vma->vm_end); \
12 } while (0)
13#define tlb_end_vma(tlb, vma) do { } while (0)
14#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)
15
16/*
17 * .. because we flush the whole mm when it fills up.
18 */
19#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
20
21#include <asm-generic/tlb.h>
22
23#endif /* __ASM_TLB_H */
diff --git a/arch/mips/include/asm/tlbdebug.h b/arch/mips/include/asm/tlbdebug.h
new file mode 100644
index 000000000000..bb8f5c29c3d9
--- /dev/null
+++ b/arch/mips/include/asm/tlbdebug.h
@@ -0,0 +1,16 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002 by Ralf Baechle
7 */
8#ifndef __ASM_TLBDEBUG_H
9#define __ASM_TLBDEBUG_H
10
11/*
12 * TLB debugging functions:
13 */
14extern void dump_tlb_all(void);
15
16#endif /* __ASM_TLBDEBUG_H */
diff --git a/arch/mips/include/asm/tlbflush.h b/arch/mips/include/asm/tlbflush.h
new file mode 100644
index 000000000000..86b21de12e91
--- /dev/null
+++ b/arch/mips/include/asm/tlbflush.h
@@ -0,0 +1,47 @@
1#ifndef __ASM_TLBFLUSH_H
2#define __ASM_TLBFLUSH_H
3
4#include <linux/mm.h>
5
6/*
7 * TLB flushing:
8 *
9 * - flush_tlb_all() flushes all processes TLB entries
10 * - flush_tlb_mm(mm) flushes the specified mm context TLB entries
11 * - flush_tlb_page(vma, vmaddr) flushes one page
12 * - flush_tlb_range(vma, start, end) flushes a range of pages
13 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
14 */
15extern void local_flush_tlb_all(void);
16extern void local_flush_tlb_mm(struct mm_struct *mm);
17extern void local_flush_tlb_range(struct vm_area_struct *vma,
18 unsigned long start, unsigned long end);
19extern void local_flush_tlb_kernel_range(unsigned long start,
20 unsigned long end);
21extern void local_flush_tlb_page(struct vm_area_struct *vma,
22 unsigned long page);
23extern void local_flush_tlb_one(unsigned long vaddr);
24
25#ifdef CONFIG_SMP
26
27extern void flush_tlb_all(void);
28extern void flush_tlb_mm(struct mm_struct *);
29extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long,
30 unsigned long);
31extern void flush_tlb_kernel_range(unsigned long, unsigned long);
32extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
33extern void flush_tlb_one(unsigned long vaddr);
34
35#else /* CONFIG_SMP */
36
37#define flush_tlb_all() local_flush_tlb_all()
38#define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
39#define flush_tlb_range(vma, vmaddr, end) local_flush_tlb_range(vma, vmaddr, end)
40#define flush_tlb_kernel_range(vmaddr,end) \
41 local_flush_tlb_kernel_range(vmaddr, end)
42#define flush_tlb_page(vma, page) local_flush_tlb_page(vma, page)
43#define flush_tlb_one(vaddr) local_flush_tlb_one(vaddr)
44
45#endif /* CONFIG_SMP */
46
47#endif /* __ASM_TLBFLUSH_H */
diff --git a/arch/mips/include/asm/topology.h b/arch/mips/include/asm/topology.h
new file mode 100644
index 000000000000..259145e07e97
--- /dev/null
+++ b/arch/mips/include/asm/topology.h
@@ -0,0 +1,17 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 by Ralf Baechle
7 */
8#ifndef __ASM_TOPOLOGY_H
9#define __ASM_TOPOLOGY_H
10
11#include <topology.h>
12
13#ifdef CONFIG_SMP
14#define smt_capable() (smp_num_siblings > 1)
15#endif
16
17#endif /* __ASM_TOPOLOGY_H */
diff --git a/arch/mips/include/asm/traps.h b/arch/mips/include/asm/traps.h
new file mode 100644
index 000000000000..90ff2f497c50
--- /dev/null
+++ b/arch/mips/include/asm/traps.h
@@ -0,0 +1,28 @@
1/*
2 * Trap handling definitions.
3 *
4 * Copyright (C) 2002, 2003 Maciej W. Rozycki
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_TRAPS_H
12#define _ASM_TRAPS_H
13
14/*
15 * Possible status responses for a board_be_handler backend.
16 */
17#define MIPS_BE_DISCARD 0 /* return with no action */
18#define MIPS_BE_FIXUP 1 /* return to the fixup code */
19#define MIPS_BE_FATAL 2 /* treat as an unrecoverable error */
20
21extern void (*board_be_init)(void);
22extern int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
23
24extern void (*board_nmi_handler_setup)(void);
25extern void (*board_ejtag_handler_setup)(void);
26extern void (*board_bind_eic_interrupt)(int irq, int regset);
27
28#endif /* _ASM_TRAPS_H */
diff --git a/arch/mips/include/asm/txx9/boards.h b/arch/mips/include/asm/txx9/boards.h
new file mode 100644
index 000000000000..cbe9476d963e
--- /dev/null
+++ b/arch/mips/include/asm/txx9/boards.h
@@ -0,0 +1,13 @@
1#ifdef CONFIG_TOSHIBA_JMR3927
2BOARD_VEC(jmr3927_vec)
3#endif
4#ifdef CONFIG_TOSHIBA_RBTX4927
5BOARD_VEC(rbtx4927_vec)
6BOARD_VEC(rbtx4937_vec)
7#endif
8#ifdef CONFIG_TOSHIBA_RBTX4938
9BOARD_VEC(rbtx4938_vec)
10#endif
11#ifdef CONFIG_TOSHIBA_RBTX4939
12BOARD_VEC(rbtx4939_vec)
13#endif
diff --git a/arch/mips/include/asm/txx9/generic.h b/arch/mips/include/asm/txx9/generic.h
new file mode 100644
index 000000000000..4316a3e57678
--- /dev/null
+++ b/arch/mips/include/asm/txx9/generic.h
@@ -0,0 +1,89 @@
1/*
2 * linux/include/asm-mips/txx9/generic.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8#ifndef __ASM_TXX9_GENERIC_H
9#define __ASM_TXX9_GENERIC_H
10
11#include <linux/init.h>
12#include <linux/ioport.h> /* for struct resource */
13
14extern struct resource txx9_ce_res[];
15#define TXX9_CE(n) (unsigned long)(txx9_ce_res[(n)].start)
16extern unsigned int txx9_pcode;
17extern char txx9_pcode_str[8];
18void txx9_reg_res_init(unsigned int pcode, unsigned long base,
19 unsigned long size);
20
21extern unsigned int txx9_master_clock;
22extern unsigned int txx9_cpu_clock;
23extern unsigned int txx9_gbus_clock;
24#define TXX9_IMCLK (txx9_gbus_clock / 2)
25
26extern int txx9_ccfg_toeon;
27struct uart_port;
28int early_serial_txx9_setup(struct uart_port *port);
29
30struct pci_dev;
31struct txx9_board_vec {
32 const char *system;
33 void (*prom_init)(void);
34 void (*mem_setup)(void);
35 void (*irq_setup)(void);
36 void (*time_init)(void);
37 void (*arch_init)(void);
38 void (*device_init)(void);
39#ifdef CONFIG_PCI
40 int (*pci_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
41#endif
42};
43extern struct txx9_board_vec *txx9_board_vec;
44extern int (*txx9_irq_dispatch)(int pending);
45char *prom_getcmdline(void);
46const char *prom_getenv(const char *name);
47void txx9_wdt_init(unsigned long base);
48void txx9_wdt_now(unsigned long base);
49void txx9_spi_init(int busid, unsigned long base, int irq);
50void txx9_ethaddr_init(unsigned int id, unsigned char *ethaddr);
51void txx9_sio_init(unsigned long baseaddr, int irq,
52 unsigned int line, unsigned int sclk, int nocts);
53void prom_putchar(char c);
54#ifdef CONFIG_EARLY_PRINTK
55extern void (*txx9_prom_putchar)(char c);
56void txx9_sio_putchar_init(unsigned long baseaddr);
57#else
58static inline void txx9_sio_putchar_init(unsigned long baseaddr)
59{
60}
61#endif
62
63struct physmap_flash_data;
64void txx9_physmap_flash_init(int no, unsigned long addr, unsigned long size,
65 const struct physmap_flash_data *pdata);
66
67/* 8 bit version of __fls(): find first bit set (returns 0..7) */
68static inline unsigned int __fls8(unsigned char x)
69{
70 int r = 7;
71
72 if (!(x & 0xf0)) {
73 r -= 4;
74 x <<= 4;
75 }
76 if (!(x & 0xc0)) {
77 r -= 2;
78 x <<= 2;
79 }
80 if (!(x & 0x80))
81 r -= 1;
82 return r;
83}
84
85void txx9_iocled_init(unsigned long baseaddr,
86 int basenum, unsigned int num, int lowactive,
87 const char *color, char **deftriggers);
88
89#endif /* __ASM_TXX9_GENERIC_H */
diff --git a/arch/mips/include/asm/txx9/jmr3927.h b/arch/mips/include/asm/txx9/jmr3927.h
new file mode 100644
index 000000000000..a409c446bf18
--- /dev/null
+++ b/arch/mips/include/asm/txx9/jmr3927.h
@@ -0,0 +1,180 @@
1/*
2 * Defines for the TJSYS JMR-TX3927
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2000-2001 Toshiba Corporation
9 */
10#ifndef __ASM_TXX9_JMR3927_H
11#define __ASM_TXX9_JMR3927_H
12
13#include <asm/txx9/tx3927.h>
14#include <asm/addrspace.h>
15#include <asm/system.h>
16#include <asm/txx9irq.h>
17
18/* CS */
19#define JMR3927_ROMCE0 0x1fc00000 /* 4M */
20#define JMR3927_ROMCE1 0x1e000000 /* 4M */
21#define JMR3927_ROMCE2 0x14000000 /* 16M */
22#define JMR3927_ROMCE3 0x10000000 /* 64M */
23#define JMR3927_ROMCE5 0x1d000000 /* 4M */
24#define JMR3927_SDCS0 0x00000000 /* 32M */
25#define JMR3927_SDCS1 0x02000000 /* 32M */
26/* PCI Direct Mappings */
27
28#define JMR3927_PCIMEM 0x08000000
29#define JMR3927_PCIMEM_SIZE 0x08000000 /* 128M */
30#define JMR3927_PCIIO 0x15000000
31#define JMR3927_PCIIO_SIZE 0x01000000 /* 16M */
32
33#define JMR3927_SDRAM_SIZE 0x02000000 /* 32M */
34#define JMR3927_PORT_BASE KSEG1
35
36/* Address map (virtual address) */
37#define JMR3927_ROM0_BASE (KSEG1 + JMR3927_ROMCE0)
38#define JMR3927_ROM1_BASE (KSEG1 + JMR3927_ROMCE1)
39#define JMR3927_IOC_BASE (KSEG1 + JMR3927_ROMCE2)
40#define JMR3927_PCIMEM_BASE (KSEG1 + JMR3927_PCIMEM)
41#define JMR3927_PCIIO_BASE (KSEG1 + JMR3927_PCIIO)
42
43#define JMR3927_IOC_REV_ADDR (JMR3927_IOC_BASE + 0x00000000)
44#define JMR3927_IOC_NVRAMB_ADDR (JMR3927_IOC_BASE + 0x00010000)
45#define JMR3927_IOC_LED_ADDR (JMR3927_IOC_BASE + 0x00020000)
46#define JMR3927_IOC_DIPSW_ADDR (JMR3927_IOC_BASE + 0x00030000)
47#define JMR3927_IOC_BREV_ADDR (JMR3927_IOC_BASE + 0x00040000)
48#define JMR3927_IOC_DTR_ADDR (JMR3927_IOC_BASE + 0x00050000)
49#define JMR3927_IOC_INTS1_ADDR (JMR3927_IOC_BASE + 0x00080000)
50#define JMR3927_IOC_INTS2_ADDR (JMR3927_IOC_BASE + 0x00090000)
51#define JMR3927_IOC_INTM_ADDR (JMR3927_IOC_BASE + 0x000a0000)
52#define JMR3927_IOC_INTP_ADDR (JMR3927_IOC_BASE + 0x000b0000)
53#define JMR3927_IOC_RESET_ADDR (JMR3927_IOC_BASE + 0x000f0000)
54
55/* Flash ROM */
56#define JMR3927_FLASH_BASE (JMR3927_ROM0_BASE)
57#define JMR3927_FLASH_SIZE 0x00400000
58
59/* bits for IOC_REV/IOC_BREV (high byte) */
60#define JMR3927_IDT_MASK 0xfc
61#define JMR3927_REV_MASK 0x03
62#define JMR3927_IOC_IDT 0xe0
63
64/* bits for IOC_INTS1/IOC_INTS2/IOC_INTM/IOC_INTP (high byte) */
65#define JMR3927_IOC_INTB_PCIA 0
66#define JMR3927_IOC_INTB_PCIB 1
67#define JMR3927_IOC_INTB_PCIC 2
68#define JMR3927_IOC_INTB_PCID 3
69#define JMR3927_IOC_INTB_MODEM 4
70#define JMR3927_IOC_INTB_INT6 5
71#define JMR3927_IOC_INTB_INT7 6
72#define JMR3927_IOC_INTB_SOFT 7
73#define JMR3927_IOC_INTF_PCIA (1 << JMR3927_IOC_INTF_PCIA)
74#define JMR3927_IOC_INTF_PCIB (1 << JMR3927_IOC_INTB_PCIB)
75#define JMR3927_IOC_INTF_PCIC (1 << JMR3927_IOC_INTB_PCIC)
76#define JMR3927_IOC_INTF_PCID (1 << JMR3927_IOC_INTB_PCID)
77#define JMR3927_IOC_INTF_MODEM (1 << JMR3927_IOC_INTB_MODEM)
78#define JMR3927_IOC_INTF_INT6 (1 << JMR3927_IOC_INTB_INT6)
79#define JMR3927_IOC_INTF_INT7 (1 << JMR3927_IOC_INTB_INT7)
80#define JMR3927_IOC_INTF_SOFT (1 << JMR3927_IOC_INTB_SOFT)
81
82/* bits for IOC_RESET (high byte) */
83#define JMR3927_IOC_RESET_CPU 1
84#define JMR3927_IOC_RESET_PCI 2
85
86#if defined(__BIG_ENDIAN)
87#define jmr3927_ioc_reg_out(d, a) ((*(volatile unsigned char *)(a)) = (d))
88#define jmr3927_ioc_reg_in(a) (*(volatile unsigned char *)(a))
89#elif defined(__LITTLE_ENDIAN)
90#define jmr3927_ioc_reg_out(d, a) ((*(volatile unsigned char *)((a)^1)) = (d))
91#define jmr3927_ioc_reg_in(a) (*(volatile unsigned char *)((a)^1))
92#else
93#error "No Endian"
94#endif
95
96/* LED macro */
97#define jmr3927_led_set(n/*0-16*/) jmr3927_ioc_reg_out(~(n), JMR3927_IOC_LED_ADDR)
98
99#define jmr3927_led_and_set(n/*0-16*/) jmr3927_ioc_reg_out((~(n)) & jmr3927_ioc_reg_in(JMR3927_IOC_LED_ADDR), JMR3927_IOC_LED_ADDR)
100
101/* DIPSW4 macro */
102#define jmr3927_dipsw1() (gpio_get_value(11) == 0)
103#define jmr3927_dipsw2() (gpio_get_value(10) == 0)
104#define jmr3927_dipsw3() ((jmr3927_ioc_reg_in(JMR3927_IOC_DIPSW_ADDR) & 2) == 0)
105#define jmr3927_dipsw4() ((jmr3927_ioc_reg_in(JMR3927_IOC_DIPSW_ADDR) & 1) == 0)
106
107/*
108 * IRQ mappings
109 */
110
111/* These are the virtual IRQ numbers, we divide all IRQ's into
112 * 'spaces', the 'space' determines where and how to enable/disable
113 * that particular IRQ on an JMR machine. Add new 'spaces' as new
114 * IRQ hardware is supported.
115 */
116#define JMR3927_NR_IRQ_IRC 16 /* On-Chip IRC */
117#define JMR3927_NR_IRQ_IOC 8 /* PCI/MODEM/INT[6:7] */
118
119#define JMR3927_IRQ_IRC TXX9_IRQ_BASE
120#define JMR3927_IRQ_IOC (JMR3927_IRQ_IRC + JMR3927_NR_IRQ_IRC)
121#define JMR3927_IRQ_END (JMR3927_IRQ_IOC + JMR3927_NR_IRQ_IOC)
122
123#define JMR3927_IRQ_IRC_INT0 (JMR3927_IRQ_IRC + TX3927_IR_INT0)
124#define JMR3927_IRQ_IRC_INT1 (JMR3927_IRQ_IRC + TX3927_IR_INT1)
125#define JMR3927_IRQ_IRC_INT2 (JMR3927_IRQ_IRC + TX3927_IR_INT2)
126#define JMR3927_IRQ_IRC_INT3 (JMR3927_IRQ_IRC + TX3927_IR_INT3)
127#define JMR3927_IRQ_IRC_INT4 (JMR3927_IRQ_IRC + TX3927_IR_INT4)
128#define JMR3927_IRQ_IRC_INT5 (JMR3927_IRQ_IRC + TX3927_IR_INT5)
129#define JMR3927_IRQ_IRC_SIO0 (JMR3927_IRQ_IRC + TX3927_IR_SIO0)
130#define JMR3927_IRQ_IRC_SIO1 (JMR3927_IRQ_IRC + TX3927_IR_SIO1)
131#define JMR3927_IRQ_IRC_SIO(ch) (JMR3927_IRQ_IRC + TX3927_IR_SIO(ch))
132#define JMR3927_IRQ_IRC_DMA (JMR3927_IRQ_IRC + TX3927_IR_DMA)
133#define JMR3927_IRQ_IRC_PIO (JMR3927_IRQ_IRC + TX3927_IR_PIO)
134#define JMR3927_IRQ_IRC_PCI (JMR3927_IRQ_IRC + TX3927_IR_PCI)
135#define JMR3927_IRQ_IRC_TMR(ch) (JMR3927_IRQ_IRC + TX3927_IR_TMR(ch))
136#define JMR3927_IRQ_IOC_PCIA (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIA)
137#define JMR3927_IRQ_IOC_PCIB (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIB)
138#define JMR3927_IRQ_IOC_PCIC (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIC)
139#define JMR3927_IRQ_IOC_PCID (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCID)
140#define JMR3927_IRQ_IOC_MODEM (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_MODEM)
141#define JMR3927_IRQ_IOC_INT6 (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_INT6)
142#define JMR3927_IRQ_IOC_INT7 (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_INT7)
143#define JMR3927_IRQ_IOC_SOFT (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_SOFT)
144
145/* IOC (PCI, MODEM) */
146#define JMR3927_IRQ_IOCINT JMR3927_IRQ_IRC_INT1
147/* TC35815 100M Ether (JMR-TX3912:JPW4:2-3 Short) */
148#define JMR3927_IRQ_ETHER0 JMR3927_IRQ_IRC_INT3
149
150/* Clocks */
151#define JMR3927_CORECLK 132710400 /* 132.7MHz */
152
153/*
154 * TX3927 Pin Configuration:
155 *
156 * PCFG bits Avail Dead
157 * SELSIO[1:0]:11 RXD[1:0], TXD[1:0] PIO[6:3]
158 * SELSIOC[0]:1 CTS[0], RTS[0] INT[5:4]
159 * SELSIOC[1]:0,SELDSF:0, GSDAO[0],GPCST[3] CTS[1], RTS[1],DSF,
160 * GDBGE* PIO[2:1]
161 * SELDMA[2]:1 DMAREQ[2],DMAACK[2] PIO[13:12]
162 * SELTMR[2:0]:000 TIMER[1:0]
163 * SELCS:0,SELDMA[1]:0 PIO[11;10] SDCS_CE[7:6],
164 * DMAREQ[1],DMAACK[1]
165 * SELDMA[0]:1 DMAREQ[0],DMAACK[0] PIO[9:8]
166 * SELDMA[3]:1 DMAREQ[3],DMAACK[3] PIO[15:14]
167 * SELDONE:1 DMADONE PIO[7]
168 *
169 * Usable pins are:
170 * RXD[1;0],TXD[1:0],CTS[0],RTS[0],
171 * DMAREQ[0,2,3],DMAACK[0,2,3],DMADONE,PIO[0,10,11]
172 * INT[3:0]
173 */
174
175void jmr3927_prom_init(void);
176void jmr3927_irq_setup(void);
177struct pci_dev;
178int jmr3927_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
179
180#endif /* __ASM_TXX9_JMR3927_H */
diff --git a/arch/mips/include/asm/txx9/pci.h b/arch/mips/include/asm/txx9/pci.h
new file mode 100644
index 000000000000..3d32529060aa
--- /dev/null
+++ b/arch/mips/include/asm/txx9/pci.h
@@ -0,0 +1,39 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 */
6#ifndef __ASM_TXX9_PCI_H
7#define __ASM_TXX9_PCI_H
8
9#include <linux/pci.h>
10
11extern struct pci_controller txx9_primary_pcic;
12struct pci_controller *
13txx9_alloc_pci_controller(struct pci_controller *pcic,
14 unsigned long mem_base, unsigned long mem_size,
15 unsigned long io_base, unsigned long io_size);
16
17int txx9_pci66_check(struct pci_controller *hose, int top_bus,
18 int current_bus);
19extern int txx9_pci_mem_high __initdata;
20
21extern int txx9_pci_option;
22#define TXX9_PCI_OPT_PICMG 0x0002
23#define TXX9_PCI_OPT_CLK_33 0x0008
24#define TXX9_PCI_OPT_CLK_66 0x0010
25#define TXX9_PCI_OPT_CLK_MASK \
26 (TXX9_PCI_OPT_CLK_33 | TXX9_PCI_OPT_CLK_66)
27#define TXX9_PCI_OPT_CLK_AUTO TXX9_PCI_OPT_CLK_MASK
28
29enum txx9_pci_err_action {
30 TXX9_PCI_ERR_REPORT,
31 TXX9_PCI_ERR_IGNORE,
32 TXX9_PCI_ERR_PANIC,
33};
34extern enum txx9_pci_err_action txx9_pci_err_action;
35
36extern char * (*txx9_board_pcibios_setup)(char *str);
37char *txx9_pcibios_setup(char *str);
38
39#endif /* __ASM_TXX9_PCI_H */
diff --git a/arch/mips/include/asm/txx9/rbtx4927.h b/arch/mips/include/asm/txx9/rbtx4927.h
new file mode 100644
index 000000000000..b2adab3d1acc
--- /dev/null
+++ b/arch/mips/include/asm/txx9/rbtx4927.h
@@ -0,0 +1,92 @@
1/*
2 * Author: MontaVista Software, Inc.
3 * source@mvista.com
4 *
5 * Copyright 2001-2002 MontaVista Software Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
17 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
18 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
20 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27#ifndef __ASM_TXX9_RBTX4927_H
28#define __ASM_TXX9_RBTX4927_H
29
30#include <asm/txx9/tx4927.h>
31
32#define RBTX4927_PCIMEM 0x08000000
33#define RBTX4927_PCIMEM_SIZE 0x08000000
34#define RBTX4927_PCIIO 0x16000000
35#define RBTX4927_PCIIO_SIZE 0x01000000
36
37#define RBTX4927_LED_ADDR (IO_BASE + TXX9_CE(2) + 0x00001000)
38#define RBTX4927_IMASK_ADDR (IO_BASE + TXX9_CE(2) + 0x00002000)
39#define RBTX4927_IMSTAT_ADDR (IO_BASE + TXX9_CE(2) + 0x00002006)
40#define RBTX4927_SOFTINT_ADDR (IO_BASE + TXX9_CE(2) + 0x00003000)
41#define RBTX4927_SOFTRESET_ADDR (IO_BASE + TXX9_CE(2) + 0x0000f000)
42#define RBTX4927_SOFTRESETLOCK_ADDR (IO_BASE + TXX9_CE(2) + 0x0000f002)
43#define RBTX4927_PCIRESET_ADDR (IO_BASE + TXX9_CE(2) + 0x0000f006)
44#define RBTX4927_BRAMRTC_BASE (IO_BASE + TXX9_CE(2) + 0x00010000)
45#define RBTX4927_ETHER_BASE (IO_BASE + TXX9_CE(2) + 0x00020000)
46
47/* Ethernet port address */
48#define RBTX4927_ETHER_ADDR (RBTX4927_ETHER_BASE + 0x280)
49
50#define rbtx4927_imask_addr ((__u8 __iomem *)RBTX4927_IMASK_ADDR)
51#define rbtx4927_imstat_addr ((__u8 __iomem *)RBTX4927_IMSTAT_ADDR)
52#define rbtx4927_softint_addr ((__u8 __iomem *)RBTX4927_SOFTINT_ADDR)
53#define rbtx4927_softreset_addr ((__u8 __iomem *)RBTX4927_SOFTRESET_ADDR)
54#define rbtx4927_softresetlock_addr \
55 ((__u8 __iomem *)RBTX4927_SOFTRESETLOCK_ADDR)
56#define rbtx4927_pcireset_addr ((__u8 __iomem *)RBTX4927_PCIRESET_ADDR)
57
58/* bits for ISTAT/IMASK/IMSTAT */
59#define RBTX4927_INTB_PCID 0
60#define RBTX4927_INTB_PCIC 1
61#define RBTX4927_INTB_PCIB 2
62#define RBTX4927_INTB_PCIA 3
63#define RBTX4927_INTF_PCID (1 << RBTX4927_INTB_PCID)
64#define RBTX4927_INTF_PCIC (1 << RBTX4927_INTB_PCIC)
65#define RBTX4927_INTF_PCIB (1 << RBTX4927_INTB_PCIB)
66#define RBTX4927_INTF_PCIA (1 << RBTX4927_INTB_PCIA)
67
68#define RBTX4927_NR_IRQ_IOC 8 /* IOC */
69
70#define RBTX4927_IRQ_IOC (TXX9_IRQ_BASE + TX4927_NUM_IR)
71#define RBTX4927_IRQ_IOC_PCID (RBTX4927_IRQ_IOC + RBTX4927_INTB_PCID)
72#define RBTX4927_IRQ_IOC_PCIC (RBTX4927_IRQ_IOC + RBTX4927_INTB_PCIC)
73#define RBTX4927_IRQ_IOC_PCIB (RBTX4927_IRQ_IOC + RBTX4927_INTB_PCIB)
74#define RBTX4927_IRQ_IOC_PCIA (RBTX4927_IRQ_IOC + RBTX4927_INTB_PCIA)
75
76#define RBTX4927_IRQ_IOCINT (TXX9_IRQ_BASE + TX4927_IR_INT(1))
77
78#ifdef CONFIG_PCI
79#define RBTX4927_ISA_IO_OFFSET RBTX4927_PCIIO
80#else
81#define RBTX4927_ISA_IO_OFFSET 0
82#endif
83
84#define RBTX4927_RTL_8019_BASE (RBTX4927_ETHER_ADDR - mips_io_port_base)
85#define RBTX4927_RTL_8019_IRQ (TXX9_IRQ_BASE + TX4927_IR_INT(3))
86
87void rbtx4927_prom_init(void);
88void rbtx4927_irq_setup(void);
89struct pci_dev;
90int rbtx4927_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
91
92#endif /* __ASM_TXX9_RBTX4927_H */
diff --git a/arch/mips/include/asm/txx9/rbtx4938.h b/arch/mips/include/asm/txx9/rbtx4938.h
new file mode 100644
index 000000000000..9f0441a28126
--- /dev/null
+++ b/arch/mips/include/asm/txx9/rbtx4938.h
@@ -0,0 +1,145 @@
1/*
2 * Definitions for TX4937/TX4938
3 *
4 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
5 * terms of the GNU General Public License version 2. This program is
6 * licensed "as is" without any warranty of any kind, whether express
7 * or implied.
8 *
9 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
10 */
11#ifndef __ASM_TXX9_RBTX4938_H
12#define __ASM_TXX9_RBTX4938_H
13
14#include <asm/addrspace.h>
15#include <asm/txx9irq.h>
16#include <asm/txx9/tx4938.h>
17
18/* Address map */
19#define RBTX4938_FPGA_REG_ADDR (IO_BASE + TXX9_CE(2) + 0x00000000)
20#define RBTX4938_FPGA_REV_ADDR (IO_BASE + TXX9_CE(2) + 0x00000002)
21#define RBTX4938_CONFIG1_ADDR (IO_BASE + TXX9_CE(2) + 0x00000004)
22#define RBTX4938_CONFIG2_ADDR (IO_BASE + TXX9_CE(2) + 0x00000006)
23#define RBTX4938_CONFIG3_ADDR (IO_BASE + TXX9_CE(2) + 0x00000008)
24#define RBTX4938_LED_ADDR (IO_BASE + TXX9_CE(2) + 0x00001000)
25#define RBTX4938_DIPSW_ADDR (IO_BASE + TXX9_CE(2) + 0x00001002)
26#define RBTX4938_BDIPSW_ADDR (IO_BASE + TXX9_CE(2) + 0x00001004)
27#define RBTX4938_IMASK_ADDR (IO_BASE + TXX9_CE(2) + 0x00002000)
28#define RBTX4938_IMASK2_ADDR (IO_BASE + TXX9_CE(2) + 0x00002002)
29#define RBTX4938_INTPOL_ADDR (IO_BASE + TXX9_CE(2) + 0x00002004)
30#define RBTX4938_ISTAT_ADDR (IO_BASE + TXX9_CE(2) + 0x00002006)
31#define RBTX4938_ISTAT2_ADDR (IO_BASE + TXX9_CE(2) + 0x00002008)
32#define RBTX4938_IMSTAT_ADDR (IO_BASE + TXX9_CE(2) + 0x0000200a)
33#define RBTX4938_IMSTAT2_ADDR (IO_BASE + TXX9_CE(2) + 0x0000200c)
34#define RBTX4938_SOFTINT_ADDR (IO_BASE + TXX9_CE(2) + 0x00003000)
35#define RBTX4938_PIOSEL_ADDR (IO_BASE + TXX9_CE(2) + 0x00005000)
36#define RBTX4938_SPICS_ADDR (IO_BASE + TXX9_CE(2) + 0x00005002)
37#define RBTX4938_SFPWR_ADDR (IO_BASE + TXX9_CE(2) + 0x00005008)
38#define RBTX4938_SFVOL_ADDR (IO_BASE + TXX9_CE(2) + 0x0000500a)
39#define RBTX4938_SOFTRESET_ADDR (IO_BASE + TXX9_CE(2) + 0x00007000)
40#define RBTX4938_SOFTRESETLOCK_ADDR (IO_BASE + TXX9_CE(2) + 0x00007002)
41#define RBTX4938_PCIRESET_ADDR (IO_BASE + TXX9_CE(2) + 0x00007004)
42#define RBTX4938_ETHER_BASE (IO_BASE + TXX9_CE(2) + 0x00020000)
43
44/* Ethernet port address (Jumperless Mode (W12:Open)) */
45#define RBTX4938_ETHER_ADDR (RBTX4938_ETHER_BASE + 0x280)
46
47/* bits for ISTAT/IMASK/IMSTAT */
48#define RBTX4938_INTB_PCID 0
49#define RBTX4938_INTB_PCIC 1
50#define RBTX4938_INTB_PCIB 2
51#define RBTX4938_INTB_PCIA 3
52#define RBTX4938_INTB_RTC 4
53#define RBTX4938_INTB_ATA 5
54#define RBTX4938_INTB_MODEM 6
55#define RBTX4938_INTB_SWINT 7
56#define RBTX4938_INTF_PCID (1 << RBTX4938_INTB_PCID)
57#define RBTX4938_INTF_PCIC (1 << RBTX4938_INTB_PCIC)
58#define RBTX4938_INTF_PCIB (1 << RBTX4938_INTB_PCIB)
59#define RBTX4938_INTF_PCIA (1 << RBTX4938_INTB_PCIA)
60#define RBTX4938_INTF_RTC (1 << RBTX4938_INTB_RTC)
61#define RBTX4938_INTF_ATA (1 << RBTX4938_INTB_ATA)
62#define RBTX4938_INTF_MODEM (1 << RBTX4938_INTB_MODEM)
63#define RBTX4938_INTF_SWINT (1 << RBTX4938_INTB_SWINT)
64
65#define rbtx4938_fpga_rev_addr ((__u8 __iomem *)RBTX4938_FPGA_REV_ADDR)
66#define rbtx4938_led_addr ((__u8 __iomem *)RBTX4938_LED_ADDR)
67#define rbtx4938_dipsw_addr ((__u8 __iomem *)RBTX4938_DIPSW_ADDR)
68#define rbtx4938_bdipsw_addr ((__u8 __iomem *)RBTX4938_BDIPSW_ADDR)
69#define rbtx4938_imask_addr ((__u8 __iomem *)RBTX4938_IMASK_ADDR)
70#define rbtx4938_imask2_addr ((__u8 __iomem *)RBTX4938_IMASK2_ADDR)
71#define rbtx4938_intpol_addr ((__u8 __iomem *)RBTX4938_INTPOL_ADDR)
72#define rbtx4938_istat_addr ((__u8 __iomem *)RBTX4938_ISTAT_ADDR)
73#define rbtx4938_istat2_addr ((__u8 __iomem *)RBTX4938_ISTAT2_ADDR)
74#define rbtx4938_imstat_addr ((__u8 __iomem *)RBTX4938_IMSTAT_ADDR)
75#define rbtx4938_imstat2_addr ((__u8 __iomem *)RBTX4938_IMSTAT2_ADDR)
76#define rbtx4938_softint_addr ((__u8 __iomem *)RBTX4938_SOFTINT_ADDR)
77#define rbtx4938_piosel_addr ((__u8 __iomem *)RBTX4938_PIOSEL_ADDR)
78#define rbtx4938_spics_addr ((__u8 __iomem *)RBTX4938_SPICS_ADDR)
79#define rbtx4938_sfpwr_addr ((__u8 __iomem *)RBTX4938_SFPWR_ADDR)
80#define rbtx4938_sfvol_addr ((__u8 __iomem *)RBTX4938_SFVOL_ADDR)
81#define rbtx4938_softreset_addr ((__u8 __iomem *)RBTX4938_SOFTRESET_ADDR)
82#define rbtx4938_softresetlock_addr \
83 ((__u8 __iomem *)RBTX4938_SOFTRESETLOCK_ADDR)
84#define rbtx4938_pcireset_addr ((__u8 __iomem *)RBTX4938_PCIRESET_ADDR)
85
86/*
87 * IRQ mappings
88 */
89
90#define RBTX4938_SOFT_INT0 0 /* not used */
91#define RBTX4938_SOFT_INT1 1 /* not used */
92#define RBTX4938_IRC_INT 2
93#define RBTX4938_TIMER_INT 7
94
95/* These are the virtual IRQ numbers, we divide all IRQ's into
96 * 'spaces', the 'space' determines where and how to enable/disable
97 * that particular IRQ on an RBTX4938 machine. Add new 'spaces' as new
98 * IRQ hardware is supported.
99 */
100#define RBTX4938_NR_IRQ_IOC 8
101
102#define RBTX4938_IRQ_IRC TXX9_IRQ_BASE
103#define RBTX4938_IRQ_IOC (TXX9_IRQ_BASE + TX4938_NUM_IR)
104#define RBTX4938_IRQ_END (RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC)
105
106#define RBTX4938_IRQ_IRC_ECCERR (RBTX4938_IRQ_IRC + TX4938_IR_ECCERR)
107#define RBTX4938_IRQ_IRC_WTOERR (RBTX4938_IRQ_IRC + TX4938_IR_WTOERR)
108#define RBTX4938_IRQ_IRC_INT(n) (RBTX4938_IRQ_IRC + TX4938_IR_INT(n))
109#define RBTX4938_IRQ_IRC_SIO(n) (RBTX4938_IRQ_IRC + TX4938_IR_SIO(n))
110#define RBTX4938_IRQ_IRC_DMA(ch, n) (RBTX4938_IRQ_IRC + TX4938_IR_DMA(ch, n))
111#define RBTX4938_IRQ_IRC_PIO (RBTX4938_IRQ_IRC + TX4938_IR_PIO)
112#define RBTX4938_IRQ_IRC_PDMAC (RBTX4938_IRQ_IRC + TX4938_IR_PDMAC)
113#define RBTX4938_IRQ_IRC_PCIC (RBTX4938_IRQ_IRC + TX4938_IR_PCIC)
114#define RBTX4938_IRQ_IRC_TMR(n) (RBTX4938_IRQ_IRC + TX4938_IR_TMR(n))
115#define RBTX4938_IRQ_IRC_NDFMC (RBTX4938_IRQ_IRC + TX4938_IR_NDFMC)
116#define RBTX4938_IRQ_IRC_PCIERR (RBTX4938_IRQ_IRC + TX4938_IR_PCIERR)
117#define RBTX4938_IRQ_IRC_PCIPME (RBTX4938_IRQ_IRC + TX4938_IR_PCIPME)
118#define RBTX4938_IRQ_IRC_ACLC (RBTX4938_IRQ_IRC + TX4938_IR_ACLC)
119#define RBTX4938_IRQ_IRC_ACLCPME (RBTX4938_IRQ_IRC + TX4938_IR_ACLCPME)
120#define RBTX4938_IRQ_IRC_PCIC1 (RBTX4938_IRQ_IRC + TX4938_IR_PCIC1)
121#define RBTX4938_IRQ_IRC_SPI (RBTX4938_IRQ_IRC + TX4938_IR_SPI)
122#define RBTX4938_IRQ_IOC_PCID (RBTX4938_IRQ_IOC + RBTX4938_INTB_PCID)
123#define RBTX4938_IRQ_IOC_PCIC (RBTX4938_IRQ_IOC + RBTX4938_INTB_PCIC)
124#define RBTX4938_IRQ_IOC_PCIB (RBTX4938_IRQ_IOC + RBTX4938_INTB_PCIB)
125#define RBTX4938_IRQ_IOC_PCIA (RBTX4938_IRQ_IOC + RBTX4938_INTB_PCIA)
126#define RBTX4938_IRQ_IOC_RTC (RBTX4938_IRQ_IOC + RBTX4938_INTB_RTC)
127#define RBTX4938_IRQ_IOC_ATA (RBTX4938_IRQ_IOC + RBTX4938_INTB_ATA)
128#define RBTX4938_IRQ_IOC_MODEM (RBTX4938_IRQ_IOC + RBTX4938_INTB_MODEM)
129#define RBTX4938_IRQ_IOC_SWINT (RBTX4938_IRQ_IOC + RBTX4938_INTB_SWINT)
130
131
132/* IOC (PCI, etc) */
133#define RBTX4938_IRQ_IOCINT (TXX9_IRQ_BASE + TX4938_IR_INT(0))
134/* Onboard 10M Ether */
135#define RBTX4938_IRQ_ETHER (TXX9_IRQ_BASE + TX4938_IR_INT(1))
136
137#define RBTX4938_RTL_8019_BASE (RBTX4938_ETHER_ADDR - mips_io_port_base)
138#define RBTX4938_RTL_8019_IRQ (RBTX4938_IRQ_ETHER)
139
140void rbtx4938_prom_init(void);
141void rbtx4938_irq_setup(void);
142struct pci_dev;
143int rbtx4938_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
144
145#endif /* __ASM_TXX9_RBTX4938_H */
diff --git a/arch/mips/include/asm/txx9/rbtx4939.h b/arch/mips/include/asm/txx9/rbtx4939.h
new file mode 100644
index 000000000000..1acf428c0b4f
--- /dev/null
+++ b/arch/mips/include/asm/txx9/rbtx4939.h
@@ -0,0 +1,133 @@
1/*
2 * Definitions for RBTX4939
3 *
4 * (C) Copyright TOSHIBA CORPORATION 2005-2006
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 */
10#ifndef __ASM_TXX9_RBTX4939_H
11#define __ASM_TXX9_RBTX4939_H
12
13#include <asm/addrspace.h>
14#include <asm/txx9irq.h>
15#include <asm/txx9/generic.h>
16#include <asm/txx9/tx4939.h>
17
18/* Address map */
19#define RBTX4939_IOC_REG_ADDR (IO_BASE + TXX9_CE(1) + 0x00000000)
20#define RBTX4939_BOARD_REV_ADDR (IO_BASE + TXX9_CE(1) + 0x00000000)
21#define RBTX4939_IOC_REV_ADDR (IO_BASE + TXX9_CE(1) + 0x00000002)
22#define RBTX4939_CONFIG1_ADDR (IO_BASE + TXX9_CE(1) + 0x00000004)
23#define RBTX4939_CONFIG2_ADDR (IO_BASE + TXX9_CE(1) + 0x00000006)
24#define RBTX4939_CONFIG3_ADDR (IO_BASE + TXX9_CE(1) + 0x00000008)
25#define RBTX4939_CONFIG4_ADDR (IO_BASE + TXX9_CE(1) + 0x0000000a)
26#define RBTX4939_USTAT_ADDR (IO_BASE + TXX9_CE(1) + 0x00001000)
27#define RBTX4939_UDIPSW_ADDR (IO_BASE + TXX9_CE(1) + 0x00001002)
28#define RBTX4939_BDIPSW_ADDR (IO_BASE + TXX9_CE(1) + 0x00001004)
29#define RBTX4939_IEN_ADDR (IO_BASE + TXX9_CE(1) + 0x00002000)
30#define RBTX4939_IPOL_ADDR (IO_BASE + TXX9_CE(1) + 0x00002002)
31#define RBTX4939_IFAC1_ADDR (IO_BASE + TXX9_CE(1) + 0x00002004)
32#define RBTX4939_IFAC2_ADDR (IO_BASE + TXX9_CE(1) + 0x00002006)
33#define RBTX4939_SOFTINT_ADDR (IO_BASE + TXX9_CE(1) + 0x00003000)
34#define RBTX4939_ISASTAT_ADDR (IO_BASE + TXX9_CE(1) + 0x00004000)
35#define RBTX4939_PCISTAT_ADDR (IO_BASE + TXX9_CE(1) + 0x00004002)
36#define RBTX4939_ROME_ADDR (IO_BASE + TXX9_CE(1) + 0x00004004)
37#define RBTX4939_SPICS_ADDR (IO_BASE + TXX9_CE(1) + 0x00004006)
38#define RBTX4939_AUDI_ADDR (IO_BASE + TXX9_CE(1) + 0x00004008)
39#define RBTX4939_ISAGPIO_ADDR (IO_BASE + TXX9_CE(1) + 0x0000400a)
40#define RBTX4939_PE1_ADDR (IO_BASE + TXX9_CE(1) + 0x00005000)
41#define RBTX4939_PE2_ADDR (IO_BASE + TXX9_CE(1) + 0x00005002)
42#define RBTX4939_PE3_ADDR (IO_BASE + TXX9_CE(1) + 0x00005004)
43#define RBTX4939_VP_ADDR (IO_BASE + TXX9_CE(1) + 0x00005006)
44#define RBTX4939_VPRESET_ADDR (IO_BASE + TXX9_CE(1) + 0x00005008)
45#define RBTX4939_VPSOUT_ADDR (IO_BASE + TXX9_CE(1) + 0x0000500a)
46#define RBTX4939_VPSIN_ADDR (IO_BASE + TXX9_CE(1) + 0x0000500c)
47#define RBTX4939_7SEG_ADDR(s, ch) \
48 (IO_BASE + TXX9_CE(1) + 0x00006000 + (s) * 16 + ((ch) & 3) * 2)
49#define RBTX4939_SOFTRESET_ADDR (IO_BASE + TXX9_CE(1) + 0x00007000)
50#define RBTX4939_RESETEN_ADDR (IO_BASE + TXX9_CE(1) + 0x00007002)
51#define RBTX4939_RESETSTAT_ADDR (IO_BASE + TXX9_CE(1) + 0x00007004)
52#define RBTX4939_ETHER_BASE (IO_BASE + TXX9_CE(1) + 0x00020000)
53
54/* Ethernet port address */
55#define RBTX4939_ETHER_ADDR (RBTX4939_ETHER_BASE + 0x300)
56
57/* bits for IEN/IPOL/IFAC */
58#define RBTX4938_INTB_ISA0 0
59#define RBTX4938_INTB_ISA11 1
60#define RBTX4938_INTB_ISA12 2
61#define RBTX4938_INTB_ISA15 3
62#define RBTX4938_INTB_I2S 4
63#define RBTX4938_INTB_SW 5
64#define RBTX4938_INTF_ISA0 (1 << RBTX4938_INTB_ISA0)
65#define RBTX4938_INTF_ISA11 (1 << RBTX4938_INTB_ISA11)
66#define RBTX4938_INTF_ISA12 (1 << RBTX4938_INTB_ISA12)
67#define RBTX4938_INTF_ISA15 (1 << RBTX4938_INTB_ISA15)
68#define RBTX4938_INTF_I2S (1 << RBTX4938_INTB_I2S)
69#define RBTX4938_INTF_SW (1 << RBTX4938_INTB_SW)
70
71/* bits for PE1,PE2,PE3 */
72#define RBTX4939_PE1_ATA(ch) (0x01 << (ch))
73#define RBTX4939_PE1_RMII(ch) (0x04 << (ch))
74#define RBTX4939_PE2_SIO0 0x01
75#define RBTX4939_PE2_SIO2 0x02
76#define RBTX4939_PE2_SIO3 0x04
77#define RBTX4939_PE2_CIR 0x08
78#define RBTX4939_PE2_SPI 0x10
79#define RBTX4939_PE2_GPIO 0x20
80#define RBTX4939_PE3_VP 0x01
81#define RBTX4939_PE3_VP_P 0x02
82#define RBTX4939_PE3_VP_S 0x04
83
84#define rbtx4939_board_rev_addr ((u8 __iomem *)RBTX4939_BOARD_REV_ADDR)
85#define rbtx4939_ioc_rev_addr ((u8 __iomem *)RBTX4939_IOC_REV_ADDR)
86#define rbtx4939_config1_addr ((u8 __iomem *)RBTX4939_CONFIG1_ADDR)
87#define rbtx4939_config2_addr ((u8 __iomem *)RBTX4939_CONFIG2_ADDR)
88#define rbtx4939_config3_addr ((u8 __iomem *)RBTX4939_CONFIG3_ADDR)
89#define rbtx4939_config4_addr ((u8 __iomem *)RBTX4939_CONFIG4_ADDR)
90#define rbtx4939_ustat_addr ((u8 __iomem *)RBTX4939_USTAT_ADDR)
91#define rbtx4939_udipsw_addr ((u8 __iomem *)RBTX4939_UDIPSW_ADDR)
92#define rbtx4939_bdipsw_addr ((u8 __iomem *)RBTX4939_BDIPSW_ADDR)
93#define rbtx4939_ien_addr ((u8 __iomem *)RBTX4939_IEN_ADDR)
94#define rbtx4939_ipol_addr ((u8 __iomem *)RBTX4939_IPOL_ADDR)
95#define rbtx4939_ifac1_addr ((u8 __iomem *)RBTX4939_IFAC1_ADDR)
96#define rbtx4939_ifac2_addr ((u8 __iomem *)RBTX4939_IFAC2_ADDR)
97#define rbtx4939_softint_addr ((u8 __iomem *)RBTX4939_SOFTINT_ADDR)
98#define rbtx4939_isastat_addr ((u8 __iomem *)RBTX4939_ISASTAT_ADDR)
99#define rbtx4939_pcistat_addr ((u8 __iomem *)RBTX4939_PCISTAT_ADDR)
100#define rbtx4939_rome_addr ((u8 __iomem *)RBTX4939_ROME_ADDR)
101#define rbtx4939_spics_addr ((u8 __iomem *)RBTX4939_SPICS_ADDR)
102#define rbtx4939_audi_addr ((u8 __iomem *)RBTX4939_AUDI_ADDR)
103#define rbtx4939_isagpio_addr ((u8 __iomem *)RBTX4939_ISAGPIO_ADDR)
104#define rbtx4939_pe1_addr ((u8 __iomem *)RBTX4939_PE1_ADDR)
105#define rbtx4939_pe2_addr ((u8 __iomem *)RBTX4939_PE2_ADDR)
106#define rbtx4939_pe3_addr ((u8 __iomem *)RBTX4939_PE3_ADDR)
107#define rbtx4939_vp_addr ((u8 __iomem *)RBTX4939_VP_ADDR)
108#define rbtx4939_vpreset_addr ((u8 __iomem *)RBTX4939_VPRESET_ADDR)
109#define rbtx4939_vpsout_addr ((u8 __iomem *)RBTX4939_VPSOUT_ADDR)
110#define rbtx4939_vpsin_addr ((u8 __iomem *)RBTX4939_VPSIN_ADDR)
111#define rbtx4939_7seg_addr(s, ch) \
112 ((u8 __iomem *)RBTX4939_7SEG_ADDR(s, ch))
113#define rbtx4939_softreset_addr ((u8 __iomem *)RBTX4939_SOFTRESET_ADDR)
114#define rbtx4939_reseten_addr ((u8 __iomem *)RBTX4939_RESETEN_ADDR)
115#define rbtx4939_resetstat_addr ((u8 __iomem *)RBTX4939_RESETSTAT_ADDR)
116
117/*
118 * IRQ mappings
119 */
120#define RBTX4939_NR_IRQ_IOC 8
121
122#define RBTX4939_IRQ_IOC (TXX9_IRQ_BASE + TX4939_NUM_IR)
123#define RBTX4939_IRQ_END (RBTX4939_IRQ_IOC + RBTX4939_NR_IRQ_IOC)
124
125/* IOC (ISA, etc) */
126#define RBTX4939_IRQ_IOCINT (TXX9_IRQ_BASE + TX4939_IR_INT(0))
127/* Onboard 10M Ether */
128#define RBTX4939_IRQ_ETHER (TXX9_IRQ_BASE + TX4939_IR_INT(1))
129
130void rbtx4939_prom_init(void);
131void rbtx4939_irq_setup(void);
132
133#endif /* __ASM_TXX9_RBTX4939_H */
diff --git a/arch/mips/include/asm/txx9/smsc_fdc37m81x.h b/arch/mips/include/asm/txx9/smsc_fdc37m81x.h
new file mode 100644
index 000000000000..d1d6332b4ca6
--- /dev/null
+++ b/arch/mips/include/asm/txx9/smsc_fdc37m81x.h
@@ -0,0 +1,68 @@
1/*
2 * Interface for smsc fdc48m81x Super IO chip
3 *
4 * Author: MontaVista Software, Inc. source@mvista.com
5 *
6 * 2001-2003 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 * Copyright (C) 2004 MontaVista Software Inc.
12 * Manish Lachwani, mlachwani@mvista.com
13 */
14
15#ifndef _SMSC_FDC37M81X_H_
16#define _SMSC_FDC37M81X_H_
17
18/* Common Registers */
19#define SMSC_FDC37M81X_CONFIG_INDEX 0x00
20#define SMSC_FDC37M81X_CONFIG_DATA 0x01
21#define SMSC_FDC37M81X_CONF 0x02
22#define SMSC_FDC37M81X_INDEX 0x03
23#define SMSC_FDC37M81X_DNUM 0x07
24#define SMSC_FDC37M81X_DID 0x20
25#define SMSC_FDC37M81X_DREV 0x21
26#define SMSC_FDC37M81X_PCNT 0x22
27#define SMSC_FDC37M81X_PMGT 0x23
28#define SMSC_FDC37M81X_OSC 0x24
29#define SMSC_FDC37M81X_CONFPA0 0x26
30#define SMSC_FDC37M81X_CONFPA1 0x27
31#define SMSC_FDC37M81X_TEST4 0x2B
32#define SMSC_FDC37M81X_TEST5 0x2C
33#define SMSC_FDC37M81X_TEST1 0x2D
34#define SMSC_FDC37M81X_TEST2 0x2E
35#define SMSC_FDC37M81X_TEST3 0x2F
36
37/* Logical device numbers */
38#define SMSC_FDC37M81X_FDD 0x00
39#define SMSC_FDC37M81X_PARALLEL 0x03
40#define SMSC_FDC37M81X_SERIAL1 0x04
41#define SMSC_FDC37M81X_SERIAL2 0x05
42#define SMSC_FDC37M81X_KBD 0x07
43#define SMSC_FDC37M81X_AUXIO 0x08
44#define SMSC_FDC37M81X_NONE 0xff
45
46/* Logical device Config Registers */
47#define SMSC_FDC37M81X_ACTIVE 0x30
48#define SMSC_FDC37M81X_BASEADDR0 0x60
49#define SMSC_FDC37M81X_BASEADDR1 0x61
50#define SMSC_FDC37M81X_INT 0x70
51#define SMSC_FDC37M81X_INT2 0x72
52#define SMSC_FDC37M81X_LDCR_F0 0xF0
53
54/* Chip Config Values */
55#define SMSC_FDC37M81X_CONFIG_ENTER 0x55
56#define SMSC_FDC37M81X_CONFIG_EXIT 0xaa
57#define SMSC_FDC37M81X_CHIP_ID 0x4d
58
59unsigned long smsc_fdc37m81x_init(unsigned long port);
60
61void smsc_fdc37m81x_config_beg(void);
62
63void smsc_fdc37m81x_config_end(void);
64
65u8 smsc_fdc37m81x_config_get(u8 reg);
66void smsc_fdc37m81x_config_set(u8 reg, u8 val);
67
68#endif
diff --git a/arch/mips/include/asm/txx9/spi.h b/arch/mips/include/asm/txx9/spi.h
new file mode 100644
index 000000000000..0d727f354557
--- /dev/null
+++ b/arch/mips/include/asm/txx9/spi.h
@@ -0,0 +1,34 @@
1/*
2 * Definitions for TX4937/TX4938 SPI
3 *
4 * Copyright (C) 2000-2001 Toshiba Corporation
5 *
6 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
7 * terms of the GNU General Public License version 2. This program is
8 * licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
12 */
13#ifndef __ASM_TXX9_SPI_H
14#define __ASM_TXX9_SPI_H
15
16#include <linux/errno.h>
17
18#ifdef CONFIG_SPI
19int spi_eeprom_register(int busid, int chipid, int size);
20int spi_eeprom_read(int busid, int chipid,
21 int address, unsigned char *buf, int len);
22#else
23static inline int spi_eeprom_register(int busid, int chipid, int size)
24{
25 return -ENODEV;
26}
27static inline int spi_eeprom_read(int busid, int chipid,
28 int address, unsigned char *buf, int len)
29{
30 return -ENODEV;
31}
32#endif
33
34#endif /* __ASM_TXX9_SPI_H */
diff --git a/arch/mips/include/asm/txx9/tx3927.h b/arch/mips/include/asm/txx9/tx3927.h
new file mode 100644
index 000000000000..dc30c8d42061
--- /dev/null
+++ b/arch/mips/include/asm/txx9/tx3927.h
@@ -0,0 +1,341 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000 Toshiba Corporation
7 */
8#ifndef __ASM_TXX9_TX3927_H
9#define __ASM_TXX9_TX3927_H
10
11#define TX3927_REG_BASE 0xfffe0000UL
12#define TX3927_REG_SIZE 0x00010000
13#define TX3927_SDRAMC_REG (TX3927_REG_BASE + 0x8000)
14#define TX3927_ROMC_REG (TX3927_REG_BASE + 0x9000)
15#define TX3927_DMA_REG (TX3927_REG_BASE + 0xb000)
16#define TX3927_IRC_REG (TX3927_REG_BASE + 0xc000)
17#define TX3927_PCIC_REG (TX3927_REG_BASE + 0xd000)
18#define TX3927_CCFG_REG (TX3927_REG_BASE + 0xe000)
19#define TX3927_NR_TMR 3
20#define TX3927_TMR_REG(ch) (TX3927_REG_BASE + 0xf000 + (ch) * 0x100)
21#define TX3927_NR_SIO 2
22#define TX3927_SIO_REG(ch) (TX3927_REG_BASE + 0xf300 + (ch) * 0x100)
23#define TX3927_PIO_REG (TX3927_REG_BASE + 0xf500)
24
25struct tx3927_sdramc_reg {
26 volatile unsigned long cr[8];
27 volatile unsigned long tr[3];
28 volatile unsigned long cmd;
29 volatile unsigned long smrs[2];
30};
31
32struct tx3927_romc_reg {
33 volatile unsigned long cr[8];
34};
35
36struct tx3927_dma_reg {
37 struct tx3927_dma_ch_reg {
38 volatile unsigned long cha;
39 volatile unsigned long sar;
40 volatile unsigned long dar;
41 volatile unsigned long cntr;
42 volatile unsigned long sair;
43 volatile unsigned long dair;
44 volatile unsigned long ccr;
45 volatile unsigned long csr;
46 } ch[4];
47 volatile unsigned long dbr[8];
48 volatile unsigned long tdhr;
49 volatile unsigned long mcr;
50 volatile unsigned long unused0;
51};
52
53#include <asm/byteorder.h>
54
55#ifdef __BIG_ENDIAN
56#define endian_def_s2(e1, e2) \
57 volatile unsigned short e1, e2
58#define endian_def_sb2(e1, e2, e3) \
59 volatile unsigned short e1;volatile unsigned char e2, e3
60#define endian_def_b2s(e1, e2, e3) \
61 volatile unsigned char e1, e2;volatile unsigned short e3
62#define endian_def_b4(e1, e2, e3, e4) \
63 volatile unsigned char e1, e2, e3, e4
64#else
65#define endian_def_s2(e1, e2) \
66 volatile unsigned short e2, e1
67#define endian_def_sb2(e1, e2, e3) \
68 volatile unsigned char e3, e2;volatile unsigned short e1
69#define endian_def_b2s(e1, e2, e3) \
70 volatile unsigned short e3;volatile unsigned char e2, e1
71#define endian_def_b4(e1, e2, e3, e4) \
72 volatile unsigned char e4, e3, e2, e1
73#endif
74
75struct tx3927_pcic_reg {
76 endian_def_s2(did, vid);
77 endian_def_s2(pcistat, pcicmd);
78 endian_def_b4(cc, scc, rpli, rid);
79 endian_def_b4(unused0, ht, mlt, cls);
80 volatile unsigned long ioba; /* +10 */
81 volatile unsigned long mba;
82 volatile unsigned long unused1[5];
83 endian_def_s2(svid, ssvid);
84 volatile unsigned long unused2; /* +30 */
85 endian_def_sb2(unused3, unused4, capptr);
86 volatile unsigned long unused5;
87 endian_def_b4(ml, mg, ip, il);
88 volatile unsigned long unused6; /* +40 */
89 volatile unsigned long istat;
90 volatile unsigned long iim;
91 volatile unsigned long rrt;
92 volatile unsigned long unused7[3]; /* +50 */
93 volatile unsigned long ipbmma;
94 volatile unsigned long ipbioma; /* +60 */
95 volatile unsigned long ilbmma;
96 volatile unsigned long ilbioma;
97 volatile unsigned long unused8[9];
98 volatile unsigned long tc; /* +90 */
99 volatile unsigned long tstat;
100 volatile unsigned long tim;
101 volatile unsigned long tccmd;
102 volatile unsigned long pcirrt; /* +a0 */
103 volatile unsigned long pcirrt_cmd;
104 volatile unsigned long pcirrdt;
105 volatile unsigned long unused9[3];
106 volatile unsigned long tlboap;
107 volatile unsigned long tlbiap;
108 volatile unsigned long tlbmma; /* +c0 */
109 volatile unsigned long tlbioma;
110 volatile unsigned long sc_msg;
111 volatile unsigned long sc_be;
112 volatile unsigned long tbl; /* +d0 */
113 volatile unsigned long unused10[3];
114 volatile unsigned long pwmng; /* +e0 */
115 volatile unsigned long pwmngs;
116 volatile unsigned long unused11[6];
117 volatile unsigned long req_trace; /* +100 */
118 volatile unsigned long pbapmc;
119 volatile unsigned long pbapms;
120 volatile unsigned long pbapmim;
121 volatile unsigned long bm; /* +110 */
122 volatile unsigned long cpcibrs;
123 volatile unsigned long cpcibgs;
124 volatile unsigned long pbacs;
125 volatile unsigned long iobas; /* +120 */
126 volatile unsigned long mbas;
127 volatile unsigned long lbc;
128 volatile unsigned long lbstat;
129 volatile unsigned long lbim; /* +130 */
130 volatile unsigned long pcistatim;
131 volatile unsigned long ica;
132 volatile unsigned long icd;
133 volatile unsigned long iiadp; /* +140 */
134 volatile unsigned long iscdp;
135 volatile unsigned long mmas;
136 volatile unsigned long iomas;
137 volatile unsigned long ipciaddr; /* +150 */
138 volatile unsigned long ipcidata;
139 volatile unsigned long ipcibe;
140};
141
142struct tx3927_ccfg_reg {
143 volatile unsigned long ccfg;
144 volatile unsigned long crir;
145 volatile unsigned long pcfg;
146 volatile unsigned long tear;
147 volatile unsigned long pdcr;
148};
149
150/*
151 * SDRAMC
152 */
153
154/*
155 * ROMC
156 */
157
158/*
159 * DMA
160 */
161/* bits for MCR */
162#define TX3927_DMA_MCR_EIS(ch) (0x10000000<<(ch))
163#define TX3927_DMA_MCR_DIS(ch) (0x01000000<<(ch))
164#define TX3927_DMA_MCR_RSFIF 0x00000080
165#define TX3927_DMA_MCR_FIFUM(ch) (0x00000008<<(ch))
166#define TX3927_DMA_MCR_LE 0x00000004
167#define TX3927_DMA_MCR_RPRT 0x00000002
168#define TX3927_DMA_MCR_MSTEN 0x00000001
169
170/* bits for CCRn */
171#define TX3927_DMA_CCR_DBINH 0x04000000
172#define TX3927_DMA_CCR_SBINH 0x02000000
173#define TX3927_DMA_CCR_CHRST 0x01000000
174#define TX3927_DMA_CCR_RVBYTE 0x00800000
175#define TX3927_DMA_CCR_ACKPOL 0x00400000
176#define TX3927_DMA_CCR_REQPL 0x00200000
177#define TX3927_DMA_CCR_EGREQ 0x00100000
178#define TX3927_DMA_CCR_CHDN 0x00080000
179#define TX3927_DMA_CCR_DNCTL 0x00060000
180#define TX3927_DMA_CCR_EXTRQ 0x00010000
181#define TX3927_DMA_CCR_INTRQD 0x0000e000
182#define TX3927_DMA_CCR_INTENE 0x00001000
183#define TX3927_DMA_CCR_INTENC 0x00000800
184#define TX3927_DMA_CCR_INTENT 0x00000400
185#define TX3927_DMA_CCR_CHNEN 0x00000200
186#define TX3927_DMA_CCR_XFACT 0x00000100
187#define TX3927_DMA_CCR_SNOP 0x00000080
188#define TX3927_DMA_CCR_DSTINC 0x00000040
189#define TX3927_DMA_CCR_SRCINC 0x00000020
190#define TX3927_DMA_CCR_XFSZ(order) (((order) << 2) & 0x0000001c)
191#define TX3927_DMA_CCR_XFSZ_1W TX3927_DMA_CCR_XFSZ(2)
192#define TX3927_DMA_CCR_XFSZ_4W TX3927_DMA_CCR_XFSZ(4)
193#define TX3927_DMA_CCR_XFSZ_8W TX3927_DMA_CCR_XFSZ(5)
194#define TX3927_DMA_CCR_XFSZ_16W TX3927_DMA_CCR_XFSZ(6)
195#define TX3927_DMA_CCR_XFSZ_32W TX3927_DMA_CCR_XFSZ(7)
196#define TX3927_DMA_CCR_MEMIO 0x00000002
197#define TX3927_DMA_CCR_ONEAD 0x00000001
198
199/* bits for CSRn */
200#define TX3927_DMA_CSR_CHNACT 0x00000100
201#define TX3927_DMA_CSR_ABCHC 0x00000080
202#define TX3927_DMA_CSR_NCHNC 0x00000040
203#define TX3927_DMA_CSR_NTRNFC 0x00000020
204#define TX3927_DMA_CSR_EXTDN 0x00000010
205#define TX3927_DMA_CSR_CFERR 0x00000008
206#define TX3927_DMA_CSR_CHERR 0x00000004
207#define TX3927_DMA_CSR_DESERR 0x00000002
208#define TX3927_DMA_CSR_SORERR 0x00000001
209
210/*
211 * IRC
212 */
213#define TX3927_IR_INT0 0
214#define TX3927_IR_INT1 1
215#define TX3927_IR_INT2 2
216#define TX3927_IR_INT3 3
217#define TX3927_IR_INT4 4
218#define TX3927_IR_INT5 5
219#define TX3927_IR_SIO0 6
220#define TX3927_IR_SIO1 7
221#define TX3927_IR_SIO(ch) (6 + (ch))
222#define TX3927_IR_DMA 8
223#define TX3927_IR_PIO 9
224#define TX3927_IR_PCI 10
225#define TX3927_IR_TMR(ch) (13 + (ch))
226#define TX3927_NUM_IR 16
227
228/*
229 * PCIC
230 */
231/* bits for PCICMD */
232/* see PCI_COMMAND_XXX in linux/pci.h */
233
234/* bits for PCISTAT */
235/* see PCI_STATUS_XXX in linux/pci.h */
236#define PCI_STATUS_NEW_CAP 0x0010
237
238/* bits for ISTAT/IIM */
239#define TX3927_PCIC_IIM_ALL 0x00001600
240
241/* bits for TC */
242#define TX3927_PCIC_TC_OF16E 0x00000020
243#define TX3927_PCIC_TC_IF8E 0x00000010
244#define TX3927_PCIC_TC_OF8E 0x00000008
245
246/* bits for TSTAT/TIM */
247#define TX3927_PCIC_TIM_ALL 0x0003ffff
248
249/* bits for IOBA/MBA */
250/* see PCI_BASE_ADDRESS_XXX in linux/pci.h */
251
252/* bits for PBAPMC */
253#define TX3927_PCIC_PBAPMC_RPBA 0x00000004
254#define TX3927_PCIC_PBAPMC_PBAEN 0x00000002
255#define TX3927_PCIC_PBAPMC_BMCEN 0x00000001
256
257/* bits for LBSTAT/LBIM */
258#define TX3927_PCIC_LBIM_ALL 0x0000003e
259
260/* bits for PCISTATIM (see also PCI_STATUS_XXX in linux/pci.h */
261#define TX3927_PCIC_PCISTATIM_ALL 0x0000f900
262
263/* bits for LBC */
264#define TX3927_PCIC_LBC_IBSE 0x00004000
265#define TX3927_PCIC_LBC_TIBSE 0x00002000
266#define TX3927_PCIC_LBC_TMFBSE 0x00001000
267#define TX3927_PCIC_LBC_HRST 0x00000800
268#define TX3927_PCIC_LBC_SRST 0x00000400
269#define TX3927_PCIC_LBC_EPCAD 0x00000200
270#define TX3927_PCIC_LBC_MSDSE 0x00000100
271#define TX3927_PCIC_LBC_CRR 0x00000080
272#define TX3927_PCIC_LBC_ILMDE 0x00000040
273#define TX3927_PCIC_LBC_ILIDE 0x00000020
274
275#define TX3927_PCIC_IDSEL_AD_TO_SLOT(ad) ((ad) - 11)
276#define TX3927_PCIC_MAX_DEVNU TX3927_PCIC_IDSEL_AD_TO_SLOT(32)
277
278/*
279 * CCFG
280 */
281/* CCFG : Chip Configuration */
282#define TX3927_CCFG_TLBOFF 0x00020000
283#define TX3927_CCFG_BEOW 0x00010000
284#define TX3927_CCFG_WR 0x00008000
285#define TX3927_CCFG_TOE 0x00004000
286#define TX3927_CCFG_PCIXARB 0x00002000
287#define TX3927_CCFG_PCI3 0x00001000
288#define TX3927_CCFG_PSNP 0x00000800
289#define TX3927_CCFG_PPRI 0x00000400
290#define TX3927_CCFG_PLLM 0x00000030
291#define TX3927_CCFG_ENDIAN 0x00000004
292#define TX3927_CCFG_HALT 0x00000002
293#define TX3927_CCFG_ACEHOLD 0x00000001
294
295/* PCFG : Pin Configuration */
296#define TX3927_PCFG_SYSCLKEN 0x08000000
297#define TX3927_PCFG_SDRCLKEN_ALL 0x07c00000
298#define TX3927_PCFG_SDRCLKEN(ch) (0x00400000<<(ch))
299#define TX3927_PCFG_PCICLKEN_ALL 0x003c0000
300#define TX3927_PCFG_PCICLKEN(ch) (0x00040000<<(ch))
301#define TX3927_PCFG_SELALL 0x0003ffff
302#define TX3927_PCFG_SELCS 0x00020000
303#define TX3927_PCFG_SELDSF 0x00010000
304#define TX3927_PCFG_SELSIOC_ALL 0x0000c000
305#define TX3927_PCFG_SELSIOC(ch) (0x00004000<<(ch))
306#define TX3927_PCFG_SELSIO_ALL 0x00003000
307#define TX3927_PCFG_SELSIO(ch) (0x00001000<<(ch))
308#define TX3927_PCFG_SELTMR_ALL 0x00000e00
309#define TX3927_PCFG_SELTMR(ch) (0x00000200<<(ch))
310#define TX3927_PCFG_SELDONE 0x00000100
311#define TX3927_PCFG_INTDMA_ALL 0x000000f0
312#define TX3927_PCFG_INTDMA(ch) (0x00000010<<(ch))
313#define TX3927_PCFG_SELDMA_ALL 0x0000000f
314#define TX3927_PCFG_SELDMA(ch) (0x00000001<<(ch))
315
316#define tx3927_sdramcptr ((struct tx3927_sdramc_reg *)TX3927_SDRAMC_REG)
317#define tx3927_romcptr ((struct tx3927_romc_reg *)TX3927_ROMC_REG)
318#define tx3927_dmaptr ((struct tx3927_dma_reg *)TX3927_DMA_REG)
319#define tx3927_pcicptr ((struct tx3927_pcic_reg *)TX3927_PCIC_REG)
320#define tx3927_ccfgptr ((struct tx3927_ccfg_reg *)TX3927_CCFG_REG)
321#define tx3927_sioptr(ch) ((struct txx927_sio_reg *)TX3927_SIO_REG(ch))
322#define tx3927_pioptr ((struct txx9_pio_reg __iomem *)TX3927_PIO_REG)
323
324#define TX3927_REV_PCODE() (tx3927_ccfgptr->crir >> 16)
325#define TX3927_ROMC_BA(ch) (tx3927_romcptr->cr[(ch)] & 0xfff00000)
326#define TX3927_ROMC_SIZE(ch) \
327 (0x00100000 << ((tx3927_romcptr->cr[(ch)] >> 8) & 0xf))
328#define TX3927_ROMC_WIDTH(ch) (32 >> ((tx3927_romcptr->cr[(ch)] >> 7) & 0x1))
329
330void tx3927_wdt_init(void);
331void tx3927_setup(void);
332void tx3927_time_init(unsigned int evt_tmrnr, unsigned int src_tmrnr);
333void tx3927_sio_init(unsigned int sclk, unsigned int cts_mask);
334struct pci_controller;
335void tx3927_pcic_setup(struct pci_controller *channel,
336 unsigned long sdram_size, int extarb);
337void tx3927_setup_pcierr_irq(void);
338void tx3927_irq_init(void);
339void tx3927_mtd_init(int ch);
340
341#endif /* __ASM_TXX9_TX3927_H */
diff --git a/arch/mips/include/asm/txx9/tx4927.h b/arch/mips/include/asm/txx9/tx4927.h
new file mode 100644
index 000000000000..7d813f1cb98d
--- /dev/null
+++ b/arch/mips/include/asm/txx9/tx4927.h
@@ -0,0 +1,269 @@
1/*
2 * Author: MontaVista Software, Inc.
3 * source@mvista.com
4 *
5 * Copyright 2001-2006 MontaVista Software Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
17 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
18 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
20 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27#ifndef __ASM_TXX9_TX4927_H
28#define __ASM_TXX9_TX4927_H
29
30#include <linux/types.h>
31#include <linux/io.h>
32#include <asm/txx9irq.h>
33#include <asm/txx9/tx4927pcic.h>
34
35#ifdef CONFIG_64BIT
36#define TX4927_REG_BASE 0xffffffffff1f0000UL
37#else
38#define TX4927_REG_BASE 0xff1f0000UL
39#endif
40#define TX4927_REG_SIZE 0x00010000
41
42#define TX4927_SDRAMC_REG (TX4927_REG_BASE + 0x8000)
43#define TX4927_EBUSC_REG (TX4927_REG_BASE + 0x9000)
44#define TX4927_PCIC_REG (TX4927_REG_BASE + 0xd000)
45#define TX4927_CCFG_REG (TX4927_REG_BASE + 0xe000)
46#define TX4927_IRC_REG (TX4927_REG_BASE + 0xf600)
47#define TX4927_NR_TMR 3
48#define TX4927_TMR_REG(ch) (TX4927_REG_BASE + 0xf000 + (ch) * 0x100)
49#define TX4927_NR_SIO 2
50#define TX4927_SIO_REG(ch) (TX4927_REG_BASE + 0xf300 + (ch) * 0x100)
51#define TX4927_PIO_REG (TX4927_REG_BASE + 0xf500)
52
53#define TX4927_IR_ECCERR 0
54#define TX4927_IR_WTOERR 1
55#define TX4927_NUM_IR_INT 6
56#define TX4927_IR_INT(n) (2 + (n))
57#define TX4927_NUM_IR_SIO 2
58#define TX4927_IR_SIO(n) (8 + (n))
59#define TX4927_NUM_IR_DMA 4
60#define TX4927_IR_DMA(n) (10 + (n))
61#define TX4927_IR_PIO 14
62#define TX4927_IR_PDMAC 15
63#define TX4927_IR_PCIC 16
64#define TX4927_NUM_IR_TMR 3
65#define TX4927_IR_TMR(n) (17 + (n))
66#define TX4927_IR_PCIERR 22
67#define TX4927_IR_PCIPME 23
68#define TX4927_IR_ACLC 24
69#define TX4927_IR_ACLCPME 25
70#define TX4927_NUM_IR 32
71
72#define TX4927_IRC_INT 2 /* IP[2] in Status register */
73
74#define TX4927_NUM_PIO 16
75
76struct tx4927_sdramc_reg {
77 u64 cr[4];
78 u64 unused0[4];
79 u64 tr;
80 u64 unused1[2];
81 u64 cmd;
82};
83
84struct tx4927_ebusc_reg {
85 u64 cr[8];
86};
87
88struct tx4927_ccfg_reg {
89 u64 ccfg;
90 u64 crir;
91 u64 pcfg;
92 u64 toea;
93 u64 clkctr;
94 u64 unused0;
95 u64 garbc;
96 u64 unused1;
97 u64 unused2;
98 u64 ramp;
99};
100
101/*
102 * CCFG
103 */
104/* CCFG : Chip Configuration */
105#define TX4927_CCFG_WDRST 0x0000020000000000ULL
106#define TX4927_CCFG_WDREXEN 0x0000010000000000ULL
107#define TX4927_CCFG_BCFG_MASK 0x000000ff00000000ULL
108#define TX4927_CCFG_TINTDIS 0x01000000
109#define TX4927_CCFG_PCI66 0x00800000
110#define TX4927_CCFG_PCIMODE 0x00400000
111#define TX4927_CCFG_DIVMODE_MASK 0x000e0000
112#define TX4927_CCFG_DIVMODE_8 (0x0 << 17)
113#define TX4927_CCFG_DIVMODE_12 (0x1 << 17)
114#define TX4927_CCFG_DIVMODE_16 (0x2 << 17)
115#define TX4927_CCFG_DIVMODE_10 (0x3 << 17)
116#define TX4927_CCFG_DIVMODE_2 (0x4 << 17)
117#define TX4927_CCFG_DIVMODE_3 (0x5 << 17)
118#define TX4927_CCFG_DIVMODE_4 (0x6 << 17)
119#define TX4927_CCFG_DIVMODE_2_5 (0x7 << 17)
120#define TX4927_CCFG_BEOW 0x00010000
121#define TX4927_CCFG_WR 0x00008000
122#define TX4927_CCFG_TOE 0x00004000
123#define TX4927_CCFG_PCIARB 0x00002000
124#define TX4927_CCFG_PCIDIVMODE_MASK 0x00001800
125#define TX4927_CCFG_PCIDIVMODE_2_5 0x00000000
126#define TX4927_CCFG_PCIDIVMODE_3 0x00000800
127#define TX4927_CCFG_PCIDIVMODE_5 0x00001000
128#define TX4927_CCFG_PCIDIVMODE_6 0x00001800
129#define TX4927_CCFG_SYSSP_MASK 0x000000c0
130#define TX4927_CCFG_ENDIAN 0x00000004
131#define TX4927_CCFG_HALT 0x00000002
132#define TX4927_CCFG_ACEHOLD 0x00000001
133#define TX4927_CCFG_W1CBITS (TX4927_CCFG_WDRST | TX4927_CCFG_BEOW)
134
135/* PCFG : Pin Configuration */
136#define TX4927_PCFG_SDCLKDLY_MASK 0x30000000
137#define TX4927_PCFG_SDCLKDLY(d) ((d)<<28)
138#define TX4927_PCFG_SYSCLKEN 0x08000000
139#define TX4927_PCFG_SDCLKEN_ALL 0x07800000
140#define TX4927_PCFG_SDCLKEN(ch) (0x00800000<<(ch))
141#define TX4927_PCFG_PCICLKEN_ALL 0x003f0000
142#define TX4927_PCFG_PCICLKEN(ch) (0x00010000<<(ch))
143#define TX4927_PCFG_SEL2 0x00000200
144#define TX4927_PCFG_SEL1 0x00000100
145#define TX4927_PCFG_DMASEL_ALL 0x000000ff
146#define TX4927_PCFG_DMASEL0_MASK 0x00000003
147#define TX4927_PCFG_DMASEL1_MASK 0x0000000c
148#define TX4927_PCFG_DMASEL2_MASK 0x00000030
149#define TX4927_PCFG_DMASEL3_MASK 0x000000c0
150#define TX4927_PCFG_DMASEL0_DRQ0 0x00000000
151#define TX4927_PCFG_DMASEL0_SIO1 0x00000001
152#define TX4927_PCFG_DMASEL0_ACL0 0x00000002
153#define TX4927_PCFG_DMASEL0_ACL2 0x00000003
154#define TX4927_PCFG_DMASEL1_DRQ1 0x00000000
155#define TX4927_PCFG_DMASEL1_SIO1 0x00000004
156#define TX4927_PCFG_DMASEL1_ACL1 0x00000008
157#define TX4927_PCFG_DMASEL1_ACL3 0x0000000c
158#define TX4927_PCFG_DMASEL2_DRQ2 0x00000000 /* SEL2=0 */
159#define TX4927_PCFG_DMASEL2_SIO0 0x00000010 /* SEL2=0 */
160#define TX4927_PCFG_DMASEL2_ACL1 0x00000000 /* SEL2=1 */
161#define TX4927_PCFG_DMASEL2_ACL2 0x00000020 /* SEL2=1 */
162#define TX4927_PCFG_DMASEL2_ACL0 0x00000030 /* SEL2=1 */
163#define TX4927_PCFG_DMASEL3_DRQ3 0x00000000
164#define TX4927_PCFG_DMASEL3_SIO0 0x00000040
165#define TX4927_PCFG_DMASEL3_ACL3 0x00000080
166#define TX4927_PCFG_DMASEL3_ACL1 0x000000c0
167
168/* CLKCTR : Clock Control */
169#define TX4927_CLKCTR_ACLCKD 0x02000000
170#define TX4927_CLKCTR_PIOCKD 0x01000000
171#define TX4927_CLKCTR_DMACKD 0x00800000
172#define TX4927_CLKCTR_PCICKD 0x00400000
173#define TX4927_CLKCTR_TM0CKD 0x00100000
174#define TX4927_CLKCTR_TM1CKD 0x00080000
175#define TX4927_CLKCTR_TM2CKD 0x00040000
176#define TX4927_CLKCTR_SIO0CKD 0x00020000
177#define TX4927_CLKCTR_SIO1CKD 0x00010000
178#define TX4927_CLKCTR_ACLRST 0x00000200
179#define TX4927_CLKCTR_PIORST 0x00000100
180#define TX4927_CLKCTR_DMARST 0x00000080
181#define TX4927_CLKCTR_PCIRST 0x00000040
182#define TX4927_CLKCTR_TM0RST 0x00000010
183#define TX4927_CLKCTR_TM1RST 0x00000008
184#define TX4927_CLKCTR_TM2RST 0x00000004
185#define TX4927_CLKCTR_SIO0RST 0x00000002
186#define TX4927_CLKCTR_SIO1RST 0x00000001
187
188#define tx4927_sdramcptr \
189 ((struct tx4927_sdramc_reg __iomem *)TX4927_SDRAMC_REG)
190#define tx4927_pcicptr \
191 ((struct tx4927_pcic_reg __iomem *)TX4927_PCIC_REG)
192#define tx4927_ccfgptr \
193 ((struct tx4927_ccfg_reg __iomem *)TX4927_CCFG_REG)
194#define tx4927_ebuscptr \
195 ((struct tx4927_ebusc_reg __iomem *)TX4927_EBUSC_REG)
196#define tx4927_pioptr ((struct txx9_pio_reg __iomem *)TX4927_PIO_REG)
197
198#define TX4927_REV_PCODE() \
199 ((__u32)__raw_readq(&tx4927_ccfgptr->crir) >> 16)
200
201#define TX4927_SDRAMC_CR(ch) __raw_readq(&tx4927_sdramcptr->cr[(ch)])
202#define TX4927_SDRAMC_BA(ch) ((TX4927_SDRAMC_CR(ch) >> 49) << 21)
203#define TX4927_SDRAMC_SIZE(ch) \
204 ((((TX4927_SDRAMC_CR(ch) >> 33) & 0x7fff) + 1) << 21)
205
206#define TX4927_EBUSC_CR(ch) __raw_readq(&tx4927_ebuscptr->cr[(ch)])
207#define TX4927_EBUSC_BA(ch) ((TX4927_EBUSC_CR(ch) >> 48) << 20)
208#define TX4927_EBUSC_SIZE(ch) \
209 (0x00100000 << ((unsigned long)(TX4927_EBUSC_CR(ch) >> 8) & 0xf))
210#define TX4927_EBUSC_WIDTH(ch) \
211 (64 >> ((__u32)(TX4927_EBUSC_CR(ch) >> 20) & 0x3))
212
213/* utilities */
214static inline void txx9_clear64(__u64 __iomem *adr, __u64 bits)
215{
216#ifdef CONFIG_32BIT
217 unsigned long flags;
218 local_irq_save(flags);
219#endif
220 ____raw_writeq(____raw_readq(adr) & ~bits, adr);
221#ifdef CONFIG_32BIT
222 local_irq_restore(flags);
223#endif
224}
225static inline void txx9_set64(__u64 __iomem *adr, __u64 bits)
226{
227#ifdef CONFIG_32BIT
228 unsigned long flags;
229 local_irq_save(flags);
230#endif
231 ____raw_writeq(____raw_readq(adr) | bits, adr);
232#ifdef CONFIG_32BIT
233 local_irq_restore(flags);
234#endif
235}
236
237/* These functions are not interrupt safe. */
238static inline void tx4927_ccfg_clear(__u64 bits)
239{
240 ____raw_writeq(____raw_readq(&tx4927_ccfgptr->ccfg)
241 & ~(TX4927_CCFG_W1CBITS | bits),
242 &tx4927_ccfgptr->ccfg);
243}
244static inline void tx4927_ccfg_set(__u64 bits)
245{
246 ____raw_writeq((____raw_readq(&tx4927_ccfgptr->ccfg)
247 & ~TX4927_CCFG_W1CBITS) | bits,
248 &tx4927_ccfgptr->ccfg);
249}
250static inline void tx4927_ccfg_change(__u64 change, __u64 new)
251{
252 ____raw_writeq((____raw_readq(&tx4927_ccfgptr->ccfg)
253 & ~(TX4927_CCFG_W1CBITS | change)) |
254 new,
255 &tx4927_ccfgptr->ccfg);
256}
257
258unsigned int tx4927_get_mem_size(void);
259void tx4927_wdt_init(void);
260void tx4927_setup(void);
261void tx4927_time_init(unsigned int tmrnr);
262void tx4927_sio_init(unsigned int sclk, unsigned int cts_mask);
263int tx4927_report_pciclk(void);
264int tx4927_pciclk66_setup(void);
265void tx4927_setup_pcierr_irq(void);
266void tx4927_irq_init(void);
267void tx4927_mtd_init(int ch);
268
269#endif /* __ASM_TXX9_TX4927_H */
diff --git a/arch/mips/include/asm/txx9/tx4927pcic.h b/arch/mips/include/asm/txx9/tx4927pcic.h
new file mode 100644
index 000000000000..c470b8a5fe57
--- /dev/null
+++ b/arch/mips/include/asm/txx9/tx4927pcic.h
@@ -0,0 +1,203 @@
1/*
2 * include/asm-mips/txx9/tx4927pcic.h
3 * TX4927 PCI controller definitions.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9#ifndef __ASM_TXX9_TX4927PCIC_H
10#define __ASM_TXX9_TX4927PCIC_H
11
12#include <linux/pci.h>
13#include <linux/irqreturn.h>
14
15struct tx4927_pcic_reg {
16 u32 pciid;
17 u32 pcistatus;
18 u32 pciccrev;
19 u32 pcicfg1;
20 u32 p2gm0plbase; /* +10 */
21 u32 p2gm0pubase;
22 u32 p2gm1plbase;
23 u32 p2gm1pubase;
24 u32 p2gm2pbase; /* +20 */
25 u32 p2giopbase;
26 u32 unused0;
27 u32 pcisid;
28 u32 unused1; /* +30 */
29 u32 pcicapptr;
30 u32 unused2;
31 u32 pcicfg2;
32 u32 g2ptocnt; /* +40 */
33 u32 unused3[15];
34 u32 g2pstatus; /* +80 */
35 u32 g2pmask;
36 u32 pcisstatus;
37 u32 pcimask;
38 u32 p2gcfg; /* +90 */
39 u32 p2gstatus;
40 u32 p2gmask;
41 u32 p2gccmd;
42 u32 unused4[24]; /* +a0 */
43 u32 pbareqport; /* +100 */
44 u32 pbacfg;
45 u32 pbastatus;
46 u32 pbamask;
47 u32 pbabm; /* +110 */
48 u32 pbacreq;
49 u32 pbacgnt;
50 u32 pbacstate;
51 u64 g2pmgbase[3]; /* +120 */
52 u64 g2piogbase;
53 u32 g2pmmask[3]; /* +140 */
54 u32 g2piomask;
55 u64 g2pmpbase[3]; /* +150 */
56 u64 g2piopbase;
57 u32 pciccfg; /* +170 */
58 u32 pcicstatus;
59 u32 pcicmask;
60 u32 unused5;
61 u64 p2gmgbase[3]; /* +180 */
62 u64 p2giogbase;
63 u32 g2pcfgadrs; /* +1a0 */
64 u32 g2pcfgdata;
65 u32 unused6[8];
66 u32 g2pintack;
67 u32 g2pspc;
68 u32 unused7[12]; /* +1d0 */
69 u64 pdmca; /* +200 */
70 u64 pdmga;
71 u64 pdmpa;
72 u64 pdmctr;
73 u64 pdmcfg; /* +220 */
74 u64 pdmsts;
75};
76
77/* bits for PCICMD */
78/* see PCI_COMMAND_XXX in linux/pci_regs.h */
79
80/* bits for PCISTAT */
81/* see PCI_STATUS_XXX in linux/pci_regs.h */
82
83/* bits for IOBA/MBA */
84/* see PCI_BASE_ADDRESS_XXX in linux/pci_regs.h */
85
86/* bits for G2PSTATUS/G2PMASK */
87#define TX4927_PCIC_G2PSTATUS_ALL 0x00000003
88#define TX4927_PCIC_G2PSTATUS_TTOE 0x00000002
89#define TX4927_PCIC_G2PSTATUS_RTOE 0x00000001
90
91/* bits for PCIMASK (see also PCI_STATUS_XXX in linux/pci_regs.h */
92#define TX4927_PCIC_PCISTATUS_ALL 0x0000f900
93
94/* bits for PBACFG */
95#define TX4927_PCIC_PBACFG_FIXPA 0x00000008
96#define TX4927_PCIC_PBACFG_RPBA 0x00000004
97#define TX4927_PCIC_PBACFG_PBAEN 0x00000002
98#define TX4927_PCIC_PBACFG_BMCEN 0x00000001
99
100/* bits for PBASTATUS/PBAMASK */
101#define TX4927_PCIC_PBASTATUS_ALL 0x00000001
102#define TX4927_PCIC_PBASTATUS_BM 0x00000001
103
104/* bits for G2PMnGBASE */
105#define TX4927_PCIC_G2PMnGBASE_BSDIS 0x0000002000000000ULL
106#define TX4927_PCIC_G2PMnGBASE_ECHG 0x0000001000000000ULL
107
108/* bits for G2PIOGBASE */
109#define TX4927_PCIC_G2PIOGBASE_BSDIS 0x0000002000000000ULL
110#define TX4927_PCIC_G2PIOGBASE_ECHG 0x0000001000000000ULL
111
112/* bits for PCICSTATUS/PCICMASK */
113#define TX4927_PCIC_PCICSTATUS_ALL 0x000007b8
114#define TX4927_PCIC_PCICSTATUS_PME 0x00000400
115#define TX4927_PCIC_PCICSTATUS_TLB 0x00000200
116#define TX4927_PCIC_PCICSTATUS_NIB 0x00000100
117#define TX4927_PCIC_PCICSTATUS_ZIB 0x00000080
118#define TX4927_PCIC_PCICSTATUS_PERR 0x00000020
119#define TX4927_PCIC_PCICSTATUS_SERR 0x00000010
120#define TX4927_PCIC_PCICSTATUS_GBE 0x00000008
121#define TX4927_PCIC_PCICSTATUS_IWB 0x00000002
122#define TX4927_PCIC_PCICSTATUS_E2PDONE 0x00000001
123
124/* bits for PCICCFG */
125#define TX4927_PCIC_PCICCFG_GBWC_MASK 0x0fff0000
126#define TX4927_PCIC_PCICCFG_HRST 0x00000800
127#define TX4927_PCIC_PCICCFG_SRST 0x00000400
128#define TX4927_PCIC_PCICCFG_IRBER 0x00000200
129#define TX4927_PCIC_PCICCFG_G2PMEN(ch) (0x00000100>>(ch))
130#define TX4927_PCIC_PCICCFG_G2PM0EN 0x00000100
131#define TX4927_PCIC_PCICCFG_G2PM1EN 0x00000080
132#define TX4927_PCIC_PCICCFG_G2PM2EN 0x00000040
133#define TX4927_PCIC_PCICCFG_G2PIOEN 0x00000020
134#define TX4927_PCIC_PCICCFG_TCAR 0x00000010
135#define TX4927_PCIC_PCICCFG_ICAEN 0x00000008
136
137/* bits for P2GMnGBASE */
138#define TX4927_PCIC_P2GMnGBASE_TMEMEN 0x0000004000000000ULL
139#define TX4927_PCIC_P2GMnGBASE_TBSDIS 0x0000002000000000ULL
140#define TX4927_PCIC_P2GMnGBASE_TECHG 0x0000001000000000ULL
141
142/* bits for P2GIOGBASE */
143#define TX4927_PCIC_P2GIOGBASE_TIOEN 0x0000004000000000ULL
144#define TX4927_PCIC_P2GIOGBASE_TBSDIS 0x0000002000000000ULL
145#define TX4927_PCIC_P2GIOGBASE_TECHG 0x0000001000000000ULL
146
147#define TX4927_PCIC_IDSEL_AD_TO_SLOT(ad) ((ad) - 11)
148#define TX4927_PCIC_MAX_DEVNU TX4927_PCIC_IDSEL_AD_TO_SLOT(32)
149
150/* bits for PDMCFG */
151#define TX4927_PCIC_PDMCFG_RSTFIFO 0x00200000
152#define TX4927_PCIC_PDMCFG_EXFER 0x00100000
153#define TX4927_PCIC_PDMCFG_REQDLY_MASK 0x00003800
154#define TX4927_PCIC_PDMCFG_REQDLY_NONE (0 << 11)
155#define TX4927_PCIC_PDMCFG_REQDLY_16 (1 << 11)
156#define TX4927_PCIC_PDMCFG_REQDLY_32 (2 << 11)
157#define TX4927_PCIC_PDMCFG_REQDLY_64 (3 << 11)
158#define TX4927_PCIC_PDMCFG_REQDLY_128 (4 << 11)
159#define TX4927_PCIC_PDMCFG_REQDLY_256 (5 << 11)
160#define TX4927_PCIC_PDMCFG_REQDLY_512 (6 << 11)
161#define TX4927_PCIC_PDMCFG_REQDLY_1024 (7 << 11)
162#define TX4927_PCIC_PDMCFG_ERRIE 0x00000400
163#define TX4927_PCIC_PDMCFG_NCCMPIE 0x00000200
164#define TX4927_PCIC_PDMCFG_NTCMPIE 0x00000100
165#define TX4927_PCIC_PDMCFG_CHNEN 0x00000080
166#define TX4927_PCIC_PDMCFG_XFRACT 0x00000040
167#define TX4927_PCIC_PDMCFG_BSWAP 0x00000020
168#define TX4927_PCIC_PDMCFG_XFRSIZE_MASK 0x0000000c
169#define TX4927_PCIC_PDMCFG_XFRSIZE_1DW 0x00000000
170#define TX4927_PCIC_PDMCFG_XFRSIZE_1QW 0x00000004
171#define TX4927_PCIC_PDMCFG_XFRSIZE_4QW 0x00000008
172#define TX4927_PCIC_PDMCFG_XFRDIRC 0x00000002
173#define TX4927_PCIC_PDMCFG_CHRST 0x00000001
174
175/* bits for PDMSTS */
176#define TX4927_PCIC_PDMSTS_REQCNT_MASK 0x3f000000
177#define TX4927_PCIC_PDMSTS_FIFOCNT_MASK 0x00f00000
178#define TX4927_PCIC_PDMSTS_FIFOWP_MASK 0x000c0000
179#define TX4927_PCIC_PDMSTS_FIFORP_MASK 0x00030000
180#define TX4927_PCIC_PDMSTS_ERRINT 0x00000800
181#define TX4927_PCIC_PDMSTS_DONEINT 0x00000400
182#define TX4927_PCIC_PDMSTS_CHNEN 0x00000200
183#define TX4927_PCIC_PDMSTS_XFRACT 0x00000100
184#define TX4927_PCIC_PDMSTS_ACCMP 0x00000080
185#define TX4927_PCIC_PDMSTS_NCCMP 0x00000040
186#define TX4927_PCIC_PDMSTS_NTCMP 0x00000020
187#define TX4927_PCIC_PDMSTS_CFGERR 0x00000008
188#define TX4927_PCIC_PDMSTS_PCIERR 0x00000004
189#define TX4927_PCIC_PDMSTS_CHNERR 0x00000002
190#define TX4927_PCIC_PDMSTS_DATAERR 0x00000001
191#define TX4927_PCIC_PDMSTS_ALL_CMP 0x000000e0
192#define TX4927_PCIC_PDMSTS_ALL_ERR 0x0000000f
193
194struct tx4927_pcic_reg __iomem *get_tx4927_pcicptr(
195 struct pci_controller *channel);
196void tx4927_pcic_setup(struct tx4927_pcic_reg __iomem *pcicptr,
197 struct pci_controller *channel, int extarb);
198void tx4927_report_pcic_status(void);
199char *tx4927_pcibios_setup(char *str);
200void tx4927_dump_pcic_settings(void);
201irqreturn_t tx4927_pcierr_interrupt(int irq, void *dev_id);
202
203#endif /* __ASM_TXX9_TX4927PCIC_H */
diff --git a/arch/mips/include/asm/txx9/tx4938.h b/arch/mips/include/asm/txx9/tx4938.h
new file mode 100644
index 000000000000..989e7751135a
--- /dev/null
+++ b/arch/mips/include/asm/txx9/tx4938.h
@@ -0,0 +1,295 @@
1/*
2 * Definitions for TX4937/TX4938
3 * Copyright (C) 2000-2001 Toshiba Corporation
4 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 *
10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11 */
12#ifndef __ASM_TXX9_TX4938_H
13#define __ASM_TXX9_TX4938_H
14
15/* some controllers are compatible with 4927 */
16#include <asm/txx9/tx4927.h>
17
18#ifdef CONFIG_64BIT
19#define TX4938_REG_BASE 0xffffffffff1f0000UL /* == TX4937_REG_BASE */
20#else
21#define TX4938_REG_BASE 0xff1f0000UL /* == TX4937_REG_BASE */
22#endif
23#define TX4938_REG_SIZE 0x00010000 /* == TX4937_REG_SIZE */
24
25/* NDFMC, SRAMC, PCIC1, SPIC: TX4938 only */
26#define TX4938_NDFMC_REG (TX4938_REG_BASE + 0x5000)
27#define TX4938_SRAMC_REG (TX4938_REG_BASE + 0x6000)
28#define TX4938_PCIC1_REG (TX4938_REG_BASE + 0x7000)
29#define TX4938_SDRAMC_REG (TX4938_REG_BASE + 0x8000)
30#define TX4938_EBUSC_REG (TX4938_REG_BASE + 0x9000)
31#define TX4938_DMA_REG(ch) (TX4938_REG_BASE + 0xb000 + (ch) * 0x800)
32#define TX4938_PCIC_REG (TX4938_REG_BASE + 0xd000)
33#define TX4938_CCFG_REG (TX4938_REG_BASE + 0xe000)
34#define TX4938_NR_TMR 3
35#define TX4938_TMR_REG(ch) ((TX4938_REG_BASE + 0xf000) + (ch) * 0x100)
36#define TX4938_NR_SIO 2
37#define TX4938_SIO_REG(ch) ((TX4938_REG_BASE + 0xf300) + (ch) * 0x100)
38#define TX4938_PIO_REG (TX4938_REG_BASE + 0xf500)
39#define TX4938_IRC_REG (TX4938_REG_BASE + 0xf600)
40#define TX4938_ACLC_REG (TX4938_REG_BASE + 0xf700)
41#define TX4938_SPI_REG (TX4938_REG_BASE + 0xf800)
42
43struct tx4938_sramc_reg {
44 u64 cr;
45};
46
47struct tx4938_ccfg_reg {
48 u64 ccfg;
49 u64 crir;
50 u64 pcfg;
51 u64 toea;
52 u64 clkctr;
53 u64 unused0;
54 u64 garbc;
55 u64 unused1;
56 u64 unused2;
57 u64 ramp;
58 u64 unused3;
59 u64 jmpadr;
60};
61
62/*
63 * IRC
64 */
65
66#define TX4938_IR_ECCERR 0
67#define TX4938_IR_WTOERR 1
68#define TX4938_NUM_IR_INT 6
69#define TX4938_IR_INT(n) (2 + (n))
70#define TX4938_NUM_IR_SIO 2
71#define TX4938_IR_SIO(n) (8 + (n))
72#define TX4938_NUM_IR_DMA 4
73#define TX4938_IR_DMA(ch, n) ((ch ? 27 : 10) + (n)) /* 10-13, 27-30 */
74#define TX4938_IR_PIO 14
75#define TX4938_IR_PDMAC 15
76#define TX4938_IR_PCIC 16
77#define TX4938_NUM_IR_TMR 3
78#define TX4938_IR_TMR(n) (17 + (n))
79#define TX4938_IR_NDFMC 21
80#define TX4938_IR_PCIERR 22
81#define TX4938_IR_PCIPME 23
82#define TX4938_IR_ACLC 24
83#define TX4938_IR_ACLCPME 25
84#define TX4938_IR_PCIC1 26
85#define TX4938_IR_SPI 31
86#define TX4938_NUM_IR 32
87/* multiplex */
88#define TX4938_IR_ETH0 TX4938_IR_INT(4)
89#define TX4938_IR_ETH1 TX4938_IR_INT(3)
90
91#define TX4938_IRC_INT 2 /* IP[2] in Status register */
92
93#define TX4938_NUM_PIO 16
94
95/*
96 * CCFG
97 */
98/* CCFG : Chip Configuration */
99#define TX4938_CCFG_WDRST 0x0000020000000000ULL
100#define TX4938_CCFG_WDREXEN 0x0000010000000000ULL
101#define TX4938_CCFG_BCFG_MASK 0x000000ff00000000ULL
102#define TX4938_CCFG_TINTDIS 0x01000000
103#define TX4938_CCFG_PCI66 0x00800000
104#define TX4938_CCFG_PCIMODE 0x00400000
105#define TX4938_CCFG_PCI1_66 0x00200000
106#define TX4938_CCFG_DIVMODE_MASK 0x001e0000
107#define TX4938_CCFG_DIVMODE_2 (0x4 << 17)
108#define TX4938_CCFG_DIVMODE_2_5 (0xf << 17)
109#define TX4938_CCFG_DIVMODE_3 (0x5 << 17)
110#define TX4938_CCFG_DIVMODE_4 (0x6 << 17)
111#define TX4938_CCFG_DIVMODE_4_5 (0xd << 17)
112#define TX4938_CCFG_DIVMODE_8 (0x0 << 17)
113#define TX4938_CCFG_DIVMODE_10 (0xb << 17)
114#define TX4938_CCFG_DIVMODE_12 (0x1 << 17)
115#define TX4938_CCFG_DIVMODE_16 (0x2 << 17)
116#define TX4938_CCFG_DIVMODE_18 (0x9 << 17)
117#define TX4938_CCFG_BEOW 0x00010000
118#define TX4938_CCFG_WR 0x00008000
119#define TX4938_CCFG_TOE 0x00004000
120#define TX4938_CCFG_PCIARB 0x00002000
121#define TX4938_CCFG_PCIDIVMODE_MASK 0x00001c00
122#define TX4938_CCFG_PCIDIVMODE_4 (0x1 << 10)
123#define TX4938_CCFG_PCIDIVMODE_4_5 (0x3 << 10)
124#define TX4938_CCFG_PCIDIVMODE_5 (0x5 << 10)
125#define TX4938_CCFG_PCIDIVMODE_5_5 (0x7 << 10)
126#define TX4938_CCFG_PCIDIVMODE_8 (0x0 << 10)
127#define TX4938_CCFG_PCIDIVMODE_9 (0x2 << 10)
128#define TX4938_CCFG_PCIDIVMODE_10 (0x4 << 10)
129#define TX4938_CCFG_PCIDIVMODE_11 (0x6 << 10)
130#define TX4938_CCFG_PCI1DMD 0x00000100
131#define TX4938_CCFG_SYSSP_MASK 0x000000c0
132#define TX4938_CCFG_ENDIAN 0x00000004
133#define TX4938_CCFG_HALT 0x00000002
134#define TX4938_CCFG_ACEHOLD 0x00000001
135
136/* PCFG : Pin Configuration */
137#define TX4938_PCFG_ETH0_SEL 0x8000000000000000ULL
138#define TX4938_PCFG_ETH1_SEL 0x4000000000000000ULL
139#define TX4938_PCFG_ATA_SEL 0x2000000000000000ULL
140#define TX4938_PCFG_ISA_SEL 0x1000000000000000ULL
141#define TX4938_PCFG_SPI_SEL 0x0800000000000000ULL
142#define TX4938_PCFG_NDF_SEL 0x0400000000000000ULL
143#define TX4938_PCFG_SDCLKDLY_MASK 0x30000000
144#define TX4938_PCFG_SDCLKDLY(d) ((d)<<28)
145#define TX4938_PCFG_SYSCLKEN 0x08000000
146#define TX4938_PCFG_SDCLKEN_ALL 0x07800000
147#define TX4938_PCFG_SDCLKEN(ch) (0x00800000<<(ch))
148#define TX4938_PCFG_PCICLKEN_ALL 0x003f0000
149#define TX4938_PCFG_PCICLKEN(ch) (0x00010000<<(ch))
150#define TX4938_PCFG_SEL2 0x00000200
151#define TX4938_PCFG_SEL1 0x00000100
152#define TX4938_PCFG_DMASEL_ALL 0x0000000f
153#define TX4938_PCFG_DMASEL0_DRQ0 0x00000000
154#define TX4938_PCFG_DMASEL0_SIO1 0x00000001
155#define TX4938_PCFG_DMASEL1_DRQ1 0x00000000
156#define TX4938_PCFG_DMASEL1_SIO1 0x00000002
157#define TX4938_PCFG_DMASEL2_DRQ2 0x00000000
158#define TX4938_PCFG_DMASEL2_SIO0 0x00000004
159#define TX4938_PCFG_DMASEL3_DRQ3 0x00000000
160#define TX4938_PCFG_DMASEL3_SIO0 0x00000008
161
162/* CLKCTR : Clock Control */
163#define TX4938_CLKCTR_NDFCKD 0x0001000000000000ULL
164#define TX4938_CLKCTR_NDFRST 0x0000000100000000ULL
165#define TX4938_CLKCTR_ETH1CKD 0x80000000
166#define TX4938_CLKCTR_ETH0CKD 0x40000000
167#define TX4938_CLKCTR_SPICKD 0x20000000
168#define TX4938_CLKCTR_SRAMCKD 0x10000000
169#define TX4938_CLKCTR_PCIC1CKD 0x08000000
170#define TX4938_CLKCTR_DMA1CKD 0x04000000
171#define TX4938_CLKCTR_ACLCKD 0x02000000
172#define TX4938_CLKCTR_PIOCKD 0x01000000
173#define TX4938_CLKCTR_DMACKD 0x00800000
174#define TX4938_CLKCTR_PCICKD 0x00400000
175#define TX4938_CLKCTR_TM0CKD 0x00100000
176#define TX4938_CLKCTR_TM1CKD 0x00080000
177#define TX4938_CLKCTR_TM2CKD 0x00040000
178#define TX4938_CLKCTR_SIO0CKD 0x00020000
179#define TX4938_CLKCTR_SIO1CKD 0x00010000
180#define TX4938_CLKCTR_ETH1RST 0x00008000
181#define TX4938_CLKCTR_ETH0RST 0x00004000
182#define TX4938_CLKCTR_SPIRST 0x00002000
183#define TX4938_CLKCTR_SRAMRST 0x00001000
184#define TX4938_CLKCTR_PCIC1RST 0x00000800
185#define TX4938_CLKCTR_DMA1RST 0x00000400
186#define TX4938_CLKCTR_ACLRST 0x00000200
187#define TX4938_CLKCTR_PIORST 0x00000100
188#define TX4938_CLKCTR_DMARST 0x00000080
189#define TX4938_CLKCTR_PCIRST 0x00000040
190#define TX4938_CLKCTR_TM0RST 0x00000010
191#define TX4938_CLKCTR_TM1RST 0x00000008
192#define TX4938_CLKCTR_TM2RST 0x00000004
193#define TX4938_CLKCTR_SIO0RST 0x00000002
194#define TX4938_CLKCTR_SIO1RST 0x00000001
195
196/*
197 * DMA
198 */
199/* bits for MCR */
200#define TX4938_DMA_MCR_EIS(ch) (0x10000000<<(ch))
201#define TX4938_DMA_MCR_DIS(ch) (0x01000000<<(ch))
202#define TX4938_DMA_MCR_RSFIF 0x00000080
203#define TX4938_DMA_MCR_FIFUM(ch) (0x00000008<<(ch))
204#define TX4938_DMA_MCR_RPRT 0x00000002
205#define TX4938_DMA_MCR_MSTEN 0x00000001
206
207/* bits for CCRn */
208#define TX4938_DMA_CCR_IMMCHN 0x20000000
209#define TX4938_DMA_CCR_USEXFSZ 0x10000000
210#define TX4938_DMA_CCR_LE 0x08000000
211#define TX4938_DMA_CCR_DBINH 0x04000000
212#define TX4938_DMA_CCR_SBINH 0x02000000
213#define TX4938_DMA_CCR_CHRST 0x01000000
214#define TX4938_DMA_CCR_RVBYTE 0x00800000
215#define TX4938_DMA_CCR_ACKPOL 0x00400000
216#define TX4938_DMA_CCR_REQPL 0x00200000
217#define TX4938_DMA_CCR_EGREQ 0x00100000
218#define TX4938_DMA_CCR_CHDN 0x00080000
219#define TX4938_DMA_CCR_DNCTL 0x00060000
220#define TX4938_DMA_CCR_EXTRQ 0x00010000
221#define TX4938_DMA_CCR_INTRQD 0x0000e000
222#define TX4938_DMA_CCR_INTENE 0x00001000
223#define TX4938_DMA_CCR_INTENC 0x00000800
224#define TX4938_DMA_CCR_INTENT 0x00000400
225#define TX4938_DMA_CCR_CHNEN 0x00000200
226#define TX4938_DMA_CCR_XFACT 0x00000100
227#define TX4938_DMA_CCR_SMPCHN 0x00000020
228#define TX4938_DMA_CCR_XFSZ(order) (((order) << 2) & 0x0000001c)
229#define TX4938_DMA_CCR_XFSZ_1W TX4938_DMA_CCR_XFSZ(2)
230#define TX4938_DMA_CCR_XFSZ_2W TX4938_DMA_CCR_XFSZ(3)
231#define TX4938_DMA_CCR_XFSZ_4W TX4938_DMA_CCR_XFSZ(4)
232#define TX4938_DMA_CCR_XFSZ_8W TX4938_DMA_CCR_XFSZ(5)
233#define TX4938_DMA_CCR_XFSZ_16W TX4938_DMA_CCR_XFSZ(6)
234#define TX4938_DMA_CCR_XFSZ_32W TX4938_DMA_CCR_XFSZ(7)
235#define TX4938_DMA_CCR_MEMIO 0x00000002
236#define TX4938_DMA_CCR_SNGAD 0x00000001
237
238/* bits for CSRn */
239#define TX4938_DMA_CSR_CHNEN 0x00000400
240#define TX4938_DMA_CSR_STLXFER 0x00000200
241#define TX4938_DMA_CSR_CHNACT 0x00000100
242#define TX4938_DMA_CSR_ABCHC 0x00000080
243#define TX4938_DMA_CSR_NCHNC 0x00000040
244#define TX4938_DMA_CSR_NTRNFC 0x00000020
245#define TX4938_DMA_CSR_EXTDN 0x00000010
246#define TX4938_DMA_CSR_CFERR 0x00000008
247#define TX4938_DMA_CSR_CHERR 0x00000004
248#define TX4938_DMA_CSR_DESERR 0x00000002
249#define TX4938_DMA_CSR_SORERR 0x00000001
250
251#define tx4938_sdramcptr tx4927_sdramcptr
252#define tx4938_ebuscptr tx4927_ebuscptr
253#define tx4938_pcicptr tx4927_pcicptr
254#define tx4938_pcic1ptr \
255 ((struct tx4927_pcic_reg __iomem *)TX4938_PCIC1_REG)
256#define tx4938_ccfgptr \
257 ((struct tx4938_ccfg_reg __iomem *)TX4938_CCFG_REG)
258#define tx4938_pioptr ((struct txx9_pio_reg __iomem *)TX4938_PIO_REG)
259#define tx4938_sramcptr \
260 ((struct tx4938_sramc_reg __iomem *)TX4938_SRAMC_REG)
261
262
263#define TX4938_REV_PCODE() \
264 ((__u32)__raw_readq(&tx4938_ccfgptr->crir) >> 16)
265
266#define tx4938_ccfg_clear(bits) tx4927_ccfg_clear(bits)
267#define tx4938_ccfg_set(bits) tx4927_ccfg_set(bits)
268#define tx4938_ccfg_change(change, new) tx4927_ccfg_change(change, new)
269
270#define TX4938_SDRAMC_CR(ch) TX4927_SDRAMC_CR(ch)
271#define TX4938_SDRAMC_BA(ch) TX4927_SDRAMC_BA(ch)
272#define TX4938_SDRAMC_SIZE(ch) TX4927_SDRAMC_SIZE(ch)
273
274#define TX4938_EBUSC_CR(ch) TX4927_EBUSC_CR(ch)
275#define TX4938_EBUSC_BA(ch) TX4927_EBUSC_BA(ch)
276#define TX4938_EBUSC_SIZE(ch) TX4927_EBUSC_SIZE(ch)
277#define TX4938_EBUSC_WIDTH(ch) TX4927_EBUSC_WIDTH(ch)
278
279#define tx4938_get_mem_size() tx4927_get_mem_size()
280void tx4938_wdt_init(void);
281void tx4938_setup(void);
282void tx4938_time_init(unsigned int tmrnr);
283void tx4938_sio_init(unsigned int sclk, unsigned int cts_mask);
284void tx4938_spi_init(int busid);
285void tx4938_ethaddr_init(unsigned char *addr0, unsigned char *addr1);
286int tx4938_report_pciclk(void);
287void tx4938_report_pci1clk(void);
288int tx4938_pciclk66_setup(void);
289struct pci_dev;
290int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot);
291void tx4938_setup_pcierr_irq(void);
292void tx4938_irq_init(void);
293void tx4938_mtd_init(int ch);
294
295#endif
diff --git a/arch/mips/include/asm/txx9/tx4939.h b/arch/mips/include/asm/txx9/tx4939.h
new file mode 100644
index 000000000000..88badb423010
--- /dev/null
+++ b/arch/mips/include/asm/txx9/tx4939.h
@@ -0,0 +1,545 @@
1/*
2 * Definitions for TX4939
3 *
4 * Copyright (C) 2000-2001,2005-2006 Toshiba Corporation
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 */
10#ifndef __ASM_TXX9_TX4939_H
11#define __ASM_TXX9_TX4939_H
12
13/* some controllers are compatible with 4927/4938 */
14#include <asm/txx9/tx4938.h>
15
16#ifdef CONFIG_64BIT
17#define TX4939_REG_BASE 0xffffffffff1f0000UL /* == TX4938_REG_BASE */
18#else
19#define TX4939_REG_BASE 0xff1f0000UL /* == TX4938_REG_BASE */
20#endif
21#define TX4939_REG_SIZE 0x00010000 /* == TX4938_REG_SIZE */
22
23#define TX4939_ATA_REG(ch) (TX4939_REG_BASE + 0x3000 + (ch) * 0x1000)
24#define TX4939_NDFMC_REG (TX4939_REG_BASE + 0x5000)
25#define TX4939_SRAMC_REG (TX4939_REG_BASE + 0x6000)
26#define TX4939_CRYPTO_REG (TX4939_REG_BASE + 0x6800)
27#define TX4939_PCIC1_REG (TX4939_REG_BASE + 0x7000)
28#define TX4939_DDRC_REG (TX4939_REG_BASE + 0x8000)
29#define TX4939_EBUSC_REG (TX4939_REG_BASE + 0x9000)
30#define TX4939_VPC_REG (TX4939_REG_BASE + 0xa000)
31#define TX4939_DMA_REG(ch) (TX4939_REG_BASE + 0xb000 + (ch) * 0x800)
32#define TX4939_PCIC_REG (TX4939_REG_BASE + 0xd000)
33#define TX4939_CCFG_REG (TX4939_REG_BASE + 0xe000)
34#define TX4939_IRC_REG (TX4939_REG_BASE + 0xe800)
35#define TX4939_NR_TMR 6 /* 0xf000,0xf100,0xf200,0xfd00,0xfe00,0xff00 */
36#define TX4939_TMR_REG(ch) \
37 (TX4939_REG_BASE + 0xf000 + ((ch) + ((ch) >= 3) * 10) * 0x100)
38#define TX4939_NR_SIO 4 /* 0xf300, 0xf400, 0xf380, 0xf480 */
39#define TX4939_SIO_REG(ch) \
40 (TX4939_REG_BASE + 0xf300 + (((ch) & 1) << 8) + (((ch) & 2) << 6))
41#define TX4939_ACLC_REG (TX4939_REG_BASE + 0xf700)
42#define TX4939_SPI_REG (TX4939_REG_BASE + 0xf800)
43#define TX4939_I2C_REG (TX4939_REG_BASE + 0xf900)
44#define TX4939_I2S_REG (TX4939_REG_BASE + 0xfa00)
45#define TX4939_RTC_REG (TX4939_REG_BASE + 0xfb00)
46#define TX4939_CIR_REG (TX4939_REG_BASE + 0xfc00)
47
48struct tx4939_le_reg {
49 __u32 r;
50 __u32 unused;
51};
52
53struct tx4939_ddrc_reg {
54 struct tx4939_le_reg ctl[47];
55 __u64 unused0[17];
56 __u64 winen;
57 __u64 win[4];
58};
59
60struct tx4939_ccfg_reg {
61 __u64 ccfg;
62 __u64 crir;
63 __u64 pcfg;
64 __u64 toea;
65 __u64 clkctr;
66 __u64 unused0;
67 __u64 garbc;
68 __u64 unused1[2];
69 __u64 ramp;
70 __u64 unused2[2];
71 __u64 dskwctrl;
72 __u64 mclkosc;
73 __u64 mclkctl;
74 __u64 unused3[17];
75 struct {
76 __u64 mr;
77 __u64 dr;
78 } gpio[2];
79};
80
81struct tx4939_irc_reg {
82 struct tx4939_le_reg den;
83 struct tx4939_le_reg scipb;
84 struct tx4939_le_reg dm[2];
85 struct tx4939_le_reg lvl[16];
86 struct tx4939_le_reg msk;
87 struct tx4939_le_reg edc;
88 struct tx4939_le_reg pnd0;
89 struct tx4939_le_reg cs;
90 struct tx4939_le_reg pnd1;
91 struct tx4939_le_reg dm2[2];
92 struct tx4939_le_reg dbr[2];
93 struct tx4939_le_reg dben;
94 struct tx4939_le_reg unused0[2];
95 struct tx4939_le_reg flag[2];
96 struct tx4939_le_reg pol;
97 struct tx4939_le_reg cnt;
98 struct tx4939_le_reg maskint;
99 struct tx4939_le_reg maskext;
100};
101
102struct tx4939_rtc_reg {
103 __u32 ctl;
104 __u32 adr;
105 __u32 dat;
106 __u32 tbc;
107};
108
109struct tx4939_crypto_reg {
110 struct tx4939_le_reg csr;
111 struct tx4939_le_reg idesptr;
112 struct tx4939_le_reg cdesptr;
113 struct tx4939_le_reg buserr;
114 struct tx4939_le_reg cip_tout;
115 struct tx4939_le_reg cir;
116 union {
117 struct {
118 struct tx4939_le_reg data[8];
119 struct tx4939_le_reg ctrl;
120 } gen;
121 struct {
122 struct {
123 struct tx4939_le_reg l;
124 struct tx4939_le_reg u;
125 } key[3], ini;
126 struct tx4939_le_reg ctrl;
127 } des;
128 struct {
129 struct tx4939_le_reg key[4];
130 struct tx4939_le_reg ini[4];
131 struct tx4939_le_reg ctrl;
132 } aes;
133 struct {
134 struct {
135 struct tx4939_le_reg l;
136 struct tx4939_le_reg u;
137 } cnt;
138 struct tx4939_le_reg ini[5];
139 struct tx4939_le_reg unused;
140 struct tx4939_le_reg ctrl;
141 } hash;
142 } cdr;
143 struct tx4939_le_reg unused0[7];
144 struct tx4939_le_reg rcsr;
145 struct tx4939_le_reg rpr;
146 __u64 rdr;
147 __u64 ror[3];
148 struct tx4939_le_reg unused1[2];
149 struct tx4939_le_reg xorslr;
150 struct tx4939_le_reg xorsur;
151};
152
153struct tx4939_crypto_desc {
154 __u32 src;
155 __u32 dst;
156 __u32 next;
157 __u32 ctrl;
158 __u32 index;
159 __u32 xor;
160};
161
162struct tx4939_vpc_reg {
163 struct tx4939_le_reg csr;
164 struct {
165 struct tx4939_le_reg ctrlA;
166 struct tx4939_le_reg ctrlB;
167 struct tx4939_le_reg idesptr;
168 struct tx4939_le_reg cdesptr;
169 } port[3];
170 struct tx4939_le_reg buserr;
171};
172
173struct tx4939_vpc_desc {
174 __u32 src;
175 __u32 next;
176 __u32 ctrl1;
177 __u32 ctrl2;
178};
179
180/*
181 * IRC
182 */
183#define TX4939_IR_NONE 0
184#define TX4939_IR_DDR 1
185#define TX4939_IR_WTOERR 2
186#define TX4939_NUM_IR_INT 3
187#define TX4939_IR_INT(n) (3 + (n))
188#define TX4939_NUM_IR_ETH 2
189#define TX4939_IR_ETH(n) ((n) ? 43 : 6)
190#define TX4939_IR_VIDEO 7
191#define TX4939_IR_CIR 8
192#define TX4939_NUM_IR_SIO 4
193#define TX4939_IR_SIO(n) ((n) ? 43 + (n) : 9) /* 9,44-46 */
194#define TX4939_NUM_IR_DMA 4
195#define TX4939_IR_DMA(ch, n) (((ch) ? 22 : 10) + (n)) /* 10-13,22-25 */
196#define TX4939_IR_IRC 14
197#define TX4939_IR_PDMAC 15
198#define TX4939_NUM_IR_TMR 6
199#define TX4939_IR_TMR(n) (((n) >= 3 ? 45 : 16) + (n)) /* 16-18,48-50 */
200#define TX4939_NUM_IR_ATA 2
201#define TX4939_IR_ATA(n) (19 + (n))
202#define TX4939_IR_ACLC 21
203#define TX4939_IR_CIPHER 26
204#define TX4939_IR_INTA 27
205#define TX4939_IR_INTB 28
206#define TX4939_IR_INTC 29
207#define TX4939_IR_INTD 30
208#define TX4939_IR_I2C 33
209#define TX4939_IR_SPI 34
210#define TX4939_IR_PCIC 35
211#define TX4939_IR_PCIC1 36
212#define TX4939_IR_PCIERR 37
213#define TX4939_IR_PCIPME 38
214#define TX4939_IR_NDFMC 39
215#define TX4939_IR_ACLCPME 40
216#define TX4939_IR_RTC 41
217#define TX4939_IR_RND 42
218#define TX4939_IR_I2S 47
219#define TX4939_NUM_IR 64
220
221#define TX4939_IRC_INT 2 /* IP[2] in Status register */
222
223/*
224 * CCFG
225 */
226/* CCFG : Chip Configuration */
227#define TX4939_CCFG_PCIBOOT 0x0000040000000000ULL
228#define TX4939_CCFG_WDRST 0x0000020000000000ULL
229#define TX4939_CCFG_WDREXEN 0x0000010000000000ULL
230#define TX4939_CCFG_BCFG_MASK 0x000000ff00000000ULL
231#define TX4939_CCFG_GTOT_MASK 0x06000000
232#define TX4939_CCFG_GTOT_4096 0x06000000
233#define TX4939_CCFG_GTOT_2048 0x04000000
234#define TX4939_CCFG_GTOT_1024 0x02000000
235#define TX4939_CCFG_GTOT_512 0x00000000
236#define TX4939_CCFG_TINTDIS 0x01000000
237#define TX4939_CCFG_PCI66 0x00800000
238#define TX4939_CCFG_PCIMODE 0x00400000
239#define TX4939_CCFG_SSCG 0x00100000
240#define TX4939_CCFG_MULCLK_MASK 0x000e0000
241#define TX4939_CCFG_MULCLK_8 (0x7 << 17)
242#define TX4939_CCFG_MULCLK_9 (0x0 << 17)
243#define TX4939_CCFG_MULCLK_10 (0x1 << 17)
244#define TX4939_CCFG_MULCLK_11 (0x2 << 17)
245#define TX4939_CCFG_MULCLK_12 (0x3 << 17)
246#define TX4939_CCFG_MULCLK_13 (0x4 << 17)
247#define TX4939_CCFG_MULCLK_14 (0x5 << 17)
248#define TX4939_CCFG_MULCLK_15 (0x6 << 17)
249#define TX4939_CCFG_BEOW 0x00010000
250#define TX4939_CCFG_WR 0x00008000
251#define TX4939_CCFG_TOE 0x00004000
252#define TX4939_CCFG_PCIARB 0x00002000
253#define TX4939_CCFG_YDIVMODE_MASK 0x00001c00
254#define TX4939_CCFG_YDIVMODE_2 (0x0 << 10)
255#define TX4939_CCFG_YDIVMODE_3 (0x1 << 10)
256#define TX4939_CCFG_YDIVMODE_5 (0x6 << 10)
257#define TX4939_CCFG_YDIVMODE_6 (0x7 << 10)
258#define TX4939_CCFG_PTSEL 0x00000200
259#define TX4939_CCFG_BESEL 0x00000100
260#define TX4939_CCFG_SYSSP_MASK 0x000000c0
261#define TX4939_CCFG_ACKSEL 0x00000020
262#define TX4939_CCFG_ROMW 0x00000010
263#define TX4939_CCFG_ENDIAN 0x00000004
264#define TX4939_CCFG_ARMODE 0x00000002
265#define TX4939_CCFG_ACEHOLD 0x00000001
266
267/* PCFG : Pin Configuration */
268#define TX4939_PCFG_SIO2MODE_MASK 0xc000000000000000ULL
269#define TX4939_PCFG_SIO2MODE_GPIO 0x8000000000000000ULL
270#define TX4939_PCFG_SIO2MODE_SIO2 0x4000000000000000ULL
271#define TX4939_PCFG_SIO2MODE_SIO0 0x0000000000000000ULL
272#define TX4939_PCFG_SPIMODE 0x2000000000000000ULL
273#define TX4939_PCFG_I2CMODE 0x1000000000000000ULL
274#define TX4939_PCFG_I2SMODE_MASK 0x0c00000000000000ULL
275#define TX4939_PCFG_I2SMODE_GPIO 0x0c00000000000000ULL
276#define TX4939_PCFG_I2SMODE_I2S 0x0800000000000000ULL
277#define TX4939_PCFG_I2SMODE_I2S_ALT 0x0400000000000000ULL
278#define TX4939_PCFG_I2SMODE_ACLC 0x0000000000000000ULL
279#define TX4939_PCFG_SIO3MODE 0x0200000000000000ULL
280#define TX4939_PCFG_DMASEL3 0x0004000000000000ULL
281#define TX4939_PCFG_DMASEL3_SIO0 0x0004000000000000ULL
282#define TX4939_PCFG_DMASEL3_NDFC 0x0000000000000000ULL
283#define TX4939_PCFG_VSSMODE 0x0000200000000000ULL
284#define TX4939_PCFG_VPSMODE 0x0000100000000000ULL
285#define TX4939_PCFG_ET1MODE 0x0000080000000000ULL
286#define TX4939_PCFG_ET0MODE 0x0000040000000000ULL
287#define TX4939_PCFG_ATA1MODE 0x0000020000000000ULL
288#define TX4939_PCFG_ATA0MODE 0x0000010000000000ULL
289#define TX4939_PCFG_BP_PLL 0x0000000100000000ULL
290
291#define TX4939_PCFG_SYSCLKEN 0x08000000
292#define TX4939_PCFG_PCICLKEN_ALL 0x000f0000
293#define TX4939_PCFG_PCICLKEN(ch) (0x00010000<<(ch))
294#define TX4939_PCFG_SPEED1 0x00002000
295#define TX4939_PCFG_SPEED0 0x00001000
296#define TX4939_PCFG_ITMODE 0x00000300
297#define TX4939_PCFG_DMASEL_ALL (0x00000007 | TX4939_PCFG_DMASEL3)
298#define TX4939_PCFG_DMASEL2 0x00000004
299#define TX4939_PCFG_DMASEL2_DRQ2 0x00000000
300#define TX4939_PCFG_DMASEL2_SIO0 0x00000004
301#define TX4939_PCFG_DMASEL1 0x00000002
302#define TX4939_PCFG_DMASEL1_DRQ1 0x00000000
303#define TX4939_PCFG_DMASEL0 0x00000001
304#define TX4939_PCFG_DMASEL0_DRQ0 0x00000000
305
306/* CLKCTR : Clock Control */
307#define TX4939_CLKCTR_IOSCKD 0x8000000000000000ULL
308#define TX4939_CLKCTR_SYSCKD 0x4000000000000000ULL
309#define TX4939_CLKCTR_TM5CKD 0x2000000000000000ULL
310#define TX4939_CLKCTR_TM4CKD 0x1000000000000000ULL
311#define TX4939_CLKCTR_TM3CKD 0x0800000000000000ULL
312#define TX4939_CLKCTR_CIRCKD 0x0400000000000000ULL
313#define TX4939_CLKCTR_SIO3CKD 0x0200000000000000ULL
314#define TX4939_CLKCTR_SIO2CKD 0x0100000000000000ULL
315#define TX4939_CLKCTR_SIO1CKD 0x0080000000000000ULL
316#define TX4939_CLKCTR_VPCCKD 0x0040000000000000ULL
317#define TX4939_CLKCTR_EPCICKD 0x0020000000000000ULL
318#define TX4939_CLKCTR_ETH1CKD 0x0008000000000000ULL
319#define TX4939_CLKCTR_ATA1CKD 0x0004000000000000ULL
320#define TX4939_CLKCTR_BROMCKD 0x0002000000000000ULL
321#define TX4939_CLKCTR_NDCCKD 0x0001000000000000ULL
322#define TX4939_CLKCTR_I2CCKD 0x0000800000000000ULL
323#define TX4939_CLKCTR_ETH0CKD 0x0000400000000000ULL
324#define TX4939_CLKCTR_SPICKD 0x0000200000000000ULL
325#define TX4939_CLKCTR_SRAMCKD 0x0000100000000000ULL
326#define TX4939_CLKCTR_PCI1CKD 0x0000080000000000ULL
327#define TX4939_CLKCTR_DMA1CKD 0x0000040000000000ULL
328#define TX4939_CLKCTR_ACLCKD 0x0000020000000000ULL
329#define TX4939_CLKCTR_ATA0CKD 0x0000010000000000ULL
330#define TX4939_CLKCTR_DMA0CKD 0x0000008000000000ULL
331#define TX4939_CLKCTR_PCICCKD 0x0000004000000000ULL
332#define TX4939_CLKCTR_I2SCKD 0x0000002000000000ULL
333#define TX4939_CLKCTR_TM0CKD 0x0000001000000000ULL
334#define TX4939_CLKCTR_TM1CKD 0x0000000800000000ULL
335#define TX4939_CLKCTR_TM2CKD 0x0000000400000000ULL
336#define TX4939_CLKCTR_SIO0CKD 0x0000000200000000ULL
337#define TX4939_CLKCTR_CYPCKD 0x0000000100000000ULL
338#define TX4939_CLKCTR_IOSRST 0x80000000
339#define TX4939_CLKCTR_SYSRST 0x40000000
340#define TX4939_CLKCTR_TM5RST 0x20000000
341#define TX4939_CLKCTR_TM4RST 0x10000000
342#define TX4939_CLKCTR_TM3RST 0x08000000
343#define TX4939_CLKCTR_CIRRST 0x04000000
344#define TX4939_CLKCTR_SIO3RST 0x02000000
345#define TX4939_CLKCTR_SIO2RST 0x01000000
346#define TX4939_CLKCTR_SIO1RST 0x00800000
347#define TX4939_CLKCTR_VPCRST 0x00400000
348#define TX4939_CLKCTR_EPCIRST 0x00200000
349#define TX4939_CLKCTR_ETH1RST 0x00080000
350#define TX4939_CLKCTR_ATA1RST 0x00040000
351#define TX4939_CLKCTR_BROMRST 0x00020000
352#define TX4939_CLKCTR_NDCRST 0x00010000
353#define TX4939_CLKCTR_I2CRST 0x00008000
354#define TX4939_CLKCTR_ETH0RST 0x00004000
355#define TX4939_CLKCTR_SPIRST 0x00002000
356#define TX4939_CLKCTR_SRAMRST 0x00001000
357#define TX4939_CLKCTR_PCI1RST 0x00000800
358#define TX4939_CLKCTR_DMA1RST 0x00000400
359#define TX4939_CLKCTR_ACLRST 0x00000200
360#define TX4939_CLKCTR_ATA0RST 0x00000100
361#define TX4939_CLKCTR_DMA0RST 0x00000080
362#define TX4939_CLKCTR_PCICRST 0x00000040
363#define TX4939_CLKCTR_I2SRST 0x00000020
364#define TX4939_CLKCTR_TM0RST 0x00000010
365#define TX4939_CLKCTR_TM1RST 0x00000008
366#define TX4939_CLKCTR_TM2RST 0x00000004
367#define TX4939_CLKCTR_SIO0RST 0x00000002
368#define TX4939_CLKCTR_CYPRST 0x00000001
369
370/*
371 * RTC
372 */
373#define TX4939_RTCCTL_ALME 0x00000080
374#define TX4939_RTCCTL_ALMD 0x00000040
375#define TX4939_RTCCTL_BUSY 0x00000020
376
377#define TX4939_RTCCTL_COMMAND 0x00000007
378#define TX4939_RTCCTL_COMMAND_NOP 0x00000000
379#define TX4939_RTCCTL_COMMAND_GETTIME 0x00000001
380#define TX4939_RTCCTL_COMMAND_SETTIME 0x00000002
381#define TX4939_RTCCTL_COMMAND_GETALARM 0x00000003
382#define TX4939_RTCCTL_COMMAND_SETALARM 0x00000004
383
384#define TX4939_RTCTBC_PM 0x00000080
385#define TX4939_RTCTBC_COMP 0x0000007f
386
387#define TX4939_RTC_REG_RAMSIZE 0x00000100
388#define TX4939_RTC_REG_RWBSIZE 0x00000006
389
390/*
391 * CRYPTO
392 */
393#define TX4939_CRYPTO_CSR_SAESO 0x08000000
394#define TX4939_CRYPTO_CSR_SAESI 0x04000000
395#define TX4939_CRYPTO_CSR_SDESO 0x02000000
396#define TX4939_CRYPTO_CSR_SDESI 0x01000000
397#define TX4939_CRYPTO_CSR_INDXBST_MASK 0x00700000
398#define TX4939_CRYPTO_CSR_INDXBST(n) ((n) << 20)
399#define TX4939_CRYPTO_CSR_TOINT 0x00080000
400#define TX4939_CRYPTO_CSR_DCINT 0x00040000
401#define TX4939_CRYPTO_CSR_GBINT 0x00010000
402#define TX4939_CRYPTO_CSR_INDXAST_MASK 0x0000e000
403#define TX4939_CRYPTO_CSR_INDXAST(n) ((n) << 13)
404#define TX4939_CRYPTO_CSR_CSWAP_MASK 0x00001800
405#define TX4939_CRYPTO_CSR_CSWAP_NONE 0x00000000
406#define TX4939_CRYPTO_CSR_CSWAP_IN 0x00000800
407#define TX4939_CRYPTO_CSR_CSWAP_OUT 0x00001000
408#define TX4939_CRYPTO_CSR_CSWAP_BOTH 0x00001800
409#define TX4939_CRYPTO_CSR_CDIV_MASK 0x00000600
410#define TX4939_CRYPTO_CSR_CDIV_DIV2 0x00000000
411#define TX4939_CRYPTO_CSR_CDIV_DIV1 0x00000200
412#define TX4939_CRYPTO_CSR_CDIV_DIV2ALT 0x00000400
413#define TX4939_CRYPTO_CSR_CDIV_DIV1ALT 0x00000600
414#define TX4939_CRYPTO_CSR_PDINT_MASK 0x000000c0
415#define TX4939_CRYPTO_CSR_PDINT_ALL 0x00000000
416#define TX4939_CRYPTO_CSR_PDINT_END 0x00000040
417#define TX4939_CRYPTO_CSR_PDINT_NEXT 0x00000080
418#define TX4939_CRYPTO_CSR_PDINT_NONE 0x000000c0
419#define TX4939_CRYPTO_CSR_GINTE 0x00000008
420#define TX4939_CRYPTO_CSR_RSTD 0x00000004
421#define TX4939_CRYPTO_CSR_RSTC 0x00000002
422#define TX4939_CRYPTO_CSR_ENCR 0x00000001
423
424/* bits for tx4939_crypto_reg.cdr.gen.ctrl */
425#define TX4939_CRYPTO_CTX_ENGINE_MASK 0x00000003
426#define TX4939_CRYPTO_CTX_ENGINE_DES 0x00000000
427#define TX4939_CRYPTO_CTX_ENGINE_AES 0x00000001
428#define TX4939_CRYPTO_CTX_ENGINE_MD5 0x00000002
429#define TX4939_CRYPTO_CTX_ENGINE_SHA1 0x00000003
430#define TX4939_CRYPTO_CTX_TDMS 0x00000010
431#define TX4939_CRYPTO_CTX_CMS 0x00000020
432#define TX4939_CRYPTO_CTX_DMS 0x00000040
433#define TX4939_CRYPTO_CTX_UPDATE 0x00000080
434
435/* bits for tx4939_crypto_desc.ctrl */
436#define TX4939_CRYPTO_DESC_OB_CNT_MASK 0xffe00000
437#define TX4939_CRYPTO_DESC_OB_CNT(cnt) ((cnt) << 21)
438#define TX4939_CRYPTO_DESC_IB_CNT_MASK 0x001ffc00
439#define TX4939_CRYPTO_DESC_IB_CNT(cnt) ((cnt) << 10)
440#define TX4939_CRYPTO_DESC_START 0x00000200
441#define TX4939_CRYPTO_DESC_END 0x00000100
442#define TX4939_CRYPTO_DESC_XOR 0x00000010
443#define TX4939_CRYPTO_DESC_LAST 0x00000008
444#define TX4939_CRYPTO_DESC_ERR_MASK 0x00000006
445#define TX4939_CRYPTO_DESC_ERR_NONE 0x00000000
446#define TX4939_CRYPTO_DESC_ERR_TOUT 0x00000002
447#define TX4939_CRYPTO_DESC_ERR_DIGEST 0x00000004
448#define TX4939_CRYPTO_DESC_OWN 0x00000001
449
450/* bits for tx4939_crypto_desc.index */
451#define TX4939_CRYPTO_DESC_HASH_IDX_MASK 0x00000070
452#define TX4939_CRYPTO_DESC_HASH_IDX(idx) ((idx) << 4)
453#define TX4939_CRYPTO_DESC_ENCRYPT_IDX_MASK 0x00000007
454#define TX4939_CRYPTO_DESC_ENCRYPT_IDX(idx) ((idx) << 0)
455
456#define TX4939_CRYPTO_NR_SET 6
457
458#define TX4939_CRYPTO_RCSR_INTE 0x00000008
459#define TX4939_CRYPTO_RCSR_RST 0x00000004
460#define TX4939_CRYPTO_RCSR_FIN 0x00000002
461#define TX4939_CRYPTO_RCSR_ST 0x00000001
462
463/*
464 * VPC
465 */
466#define TX4939_VPC_CSR_GBINT 0x00010000
467#define TX4939_VPC_CSR_SWAPO 0x00000020
468#define TX4939_VPC_CSR_SWAPI 0x00000010
469#define TX4939_VPC_CSR_GINTE 0x00000008
470#define TX4939_VPC_CSR_RSTD 0x00000004
471#define TX4939_VPC_CSR_RSTVPC 0x00000002
472
473#define TX4939_VPC_CTRLA_VDPSN 0x00000200
474#define TX4939_VPC_CTRLA_PBUSY 0x00000100
475#define TX4939_VPC_CTRLA_DCINT 0x00000080
476#define TX4939_VPC_CTRLA_UOINT 0x00000040
477#define TX4939_VPC_CTRLA_PDINT_MASK 0x00000030
478#define TX4939_VPC_CTRLA_PDINT_ALL 0x00000000
479#define TX4939_VPC_CTRLA_PDINT_NEXT 0x00000010
480#define TX4939_VPC_CTRLA_PDINT_NONE 0x00000030
481#define TX4939_VPC_CTRLA_VDVLDP 0x00000008
482#define TX4939_VPC_CTRLA_VDMODE 0x00000004
483#define TX4939_VPC_CTRLA_VDFOR 0x00000002
484#define TX4939_VPC_CTRLA_ENVPC 0x00000001
485
486/* bits for tx4939_vpc_desc.ctrl1 */
487#define TX4939_VPC_DESC_CTRL1_ERR_MASK 0x00000006
488#define TX4939_VPC_DESC_CTRL1_OWN 0x00000001
489
490#define tx4939_ddrcptr ((struct tx4939_ddrc_reg __iomem *)TX4939_DDRC_REG)
491#define tx4939_ebuscptr tx4938_ebuscptr
492#define tx4939_ircptr \
493 ((struct tx4939_irc_reg __iomem *)TX4939_IRC_REG)
494#define tx4939_pcicptr tx4938_pcicptr
495#define tx4939_pcic1ptr tx4938_pcic1ptr
496#define tx4939_ccfgptr \
497 ((struct tx4939_ccfg_reg __iomem *)TX4939_CCFG_REG)
498#define tx4939_sramcptr tx4938_sramcptr
499#define tx4939_rtcptr \
500 ((struct tx4939_rtc_reg __iomem *)TX4939_RTC_REG)
501#define tx4939_cryptoptr \
502 ((struct tx4939_crypto_reg __iomem *)TX4939_CRYPTO_REG)
503#define tx4939_vpcptr ((struct tx4939_vpc_reg __iomem *)TX4939_VPC_REG)
504
505#define TX4939_REV_MAJ_MIN() \
506 ((__u32)__raw_readq(&tx4939_ccfgptr->crir) & 0x00ff)
507#define TX4939_REV_PCODE() \
508 ((__u32)__raw_readq(&tx4939_ccfgptr->crir) >> 16)
509#define TX4939_CCFG_BCFG() \
510 ((__u32)((__raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_BCFG_MASK) \
511 >> 32))
512
513#define tx4939_ccfg_clear(bits) tx4938_ccfg_clear(bits)
514#define tx4939_ccfg_set(bits) tx4938_ccfg_set(bits)
515#define tx4939_ccfg_change(change, new) tx4938_ccfg_change(change, new)
516
517#define TX4939_EBUSC_CR(ch) TX4927_EBUSC_CR(ch)
518#define TX4939_EBUSC_BA(ch) TX4927_EBUSC_BA(ch)
519#define TX4939_EBUSC_SIZE(ch) TX4927_EBUSC_SIZE(ch)
520#define TX4939_EBUSC_WIDTH(ch) \
521 (16 >> ((__u32)(TX4939_EBUSC_CR(ch) >> 20) & 0x1))
522
523/* SCLK0 = MSTCLK * 429/19 * 16/245 / 2 (14.745MHz for MST 20MHz) */
524#define TX4939_SCLK0(mst) \
525 ((((mst) + 245/2) / 245UL * 429 * 16 + 19) / 19 / 2)
526
527void tx4939_wdt_init(void);
528void tx4939_add_memory_regions(void);
529void tx4939_setup(void);
530void tx4939_time_init(unsigned int tmrnr);
531void tx4939_sio_init(unsigned int sclk, unsigned int cts_mask);
532void tx4939_spi_init(int busid);
533void tx4939_ethaddr_init(unsigned char *addr0, unsigned char *addr1);
534int tx4939_report_pciclk(void);
535void tx4939_report_pci1clk(void);
536struct pci_dev;
537int tx4939_pcic1_map_irq(const struct pci_dev *dev, u8 slot);
538int tx4939_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
539void tx4939_setup_pcierr_irq(void);
540void tx4939_irq_init(void);
541int tx4939_irq(void);
542void tx4939_mtd_init(int ch);
543void tx4939_ata_init(void);
544
545#endif /* __ASM_TXX9_TX4939_H */
diff --git a/arch/mips/include/asm/txx9irq.h b/arch/mips/include/asm/txx9irq.h
new file mode 100644
index 000000000000..5620879be37f
--- /dev/null
+++ b/arch/mips/include/asm/txx9irq.h
@@ -0,0 +1,34 @@
1/*
2 * include/asm-mips/txx9irq.h
3 * TX39/TX49 interrupt controller definitions.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9#ifndef __ASM_TXX9IRQ_H
10#define __ASM_TXX9IRQ_H
11
12#include <irq.h>
13
14#ifdef CONFIG_IRQ_CPU
15#define TXX9_IRQ_BASE (MIPS_CPU_IRQ_BASE + 8)
16#else
17#ifdef CONFIG_I8259
18#define TXX9_IRQ_BASE (I8259A_IRQ_BASE + 16)
19#else
20#define TXX9_IRQ_BASE 0
21#endif
22#endif
23
24#ifdef CONFIG_CPU_TX39XX
25#define TXx9_MAX_IR 16
26#else
27#define TXx9_MAX_IR 32
28#endif
29
30void txx9_irq_init(unsigned long baseaddr);
31int txx9_irq(void);
32int txx9_irq_set_pri(int irc_irq, int new_pri);
33
34#endif /* __ASM_TXX9IRQ_H */
diff --git a/arch/mips/include/asm/txx9pio.h b/arch/mips/include/asm/txx9pio.h
new file mode 100644
index 000000000000..3d6fa9f8d513
--- /dev/null
+++ b/arch/mips/include/asm/txx9pio.h
@@ -0,0 +1,29 @@
1/*
2 * include/asm-mips/txx9pio.h
3 * TX39/TX49 PIO controller definitions.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9#ifndef __ASM_TXX9PIO_H
10#define __ASM_TXX9PIO_H
11
12#include <linux/types.h>
13
14struct txx9_pio_reg {
15 __u32 dout;
16 __u32 din;
17 __u32 dir;
18 __u32 od;
19 __u32 flag[2];
20 __u32 pol;
21 __u32 intc;
22 __u32 maskcpu;
23 __u32 maskext;
24};
25
26int txx9_gpio_init(unsigned long baseaddr,
27 unsigned int base, unsigned int num);
28
29#endif /* __ASM_TXX9PIO_H */
diff --git a/arch/mips/include/asm/txx9tmr.h b/arch/mips/include/asm/txx9tmr.h
new file mode 100644
index 000000000000..67f70a8f09bd
--- /dev/null
+++ b/arch/mips/include/asm/txx9tmr.h
@@ -0,0 +1,67 @@
1/*
2 * include/asm-mips/txx9tmr.h
3 * TX39/TX49 timer controller definitions.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9#ifndef __ASM_TXX9TMR_H
10#define __ASM_TXX9TMR_H
11
12#include <linux/types.h>
13
14struct txx9_tmr_reg {
15 u32 tcr;
16 u32 tisr;
17 u32 cpra;
18 u32 cprb;
19 u32 itmr;
20 u32 unused0[3];
21 u32 ccdr;
22 u32 unused1[3];
23 u32 pgmr;
24 u32 unused2[3];
25 u32 wtmr;
26 u32 unused3[43];
27 u32 trr;
28};
29
30/* TMTCR : Timer Control */
31#define TXx9_TMTCR_TCE 0x00000080
32#define TXx9_TMTCR_CCDE 0x00000040
33#define TXx9_TMTCR_CRE 0x00000020
34#define TXx9_TMTCR_ECES 0x00000008
35#define TXx9_TMTCR_CCS 0x00000004
36#define TXx9_TMTCR_TMODE_MASK 0x00000003
37#define TXx9_TMTCR_TMODE_ITVL 0x00000000
38#define TXx9_TMTCR_TMODE_PGEN 0x00000001
39#define TXx9_TMTCR_TMODE_WDOG 0x00000002
40
41/* TMTISR : Timer Int. Status */
42#define TXx9_TMTISR_TPIBS 0x00000004
43#define TXx9_TMTISR_TPIAS 0x00000002
44#define TXx9_TMTISR_TIIS 0x00000001
45
46/* TMITMR : Interval Timer Mode */
47#define TXx9_TMITMR_TIIE 0x00008000
48#define TXx9_TMITMR_TZCE 0x00000001
49
50/* TMWTMR : Watchdog Timer Mode */
51#define TXx9_TMWTMR_TWIE 0x00008000
52#define TXx9_TMWTMR_WDIS 0x00000080
53#define TXx9_TMWTMR_TWC 0x00000001
54
55void txx9_clocksource_init(unsigned long baseaddr,
56 unsigned int imbusclk);
57void txx9_clockevent_init(unsigned long baseaddr, int irq,
58 unsigned int imbusclk);
59void txx9_tmr_init(unsigned long baseaddr);
60
61#ifdef CONFIG_CPU_TX39XX
62#define TXX9_TIMER_BITS 24
63#else
64#define TXX9_TIMER_BITS 32
65#endif
66
67#endif /* __ASM_TXX9TMR_H */
diff --git a/arch/mips/include/asm/types.h b/arch/mips/include/asm/types.h
new file mode 100644
index 000000000000..bcbb8d675af5
--- /dev/null
+++ b/arch/mips/include/asm/types.h
@@ -0,0 +1,54 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 */
9#ifndef _ASM_TYPES_H
10#define _ASM_TYPES_H
11
12#if _MIPS_SZLONG == 64
13# include <asm-generic/int-l64.h>
14#else
15# include <asm-generic/int-ll64.h>
16#endif
17
18#ifndef __ASSEMBLY__
19
20typedef unsigned short umode_t;
21
22#endif /* __ASSEMBLY__ */
23
24/*
25 * These aren't exported outside the kernel to avoid name space clashes
26 */
27#ifdef __KERNEL__
28
29#define BITS_PER_LONG _MIPS_SZLONG
30
31#ifndef __ASSEMBLY__
32
33#if (defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) \
34 || defined(CONFIG_64BIT)
35typedef u64 dma_addr_t;
36#else
37typedef u32 dma_addr_t;
38#endif
39typedef u64 dma64_addr_t;
40
41/*
42 * Don't use phys_t. You've been warned.
43 */
44#ifdef CONFIG_64BIT_PHYS_ADDR
45typedef unsigned long long phys_t;
46#else
47typedef unsigned long phys_t;
48#endif
49
50#endif /* __ASSEMBLY__ */
51
52#endif /* __KERNEL__ */
53
54#endif /* _ASM_TYPES_H */
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
new file mode 100644
index 000000000000..09ff5bb17445
--- /dev/null
+++ b/arch/mips/include/asm/uaccess.h
@@ -0,0 +1,1114 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 03, 04 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2007 Maciej W. Rozycki
9 */
10#ifndef _ASM_UACCESS_H
11#define _ASM_UACCESS_H
12
13#include <linux/kernel.h>
14#include <linux/errno.h>
15#include <linux/thread_info.h>
16
17/*
18 * The fs value determines whether argument validity checking should be
19 * performed or not. If get_fs() == USER_DS, checking is performed, with
20 * get_fs() == KERNEL_DS, checking is bypassed.
21 *
22 * For historical reasons, these macros are grossly misnamed.
23 */
24#ifdef CONFIG_32BIT
25
26#define __UA_LIMIT 0x80000000UL
27
28#define __UA_ADDR ".word"
29#define __UA_LA "la"
30#define __UA_ADDU "addu"
31#define __UA_t0 "$8"
32#define __UA_t1 "$9"
33
34#endif /* CONFIG_32BIT */
35
36#ifdef CONFIG_64BIT
37
38#define __UA_LIMIT (- TASK_SIZE)
39
40#define __UA_ADDR ".dword"
41#define __UA_LA "dla"
42#define __UA_ADDU "daddu"
43#define __UA_t0 "$12"
44#define __UA_t1 "$13"
45
46#endif /* CONFIG_64BIT */
47
48/*
49 * USER_DS is a bitmask that has the bits set that may not be set in a valid
50 * userspace address. Note that we limit 32-bit userspace to 0x7fff8000 but
51 * the arithmetic we're doing only works if the limit is a power of two, so
52 * we use 0x80000000 here on 32-bit kernels. If a process passes an invalid
53 * address in this range it's the process's problem, not ours :-)
54 */
55
56#define KERNEL_DS ((mm_segment_t) { 0UL })
57#define USER_DS ((mm_segment_t) { __UA_LIMIT })
58
59#define VERIFY_READ 0
60#define VERIFY_WRITE 1
61
62#define get_ds() (KERNEL_DS)
63#define get_fs() (current_thread_info()->addr_limit)
64#define set_fs(x) (current_thread_info()->addr_limit = (x))
65
66#define segment_eq(a, b) ((a).seg == (b).seg)
67
68
69/*
70 * Is a address valid? This does a straighforward calculation rather
71 * than tests.
72 *
73 * Address valid if:
74 * - "addr" doesn't have any high-bits set
75 * - AND "size" doesn't have any high-bits set
76 * - AND "addr+size" doesn't have any high-bits set
77 * - OR we are in kernel mode.
78 *
79 * __ua_size() is a trick to avoid runtime checking of positive constant
80 * sizes; for those we already know at compile time that the size is ok.
81 */
82#define __ua_size(size) \
83 ((__builtin_constant_p(size) && (signed long) (size) > 0) ? 0 : (size))
84
85/*
86 * access_ok: - Checks if a user space pointer is valid
87 * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that
88 * %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe
89 * to write to a block, it is always safe to read from it.
90 * @addr: User space pointer to start of block to check
91 * @size: Size of block to check
92 *
93 * Context: User context only. This function may sleep.
94 *
95 * Checks if a pointer to a block of memory in user space is valid.
96 *
97 * Returns true (nonzero) if the memory block may be valid, false (zero)
98 * if it is definitely invalid.
99 *
100 * Note that, depending on architecture, this function probably just
101 * checks that the pointer is in the user space range - after calling
102 * this function, memory access functions may still return -EFAULT.
103 */
104
105#define __access_mask get_fs().seg
106
107#define __access_ok(addr, size, mask) \
108 (((signed long)((mask) & ((addr) | ((addr) + (size)) | __ua_size(size)))) == 0)
109
110#define access_ok(type, addr, size) \
111 likely(__access_ok((unsigned long)(addr), (size), __access_mask))
112
113/*
114 * put_user: - Write a simple value into user space.
115 * @x: Value to copy to user space.
116 * @ptr: Destination address, in user space.
117 *
118 * Context: User context only. This function may sleep.
119 *
120 * This macro copies a single simple value from kernel space to user
121 * space. It supports simple types like char and int, but not larger
122 * data types like structures or arrays.
123 *
124 * @ptr must have pointer-to-simple-variable type, and @x must be assignable
125 * to the result of dereferencing @ptr.
126 *
127 * Returns zero on success, or -EFAULT on error.
128 */
129#define put_user(x,ptr) \
130 __put_user_check((x), (ptr), sizeof(*(ptr)))
131
132/*
133 * get_user: - Get a simple variable from user space.
134 * @x: Variable to store result.
135 * @ptr: Source address, in user space.
136 *
137 * Context: User context only. This function may sleep.
138 *
139 * This macro copies a single simple variable from user space to kernel
140 * space. It supports simple types like char and int, but not larger
141 * data types like structures or arrays.
142 *
143 * @ptr must have pointer-to-simple-variable type, and the result of
144 * dereferencing @ptr must be assignable to @x without a cast.
145 *
146 * Returns zero on success, or -EFAULT on error.
147 * On error, the variable @x is set to zero.
148 */
149#define get_user(x,ptr) \
150 __get_user_check((x), (ptr), sizeof(*(ptr)))
151
152/*
153 * __put_user: - Write a simple value into user space, with less checking.
154 * @x: Value to copy to user space.
155 * @ptr: Destination address, in user space.
156 *
157 * Context: User context only. This function may sleep.
158 *
159 * This macro copies a single simple value from kernel space to user
160 * space. It supports simple types like char and int, but not larger
161 * data types like structures or arrays.
162 *
163 * @ptr must have pointer-to-simple-variable type, and @x must be assignable
164 * to the result of dereferencing @ptr.
165 *
166 * Caller must check the pointer with access_ok() before calling this
167 * function.
168 *
169 * Returns zero on success, or -EFAULT on error.
170 */
171#define __put_user(x,ptr) \
172 __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
173
174/*
175 * __get_user: - Get a simple variable from user space, with less checking.
176 * @x: Variable to store result.
177 * @ptr: Source address, in user space.
178 *
179 * Context: User context only. This function may sleep.
180 *
181 * This macro copies a single simple variable from user space to kernel
182 * space. It supports simple types like char and int, but not larger
183 * data types like structures or arrays.
184 *
185 * @ptr must have pointer-to-simple-variable type, and the result of
186 * dereferencing @ptr must be assignable to @x without a cast.
187 *
188 * Caller must check the pointer with access_ok() before calling this
189 * function.
190 *
191 * Returns zero on success, or -EFAULT on error.
192 * On error, the variable @x is set to zero.
193 */
194#define __get_user(x,ptr) \
195 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
196
197struct __large_struct { unsigned long buf[100]; };
198#define __m(x) (*(struct __large_struct __user *)(x))
199
200/*
201 * Yuck. We need two variants, one for 64bit operation and one
202 * for 32 bit mode and old iron.
203 */
204#ifdef CONFIG_32BIT
205#define __GET_USER_DW(val, ptr) __get_user_asm_ll32(val, ptr)
206#endif
207#ifdef CONFIG_64BIT
208#define __GET_USER_DW(val, ptr) __get_user_asm(val, "ld", ptr)
209#endif
210
211extern void __get_user_unknown(void);
212
213#define __get_user_common(val, size, ptr) \
214do { \
215 switch (size) { \
216 case 1: __get_user_asm(val, "lb", ptr); break; \
217 case 2: __get_user_asm(val, "lh", ptr); break; \
218 case 4: __get_user_asm(val, "lw", ptr); break; \
219 case 8: __GET_USER_DW(val, ptr); break; \
220 default: __get_user_unknown(); break; \
221 } \
222} while (0)
223
224#define __get_user_nocheck(x, ptr, size) \
225({ \
226 int __gu_err; \
227 \
228 __get_user_common((x), size, ptr); \
229 __gu_err; \
230})
231
232#define __get_user_check(x, ptr, size) \
233({ \
234 int __gu_err = -EFAULT; \
235 const __typeof__(*(ptr)) __user * __gu_ptr = (ptr); \
236 \
237 if (likely(access_ok(VERIFY_READ, __gu_ptr, size))) \
238 __get_user_common((x), size, __gu_ptr); \
239 \
240 __gu_err; \
241})
242
243#define __get_user_asm(val, insn, addr) \
244{ \
245 long __gu_tmp; \
246 \
247 __asm__ __volatile__( \
248 "1: " insn " %1, %3 \n" \
249 "2: \n" \
250 " .section .fixup,\"ax\" \n" \
251 "3: li %0, %4 \n" \
252 " j 2b \n" \
253 " .previous \n" \
254 " .section __ex_table,\"a\" \n" \
255 " "__UA_ADDR "\t1b, 3b \n" \
256 " .previous \n" \
257 : "=r" (__gu_err), "=r" (__gu_tmp) \
258 : "0" (0), "o" (__m(addr)), "i" (-EFAULT)); \
259 \
260 (val) = (__typeof__(*(addr))) __gu_tmp; \
261}
262
263/*
264 * Get a long long 64 using 32 bit registers.
265 */
266#define __get_user_asm_ll32(val, addr) \
267{ \
268 union { \
269 unsigned long long l; \
270 __typeof__(*(addr)) t; \
271 } __gu_tmp; \
272 \
273 __asm__ __volatile__( \
274 "1: lw %1, (%3) \n" \
275 "2: lw %D1, 4(%3) \n" \
276 "3: .section .fixup,\"ax\" \n" \
277 "4: li %0, %4 \n" \
278 " move %1, $0 \n" \
279 " move %D1, $0 \n" \
280 " j 3b \n" \
281 " .previous \n" \
282 " .section __ex_table,\"a\" \n" \
283 " " __UA_ADDR " 1b, 4b \n" \
284 " " __UA_ADDR " 2b, 4b \n" \
285 " .previous \n" \
286 : "=r" (__gu_err), "=&r" (__gu_tmp.l) \
287 : "0" (0), "r" (addr), "i" (-EFAULT)); \
288 \
289 (val) = __gu_tmp.t; \
290}
291
292/*
293 * Yuck. We need two variants, one for 64bit operation and one
294 * for 32 bit mode and old iron.
295 */
296#ifdef CONFIG_32BIT
297#define __PUT_USER_DW(ptr) __put_user_asm_ll32(ptr)
298#endif
299#ifdef CONFIG_64BIT
300#define __PUT_USER_DW(ptr) __put_user_asm("sd", ptr)
301#endif
302
303#define __put_user_nocheck(x, ptr, size) \
304({ \
305 __typeof__(*(ptr)) __pu_val; \
306 int __pu_err = 0; \
307 \
308 __pu_val = (x); \
309 switch (size) { \
310 case 1: __put_user_asm("sb", ptr); break; \
311 case 2: __put_user_asm("sh", ptr); break; \
312 case 4: __put_user_asm("sw", ptr); break; \
313 case 8: __PUT_USER_DW(ptr); break; \
314 default: __put_user_unknown(); break; \
315 } \
316 __pu_err; \
317})
318
319#define __put_user_check(x, ptr, size) \
320({ \
321 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
322 __typeof__(*(ptr)) __pu_val = (x); \
323 int __pu_err = -EFAULT; \
324 \
325 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) { \
326 switch (size) { \
327 case 1: __put_user_asm("sb", __pu_addr); break; \
328 case 2: __put_user_asm("sh", __pu_addr); break; \
329 case 4: __put_user_asm("sw", __pu_addr); break; \
330 case 8: __PUT_USER_DW(__pu_addr); break; \
331 default: __put_user_unknown(); break; \
332 } \
333 } \
334 __pu_err; \
335})
336
337#define __put_user_asm(insn, ptr) \
338{ \
339 __asm__ __volatile__( \
340 "1: " insn " %z2, %3 # __put_user_asm\n" \
341 "2: \n" \
342 " .section .fixup,\"ax\" \n" \
343 "3: li %0, %4 \n" \
344 " j 2b \n" \
345 " .previous \n" \
346 " .section __ex_table,\"a\" \n" \
347 " " __UA_ADDR " 1b, 3b \n" \
348 " .previous \n" \
349 : "=r" (__pu_err) \
350 : "0" (0), "Jr" (__pu_val), "o" (__m(ptr)), \
351 "i" (-EFAULT)); \
352}
353
354#define __put_user_asm_ll32(ptr) \
355{ \
356 __asm__ __volatile__( \
357 "1: sw %2, (%3) # __put_user_asm_ll32 \n" \
358 "2: sw %D2, 4(%3) \n" \
359 "3: \n" \
360 " .section .fixup,\"ax\" \n" \
361 "4: li %0, %4 \n" \
362 " j 3b \n" \
363 " .previous \n" \
364 " .section __ex_table,\"a\" \n" \
365 " " __UA_ADDR " 1b, 4b \n" \
366 " " __UA_ADDR " 2b, 4b \n" \
367 " .previous" \
368 : "=r" (__pu_err) \
369 : "0" (0), "r" (__pu_val), "r" (ptr), \
370 "i" (-EFAULT)); \
371}
372
373extern void __put_user_unknown(void);
374
375/*
376 * put_user_unaligned: - Write a simple value into user space.
377 * @x: Value to copy to user space.
378 * @ptr: Destination address, in user space.
379 *
380 * Context: User context only. This function may sleep.
381 *
382 * This macro copies a single simple value from kernel space to user
383 * space. It supports simple types like char and int, but not larger
384 * data types like structures or arrays.
385 *
386 * @ptr must have pointer-to-simple-variable type, and @x must be assignable
387 * to the result of dereferencing @ptr.
388 *
389 * Returns zero on success, or -EFAULT on error.
390 */
391#define put_user_unaligned(x,ptr) \
392 __put_user_unaligned_check((x),(ptr),sizeof(*(ptr)))
393
394/*
395 * get_user_unaligned: - Get a simple variable from user space.
396 * @x: Variable to store result.
397 * @ptr: Source address, in user space.
398 *
399 * Context: User context only. This function may sleep.
400 *
401 * This macro copies a single simple variable from user space to kernel
402 * space. It supports simple types like char and int, but not larger
403 * data types like structures or arrays.
404 *
405 * @ptr must have pointer-to-simple-variable type, and the result of
406 * dereferencing @ptr must be assignable to @x without a cast.
407 *
408 * Returns zero on success, or -EFAULT on error.
409 * On error, the variable @x is set to zero.
410 */
411#define get_user_unaligned(x,ptr) \
412 __get_user_unaligned_check((x),(ptr),sizeof(*(ptr)))
413
414/*
415 * __put_user_unaligned: - Write a simple value into user space, with less checking.
416 * @x: Value to copy to user space.
417 * @ptr: Destination address, in user space.
418 *
419 * Context: User context only. This function may sleep.
420 *
421 * This macro copies a single simple value from kernel space to user
422 * space. It supports simple types like char and int, but not larger
423 * data types like structures or arrays.
424 *
425 * @ptr must have pointer-to-simple-variable type, and @x must be assignable
426 * to the result of dereferencing @ptr.
427 *
428 * Caller must check the pointer with access_ok() before calling this
429 * function.
430 *
431 * Returns zero on success, or -EFAULT on error.
432 */
433#define __put_user_unaligned(x,ptr) \
434 __put_user_unaligned_nocheck((x),(ptr),sizeof(*(ptr)))
435
436/*
437 * __get_user_unaligned: - Get a simple variable from user space, with less checking.
438 * @x: Variable to store result.
439 * @ptr: Source address, in user space.
440 *
441 * Context: User context only. This function may sleep.
442 *
443 * This macro copies a single simple variable from user space to kernel
444 * space. It supports simple types like char and int, but not larger
445 * data types like structures or arrays.
446 *
447 * @ptr must have pointer-to-simple-variable type, and the result of
448 * dereferencing @ptr must be assignable to @x without a cast.
449 *
450 * Caller must check the pointer with access_ok() before calling this
451 * function.
452 *
453 * Returns zero on success, or -EFAULT on error.
454 * On error, the variable @x is set to zero.
455 */
456#define __get_user_unaligned(x,ptr) \
457 __get_user__unalignednocheck((x),(ptr),sizeof(*(ptr)))
458
459/*
460 * Yuck. We need two variants, one for 64bit operation and one
461 * for 32 bit mode and old iron.
462 */
463#ifdef CONFIG_32BIT
464#define __GET_USER_UNALIGNED_DW(val, ptr) \
465 __get_user_unaligned_asm_ll32(val, ptr)
466#endif
467#ifdef CONFIG_64BIT
468#define __GET_USER_UNALIGNED_DW(val, ptr) \
469 __get_user_unaligned_asm(val, "uld", ptr)
470#endif
471
472extern void __get_user_unaligned_unknown(void);
473
474#define __get_user_unaligned_common(val, size, ptr) \
475do { \
476 switch (size) { \
477 case 1: __get_user_asm(val, "lb", ptr); break; \
478 case 2: __get_user_unaligned_asm(val, "ulh", ptr); break; \
479 case 4: __get_user_unaligned_asm(val, "ulw", ptr); break; \
480 case 8: __GET_USER_UNALIGNED_DW(val, ptr); break; \
481 default: __get_user_unaligned_unknown(); break; \
482 } \
483} while (0)
484
485#define __get_user_unaligned_nocheck(x,ptr,size) \
486({ \
487 int __gu_err; \
488 \
489 __get_user_unaligned_common((x), size, ptr); \
490 __gu_err; \
491})
492
493#define __get_user_unaligned_check(x,ptr,size) \
494({ \
495 int __gu_err = -EFAULT; \
496 const __typeof__(*(ptr)) __user * __gu_ptr = (ptr); \
497 \
498 if (likely(access_ok(VERIFY_READ, __gu_ptr, size))) \
499 __get_user_unaligned_common((x), size, __gu_ptr); \
500 \
501 __gu_err; \
502})
503
504#define __get_user_unaligned_asm(val, insn, addr) \
505{ \
506 long __gu_tmp; \
507 \
508 __asm__ __volatile__( \
509 "1: " insn " %1, %3 \n" \
510 "2: \n" \
511 " .section .fixup,\"ax\" \n" \
512 "3: li %0, %4 \n" \
513 " j 2b \n" \
514 " .previous \n" \
515 " .section __ex_table,\"a\" \n" \
516 " "__UA_ADDR "\t1b, 3b \n" \
517 " "__UA_ADDR "\t1b + 4, 3b \n" \
518 " .previous \n" \
519 : "=r" (__gu_err), "=r" (__gu_tmp) \
520 : "0" (0), "o" (__m(addr)), "i" (-EFAULT)); \
521 \
522 (val) = (__typeof__(*(addr))) __gu_tmp; \
523}
524
525/*
526 * Get a long long 64 using 32 bit registers.
527 */
528#define __get_user_unaligned_asm_ll32(val, addr) \
529{ \
530 unsigned long long __gu_tmp; \
531 \
532 __asm__ __volatile__( \
533 "1: ulw %1, (%3) \n" \
534 "2: ulw %D1, 4(%3) \n" \
535 " move %0, $0 \n" \
536 "3: .section .fixup,\"ax\" \n" \
537 "4: li %0, %4 \n" \
538 " move %1, $0 \n" \
539 " move %D1, $0 \n" \
540 " j 3b \n" \
541 " .previous \n" \
542 " .section __ex_table,\"a\" \n" \
543 " " __UA_ADDR " 1b, 4b \n" \
544 " " __UA_ADDR " 1b + 4, 4b \n" \
545 " " __UA_ADDR " 2b, 4b \n" \
546 " " __UA_ADDR " 2b + 4, 4b \n" \
547 " .previous \n" \
548 : "=r" (__gu_err), "=&r" (__gu_tmp) \
549 : "0" (0), "r" (addr), "i" (-EFAULT)); \
550 (val) = (__typeof__(*(addr))) __gu_tmp; \
551}
552
553/*
554 * Yuck. We need two variants, one for 64bit operation and one
555 * for 32 bit mode and old iron.
556 */
557#ifdef CONFIG_32BIT
558#define __PUT_USER_UNALIGNED_DW(ptr) __put_user_unaligned_asm_ll32(ptr)
559#endif
560#ifdef CONFIG_64BIT
561#define __PUT_USER_UNALIGNED_DW(ptr) __put_user_unaligned_asm("usd", ptr)
562#endif
563
564#define __put_user_unaligned_nocheck(x,ptr,size) \
565({ \
566 __typeof__(*(ptr)) __pu_val; \
567 int __pu_err = 0; \
568 \
569 __pu_val = (x); \
570 switch (size) { \
571 case 1: __put_user_asm("sb", ptr); break; \
572 case 2: __put_user_unaligned_asm("ush", ptr); break; \
573 case 4: __put_user_unaligned_asm("usw", ptr); break; \
574 case 8: __PUT_USER_UNALIGNED_DW(ptr); break; \
575 default: __put_user_unaligned_unknown(); break; \
576 } \
577 __pu_err; \
578})
579
580#define __put_user_unaligned_check(x,ptr,size) \
581({ \
582 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
583 __typeof__(*(ptr)) __pu_val = (x); \
584 int __pu_err = -EFAULT; \
585 \
586 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) { \
587 switch (size) { \
588 case 1: __put_user_asm("sb", __pu_addr); break; \
589 case 2: __put_user_unaligned_asm("ush", __pu_addr); break; \
590 case 4: __put_user_unaligned_asm("usw", __pu_addr); break; \
591 case 8: __PUT_USER_UNALGINED_DW(__pu_addr); break; \
592 default: __put_user_unaligned_unknown(); break; \
593 } \
594 } \
595 __pu_err; \
596})
597
598#define __put_user_unaligned_asm(insn, ptr) \
599{ \
600 __asm__ __volatile__( \
601 "1: " insn " %z2, %3 # __put_user_unaligned_asm\n" \
602 "2: \n" \
603 " .section .fixup,\"ax\" \n" \
604 "3: li %0, %4 \n" \
605 " j 2b \n" \
606 " .previous \n" \
607 " .section __ex_table,\"a\" \n" \
608 " " __UA_ADDR " 1b, 3b \n" \
609 " .previous \n" \
610 : "=r" (__pu_err) \
611 : "0" (0), "Jr" (__pu_val), "o" (__m(ptr)), \
612 "i" (-EFAULT)); \
613}
614
615#define __put_user_unaligned_asm_ll32(ptr) \
616{ \
617 __asm__ __volatile__( \
618 "1: sw %2, (%3) # __put_user_unaligned_asm_ll32 \n" \
619 "2: sw %D2, 4(%3) \n" \
620 "3: \n" \
621 " .section .fixup,\"ax\" \n" \
622 "4: li %0, %4 \n" \
623 " j 3b \n" \
624 " .previous \n" \
625 " .section __ex_table,\"a\" \n" \
626 " " __UA_ADDR " 1b, 4b \n" \
627 " " __UA_ADDR " 1b + 4, 4b \n" \
628 " " __UA_ADDR " 2b, 4b \n" \
629 " " __UA_ADDR " 2b + 4, 4b \n" \
630 " .previous" \
631 : "=r" (__pu_err) \
632 : "0" (0), "r" (__pu_val), "r" (ptr), \
633 "i" (-EFAULT)); \
634}
635
636extern void __put_user_unaligned_unknown(void);
637
638/*
639 * We're generating jump to subroutines which will be outside the range of
640 * jump instructions
641 */
642#ifdef MODULE
643#define __MODULE_JAL(destination) \
644 ".set\tnoat\n\t" \
645 __UA_LA "\t$1, " #destination "\n\t" \
646 "jalr\t$1\n\t" \
647 ".set\tat\n\t"
648#else
649#define __MODULE_JAL(destination) \
650 "jal\t" #destination "\n\t"
651#endif
652
653#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
654#define DADDI_SCRATCH "$0"
655#else
656#define DADDI_SCRATCH "$3"
657#endif
658
659extern size_t __copy_user(void *__to, const void *__from, size_t __n);
660
661#define __invoke_copy_to_user(to, from, n) \
662({ \
663 register void __user *__cu_to_r __asm__("$4"); \
664 register const void *__cu_from_r __asm__("$5"); \
665 register long __cu_len_r __asm__("$6"); \
666 \
667 __cu_to_r = (to); \
668 __cu_from_r = (from); \
669 __cu_len_r = (n); \
670 __asm__ __volatile__( \
671 __MODULE_JAL(__copy_user) \
672 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
673 : \
674 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \
675 DADDI_SCRATCH, "memory"); \
676 __cu_len_r; \
677})
678
679/*
680 * __copy_to_user: - Copy a block of data into user space, with less checking.
681 * @to: Destination address, in user space.
682 * @from: Source address, in kernel space.
683 * @n: Number of bytes to copy.
684 *
685 * Context: User context only. This function may sleep.
686 *
687 * Copy data from kernel space to user space. Caller must check
688 * the specified block with access_ok() before calling this function.
689 *
690 * Returns number of bytes that could not be copied.
691 * On success, this will be zero.
692 */
693#define __copy_to_user(to, from, n) \
694({ \
695 void __user *__cu_to; \
696 const void *__cu_from; \
697 long __cu_len; \
698 \
699 might_sleep(); \
700 __cu_to = (to); \
701 __cu_from = (from); \
702 __cu_len = (n); \
703 __cu_len = __invoke_copy_to_user(__cu_to, __cu_from, __cu_len); \
704 __cu_len; \
705})
706
707extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
708
709#define __copy_to_user_inatomic(to, from, n) \
710({ \
711 void __user *__cu_to; \
712 const void *__cu_from; \
713 long __cu_len; \
714 \
715 __cu_to = (to); \
716 __cu_from = (from); \
717 __cu_len = (n); \
718 __cu_len = __invoke_copy_to_user(__cu_to, __cu_from, __cu_len); \
719 __cu_len; \
720})
721
722#define __copy_from_user_inatomic(to, from, n) \
723({ \
724 void *__cu_to; \
725 const void __user *__cu_from; \
726 long __cu_len; \
727 \
728 __cu_to = (to); \
729 __cu_from = (from); \
730 __cu_len = (n); \
731 __cu_len = __invoke_copy_from_user_inatomic(__cu_to, __cu_from, \
732 __cu_len); \
733 __cu_len; \
734})
735
736/*
737 * copy_to_user: - Copy a block of data into user space.
738 * @to: Destination address, in user space.
739 * @from: Source address, in kernel space.
740 * @n: Number of bytes to copy.
741 *
742 * Context: User context only. This function may sleep.
743 *
744 * Copy data from kernel space to user space.
745 *
746 * Returns number of bytes that could not be copied.
747 * On success, this will be zero.
748 */
749#define copy_to_user(to, from, n) \
750({ \
751 void __user *__cu_to; \
752 const void *__cu_from; \
753 long __cu_len; \
754 \
755 might_sleep(); \
756 __cu_to = (to); \
757 __cu_from = (from); \
758 __cu_len = (n); \
759 if (access_ok(VERIFY_WRITE, __cu_to, __cu_len)) \
760 __cu_len = __invoke_copy_to_user(__cu_to, __cu_from, \
761 __cu_len); \
762 __cu_len; \
763})
764
765#define __invoke_copy_from_user(to, from, n) \
766({ \
767 register void *__cu_to_r __asm__("$4"); \
768 register const void __user *__cu_from_r __asm__("$5"); \
769 register long __cu_len_r __asm__("$6"); \
770 \
771 __cu_to_r = (to); \
772 __cu_from_r = (from); \
773 __cu_len_r = (n); \
774 __asm__ __volatile__( \
775 ".set\tnoreorder\n\t" \
776 __MODULE_JAL(__copy_user) \
777 ".set\tnoat\n\t" \
778 __UA_ADDU "\t$1, %1, %2\n\t" \
779 ".set\tat\n\t" \
780 ".set\treorder" \
781 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
782 : \
783 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \
784 DADDI_SCRATCH, "memory"); \
785 __cu_len_r; \
786})
787
788#define __invoke_copy_from_user_inatomic(to, from, n) \
789({ \
790 register void *__cu_to_r __asm__("$4"); \
791 register const void __user *__cu_from_r __asm__("$5"); \
792 register long __cu_len_r __asm__("$6"); \
793 \
794 __cu_to_r = (to); \
795 __cu_from_r = (from); \
796 __cu_len_r = (n); \
797 __asm__ __volatile__( \
798 ".set\tnoreorder\n\t" \
799 __MODULE_JAL(__copy_user_inatomic) \
800 ".set\tnoat\n\t" \
801 __UA_ADDU "\t$1, %1, %2\n\t" \
802 ".set\tat\n\t" \
803 ".set\treorder" \
804 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
805 : \
806 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \
807 DADDI_SCRATCH, "memory"); \
808 __cu_len_r; \
809})
810
811/*
812 * __copy_from_user: - Copy a block of data from user space, with less checking.
813 * @to: Destination address, in kernel space.
814 * @from: Source address, in user space.
815 * @n: Number of bytes to copy.
816 *
817 * Context: User context only. This function may sleep.
818 *
819 * Copy data from user space to kernel space. Caller must check
820 * the specified block with access_ok() before calling this function.
821 *
822 * Returns number of bytes that could not be copied.
823 * On success, this will be zero.
824 *
825 * If some data could not be copied, this function will pad the copied
826 * data to the requested size using zero bytes.
827 */
828#define __copy_from_user(to, from, n) \
829({ \
830 void *__cu_to; \
831 const void __user *__cu_from; \
832 long __cu_len; \
833 \
834 might_sleep(); \
835 __cu_to = (to); \
836 __cu_from = (from); \
837 __cu_len = (n); \
838 __cu_len = __invoke_copy_from_user(__cu_to, __cu_from, \
839 __cu_len); \
840 __cu_len; \
841})
842
843/*
844 * copy_from_user: - Copy a block of data from user space.
845 * @to: Destination address, in kernel space.
846 * @from: Source address, in user space.
847 * @n: Number of bytes to copy.
848 *
849 * Context: User context only. This function may sleep.
850 *
851 * Copy data from user space to kernel space.
852 *
853 * Returns number of bytes that could not be copied.
854 * On success, this will be zero.
855 *
856 * If some data could not be copied, this function will pad the copied
857 * data to the requested size using zero bytes.
858 */
859#define copy_from_user(to, from, n) \
860({ \
861 void *__cu_to; \
862 const void __user *__cu_from; \
863 long __cu_len; \
864 \
865 might_sleep(); \
866 __cu_to = (to); \
867 __cu_from = (from); \
868 __cu_len = (n); \
869 if (access_ok(VERIFY_READ, __cu_from, __cu_len)) \
870 __cu_len = __invoke_copy_from_user(__cu_to, __cu_from, \
871 __cu_len); \
872 __cu_len; \
873})
874
875#define __copy_in_user(to, from, n) __copy_from_user(to, from, n)
876
877#define copy_in_user(to, from, n) \
878({ \
879 void __user *__cu_to; \
880 const void __user *__cu_from; \
881 long __cu_len; \
882 \
883 might_sleep(); \
884 __cu_to = (to); \
885 __cu_from = (from); \
886 __cu_len = (n); \
887 if (likely(access_ok(VERIFY_READ, __cu_from, __cu_len) && \
888 access_ok(VERIFY_WRITE, __cu_to, __cu_len))) \
889 __cu_len = __invoke_copy_from_user(__cu_to, __cu_from, \
890 __cu_len); \
891 __cu_len; \
892})
893
894/*
895 * __clear_user: - Zero a block of memory in user space, with less checking.
896 * @to: Destination address, in user space.
897 * @n: Number of bytes to zero.
898 *
899 * Zero a block of memory in user space. Caller must check
900 * the specified block with access_ok() before calling this function.
901 *
902 * Returns number of bytes that could not be cleared.
903 * On success, this will be zero.
904 */
905static inline __kernel_size_t
906__clear_user(void __user *addr, __kernel_size_t size)
907{
908 __kernel_size_t res;
909
910 might_sleep();
911 __asm__ __volatile__(
912 "move\t$4, %1\n\t"
913 "move\t$5, $0\n\t"
914 "move\t$6, %2\n\t"
915 __MODULE_JAL(__bzero)
916 "move\t%0, $6"
917 : "=r" (res)
918 : "r" (addr), "r" (size)
919 : "$4", "$5", "$6", __UA_t0, __UA_t1, "$31");
920
921 return res;
922}
923
924#define clear_user(addr,n) \
925({ \
926 void __user * __cl_addr = (addr); \
927 unsigned long __cl_size = (n); \
928 if (__cl_size && access_ok(VERIFY_WRITE, \
929 ((unsigned long)(__cl_addr)), __cl_size)) \
930 __cl_size = __clear_user(__cl_addr, __cl_size); \
931 __cl_size; \
932})
933
934/*
935 * __strncpy_from_user: - Copy a NUL terminated string from userspace, with less checking.
936 * @dst: Destination address, in kernel space. This buffer must be at
937 * least @count bytes long.
938 * @src: Source address, in user space.
939 * @count: Maximum number of bytes to copy, including the trailing NUL.
940 *
941 * Copies a NUL-terminated string from userspace to kernel space.
942 * Caller must check the specified block with access_ok() before calling
943 * this function.
944 *
945 * On success, returns the length of the string (not including the trailing
946 * NUL).
947 *
948 * If access to userspace fails, returns -EFAULT (some data may have been
949 * copied).
950 *
951 * If @count is smaller than the length of the string, copies @count bytes
952 * and returns @count.
953 */
954static inline long
955__strncpy_from_user(char *__to, const char __user *__from, long __len)
956{
957 long res;
958
959 might_sleep();
960 __asm__ __volatile__(
961 "move\t$4, %1\n\t"
962 "move\t$5, %2\n\t"
963 "move\t$6, %3\n\t"
964 __MODULE_JAL(__strncpy_from_user_nocheck_asm)
965 "move\t%0, $2"
966 : "=r" (res)
967 : "r" (__to), "r" (__from), "r" (__len)
968 : "$2", "$3", "$4", "$5", "$6", __UA_t0, "$31", "memory");
969
970 return res;
971}
972
973/*
974 * strncpy_from_user: - Copy a NUL terminated string from userspace.
975 * @dst: Destination address, in kernel space. This buffer must be at
976 * least @count bytes long.
977 * @src: Source address, in user space.
978 * @count: Maximum number of bytes to copy, including the trailing NUL.
979 *
980 * Copies a NUL-terminated string from userspace to kernel space.
981 *
982 * On success, returns the length of the string (not including the trailing
983 * NUL).
984 *
985 * If access to userspace fails, returns -EFAULT (some data may have been
986 * copied).
987 *
988 * If @count is smaller than the length of the string, copies @count bytes
989 * and returns @count.
990 */
991static inline long
992strncpy_from_user(char *__to, const char __user *__from, long __len)
993{
994 long res;
995
996 might_sleep();
997 __asm__ __volatile__(
998 "move\t$4, %1\n\t"
999 "move\t$5, %2\n\t"
1000 "move\t$6, %3\n\t"
1001 __MODULE_JAL(__strncpy_from_user_asm)
1002 "move\t%0, $2"
1003 : "=r" (res)
1004 : "r" (__to), "r" (__from), "r" (__len)
1005 : "$2", "$3", "$4", "$5", "$6", __UA_t0, "$31", "memory");
1006
1007 return res;
1008}
1009
1010/* Returns: 0 if bad, string length+1 (memory size) of string if ok */
1011static inline long __strlen_user(const char __user *s)
1012{
1013 long res;
1014
1015 might_sleep();
1016 __asm__ __volatile__(
1017 "move\t$4, %1\n\t"
1018 __MODULE_JAL(__strlen_user_nocheck_asm)
1019 "move\t%0, $2"
1020 : "=r" (res)
1021 : "r" (s)
1022 : "$2", "$4", __UA_t0, "$31");
1023
1024 return res;
1025}
1026
1027/*
1028 * strlen_user: - Get the size of a string in user space.
1029 * @str: The string to measure.
1030 *
1031 * Context: User context only. This function may sleep.
1032 *
1033 * Get the size of a NUL-terminated string in user space.
1034 *
1035 * Returns the size of the string INCLUDING the terminating NUL.
1036 * On exception, returns 0.
1037 *
1038 * If there is a limit on the length of a valid string, you may wish to
1039 * consider using strnlen_user() instead.
1040 */
1041static inline long strlen_user(const char __user *s)
1042{
1043 long res;
1044
1045 might_sleep();
1046 __asm__ __volatile__(
1047 "move\t$4, %1\n\t"
1048 __MODULE_JAL(__strlen_user_asm)
1049 "move\t%0, $2"
1050 : "=r" (res)
1051 : "r" (s)
1052 : "$2", "$4", __UA_t0, "$31");
1053
1054 return res;
1055}
1056
1057/* Returns: 0 if bad, string length+1 (memory size) of string if ok */
1058static inline long __strnlen_user(const char __user *s, long n)
1059{
1060 long res;
1061
1062 might_sleep();
1063 __asm__ __volatile__(
1064 "move\t$4, %1\n\t"
1065 "move\t$5, %2\n\t"
1066 __MODULE_JAL(__strnlen_user_nocheck_asm)
1067 "move\t%0, $2"
1068 : "=r" (res)
1069 : "r" (s), "r" (n)
1070 : "$2", "$4", "$5", __UA_t0, "$31");
1071
1072 return res;
1073}
1074
1075/*
1076 * strlen_user: - Get the size of a string in user space.
1077 * @str: The string to measure.
1078 *
1079 * Context: User context only. This function may sleep.
1080 *
1081 * Get the size of a NUL-terminated string in user space.
1082 *
1083 * Returns the size of the string INCLUDING the terminating NUL.
1084 * On exception, returns 0.
1085 *
1086 * If there is a limit on the length of a valid string, you may wish to
1087 * consider using strnlen_user() instead.
1088 */
1089static inline long strnlen_user(const char __user *s, long n)
1090{
1091 long res;
1092
1093 might_sleep();
1094 __asm__ __volatile__(
1095 "move\t$4, %1\n\t"
1096 "move\t$5, %2\n\t"
1097 __MODULE_JAL(__strnlen_user_asm)
1098 "move\t%0, $2"
1099 : "=r" (res)
1100 : "r" (s), "r" (n)
1101 : "$2", "$4", "$5", __UA_t0, "$31");
1102
1103 return res;
1104}
1105
1106struct exception_table_entry
1107{
1108 unsigned long insn;
1109 unsigned long nextinsn;
1110};
1111
1112extern int fixup_exception(struct pt_regs *regs);
1113
1114#endif /* _ASM_UACCESS_H */
diff --git a/arch/mips/include/asm/ucontext.h b/arch/mips/include/asm/ucontext.h
new file mode 100644
index 000000000000..8a4b20e88b81
--- /dev/null
+++ b/arch/mips/include/asm/ucontext.h
@@ -0,0 +1,21 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Low level exception handling
7 *
8 * Copyright (C) 1998, 1999 by Ralf Baechle
9 */
10#ifndef _ASM_UCONTEXT_H
11#define _ASM_UCONTEXT_H
12
13struct ucontext {
14 unsigned long uc_flags;
15 struct ucontext *uc_link;
16 stack_t uc_stack;
17 struct sigcontext uc_mcontext;
18 sigset_t uc_sigmask; /* mask last for extensibility */
19};
20
21#endif /* _ASM_UCONTEXT_H */
diff --git a/arch/mips/include/asm/unaligned.h b/arch/mips/include/asm/unaligned.h
new file mode 100644
index 000000000000..792404948571
--- /dev/null
+++ b/arch/mips/include/asm/unaligned.h
@@ -0,0 +1,28 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef _ASM_MIPS_UNALIGNED_H
9#define _ASM_MIPS_UNALIGNED_H
10
11#include <linux/compiler.h>
12#if defined(__MIPSEB__)
13# include <linux/unaligned/be_struct.h>
14# include <linux/unaligned/le_byteshift.h>
15# include <linux/unaligned/generic.h>
16# define get_unaligned __get_unaligned_be
17# define put_unaligned __put_unaligned_be
18#elif defined(__MIPSEL__)
19# include <linux/unaligned/le_struct.h>
20# include <linux/unaligned/be_byteshift.h>
21# include <linux/unaligned/generic.h>
22# define get_unaligned __get_unaligned_le
23# define put_unaligned __put_unaligned_le
24#else
25# error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???"
26#endif
27
28#endif /* _ASM_MIPS_UNALIGNED_H */
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
new file mode 100644
index 000000000000..a73e1531e151
--- /dev/null
+++ b/arch/mips/include/asm/unistd.h
@@ -0,0 +1,1037 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 96, 97, 98, 99, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 *
9 * Changed system calls macros _syscall5 - _syscall7 to push args 5 to 7 onto
10 * the stack. Robin Farine for ACN S.A, Copyright (C) 1996 by ACN S.A
11 */
12#ifndef _ASM_UNISTD_H
13#define _ASM_UNISTD_H
14
15#include <asm/sgidefs.h>
16
17#if _MIPS_SIM == _MIPS_SIM_ABI32
18
19/*
20 * Linux o32 style syscalls are in the range from 4000 to 4999.
21 */
22#define __NR_Linux 4000
23#define __NR_syscall (__NR_Linux + 0)
24#define __NR_exit (__NR_Linux + 1)
25#define __NR_fork (__NR_Linux + 2)
26#define __NR_read (__NR_Linux + 3)
27#define __NR_write (__NR_Linux + 4)
28#define __NR_open (__NR_Linux + 5)
29#define __NR_close (__NR_Linux + 6)
30#define __NR_waitpid (__NR_Linux + 7)
31#define __NR_creat (__NR_Linux + 8)
32#define __NR_link (__NR_Linux + 9)
33#define __NR_unlink (__NR_Linux + 10)
34#define __NR_execve (__NR_Linux + 11)
35#define __NR_chdir (__NR_Linux + 12)
36#define __NR_time (__NR_Linux + 13)
37#define __NR_mknod (__NR_Linux + 14)
38#define __NR_chmod (__NR_Linux + 15)
39#define __NR_lchown (__NR_Linux + 16)
40#define __NR_break (__NR_Linux + 17)
41#define __NR_unused18 (__NR_Linux + 18)
42#define __NR_lseek (__NR_Linux + 19)
43#define __NR_getpid (__NR_Linux + 20)
44#define __NR_mount (__NR_Linux + 21)
45#define __NR_umount (__NR_Linux + 22)
46#define __NR_setuid (__NR_Linux + 23)
47#define __NR_getuid (__NR_Linux + 24)
48#define __NR_stime (__NR_Linux + 25)
49#define __NR_ptrace (__NR_Linux + 26)
50#define __NR_alarm (__NR_Linux + 27)
51#define __NR_unused28 (__NR_Linux + 28)
52#define __NR_pause (__NR_Linux + 29)
53#define __NR_utime (__NR_Linux + 30)
54#define __NR_stty (__NR_Linux + 31)
55#define __NR_gtty (__NR_Linux + 32)
56#define __NR_access (__NR_Linux + 33)
57#define __NR_nice (__NR_Linux + 34)
58#define __NR_ftime (__NR_Linux + 35)
59#define __NR_sync (__NR_Linux + 36)
60#define __NR_kill (__NR_Linux + 37)
61#define __NR_rename (__NR_Linux + 38)
62#define __NR_mkdir (__NR_Linux + 39)
63#define __NR_rmdir (__NR_Linux + 40)
64#define __NR_dup (__NR_Linux + 41)
65#define __NR_pipe (__NR_Linux + 42)
66#define __NR_times (__NR_Linux + 43)
67#define __NR_prof (__NR_Linux + 44)
68#define __NR_brk (__NR_Linux + 45)
69#define __NR_setgid (__NR_Linux + 46)
70#define __NR_getgid (__NR_Linux + 47)
71#define __NR_signal (__NR_Linux + 48)
72#define __NR_geteuid (__NR_Linux + 49)
73#define __NR_getegid (__NR_Linux + 50)
74#define __NR_acct (__NR_Linux + 51)
75#define __NR_umount2 (__NR_Linux + 52)
76#define __NR_lock (__NR_Linux + 53)
77#define __NR_ioctl (__NR_Linux + 54)
78#define __NR_fcntl (__NR_Linux + 55)
79#define __NR_mpx (__NR_Linux + 56)
80#define __NR_setpgid (__NR_Linux + 57)
81#define __NR_ulimit (__NR_Linux + 58)
82#define __NR_unused59 (__NR_Linux + 59)
83#define __NR_umask (__NR_Linux + 60)
84#define __NR_chroot (__NR_Linux + 61)
85#define __NR_ustat (__NR_Linux + 62)
86#define __NR_dup2 (__NR_Linux + 63)
87#define __NR_getppid (__NR_Linux + 64)
88#define __NR_getpgrp (__NR_Linux + 65)
89#define __NR_setsid (__NR_Linux + 66)
90#define __NR_sigaction (__NR_Linux + 67)
91#define __NR_sgetmask (__NR_Linux + 68)
92#define __NR_ssetmask (__NR_Linux + 69)
93#define __NR_setreuid (__NR_Linux + 70)
94#define __NR_setregid (__NR_Linux + 71)
95#define __NR_sigsuspend (__NR_Linux + 72)
96#define __NR_sigpending (__NR_Linux + 73)
97#define __NR_sethostname (__NR_Linux + 74)
98#define __NR_setrlimit (__NR_Linux + 75)
99#define __NR_getrlimit (__NR_Linux + 76)
100#define __NR_getrusage (__NR_Linux + 77)
101#define __NR_gettimeofday (__NR_Linux + 78)
102#define __NR_settimeofday (__NR_Linux + 79)
103#define __NR_getgroups (__NR_Linux + 80)
104#define __NR_setgroups (__NR_Linux + 81)
105#define __NR_reserved82 (__NR_Linux + 82)
106#define __NR_symlink (__NR_Linux + 83)
107#define __NR_unused84 (__NR_Linux + 84)
108#define __NR_readlink (__NR_Linux + 85)
109#define __NR_uselib (__NR_Linux + 86)
110#define __NR_swapon (__NR_Linux + 87)
111#define __NR_reboot (__NR_Linux + 88)
112#define __NR_readdir (__NR_Linux + 89)
113#define __NR_mmap (__NR_Linux + 90)
114#define __NR_munmap (__NR_Linux + 91)
115#define __NR_truncate (__NR_Linux + 92)
116#define __NR_ftruncate (__NR_Linux + 93)
117#define __NR_fchmod (__NR_Linux + 94)
118#define __NR_fchown (__NR_Linux + 95)
119#define __NR_getpriority (__NR_Linux + 96)
120#define __NR_setpriority (__NR_Linux + 97)
121#define __NR_profil (__NR_Linux + 98)
122#define __NR_statfs (__NR_Linux + 99)
123#define __NR_fstatfs (__NR_Linux + 100)
124#define __NR_ioperm (__NR_Linux + 101)
125#define __NR_socketcall (__NR_Linux + 102)
126#define __NR_syslog (__NR_Linux + 103)
127#define __NR_setitimer (__NR_Linux + 104)
128#define __NR_getitimer (__NR_Linux + 105)
129#define __NR_stat (__NR_Linux + 106)
130#define __NR_lstat (__NR_Linux + 107)
131#define __NR_fstat (__NR_Linux + 108)
132#define __NR_unused109 (__NR_Linux + 109)
133#define __NR_iopl (__NR_Linux + 110)
134#define __NR_vhangup (__NR_Linux + 111)
135#define __NR_idle (__NR_Linux + 112)
136#define __NR_vm86 (__NR_Linux + 113)
137#define __NR_wait4 (__NR_Linux + 114)
138#define __NR_swapoff (__NR_Linux + 115)
139#define __NR_sysinfo (__NR_Linux + 116)
140#define __NR_ipc (__NR_Linux + 117)
141#define __NR_fsync (__NR_Linux + 118)
142#define __NR_sigreturn (__NR_Linux + 119)
143#define __NR_clone (__NR_Linux + 120)
144#define __NR_setdomainname (__NR_Linux + 121)
145#define __NR_uname (__NR_Linux + 122)
146#define __NR_modify_ldt (__NR_Linux + 123)
147#define __NR_adjtimex (__NR_Linux + 124)
148#define __NR_mprotect (__NR_Linux + 125)
149#define __NR_sigprocmask (__NR_Linux + 126)
150#define __NR_create_module (__NR_Linux + 127)
151#define __NR_init_module (__NR_Linux + 128)
152#define __NR_delete_module (__NR_Linux + 129)
153#define __NR_get_kernel_syms (__NR_Linux + 130)
154#define __NR_quotactl (__NR_Linux + 131)
155#define __NR_getpgid (__NR_Linux + 132)
156#define __NR_fchdir (__NR_Linux + 133)
157#define __NR_bdflush (__NR_Linux + 134)
158#define __NR_sysfs (__NR_Linux + 135)
159#define __NR_personality (__NR_Linux + 136)
160#define __NR_afs_syscall (__NR_Linux + 137) /* Syscall for Andrew File System */
161#define __NR_setfsuid (__NR_Linux + 138)
162#define __NR_setfsgid (__NR_Linux + 139)
163#define __NR__llseek (__NR_Linux + 140)
164#define __NR_getdents (__NR_Linux + 141)
165#define __NR__newselect (__NR_Linux + 142)
166#define __NR_flock (__NR_Linux + 143)
167#define __NR_msync (__NR_Linux + 144)
168#define __NR_readv (__NR_Linux + 145)
169#define __NR_writev (__NR_Linux + 146)
170#define __NR_cacheflush (__NR_Linux + 147)
171#define __NR_cachectl (__NR_Linux + 148)
172#define __NR_sysmips (__NR_Linux + 149)
173#define __NR_unused150 (__NR_Linux + 150)
174#define __NR_getsid (__NR_Linux + 151)
175#define __NR_fdatasync (__NR_Linux + 152)
176#define __NR__sysctl (__NR_Linux + 153)
177#define __NR_mlock (__NR_Linux + 154)
178#define __NR_munlock (__NR_Linux + 155)
179#define __NR_mlockall (__NR_Linux + 156)
180#define __NR_munlockall (__NR_Linux + 157)
181#define __NR_sched_setparam (__NR_Linux + 158)
182#define __NR_sched_getparam (__NR_Linux + 159)
183#define __NR_sched_setscheduler (__NR_Linux + 160)
184#define __NR_sched_getscheduler (__NR_Linux + 161)
185#define __NR_sched_yield (__NR_Linux + 162)
186#define __NR_sched_get_priority_max (__NR_Linux + 163)
187#define __NR_sched_get_priority_min (__NR_Linux + 164)
188#define __NR_sched_rr_get_interval (__NR_Linux + 165)
189#define __NR_nanosleep (__NR_Linux + 166)
190#define __NR_mremap (__NR_Linux + 167)
191#define __NR_accept (__NR_Linux + 168)
192#define __NR_bind (__NR_Linux + 169)
193#define __NR_connect (__NR_Linux + 170)
194#define __NR_getpeername (__NR_Linux + 171)
195#define __NR_getsockname (__NR_Linux + 172)
196#define __NR_getsockopt (__NR_Linux + 173)
197#define __NR_listen (__NR_Linux + 174)
198#define __NR_recv (__NR_Linux + 175)
199#define __NR_recvfrom (__NR_Linux + 176)
200#define __NR_recvmsg (__NR_Linux + 177)
201#define __NR_send (__NR_Linux + 178)
202#define __NR_sendmsg (__NR_Linux + 179)
203#define __NR_sendto (__NR_Linux + 180)
204#define __NR_setsockopt (__NR_Linux + 181)
205#define __NR_shutdown (__NR_Linux + 182)
206#define __NR_socket (__NR_Linux + 183)
207#define __NR_socketpair (__NR_Linux + 184)
208#define __NR_setresuid (__NR_Linux + 185)
209#define __NR_getresuid (__NR_Linux + 186)
210#define __NR_query_module (__NR_Linux + 187)
211#define __NR_poll (__NR_Linux + 188)
212#define __NR_nfsservctl (__NR_Linux + 189)
213#define __NR_setresgid (__NR_Linux + 190)
214#define __NR_getresgid (__NR_Linux + 191)
215#define __NR_prctl (__NR_Linux + 192)
216#define __NR_rt_sigreturn (__NR_Linux + 193)
217#define __NR_rt_sigaction (__NR_Linux + 194)
218#define __NR_rt_sigprocmask (__NR_Linux + 195)
219#define __NR_rt_sigpending (__NR_Linux + 196)
220#define __NR_rt_sigtimedwait (__NR_Linux + 197)
221#define __NR_rt_sigqueueinfo (__NR_Linux + 198)
222#define __NR_rt_sigsuspend (__NR_Linux + 199)
223#define __NR_pread64 (__NR_Linux + 200)
224#define __NR_pwrite64 (__NR_Linux + 201)
225#define __NR_chown (__NR_Linux + 202)
226#define __NR_getcwd (__NR_Linux + 203)
227#define __NR_capget (__NR_Linux + 204)
228#define __NR_capset (__NR_Linux + 205)
229#define __NR_sigaltstack (__NR_Linux + 206)
230#define __NR_sendfile (__NR_Linux + 207)
231#define __NR_getpmsg (__NR_Linux + 208)
232#define __NR_putpmsg (__NR_Linux + 209)
233#define __NR_mmap2 (__NR_Linux + 210)
234#define __NR_truncate64 (__NR_Linux + 211)
235#define __NR_ftruncate64 (__NR_Linux + 212)
236#define __NR_stat64 (__NR_Linux + 213)
237#define __NR_lstat64 (__NR_Linux + 214)
238#define __NR_fstat64 (__NR_Linux + 215)
239#define __NR_pivot_root (__NR_Linux + 216)
240#define __NR_mincore (__NR_Linux + 217)
241#define __NR_madvise (__NR_Linux + 218)
242#define __NR_getdents64 (__NR_Linux + 219)
243#define __NR_fcntl64 (__NR_Linux + 220)
244#define __NR_reserved221 (__NR_Linux + 221)
245#define __NR_gettid (__NR_Linux + 222)
246#define __NR_readahead (__NR_Linux + 223)
247#define __NR_setxattr (__NR_Linux + 224)
248#define __NR_lsetxattr (__NR_Linux + 225)
249#define __NR_fsetxattr (__NR_Linux + 226)
250#define __NR_getxattr (__NR_Linux + 227)
251#define __NR_lgetxattr (__NR_Linux + 228)
252#define __NR_fgetxattr (__NR_Linux + 229)
253#define __NR_listxattr (__NR_Linux + 230)
254#define __NR_llistxattr (__NR_Linux + 231)
255#define __NR_flistxattr (__NR_Linux + 232)
256#define __NR_removexattr (__NR_Linux + 233)
257#define __NR_lremovexattr (__NR_Linux + 234)
258#define __NR_fremovexattr (__NR_Linux + 235)
259#define __NR_tkill (__NR_Linux + 236)
260#define __NR_sendfile64 (__NR_Linux + 237)
261#define __NR_futex (__NR_Linux + 238)
262#define __NR_sched_setaffinity (__NR_Linux + 239)
263#define __NR_sched_getaffinity (__NR_Linux + 240)
264#define __NR_io_setup (__NR_Linux + 241)
265#define __NR_io_destroy (__NR_Linux + 242)
266#define __NR_io_getevents (__NR_Linux + 243)
267#define __NR_io_submit (__NR_Linux + 244)
268#define __NR_io_cancel (__NR_Linux + 245)
269#define __NR_exit_group (__NR_Linux + 246)
270#define __NR_lookup_dcookie (__NR_Linux + 247)
271#define __NR_epoll_create (__NR_Linux + 248)
272#define __NR_epoll_ctl (__NR_Linux + 249)
273#define __NR_epoll_wait (__NR_Linux + 250)
274#define __NR_remap_file_pages (__NR_Linux + 251)
275#define __NR_set_tid_address (__NR_Linux + 252)
276#define __NR_restart_syscall (__NR_Linux + 253)
277#define __NR_fadvise64 (__NR_Linux + 254)
278#define __NR_statfs64 (__NR_Linux + 255)
279#define __NR_fstatfs64 (__NR_Linux + 256)
280#define __NR_timer_create (__NR_Linux + 257)
281#define __NR_timer_settime (__NR_Linux + 258)
282#define __NR_timer_gettime (__NR_Linux + 259)
283#define __NR_timer_getoverrun (__NR_Linux + 260)
284#define __NR_timer_delete (__NR_Linux + 261)
285#define __NR_clock_settime (__NR_Linux + 262)
286#define __NR_clock_gettime (__NR_Linux + 263)
287#define __NR_clock_getres (__NR_Linux + 264)
288#define __NR_clock_nanosleep (__NR_Linux + 265)
289#define __NR_tgkill (__NR_Linux + 266)
290#define __NR_utimes (__NR_Linux + 267)
291#define __NR_mbind (__NR_Linux + 268)
292#define __NR_get_mempolicy (__NR_Linux + 269)
293#define __NR_set_mempolicy (__NR_Linux + 270)
294#define __NR_mq_open (__NR_Linux + 271)
295#define __NR_mq_unlink (__NR_Linux + 272)
296#define __NR_mq_timedsend (__NR_Linux + 273)
297#define __NR_mq_timedreceive (__NR_Linux + 274)
298#define __NR_mq_notify (__NR_Linux + 275)
299#define __NR_mq_getsetattr (__NR_Linux + 276)
300#define __NR_vserver (__NR_Linux + 277)
301#define __NR_waitid (__NR_Linux + 278)
302/* #define __NR_sys_setaltroot (__NR_Linux + 279) */
303#define __NR_add_key (__NR_Linux + 280)
304#define __NR_request_key (__NR_Linux + 281)
305#define __NR_keyctl (__NR_Linux + 282)
306#define __NR_set_thread_area (__NR_Linux + 283)
307#define __NR_inotify_init (__NR_Linux + 284)
308#define __NR_inotify_add_watch (__NR_Linux + 285)
309#define __NR_inotify_rm_watch (__NR_Linux + 286)
310#define __NR_migrate_pages (__NR_Linux + 287)
311#define __NR_openat (__NR_Linux + 288)
312#define __NR_mkdirat (__NR_Linux + 289)
313#define __NR_mknodat (__NR_Linux + 290)
314#define __NR_fchownat (__NR_Linux + 291)
315#define __NR_futimesat (__NR_Linux + 292)
316#define __NR_fstatat64 (__NR_Linux + 293)
317#define __NR_unlinkat (__NR_Linux + 294)
318#define __NR_renameat (__NR_Linux + 295)
319#define __NR_linkat (__NR_Linux + 296)
320#define __NR_symlinkat (__NR_Linux + 297)
321#define __NR_readlinkat (__NR_Linux + 298)
322#define __NR_fchmodat (__NR_Linux + 299)
323#define __NR_faccessat (__NR_Linux + 300)
324#define __NR_pselect6 (__NR_Linux + 301)
325#define __NR_ppoll (__NR_Linux + 302)
326#define __NR_unshare (__NR_Linux + 303)
327#define __NR_splice (__NR_Linux + 304)
328#define __NR_sync_file_range (__NR_Linux + 305)
329#define __NR_tee (__NR_Linux + 306)
330#define __NR_vmsplice (__NR_Linux + 307)
331#define __NR_move_pages (__NR_Linux + 308)
332#define __NR_set_robust_list (__NR_Linux + 309)
333#define __NR_get_robust_list (__NR_Linux + 310)
334#define __NR_kexec_load (__NR_Linux + 311)
335#define __NR_getcpu (__NR_Linux + 312)
336#define __NR_epoll_pwait (__NR_Linux + 313)
337#define __NR_ioprio_set (__NR_Linux + 314)
338#define __NR_ioprio_get (__NR_Linux + 315)
339#define __NR_utimensat (__NR_Linux + 316)
340#define __NR_signalfd (__NR_Linux + 317)
341#define __NR_timerfd (__NR_Linux + 318)
342#define __NR_eventfd (__NR_Linux + 319)
343#define __NR_fallocate (__NR_Linux + 320)
344#define __NR_timerfd_create (__NR_Linux + 321)
345#define __NR_timerfd_gettime (__NR_Linux + 322)
346#define __NR_timerfd_settime (__NR_Linux + 323)
347#define __NR_signalfd4 (__NR_Linux + 324)
348#define __NR_eventfd2 (__NR_Linux + 325)
349#define __NR_epoll_create1 (__NR_Linux + 326)
350#define __NR_dup3 (__NR_Linux + 327)
351#define __NR_pipe2 (__NR_Linux + 328)
352#define __NR_inotify_init1 (__NR_Linux + 329)
353
354/*
355 * Offset of the last Linux o32 flavoured syscall
356 */
357#define __NR_Linux_syscalls 329
358
359#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
360
361#define __NR_O32_Linux 4000
362#define __NR_O32_Linux_syscalls 329
363
364#if _MIPS_SIM == _MIPS_SIM_ABI64
365
366/*
367 * Linux 64-bit syscalls are in the range from 5000 to 5999.
368 */
369#define __NR_Linux 5000
370#define __NR_read (__NR_Linux + 0)
371#define __NR_write (__NR_Linux + 1)
372#define __NR_open (__NR_Linux + 2)
373#define __NR_close (__NR_Linux + 3)
374#define __NR_stat (__NR_Linux + 4)
375#define __NR_fstat (__NR_Linux + 5)
376#define __NR_lstat (__NR_Linux + 6)
377#define __NR_poll (__NR_Linux + 7)
378#define __NR_lseek (__NR_Linux + 8)
379#define __NR_mmap (__NR_Linux + 9)
380#define __NR_mprotect (__NR_Linux + 10)
381#define __NR_munmap (__NR_Linux + 11)
382#define __NR_brk (__NR_Linux + 12)
383#define __NR_rt_sigaction (__NR_Linux + 13)
384#define __NR_rt_sigprocmask (__NR_Linux + 14)
385#define __NR_ioctl (__NR_Linux + 15)
386#define __NR_pread64 (__NR_Linux + 16)
387#define __NR_pwrite64 (__NR_Linux + 17)
388#define __NR_readv (__NR_Linux + 18)
389#define __NR_writev (__NR_Linux + 19)
390#define __NR_access (__NR_Linux + 20)
391#define __NR_pipe (__NR_Linux + 21)
392#define __NR__newselect (__NR_Linux + 22)
393#define __NR_sched_yield (__NR_Linux + 23)
394#define __NR_mremap (__NR_Linux + 24)
395#define __NR_msync (__NR_Linux + 25)
396#define __NR_mincore (__NR_Linux + 26)
397#define __NR_madvise (__NR_Linux + 27)
398#define __NR_shmget (__NR_Linux + 28)
399#define __NR_shmat (__NR_Linux + 29)
400#define __NR_shmctl (__NR_Linux + 30)
401#define __NR_dup (__NR_Linux + 31)
402#define __NR_dup2 (__NR_Linux + 32)
403#define __NR_pause (__NR_Linux + 33)
404#define __NR_nanosleep (__NR_Linux + 34)
405#define __NR_getitimer (__NR_Linux + 35)
406#define __NR_setitimer (__NR_Linux + 36)
407#define __NR_alarm (__NR_Linux + 37)
408#define __NR_getpid (__NR_Linux + 38)
409#define __NR_sendfile (__NR_Linux + 39)
410#define __NR_socket (__NR_Linux + 40)
411#define __NR_connect (__NR_Linux + 41)
412#define __NR_accept (__NR_Linux + 42)
413#define __NR_sendto (__NR_Linux + 43)
414#define __NR_recvfrom (__NR_Linux + 44)
415#define __NR_sendmsg (__NR_Linux + 45)
416#define __NR_recvmsg (__NR_Linux + 46)
417#define __NR_shutdown (__NR_Linux + 47)
418#define __NR_bind (__NR_Linux + 48)
419#define __NR_listen (__NR_Linux + 49)
420#define __NR_getsockname (__NR_Linux + 50)
421#define __NR_getpeername (__NR_Linux + 51)
422#define __NR_socketpair (__NR_Linux + 52)
423#define __NR_setsockopt (__NR_Linux + 53)
424#define __NR_getsockopt (__NR_Linux + 54)
425#define __NR_clone (__NR_Linux + 55)
426#define __NR_fork (__NR_Linux + 56)
427#define __NR_execve (__NR_Linux + 57)
428#define __NR_exit (__NR_Linux + 58)
429#define __NR_wait4 (__NR_Linux + 59)
430#define __NR_kill (__NR_Linux + 60)
431#define __NR_uname (__NR_Linux + 61)
432#define __NR_semget (__NR_Linux + 62)
433#define __NR_semop (__NR_Linux + 63)
434#define __NR_semctl (__NR_Linux + 64)
435#define __NR_shmdt (__NR_Linux + 65)
436#define __NR_msgget (__NR_Linux + 66)
437#define __NR_msgsnd (__NR_Linux + 67)
438#define __NR_msgrcv (__NR_Linux + 68)
439#define __NR_msgctl (__NR_Linux + 69)
440#define __NR_fcntl (__NR_Linux + 70)
441#define __NR_flock (__NR_Linux + 71)
442#define __NR_fsync (__NR_Linux + 72)
443#define __NR_fdatasync (__NR_Linux + 73)
444#define __NR_truncate (__NR_Linux + 74)
445#define __NR_ftruncate (__NR_Linux + 75)
446#define __NR_getdents (__NR_Linux + 76)
447#define __NR_getcwd (__NR_Linux + 77)
448#define __NR_chdir (__NR_Linux + 78)
449#define __NR_fchdir (__NR_Linux + 79)
450#define __NR_rename (__NR_Linux + 80)
451#define __NR_mkdir (__NR_Linux + 81)
452#define __NR_rmdir (__NR_Linux + 82)
453#define __NR_creat (__NR_Linux + 83)
454#define __NR_link (__NR_Linux + 84)
455#define __NR_unlink (__NR_Linux + 85)
456#define __NR_symlink (__NR_Linux + 86)
457#define __NR_readlink (__NR_Linux + 87)
458#define __NR_chmod (__NR_Linux + 88)
459#define __NR_fchmod (__NR_Linux + 89)
460#define __NR_chown (__NR_Linux + 90)
461#define __NR_fchown (__NR_Linux + 91)
462#define __NR_lchown (__NR_Linux + 92)
463#define __NR_umask (__NR_Linux + 93)
464#define __NR_gettimeofday (__NR_Linux + 94)
465#define __NR_getrlimit (__NR_Linux + 95)
466#define __NR_getrusage (__NR_Linux + 96)
467#define __NR_sysinfo (__NR_Linux + 97)
468#define __NR_times (__NR_Linux + 98)
469#define __NR_ptrace (__NR_Linux + 99)
470#define __NR_getuid (__NR_Linux + 100)
471#define __NR_syslog (__NR_Linux + 101)
472#define __NR_getgid (__NR_Linux + 102)
473#define __NR_setuid (__NR_Linux + 103)
474#define __NR_setgid (__NR_Linux + 104)
475#define __NR_geteuid (__NR_Linux + 105)
476#define __NR_getegid (__NR_Linux + 106)
477#define __NR_setpgid (__NR_Linux + 107)
478#define __NR_getppid (__NR_Linux + 108)
479#define __NR_getpgrp (__NR_Linux + 109)
480#define __NR_setsid (__NR_Linux + 110)
481#define __NR_setreuid (__NR_Linux + 111)
482#define __NR_setregid (__NR_Linux + 112)
483#define __NR_getgroups (__NR_Linux + 113)
484#define __NR_setgroups (__NR_Linux + 114)
485#define __NR_setresuid (__NR_Linux + 115)
486#define __NR_getresuid (__NR_Linux + 116)
487#define __NR_setresgid (__NR_Linux + 117)
488#define __NR_getresgid (__NR_Linux + 118)
489#define __NR_getpgid (__NR_Linux + 119)
490#define __NR_setfsuid (__NR_Linux + 120)
491#define __NR_setfsgid (__NR_Linux + 121)
492#define __NR_getsid (__NR_Linux + 122)
493#define __NR_capget (__NR_Linux + 123)
494#define __NR_capset (__NR_Linux + 124)
495#define __NR_rt_sigpending (__NR_Linux + 125)
496#define __NR_rt_sigtimedwait (__NR_Linux + 126)
497#define __NR_rt_sigqueueinfo (__NR_Linux + 127)
498#define __NR_rt_sigsuspend (__NR_Linux + 128)
499#define __NR_sigaltstack (__NR_Linux + 129)
500#define __NR_utime (__NR_Linux + 130)
501#define __NR_mknod (__NR_Linux + 131)
502#define __NR_personality (__NR_Linux + 132)
503#define __NR_ustat (__NR_Linux + 133)
504#define __NR_statfs (__NR_Linux + 134)
505#define __NR_fstatfs (__NR_Linux + 135)
506#define __NR_sysfs (__NR_Linux + 136)
507#define __NR_getpriority (__NR_Linux + 137)
508#define __NR_setpriority (__NR_Linux + 138)
509#define __NR_sched_setparam (__NR_Linux + 139)
510#define __NR_sched_getparam (__NR_Linux + 140)
511#define __NR_sched_setscheduler (__NR_Linux + 141)
512#define __NR_sched_getscheduler (__NR_Linux + 142)
513#define __NR_sched_get_priority_max (__NR_Linux + 143)
514#define __NR_sched_get_priority_min (__NR_Linux + 144)
515#define __NR_sched_rr_get_interval (__NR_Linux + 145)
516#define __NR_mlock (__NR_Linux + 146)
517#define __NR_munlock (__NR_Linux + 147)
518#define __NR_mlockall (__NR_Linux + 148)
519#define __NR_munlockall (__NR_Linux + 149)
520#define __NR_vhangup (__NR_Linux + 150)
521#define __NR_pivot_root (__NR_Linux + 151)
522#define __NR__sysctl (__NR_Linux + 152)
523#define __NR_prctl (__NR_Linux + 153)
524#define __NR_adjtimex (__NR_Linux + 154)
525#define __NR_setrlimit (__NR_Linux + 155)
526#define __NR_chroot (__NR_Linux + 156)
527#define __NR_sync (__NR_Linux + 157)
528#define __NR_acct (__NR_Linux + 158)
529#define __NR_settimeofday (__NR_Linux + 159)
530#define __NR_mount (__NR_Linux + 160)
531#define __NR_umount2 (__NR_Linux + 161)
532#define __NR_swapon (__NR_Linux + 162)
533#define __NR_swapoff (__NR_Linux + 163)
534#define __NR_reboot (__NR_Linux + 164)
535#define __NR_sethostname (__NR_Linux + 165)
536#define __NR_setdomainname (__NR_Linux + 166)
537#define __NR_create_module (__NR_Linux + 167)
538#define __NR_init_module (__NR_Linux + 168)
539#define __NR_delete_module (__NR_Linux + 169)
540#define __NR_get_kernel_syms (__NR_Linux + 170)
541#define __NR_query_module (__NR_Linux + 171)
542#define __NR_quotactl (__NR_Linux + 172)
543#define __NR_nfsservctl (__NR_Linux + 173)
544#define __NR_getpmsg (__NR_Linux + 174)
545#define __NR_putpmsg (__NR_Linux + 175)
546#define __NR_afs_syscall (__NR_Linux + 176)
547#define __NR_reserved177 (__NR_Linux + 177)
548#define __NR_gettid (__NR_Linux + 178)
549#define __NR_readahead (__NR_Linux + 179)
550#define __NR_setxattr (__NR_Linux + 180)
551#define __NR_lsetxattr (__NR_Linux + 181)
552#define __NR_fsetxattr (__NR_Linux + 182)
553#define __NR_getxattr (__NR_Linux + 183)
554#define __NR_lgetxattr (__NR_Linux + 184)
555#define __NR_fgetxattr (__NR_Linux + 185)
556#define __NR_listxattr (__NR_Linux + 186)
557#define __NR_llistxattr (__NR_Linux + 187)
558#define __NR_flistxattr (__NR_Linux + 188)
559#define __NR_removexattr (__NR_Linux + 189)
560#define __NR_lremovexattr (__NR_Linux + 190)
561#define __NR_fremovexattr (__NR_Linux + 191)
562#define __NR_tkill (__NR_Linux + 192)
563#define __NR_reserved193 (__NR_Linux + 193)
564#define __NR_futex (__NR_Linux + 194)
565#define __NR_sched_setaffinity (__NR_Linux + 195)
566#define __NR_sched_getaffinity (__NR_Linux + 196)
567#define __NR_cacheflush (__NR_Linux + 197)
568#define __NR_cachectl (__NR_Linux + 198)
569#define __NR_sysmips (__NR_Linux + 199)
570#define __NR_io_setup (__NR_Linux + 200)
571#define __NR_io_destroy (__NR_Linux + 201)
572#define __NR_io_getevents (__NR_Linux + 202)
573#define __NR_io_submit (__NR_Linux + 203)
574#define __NR_io_cancel (__NR_Linux + 204)
575#define __NR_exit_group (__NR_Linux + 205)
576#define __NR_lookup_dcookie (__NR_Linux + 206)
577#define __NR_epoll_create (__NR_Linux + 207)
578#define __NR_epoll_ctl (__NR_Linux + 208)
579#define __NR_epoll_wait (__NR_Linux + 209)
580#define __NR_remap_file_pages (__NR_Linux + 210)
581#define __NR_rt_sigreturn (__NR_Linux + 211)
582#define __NR_set_tid_address (__NR_Linux + 212)
583#define __NR_restart_syscall (__NR_Linux + 213)
584#define __NR_semtimedop (__NR_Linux + 214)
585#define __NR_fadvise64 (__NR_Linux + 215)
586#define __NR_timer_create (__NR_Linux + 216)
587#define __NR_timer_settime (__NR_Linux + 217)
588#define __NR_timer_gettime (__NR_Linux + 218)
589#define __NR_timer_getoverrun (__NR_Linux + 219)
590#define __NR_timer_delete (__NR_Linux + 220)
591#define __NR_clock_settime (__NR_Linux + 221)
592#define __NR_clock_gettime (__NR_Linux + 222)
593#define __NR_clock_getres (__NR_Linux + 223)
594#define __NR_clock_nanosleep (__NR_Linux + 224)
595#define __NR_tgkill (__NR_Linux + 225)
596#define __NR_utimes (__NR_Linux + 226)
597#define __NR_mbind (__NR_Linux + 227)
598#define __NR_get_mempolicy (__NR_Linux + 228)
599#define __NR_set_mempolicy (__NR_Linux + 229)
600#define __NR_mq_open (__NR_Linux + 230)
601#define __NR_mq_unlink (__NR_Linux + 231)
602#define __NR_mq_timedsend (__NR_Linux + 232)
603#define __NR_mq_timedreceive (__NR_Linux + 233)
604#define __NR_mq_notify (__NR_Linux + 234)
605#define __NR_mq_getsetattr (__NR_Linux + 235)
606#define __NR_vserver (__NR_Linux + 236)
607#define __NR_waitid (__NR_Linux + 237)
608/* #define __NR_sys_setaltroot (__NR_Linux + 238) */
609#define __NR_add_key (__NR_Linux + 239)
610#define __NR_request_key (__NR_Linux + 240)
611#define __NR_keyctl (__NR_Linux + 241)
612#define __NR_set_thread_area (__NR_Linux + 242)
613#define __NR_inotify_init (__NR_Linux + 243)
614#define __NR_inotify_add_watch (__NR_Linux + 244)
615#define __NR_inotify_rm_watch (__NR_Linux + 245)
616#define __NR_migrate_pages (__NR_Linux + 246)
617#define __NR_openat (__NR_Linux + 247)
618#define __NR_mkdirat (__NR_Linux + 248)
619#define __NR_mknodat (__NR_Linux + 249)
620#define __NR_fchownat (__NR_Linux + 250)
621#define __NR_futimesat (__NR_Linux + 251)
622#define __NR_newfstatat (__NR_Linux + 252)
623#define __NR_unlinkat (__NR_Linux + 253)
624#define __NR_renameat (__NR_Linux + 254)
625#define __NR_linkat (__NR_Linux + 255)
626#define __NR_symlinkat (__NR_Linux + 256)
627#define __NR_readlinkat (__NR_Linux + 257)
628#define __NR_fchmodat (__NR_Linux + 258)
629#define __NR_faccessat (__NR_Linux + 259)
630#define __NR_pselect6 (__NR_Linux + 260)
631#define __NR_ppoll (__NR_Linux + 261)
632#define __NR_unshare (__NR_Linux + 262)
633#define __NR_splice (__NR_Linux + 263)
634#define __NR_sync_file_range (__NR_Linux + 264)
635#define __NR_tee (__NR_Linux + 265)
636#define __NR_vmsplice (__NR_Linux + 266)
637#define __NR_move_pages (__NR_Linux + 267)
638#define __NR_set_robust_list (__NR_Linux + 268)
639#define __NR_get_robust_list (__NR_Linux + 269)
640#define __NR_kexec_load (__NR_Linux + 270)
641#define __NR_getcpu (__NR_Linux + 271)
642#define __NR_epoll_pwait (__NR_Linux + 272)
643#define __NR_ioprio_set (__NR_Linux + 273)
644#define __NR_ioprio_get (__NR_Linux + 274)
645#define __NR_utimensat (__NR_Linux + 275)
646#define __NR_signalfd (__NR_Linux + 276)
647#define __NR_timerfd (__NR_Linux + 277)
648#define __NR_eventfd (__NR_Linux + 278)
649#define __NR_fallocate (__NR_Linux + 279)
650#define __NR_timerfd_create (__NR_Linux + 280)
651#define __NR_timerfd_gettime (__NR_Linux + 281)
652#define __NR_timerfd_settime (__NR_Linux + 282)
653#define __NR_signalfd4 (__NR_Linux + 283)
654#define __NR_eventfd2 (__NR_Linux + 284)
655#define __NR_epoll_create1 (__NR_Linux + 285)
656#define __NR_dup3 (__NR_Linux + 286)
657#define __NR_pipe2 (__NR_Linux + 287)
658#define __NR_inotify_init1 (__NR_Linux + 288)
659
660/*
661 * Offset of the last Linux 64-bit flavoured syscall
662 */
663#define __NR_Linux_syscalls 288
664
665#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
666
667#define __NR_64_Linux 5000
668#define __NR_64_Linux_syscalls 288
669
670#if _MIPS_SIM == _MIPS_SIM_NABI32
671
672/*
673 * Linux N32 syscalls are in the range from 6000 to 6999.
674 */
675#define __NR_Linux 6000
676#define __NR_read (__NR_Linux + 0)
677#define __NR_write (__NR_Linux + 1)
678#define __NR_open (__NR_Linux + 2)
679#define __NR_close (__NR_Linux + 3)
680#define __NR_stat (__NR_Linux + 4)
681#define __NR_fstat (__NR_Linux + 5)
682#define __NR_lstat (__NR_Linux + 6)
683#define __NR_poll (__NR_Linux + 7)
684#define __NR_lseek (__NR_Linux + 8)
685#define __NR_mmap (__NR_Linux + 9)
686#define __NR_mprotect (__NR_Linux + 10)
687#define __NR_munmap (__NR_Linux + 11)
688#define __NR_brk (__NR_Linux + 12)
689#define __NR_rt_sigaction (__NR_Linux + 13)
690#define __NR_rt_sigprocmask (__NR_Linux + 14)
691#define __NR_ioctl (__NR_Linux + 15)
692#define __NR_pread64 (__NR_Linux + 16)
693#define __NR_pwrite64 (__NR_Linux + 17)
694#define __NR_readv (__NR_Linux + 18)
695#define __NR_writev (__NR_Linux + 19)
696#define __NR_access (__NR_Linux + 20)
697#define __NR_pipe (__NR_Linux + 21)
698#define __NR__newselect (__NR_Linux + 22)
699#define __NR_sched_yield (__NR_Linux + 23)
700#define __NR_mremap (__NR_Linux + 24)
701#define __NR_msync (__NR_Linux + 25)
702#define __NR_mincore (__NR_Linux + 26)
703#define __NR_madvise (__NR_Linux + 27)
704#define __NR_shmget (__NR_Linux + 28)
705#define __NR_shmat (__NR_Linux + 29)
706#define __NR_shmctl (__NR_Linux + 30)
707#define __NR_dup (__NR_Linux + 31)
708#define __NR_dup2 (__NR_Linux + 32)
709#define __NR_pause (__NR_Linux + 33)
710#define __NR_nanosleep (__NR_Linux + 34)
711#define __NR_getitimer (__NR_Linux + 35)
712#define __NR_setitimer (__NR_Linux + 36)
713#define __NR_alarm (__NR_Linux + 37)
714#define __NR_getpid (__NR_Linux + 38)
715#define __NR_sendfile (__NR_Linux + 39)
716#define __NR_socket (__NR_Linux + 40)
717#define __NR_connect (__NR_Linux + 41)
718#define __NR_accept (__NR_Linux + 42)
719#define __NR_sendto (__NR_Linux + 43)
720#define __NR_recvfrom (__NR_Linux + 44)
721#define __NR_sendmsg (__NR_Linux + 45)
722#define __NR_recvmsg (__NR_Linux + 46)
723#define __NR_shutdown (__NR_Linux + 47)
724#define __NR_bind (__NR_Linux + 48)
725#define __NR_listen (__NR_Linux + 49)
726#define __NR_getsockname (__NR_Linux + 50)
727#define __NR_getpeername (__NR_Linux + 51)
728#define __NR_socketpair (__NR_Linux + 52)
729#define __NR_setsockopt (__NR_Linux + 53)
730#define __NR_getsockopt (__NR_Linux + 54)
731#define __NR_clone (__NR_Linux + 55)
732#define __NR_fork (__NR_Linux + 56)
733#define __NR_execve (__NR_Linux + 57)
734#define __NR_exit (__NR_Linux + 58)
735#define __NR_wait4 (__NR_Linux + 59)
736#define __NR_kill (__NR_Linux + 60)
737#define __NR_uname (__NR_Linux + 61)
738#define __NR_semget (__NR_Linux + 62)
739#define __NR_semop (__NR_Linux + 63)
740#define __NR_semctl (__NR_Linux + 64)
741#define __NR_shmdt (__NR_Linux + 65)
742#define __NR_msgget (__NR_Linux + 66)
743#define __NR_msgsnd (__NR_Linux + 67)
744#define __NR_msgrcv (__NR_Linux + 68)
745#define __NR_msgctl (__NR_Linux + 69)
746#define __NR_fcntl (__NR_Linux + 70)
747#define __NR_flock (__NR_Linux + 71)
748#define __NR_fsync (__NR_Linux + 72)
749#define __NR_fdatasync (__NR_Linux + 73)
750#define __NR_truncate (__NR_Linux + 74)
751#define __NR_ftruncate (__NR_Linux + 75)
752#define __NR_getdents (__NR_Linux + 76)
753#define __NR_getcwd (__NR_Linux + 77)
754#define __NR_chdir (__NR_Linux + 78)
755#define __NR_fchdir (__NR_Linux + 79)
756#define __NR_rename (__NR_Linux + 80)
757#define __NR_mkdir (__NR_Linux + 81)
758#define __NR_rmdir (__NR_Linux + 82)
759#define __NR_creat (__NR_Linux + 83)
760#define __NR_link (__NR_Linux + 84)
761#define __NR_unlink (__NR_Linux + 85)
762#define __NR_symlink (__NR_Linux + 86)
763#define __NR_readlink (__NR_Linux + 87)
764#define __NR_chmod (__NR_Linux + 88)
765#define __NR_fchmod (__NR_Linux + 89)
766#define __NR_chown (__NR_Linux + 90)
767#define __NR_fchown (__NR_Linux + 91)
768#define __NR_lchown (__NR_Linux + 92)
769#define __NR_umask (__NR_Linux + 93)
770#define __NR_gettimeofday (__NR_Linux + 94)
771#define __NR_getrlimit (__NR_Linux + 95)
772#define __NR_getrusage (__NR_Linux + 96)
773#define __NR_sysinfo (__NR_Linux + 97)
774#define __NR_times (__NR_Linux + 98)
775#define __NR_ptrace (__NR_Linux + 99)
776#define __NR_getuid (__NR_Linux + 100)
777#define __NR_syslog (__NR_Linux + 101)
778#define __NR_getgid (__NR_Linux + 102)
779#define __NR_setuid (__NR_Linux + 103)
780#define __NR_setgid (__NR_Linux + 104)
781#define __NR_geteuid (__NR_Linux + 105)
782#define __NR_getegid (__NR_Linux + 106)
783#define __NR_setpgid (__NR_Linux + 107)
784#define __NR_getppid (__NR_Linux + 108)
785#define __NR_getpgrp (__NR_Linux + 109)
786#define __NR_setsid (__NR_Linux + 110)
787#define __NR_setreuid (__NR_Linux + 111)
788#define __NR_setregid (__NR_Linux + 112)
789#define __NR_getgroups (__NR_Linux + 113)
790#define __NR_setgroups (__NR_Linux + 114)
791#define __NR_setresuid (__NR_Linux + 115)
792#define __NR_getresuid (__NR_Linux + 116)
793#define __NR_setresgid (__NR_Linux + 117)
794#define __NR_getresgid (__NR_Linux + 118)
795#define __NR_getpgid (__NR_Linux + 119)
796#define __NR_setfsuid (__NR_Linux + 120)
797#define __NR_setfsgid (__NR_Linux + 121)
798#define __NR_getsid (__NR_Linux + 122)
799#define __NR_capget (__NR_Linux + 123)
800#define __NR_capset (__NR_Linux + 124)
801#define __NR_rt_sigpending (__NR_Linux + 125)
802#define __NR_rt_sigtimedwait (__NR_Linux + 126)
803#define __NR_rt_sigqueueinfo (__NR_Linux + 127)
804#define __NR_rt_sigsuspend (__NR_Linux + 128)
805#define __NR_sigaltstack (__NR_Linux + 129)
806#define __NR_utime (__NR_Linux + 130)
807#define __NR_mknod (__NR_Linux + 131)
808#define __NR_personality (__NR_Linux + 132)
809#define __NR_ustat (__NR_Linux + 133)
810#define __NR_statfs (__NR_Linux + 134)
811#define __NR_fstatfs (__NR_Linux + 135)
812#define __NR_sysfs (__NR_Linux + 136)
813#define __NR_getpriority (__NR_Linux + 137)
814#define __NR_setpriority (__NR_Linux + 138)
815#define __NR_sched_setparam (__NR_Linux + 139)
816#define __NR_sched_getparam (__NR_Linux + 140)
817#define __NR_sched_setscheduler (__NR_Linux + 141)
818#define __NR_sched_getscheduler (__NR_Linux + 142)
819#define __NR_sched_get_priority_max (__NR_Linux + 143)
820#define __NR_sched_get_priority_min (__NR_Linux + 144)
821#define __NR_sched_rr_get_interval (__NR_Linux + 145)
822#define __NR_mlock (__NR_Linux + 146)
823#define __NR_munlock (__NR_Linux + 147)
824#define __NR_mlockall (__NR_Linux + 148)
825#define __NR_munlockall (__NR_Linux + 149)
826#define __NR_vhangup (__NR_Linux + 150)
827#define __NR_pivot_root (__NR_Linux + 151)
828#define __NR__sysctl (__NR_Linux + 152)
829#define __NR_prctl (__NR_Linux + 153)
830#define __NR_adjtimex (__NR_Linux + 154)
831#define __NR_setrlimit (__NR_Linux + 155)
832#define __NR_chroot (__NR_Linux + 156)
833#define __NR_sync (__NR_Linux + 157)
834#define __NR_acct (__NR_Linux + 158)
835#define __NR_settimeofday (__NR_Linux + 159)
836#define __NR_mount (__NR_Linux + 160)
837#define __NR_umount2 (__NR_Linux + 161)
838#define __NR_swapon (__NR_Linux + 162)
839#define __NR_swapoff (__NR_Linux + 163)
840#define __NR_reboot (__NR_Linux + 164)
841#define __NR_sethostname (__NR_Linux + 165)
842#define __NR_setdomainname (__NR_Linux + 166)
843#define __NR_create_module (__NR_Linux + 167)
844#define __NR_init_module (__NR_Linux + 168)
845#define __NR_delete_module (__NR_Linux + 169)
846#define __NR_get_kernel_syms (__NR_Linux + 170)
847#define __NR_query_module (__NR_Linux + 171)
848#define __NR_quotactl (__NR_Linux + 172)
849#define __NR_nfsservctl (__NR_Linux + 173)
850#define __NR_getpmsg (__NR_Linux + 174)
851#define __NR_putpmsg (__NR_Linux + 175)
852#define __NR_afs_syscall (__NR_Linux + 176)
853#define __NR_reserved177 (__NR_Linux + 177)
854#define __NR_gettid (__NR_Linux + 178)
855#define __NR_readahead (__NR_Linux + 179)
856#define __NR_setxattr (__NR_Linux + 180)
857#define __NR_lsetxattr (__NR_Linux + 181)
858#define __NR_fsetxattr (__NR_Linux + 182)
859#define __NR_getxattr (__NR_Linux + 183)
860#define __NR_lgetxattr (__NR_Linux + 184)
861#define __NR_fgetxattr (__NR_Linux + 185)
862#define __NR_listxattr (__NR_Linux + 186)
863#define __NR_llistxattr (__NR_Linux + 187)
864#define __NR_flistxattr (__NR_Linux + 188)
865#define __NR_removexattr (__NR_Linux + 189)
866#define __NR_lremovexattr (__NR_Linux + 190)
867#define __NR_fremovexattr (__NR_Linux + 191)
868#define __NR_tkill (__NR_Linux + 192)
869#define __NR_reserved193 (__NR_Linux + 193)
870#define __NR_futex (__NR_Linux + 194)
871#define __NR_sched_setaffinity (__NR_Linux + 195)
872#define __NR_sched_getaffinity (__NR_Linux + 196)
873#define __NR_cacheflush (__NR_Linux + 197)
874#define __NR_cachectl (__NR_Linux + 198)
875#define __NR_sysmips (__NR_Linux + 199)
876#define __NR_io_setup (__NR_Linux + 200)
877#define __NR_io_destroy (__NR_Linux + 201)
878#define __NR_io_getevents (__NR_Linux + 202)
879#define __NR_io_submit (__NR_Linux + 203)
880#define __NR_io_cancel (__NR_Linux + 204)
881#define __NR_exit_group (__NR_Linux + 205)
882#define __NR_lookup_dcookie (__NR_Linux + 206)
883#define __NR_epoll_create (__NR_Linux + 207)
884#define __NR_epoll_ctl (__NR_Linux + 208)
885#define __NR_epoll_wait (__NR_Linux + 209)
886#define __NR_remap_file_pages (__NR_Linux + 210)
887#define __NR_rt_sigreturn (__NR_Linux + 211)
888#define __NR_fcntl64 (__NR_Linux + 212)
889#define __NR_set_tid_address (__NR_Linux + 213)
890#define __NR_restart_syscall (__NR_Linux + 214)
891#define __NR_semtimedop (__NR_Linux + 215)
892#define __NR_fadvise64 (__NR_Linux + 216)
893#define __NR_statfs64 (__NR_Linux + 217)
894#define __NR_fstatfs64 (__NR_Linux + 218)
895#define __NR_sendfile64 (__NR_Linux + 219)
896#define __NR_timer_create (__NR_Linux + 220)
897#define __NR_timer_settime (__NR_Linux + 221)
898#define __NR_timer_gettime (__NR_Linux + 222)
899#define __NR_timer_getoverrun (__NR_Linux + 223)
900#define __NR_timer_delete (__NR_Linux + 224)
901#define __NR_clock_settime (__NR_Linux + 225)
902#define __NR_clock_gettime (__NR_Linux + 226)
903#define __NR_clock_getres (__NR_Linux + 227)
904#define __NR_clock_nanosleep (__NR_Linux + 228)
905#define __NR_tgkill (__NR_Linux + 229)
906#define __NR_utimes (__NR_Linux + 230)
907#define __NR_mbind (__NR_Linux + 231)
908#define __NR_get_mempolicy (__NR_Linux + 232)
909#define __NR_set_mempolicy (__NR_Linux + 233)
910#define __NR_mq_open (__NR_Linux + 234)
911#define __NR_mq_unlink (__NR_Linux + 235)
912#define __NR_mq_timedsend (__NR_Linux + 236)
913#define __NR_mq_timedreceive (__NR_Linux + 237)
914#define __NR_mq_notify (__NR_Linux + 238)
915#define __NR_mq_getsetattr (__NR_Linux + 239)
916#define __NR_vserver (__NR_Linux + 240)
917#define __NR_waitid (__NR_Linux + 241)
918/* #define __NR_sys_setaltroot (__NR_Linux + 242) */
919#define __NR_add_key (__NR_Linux + 243)
920#define __NR_request_key (__NR_Linux + 244)
921#define __NR_keyctl (__NR_Linux + 245)
922#define __NR_set_thread_area (__NR_Linux + 246)
923#define __NR_inotify_init (__NR_Linux + 247)
924#define __NR_inotify_add_watch (__NR_Linux + 248)
925#define __NR_inotify_rm_watch (__NR_Linux + 249)
926#define __NR_migrate_pages (__NR_Linux + 250)
927#define __NR_openat (__NR_Linux + 251)
928#define __NR_mkdirat (__NR_Linux + 252)
929#define __NR_mknodat (__NR_Linux + 253)
930#define __NR_fchownat (__NR_Linux + 254)
931#define __NR_futimesat (__NR_Linux + 255)
932#define __NR_newfstatat (__NR_Linux + 256)
933#define __NR_unlinkat (__NR_Linux + 257)
934#define __NR_renameat (__NR_Linux + 258)
935#define __NR_linkat (__NR_Linux + 259)
936#define __NR_symlinkat (__NR_Linux + 260)
937#define __NR_readlinkat (__NR_Linux + 261)
938#define __NR_fchmodat (__NR_Linux + 262)
939#define __NR_faccessat (__NR_Linux + 263)
940#define __NR_pselect6 (__NR_Linux + 264)
941#define __NR_ppoll (__NR_Linux + 265)
942#define __NR_unshare (__NR_Linux + 266)
943#define __NR_splice (__NR_Linux + 267)
944#define __NR_sync_file_range (__NR_Linux + 268)
945#define __NR_tee (__NR_Linux + 269)
946#define __NR_vmsplice (__NR_Linux + 270)
947#define __NR_move_pages (__NR_Linux + 271)
948#define __NR_set_robust_list (__NR_Linux + 272)
949#define __NR_get_robust_list (__NR_Linux + 273)
950#define __NR_kexec_load (__NR_Linux + 274)
951#define __NR_getcpu (__NR_Linux + 275)
952#define __NR_epoll_pwait (__NR_Linux + 276)
953#define __NR_ioprio_set (__NR_Linux + 277)
954#define __NR_ioprio_get (__NR_Linux + 278)
955#define __NR_utimensat (__NR_Linux + 279)
956#define __NR_signalfd (__NR_Linux + 280)
957#define __NR_timerfd (__NR_Linux + 281)
958#define __NR_eventfd (__NR_Linux + 282)
959#define __NR_fallocate (__NR_Linux + 283)
960#define __NR_timerfd_create (__NR_Linux + 284)
961#define __NR_timerfd_gettime (__NR_Linux + 285)
962#define __NR_timerfd_settime (__NR_Linux + 286)
963#define __NR_signalfd4 (__NR_Linux + 287)
964#define __NR_eventfd2 (__NR_Linux + 288)
965#define __NR_epoll_create1 (__NR_Linux + 289)
966#define __NR_dup3 (__NR_Linux + 290)
967#define __NR_pipe2 (__NR_Linux + 291)
968#define __NR_inotify_init1 (__NR_Linux + 292)
969
970/*
971 * Offset of the last N32 flavoured syscall
972 */
973#define __NR_Linux_syscalls 292
974
975#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
976
977#define __NR_N32_Linux 6000
978#define __NR_N32_Linux_syscalls 292
979
980#ifdef __KERNEL__
981
982#ifndef __ASSEMBLY__
983
984#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
985#define __ARCH_WANT_IPC_PARSE_VERSION
986#define __ARCH_WANT_OLD_READDIR
987#define __ARCH_WANT_SYS_ALARM
988#define __ARCH_WANT_SYS_GETHOSTNAME
989#define __ARCH_WANT_SYS_PAUSE
990#define __ARCH_WANT_SYS_SGETMASK
991#define __ARCH_WANT_SYS_UTIME
992#define __ARCH_WANT_SYS_WAITPID
993#define __ARCH_WANT_SYS_SOCKETCALL
994#define __ARCH_WANT_SYS_GETPGRP
995#define __ARCH_WANT_SYS_LLSEEK
996#define __ARCH_WANT_SYS_NICE
997#define __ARCH_WANT_SYS_OLD_GETRLIMIT
998#define __ARCH_WANT_SYS_OLDUMOUNT
999#define __ARCH_WANT_SYS_SIGPENDING
1000#define __ARCH_WANT_SYS_SIGPROCMASK
1001#define __ARCH_WANT_SYS_RT_SIGACTION
1002# ifdef CONFIG_32BIT
1003# define __ARCH_WANT_STAT64
1004# define __ARCH_WANT_SYS_TIME
1005# endif
1006# ifdef CONFIG_MIPS32_O32
1007# define __ARCH_WANT_COMPAT_SYS_TIME
1008# endif
1009
1010/* whitelists for checksyscalls */
1011#define __IGNORE_select
1012#define __IGNORE_vfork
1013#define __IGNORE_time
1014#define __IGNORE_uselib
1015#define __IGNORE_fadvise64_64
1016#define __IGNORE_getdents64
1017#if _MIPS_SIM == _MIPS_SIM_NABI32
1018#define __IGNORE_truncate64
1019#define __IGNORE_ftruncate64
1020#define __IGNORE_stat64
1021#define __IGNORE_lstat64
1022#define __IGNORE_fstat64
1023#define __IGNORE_fstatat64
1024#endif
1025
1026#endif /* !__ASSEMBLY__ */
1027
1028/*
1029 * "Conditional" syscalls
1030 *
1031 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
1032 * but it doesn't work on all toolchains, so we just do it by hand
1033 */
1034#define cond_syscall(x) asm(".weak\t" #x "\n" #x "\t=\tsys_ni_syscall")
1035
1036#endif /* __KERNEL__ */
1037#endif /* _ASM_UNISTD_H */
diff --git a/arch/mips/include/asm/user.h b/arch/mips/include/asm/user.h
new file mode 100644
index 000000000000..afa83a4c1888
--- /dev/null
+++ b/arch/mips/include/asm/user.h
@@ -0,0 +1,58 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
7 */
8#ifndef _ASM_USER_H
9#define _ASM_USER_H
10
11#include <asm/page.h>
12#include <asm/reg.h>
13
14/*
15 * Core file format: The core file is written in such a way that gdb
16 * can understand it and provide useful information to the user (under
17 * linux we use the `trad-core' bfd, NOT the irix-core). The file
18 * contents are as follows:
19 *
20 * upage: 1 page consisting of a user struct that tells gdb
21 * what is present in the file. Directly after this is a
22 * copy of the task_struct, which is currently not used by gdb,
23 * but it may come in handy at some point. All of the registers
24 * are stored as part of the upage. The upage should always be
25 * only one page long.
26 * data: The data segment follows next. We use current->end_text to
27 * current->brk to pick up all of the user variables, plus any memory
28 * that may have been sbrk'ed. No attempt is made to determine if a
29 * page is demand-zero or if a page is totally unused, we just cover
30 * the entire range. All of the addresses are rounded in such a way
31 * that an integral number of pages is written.
32 * stack: We need the stack information in order to get a meaningful
33 * backtrace. We need to write the data from usp to
34 * current->start_stack, so we round each of these in order to be able
35 * to write an integer number of pages.
36 */
37struct user {
38 unsigned long regs[EF_SIZE / /* integer and fp regs */
39 sizeof(unsigned long) + 64];
40 size_t u_tsize; /* text size (pages) */
41 size_t u_dsize; /* data size (pages) */
42 size_t u_ssize; /* stack size (pages) */
43 unsigned long start_code; /* text starting address */
44 unsigned long start_data; /* data starting address */
45 unsigned long start_stack; /* stack starting address */
46 long int signal; /* signal causing core dump */
47 unsigned long u_ar0; /* help gdb find registers */
48 unsigned long magic; /* identifies a core file */
49 char u_comm[32]; /* user command name */
50};
51
52#define NBPG PAGE_SIZE
53#define UPAGES 1
54#define HOST_TEXT_START_ADDR (u.start_code)
55#define HOST_DATA_START_ADDR (u.start_data)
56#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
57
58#endif /* _ASM_USER_H */
diff --git a/arch/mips/include/asm/vga.h b/arch/mips/include/asm/vga.h
new file mode 100644
index 000000000000..f4cff7e4fa8a
--- /dev/null
+++ b/arch/mips/include/asm/vga.h
@@ -0,0 +1,47 @@
1/*
2 * Access to VGA videoram
3 *
4 * (c) 1998 Martin Mares <mj@ucw.cz>
5 */
6#ifndef _ASM_VGA_H
7#define _ASM_VGA_H
8
9#include <asm/byteorder.h>
10
11/*
12 * On the PC, we can just recalculate addresses and then
13 * access the videoram directly without any black magic.
14 */
15
16#define VGA_MAP_MEM(x, s) (0xb0000000L + (unsigned long)(x))
17
18#define vga_readb(x) (*(x))
19#define vga_writeb(x, y) (*(y) = (x))
20
21#define VT_BUF_HAVE_RW
22/*
23 * These are only needed for supporting VGA or MDA text mode, which use little
24 * endian byte ordering.
25 * In other cases, we can optimize by using native byte ordering and
26 * <linux/vt_buffer.h> has already done the right job for us.
27 */
28
29#undef scr_writew
30#undef scr_readw
31
32static inline void scr_writew(u16 val, volatile u16 *addr)
33{
34 *addr = cpu_to_le16(val);
35}
36
37static inline u16 scr_readw(volatile const u16 *addr)
38{
39 return le16_to_cpu(*addr);
40}
41
42#define scr_memcpyw(d, s, c) memcpy(d, s, c)
43#define scr_memmovew(d, s, c) memmove(d, s, c)
44#define VT_BUF_HAVE_MEMCPYW
45#define VT_BUF_HAVE_MEMMOVEW
46
47#endif /* _ASM_VGA_H */
diff --git a/arch/mips/include/asm/vpe.h b/arch/mips/include/asm/vpe.h
new file mode 100644
index 000000000000..c6e1b961537d
--- /dev/null
+++ b/arch/mips/include/asm/vpe.h
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
3 *
4 * This program is free software; you can distribute it and/or modify it
5 * under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 *
17 */
18
19#ifndef _ASM_VPE_H
20#define _ASM_VPE_H
21
22struct vpe_notifications {
23 void (*start)(int vpe);
24 void (*stop)(int vpe);
25
26 struct list_head list;
27};
28
29
30extern int vpe_notify(int index, struct vpe_notifications *notify);
31
32extern void *vpe_get_shared(int index);
33extern int vpe_getuid(int index);
34extern int vpe_getgid(int index);
35extern char *vpe_getcwd(int index);
36
37#endif /* _ASM_VPE_H */
diff --git a/arch/mips/include/asm/vr41xx/capcella.h b/arch/mips/include/asm/vr41xx/capcella.h
new file mode 100644
index 000000000000..e0ee05a3dfcc
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/capcella.h
@@ -0,0 +1,43 @@
1/*
2 * capcella.h, Include file for ZAO Networks Capcella.
3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __ZAO_CAPCELLA_H
21#define __ZAO_CAPCELLA_H
22
23#include <asm/vr41xx/irq.h>
24
25/*
26 * General-Purpose I/O Pin Number
27 */
28#define PC104PLUS_INTA_PIN 2
29#define PC104PLUS_INTB_PIN 3
30#define PC104PLUS_INTC_PIN 4
31#define PC104PLUS_INTD_PIN 5
32
33/*
34 * Interrupt Number
35 */
36#define RTL8139_1_IRQ GIU_IRQ(PC104PLUS_INTC_PIN)
37#define RTL8139_2_IRQ GIU_IRQ(PC104PLUS_INTD_PIN)
38#define PC104PLUS_INTA_IRQ GIU_IRQ(PC104PLUS_INTA_PIN)
39#define PC104PLUS_INTB_IRQ GIU_IRQ(PC104PLUS_INTB_PIN)
40#define PC104PLUS_INTC_IRQ GIU_IRQ(PC104PLUS_INTC_PIN)
41#define PC104PLUS_INTD_IRQ GIU_IRQ(PC104PLUS_INTD_PIN)
42
43#endif /* __ZAO_CAPCELLA_H */
diff --git a/arch/mips/include/asm/vr41xx/giu.h b/arch/mips/include/asm/vr41xx/giu.h
new file mode 100644
index 000000000000..0bcdd3a5c256
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/giu.h
@@ -0,0 +1,78 @@
1/*
2 * Include file for NEC VR4100 series General-purpose I/O Unit.
3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __NEC_VR41XX_GIU_H
21#define __NEC_VR41XX_GIU_H
22
23/*
24 * NEC VR4100 series GIU platform device IDs.
25 */
26enum {
27 GPIO_50PINS_PULLUPDOWN,
28 GPIO_36PINS,
29 GPIO_48PINS_EDGE_SELECT,
30};
31
32typedef enum {
33 IRQ_TRIGGER_LEVEL,
34 IRQ_TRIGGER_EDGE,
35 IRQ_TRIGGER_EDGE_FALLING,
36 IRQ_TRIGGER_EDGE_RISING,
37} irq_trigger_t;
38
39typedef enum {
40 IRQ_SIGNAL_THROUGH,
41 IRQ_SIGNAL_HOLD,
42} irq_signal_t;
43
44extern void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger, irq_signal_t signal);
45
46typedef enum {
47 IRQ_LEVEL_LOW,
48 IRQ_LEVEL_HIGH,
49} irq_level_t;
50
51extern void vr41xx_set_irq_level(unsigned int pin, irq_level_t level);
52
53typedef enum {
54 GPIO_DATA_LOW,
55 GPIO_DATA_HIGH,
56 GPIO_DATA_INVAL,
57} gpio_data_t;
58
59extern gpio_data_t vr41xx_gpio_get_pin(unsigned int pin);
60extern int vr41xx_gpio_set_pin(unsigned int pin, gpio_data_t data);
61
62typedef enum {
63 GPIO_INPUT,
64 GPIO_OUTPUT,
65 GPIO_OUTPUT_DISABLE,
66} gpio_direction_t;
67
68extern int vr41xx_gpio_set_direction(unsigned int pin, gpio_direction_t dir);
69
70typedef enum {
71 GPIO_PULL_DOWN,
72 GPIO_PULL_UP,
73 GPIO_PULL_DISABLE,
74} gpio_pull_t;
75
76extern int vr41xx_gpio_pullupdown(unsigned int pin, gpio_pull_t pull);
77
78#endif /* __NEC_VR41XX_GIU_H */
diff --git a/arch/mips/include/asm/vr41xx/irq.h b/arch/mips/include/asm/vr41xx/irq.h
new file mode 100644
index 000000000000..d315dfbc08f2
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/irq.h
@@ -0,0 +1,101 @@
1/*
2 * include/asm-mips/vr41xx/irq.h
3 *
4 * Interrupt numbers for NEC VR4100 series.
5 *
6 * Copyright (C) 1999 Michael Klar
7 * Copyright (C) 2001, 2002 Paul Mundt
8 * Copyright (C) 2002 MontaVista Software, Inc.
9 * Copyright (C) 2002 TimeSys Corp.
10 * Copyright (C) 2003-2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17#ifndef __NEC_VR41XX_IRQ_H
18#define __NEC_VR41XX_IRQ_H
19
20/*
21 * CPU core Interrupt Numbers
22 */
23#define MIPS_CPU_IRQ_BASE 0
24#define MIPS_CPU_IRQ(x) (MIPS_CPU_IRQ_BASE + (x))
25#define MIPS_SOFTINT0_IRQ MIPS_CPU_IRQ(0)
26#define MIPS_SOFTINT1_IRQ MIPS_CPU_IRQ(1)
27#define INT0_IRQ MIPS_CPU_IRQ(2)
28#define INT1_IRQ MIPS_CPU_IRQ(3)
29#define INT2_IRQ MIPS_CPU_IRQ(4)
30#define INT3_IRQ MIPS_CPU_IRQ(5)
31#define INT4_IRQ MIPS_CPU_IRQ(6)
32#define TIMER_IRQ MIPS_CPU_IRQ(7)
33
34/*
35 * SYINT1 Interrupt Numbers
36 */
37#define SYSINT1_IRQ_BASE 8
38#define SYSINT1_IRQ(x) (SYSINT1_IRQ_BASE + (x))
39#define BATTRY_IRQ SYSINT1_IRQ(0)
40#define POWER_IRQ SYSINT1_IRQ(1)
41#define RTCLONG1_IRQ SYSINT1_IRQ(2)
42#define ELAPSEDTIME_IRQ SYSINT1_IRQ(3)
43/* RFU */
44#define PIU_IRQ SYSINT1_IRQ(5)
45#define AIU_IRQ SYSINT1_IRQ(6)
46#define KIU_IRQ SYSINT1_IRQ(7)
47#define GIUINT_IRQ SYSINT1_IRQ(8)
48#define SIU_IRQ SYSINT1_IRQ(9)
49#define BUSERR_IRQ SYSINT1_IRQ(10)
50#define SOFTINT_IRQ SYSINT1_IRQ(11)
51#define CLKRUN_IRQ SYSINT1_IRQ(12)
52#define DOZEPIU_IRQ SYSINT1_IRQ(13)
53#define SYSINT1_IRQ_LAST DOZEPIU_IRQ
54
55/*
56 * SYSINT2 Interrupt Numbers
57 */
58#define SYSINT2_IRQ_BASE 24
59#define SYSINT2_IRQ(x) (SYSINT2_IRQ_BASE + (x))
60#define RTCLONG2_IRQ SYSINT2_IRQ(0)
61#define LED_IRQ SYSINT2_IRQ(1)
62#define HSP_IRQ SYSINT2_IRQ(2)
63#define TCLOCK_IRQ SYSINT2_IRQ(3)
64#define FIR_IRQ SYSINT2_IRQ(4)
65#define CEU_IRQ SYSINT2_IRQ(4) /* same number as FIR_IRQ */
66#define DSIU_IRQ SYSINT2_IRQ(5)
67#define PCI_IRQ SYSINT2_IRQ(6)
68#define SCU_IRQ SYSINT2_IRQ(7)
69#define CSI_IRQ SYSINT2_IRQ(8)
70#define BCU_IRQ SYSINT2_IRQ(9)
71#define ETHERNET_IRQ SYSINT2_IRQ(10)
72#define SYSINT2_IRQ_LAST ETHERNET_IRQ
73
74/*
75 * GIU Interrupt Numbers
76 */
77#define GIU_IRQ_BASE 40
78#define GIU_IRQ(x) (GIU_IRQ_BASE + (x)) /* IRQ 40-71 */
79#define GIU_IRQ_LAST GIU_IRQ(31)
80
81/*
82 * VRC4173 Interrupt Numbers
83 */
84#define VRC4173_IRQ_BASE 72
85#define VRC4173_IRQ(x) (VRC4173_IRQ_BASE + (x))
86#define VRC4173_USB_IRQ VRC4173_IRQ(0)
87#define VRC4173_PCMCIA2_IRQ VRC4173_IRQ(1)
88#define VRC4173_PCMCIA1_IRQ VRC4173_IRQ(2)
89#define VRC4173_PS2CH2_IRQ VRC4173_IRQ(3)
90#define VRC4173_PS2CH1_IRQ VRC4173_IRQ(4)
91#define VRC4173_PIU_IRQ VRC4173_IRQ(5)
92#define VRC4173_AIU_IRQ VRC4173_IRQ(6)
93#define VRC4173_KIU_IRQ VRC4173_IRQ(7)
94#define VRC4173_GIU_IRQ VRC4173_IRQ(8)
95#define VRC4173_AC97_IRQ VRC4173_IRQ(9)
96#define VRC4173_AC97INT1_IRQ VRC4173_IRQ(10)
97/* RFU */
98#define VRC4173_DOZEPIU_IRQ VRC4173_IRQ(13)
99#define VRC4173_IRQ_LAST VRC4173_DOZEPIU_IRQ
100
101#endif /* __NEC_VR41XX_IRQ_H */
diff --git a/arch/mips/include/asm/vr41xx/mpc30x.h b/arch/mips/include/asm/vr41xx/mpc30x.h
new file mode 100644
index 000000000000..1d67df843dc3
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/mpc30x.h
@@ -0,0 +1,37 @@
1/*
2 * mpc30x.h, Include file for Victor MP-C303/304.
3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __VICTOR_MPC30X_H
21#define __VICTOR_MPC30X_H
22
23#include <asm/vr41xx/irq.h>
24
25/*
26 * General-Purpose I/O Pin Number
27 */
28#define VRC4173_PIN 1
29#define MQ200_PIN 4
30
31/*
32 * Interrupt Number
33 */
34#define VRC4173_CASCADE_IRQ GIU_IRQ(VRC4173_PIN)
35#define MQ200_IRQ GIU_IRQ(MQ200_PIN)
36
37#endif /* __VICTOR_MPC30X_H */
diff --git a/arch/mips/include/asm/vr41xx/pci.h b/arch/mips/include/asm/vr41xx/pci.h
new file mode 100644
index 000000000000..6fc01ce19777
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/pci.h
@@ -0,0 +1,90 @@
1/*
2 * Include file for NEC VR4100 series PCI Control Unit.
3 *
4 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __NEC_VR41XX_PCI_H
21#define __NEC_VR41XX_PCI_H
22
23#define PCI_MASTER_ADDRESS_MASK 0x7fffffffU
24
25struct pci_master_address_conversion {
26 uint32_t bus_base_address;
27 uint32_t address_mask;
28 uint32_t pci_base_address;
29};
30
31struct pci_target_address_conversion {
32 uint32_t address_mask;
33 uint32_t bus_base_address;
34};
35
36typedef enum {
37 CANNOT_LOCK_FROM_DEVICE,
38 CAN_LOCK_FROM_DEVICE,
39} pci_exclusive_access_t;
40
41struct pci_mailbox_address {
42 uint32_t base_address;
43};
44
45struct pci_target_address_window {
46 uint32_t base_address;
47};
48
49typedef enum {
50 PCI_ARBITRATION_MODE_FAIR,
51 PCI_ARBITRATION_MODE_ALTERNATE_0,
52 PCI_ARBITRATION_MODE_ALTERNATE_B,
53} pci_arbiter_priority_control_t;
54
55typedef enum {
56 PCI_TAKE_AWAY_GNT_DISABLE,
57 PCI_TAKE_AWAY_GNT_ENABLE,
58} pci_take_away_gnt_mode_t;
59
60struct pci_controller_unit_setup {
61 struct pci_master_address_conversion *master_memory1;
62 struct pci_master_address_conversion *master_memory2;
63
64 struct pci_target_address_conversion *target_memory1;
65 struct pci_target_address_conversion *target_memory2;
66
67 struct pci_master_address_conversion *master_io;
68
69 pci_exclusive_access_t exclusive_access;
70
71 uint32_t pci_clock_max;
72 uint8_t wait_time_limit_from_irdy_to_trdy; /* Only VR4122 is supported */
73
74 struct pci_mailbox_address *mailbox;
75 struct pci_target_address_window *target_window1;
76 struct pci_target_address_window *target_window2;
77
78 uint8_t master_latency_timer;
79 uint8_t retry_limit;
80
81 pci_arbiter_priority_control_t arbiter_priority_control;
82 pci_take_away_gnt_mode_t take_away_gnt_mode;
83
84 struct resource *mem_resource;
85 struct resource *io_resource;
86};
87
88extern void vr41xx_pciu_setup(struct pci_controller_unit_setup *setup);
89
90#endif /* __NEC_VR41XX_PCI_H */
diff --git a/arch/mips/include/asm/vr41xx/siu.h b/arch/mips/include/asm/vr41xx/siu.h
new file mode 100644
index 000000000000..da9f6e373409
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/siu.h
@@ -0,0 +1,58 @@
1/*
2 * Include file for NEC VR4100 series Serial Interface Unit.
3 *
4 * Copyright (C) 2005-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __NEC_VR41XX_SIU_H
21#define __NEC_VR41XX_SIU_H
22
23#define SIU_PORTS_MAX 2
24
25typedef enum {
26 SIU_INTERFACE_RS232C,
27 SIU_INTERFACE_IRDA,
28} siu_interface_t;
29
30extern void vr41xx_select_siu_interface(siu_interface_t interface);
31
32typedef enum {
33 SIU_USE_IRDA,
34 FIR_USE_IRDA,
35} irda_use_t;
36
37extern void vr41xx_use_irda(irda_use_t use);
38
39typedef enum {
40 SHARP_IRDA,
41 TEMIC_IRDA,
42 HP_IRDA,
43} irda_module_t;
44
45typedef enum {
46 IRDA_TX_1_5MBPS,
47 IRDA_TX_4MBPS,
48} irda_speed_t;
49
50extern void vr41xx_select_irda_module(irda_module_t module, irda_speed_t speed);
51
52#ifdef CONFIG_SERIAL_VR41XX_CONSOLE
53extern void vr41xx_siu_early_setup(struct uart_port *port);
54#else
55static inline void vr41xx_siu_early_setup(struct uart_port *port) {}
56#endif
57
58#endif /* __NEC_VR41XX_SIU_H */
diff --git a/arch/mips/include/asm/vr41xx/tb0219.h b/arch/mips/include/asm/vr41xx/tb0219.h
new file mode 100644
index 000000000000..dc981b4be0a4
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/tb0219.h
@@ -0,0 +1,42 @@
1/*
2 * tb0219.h, Include file for TANBAC TB0219.
3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * Modified for TANBAC TB0219:
7 * Copyright (C) 2003 Megasolution Inc. <matsu@megasolution.jp>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23#ifndef __TANBAC_TB0219_H
24#define __TANBAC_TB0219_H
25
26#include <asm/vr41xx/irq.h>
27
28/*
29 * General-Purpose I/O Pin Number
30 */
31#define TB0219_PCI_SLOT1_PIN 2
32#define TB0219_PCI_SLOT2_PIN 3
33#define TB0219_PCI_SLOT3_PIN 4
34
35/*
36 * Interrupt Number
37 */
38#define TB0219_PCI_SLOT1_IRQ GIU_IRQ(TB0219_PCI_SLOT1_PIN)
39#define TB0219_PCI_SLOT2_IRQ GIU_IRQ(TB0219_PCI_SLOT2_PIN)
40#define TB0219_PCI_SLOT3_IRQ GIU_IRQ(TB0219_PCI_SLOT3_PIN)
41
42#endif /* __TANBAC_TB0219_H */
diff --git a/arch/mips/include/asm/vr41xx/tb0226.h b/arch/mips/include/asm/vr41xx/tb0226.h
new file mode 100644
index 000000000000..de527dcfa5f3
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/tb0226.h
@@ -0,0 +1,43 @@
1/*
2 * tb0226.h, Include file for TANBAC TB0226.
3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __TANBAC_TB0226_H
21#define __TANBAC_TB0226_H
22
23#include <asm/vr41xx/irq.h>
24
25/*
26 * General-Purpose I/O Pin Number
27 */
28#define GD82559_1_PIN 2
29#define GD82559_2_PIN 3
30#define UPD720100_INTA_PIN 4
31#define UPD720100_INTB_PIN 8
32#define UPD720100_INTC_PIN 13
33
34/*
35 * Interrupt Number
36 */
37#define GD82559_1_IRQ GIU_IRQ(GD82559_1_PIN)
38#define GD82559_2_IRQ GIU_IRQ(GD82559_2_PIN)
39#define UPD720100_INTA_IRQ GIU_IRQ(UPD720100_INTA_PIN)
40#define UPD720100_INTB_IRQ GIU_IRQ(UPD720100_INTB_PIN)
41#define UPD720100_INTC_IRQ GIU_IRQ(UPD720100_INTC_PIN)
42
43#endif /* __TANBAC_TB0226_H */
diff --git a/arch/mips/include/asm/vr41xx/tb0287.h b/arch/mips/include/asm/vr41xx/tb0287.h
new file mode 100644
index 000000000000..61bead68abf0
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/tb0287.h
@@ -0,0 +1,43 @@
1/*
2 * tb0287.h, Include file for TANBAC TB0287 mini-ITX board.
3 *
4 * Copyright (C) 2005 Media Lab Inc. <ito@mlb.co.jp>
5 *
6 * This code is largely based on tb0219.h.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#ifndef __TANBAC_TB0287_H
23#define __TANBAC_TB0287_H
24
25#include <asm/vr41xx/irq.h>
26
27/*
28 * General-Purpose I/O Pin Number
29 */
30#define TB0287_PCI_SLOT_PIN 2
31#define TB0287_SM501_PIN 3
32#define TB0287_SIL680A_PIN 8
33#define TB0287_RTL8110_PIN 13
34
35/*
36 * Interrupt Number
37 */
38#define TB0287_PCI_SLOT_IRQ GIU_IRQ(TB0287_PCI_SLOT_PIN)
39#define TB0287_SM501_IRQ GIU_IRQ(TB0287_SM501_PIN)
40#define TB0287_SIL680A_IRQ GIU_IRQ(TB0287_SIL680A_PIN)
41#define TB0287_RTL8110_IRQ GIU_IRQ(TB0287_RTL8110_PIN)
42
43#endif /* __TANBAC_TB0287_H */
diff --git a/arch/mips/include/asm/vr41xx/vr41xx.h b/arch/mips/include/asm/vr41xx/vr41xx.h
new file mode 100644
index 000000000000..22be64971cc6
--- /dev/null
+++ b/arch/mips/include/asm/vr41xx/vr41xx.h
@@ -0,0 +1,152 @@
1/*
2 * include/asm-mips/vr41xx/vr41xx.h
3 *
4 * Include file for NEC VR4100 series.
5 *
6 * Copyright (C) 1999 Michael Klar
7 * Copyright (C) 2001, 2002 Paul Mundt
8 * Copyright (C) 2002 MontaVista Software, Inc.
9 * Copyright (C) 2002 TimeSys Corp.
10 * Copyright (C) 2003-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17#ifndef __NEC_VR41XX_H
18#define __NEC_VR41XX_H
19
20#include <linux/interrupt.h>
21
22/*
23 * CPU Revision
24 */
25/* VR4122 0x00000c70-0x00000c72 */
26#define PRID_VR4122_REV1_0 0x00000c70
27#define PRID_VR4122_REV2_0 0x00000c70
28#define PRID_VR4122_REV2_1 0x00000c70
29#define PRID_VR4122_REV3_0 0x00000c71
30#define PRID_VR4122_REV3_1 0x00000c72
31
32/* VR4181A 0x00000c73-0x00000c7f */
33#define PRID_VR4181A_REV1_0 0x00000c73
34#define PRID_VR4181A_REV1_1 0x00000c74
35
36/* VR4131 0x00000c80-0x00000c83 */
37#define PRID_VR4131_REV1_2 0x00000c80
38#define PRID_VR4131_REV2_0 0x00000c81
39#define PRID_VR4131_REV2_1 0x00000c82
40#define PRID_VR4131_REV2_2 0x00000c83
41
42/* VR4133 0x00000c84- */
43#define PRID_VR4133 0x00000c84
44
45/*
46 * Bus Control Uint
47 */
48extern unsigned long vr41xx_calculate_clock_frequency(void);
49extern unsigned long vr41xx_get_vtclock_frequency(void);
50extern unsigned long vr41xx_get_tclock_frequency(void);
51
52/*
53 * Clock Mask Unit
54 */
55typedef enum {
56 PIU_CLOCK,
57 SIU_CLOCK,
58 AIU_CLOCK,
59 KIU_CLOCK,
60 FIR_CLOCK,
61 DSIU_CLOCK,
62 CSI_CLOCK,
63 PCIU_CLOCK,
64 HSP_CLOCK,
65 PCI_CLOCK,
66 CEU_CLOCK,
67 ETHER0_CLOCK,
68 ETHER1_CLOCK
69} vr41xx_clock_t;
70
71extern void vr41xx_supply_clock(vr41xx_clock_t clock);
72extern void vr41xx_mask_clock(vr41xx_clock_t clock);
73
74/*
75 * Interrupt Control Unit
76 */
77extern int vr41xx_set_intassign(unsigned int irq, unsigned char intassign);
78extern int cascade_irq(unsigned int irq, int (*get_irq)(unsigned int));
79
80#define PIUINT_COMMAND 0x0040
81#define PIUINT_DATA 0x0020
82#define PIUINT_PAGE1 0x0010
83#define PIUINT_PAGE0 0x0008
84#define PIUINT_DATALOST 0x0004
85#define PIUINT_STATUSCHANGE 0x0001
86
87extern void vr41xx_enable_piuint(uint16_t mask);
88extern void vr41xx_disable_piuint(uint16_t mask);
89
90#define AIUINT_INPUT_DMAEND 0x0800
91#define AIUINT_INPUT_DMAHALT 0x0400
92#define AIUINT_INPUT_DATALOST 0x0200
93#define AIUINT_INPUT_DATA 0x0100
94#define AIUINT_OUTPUT_DMAEND 0x0008
95#define AIUINT_OUTPUT_DMAHALT 0x0004
96#define AIUINT_OUTPUT_NODATA 0x0002
97
98extern void vr41xx_enable_aiuint(uint16_t mask);
99extern void vr41xx_disable_aiuint(uint16_t mask);
100
101#define KIUINT_DATALOST 0x0004
102#define KIUINT_DATAREADY 0x0002
103#define KIUINT_SCAN 0x0001
104
105extern void vr41xx_enable_kiuint(uint16_t mask);
106extern void vr41xx_disable_kiuint(uint16_t mask);
107
108#define DSIUINT_CTS 0x0800
109#define DSIUINT_RXERR 0x0400
110#define DSIUINT_RX 0x0200
111#define DSIUINT_TX 0x0100
112#define DSIUINT_ALL 0x0f00
113
114extern void vr41xx_enable_dsiuint(uint16_t mask);
115extern void vr41xx_disable_dsiuint(uint16_t mask);
116
117#define FIRINT_UNIT 0x0010
118#define FIRINT_RX_DMAEND 0x0008
119#define FIRINT_RX_DMAHALT 0x0004
120#define FIRINT_TX_DMAEND 0x0002
121#define FIRINT_TX_DMAHALT 0x0001
122
123extern void vr41xx_enable_firint(uint16_t mask);
124extern void vr41xx_disable_firint(uint16_t mask);
125
126extern void vr41xx_enable_pciint(void);
127extern void vr41xx_disable_pciint(void);
128
129extern void vr41xx_enable_scuint(void);
130extern void vr41xx_disable_scuint(void);
131
132#define CSIINT_TX_DMAEND 0x0040
133#define CSIINT_TX_DMAHALT 0x0020
134#define CSIINT_TX_DATA 0x0010
135#define CSIINT_TX_FIFOEMPTY 0x0008
136#define CSIINT_RX_DMAEND 0x0004
137#define CSIINT_RX_DMAHALT 0x0002
138#define CSIINT_RX_FIFOEMPTY 0x0001
139
140extern void vr41xx_enable_csiint(uint16_t mask);
141extern void vr41xx_disable_csiint(uint16_t mask);
142
143extern void vr41xx_enable_bcuint(void);
144extern void vr41xx_disable_bcuint(void);
145
146#ifdef CONFIG_SERIAL_VR41XX_CONSOLE
147extern void vr41xx_siu_setup(void);
148#else
149static inline void vr41xx_siu_setup(void) {}
150#endif
151
152#endif /* __NEC_VR41XX_H */
diff --git a/arch/mips/include/asm/war.h b/arch/mips/include/asm/war.h
new file mode 100644
index 000000000000..22361d5e3bf0
--- /dev/null
+++ b/arch/mips/include/asm/war.h
@@ -0,0 +1,244 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle
7 * Copyright (C) 2007 Maciej W. Rozycki
8 */
9#ifndef _ASM_WAR_H
10#define _ASM_WAR_H
11
12#include <war.h>
13
14/*
15 * Work around certain R4000 CPU errata (as implemented by GCC):
16 *
17 * - A double-word or a variable shift may give an incorrect result
18 * if executed immediately after starting an integer division:
19 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
20 * erratum #28
21 * "MIPS R4000MC Errata, Processor Revision 2.2 and 3.0", erratum
22 * #19
23 *
24 * - A double-word or a variable shift may give an incorrect result
25 * if executed while an integer multiplication is in progress:
26 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
27 * errata #16 & #28
28 *
29 * - An integer division may give an incorrect result if started in
30 * a delay slot of a taken branch or a jump:
31 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
32 * erratum #52
33 */
34#ifdef CONFIG_CPU_R4000_WORKAROUNDS
35#define R4000_WAR 1
36#else
37#define R4000_WAR 0
38#endif
39
40/*
41 * Work around certain R4400 CPU errata (as implemented by GCC):
42 *
43 * - A double-word or a variable shift may give an incorrect result
44 * if executed immediately after starting an integer division:
45 * "MIPS R4400MC Errata, Processor Revision 1.0", erratum #10
46 * "MIPS R4400MC Errata, Processor Revision 2.0 & 3.0", erratum #4
47 */
48#ifdef CONFIG_CPU_R4400_WORKAROUNDS
49#define R4400_WAR 1
50#else
51#define R4400_WAR 0
52#endif
53
54/*
55 * Work around the "daddi" and "daddiu" CPU errata:
56 *
57 * - The `daddi' instruction fails to trap on overflow.
58 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
59 * erratum #23
60 *
61 * - The `daddiu' instruction can produce an incorrect result.
62 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
63 * erratum #41
64 * "MIPS R4000MC Errata, Processor Revision 2.2 and 3.0", erratum
65 * #15
66 * "MIPS R4400PC/SC Errata, Processor Revision 1.0", erratum #7
67 * "MIPS R4400MC Errata, Processor Revision 1.0", erratum #5
68 */
69#ifdef CONFIG_CPU_DADDI_WORKAROUNDS
70#define DADDI_WAR 1
71#else
72#define DADDI_WAR 0
73#endif
74
75/*
76 * Another R4600 erratum. Due to the lack of errata information the exact
77 * technical details aren't known. I've experimentally found that disabling
78 * interrupts during indexed I-cache flushes seems to be sufficient to deal
79 * with the issue.
80 */
81#ifndef R4600_V1_INDEX_ICACHEOP_WAR
82#error Check setting of R4600_V1_INDEX_ICACHEOP_WAR for your platform
83#endif
84
85/*
86 * Pleasures of the R4600 V1.x. Cite from the IDT R4600 V1.7 errata:
87 *
88 * 18. The CACHE instructions Hit_Writeback_Invalidate_D, Hit_Writeback_D,
89 * Hit_Invalidate_D and Create_Dirty_Excl_D should only be
90 * executed if there is no other dcache activity. If the dcache is
91 * accessed for another instruction immeidately preceding when these
92 * cache instructions are executing, it is possible that the dcache
93 * tag match outputs used by these cache instructions will be
94 * incorrect. These cache instructions should be preceded by at least
95 * four instructions that are not any kind of load or store
96 * instruction.
97 *
98 * This is not allowed: lw
99 * nop
100 * nop
101 * nop
102 * cache Hit_Writeback_Invalidate_D
103 *
104 * This is allowed: lw
105 * nop
106 * nop
107 * nop
108 * nop
109 * cache Hit_Writeback_Invalidate_D
110 */
111#ifndef R4600_V1_HIT_CACHEOP_WAR
112#error Check setting of R4600_V1_HIT_CACHEOP_WAR for your platform
113#endif
114
115
116/*
117 * Writeback and invalidate the primary cache dcache before DMA.
118 *
119 * R4600 v2.0 bug: "The CACHE instructions Hit_Writeback_Inv_D,
120 * Hit_Writeback_D, Hit_Invalidate_D and Create_Dirty_Exclusive_D will only
121 * operate correctly if the internal data cache refill buffer is empty. These
122 * CACHE instructions should be separated from any potential data cache miss
123 * by a load instruction to an uncached address to empty the response buffer."
124 * (Revision 2.0 device errata from IDT available on http://www.idt.com/
125 * in .pdf format.)
126 */
127#ifndef R4600_V2_HIT_CACHEOP_WAR
128#error Check setting of R4600_V2_HIT_CACHEOP_WAR for your platform
129#endif
130
131/*
132 * When an interrupt happens on a CP0 register read instruction, CPU may
133 * lock up or read corrupted values of CP0 registers after it enters
134 * the exception handler.
135 *
136 * This workaround makes sure that we read a "safe" CP0 register as the
137 * first thing in the exception handler, which breaks one of the
138 * pre-conditions for this problem.
139 */
140#ifndef R5432_CP0_INTERRUPT_WAR
141#error Check setting of R5432_CP0_INTERRUPT_WAR for your platform
142#endif
143
144/*
145 * Workaround for the Sibyte M3 errata the text of which can be found at
146 *
147 * http://sibyte.broadcom.com/hw/bcm1250/docs/pass2errata.txt
148 *
149 * This will enable the use of a special TLB refill handler which does a
150 * consistency check on the information in c0_badvaddr and c0_entryhi and
151 * will just return and take the exception again if the information was
152 * found to be inconsistent.
153 */
154#ifndef BCM1250_M3_WAR
155#error Check setting of BCM1250_M3_WAR for your platform
156#endif
157
158/*
159 * This is a DUART workaround related to glitches around register accesses
160 */
161#ifndef SIBYTE_1956_WAR
162#error Check setting of SIBYTE_1956_WAR for your platform
163#endif
164
165/*
166 * Fill buffers not flushed on CACHE instructions
167 *
168 * Hit_Invalidate_I cacheops invalidate an icache line but the refill
169 * for that line can get stale data from the fill buffer instead of
170 * accessing memory if the previous icache miss was also to that line.
171 *
172 * Workaround: generate an icache refill from a different line
173 *
174 * Affects:
175 * MIPS 4K RTL revision <3.0, PRID revision <4
176 */
177#ifndef MIPS4K_ICACHE_REFILL_WAR
178#error Check setting of MIPS4K_ICACHE_REFILL_WAR for your platform
179#endif
180
181/*
182 * Missing implicit forced flush of evictions caused by CACHE
183 * instruction
184 *
185 * Evictions caused by a CACHE instructions are not forced on to the
186 * bus. The BIU gives higher priority to fetches than to the data from
187 * the eviction buffer and no collision detection is performed between
188 * fetches and pending data from the eviction buffer.
189 *
190 * Workaround: Execute a SYNC instruction after the cache instruction
191 *
192 * Affects:
193 * MIPS 5Kc,5Kf RTL revision <2.3, PRID revision <8
194 * MIPS 20Kc RTL revision <4.0, PRID revision <?
195 */
196#ifndef MIPS_CACHE_SYNC_WAR
197#error Check setting of MIPS_CACHE_SYNC_WAR for your platform
198#endif
199
200/*
201 * From TX49/H2 manual: "If the instruction (i.e. CACHE) is issued for
202 * the line which this instruction itself exists, the following
203 * operation is not guaranteed."
204 *
205 * Workaround: do two phase flushing for Index_Invalidate_I
206 */
207#ifndef TX49XX_ICACHE_INDEX_INV_WAR
208#error Check setting of TX49XX_ICACHE_INDEX_INV_WAR for your platform
209#endif
210
211/*
212 * On the RM9000 there is a problem which makes the CreateDirtyExclusive
213 * eache operation unusable on SMP systems.
214 */
215#ifndef RM9000_CDEX_SMP_WAR
216#error Check setting of RM9000_CDEX_SMP_WAR for your platform
217#endif
218
219/*
220 * The RM7000 processors and the E9000 cores have a bug (though PMC-Sierra
221 * opposes it being called that) where invalid instructions in the same
222 * I-cache line worth of instructions being fetched may case spurious
223 * exceptions.
224 */
225#ifndef ICACHE_REFILLS_WORKAROUND_WAR
226#error Check setting of ICACHE_REFILLS_WORKAROUND_WAR for your platform
227#endif
228
229/*
230 * On the R10000 upto version 2.6 (not sure about 2.7) there is a bug that
231 * may cause ll / sc and lld / scd sequences to execute non-atomically.
232 */
233#ifndef R10000_LLSC_WAR
234#error Check setting of R10000_LLSC_WAR for your platform
235#endif
236
237/*
238 * 34K core erratum: "Problems Executing the TLBR Instruction"
239 */
240#ifndef MIPS34K_MISSED_ITLB_WAR
241#error Check setting of MIPS34K_MISSED_ITLB_WAR for your platform
242#endif
243
244#endif /* _ASM_WAR_H */
diff --git a/arch/mips/include/asm/watch.h b/arch/mips/include/asm/watch.h
new file mode 100644
index 000000000000..20126ec79359
--- /dev/null
+++ b/arch/mips/include/asm/watch.h
@@ -0,0 +1,32 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2008 David Daney
7 */
8#ifndef _ASM_WATCH_H
9#define _ASM_WATCH_H
10
11#include <linux/bitops.h>
12
13#include <asm/mipsregs.h>
14
15void mips_install_watch_registers(void);
16void mips_read_watch_registers(void);
17void mips_clear_watch_registers(void);
18void mips_probe_watch_registers(struct cpuinfo_mips *c);
19
20#ifdef CONFIG_HARDWARE_WATCHPOINTS
21#define __restore_watch() do { \
22 if (unlikely(test_bit(TIF_LOAD_WATCH, \
23 &current_thread_info()->flags))) { \
24 mips_install_watch_registers(); \
25 } \
26} while (0)
27
28#else
29#define __restore_watch() do {} while (0)
30#endif
31
32#endif /* _ASM_WATCH_H */
diff --git a/arch/mips/include/asm/wbflush.h b/arch/mips/include/asm/wbflush.h
new file mode 100644
index 000000000000..eadc0ac47e24
--- /dev/null
+++ b/arch/mips/include/asm/wbflush.h
@@ -0,0 +1,34 @@
1/*
2 * Header file for using the wbflush routine
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (c) 1998 Harald Koerfgen
9 * Copyright (C) 2002 Maciej W. Rozycki
10 */
11#ifndef _ASM_WBFLUSH_H
12#define _ASM_WBFLUSH_H
13
14
15#ifdef CONFIG_CPU_HAS_WB
16
17extern void (*__wbflush)(void);
18extern void wbflush_setup(void);
19
20#define wbflush() \
21 do { \
22 __sync(); \
23 __wbflush(); \
24 } while (0)
25
26#else /* !CONFIG_CPU_HAS_WB */
27
28#define wbflush_setup() do { } while (0)
29
30#define wbflush() fast_iob()
31
32#endif /* !CONFIG_CPU_HAS_WB */
33
34#endif /* _ASM_WBFLUSH_H */
diff --git a/arch/mips/include/asm/xor.h b/arch/mips/include/asm/xor.h
new file mode 100644
index 000000000000..c82eb12a5b18
--- /dev/null
+++ b/arch/mips/include/asm/xor.h
@@ -0,0 +1 @@
#include <asm-generic/xor.h>
diff --git a/arch/mips/include/asm/xtalk/xtalk.h b/arch/mips/include/asm/xtalk/xtalk.h
new file mode 100644
index 000000000000..79bac882a739
--- /dev/null
+++ b/arch/mips/include/asm/xtalk/xtalk.h
@@ -0,0 +1,52 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * xtalk.h -- platform-independent crosstalk interface, derived from
7 * IRIX <sys/PCI/bridge.h>, revision 1.38.
8 *
9 * Copyright (C) 1995 - 1997, 1999 Silcon Graphics, Inc.
10 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
11 */
12#ifndef _ASM_XTALK_XTALK_H
13#define _ASM_XTALK_XTALK_H
14
15#ifndef __ASSEMBLY__
16/*
17 * User-level device driver visible types
18 */
19typedef char xwidgetnum_t; /* xtalk widget number (0..15) */
20
21#define XWIDGET_NONE -1
22
23typedef int xwidget_part_num_t; /* xtalk widget part number */
24
25#define XWIDGET_PART_NUM_NONE -1
26
27typedef int xwidget_rev_num_t; /* xtalk widget revision number */
28
29#define XWIDGET_REV_NUM_NONE -1
30
31typedef int xwidget_mfg_num_t; /* xtalk widget manufacturing ID */
32
33#define XWIDGET_MFG_NUM_NONE -1
34
35typedef struct xtalk_piomap_s *xtalk_piomap_t;
36
37/* It is often convenient to fold the XIO target port
38 * number into the XIO address.
39 */
40#define XIO_NOWHERE (0xFFFFFFFFFFFFFFFFull)
41#define XIO_ADDR_BITS (0x0000FFFFFFFFFFFFull)
42#define XIO_PORT_BITS (0xF000000000000000ull)
43#define XIO_PORT_SHIFT (60)
44
45#define XIO_PACKED(x) (((x)&XIO_PORT_BITS) != 0)
46#define XIO_ADDR(x) ((x)&XIO_ADDR_BITS)
47#define XIO_PORT(x) ((xwidgetnum_t)(((x)&XIO_PORT_BITS) >> XIO_PORT_SHIFT))
48#define XIO_PACK(p, o) ((((uint64_t)(p))<<XIO_PORT_SHIFT) | ((o)&XIO_ADDR_BITS))
49
50#endif /* !__ASSEMBLY__ */
51
52#endif /* _ASM_XTALK_XTALK_H */
diff --git a/arch/mips/include/asm/xtalk/xwidget.h b/arch/mips/include/asm/xtalk/xwidget.h
new file mode 100644
index 000000000000..b4a13d7405ee
--- /dev/null
+++ b/arch/mips/include/asm/xtalk/xwidget.h
@@ -0,0 +1,167 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * xwidget.h - generic crosstalk widget header file, derived from IRIX
7 * <sys/xtalk/xtalkwidget.h>, revision 1.32.
8 *
9 * Copyright (C) 1996, 1999 Silcon Graphics, Inc.
10 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
11 */
12#ifndef _ASM_XTALK_XWIDGET_H
13#define _ASM_XTALK_XWIDGET_H
14
15#include <linux/types.h>
16#include <asm/xtalk/xtalk.h>
17
18#define WIDGET_ID 0x04
19#define WIDGET_STATUS 0x0c
20#define WIDGET_ERR_UPPER_ADDR 0x14
21#define WIDGET_ERR_LOWER_ADDR 0x1c
22#define WIDGET_CONTROL 0x24
23#define WIDGET_REQ_TIMEOUT 0x2c
24#define WIDGET_INTDEST_UPPER_ADDR 0x34
25#define WIDGET_INTDEST_LOWER_ADDR 0x3c
26#define WIDGET_ERR_CMD_WORD 0x44
27#define WIDGET_LLP_CFG 0x4c
28#define WIDGET_TFLUSH 0x54
29
30/* WIDGET_ID */
31#define WIDGET_REV_NUM 0xf0000000
32#define WIDGET_PART_NUM 0x0ffff000
33#define WIDGET_MFG_NUM 0x00000ffe
34#define WIDGET_REV_NUM_SHFT 28
35#define WIDGET_PART_NUM_SHFT 12
36#define WIDGET_MFG_NUM_SHFT 1
37
38#define XWIDGET_PART_NUM(widgetid) (((widgetid) & WIDGET_PART_NUM) >> WIDGET_PART_NUM_SHFT)
39#define XWIDGET_REV_NUM(widgetid) (((widgetid) & WIDGET_REV_NUM) >> WIDGET_REV_NUM_SHFT)
40#define XWIDGET_MFG_NUM(widgetid) (((widgetid) & WIDGET_MFG_NUM) >> WIDGET_MFG_NUM_SHFT)
41
42/* WIDGET_STATUS */
43#define WIDGET_LLP_REC_CNT 0xff000000
44#define WIDGET_LLP_TX_CNT 0x00ff0000
45#define WIDGET_PENDING 0x0000001f
46
47/* WIDGET_ERR_UPPER_ADDR */
48#define WIDGET_ERR_UPPER_ADDR_ONLY 0x0000ffff
49
50/* WIDGET_CONTROL */
51#define WIDGET_F_BAD_PKT 0x00010000
52#define WIDGET_LLP_XBAR_CRD 0x0000f000
53#define WIDGET_LLP_XBAR_CRD_SHFT 12
54#define WIDGET_CLR_RLLP_CNT 0x00000800
55#define WIDGET_CLR_TLLP_CNT 0x00000400
56#define WIDGET_SYS_END 0x00000200
57#define WIDGET_MAX_TRANS 0x000001f0
58#define WIDGET_WIDGET_ID 0x0000000f
59
60/* WIDGET_INTDEST_UPPER_ADDR */
61#define WIDGET_INT_VECTOR 0xff000000
62#define WIDGET_INT_VECTOR_SHFT 24
63#define WIDGET_TARGET_ID 0x000f0000
64#define WIDGET_TARGET_ID_SHFT 16
65#define WIDGET_UPP_ADDR 0x0000ffff
66
67/* WIDGET_ERR_CMD_WORD */
68#define WIDGET_DIDN 0xf0000000
69#define WIDGET_SIDN 0x0f000000
70#define WIDGET_PACTYP 0x00f00000
71#define WIDGET_TNUM 0x000f8000
72#define WIDGET_COHERENT 0x00004000
73#define WIDGET_DS 0x00003000
74#define WIDGET_GBR 0x00000800
75#define WIDGET_VBPM 0x00000400
76#define WIDGET_ERROR 0x00000200
77#define WIDGET_BARRIER 0x00000100
78
79/* WIDGET_LLP_CFG */
80#define WIDGET_LLP_MAXRETRY 0x03ff0000
81#define WIDGET_LLP_MAXRETRY_SHFT 16
82#define WIDGET_LLP_NULLTIMEOUT 0x0000fc00
83#define WIDGET_LLP_NULLTIMEOUT_SHFT 10
84#define WIDGET_LLP_MAXBURST 0x000003ff
85#define WIDGET_LLP_MAXBURST_SHFT 0
86
87/*
88 * according to the crosstalk spec, only 32-bits access to the widget
89 * configuration registers is allowed. some widgets may allow 64-bits
90 * access but software should not depend on it. registers beyond the
91 * widget target flush register are widget dependent thus will not be
92 * defined here
93 */
94#ifndef __ASSEMBLY__
95typedef u32 widgetreg_t;
96
97/* widget configuration registers */
98typedef volatile struct widget_cfg {
99 widgetreg_t w_pad_0; /* 0x00 */
100 widgetreg_t w_id; /* 0x04 */
101 widgetreg_t w_pad_1; /* 0x08 */
102 widgetreg_t w_status; /* 0x0c */
103 widgetreg_t w_pad_2; /* 0x10 */
104 widgetreg_t w_err_upper_addr; /* 0x14 */
105 widgetreg_t w_pad_3; /* 0x18 */
106 widgetreg_t w_err_lower_addr; /* 0x1c */
107 widgetreg_t w_pad_4; /* 0x20 */
108 widgetreg_t w_control; /* 0x24 */
109 widgetreg_t w_pad_5; /* 0x28 */
110 widgetreg_t w_req_timeout; /* 0x2c */
111 widgetreg_t w_pad_6; /* 0x30 */
112 widgetreg_t w_intdest_upper_addr; /* 0x34 */
113 widgetreg_t w_pad_7; /* 0x38 */
114 widgetreg_t w_intdest_lower_addr; /* 0x3c */
115 widgetreg_t w_pad_8; /* 0x40 */
116 widgetreg_t w_err_cmd_word; /* 0x44 */
117 widgetreg_t w_pad_9; /* 0x48 */
118 widgetreg_t w_llp_cfg; /* 0x4c */
119 widgetreg_t w_pad_10; /* 0x50 */
120 widgetreg_t w_tflush; /* 0x54 */
121} widget_cfg_t;
122
123typedef struct {
124 unsigned didn:4;
125 unsigned sidn:4;
126 unsigned pactyp:4;
127 unsigned tnum:5;
128 unsigned ct:1;
129 unsigned ds:2;
130 unsigned gbr:1;
131 unsigned vbpm:1;
132 unsigned error:1;
133 unsigned bo:1;
134 unsigned other:8;
135} w_err_cmd_word_f;
136
137typedef union {
138 widgetreg_t r;
139 w_err_cmd_word_f f;
140} w_err_cmd_word_u;
141
142typedef struct xwidget_info_s *xwidget_info_t;
143
144/*
145 * Crosstalk Widget Hardware Identification, as defined in the Crosstalk spec.
146 */
147typedef struct xwidget_hwid_s {
148 xwidget_part_num_t part_num;
149 xwidget_rev_num_t rev_num;
150 xwidget_mfg_num_t mfg_num;
151} *xwidget_hwid_t;
152
153
154/*
155 * Returns 1 if a driver that handles devices described by hwid1 is able
156 * to manage a device with hardwareid hwid2. NOTE: We don't check rev
157 * numbers at all.
158 */
159#define XWIDGET_HARDWARE_ID_MATCH(hwid1, hwid2) \
160 (((hwid1)->part_num == (hwid2)->part_num) && \
161 (((hwid1)->mfg_num == XWIDGET_MFG_NUM_NONE) || \
162 ((hwid2)->mfg_num == XWIDGET_MFG_NUM_NONE) || \
163 ((hwid1)->mfg_num == (hwid2)->mfg_num)))
164
165#endif /* !__ASSEMBLY__ */
166
167#endif /* _ASM_XTALK_XWIDGET_H */
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 706f93974797..d9da7112aaf8 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -6,10 +6,11 @@ extra-y := head.o init_task.o vmlinux.lds
6 6
7obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \ 7obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \
8 ptrace.o reset.o setup.o signal.o syscall.o \ 8 ptrace.o reset.o setup.o signal.o syscall.o \
9 time.o topology.o traps.o unaligned.o 9 time.o topology.o traps.o unaligned.o watch.o
10 10
11obj-$(CONFIG_CEVT_BCM1480) += cevt-bcm1480.o 11obj-$(CONFIG_CEVT_BCM1480) += cevt-bcm1480.o
12obj-$(CONFIG_CEVT_R4K) += cevt-r4k.o 12obj-$(CONFIG_CEVT_R4K) += cevt-r4k.o
13obj-$(CONFIG_MIPS_MT_SMTC) += cevt-smtc.o
13obj-$(CONFIG_CEVT_DS1287) += cevt-ds1287.o 14obj-$(CONFIG_CEVT_DS1287) += cevt-ds1287.o
14obj-$(CONFIG_CEVT_GT641XX) += cevt-gt641xx.o 15obj-$(CONFIG_CEVT_GT641XX) += cevt-gt641xx.o
15obj-$(CONFIG_CEVT_SB1250) += cevt-sb1250.o 16obj-$(CONFIG_CEVT_SB1250) += cevt-sb1250.o
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 24a2d907aa0d..4a4c59f2737a 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -12,6 +12,14 @@
12 12
13#include <asm/smtc_ipi.h> 13#include <asm/smtc_ipi.h>
14#include <asm/time.h> 14#include <asm/time.h>
15#include <asm/cevt-r4k.h>
16
17/*
18 * The SMTC Kernel for the 34K, 1004K, et. al. replaces several
19 * of these routines with SMTC-specific variants.
20 */
21
22#ifndef CONFIG_MIPS_MT_SMTC
15 23
16static int mips_next_event(unsigned long delta, 24static int mips_next_event(unsigned long delta,
17 struct clock_event_device *evt) 25 struct clock_event_device *evt)
@@ -19,60 +27,27 @@ static int mips_next_event(unsigned long delta,
19 unsigned int cnt; 27 unsigned int cnt;
20 int res; 28 int res;
21 29
22#ifdef CONFIG_MIPS_MT_SMTC
23 {
24 unsigned long flags, vpflags;
25 local_irq_save(flags);
26 vpflags = dvpe();
27#endif
28 cnt = read_c0_count(); 30 cnt = read_c0_count();
29 cnt += delta; 31 cnt += delta;
30 write_c0_compare(cnt); 32 write_c0_compare(cnt);
31 res = ((int)(read_c0_count() - cnt) > 0) ? -ETIME : 0; 33 res = ((int)(read_c0_count() - cnt) > 0) ? -ETIME : 0;
32#ifdef CONFIG_MIPS_MT_SMTC
33 evpe(vpflags);
34 local_irq_restore(flags);
35 }
36#endif
37 return res; 34 return res;
38} 35}
39 36
40static void mips_set_mode(enum clock_event_mode mode, 37#endif /* CONFIG_MIPS_MT_SMTC */
41 struct clock_event_device *evt) 38
39void mips_set_clock_mode(enum clock_event_mode mode,
40 struct clock_event_device *evt)
42{ 41{
43 /* Nothing to do ... */ 42 /* Nothing to do ... */
44} 43}
45 44
46static DEFINE_PER_CPU(struct clock_event_device, mips_clockevent_device); 45DEFINE_PER_CPU(struct clock_event_device, mips_clockevent_device);
47static int cp0_timer_irq_installed; 46int cp0_timer_irq_installed;
48 47
49/* 48#ifndef CONFIG_MIPS_MT_SMTC
50 * Timer ack for an R4k-compatible timer of a known frequency.
51 */
52static void c0_timer_ack(void)
53{
54 write_c0_compare(read_c0_compare());
55}
56 49
57/* 50irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
58 * Possibly handle a performance counter interrupt.
59 * Return true if the timer interrupt should not be checked
60 */
61static inline int handle_perf_irq(int r2)
62{
63 /*
64 * The performance counter overflow interrupt may be shared with the
65 * timer interrupt (cp0_perfcount_irq < 0). If it is and a
66 * performance counter has overflowed (perf_irq() == IRQ_HANDLED)
67 * and we can't reliably determine if a counter interrupt has also
68 * happened (!r2) then don't check for a timer interrupt.
69 */
70 return (cp0_perfcount_irq < 0) &&
71 perf_irq() == IRQ_HANDLED &&
72 !r2;
73}
74
75static irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
76{ 51{
77 const int r2 = cpu_has_mips_r2; 52 const int r2 = cpu_has_mips_r2;
78 struct clock_event_device *cd; 53 struct clock_event_device *cd;
@@ -93,12 +68,8 @@ static irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
93 * interrupt. Being the paranoiacs we are we check anyway. 68 * interrupt. Being the paranoiacs we are we check anyway.
94 */ 69 */
95 if (!r2 || (read_c0_cause() & (1 << 30))) { 70 if (!r2 || (read_c0_cause() & (1 << 30))) {
96 c0_timer_ack(); 71 /* Clear Count/Compare Interrupt */
97#ifdef CONFIG_MIPS_MT_SMTC 72 write_c0_compare(read_c0_compare());
98 if (cpu_data[cpu].vpe_id)
99 goto out;
100 cpu = 0;
101#endif
102 cd = &per_cpu(mips_clockevent_device, cpu); 73 cd = &per_cpu(mips_clockevent_device, cpu);
103 cd->event_handler(cd); 74 cd->event_handler(cd);
104 } 75 }
@@ -107,65 +78,16 @@ out:
107 return IRQ_HANDLED; 78 return IRQ_HANDLED;
108} 79}
109 80
110static struct irqaction c0_compare_irqaction = { 81#endif /* Not CONFIG_MIPS_MT_SMTC */
82
83struct irqaction c0_compare_irqaction = {
111 .handler = c0_compare_interrupt, 84 .handler = c0_compare_interrupt,
112#ifdef CONFIG_MIPS_MT_SMTC
113 .flags = IRQF_DISABLED,
114#else
115 .flags = IRQF_DISABLED | IRQF_PERCPU, 85 .flags = IRQF_DISABLED | IRQF_PERCPU,
116#endif
117 .name = "timer", 86 .name = "timer",
118}; 87};
119 88
120#ifdef CONFIG_MIPS_MT_SMTC
121DEFINE_PER_CPU(struct clock_event_device, smtc_dummy_clockevent_device);
122
123static void smtc_set_mode(enum clock_event_mode mode,
124 struct clock_event_device *evt)
125{
126}
127
128static void mips_broadcast(cpumask_t mask)
129{
130 unsigned int cpu;
131
132 for_each_cpu_mask(cpu, mask)
133 smtc_send_ipi(cpu, SMTC_CLOCK_TICK, 0);
134}
135
136static void setup_smtc_dummy_clockevent_device(void)
137{
138 //uint64_t mips_freq = mips_hpt_^frequency;
139 unsigned int cpu = smp_processor_id();
140 struct clock_event_device *cd;
141 89
142 cd = &per_cpu(smtc_dummy_clockevent_device, cpu); 90void mips_event_handler(struct clock_event_device *dev)
143
144 cd->name = "SMTC";
145 cd->features = CLOCK_EVT_FEAT_DUMMY;
146
147 /* Calculate the min / max delta */
148 cd->mult = 0; //div_sc((unsigned long) mips_freq, NSEC_PER_SEC, 32);
149 cd->shift = 0; //32;
150 cd->max_delta_ns = 0; //clockevent_delta2ns(0x7fffffff, cd);
151 cd->min_delta_ns = 0; //clockevent_delta2ns(0x30, cd);
152
153 cd->rating = 200;
154 cd->irq = 17; //-1;
155// if (cpu)
156// cd->cpumask = CPU_MASK_ALL; // cpumask_of_cpu(cpu);
157// else
158 cd->cpumask = cpumask_of_cpu(cpu);
159
160 cd->set_mode = smtc_set_mode;
161
162 cd->broadcast = mips_broadcast;
163
164 clockevents_register_device(cd);
165}
166#endif
167
168static void mips_event_handler(struct clock_event_device *dev)
169{ 91{
170} 92}
171 93
@@ -177,7 +99,23 @@ static int c0_compare_int_pending(void)
177 return (read_c0_cause() >> cp0_compare_irq) & 0x100; 99 return (read_c0_cause() >> cp0_compare_irq) & 0x100;
178} 100}
179 101
180static int c0_compare_int_usable(void) 102/*
103 * Compare interrupt can be routed and latched outside the core,
104 * so a single execution hazard barrier may not be enough to give
105 * it time to clear as seen in the Cause register. 4 time the
106 * pipeline depth seems reasonably conservative, and empirically
107 * works better in configurations with high CPU/bus clock ratios.
108 */
109
110#define compare_change_hazard() \
111 do { \
112 irq_disable_hazard(); \
113 irq_disable_hazard(); \
114 irq_disable_hazard(); \
115 irq_disable_hazard(); \
116 } while (0)
117
118int c0_compare_int_usable(void)
181{ 119{
182 unsigned int delta; 120 unsigned int delta;
183 unsigned int cnt; 121 unsigned int cnt;
@@ -187,7 +125,7 @@ static int c0_compare_int_usable(void)
187 */ 125 */
188 if (c0_compare_int_pending()) { 126 if (c0_compare_int_pending()) {
189 write_c0_compare(read_c0_count()); 127 write_c0_compare(read_c0_count());
190 irq_disable_hazard(); 128 compare_change_hazard();
191 if (c0_compare_int_pending()) 129 if (c0_compare_int_pending())
192 return 0; 130 return 0;
193 } 131 }
@@ -196,7 +134,7 @@ static int c0_compare_int_usable(void)
196 cnt = read_c0_count(); 134 cnt = read_c0_count();
197 cnt += delta; 135 cnt += delta;
198 write_c0_compare(cnt); 136 write_c0_compare(cnt);
199 irq_disable_hazard(); 137 compare_change_hazard();
200 if ((int)(read_c0_count() - cnt) < 0) 138 if ((int)(read_c0_count() - cnt) < 0)
201 break; 139 break;
202 /* increase delta if the timer was already expired */ 140 /* increase delta if the timer was already expired */
@@ -205,11 +143,12 @@ static int c0_compare_int_usable(void)
205 while ((int)(read_c0_count() - cnt) <= 0) 143 while ((int)(read_c0_count() - cnt) <= 0)
206 ; /* Wait for expiry */ 144 ; /* Wait for expiry */
207 145
146 compare_change_hazard();
208 if (!c0_compare_int_pending()) 147 if (!c0_compare_int_pending())
209 return 0; 148 return 0;
210 149
211 write_c0_compare(read_c0_count()); 150 write_c0_compare(read_c0_count());
212 irq_disable_hazard(); 151 compare_change_hazard();
213 if (c0_compare_int_pending()) 152 if (c0_compare_int_pending())
214 return 0; 153 return 0;
215 154
@@ -219,6 +158,8 @@ static int c0_compare_int_usable(void)
219 return 1; 158 return 1;
220} 159}
221 160
161#ifndef CONFIG_MIPS_MT_SMTC
162
222int __cpuinit mips_clockevent_init(void) 163int __cpuinit mips_clockevent_init(void)
223{ 164{
224 uint64_t mips_freq = mips_hpt_frequency; 165 uint64_t mips_freq = mips_hpt_frequency;
@@ -229,17 +170,6 @@ int __cpuinit mips_clockevent_init(void)
229 if (!cpu_has_counter || !mips_hpt_frequency) 170 if (!cpu_has_counter || !mips_hpt_frequency)
230 return -ENXIO; 171 return -ENXIO;
231 172
232#ifdef CONFIG_MIPS_MT_SMTC
233 setup_smtc_dummy_clockevent_device();
234
235 /*
236 * On SMTC we only register VPE0's compare interrupt as clockevent
237 * device.
238 */
239 if (cpu)
240 return 0;
241#endif
242
243 if (!c0_compare_int_usable()) 173 if (!c0_compare_int_usable())
244 return -ENXIO; 174 return -ENXIO;
245 175
@@ -265,13 +195,9 @@ int __cpuinit mips_clockevent_init(void)
265 195
266 cd->rating = 300; 196 cd->rating = 300;
267 cd->irq = irq; 197 cd->irq = irq;
268#ifdef CONFIG_MIPS_MT_SMTC
269 cd->cpumask = CPU_MASK_ALL;
270#else
271 cd->cpumask = cpumask_of_cpu(cpu); 198 cd->cpumask = cpumask_of_cpu(cpu);
272#endif
273 cd->set_next_event = mips_next_event; 199 cd->set_next_event = mips_next_event;
274 cd->set_mode = mips_set_mode; 200 cd->set_mode = mips_set_clock_mode;
275 cd->event_handler = mips_event_handler; 201 cd->event_handler = mips_event_handler;
276 202
277 clockevents_register_device(cd); 203 clockevents_register_device(cd);
@@ -281,12 +207,9 @@ int __cpuinit mips_clockevent_init(void)
281 207
282 cp0_timer_irq_installed = 1; 208 cp0_timer_irq_installed = 1;
283 209
284#ifdef CONFIG_MIPS_MT_SMTC
285#define CPUCTR_IMASKBIT (0x100 << cp0_compare_irq)
286 setup_irq_smtc(irq, &c0_compare_irqaction, CPUCTR_IMASKBIT);
287#else
288 setup_irq(irq, &c0_compare_irqaction); 210 setup_irq(irq, &c0_compare_irqaction);
289#endif
290 211
291 return 0; 212 return 0;
292} 213}
214
215#endif /* Not CONFIG_MIPS_MT_SMTC */
diff --git a/arch/mips/kernel/cevt-smtc.c b/arch/mips/kernel/cevt-smtc.c
new file mode 100644
index 000000000000..5162fe4b5952
--- /dev/null
+++ b/arch/mips/kernel/cevt-smtc.c
@@ -0,0 +1,321 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 MIPS Technologies, Inc.
7 * Copyright (C) 2007 Ralf Baechle <ralf@linux-mips.org>
8 * Copyright (C) 2008 Kevin D. Kissell, Paralogos sarl
9 */
10#include <linux/clockchips.h>
11#include <linux/interrupt.h>
12#include <linux/percpu.h>
13
14#include <asm/smtc_ipi.h>
15#include <asm/time.h>
16#include <asm/cevt-r4k.h>
17
18/*
19 * Variant clock event timer support for SMTC on MIPS 34K, 1004K
20 * or other MIPS MT cores.
21 *
22 * Notes on SMTC Support:
23 *
24 * SMTC has multiple microthread TCs pretending to be Linux CPUs.
25 * But there's only one Count/Compare pair per VPE, and Compare
26 * interrupts are taken opportunisitically by available TCs
27 * bound to the VPE with the Count register. The new timer
28 * framework provides for global broadcasts, but we really
29 * want VPE-level multicasts for best behavior. So instead
30 * of invoking the high-level clock-event broadcast code,
31 * this version of SMTC support uses the historical SMTC
32 * multicast mechanisms "under the hood", appearing to the
33 * generic clock layer as if the interrupts are per-CPU.
34 *
35 * The approach taken here is to maintain a set of NR_CPUS
36 * virtual timers, and track which "CPU" needs to be alerted
37 * at each event.
38 *
39 * It's unlikely that we'll see a MIPS MT core with more than
40 * 2 VPEs, but we *know* that we won't need to handle more
41 * VPEs than we have "CPUs". So NCPUs arrays of NCPUs elements
42 * is always going to be overkill, but always going to be enough.
43 */
44
45unsigned long smtc_nexttime[NR_CPUS][NR_CPUS];
46static int smtc_nextinvpe[NR_CPUS];
47
48/*
49 * Timestamps stored are absolute values to be programmed
50 * into Count register. Valid timestamps will never be zero.
51 * If a Zero Count value is actually calculated, it is converted
52 * to be a 1, which will introduce 1 or two CPU cycles of error
53 * roughly once every four billion events, which at 1000 HZ means
54 * about once every 50 days. If that's actually a problem, one
55 * could alternate squashing 0 to 1 and to -1.
56 */
57
58#define MAKEVALID(x) (((x) == 0L) ? 1L : (x))
59#define ISVALID(x) ((x) != 0L)
60
61/*
62 * Time comparison is subtle, as it's really truncated
63 * modular arithmetic.
64 */
65
66#define IS_SOONER(a, b, reference) \
67 (((a) - (unsigned long)(reference)) < ((b) - (unsigned long)(reference)))
68
69/*
70 * CATCHUP_INCREMENT, used when the function falls behind the counter.
71 * Could be an increasing function instead of a constant;
72 */
73
74#define CATCHUP_INCREMENT 64
75
76static int mips_next_event(unsigned long delta,
77 struct clock_event_device *evt)
78{
79 unsigned long flags;
80 unsigned int mtflags;
81 unsigned long timestamp, reference, previous;
82 unsigned long nextcomp = 0L;
83 int vpe = current_cpu_data.vpe_id;
84 int cpu = smp_processor_id();
85 local_irq_save(flags);
86 mtflags = dmt();
87
88 /*
89 * Maintain the per-TC virtual timer
90 * and program the per-VPE shared Count register
91 * as appropriate here...
92 */
93 reference = (unsigned long)read_c0_count();
94 timestamp = MAKEVALID(reference + delta);
95 /*
96 * To really model the clock, we have to catch the case
97 * where the current next-in-VPE timestamp is the old
98 * timestamp for the calling CPE, but the new value is
99 * in fact later. In that case, we have to do a full
100 * scan and discover the new next-in-VPE CPU id and
101 * timestamp.
102 */
103 previous = smtc_nexttime[vpe][cpu];
104 if (cpu == smtc_nextinvpe[vpe] && ISVALID(previous)
105 && IS_SOONER(previous, timestamp, reference)) {
106 int i;
107 int soonest = cpu;
108
109 /*
110 * Update timestamp array here, so that new
111 * value gets considered along with those of
112 * other virtual CPUs on the VPE.
113 */
114 smtc_nexttime[vpe][cpu] = timestamp;
115 for_each_online_cpu(i) {
116 if (ISVALID(smtc_nexttime[vpe][i])
117 && IS_SOONER(smtc_nexttime[vpe][i],
118 smtc_nexttime[vpe][soonest], reference)) {
119 soonest = i;
120 }
121 }
122 smtc_nextinvpe[vpe] = soonest;
123 nextcomp = smtc_nexttime[vpe][soonest];
124 /*
125 * Otherwise, we don't have to process the whole array rank,
126 * we just have to see if the event horizon has gotten closer.
127 */
128 } else {
129 if (!ISVALID(smtc_nexttime[vpe][smtc_nextinvpe[vpe]]) ||
130 IS_SOONER(timestamp,
131 smtc_nexttime[vpe][smtc_nextinvpe[vpe]], reference)) {
132 smtc_nextinvpe[vpe] = cpu;
133 nextcomp = timestamp;
134 }
135 /*
136 * Since next-in-VPE may me the same as the executing
137 * virtual CPU, we update the array *after* checking
138 * its value.
139 */
140 smtc_nexttime[vpe][cpu] = timestamp;
141 }
142
143 /*
144 * It may be that, in fact, we don't need to update Compare,
145 * but if we do, we want to make sure we didn't fall into
146 * a crack just behind Count.
147 */
148 if (ISVALID(nextcomp)) {
149 write_c0_compare(nextcomp);
150 ehb();
151 /*
152 * We never return an error, we just make sure
153 * that we trigger the handlers as quickly as
154 * we can if we fell behind.
155 */
156 while ((nextcomp - (unsigned long)read_c0_count())
157 > (unsigned long)LONG_MAX) {
158 nextcomp += CATCHUP_INCREMENT;
159 write_c0_compare(nextcomp);
160 ehb();
161 }
162 }
163 emt(mtflags);
164 local_irq_restore(flags);
165 return 0;
166}
167
168
169void smtc_distribute_timer(int vpe)
170{
171 unsigned long flags;
172 unsigned int mtflags;
173 int cpu;
174 struct clock_event_device *cd;
175 unsigned long nextstamp = 0L;
176 unsigned long reference;
177
178
179repeat:
180 for_each_online_cpu(cpu) {
181 /*
182 * Find virtual CPUs within the current VPE who have
183 * unserviced timer requests whose time is now past.
184 */
185 local_irq_save(flags);
186 mtflags = dmt();
187 if (cpu_data[cpu].vpe_id == vpe &&
188 ISVALID(smtc_nexttime[vpe][cpu])) {
189 reference = (unsigned long)read_c0_count();
190 if ((smtc_nexttime[vpe][cpu] - reference)
191 > (unsigned long)LONG_MAX) {
192 smtc_nexttime[vpe][cpu] = 0L;
193 emt(mtflags);
194 local_irq_restore(flags);
195 /*
196 * We don't send IPIs to ourself.
197 */
198 if (cpu != smp_processor_id()) {
199 smtc_send_ipi(cpu, SMTC_CLOCK_TICK, 0);
200 } else {
201 cd = &per_cpu(mips_clockevent_device, cpu);
202 cd->event_handler(cd);
203 }
204 } else {
205 /* Local to VPE but Valid Time not yet reached. */
206 if (!ISVALID(nextstamp) ||
207 IS_SOONER(smtc_nexttime[vpe][cpu], nextstamp,
208 reference)) {
209 smtc_nextinvpe[vpe] = cpu;
210 nextstamp = smtc_nexttime[vpe][cpu];
211 }
212 emt(mtflags);
213 local_irq_restore(flags);
214 }
215 } else {
216 emt(mtflags);
217 local_irq_restore(flags);
218
219 }
220 }
221 /* Reprogram for interrupt at next soonest timestamp for VPE */
222 if (ISVALID(nextstamp)) {
223 write_c0_compare(nextstamp);
224 ehb();
225 if ((nextstamp - (unsigned long)read_c0_count())
226 > (unsigned long)LONG_MAX)
227 goto repeat;
228 }
229}
230
231
232irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
233{
234 int cpu = smp_processor_id();
235
236 /* If we're running SMTC, we've got MIPS MT and therefore MIPS32R2 */
237 handle_perf_irq(1);
238
239 if (read_c0_cause() & (1 << 30)) {
240 /* Clear Count/Compare Interrupt */
241 write_c0_compare(read_c0_compare());
242 smtc_distribute_timer(cpu_data[cpu].vpe_id);
243 }
244 return IRQ_HANDLED;
245}
246
247
248int __cpuinit mips_clockevent_init(void)
249{
250 uint64_t mips_freq = mips_hpt_frequency;
251 unsigned int cpu = smp_processor_id();
252 struct clock_event_device *cd;
253 unsigned int irq;
254 int i;
255 int j;
256
257 if (!cpu_has_counter || !mips_hpt_frequency)
258 return -ENXIO;
259 if (cpu == 0) {
260 for (i = 0; i < num_possible_cpus(); i++) {
261 smtc_nextinvpe[i] = 0;
262 for (j = 0; j < num_possible_cpus(); j++)
263 smtc_nexttime[i][j] = 0L;
264 }
265 /*
266 * SMTC also can't have the usablility test
267 * run by secondary TCs once Compare is in use.
268 */
269 if (!c0_compare_int_usable())
270 return -ENXIO;
271 }
272
273 /*
274 * With vectored interrupts things are getting platform specific.
275 * get_c0_compare_int is a hook to allow a platform to return the
276 * interrupt number of it's liking.
277 */
278 irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq;
279 if (get_c0_compare_int)
280 irq = get_c0_compare_int();
281
282 cd = &per_cpu(mips_clockevent_device, cpu);
283
284 cd->name = "MIPS";
285 cd->features = CLOCK_EVT_FEAT_ONESHOT;
286
287 /* Calculate the min / max delta */
288 cd->mult = div_sc((unsigned long) mips_freq, NSEC_PER_SEC, 32);
289 cd->shift = 32;
290 cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd);
291 cd->min_delta_ns = clockevent_delta2ns(0x300, cd);
292
293 cd->rating = 300;
294 cd->irq = irq;
295 cd->cpumask = cpumask_of_cpu(cpu);
296 cd->set_next_event = mips_next_event;
297 cd->set_mode = mips_set_clock_mode;
298 cd->event_handler = mips_event_handler;
299
300 clockevents_register_device(cd);
301
302 /*
303 * On SMTC we only want to do the data structure
304 * initialization and IRQ setup once.
305 */
306 if (cpu)
307 return 0;
308 /*
309 * And we need the hwmask associated with the c0_compare
310 * vector to be initialized.
311 */
312 irq_hwmask[irq] = (0x100 << cp0_compare_irq);
313 if (cp0_timer_irq_installed)
314 return 0;
315
316 cp0_timer_irq_installed = 1;
317
318 setup_irq(irq, &c0_compare_irqaction);
319
320 return 0;
321}
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 11c92dc53791..0cf15457ecac 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -21,6 +21,7 @@
21#include <asm/fpu.h> 21#include <asm/fpu.h>
22#include <asm/mipsregs.h> 22#include <asm/mipsregs.h>
23#include <asm/system.h> 23#include <asm/system.h>
24#include <asm/watch.h>
24 25
25/* 26/*
26 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover, 27 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
@@ -54,14 +55,18 @@ extern void r4k_wait(void);
54 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes 55 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
55 * using this version a gamble. 56 * using this version a gamble.
56 */ 57 */
57static void r4k_wait_irqoff(void) 58void r4k_wait_irqoff(void)
58{ 59{
59 local_irq_disable(); 60 local_irq_disable();
60 if (!need_resched()) 61 if (!need_resched())
61 __asm__(" .set mips3 \n" 62 __asm__(" .set push \n"
63 " .set mips3 \n"
62 " wait \n" 64 " wait \n"
63 " .set mips0 \n"); 65 " .set pop \n");
64 local_irq_enable(); 66 local_irq_enable();
67 __asm__(" .globl __pastwait \n"
68 "__pastwait: \n");
69 return;
65} 70}
66 71
67/* 72/*
@@ -673,6 +678,7 @@ static inline void spram_config(void) {}
673static inline void cpu_probe_mips(struct cpuinfo_mips *c) 678static inline void cpu_probe_mips(struct cpuinfo_mips *c)
674{ 679{
675 decode_configs(c); 680 decode_configs(c);
681 mips_probe_watch_registers(c);
676 switch (c->processor_id & 0xff00) { 682 switch (c->processor_id & 0xff00) {
677 case PRID_IMP_4KC: 683 case PRID_IMP_4KC:
678 c->cputype = CPU_4KC; 684 c->cputype = CPU_4KC;
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index e29598ae939d..ffa331029e08 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -79,11 +79,6 @@ FEXPORT(syscall_exit)
79 79
80FEXPORT(restore_all) # restore full frame 80FEXPORT(restore_all) # restore full frame
81#ifdef CONFIG_MIPS_MT_SMTC 81#ifdef CONFIG_MIPS_MT_SMTC
82/* Detect and execute deferred IPI "interrupts" */
83 LONG_L s0, TI_REGS($28)
84 LONG_S sp, TI_REGS($28)
85 jal deferred_smtc_ipi
86 LONG_S s0, TI_REGS($28)
87#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP 82#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
88/* Re-arm any temporarily masked interrupts not explicitly "acked" */ 83/* Re-arm any temporarily masked interrupts not explicitly "acked" */
89 mfc0 v0, CP0_TCSTATUS 84 mfc0 v0, CP0_TCSTATUS
@@ -112,6 +107,11 @@ FEXPORT(restore_all) # restore full frame
112 xor t0, t0, t3 107 xor t0, t0, t3
113 mtc0 t0, CP0_TCCONTEXT 108 mtc0 t0, CP0_TCCONTEXT
114#endif /* CONFIG_MIPS_MT_SMTC_IM_BACKSTOP */ 109#endif /* CONFIG_MIPS_MT_SMTC_IM_BACKSTOP */
110/* Detect and execute deferred IPI "interrupts" */
111 LONG_L s0, TI_REGS($28)
112 LONG_S sp, TI_REGS($28)
113 jal deferred_smtc_ipi
114 LONG_S s0, TI_REGS($28)
115#endif /* CONFIG_MIPS_MT_SMTC */ 115#endif /* CONFIG_MIPS_MT_SMTC */
116 .set noat 116 .set noat
117 RESTORE_TEMP 117 RESTORE_TEMP
diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
index f886dd7f708e..757d48f0d80f 100644
--- a/arch/mips/kernel/genex.S
+++ b/arch/mips/kernel/genex.S
@@ -282,8 +282,8 @@ NESTED(except_vec_vi_handler, 0, sp)
282 and t0, a0, t1 282 and t0, a0, t1
283#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP 283#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
284 mfc0 t2, CP0_TCCONTEXT 284 mfc0 t2, CP0_TCCONTEXT
285 or t0, t0, t2 285 or t2, t0, t2
286 mtc0 t0, CP0_TCCONTEXT 286 mtc0 t2, CP0_TCCONTEXT
287#endif /* CONFIG_MIPS_MT_SMTC_IM_BACKSTOP */ 287#endif /* CONFIG_MIPS_MT_SMTC_IM_BACKSTOP */
288 xor t1, t1, t0 288 xor t1, t1, t0
289 mtc0 t1, CP0_STATUS 289 mtc0 t1, CP0_STATUS
@@ -453,7 +453,11 @@ NESTED(nmi_handler, PT_SIZE, sp)
453 BUILD_HANDLER tr tr sti silent /* #13 */ 453 BUILD_HANDLER tr tr sti silent /* #13 */
454 BUILD_HANDLER fpe fpe fpe silent /* #15 */ 454 BUILD_HANDLER fpe fpe fpe silent /* #15 */
455 BUILD_HANDLER mdmx mdmx sti silent /* #22 */ 455 BUILD_HANDLER mdmx mdmx sti silent /* #22 */
456#ifdef CONFIG_HARDWARE_WATCHPOINTS
457 BUILD_HANDLER watch watch sti silent /* #23 */
458#else
456 BUILD_HANDLER watch watch sti verbose /* #23 */ 459 BUILD_HANDLER watch watch sti verbose /* #23 */
460#endif
457 BUILD_HANDLER mcheck mcheck cli verbose /* #24 */ 461 BUILD_HANDLER mcheck mcheck cli verbose /* #24 */
458 BUILD_HANDLER mt mt sti silent /* #25 */ 462 BUILD_HANDLER mt mt sti silent /* #25 */
459 BUILD_HANDLER dsp dsp sti silent /* #26 */ 463 BUILD_HANDLER dsp dsp sti silent /* #26 */
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 361364501d34..492a0a8d70fb 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -22,6 +22,7 @@
22#include <asm/irqflags.h> 22#include <asm/irqflags.h>
23#include <asm/regdef.h> 23#include <asm/regdef.h>
24#include <asm/page.h> 24#include <asm/page.h>
25#include <asm/pgtable-bits.h>
25#include <asm/mipsregs.h> 26#include <asm/mipsregs.h>
26#include <asm/stackframe.h> 27#include <asm/stackframe.h>
27 28
diff --git a/arch/mips/kernel/mips-mt-fpaff.c b/arch/mips/kernel/mips-mt-fpaff.c
index df4d3f2f740c..dc9eb72ed9de 100644
--- a/arch/mips/kernel/mips-mt-fpaff.c
+++ b/arch/mips/kernel/mips-mt-fpaff.c
@@ -159,7 +159,7 @@ __setup("fpaff=", fpaff_thresh);
159/* 159/*
160 * FPU Use Factor empirically derived from experiments on 34K 160 * FPU Use Factor empirically derived from experiments on 34K
161 */ 161 */
162#define FPUSEFACTOR 333 162#define FPUSEFACTOR 2000
163 163
164static __init int mt_fp_affinity_init(void) 164static __init int mt_fp_affinity_init(void)
165{ 165{
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
index 36f065398243..75bb1300dd7a 100644
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -23,6 +23,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
23 unsigned int version = cpu_data[n].processor_id; 23 unsigned int version = cpu_data[n].processor_id;
24 unsigned int fp_vers = cpu_data[n].fpu_id; 24 unsigned int fp_vers = cpu_data[n].fpu_id;
25 char fmt [64]; 25 char fmt [64];
26 int i;
26 27
27#ifdef CONFIG_SMP 28#ifdef CONFIG_SMP
28 if (!cpu_isset(n, cpu_online_map)) 29 if (!cpu_isset(n, cpu_online_map))
@@ -50,8 +51,16 @@ static int show_cpuinfo(struct seq_file *m, void *v)
50 seq_printf(m, "tlb_entries\t\t: %d\n", cpu_data[n].tlbsize); 51 seq_printf(m, "tlb_entries\t\t: %d\n", cpu_data[n].tlbsize);
51 seq_printf(m, "extra interrupt vector\t: %s\n", 52 seq_printf(m, "extra interrupt vector\t: %s\n",
52 cpu_has_divec ? "yes" : "no"); 53 cpu_has_divec ? "yes" : "no");
53 seq_printf(m, "hardware watchpoint\t: %s\n", 54 seq_printf(m, "hardware watchpoint\t: %s",
54 cpu_has_watch ? "yes" : "no"); 55 cpu_has_watch ? "yes, " : "no\n");
56 if (cpu_has_watch) {
57 seq_printf(m, "count: %d, address/irw mask: [",
58 cpu_data[n].watch_reg_count);
59 for (i = 0; i < cpu_data[n].watch_reg_count; i++)
60 seq_printf(m, "%s0x%04x", i ? ", " : "" ,
61 cpu_data[n].watch_reg_masks[i]);
62 seq_printf(m, "]\n");
63 }
55 seq_printf(m, "ASEs implemented\t:%s%s%s%s%s%s\n", 64 seq_printf(m, "ASEs implemented\t:%s%s%s%s%s%s\n",
56 cpu_has_mips16 ? " mips16" : "", 65 cpu_has_mips16 ? " mips16" : "",
57 cpu_has_mdmx ? " mdmx" : "", 66 cpu_has_mdmx ? " mdmx" : "",
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index ce7684335a41..22fc19bbe87f 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -55,7 +55,7 @@ void __noreturn cpu_idle(void)
55 while (1) { 55 while (1) {
56 tick_nohz_stop_sched_tick(1); 56 tick_nohz_stop_sched_tick(1);
57 while (!need_resched()) { 57 while (!need_resched()) {
58#ifdef CONFIG_SMTC_IDLE_HOOK_DEBUG 58#ifdef CONFIG_MIPS_MT_SMTC
59 extern void smtc_idle_loop_hook(void); 59 extern void smtc_idle_loop_hook(void);
60 60
61 smtc_idle_loop_hook(); 61 smtc_idle_loop_hook();
@@ -145,19 +145,18 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
145 */ 145 */
146 p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1); 146 p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1);
147 childregs->cp0_status &= ~(ST0_CU2|ST0_CU1); 147 childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);
148
149#ifdef CONFIG_MIPS_MT_SMTC
150 /*
151 * SMTC restores TCStatus after Status, and the CU bits
152 * are aliased there.
153 */
154 childregs->cp0_tcstatus &= ~(ST0_CU2|ST0_CU1);
155#endif
148 clear_tsk_thread_flag(p, TIF_USEDFPU); 156 clear_tsk_thread_flag(p, TIF_USEDFPU);
149 157
150#ifdef CONFIG_MIPS_MT_FPAFF 158#ifdef CONFIG_MIPS_MT_FPAFF
151 clear_tsk_thread_flag(p, TIF_FPUBOUND); 159 clear_tsk_thread_flag(p, TIF_FPUBOUND);
152
153 /*
154 * FPU affinity support is cleaner if we track the
155 * user-visible CPU affinity from the very beginning.
156 * The generic cpus_allowed mask will already have
157 * been copied from the parent before copy_thread
158 * is invoked.
159 */
160 p->thread.user_cpus_allowed = p->cpus_allowed;
161#endif /* CONFIG_MIPS_MT_FPAFF */ 160#endif /* CONFIG_MIPS_MT_FPAFF */
162 161
163 if (clone_flags & CLONE_SETTLS) 162 if (clone_flags & CLONE_SETTLS)
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 35234b92b9a5..054861ccb4dd 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -46,7 +46,8 @@
46 */ 46 */
47void ptrace_disable(struct task_struct *child) 47void ptrace_disable(struct task_struct *child)
48{ 48{
49 /* Nothing to do.. */ 49 /* Don't load the watchpoint registers for the ex-child. */
50 clear_tsk_thread_flag(child, TIF_LOAD_WATCH);
50} 51}
51 52
52/* 53/*
@@ -167,6 +168,93 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data)
167 return 0; 168 return 0;
168} 169}
169 170
171int ptrace_get_watch_regs(struct task_struct *child,
172 struct pt_watch_regs __user *addr)
173{
174 enum pt_watch_style style;
175 int i;
176
177 if (!cpu_has_watch || current_cpu_data.watch_reg_use_cnt == 0)
178 return -EIO;
179 if (!access_ok(VERIFY_WRITE, addr, sizeof(struct pt_watch_regs)))
180 return -EIO;
181
182#ifdef CONFIG_32BIT
183 style = pt_watch_style_mips32;
184#define WATCH_STYLE mips32
185#else
186 style = pt_watch_style_mips64;
187#define WATCH_STYLE mips64
188#endif
189
190 __put_user(style, &addr->style);
191 __put_user(current_cpu_data.watch_reg_use_cnt,
192 &addr->WATCH_STYLE.num_valid);
193 for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
194 __put_user(child->thread.watch.mips3264.watchlo[i],
195 &addr->WATCH_STYLE.watchlo[i]);
196 __put_user(child->thread.watch.mips3264.watchhi[i] & 0xfff,
197 &addr->WATCH_STYLE.watchhi[i]);
198 __put_user(current_cpu_data.watch_reg_masks[i],
199 &addr->WATCH_STYLE.watch_masks[i]);
200 }
201 for (; i < 8; i++) {
202 __put_user(0, &addr->WATCH_STYLE.watchlo[i]);
203 __put_user(0, &addr->WATCH_STYLE.watchhi[i]);
204 __put_user(0, &addr->WATCH_STYLE.watch_masks[i]);
205 }
206
207 return 0;
208}
209
210int ptrace_set_watch_regs(struct task_struct *child,
211 struct pt_watch_regs __user *addr)
212{
213 int i;
214 int watch_active = 0;
215 unsigned long lt[NUM_WATCH_REGS];
216 u16 ht[NUM_WATCH_REGS];
217
218 if (!cpu_has_watch || current_cpu_data.watch_reg_use_cnt == 0)
219 return -EIO;
220 if (!access_ok(VERIFY_READ, addr, sizeof(struct pt_watch_regs)))
221 return -EIO;
222 /* Check the values. */
223 for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
224 __get_user(lt[i], &addr->WATCH_STYLE.watchlo[i]);
225#ifdef CONFIG_32BIT
226 if (lt[i] & __UA_LIMIT)
227 return -EINVAL;
228#else
229 if (test_tsk_thread_flag(child, TIF_32BIT_ADDR)) {
230 if (lt[i] & 0xffffffff80000000UL)
231 return -EINVAL;
232 } else {
233 if (lt[i] & __UA_LIMIT)
234 return -EINVAL;
235 }
236#endif
237 __get_user(ht[i], &addr->WATCH_STYLE.watchhi[i]);
238 if (ht[i] & ~0xff8)
239 return -EINVAL;
240 }
241 /* Install them. */
242 for (i = 0; i < current_cpu_data.watch_reg_use_cnt; i++) {
243 if (lt[i] & 7)
244 watch_active = 1;
245 child->thread.watch.mips3264.watchlo[i] = lt[i];
246 /* Set the G bit. */
247 child->thread.watch.mips3264.watchhi[i] = ht[i];
248 }
249
250 if (watch_active)
251 set_tsk_thread_flag(child, TIF_LOAD_WATCH);
252 else
253 clear_tsk_thread_flag(child, TIF_LOAD_WATCH);
254
255 return 0;
256}
257
170long arch_ptrace(struct task_struct *child, long request, long addr, long data) 258long arch_ptrace(struct task_struct *child, long request, long addr, long data)
171{ 259{
172 int ret; 260 int ret;
@@ -238,7 +326,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
238 case FPC_EIR: { /* implementation / version register */ 326 case FPC_EIR: { /* implementation / version register */
239 unsigned int flags; 327 unsigned int flags;
240#ifdef CONFIG_MIPS_MT_SMTC 328#ifdef CONFIG_MIPS_MT_SMTC
241 unsigned int irqflags; 329 unsigned long irqflags;
242 unsigned int mtflags; 330 unsigned int mtflags;
243#endif /* CONFIG_MIPS_MT_SMTC */ 331#endif /* CONFIG_MIPS_MT_SMTC */
244 332
@@ -440,6 +528,16 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
440 (unsigned long __user *) data); 528 (unsigned long __user *) data);
441 break; 529 break;
442 530
531 case PTRACE_GET_WATCH_REGS:
532 ret = ptrace_get_watch_regs(child,
533 (struct pt_watch_regs __user *) addr);
534 break;
535
536 case PTRACE_SET_WATCH_REGS:
537 ret = ptrace_set_watch_regs(child,
538 (struct pt_watch_regs __user *) addr);
539 break;
540
443 default: 541 default:
444 ret = ptrace_request(child, request, addr, data); 542 ret = ptrace_request(child, request, addr, data);
445 break; 543 break;
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
index 76818be6ba7c..1ca34104e593 100644
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -15,6 +15,7 @@
15 * binaries. 15 * binaries.
16 */ 16 */
17#include <linux/compiler.h> 17#include <linux/compiler.h>
18#include <linux/compat.h>
18#include <linux/kernel.h> 19#include <linux/kernel.h>
19#include <linux/sched.h> 20#include <linux/sched.h>
20#include <linux/mm.h> 21#include <linux/mm.h>
@@ -36,47 +37,17 @@
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
37#include <asm/bootinfo.h> 38#include <asm/bootinfo.h>
38 39
39int ptrace_getregs(struct task_struct *child, __s64 __user *data);
40int ptrace_setregs(struct task_struct *child, __s64 __user *data);
41
42int ptrace_getfpregs(struct task_struct *child, __u32 __user *data);
43int ptrace_setfpregs(struct task_struct *child, __u32 __user *data);
44
45/* 40/*
46 * Tracing a 32-bit process with a 64-bit strace and vice versa will not 41 * Tracing a 32-bit process with a 64-bit strace and vice versa will not
47 * work. I don't know how to fix this. 42 * work. I don't know how to fix this.
48 */ 43 */
49asmlinkage int sys32_ptrace(int request, int pid, int addr, int data) 44long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
45 compat_ulong_t caddr, compat_ulong_t cdata)
50{ 46{
51 struct task_struct *child; 47 int addr = caddr;
48 int data = cdata;
52 int ret; 49 int ret;
53 50
54#if 0
55 printk("ptrace(r=%d,pid=%d,addr=%08lx,data=%08lx)\n",
56 (int) request, (int) pid, (unsigned long) addr,
57 (unsigned long) data);
58#endif
59 lock_kernel();
60 if (request == PTRACE_TRACEME) {
61 ret = ptrace_traceme();
62 goto out;
63 }
64
65 child = ptrace_get_task_struct(pid);
66 if (IS_ERR(child)) {
67 ret = PTR_ERR(child);
68 goto out;
69 }
70
71 if (request == PTRACE_ATTACH) {
72 ret = ptrace_attach(child);
73 goto out_tsk;
74 }
75
76 ret = ptrace_check_attach(child, request == PTRACE_KILL);
77 if (ret < 0)
78 goto out_tsk;
79
80 switch (request) { 51 switch (request) {
81 /* when I and D space are separate, these will need to be fixed. */ 52 /* when I and D space are separate, these will need to be fixed. */
82 case PTRACE_PEEKTEXT: /* read word at location addr. */ 53 case PTRACE_PEEKTEXT: /* read word at location addr. */
@@ -214,7 +185,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
214 if (!cpu_has_dsp) { 185 if (!cpu_has_dsp) {
215 tmp = 0; 186 tmp = 0;
216 ret = -EIO; 187 ret = -EIO;
217 goto out_tsk; 188 goto out;
218 } 189 }
219 dregs = __get_dsp_regs(child); 190 dregs = __get_dsp_regs(child);
220 tmp = (unsigned long) (dregs[addr - DSP_BASE]); 191 tmp = (unsigned long) (dregs[addr - DSP_BASE]);
@@ -224,14 +195,14 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
224 if (!cpu_has_dsp) { 195 if (!cpu_has_dsp) {
225 tmp = 0; 196 tmp = 0;
226 ret = -EIO; 197 ret = -EIO;
227 goto out_tsk; 198 goto out;
228 } 199 }
229 tmp = child->thread.dsp.dspcontrol; 200 tmp = child->thread.dsp.dspcontrol;
230 break; 201 break;
231 default: 202 default:
232 tmp = 0; 203 tmp = 0;
233 ret = -EIO; 204 ret = -EIO;
234 goto out_tsk; 205 goto out;
235 } 206 }
236 ret = put_user(tmp, (unsigned __user *) (unsigned long) data); 207 ret = put_user(tmp, (unsigned __user *) (unsigned long) data);
237 break; 208 break;
@@ -410,14 +381,20 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
410 (unsigned long __user *) (unsigned long) data); 381 (unsigned long __user *) (unsigned long) data);
411 break; 382 break;
412 383
384 case PTRACE_GET_WATCH_REGS:
385 ret = ptrace_get_watch_regs(child,
386 (struct pt_watch_regs __user *) (unsigned long) addr);
387 break;
388
389 case PTRACE_SET_WATCH_REGS:
390 ret = ptrace_set_watch_regs(child,
391 (struct pt_watch_regs __user *) (unsigned long) addr);
392 break;
393
413 default: 394 default:
414 ret = ptrace_request(child, request, addr, data); 395 ret = ptrace_request(child, request, addr, data);
415 break; 396 break;
416 } 397 }
417
418out_tsk:
419 put_task_struct(child);
420out: 398out:
421 unlock_kernel();
422 return ret; 399 return ret;
423} 400}
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index da7f1b6ea0fb..324c5499dec2 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -219,7 +219,7 @@ EXPORT(sysn32_call_table)
219 PTR compat_sys_getrusage 219 PTR compat_sys_getrusage
220 PTR compat_sys_sysinfo 220 PTR compat_sys_sysinfo
221 PTR compat_sys_times 221 PTR compat_sys_times
222 PTR sys32_ptrace 222 PTR compat_sys_ptrace
223 PTR sys_getuid /* 6100 */ 223 PTR sys_getuid /* 6100 */
224 PTR sys_syslog 224 PTR sys_syslog
225 PTR sys_getgid 225 PTR sys_getgid
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index d7cd1aac9ada..85fedac99a57 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -231,7 +231,7 @@ sys_call_table:
231 PTR sys_setuid 231 PTR sys_setuid
232 PTR sys_getuid 232 PTR sys_getuid
233 PTR compat_sys_stime /* 4025 */ 233 PTR compat_sys_stime /* 4025 */
234 PTR sys32_ptrace 234 PTR compat_sys_ptrace
235 PTR sys_alarm 235 PTR sys_alarm
236 PTR sys_ni_syscall /* was sys_fstat */ 236 PTR sys_ni_syscall /* was sys_fstat */
237 PTR sys_pause 237 PTR sys_pause
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index 572c610db1b1..652709b353ad 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -482,6 +482,18 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
482 return err; 482 return err;
483} 483}
484 484
485int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
486{
487 memset(to, 0, sizeof *to);
488
489 if (copy_from_user(to, from, 3*sizeof(int)) ||
490 copy_from_user(to->_sifields._pad,
491 from->_sifields._pad, SI_PAD_SIZE32))
492 return -EFAULT;
493
494 return 0;
495}
496
485asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs) 497asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
486{ 498{
487 struct sigframe32 __user *frame; 499 struct sigframe32 __user *frame;
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 4410f172b8ab..7b59cfb7e602 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -121,6 +121,8 @@ asmlinkage __cpuinit void start_secondary(void)
121 cpu = smp_processor_id(); 121 cpu = smp_processor_id();
122 cpu_data[cpu].udelay_val = loops_per_jiffy; 122 cpu_data[cpu].udelay_val = loops_per_jiffy;
123 123
124 notify_cpu_starting(cpu);
125
124 mp_ops->smp_finish(); 126 mp_ops->smp_finish();
125 set_cpu_sibling_map(cpu); 127 set_cpu_sibling_map(cpu);
126 128
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index a516286532ab..897fb2b4751c 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -1,4 +1,21 @@
1/* Copyright (C) 2004 Mips Technologies, Inc */ 1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) 2004 Mips Technologies, Inc
17 * Copyright (C) 2008 Kevin D. Kissell
18 */
2 19
3#include <linux/clockchips.h> 20#include <linux/clockchips.h>
4#include <linux/kernel.h> 21#include <linux/kernel.h>
@@ -21,7 +38,6 @@
21#include <asm/time.h> 38#include <asm/time.h>
22#include <asm/addrspace.h> 39#include <asm/addrspace.h>
23#include <asm/smtc.h> 40#include <asm/smtc.h>
24#include <asm/smtc_ipi.h>
25#include <asm/smtc_proc.h> 41#include <asm/smtc_proc.h>
26 42
27/* 43/*
@@ -58,11 +74,6 @@ unsigned long irq_hwmask[NR_IRQS];
58 74
59asiduse smtc_live_asid[MAX_SMTC_TLBS][MAX_SMTC_ASIDS]; 75asiduse smtc_live_asid[MAX_SMTC_TLBS][MAX_SMTC_ASIDS];
60 76
61/*
62 * Clock interrupt "latch" buffers, per "CPU"
63 */
64
65static atomic_t ipi_timer_latch[NR_CPUS];
66 77
67/* 78/*
68 * Number of InterProcessor Interrupt (IPI) message buffers to allocate 79 * Number of InterProcessor Interrupt (IPI) message buffers to allocate
@@ -70,7 +81,7 @@ static atomic_t ipi_timer_latch[NR_CPUS];
70 81
71#define IPIBUF_PER_CPU 4 82#define IPIBUF_PER_CPU 4
72 83
73static struct smtc_ipi_q IPIQ[NR_CPUS]; 84struct smtc_ipi_q IPIQ[NR_CPUS];
74static struct smtc_ipi_q freeIPIq; 85static struct smtc_ipi_q freeIPIq;
75 86
76 87
@@ -282,7 +293,7 @@ static void smtc_configure_tlb(void)
282 * phys_cpu_present_map and the logical/physical mappings. 293 * phys_cpu_present_map and the logical/physical mappings.
283 */ 294 */
284 295
285int __init mipsmt_build_cpu_map(int start_cpu_slot) 296int __init smtc_build_cpu_map(int start_cpu_slot)
286{ 297{
287 int i, ntcs; 298 int i, ntcs;
288 299
@@ -325,7 +336,12 @@ static void smtc_tc_setup(int vpe, int tc, int cpu)
325 write_tc_c0_tcstatus((read_tc_c0_tcstatus() 336 write_tc_c0_tcstatus((read_tc_c0_tcstatus()
326 & ~(TCSTATUS_TKSU | TCSTATUS_DA | TCSTATUS_IXMT)) 337 & ~(TCSTATUS_TKSU | TCSTATUS_DA | TCSTATUS_IXMT))
327 | TCSTATUS_A); 338 | TCSTATUS_A);
328 write_tc_c0_tccontext(0); 339 /*
340 * TCContext gets an offset from the base of the IPIQ array
341 * to be used in low-level code to detect the presence of
342 * an active IPI queue
343 */
344 write_tc_c0_tccontext((sizeof(struct smtc_ipi_q) * cpu) << 16);
329 /* Bind tc to vpe */ 345 /* Bind tc to vpe */
330 write_tc_c0_tcbind(vpe); 346 write_tc_c0_tcbind(vpe);
331 /* In general, all TCs should have the same cpu_data indications */ 347 /* In general, all TCs should have the same cpu_data indications */
@@ -336,10 +352,18 @@ static void smtc_tc_setup(int vpe, int tc, int cpu)
336 cpu_data[cpu].options &= ~MIPS_CPU_FPU; 352 cpu_data[cpu].options &= ~MIPS_CPU_FPU;
337 cpu_data[cpu].vpe_id = vpe; 353 cpu_data[cpu].vpe_id = vpe;
338 cpu_data[cpu].tc_id = tc; 354 cpu_data[cpu].tc_id = tc;
355 /* Multi-core SMTC hasn't been tested, but be prepared */
356 cpu_data[cpu].core = (read_vpe_c0_ebase() >> 1) & 0xff;
339} 357}
340 358
359/*
360 * Tweak to get Count registes in as close a sync as possible.
361 * Value seems good for 34K-class cores.
362 */
363
364#define CP0_SKEW 8
341 365
342void mipsmt_prepare_cpus(void) 366void smtc_prepare_cpus(int cpus)
343{ 367{
344 int i, vpe, tc, ntc, nvpe, tcpervpe[NR_CPUS], slop, cpu; 368 int i, vpe, tc, ntc, nvpe, tcpervpe[NR_CPUS], slop, cpu;
345 unsigned long flags; 369 unsigned long flags;
@@ -363,13 +387,13 @@ void mipsmt_prepare_cpus(void)
363 IPIQ[i].head = IPIQ[i].tail = NULL; 387 IPIQ[i].head = IPIQ[i].tail = NULL;
364 spin_lock_init(&IPIQ[i].lock); 388 spin_lock_init(&IPIQ[i].lock);
365 IPIQ[i].depth = 0; 389 IPIQ[i].depth = 0;
366 atomic_set(&ipi_timer_latch[i], 0);
367 } 390 }
368 391
369 /* cpu_data index starts at zero */ 392 /* cpu_data index starts at zero */
370 cpu = 0; 393 cpu = 0;
371 cpu_data[cpu].vpe_id = 0; 394 cpu_data[cpu].vpe_id = 0;
372 cpu_data[cpu].tc_id = 0; 395 cpu_data[cpu].tc_id = 0;
396 cpu_data[cpu].core = (read_c0_ebase() >> 1) & 0xff;
373 cpu++; 397 cpu++;
374 398
375 /* Report on boot-time options */ 399 /* Report on boot-time options */
@@ -484,7 +508,8 @@ void mipsmt_prepare_cpus(void)
484 write_vpe_c0_compare(0); 508 write_vpe_c0_compare(0);
485 /* Propagate Config7 */ 509 /* Propagate Config7 */
486 write_vpe_c0_config7(read_c0_config7()); 510 write_vpe_c0_config7(read_c0_config7());
487 write_vpe_c0_count(read_c0_count()); 511 write_vpe_c0_count(read_c0_count() + CP0_SKEW);
512 ehb();
488 } 513 }
489 /* enable multi-threading within VPE */ 514 /* enable multi-threading within VPE */
490 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() | VPECONTROL_TE); 515 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() | VPECONTROL_TE);
@@ -556,7 +581,7 @@ void mipsmt_prepare_cpus(void)
556void __cpuinit smtc_boot_secondary(int cpu, struct task_struct *idle) 581void __cpuinit smtc_boot_secondary(int cpu, struct task_struct *idle)
557{ 582{
558 extern u32 kernelsp[NR_CPUS]; 583 extern u32 kernelsp[NR_CPUS];
559 long flags; 584 unsigned long flags;
560 int mtflags; 585 int mtflags;
561 586
562 LOCK_MT_PRA(); 587 LOCK_MT_PRA();
@@ -585,24 +610,22 @@ void __cpuinit smtc_boot_secondary(int cpu, struct task_struct *idle)
585 610
586void smtc_init_secondary(void) 611void smtc_init_secondary(void)
587{ 612{
588 /*
589 * Start timer on secondary VPEs if necessary.
590 * plat_timer_setup has already have been invoked by init/main
591 * on "boot" TC. Like per_cpu_trap_init() hack, this assumes that
592 * SMTC init code assigns TCs consdecutively and in ascending order
593 * to across available VPEs.
594 */
595 if (((read_c0_tcbind() & TCBIND_CURTC) != 0) &&
596 ((read_c0_tcbind() & TCBIND_CURVPE)
597 != cpu_data[smp_processor_id() - 1].vpe_id)){
598 write_c0_compare(read_c0_count() + mips_hpt_frequency/HZ);
599 }
600
601 local_irq_enable(); 613 local_irq_enable();
602} 614}
603 615
604void smtc_smp_finish(void) 616void smtc_smp_finish(void)
605{ 617{
618 int cpu = smp_processor_id();
619
620 /*
621 * Lowest-numbered CPU per VPE starts a clock tick.
622 * Like per_cpu_trap_init() hack, this assumes that
623 * SMTC init code assigns TCs consdecutively and
624 * in ascending order across available VPEs.
625 */
626 if (cpu > 0 && (cpu_data[cpu].vpe_id != cpu_data[cpu - 1].vpe_id))
627 write_c0_compare(read_c0_count() + mips_hpt_frequency/HZ);
628
606 printk("TC %d going on-line as CPU %d\n", 629 printk("TC %d going on-line as CPU %d\n",
607 cpu_data[smp_processor_id()].tc_id, smp_processor_id()); 630 cpu_data[smp_processor_id()].tc_id, smp_processor_id());
608} 631}
@@ -753,8 +776,10 @@ void smtc_send_ipi(int cpu, int type, unsigned int action)
753{ 776{
754 int tcstatus; 777 int tcstatus;
755 struct smtc_ipi *pipi; 778 struct smtc_ipi *pipi;
756 long flags; 779 unsigned long flags;
757 int mtflags; 780 int mtflags;
781 unsigned long tcrestart;
782 extern void r4k_wait_irqoff(void), __pastwait(void);
758 783
759 if (cpu == smp_processor_id()) { 784 if (cpu == smp_processor_id()) {
760 printk("Cannot Send IPI to self!\n"); 785 printk("Cannot Send IPI to self!\n");
@@ -771,8 +796,6 @@ void smtc_send_ipi(int cpu, int type, unsigned int action)
771 pipi->arg = (void *)action; 796 pipi->arg = (void *)action;
772 pipi->dest = cpu; 797 pipi->dest = cpu;
773 if (cpu_data[cpu].vpe_id != cpu_data[smp_processor_id()].vpe_id) { 798 if (cpu_data[cpu].vpe_id != cpu_data[smp_processor_id()].vpe_id) {
774 if (type == SMTC_CLOCK_TICK)
775 atomic_inc(&ipi_timer_latch[cpu]);
776 /* If not on same VPE, enqueue and send cross-VPE interrupt */ 799 /* If not on same VPE, enqueue and send cross-VPE interrupt */
777 smtc_ipi_nq(&IPIQ[cpu], pipi); 800 smtc_ipi_nq(&IPIQ[cpu], pipi);
778 LOCK_CORE_PRA(); 801 LOCK_CORE_PRA();
@@ -800,22 +823,29 @@ void smtc_send_ipi(int cpu, int type, unsigned int action)
800 823
801 if ((tcstatus & TCSTATUS_IXMT) != 0) { 824 if ((tcstatus & TCSTATUS_IXMT) != 0) {
802 /* 825 /*
803 * Spin-waiting here can deadlock, 826 * If we're in the the irq-off version of the wait
804 * so we queue the message for the target TC. 827 * loop, we need to force exit from the wait and
828 * do a direct post of the IPI.
829 */
830 if (cpu_wait == r4k_wait_irqoff) {
831 tcrestart = read_tc_c0_tcrestart();
832 if (tcrestart >= (unsigned long)r4k_wait_irqoff
833 && tcrestart < (unsigned long)__pastwait) {
834 write_tc_c0_tcrestart(__pastwait);
835 tcstatus &= ~TCSTATUS_IXMT;
836 write_tc_c0_tcstatus(tcstatus);
837 goto postdirect;
838 }
839 }
840 /*
841 * Otherwise we queue the message for the target TC
842 * to pick up when he does a local_irq_restore()
805 */ 843 */
806 write_tc_c0_tchalt(0); 844 write_tc_c0_tchalt(0);
807 UNLOCK_CORE_PRA(); 845 UNLOCK_CORE_PRA();
808 /* Try to reduce redundant timer interrupt messages */
809 if (type == SMTC_CLOCK_TICK) {
810 if (atomic_postincrement(&ipi_timer_latch[cpu])!=0){
811 smtc_ipi_nq(&freeIPIq, pipi);
812 return;
813 }
814 }
815 smtc_ipi_nq(&IPIQ[cpu], pipi); 846 smtc_ipi_nq(&IPIQ[cpu], pipi);
816 } else { 847 } else {
817 if (type == SMTC_CLOCK_TICK) 848postdirect:
818 atomic_inc(&ipi_timer_latch[cpu]);
819 post_direct_ipi(cpu, pipi); 849 post_direct_ipi(cpu, pipi);
820 write_tc_c0_tchalt(0); 850 write_tc_c0_tchalt(0);
821 UNLOCK_CORE_PRA(); 851 UNLOCK_CORE_PRA();
@@ -883,7 +913,7 @@ static void ipi_call_interrupt(void)
883 smp_call_function_interrupt(); 913 smp_call_function_interrupt();
884} 914}
885 915
886DECLARE_PER_CPU(struct clock_event_device, smtc_dummy_clockevent_device); 916DECLARE_PER_CPU(struct clock_event_device, mips_clockevent_device);
887 917
888void ipi_decode(struct smtc_ipi *pipi) 918void ipi_decode(struct smtc_ipi *pipi)
889{ 919{
@@ -891,20 +921,13 @@ void ipi_decode(struct smtc_ipi *pipi)
891 struct clock_event_device *cd; 921 struct clock_event_device *cd;
892 void *arg_copy = pipi->arg; 922 void *arg_copy = pipi->arg;
893 int type_copy = pipi->type; 923 int type_copy = pipi->type;
894 int ticks;
895
896 smtc_ipi_nq(&freeIPIq, pipi); 924 smtc_ipi_nq(&freeIPIq, pipi);
897 switch (type_copy) { 925 switch (type_copy) {
898 case SMTC_CLOCK_TICK: 926 case SMTC_CLOCK_TICK:
899 irq_enter(); 927 irq_enter();
900 kstat_this_cpu.irqs[MIPS_CPU_IRQ_BASE + 1]++; 928 kstat_this_cpu.irqs[MIPS_CPU_IRQ_BASE + 1]++;
901 cd = &per_cpu(smtc_dummy_clockevent_device, cpu); 929 cd = &per_cpu(mips_clockevent_device, cpu);
902 ticks = atomic_read(&ipi_timer_latch[cpu]); 930 cd->event_handler(cd);
903 atomic_sub(ticks, &ipi_timer_latch[cpu]);
904 while (ticks) {
905 cd->event_handler(cd);
906 ticks--;
907 }
908 irq_exit(); 931 irq_exit();
909 break; 932 break;
910 933
@@ -937,24 +960,48 @@ void ipi_decode(struct smtc_ipi *pipi)
937 } 960 }
938} 961}
939 962
963/*
964 * Similar to smtc_ipi_replay(), but invoked from context restore,
965 * so it reuses the current exception frame rather than set up a
966 * new one with self_ipi.
967 */
968
940void deferred_smtc_ipi(void) 969void deferred_smtc_ipi(void)
941{ 970{
942 struct smtc_ipi *pipi; 971 int cpu = smp_processor_id();
943 unsigned long flags;
944/* DEBUG */
945 int q = smp_processor_id();
946 972
947 /* 973 /*
948 * Test is not atomic, but much faster than a dequeue, 974 * Test is not atomic, but much faster than a dequeue,
949 * and the vast majority of invocations will have a null queue. 975 * and the vast majority of invocations will have a null queue.
976 * If irq_disabled when this was called, then any IPIs queued
977 * after we test last will be taken on the next irq_enable/restore.
978 * If interrupts were enabled, then any IPIs added after the
979 * last test will be taken directly.
950 */ 980 */
951 if (IPIQ[q].head != NULL) { 981
952 while((pipi = smtc_ipi_dq(&IPIQ[q])) != NULL) { 982 while (IPIQ[cpu].head != NULL) {
953 /* ipi_decode() should be called with interrupts off */ 983 struct smtc_ipi_q *q = &IPIQ[cpu];
954 local_irq_save(flags); 984 struct smtc_ipi *pipi;
985 unsigned long flags;
986
987 /*
988 * It may be possible we'll come in with interrupts
989 * already enabled.
990 */
991 local_irq_save(flags);
992
993 spin_lock(&q->lock);
994 pipi = __smtc_ipi_dq(q);
995 spin_unlock(&q->lock);
996 if (pipi != NULL)
955 ipi_decode(pipi); 997 ipi_decode(pipi);
956 local_irq_restore(flags); 998 /*
957 } 999 * The use of the __raw_local restore isn't
1000 * as obviously necessary here as in smtc_ipi_replay(),
1001 * but it's more efficient, given that we're already
1002 * running down the IPI queue.
1003 */
1004 __raw_local_irq_restore(flags);
958 } 1005 }
959} 1006}
960 1007
@@ -975,7 +1022,7 @@ static irqreturn_t ipi_interrupt(int irq, void *dev_idm)
975 struct smtc_ipi *pipi; 1022 struct smtc_ipi *pipi;
976 unsigned long tcstatus; 1023 unsigned long tcstatus;
977 int sent; 1024 int sent;
978 long flags; 1025 unsigned long flags;
979 unsigned int mtflags; 1026 unsigned int mtflags;
980 unsigned int vpflags; 1027 unsigned int vpflags;
981 1028
@@ -1066,55 +1113,53 @@ static void setup_cross_vpe_interrupts(unsigned int nvpe)
1066 1113
1067/* 1114/*
1068 * SMTC-specific hacks invoked from elsewhere in the kernel. 1115 * SMTC-specific hacks invoked from elsewhere in the kernel.
1069 *
1070 * smtc_ipi_replay is called from raw_local_irq_restore which is only ever
1071 * called with interrupts disabled. We do rely on interrupts being disabled
1072 * here because using spin_lock_irqsave()/spin_unlock_irqrestore() would
1073 * result in a recursive call to raw_local_irq_restore().
1074 */ 1116 */
1075 1117
1076static void __smtc_ipi_replay(void) 1118 /*
1119 * smtc_ipi_replay is called from raw_local_irq_restore
1120 */
1121
1122void smtc_ipi_replay(void)
1077{ 1123{
1078 unsigned int cpu = smp_processor_id(); 1124 unsigned int cpu = smp_processor_id();
1079 1125
1080 /* 1126 /*
1081 * To the extent that we've ever turned interrupts off, 1127 * To the extent that we've ever turned interrupts off,
1082 * we may have accumulated deferred IPIs. This is subtle. 1128 * we may have accumulated deferred IPIs. This is subtle.
1083 * If we use the smtc_ipi_qdepth() macro, we'll get an
1084 * exact number - but we'll also disable interrupts
1085 * and create a window of failure where a new IPI gets
1086 * queued after we test the depth but before we re-enable
1087 * interrupts. So long as IXMT never gets set, however,
1088 * we should be OK: If we pick up something and dispatch 1129 * we should be OK: If we pick up something and dispatch
1089 * it here, that's great. If we see nothing, but concurrent 1130 * it here, that's great. If we see nothing, but concurrent
1090 * with this operation, another TC sends us an IPI, IXMT 1131 * with this operation, another TC sends us an IPI, IXMT
1091 * is clear, and we'll handle it as a real pseudo-interrupt 1132 * is clear, and we'll handle it as a real pseudo-interrupt
1092 * and not a pseudo-pseudo interrupt. 1133 * and not a pseudo-pseudo interrupt. The important thing
1134 * is to do the last check for queued message *after* the
1135 * re-enabling of interrupts.
1093 */ 1136 */
1094 if (IPIQ[cpu].depth > 0) { 1137 while (IPIQ[cpu].head != NULL) {
1095 while (1) { 1138 struct smtc_ipi_q *q = &IPIQ[cpu];
1096 struct smtc_ipi_q *q = &IPIQ[cpu]; 1139 struct smtc_ipi *pipi;
1097 struct smtc_ipi *pipi; 1140 unsigned long flags;
1098 extern void self_ipi(struct smtc_ipi *); 1141
1099 1142 /*
1100 spin_lock(&q->lock); 1143 * It's just possible we'll come in with interrupts
1101 pipi = __smtc_ipi_dq(q); 1144 * already enabled.
1102 spin_unlock(&q->lock); 1145 */
1103 if (!pipi) 1146 local_irq_save(flags);
1104 break; 1147
1148 spin_lock(&q->lock);
1149 pipi = __smtc_ipi_dq(q);
1150 spin_unlock(&q->lock);
1151 /*
1152 ** But use a raw restore here to avoid recursion.
1153 */
1154 __raw_local_irq_restore(flags);
1105 1155
1156 if (pipi) {
1106 self_ipi(pipi); 1157 self_ipi(pipi);
1107 smtc_cpu_stats[cpu].selfipis++; 1158 smtc_cpu_stats[cpu].selfipis++;
1108 } 1159 }
1109 } 1160 }
1110} 1161}
1111 1162
1112void smtc_ipi_replay(void)
1113{
1114 raw_local_irq_disable();
1115 __smtc_ipi_replay();
1116}
1117
1118EXPORT_SYMBOL(smtc_ipi_replay); 1163EXPORT_SYMBOL(smtc_ipi_replay);
1119 1164
1120void smtc_idle_loop_hook(void) 1165void smtc_idle_loop_hook(void)
@@ -1193,40 +1238,13 @@ void smtc_idle_loop_hook(void)
1193 } 1238 }
1194 } 1239 }
1195 1240
1196 /*
1197 * Now that we limit outstanding timer IPIs, check for hung TC
1198 */
1199 for (tc = 0; tc < NR_CPUS; tc++) {
1200 /* Don't check ourself - we'll dequeue IPIs just below */
1201 if ((tc != smp_processor_id()) &&
1202 atomic_read(&ipi_timer_latch[tc]) > timerq_limit) {
1203 if (clock_hang_reported[tc] == 0) {
1204 pdb_msg += sprintf(pdb_msg,
1205 "TC %d looks hung with timer latch at %d\n",
1206 tc, atomic_read(&ipi_timer_latch[tc]));
1207 clock_hang_reported[tc]++;
1208 }
1209 }
1210 }
1211 emt(mtflags); 1241 emt(mtflags);
1212 local_irq_restore(flags); 1242 local_irq_restore(flags);
1213 if (pdb_msg != &id_ho_db_msg[0]) 1243 if (pdb_msg != &id_ho_db_msg[0])
1214 printk("CPU%d: %s", smp_processor_id(), id_ho_db_msg); 1244 printk("CPU%d: %s", smp_processor_id(), id_ho_db_msg);
1215#endif /* CONFIG_SMTC_IDLE_HOOK_DEBUG */ 1245#endif /* CONFIG_SMTC_IDLE_HOOK_DEBUG */
1216 1246
1217 /* 1247 smtc_ipi_replay();
1218 * Replay any accumulated deferred IPIs. If "Instant Replay"
1219 * is in use, there should never be any.
1220 */
1221#ifndef CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY
1222 {
1223 unsigned long flags;
1224
1225 local_irq_save(flags);
1226 __smtc_ipi_replay();
1227 local_irq_restore(flags);
1228 }
1229#endif /* CONFIG_MIPS_MT_SMTC_INSTANT_REPLAY */
1230} 1248}
1231 1249
1232void smtc_soft_dump(void) 1250void smtc_soft_dump(void)
@@ -1242,10 +1260,6 @@ void smtc_soft_dump(void)
1242 printk("%d: %ld\n", i, smtc_cpu_stats[i].selfipis); 1260 printk("%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
1243 } 1261 }
1244 smtc_ipi_qdump(); 1262 smtc_ipi_qdump();
1245 printk("Timer IPI Backlogs:\n");
1246 for (i=0; i < NR_CPUS; i++) {
1247 printk("%d: %d\n", i, atomic_read(&ipi_timer_latch[i]));
1248 }
1249 printk("%d Recoveries of \"stolen\" FPU\n", 1263 printk("%d Recoveries of \"stolen\" FPU\n",
1250 atomic_read(&smtc_fpu_recoveries)); 1264 atomic_read(&smtc_fpu_recoveries));
1251} 1265}
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 5fd0cd020af5..80b9e070c207 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -42,6 +42,7 @@
42#include <asm/tlbdebug.h> 42#include <asm/tlbdebug.h>
43#include <asm/traps.h> 43#include <asm/traps.h>
44#include <asm/uaccess.h> 44#include <asm/uaccess.h>
45#include <asm/watch.h>
45#include <asm/mmu_context.h> 46#include <asm/mmu_context.h>
46#include <asm/types.h> 47#include <asm/types.h>
47#include <asm/stacktrace.h> 48#include <asm/stacktrace.h>
@@ -825,8 +826,10 @@ static void mt_ase_fp_affinity(void)
825 if (cpus_intersects(current->cpus_allowed, mt_fpu_cpumask)) { 826 if (cpus_intersects(current->cpus_allowed, mt_fpu_cpumask)) {
826 cpumask_t tmask; 827 cpumask_t tmask;
827 828
828 cpus_and(tmask, current->thread.user_cpus_allowed, 829 current->thread.user_cpus_allowed
829 mt_fpu_cpumask); 830 = current->cpus_allowed;
831 cpus_and(tmask, current->cpus_allowed,
832 mt_fpu_cpumask);
830 set_cpus_allowed(current, tmask); 833 set_cpus_allowed(current, tmask);
831 set_thread_flag(TIF_FPUBOUND); 834 set_thread_flag(TIF_FPUBOUND);
832 } 835 }
@@ -910,13 +913,26 @@ asmlinkage void do_mdmx(struct pt_regs *regs)
910 913
911asmlinkage void do_watch(struct pt_regs *regs) 914asmlinkage void do_watch(struct pt_regs *regs)
912{ 915{
916 u32 cause;
917
913 /* 918 /*
914 * We use the watch exception where available to detect stack 919 * Clear WP (bit 22) bit of cause register so we don't loop
915 * overflows. 920 * forever.
916 */ 921 */
917 dump_tlb_all(); 922 cause = read_c0_cause();
918 show_regs(regs); 923 cause &= ~(1 << 22);
919 panic("Caught WATCH exception - probably caused by stack overflow."); 924 write_c0_cause(cause);
925
926 /*
927 * If the current thread has the watch registers loaded, save
928 * their values and send SIGTRAP. Otherwise another thread
929 * left the registers set, clear them and continue.
930 */
931 if (test_tsk_thread_flag(current, TIF_LOAD_WATCH)) {
932 mips_read_watch_registers();
933 force_sig(SIGTRAP, current);
934 } else
935 mips_clear_watch_registers();
920} 936}
921 937
922asmlinkage void do_mcheck(struct pt_regs *regs) 938asmlinkage void do_mcheck(struct pt_regs *regs)
diff --git a/arch/mips/kernel/watch.c b/arch/mips/kernel/watch.c
new file mode 100644
index 000000000000..c15406968030
--- /dev/null
+++ b/arch/mips/kernel/watch.c
@@ -0,0 +1,188 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2008 David Daney
7 */
8
9#include <linux/sched.h>
10
11#include <asm/processor.h>
12#include <asm/watch.h>
13
14/*
15 * Install the watch registers for the current thread. A maximum of
16 * four registers are installed although the machine may have more.
17 */
18void mips_install_watch_registers(void)
19{
20 struct mips3264_watch_reg_state *watches =
21 &current->thread.watch.mips3264;
22 switch (current_cpu_data.watch_reg_use_cnt) {
23 default:
24 BUG();
25 case 4:
26 write_c0_watchlo3(watches->watchlo[3]);
27 /* Write 1 to the I, R, and W bits to clear them, and
28 1 to G so all ASIDs are trapped. */
29 write_c0_watchhi3(0x40000007 | watches->watchhi[3]);
30 case 3:
31 write_c0_watchlo2(watches->watchlo[2]);
32 write_c0_watchhi2(0x40000007 | watches->watchhi[2]);
33 case 2:
34 write_c0_watchlo1(watches->watchlo[1]);
35 write_c0_watchhi1(0x40000007 | watches->watchhi[1]);
36 case 1:
37 write_c0_watchlo0(watches->watchlo[0]);
38 write_c0_watchhi0(0x40000007 | watches->watchhi[0]);
39 }
40}
41
42/*
43 * Read back the watchhi registers so the user space debugger has
44 * access to the I, R, and W bits. A maximum of four registers are
45 * read although the machine may have more.
46 */
47void mips_read_watch_registers(void)
48{
49 struct mips3264_watch_reg_state *watches =
50 &current->thread.watch.mips3264;
51 switch (current_cpu_data.watch_reg_use_cnt) {
52 default:
53 BUG();
54 case 4:
55 watches->watchhi[3] = (read_c0_watchhi3() & 0x0fff);
56 case 3:
57 watches->watchhi[2] = (read_c0_watchhi2() & 0x0fff);
58 case 2:
59 watches->watchhi[1] = (read_c0_watchhi1() & 0x0fff);
60 case 1:
61 watches->watchhi[0] = (read_c0_watchhi0() & 0x0fff);
62 }
63 if (current_cpu_data.watch_reg_use_cnt == 1 &&
64 (watches->watchhi[0] & 7) == 0) {
65 /* Pathological case of release 1 architecture that
66 * doesn't set the condition bits. We assume that
67 * since we got here, the watch condition was met and
68 * signal that the conditions requested in watchlo
69 * were met. */
70 watches->watchhi[0] |= (watches->watchlo[0] & 7);
71 }
72 }
73
74/*
75 * Disable all watch registers. Although only four registers are
76 * installed, all are cleared to eliminate the possibility of endless
77 * looping in the watch handler.
78 */
79void mips_clear_watch_registers(void)
80{
81 switch (current_cpu_data.watch_reg_count) {
82 default:
83 BUG();
84 case 8:
85 write_c0_watchlo7(0);
86 case 7:
87 write_c0_watchlo6(0);
88 case 6:
89 write_c0_watchlo5(0);
90 case 5:
91 write_c0_watchlo4(0);
92 case 4:
93 write_c0_watchlo3(0);
94 case 3:
95 write_c0_watchlo2(0);
96 case 2:
97 write_c0_watchlo1(0);
98 case 1:
99 write_c0_watchlo0(0);
100 }
101}
102
103__cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c)
104{
105 unsigned int t;
106
107 if ((c->options & MIPS_CPU_WATCH) == 0)
108 return;
109 /*
110 * Check which of the I,R and W bits are supported, then
111 * disable the register.
112 */
113 write_c0_watchlo0(7);
114 t = read_c0_watchlo0();
115 write_c0_watchlo0(0);
116 c->watch_reg_masks[0] = t & 7;
117
118 /* Write the mask bits and read them back to determine which
119 * can be used. */
120 c->watch_reg_count = 1;
121 c->watch_reg_use_cnt = 1;
122 t = read_c0_watchhi0();
123 write_c0_watchhi0(t | 0xff8);
124 t = read_c0_watchhi0();
125 c->watch_reg_masks[0] |= (t & 0xff8);
126 if ((t & 0x80000000) == 0)
127 return;
128
129 write_c0_watchlo1(7);
130 t = read_c0_watchlo1();
131 write_c0_watchlo1(0);
132 c->watch_reg_masks[1] = t & 7;
133
134 c->watch_reg_count = 2;
135 c->watch_reg_use_cnt = 2;
136 t = read_c0_watchhi1();
137 write_c0_watchhi1(t | 0xff8);
138 t = read_c0_watchhi1();
139 c->watch_reg_masks[1] |= (t & 0xff8);
140 if ((t & 0x80000000) == 0)
141 return;
142
143 write_c0_watchlo2(7);
144 t = read_c0_watchlo2();
145 write_c0_watchlo2(0);
146 c->watch_reg_masks[2] = t & 7;
147
148 c->watch_reg_count = 3;
149 c->watch_reg_use_cnt = 3;
150 t = read_c0_watchhi2();
151 write_c0_watchhi2(t | 0xff8);
152 t = read_c0_watchhi2();
153 c->watch_reg_masks[2] |= (t & 0xff8);
154 if ((t & 0x80000000) == 0)
155 return;
156
157 write_c0_watchlo3(7);
158 t = read_c0_watchlo3();
159 write_c0_watchlo3(0);
160 c->watch_reg_masks[3] = t & 7;
161
162 c->watch_reg_count = 4;
163 c->watch_reg_use_cnt = 4;
164 t = read_c0_watchhi3();
165 write_c0_watchhi3(t | 0xff8);
166 t = read_c0_watchhi3();
167 c->watch_reg_masks[3] |= (t & 0xff8);
168 if ((t & 0x80000000) == 0)
169 return;
170
171 /* We use at most 4, but probe and report up to 8. */
172 c->watch_reg_count = 5;
173 t = read_c0_watchhi4();
174 if ((t & 0x80000000) == 0)
175 return;
176
177 c->watch_reg_count = 6;
178 t = read_c0_watchhi5();
179 if ((t & 0x80000000) == 0)
180 return;
181
182 c->watch_reg_count = 7;
183 t = read_c0_watchhi6();
184 if ((t & 0x80000000) == 0)
185 return;
186
187 c->watch_reg_count = 8;
188}
diff --git a/arch/mips/lib/csum_partial.S b/arch/mips/lib/csum_partial.S
index edac9892c51a..6b876ca299ee 100644
--- a/arch/mips/lib/csum_partial.S
+++ b/arch/mips/lib/csum_partial.S
@@ -55,20 +55,14 @@
55#define UNIT(unit) ((unit)*NBYTES) 55#define UNIT(unit) ((unit)*NBYTES)
56 56
57#define ADDC(sum,reg) \ 57#define ADDC(sum,reg) \
58 .set push; \
59 .set noat; \
60 ADD sum, reg; \ 58 ADD sum, reg; \
61 sltu v1, sum, reg; \ 59 sltu v1, sum, reg; \
62 ADD sum, v1; \ 60 ADD sum, v1; \
63 .set pop
64 61
65#define ADDC32(sum,reg) \ 62#define ADDC32(sum,reg) \
66 .set push; \
67 .set noat; \
68 addu sum, reg; \ 63 addu sum, reg; \
69 sltu v1, sum, reg; \ 64 sltu v1, sum, reg; \
70 addu sum, v1; \ 65 addu sum, v1; \
71 .set pop
72 66
73#define CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3) \ 67#define CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3) \
74 LOAD _t0, (offset + UNIT(0))(src); \ 68 LOAD _t0, (offset + UNIT(0))(src); \
@@ -267,8 +261,6 @@ LEAF(csum_partial)
2671: ADDC(sum, t1) 2611: ADDC(sum, t1)
268 262
269 /* fold checksum */ 263 /* fold checksum */
270 .set push
271 .set noat
272#ifdef USE_DOUBLE 264#ifdef USE_DOUBLE
273 dsll32 v1, sum, 0 265 dsll32 v1, sum, 0
274 daddu sum, v1 266 daddu sum, v1
@@ -276,21 +268,22 @@ LEAF(csum_partial)
276 dsra32 sum, sum, 0 268 dsra32 sum, sum, 0
277 addu sum, v1 269 addu sum, v1
278#endif 270#endif
279 sll v1, sum, 16
280 addu sum, v1
281 sltu v1, sum, v1
282 srl sum, sum, 16
283 addu sum, v1
284 271
285 /* odd buffer alignment? */ 272 /* odd buffer alignment? */
286 beqz t7, 1f 273#ifdef CPU_MIPSR2
287 nop 274 wsbh v1, sum
288 sll v1, sum, 8 275 movn sum, v1, t7
276#else
277 beqz t7, 1f /* odd buffer alignment? */
278 lui v1, 0x00ff
279 addu v1, 0x00ff
280 and t0, sum, v1
281 sll t0, t0, 8
289 srl sum, sum, 8 282 srl sum, sum, 8
290 or sum, v1 283 and sum, sum, v1
291 andi sum, 0xffff 284 or sum, sum, t0
292 .set pop
2931: 2851:
286#endif
294 .set reorder 287 .set reorder
295 /* Add the passed partial csum. */ 288 /* Add the passed partial csum. */
296 ADDC32(sum, a2) 289 ADDC32(sum, a2)
@@ -669,8 +662,6 @@ EXC( sb t0, NBYTES-2(dst), .Ls_exc)
669 ADDC(sum, t2) 662 ADDC(sum, t2)
670.Ldone: 663.Ldone:
671 /* fold checksum */ 664 /* fold checksum */
672 .set push
673 .set noat
674#ifdef USE_DOUBLE 665#ifdef USE_DOUBLE
675 dsll32 v1, sum, 0 666 dsll32 v1, sum, 0
676 daddu sum, v1 667 daddu sum, v1
@@ -678,21 +669,21 @@ EXC( sb t0, NBYTES-2(dst), .Ls_exc)
678 dsra32 sum, sum, 0 669 dsra32 sum, sum, 0
679 addu sum, v1 670 addu sum, v1
680#endif 671#endif
681 sll v1, sum, 16
682 addu sum, v1
683 sltu v1, sum, v1
684 srl sum, sum, 16
685 addu sum, v1
686 672
687 /* odd buffer alignment? */ 673#ifdef CPU_MIPSR2
688 beqz odd, 1f 674 wsbh v1, sum
689 nop 675 movn sum, v1, odd
690 sll v1, sum, 8 676#else
677 beqz odd, 1f /* odd buffer alignment? */
678 lui v1, 0x00ff
679 addu v1, 0x00ff
680 and t0, sum, v1
681 sll t0, t0, 8
691 srl sum, sum, 8 682 srl sum, sum, 8
692 or sum, v1 683 and sum, sum, v1
693 andi sum, 0xffff 684 or sum, sum, t0
694 .set pop
6951: 6851:
686#endif
696 .set reorder 687 .set reorder
697 ADDC32(sum, psum) 688 ADDC32(sum, psum)
698 jr ra 689 jr ra
diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
index 3b7dd722c32a..cef2db8d2225 100644
--- a/arch/mips/mti-malta/Makefile
+++ b/arch/mips/mti-malta/Makefile
@@ -15,6 +15,6 @@ obj-$(CONFIG_EARLY_PRINTK) += malta-console.o
15obj-$(CONFIG_PCI) += malta-pci.o 15obj-$(CONFIG_PCI) += malta-pci.o
16 16
17# FIXME FIXME FIXME 17# FIXME FIXME FIXME
18obj-$(CONFIG_MIPS_MT_SMTC) += malta_smtc.o 18obj-$(CONFIG_MIPS_MT_SMTC) += malta-smtc.o
19 19
20EXTRA_CFLAGS += -Werror 20EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mti-malta/malta-smtc.c b/arch/mips/mti-malta/malta-smtc.c
index 5ea705e49454..f84a46a8ae6e 100644
--- a/arch/mips/mti-malta/malta-smtc.c
+++ b/arch/mips/mti-malta/malta-smtc.c
@@ -84,12 +84,17 @@ static void msmtc_cpus_done(void)
84 84
85static void __init msmtc_smp_setup(void) 85static void __init msmtc_smp_setup(void)
86{ 86{
87 mipsmt_build_cpu_map(0); 87 /*
88 * we won't get the definitive value until
89 * we've run smtc_prepare_cpus later, but
90 * we would appear to need an upper bound now.
91 */
92 smp_num_siblings = smtc_build_cpu_map(0);
88} 93}
89 94
90static void __init msmtc_prepare_cpus(unsigned int max_cpus) 95static void __init msmtc_prepare_cpus(unsigned int max_cpus)
91{ 96{
92 mipsmt_prepare_cpus(); 97 smtc_prepare_cpus(max_cpus);
93} 98}
94 99
95struct plat_smp_ops msmtc_smp_ops = { 100struct plat_smp_ops msmtc_smp_ops = {
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index c8c32f417b6c..b1886244cedf 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_TANBAC_TB0287) += fixup-tb0287.o
45obj-$(CONFIG_TOSHIBA_JMR3927) += fixup-jmr3927.o 45obj-$(CONFIG_TOSHIBA_JMR3927) += fixup-jmr3927.o
46obj-$(CONFIG_SOC_TX4927) += pci-tx4927.o 46obj-$(CONFIG_SOC_TX4927) += pci-tx4927.o
47obj-$(CONFIG_SOC_TX4938) += pci-tx4938.o 47obj-$(CONFIG_SOC_TX4938) += pci-tx4938.o
48obj-$(CONFIG_SOC_TX4939) += pci-tx4939.o
48obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o 49obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o
49obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup-rbtx4938.o 50obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup-rbtx4938.o
50obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o 51obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o
diff --git a/arch/mips/pci/pci-tx4938.c b/arch/mips/pci/pci-tx4938.c
index 60e2c52c2c5e..1ea257bc3b8f 100644
--- a/arch/mips/pci/pci-tx4938.c
+++ b/arch/mips/pci/pci-tx4938.c
@@ -114,7 +114,7 @@ int __init tx4938_pciclk66_setup(void)
114 return pciclk; 114 return pciclk;
115} 115}
116 116
117int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot) 117int __init tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot)
118{ 118{
119 if (get_tx4927_pcicptr(dev->bus->sysdata) == tx4938_pcic1ptr) { 119 if (get_tx4927_pcicptr(dev->bus->sysdata) == tx4938_pcic1ptr) {
120 switch (slot) { 120 switch (slot) {
diff --git a/arch/mips/pci/pci-tx4939.c b/arch/mips/pci/pci-tx4939.c
new file mode 100644
index 000000000000..5fecf1cdc325
--- /dev/null
+++ b/arch/mips/pci/pci-tx4939.c
@@ -0,0 +1,109 @@
1/*
2 * linux/arch/mips/pci/pci-tx4939.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4939/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
6 *
7 * Copyright 2001, 2003-2005 MontaVista Software Inc.
8 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
9 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/init.h>
16#include <linux/pci.h>
17#include <linux/kernel.h>
18#include <linux/interrupt.h>
19#include <asm/txx9/generic.h>
20#include <asm/txx9/tx4939.h>
21
22int __init tx4939_report_pciclk(void)
23{
24 int pciclk = 0;
25
26 pr_info("PCIC --%s PCICLK:",
27 (__raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_PCI66) ?
28 " PCI66" : "");
29 if (__raw_readq(&tx4939_ccfgptr->pcfg) & TX4939_PCFG_PCICLKEN_ALL) {
30 pciclk = txx9_master_clock * 20 / 6;
31 if (!(__raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_PCI66))
32 pciclk /= 2;
33 printk(KERN_CONT "Internal(%u.%uMHz)",
34 (pciclk + 50000) / 1000000,
35 ((pciclk + 50000) / 100000) % 10);
36 } else {
37 printk(KERN_CONT "External");
38 pciclk = -1;
39 }
40 printk(KERN_CONT "\n");
41 return pciclk;
42}
43
44void __init tx4939_report_pci1clk(void)
45{
46 unsigned int pciclk = txx9_master_clock * 20 / 6;
47
48 pr_info("PCIC1 -- PCICLK:%u.%uMHz\n",
49 (pciclk + 50000) / 1000000,
50 ((pciclk + 50000) / 100000) % 10);
51}
52
53int __init tx4939_pcic1_map_irq(const struct pci_dev *dev, u8 slot)
54{
55 if (get_tx4927_pcicptr(dev->bus->sysdata) == tx4939_pcic1ptr) {
56 switch (slot) {
57 case TX4927_PCIC_IDSEL_AD_TO_SLOT(31):
58 if (__raw_readq(&tx4939_ccfgptr->pcfg) &
59 TX4939_PCFG_ET0MODE)
60 return TXX9_IRQ_BASE + TX4939_IR_ETH(0);
61 break;
62 case TX4927_PCIC_IDSEL_AD_TO_SLOT(30):
63 if (__raw_readq(&tx4939_ccfgptr->pcfg) &
64 TX4939_PCFG_ET1MODE)
65 return TXX9_IRQ_BASE + TX4939_IR_ETH(1);
66 break;
67 }
68 return 0;
69 }
70 return -1;
71}
72
73int __init tx4939_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
74{
75 int irq = tx4939_pcic1_map_irq(dev, slot);
76
77 if (irq >= 0)
78 return irq;
79 irq = pin;
80 /* IRQ rotation */
81 irq--; /* 0-3 */
82 irq = (irq + 33 - slot) % 4;
83 irq++; /* 1-4 */
84
85 switch (irq) {
86 case 1:
87 irq = TXX9_IRQ_BASE + TX4939_IR_INTA;
88 break;
89 case 2:
90 irq = TXX9_IRQ_BASE + TX4939_IR_INTB;
91 break;
92 case 3:
93 irq = TXX9_IRQ_BASE + TX4939_IR_INTC;
94 break;
95 case 4:
96 irq = TXX9_IRQ_BASE + TX4939_IR_INTD;
97 break;
98 }
99 return irq;
100}
101
102void __init tx4939_setup_pcierr_irq(void)
103{
104 if (request_irq(TXX9_IRQ_BASE + TX4939_IR_PCIERR,
105 tx4927_pcierr_interrupt,
106 IRQF_DISABLED, "PCI error",
107 (void *)TX4939_PCIC_REG))
108 pr_warning("Failed to request irq for PCIERR\n");
109}
diff --git a/arch/mips/pmc-sierra/msp71xx/Makefile b/arch/mips/pmc-sierra/msp71xx/Makefile
index 4bba79c1cc79..e107f79b1491 100644
--- a/arch/mips/pmc-sierra/msp71xx/Makefile
+++ b/arch/mips/pmc-sierra/msp71xx/Makefile
@@ -3,6 +3,7 @@
3# 3#
4obj-y += msp_prom.o msp_setup.o msp_irq.o \ 4obj-y += msp_prom.o msp_setup.o msp_irq.o \
5 msp_time.o msp_serial.o msp_elb.o 5 msp_time.o msp_serial.o msp_elb.o
6obj-$(CONFIG_HAVE_GPIO_LIB) += gpio.o gpio_extended.o
6obj-$(CONFIG_PMC_MSP7120_GW) += msp_hwbutton.o 7obj-$(CONFIG_PMC_MSP7120_GW) += msp_hwbutton.o
7obj-$(CONFIG_IRQ_MSP_SLP) += msp_irq_slp.o 8obj-$(CONFIG_IRQ_MSP_SLP) += msp_irq_slp.o
8obj-$(CONFIG_IRQ_MSP_CIC) += msp_irq_cic.o 9obj-$(CONFIG_IRQ_MSP_CIC) += msp_irq_cic.o
diff --git a/arch/mips/pmc-sierra/msp71xx/gpio.c b/arch/mips/pmc-sierra/msp71xx/gpio.c
new file mode 100644
index 000000000000..69848c5813e2
--- /dev/null
+++ b/arch/mips/pmc-sierra/msp71xx/gpio.c
@@ -0,0 +1,218 @@
1/*
2 * @file /arch/mips/pmc-sierra/msp71xx/gpio.c
3 *
4 * Generic PMC MSP71xx GPIO handling. These base gpio are controlled by two
5 * types of registers. The data register sets the output level when in output
6 * mode and when in input mode will contain the value at the input. The config
7 * register sets the various modes for each gpio.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * @author Patrick Glass <patrickglass@gmail.com>
14 */
15
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/init.h>
19#include <linux/gpio.h>
20#include <linux/spinlock.h>
21#include <linux/io.h>
22
23#define MSP71XX_CFG_OFFSET(gpio) (4 * (gpio))
24#define CONF_MASK 0x0F
25#define MSP71XX_GPIO_INPUT 0x01
26#define MSP71XX_GPIO_OUTPUT 0x08
27
28#define MSP71XX_GPIO_BASE 0x0B8400000L
29
30#define to_msp71xx_gpio_chip(c) container_of(c, struct msp71xx_gpio_chip, chip)
31
32static spinlock_t gpio_lock;
33
34/*
35 * struct msp71xx_gpio_chip - container for gpio chip and registers
36 * @chip: chip structure for the specified gpio bank
37 * @data_reg: register for reading and writing the gpio pin value
38 * @config_reg: register to set the mode for the gpio pin bank
39 * @out_drive_reg: register to set the output drive mode for the gpio pin bank
40 */
41struct msp71xx_gpio_chip {
42 struct gpio_chip chip;
43 void __iomem *data_reg;
44 void __iomem *config_reg;
45 void __iomem *out_drive_reg;
46};
47
48/*
49 * msp71xx_gpio_get() - return the chip's gpio value
50 * @chip: chip structure which controls the specified gpio
51 * @offset: gpio whose value will be returned
52 *
53 * It will return 0 if gpio value is low and other if high.
54 */
55static int msp71xx_gpio_get(struct gpio_chip *chip, unsigned offset)
56{
57 struct msp71xx_gpio_chip *msp_chip = to_msp71xx_gpio_chip(chip);
58
59 return __raw_readl(msp_chip->data_reg) & (1 << offset);
60}
61
62/*
63 * msp71xx_gpio_set() - set the output value for the gpio
64 * @chip: chip structure who controls the specified gpio
65 * @offset: gpio whose value will be assigned
66 * @value: logic level to assign to the gpio initially
67 *
68 * This will set the gpio bit specified to the desired value. It will set the
69 * gpio pin low if value is 0 otherwise it will be high.
70 */
71static void msp71xx_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
72{
73 struct msp71xx_gpio_chip *msp_chip = to_msp71xx_gpio_chip(chip);
74 unsigned long flags;
75 u32 data;
76
77 spin_lock_irqsave(&gpio_lock, flags);
78
79 data = __raw_readl(msp_chip->data_reg);
80 if (value)
81 data |= (1 << offset);
82 else
83 data &= ~(1 << offset);
84 __raw_writel(data, msp_chip->data_reg);
85
86 spin_unlock_irqrestore(&gpio_lock, flags);
87}
88
89/*
90 * msp71xx_set_gpio_mode() - declare the mode for a gpio
91 * @chip: chip structure which controls the specified gpio
92 * @offset: gpio whose value will be assigned
93 * @mode: desired configuration for the gpio (see datasheet)
94 *
95 * It will set the gpio pin config to the @mode value passed in.
96 */
97static int msp71xx_set_gpio_mode(struct gpio_chip *chip,
98 unsigned offset, int mode)
99{
100 struct msp71xx_gpio_chip *msp_chip = to_msp71xx_gpio_chip(chip);
101 const unsigned bit_offset = MSP71XX_CFG_OFFSET(offset);
102 unsigned long flags;
103 u32 cfg;
104
105 spin_lock_irqsave(&gpio_lock, flags);
106
107 cfg = __raw_readl(msp_chip->config_reg);
108 cfg &= ~(CONF_MASK << bit_offset);
109 cfg |= (mode << bit_offset);
110 __raw_writel(cfg, msp_chip->config_reg);
111
112 spin_unlock_irqrestore(&gpio_lock, flags);
113
114 return 0;
115}
116
117/*
118 * msp71xx_direction_output() - declare the direction mode for a gpio
119 * @chip: chip structure which controls the specified gpio
120 * @offset: gpio whose value will be assigned
121 * @value: logic level to assign to the gpio initially
122 *
123 * This call will set the mode for the @gpio to output. It will set the
124 * gpio pin low if value is 0 otherwise it will be high.
125 */
126static int msp71xx_direction_output(struct gpio_chip *chip,
127 unsigned offset, int value)
128{
129 msp71xx_gpio_set(chip, offset, value);
130
131 return msp71xx_set_gpio_mode(chip, offset, MSP71XX_GPIO_OUTPUT);
132}
133
134/*
135 * msp71xx_direction_input() - declare the direction mode for a gpio
136 * @chip: chip structure which controls the specified gpio
137 * @offset: gpio whose to which the value will be assigned
138 *
139 * This call will set the mode for the @gpio to input.
140 */
141static int msp71xx_direction_input(struct gpio_chip *chip, unsigned offset)
142{
143 return msp71xx_set_gpio_mode(chip, offset, MSP71XX_GPIO_INPUT);
144}
145
146/*
147 * msp71xx_set_output_drive() - declare the output drive for the gpio line
148 * @gpio: gpio pin whose output drive you wish to modify
149 * @value: zero for active drain 1 for open drain drive
150 *
151 * This call will set the output drive mode for the @gpio to output.
152 */
153int msp71xx_set_output_drive(unsigned gpio, int value)
154{
155 unsigned long flags;
156 u32 data;
157
158 if (gpio > 15 || gpio < 0)
159 return -EINVAL;
160
161 spin_lock_irqsave(&gpio_lock, flags);
162
163 data = __raw_readl((void __iomem *)(MSP71XX_GPIO_BASE + 0x190));
164 if (value)
165 data |= (1 << gpio);
166 else
167 data &= ~(1 << gpio);
168 __raw_writel(data, (void __iomem *)(MSP71XX_GPIO_BASE + 0x190));
169
170 spin_unlock_irqrestore(&gpio_lock, flags);
171
172 return 0;
173}
174EXPORT_SYMBOL(msp71xx_set_output_drive);
175
176#define MSP71XX_GPIO_BANK(name, dr, cr, base_gpio, num_gpio) \
177{ \
178 .chip = { \
179 .label = name, \
180 .direction_input = msp71xx_direction_input, \
181 .direction_output = msp71xx_direction_output, \
182 .get = msp71xx_gpio_get, \
183 .set = msp71xx_gpio_set, \
184 .base = base_gpio, \
185 .ngpio = num_gpio \
186 }, \
187 .data_reg = (void __iomem *)(MSP71XX_GPIO_BASE + dr), \
188 .config_reg = (void __iomem *)(MSP71XX_GPIO_BASE + cr), \
189 .out_drive_reg = (void __iomem *)(MSP71XX_GPIO_BASE + 0x190), \
190}
191
192/*
193 * struct msp71xx_gpio_banks[] - container array of gpio banks
194 * @chip: chip structure for the specified gpio bank
195 * @data_reg: register for reading and writing the gpio pin value
196 * @config_reg: register to set the mode for the gpio pin bank
197 *
198 * This array structure defines the gpio banks for the PMC MIPS Processor.
199 * We specify the bank name, the data register, the config register, base
200 * starting gpio number, and the number of gpios exposed by the bank.
201 */
202static struct msp71xx_gpio_chip msp71xx_gpio_banks[] = {
203
204 MSP71XX_GPIO_BANK("GPIO_1_0", 0x170, 0x180, 0, 2),
205 MSP71XX_GPIO_BANK("GPIO_5_2", 0x174, 0x184, 2, 4),
206 MSP71XX_GPIO_BANK("GPIO_9_6", 0x178, 0x188, 6, 4),
207 MSP71XX_GPIO_BANK("GPIO_15_10", 0x17C, 0x18C, 10, 6),
208};
209
210void __init msp71xx_init_gpio(void)
211{
212 int i;
213
214 spin_lock_init(&gpio_lock);
215
216 for (i = 0; i < ARRAY_SIZE(msp71xx_gpio_banks); i++)
217 gpiochip_add(&msp71xx_gpio_banks[i].chip);
218}
diff --git a/arch/mips/pmc-sierra/msp71xx/gpio_extended.c b/arch/mips/pmc-sierra/msp71xx/gpio_extended.c
new file mode 100644
index 000000000000..fc6dbc6cf1c0
--- /dev/null
+++ b/arch/mips/pmc-sierra/msp71xx/gpio_extended.c
@@ -0,0 +1,148 @@
1/*
2 * @file /arch/mips/pmc-sierra/msp71xx/gpio_extended.c
3 *
4 * Generic PMC MSP71xx EXTENDED (EXD) GPIO handling. The extended gpio is
5 * a set of hardware registers that have no need for explicit locking as
6 * it is handled by unique method of writing individual set/clr bits.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * @author Patrick Glass <patrickglass@gmail.com>
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/gpio.h>
19#include <linux/io.h>
20
21#define MSP71XX_DATA_OFFSET(gpio) (2 * (gpio))
22#define MSP71XX_READ_OFFSET(gpio) (MSP71XX_DATA_OFFSET(gpio) + 1)
23#define MSP71XX_CFG_OUT_OFFSET(gpio) (MSP71XX_DATA_OFFSET(gpio) + 16)
24#define MSP71XX_CFG_IN_OFFSET(gpio) (MSP71XX_CFG_OUT_OFFSET(gpio) + 1)
25
26#define MSP71XX_EXD_GPIO_BASE 0x0BC000000L
27
28#define to_msp71xx_exd_gpio_chip(c) \
29 container_of(c, struct msp71xx_exd_gpio_chip, chip)
30
31/*
32 * struct msp71xx_exd_gpio_chip - container for gpio chip and registers
33 * @chip: chip structure for the specified gpio bank
34 * @reg: register for control and data of gpio pin
35 */
36struct msp71xx_exd_gpio_chip {
37 struct gpio_chip chip;
38 void __iomem *reg;
39};
40
41/*
42 * msp71xx_exd_gpio_get() - return the chip's gpio value
43 * @chip: chip structure which controls the specified gpio
44 * @offset: gpio whose value will be returned
45 *
46 * It will return 0 if gpio value is low and other if high.
47 */
48static int msp71xx_exd_gpio_get(struct gpio_chip *chip, unsigned offset)
49{
50 struct msp71xx_exd_gpio_chip *msp71xx_chip =
51 to_msp71xx_exd_gpio_chip(chip);
52 const unsigned bit = MSP71XX_READ_OFFSET(offset);
53
54 return __raw_readl(msp71xx_chip->reg) & (1 << bit);
55}
56
57/*
58 * msp71xx_exd_gpio_set() - set the output value for the gpio
59 * @chip: chip structure who controls the specified gpio
60 * @offset: gpio whose value will be assigned
61 * @value: logic level to assign to the gpio initially
62 *
63 * This will set the gpio bit specified to the desired value. It will set the
64 * gpio pin low if value is 0 otherwise it will be high.
65 */
66static void msp71xx_exd_gpio_set(struct gpio_chip *chip,
67 unsigned offset, int value)
68{
69 struct msp71xx_exd_gpio_chip *msp71xx_chip =
70 to_msp71xx_exd_gpio_chip(chip);
71 const unsigned bit = MSP71XX_DATA_OFFSET(offset);
72
73 __raw_writel(1 << (bit + (value ? 1 : 0)), msp71xx_chip->reg);
74}
75
76/*
77 * msp71xx_exd_direction_output() - declare the direction mode for a gpio
78 * @chip: chip structure which controls the specified gpio
79 * @offset: gpio whose value will be assigned
80 * @value: logic level to assign to the gpio initially
81 *
82 * This call will set the mode for the @gpio to output. It will set the
83 * gpio pin low if value is 0 otherwise it will be high.
84 */
85static int msp71xx_exd_direction_output(struct gpio_chip *chip,
86 unsigned offset, int value)
87{
88 struct msp71xx_exd_gpio_chip *msp71xx_chip =
89 to_msp71xx_exd_gpio_chip(chip);
90
91 msp71xx_exd_gpio_set(chip, offset, value);
92 __raw_writel(1 << MSP71XX_CFG_OUT_OFFSET(offset), msp71xx_chip->reg);
93 return 0;
94}
95
96/*
97 * msp71xx_exd_direction_input() - declare the direction mode for a gpio
98 * @chip: chip structure which controls the specified gpio
99 * @offset: gpio whose to which the value will be assigned
100 *
101 * This call will set the mode for the @gpio to input.
102 */
103static int msp71xx_exd_direction_input(struct gpio_chip *chip, unsigned offset)
104{
105 struct msp71xx_exd_gpio_chip *msp71xx_chip =
106 to_msp71xx_exd_gpio_chip(chip);
107
108 __raw_writel(1 << MSP71XX_CFG_IN_OFFSET(offset), msp71xx_chip->reg);
109 return 0;
110}
111
112#define MSP71XX_EXD_GPIO_BANK(name, exd_reg, base_gpio, num_gpio) \
113{ \
114 .chip = { \
115 .label = name, \
116 .direction_input = msp71xx_exd_direction_input, \
117 .direction_output = msp71xx_exd_direction_output, \
118 .get = msp71xx_exd_gpio_get, \
119 .set = msp71xx_exd_gpio_set, \
120 .base = base_gpio, \
121 .ngpio = num_gpio, \
122 }, \
123 .reg = (void __iomem *)(MSP71XX_EXD_GPIO_BASE + exd_reg), \
124}
125
126/*
127 * struct msp71xx_exd_gpio_banks[] - container array of gpio banks
128 * @chip: chip structure for the specified gpio bank
129 * @reg: register for reading and writing the gpio pin value
130 *
131 * This array structure defines the extended gpio banks for the
132 * PMC MIPS Processor. We specify the bank name, the data/config
133 * register,the base starting gpio number, and the number of
134 * gpios exposed by the bank of gpios.
135 */
136static struct msp71xx_exd_gpio_chip msp71xx_exd_gpio_banks[] = {
137
138 MSP71XX_EXD_GPIO_BANK("GPIO_23_16", 0x188, 16, 8),
139 MSP71XX_EXD_GPIO_BANK("GPIO_27_24", 0x18C, 24, 4),
140};
141
142void __init msp71xx_init_gpio_extended(void)
143{
144 int i;
145
146 for (i = 0; i < ARRAY_SIZE(msp71xx_exd_gpio_banks); i++)
147 gpiochip_add(&msp71xx_exd_gpio_banks[i].chip);
148}
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index 82ab395efa33..31619c601b11 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -34,21 +34,11 @@
34#include <asm/mach-rc32434/rb.h> 34#include <asm/mach-rc32434/rb.h>
35#include <asm/mach-rc32434/integ.h> 35#include <asm/mach-rc32434/integ.h>
36#include <asm/mach-rc32434/gpio.h> 36#include <asm/mach-rc32434/gpio.h>
37 37#include <asm/mach-rc32434/irq.h>
38#define ETH0_DMA_RX_IRQ (GROUP1_IRQ_BASE + 0)
39#define ETH0_DMA_TX_IRQ (GROUP1_IRQ_BASE + 1)
40#define ETH0_RX_OVR_IRQ (GROUP3_IRQ_BASE + 9)
41#define ETH0_TX_UND_IRQ (GROUP3_IRQ_BASE + 10)
42 38
43#define ETH0_RX_DMA_ADDR (DMA0_BASE_ADDR + 0 * DMA_CHAN_OFFSET) 39#define ETH0_RX_DMA_ADDR (DMA0_BASE_ADDR + 0 * DMA_CHAN_OFFSET)
44#define ETH0_TX_DMA_ADDR (DMA0_BASE_ADDR + 1 * DMA_CHAN_OFFSET) 40#define ETH0_TX_DMA_ADDR (DMA0_BASE_ADDR + 1 * DMA_CHAN_OFFSET)
45 41
46/* NAND definitions */
47#define GPIO_RDY (1 << 0x08)
48#define GPIO_WPX (1 << 0x09)
49#define GPIO_ALE (1 << 0x0a)
50#define GPIO_CLE (1 << 0x0b)
51
52static struct resource korina_dev0_res[] = { 42static struct resource korina_dev0_res[] = {
53 { 43 {
54 .name = "korina_regs", 44 .name = "korina_regs",
@@ -94,15 +84,13 @@ static struct korina_device korina_dev0_data = {
94}; 84};
95 85
96static struct platform_device korina_dev0 = { 86static struct platform_device korina_dev0 = {
97 .id = 0, 87 .id = -1,
98 .name = "korina", 88 .name = "korina",
99 .dev.platform_data = &korina_dev0_data, 89 .dev.platform_data = &korina_dev0_data,
100 .resource = korina_dev0_res, 90 .resource = korina_dev0_res,
101 .num_resources = ARRAY_SIZE(korina_dev0_res), 91 .num_resources = ARRAY_SIZE(korina_dev0_res),
102}; 92};
103 93
104#define CF_GPIO_NUM 13
105
106static struct resource cf_slot0_res[] = { 94static struct resource cf_slot0_res[] = {
107 { 95 {
108 .name = "cf_membase", 96 .name = "cf_membase",
@@ -116,11 +104,11 @@ static struct resource cf_slot0_res[] = {
116}; 104};
117 105
118static struct cf_device cf_slot0_data = { 106static struct cf_device cf_slot0_data = {
119 .gpio_pin = 13 107 .gpio_pin = CF_GPIO_NUM
120}; 108};
121 109
122static struct platform_device cf_slot0 = { 110static struct platform_device cf_slot0 = {
123 .id = 0, 111 .id = -1,
124 .name = "pata-rb532-cf", 112 .name = "pata-rb532-cf",
125 .dev.platform_data = &cf_slot0_data, 113 .dev.platform_data = &cf_slot0_data,
126 .resource = cf_slot0_res, 114 .resource = cf_slot0_res,
@@ -185,7 +173,7 @@ static struct mtd_partition rb532_partition_info[] = {
185 173
186static struct platform_device rb532_led = { 174static struct platform_device rb532_led = {
187 .name = "rb532-led", 175 .name = "rb532-led",
188 .id = 0, 176 .id = -1,
189}; 177};
190 178
191static struct gpio_keys_button rb532_gpio_btn[] = { 179static struct gpio_keys_button rb532_gpio_btn[] = {
diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c
index 00a1c7877bf4..76a7fd96d564 100644
--- a/arch/mips/rb532/gpio.c
+++ b/arch/mips/rb532/gpio.c
@@ -27,28 +27,31 @@
27 */ 27 */
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/gpio.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/types.h> 31#include <linux/types.h>
33#include <linux/pci.h>
34#include <linux/spinlock.h> 32#include <linux/spinlock.h>
35#include <linux/io.h>
36#include <linux/platform_device.h> 33#include <linux/platform_device.h>
37 34#include <linux/gpio.h>
38#include <asm/addrspace.h>
39 35
40#include <asm/mach-rc32434/rb.h> 36#include <asm/mach-rc32434/rb.h>
41 37#include <asm/mach-rc32434/gpio.h>
42struct rb532_gpio_reg __iomem *rb532_gpio_reg0; 38
43EXPORT_SYMBOL(rb532_gpio_reg0); 39struct rb532_gpio_chip {
40 struct gpio_chip chip;
41 void __iomem *regbase;
42 void (*set_int_level)(struct gpio_chip *chip, unsigned offset, int value);
43 int (*get_int_level)(struct gpio_chip *chip, unsigned offset);
44 void (*set_int_status)(struct gpio_chip *chip, unsigned offset, int value);
45 int (*get_int_status)(struct gpio_chip *chip, unsigned offset);
46};
44 47
45struct mpmc_device dev3; 48struct mpmc_device dev3;
46 49
47static struct resource rb532_gpio_reg0_res[] = { 50static struct resource rb532_gpio_reg0_res[] = {
48 { 51 {
49 .name = "gpio_reg0", 52 .name = "gpio_reg0",
50 .start = (u32)(IDT434_REG_BASE + GPIOBASE), 53 .start = REGBASE + GPIOBASE,
51 .end = (u32)(IDT434_REG_BASE + GPIOBASE + sizeof(struct rb532_gpio_reg)), 54 .end = REGBASE + GPIOBASE + sizeof(struct rb532_gpio_reg) - 1,
52 .flags = IORESOURCE_MEM, 55 .flags = IORESOURCE_MEM,
53 } 56 }
54}; 57};
@@ -56,8 +59,8 @@ static struct resource rb532_gpio_reg0_res[] = {
56static struct resource rb532_dev3_ctl_res[] = { 59static struct resource rb532_dev3_ctl_res[] = {
57 { 60 {
58 .name = "dev3_ctl", 61 .name = "dev3_ctl",
59 .start = (u32)(IDT434_REG_BASE + DEV3BASE), 62 .start = REGBASE + DEV3BASE,
60 .end = (u32)(IDT434_REG_BASE + DEV3BASE + sizeof(struct dev_reg)), 63 .end = REGBASE + DEV3BASE + sizeof(struct dev_reg) - 1,
61 .flags = IORESOURCE_MEM, 64 .flags = IORESOURCE_MEM,
62 } 65 }
63}; 66};
@@ -70,7 +73,7 @@ void set_434_reg(unsigned reg_offs, unsigned bit, unsigned len, unsigned val)
70 73
71 spin_lock_irqsave(&dev3.lock, flags); 74 spin_lock_irqsave(&dev3.lock, flags);
72 75
73 data = *(volatile unsigned *) (IDT434_REG_BASE + reg_offs); 76 data = readl(IDT434_REG_BASE + reg_offs);
74 for (i = 0; i != len; ++i) { 77 for (i = 0; i != len; ++i) {
75 if (val & (1 << i)) 78 if (val & (1 << i))
76 data |= (1 << (i + bit)); 79 data |= (1 << (i + bit));
@@ -108,108 +111,199 @@ unsigned char get_latch_u5(void)
108} 111}
109EXPORT_SYMBOL(get_latch_u5); 112EXPORT_SYMBOL(get_latch_u5);
110 113
111int rb532_gpio_get_value(unsigned gpio) 114/*
115 * Return GPIO level */
116static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset)
112{ 117{
113 return readl(&rb532_gpio_reg0->gpiod) & (1 << gpio); 118 u32 mask = 1 << offset;
119 struct rb532_gpio_chip *gpch;
120
121 gpch = container_of(chip, struct rb532_gpio_chip, chip);
122 return readl(gpch->regbase + GPIOD) & mask;
114} 123}
115EXPORT_SYMBOL(rb532_gpio_get_value);
116 124
117void rb532_gpio_set_value(unsigned gpio, int value) 125/*
126 * Set output GPIO level
127 */
128static void rb532_gpio_set(struct gpio_chip *chip,
129 unsigned offset, int value)
118{ 130{
119 unsigned tmp; 131 unsigned long flags;
132 u32 mask = 1 << offset;
133 u32 tmp;
134 struct rb532_gpio_chip *gpch;
135 void __iomem *gpvr;
120 136
121 tmp = readl(&rb532_gpio_reg0->gpiod) & ~(1 << gpio); 137 gpch = container_of(chip, struct rb532_gpio_chip, chip);
122 if (value) 138 gpvr = gpch->regbase + GPIOD;
123 tmp |= 1 << gpio;
124 139
125 writel(tmp, (void *)&rb532_gpio_reg0->gpiod); 140 local_irq_save(flags);
141 tmp = readl(gpvr);
142 if (value)
143 tmp |= mask;
144 else
145 tmp &= ~mask;
146 writel(tmp, gpvr);
147 local_irq_restore(flags);
126} 148}
127EXPORT_SYMBOL(rb532_gpio_set_value);
128 149
129int rb532_gpio_direction_input(unsigned gpio) 150/*
151 * Set GPIO direction to input
152 */
153static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
130{ 154{
131 writel(readl(&rb532_gpio_reg0->gpiocfg) & ~(1 << gpio), 155 unsigned long flags;
132 (void *)&rb532_gpio_reg0->gpiocfg); 156 u32 mask = 1 << offset;
157 u32 value;
158 struct rb532_gpio_chip *gpch;
159 void __iomem *gpdr;
133 160
134 return 0; 161 gpch = container_of(chip, struct rb532_gpio_chip, chip);
135} 162 gpdr = gpch->regbase + GPIOCFG;
136EXPORT_SYMBOL(rb532_gpio_direction_input);
137 163
138int rb532_gpio_direction_output(unsigned gpio, int value) 164 local_irq_save(flags);
139{ 165 value = readl(gpdr);
140 gpio_set_value(gpio, value); 166 value &= ~mask;
141 writel(readl(&rb532_gpio_reg0->gpiocfg) | (1 << gpio), 167 writel(value, gpdr);
142 (void *)&rb532_gpio_reg0->gpiocfg); 168 local_irq_restore(flags);
143 169
144 return 0; 170 return 0;
145} 171}
146EXPORT_SYMBOL(rb532_gpio_direction_output);
147 172
148void rb532_gpio_set_int_level(unsigned gpio, int value) 173/*
174 * Set GPIO direction to output
175 */
176static int rb532_gpio_direction_output(struct gpio_chip *chip,
177 unsigned offset, int value)
149{ 178{
150 unsigned tmp; 179 unsigned long flags;
180 u32 mask = 1 << offset;
181 u32 tmp;
182 struct rb532_gpio_chip *gpch;
183 void __iomem *gpdr;
184
185 gpch = container_of(chip, struct rb532_gpio_chip, chip);
186 writel(mask, gpch->regbase + GPIOD);
187 gpdr = gpch->regbase + GPIOCFG;
188
189 local_irq_save(flags);
190 tmp = readl(gpdr);
191 tmp |= mask;
192 writel(tmp, gpdr);
193 local_irq_restore(flags);
151 194
152 tmp = readl(&rb532_gpio_reg0->gpioilevel) & ~(1 << gpio); 195 return 0;
153 if (value)
154 tmp |= 1 << gpio;
155 writel(tmp, (void *)&rb532_gpio_reg0->gpioilevel);
156} 196}
157EXPORT_SYMBOL(rb532_gpio_set_int_level);
158 197
159int rb532_gpio_get_int_level(unsigned gpio) 198/*
199 * Set the GPIO interrupt level
200 */
201static void rb532_gpio_set_int_level(struct gpio_chip *chip,
202 unsigned offset, int value)
160{ 203{
161 return readl(&rb532_gpio_reg0->gpioilevel) & (1 << gpio); 204 unsigned long flags;
162} 205 u32 mask = 1 << offset;
163EXPORT_SYMBOL(rb532_gpio_get_int_level); 206 u32 tmp;
207 struct rb532_gpio_chip *gpch;
208 void __iomem *gpil;
164 209
165void rb532_gpio_set_int_status(unsigned gpio, int value) 210 gpch = container_of(chip, struct rb532_gpio_chip, chip);
166{ 211 gpil = gpch->regbase + GPIOILEVEL;
167 unsigned tmp;
168 212
169 tmp = readl(&rb532_gpio_reg0->gpioistat); 213 local_irq_save(flags);
214 tmp = readl(gpil);
170 if (value) 215 if (value)
171 tmp |= 1 << gpio; 216 tmp |= mask;
172 writel(tmp, (void *)&rb532_gpio_reg0->gpioistat); 217 else
218 tmp &= ~mask;
219 writel(tmp, gpil);
220 local_irq_restore(flags);
173} 221}
174EXPORT_SYMBOL(rb532_gpio_set_int_status);
175 222
176int rb532_gpio_get_int_status(unsigned gpio) 223/*
224 * Get the GPIO interrupt level
225 */
226static int rb532_gpio_get_int_level(struct gpio_chip *chip, unsigned offset)
177{ 227{
178 return readl(&rb532_gpio_reg0->gpioistat) & (1 << gpio); 228 u32 mask = 1 << offset;
229 struct rb532_gpio_chip *gpch;
230
231 gpch = container_of(chip, struct rb532_gpio_chip, chip);
232 return readl(gpch->regbase + GPIOILEVEL) & mask;
179} 233}
180EXPORT_SYMBOL(rb532_gpio_get_int_status);
181 234
182void rb532_gpio_set_func(unsigned gpio, int value) 235/*
236 * Set the GPIO interrupt status
237 */
238static void rb532_gpio_set_int_status(struct gpio_chip *chip,
239 unsigned offset, int value)
183{ 240{
184 unsigned tmp; 241 unsigned long flags;
242 u32 mask = 1 << offset;
243 u32 tmp;
244 struct rb532_gpio_chip *gpch;
245 void __iomem *gpis;
246
247 gpch = container_of(chip, struct rb532_gpio_chip, chip);
248 gpis = gpch->regbase + GPIOISTAT;
185 249
186 tmp = readl(&rb532_gpio_reg0->gpiofunc); 250 local_irq_save(flags);
251 tmp = readl(gpis);
187 if (value) 252 if (value)
188 tmp |= 1 << gpio; 253 tmp |= mask;
189 writel(tmp, (void *)&rb532_gpio_reg0->gpiofunc); 254 else
255 tmp &= ~mask;
256 writel(tmp, gpis);
257 local_irq_restore(flags);
190} 258}
191EXPORT_SYMBOL(rb532_gpio_set_func);
192 259
193int rb532_gpio_get_func(unsigned gpio) 260/*
261 * Get the GPIO interrupt status
262 */
263static int rb532_gpio_get_int_status(struct gpio_chip *chip, unsigned offset)
194{ 264{
195 return readl(&rb532_gpio_reg0->gpiofunc) & (1 << gpio); 265 u32 mask = 1 << offset;
266 struct rb532_gpio_chip *gpch;
267
268 gpch = container_of(chip, struct rb532_gpio_chip, chip);
269 return readl(gpch->regbase + GPIOISTAT) & mask;
196} 270}
197EXPORT_SYMBOL(rb532_gpio_get_func); 271
272static struct rb532_gpio_chip rb532_gpio_chip[] = {
273 [0] = {
274 .chip = {
275 .label = "gpio0",
276 .direction_input = rb532_gpio_direction_input,
277 .direction_output = rb532_gpio_direction_output,
278 .get = rb532_gpio_get,
279 .set = rb532_gpio_set,
280 .base = 0,
281 .ngpio = 32,
282 },
283 .get_int_level = rb532_gpio_get_int_level,
284 .set_int_level = rb532_gpio_set_int_level,
285 .get_int_status = rb532_gpio_get_int_status,
286 .set_int_status = rb532_gpio_set_int_status,
287 },
288};
198 289
199int __init rb532_gpio_init(void) 290int __init rb532_gpio_init(void)
200{ 291{
201 rb532_gpio_reg0 = ioremap_nocache(rb532_gpio_reg0_res[0].start, 292 struct resource *r;
202 rb532_gpio_reg0_res[0].end -
203 rb532_gpio_reg0_res[0].start);
204 293
205 if (!rb532_gpio_reg0) { 294 r = rb532_gpio_reg0_res;
295 rb532_gpio_chip->regbase = ioremap_nocache(r->start, r->end - r->start);
296
297 if (!rb532_gpio_chip->regbase) {
206 printk(KERN_ERR "rb532: cannot remap GPIO register 0\n"); 298 printk(KERN_ERR "rb532: cannot remap GPIO register 0\n");
207 return -ENXIO; 299 return -ENXIO;
208 } 300 }
209 301
210 dev3.base = ioremap_nocache(rb532_dev3_ctl_res[0].start, 302 /* Register our GPIO chip */
211 rb532_dev3_ctl_res[0].end - 303 gpiochip_add(&rb532_gpio_chip->chip);
212 rb532_dev3_ctl_res[0].start); 304
305 r = rb532_dev3_ctl_res;
306 dev3.base = ioremap_nocache(r->start, r->end - r->start);
213 307
214 if (!dev3.base) { 308 if (!dev3.base) {
215 printk(KERN_ERR "rb532: cannot remap device controller 3\n"); 309 printk(KERN_ERR "rb532: cannot remap device controller 3\n");
diff --git a/arch/mips/rb532/irq.c b/arch/mips/rb532/irq.c
index c0d0f950caf2..549b46d2fcee 100644
--- a/arch/mips/rb532/irq.c
+++ b/arch/mips/rb532/irq.c
@@ -45,7 +45,7 @@
45#include <asm/mipsregs.h> 45#include <asm/mipsregs.h>
46#include <asm/system.h> 46#include <asm/system.h>
47 47
48#include <asm/mach-rc32434/rc32434.h> 48#include <asm/mach-rc32434/irq.h>
49 49
50struct intr_group { 50struct intr_group {
51 u32 mask; /* mask of valid bits in pending/mask registers */ 51 u32 mask; /* mask of valid bits in pending/mask registers */
diff --git a/arch/mips/rb532/prom.c b/arch/mips/rb532/prom.c
index 1bc0af8febf4..46ca24dbcc2d 100644
--- a/arch/mips/rb532/prom.c
+++ b/arch/mips/rb532/prom.c
@@ -37,12 +37,8 @@
37#include <asm/mach-rc32434/ddr.h> 37#include <asm/mach-rc32434/ddr.h>
38#include <asm/mach-rc32434/prom.h> 38#include <asm/mach-rc32434/prom.h>
39 39
40extern void __init setup_serial_port(void);
41
42unsigned int idt_cpu_freq = 132000000; 40unsigned int idt_cpu_freq = 132000000;
43EXPORT_SYMBOL(idt_cpu_freq); 41EXPORT_SYMBOL(idt_cpu_freq);
44unsigned int gpio_bootup_state;
45EXPORT_SYMBOL(gpio_bootup_state);
46 42
47static struct resource ddr_reg[] = { 43static struct resource ddr_reg[] = {
48 { 44 {
@@ -108,9 +104,6 @@ void __init prom_setup_cmdline(void)
108 mips_machtype = MACH_MIKROTIK_RB532; 104 mips_machtype = MACH_MIKROTIK_RB532;
109 } 105 }
110 106
111 if (match_tag(prom_argv[i], GPIO_TAG))
112 gpio_bootup_state = tag2ul(prom_argv[i], GPIO_TAG);
113
114 strcpy(cp, prom_argv[i]); 107 strcpy(cp, prom_argv[i]);
115 cp += strlen(prom_argv[i]); 108 cp += strlen(prom_argv[i]);
116 } 109 }
@@ -122,11 +115,6 @@ void __init prom_setup_cmdline(void)
122 strcpy(cp, arcs_cmdline); 115 strcpy(cp, arcs_cmdline);
123 cp += strlen(arcs_cmdline); 116 cp += strlen(arcs_cmdline);
124 } 117 }
125 if (gpio_bootup_state & 0x02)
126 strcpy(cp, GPIO_INIT_NOBUTTON);
127 else
128 strcpy(cp, GPIO_INIT_BUTTON);
129
130 cmd_line[CL_SIZE-1] = '\0'; 118 cmd_line[CL_SIZE-1] = '\0';
131 119
132 strcpy(arcs_cmdline, cmd_line); 120 strcpy(arcs_cmdline, cmd_line);
diff --git a/arch/mips/rb532/serial.c b/arch/mips/rb532/serial.c
index 1a05b5ddee09..3e0d7ec3a579 100644
--- a/arch/mips/rb532/serial.c
+++ b/arch/mips/rb532/serial.c
@@ -31,16 +31,16 @@
31#include <linux/serial_8250.h> 31#include <linux/serial_8250.h>
32 32
33#include <asm/serial.h> 33#include <asm/serial.h>
34#include <asm/mach-rc32434/rc32434.h> 34#include <asm/mach-rc32434/rb.h>
35 35
36extern unsigned int idt_cpu_freq; 36extern unsigned int idt_cpu_freq;
37 37
38static struct uart_port rb532_uart = { 38static struct uart_port rb532_uart = {
39 .type = PORT_16550A, 39 .type = PORT_16550A,
40 .line = 0, 40 .line = 0,
41 .irq = RC32434_UART0_IRQ, 41 .irq = UART0_IRQ,
42 .iotype = UPIO_MEM, 42 .iotype = UPIO_MEM,
43 .membase = (char *)KSEG1ADDR(RC32434_UART0_BASE), 43 .membase = (char *)KSEG1ADDR(REGBASE + UART0BASE),
44 .regshift = 2 44 .regshift = 2
45}; 45};
46 46
diff --git a/arch/mips/rb532/setup.c b/arch/mips/rb532/setup.c
index 7aafa95ac20b..50f530f5b602 100644
--- a/arch/mips/rb532/setup.c
+++ b/arch/mips/rb532/setup.c
@@ -9,7 +9,7 @@
9#include <asm/time.h> 9#include <asm/time.h>
10#include <linux/ioport.h> 10#include <linux/ioport.h>
11 11
12#include <asm/mach-rc32434/rc32434.h> 12#include <asm/mach-rc32434/rb.h>
13#include <asm/mach-rc32434/pci.h> 13#include <asm/mach-rc32434/pci.h>
14 14
15struct pci_reg __iomem *pci_reg; 15struct pci_reg __iomem *pci_reg;
@@ -27,7 +27,7 @@ static struct resource pci0_res[] = {
27static void rb_machine_restart(char *command) 27static void rb_machine_restart(char *command)
28{ 28{
29 /* just jump to the reset vector */ 29 /* just jump to the reset vector */
30 writel(0x80000001, (void *)KSEG1ADDR(RC32434_REG_BASE + RC32434_RST)); 30 writel(0x80000001, IDT434_REG_BASE + RST);
31 ((void (*)(void)) KSEG1ADDR(0x1FC00000u))(); 31 ((void (*)(void)) KSEG1ADDR(0x1FC00000u))();
32} 32}
33 33
diff --git a/arch/mips/sibyte/swarm/Makefile b/arch/mips/sibyte/swarm/Makefile
index f18ba9201bbc..7b45f199d92a 100644
--- a/arch/mips/sibyte/swarm/Makefile
+++ b/arch/mips/sibyte/swarm/Makefile
@@ -1,3 +1,4 @@
1obj-y := setup.o rtc_xicor1241.o rtc_m41t81.o 1obj-y := platform.o setup.o rtc_xicor1241.o \
2 rtc_m41t81.o
2 3
3obj-$(CONFIG_I2C_BOARDINFO) += swarm-i2c.o 4obj-$(CONFIG_I2C_BOARDINFO) += swarm-i2c.o
diff --git a/arch/mips/sibyte/swarm/platform.c b/arch/mips/sibyte/swarm/platform.c
new file mode 100644
index 000000000000..54847fe1e564
--- /dev/null
+++ b/arch/mips/sibyte/swarm/platform.c
@@ -0,0 +1,85 @@
1#include <linux/err.h>
2#include <linux/kernel.h>
3#include <linux/init.h>
4#include <linux/io.h>
5#include <linux/platform_device.h>
6#include <linux/ata_platform.h>
7
8#include <asm/sibyte/board.h>
9#include <asm/sibyte/sb1250_genbus.h>
10#include <asm/sibyte/sb1250_regs.h>
11
12#if defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR)
13
14#define DRV_NAME "pata-swarm"
15
16#define SWARM_IDE_SHIFT 5
17#define SWARM_IDE_BASE 0x1f0
18#define SWARM_IDE_CTRL 0x3f6
19
20static struct resource swarm_pata_resource[] = {
21 {
22 .name = "Swarm GenBus IDE",
23 .flags = IORESOURCE_MEM,
24 }, {
25 .name = "Swarm GenBus IDE",
26 .flags = IORESOURCE_MEM,
27 }, {
28 .name = "Swarm GenBus IDE",
29 .flags = IORESOURCE_IRQ,
30 .start = K_INT_GB_IDE,
31 .end = K_INT_GB_IDE,
32 },
33};
34
35static struct pata_platform_info pata_platform_data = {
36 .ioport_shift = SWARM_IDE_SHIFT,
37};
38
39static struct platform_device swarm_pata_device = {
40 .name = "pata_platform",
41 .id = -1,
42 .resource = swarm_pata_resource,
43 .num_resources = ARRAY_SIZE(swarm_pata_resource),
44 .dev = {
45 .platform_data = &pata_platform_data,
46 .coherent_dma_mask = ~0, /* grumble */
47 },
48};
49
50static int __init swarm_pata_init(void)
51{
52 u8 __iomem *base;
53 phys_t offset, size;
54 struct resource *r;
55
56 if (!SIBYTE_HAVE_IDE)
57 return -ENODEV;
58
59 base = ioremap(A_IO_EXT_BASE, 0x800);
60 offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
61 size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
62 iounmap(base);
63
64 offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
65 size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
66 if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
67 pr_info(DRV_NAME ": PATA interface at GenBus disabled\n");
68
69 return -EBUSY;
70 }
71
72 pr_info(DRV_NAME ": PATA interface at GenBus slot %i\n", IDE_CS);
73
74 r = swarm_pata_resource;
75 r[0].start = offset + (SWARM_IDE_BASE << SWARM_IDE_SHIFT);
76 r[0].end = offset + ((SWARM_IDE_BASE + 8) << SWARM_IDE_SHIFT) - 1;
77 r[1].start = offset + (SWARM_IDE_CTRL << SWARM_IDE_SHIFT);
78 r[1].end = offset + ((SWARM_IDE_CTRL + 1) << SWARM_IDE_SHIFT) - 1;
79
80 return platform_device_register(&swarm_pata_device);
81}
82
83device_initcall(swarm_pata_init);
84
85#endif /* defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR) */
diff --git a/arch/mips/txx9/Kconfig b/arch/mips/txx9/Kconfig
index 840fe757c48d..17052db4161d 100644
--- a/arch/mips/txx9/Kconfig
+++ b/arch/mips/txx9/Kconfig
@@ -45,6 +45,14 @@ config TOSHIBA_RBTX4938
45 This Toshiba board is based on the TX4938 processor. Say Y here to 45 This Toshiba board is based on the TX4938 processor. Say Y here to
46 support this machine type 46 support this machine type
47 47
48config TOSHIBA_RBTX4939
49 bool "Toshiba RBTX4939 bobard"
50 depends on MACH_TX49XX
51 select SOC_TX4939
52 help
53 This Toshiba board is based on the TX4939 processor. Say Y here to
54 support this machine type
55
48config SOC_TX3927 56config SOC_TX3927
49 bool 57 bool
50 select CEVT_TXX9 58 select CEVT_TXX9
@@ -71,6 +79,13 @@ config SOC_TX4938
71 select PCI_TX4927 79 select PCI_TX4927
72 select GPIO_TXX9 80 select GPIO_TXX9
73 81
82config SOC_TX4939
83 bool
84 select CEVT_TXX9
85 select HAS_TXX9_SERIAL
86 select HW_HAS_PCI
87 select PCI_TX4927
88
74config TOSHIBA_FPCIB0 89config TOSHIBA_FPCIB0
75 bool "FPCIB0 Backplane Support" 90 bool "FPCIB0 Backplane Support"
76 depends on PCI && MACH_TXX9 91 depends on PCI && MACH_TXX9
@@ -94,16 +109,11 @@ config TOSHIBA_RBTX4938_MPLEX_NAND
94 bool "NAND" 109 bool "NAND"
95config TOSHIBA_RBTX4938_MPLEX_ATA 110config TOSHIBA_RBTX4938_MPLEX_ATA
96 bool "ATA" 111 bool "ATA"
112config TOSHIBA_RBTX4938_MPLEX_KEEP
113 bool "Keep firmware settings"
97 114
98endchoice 115endchoice
99 116
100config TX4938_NAND_BOOT
101 depends on EXPERIMENTAL && TOSHIBA_RBTX4938_MPLEX_NAND
102 bool "NAND Boot Support (EXPERIMENTAL)"
103 help
104 This is only for Toshiba RBTX4938 reference board, which has NAND IPL.
105 Select this option if you need to use NAND boot.
106
107endif 117endif
108 118
109config PCI_TX4927 119config PCI_TX4927
diff --git a/arch/mips/txx9/generic/Makefile b/arch/mips/txx9/generic/Makefile
index 9bb34af26b73..0030d23bef5b 100644
--- a/arch/mips/txx9/generic/Makefile
+++ b/arch/mips/txx9/generic/Makefile
@@ -7,6 +7,8 @@ obj-$(CONFIG_PCI) += pci.o
7obj-$(CONFIG_SOC_TX3927) += setup_tx3927.o irq_tx3927.o 7obj-$(CONFIG_SOC_TX3927) += setup_tx3927.o irq_tx3927.o
8obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o setup_tx4927.o irq_tx4927.o 8obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o setup_tx4927.o irq_tx4927.o
9obj-$(CONFIG_SOC_TX4938) += mem_tx4927.o setup_tx4938.o irq_tx4938.o 9obj-$(CONFIG_SOC_TX4938) += mem_tx4927.o setup_tx4938.o irq_tx4938.o
10obj-$(CONFIG_SOC_TX4939) += setup_tx4939.o irq_tx4939.o
10obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o 11obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o
12obj-$(CONFIG_SPI) += spi_eeprom.o
11 13
12EXTRA_CFLAGS += -Werror 14EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/txx9/generic/irq_tx4927.c b/arch/mips/txx9/generic/irq_tx4927.c
index cbea1fdde82b..ad2870def8f1 100644
--- a/arch/mips/txx9/generic/irq_tx4927.c
+++ b/arch/mips/txx9/generic/irq_tx4927.c
@@ -30,8 +30,19 @@
30 30
31void __init tx4927_irq_init(void) 31void __init tx4927_irq_init(void)
32{ 32{
33 int i;
34
33 mips_cpu_irq_init(); 35 mips_cpu_irq_init();
34 txx9_irq_init(TX4927_IRC_REG & 0xfffffffffULL); 36 txx9_irq_init(TX4927_IRC_REG & 0xfffffffffULL);
35 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4927_IRC_INT, 37 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4927_IRC_INT,
36 handle_simple_irq); 38 handle_simple_irq);
39 /* raise priority for errors, timers, SIO */
40 txx9_irq_set_pri(TX4927_IR_ECCERR, 7);
41 txx9_irq_set_pri(TX4927_IR_WTOERR, 7);
42 txx9_irq_set_pri(TX4927_IR_PCIERR, 7);
43 txx9_irq_set_pri(TX4927_IR_PCIPME, 7);
44 for (i = 0; i < TX4927_NUM_IR_TMR; i++)
45 txx9_irq_set_pri(TX4927_IR_TMR(i), 6);
46 for (i = 0; i < TX4927_NUM_IR_SIO; i++)
47 txx9_irq_set_pri(TX4927_IR_SIO(i), 5);
37} 48}
diff --git a/arch/mips/txx9/generic/irq_tx4938.c b/arch/mips/txx9/generic/irq_tx4938.c
index 6eac684bf190..025ae11359a8 100644
--- a/arch/mips/txx9/generic/irq_tx4938.c
+++ b/arch/mips/txx9/generic/irq_tx4938.c
@@ -18,8 +18,19 @@
18 18
19void __init tx4938_irq_init(void) 19void __init tx4938_irq_init(void)
20{ 20{
21 int i;
22
21 mips_cpu_irq_init(); 23 mips_cpu_irq_init();
22 txx9_irq_init(TX4938_IRC_REG & 0xfffffffffULL); 24 txx9_irq_init(TX4938_IRC_REG & 0xfffffffffULL);
23 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4938_IRC_INT, 25 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4938_IRC_INT,
24 handle_simple_irq); 26 handle_simple_irq);
27 /* raise priority for errors, timers, SIO */
28 txx9_irq_set_pri(TX4938_IR_ECCERR, 7);
29 txx9_irq_set_pri(TX4938_IR_WTOERR, 7);
30 txx9_irq_set_pri(TX4938_IR_PCIERR, 7);
31 txx9_irq_set_pri(TX4938_IR_PCIPME, 7);
32 for (i = 0; i < TX4938_NUM_IR_TMR; i++)
33 txx9_irq_set_pri(TX4938_IR_TMR(i), 6);
34 for (i = 0; i < TX4938_NUM_IR_SIO; i++)
35 txx9_irq_set_pri(TX4938_IR_SIO(i), 5);
25} 36}
diff --git a/arch/mips/txx9/generic/irq_tx4939.c b/arch/mips/txx9/generic/irq_tx4939.c
new file mode 100644
index 000000000000..013213a8706b
--- /dev/null
+++ b/arch/mips/txx9/generic/irq_tx4939.c
@@ -0,0 +1,215 @@
1/*
2 * TX4939 irq routines
3 * Based on linux/arch/mips/kernel/irq_txx9.c,
4 * and RBTX49xx patch from CELF patch archive.
5 *
6 * Copyright 2001, 2003-2005 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc.
8 * ahennessy@mvista.com
9 * source@mvista.com
10 * Copyright (C) 2000-2001,2005-2007 Toshiba Corporation
11 *
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file "COPYING" in the main directory of this archive
14 * for more details.
15 */
16/*
17 * TX4939 defines 64 IRQs.
18 * Similer to irq_txx9.c but different register layouts.
19 */
20#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/types.h>
23#include <asm/irq_cpu.h>
24#include <asm/txx9irq.h>
25#include <asm/txx9/tx4939.h>
26
27/* IRCER : Int. Control Enable */
28#define TXx9_IRCER_ICE 0x00000001
29
30/* IRCR : Int. Control */
31#define TXx9_IRCR_LOW 0x00000000
32#define TXx9_IRCR_HIGH 0x00000001
33#define TXx9_IRCR_DOWN 0x00000002
34#define TXx9_IRCR_UP 0x00000003
35#define TXx9_IRCR_EDGE(cr) ((cr) & 0x00000002)
36
37/* IRSCR : Int. Status Control */
38#define TXx9_IRSCR_EIClrE 0x00000100
39#define TXx9_IRSCR_EIClr_MASK 0x0000000f
40
41/* IRCSR : Int. Current Status */
42#define TXx9_IRCSR_IF 0x00010000
43
44#define irc_dlevel 0
45#define irc_elevel 1
46
47static struct {
48 unsigned char level;
49 unsigned char mode;
50} tx4939irq[TX4939_NUM_IR] __read_mostly;
51
52static void tx4939_irq_unmask(unsigned int irq)
53{
54 unsigned int irq_nr = irq - TXX9_IRQ_BASE;
55 u32 __iomem *lvlp;
56 int ofs;
57 if (irq_nr < 32) {
58 irq_nr--;
59 lvlp = &tx4939_ircptr->lvl[(irq_nr % 16) / 2].r;
60 } else {
61 irq_nr -= 32;
62 lvlp = &tx4939_ircptr->lvl[8 + (irq_nr % 16) / 2].r;
63 }
64 ofs = (irq_nr & 16) + (irq_nr & 1) * 8;
65 __raw_writel((__raw_readl(lvlp) & ~(0xff << ofs))
66 | (tx4939irq[irq_nr].level << ofs),
67 lvlp);
68}
69
70static inline void tx4939_irq_mask(unsigned int irq)
71{
72 unsigned int irq_nr = irq - TXX9_IRQ_BASE;
73 u32 __iomem *lvlp;
74 int ofs;
75 if (irq_nr < 32) {
76 irq_nr--;
77 lvlp = &tx4939_ircptr->lvl[(irq_nr % 16) / 2].r;
78 } else {
79 irq_nr -= 32;
80 lvlp = &tx4939_ircptr->lvl[8 + (irq_nr % 16) / 2].r;
81 }
82 ofs = (irq_nr & 16) + (irq_nr & 1) * 8;
83 __raw_writel((__raw_readl(lvlp) & ~(0xff << ofs))
84 | (irc_dlevel << ofs),
85 lvlp);
86 mmiowb();
87}
88
89static void tx4939_irq_mask_ack(unsigned int irq)
90{
91 unsigned int irq_nr = irq - TXX9_IRQ_BASE;
92
93 tx4939_irq_mask(irq);
94 if (TXx9_IRCR_EDGE(tx4939irq[irq_nr].mode)) {
95 irq_nr--;
96 /* clear edge detection */
97 __raw_writel((TXx9_IRSCR_EIClrE | (irq_nr & 0xf))
98 << (irq_nr & 0x10),
99 &tx4939_ircptr->edc.r);
100 }
101}
102
103static int tx4939_irq_set_type(unsigned int irq, unsigned int flow_type)
104{
105 unsigned int irq_nr = irq - TXX9_IRQ_BASE;
106 u32 cr;
107 u32 __iomem *crp;
108 int ofs;
109 int mode;
110
111 if (flow_type & IRQF_TRIGGER_PROBE)
112 return 0;
113 switch (flow_type & IRQF_TRIGGER_MASK) {
114 case IRQF_TRIGGER_RISING:
115 mode = TXx9_IRCR_UP;
116 break;
117 case IRQF_TRIGGER_FALLING:
118 mode = TXx9_IRCR_DOWN;
119 break;
120 case IRQF_TRIGGER_HIGH:
121 mode = TXx9_IRCR_HIGH;
122 break;
123 case IRQF_TRIGGER_LOW:
124 mode = TXx9_IRCR_LOW;
125 break;
126 default:
127 return -EINVAL;
128 }
129 if (irq_nr < 32) {
130 irq_nr--;
131 crp = &tx4939_ircptr->dm[(irq_nr & 8) >> 3].r;
132 } else {
133 irq_nr -= 32;
134 crp = &tx4939_ircptr->dm2[((irq_nr & 8) >> 3)].r;
135 }
136 ofs = (((irq_nr & 16) >> 1) | (irq_nr & (8 - 1))) * 2;
137 cr = __raw_readl(crp);
138 cr &= ~(0x3 << ofs);
139 cr |= (mode & 0x3) << ofs;
140 __raw_writel(cr, crp);
141 tx4939irq[irq_nr].mode = mode;
142 return 0;
143}
144
145static struct irq_chip tx4939_irq_chip = {
146 .name = "TX4939",
147 .ack = tx4939_irq_mask_ack,
148 .mask = tx4939_irq_mask,
149 .mask_ack = tx4939_irq_mask_ack,
150 .unmask = tx4939_irq_unmask,
151 .set_type = tx4939_irq_set_type,
152};
153
154static int tx4939_irq_set_pri(int irc_irq, int new_pri)
155{
156 int old_pri;
157
158 if ((unsigned int)irc_irq >= TX4939_NUM_IR)
159 return 0;
160 old_pri = tx4939irq[irc_irq].level;
161 tx4939irq[irc_irq].level = new_pri;
162 return old_pri;
163}
164
165void __init tx4939_irq_init(void)
166{
167 int i;
168
169 mips_cpu_irq_init();
170 /* disable interrupt control */
171 __raw_writel(0, &tx4939_ircptr->den.r);
172 __raw_writel(0, &tx4939_ircptr->maskint.r);
173 __raw_writel(0, &tx4939_ircptr->maskext.r);
174 /* irq_base + 0 is not used */
175 for (i = 1; i < TX4939_NUM_IR; i++) {
176 tx4939irq[i].level = 4; /* middle level */
177 tx4939irq[i].mode = TXx9_IRCR_LOW;
178 set_irq_chip_and_handler(TXX9_IRQ_BASE + i,
179 &tx4939_irq_chip, handle_level_irq);
180 }
181
182 /* mask all IRC interrupts */
183 __raw_writel(0, &tx4939_ircptr->msk.r);
184 for (i = 0; i < 16; i++)
185 __raw_writel(0, &tx4939_ircptr->lvl[i].r);
186 /* setup IRC interrupt mode (Low Active) */
187 for (i = 0; i < 2; i++)
188 __raw_writel(0, &tx4939_ircptr->dm[i].r);
189 for (i = 0; i < 2; i++)
190 __raw_writel(0, &tx4939_ircptr->dm2[i].r);
191 /* enable interrupt control */
192 __raw_writel(TXx9_IRCER_ICE, &tx4939_ircptr->den.r);
193 __raw_writel(irc_elevel, &tx4939_ircptr->msk.r);
194
195 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4939_IRC_INT,
196 handle_simple_irq);
197
198 /* raise priority for errors, timers, sio */
199 tx4939_irq_set_pri(TX4939_IR_WTOERR, 7);
200 tx4939_irq_set_pri(TX4939_IR_PCIERR, 7);
201 tx4939_irq_set_pri(TX4939_IR_PCIPME, 7);
202 for (i = 0; i < TX4939_NUM_IR_TMR; i++)
203 tx4939_irq_set_pri(TX4939_IR_TMR(i), 6);
204 for (i = 0; i < TX4939_NUM_IR_SIO; i++)
205 tx4939_irq_set_pri(TX4939_IR_SIO(i), 5);
206}
207
208int tx4939_irq(void)
209{
210 u32 csr = __raw_readl(&tx4939_ircptr->cs.r);
211
212 if (likely(!(csr & TXx9_IRCSR_IF)))
213 return TXX9_IRQ_BASE + (csr & (TX4939_NUM_IR - 1));
214 return -1;
215}
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index fe6bee09cece..5526375010f8 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -22,11 +22,16 @@
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/serial_core.h> 24#include <linux/serial_core.h>
25#include <linux/mtd/physmap.h>
26#include <linux/leds.h>
25#include <asm/bootinfo.h> 27#include <asm/bootinfo.h>
26#include <asm/time.h> 28#include <asm/time.h>
27#include <asm/reboot.h> 29#include <asm/reboot.h>
30#include <asm/r4kcache.h>
31#include <asm/sections.h>
28#include <asm/txx9/generic.h> 32#include <asm/txx9/generic.h>
29#include <asm/txx9/pci.h> 33#include <asm/txx9/pci.h>
34#include <asm/txx9tmr.h>
30#ifdef CONFIG_CPU_TX49XX 35#ifdef CONFIG_CPU_TX49XX
31#include <asm/txx9/tx4938.h> 36#include <asm/txx9/tx4938.h>
32#endif 37#endif
@@ -67,7 +72,12 @@ unsigned int txx9_master_clock;
67unsigned int txx9_cpu_clock; 72unsigned int txx9_cpu_clock;
68unsigned int txx9_gbus_clock; 73unsigned int txx9_gbus_clock;
69 74
75#ifdef CONFIG_CPU_TX39XX
76/* don't enable by default - see errata */
77int txx9_ccfg_toeon __initdata;
78#else
70int txx9_ccfg_toeon __initdata = 1; 79int txx9_ccfg_toeon __initdata = 1;
80#endif
71 81
72/* Minimum CLK support */ 82/* Minimum CLK support */
73 83
@@ -119,39 +129,232 @@ int irq_to_gpio(unsigned irq)
119EXPORT_SYMBOL(irq_to_gpio); 129EXPORT_SYMBOL(irq_to_gpio);
120#endif 130#endif
121 131
122extern struct txx9_board_vec jmr3927_vec; 132#define BOARD_VEC(board) extern struct txx9_board_vec board;
123extern struct txx9_board_vec rbtx4927_vec; 133#include <asm/txx9/boards.h>
124extern struct txx9_board_vec rbtx4937_vec; 134#undef BOARD_VEC
125extern struct txx9_board_vec rbtx4938_vec;
126 135
127struct txx9_board_vec *txx9_board_vec __initdata; 136struct txx9_board_vec *txx9_board_vec __initdata;
128static char txx9_system_type[32]; 137static char txx9_system_type[32];
129 138
130void __init prom_init_cmdline(void) 139static struct txx9_board_vec *board_vecs[] __initdata = {
140#define BOARD_VEC(board) &board,
141#include <asm/txx9/boards.h>
142#undef BOARD_VEC
143};
144
145static struct txx9_board_vec *__init find_board_byname(const char *name)
146{
147 int i;
148
149 /* search board_vecs table */
150 for (i = 0; i < ARRAY_SIZE(board_vecs); i++) {
151 if (strstr(board_vecs[i]->system, name))
152 return board_vecs[i];
153 }
154 return NULL;
155}
156
157static void __init prom_init_cmdline(void)
131{ 158{
132 int argc = (int)fw_arg0; 159 int argc = (int)fw_arg0;
133 char **argv = (char **)fw_arg1; 160 int *argv32 = (int *)fw_arg1;
134 int i; /* Always ignore the "-c" at argv[0] */ 161 int i; /* Always ignore the "-c" at argv[0] */
135#ifdef CONFIG_64BIT 162 char builtin[CL_SIZE];
136 char *fixed_argv[32];
137 for (i = 0; i < argc; i++)
138 fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
139 argv = fixed_argv;
140#endif
141 163
142 /* ignore all built-in args if any f/w args given */ 164 /* ignore all built-in args if any f/w args given */
143 if (argc > 1) 165 /*
144 *arcs_cmdline = '\0'; 166 * But if built-in strings was started with '+', append them
167 * to command line args. If built-in was started with '-',
168 * ignore all f/w args.
169 */
170 builtin[0] = '\0';
171 if (arcs_cmdline[0] == '+')
172 strcpy(builtin, arcs_cmdline + 1);
173 else if (arcs_cmdline[0] == '-') {
174 strcpy(builtin, arcs_cmdline + 1);
175 argc = 0;
176 } else if (argc <= 1)
177 strcpy(builtin, arcs_cmdline);
178 arcs_cmdline[0] = '\0';
145 179
146 for (i = 1; i < argc; i++) { 180 for (i = 1; i < argc; i++) {
181 char *str = (char *)(long)argv32[i];
147 if (i != 1) 182 if (i != 1)
148 strcat(arcs_cmdline, " "); 183 strcat(arcs_cmdline, " ");
149 strcat(arcs_cmdline, argv[i]); 184 if (strchr(str, ' ')) {
185 strcat(arcs_cmdline, "\"");
186 strcat(arcs_cmdline, str);
187 strcat(arcs_cmdline, "\"");
188 } else
189 strcat(arcs_cmdline, str);
190 }
191 /* append saved builtin args */
192 if (builtin[0]) {
193 if (arcs_cmdline[0])
194 strcat(arcs_cmdline, " ");
195 strcat(arcs_cmdline, builtin);
150 } 196 }
151} 197}
152 198
153void __init prom_init(void) 199static int txx9_ic_disable __initdata;
200static int txx9_dc_disable __initdata;
201
202#if defined(CONFIG_CPU_TX49XX)
203/* flush all cache on very early stage (before 4k_cache_init) */
204static void __init early_flush_dcache(void)
154{ 205{
206 unsigned int conf = read_c0_config();
207 unsigned int dc_size = 1 << (12 + ((conf & CONF_DC) >> 6));
208 unsigned int linesz = 32;
209 unsigned long addr, end;
210
211 end = INDEX_BASE + dc_size / 4;
212 /* 4way, waybit=0 */
213 for (addr = INDEX_BASE; addr < end; addr += linesz) {
214 cache_op(Index_Writeback_Inv_D, addr | 0);
215 cache_op(Index_Writeback_Inv_D, addr | 1);
216 cache_op(Index_Writeback_Inv_D, addr | 2);
217 cache_op(Index_Writeback_Inv_D, addr | 3);
218 }
219}
220
221static void __init txx9_cache_fixup(void)
222{
223 unsigned int conf;
224
225 conf = read_c0_config();
226 /* flush and disable */
227 if (txx9_ic_disable) {
228 conf |= TX49_CONF_IC;
229 write_c0_config(conf);
230 }
231 if (txx9_dc_disable) {
232 early_flush_dcache();
233 conf |= TX49_CONF_DC;
234 write_c0_config(conf);
235 }
236
237 /* enable cache */
238 conf = read_c0_config();
239 if (!txx9_ic_disable)
240 conf &= ~TX49_CONF_IC;
241 if (!txx9_dc_disable)
242 conf &= ~TX49_CONF_DC;
243 write_c0_config(conf);
244
245 if (conf & TX49_CONF_IC)
246 pr_info("TX49XX I-Cache disabled.\n");
247 if (conf & TX49_CONF_DC)
248 pr_info("TX49XX D-Cache disabled.\n");
249}
250#elif defined(CONFIG_CPU_TX39XX)
251/* flush all cache on very early stage (before tx39_cache_init) */
252static void __init early_flush_dcache(void)
253{
254 unsigned int conf = read_c0_config();
255 unsigned int dc_size = 1 << (10 + ((conf & TX39_CONF_DCS_MASK) >>
256 TX39_CONF_DCS_SHIFT));
257 unsigned int linesz = 16;
258 unsigned long addr, end;
259
260 end = INDEX_BASE + dc_size / 2;
261 /* 2way, waybit=0 */
262 for (addr = INDEX_BASE; addr < end; addr += linesz) {
263 cache_op(Index_Writeback_Inv_D, addr | 0);
264 cache_op(Index_Writeback_Inv_D, addr | 1);
265 }
266}
267
268static void __init txx9_cache_fixup(void)
269{
270 unsigned int conf;
271
272 conf = read_c0_config();
273 /* flush and disable */
274 if (txx9_ic_disable) {
275 conf &= ~TX39_CONF_ICE;
276 write_c0_config(conf);
277 }
278 if (txx9_dc_disable) {
279 early_flush_dcache();
280 conf &= ~TX39_CONF_DCE;
281 write_c0_config(conf);
282 }
283
284 /* enable cache */
285 conf = read_c0_config();
286 if (!txx9_ic_disable)
287 conf |= TX39_CONF_ICE;
288 if (!txx9_dc_disable)
289 conf |= TX39_CONF_DCE;
290 write_c0_config(conf);
291
292 if (!(conf & TX39_CONF_ICE))
293 pr_info("TX39XX I-Cache disabled.\n");
294 if (!(conf & TX39_CONF_DCE))
295 pr_info("TX39XX D-Cache disabled.\n");
296}
297#else
298static inline void txx9_cache_fixup(void)
299{
300}
301#endif
302
303static void __init preprocess_cmdline(void)
304{
305 char cmdline[CL_SIZE];
306 char *s;
307
308 strcpy(cmdline, arcs_cmdline);
309 s = cmdline;
310 arcs_cmdline[0] = '\0';
311 while (s && *s) {
312 char *str = strsep(&s, " ");
313 if (strncmp(str, "board=", 6) == 0) {
314 txx9_board_vec = find_board_byname(str + 6);
315 continue;
316 } else if (strncmp(str, "masterclk=", 10) == 0) {
317 unsigned long val;
318 if (strict_strtoul(str + 10, 10, &val) == 0)
319 txx9_master_clock = val;
320 continue;
321 } else if (strcmp(str, "icdisable") == 0) {
322 txx9_ic_disable = 1;
323 continue;
324 } else if (strcmp(str, "dcdisable") == 0) {
325 txx9_dc_disable = 1;
326 continue;
327 } else if (strcmp(str, "toeoff") == 0) {
328 txx9_ccfg_toeon = 0;
329 continue;
330 } else if (strcmp(str, "toeon") == 0) {
331 txx9_ccfg_toeon = 1;
332 continue;
333 }
334 if (arcs_cmdline[0])
335 strcat(arcs_cmdline, " ");
336 strcat(arcs_cmdline, str);
337 }
338
339 txx9_cache_fixup();
340}
341
342static void __init select_board(void)
343{
344 const char *envstr;
345
346 /* first, determine by "board=" argument in preprocess_cmdline() */
347 if (txx9_board_vec)
348 return;
349 /* next, determine by "board" envvar */
350 envstr = prom_getenv("board");
351 if (envstr) {
352 txx9_board_vec = find_board_byname(envstr);
353 if (txx9_board_vec)
354 return;
355 }
356
357 /* select "default" board */
155#ifdef CONFIG_CPU_TX39XX 358#ifdef CONFIG_CPU_TX39XX
156 txx9_board_vec = &jmr3927_vec; 359 txx9_board_vec = &jmr3927_vec;
157#endif 360#endif
@@ -170,8 +373,20 @@ void __init prom_init(void)
170 txx9_board_vec = &rbtx4938_vec; 373 txx9_board_vec = &rbtx4938_vec;
171 break; 374 break;
172#endif 375#endif
376#ifdef CONFIG_TOSHIBA_RBTX4939
377 case 0x4939:
378 txx9_board_vec = &rbtx4939_vec;
379 break;
380#endif
173 } 381 }
174#endif 382#endif
383}
384
385void __init prom_init(void)
386{
387 prom_init_cmdline();
388 preprocess_cmdline();
389 select_board();
175 390
176 strcpy(txx9_system_type, txx9_board_vec->system); 391 strcpy(txx9_system_type, txx9_board_vec->system);
177 392
@@ -180,6 +395,11 @@ void __init prom_init(void)
180 395
181void __init prom_free_prom_memory(void) 396void __init prom_free_prom_memory(void)
182{ 397{
398 unsigned long saddr = PAGE_SIZE;
399 unsigned long eaddr = __pa_symbol(&_text);
400
401 if (saddr < eaddr)
402 free_init_pages("prom memory", saddr, eaddr);
183} 403}
184 404
185const char *get_system_type(void) 405const char *get_system_type(void)
@@ -192,6 +412,21 @@ char * __init prom_getcmdline(void)
192 return &(arcs_cmdline[0]); 412 return &(arcs_cmdline[0]);
193} 413}
194 414
415const char *__init prom_getenv(const char *name)
416{
417 const s32 *str = (const s32 *)fw_arg2;
418
419 if (!str)
420 return NULL;
421 /* YAMON style ("name", "value" pairs) */
422 while (str[0] && str[1]) {
423 if (!strcmp((const char *)(unsigned long)str[0], name))
424 return (const char *)(unsigned long)str[1];
425 str += 2;
426 }
427 return NULL;
428}
429
195static void __noreturn txx9_machine_halt(void) 430static void __noreturn txx9_machine_halt(void)
196{ 431{
197 local_irq_disable(); 432 local_irq_disable();
@@ -222,6 +457,20 @@ void __init txx9_wdt_init(unsigned long base)
222 platform_device_register_simple("txx9wdt", -1, &res, 1); 457 platform_device_register_simple("txx9wdt", -1, &res, 1);
223} 458}
224 459
460void txx9_wdt_now(unsigned long base)
461{
462 struct txx9_tmr_reg __iomem *tmrptr =
463 ioremap(base, sizeof(struct txx9_tmr_reg));
464 /* disable watch dog timer */
465 __raw_writel(TXx9_TMWTMR_WDIS | TXx9_TMWTMR_TWC, &tmrptr->wtmr);
466 __raw_writel(0, &tmrptr->tcr);
467 /* kick watchdog */
468 __raw_writel(TXx9_TMWTMR_TWIE, &tmrptr->wtmr);
469 __raw_writel(1, &tmrptr->cpra); /* immediate */
470 __raw_writel(TXx9_TMTCR_TCE | TXx9_TMTCR_CCDE | TXx9_TMTCR_TMODE_WDOG,
471 &tmrptr->tcr);
472}
473
225/* SPI support */ 474/* SPI support */
226void __init txx9_spi_init(int busid, unsigned long base, int irq) 475void __init txx9_spi_init(int busid, unsigned long base, int irq)
227{ 476{
@@ -372,3 +621,153 @@ static unsigned long __swizzle_addr_none(unsigned long port)
372unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none; 621unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
373EXPORT_SYMBOL(__swizzle_addr_b); 622EXPORT_SYMBOL(__swizzle_addr_b);
374#endif 623#endif
624
625void __init txx9_physmap_flash_init(int no, unsigned long addr,
626 unsigned long size,
627 const struct physmap_flash_data *pdata)
628{
629#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
630 struct resource res = {
631 .start = addr,
632 .end = addr + size - 1,
633 .flags = IORESOURCE_MEM,
634 };
635 struct platform_device *pdev;
636#ifdef CONFIG_MTD_PARTITIONS
637 static struct mtd_partition parts[2];
638 struct physmap_flash_data pdata_part;
639
640 /* If this area contained boot area, make separate partition */
641 if (pdata->nr_parts == 0 && !pdata->parts &&
642 addr < 0x1fc00000 && addr + size > 0x1fc00000 &&
643 !parts[0].name) {
644 parts[0].name = "boot";
645 parts[0].offset = 0x1fc00000 - addr;
646 parts[0].size = addr + size - 0x1fc00000;
647 parts[1].name = "user";
648 parts[1].offset = 0;
649 parts[1].size = 0x1fc00000 - addr;
650 pdata_part = *pdata;
651 pdata_part.nr_parts = ARRAY_SIZE(parts);
652 pdata_part.parts = parts;
653 pdata = &pdata_part;
654 }
655#endif
656 pdev = platform_device_alloc("physmap-flash", no);
657 if (!pdev ||
658 platform_device_add_resources(pdev, &res, 1) ||
659 platform_device_add_data(pdev, pdata, sizeof(*pdata)) ||
660 platform_device_add(pdev))
661 platform_device_put(pdev);
662#endif
663}
664
665#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
666static DEFINE_SPINLOCK(txx9_iocled_lock);
667
668#define TXX9_IOCLED_MAXLEDS 8
669
670struct txx9_iocled_data {
671 struct gpio_chip chip;
672 u8 cur_val;
673 void __iomem *mmioaddr;
674 struct gpio_led_platform_data pdata;
675 struct gpio_led leds[TXX9_IOCLED_MAXLEDS];
676 char names[TXX9_IOCLED_MAXLEDS][32];
677};
678
679static int txx9_iocled_get(struct gpio_chip *chip, unsigned int offset)
680{
681 struct txx9_iocled_data *data =
682 container_of(chip, struct txx9_iocled_data, chip);
683 return data->cur_val & (1 << offset);
684}
685
686static void txx9_iocled_set(struct gpio_chip *chip, unsigned int offset,
687 int value)
688{
689 struct txx9_iocled_data *data =
690 container_of(chip, struct txx9_iocled_data, chip);
691 unsigned long flags;
692 spin_lock_irqsave(&txx9_iocled_lock, flags);
693 if (value)
694 data->cur_val |= 1 << offset;
695 else
696 data->cur_val &= ~(1 << offset);
697 writeb(data->cur_val, data->mmioaddr);
698 mmiowb();
699 spin_unlock_irqrestore(&txx9_iocled_lock, flags);
700}
701
702static int txx9_iocled_dir_in(struct gpio_chip *chip, unsigned int offset)
703{
704 return 0;
705}
706
707static int txx9_iocled_dir_out(struct gpio_chip *chip, unsigned int offset,
708 int value)
709{
710 txx9_iocled_set(chip, offset, value);
711 return 0;
712}
713
714void __init txx9_iocled_init(unsigned long baseaddr,
715 int basenum, unsigned int num, int lowactive,
716 const char *color, char **deftriggers)
717{
718 struct txx9_iocled_data *iocled;
719 struct platform_device *pdev;
720 int i;
721 static char *default_triggers[] __initdata = {
722 "heartbeat",
723 "ide-disk",
724 "nand-disk",
725 NULL,
726 };
727
728 if (!deftriggers)
729 deftriggers = default_triggers;
730 iocled = kzalloc(sizeof(*iocled), GFP_KERNEL);
731 if (!iocled)
732 return;
733 iocled->mmioaddr = ioremap(baseaddr, 1);
734 if (!iocled->mmioaddr)
735 return;
736 iocled->chip.get = txx9_iocled_get;
737 iocled->chip.set = txx9_iocled_set;
738 iocled->chip.direction_input = txx9_iocled_dir_in;
739 iocled->chip.direction_output = txx9_iocled_dir_out;
740 iocled->chip.label = "iocled";
741 iocled->chip.base = basenum;
742 iocled->chip.ngpio = num;
743 if (gpiochip_add(&iocled->chip))
744 return;
745 if (basenum < 0)
746 basenum = iocled->chip.base;
747
748 pdev = platform_device_alloc("leds-gpio", basenum);
749 if (!pdev)
750 return;
751 iocled->pdata.num_leds = num;
752 iocled->pdata.leds = iocled->leds;
753 for (i = 0; i < num; i++) {
754 struct gpio_led *led = &iocled->leds[i];
755 snprintf(iocled->names[i], sizeof(iocled->names[i]),
756 "iocled:%s:%u", color, i);
757 led->name = iocled->names[i];
758 led->gpio = basenum + i;
759 led->active_low = lowactive;
760 if (deftriggers && *deftriggers)
761 led->default_trigger = *deftriggers++;
762 }
763 pdev->dev.platform_data = &iocled->pdata;
764 if (platform_device_add(pdev))
765 platform_device_put(pdev);
766}
767#else /* CONFIG_LEDS_GPIO */
768void __init txx9_iocled_init(unsigned long baseaddr,
769 int basenum, unsigned int num, int lowactive,
770 const char *color, char **deftriggers)
771{
772}
773#endif /* CONFIG_LEDS_GPIO */
diff --git a/arch/mips/txx9/generic/setup_tx3927.c b/arch/mips/txx9/generic/setup_tx3927.c
index 7bd963d37fc3..9505d58454c8 100644
--- a/arch/mips/txx9/generic/setup_tx3927.c
+++ b/arch/mips/txx9/generic/setup_tx3927.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/param.h> 16#include <linux/param.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/mtd/physmap.h>
18#include <asm/mipsregs.h> 19#include <asm/mipsregs.h>
19#include <asm/txx9irq.h> 20#include <asm/txx9irq.h>
20#include <asm/txx9tmr.h> 21#include <asm/txx9tmr.h>
@@ -32,11 +33,6 @@ void __init tx3927_setup(void)
32 int i; 33 int i;
33 unsigned int conf; 34 unsigned int conf;
34 35
35 /* don't enable - see errata */
36 txx9_ccfg_toeon = 0;
37 if (strstr(prom_getcmdline(), "toeon") != NULL)
38 txx9_ccfg_toeon = 1;
39
40 txx9_reg_res_init(TX3927_REV_PCODE(), TX3927_REG_BASE, 36 txx9_reg_res_init(TX3927_REV_PCODE(), TX3927_REG_BASE,
41 TX3927_REG_SIZE); 37 TX3927_REG_SIZE);
42 38
@@ -99,16 +95,14 @@ void __init tx3927_setup(void)
99 txx9_gpio_init(TX3927_PIO_REG, 0, 16); 95 txx9_gpio_init(TX3927_PIO_REG, 0, 16);
100 96
101 conf = read_c0_conf(); 97 conf = read_c0_conf();
102 if (!(conf & TX39_CONF_ICE)) 98 if (conf & TX39_CONF_DCE) {
103 printk(KERN_INFO "TX3927 I-Cache disabled.\n"); 99 if (!(conf & TX39_CONF_WBON))
104 if (!(conf & TX39_CONF_DCE)) 100 pr_info("TX3927 D-Cache WriteThrough.\n");
105 printk(KERN_INFO "TX3927 D-Cache disabled.\n"); 101 else if (!(conf & TX39_CONF_CWFON))
106 else if (!(conf & TX39_CONF_WBON)) 102 pr_info("TX3927 D-Cache WriteBack.\n");
107 printk(KERN_INFO "TX3927 D-Cache WriteThrough.\n"); 103 else
108 else if (!(conf & TX39_CONF_CWFON)) 104 pr_info("TX3927 D-Cache WriteBack (CWF) .\n");
109 printk(KERN_INFO "TX3927 D-Cache WriteBack.\n"); 105 }
110 else
111 printk(KERN_INFO "TX3927 D-Cache WriteBack (CWF) .\n");
112} 106}
113 107
114void __init tx3927_time_init(unsigned int evt_tmrnr, unsigned int src_tmrnr) 108void __init tx3927_time_init(unsigned int evt_tmrnr, unsigned int src_tmrnr)
@@ -128,3 +122,16 @@ void __init tx3927_sio_init(unsigned int sclk, unsigned int cts_mask)
128 TXX9_IRQ_BASE + TX3927_IR_SIO(i), 122 TXX9_IRQ_BASE + TX3927_IR_SIO(i),
129 i, sclk, (1 << i) & cts_mask); 123 i, sclk, (1 << i) & cts_mask);
130} 124}
125
126void __init tx3927_mtd_init(int ch)
127{
128 struct physmap_flash_data pdata = {
129 .width = TX3927_ROMC_WIDTH(ch) / 8,
130 };
131 unsigned long start = txx9_ce_res[ch].start;
132 unsigned long size = txx9_ce_res[ch].end - start + 1;
133
134 if (!(tx3927_romcptr->cr[ch] & 0x8))
135 return; /* disabled */
136 txx9_physmap_flash_init(ch, start, size, &pdata);
137}
diff --git a/arch/mips/txx9/generic/setup_tx4927.c b/arch/mips/txx9/generic/setup_tx4927.c
index f80d4b7a694d..914e93c62639 100644
--- a/arch/mips/txx9/generic/setup_tx4927.c
+++ b/arch/mips/txx9/generic/setup_tx4927.c
@@ -14,6 +14,10 @@
14#include <linux/ioport.h> 14#include <linux/ioport.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/param.h> 16#include <linux/param.h>
17#include <linux/ptrace.h>
18#include <linux/mtd/physmap.h>
19#include <asm/reboot.h>
20#include <asm/traps.h>
17#include <asm/txx9irq.h> 21#include <asm/txx9irq.h>
18#include <asm/txx9tmr.h> 22#include <asm/txx9tmr.h>
19#include <asm/txx9pio.h> 23#include <asm/txx9pio.h>
@@ -22,6 +26,10 @@
22 26
23static void __init tx4927_wdr_init(void) 27static void __init tx4927_wdr_init(void)
24{ 28{
29 /* report watchdog reset status */
30 if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_WDRST)
31 pr_warning("Watchdog reset detected at 0x%lx\n",
32 read_c0_errorepc());
25 /* clear WatchDogReset (W1C) */ 33 /* clear WatchDogReset (W1C) */
26 tx4927_ccfg_set(TX4927_CCFG_WDRST); 34 tx4927_ccfg_set(TX4927_CCFG_WDRST);
27 /* do reset on watchdog */ 35 /* do reset on watchdog */
@@ -33,6 +41,47 @@ void __init tx4927_wdt_init(void)
33 txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL); 41 txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL);
34} 42}
35 43
44static void tx4927_machine_restart(char *command)
45{
46 local_irq_disable();
47 pr_emerg("Rebooting (with %s watchdog reset)...\n",
48 (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_WDREXEN) ?
49 "external" : "internal");
50 /* clear watchdog status */
51 tx4927_ccfg_set(TX4927_CCFG_WDRST); /* W1C */
52 txx9_wdt_now(TX4927_TMR_REG(2) & 0xfffffffffULL);
53 while (!(____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_WDRST))
54 ;
55 mdelay(10);
56 if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_WDREXEN) {
57 pr_emerg("Rebooting (with internal watchdog reset)...\n");
58 /* External WDRST failed. Do internal watchdog reset */
59 tx4927_ccfg_clear(TX4927_CCFG_WDREXEN);
60 }
61 /* fallback */
62 (*_machine_halt)();
63}
64
65void show_registers(struct pt_regs *regs);
66static int tx4927_be_handler(struct pt_regs *regs, int is_fixup)
67{
68 int data = regs->cp0_cause & 4;
69 console_verbose();
70 pr_err("%cBE exception at %#lx\n", data ? 'D' : 'I', regs->cp0_epc);
71 pr_err("ccfg:%llx, toea:%llx\n",
72 (unsigned long long)____raw_readq(&tx4927_ccfgptr->ccfg),
73 (unsigned long long)____raw_readq(&tx4927_ccfgptr->toea));
74#ifdef CONFIG_PCI
75 tx4927_report_pcic_status();
76#endif
77 show_registers(regs);
78 panic("BusError!");
79}
80static void __init tx4927_be_init(void)
81{
82 board_be_handler = tx4927_be_handler;
83}
84
36static struct resource tx4927_sdram_resource[4]; 85static struct resource tx4927_sdram_resource[4];
37 86
38void __init tx4927_setup(void) 87void __init tx4927_setup(void)
@@ -44,6 +93,7 @@ void __init tx4927_setup(void)
44 93
45 txx9_reg_res_init(TX4927_REV_PCODE(), TX4927_REG_BASE, 94 txx9_reg_res_init(TX4927_REV_PCODE(), TX4927_REG_BASE,
46 TX4927_REG_SIZE); 95 TX4927_REG_SIZE);
96 set_c0_config(TX49_CONF_CWFON);
47 97
48 /* SDRAMC,EBUSC are configured by PROM */ 98 /* SDRAMC,EBUSC are configured by PROM */
49 for (i = 0; i < 8; i++) { 99 for (i = 0; i < 8; i++) {
@@ -167,6 +217,9 @@ void __init tx4927_setup(void)
167 txx9_gpio_init(TX4927_PIO_REG & 0xfffffffffULL, 0, TX4927_NUM_PIO); 217 txx9_gpio_init(TX4927_PIO_REG & 0xfffffffffULL, 0, TX4927_NUM_PIO);
168 __raw_writel(0, &tx4927_pioptr->maskcpu); 218 __raw_writel(0, &tx4927_pioptr->maskcpu);
169 __raw_writel(0, &tx4927_pioptr->maskext); 219 __raw_writel(0, &tx4927_pioptr->maskext);
220
221 _machine_restart = tx4927_machine_restart;
222 board_be_init = tx4927_be_init;
170} 223}
171 224
172void __init tx4927_time_init(unsigned int tmrnr) 225void __init tx4927_time_init(unsigned int tmrnr)
@@ -186,3 +239,47 @@ void __init tx4927_sio_init(unsigned int sclk, unsigned int cts_mask)
186 TXX9_IRQ_BASE + TX4927_IR_SIO(i), 239 TXX9_IRQ_BASE + TX4927_IR_SIO(i),
187 i, sclk, (1 << i) & cts_mask); 240 i, sclk, (1 << i) & cts_mask);
188} 241}
242
243void __init tx4927_mtd_init(int ch)
244{
245 struct physmap_flash_data pdata = {
246 .width = TX4927_EBUSC_WIDTH(ch) / 8,
247 };
248 unsigned long start = txx9_ce_res[ch].start;
249 unsigned long size = txx9_ce_res[ch].end - start + 1;
250
251 if (!(TX4927_EBUSC_CR(ch) & 0x8))
252 return; /* disabled */
253 txx9_physmap_flash_init(ch, start, size, &pdata);
254}
255
256static void __init tx4927_stop_unused_modules(void)
257{
258 __u64 pcfg, rst = 0, ckd = 0;
259 char buf[128];
260
261 buf[0] = '\0';
262 local_irq_disable();
263 pcfg = ____raw_readq(&tx4927_ccfgptr->pcfg);
264 if (!(pcfg & TX4927_PCFG_SEL2)) {
265 rst |= TX4927_CLKCTR_ACLRST;
266 ckd |= TX4927_CLKCTR_ACLCKD;
267 strcat(buf, " ACLC");
268 }
269 if (rst | ckd) {
270 txx9_set64(&tx4927_ccfgptr->clkctr, rst);
271 txx9_set64(&tx4927_ccfgptr->clkctr, ckd);
272 }
273 local_irq_enable();
274 if (buf[0])
275 pr_info("%s: stop%s\n", txx9_pcode_str, buf);
276}
277
278static int __init tx4927_late_init(void)
279{
280 if (txx9_pcode != 0x4927)
281 return -ENODEV;
282 tx4927_stop_unused_modules();
283 return 0;
284}
285late_initcall(tx4927_late_init);
diff --git a/arch/mips/txx9/generic/setup_tx4938.c b/arch/mips/txx9/generic/setup_tx4938.c
index f3040b9ba059..af724e53ef91 100644
--- a/arch/mips/txx9/generic/setup_tx4938.c
+++ b/arch/mips/txx9/generic/setup_tx4938.c
@@ -14,6 +14,10 @@
14#include <linux/ioport.h> 14#include <linux/ioport.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/param.h> 16#include <linux/param.h>
17#include <linux/ptrace.h>
18#include <linux/mtd/physmap.h>
19#include <asm/reboot.h>
20#include <asm/traps.h>
17#include <asm/txx9irq.h> 21#include <asm/txx9irq.h>
18#include <asm/txx9tmr.h> 22#include <asm/txx9tmr.h>
19#include <asm/txx9pio.h> 23#include <asm/txx9pio.h>
@@ -22,6 +26,10 @@
22 26
23static void __init tx4938_wdr_init(void) 27static void __init tx4938_wdr_init(void)
24{ 28{
29 /* report watchdog reset status */
30 if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_WDRST)
31 pr_warning("Watchdog reset detected at 0x%lx\n",
32 read_c0_errorepc());
25 /* clear WatchDogReset (W1C) */ 33 /* clear WatchDogReset (W1C) */
26 tx4938_ccfg_set(TX4938_CCFG_WDRST); 34 tx4938_ccfg_set(TX4938_CCFG_WDRST);
27 /* do reset on watchdog */ 35 /* do reset on watchdog */
@@ -33,6 +41,47 @@ void __init tx4938_wdt_init(void)
33 txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL); 41 txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL);
34} 42}
35 43
44static void tx4938_machine_restart(char *command)
45{
46 local_irq_disable();
47 pr_emerg("Rebooting (with %s watchdog reset)...\n",
48 (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_WDREXEN) ?
49 "external" : "internal");
50 /* clear watchdog status */
51 tx4938_ccfg_set(TX4938_CCFG_WDRST); /* W1C */
52 txx9_wdt_now(TX4938_TMR_REG(2) & 0xfffffffffULL);
53 while (!(____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_WDRST))
54 ;
55 mdelay(10);
56 if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_WDREXEN) {
57 pr_emerg("Rebooting (with internal watchdog reset)...\n");
58 /* External WDRST failed. Do internal watchdog reset */
59 tx4938_ccfg_clear(TX4938_CCFG_WDREXEN);
60 }
61 /* fallback */
62 (*_machine_halt)();
63}
64
65void show_registers(struct pt_regs *regs);
66static int tx4938_be_handler(struct pt_regs *regs, int is_fixup)
67{
68 int data = regs->cp0_cause & 4;
69 console_verbose();
70 pr_err("%cBE exception at %#lx\n", data ? 'D' : 'I', regs->cp0_epc);
71 pr_err("ccfg:%llx, toea:%llx\n",
72 (unsigned long long)____raw_readq(&tx4938_ccfgptr->ccfg),
73 (unsigned long long)____raw_readq(&tx4938_ccfgptr->toea));
74#ifdef CONFIG_PCI
75 tx4927_report_pcic_status();
76#endif
77 show_registers(regs);
78 panic("BusError!");
79}
80static void __init tx4938_be_init(void)
81{
82 board_be_handler = tx4938_be_handler;
83}
84
36static struct resource tx4938_sdram_resource[4]; 85static struct resource tx4938_sdram_resource[4];
37static struct resource tx4938_sram_resource; 86static struct resource tx4938_sram_resource;
38 87
@@ -47,6 +96,7 @@ void __init tx4938_setup(void)
47 96
48 txx9_reg_res_init(TX4938_REV_PCODE(), TX4938_REG_BASE, 97 txx9_reg_res_init(TX4938_REV_PCODE(), TX4938_REG_BASE,
49 TX4938_REG_SIZE); 98 TX4938_REG_SIZE);
99 set_c0_config(TX49_CONF_CWFON);
50 100
51 /* SDRAMC,EBUSC are configured by PROM */ 101 /* SDRAMC,EBUSC are configured by PROM */
52 for (i = 0; i < 8; i++) { 102 for (i = 0; i < 8; i++) {
@@ -227,6 +277,9 @@ void __init tx4938_setup(void)
227 TX4938_CLKCTR_ETH1CKD); 277 TX4938_CLKCTR_ETH1CKD);
228 } 278 }
229 } 279 }
280
281 _machine_restart = tx4938_machine_restart;
282 board_be_init = tx4938_be_init;
230} 283}
231 284
232void __init tx4938_time_init(unsigned int tmrnr) 285void __init tx4938_time_init(unsigned int tmrnr)
@@ -268,3 +321,72 @@ void __init tx4938_ethaddr_init(unsigned char *addr0, unsigned char *addr1)
268 if (addr1 && (pcfg & TX4938_PCFG_ETH1_SEL)) 321 if (addr1 && (pcfg & TX4938_PCFG_ETH1_SEL))
269 txx9_ethaddr_init(TXX9_IRQ_BASE + TX4938_IR_ETH1, addr1); 322 txx9_ethaddr_init(TXX9_IRQ_BASE + TX4938_IR_ETH1, addr1);
270} 323}
324
325void __init tx4938_mtd_init(int ch)
326{
327 struct physmap_flash_data pdata = {
328 .width = TX4938_EBUSC_WIDTH(ch) / 8,
329 };
330 unsigned long start = txx9_ce_res[ch].start;
331 unsigned long size = txx9_ce_res[ch].end - start + 1;
332
333 if (!(TX4938_EBUSC_CR(ch) & 0x8))
334 return; /* disabled */
335 txx9_physmap_flash_init(ch, start, size, &pdata);
336}
337
338static void __init tx4938_stop_unused_modules(void)
339{
340 __u64 pcfg, rst = 0, ckd = 0;
341 char buf[128];
342
343 buf[0] = '\0';
344 local_irq_disable();
345 pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg);
346 switch (txx9_pcode) {
347 case 0x4937:
348 if (!(pcfg & TX4938_PCFG_SEL2)) {
349 rst |= TX4938_CLKCTR_ACLRST;
350 ckd |= TX4938_CLKCTR_ACLCKD;
351 strcat(buf, " ACLC");
352 }
353 break;
354 case 0x4938:
355 if (!(pcfg & TX4938_PCFG_SEL2) ||
356 (pcfg & TX4938_PCFG_ETH0_SEL)) {
357 rst |= TX4938_CLKCTR_ACLRST;
358 ckd |= TX4938_CLKCTR_ACLCKD;
359 strcat(buf, " ACLC");
360 }
361 if ((pcfg &
362 (TX4938_PCFG_ATA_SEL | TX4938_PCFG_ISA_SEL |
363 TX4938_PCFG_NDF_SEL))
364 != TX4938_PCFG_NDF_SEL) {
365 rst |= TX4938_CLKCTR_NDFRST;
366 ckd |= TX4938_CLKCTR_NDFCKD;
367 strcat(buf, " NDFMC");
368 }
369 if (!(pcfg & TX4938_PCFG_SPI_SEL)) {
370 rst |= TX4938_CLKCTR_SPIRST;
371 ckd |= TX4938_CLKCTR_SPICKD;
372 strcat(buf, " SPI");
373 }
374 break;
375 }
376 if (rst | ckd) {
377 txx9_set64(&tx4938_ccfgptr->clkctr, rst);
378 txx9_set64(&tx4938_ccfgptr->clkctr, ckd);
379 }
380 local_irq_enable();
381 if (buf[0])
382 pr_info("%s: stop%s\n", txx9_pcode_str, buf);
383}
384
385static int __init tx4938_late_init(void)
386{
387 if (txx9_pcode != 0x4937 && txx9_pcode != 0x4938)
388 return -ENODEV;
389 tx4938_stop_unused_modules();
390 return 0;
391}
392late_initcall(tx4938_late_init);
diff --git a/arch/mips/txx9/generic/setup_tx4939.c b/arch/mips/txx9/generic/setup_tx4939.c
new file mode 100644
index 000000000000..6c0049a5bbc1
--- /dev/null
+++ b/arch/mips/txx9/generic/setup_tx4939.c
@@ -0,0 +1,506 @@
1/*
2 * TX4939 setup routines
3 * Based on linux/arch/mips/txx9/generic/setup_tx4938.c,
4 * and RBTX49xx patch from CELF patch archive.
5 *
6 * 2003-2005 (c) MontaVista Software, Inc.
7 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/ioport.h>
15#include <linux/delay.h>
16#include <linux/netdevice.h>
17#include <linux/notifier.h>
18#include <linux/sysdev.h>
19#include <linux/ethtool.h>
20#include <linux/param.h>
21#include <linux/ptrace.h>
22#include <linux/mtd/physmap.h>
23#include <linux/platform_device.h>
24#include <asm/bootinfo.h>
25#include <asm/reboot.h>
26#include <asm/traps.h>
27#include <asm/txx9irq.h>
28#include <asm/txx9tmr.h>
29#include <asm/txx9/generic.h>
30#include <asm/txx9/tx4939.h>
31
32static void __init tx4939_wdr_init(void)
33{
34 /* report watchdog reset status */
35 if (____raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_WDRST)
36 pr_warning("Watchdog reset detected at 0x%lx\n",
37 read_c0_errorepc());
38 /* clear WatchDogReset (W1C) */
39 tx4939_ccfg_set(TX4939_CCFG_WDRST);
40 /* do reset on watchdog */
41 tx4939_ccfg_set(TX4939_CCFG_WR);
42}
43
44void __init tx4939_wdt_init(void)
45{
46 txx9_wdt_init(TX4939_TMR_REG(2) & 0xfffffffffULL);
47}
48
49static void tx4939_machine_restart(char *command)
50{
51 local_irq_disable();
52 pr_emerg("Rebooting (with %s watchdog reset)...\n",
53 (____raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_WDREXEN) ?
54 "external" : "internal");
55 /* clear watchdog status */
56 tx4939_ccfg_set(TX4939_CCFG_WDRST); /* W1C */
57 txx9_wdt_now(TX4939_TMR_REG(2) & 0xfffffffffULL);
58 while (!(____raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_WDRST))
59 ;
60 mdelay(10);
61 if (____raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_WDREXEN) {
62 pr_emerg("Rebooting (with internal watchdog reset)...\n");
63 /* External WDRST failed. Do internal watchdog reset */
64 tx4939_ccfg_clear(TX4939_CCFG_WDREXEN);
65 }
66 /* fallback */
67 (*_machine_halt)();
68}
69
70void show_registers(struct pt_regs *regs);
71static int tx4939_be_handler(struct pt_regs *regs, int is_fixup)
72{
73 int data = regs->cp0_cause & 4;
74 console_verbose();
75 pr_err("%cBE exception at %#lx\n",
76 data ? 'D' : 'I', regs->cp0_epc);
77 pr_err("ccfg:%llx, toea:%llx\n",
78 (unsigned long long)____raw_readq(&tx4939_ccfgptr->ccfg),
79 (unsigned long long)____raw_readq(&tx4939_ccfgptr->toea));
80#ifdef CONFIG_PCI
81 tx4927_report_pcic_status();
82#endif
83 show_registers(regs);
84 panic("BusError!");
85}
86static void __init tx4939_be_init(void)
87{
88 board_be_handler = tx4939_be_handler;
89}
90
91static struct resource tx4939_sdram_resource[4];
92static struct resource tx4939_sram_resource;
93#define TX4939_SRAM_SIZE 0x800
94
95void __init tx4939_add_memory_regions(void)
96{
97 int i;
98 unsigned long start, size;
99 u64 win;
100
101 for (i = 0; i < 4; i++) {
102 if (!((__u32)____raw_readq(&tx4939_ddrcptr->winen) & (1 << i)))
103 continue;
104 win = ____raw_readq(&tx4939_ddrcptr->win[i]);
105 start = (unsigned long)(win >> 48);
106 size = (((unsigned long)(win >> 32) & 0xffff) + 1) - start;
107 add_memory_region(start << 20, size << 20, BOOT_MEM_RAM);
108 }
109}
110
111void __init tx4939_setup(void)
112{
113 int i;
114 __u32 divmode;
115 __u64 pcfg;
116 int cpuclk = 0;
117
118 txx9_reg_res_init(TX4939_REV_PCODE(), TX4939_REG_BASE,
119 TX4939_REG_SIZE);
120 set_c0_config(TX49_CONF_CWFON);
121
122 /* SDRAMC,EBUSC are configured by PROM */
123 for (i = 0; i < 4; i++) {
124 if (!(TX4939_EBUSC_CR(i) & 0x8))
125 continue; /* disabled */
126 txx9_ce_res[i].start = (unsigned long)TX4939_EBUSC_BA(i);
127 txx9_ce_res[i].end =
128 txx9_ce_res[i].start + TX4939_EBUSC_SIZE(i) - 1;
129 request_resource(&iomem_resource, &txx9_ce_res[i]);
130 }
131
132 /* clocks */
133 if (txx9_master_clock) {
134 /* calculate cpu_clock from master_clock */
135 divmode = (__u32)____raw_readq(&tx4939_ccfgptr->ccfg) &
136 TX4939_CCFG_MULCLK_MASK;
137 cpuclk = txx9_master_clock * 20 / 2;
138 switch (divmode) {
139 case TX4939_CCFG_MULCLK_8:
140 cpuclk = cpuclk / 3 * 4 /* / 6 * 8 */; break;
141 case TX4939_CCFG_MULCLK_9:
142 cpuclk = cpuclk / 2 * 3 /* / 6 * 9 */; break;
143 case TX4939_CCFG_MULCLK_10:
144 cpuclk = cpuclk / 3 * 5 /* / 6 * 10 */; break;
145 case TX4939_CCFG_MULCLK_11:
146 cpuclk = cpuclk / 6 * 11; break;
147 case TX4939_CCFG_MULCLK_12:
148 cpuclk = cpuclk * 2 /* / 6 * 12 */; break;
149 case TX4939_CCFG_MULCLK_13:
150 cpuclk = cpuclk / 6 * 13; break;
151 case TX4939_CCFG_MULCLK_14:
152 cpuclk = cpuclk / 3 * 7 /* / 6 * 14 */; break;
153 case TX4939_CCFG_MULCLK_15:
154 cpuclk = cpuclk / 2 * 5 /* / 6 * 15 */; break;
155 }
156 txx9_cpu_clock = cpuclk;
157 } else {
158 if (txx9_cpu_clock == 0)
159 txx9_cpu_clock = 400000000; /* 400MHz */
160 /* calculate master_clock from cpu_clock */
161 cpuclk = txx9_cpu_clock;
162 divmode = (__u32)____raw_readq(&tx4939_ccfgptr->ccfg) &
163 TX4939_CCFG_MULCLK_MASK;
164 switch (divmode) {
165 case TX4939_CCFG_MULCLK_8:
166 txx9_master_clock = cpuclk * 6 / 8; break;
167 case TX4939_CCFG_MULCLK_9:
168 txx9_master_clock = cpuclk * 6 / 9; break;
169 case TX4939_CCFG_MULCLK_10:
170 txx9_master_clock = cpuclk * 6 / 10; break;
171 case TX4939_CCFG_MULCLK_11:
172 txx9_master_clock = cpuclk * 6 / 11; break;
173 case TX4939_CCFG_MULCLK_12:
174 txx9_master_clock = cpuclk * 6 / 12; break;
175 case TX4939_CCFG_MULCLK_13:
176 txx9_master_clock = cpuclk * 6 / 13; break;
177 case TX4939_CCFG_MULCLK_14:
178 txx9_master_clock = cpuclk * 6 / 14; break;
179 case TX4939_CCFG_MULCLK_15:
180 txx9_master_clock = cpuclk * 6 / 15; break;
181 }
182 txx9_master_clock /= 10; /* * 2 / 20 */
183 }
184 /* calculate gbus_clock from cpu_clock */
185 divmode = (__u32)____raw_readq(&tx4939_ccfgptr->ccfg) &
186 TX4939_CCFG_YDIVMODE_MASK;
187 txx9_gbus_clock = txx9_cpu_clock;
188 switch (divmode) {
189 case TX4939_CCFG_YDIVMODE_2:
190 txx9_gbus_clock /= 2; break;
191 case TX4939_CCFG_YDIVMODE_3:
192 txx9_gbus_clock /= 3; break;
193 case TX4939_CCFG_YDIVMODE_5:
194 txx9_gbus_clock /= 5; break;
195 case TX4939_CCFG_YDIVMODE_6:
196 txx9_gbus_clock /= 6; break;
197 }
198 /* change default value to udelay/mdelay take reasonable time */
199 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
200
201 /* CCFG */
202 tx4939_wdr_init();
203 /* clear BusErrorOnWrite flag (W1C) */
204 tx4939_ccfg_set(TX4939_CCFG_WDRST | TX4939_CCFG_BEOW);
205 /* enable Timeout BusError */
206 if (txx9_ccfg_toeon)
207 tx4939_ccfg_set(TX4939_CCFG_TOE);
208
209 /* DMA selection */
210 txx9_clear64(&tx4939_ccfgptr->pcfg, TX4939_PCFG_DMASEL_ALL);
211
212 /* Use external clock for external arbiter */
213 if (!(____raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_PCIARB))
214 txx9_clear64(&tx4939_ccfgptr->pcfg, TX4939_PCFG_PCICLKEN_ALL);
215
216 pr_info("%s -- %dMHz(M%dMHz,G%dMHz) CRIR:%08x CCFG:%llx PCFG:%llx\n",
217 txx9_pcode_str,
218 (cpuclk + 500000) / 1000000,
219 (txx9_master_clock + 500000) / 1000000,
220 (txx9_gbus_clock + 500000) / 1000000,
221 (__u32)____raw_readq(&tx4939_ccfgptr->crir),
222 (unsigned long long)____raw_readq(&tx4939_ccfgptr->ccfg),
223 (unsigned long long)____raw_readq(&tx4939_ccfgptr->pcfg));
224
225 pr_info("%s DDRC -- EN:%08x", txx9_pcode_str,
226 (__u32)____raw_readq(&tx4939_ddrcptr->winen));
227 for (i = 0; i < 4; i++) {
228 __u64 win = ____raw_readq(&tx4939_ddrcptr->win[i]);
229 if (!((__u32)____raw_readq(&tx4939_ddrcptr->winen) & (1 << i)))
230 continue; /* disabled */
231 printk(KERN_CONT " #%d:%016llx", i, (unsigned long long)win);
232 tx4939_sdram_resource[i].name = "DDR SDRAM";
233 tx4939_sdram_resource[i].start =
234 (unsigned long)(win >> 48) << 20;
235 tx4939_sdram_resource[i].end =
236 ((((unsigned long)(win >> 32) & 0xffff) + 1) <<
237 20) - 1;
238 tx4939_sdram_resource[i].flags = IORESOURCE_MEM;
239 request_resource(&iomem_resource, &tx4939_sdram_resource[i]);
240 }
241 printk(KERN_CONT "\n");
242
243 /* SRAM */
244 if (____raw_readq(&tx4939_sramcptr->cr) & 1) {
245 unsigned int size = TX4939_SRAM_SIZE;
246 tx4939_sram_resource.name = "SRAM";
247 tx4939_sram_resource.start =
248 (____raw_readq(&tx4939_sramcptr->cr) >> (39-11))
249 & ~(size - 1);
250 tx4939_sram_resource.end =
251 tx4939_sram_resource.start + TX4939_SRAM_SIZE - 1;
252 tx4939_sram_resource.flags = IORESOURCE_MEM;
253 request_resource(&iomem_resource, &tx4939_sram_resource);
254 }
255
256 /* TMR */
257 /* disable all timers */
258 for (i = 0; i < TX4939_NR_TMR; i++)
259 txx9_tmr_init(TX4939_TMR_REG(i) & 0xfffffffffULL);
260
261 /* DMA */
262 for (i = 0; i < 2; i++)
263 ____raw_writeq(TX4938_DMA_MCR_MSTEN,
264 (void __iomem *)(TX4939_DMA_REG(i) + 0x50));
265
266 /* set PCIC1 reset (required to prevent hangup on BIST) */
267 txx9_set64(&tx4939_ccfgptr->clkctr, TX4939_CLKCTR_PCI1RST);
268 pcfg = ____raw_readq(&tx4939_ccfgptr->pcfg);
269 if (pcfg & (TX4939_PCFG_ET0MODE | TX4939_PCFG_ET1MODE)) {
270 mdelay(1); /* at least 128 cpu clock */
271 /* clear PCIC1 reset */
272 txx9_clear64(&tx4939_ccfgptr->clkctr, TX4939_CLKCTR_PCI1RST);
273 } else {
274 pr_info("%s: stop PCIC1\n", txx9_pcode_str);
275 /* stop PCIC1 */
276 txx9_set64(&tx4939_ccfgptr->clkctr, TX4939_CLKCTR_PCI1CKD);
277 }
278 if (!(pcfg & TX4939_PCFG_ET0MODE)) {
279 pr_info("%s: stop ETH0\n", txx9_pcode_str);
280 txx9_set64(&tx4939_ccfgptr->clkctr, TX4939_CLKCTR_ETH0RST);
281 txx9_set64(&tx4939_ccfgptr->clkctr, TX4939_CLKCTR_ETH0CKD);
282 }
283 if (!(pcfg & TX4939_PCFG_ET1MODE)) {
284 pr_info("%s: stop ETH1\n", txx9_pcode_str);
285 txx9_set64(&tx4939_ccfgptr->clkctr, TX4939_CLKCTR_ETH1RST);
286 txx9_set64(&tx4939_ccfgptr->clkctr, TX4939_CLKCTR_ETH1CKD);
287 }
288
289 _machine_restart = tx4939_machine_restart;
290 board_be_init = tx4939_be_init;
291}
292
293void __init tx4939_time_init(unsigned int tmrnr)
294{
295 if (____raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_TINTDIS)
296 txx9_clockevent_init(TX4939_TMR_REG(tmrnr) & 0xfffffffffULL,
297 TXX9_IRQ_BASE + TX4939_IR_TMR(tmrnr),
298 TXX9_IMCLK);
299}
300
301void __init tx4939_sio_init(unsigned int sclk, unsigned int cts_mask)
302{
303 int i;
304 unsigned int ch_mask = 0;
305 __u64 pcfg = __raw_readq(&tx4939_ccfgptr->pcfg);
306
307 cts_mask |= ~1; /* only SIO0 have RTS/CTS */
308 if ((pcfg & TX4939_PCFG_SIO2MODE_MASK) != TX4939_PCFG_SIO2MODE_SIO0)
309 cts_mask |= 1 << 0; /* disable SIO0 RTS/CTS by PCFG setting */
310 if ((pcfg & TX4939_PCFG_SIO2MODE_MASK) != TX4939_PCFG_SIO2MODE_SIO2)
311 ch_mask |= 1 << 2; /* disable SIO2 by PCFG setting */
312 if (pcfg & TX4939_PCFG_SIO3MODE)
313 ch_mask |= 1 << 3; /* disable SIO3 by PCFG setting */
314 for (i = 0; i < 4; i++) {
315 if ((1 << i) & ch_mask)
316 continue;
317 txx9_sio_init(TX4939_SIO_REG(i) & 0xfffffffffULL,
318 TXX9_IRQ_BASE + TX4939_IR_SIO(i),
319 i, sclk, (1 << i) & cts_mask);
320 }
321}
322
323#if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE)
324static int tx4939_get_eth_speed(struct net_device *dev)
325{
326 struct ethtool_cmd cmd = { ETHTOOL_GSET };
327 int speed = 100; /* default 100Mbps */
328 int err;
329 if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings)
330 return speed;
331 err = dev->ethtool_ops->get_settings(dev, &cmd);
332 if (err < 0)
333 return speed;
334 speed = cmd.speed == SPEED_100 ? 100 : 10;
335 return speed;
336}
337static int tx4939_netdev_event(struct notifier_block *this,
338 unsigned long event,
339 void *ptr)
340{
341 struct net_device *dev = ptr;
342 if (event == NETDEV_CHANGE && netif_carrier_ok(dev)) {
343 __u64 bit = 0;
344 if (dev->irq == TXX9_IRQ_BASE + TX4939_IR_ETH(0))
345 bit = TX4939_PCFG_SPEED0;
346 else if (dev->irq == TXX9_IRQ_BASE + TX4939_IR_ETH(1))
347 bit = TX4939_PCFG_SPEED1;
348 if (bit) {
349 int speed = tx4939_get_eth_speed(dev);
350 if (speed == 100)
351 txx9_set64(&tx4939_ccfgptr->pcfg, bit);
352 else
353 txx9_clear64(&tx4939_ccfgptr->pcfg, bit);
354 }
355 }
356 return NOTIFY_DONE;
357}
358
359static struct notifier_block tx4939_netdev_notifier = {
360 .notifier_call = tx4939_netdev_event,
361 .priority = 1,
362};
363
364void __init tx4939_ethaddr_init(unsigned char *addr0, unsigned char *addr1)
365{
366 u64 pcfg = __raw_readq(&tx4939_ccfgptr->pcfg);
367
368 if (addr0 && (pcfg & TX4939_PCFG_ET0MODE))
369 txx9_ethaddr_init(TXX9_IRQ_BASE + TX4939_IR_ETH(0), addr0);
370 if (addr1 && (pcfg & TX4939_PCFG_ET1MODE))
371 txx9_ethaddr_init(TXX9_IRQ_BASE + TX4939_IR_ETH(1), addr1);
372 register_netdevice_notifier(&tx4939_netdev_notifier);
373}
374#else
375void __init tx4939_ethaddr_init(unsigned char *addr0, unsigned char *addr1)
376{
377}
378#endif
379
380void __init tx4939_mtd_init(int ch)
381{
382 struct physmap_flash_data pdata = {
383 .width = TX4939_EBUSC_WIDTH(ch) / 8,
384 };
385 unsigned long start = txx9_ce_res[ch].start;
386 unsigned long size = txx9_ce_res[ch].end - start + 1;
387
388 if (!(TX4939_EBUSC_CR(ch) & 0x8))
389 return; /* disabled */
390 txx9_physmap_flash_init(ch, start, size, &pdata);
391}
392
393#define TX4939_ATA_REG_PHYS(ch) (TX4939_ATA_REG(ch) & 0xfffffffffULL)
394void __init tx4939_ata_init(void)
395{
396 static struct resource ata0_res[] = {
397 {
398 .start = TX4939_ATA_REG_PHYS(0),
399 .end = TX4939_ATA_REG_PHYS(0) + 0x1000 - 1,
400 .flags = IORESOURCE_MEM,
401 }, {
402 .start = TXX9_IRQ_BASE + TX4939_IR_ATA(0),
403 .flags = IORESOURCE_IRQ,
404 },
405 };
406 static struct resource ata1_res[] = {
407 {
408 .start = TX4939_ATA_REG_PHYS(1),
409 .end = TX4939_ATA_REG_PHYS(1) + 0x1000 - 1,
410 .flags = IORESOURCE_MEM,
411 }, {
412 .start = TXX9_IRQ_BASE + TX4939_IR_ATA(1),
413 .flags = IORESOURCE_IRQ,
414 },
415 };
416 static struct platform_device ata0_dev = {
417 .name = "tx4939ide",
418 .id = 0,
419 .num_resources = ARRAY_SIZE(ata0_res),
420 .resource = ata0_res,
421 };
422 static struct platform_device ata1_dev = {
423 .name = "tx4939ide",
424 .id = 1,
425 .num_resources = ARRAY_SIZE(ata1_res),
426 .resource = ata1_res,
427 };
428 __u64 pcfg = __raw_readq(&tx4939_ccfgptr->pcfg);
429
430 if (pcfg & TX4939_PCFG_ATA0MODE)
431 platform_device_register(&ata0_dev);
432 if ((pcfg & (TX4939_PCFG_ATA1MODE |
433 TX4939_PCFG_ET1MODE |
434 TX4939_PCFG_ET0MODE)) == TX4939_PCFG_ATA1MODE)
435 platform_device_register(&ata1_dev);
436}
437
438static void __init tx4939_stop_unused_modules(void)
439{
440 __u64 pcfg, rst = 0, ckd = 0;
441 char buf[128];
442
443 buf[0] = '\0';
444 local_irq_disable();
445 pcfg = ____raw_readq(&tx4939_ccfgptr->pcfg);
446 if ((pcfg & TX4939_PCFG_I2SMODE_MASK) !=
447 TX4939_PCFG_I2SMODE_ACLC) {
448 rst |= TX4939_CLKCTR_ACLRST;
449 ckd |= TX4939_CLKCTR_ACLCKD;
450 strcat(buf, " ACLC");
451 }
452 if ((pcfg & TX4939_PCFG_I2SMODE_MASK) !=
453 TX4939_PCFG_I2SMODE_I2S &&
454 (pcfg & TX4939_PCFG_I2SMODE_MASK) !=
455 TX4939_PCFG_I2SMODE_I2S_ALT) {
456 rst |= TX4939_CLKCTR_I2SRST;
457 ckd |= TX4939_CLKCTR_I2SCKD;
458 strcat(buf, " I2S");
459 }
460 if (!(pcfg & TX4939_PCFG_ATA0MODE)) {
461 rst |= TX4939_CLKCTR_ATA0RST;
462 ckd |= TX4939_CLKCTR_ATA0CKD;
463 strcat(buf, " ATA0");
464 }
465 if (!(pcfg & TX4939_PCFG_ATA1MODE)) {
466 rst |= TX4939_CLKCTR_ATA1RST;
467 ckd |= TX4939_CLKCTR_ATA1CKD;
468 strcat(buf, " ATA1");
469 }
470 if (pcfg & TX4939_PCFG_SPIMODE) {
471 rst |= TX4939_CLKCTR_SPIRST;
472 ckd |= TX4939_CLKCTR_SPICKD;
473 strcat(buf, " SPI");
474 }
475 if (!(pcfg & (TX4939_PCFG_VSSMODE | TX4939_PCFG_VPSMODE))) {
476 rst |= TX4939_CLKCTR_VPCRST;
477 ckd |= TX4939_CLKCTR_VPCCKD;
478 strcat(buf, " VPC");
479 }
480 if ((pcfg & TX4939_PCFG_SIO2MODE_MASK) != TX4939_PCFG_SIO2MODE_SIO2) {
481 rst |= TX4939_CLKCTR_SIO2RST;
482 ckd |= TX4939_CLKCTR_SIO2CKD;
483 strcat(buf, " SIO2");
484 }
485 if (pcfg & TX4939_PCFG_SIO3MODE) {
486 rst |= TX4939_CLKCTR_SIO3RST;
487 ckd |= TX4939_CLKCTR_SIO3CKD;
488 strcat(buf, " SIO3");
489 }
490 if (rst | ckd) {
491 txx9_set64(&tx4939_ccfgptr->clkctr, rst);
492 txx9_set64(&tx4939_ccfgptr->clkctr, ckd);
493 }
494 local_irq_enable();
495 if (buf[0])
496 pr_info("%s: stop%s\n", txx9_pcode_str, buf);
497}
498
499static int __init tx4939_late_init(void)
500{
501 if (txx9_pcode != 0x4939)
502 return -ENODEV;
503 tx4939_stop_unused_modules();
504 return 0;
505}
506late_initcall(tx4939_late_init);
diff --git a/arch/mips/txx9/rbtx4938/spi_eeprom.c b/arch/mips/txx9/generic/spi_eeprom.c
index a7ea8b041c1d..75c347238f47 100644
--- a/arch/mips/txx9/rbtx4938/spi_eeprom.c
+++ b/arch/mips/txx9/generic/spi_eeprom.c
@@ -18,29 +18,31 @@
18#define AT250X0_PAGE_SIZE 8 18#define AT250X0_PAGE_SIZE 8
19 19
20/* register board information for at25 driver */ 20/* register board information for at25 driver */
21int __init spi_eeprom_register(int chipid) 21int __init spi_eeprom_register(int busid, int chipid, int size)
22{ 22{
23 static struct spi_eeprom eeprom = {
24 .name = "at250x0",
25 .byte_len = 128,
26 .page_size = AT250X0_PAGE_SIZE,
27 .flags = EE_ADDR1,
28 };
29 struct spi_board_info info = { 23 struct spi_board_info info = {
30 .modalias = "at25", 24 .modalias = "at25",
31 .max_speed_hz = 1500000, /* 1.5Mbps */ 25 .max_speed_hz = 1500000, /* 1.5Mbps */
32 .bus_num = 0, 26 .bus_num = busid,
33 .chip_select = chipid, 27 .chip_select = chipid,
34 .platform_data = &eeprom,
35 /* Mode 0: High-Active, Sample-Then-Shift */ 28 /* Mode 0: High-Active, Sample-Then-Shift */
36 }; 29 };
37 30 struct spi_eeprom *eeprom;
31 eeprom = kzalloc(sizeof(*eeprom), GFP_KERNEL);
32 if (!eeprom)
33 return -ENOMEM;
34 strcpy(eeprom->name, "at250x0");
35 eeprom->byte_len = size;
36 eeprom->page_size = AT250X0_PAGE_SIZE;
37 eeprom->flags = EE_ADDR1;
38 info.platform_data = eeprom;
38 return spi_register_board_info(&info, 1); 39 return spi_register_board_info(&info, 1);
39} 40}
40 41
41/* simple temporary spi driver to provide early access to seeprom. */ 42/* simple temporary spi driver to provide early access to seeprom. */
42 43
43static struct read_param { 44static struct read_param {
45 int busid;
44 int chipid; 46 int chipid;
45 int address; 47 int address;
46 unsigned char *buf; 48 unsigned char *buf;
@@ -57,7 +59,8 @@ static int __init early_seeprom_probe(struct spi_device *spi)
57 59
58 dev_info(&spi->dev, "spiclk %u KHz.\n", 60 dev_info(&spi->dev, "spiclk %u KHz.\n",
59 (spi->max_speed_hz + 500) / 1000); 61 (spi->max_speed_hz + 500) / 1000);
60 if (read_param->chipid != spi->chip_select) 62 if (read_param->busid != spi->master->bus_num ||
63 read_param->chipid != spi->chip_select)
61 return -ENODEV; 64 return -ENODEV;
62 while (len > 0) { 65 while (len > 0) {
63 /* spi_write_then_read can only work with small chunk */ 66 /* spi_write_then_read can only work with small chunk */
@@ -80,11 +83,12 @@ static struct spi_driver early_seeprom_driver __initdata = {
80 .probe = early_seeprom_probe, 83 .probe = early_seeprom_probe,
81}; 84};
82 85
83int __init spi_eeprom_read(int chipid, int address, 86int __init spi_eeprom_read(int busid, int chipid, int address,
84 unsigned char *buf, int len) 87 unsigned char *buf, int len)
85{ 88{
86 int ret; 89 int ret;
87 struct read_param param = { 90 struct read_param param = {
91 .busid = busid,
88 .chipid = chipid, 92 .chipid = chipid,
89 .address = address, 93 .address = address,
90 .buf = buf, 94 .buf = buf,
diff --git a/arch/mips/txx9/jmr3927/prom.c b/arch/mips/txx9/jmr3927/prom.c
index 70c4c8ec3e84..c899c0c087a0 100644
--- a/arch/mips/txx9/jmr3927/prom.c
+++ b/arch/mips/txx9/jmr3927/prom.c
@@ -47,7 +47,6 @@ void __init jmr3927_prom_init(void)
47 if ((tx3927_ccfgptr->ccfg & TX3927_CCFG_TLBOFF) == 0) 47 if ((tx3927_ccfgptr->ccfg & TX3927_CCFG_TLBOFF) == 0)
48 printk(KERN_ERR "TX3927 TLB off\n"); 48 printk(KERN_ERR "TX3927 TLB off\n");
49 49
50 prom_init_cmdline();
51 add_memory_region(0, JMR3927_SDRAM_SIZE, BOOT_MEM_RAM); 50 add_memory_region(0, JMR3927_SDRAM_SIZE, BOOT_MEM_RAM);
52 txx9_sio_putchar_init(TX3927_SIO_REG(1)); 51 txx9_sio_putchar_init(TX3927_SIO_REG(1));
53} 52}
diff --git a/arch/mips/txx9/jmr3927/setup.c b/arch/mips/txx9/jmr3927/setup.c
index 87db41be8a56..25e50a7be387 100644
--- a/arch/mips/txx9/jmr3927/setup.c
+++ b/arch/mips/txx9/jmr3927/setup.c
@@ -62,7 +62,6 @@ static void __init jmr3927_time_init(void)
62} 62}
63 63
64#define DO_WRITE_THROUGH 64#define DO_WRITE_THROUGH
65#define DO_ENABLE_CACHE
66 65
67static void jmr3927_board_init(void); 66static void jmr3927_board_init(void);
68 67
@@ -77,11 +76,6 @@ static void __init jmr3927_mem_setup(void)
77 /* cache setup */ 76 /* cache setup */
78 { 77 {
79 unsigned int conf; 78 unsigned int conf;
80#ifdef DO_ENABLE_CACHE
81 int mips_ic_disable = 0, mips_dc_disable = 0;
82#else
83 int mips_ic_disable = 1, mips_dc_disable = 1;
84#endif
85#ifdef DO_WRITE_THROUGH 79#ifdef DO_WRITE_THROUGH
86 int mips_config_cwfon = 0; 80 int mips_config_cwfon = 0;
87 int mips_config_wbon = 0; 81 int mips_config_wbon = 0;
@@ -91,10 +85,7 @@ static void __init jmr3927_mem_setup(void)
91#endif 85#endif
92 86
93 conf = read_c0_conf(); 87 conf = read_c0_conf();
94 conf &= ~(TX39_CONF_ICE | TX39_CONF_DCE | 88 conf &= ~(TX39_CONF_WBON | TX39_CONF_CWFON);
95 TX39_CONF_WBON | TX39_CONF_CWFON);
96 conf |= mips_ic_disable ? 0 : TX39_CONF_ICE;
97 conf |= mips_dc_disable ? 0 : TX39_CONF_DCE;
98 conf |= mips_config_wbon ? TX39_CONF_WBON : 0; 89 conf |= mips_config_wbon ? TX39_CONF_WBON : 0;
99 conf |= mips_config_cwfon ? TX39_CONF_CWFON : 0; 90 conf |= mips_config_cwfon ? TX39_CONF_CWFON : 0;
100 91
@@ -199,11 +190,25 @@ static void __init jmr3927_rtc_init(void)
199 platform_device_register_simple("rtc-ds1742", -1, &res, 1); 190 platform_device_register_simple("rtc-ds1742", -1, &res, 1);
200} 191}
201 192
193static void __init jmr3927_mtd_init(void)
194{
195 int i;
196
197 for (i = 0; i < 2; i++)
198 tx3927_mtd_init(i);
199}
200
202static void __init jmr3927_device_init(void) 201static void __init jmr3927_device_init(void)
203{ 202{
203 unsigned long iocled_base = JMR3927_IOC_LED_ADDR - IO_BASE;
204#ifdef __LITTLE_ENDIAN
205 iocled_base |= 1;
206#endif
204 __swizzle_addr_b = jmr3927_swizzle_addr_b; 207 __swizzle_addr_b = jmr3927_swizzle_addr_b;
205 jmr3927_rtc_init(); 208 jmr3927_rtc_init();
206 tx3927_wdt_init(); 209 tx3927_wdt_init();
210 jmr3927_mtd_init();
211 txx9_iocled_init(iocled_base, -1, 8, 1, "green", NULL);
207} 212}
208 213
209struct txx9_board_vec jmr3927_vec __initdata = { 214struct txx9_board_vec jmr3927_vec __initdata = {
diff --git a/arch/mips/txx9/rbtx4927/irq.c b/arch/mips/txx9/rbtx4927/irq.c
index 00cd5231da30..9c14ebb26cb4 100644
--- a/arch/mips/txx9/rbtx4927/irq.c
+++ b/arch/mips/txx9/rbtx4927/irq.c
@@ -133,15 +133,20 @@ static int toshiba_rbtx4927_irq_nested(int sw_irq)
133 u8 level3; 133 u8 level3;
134 134
135 level3 = readb(rbtx4927_imstat_addr) & 0x1f; 135 level3 = readb(rbtx4927_imstat_addr) & 0x1f;
136 if (level3) 136 if (unlikely(!level3))
137 sw_irq = RBTX4927_IRQ_IOC + fls(level3) - 1; 137 return -1;
138 return sw_irq; 138 return RBTX4927_IRQ_IOC + __fls8(level3);
139} 139}
140 140
141static void __init toshiba_rbtx4927_irq_ioc_init(void) 141static void __init toshiba_rbtx4927_irq_ioc_init(void)
142{ 142{
143 int i; 143 int i;
144 144
145 /* mask all IOC interrupts */
146 writeb(0, rbtx4927_imask_addr);
147 /* clear SoftInt interrupts */
148 writeb(0, rbtx4927_softint_addr);
149
145 for (i = RBTX4927_IRQ_IOC; 150 for (i = RBTX4927_IRQ_IOC;
146 i < RBTX4927_IRQ_IOC + RBTX4927_NR_IRQ_IOC; i++) 151 i < RBTX4927_IRQ_IOC + RBTX4927_NR_IRQ_IOC; i++)
147 set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_ioc_type, 152 set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_ioc_type,
diff --git a/arch/mips/txx9/rbtx4927/prom.c b/arch/mips/txx9/rbtx4927/prom.c
index 1dc0a5b1956b..cc97c6a6011b 100644
--- a/arch/mips/txx9/rbtx4927/prom.c
+++ b/arch/mips/txx9/rbtx4927/prom.c
@@ -36,7 +36,6 @@
36 36
37void __init rbtx4927_prom_init(void) 37void __init rbtx4927_prom_init(void)
38{ 38{
39 prom_init_cmdline();
40 add_memory_region(0, tx4927_get_mem_size(), BOOT_MEM_RAM); 39 add_memory_region(0, tx4927_get_mem_size(), BOOT_MEM_RAM);
41 txx9_sio_putchar_init(TX4927_SIO_REG(0) & 0xfffffffffULL); 40 txx9_sio_putchar_init(TX4927_SIO_REG(0) & 0xfffffffffULL);
42} 41}
diff --git a/arch/mips/txx9/rbtx4927/setup.c b/arch/mips/txx9/rbtx4927/setup.c
index 0d39bafea794..4a74423b2ba8 100644
--- a/arch/mips/txx9/rbtx4927/setup.c
+++ b/arch/mips/txx9/rbtx4927/setup.c
@@ -48,6 +48,7 @@
48#include <linux/ioport.h> 48#include <linux/ioport.h>
49#include <linux/platform_device.h> 49#include <linux/platform_device.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/gpio.h>
51#include <asm/io.h> 52#include <asm/io.h>
52#include <asm/reboot.h> 53#include <asm/reboot.h>
53#include <asm/txx9/generic.h> 54#include <asm/txx9/generic.h>
@@ -185,14 +186,8 @@ static void __init rbtx4937_clock_init(void);
185 186
186static void __init rbtx4927_mem_setup(void) 187static void __init rbtx4927_mem_setup(void)
187{ 188{
188 u32 cp0_config;
189 char *argptr; 189 char *argptr;
190 190
191 /* enable caches -- HCP5 does this, pmon does not */
192 cp0_config = read_c0_config();
193 cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC);
194 write_c0_config(cp0_config);
195
196 if (TX4927_REV_PCODE() == 0x4927) { 191 if (TX4927_REV_PCODE() == 0x4927) {
197 rbtx4927_clock_init(); 192 rbtx4927_clock_init();
198 tx4927_setup(); 193 tx4927_setup();
@@ -212,6 +207,14 @@ static void __init rbtx4927_mem_setup(void)
212 set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET); 207 set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET);
213#endif 208#endif
214 209
210 /* TX4927-SIO DTR on (PIO[15]) */
211 gpio_request(15, "sio-dtr");
212 gpio_direction_output(15, 1);
213 gpio_request(0, "led");
214 gpio_direction_output(0, 1);
215 gpio_request(1, "led");
216 gpio_direction_output(1, 1);
217
215 tx4927_sio_init(0, 0); 218 tx4927_sio_init(0, 0);
216#ifdef CONFIG_SERIAL_TXX9_CONSOLE 219#ifdef CONFIG_SERIAL_TXX9_CONSOLE
217 argptr = prom_getcmdline(); 220 argptr = prom_getcmdline();
@@ -304,11 +307,21 @@ static void __init rbtx4927_ne_init(void)
304 platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res)); 307 platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res));
305} 308}
306 309
310static void __init rbtx4927_mtd_init(void)
311{
312 int i;
313
314 for (i = 0; i < 2; i++)
315 tx4927_mtd_init(i);
316}
317
307static void __init rbtx4927_device_init(void) 318static void __init rbtx4927_device_init(void)
308{ 319{
309 toshiba_rbtx4927_rtc_init(); 320 toshiba_rbtx4927_rtc_init();
310 rbtx4927_ne_init(); 321 rbtx4927_ne_init();
311 tx4927_wdt_init(); 322 tx4927_wdt_init();
323 rbtx4927_mtd_init();
324 txx9_iocled_init(RBTX4927_LED_ADDR - IO_BASE, -1, 3, 1, "green", NULL);
312} 325}
313 326
314struct txx9_board_vec rbtx4927_vec __initdata = { 327struct txx9_board_vec rbtx4927_vec __initdata = {
diff --git a/arch/mips/txx9/rbtx4938/Makefile b/arch/mips/txx9/rbtx4938/Makefile
index 9dcc52ae5b9d..f3e1f597b4f1 100644
--- a/arch/mips/txx9/rbtx4938/Makefile
+++ b/arch/mips/txx9/rbtx4938/Makefile
@@ -1,3 +1,3 @@
1obj-y += prom.o setup.o irq.o spi_eeprom.o 1obj-y += prom.o setup.o irq.o
2 2
3EXTRA_CFLAGS += -Werror 3EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/txx9/rbtx4938/irq.c b/arch/mips/txx9/rbtx4938/irq.c
index ca2f8306ce93..7d21befb8932 100644
--- a/arch/mips/txx9/rbtx4938/irq.c
+++ b/arch/mips/txx9/rbtx4938/irq.c
@@ -85,10 +85,10 @@ static int toshiba_rbtx4938_irq_nested(int sw_irq)
85 u8 level3; 85 u8 level3;
86 86
87 level3 = readb(rbtx4938_imstat_addr); 87 level3 = readb(rbtx4938_imstat_addr);
88 if (level3) 88 if (unlikely(!level3))
89 /* must use fls so onboard ATA has priority */ 89 return -1;
90 sw_irq = RBTX4938_IRQ_IOC + fls(level3) - 1; 90 /* must use fls so onboard ATA has priority */
91 return sw_irq; 91 return RBTX4938_IRQ_IOC + __fls8(level3);
92} 92}
93 93
94static void __init 94static void __init
diff --git a/arch/mips/txx9/rbtx4938/prom.c b/arch/mips/txx9/rbtx4938/prom.c
index d73123cd2ab9..bcb469247e8c 100644
--- a/arch/mips/txx9/rbtx4938/prom.c
+++ b/arch/mips/txx9/rbtx4938/prom.c
@@ -18,9 +18,6 @@
18 18
19void __init rbtx4938_prom_init(void) 19void __init rbtx4938_prom_init(void)
20{ 20{
21#ifndef CONFIG_TX4938_NAND_BOOT
22 prom_init_cmdline();
23#endif
24 add_memory_region(0, tx4938_get_mem_size(), BOOT_MEM_RAM); 21 add_memory_region(0, tx4938_get_mem_size(), BOOT_MEM_RAM);
25 txx9_sio_putchar_init(TX4938_SIO_REG(0) & 0xfffffffffULL); 22 txx9_sio_putchar_init(TX4938_SIO_REG(0) & 0xfffffffffULL);
26} 23}
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c
index 9ab48dec0fe8..e077cc4d3a59 100644
--- a/arch/mips/txx9/rbtx4938/setup.c
+++ b/arch/mips/txx9/rbtx4938/setup.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/mtd/physmap.h>
18 19
19#include <asm/reboot.h> 20#include <asm/reboot.h>
20#include <asm/io.h> 21#include <asm/io.h>
@@ -110,6 +111,7 @@ static void __init rbtx4938_pci_setup(void)
110#define SEEPROM2_CS 0 /* IOC */ 111#define SEEPROM2_CS 0 /* IOC */
111#define SEEPROM3_CS 1 /* IOC */ 112#define SEEPROM3_CS 1 /* IOC */
112#define SRTC_CS 2 /* IOC */ 113#define SRTC_CS 2 /* IOC */
114#define SPI_BUSNO 0
113 115
114static int __init rbtx4938_ethaddr_init(void) 116static int __init rbtx4938_ethaddr_init(void)
115{ 117{
@@ -119,7 +121,7 @@ static int __init rbtx4938_ethaddr_init(void)
119 int i; 121 int i;
120 122
121 /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */ 123 /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */
122 if (spi_eeprom_read(SEEPROM1_CS, 0, dat, sizeof(dat))) { 124 if (spi_eeprom_read(SPI_BUSNO, SEEPROM1_CS, 0, dat, sizeof(dat))) {
123 printk(KERN_ERR "seeprom: read error.\n"); 125 printk(KERN_ERR "seeprom: read error.\n");
124 return -ENODEV; 126 return -ENODEV;
125 } else { 127 } else {
@@ -173,23 +175,30 @@ static void __init rbtx4938_mem_setup(void)
173#endif 175#endif
174 176
175#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61 177#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61
176 printk(KERN_INFO "PIOSEL: disabling both ata and nand selection\n"); 178 pr_info("PIOSEL: disabling both ATA and NAND selection\n");
177 txx9_clear64(&tx4938_ccfgptr->pcfg, 179 txx9_clear64(&tx4938_ccfgptr->pcfg,
178 TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL); 180 TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL);
179#endif 181#endif
180 182
181#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND 183#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND
182 printk(KERN_INFO "PIOSEL: enabling nand selection\n"); 184 pr_info("PIOSEL: enabling NAND selection\n");
183 txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL); 185 txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL);
184 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL); 186 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL);
185#endif 187#endif
186 188
187#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA 189#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA
188 printk(KERN_INFO "PIOSEL: enabling ata selection\n"); 190 pr_info("PIOSEL: enabling ATA selection\n");
189 txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL); 191 txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL);
190 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL); 192 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL);
191#endif 193#endif
192 194
195#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_KEEP
196 pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg);
197 pr_info("PIOSEL: NAND %s, ATA %s\n",
198 (pcfg & TX4938_PCFG_NDF_SEL) ? "enabled" : "disabled",
199 (pcfg & TX4938_PCFG_ATA_SEL) ? "enabled" : "disabled");
200#endif
201
193 rbtx4938_spi_setup(); 202 rbtx4938_spi_setup();
194 pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg); /* updated */ 203 pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg); /* updated */
195 /* fixup piosel */ 204 /* fixup piosel */
@@ -279,9 +288,9 @@ static int __init rbtx4938_spi_init(void)
279 .mode = SPI_MODE_1 | SPI_CS_HIGH, 288 .mode = SPI_MODE_1 | SPI_CS_HIGH,
280 }; 289 };
281 spi_register_board_info(&srtc_info, 1); 290 spi_register_board_info(&srtc_info, 1);
282 spi_eeprom_register(SEEPROM1_CS); 291 spi_eeprom_register(SPI_BUSNO, SEEPROM1_CS, 128);
283 spi_eeprom_register(16 + SEEPROM2_CS); 292 spi_eeprom_register(SPI_BUSNO, 16 + SEEPROM2_CS, 128);
284 spi_eeprom_register(16 + SEEPROM3_CS); 293 spi_eeprom_register(SPI_BUSNO, 16 + SEEPROM3_CS, 128);
285 gpio_request(16 + SRTC_CS, "rtc-rs5c348"); 294 gpio_request(16 + SRTC_CS, "rtc-rs5c348");
286 gpio_direction_output(16 + SRTC_CS, 0); 295 gpio_direction_output(16 + SRTC_CS, 0);
287 gpio_request(SEEPROM1_CS, "seeprom1"); 296 gpio_request(SEEPROM1_CS, "seeprom1");
@@ -290,10 +299,46 @@ static int __init rbtx4938_spi_init(void)
290 gpio_direction_output(16 + SEEPROM2_CS, 1); 299 gpio_direction_output(16 + SEEPROM2_CS, 1);
291 gpio_request(16 + SEEPROM3_CS, "seeprom3"); 300 gpio_request(16 + SEEPROM3_CS, "seeprom3");
292 gpio_direction_output(16 + SEEPROM3_CS, 1); 301 gpio_direction_output(16 + SEEPROM3_CS, 1);
293 tx4938_spi_init(0); 302 tx4938_spi_init(SPI_BUSNO);
294 return 0; 303 return 0;
295} 304}
296 305
306static void __init rbtx4938_mtd_init(void)
307{
308 struct physmap_flash_data pdata = {
309 .width = 4,
310 };
311
312 switch (readb(rbtx4938_bdipsw_addr) & 7) {
313 case 0:
314 /* Boot */
315 txx9_physmap_flash_init(0, 0x1fc00000, 0x400000, &pdata);
316 /* System */
317 txx9_physmap_flash_init(1, 0x1e000000, 0x1000000, &pdata);
318 break;
319 case 1:
320 /* System */
321 txx9_physmap_flash_init(0, 0x1f000000, 0x1000000, &pdata);
322 /* Boot */
323 txx9_physmap_flash_init(1, 0x1ec00000, 0x400000, &pdata);
324 break;
325 case 2:
326 /* Ext */
327 txx9_physmap_flash_init(0, 0x1f000000, 0x1000000, &pdata);
328 /* System */
329 txx9_physmap_flash_init(1, 0x1e000000, 0x1000000, &pdata);
330 /* Boot */
331 txx9_physmap_flash_init(2, 0x1dc00000, 0x400000, &pdata);
332 break;
333 case 3:
334 /* Boot */
335 txx9_physmap_flash_init(1, 0x1bc00000, 0x400000, &pdata);
336 /* System */
337 txx9_physmap_flash_init(2, 0x1a000000, 0x1000000, &pdata);
338 break;
339 }
340}
341
297static void __init rbtx4938_arch_init(void) 342static void __init rbtx4938_arch_init(void)
298{ 343{
299 gpiochip_add(&rbtx4938_spi_gpio_chip); 344 gpiochip_add(&rbtx4938_spi_gpio_chip);
@@ -306,6 +351,8 @@ static void __init rbtx4938_device_init(void)
306 rbtx4938_ethaddr_init(); 351 rbtx4938_ethaddr_init();
307 rbtx4938_ne_init(); 352 rbtx4938_ne_init();
308 tx4938_wdt_init(); 353 tx4938_wdt_init();
354 rbtx4938_mtd_init();
355 txx9_iocled_init(RBTX4938_LED_ADDR - IO_BASE, -1, 8, 1, "green", NULL);
309} 356}
310 357
311struct txx9_board_vec rbtx4938_vec __initdata = { 358struct txx9_board_vec rbtx4938_vec __initdata = {
diff --git a/arch/mips/txx9/rbtx4939/Makefile b/arch/mips/txx9/rbtx4939/Makefile
new file mode 100644
index 000000000000..3232cd03a7d6
--- /dev/null
+++ b/arch/mips/txx9/rbtx4939/Makefile
@@ -0,0 +1,3 @@
1obj-y += irq.o setup.o prom.o
2
3EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/txx9/rbtx4939/irq.c b/arch/mips/txx9/rbtx4939/irq.c
new file mode 100644
index 000000000000..500cc0a908e6
--- /dev/null
+++ b/arch/mips/txx9/rbtx4939/irq.c
@@ -0,0 +1,96 @@
1/*
2 * Toshiba RBTX4939 interrupt routines
3 * Based on linux/arch/mips/txx9/rbtx4938/irq.c,
4 * and RBTX49xx patch from CELF patch archive.
5 *
6 * Copyright (C) 2000-2001,2005-2006 Toshiba Corporation
7 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 */
12#include <linux/init.h>
13#include <linux/interrupt.h>
14#include <asm/mipsregs.h>
15#include <asm/txx9/rbtx4939.h>
16
17/*
18 * RBTX4939 IOC controller definition
19 */
20
21static void rbtx4939_ioc_irq_unmask(unsigned int irq)
22{
23 int ioc_nr = irq - RBTX4939_IRQ_IOC;
24
25 writeb(readb(rbtx4939_ien_addr) | (1 << ioc_nr), rbtx4939_ien_addr);
26}
27
28static void rbtx4939_ioc_irq_mask(unsigned int irq)
29{
30 int ioc_nr = irq - RBTX4939_IRQ_IOC;
31
32 writeb(readb(rbtx4939_ien_addr) & ~(1 << ioc_nr), rbtx4939_ien_addr);
33 mmiowb();
34}
35
36static struct irq_chip rbtx4939_ioc_irq_chip = {
37 .name = "IOC",
38 .ack = rbtx4939_ioc_irq_mask,
39 .mask = rbtx4939_ioc_irq_mask,
40 .mask_ack = rbtx4939_ioc_irq_mask,
41 .unmask = rbtx4939_ioc_irq_unmask,
42};
43
44
45static inline int rbtx4939_ioc_irqroute(void)
46{
47 unsigned char istat = readb(rbtx4939_ifac2_addr);
48
49 if (unlikely(istat == 0))
50 return -1;
51 return RBTX4939_IRQ_IOC + __fls8(istat);
52}
53
54static int rbtx4939_irq_dispatch(int pending)
55{
56 int irq;
57
58 if (pending & CAUSEF_IP7)
59 return MIPS_CPU_IRQ_BASE + 7;
60 irq = tx4939_irq();
61 if (likely(irq >= 0)) {
62 /* redirect IOC interrupts */
63 switch (irq) {
64 case RBTX4939_IRQ_IOCINT:
65 irq = rbtx4939_ioc_irqroute();
66 break;
67 }
68 } else if (pending & CAUSEF_IP0)
69 irq = MIPS_CPU_IRQ_BASE + 0;
70 else if (pending & CAUSEF_IP1)
71 irq = MIPS_CPU_IRQ_BASE + 1;
72 else
73 irq = -1;
74 return irq;
75}
76
77void __init rbtx4939_irq_setup(void)
78{
79 int i;
80
81 /* mask all IOC interrupts */
82 writeb(0, rbtx4939_ien_addr);
83
84 /* clear SoftInt interrupts */
85 writeb(0, rbtx4939_softint_addr);
86
87 txx9_irq_dispatch = rbtx4939_irq_dispatch;
88
89 tx4939_irq_init();
90 for (i = RBTX4939_IRQ_IOC;
91 i < RBTX4939_IRQ_IOC + RBTX4939_NR_IRQ_IOC; i++)
92 set_irq_chip_and_handler(i, &rbtx4939_ioc_irq_chip,
93 handle_level_irq);
94
95 set_irq_chained_handler(RBTX4939_IRQ_IOCINT, handle_simple_irq);
96}
diff --git a/arch/mips/txx9/rbtx4939/prom.c b/arch/mips/txx9/rbtx4939/prom.c
new file mode 100644
index 000000000000..bd277ecb4ad6
--- /dev/null
+++ b/arch/mips/txx9/rbtx4939/prom.c
@@ -0,0 +1,17 @@
1/*
2 * rbtx4939 specific prom routines
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#include <linux/init.h>
10#include <asm/txx9/generic.h>
11#include <asm/txx9/rbtx4939.h>
12
13void __init rbtx4939_prom_init(void)
14{
15 tx4939_add_memory_regions();
16 txx9_sio_putchar_init(TX4939_SIO_REG(0) & 0xfffffffffULL);
17}
diff --git a/arch/mips/txx9/rbtx4939/setup.c b/arch/mips/txx9/rbtx4939/setup.c
new file mode 100644
index 000000000000..9855d7bccc20
--- /dev/null
+++ b/arch/mips/txx9/rbtx4939/setup.c
@@ -0,0 +1,307 @@
1/*
2 * Toshiba RBTX4939 setup routines.
3 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
4 * and RBTX49xx patch from CELF patch archive.
5 *
6 * Copyright (C) 2000-2001,2005-2007 Toshiba Corporation
7 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 */
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/platform_device.h>
16#include <linux/leds.h>
17#include <asm/reboot.h>
18#include <asm/txx9/generic.h>
19#include <asm/txx9/pci.h>
20#include <asm/txx9/rbtx4939.h>
21
22static void rbtx4939_machine_restart(char *command)
23{
24 local_irq_disable();
25 writeb(1, rbtx4939_reseten_addr);
26 writeb(1, rbtx4939_softreset_addr);
27 while (1)
28 ;
29}
30
31static void __init rbtx4939_time_init(void)
32{
33 tx4939_time_init(0);
34}
35
36static void __init rbtx4939_pci_setup(void)
37{
38#ifdef CONFIG_PCI
39 int extarb = !(__raw_readq(&tx4939_ccfgptr->ccfg) & TX4939_CCFG_PCIARB);
40 struct pci_controller *c = &txx9_primary_pcic;
41
42 register_pci_controller(c);
43
44 tx4939_report_pciclk();
45 tx4927_pcic_setup(tx4939_pcicptr, c, extarb);
46 if (!(__raw_readq(&tx4939_ccfgptr->pcfg) & TX4939_PCFG_ATA1MODE) &&
47 (__raw_readq(&tx4939_ccfgptr->pcfg) &
48 (TX4939_PCFG_ET0MODE | TX4939_PCFG_ET1MODE))) {
49 tx4939_report_pci1clk();
50
51 /* mem:64K(max), io:64K(max) (enough for ETH0,ETH1) */
52 c = txx9_alloc_pci_controller(NULL, 0, 0x10000, 0, 0x10000);
53 register_pci_controller(c);
54 tx4927_pcic_setup(tx4939_pcic1ptr, c, 0);
55 }
56
57 tx4939_setup_pcierr_irq();
58#endif /* CONFIG_PCI */
59}
60
61static unsigned long long default_ebccr[] __initdata = {
62 0x01c0000000007608ULL, /* 64M ROM */
63 0x017f000000007049ULL, /* 1M IOC */
64 0x0180000000408608ULL, /* ISA */
65 0,
66};
67
68static void __init rbtx4939_ebusc_setup(void)
69{
70 int i;
71 unsigned int sp;
72
73 /* use user-configured speed */
74 sp = TX4939_EBUSC_CR(0) & 0x30;
75 default_ebccr[0] |= sp;
76 default_ebccr[1] |= sp;
77 default_ebccr[2] |= sp;
78 /* initialise by myself */
79 for (i = 0; i < ARRAY_SIZE(default_ebccr); i++) {
80 if (default_ebccr[i])
81 ____raw_writeq(default_ebccr[i],
82 &tx4939_ebuscptr->cr[i]);
83 else
84 ____raw_writeq(____raw_readq(&tx4939_ebuscptr->cr[i])
85 & ~8,
86 &tx4939_ebuscptr->cr[i]);
87 }
88}
89
90static void __init rbtx4939_update_ioc_pen(void)
91{
92 __u64 pcfg = ____raw_readq(&tx4939_ccfgptr->pcfg);
93 __u64 ccfg = ____raw_readq(&tx4939_ccfgptr->ccfg);
94 __u8 pe1 = readb(rbtx4939_pe1_addr);
95 __u8 pe2 = readb(rbtx4939_pe2_addr);
96 __u8 pe3 = readb(rbtx4939_pe3_addr);
97 if (pcfg & TX4939_PCFG_ATA0MODE)
98 pe1 |= RBTX4939_PE1_ATA(0);
99 else
100 pe1 &= ~RBTX4939_PE1_ATA(0);
101 if (pcfg & TX4939_PCFG_ATA1MODE) {
102 pe1 |= RBTX4939_PE1_ATA(1);
103 pe1 &= ~(RBTX4939_PE1_RMII(0) | RBTX4939_PE1_RMII(1));
104 } else {
105 pe1 &= ~RBTX4939_PE1_ATA(1);
106 if (pcfg & TX4939_PCFG_ET0MODE)
107 pe1 |= RBTX4939_PE1_RMII(0);
108 else
109 pe1 &= ~RBTX4939_PE1_RMII(0);
110 if (pcfg & TX4939_PCFG_ET1MODE)
111 pe1 |= RBTX4939_PE1_RMII(1);
112 else
113 pe1 &= ~RBTX4939_PE1_RMII(1);
114 }
115 if (ccfg & TX4939_CCFG_PTSEL)
116 pe3 &= ~(RBTX4939_PE3_VP | RBTX4939_PE3_VP_P |
117 RBTX4939_PE3_VP_S);
118 else {
119 __u64 vmode = pcfg &
120 (TX4939_PCFG_VSSMODE | TX4939_PCFG_VPSMODE);
121 if (vmode == 0)
122 pe3 &= ~(RBTX4939_PE3_VP | RBTX4939_PE3_VP_P |
123 RBTX4939_PE3_VP_S);
124 else if (vmode == TX4939_PCFG_VPSMODE) {
125 pe3 |= RBTX4939_PE3_VP_P;
126 pe3 &= ~(RBTX4939_PE3_VP | RBTX4939_PE3_VP_S);
127 } else if (vmode == TX4939_PCFG_VSSMODE) {
128 pe3 |= RBTX4939_PE3_VP | RBTX4939_PE3_VP_S;
129 pe3 &= ~RBTX4939_PE3_VP_P;
130 } else {
131 pe3 |= RBTX4939_PE3_VP | RBTX4939_PE3_VP_P;
132 pe3 &= ~RBTX4939_PE3_VP_S;
133 }
134 }
135 if (pcfg & TX4939_PCFG_SPIMODE) {
136 if (pcfg & TX4939_PCFG_SIO2MODE_GPIO)
137 pe2 &= ~(RBTX4939_PE2_SIO2 | RBTX4939_PE2_SIO0);
138 else {
139 if (pcfg & TX4939_PCFG_SIO2MODE_SIO2) {
140 pe2 |= RBTX4939_PE2_SIO2;
141 pe2 &= ~RBTX4939_PE2_SIO0;
142 } else {
143 pe2 |= RBTX4939_PE2_SIO0;
144 pe2 &= ~RBTX4939_PE2_SIO2;
145 }
146 }
147 if (pcfg & TX4939_PCFG_SIO3MODE)
148 pe2 |= RBTX4939_PE2_SIO3;
149 else
150 pe2 &= ~RBTX4939_PE2_SIO3;
151 pe2 &= ~RBTX4939_PE2_SPI;
152 } else {
153 pe2 |= RBTX4939_PE2_SPI;
154 pe2 &= ~(RBTX4939_PE2_SIO3 | RBTX4939_PE2_SIO2 |
155 RBTX4939_PE2_SIO0);
156 }
157 if ((pcfg & TX4939_PCFG_I2SMODE_MASK) == TX4939_PCFG_I2SMODE_GPIO)
158 pe2 |= RBTX4939_PE2_GPIO;
159 else
160 pe2 &= ~RBTX4939_PE2_GPIO;
161 writeb(pe1, rbtx4939_pe1_addr);
162 writeb(pe2, rbtx4939_pe2_addr);
163 writeb(pe3, rbtx4939_pe3_addr);
164}
165
166#define RBTX4939_MAX_7SEGLEDS 8
167
168#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
169static u8 led_val[RBTX4939_MAX_7SEGLEDS];
170struct rbtx4939_led_data {
171 struct led_classdev cdev;
172 char name[32];
173 unsigned int num;
174};
175
176/* Use "dot" in 7seg LEDs */
177static void rbtx4939_led_brightness_set(struct led_classdev *led_cdev,
178 enum led_brightness value)
179{
180 struct rbtx4939_led_data *led_dat =
181 container_of(led_cdev, struct rbtx4939_led_data, cdev);
182 unsigned int num = led_dat->num;
183 unsigned long flags;
184
185 local_irq_save(flags);
186 led_val[num] = (led_val[num] & 0x7f) | (value ? 0x80 : 0);
187 writeb(led_val[num], rbtx4939_7seg_addr(num / 4, num % 4));
188 local_irq_restore(flags);
189}
190
191static int __init rbtx4939_led_probe(struct platform_device *pdev)
192{
193 struct rbtx4939_led_data *leds_data;
194 int i;
195 static char *default_triggers[] __initdata = {
196 "heartbeat",
197 "ide-disk",
198 "nand-disk",
199 };
200
201 leds_data = kzalloc(sizeof(*leds_data) * RBTX4939_MAX_7SEGLEDS,
202 GFP_KERNEL);
203 if (!leds_data)
204 return -ENOMEM;
205 for (i = 0; i < RBTX4939_MAX_7SEGLEDS; i++) {
206 int rc;
207 struct rbtx4939_led_data *led_dat = &leds_data[i];
208
209 led_dat->num = i;
210 led_dat->cdev.brightness_set = rbtx4939_led_brightness_set;
211 sprintf(led_dat->name, "rbtx4939:amber:%u", i);
212 led_dat->cdev.name = led_dat->name;
213 if (i < ARRAY_SIZE(default_triggers))
214 led_dat->cdev.default_trigger = default_triggers[i];
215 rc = led_classdev_register(&pdev->dev, &led_dat->cdev);
216 if (rc < 0)
217 return rc;
218 led_dat->cdev.brightness_set(&led_dat->cdev, 0);
219 }
220 return 0;
221
222}
223
224static struct platform_driver rbtx4939_led_driver = {
225 .driver = {
226 .name = "rbtx4939-led",
227 .owner = THIS_MODULE,
228 },
229};
230
231static void __init rbtx4939_led_setup(void)
232{
233 platform_device_register_simple("rbtx4939-led", -1, NULL, 0);
234 platform_driver_probe(&rbtx4939_led_driver, rbtx4939_led_probe);
235}
236#else
237static inline void rbtx4939_led_setup(void)
238{
239}
240#endif
241
242static void __init rbtx4939_arch_init(void)
243{
244 rbtx4939_pci_setup();
245}
246
247static void __init rbtx4939_device_init(void)
248{
249#if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE)
250 int i, j;
251 unsigned char ethaddr[2][6];
252 for (i = 0; i < 2; i++) {
253 unsigned long area = CKSEG1 + 0x1fff0000 + (i * 0x10);
254 if (readb(rbtx4939_bdipsw_addr) & 8) {
255 u16 buf[3];
256 area -= 0x03000000;
257 for (j = 0; j < 3; j++)
258 buf[j] = le16_to_cpup((u16 *)(area + j * 2));
259 memcpy(ethaddr[i], buf, 6);
260 } else
261 memcpy(ethaddr[i], (void *)area, 6);
262 }
263 tx4939_ethaddr_init(ethaddr[0], ethaddr[1]);
264#endif
265 rbtx4939_led_setup();
266 tx4939_wdt_init();
267 tx4939_ata_init();
268}
269
270static void __init rbtx4939_setup(void)
271{
272 rbtx4939_ebusc_setup();
273 /* always enable ATA0 */
274 txx9_set64(&tx4939_ccfgptr->pcfg, TX4939_PCFG_ATA0MODE);
275 rbtx4939_update_ioc_pen();
276 if (txx9_master_clock == 0)
277 txx9_master_clock = 20000000;
278 tx4939_setup();
279
280 _machine_restart = rbtx4939_machine_restart;
281
282 pr_info("RBTX4939 (Rev %02x) --- FPGA(Rev %02x) DIPSW:%02x,%02x\n",
283 readb(rbtx4939_board_rev_addr), readb(rbtx4939_ioc_rev_addr),
284 readb(rbtx4939_udipsw_addr), readb(rbtx4939_bdipsw_addr));
285
286#ifdef CONFIG_PCI
287 txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0);
288 txx9_board_pcibios_setup = tx4927_pcibios_setup;
289#else
290 set_io_port_base(RBTX4939_ETHER_BASE);
291#endif
292
293 tx4939_sio_init(TX4939_SCLK0(txx9_master_clock), 0);
294}
295
296struct txx9_board_vec rbtx4939_vec __initdata = {
297 .system = "Tothiba RBTX4939",
298 .prom_init = rbtx4939_prom_init,
299 .mem_setup = rbtx4939_setup,
300 .irq_setup = rbtx4939_irq_setup,
301 .time_init = rbtx4939_time_init,
302 .device_init = rbtx4939_device_init,
303 .arch_init = rbtx4939_arch_init,
304#ifdef CONFIG_PCI
305 .pci_map_irq = tx4939_pci_map_irq,
306#endif
307};
diff --git a/arch/mn10300/kernel/irq.c b/arch/mn10300/kernel/irq.c
index 761c434a2488..56c64ccc9c21 100644
--- a/arch/mn10300/kernel/irq.c
+++ b/arch/mn10300/kernel/irq.c
@@ -20,22 +20,8 @@ EXPORT_SYMBOL(__mn10300_irq_enabled_epsw);
20atomic_t irq_err_count; 20atomic_t irq_err_count;
21 21
22/* 22/*
23 * MN10300 INTC controller operations 23 * MN10300 interrupt controller operations
24 */ 24 */
25static void mn10300_cpupic_disable(unsigned int irq)
26{
27 u16 tmp = GxICR(irq);
28 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_DETECT;
29 tmp = GxICR(irq);
30}
31
32static void mn10300_cpupic_enable(unsigned int irq)
33{
34 u16 tmp = GxICR(irq);
35 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE;
36 tmp = GxICR(irq);
37}
38
39static void mn10300_cpupic_ack(unsigned int irq) 25static void mn10300_cpupic_ack(unsigned int irq)
40{ 26{
41 u16 tmp; 27 u16 tmp;
@@ -60,26 +46,54 @@ static void mn10300_cpupic_mask_ack(unsigned int irq)
60static void mn10300_cpupic_unmask(unsigned int irq) 46static void mn10300_cpupic_unmask(unsigned int irq)
61{ 47{
62 u16 tmp = GxICR(irq); 48 u16 tmp = GxICR(irq);
63 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT; 49 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE;
64 tmp = GxICR(irq); 50 tmp = GxICR(irq);
65} 51}
66 52
67static void mn10300_cpupic_end(unsigned int irq) 53static void mn10300_cpupic_unmask_clear(unsigned int irq)
68{ 54{
55 /* the MN10300 PIC latches its interrupt request bit, even after the
56 * device has ceased to assert its interrupt line and the interrupt
57 * channel has been disabled in the PIC, so for level-triggered
58 * interrupts we need to clear the request bit when we re-enable */
69 u16 tmp = GxICR(irq); 59 u16 tmp = GxICR(irq);
70 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE; 60 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT;
71 tmp = GxICR(irq); 61 tmp = GxICR(irq);
72} 62}
73 63
74static struct irq_chip mn10300_cpu_pic = { 64/*
75 .name = "cpu", 65 * MN10300 PIC level-triggered IRQ handling.
76 .disable = mn10300_cpupic_disable, 66 *
77 .enable = mn10300_cpupic_enable, 67 * The PIC has no 'ACK' function per se. It is possible to clear individual
68 * channel latches, but each latch relatches whether or not the channel is
69 * masked, so we need to clear the latch when we unmask the channel.
70 *
71 * Also for this reason, we don't supply an ack() op (it's unused anyway if
72 * mask_ack() is provided), and mask_ack() just masks.
73 */
74static struct irq_chip mn10300_cpu_pic_level = {
75 .name = "cpu_l",
76 .disable = mn10300_cpupic_mask,
77 .enable = mn10300_cpupic_unmask_clear,
78 .ack = NULL,
79 .mask = mn10300_cpupic_mask,
80 .mask_ack = mn10300_cpupic_mask,
81 .unmask = mn10300_cpupic_unmask_clear,
82};
83
84/*
85 * MN10300 PIC edge-triggered IRQ handling.
86 *
87 * We use the latch clearing function of the PIC as the 'ACK' function.
88 */
89static struct irq_chip mn10300_cpu_pic_edge = {
90 .name = "cpu_e",
91 .disable = mn10300_cpupic_mask,
92 .enable = mn10300_cpupic_unmask,
78 .ack = mn10300_cpupic_ack, 93 .ack = mn10300_cpupic_ack,
79 .mask = mn10300_cpupic_mask, 94 .mask = mn10300_cpupic_mask,
80 .mask_ack = mn10300_cpupic_mask_ack, 95 .mask_ack = mn10300_cpupic_mask_ack,
81 .unmask = mn10300_cpupic_unmask, 96 .unmask = mn10300_cpupic_unmask,
82 .end = mn10300_cpupic_end,
83}; 97};
84 98
85/* 99/*
@@ -114,7 +128,8 @@ void set_intr_level(int irq, u16 level)
114 */ 128 */
115void set_intr_postackable(int irq) 129void set_intr_postackable(int irq)
116{ 130{
117 set_irq_handler(irq, handle_level_irq); 131 set_irq_chip_and_handler(irq, &mn10300_cpu_pic_level,
132 handle_level_irq);
118} 133}
119 134
120/* 135/*
@@ -126,8 +141,12 @@ void __init init_IRQ(void)
126 141
127 for (irq = 0; irq < NR_IRQS; irq++) 142 for (irq = 0; irq < NR_IRQS; irq++)
128 if (irq_desc[irq].chip == &no_irq_type) 143 if (irq_desc[irq].chip == &no_irq_type)
129 set_irq_chip_and_handler(irq, &mn10300_cpu_pic, 144 /* due to the PIC latching interrupt requests, even
130 handle_edge_irq); 145 * when the IRQ is disabled, IRQ_PENDING is superfluous
146 * and we can use handle_level_irq() for edge-triggered
147 * interrupts */
148 set_irq_chip_and_handler(irq, &mn10300_cpu_pic_edge,
149 handle_level_irq);
131 unit_init_IRQ(); 150 unit_init_IRQ();
132} 151}
133 152
diff --git a/arch/mn10300/unit-asb2303/unit-init.c b/arch/mn10300/unit-asb2303/unit-init.c
index 14b2c817cff8..70e8cb4ea266 100644
--- a/arch/mn10300/unit-asb2303/unit-init.c
+++ b/arch/mn10300/unit-asb2303/unit-init.c
@@ -51,7 +51,7 @@ void __init unit_init_IRQ(void)
51 switch (GET_XIRQ_TRIGGER(extnum)) { 51 switch (GET_XIRQ_TRIGGER(extnum)) {
52 case XIRQ_TRIGGER_HILEVEL: 52 case XIRQ_TRIGGER_HILEVEL:
53 case XIRQ_TRIGGER_LOWLEVEL: 53 case XIRQ_TRIGGER_LOWLEVEL:
54 set_irq_handler(XIRQ2IRQ(extnum), handle_level_irq); 54 set_intr_postackable(XIRQ2IRQ(extnum));
55 break; 55 break;
56 default: 56 default:
57 break; 57 break;
diff --git a/arch/mn10300/unit-asb2305/unit-init.c b/arch/mn10300/unit-asb2305/unit-init.c
index 6a352414a358..72812a9439ac 100644
--- a/arch/mn10300/unit-asb2305/unit-init.c
+++ b/arch/mn10300/unit-asb2305/unit-init.c
@@ -52,7 +52,7 @@ void __init unit_init_IRQ(void)
52 switch (GET_XIRQ_TRIGGER(extnum)) { 52 switch (GET_XIRQ_TRIGGER(extnum)) {
53 case XIRQ_TRIGGER_HILEVEL: 53 case XIRQ_TRIGGER_HILEVEL:
54 case XIRQ_TRIGGER_LOWLEVEL: 54 case XIRQ_TRIGGER_LOWLEVEL:
55 set_irq_handler(XIRQ2IRQ(extnum), handle_level_irq); 55 set_intr_postackable(XIRQ2IRQ(extnum));
56 break; 56 break;
57 default: 57 default:
58 break; 58 break;
diff --git a/arch/powerpc/boot/dts/holly.dts b/arch/powerpc/boot/dts/holly.dts
index f87fe7b9ced9..c6e11ebecebb 100644
--- a/arch/powerpc/boot/dts/holly.dts
+++ b/arch/powerpc/boot/dts/holly.dts
@@ -133,61 +133,61 @@
133 reg = <0x00007400 0x00000400>; 133 reg = <0x00007400 0x00000400>;
134 big-endian; 134 big-endian;
135 }; 135 };
136 };
136 137
137 pci@1000 { 138 pci@c0001000 {
138 device_type = "pci"; 139 device_type = "pci";
139 compatible = "tsi109-pci", "tsi108-pci"; 140 compatible = "tsi109-pci", "tsi108-pci";
140 #interrupt-cells = <1>; 141 #interrupt-cells = <1>;
141 #size-cells = <2>; 142 #size-cells = <2>;
142 #address-cells = <3>; 143 #address-cells = <3>;
143 reg = <0x00001000 0x00001000>; 144 reg = <0xc0001000 0x00001000>;
144 bus-range = <0x0 0x0>; 145 bus-range = <0x0 0x0>;
145 /*----------------------------------------------------+ 146 /*----------------------------------------------------+
146 | PCI memory range. 147 | PCI memory range.
147 | 01 denotes I/O space 148 | 01 denotes I/O space
148 | 02 denotes 32-bit memory space 149 | 02 denotes 32-bit memory space
149 +----------------------------------------------------*/ 150 +----------------------------------------------------*/
150 ranges = <0x02000000 0x00000000 0x40000000 0x40000000 0x00000000 0x10000000 151 ranges = <0x02000000 0x00000000 0x40000000 0x40000000 0x00000000 0x10000000
151 0x01000000 0x00000000 0x00000000 0x7e000000 0x00000000 0x00010000>; 152 0x01000000 0x00000000 0x00000000 0x7e000000 0x00000000 0x00010000>;
152 clock-frequency = <133333332>; 153 clock-frequency = <133333332>;
153 interrupt-parent = <&MPIC>; 154 interrupt-parent = <&MPIC>;
155 interrupts = <0x17 0x2>;
156 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
157 /*----------------------------------------------------+
158 | The INTA, INTB, INTC, INTD are shared.
159 +----------------------------------------------------*/
160 interrupt-map = <
161 0x800 0x0 0x0 0x1 &RT0 0x24 0x0
162 0x800 0x0 0x0 0x2 &RT0 0x25 0x0
163 0x800 0x0 0x0 0x3 &RT0 0x26 0x0
164 0x800 0x0 0x0 0x4 &RT0 0x27 0x0
165
166 0x1000 0x0 0x0 0x1 &RT0 0x25 0x0
167 0x1000 0x0 0x0 0x2 &RT0 0x26 0x0
168 0x1000 0x0 0x0 0x3 &RT0 0x27 0x0
169 0x1000 0x0 0x0 0x4 &RT0 0x24 0x0
170
171 0x1800 0x0 0x0 0x1 &RT0 0x26 0x0
172 0x1800 0x0 0x0 0x2 &RT0 0x27 0x0
173 0x1800 0x0 0x0 0x3 &RT0 0x24 0x0
174 0x1800 0x0 0x0 0x4 &RT0 0x25 0x0
175
176 0x2000 0x0 0x0 0x1 &RT0 0x27 0x0
177 0x2000 0x0 0x0 0x2 &RT0 0x24 0x0
178 0x2000 0x0 0x0 0x3 &RT0 0x25 0x0
179 0x2000 0x0 0x0 0x4 &RT0 0x26 0x0
180 >;
181
182 RT0: router@1180 {
183 device_type = "pic-router";
184 interrupt-controller;
185 big-endian;
186 clock-frequency = <0>;
187 #address-cells = <0>;
188 #interrupt-cells = <2>;
154 interrupts = <0x17 0x2>; 189 interrupts = <0x17 0x2>;
155 interrupt-map-mask = <0xf800 0x0 0x0 0x7>; 190 interrupt-parent = <&MPIC>;
156 /*----------------------------------------------------+
157 | The INTA, INTB, INTC, INTD are shared.
158 +----------------------------------------------------*/
159 interrupt-map = <
160 0x800 0x0 0x0 0x1 &RT0 0x24 0x0
161 0x800 0x0 0x0 0x2 &RT0 0x25 0x0
162 0x800 0x0 0x0 0x3 &RT0 0x26 0x0
163 0x800 0x0 0x0 0x4 &RT0 0x27 0x0
164
165 0x1000 0x0 0x0 0x1 &RT0 0x25 0x0
166 0x1000 0x0 0x0 0x2 &RT0 0x26 0x0
167 0x1000 0x0 0x0 0x3 &RT0 0x27 0x0
168 0x1000 0x0 0x0 0x4 &RT0 0x24 0x0
169
170 0x1800 0x0 0x0 0x1 &RT0 0x26 0x0
171 0x1800 0x0 0x0 0x2 &RT0 0x27 0x0
172 0x1800 0x0 0x0 0x3 &RT0 0x24 0x0
173 0x1800 0x0 0x0 0x4 &RT0 0x25 0x0
174
175 0x2000 0x0 0x0 0x1 &RT0 0x27 0x0
176 0x2000 0x0 0x0 0x2 &RT0 0x24 0x0
177 0x2000 0x0 0x0 0x3 &RT0 0x25 0x0
178 0x2000 0x0 0x0 0x4 &RT0 0x26 0x0
179 >;
180
181 RT0: router@1180 {
182 device_type = "pic-router";
183 interrupt-controller;
184 big-endian;
185 clock-frequency = <0>;
186 #address-cells = <0>;
187 #interrupt-cells = <2>;
188 interrupts = <0x17 0x2>;
189 interrupt-parent = <&MPIC>;
190 };
191 }; 191 };
192 }; 192 };
193 193
diff --git a/arch/powerpc/include/asm/dcr-regs.h b/arch/powerpc/include/asm/dcr-regs.h
index 29b0ecef980a..f15296cf3598 100644
--- a/arch/powerpc/include/asm/dcr-regs.h
+++ b/arch/powerpc/include/asm/dcr-regs.h
@@ -68,6 +68,10 @@
68#define SDR0_UART3 0x0123 68#define SDR0_UART3 0x0123
69#define SDR0_CUST0 0x4000 69#define SDR0_CUST0 0x4000
70 70
71/* SDRs (460EX/460GT) */
72#define SDR0_ETH_CFG 0x4103
73#define SDR0_ETH_CFG_ECS 0x00000100 /* EMAC int clk source */
74
71/* 75/*
72 * All those DCR register addresses are offsets from the base address 76 * All those DCR register addresses are offsets from the base address
73 * for the SRAM0 controller (e.g. 0x20 on 440GX). The base address is 77 * for the SRAM0 controller (e.g. 0x20 on 440GX). The base address is
diff --git a/arch/powerpc/include/asm/siginfo.h b/arch/powerpc/include/asm/siginfo.h
index 12f1bce037be..49495b0534ed 100644
--- a/arch/powerpc/include/asm/siginfo.h
+++ b/arch/powerpc/include/asm/siginfo.h
@@ -15,11 +15,6 @@
15 15
16#include <asm-generic/siginfo.h> 16#include <asm-generic/siginfo.h>
17 17
18/*
19 * SIGTRAP si_codes
20 */
21#define TRAP_BRANCH (__SI_FAULT|3) /* process taken branch trap */
22#define TRAP_HWBKPT (__SI_FAULT|4) /* hardware breakpoint or watchpoint */
23#undef NSIGTRAP 18#undef NSIGTRAP
24#define NSIGTRAP 4 19#define NSIGTRAP 4
25 20
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index d308a9f70f1b..31982d05d81a 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -34,11 +34,7 @@
34#include <asm/smp.h> 34#include <asm/smp.h>
35 35
36#ifdef CONFIG_HOTPLUG_CPU 36#ifdef CONFIG_HOTPLUG_CPU
37/* this is used for software suspend, and that shuts down 37#define cpu_should_die() cpu_is_offline(smp_processor_id())
38 * CPUs even while the system is still booting... */
39#define cpu_should_die() (cpu_is_offline(smp_processor_id()) && \
40 (system_state == SYSTEM_RUNNING \
41 || system_state == SYSTEM_BOOTING))
42#else 38#else
43#define cpu_should_die() 0 39#define cpu_should_die() 0
44#endif 40#endif
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 5337ca7bb649..c27b10a1bd79 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -453,6 +453,7 @@ int __devinit start_secondary(void *unused)
453 secondary_cpu_time_init(); 453 secondary_cpu_time_init();
454 454
455 ipi_call_lock(); 455 ipi_call_lock();
456 notify_cpu_starting(cpu);
456 cpu_set(cpu, cpu_online_map); 457 cpu_set(cpu, cpu_online_map);
457 /* Update sibling maps */ 458 /* Update sibling maps */
458 base = cpu_first_thread_in_core(cpu); 459 base = cpu_first_thread_in_core(cpu);
diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c
index d5770fdf7f09..0eb6d7f62241 100644
--- a/arch/powerpc/platforms/82xx/ep8248e.c
+++ b/arch/powerpc/platforms/82xx/ep8248e.c
@@ -137,7 +137,7 @@ static int __devinit ep8248e_mdio_probe(struct of_device *ofdev,
137 bus->irq[i] = -1; 137 bus->irq[i] = -1;
138 138
139 bus->name = "ep8248e-mdio-bitbang"; 139 bus->name = "ep8248e-mdio-bitbang";
140 bus->dev = &ofdev->dev; 140 bus->parent = &ofdev->dev;
141 snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); 141 snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
142 142
143 return mdiobus_register(bus); 143 return mdiobus_register(bus);
diff --git a/arch/powerpc/platforms/fsl_uli1575.c b/arch/powerpc/platforms/fsl_uli1575.c
index ef74a0763ec1..8c619963becc 100644
--- a/arch/powerpc/platforms/fsl_uli1575.c
+++ b/arch/powerpc/platforms/fsl_uli1575.c
@@ -219,11 +219,21 @@ static void __devinit quirk_final_uli5249(struct pci_dev *dev)
219 int i; 219 int i;
220 u8 *dummy; 220 u8 *dummy;
221 struct pci_bus *bus = dev->bus; 221 struct pci_bus *bus = dev->bus;
222 resource_size_t end = 0;
223
224 for (i = PCI_BRIDGE_RESOURCES; i < PCI_BRIDGE_RESOURCES+3; i++) {
225 unsigned long flags = pci_resource_flags(dev, i);
226 if ((flags & (IORESOURCE_MEM|IORESOURCE_PREFETCH)) == IORESOURCE_MEM)
227 end = pci_resource_end(dev, i);
228 }
222 229
223 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { 230 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
224 if ((bus->resource[i]) && 231 if ((bus->resource[i]) &&
225 (bus->resource[i]->flags & IORESOURCE_MEM)) { 232 (bus->resource[i]->flags & IORESOURCE_MEM)) {
226 dummy = ioremap(bus->resource[i]->end - 3, 0x4); 233 if (bus->resource[i]->end == end)
234 dummy = ioremap(bus->resource[i]->start, 0x4);
235 else
236 dummy = ioremap(bus->resource[i]->end - 3, 0x4);
227 if (dummy) { 237 if (dummy) {
228 in_8(dummy); 238 in_8(dummy);
229 iounmap(dummy); 239 iounmap(dummy);
diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c
index ab6955412ba4..75cc165d5bee 100644
--- a/arch/powerpc/platforms/pasemi/gpio_mdio.c
+++ b/arch/powerpc/platforms/pasemi/gpio_mdio.c
@@ -230,7 +230,7 @@ static int __devinit gpio_mdio_probe(struct of_device *ofdev,
230 if (!priv) 230 if (!priv)
231 goto out; 231 goto out;
232 232
233 new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL); 233 new_bus = mdiobus_alloc();
234 234
235 if (!new_bus) 235 if (!new_bus)
236 goto out_free_priv; 236 goto out_free_priv;
@@ -272,7 +272,7 @@ static int __devinit gpio_mdio_probe(struct of_device *ofdev,
272 prop = of_get_property(np, "mdio-pin", NULL); 272 prop = of_get_property(np, "mdio-pin", NULL);
273 priv->mdio_pin = *prop; 273 priv->mdio_pin = *prop;
274 274
275 new_bus->dev = dev; 275 new_bus->parent = dev;
276 dev_set_drvdata(dev, new_bus); 276 dev_set_drvdata(dev, new_bus);
277 277
278 err = mdiobus_register(new_bus); 278 err = mdiobus_register(new_bus);
@@ -306,7 +306,7 @@ static int gpio_mdio_remove(struct of_device *dev)
306 306
307 kfree(bus->priv); 307 kfree(bus->priv);
308 bus->priv = NULL; 308 bus->priv = NULL;
309 kfree(bus); 309 mdiobus_free(bus);
310 310
311 return 0; 311 return 0;
312} 312}
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index 32e0ad0ebea8..b6bd775d2e22 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -293,10 +293,8 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id,
293 return -ENODEV; 293 return -ENODEV;
294 294
295 prop = of_get_property(phy, "reg", NULL); 295 prop = of_get_property(phy, "reg", NULL);
296 if (prop) { 296 if (prop)
297 pdata.force_phy_addr = 1; 297 pdata.phy_addr = MV643XX_ETH_PHY_ADDR(*prop);
298 pdata.phy_addr = *prop;
299 }
300 298
301 of_node_put(phy); 299 of_node_put(phy);
302 300
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 8d41908e2513..4c03049e7db9 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -74,6 +74,7 @@ config S390
74 select HAVE_KPROBES 74 select HAVE_KPROBES
75 select HAVE_KRETPROBES 75 select HAVE_KRETPROBES
76 select HAVE_KVM if 64BIT 76 select HAVE_KVM if 64BIT
77 select HAVE_ARCH_TRACEHOOK
77 78
78source "init/Kconfig" 79source "init/Kconfig"
79 80
diff --git a/arch/s390/include/asm/dasd.h b/arch/s390/include/asm/dasd.h
index 3f002e13d024..55b2b80cdf6e 100644
--- a/arch/s390/include/asm/dasd.h
+++ b/arch/s390/include/asm/dasd.h
@@ -3,6 +3,8 @@
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
6 * EMC Symmetrix ioctl Copyright EMC Corporation, 2008
7 * Author.........: Nigel Hislop <hislop_nigel@emc.com>
6 * 8 *
7 * This file is the interface of the DASD device driver, which is exported to user space 9 * This file is the interface of the DASD device driver, which is exported to user space
8 * any future changes wrt the API will result in a change of the APIVERSION reported 10 * any future changes wrt the API will result in a change of the APIVERSION reported
@@ -202,6 +204,16 @@ typedef struct attrib_data_t {
202#define DASD_SEQ_PRESTAGE 0x4 204#define DASD_SEQ_PRESTAGE 0x4
203#define DASD_REC_ACCESS 0x5 205#define DASD_REC_ACCESS 0x5
204 206
207/*
208 * Perform EMC Symmetrix I/O
209 */
210typedef struct dasd_symmio_parms {
211 unsigned char reserved[8]; /* compat with older releases */
212 unsigned long long psf_data; /* char * cast to u64 */
213 unsigned long long rssd_result; /* char * cast to u64 */
214 int psf_data_len;
215 int rssd_result_len;
216} __attribute__ ((packed)) dasd_symmio_parms_t;
205 217
206/******************************************************************************** 218/********************************************************************************
207 * SECTION: Definition of IOCTLs 219 * SECTION: Definition of IOCTLs
@@ -247,6 +259,7 @@ typedef struct attrib_data_t {
247/* Set Attributes (cache operations) */ 259/* Set Attributes (cache operations) */
248#define BIODASDSATTR _IOW(DASD_IOCTL_LETTER,2,attrib_data_t) 260#define BIODASDSATTR _IOW(DASD_IOCTL_LETTER,2,attrib_data_t)
249 261
262#define BIODASDSYMMIO _IOWR(DASD_IOCTL_LETTER, 240, dasd_symmio_parms_t)
250 263
251#endif /* DASD_H */ 264#endif /* DASD_H */
252 265
diff --git a/arch/s390/include/asm/delay.h b/arch/s390/include/asm/delay.h
index 78357314c450..a356c958e260 100644
--- a/arch/s390/include/asm/delay.h
+++ b/arch/s390/include/asm/delay.h
@@ -15,6 +15,7 @@
15#define _S390_DELAY_H 15#define _S390_DELAY_H
16 16
17extern void __udelay(unsigned long usecs); 17extern void __udelay(unsigned long usecs);
18extern void udelay_simple(unsigned long usecs);
18extern void __delay(unsigned long loops); 19extern void __delay(unsigned long loops);
19 20
20#define udelay(n) __udelay(n) 21#define udelay(n) __udelay(n)
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 0bdb704ae051..1a928f84afd6 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -281,6 +281,9 @@ extern char empty_zero_page[PAGE_SIZE];
281#define RCP_GR_BIT 50 281#define RCP_GR_BIT 50
282#define RCP_GC_BIT 49 282#define RCP_GC_BIT 49
283 283
284/* User dirty bit for KVM's migration feature */
285#define KVM_UD_BIT 47
286
284#ifndef __s390x__ 287#ifndef __s390x__
285 288
286/* Bits in the segment table address-space-control-element */ 289/* Bits in the segment table address-space-control-element */
@@ -575,12 +578,16 @@ static inline void ptep_rcp_copy(pte_t *ptep)
575 unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE); 578 unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
576 579
577 skey = page_get_storage_key(page_to_phys(page)); 580 skey = page_get_storage_key(page_to_phys(page));
578 if (skey & _PAGE_CHANGED) 581 if (skey & _PAGE_CHANGED) {
579 set_bit_simple(RCP_GC_BIT, pgste); 582 set_bit_simple(RCP_GC_BIT, pgste);
583 set_bit_simple(KVM_UD_BIT, pgste);
584 }
580 if (skey & _PAGE_REFERENCED) 585 if (skey & _PAGE_REFERENCED)
581 set_bit_simple(RCP_GR_BIT, pgste); 586 set_bit_simple(RCP_GR_BIT, pgste);
582 if (test_and_clear_bit_simple(RCP_HC_BIT, pgste)) 587 if (test_and_clear_bit_simple(RCP_HC_BIT, pgste)) {
583 SetPageDirty(page); 588 SetPageDirty(page);
589 set_bit_simple(KVM_UD_BIT, pgste);
590 }
584 if (test_and_clear_bit_simple(RCP_HR_BIT, pgste)) 591 if (test_and_clear_bit_simple(RCP_HR_BIT, pgste))
585 SetPageReferenced(page); 592 SetPageReferenced(page);
586#endif 593#endif
@@ -744,6 +751,40 @@ static inline pte_t pte_mkspecial(pte_t pte)
744 return pte; 751 return pte;
745} 752}
746 753
754#ifdef CONFIG_PGSTE
755/*
756 * Get (and clear) the user dirty bit for a PTE.
757 */
758static inline int kvm_s390_test_and_clear_page_dirty(struct mm_struct *mm,
759 pte_t *ptep)
760{
761 int dirty;
762 unsigned long *pgste;
763 struct page *page;
764 unsigned int skey;
765
766 if (!mm->context.pgstes)
767 return -EINVAL;
768 rcp_lock(ptep);
769 pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
770 page = virt_to_page(pte_val(*ptep));
771 skey = page_get_storage_key(page_to_phys(page));
772 if (skey & _PAGE_CHANGED) {
773 set_bit_simple(RCP_GC_BIT, pgste);
774 set_bit_simple(KVM_UD_BIT, pgste);
775 }
776 if (test_and_clear_bit_simple(RCP_HC_BIT, pgste)) {
777 SetPageDirty(page);
778 set_bit_simple(KVM_UD_BIT, pgste);
779 }
780 dirty = test_and_clear_bit_simple(KVM_UD_BIT, pgste);
781 if (skey & _PAGE_CHANGED)
782 page_clear_dirty(page);
783 rcp_unlock(ptep);
784 return dirty;
785}
786#endif
787
747#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 788#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
748static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, 789static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
749 unsigned long addr, pte_t *ptep) 790 unsigned long addr, pte_t *ptep)
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index af2c9ac28a07..a7226f8143fb 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -490,6 +490,7 @@ extern void user_disable_single_step(struct task_struct *);
490 490
491#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0) 491#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
492#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN) 492#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
493#define user_stack_pointer(regs)((regs)->gprs[15])
493#define regs_return_value(regs)((regs)->gprs[2]) 494#define regs_return_value(regs)((regs)->gprs[2])
494#define profile_pc(regs) instruction_pointer(regs) 495#define profile_pc(regs) instruction_pointer(regs)
495extern void show_regs(struct pt_regs * regs); 496extern void show_regs(struct pt_regs * regs);
diff --git a/arch/s390/include/asm/qdio.h b/arch/s390/include/asm/qdio.h
index 6813772171f2..4734c3f05354 100644
--- a/arch/s390/include/asm/qdio.h
+++ b/arch/s390/include/asm/qdio.h
@@ -299,7 +299,13 @@ struct qdio_ssqd_desc {
299 u8 mbccnt; 299 u8 mbccnt;
300 u16 qdioac2; 300 u16 qdioac2;
301 u64 sch_token; 301 u64 sch_token;
302 u64:64; 302 u8 mro;
303 u8 mri;
304 u8:8;
305 u8 sbalic;
306 u16:16;
307 u8:8;
308 u8 mmwc;
303} __attribute__ ((packed)); 309} __attribute__ ((packed));
304 310
305/* params are: ccw_device, qdio_error, queue_number, 311/* params are: ccw_device, qdio_error, queue_number,
diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
new file mode 100644
index 000000000000..6e623971fbb9
--- /dev/null
+++ b/arch/s390/include/asm/syscall.h
@@ -0,0 +1,80 @@
1/*
2 * Access to user system call parameters and results
3 *
4 * Copyright IBM Corp. 2008
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License (version 2 only)
9 * as published by the Free Software Foundation.
10 */
11
12#ifndef _ASM_SYSCALL_H
13#define _ASM_SYSCALL_H 1
14
15#include <asm/ptrace.h>
16
17static inline long syscall_get_nr(struct task_struct *task,
18 struct pt_regs *regs)
19{
20 if (regs->trap != __LC_SVC_OLD_PSW)
21 return -1;
22 return regs->gprs[2];
23}
24
25static inline void syscall_rollback(struct task_struct *task,
26 struct pt_regs *regs)
27{
28 regs->gprs[2] = regs->orig_gpr2;
29}
30
31static inline long syscall_get_error(struct task_struct *task,
32 struct pt_regs *regs)
33{
34 return (regs->gprs[2] >= -4096UL) ? -regs->gprs[2] : 0;
35}
36
37static inline long syscall_get_return_value(struct task_struct *task,
38 struct pt_regs *regs)
39{
40 return regs->gprs[2];
41}
42
43static inline void syscall_set_return_value(struct task_struct *task,
44 struct pt_regs *regs,
45 int error, long val)
46{
47 regs->gprs[2] = error ? -error : val;
48}
49
50static inline void syscall_get_arguments(struct task_struct *task,
51 struct pt_regs *regs,
52 unsigned int i, unsigned int n,
53 unsigned long *args)
54{
55 BUG_ON(i + n > 6);
56#ifdef CONFIG_COMPAT
57 if (test_tsk_thread_flag(task, TIF_31BIT)) {
58 if (i + n == 6)
59 args[--n] = (u32) regs->args[0];
60 while (n-- > 0)
61 args[n] = (u32) regs->gprs[2 + i + n];
62 }
63#endif
64 if (i + n == 6)
65 args[--n] = regs->args[0];
66 memcpy(args, &regs->gprs[2 + i], n * sizeof(args[0]));
67}
68
69static inline void syscall_set_arguments(struct task_struct *task,
70 struct pt_regs *regs,
71 unsigned int i, unsigned int n,
72 const unsigned long *args)
73{
74 BUG_ON(i + n > 6);
75 if (i + n == 6)
76 regs->args[0] = args[--n];
77 memcpy(&regs->gprs[2 + i], args, n * sizeof(args[0]));
78}
79
80#endif /* _ASM_SYSCALL_H */
diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h
index 91a8f93ad355..ea40a9d690fc 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -86,6 +86,7 @@ static inline struct thread_info *current_thread_info(void)
86 * thread information flags bit numbers 86 * thread information flags bit numbers
87 */ 87 */
88#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 88#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
89#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
89#define TIF_SIGPENDING 2 /* signal pending */ 90#define TIF_SIGPENDING 2 /* signal pending */
90#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 91#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
91#define TIF_RESTART_SVC 4 /* restart svc with new svc number */ 92#define TIF_RESTART_SVC 4 /* restart svc with new svc number */
@@ -100,6 +101,7 @@ static inline struct thread_info *current_thread_info(void)
100#define TIF_RESTORE_SIGMASK 20 /* restore signal mask in do_signal() */ 101#define TIF_RESTORE_SIGMASK 20 /* restore signal mask in do_signal() */
101 102
102#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 103#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
104#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
103#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 105#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
104#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 106#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
105#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 107#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index d7f22226fc4e..98e246dc0233 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -608,14 +608,6 @@ asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv, struct time
608 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); 608 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
609} 609}
610 610
611/* These are here just in case some old sparc32 binary calls it. */
612asmlinkage long sys32_pause(void)
613{
614 current->state = TASK_INTERRUPTIBLE;
615 schedule();
616 return -ERESTARTNOHAND;
617}
618
619asmlinkage long sys32_pread64(unsigned int fd, char __user *ubuf, 611asmlinkage long sys32_pread64(unsigned int fd, char __user *ubuf,
620 size_t count, u32 poshi, u32 poslo) 612 size_t count, u32 poshi, u32 poslo)
621{ 613{
diff --git a/arch/s390/kernel/compat_linux.h b/arch/s390/kernel/compat_linux.h
index 20723a062017..05f8516366ab 100644
--- a/arch/s390/kernel/compat_linux.h
+++ b/arch/s390/kernel/compat_linux.h
@@ -206,7 +206,6 @@ long sys32_gettimeofday(struct compat_timeval __user *tv,
206 struct timezone __user *tz); 206 struct timezone __user *tz);
207long sys32_settimeofday(struct compat_timeval __user *tv, 207long sys32_settimeofday(struct compat_timeval __user *tv,
208 struct timezone __user *tz); 208 struct timezone __user *tz);
209long sys32_pause(void);
210long sys32_pread64(unsigned int fd, char __user *ubuf, size_t count, 209long sys32_pread64(unsigned int fd, char __user *ubuf, size_t count,
211 u32 poshi, u32 poslo); 210 u32 poshi, u32 poslo);
212long sys32_pwrite64(unsigned int fd, const char __user *ubuf, 211long sys32_pwrite64(unsigned int fd, const char __user *ubuf,
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 328a20e880b5..ee51ca9e23b5 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -128,8 +128,6 @@ sys32_alarm_wrapper:
128 llgfr %r2,%r2 # unsigned int 128 llgfr %r2,%r2 # unsigned int
129 jg sys_alarm # branch to system call 129 jg sys_alarm # branch to system call
130 130
131#sys32_pause_wrapper # void
132
133 .globl compat_sys_utime_wrapper 131 .globl compat_sys_utime_wrapper
134compat_sys_utime_wrapper: 132compat_sys_utime_wrapper:
135 llgtr %r2,%r2 # char * 133 llgtr %r2,%r2 # char *
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 708cf9cf9a35..ed500ef799b7 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -49,9 +49,9 @@ SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
49SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP 49SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP
50SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE 50SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
51 51
52_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 52_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
53 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP ) 53 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
54_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 54_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
55 _TIF_MCCK_PENDING) 55 _TIF_MCCK_PENDING)
56 56
57STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER 57STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
@@ -318,6 +318,8 @@ sysc_work:
318 bo BASED(sysc_reschedule) 318 bo BASED(sysc_reschedule)
319 tm __TI_flags+3(%r9),_TIF_SIGPENDING 319 tm __TI_flags+3(%r9),_TIF_SIGPENDING
320 bnz BASED(sysc_sigpending) 320 bnz BASED(sysc_sigpending)
321 tm __TI_flags+3(%r9),_TIF_NOTIFY_RESUME
322 bnz BASED(sysc_notify_resume)
321 tm __TI_flags+3(%r9),_TIF_RESTART_SVC 323 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
322 bo BASED(sysc_restart) 324 bo BASED(sysc_restart)
323 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP 325 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
@@ -356,6 +358,16 @@ sysc_sigpending:
356 b BASED(sysc_work_loop) 358 b BASED(sysc_work_loop)
357 359
358# 360#
361# _TIF_NOTIFY_RESUME is set, call do_notify_resume
362#
363sysc_notify_resume:
364 la %r2,SP_PTREGS(%r15) # load pt_regs
365 l %r1,BASED(.Ldo_notify_resume)
366 la %r14,BASED(sysc_work_loop)
367 br %r1 # call do_notify_resume
368
369
370#
359# _TIF_RESTART_SVC is set, set up registers and restart svc 371# _TIF_RESTART_SVC is set, set up registers and restart svc
360# 372#
361sysc_restart: 373sysc_restart:
@@ -378,20 +390,21 @@ sysc_singlestep:
378 br %r1 # branch to do_single_step 390 br %r1 # branch to do_single_step
379 391
380# 392#
381# call trace before and after sys_call 393# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
394# and after the system call
382# 395#
383sysc_tracesys: 396sysc_tracesys:
384 l %r1,BASED(.Ltrace) 397 l %r1,BASED(.Ltrace_entry)
385 la %r2,SP_PTREGS(%r15) # load pt_regs 398 la %r2,SP_PTREGS(%r15) # load pt_regs
386 la %r3,0 399 la %r3,0
387 srl %r7,2 400 srl %r7,2
388 st %r7,SP_R2(%r15) 401 st %r7,SP_R2(%r15)
389 basr %r14,%r1 402 basr %r14,%r1
390 clc SP_R2(4,%r15),BASED(.Lnr_syscalls) 403 cl %r2,BASED(.Lnr_syscalls)
391 bnl BASED(sysc_tracenogo) 404 bnl BASED(sysc_tracenogo)
392 l %r8,BASED(.Lsysc_table) 405 l %r8,BASED(.Lsysc_table)
393 l %r7,SP_R2(%r15) # strace might have changed the 406 lr %r7,%r2
394 sll %r7,2 # system call 407 sll %r7,2 # *4
395 l %r8,0(%r7,%r8) 408 l %r8,0(%r7,%r8)
396sysc_tracego: 409sysc_tracego:
397 lm %r3,%r6,SP_R3(%r15) 410 lm %r3,%r6,SP_R3(%r15)
@@ -401,9 +414,8 @@ sysc_tracego:
401sysc_tracenogo: 414sysc_tracenogo:
402 tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) 415 tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
403 bz BASED(sysc_return) 416 bz BASED(sysc_return)
404 l %r1,BASED(.Ltrace) 417 l %r1,BASED(.Ltrace_exit)
405 la %r2,SP_PTREGS(%r15) # load pt_regs 418 la %r2,SP_PTREGS(%r15) # load pt_regs
406 la %r3,1
407 la %r14,BASED(sysc_return) 419 la %r14,BASED(sysc_return)
408 br %r1 420 br %r1
409 421
@@ -666,6 +678,8 @@ io_work_loop:
666 bo BASED(io_reschedule) 678 bo BASED(io_reschedule)
667 tm __TI_flags+3(%r9),_TIF_SIGPENDING 679 tm __TI_flags+3(%r9),_TIF_SIGPENDING
668 bnz BASED(io_sigpending) 680 bnz BASED(io_sigpending)
681 tm __TI_flags+3(%r9),_TIF_NOTIFY_RESUME
682 bnz BASED(io_notify_resume)
669 b BASED(io_restore) 683 b BASED(io_restore)
670io_work_done: 684io_work_done:
671 685
@@ -704,6 +718,19 @@ io_sigpending:
704 TRACE_IRQS_OFF 718 TRACE_IRQS_OFF
705 b BASED(io_work_loop) 719 b BASED(io_work_loop)
706 720
721#
722# _TIF_SIGPENDING is set, call do_signal
723#
724io_notify_resume:
725 TRACE_IRQS_ON
726 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
727 la %r2,SP_PTREGS(%r15) # load pt_regs
728 l %r1,BASED(.Ldo_notify_resume)
729 basr %r14,%r1 # call do_signal
730 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
731 TRACE_IRQS_OFF
732 b BASED(io_work_loop)
733
707/* 734/*
708 * External interrupt handler routine 735 * External interrupt handler routine
709 */ 736 */
@@ -1070,6 +1097,8 @@ cleanup_io_leave_insn:
1070.Ldo_IRQ: .long do_IRQ 1097.Ldo_IRQ: .long do_IRQ
1071.Ldo_extint: .long do_extint 1098.Ldo_extint: .long do_extint
1072.Ldo_signal: .long do_signal 1099.Ldo_signal: .long do_signal
1100.Ldo_notify_resume:
1101 .long do_notify_resume
1073.Lhandle_per: .long do_single_step 1102.Lhandle_per: .long do_single_step
1074.Ldo_execve: .long do_execve 1103.Ldo_execve: .long do_execve
1075.Lexecve_tail: .long execve_tail 1104.Lexecve_tail: .long execve_tail
@@ -1079,7 +1108,8 @@ cleanup_io_leave_insn:
1079.Lpreempt_schedule_irq: 1108.Lpreempt_schedule_irq:
1080 .long preempt_schedule_irq 1109 .long preempt_schedule_irq
1081#endif 1110#endif
1082.Ltrace: .long syscall_trace 1111.Ltrace_entry: .long do_syscall_trace_enter
1112.Ltrace_exit: .long do_syscall_trace_exit
1083.Lschedtail: .long schedule_tail 1113.Lschedtail: .long schedule_tail
1084.Lsysc_table: .long sys_call_table 1114.Lsysc_table: .long sys_call_table
1085#ifdef CONFIG_TRACE_IRQFLAGS 1115#ifdef CONFIG_TRACE_IRQFLAGS
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index fee10177dbfc..d7ce150453f2 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -52,9 +52,9 @@ SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
52STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER 52STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
53STACK_SIZE = 1 << STACK_SHIFT 53STACK_SIZE = 1 << STACK_SHIFT
54 54
55_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 55_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
56 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP ) 56 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
57_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 57_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
58 _TIF_MCCK_PENDING) 58 _TIF_MCCK_PENDING)
59 59
60#define BASED(name) name-system_call(%r13) 60#define BASED(name) name-system_call(%r13)
@@ -310,6 +310,8 @@ sysc_work:
310 jo sysc_reschedule 310 jo sysc_reschedule
311 tm __TI_flags+7(%r9),_TIF_SIGPENDING 311 tm __TI_flags+7(%r9),_TIF_SIGPENDING
312 jnz sysc_sigpending 312 jnz sysc_sigpending
313 tm __TI_flags+7(%r9),_TIF_NOTIFY_RESUME
314 jnz sysc_notify_resume
313 tm __TI_flags+7(%r9),_TIF_RESTART_SVC 315 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
314 jo sysc_restart 316 jo sysc_restart
315 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP 317 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
@@ -345,6 +347,14 @@ sysc_sigpending:
345 j sysc_work_loop 347 j sysc_work_loop
346 348
347# 349#
350# _TIF_NOTIFY_RESUME is set, call do_notify_resume
351#
352sysc_notify_resume:
353 la %r2,SP_PTREGS(%r15) # load pt_regs
354 larl %r14,sysc_work_loop
355 jg do_notify_resume # call do_notify_resume
356
357#
348# _TIF_RESTART_SVC is set, set up registers and restart svc 358# _TIF_RESTART_SVC is set, set up registers and restart svc
349# 359#
350sysc_restart: 360sysc_restart:
@@ -367,20 +377,19 @@ sysc_singlestep:
367 jg do_single_step # branch to do_sigtrap 377 jg do_single_step # branch to do_sigtrap
368 378
369# 379#
370# call syscall_trace before and after system call 380# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
371# special linkage: %r12 contains the return address for trace_svc 381# and after the system call
372# 382#
373sysc_tracesys: 383sysc_tracesys:
374 la %r2,SP_PTREGS(%r15) # load pt_regs 384 la %r2,SP_PTREGS(%r15) # load pt_regs
375 la %r3,0 385 la %r3,0
376 srl %r7,2 386 srl %r7,2
377 stg %r7,SP_R2(%r15) 387 stg %r7,SP_R2(%r15)
378 brasl %r14,syscall_trace 388 brasl %r14,do_syscall_trace_enter
379 lghi %r0,NR_syscalls 389 lghi %r0,NR_syscalls
380 clg %r0,SP_R2(%r15) 390 clgr %r0,%r2
381 jnh sysc_tracenogo 391 jnh sysc_tracenogo
382 lg %r7,SP_R2(%r15) # strace might have changed the 392 slag %r7,%r2,2 # *4
383 sll %r7,2 # system call
384 lgf %r8,0(%r7,%r10) 393 lgf %r8,0(%r7,%r10)
385sysc_tracego: 394sysc_tracego:
386 lmg %r3,%r6,SP_R3(%r15) 395 lmg %r3,%r6,SP_R3(%r15)
@@ -391,9 +400,8 @@ sysc_tracenogo:
391 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) 400 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
392 jz sysc_return 401 jz sysc_return
393 la %r2,SP_PTREGS(%r15) # load pt_regs 402 la %r2,SP_PTREGS(%r15) # load pt_regs
394 la %r3,1
395 larl %r14,sysc_return # return point is sysc_return 403 larl %r14,sysc_return # return point is sysc_return
396 jg syscall_trace 404 jg do_syscall_trace_exit
397 405
398# 406#
399# a new process exits the kernel with ret_from_fork 407# a new process exits the kernel with ret_from_fork
@@ -672,6 +680,8 @@ io_work_loop:
672 jo io_reschedule 680 jo io_reschedule
673 tm __TI_flags+7(%r9),_TIF_SIGPENDING 681 tm __TI_flags+7(%r9),_TIF_SIGPENDING
674 jnz io_sigpending 682 jnz io_sigpending
683 tm __TI_flags+7(%r9),_TIF_NOTIFY_RESUME
684 jnz io_notify_resume
675 j io_restore 685 j io_restore
676io_work_done: 686io_work_done:
677 687
@@ -712,6 +722,18 @@ io_sigpending:
712 TRACE_IRQS_OFF 722 TRACE_IRQS_OFF
713 j io_work_loop 723 j io_work_loop
714 724
725#
726# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
727#
728io_notify_resume:
729 TRACE_IRQS_ON
730 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
731 la %r2,SP_PTREGS(%r15) # load pt_regs
732 brasl %r14,do_notify_resume # call do_notify_resume
733 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
734 TRACE_IRQS_OFF
735 j io_work_loop
736
715/* 737/*
716 * External interrupt handler routine 738 * External interrupt handler routine
717 */ 739 */
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index c8b08289eb87..1f31be1ecc4b 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -35,6 +35,7 @@
35#include <linux/signal.h> 35#include <linux/signal.h>
36#include <linux/elf.h> 36#include <linux/elf.h>
37#include <linux/regset.h> 37#include <linux/regset.h>
38#include <linux/tracehook.h>
38 39
39#include <asm/segment.h> 40#include <asm/segment.h>
40#include <asm/page.h> 41#include <asm/page.h>
@@ -639,40 +640,44 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
639} 640}
640#endif 641#endif
641 642
642asmlinkage void 643asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
643syscall_trace(struct pt_regs *regs, int entryexit)
644{ 644{
645 if (unlikely(current->audit_context) && entryexit) 645 long ret;
646 audit_syscall_exit(AUDITSC_RESULT(regs->gprs[2]), regs->gprs[2]);
647
648 if (!test_thread_flag(TIF_SYSCALL_TRACE))
649 goto out;
650 if (!(current->ptrace & PT_PTRACED))
651 goto out;
652 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
653 ? 0x80 : 0));
654 646
655 /* 647 /*
656 * If the debuffer has set an invalid system call number, 648 * The sysc_tracesys code in entry.S stored the system
657 * we prepare to skip the system call restart handling. 649 * call number to gprs[2].
658 */ 650 */
659 if (!entryexit && regs->gprs[2] >= NR_syscalls) 651 ret = regs->gprs[2];
652 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
653 (tracehook_report_syscall_entry(regs) ||
654 regs->gprs[2] >= NR_syscalls)) {
655 /*
656 * Tracing decided this syscall should not happen or the
657 * debugger stored an invalid system call number. Skip
658 * the system call and the system call restart handling.
659 */
660 regs->trap = -1; 660 regs->trap = -1;
661 661 ret = -1;
662 /*
663 * this isn't the same as continuing with a signal, but it will do
664 * for normal use. strace only continues with a signal if the
665 * stopping signal is not SIGTRAP. -brl
666 */
667 if (current->exit_code) {
668 send_sig(current->exit_code, current, 1);
669 current->exit_code = 0;
670 } 662 }
671 out: 663
672 if (unlikely(current->audit_context) && !entryexit) 664 if (unlikely(current->audit_context))
673 audit_syscall_entry(test_thread_flag(TIF_31BIT)?AUDIT_ARCH_S390:AUDIT_ARCH_S390X, 665 audit_syscall_entry(test_thread_flag(TIF_31BIT) ?
674 regs->gprs[2], regs->orig_gpr2, regs->gprs[3], 666 AUDIT_ARCH_S390 : AUDIT_ARCH_S390X,
675 regs->gprs[4], regs->gprs[5]); 667 regs->gprs[2], regs->orig_gpr2,
668 regs->gprs[3], regs->gprs[4],
669 regs->gprs[5]);
670 return ret;
671}
672
673asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
674{
675 if (unlikely(current->audit_context))
676 audit_syscall_exit(AUDITSC_RESULT(regs->gprs[2]),
677 regs->gprs[2]);
678
679 if (test_thread_flag(TIF_SYSCALL_TRACE))
680 tracehook_report_syscall_exit(regs, 0);
676} 681}
677 682
678/* 683/*
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index b97682040215..4f7fc3059a8e 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -24,6 +24,7 @@
24#include <linux/tty.h> 24#include <linux/tty.h>
25#include <linux/personality.h> 25#include <linux/personality.h>
26#include <linux/binfmts.h> 26#include <linux/binfmts.h>
27#include <linux/tracehook.h>
27#include <asm/ucontext.h> 28#include <asm/ucontext.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include <asm/lowcore.h> 30#include <asm/lowcore.h>
@@ -507,6 +508,12 @@ void do_signal(struct pt_regs *regs)
507 */ 508 */
508 if (current->thread.per_info.single_step) 509 if (current->thread.per_info.single_step)
509 set_thread_flag(TIF_SINGLE_STEP); 510 set_thread_flag(TIF_SINGLE_STEP);
511
512 /*
513 * Let tracing know that we've done the handler setup.
514 */
515 tracehook_signal_handler(signr, &info, &ka, regs,
516 test_thread_flag(TIF_SINGLE_STEP));
510 } 517 }
511 return; 518 return;
512 } 519 }
@@ -526,3 +533,9 @@ void do_signal(struct pt_regs *regs)
526 set_thread_flag(TIF_RESTART_SVC); 533 set_thread_flag(TIF_RESTART_SVC);
527 } 534 }
528} 535}
536
537void do_notify_resume(struct pt_regs *regs)
538{
539 clear_thread_flag(TIF_NOTIFY_RESUME);
540 tracehook_notify_resume(regs);
541}
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 00b9b4dec5eb..9e8b1f9b8f4d 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -585,6 +585,8 @@ int __cpuinit start_secondary(void *cpuvoid)
585 /* Enable pfault pseudo page faults on this cpu. */ 585 /* Enable pfault pseudo page faults on this cpu. */
586 pfault_init(); 586 pfault_init();
587 587
588 /* call cpu notifiers */
589 notify_cpu_starting(smp_processor_id());
588 /* Mark this cpu as online */ 590 /* Mark this cpu as online */
589 spin_lock(&call_lock); 591 spin_lock(&call_lock);
590 cpu_set(smp_processor_id(), cpu_online_map); 592 cpu_set(smp_processor_id(), cpu_online_map);
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index c66d35e55142..3ae303914b42 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -37,7 +37,7 @@ SYSCALL(sys_stime,sys_ni_syscall,sys32_stime_wrapper) /* 25 old stime syscall *
37SYSCALL(sys_ptrace,sys_ptrace,sys32_ptrace_wrapper) 37SYSCALL(sys_ptrace,sys_ptrace,sys32_ptrace_wrapper)
38SYSCALL(sys_alarm,sys_alarm,sys32_alarm_wrapper) 38SYSCALL(sys_alarm,sys_alarm,sys32_alarm_wrapper)
39NI_SYSCALL /* old fstat syscall */ 39NI_SYSCALL /* old fstat syscall */
40SYSCALL(sys_pause,sys_pause,sys32_pause) 40SYSCALL(sys_pause,sys_pause,sys_pause)
41SYSCALL(sys_utime,sys_utime,compat_sys_utime_wrapper) /* 30 */ 41SYSCALL(sys_utime,sys_utime,compat_sys_utime_wrapper) /* 30 */
42NI_SYSCALL /* old stty syscall */ 42NI_SYSCALL /* old stty syscall */
43NI_SYSCALL /* old gtty syscall */ 43NI_SYSCALL /* old gtty syscall */
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index ca114fe46ffb..b94e9e3b694a 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -169,6 +169,8 @@ void init_cpu_timer(void)
169 169
170static void clock_comparator_interrupt(__u16 code) 170static void clock_comparator_interrupt(__u16 code)
171{ 171{
172 if (S390_lowcore.clock_comparator == -1ULL)
173 set_clock_comparator(S390_lowcore.clock_comparator);
172} 174}
173 175
174static void etr_timing_alert(struct etr_irq_parm *); 176static void etr_timing_alert(struct etr_irq_parm *);
@@ -1354,7 +1356,7 @@ static void __init stp_reset(void)
1354 1356
1355 stp_page = alloc_bootmem_pages(PAGE_SIZE); 1357 stp_page = alloc_bootmem_pages(PAGE_SIZE);
1356 rc = chsc_sstpc(stp_page, STP_OP_CTRL, 0x0000); 1358 rc = chsc_sstpc(stp_page, STP_OP_CTRL, 0x0000);
1357 if (rc == 1) 1359 if (rc == 0)
1358 set_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags); 1360 set_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags);
1359 else if (stp_online) { 1361 else if (stp_online) {
1360 printk(KERN_WARNING "Running on non STP capable machine.\n"); 1362 printk(KERN_WARNING "Running on non STP capable machine.\n");
diff --git a/arch/s390/lib/delay.c b/arch/s390/lib/delay.c
index fc6ab6094df8..6ccb9fab055a 100644
--- a/arch/s390/lib/delay.c
+++ b/arch/s390/lib/delay.c
@@ -1,14 +1,9 @@
1/* 1/*
2 * arch/s390/lib/delay.c
3 * Precise Delay Loops for S390 2 * Precise Delay Loops for S390
4 * 3 *
5 * S390 version 4 * Copyright IBM Corp. 1999,2008
6 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>,
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 6 * Heiko Carstens <heiko.carstens@de.ibm.com>,
8 *
9 * Derived from "arch/i386/lib/delay.c"
10 * Copyright (C) 1993 Linus Torvalds
11 * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
12 */ 7 */
13 8
14#include <linux/sched.h> 9#include <linux/sched.h>
@@ -29,30 +24,31 @@ void __delay(unsigned long loops)
29 asm volatile("0: brct %0,0b" : : "d" ((loops/2) + 1)); 24 asm volatile("0: brct %0,0b" : : "d" ((loops/2) + 1));
30} 25}
31 26
32/* 27static void __udelay_disabled(unsigned long usecs)
33 * Waits for 'usecs' microseconds using the TOD clock comparator.
34 */
35void __udelay(unsigned long usecs)
36{ 28{
37 u64 end, time, old_cc = 0; 29 unsigned long mask, cr0, cr0_saved;
38 unsigned long flags, cr0, mask, dummy; 30 u64 clock_saved;
39 int irq_context;
40 31
41 irq_context = in_interrupt(); 32 clock_saved = local_tick_disable();
42 if (!irq_context) 33 set_clock_comparator(get_clock() + ((u64) usecs << 12));
43 local_bh_disable(); 34 __ctl_store(cr0_saved, 0, 0);
44 local_irq_save(flags); 35 cr0 = (cr0_saved & 0xffff00e0) | 0x00000800;
45 if (raw_irqs_disabled_flags(flags)) { 36 __ctl_load(cr0 , 0, 0);
46 old_cc = local_tick_disable(); 37 mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT;
47 S390_lowcore.clock_comparator = -1ULL; 38 trace_hardirqs_on();
48 __ctl_store(cr0, 0, 0); 39 __load_psw_mask(mask);
49 dummy = (cr0 & 0xffff00e0) | 0x00000800; 40 local_irq_disable();
50 __ctl_load(dummy , 0, 0); 41 __ctl_load(cr0_saved, 0, 0);
51 mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT; 42 local_tick_enable(clock_saved);
52 } else 43 set_clock_comparator(S390_lowcore.clock_comparator);
53 mask = psw_kernel_bits | PSW_MASK_WAIT | 44}
54 PSW_MASK_EXT | PSW_MASK_IO; 45
46static void __udelay_enabled(unsigned long usecs)
47{
48 unsigned long mask;
49 u64 end, time;
55 50
51 mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT | PSW_MASK_IO;
56 end = get_clock() + ((u64) usecs << 12); 52 end = get_clock() + ((u64) usecs << 12);
57 do { 53 do {
58 time = end < S390_lowcore.clock_comparator ? 54 time = end < S390_lowcore.clock_comparator ?
@@ -62,13 +58,50 @@ void __udelay(unsigned long usecs)
62 __load_psw_mask(mask); 58 __load_psw_mask(mask);
63 local_irq_disable(); 59 local_irq_disable();
64 } while (get_clock() < end); 60 } while (get_clock() < end);
61 set_clock_comparator(S390_lowcore.clock_comparator);
62}
65 63
66 if (raw_irqs_disabled_flags(flags)) { 64/*
67 __ctl_load(cr0, 0, 0); 65 * Waits for 'usecs' microseconds using the TOD clock comparator.
68 local_tick_enable(old_cc); 66 */
67void __udelay(unsigned long usecs)
68{
69 unsigned long flags;
70
71 preempt_disable();
72 local_irq_save(flags);
73 if (in_irq()) {
74 __udelay_disabled(usecs);
75 goto out;
69 } 76 }
70 if (!irq_context) 77 if (in_softirq()) {
78 if (raw_irqs_disabled_flags(flags))
79 __udelay_disabled(usecs);
80 else
81 __udelay_enabled(usecs);
82 goto out;
83 }
84 if (raw_irqs_disabled_flags(flags)) {
85 local_bh_disable();
86 __udelay_disabled(usecs);
71 _local_bh_enable(); 87 _local_bh_enable();
72 set_clock_comparator(S390_lowcore.clock_comparator); 88 goto out;
89 }
90 __udelay_enabled(usecs);
91out:
73 local_irq_restore(flags); 92 local_irq_restore(flags);
93 preempt_enable();
94}
95
96/*
97 * Simple udelay variant. To be used on startup and reboot
98 * when the interrupt handler isn't working.
99 */
100void udelay_simple(unsigned long usecs)
101{
102 u64 end;
103
104 end = get_clock() + ((u64) usecs << 12);
105 while (get_clock() < end)
106 cpu_relax();
74} 107}
diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
index f231f5ec74b6..580fc64cc735 100644
--- a/arch/s390/mm/extmem.c
+++ b/arch/s390/mm/extmem.c
@@ -43,20 +43,40 @@
43#define DCSS_FINDSEG 0x0c 43#define DCSS_FINDSEG 0x0c
44#define DCSS_LOADNOLY 0x10 44#define DCSS_LOADNOLY 0x10
45#define DCSS_SEGEXT 0x18 45#define DCSS_SEGEXT 0x18
46#define DCSS_LOADSHRX 0x20
47#define DCSS_LOADNSRX 0x24
48#define DCSS_FINDSEGX 0x2c
49#define DCSS_SEGEXTX 0x38
46#define DCSS_FINDSEGA 0x0c 50#define DCSS_FINDSEGA 0x0c
47 51
48struct qrange { 52struct qrange {
49 unsigned int start; // 3byte start address, 1 byte type 53 unsigned long start; /* last byte type */
50 unsigned int end; // 3byte end address, 1 byte reserved 54 unsigned long end; /* last byte reserved */
51}; 55};
52 56
53struct qout64 { 57struct qout64 {
58 unsigned long segstart;
59 unsigned long segend;
60 int segcnt;
61 int segrcnt;
62 struct qrange range[6];
63};
64
65#ifdef CONFIG_64BIT
66struct qrange_old {
67 unsigned int start; /* last byte type */
68 unsigned int end; /* last byte reserved */
69};
70
71/* output area format for the Diag x'64' old subcode x'18' */
72struct qout64_old {
54 int segstart; 73 int segstart;
55 int segend; 74 int segend;
56 int segcnt; 75 int segcnt;
57 int segrcnt; 76 int segrcnt;
58 struct qrange range[6]; 77 struct qrange_old range[6];
59}; 78};
79#endif
60 80
61struct qin64 { 81struct qin64 {
62 char qopcode; 82 char qopcode;
@@ -86,6 +106,55 @@ static DEFINE_MUTEX(dcss_lock);
86static LIST_HEAD(dcss_list); 106static LIST_HEAD(dcss_list);
87static char *segtype_string[] = { "SW", "EW", "SR", "ER", "SN", "EN", "SC", 107static char *segtype_string[] = { "SW", "EW", "SR", "ER", "SN", "EN", "SC",
88 "EW/EN-MIXED" }; 108 "EW/EN-MIXED" };
109static int loadshr_scode, loadnsr_scode, findseg_scode;
110static int segext_scode, purgeseg_scode;
111static int scode_set;
112
113/* set correct Diag x'64' subcodes. */
114static int
115dcss_set_subcodes(void)
116{
117#ifdef CONFIG_64BIT
118 char *name = kmalloc(8 * sizeof(char), GFP_DMA);
119 unsigned long rx, ry;
120 int rc;
121
122 if (name == NULL)
123 return -ENOMEM;
124
125 rx = (unsigned long) name;
126 ry = DCSS_FINDSEGX;
127
128 strcpy(name, "dummy");
129 asm volatile(
130 " diag %0,%1,0x64\n"
131 "0: ipm %2\n"
132 " srl %2,28\n"
133 " j 2f\n"
134 "1: la %2,3\n"
135 "2:\n"
136 EX_TABLE(0b, 1b)
137 : "+d" (rx), "+d" (ry), "=d" (rc) : : "cc");
138
139 kfree(name);
140 /* Diag x'64' new subcodes are supported, set to new subcodes */
141 if (rc != 3) {
142 loadshr_scode = DCSS_LOADSHRX;
143 loadnsr_scode = DCSS_LOADNSRX;
144 purgeseg_scode = DCSS_PURGESEG;
145 findseg_scode = DCSS_FINDSEGX;
146 segext_scode = DCSS_SEGEXTX;
147 return 0;
148 }
149#endif
150 /* Diag x'64' new subcodes are not supported, set to old subcodes */
151 loadshr_scode = DCSS_LOADNOLY;
152 loadnsr_scode = DCSS_LOADNSR;
153 purgeseg_scode = DCSS_PURGESEG;
154 findseg_scode = DCSS_FINDSEG;
155 segext_scode = DCSS_SEGEXT;
156 return 0;
157}
89 158
90/* 159/*
91 * Create the 8 bytes, ebcdic VM segment name from 160 * Create the 8 bytes, ebcdic VM segment name from
@@ -135,25 +204,45 @@ segment_by_name (char *name)
135 * Perform a function on a dcss segment. 204 * Perform a function on a dcss segment.
136 */ 205 */
137static inline int 206static inline int
138dcss_diag (__u8 func, void *parameter, 207dcss_diag(int *func, void *parameter,
139 unsigned long *ret1, unsigned long *ret2) 208 unsigned long *ret1, unsigned long *ret2)
140{ 209{
141 unsigned long rx, ry; 210 unsigned long rx, ry;
142 int rc; 211 int rc;
143 212
213 if (scode_set == 0) {
214 rc = dcss_set_subcodes();
215 if (rc < 0)
216 return rc;
217 scode_set = 1;
218 }
144 rx = (unsigned long) parameter; 219 rx = (unsigned long) parameter;
145 ry = (unsigned long) func; 220 ry = (unsigned long) *func;
146 asm volatile( 221
147#ifdef CONFIG_64BIT 222#ifdef CONFIG_64BIT
148 " sam31\n" 223 /* 64-bit Diag x'64' new subcode, keep in 64-bit addressing mode */
149 " diag %0,%1,0x64\n" 224 if (*func > DCSS_SEGEXT)
150 " sam64\n" 225 asm volatile(
226 " diag %0,%1,0x64\n"
227 " ipm %2\n"
228 " srl %2,28\n"
229 : "+d" (rx), "+d" (ry), "=d" (rc) : : "cc");
230 /* 31-bit Diag x'64' old subcode, switch to 31-bit addressing mode */
231 else
232 asm volatile(
233 " sam31\n"
234 " diag %0,%1,0x64\n"
235 " sam64\n"
236 " ipm %2\n"
237 " srl %2,28\n"
238 : "+d" (rx), "+d" (ry), "=d" (rc) : : "cc");
151#else 239#else
240 asm volatile(
152 " diag %0,%1,0x64\n" 241 " diag %0,%1,0x64\n"
153#endif
154 " ipm %2\n" 242 " ipm %2\n"
155 " srl %2,28\n" 243 " srl %2,28\n"
156 : "+d" (rx), "+d" (ry), "=d" (rc) : : "cc"); 244 : "+d" (rx), "+d" (ry), "=d" (rc) : : "cc");
245#endif
157 *ret1 = rx; 246 *ret1 = rx;
158 *ret2 = ry; 247 *ret2 = ry;
159 return rc; 248 return rc;
@@ -190,14 +279,45 @@ query_segment_type (struct dcss_segment *seg)
190 qin->qoutlen = sizeof(struct qout64); 279 qin->qoutlen = sizeof(struct qout64);
191 memcpy (qin->qname, seg->dcss_name, 8); 280 memcpy (qin->qname, seg->dcss_name, 8);
192 281
193 diag_cc = dcss_diag (DCSS_SEGEXT, qin, &dummy, &vmrc); 282 diag_cc = dcss_diag(&segext_scode, qin, &dummy, &vmrc);
194 283
284 if (diag_cc < 0) {
285 rc = diag_cc;
286 goto out_free;
287 }
195 if (diag_cc > 1) { 288 if (diag_cc > 1) {
196 PRINT_WARN ("segment_type: diag returned error %ld\n", vmrc); 289 PRINT_WARN ("segment_type: diag returned error %ld\n", vmrc);
197 rc = dcss_diag_translate_rc (vmrc); 290 rc = dcss_diag_translate_rc (vmrc);
198 goto out_free; 291 goto out_free;
199 } 292 }
200 293
294#ifdef CONFIG_64BIT
295 /* Only old format of output area of Diagnose x'64' is supported,
296 copy data for the new format. */
297 if (segext_scode == DCSS_SEGEXT) {
298 struct qout64_old *qout_old;
299 qout_old = kzalloc(sizeof(struct qout64_old), GFP_DMA);
300 if (qout_old == NULL) {
301 rc = -ENOMEM;
302 goto out_free;
303 }
304 memcpy(qout_old, qout, sizeof(struct qout64_old));
305 qout->segstart = (unsigned long) qout_old->segstart;
306 qout->segend = (unsigned long) qout_old->segend;
307 qout->segcnt = qout_old->segcnt;
308 qout->segrcnt = qout_old->segrcnt;
309
310 if (qout->segcnt > 6)
311 qout->segrcnt = 6;
312 for (i = 0; i < qout->segrcnt; i++) {
313 qout->range[i].start =
314 (unsigned long) qout_old->range[i].start;
315 qout->range[i].end =
316 (unsigned long) qout_old->range[i].end;
317 }
318 kfree(qout_old);
319 }
320#endif
201 if (qout->segcnt > 6) { 321 if (qout->segcnt > 6) {
202 rc = -ENOTSUPP; 322 rc = -ENOTSUPP;
203 goto out_free; 323 goto out_free;
@@ -269,6 +389,30 @@ segment_type (char* name)
269} 389}
270 390
271/* 391/*
392 * check if segment collides with other segments that are currently loaded
393 * returns 1 if this is the case, 0 if no collision was found
394 */
395static int
396segment_overlaps_others (struct dcss_segment *seg)
397{
398 struct list_head *l;
399 struct dcss_segment *tmp;
400
401 BUG_ON(!mutex_is_locked(&dcss_lock));
402 list_for_each(l, &dcss_list) {
403 tmp = list_entry(l, struct dcss_segment, list);
404 if ((tmp->start_addr >> 20) > (seg->end >> 20))
405 continue;
406 if ((tmp->end >> 20) < (seg->start_addr >> 20))
407 continue;
408 if (seg == tmp)
409 continue;
410 return 1;
411 }
412 return 0;
413}
414
415/*
272 * real segment loading function, called from segment_load 416 * real segment loading function, called from segment_load
273 */ 417 */
274static int 418static int
@@ -276,7 +420,8 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
276{ 420{
277 struct dcss_segment *seg = kmalloc(sizeof(struct dcss_segment), 421 struct dcss_segment *seg = kmalloc(sizeof(struct dcss_segment),
278 GFP_DMA); 422 GFP_DMA);
279 int dcss_command, rc, diag_cc; 423 int rc, diag_cc;
424 unsigned long start_addr, end_addr, dummy;
280 425
281 if (seg == NULL) { 426 if (seg == NULL) {
282 rc = -ENOMEM; 427 rc = -ENOMEM;
@@ -287,6 +432,13 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
287 if (rc < 0) 432 if (rc < 0)
288 goto out_free; 433 goto out_free;
289 434
435 if (loadshr_scode == DCSS_LOADSHRX) {
436 if (segment_overlaps_others(seg)) {
437 rc = -EBUSY;
438 goto out_free;
439 }
440 }
441
290 rc = vmem_add_mapping(seg->start_addr, seg->end - seg->start_addr + 1); 442 rc = vmem_add_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
291 443
292 if (rc) 444 if (rc)
@@ -316,20 +468,28 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
316 } 468 }
317 469
318 if (do_nonshared) 470 if (do_nonshared)
319 dcss_command = DCSS_LOADNSR; 471 diag_cc = dcss_diag(&loadnsr_scode, seg->dcss_name,
472 &start_addr, &end_addr);
320 else 473 else
321 dcss_command = DCSS_LOADNOLY; 474 diag_cc = dcss_diag(&loadshr_scode, seg->dcss_name,
322 475 &start_addr, &end_addr);
323 diag_cc = dcss_diag(dcss_command, seg->dcss_name, 476 if (diag_cc < 0) {
324 &seg->start_addr, &seg->end); 477 dcss_diag(&purgeseg_scode, seg->dcss_name,
478 &dummy, &dummy);
479 rc = diag_cc;
480 goto out_resource;
481 }
325 if (diag_cc > 1) { 482 if (diag_cc > 1) {
326 PRINT_WARN ("segment_load: could not load segment %s - " 483 PRINT_WARN ("segment_load: could not load segment %s - "
327 "diag returned error (%ld)\n",name,seg->end); 484 "diag returned error (%ld)\n",
328 rc = dcss_diag_translate_rc (seg->end); 485 name, end_addr);
329 dcss_diag(DCSS_PURGESEG, seg->dcss_name, 486 rc = dcss_diag_translate_rc(end_addr);
330 &seg->start_addr, &seg->end); 487 dcss_diag(&purgeseg_scode, seg->dcss_name,
488 &dummy, &dummy);
331 goto out_resource; 489 goto out_resource;
332 } 490 }
491 seg->start_addr = start_addr;
492 seg->end = end_addr;
333 seg->do_nonshared = do_nonshared; 493 seg->do_nonshared = do_nonshared;
334 atomic_set(&seg->ref_count, 1); 494 atomic_set(&seg->ref_count, 1);
335 list_add(&seg->list, &dcss_list); 495 list_add(&seg->list, &dcss_list);
@@ -423,8 +583,8 @@ int
423segment_modify_shared (char *name, int do_nonshared) 583segment_modify_shared (char *name, int do_nonshared)
424{ 584{
425 struct dcss_segment *seg; 585 struct dcss_segment *seg;
426 unsigned long dummy; 586 unsigned long start_addr, end_addr, dummy;
427 int dcss_command, rc, diag_cc; 587 int rc, diag_cc;
428 588
429 mutex_lock(&dcss_lock); 589 mutex_lock(&dcss_lock);
430 seg = segment_by_name (name); 590 seg = segment_by_name (name);
@@ -445,38 +605,51 @@ segment_modify_shared (char *name, int do_nonshared)
445 goto out_unlock; 605 goto out_unlock;
446 } 606 }
447 release_resource(seg->res); 607 release_resource(seg->res);
448 if (do_nonshared) { 608 if (do_nonshared)
449 dcss_command = DCSS_LOADNSR;
450 seg->res->flags &= ~IORESOURCE_READONLY; 609 seg->res->flags &= ~IORESOURCE_READONLY;
451 } else { 610 else
452 dcss_command = DCSS_LOADNOLY;
453 if (seg->vm_segtype == SEG_TYPE_SR || 611 if (seg->vm_segtype == SEG_TYPE_SR ||
454 seg->vm_segtype == SEG_TYPE_ER) 612 seg->vm_segtype == SEG_TYPE_ER)
455 seg->res->flags |= IORESOURCE_READONLY; 613 seg->res->flags |= IORESOURCE_READONLY;
456 } 614
457 if (request_resource(&iomem_resource, seg->res)) { 615 if (request_resource(&iomem_resource, seg->res)) {
458 PRINT_WARN("segment_modify_shared: could not reload segment %s" 616 PRINT_WARN("segment_modify_shared: could not reload segment %s"
459 " - overlapping resources\n", name); 617 " - overlapping resources\n", name);
460 rc = -EBUSY; 618 rc = -EBUSY;
461 kfree(seg->res); 619 kfree(seg->res);
462 goto out_del; 620 goto out_del_mem;
621 }
622
623 dcss_diag(&purgeseg_scode, seg->dcss_name, &dummy, &dummy);
624 if (do_nonshared)
625 diag_cc = dcss_diag(&loadnsr_scode, seg->dcss_name,
626 &start_addr, &end_addr);
627 else
628 diag_cc = dcss_diag(&loadshr_scode, seg->dcss_name,
629 &start_addr, &end_addr);
630 if (diag_cc < 0) {
631 rc = diag_cc;
632 goto out_del_res;
463 } 633 }
464 dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy);
465 diag_cc = dcss_diag(dcss_command, seg->dcss_name,
466 &seg->start_addr, &seg->end);
467 if (diag_cc > 1) { 634 if (diag_cc > 1) {
468 PRINT_WARN ("segment_modify_shared: could not reload segment %s" 635 PRINT_WARN ("segment_modify_shared: could not reload segment %s"
469 " - diag returned error (%ld)\n",name,seg->end); 636 " - diag returned error (%ld)\n",
470 rc = dcss_diag_translate_rc (seg->end); 637 name, end_addr);
471 goto out_del; 638 rc = dcss_diag_translate_rc(end_addr);
639 goto out_del_res;
472 } 640 }
641 seg->start_addr = start_addr;
642 seg->end = end_addr;
473 seg->do_nonshared = do_nonshared; 643 seg->do_nonshared = do_nonshared;
474 rc = 0; 644 rc = 0;
475 goto out_unlock; 645 goto out_unlock;
476 out_del: 646 out_del_res:
647 release_resource(seg->res);
648 kfree(seg->res);
649 out_del_mem:
477 vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1); 650 vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
478 list_del(&seg->list); 651 list_del(&seg->list);
479 dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy); 652 dcss_diag(&purgeseg_scode, seg->dcss_name, &dummy, &dummy);
480 kfree(seg); 653 kfree(seg);
481 out_unlock: 654 out_unlock:
482 mutex_unlock(&dcss_lock); 655 mutex_unlock(&dcss_lock);
@@ -510,7 +683,7 @@ segment_unload(char *name)
510 kfree(seg->res); 683 kfree(seg->res);
511 vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1); 684 vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
512 list_del(&seg->list); 685 list_del(&seg->list);
513 dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy); 686 dcss_diag(&purgeseg_scode, seg->dcss_name, &dummy, &dummy);
514 kfree(seg); 687 kfree(seg);
515out_unlock: 688out_unlock:
516 mutex_unlock(&dcss_lock); 689 mutex_unlock(&dcss_lock);
@@ -545,7 +718,7 @@ segment_save(char *name)
545 endpfn = (seg->end) >> PAGE_SHIFT; 718 endpfn = (seg->end) >> PAGE_SHIFT;
546 sprintf(cmd1, "DEFSEG %s", name); 719 sprintf(cmd1, "DEFSEG %s", name);
547 for (i=0; i<seg->segcnt; i++) { 720 for (i=0; i<seg->segcnt; i++) {
548 sprintf(cmd1+strlen(cmd1), " %X-%X %s", 721 sprintf(cmd1+strlen(cmd1), " %lX-%lX %s",
549 seg->range[i].start >> PAGE_SHIFT, 722 seg->range[i].start >> PAGE_SHIFT,
550 seg->range[i].end >> PAGE_SHIFT, 723 seg->range[i].end >> PAGE_SHIFT,
551 segtype_string[seg->range[i].start & 0xff]); 724 segtype_string[seg->range[i].start & 0xff]);
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 60c50841143e..001778f9adaf 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -82,6 +82,8 @@ asmlinkage void __cpuinit start_secondary(void)
82 82
83 preempt_disable(); 83 preempt_disable();
84 84
85 notify_cpu_starting(smp_processor_id());
86
85 local_irq_enable(); 87 local_irq_enable();
86 88
87 calibrate_delay(); 89 calibrate_delay();
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index a214002114ed..97671dac12a6 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -20,6 +20,11 @@ config GENERIC_ISA_DMA
20 bool 20 bool
21 default y 21 default y
22 22
23config GENERIC_GPIO
24 bool
25 help
26 Generic GPIO API support
27
23config ARCH_NO_VIRT_TO_BUS 28config ARCH_NO_VIRT_TO_BUS
24 def_bool y 29 def_bool y
25 30
@@ -69,6 +74,9 @@ config SPARC
69 select HAVE_OPROFILE 74 select HAVE_OPROFILE
70 select HAVE_ARCH_KGDB if !SMP 75 select HAVE_ARCH_KGDB if !SMP
71 select HAVE_ARCH_TRACEHOOK 76 select HAVE_ARCH_TRACEHOOK
77 select ARCH_WANT_OPTIONAL_GPIOLIB
78 select RTC_CLASS
79 select RTC_DRV_M48T59
72 80
73# Identify this as a Sparc32 build 81# Identify this as a Sparc32 build
74config SPARC32 82config SPARC32
@@ -204,17 +212,6 @@ config SUN_PM
204 Enable power management and CPU standby features on supported 212 Enable power management and CPU standby features on supported
205 SPARC platforms. 213 SPARC platforms.
206 214
207config SUN4
208 bool "Support for SUN4 machines (disables SUN4[CDM] support)"
209 depends on !SMP
210 default n
211 help
212 Say Y here if, and only if, your machine is a sun4. Note that
213 a kernel compiled with this option will run only on sun4.
214 (And the current version will probably work only on sun4/330.)
215
216if !SUN4
217
218config PCI 215config PCI
219 bool "Support for PCI and PS/2 keyboard/mouse" 216 bool "Support for PCI and PS/2 keyboard/mouse"
220 help 217 help
@@ -227,11 +224,6 @@ config PCI_SYSCALL
227 224
228source "drivers/pci/Kconfig" 225source "drivers/pci/Kconfig"
229 226
230endif
231
232config NO_DMA
233 def_bool !PCI
234
235config SUN_OPENPROMFS 227config SUN_OPENPROMFS
236 tristate "Openprom tree appears in /proc/openprom" 228 tristate "Openprom tree appears in /proc/openprom"
237 help 229 help
@@ -263,9 +255,7 @@ source "net/Kconfig"
263 255
264source "drivers/Kconfig" 256source "drivers/Kconfig"
265 257
266if !SUN4
267source "drivers/sbus/char/Kconfig" 258source "drivers/sbus/char/Kconfig"
268endif
269 259
270# This one must be before the filesystem configs. -DaveM 260# This one must be before the filesystem configs. -DaveM
271 261
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
index a5f0ce734ff7..2ba7183bc1f0 100644
--- a/arch/sparc/include/asm/Kbuild
+++ b/arch/sparc/include/asm/Kbuild
@@ -22,7 +22,6 @@ header-y += unistd_64.h
22 22
23header-y += apc.h 23header-y += apc.h
24header-y += asi.h 24header-y += asi.h
25header-y += bpp.h
26header-y += display7seg.h 25header-y += display7seg.h
27header-y += envctrl.h 26header-y += envctrl.h
28header-y += fbio.h 27header-y += fbio.h
@@ -41,5 +40,4 @@ header-y += reg_64.h
41header-y += traps.h 40header-y += traps.h
42header-y += uctx.h 41header-y += uctx.h
43header-y += utrap.h 42header-y += utrap.h
44header-y += vfc_ioctls.h
45header-y += watchdog.h 43header-y += watchdog.h
diff --git a/arch/sparc/include/asm/asmmacro.h b/arch/sparc/include/asm/asmmacro.h
index a619a4d97aae..a995bf8aba3f 100644
--- a/arch/sparc/include/asm/asmmacro.h
+++ b/arch/sparc/include/asm/asmmacro.h
@@ -34,12 +34,7 @@
34/* sun4 probably wants half word accesses to ASI_SEGMAP, while sun4c+ 34/* sun4 probably wants half word accesses to ASI_SEGMAP, while sun4c+
35 likes byte accesses. These are to avoid ifdef mania. */ 35 likes byte accesses. These are to avoid ifdef mania. */
36 36
37#ifdef CONFIG_SUN4
38#define lduXa lduha
39#define stXa stha
40#else
41#define lduXa lduba 37#define lduXa lduba
42#define stXa stba 38#define stXa stba
43#endif
44 39
45#endif /* !(_SPARC_ASMMACRO_H) */ 40#endif /* !(_SPARC_ASMMACRO_H) */
diff --git a/arch/sparc/include/asm/bpp.h b/arch/sparc/include/asm/bpp.h
deleted file mode 100644
index 31f515e499a7..000000000000
--- a/arch/sparc/include/asm/bpp.h
+++ /dev/null
@@ -1,73 +0,0 @@
1#ifndef _SPARC_BPP_H
2#define _SPARC_BPP_H
3
4/*
5 * Copyright (c) 1995 Picture Elements
6 * Stephen Williams
7 * Gus Baldauf
8 *
9 * Linux/SPARC port by Peter Zaitcev.
10 * Integration into SPARC tree by Tom Dyas.
11 */
12
13#include <linux/ioctl.h>
14
15/*
16 * This is a driver that supports IEEE Std 1284-1994 communications
17 * with compliant or compatible devices. It will use whatever features
18 * the device supports, prefering those that are typically faster.
19 *
20 * When the device is opened, it is left in COMPATIBILITY mode, and
21 * writes work like any printer device. The driver only attempt to
22 * negotiate 1284 modes when needed so that plugs can be pulled,
23 * switch boxes switched, etc., without disrupting things. It will
24 * also leave the device in compatibility mode when closed.
25 */
26
27
28
29/*
30 * This driver also supplies ioctls to manually manipulate the
31 * pins. This is great for testing devices, or writing code to deal
32 * with bizzarro-mode of the ACME Special TurboThingy Plus.
33 *
34 * NOTE: These ioctl currently do not interact well with
35 * read/write. Caveat emptor.
36 *
37 * PUT_PINS allows us to assign the sense of all the pins, including
38 * the data pins if being driven by the host. The GET_PINS returns the
39 * pins that the peripheral drives, including data if appropriate.
40 */
41
42# define BPP_PUT_PINS _IOW('B', 1, int)
43# define BPP_GET_PINS _IOR('B', 2, char) /* that's bogus - should've been _IO */
44# define BPP_PUT_DATA _IOW('B', 3, int)
45# define BPP_GET_DATA _IOR('B', 4, char) /* ditto */
46
47/*
48 * Set the data bus to input mode. Disengage the data bin driver and
49 * be prepared to read values from the peripheral. If the arg is 0,
50 * then revert the bus to output mode.
51 */
52# define BPP_SET_INPUT _IOW('B', 5, int)
53
54/*
55 * These bits apply to the PUT operation...
56 */
57# define BPP_PP_nStrobe 0x0001
58# define BPP_PP_nAutoFd 0x0002
59# define BPP_PP_nInit 0x0004
60# define BPP_PP_nSelectIn 0x0008
61
62/*
63 * These apply to the GET operation, which also reads the current value
64 * of the previously put values. A bit mask of these will be returned
65 * as a bit mask in the return code of the ioctl().
66 */
67# define BPP_GP_nAck 0x0100
68# define BPP_GP_Busy 0x0200
69# define BPP_GP_PError 0x0400
70# define BPP_GP_Select 0x0800
71# define BPP_GP_nFault 0x1000
72
73#endif
diff --git a/arch/sparc/include/asm/bugs.h b/arch/sparc/include/asm/bugs.h
index e179bc12f64a..61d86bbbe2b2 100644
--- a/arch/sparc/include/asm/bugs.h
+++ b/arch/sparc/include/asm/bugs.h
@@ -7,10 +7,6 @@
7#include <asm/cpudata.h> 7#include <asm/cpudata.h>
8#endif 8#endif
9 9
10#ifdef CONFIG_SPARC64
11#include <asm/sstate.h>
12#endif
13
14extern unsigned long loops_per_jiffy; 10extern unsigned long loops_per_jiffy;
15 11
16static void __init check_bugs(void) 12static void __init check_bugs(void)
@@ -18,7 +14,4 @@ static void __init check_bugs(void)
18#if defined(CONFIG_SPARC32) && !defined(CONFIG_SMP) 14#if defined(CONFIG_SPARC32) && !defined(CONFIG_SMP)
19 cpu_data(0).udelay_val = loops_per_jiffy; 15 cpu_data(0).udelay_val = loops_per_jiffy;
20#endif 16#endif
21#ifdef CONFIG_SPARC64
22 sstate_running();
23#endif
24} 17}
diff --git a/arch/sparc/include/asm/cpudata_64.h b/arch/sparc/include/asm/cpudata_64.h
index 532975ecfe10..7da7c13d23c4 100644
--- a/arch/sparc/include/asm/cpudata_64.h
+++ b/arch/sparc/include/asm/cpudata_64.h
@@ -86,7 +86,6 @@ extern struct trap_per_cpu trap_block[NR_CPUS];
86extern void init_cur_cpu_trap(struct thread_info *); 86extern void init_cur_cpu_trap(struct thread_info *);
87extern void setup_tba(void); 87extern void setup_tba(void);
88extern int ncpus_probed; 88extern int ncpus_probed;
89extern void __init cpu_probe(void);
90extern const struct seq_operations cpuinfo_op; 89extern const struct seq_operations cpuinfo_op;
91 90
92extern unsigned long real_hard_smp_processor_id(void); 91extern unsigned long real_hard_smp_processor_id(void);
diff --git a/arch/sparc/include/asm/dma-mapping_32.h b/arch/sparc/include/asm/dma-mapping_32.h
index f3a641e6b2c8..8a57ea0573e6 100644
--- a/arch/sparc/include/asm/dma-mapping_32.h
+++ b/arch/sparc/include/asm/dma-mapping_32.h
@@ -1,11 +1,60 @@
1#ifndef _ASM_SPARC_DMA_MAPPING_H 1#ifndef _ASM_SPARC_DMA_MAPPING_H
2#define _ASM_SPARC_DMA_MAPPING_H 2#define _ASM_SPARC_DMA_MAPPING_H
3 3
4#include <linux/types.h>
4 5
5#ifdef CONFIG_PCI 6struct device;
6#include <asm-generic/dma-mapping.h> 7struct scatterlist;
7#else 8struct page;
8#include <asm-generic/dma-mapping-broken.h> 9
9#endif /* PCI */ 10#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
11
12extern int dma_supported(struct device *dev, u64 mask);
13extern int dma_set_mask(struct device *dev, u64 dma_mask);
14extern void *dma_alloc_coherent(struct device *dev, size_t size,
15 dma_addr_t *dma_handle, gfp_t flag);
16extern void dma_free_coherent(struct device *dev, size_t size,
17 void *cpu_addr, dma_addr_t dma_handle);
18extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
19 size_t size,
20 enum dma_data_direction direction);
21extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
22 size_t size,
23 enum dma_data_direction direction);
24extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
25 unsigned long offset, size_t size,
26 enum dma_data_direction direction);
27extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
28 size_t size, enum dma_data_direction direction);
29extern int dma_map_sg(struct device *dev, struct scatterlist *sg,
30 int nents, enum dma_data_direction direction);
31extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
32 int nents, enum dma_data_direction direction);
33extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
34 size_t size,
35 enum dma_data_direction direction);
36extern void dma_sync_single_for_device(struct device *dev,
37 dma_addr_t dma_handle,
38 size_t size,
39 enum dma_data_direction direction);
40extern void dma_sync_single_range_for_cpu(struct device *dev,
41 dma_addr_t dma_handle,
42 unsigned long offset,
43 size_t size,
44 enum dma_data_direction direction);
45extern void dma_sync_single_range_for_device(struct device *dev,
46 dma_addr_t dma_handle,
47 unsigned long offset, size_t size,
48 enum dma_data_direction direction);
49extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
50 int nelems, enum dma_data_direction direction);
51extern void dma_sync_sg_for_device(struct device *dev,
52 struct scatterlist *sg, int nelems,
53 enum dma_data_direction direction);
54extern int dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
55extern int dma_get_cache_alignment(void);
56
57#define dma_alloc_noncoherent dma_alloc_coherent
58#define dma_free_noncoherent dma_free_coherent
10 59
11#endif /* _ASM_SPARC_DMA_MAPPING_H */ 60#endif /* _ASM_SPARC_DMA_MAPPING_H */
diff --git a/arch/sparc/include/asm/dma.h b/arch/sparc/include/asm/dma.h
index aa1d90ac04c5..b554927bbaf6 100644
--- a/arch/sparc/include/asm/dma.h
+++ b/arch/sparc/include/asm/dma.h
@@ -1,8 +1,139 @@
1#ifndef ___ASM_SPARC_DMA_H 1#ifndef _ASM_SPARC_DMA_H
2#define ___ASM_SPARC_DMA_H 2#define _ASM_SPARC_DMA_H
3#if defined(__sparc__) && defined(__arch64__) 3
4#include <asm/dma_64.h> 4/* These are irrelevant for Sparc DMA, but we leave it in so that
5 * things can compile.
6 */
7#define MAX_DMA_CHANNELS 8
8#define DMA_MODE_READ 1
9#define DMA_MODE_WRITE 2
10#define MAX_DMA_ADDRESS (~0UL)
11
12/* Useful constants */
13#define SIZE_16MB (16*1024*1024)
14#define SIZE_64K (64*1024)
15
16/* SBUS DMA controller reg offsets */
17#define DMA_CSR 0x00UL /* rw DMA control/status register 0x00 */
18#define DMA_ADDR 0x04UL /* rw DMA transfer address register 0x04 */
19#define DMA_COUNT 0x08UL /* rw DMA transfer count register 0x08 */
20#define DMA_TEST 0x0cUL /* rw DMA test/debug register 0x0c */
21
22/* Fields in the cond_reg register */
23/* First, the version identification bits */
24#define DMA_DEVICE_ID 0xf0000000 /* Device identification bits */
25#define DMA_VERS0 0x00000000 /* Sunray DMA version */
26#define DMA_ESCV1 0x40000000 /* DMA ESC Version 1 */
27#define DMA_VERS1 0x80000000 /* DMA rev 1 */
28#define DMA_VERS2 0xa0000000 /* DMA rev 2 */
29#define DMA_VERHME 0xb0000000 /* DMA hme gate array */
30#define DMA_VERSPLUS 0x90000000 /* DMA rev 1 PLUS */
31
32#define DMA_HNDL_INTR 0x00000001 /* An IRQ needs to be handled */
33#define DMA_HNDL_ERROR 0x00000002 /* We need to take an error */
34#define DMA_FIFO_ISDRAIN 0x0000000c /* The DMA FIFO is draining */
35#define DMA_INT_ENAB 0x00000010 /* Turn on interrupts */
36#define DMA_FIFO_INV 0x00000020 /* Invalidate the FIFO */
37#define DMA_ACC_SZ_ERR 0x00000040 /* The access size was bad */
38#define DMA_FIFO_STDRAIN 0x00000040 /* DMA_VERS1 Drain the FIFO */
39#define DMA_RST_SCSI 0x00000080 /* Reset the SCSI controller */
40#define DMA_RST_ENET DMA_RST_SCSI /* Reset the ENET controller */
41#define DMA_ST_WRITE 0x00000100 /* write from device to memory */
42#define DMA_ENABLE 0x00000200 /* Fire up DMA, handle requests */
43#define DMA_PEND_READ 0x00000400 /* DMA_VERS1/0/PLUS Pending Read */
44#define DMA_ESC_BURST 0x00000800 /* 1=16byte 0=32byte */
45#define DMA_READ_AHEAD 0x00001800 /* DMA read ahead partial longword */
46#define DMA_DSBL_RD_DRN 0x00001000 /* No EC drain on slave reads */
47#define DMA_BCNT_ENAB 0x00002000 /* If on, use the byte counter */
48#define DMA_TERM_CNTR 0x00004000 /* Terminal counter */
49#define DMA_SCSI_SBUS64 0x00008000 /* HME: Enable 64-bit SBUS mode. */
50#define DMA_CSR_DISAB 0x00010000 /* No FIFO drains during csr */
51#define DMA_SCSI_DISAB 0x00020000 /* No FIFO drains during reg */
52#define DMA_DSBL_WR_INV 0x00020000 /* No EC inval. on slave writes */
53#define DMA_ADD_ENABLE 0x00040000 /* Special ESC DVMA optimization */
54#define DMA_E_BURSTS 0x000c0000 /* ENET: SBUS r/w burst mask */
55#define DMA_E_BURST32 0x00040000 /* ENET: SBUS 32 byte r/w burst */
56#define DMA_E_BURST16 0x00000000 /* ENET: SBUS 16 byte r/w burst */
57#define DMA_BRST_SZ 0x000c0000 /* SCSI: SBUS r/w burst size */
58#define DMA_BRST64 0x000c0000 /* SCSI: 64byte bursts (HME on UltraSparc only) */
59#define DMA_BRST32 0x00040000 /* SCSI: 32byte bursts */
60#define DMA_BRST16 0x00000000 /* SCSI: 16byte bursts */
61#define DMA_BRST0 0x00080000 /* SCSI: no bursts (non-HME gate arrays) */
62#define DMA_ADDR_DISAB 0x00100000 /* No FIFO drains during addr */
63#define DMA_2CLKS 0x00200000 /* Each transfer = 2 clock ticks */
64#define DMA_3CLKS 0x00400000 /* Each transfer = 3 clock ticks */
65#define DMA_EN_ENETAUI DMA_3CLKS /* Put lance into AUI-cable mode */
66#define DMA_CNTR_DISAB 0x00800000 /* No IRQ when DMA_TERM_CNTR set */
67#define DMA_AUTO_NADDR 0x01000000 /* Use "auto nxt addr" feature */
68#define DMA_SCSI_ON 0x02000000 /* Enable SCSI dma */
69#define DMA_PARITY_OFF 0x02000000 /* HME: disable parity checking */
70#define DMA_LOADED_ADDR 0x04000000 /* Address has been loaded */
71#define DMA_LOADED_NADDR 0x08000000 /* Next address has been loaded */
72#define DMA_RESET_FAS366 0x08000000 /* HME: Assert RESET to FAS366 */
73
74/* Values describing the burst-size property from the PROM */
75#define DMA_BURST1 0x01
76#define DMA_BURST2 0x02
77#define DMA_BURST4 0x04
78#define DMA_BURST8 0x08
79#define DMA_BURST16 0x10
80#define DMA_BURST32 0x20
81#define DMA_BURST64 0x40
82#define DMA_BURSTBITS 0x7f
83
84/* From PCI */
85
86#ifdef CONFIG_PCI
87extern int isa_dma_bridge_buggy;
5#else 88#else
6#include <asm/dma_32.h> 89#define isa_dma_bridge_buggy (0)
7#endif 90#endif
91
92#ifdef CONFIG_SPARC32
93
94/* Routines for data transfer buffers. */
95BTFIXUPDEF_CALL(char *, mmu_lockarea, char *, unsigned long)
96BTFIXUPDEF_CALL(void, mmu_unlockarea, char *, unsigned long)
97
98#define mmu_lockarea(vaddr,len) BTFIXUP_CALL(mmu_lockarea)(vaddr,len)
99#define mmu_unlockarea(vaddr,len) BTFIXUP_CALL(mmu_unlockarea)(vaddr,len)
100
101struct page;
102struct device;
103struct scatterlist;
104
105/* These are implementations for sbus_map_sg/sbus_unmap_sg... collapse later */
106BTFIXUPDEF_CALL(__u32, mmu_get_scsi_one, struct device *, char *, unsigned long)
107BTFIXUPDEF_CALL(void, mmu_get_scsi_sgl, struct device *, struct scatterlist *, int)
108BTFIXUPDEF_CALL(void, mmu_release_scsi_one, struct device *, __u32, unsigned long)
109BTFIXUPDEF_CALL(void, mmu_release_scsi_sgl, struct device *, struct scatterlist *, int)
110
111#define mmu_get_scsi_one(dev,vaddr,len) BTFIXUP_CALL(mmu_get_scsi_one)(dev,vaddr,len)
112#define mmu_get_scsi_sgl(dev,sg,sz) BTFIXUP_CALL(mmu_get_scsi_sgl)(dev,sg,sz)
113#define mmu_release_scsi_one(dev,vaddr,len) BTFIXUP_CALL(mmu_release_scsi_one)(dev,vaddr,len)
114#define mmu_release_scsi_sgl(dev,sg,sz) BTFIXUP_CALL(mmu_release_scsi_sgl)(dev,sg,sz)
115
116/*
117 * mmu_map/unmap are provided by iommu/iounit; Invalid to call on IIep.
118 *
119 * The mmu_map_dma_area establishes two mappings in one go.
120 * These mappings point to pages normally mapped at 'va' (linear address).
121 * First mapping is for CPU visible address at 'a', uncached.
122 * This is an alias, but it works because it is an uncached mapping.
123 * Second mapping is for device visible address, or "bus" address.
124 * The bus address is returned at '*pba'.
125 *
126 * These functions seem distinct, but are hard to split. On sun4c,
127 * at least for now, 'a' is equal to bus address, and retured in *pba.
128 * On sun4m, page attributes depend on the CPU type, so we have to
129 * know if we are mapping RAM or I/O, so it has to be an additional argument
130 * to a separate mapping function for CPU visible mappings.
131 */
132BTFIXUPDEF_CALL(int, mmu_map_dma_area, struct device *, dma_addr_t *, unsigned long, unsigned long, int len)
133BTFIXUPDEF_CALL(void, mmu_unmap_dma_area, struct device *, unsigned long busa, int len)
134
135#define mmu_map_dma_area(dev,pba,va,a,len) BTFIXUP_CALL(mmu_map_dma_area)(dev,pba,va,a,len)
136#define mmu_unmap_dma_area(dev,ba,len) BTFIXUP_CALL(mmu_unmap_dma_area)(dev,ba,len)
8#endif 137#endif
138
139#endif /* !(_ASM_SPARC_DMA_H) */
diff --git a/arch/sparc/include/asm/dma_32.h b/arch/sparc/include/asm/dma_32.h
deleted file mode 100644
index cf7189c0079b..000000000000
--- a/arch/sparc/include/asm/dma_32.h
+++ /dev/null
@@ -1,288 +0,0 @@
1/* include/asm/dma.h
2 *
3 * Copyright 1995 (C) David S. Miller (davem@davemloft.net)
4 */
5
6#ifndef _ASM_SPARC_DMA_H
7#define _ASM_SPARC_DMA_H
8
9#include <linux/kernel.h>
10#include <linux/types.h>
11
12#include <asm/vac-ops.h> /* for invalidate's, etc. */
13#include <asm/sbus.h>
14#include <asm/delay.h>
15#include <asm/oplib.h>
16#include <asm/system.h>
17#include <asm/io.h>
18#include <linux/spinlock.h>
19
20struct page;
21extern spinlock_t dma_spin_lock;
22
23static inline unsigned long claim_dma_lock(void)
24{
25 unsigned long flags;
26 spin_lock_irqsave(&dma_spin_lock, flags);
27 return flags;
28}
29
30static inline void release_dma_lock(unsigned long flags)
31{
32 spin_unlock_irqrestore(&dma_spin_lock, flags);
33}
34
35/* These are irrelevant for Sparc DMA, but we leave it in so that
36 * things can compile.
37 */
38#define MAX_DMA_CHANNELS 8
39#define MAX_DMA_ADDRESS (~0UL)
40#define DMA_MODE_READ 1
41#define DMA_MODE_WRITE 2
42
43/* Useful constants */
44#define SIZE_16MB (16*1024*1024)
45#define SIZE_64K (64*1024)
46
47/* SBUS DMA controller reg offsets */
48#define DMA_CSR 0x00UL /* rw DMA control/status register 0x00 */
49#define DMA_ADDR 0x04UL /* rw DMA transfer address register 0x04 */
50#define DMA_COUNT 0x08UL /* rw DMA transfer count register 0x08 */
51#define DMA_TEST 0x0cUL /* rw DMA test/debug register 0x0c */
52
53/* DVMA chip revisions */
54enum dvma_rev {
55 dvmarev0,
56 dvmaesc1,
57 dvmarev1,
58 dvmarev2,
59 dvmarev3,
60 dvmarevplus,
61 dvmahme
62};
63
64#define DMA_HASCOUNT(rev) ((rev)==dvmaesc1)
65
66/* Linux DMA information structure, filled during probe. */
67struct sbus_dma {
68 struct sbus_dma *next;
69 struct sbus_dev *sdev;
70 void __iomem *regs;
71
72 /* Status, misc info */
73 int node; /* Prom node for this DMA device */
74 int running; /* Are we doing DMA now? */
75 int allocated; /* Are we "owned" by anyone yet? */
76
77 /* Transfer information. */
78 unsigned long addr; /* Start address of current transfer */
79 int nbytes; /* Size of current transfer */
80 int realbytes; /* For splitting up large transfers, etc. */
81
82 /* DMA revision */
83 enum dvma_rev revision;
84};
85
86extern struct sbus_dma *dma_chain;
87
88/* Broken hardware... */
89#ifdef CONFIG_SUN4
90/* Have to sort this out. Does rev0 work fine on sun4[cmd] without isbroken?
91 * Or is rev0 present only on sun4 boxes? -jj */
92#define DMA_ISBROKEN(dma) ((dma)->revision == dvmarev0 || (dma)->revision == dvmarev1)
93#else
94#define DMA_ISBROKEN(dma) ((dma)->revision == dvmarev1)
95#endif
96#define DMA_ISESC1(dma) ((dma)->revision == dvmaesc1)
97
98/* Main routines in dma.c */
99extern void dvma_init(struct sbus_bus *);
100
101/* Fields in the cond_reg register */
102/* First, the version identification bits */
103#define DMA_DEVICE_ID 0xf0000000 /* Device identification bits */
104#define DMA_VERS0 0x00000000 /* Sunray DMA version */
105#define DMA_ESCV1 0x40000000 /* DMA ESC Version 1 */
106#define DMA_VERS1 0x80000000 /* DMA rev 1 */
107#define DMA_VERS2 0xa0000000 /* DMA rev 2 */
108#define DMA_VERHME 0xb0000000 /* DMA hme gate array */
109#define DMA_VERSPLUS 0x90000000 /* DMA rev 1 PLUS */
110
111#define DMA_HNDL_INTR 0x00000001 /* An IRQ needs to be handled */
112#define DMA_HNDL_ERROR 0x00000002 /* We need to take an error */
113#define DMA_FIFO_ISDRAIN 0x0000000c /* The DMA FIFO is draining */
114#define DMA_INT_ENAB 0x00000010 /* Turn on interrupts */
115#define DMA_FIFO_INV 0x00000020 /* Invalidate the FIFO */
116#define DMA_ACC_SZ_ERR 0x00000040 /* The access size was bad */
117#define DMA_FIFO_STDRAIN 0x00000040 /* DMA_VERS1 Drain the FIFO */
118#define DMA_RST_SCSI 0x00000080 /* Reset the SCSI controller */
119#define DMA_RST_ENET DMA_RST_SCSI /* Reset the ENET controller */
120#define DMA_RST_BPP DMA_RST_SCSI /* Reset the BPP controller */
121#define DMA_ST_WRITE 0x00000100 /* write from device to memory */
122#define DMA_ENABLE 0x00000200 /* Fire up DMA, handle requests */
123#define DMA_PEND_READ 0x00000400 /* DMA_VERS1/0/PLUS Pending Read */
124#define DMA_ESC_BURST 0x00000800 /* 1=16byte 0=32byte */
125#define DMA_READ_AHEAD 0x00001800 /* DMA read ahead partial longword */
126#define DMA_DSBL_RD_DRN 0x00001000 /* No EC drain on slave reads */
127#define DMA_BCNT_ENAB 0x00002000 /* If on, use the byte counter */
128#define DMA_TERM_CNTR 0x00004000 /* Terminal counter */
129#define DMA_SCSI_SBUS64 0x00008000 /* HME: Enable 64-bit SBUS mode. */
130#define DMA_CSR_DISAB 0x00010000 /* No FIFO drains during csr */
131#define DMA_SCSI_DISAB 0x00020000 /* No FIFO drains during reg */
132#define DMA_DSBL_WR_INV 0x00020000 /* No EC inval. on slave writes */
133#define DMA_ADD_ENABLE 0x00040000 /* Special ESC DVMA optimization */
134#define DMA_E_BURSTS 0x000c0000 /* ENET: SBUS r/w burst mask */
135#define DMA_E_BURST32 0x00040000 /* ENET: SBUS 32 byte r/w burst */
136#define DMA_E_BURST16 0x00000000 /* ENET: SBUS 16 byte r/w burst */
137#define DMA_BRST_SZ 0x000c0000 /* SCSI: SBUS r/w burst size */
138#define DMA_BRST64 0x00080000 /* SCSI: 64byte bursts (HME on UltraSparc only) */
139#define DMA_BRST32 0x00040000 /* SCSI/BPP: 32byte bursts */
140#define DMA_BRST16 0x00000000 /* SCSI/BPP: 16byte bursts */
141#define DMA_BRST0 0x00080000 /* SCSI: no bursts (non-HME gate arrays) */
142#define DMA_ADDR_DISAB 0x00100000 /* No FIFO drains during addr */
143#define DMA_2CLKS 0x00200000 /* Each transfer = 2 clock ticks */
144#define DMA_3CLKS 0x00400000 /* Each transfer = 3 clock ticks */
145#define DMA_EN_ENETAUI DMA_3CLKS /* Put lance into AUI-cable mode */
146#define DMA_CNTR_DISAB 0x00800000 /* No IRQ when DMA_TERM_CNTR set */
147#define DMA_AUTO_NADDR 0x01000000 /* Use "auto nxt addr" feature */
148#define DMA_SCSI_ON 0x02000000 /* Enable SCSI dma */
149#define DMA_BPP_ON DMA_SCSI_ON /* Enable BPP dma */
150#define DMA_PARITY_OFF 0x02000000 /* HME: disable parity checking */
151#define DMA_LOADED_ADDR 0x04000000 /* Address has been loaded */
152#define DMA_LOADED_NADDR 0x08000000 /* Next address has been loaded */
153#define DMA_RESET_FAS366 0x08000000 /* HME: Assert RESET to FAS366 */
154
155/* Values describing the burst-size property from the PROM */
156#define DMA_BURST1 0x01
157#define DMA_BURST2 0x02
158#define DMA_BURST4 0x04
159#define DMA_BURST8 0x08
160#define DMA_BURST16 0x10
161#define DMA_BURST32 0x20
162#define DMA_BURST64 0x40
163#define DMA_BURSTBITS 0x7f
164
165/* Determine highest possible final transfer address given a base */
166#define DMA_MAXEND(addr) (0x01000000UL-(((unsigned long)(addr))&0x00ffffffUL))
167
168/* Yes, I hack a lot of elisp in my spare time... */
169#define DMA_ERROR_P(regs) ((((regs)->cond_reg) & DMA_HNDL_ERROR))
170#define DMA_IRQ_P(regs) ((((regs)->cond_reg) & (DMA_HNDL_INTR | DMA_HNDL_ERROR)))
171#define DMA_WRITE_P(regs) ((((regs)->cond_reg) & DMA_ST_WRITE))
172#define DMA_OFF(regs) ((((regs)->cond_reg) &= (~DMA_ENABLE)))
173#define DMA_INTSOFF(regs) ((((regs)->cond_reg) &= (~DMA_INT_ENAB)))
174#define DMA_INTSON(regs) ((((regs)->cond_reg) |= (DMA_INT_ENAB)))
175#define DMA_PUNTFIFO(regs) ((((regs)->cond_reg) |= DMA_FIFO_INV))
176#define DMA_SETSTART(regs, addr) ((((regs)->st_addr) = (char *) addr))
177#define DMA_BEGINDMA_W(regs) \
178 ((((regs)->cond_reg |= (DMA_ST_WRITE|DMA_ENABLE|DMA_INT_ENAB))))
179#define DMA_BEGINDMA_R(regs) \
180 ((((regs)->cond_reg |= ((DMA_ENABLE|DMA_INT_ENAB)&(~DMA_ST_WRITE)))))
181
182/* For certain DMA chips, we need to disable ints upon irq entry
183 * and turn them back on when we are done. So in any ESP interrupt
184 * handler you *must* call DMA_IRQ_ENTRY upon entry and DMA_IRQ_EXIT
185 * when leaving the handler. You have been warned...
186 */
187#define DMA_IRQ_ENTRY(dma, dregs) do { \
188 if(DMA_ISBROKEN(dma)) DMA_INTSOFF(dregs); \
189 } while (0)
190
191#define DMA_IRQ_EXIT(dma, dregs) do { \
192 if(DMA_ISBROKEN(dma)) DMA_INTSON(dregs); \
193 } while(0)
194
195#if 0 /* P3 this stuff is inline in ledma.c:init_restart_ledma() */
196/* Pause until counter runs out or BIT isn't set in the DMA condition
197 * register.
198 */
199static inline void sparc_dma_pause(struct sparc_dma_registers *regs,
200 unsigned long bit)
201{
202 int ctr = 50000; /* Let's find some bugs ;) */
203
204 /* Busy wait until the bit is not set any more */
205 while((regs->cond_reg&bit) && (ctr>0)) {
206 ctr--;
207 __delay(5);
208 }
209
210 /* Check for bogus outcome. */
211 if(!ctr)
212 panic("DMA timeout");
213}
214
215/* Reset the friggin' thing... */
216#define DMA_RESET(dma) do { \
217 struct sparc_dma_registers *regs = dma->regs; \
218 /* Let the current FIFO drain itself */ \
219 sparc_dma_pause(regs, (DMA_FIFO_ISDRAIN)); \
220 /* Reset the logic */ \
221 regs->cond_reg |= (DMA_RST_SCSI); /* assert */ \
222 __delay(400); /* let the bits set ;) */ \
223 regs->cond_reg &= ~(DMA_RST_SCSI); /* de-assert */ \
224 sparc_dma_enable_interrupts(regs); /* Re-enable interrupts */ \
225 /* Enable FAST transfers if available */ \
226 if(dma->revision>dvmarev1) regs->cond_reg |= DMA_3CLKS; \
227 dma->running = 0; \
228} while(0)
229#endif
230
231#define for_each_dvma(dma) \
232 for((dma) = dma_chain; (dma); (dma) = (dma)->next)
233
234extern int get_dma_list(char *);
235extern int request_dma(unsigned int, __const__ char *);
236extern void free_dma(unsigned int);
237
238/* From PCI */
239
240#ifdef CONFIG_PCI
241extern int isa_dma_bridge_buggy;
242#else
243#define isa_dma_bridge_buggy (0)
244#endif
245
246/* Routines for data transfer buffers. */
247BTFIXUPDEF_CALL(char *, mmu_lockarea, char *, unsigned long)
248BTFIXUPDEF_CALL(void, mmu_unlockarea, char *, unsigned long)
249
250#define mmu_lockarea(vaddr,len) BTFIXUP_CALL(mmu_lockarea)(vaddr,len)
251#define mmu_unlockarea(vaddr,len) BTFIXUP_CALL(mmu_unlockarea)(vaddr,len)
252
253/* These are implementations for sbus_map_sg/sbus_unmap_sg... collapse later */
254BTFIXUPDEF_CALL(__u32, mmu_get_scsi_one, char *, unsigned long, struct sbus_bus *sbus)
255BTFIXUPDEF_CALL(void, mmu_get_scsi_sgl, struct scatterlist *, int, struct sbus_bus *sbus)
256BTFIXUPDEF_CALL(void, mmu_release_scsi_one, __u32, unsigned long, struct sbus_bus *sbus)
257BTFIXUPDEF_CALL(void, mmu_release_scsi_sgl, struct scatterlist *, int, struct sbus_bus *sbus)
258
259#define mmu_get_scsi_one(vaddr,len,sbus) BTFIXUP_CALL(mmu_get_scsi_one)(vaddr,len,sbus)
260#define mmu_get_scsi_sgl(sg,sz,sbus) BTFIXUP_CALL(mmu_get_scsi_sgl)(sg,sz,sbus)
261#define mmu_release_scsi_one(vaddr,len,sbus) BTFIXUP_CALL(mmu_release_scsi_one)(vaddr,len,sbus)
262#define mmu_release_scsi_sgl(sg,sz,sbus) BTFIXUP_CALL(mmu_release_scsi_sgl)(sg,sz,sbus)
263
264/*
265 * mmu_map/unmap are provided by iommu/iounit; Invalid to call on IIep.
266 *
267 * The mmu_map_dma_area establishes two mappings in one go.
268 * These mappings point to pages normally mapped at 'va' (linear address).
269 * First mapping is for CPU visible address at 'a', uncached.
270 * This is an alias, but it works because it is an uncached mapping.
271 * Second mapping is for device visible address, or "bus" address.
272 * The bus address is returned at '*pba'.
273 *
274 * These functions seem distinct, but are hard to split. On sun4c,
275 * at least for now, 'a' is equal to bus address, and retured in *pba.
276 * On sun4m, page attributes depend on the CPU type, so we have to
277 * know if we are mapping RAM or I/O, so it has to be an additional argument
278 * to a separate mapping function for CPU visible mappings.
279 */
280BTFIXUPDEF_CALL(int, mmu_map_dma_area, dma_addr_t *, unsigned long, unsigned long, int len)
281BTFIXUPDEF_CALL(struct page *, mmu_translate_dvma, unsigned long busa)
282BTFIXUPDEF_CALL(void, mmu_unmap_dma_area, unsigned long busa, int len)
283
284#define mmu_map_dma_area(pba,va,a,len) BTFIXUP_CALL(mmu_map_dma_area)(pba,va,a,len)
285#define mmu_unmap_dma_area(ba,len) BTFIXUP_CALL(mmu_unmap_dma_area)(ba,len)
286#define mmu_translate_dvma(ba) BTFIXUP_CALL(mmu_translate_dvma)(ba)
287
288#endif /* !(_ASM_SPARC_DMA_H) */
diff --git a/arch/sparc/include/asm/dma_64.h b/arch/sparc/include/asm/dma_64.h
deleted file mode 100644
index 46a8aecffc02..000000000000
--- a/arch/sparc/include/asm/dma_64.h
+++ /dev/null
@@ -1,205 +0,0 @@
1/*
2 * include/asm/dma.h
3 *
4 * Copyright 1996 (C) David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _ASM_SPARC64_DMA_H
8#define _ASM_SPARC64_DMA_H
9
10#include <linux/kernel.h>
11#include <linux/types.h>
12#include <linux/spinlock.h>
13
14#include <asm/sbus.h>
15#include <asm/delay.h>
16#include <asm/oplib.h>
17
18/* These are irrelevant for Sparc DMA, but we leave it in so that
19 * things can compile.
20 */
21#define MAX_DMA_CHANNELS 8
22#define DMA_MODE_READ 1
23#define DMA_MODE_WRITE 2
24#define MAX_DMA_ADDRESS (~0UL)
25
26/* Useful constants */
27#define SIZE_16MB (16*1024*1024)
28#define SIZE_64K (64*1024)
29
30/* SBUS DMA controller reg offsets */
31#define DMA_CSR 0x00UL /* rw DMA control/status register 0x00 */
32#define DMA_ADDR 0x04UL /* rw DMA transfer address register 0x04 */
33#define DMA_COUNT 0x08UL /* rw DMA transfer count register 0x08 */
34#define DMA_TEST 0x0cUL /* rw DMA test/debug register 0x0c */
35
36/* DVMA chip revisions */
37enum dvma_rev {
38 dvmarev0,
39 dvmaesc1,
40 dvmarev1,
41 dvmarev2,
42 dvmarev3,
43 dvmarevplus,
44 dvmahme
45};
46
47#define DMA_HASCOUNT(rev) ((rev)==dvmaesc1)
48
49/* Linux DMA information structure, filled during probe. */
50struct sbus_dma {
51 struct sbus_dma *next;
52 struct sbus_dev *sdev;
53 void __iomem *regs;
54
55 /* Status, misc info */
56 int node; /* Prom node for this DMA device */
57 int running; /* Are we doing DMA now? */
58 int allocated; /* Are we "owned" by anyone yet? */
59
60 /* Transfer information. */
61 u32 addr; /* Start address of current transfer */
62 int nbytes; /* Size of current transfer */
63 int realbytes; /* For splitting up large transfers, etc. */
64
65 /* DMA revision */
66 enum dvma_rev revision;
67};
68
69extern struct sbus_dma *dma_chain;
70
71/* Broken hardware... */
72#define DMA_ISBROKEN(dma) ((dma)->revision == dvmarev1)
73#define DMA_ISESC1(dma) ((dma)->revision == dvmaesc1)
74
75/* Main routines in dma.c */
76extern void dvma_init(struct sbus_bus *);
77
78/* Fields in the cond_reg register */
79/* First, the version identification bits */
80#define DMA_DEVICE_ID 0xf0000000 /* Device identification bits */
81#define DMA_VERS0 0x00000000 /* Sunray DMA version */
82#define DMA_ESCV1 0x40000000 /* DMA ESC Version 1 */
83#define DMA_VERS1 0x80000000 /* DMA rev 1 */
84#define DMA_VERS2 0xa0000000 /* DMA rev 2 */
85#define DMA_VERHME 0xb0000000 /* DMA hme gate array */
86#define DMA_VERSPLUS 0x90000000 /* DMA rev 1 PLUS */
87
88#define DMA_HNDL_INTR 0x00000001 /* An IRQ needs to be handled */
89#define DMA_HNDL_ERROR 0x00000002 /* We need to take an error */
90#define DMA_FIFO_ISDRAIN 0x0000000c /* The DMA FIFO is draining */
91#define DMA_INT_ENAB 0x00000010 /* Turn on interrupts */
92#define DMA_FIFO_INV 0x00000020 /* Invalidate the FIFO */
93#define DMA_ACC_SZ_ERR 0x00000040 /* The access size was bad */
94#define DMA_FIFO_STDRAIN 0x00000040 /* DMA_VERS1 Drain the FIFO */
95#define DMA_RST_SCSI 0x00000080 /* Reset the SCSI controller */
96#define DMA_RST_ENET DMA_RST_SCSI /* Reset the ENET controller */
97#define DMA_ST_WRITE 0x00000100 /* write from device to memory */
98#define DMA_ENABLE 0x00000200 /* Fire up DMA, handle requests */
99#define DMA_PEND_READ 0x00000400 /* DMA_VERS1/0/PLUS Pending Read */
100#define DMA_ESC_BURST 0x00000800 /* 1=16byte 0=32byte */
101#define DMA_READ_AHEAD 0x00001800 /* DMA read ahead partial longword */
102#define DMA_DSBL_RD_DRN 0x00001000 /* No EC drain on slave reads */
103#define DMA_BCNT_ENAB 0x00002000 /* If on, use the byte counter */
104#define DMA_TERM_CNTR 0x00004000 /* Terminal counter */
105#define DMA_SCSI_SBUS64 0x00008000 /* HME: Enable 64-bit SBUS mode. */
106#define DMA_CSR_DISAB 0x00010000 /* No FIFO drains during csr */
107#define DMA_SCSI_DISAB 0x00020000 /* No FIFO drains during reg */
108#define DMA_DSBL_WR_INV 0x00020000 /* No EC inval. on slave writes */
109#define DMA_ADD_ENABLE 0x00040000 /* Special ESC DVMA optimization */
110#define DMA_E_BURSTS 0x000c0000 /* ENET: SBUS r/w burst mask */
111#define DMA_E_BURST32 0x00040000 /* ENET: SBUS 32 byte r/w burst */
112#define DMA_E_BURST16 0x00000000 /* ENET: SBUS 16 byte r/w burst */
113#define DMA_BRST_SZ 0x000c0000 /* SCSI: SBUS r/w burst size */
114#define DMA_BRST64 0x000c0000 /* SCSI: 64byte bursts (HME on UltraSparc only) */
115#define DMA_BRST32 0x00040000 /* SCSI: 32byte bursts */
116#define DMA_BRST16 0x00000000 /* SCSI: 16byte bursts */
117#define DMA_BRST0 0x00080000 /* SCSI: no bursts (non-HME gate arrays) */
118#define DMA_ADDR_DISAB 0x00100000 /* No FIFO drains during addr */
119#define DMA_2CLKS 0x00200000 /* Each transfer = 2 clock ticks */
120#define DMA_3CLKS 0x00400000 /* Each transfer = 3 clock ticks */
121#define DMA_EN_ENETAUI DMA_3CLKS /* Put lance into AUI-cable mode */
122#define DMA_CNTR_DISAB 0x00800000 /* No IRQ when DMA_TERM_CNTR set */
123#define DMA_AUTO_NADDR 0x01000000 /* Use "auto nxt addr" feature */
124#define DMA_SCSI_ON 0x02000000 /* Enable SCSI dma */
125#define DMA_PARITY_OFF 0x02000000 /* HME: disable parity checking */
126#define DMA_LOADED_ADDR 0x04000000 /* Address has been loaded */
127#define DMA_LOADED_NADDR 0x08000000 /* Next address has been loaded */
128#define DMA_RESET_FAS366 0x08000000 /* HME: Assert RESET to FAS366 */
129
130/* Values describing the burst-size property from the PROM */
131#define DMA_BURST1 0x01
132#define DMA_BURST2 0x02
133#define DMA_BURST4 0x04
134#define DMA_BURST8 0x08
135#define DMA_BURST16 0x10
136#define DMA_BURST32 0x20
137#define DMA_BURST64 0x40
138#define DMA_BURSTBITS 0x7f
139
140/* Determine highest possible final transfer address given a base */
141#define DMA_MAXEND(addr) (0x01000000UL-(((unsigned long)(addr))&0x00ffffffUL))
142
143/* Yes, I hack a lot of elisp in my spare time... */
144#define DMA_ERROR_P(regs) ((sbus_readl((regs) + DMA_CSR) & DMA_HNDL_ERROR))
145#define DMA_IRQ_P(regs) ((sbus_readl((regs) + DMA_CSR)) & (DMA_HNDL_INTR | DMA_HNDL_ERROR))
146#define DMA_WRITE_P(regs) ((sbus_readl((regs) + DMA_CSR) & DMA_ST_WRITE))
147#define DMA_OFF(__regs) \
148do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
149 tmp &= ~DMA_ENABLE; \
150 sbus_writel(tmp, (__regs) + DMA_CSR); \
151} while(0)
152#define DMA_INTSOFF(__regs) \
153do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
154 tmp &= ~DMA_INT_ENAB; \
155 sbus_writel(tmp, (__regs) + DMA_CSR); \
156} while(0)
157#define DMA_INTSON(__regs) \
158do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
159 tmp |= DMA_INT_ENAB; \
160 sbus_writel(tmp, (__regs) + DMA_CSR); \
161} while(0)
162#define DMA_PUNTFIFO(__regs) \
163do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
164 tmp |= DMA_FIFO_INV; \
165 sbus_writel(tmp, (__regs) + DMA_CSR); \
166} while(0)
167#define DMA_SETSTART(__regs, __addr) \
168 sbus_writel((u32)(__addr), (__regs) + DMA_ADDR);
169#define DMA_BEGINDMA_W(__regs) \
170do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
171 tmp |= (DMA_ST_WRITE|DMA_ENABLE|DMA_INT_ENAB); \
172 sbus_writel(tmp, (__regs) + DMA_CSR); \
173} while(0)
174#define DMA_BEGINDMA_R(__regs) \
175do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
176 tmp |= (DMA_ENABLE|DMA_INT_ENAB); \
177 tmp &= ~DMA_ST_WRITE; \
178 sbus_writel(tmp, (__regs) + DMA_CSR); \
179} while(0)
180
181/* For certain DMA chips, we need to disable ints upon irq entry
182 * and turn them back on when we are done. So in any ESP interrupt
183 * handler you *must* call DMA_IRQ_ENTRY upon entry and DMA_IRQ_EXIT
184 * when leaving the handler. You have been warned...
185 */
186#define DMA_IRQ_ENTRY(dma, dregs) do { \
187 if(DMA_ISBROKEN(dma)) DMA_INTSOFF(dregs); \
188 } while (0)
189
190#define DMA_IRQ_EXIT(dma, dregs) do { \
191 if(DMA_ISBROKEN(dma)) DMA_INTSON(dregs); \
192 } while(0)
193
194#define for_each_dvma(dma) \
195 for((dma) = dma_chain; (dma); (dma) = (dma)->next)
196
197/* From PCI */
198
199#ifdef CONFIG_PCI
200extern int isa_dma_bridge_buggy;
201#else
202#define isa_dma_bridge_buggy (0)
203#endif
204
205#endif /* !(_ASM_SPARC64_DMA_H) */
diff --git a/arch/sparc/include/asm/ebus.h b/arch/sparc/include/asm/ebus.h
deleted file mode 100644
index 83a6d16c22e6..000000000000
--- a/arch/sparc/include/asm/ebus.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef ___ASM_SPARC_EBUS_H
2#define ___ASM_SPARC_EBUS_H
3#if defined(__sparc__) && defined(__arch64__)
4#include <asm/ebus_64.h>
5#else
6#include <asm/ebus_32.h>
7#endif
8#endif
diff --git a/arch/sparc/include/asm/ebus_32.h b/arch/sparc/include/asm/ebus_32.h
deleted file mode 100644
index f91f0b267ce1..000000000000
--- a/arch/sparc/include/asm/ebus_32.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * ebus.h: PCI to Ebus pseudo driver software state.
3 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 *
6 * Adopted for sparc by V. Roganov and G. Raiko.
7 */
8
9#ifndef __SPARC_EBUS_H
10#define __SPARC_EBUS_H
11
12#ifndef _LINUX_IOPORT_H
13#include <linux/ioport.h>
14#endif
15#include <linux/of_device.h>
16#include <asm/oplib.h>
17#include <asm/prom.h>
18
19struct linux_ebus_child {
20 struct linux_ebus_child *next;
21 struct linux_ebus_device *parent;
22 struct linux_ebus *bus;
23 struct device_node *prom_node;
24 struct resource resource[PROMREG_MAX];
25 int num_addrs;
26 unsigned int irqs[PROMINTR_MAX];
27 int num_irqs;
28};
29
30struct linux_ebus_device {
31 struct of_device ofdev;
32 struct linux_ebus_device *next;
33 struct linux_ebus_child *children;
34 struct linux_ebus *bus;
35 struct device_node *prom_node;
36 struct resource resource[PROMREG_MAX];
37 int num_addrs;
38 unsigned int irqs[PROMINTR_MAX];
39 int num_irqs;
40};
41#define to_ebus_device(d) container_of(d, struct linux_ebus_device, ofdev.dev)
42
43struct linux_ebus {
44 struct of_device ofdev;
45 struct linux_ebus *next;
46 struct linux_ebus_device *devices;
47 struct linux_pbm_info *parent;
48 struct pci_dev *self;
49 struct device_node *prom_node;
50};
51#define to_ebus(d) container_of(d, struct linux_ebus, ofdev.dev)
52
53struct linux_ebus_dma {
54 unsigned int dcsr;
55 unsigned int dacr;
56 unsigned int dbcr;
57};
58
59#define EBUS_DCSR_INT_PEND 0x00000001
60#define EBUS_DCSR_ERR_PEND 0x00000002
61#define EBUS_DCSR_DRAIN 0x00000004
62#define EBUS_DCSR_INT_EN 0x00000010
63#define EBUS_DCSR_RESET 0x00000080
64#define EBUS_DCSR_WRITE 0x00000100
65#define EBUS_DCSR_EN_DMA 0x00000200
66#define EBUS_DCSR_CYC_PEND 0x00000400
67#define EBUS_DCSR_DIAG_RD_DONE 0x00000800
68#define EBUS_DCSR_DIAG_WR_DONE 0x00001000
69#define EBUS_DCSR_EN_CNT 0x00002000
70#define EBUS_DCSR_TC 0x00004000
71#define EBUS_DCSR_DIS_CSR_DRN 0x00010000
72#define EBUS_DCSR_BURST_SZ_MASK 0x000c0000
73#define EBUS_DCSR_BURST_SZ_1 0x00080000
74#define EBUS_DCSR_BURST_SZ_4 0x00000000
75#define EBUS_DCSR_BURST_SZ_8 0x00040000
76#define EBUS_DCSR_BURST_SZ_16 0x000c0000
77#define EBUS_DCSR_DIAG_EN 0x00100000
78#define EBUS_DCSR_DIS_ERR_PEND 0x00400000
79#define EBUS_DCSR_TCI_DIS 0x00800000
80#define EBUS_DCSR_EN_NEXT 0x01000000
81#define EBUS_DCSR_DMA_ON 0x02000000
82#define EBUS_DCSR_A_LOADED 0x04000000
83#define EBUS_DCSR_NA_LOADED 0x08000000
84#define EBUS_DCSR_DEV_ID_MASK 0xf0000000
85
86extern struct linux_ebus *ebus_chain;
87
88extern void ebus_init(void);
89
90#define for_each_ebus(bus) \
91 for((bus) = ebus_chain; (bus); (bus) = (bus)->next)
92
93#define for_each_ebusdev(dev, bus) \
94 for((dev) = (bus)->devices; (dev); (dev) = (dev)->next)
95
96#define for_each_edevchild(dev, child) \
97 for((child) = (dev)->children; (child); (child) = (child)->next)
98
99#endif /* !(__SPARC_EBUS_H) */
diff --git a/arch/sparc/include/asm/ebus_64.h b/arch/sparc/include/asm/ebus_64.h
deleted file mode 100644
index 14c6a111f60c..000000000000
--- a/arch/sparc/include/asm/ebus_64.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * ebus.h: PCI to Ebus pseudo driver software state.
3 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
6 */
7
8#ifndef __SPARC64_EBUS_H
9#define __SPARC64_EBUS_H
10
11#include <linux/of_device.h>
12
13#include <asm/oplib.h>
14#include <asm/prom.h>
15
16struct linux_ebus_child {
17 struct linux_ebus_child *next;
18 struct linux_ebus_device *parent;
19 struct linux_ebus *bus;
20 struct device_node *prom_node;
21 struct resource resource[PROMREG_MAX];
22 int num_addrs;
23 unsigned int irqs[PROMINTR_MAX];
24 int num_irqs;
25};
26
27struct linux_ebus_device {
28 struct of_device ofdev;
29 struct linux_ebus_device *next;
30 struct linux_ebus_child *children;
31 struct linux_ebus *bus;
32 struct device_node *prom_node;
33 struct resource resource[PROMREG_MAX];
34 int num_addrs;
35 unsigned int irqs[PROMINTR_MAX];
36 int num_irqs;
37};
38#define to_ebus_device(d) container_of(d, struct linux_ebus_device, ofdev.dev)
39
40struct linux_ebus {
41 struct of_device ofdev;
42 struct linux_ebus *next;
43 struct linux_ebus_device *devices;
44 struct pci_dev *self;
45 int index;
46 int is_rio;
47 struct device_node *prom_node;
48};
49#define to_ebus(d) container_of(d, struct linux_ebus, ofdev.dev)
50
51struct ebus_dma_info {
52 spinlock_t lock;
53 void __iomem *regs;
54
55 unsigned int flags;
56#define EBUS_DMA_FLAG_USE_EBDMA_HANDLER 0x00000001
57#define EBUS_DMA_FLAG_TCI_DISABLE 0x00000002
58
59 /* These are only valid is EBUS_DMA_FLAG_USE_EBDMA_HANDLER is
60 * set.
61 */
62 void (*callback)(struct ebus_dma_info *p, int event, void *cookie);
63 void *client_cookie;
64 unsigned int irq;
65#define EBUS_DMA_EVENT_ERROR 1
66#define EBUS_DMA_EVENT_DMA 2
67#define EBUS_DMA_EVENT_DEVICE 4
68
69 unsigned char name[64];
70};
71
72extern int ebus_dma_register(struct ebus_dma_info *p);
73extern int ebus_dma_irq_enable(struct ebus_dma_info *p, int on);
74extern void ebus_dma_unregister(struct ebus_dma_info *p);
75extern int ebus_dma_request(struct ebus_dma_info *p, dma_addr_t bus_addr,
76 size_t len);
77extern void ebus_dma_prepare(struct ebus_dma_info *p, int write);
78extern unsigned int ebus_dma_residue(struct ebus_dma_info *p);
79extern unsigned int ebus_dma_addr(struct ebus_dma_info *p);
80extern void ebus_dma_enable(struct ebus_dma_info *p, int on);
81
82extern struct linux_ebus *ebus_chain;
83
84extern void ebus_init(void);
85
86#define for_each_ebus(bus) \
87 for((bus) = ebus_chain; (bus); (bus) = (bus)->next)
88
89#define for_each_ebusdev(dev, bus) \
90 for((dev) = (bus)->devices; (dev); (dev) = (dev)->next)
91
92#define for_each_edevchild(dev, child) \
93 for((child) = (dev)->children; (child); (child) = (child)->next)
94
95#endif /* !(__SPARC64_EBUS_H) */
diff --git a/arch/sparc/include/asm/ebus_dma.h b/arch/sparc/include/asm/ebus_dma.h
new file mode 100644
index 000000000000..f07a5b541c98
--- /dev/null
+++ b/arch/sparc/include/asm/ebus_dma.h
@@ -0,0 +1,35 @@
1#ifndef __ASM_SPARC_EBUS_DMA_H
2#define __ASM_SPARC_EBUS_DMA_H
3
4struct ebus_dma_info {
5 spinlock_t lock;
6 void __iomem *regs;
7
8 unsigned int flags;
9#define EBUS_DMA_FLAG_USE_EBDMA_HANDLER 0x00000001
10#define EBUS_DMA_FLAG_TCI_DISABLE 0x00000002
11
12 /* These are only valid is EBUS_DMA_FLAG_USE_EBDMA_HANDLER is
13 * set.
14 */
15 void (*callback)(struct ebus_dma_info *p, int event, void *cookie);
16 void *client_cookie;
17 unsigned int irq;
18#define EBUS_DMA_EVENT_ERROR 1
19#define EBUS_DMA_EVENT_DMA 2
20#define EBUS_DMA_EVENT_DEVICE 4
21
22 unsigned char name[64];
23};
24
25extern int ebus_dma_register(struct ebus_dma_info *p);
26extern int ebus_dma_irq_enable(struct ebus_dma_info *p, int on);
27extern void ebus_dma_unregister(struct ebus_dma_info *p);
28extern int ebus_dma_request(struct ebus_dma_info *p, dma_addr_t bus_addr,
29 size_t len);
30extern void ebus_dma_prepare(struct ebus_dma_info *p, int write);
31extern unsigned int ebus_dma_residue(struct ebus_dma_info *p);
32extern unsigned int ebus_dma_addr(struct ebus_dma_info *p);
33extern void ebus_dma_enable(struct ebus_dma_info *p, int on);
34
35#endif /* __ASM_SPARC_EBUS_DMA_H */
diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
index d043f80bc2fd..b7ab60547827 100644
--- a/arch/sparc/include/asm/elf_32.h
+++ b/arch/sparc/include/asm/elf_32.h
@@ -105,11 +105,8 @@ typedef struct {
105#define ELF_DATA ELFDATA2MSB 105#define ELF_DATA ELFDATA2MSB
106 106
107#define USE_ELF_CORE_DUMP 107#define USE_ELF_CORE_DUMP
108#ifndef CONFIG_SUN4 108
109#define ELF_EXEC_PAGESIZE 4096 109#define ELF_EXEC_PAGESIZE 4096
110#else
111#define ELF_EXEC_PAGESIZE 8192
112#endif
113 110
114 111
115/* This is the location that an ET_DYN program is loaded if exec'ed. Typical 112/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
@@ -126,7 +123,7 @@ typedef struct {
126/* Sun4c has none of the capabilities, most sun4m's have them all. 123/* Sun4c has none of the capabilities, most sun4m's have them all.
127 * XXX This is gross, set some global variable at boot time. -DaveM 124 * XXX This is gross, set some global variable at boot time. -DaveM
128 */ 125 */
129#define ELF_HWCAP ((ARCH_SUN4C_SUN4) ? 0 : \ 126#define ELF_HWCAP ((ARCH_SUN4C) ? 0 : \
130 (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \ 127 (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \
131 HWCAP_SPARC_SWAP | \ 128 HWCAP_SPARC_SWAP | \
132 ((srmmu_modtype != Cypress && \ 129 ((srmmu_modtype != Cypress && \
diff --git a/arch/sparc/include/asm/fhc.h b/arch/sparc/include/asm/fhc.h
index 788cbc46a116..57f1b303ad54 100644
--- a/arch/sparc/include/asm/fhc.h
+++ b/arch/sparc/include/asm/fhc.h
@@ -1,5 +1,4 @@
1/* 1/* fhc.h: FHC and Clock board register definitions.
2 * fhc.h: Structures for central/fhc pseudo driver on Sunfire/Starfire/Wildfire.
3 * 2 *
4 * Copyright (C) 1997, 1999 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1997, 1999 David S. Miller (davem@redhat.com)
5 */ 4 */
@@ -7,14 +6,6 @@
7#ifndef _SPARC64_FHC_H 6#ifndef _SPARC64_FHC_H
8#define _SPARC64_FHC_H 7#define _SPARC64_FHC_H
9 8
10#include <linux/timer.h>
11
12#include <asm/oplib.h>
13#include <asm/prom.h>
14#include <asm/upa.h>
15
16struct linux_fhc;
17
18/* Clock board register offsets. */ 9/* Clock board register offsets. */
19#define CLOCK_CTRL 0x00UL /* Main control */ 10#define CLOCK_CTRL 0x00UL /* Main control */
20#define CLOCK_STAT1 0x10UL /* Status one */ 11#define CLOCK_STAT1 0x10UL /* Status one */
@@ -29,21 +20,7 @@ struct linux_fhc;
29#define CLOCK_CTRL_MLED 0x02 /* Mid LED, 1 == on */ 20#define CLOCK_CTRL_MLED 0x02 /* Mid LED, 1 == on */
30#define CLOCK_CTRL_RLED 0x01 /* RIght LED, 1 == on */ 21#define CLOCK_CTRL_RLED 0x01 /* RIght LED, 1 == on */
31 22
32struct linux_central {
33 struct linux_fhc *child;
34 unsigned long cfreg;
35 unsigned long clkregs;
36 unsigned long clkver;
37 int slots;
38 struct device_node *prom_node;
39
40 struct linux_prom_ranges central_ranges[PROMREG_MAX];
41 int num_central_ranges;
42};
43
44/* Firehose controller register offsets */ 23/* Firehose controller register offsets */
45struct fhc_regs {
46 unsigned long pregs; /* FHC internal regs */
47#define FHC_PREGS_ID 0x00UL /* FHC ID */ 24#define FHC_PREGS_ID 0x00UL /* FHC ID */
48#define FHC_ID_VERS 0xf0000000 /* Version of this FHC */ 25#define FHC_ID_VERS 0xf0000000 /* Version of this FHC */
49#define FHC_ID_PARTID 0x0ffff000 /* Part ID code (0x0f9f == FHC) */ 26#define FHC_ID_PARTID 0x0ffff000 /* Part ID code (0x0f9f == FHC) */
@@ -90,32 +67,14 @@ struct fhc_regs {
90#define FHC_JTAG_CTRL_MENAB 0x80000000 /* Indicates this is JTAG Master */ 67#define FHC_JTAG_CTRL_MENAB 0x80000000 /* Indicates this is JTAG Master */
91#define FHC_JTAG_CTRL_MNONE 0x40000000 /* Indicates no JTAG Master present */ 68#define FHC_JTAG_CTRL_MNONE 0x40000000 /* Indicates no JTAG Master present */
92#define FHC_PREGS_JCMD 0x100UL /* FHC JTAG Command Register */ 69#define FHC_PREGS_JCMD 0x100UL /* FHC JTAG Command Register */
93 unsigned long ireg; /* FHC IGN reg */
94#define FHC_IREG_IGN 0x00UL /* This FHC's IGN */ 70#define FHC_IREG_IGN 0x00UL /* This FHC's IGN */
95 unsigned long ffregs; /* FHC fanfail regs */
96#define FHC_FFREGS_IMAP 0x00UL /* FHC Fanfail IMAP */ 71#define FHC_FFREGS_IMAP 0x00UL /* FHC Fanfail IMAP */
97#define FHC_FFREGS_ICLR 0x10UL /* FHC Fanfail ICLR */ 72#define FHC_FFREGS_ICLR 0x10UL /* FHC Fanfail ICLR */
98 unsigned long sregs; /* FHC system regs */
99#define FHC_SREGS_IMAP 0x00UL /* FHC System IMAP */ 73#define FHC_SREGS_IMAP 0x00UL /* FHC System IMAP */
100#define FHC_SREGS_ICLR 0x10UL /* FHC System ICLR */ 74#define FHC_SREGS_ICLR 0x10UL /* FHC System ICLR */
101 unsigned long uregs; /* FHC uart regs */
102#define FHC_UREGS_IMAP 0x00UL /* FHC Uart IMAP */ 75#define FHC_UREGS_IMAP 0x00UL /* FHC Uart IMAP */
103#define FHC_UREGS_ICLR 0x10UL /* FHC Uart ICLR */ 76#define FHC_UREGS_ICLR 0x10UL /* FHC Uart ICLR */
104 unsigned long tregs; /* FHC TOD regs */
105#define FHC_TREGS_IMAP 0x00UL /* FHC TOD IMAP */ 77#define FHC_TREGS_IMAP 0x00UL /* FHC TOD IMAP */
106#define FHC_TREGS_ICLR 0x10UL /* FHC TOD ICLR */ 78#define FHC_TREGS_ICLR 0x10UL /* FHC TOD ICLR */
107};
108
109struct linux_fhc {
110 struct linux_fhc *next;
111 struct linux_central *parent; /* NULL if not central FHC */
112 struct fhc_regs fhc_regs;
113 int board;
114 int jtag_master;
115 struct device_node *prom_node;
116
117 struct linux_prom_ranges fhc_ranges[PROMREG_MAX];
118 int num_fhc_ranges;
119};
120 79
121#endif /* !(_SPARC64_FHC_H) */ 80#endif /* !(_SPARC64_FHC_H) */
diff --git a/arch/sparc/include/asm/floppy_32.h b/arch/sparc/include/asm/floppy_32.h
index ae3f00bf22ff..c792830636de 100644
--- a/arch/sparc/include/asm/floppy_32.h
+++ b/arch/sparc/include/asm/floppy_32.h
@@ -6,6 +6,9 @@
6#ifndef __ASM_SPARC_FLOPPY_H 6#ifndef __ASM_SPARC_FLOPPY_H
7#define __ASM_SPARC_FLOPPY_H 7#define __ASM_SPARC_FLOPPY_H
8 8
9#include <linux/of.h>
10#include <linux/of_device.h>
11
9#include <asm/page.h> 12#include <asm/page.h>
10#include <asm/pgtable.h> 13#include <asm/pgtable.h>
11#include <asm/system.h> 14#include <asm/system.h>
@@ -343,7 +346,7 @@ static int sun_floppy_init(void)
343 r.flags = fd_regs[0].which_io; 346 r.flags = fd_regs[0].which_io;
344 r.start = fd_regs[0].phys_addr; 347 r.start = fd_regs[0].phys_addr;
345 sun_fdc = (struct sun_flpy_controller *) 348 sun_fdc = (struct sun_flpy_controller *)
346 sbus_ioremap(&r, 0, fd_regs[0].reg_size, "floppy"); 349 of_ioremap(&r, 0, fd_regs[0].reg_size, "floppy");
347 350
348 /* Last minute sanity check... */ 351 /* Last minute sanity check... */
349 if(sun_fdc->status_82072 == 0xff) { 352 if(sun_fdc->status_82072 == 0xff) {
@@ -385,4 +388,15 @@ static int sparc_eject(void)
385 388
386#define EXTRA_FLOPPY_PARAMS 389#define EXTRA_FLOPPY_PARAMS
387 390
391static DEFINE_SPINLOCK(dma_spin_lock);
392
393#define claim_dma_lock() \
394({ unsigned long flags; \
395 spin_lock_irqsave(&dma_spin_lock, flags); \
396 flags; \
397})
398
399#define release_dma_lock(__flags) \
400 spin_unlock_irqrestore(&dma_spin_lock, __flags);
401
388#endif /* !(__ASM_SPARC_FLOPPY_H) */ 402#endif /* !(__ASM_SPARC_FLOPPY_H) */
diff --git a/arch/sparc/include/asm/floppy_64.h b/arch/sparc/include/asm/floppy_64.h
index c39db1060bc7..36439d67ad71 100644
--- a/arch/sparc/include/asm/floppy_64.h
+++ b/arch/sparc/include/asm/floppy_64.h
@@ -1,6 +1,6 @@
1/* floppy.h: Sparc specific parts of the Floppy driver. 1/* floppy.h: Sparc specific parts of the Floppy driver.
2 * 2 *
3 * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 1996, 2007, 2008 David S. Miller (davem@davemloft.net)
4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 * 5 *
6 * Ultra/PCI support added: Sep 1997 Eddie C. Dost (ecd@skynet.be) 6 * Ultra/PCI support added: Sep 1997 Eddie C. Dost (ecd@skynet.be)
@@ -9,18 +9,11 @@
9#ifndef __ASM_SPARC64_FLOPPY_H 9#ifndef __ASM_SPARC64_FLOPPY_H
10#define __ASM_SPARC64_FLOPPY_H 10#define __ASM_SPARC64_FLOPPY_H
11 11
12#include <linux/init.h> 12#include <linux/of.h>
13#include <linux/pci.h> 13#include <linux/of_device.h>
14#include <linux/dma-mapping.h>
14 15
15#include <asm/page.h>
16#include <asm/pgtable.h>
17#include <asm/system.h>
18#include <asm/idprom.h>
19#include <asm/oplib.h>
20#include <asm/auxio.h> 16#include <asm/auxio.h>
21#include <asm/sbus.h>
22#include <asm/irq.h>
23
24 17
25/* 18/*
26 * Define this to enable exchanging drive 0 and 1 if only drive 1 is 19 * Define this to enable exchanging drive 0 and 1 if only drive 1 is
@@ -50,7 +43,7 @@ struct sun_flpy_controller {
50/* You'll only ever find one controller on an Ultra anyways. */ 43/* You'll only ever find one controller on an Ultra anyways. */
51static struct sun_flpy_controller *sun_fdc = (struct sun_flpy_controller *)-1; 44static struct sun_flpy_controller *sun_fdc = (struct sun_flpy_controller *)-1;
52unsigned long fdc_status; 45unsigned long fdc_status;
53static struct sbus_dev *floppy_sdev = NULL; 46static struct of_device *floppy_op = NULL;
54 47
55struct sun_floppy_ops { 48struct sun_floppy_ops {
56 unsigned char (*fd_inb) (unsigned long port); 49 unsigned char (*fd_inb) (unsigned long port);
@@ -291,12 +284,11 @@ static int sun_fd_eject(int drive)
291 return 0; 284 return 0;
292} 285}
293 286
294#ifdef CONFIG_PCI 287#include <asm/ebus_dma.h>
295#include <asm/ebus.h>
296#include <asm/ns87303.h> 288#include <asm/ns87303.h>
297 289
298static struct ebus_dma_info sun_pci_fd_ebus_dma; 290static struct ebus_dma_info sun_pci_fd_ebus_dma;
299static struct pci_dev *sun_pci_ebus_dev; 291static struct device *sun_floppy_dev;
300static int sun_pci_broken_drive = -1; 292static int sun_pci_broken_drive = -1;
301 293
302struct sun_pci_dma_op { 294struct sun_pci_dma_op {
@@ -377,7 +369,7 @@ static void sun_pci_fd_enable_dma(void)
377 sun_pci_dma_pending.addr = -1U; 369 sun_pci_dma_pending.addr = -1U;
378 370
379 sun_pci_dma_current.addr = 371 sun_pci_dma_current.addr =
380 pci_map_single(sun_pci_ebus_dev, 372 dma_map_single(sun_floppy_dev,
381 sun_pci_dma_current.buf, 373 sun_pci_dma_current.buf,
382 sun_pci_dma_current.len, 374 sun_pci_dma_current.len,
383 sun_pci_dma_current.direction); 375 sun_pci_dma_current.direction);
@@ -394,7 +386,7 @@ static void sun_pci_fd_disable_dma(void)
394{ 386{
395 ebus_dma_enable(&sun_pci_fd_ebus_dma, 0); 387 ebus_dma_enable(&sun_pci_fd_ebus_dma, 0);
396 if (sun_pci_dma_current.addr != -1U) 388 if (sun_pci_dma_current.addr != -1U)
397 pci_unmap_single(sun_pci_ebus_dev, 389 dma_unmap_single(sun_floppy_dev,
398 sun_pci_dma_current.addr, 390 sun_pci_dma_current.addr,
399 sun_pci_dma_current.len, 391 sun_pci_dma_current.len,
400 sun_pci_dma_current.direction); 392 sun_pci_dma_current.direction);
@@ -404,9 +396,9 @@ static void sun_pci_fd_disable_dma(void)
404static void sun_pci_fd_set_dma_mode(int mode) 396static void sun_pci_fd_set_dma_mode(int mode)
405{ 397{
406 if (mode == DMA_MODE_WRITE) 398 if (mode == DMA_MODE_WRITE)
407 sun_pci_dma_pending.direction = PCI_DMA_TODEVICE; 399 sun_pci_dma_pending.direction = DMA_TO_DEVICE;
408 else 400 else
409 sun_pci_dma_pending.direction = PCI_DMA_FROMDEVICE; 401 sun_pci_dma_pending.direction = DMA_FROM_DEVICE;
410 402
411 ebus_dma_prepare(&sun_pci_fd_ebus_dma, mode != DMA_MODE_WRITE); 403 ebus_dma_prepare(&sun_pci_fd_ebus_dma, mode != DMA_MODE_WRITE);
412} 404}
@@ -538,80 +530,84 @@ static int sun_pci_fd_test_drive(unsigned long port, int drive)
538#undef MSR 530#undef MSR
539#undef DOR 531#undef DOR
540 532
541#endif /* CONFIG_PCI */ 533static int __init ebus_fdthree_p(struct device_node *dp)
542
543#ifdef CONFIG_PCI
544static int __init ebus_fdthree_p(struct linux_ebus_device *edev)
545{ 534{
546 if (!strcmp(edev->prom_node->name, "fdthree")) 535 if (!strcmp(dp->name, "fdthree"))
547 return 1; 536 return 1;
548 if (!strcmp(edev->prom_node->name, "floppy")) { 537 if (!strcmp(dp->name, "floppy")) {
549 const char *compat; 538 const char *compat;
550 539
551 compat = of_get_property(edev->prom_node, 540 compat = of_get_property(dp, "compatible", NULL);
552 "compatible", NULL);
553 if (compat && !strcmp(compat, "fdthree")) 541 if (compat && !strcmp(compat, "fdthree"))
554 return 1; 542 return 1;
555 } 543 }
556 return 0; 544 return 0;
557} 545}
558#endif
559 546
560static unsigned long __init sun_floppy_init(void) 547static unsigned long __init sun_floppy_init(void)
561{ 548{
562 char state[128];
563 struct sbus_bus *bus;
564 struct sbus_dev *sdev = NULL;
565 static int initialized = 0; 549 static int initialized = 0;
550 struct device_node *dp;
551 struct of_device *op;
552 const char *prop;
553 char state[128];
566 554
567 if (initialized) 555 if (initialized)
568 return sun_floppy_types[0]; 556 return sun_floppy_types[0];
569 initialized = 1; 557 initialized = 1;
570 558
571 for_all_sbusdev (sdev, bus) { 559 op = NULL;
572 if (!strcmp(sdev->prom_name, "SUNW,fdtwo")) 560
561 for_each_node_by_name(dp, "SUNW,fdtwo") {
562 if (strcmp(dp->parent->name, "sbus"))
563 continue;
564 op = of_find_device_by_node(dp);
565 if (op)
573 break; 566 break;
574 } 567 }
575 if(sdev) { 568 if (op) {
576 floppy_sdev = sdev; 569 floppy_op = op;
577 FLOPPY_IRQ = sdev->irqs[0]; 570 FLOPPY_IRQ = op->irqs[0];
578 } else { 571 } else {
579#ifdef CONFIG_PCI 572 struct device_node *ebus_dp;
580 struct linux_ebus *ebus;
581 struct linux_ebus_device *edev = NULL;
582 unsigned long config = 0;
583 void __iomem *auxio_reg; 573 void __iomem *auxio_reg;
584 const char *state_prop; 574 const char *state_prop;
575 unsigned long config;
585 576
586 for_each_ebus(ebus) { 577 dp = NULL;
587 for_each_ebusdev(edev, ebus) { 578 for_each_node_by_name(ebus_dp, "ebus") {
588 if (ebus_fdthree_p(edev)) 579 for (dp = ebus_dp->child; dp; dp = dp->sibling) {
589 goto ebus_done; 580 if (ebus_fdthree_p(dp))
581 goto found_fdthree;
590 } 582 }
591 } 583 }
592 ebus_done: 584 found_fdthree:
593 if (!edev) 585 if (!dp)
586 return 0;
587
588 op = of_find_device_by_node(dp);
589 if (!op)
594 return 0; 590 return 0;
595 591
596 state_prop = of_get_property(edev->prom_node, "status", NULL); 592 state_prop = of_get_property(op->node, "status", NULL);
597 if (state_prop && !strncmp(state_prop, "disabled", 8)) 593 if (state_prop && !strncmp(state_prop, "disabled", 8))
598 return 0; 594 return 0;
599 595
600 FLOPPY_IRQ = edev->irqs[0]; 596 FLOPPY_IRQ = op->irqs[0];
601 597
602 /* Make sure the high density bit is set, some systems 598 /* Make sure the high density bit is set, some systems
603 * (most notably Ultra5/Ultra10) come up with it clear. 599 * (most notably Ultra5/Ultra10) come up with it clear.
604 */ 600 */
605 auxio_reg = (void __iomem *) edev->resource[2].start; 601 auxio_reg = (void __iomem *) op->resource[2].start;
606 writel(readl(auxio_reg)|0x2, auxio_reg); 602 writel(readl(auxio_reg)|0x2, auxio_reg);
607 603
608 sun_pci_ebus_dev = ebus->self; 604 sun_floppy_dev = &op->dev;
609 605
610 spin_lock_init(&sun_pci_fd_ebus_dma.lock); 606 spin_lock_init(&sun_pci_fd_ebus_dma.lock);
611 607
612 /* XXX ioremap */ 608 /* XXX ioremap */
613 sun_pci_fd_ebus_dma.regs = (void __iomem *) 609 sun_pci_fd_ebus_dma.regs = (void __iomem *)
614 edev->resource[1].start; 610 op->resource[1].start;
615 if (!sun_pci_fd_ebus_dma.regs) 611 if (!sun_pci_fd_ebus_dma.regs)
616 return 0; 612 return 0;
617 613
@@ -625,7 +621,7 @@ static unsigned long __init sun_floppy_init(void)
625 return 0; 621 return 0;
626 622
627 /* XXX ioremap */ 623 /* XXX ioremap */
628 sun_fdc = (struct sun_flpy_controller *)edev->resource[0].start; 624 sun_fdc = (struct sun_flpy_controller *) op->resource[0].start;
629 625
630 sun_fdops.fd_inb = sun_pci_fd_inb; 626 sun_fdops.fd_inb = sun_pci_fd_inb;
631 sun_fdops.fd_outb = sun_pci_fd_outb; 627 sun_fdops.fd_outb = sun_pci_fd_outb;
@@ -662,12 +658,15 @@ static unsigned long __init sun_floppy_init(void)
662 /* 658 /*
663 * Find NS87303 SuperIO config registers (through ecpp). 659 * Find NS87303 SuperIO config registers (through ecpp).
664 */ 660 */
665 for_each_ebus(ebus) { 661 config = 0;
666 for_each_ebusdev(edev, ebus) { 662 for (dp = ebus_dp->child; dp; dp = dp->sibling) {
667 if (!strcmp(edev->prom_node->name, "ecpp")) { 663 if (!strcmp(dp->name, "ecpp")) {
668 config = edev->resource[1].start; 664 struct of_device *ecpp_op;
669 goto config_done; 665
670 } 666 ecpp_op = of_find_device_by_node(dp);
667 if (ecpp_op)
668 config = ecpp_op->resource[1].start;
669 goto config_done;
671 } 670 }
672 } 671 }
673 config_done: 672 config_done:
@@ -716,26 +715,23 @@ static unsigned long __init sun_floppy_init(void)
716#endif /* PCI_FDC_SWAP_DRIVES */ 715#endif /* PCI_FDC_SWAP_DRIVES */
717 716
718 return sun_floppy_types[0]; 717 return sun_floppy_types[0];
719#else
720 return 0;
721#endif
722 } 718 }
723 prom_getproperty(sdev->prom_node, "status", state, sizeof(state)); 719 prop = of_get_property(op->node, "status", NULL);
724 if(!strncmp(state, "disabled", 8)) 720 if (prop && !strncmp(state, "disabled", 8))
725 return 0; 721 return 0;
726 722
727 /* 723 /*
728 * We cannot do sbus_ioremap here: it does request_region, 724 * We cannot do of_ioremap here: it does request_region,
729 * which the generic floppy driver tries to do once again. 725 * which the generic floppy driver tries to do once again.
730 * But we must use the sdev resource values as they have 726 * But we must use the sdev resource values as they have
731 * had parent ranges applied. 727 * had parent ranges applied.
732 */ 728 */
733 sun_fdc = (struct sun_flpy_controller *) 729 sun_fdc = (struct sun_flpy_controller *)
734 (sdev->resource[0].start + 730 (op->resource[0].start +
735 ((sdev->resource[0].flags & 0x1ffUL) << 32UL)); 731 ((op->resource[0].flags & 0x1ffUL) << 32UL));
736 732
737 /* Last minute sanity check... */ 733 /* Last minute sanity check... */
738 if(sbus_readb(&sun_fdc->status1_82077) == 0xff) { 734 if (sbus_readb(&sun_fdc->status1_82077) == 0xff) {
739 sun_fdc = (struct sun_flpy_controller *)-1; 735 sun_fdc = (struct sun_flpy_controller *)-1;
740 return 0; 736 return 0;
741 } 737 }
diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h
new file mode 100644
index 000000000000..a0e3ac0af599
--- /dev/null
+++ b/arch/sparc/include/asm/gpio.h
@@ -0,0 +1,36 @@
1#ifndef __ASM_SPARC_GPIO_H
2#define __ASM_SPARC_GPIO_H
3
4#include <linux/errno.h>
5#include <asm-generic/gpio.h>
6
7#ifdef CONFIG_GPIOLIB
8
9static inline int gpio_get_value(unsigned int gpio)
10{
11 return __gpio_get_value(gpio);
12}
13
14static inline void gpio_set_value(unsigned int gpio, int value)
15{
16 __gpio_set_value(gpio, value);
17}
18
19static inline int gpio_cansleep(unsigned int gpio)
20{
21 return __gpio_cansleep(gpio);
22}
23
24static inline int gpio_to_irq(unsigned int gpio)
25{
26 return -ENOSYS;
27}
28
29static inline int irq_to_gpio(unsigned int irq)
30{
31 return -EINVAL;
32}
33
34#endif /* CONFIG_GPIOLIB */
35
36#endif /* __ASM_SPARC_GPIO_H */
diff --git a/arch/sparc/include/asm/io-unit.h b/arch/sparc/include/asm/io-unit.h
index 96823b47fd45..01ab2f613e91 100644
--- a/arch/sparc/include/asm/io-unit.h
+++ b/arch/sparc/include/asm/io-unit.h
@@ -55,8 +55,4 @@ struct iounit_struct {
55#define IOUNIT_BMAPM_START IOUNIT_BMAP2_END 55#define IOUNIT_BMAPM_START IOUNIT_BMAP2_END
56#define IOUNIT_BMAPM_END ((IOUNIT_DMA_SIZE - IOUNIT_DVMA_SIZE) >> PAGE_SHIFT) 56#define IOUNIT_BMAPM_END ((IOUNIT_DMA_SIZE - IOUNIT_DVMA_SIZE) >> PAGE_SHIFT)
57 57
58extern __u32 iounit_map_dma_init(struct sbus_bus *, int);
59#define iounit_map_dma_finish(sbus, addr, len) mmu_release_scsi_one(addr, len, sbus)
60extern __u32 iounit_map_dma_page(__u32, void *, struct sbus_bus *);
61
62#endif /* !(_SPARC_IO_UNIT_H) */ 58#endif /* !(_SPARC_IO_UNIT_H) */
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 10d7da450070..93fe21e02c86 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -293,14 +293,6 @@ extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
293extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 293extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
294 294
295/* 295/*
296 * Bus number may be in res->flags... somewhere.
297 */
298extern void __iomem *sbus_ioremap(struct resource *res, unsigned long offset,
299 unsigned long size, char *name);
300extern void sbus_iounmap(volatile void __iomem *vaddr, unsigned long size);
301
302
303/*
304 * At the moment, we do not use CMOS_READ anywhere outside of rtc.c, 296 * At the moment, we do not use CMOS_READ anywhere outside of rtc.c,
305 * so rtc_port is static in it. This should not change unless a new 297 * so rtc_port is static in it. This should not change unless a new
306 * hardware pops up. 298 * hardware pops up.
@@ -308,6 +300,17 @@ extern void sbus_iounmap(volatile void __iomem *vaddr, unsigned long size);
308#define RTC_PORT(x) (rtc_port + (x)) 300#define RTC_PORT(x) (rtc_port + (x))
309#define RTC_ALWAYS_BCD 0 301#define RTC_ALWAYS_BCD 0
310 302
303static inline int sbus_can_dma_64bit(void)
304{
305 return 0; /* actually, sparc_cpu_model==sun4d */
306}
307static inline int sbus_can_burst64(void)
308{
309 return 0; /* actually, sparc_cpu_model==sun4d */
310}
311struct device;
312extern void sbus_set_sbus64(struct device *, int);
313
311#endif 314#endif
312 315
313#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1 316#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h
index 0bff078ffdd0..4aee21dc9c6f 100644
--- a/arch/sparc/include/asm/io_64.h
+++ b/arch/sparc/include/asm/io_64.h
@@ -482,18 +482,16 @@ struct pci_dev;
482extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max); 482extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
483extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 483extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
484 484
485/* Similarly for SBUS. */ 485static inline int sbus_can_dma_64bit(void)
486#define sbus_ioremap(__res, __offset, __size, __name) \ 486{
487({ unsigned long __ret; \ 487 return 1;
488 __ret = (__res)->start + (((__res)->flags & 0x1ffUL) << 32UL); \ 488}
489 __ret += (unsigned long) (__offset); \ 489static inline int sbus_can_burst64(void)
490 if (! request_region((__ret), (__size), (__name))) \ 490{
491 __ret = 0UL; \ 491 return 1;
492 (void __iomem *) __ret; \ 492}
493}) 493struct device;
494 494extern void sbus_set_sbus64(struct device *, int);
495#define sbus_iounmap(__addr, __size) \
496 release_region((unsigned long)(__addr), (__size))
497 495
498/* 496/*
499 * Convert a physical pointer to a virtual kernel pointer for /dev/mem 497 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
diff --git a/arch/sparc/include/asm/iommu_64.h b/arch/sparc/include/asm/iommu_64.h
index d7b9afcba08b..caf798b56191 100644
--- a/arch/sparc/include/asm/iommu_64.h
+++ b/arch/sparc/include/asm/iommu_64.h
@@ -48,6 +48,9 @@ struct strbuf {
48 unsigned long strbuf_control; 48 unsigned long strbuf_control;
49 unsigned long strbuf_pflush; 49 unsigned long strbuf_pflush;
50 unsigned long strbuf_fsync; 50 unsigned long strbuf_fsync;
51 unsigned long strbuf_err_stat;
52 unsigned long strbuf_tag_diag;
53 unsigned long strbuf_line_diag;
51 unsigned long strbuf_ctxflush; 54 unsigned long strbuf_ctxflush;
52 unsigned long strbuf_ctxmatch_base; 55 unsigned long strbuf_ctxmatch_base;
53 unsigned long strbuf_flushflag_pa; 56 unsigned long strbuf_flushflag_pa;
diff --git a/arch/sparc/include/asm/irq_64.h b/arch/sparc/include/asm/irq_64.h
index e3dd9303643d..71673eca3660 100644
--- a/arch/sparc/include/asm/irq_64.h
+++ b/arch/sparc/include/asm/irq_64.h
@@ -56,7 +56,6 @@ extern unsigned int sun4u_build_msi(u32 portid, unsigned int *virt_irq_p,
56 unsigned long imap_base, 56 unsigned long imap_base,
57 unsigned long iclr_base); 57 unsigned long iclr_base);
58extern void sun4u_destroy_msi(unsigned int virt_irq); 58extern void sun4u_destroy_msi(unsigned int virt_irq);
59extern unsigned int sbus_build_irq(void *sbus, unsigned int ino);
60 59
61extern unsigned char virt_irq_alloc(unsigned int dev_handle, 60extern unsigned char virt_irq_alloc(unsigned int dev_handle,
62 unsigned int dev_ino); 61 unsigned int dev_ino);
diff --git a/arch/sparc/include/asm/mc146818rtc_64.h b/arch/sparc/include/asm/mc146818rtc_64.h
index e9c0fcc25c6f..7238d174e0e3 100644
--- a/arch/sparc/include/asm/mc146818rtc_64.h
+++ b/arch/sparc/include/asm/mc146818rtc_64.h
@@ -7,12 +7,8 @@
7#include <asm/io.h> 7#include <asm/io.h>
8 8
9#ifndef RTC_PORT 9#ifndef RTC_PORT
10#ifdef CONFIG_PCI 10extern unsigned long cmos_regs;
11extern unsigned long ds1287_regs; 11#define RTC_PORT(x) (cmos_regs + (x))
12#else
13#define ds1287_regs (0UL)
14#endif
15#define RTC_PORT(x) (ds1287_regs + (x))
16#define RTC_ALWAYS_BCD 0 12#define RTC_ALWAYS_BCD 0
17#endif 13#endif
18 14
@@ -29,6 +25,4 @@ outb_p((addr),RTC_PORT(0)); \
29outb_p((val),RTC_PORT(1)); \ 25outb_p((val),RTC_PORT(1)); \
30}) 26})
31 27
32#define RTC_IRQ 8
33
34#endif /* __ASM_SPARC64_MC146818RTC_H */ 28#endif /* __ASM_SPARC64_MC146818RTC_H */
diff --git a/arch/sparc/include/asm/memctrl.h b/arch/sparc/include/asm/memctrl.h
new file mode 100644
index 000000000000..4065c56af7b6
--- /dev/null
+++ b/arch/sparc/include/asm/memctrl.h
@@ -0,0 +1,9 @@
1#ifndef _SPARC_MEMCTRL_H
2#define _SPARC_MEMCTRL_H
3
4typedef int (*dimm_printer_t)(int synd_code, unsigned long paddr, char *buf, int buflen);
5
6int register_dimm_printer(dimm_printer_t func);
7void unregister_dimm_printer(dimm_printer_t func);
8
9#endif /* _SPARC_MEMCTRL_H */
diff --git a/arch/sparc/include/asm/mostek.h b/arch/sparc/include/asm/mostek.h
deleted file mode 100644
index 433be3e0a69b..000000000000
--- a/arch/sparc/include/asm/mostek.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef ___ASM_SPARC_MOSTEK_H
2#define ___ASM_SPARC_MOSTEK_H
3#if defined(__sparc__) && defined(__arch64__)
4#include <asm/mostek_64.h>
5#else
6#include <asm/mostek_32.h>
7#endif
8#endif
diff --git a/arch/sparc/include/asm/mostek_32.h b/arch/sparc/include/asm/mostek_32.h
deleted file mode 100644
index a99590c4c507..000000000000
--- a/arch/sparc/include/asm/mostek_32.h
+++ /dev/null
@@ -1,171 +0,0 @@
1/*
2 * mostek.h: Describes the various Mostek time of day clock registers.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
6 * Added intersil code 05/25/98 Chris Davis (cdavis@cois.on.ca)
7 */
8
9#ifndef _SPARC_MOSTEK_H
10#define _SPARC_MOSTEK_H
11
12#include <asm/idprom.h>
13#include <asm/io.h>
14
15/* M48T02 Register Map (adapted from Sun NVRAM/Hostid FAQ)
16 *
17 * Data
18 * Address Function
19 * Bit 7 Bit 6 Bit 5 Bit 4Bit 3 Bit 2 Bit 1 Bit 0
20 * 7ff - - - - - - - - Year 00-99
21 * 7fe 0 0 0 - - - - - Month 01-12
22 * 7fd 0 0 - - - - - - Date 01-31
23 * 7fc 0 FT 0 0 0 - - - Day 01-07
24 * 7fb KS 0 - - - - - - Hours 00-23
25 * 7fa 0 - - - - - - - Minutes 00-59
26 * 7f9 ST - - - - - - - Seconds 00-59
27 * 7f8 W R S - - - - - Control
28 *
29 * * ST is STOP BIT
30 * * W is WRITE BIT
31 * * R is READ BIT
32 * * S is SIGN BIT
33 * * FT is FREQ TEST BIT
34 * * KS is KICK START BIT
35 */
36
37/* The Mostek 48t02 real time clock and NVRAM chip. The registers
38 * other than the control register are in binary coded decimal. Some
39 * control bits also live outside the control register.
40 */
41#define mostek_read(_addr) readb(_addr)
42#define mostek_write(_addr,_val) writeb(_val, _addr)
43#define MOSTEK_EEPROM 0x0000UL
44#define MOSTEK_IDPROM 0x07d8UL
45#define MOSTEK_CREG 0x07f8UL
46#define MOSTEK_SEC 0x07f9UL
47#define MOSTEK_MIN 0x07faUL
48#define MOSTEK_HOUR 0x07fbUL
49#define MOSTEK_DOW 0x07fcUL
50#define MOSTEK_DOM 0x07fdUL
51#define MOSTEK_MONTH 0x07feUL
52#define MOSTEK_YEAR 0x07ffUL
53
54struct mostek48t02 {
55 volatile char eeprom[2008]; /* This is the eeprom, don't touch! */
56 struct idprom idprom; /* The idprom lives here. */
57 volatile unsigned char creg; /* Control register */
58 volatile unsigned char sec; /* Seconds (0-59) */
59 volatile unsigned char min; /* Minutes (0-59) */
60 volatile unsigned char hour; /* Hour (0-23) */
61 volatile unsigned char dow; /* Day of the week (1-7) */
62 volatile unsigned char dom; /* Day of the month (1-31) */
63 volatile unsigned char month; /* Month of year (1-12) */
64 volatile unsigned char year; /* Year (0-99) */
65};
66
67extern spinlock_t mostek_lock;
68extern void __iomem *mstk48t02_regs;
69
70/* Control register values. */
71#define MSTK_CREG_WRITE 0x80 /* Must set this before placing values. */
72#define MSTK_CREG_READ 0x40 /* Stop updates to allow a clean read. */
73#define MSTK_CREG_SIGN 0x20 /* Slow/speed clock in calibration mode. */
74
75/* Control bits that live in the other registers. */
76#define MSTK_STOP 0x80 /* Stop the clock oscillator. (sec) */
77#define MSTK_KICK_START 0x80 /* Kick start the clock chip. (hour) */
78#define MSTK_FREQ_TEST 0x40 /* Frequency test mode. (day) */
79
80#define MSTK_YEAR_ZERO 1968 /* If year reg has zero, it is 1968. */
81#define MSTK_CVT_YEAR(yr) ((yr) + MSTK_YEAR_ZERO)
82
83/* Masks that define how much space each value takes up. */
84#define MSTK_SEC_MASK 0x7f
85#define MSTK_MIN_MASK 0x7f
86#define MSTK_HOUR_MASK 0x3f
87#define MSTK_DOW_MASK 0x07
88#define MSTK_DOM_MASK 0x3f
89#define MSTK_MONTH_MASK 0x1f
90#define MSTK_YEAR_MASK 0xffU
91
92/* Binary coded decimal conversion macros. */
93#define MSTK_REGVAL_TO_DECIMAL(x) (((x) & 0x0F) + 0x0A * ((x) >> 0x04))
94#define MSTK_DECIMAL_TO_REGVAL(x) ((((x) / 0x0A) << 0x04) + ((x) % 0x0A))
95
96/* Generic register set and get macros for internal use. */
97#define MSTK_GET(regs,var,mask) (MSTK_REGVAL_TO_DECIMAL(((struct mostek48t02 *)regs)->var & MSTK_ ## mask ## _MASK))
98#define MSTK_SET(regs,var,value,mask) do { ((struct mostek48t02 *)regs)->var &= ~(MSTK_ ## mask ## _MASK); ((struct mostek48t02 *)regs)->var |= MSTK_DECIMAL_TO_REGVAL(value) & (MSTK_ ## mask ## _MASK); } while (0)
99
100/* Macros to make register access easier on our fingers. These give you
101 * the decimal value of the register requested if applicable. You pass
102 * the a pointer to a 'struct mostek48t02'.
103 */
104#define MSTK_REG_CREG(regs) (((struct mostek48t02 *)regs)->creg)
105#define MSTK_REG_SEC(regs) MSTK_GET(regs,sec,SEC)
106#define MSTK_REG_MIN(regs) MSTK_GET(regs,min,MIN)
107#define MSTK_REG_HOUR(regs) MSTK_GET(regs,hour,HOUR)
108#define MSTK_REG_DOW(regs) MSTK_GET(regs,dow,DOW)
109#define MSTK_REG_DOM(regs) MSTK_GET(regs,dom,DOM)
110#define MSTK_REG_MONTH(regs) MSTK_GET(regs,month,MONTH)
111#define MSTK_REG_YEAR(regs) MSTK_GET(regs,year,YEAR)
112
113#define MSTK_SET_REG_SEC(regs,value) MSTK_SET(regs,sec,value,SEC)
114#define MSTK_SET_REG_MIN(regs,value) MSTK_SET(regs,min,value,MIN)
115#define MSTK_SET_REG_HOUR(regs,value) MSTK_SET(regs,hour,value,HOUR)
116#define MSTK_SET_REG_DOW(regs,value) MSTK_SET(regs,dow,value,DOW)
117#define MSTK_SET_REG_DOM(regs,value) MSTK_SET(regs,dom,value,DOM)
118#define MSTK_SET_REG_MONTH(regs,value) MSTK_SET(regs,month,value,MONTH)
119#define MSTK_SET_REG_YEAR(regs,value) MSTK_SET(regs,year,value,YEAR)
120
121
122/* The Mostek 48t08 clock chip. Found on Sun4m's I think. It has the
123 * same (basically) layout of the 48t02 chip except for the extra
124 * NVRAM on board (8 KB against the 48t02's 2 KB).
125 */
126struct mostek48t08 {
127 char offset[6*1024]; /* Magic things may be here, who knows? */
128 struct mostek48t02 regs; /* Here is what we are interested in. */
129};
130
131#ifdef CONFIG_SUN4
132enum sparc_clock_type { MSTK48T02, MSTK48T08, \
133INTERSIL, MSTK_INVALID };
134#else
135enum sparc_clock_type { MSTK48T02, MSTK48T08, \
136MSTK_INVALID };
137#endif
138
139#ifdef CONFIG_SUN4
140/* intersil on a sun 4/260 code data from harris doc */
141struct intersil_dt {
142 volatile unsigned char int_csec;
143 volatile unsigned char int_hour;
144 volatile unsigned char int_min;
145 volatile unsigned char int_sec;
146 volatile unsigned char int_month;
147 volatile unsigned char int_day;
148 volatile unsigned char int_year;
149 volatile unsigned char int_dow;
150};
151
152struct intersil {
153 struct intersil_dt clk;
154 struct intersil_dt cmp;
155 volatile unsigned char int_intr_reg;
156 volatile unsigned char int_cmd_reg;
157};
158
159#define INTERSIL_STOP 0x0
160#define INTERSIL_START 0x8
161#define INTERSIL_INTR_DISABLE 0x0
162#define INTERSIL_INTR_ENABLE 0x10
163#define INTERSIL_32K 0x0
164#define INTERSIL_NORMAL 0x0
165#define INTERSIL_24H 0x4
166#define INTERSIL_INT_100HZ 0x2
167
168/* end of intersil info */
169#endif
170
171#endif /* !(_SPARC_MOSTEK_H) */
diff --git a/arch/sparc/include/asm/mostek_64.h b/arch/sparc/include/asm/mostek_64.h
deleted file mode 100644
index c5652de2ace2..000000000000
--- a/arch/sparc/include/asm/mostek_64.h
+++ /dev/null
@@ -1,143 +0,0 @@
1/* mostek.h: Describes the various Mostek time of day clock registers.
2 *
3 * Copyright (C) 1995 David S. Miller (davem@davemloft.net)
4 * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
5 */
6
7#ifndef _SPARC64_MOSTEK_H
8#define _SPARC64_MOSTEK_H
9
10#include <asm/idprom.h>
11
12/* M48T02 Register Map (adapted from Sun NVRAM/Hostid FAQ)
13 *
14 * Data
15 * Address Function
16 * Bit 7 Bit 6 Bit 5 Bit 4Bit 3 Bit 2 Bit 1 Bit 0
17 * 7ff - - - - - - - - Year 00-99
18 * 7fe 0 0 0 - - - - - Month 01-12
19 * 7fd 0 0 - - - - - - Date 01-31
20 * 7fc 0 FT 0 0 0 - - - Day 01-07
21 * 7fb KS 0 - - - - - - Hours 00-23
22 * 7fa 0 - - - - - - - Minutes 00-59
23 * 7f9 ST - - - - - - - Seconds 00-59
24 * 7f8 W R S - - - - - Control
25 *
26 * * ST is STOP BIT
27 * * W is WRITE BIT
28 * * R is READ BIT
29 * * S is SIGN BIT
30 * * FT is FREQ TEST BIT
31 * * KS is KICK START BIT
32 */
33
34/* The Mostek 48t02 real time clock and NVRAM chip. The registers
35 * other than the control register are in binary coded decimal. Some
36 * control bits also live outside the control register.
37 *
38 * We now deal with physical addresses for I/O to the chip. -DaveM
39 */
40static inline u8 mostek_read(void __iomem *addr)
41{
42 u8 ret;
43
44 __asm__ __volatile__("lduba [%1] %2, %0"
45 : "=r" (ret)
46 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
47 return ret;
48}
49
50static inline void mostek_write(void __iomem *addr, u8 val)
51{
52 __asm__ __volatile__("stba %0, [%1] %2"
53 : /* no outputs */
54 : "r" (val), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
55}
56
57#define MOSTEK_EEPROM 0x0000UL
58#define MOSTEK_IDPROM 0x07d8UL
59#define MOSTEK_CREG 0x07f8UL
60#define MOSTEK_SEC 0x07f9UL
61#define MOSTEK_MIN 0x07faUL
62#define MOSTEK_HOUR 0x07fbUL
63#define MOSTEK_DOW 0x07fcUL
64#define MOSTEK_DOM 0x07fdUL
65#define MOSTEK_MONTH 0x07feUL
66#define MOSTEK_YEAR 0x07ffUL
67
68extern spinlock_t mostek_lock;
69extern void __iomem *mstk48t02_regs;
70
71/* Control register values. */
72#define MSTK_CREG_WRITE 0x80 /* Must set this before placing values. */
73#define MSTK_CREG_READ 0x40 /* Stop updates to allow a clean read. */
74#define MSTK_CREG_SIGN 0x20 /* Slow/speed clock in calibration mode. */
75
76/* Control bits that live in the other registers. */
77#define MSTK_STOP 0x80 /* Stop the clock oscillator. (sec) */
78#define MSTK_KICK_START 0x80 /* Kick start the clock chip. (hour) */
79#define MSTK_FREQ_TEST 0x40 /* Frequency test mode. (day) */
80
81#define MSTK_YEAR_ZERO 1968 /* If year reg has zero, it is 1968. */
82#define MSTK_CVT_YEAR(yr) ((yr) + MSTK_YEAR_ZERO)
83
84/* Masks that define how much space each value takes up. */
85#define MSTK_SEC_MASK 0x7f
86#define MSTK_MIN_MASK 0x7f
87#define MSTK_HOUR_MASK 0x3f
88#define MSTK_DOW_MASK 0x07
89#define MSTK_DOM_MASK 0x3f
90#define MSTK_MONTH_MASK 0x1f
91#define MSTK_YEAR_MASK 0xffU
92
93/* Binary coded decimal conversion macros. */
94#define MSTK_REGVAL_TO_DECIMAL(x) (((x) & 0x0F) + 0x0A * ((x) >> 0x04))
95#define MSTK_DECIMAL_TO_REGVAL(x) ((((x) / 0x0A) << 0x04) + ((x) % 0x0A))
96
97/* Generic register set and get macros for internal use. */
98#define MSTK_GET(regs,name) \
99 (MSTK_REGVAL_TO_DECIMAL(mostek_read(regs + MOSTEK_ ## name) & MSTK_ ## name ## _MASK))
100#define MSTK_SET(regs,name,value) \
101do { u8 __val = mostek_read(regs + MOSTEK_ ## name); \
102 __val &= ~(MSTK_ ## name ## _MASK); \
103 __val |= (MSTK_DECIMAL_TO_REGVAL(value) & \
104 (MSTK_ ## name ## _MASK)); \
105 mostek_write(regs + MOSTEK_ ## name, __val); \
106} while(0)
107
108/* Macros to make register access easier on our fingers. These give you
109 * the decimal value of the register requested if applicable. You pass
110 * the a pointer to a 'struct mostek48t02'.
111 */
112#define MSTK_REG_CREG(regs) (mostek_read((regs) + MOSTEK_CREG))
113#define MSTK_REG_SEC(regs) MSTK_GET(regs,SEC)
114#define MSTK_REG_MIN(regs) MSTK_GET(regs,MIN)
115#define MSTK_REG_HOUR(regs) MSTK_GET(regs,HOUR)
116#define MSTK_REG_DOW(regs) MSTK_GET(regs,DOW)
117#define MSTK_REG_DOM(regs) MSTK_GET(regs,DOM)
118#define MSTK_REG_MONTH(regs) MSTK_GET(regs,MONTH)
119#define MSTK_REG_YEAR(regs) MSTK_GET(regs,YEAR)
120
121#define MSTK_SET_REG_SEC(regs,value) MSTK_SET(regs,SEC,value)
122#define MSTK_SET_REG_MIN(regs,value) MSTK_SET(regs,MIN,value)
123#define MSTK_SET_REG_HOUR(regs,value) MSTK_SET(regs,HOUR,value)
124#define MSTK_SET_REG_DOW(regs,value) MSTK_SET(regs,DOW,value)
125#define MSTK_SET_REG_DOM(regs,value) MSTK_SET(regs,DOM,value)
126#define MSTK_SET_REG_MONTH(regs,value) MSTK_SET(regs,MONTH,value)
127#define MSTK_SET_REG_YEAR(regs,value) MSTK_SET(regs,YEAR,value)
128
129
130/* The Mostek 48t08 clock chip. Found on Sun4m's I think. It has the
131 * same (basically) layout of the 48t02 chip except for the extra
132 * NVRAM on board (8 KB against the 48t02's 2 KB).
133 */
134#define MOSTEK_48T08_OFFSET 0x0000UL /* Lower NVRAM portions */
135#define MOSTEK_48T08_48T02 0x1800UL /* Offset to 48T02 chip */
136
137/* SUN5 systems usually have 48t59 model clock chipsets. But we keep the older
138 * clock chip definitions around just in case.
139 */
140#define MOSTEK_48T59_OFFSET 0x0000UL /* Lower NVRAM portions */
141#define MOSTEK_48T59_48T02 0x1800UL /* Offset to 48T02 chip */
142
143#endif /* !(_SPARC64_MOSTEK_H) */
diff --git a/arch/sparc/include/asm/obio.h b/arch/sparc/include/asm/obio.h
index 1a7544ceb574..4ade0c8a2c79 100644
--- a/arch/sparc/include/asm/obio.h
+++ b/arch/sparc/include/asm/obio.h
@@ -155,17 +155,6 @@ static inline void bw_set_ctrl(int cpu, unsigned ctrl)
155 "i" (ASI_M_CTL)); 155 "i" (ASI_M_CTL));
156} 156}
157 157
158extern unsigned char cpu_leds[32];
159
160static inline void show_leds(int cpuid)
161{
162 cpuid &= 0x1e;
163 __asm__ __volatile__ ("stba %0, [%1] %2" : :
164 "r" ((cpu_leds[cpuid] << 4) | cpu_leds[cpuid+1]),
165 "r" (ECSR_BASE(cpuid) | BB_LEDS),
166 "i" (ASI_M_CTL));
167}
168
169static inline unsigned cc_get_ipen(void) 158static inline unsigned cc_get_ipen(void)
170{ 159{
171 unsigned pending; 160 unsigned pending;
diff --git a/arch/sparc/include/asm/of_device.h b/arch/sparc/include/asm/of_device.h
index bba777a416d3..a5d9811f9697 100644
--- a/arch/sparc/include/asm/of_device.h
+++ b/arch/sparc/include/asm/of_device.h
@@ -30,6 +30,8 @@ struct of_device
30extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); 30extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name);
31extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); 31extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size);
32 32
33extern void of_propagate_archdata(struct of_device *bus);
34
33/* This is just here during the transition */ 35/* This is just here during the transition */
34#include <linux/of_platform.h> 36#include <linux/of_platform.h>
35 37
diff --git a/arch/sparc/include/asm/of_platform.h b/arch/sparc/include/asm/of_platform.h
index 2348ab90a57c..90da99059f83 100644
--- a/arch/sparc/include/asm/of_platform.h
+++ b/arch/sparc/include/asm/of_platform.h
@@ -13,9 +13,6 @@
13 * 13 *
14 */ 14 */
15 15
16extern struct bus_type ebus_bus_type;
17extern struct bus_type sbus_bus_type;
18
19#define of_bus_type of_platform_bus_type /* for compatibility */ 16#define of_bus_type of_platform_bus_type /* for compatibility */
20 17
21#endif 18#endif
diff --git a/arch/sparc/include/asm/oplib_32.h b/arch/sparc/include/asm/oplib_32.h
index b2631da259e0..699da05235c8 100644
--- a/arch/sparc/include/asm/oplib_32.h
+++ b/arch/sparc/include/asm/oplib_32.h
@@ -21,7 +21,6 @@ enum prom_major_version {
21 PROM_V2, /* sun4c and early sun4m V2 prom */ 21 PROM_V2, /* sun4c and early sun4m V2 prom */
22 PROM_V3, /* sun4m and later, up to sun4d/sun4e machines V3 */ 22 PROM_V3, /* sun4m and later, up to sun4d/sun4e machines V3 */
23 PROM_P1275, /* IEEE compliant ISA based Sun PROM, only sun4u */ 23 PROM_P1275, /* IEEE compliant ISA based Sun PROM, only sun4u */
24 PROM_SUN4, /* Old sun4 proms are totally different, but we'll shoehorn it to make it fit */
25}; 24};
26 25
27extern enum prom_major_version prom_vers; 26extern enum prom_major_version prom_vers;
diff --git a/arch/sparc/include/asm/page_32.h b/arch/sparc/include/asm/page_32.h
index cf5fb70ca1c1..d1806edc0958 100644
--- a/arch/sparc/include/asm/page_32.h
+++ b/arch/sparc/include/asm/page_32.h
@@ -8,11 +8,8 @@
8#ifndef _SPARC_PAGE_H 8#ifndef _SPARC_PAGE_H
9#define _SPARC_PAGE_H 9#define _SPARC_PAGE_H
10 10
11#ifdef CONFIG_SUN4
12#define PAGE_SHIFT 13
13#else
14#define PAGE_SHIFT 12 11#define PAGE_SHIFT 12
15#endif 12
16#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
17/* I have my suspicions... -DaveM */ 14/* I have my suspicions... -DaveM */
18#define PAGE_SIZE (1UL << PAGE_SHIFT) 15#define PAGE_SIZE (1UL << PAGE_SHIFT)
diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h
index b579b910ef51..4274ed13ddb2 100644
--- a/arch/sparc/include/asm/page_64.h
+++ b/arch/sparc/include/asm/page_64.h
@@ -38,6 +38,8 @@
38 38
39#ifndef __ASSEMBLY__ 39#ifndef __ASSEMBLY__
40 40
41#define WANT_PAGE_VIRTUAL
42
41extern void _clear_page(void *page); 43extern void _clear_page(void *page);
42#define clear_page(X) _clear_page((void *)(X)) 44#define clear_page(X) _clear_page((void *)(X))
43struct page; 45struct page;
diff --git a/arch/sparc/include/asm/parport.h b/arch/sparc/include/asm/parport.h
index d9830621c906..dff3f0253aa8 100644
--- a/arch/sparc/include/asm/parport.h
+++ b/arch/sparc/include/asm/parport.h
@@ -8,7 +8,7 @@
8 8
9#include <linux/of_device.h> 9#include <linux/of_device.h>
10 10
11#include <asm/ebus.h> 11#include <asm/ebus_dma.h>
12#include <asm/ns87303.h> 12#include <asm/ns87303.h>
13#include <asm/prom.h> 13#include <asm/prom.h>
14 14
@@ -215,7 +215,7 @@ static int __devexit ecpp_remove(struct of_device *op)
215 return 0; 215 return 0;
216} 216}
217 217
218static struct of_device_id ecpp_match[] = { 218static const struct of_device_id ecpp_match[] = {
219 { 219 {
220 .name = "ecpp", 220 .name = "ecpp",
221 }, 221 },
diff --git a/arch/sparc/include/asm/pci_32.h b/arch/sparc/include/asm/pci_32.h
index 0ee949d220c0..b41c4c198159 100644
--- a/arch/sparc/include/asm/pci_32.h
+++ b/arch/sparc/include/asm/pci_32.h
@@ -3,6 +3,8 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/dma-mapping.h>
7
6/* Can be used to override the logic in pci_scan_bus for skipping 8/* Can be used to override the logic in pci_scan_bus for skipping
7 * already-configured bus numbers - to be used for buggy BIOSes 9 * already-configured bus numbers - to be used for buggy BIOSes
8 * or architectures with incomplete PCI setup by the loader. 10 * or architectures with incomplete PCI setup by the loader.
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index 08237fda8874..e0cabe790ec1 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -14,11 +14,7 @@
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/swap.h> 15#include <linux/swap.h>
16#include <asm/types.h> 16#include <asm/types.h>
17#ifdef CONFIG_SUN4
18#include <asm/pgtsun4.h>
19#else
20#include <asm/pgtsun4c.h> 17#include <asm/pgtsun4c.h>
21#endif
22#include <asm/pgtsrmmu.h> 18#include <asm/pgtsrmmu.h>
23#include <asm/vac-ops.h> 19#include <asm/vac-ops.h>
24#include <asm/oplib.h> 20#include <asm/oplib.h>
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index bb9ec2cce355..b049abf9902f 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -770,6 +770,8 @@ extern void sun4v_patch_tlb_handlers(void);
770 770
771extern unsigned long cmdline_memory_size; 771extern unsigned long cmdline_memory_size;
772 772
773extern asmlinkage void do_sparc64_fault(struct pt_regs *regs);
774
773#endif /* !(__ASSEMBLY__) */ 775#endif /* !(__ASSEMBLY__) */
774 776
775#endif /* !(_SPARC64_PGTABLE_H) */ 777#endif /* !(_SPARC64_PGTABLE_H) */
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h
index fd55522481cd..900d44714f8d 100644
--- a/arch/sparc/include/asm/prom.h
+++ b/arch/sparc/include/asm/prom.h
@@ -18,6 +18,7 @@
18 */ 18 */
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <linux/mutex.h>
21#include <asm/atomic.h> 22#include <asm/atomic.h>
22 23
23#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 24#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
@@ -73,6 +74,7 @@ struct of_irq_controller {
73 74
74extern struct device_node *of_find_node_by_cpuid(int cpuid); 75extern struct device_node *of_find_node_by_cpuid(int cpuid);
75extern int of_set_property(struct device_node *node, const char *name, void *val, int len); 76extern int of_set_property(struct device_node *node, const char *name, void *val, int len);
77extern struct mutex of_set_property_mutex;
76extern int of_getintprop_default(struct device_node *np, 78extern int of_getintprop_default(struct device_node *np,
77 const char *name, 79 const char *name,
78 int def); 80 int def);
@@ -94,6 +96,16 @@ static inline void of_node_put(struct device_node *node)
94{ 96{
95} 97}
96 98
99/* These routines are here to provide compatibility with how powerpc
100 * handles IRQ mapping for OF device nodes. We precompute and permanently
101 * register them in the of_device objects, whereas powerpc computes them
102 * on request.
103 */
104extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
105static inline void irq_dispose_mapping(unsigned int virq)
106{
107}
108
97/* 109/*
98 * NB: This is here while we transition from using asm/prom.h 110 * NB: This is here while we transition from using asm/prom.h
99 * to linux/of.h 111 * to linux/of.h
diff --git a/arch/sparc/include/asm/ptrace_64.h b/arch/sparc/include/asm/ptrace_64.h
index 06e4914c13f4..3d3e9c161d8b 100644
--- a/arch/sparc/include/asm/ptrace_64.h
+++ b/arch/sparc/include/asm/ptrace_64.h
@@ -113,6 +113,8 @@ struct sparc_trapf {
113 113
114#ifdef __KERNEL__ 114#ifdef __KERNEL__
115 115
116#include <linux/threads.h>
117
116static inline int pt_regs_trap_type(struct pt_regs *regs) 118static inline int pt_regs_trap_type(struct pt_regs *regs)
117{ 119{
118 return regs->magic & 0x1ff; 120 return regs->magic & 0x1ff;
@@ -138,6 +140,7 @@ struct global_reg_snapshot {
138 struct thread_info *thread; 140 struct thread_info *thread;
139 unsigned long pad1; 141 unsigned long pad1;
140}; 142};
143extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
141 144
142#define __ARCH_WANT_COMPAT_SYS_PTRACE 145#define __ARCH_WANT_COMPAT_SYS_PTRACE
143 146
diff --git a/arch/sparc/include/asm/reboot.h b/arch/sparc/include/asm/reboot.h
deleted file mode 100644
index 3f3f43f5be5e..000000000000
--- a/arch/sparc/include/asm/reboot.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _SPARC64_REBOOT_H
2#define _SPARC64_REBOOT_H
3
4extern void machine_alt_power_off(void);
5
6#endif /* _SPARC64_REBOOT_H */
diff --git a/arch/sparc/include/asm/rtc.h b/arch/sparc/include/asm/rtc.h
deleted file mode 100644
index f9ecb1fe2ecd..000000000000
--- a/arch/sparc/include/asm/rtc.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * rtc.h: Definitions for access to the Mostek real time clock
3 *
4 * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
5 */
6
7#ifndef _RTC_H
8#define _RTC_H
9
10#include <linux/ioctl.h>
11
12struct rtc_time
13{
14 int sec; /* Seconds (0-59) */
15 int min; /* Minutes (0-59) */
16 int hour; /* Hour (0-23) */
17 int dow; /* Day of the week (1-7) */
18 int dom; /* Day of the month (1-31) */
19 int month; /* Month of year (1-12) */
20 int year; /* Year (0-99) */
21};
22
23#define RTCGET _IOR('p', 20, struct rtc_time)
24#define RTCSET _IOW('p', 21, struct rtc_time)
25
26#endif
diff --git a/arch/sparc/include/asm/sbus.h b/arch/sparc/include/asm/sbus.h
deleted file mode 100644
index f82481ab44db..000000000000
--- a/arch/sparc/include/asm/sbus.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef ___ASM_SPARC_SBUS_H
2#define ___ASM_SPARC_SBUS_H
3#if defined(__sparc__) && defined(__arch64__)
4#include <asm/sbus_64.h>
5#else
6#include <asm/sbus_32.h>
7#endif
8#endif
diff --git a/arch/sparc/include/asm/sbus_32.h b/arch/sparc/include/asm/sbus_32.h
deleted file mode 100644
index a7b4fa21931d..000000000000
--- a/arch/sparc/include/asm/sbus_32.h
+++ /dev/null
@@ -1,153 +0,0 @@
1/*
2 * sbus.h: Defines for the Sun SBus.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC_SBUS_H
8#define _SPARC_SBUS_H
9
10#include <linux/dma-mapping.h>
11#include <linux/ioport.h>
12#include <linux/of_device.h>
13
14#include <asm/oplib.h>
15#include <asm/prom.h>
16#include <asm/scatterlist.h>
17
18/* We scan which devices are on the SBus using the PROM node device
19 * tree. SBus devices are described in two different ways. You can
20 * either get an absolute address at which to access the device, or
21 * you can get a SBus 'slot' number and an offset within that slot.
22 */
23
24/* The base address at which to calculate device OBIO addresses. */
25#define SUN_SBUS_BVADDR 0xf8000000
26#define SBUS_OFF_MASK 0x01ffffff
27
28/* These routines are used to calculate device address from slot
29 * numbers + offsets, and vice versa.
30 */
31
32static inline unsigned long sbus_devaddr(int slotnum, unsigned long offset)
33{
34 return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset));
35}
36
37static inline int sbus_dev_slot(unsigned long dev_addr)
38{
39 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
40}
41
42struct sbus_bus;
43
44/* Linux SBUS device tables */
45struct sbus_dev {
46 struct of_device ofdev;
47 struct sbus_bus *bus;
48 struct sbus_dev *next;
49 struct sbus_dev *child;
50 struct sbus_dev *parent;
51 int prom_node;
52 char prom_name[64];
53 int slot;
54
55 struct resource resource[PROMREG_MAX];
56
57 struct linux_prom_registers reg_addrs[PROMREG_MAX];
58 int num_registers;
59
60 struct linux_prom_ranges device_ranges[PROMREG_MAX];
61 int num_device_ranges;
62
63 unsigned int irqs[4];
64 int num_irqs;
65};
66#define to_sbus_device(d) container_of(d, struct sbus_dev, ofdev.dev)
67
68/* This struct describes the SBus(s) found on this machine. */
69struct sbus_bus {
70 struct of_device ofdev;
71 struct sbus_dev *devices; /* Link to devices on this SBus */
72 struct sbus_bus *next; /* next SBus, if more than one SBus */
73 int prom_node; /* PROM device tree node for this SBus */
74 char prom_name[64]; /* Usually "sbus" or "sbi" */
75 int clock_freq;
76
77 struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
78 int num_sbus_ranges;
79
80 int devid;
81 int board;
82};
83#define to_sbus(d) container_of(d, struct sbus_bus, ofdev.dev)
84
85extern struct sbus_bus *sbus_root;
86
87static inline int
88sbus_is_slave(struct sbus_dev *dev)
89{
90 /* XXX Have to write this for sun4c's */
91 return 0;
92}
93
94/* Device probing routines could find these handy */
95#define for_each_sbus(bus) \
96 for((bus) = sbus_root; (bus); (bus)=(bus)->next)
97
98#define for_each_sbusdev(device, bus) \
99 for((device) = (bus)->devices; (device); (device)=(device)->next)
100
101#define for_all_sbusdev(device, bus) \
102 for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
103 for ((device) = (bus)->devices; (device); (device) = (device)->next)
104
105/* Driver DVMA interfaces. */
106#define sbus_can_dma_64bit(sdev) (0) /* actually, sparc_cpu_model==sun4d */
107#define sbus_can_burst64(sdev) (0) /* actually, sparc_cpu_model==sun4d */
108extern void sbus_set_sbus64(struct sbus_dev *, int);
109extern void sbus_fill_device_irq(struct sbus_dev *);
110
111/* These yield IOMMU mappings in consistent mode. */
112extern void *sbus_alloc_consistent(struct sbus_dev *, long, u32 *dma_addrp);
113extern void sbus_free_consistent(struct sbus_dev *, long, void *, u32);
114void prom_adjust_ranges(struct linux_prom_ranges *, int,
115 struct linux_prom_ranges *, int);
116
117#define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL
118#define SBUS_DMA_TODEVICE DMA_TO_DEVICE
119#define SBUS_DMA_FROMDEVICE DMA_FROM_DEVICE
120#define SBUS_DMA_NONE DMA_NONE
121
122/* All the rest use streaming mode mappings. */
123extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
124extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
125extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
126extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
127
128/* Finally, allow explicit synchronization of streamable mappings. */
129extern void sbus_dma_sync_single_for_cpu(struct sbus_dev *, dma_addr_t, size_t, int);
130#define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
131extern void sbus_dma_sync_single_for_device(struct sbus_dev *, dma_addr_t, size_t, int);
132extern void sbus_dma_sync_sg_for_cpu(struct sbus_dev *, struct scatterlist *, int, int);
133#define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
134extern void sbus_dma_sync_sg_for_device(struct sbus_dev *, struct scatterlist *, int, int);
135
136/* Eric Brower (ebrower@usa.net)
137 * Translate SBus interrupt levels to ino values--
138 * this is used when converting sbus "interrupts" OBP
139 * node values to "intr" node values, and is platform
140 * dependent. If only we could call OBP with
141 * "sbus-intr>cpu (sbint -- ino)" from kernel...
142 * See .../drivers/sbus/sbus.c for details.
143 */
144BTFIXUPDEF_CALL(unsigned int, sbint_to_irq, struct sbus_dev *sdev, unsigned int)
145#define sbint_to_irq(sdev, sbint) BTFIXUP_CALL(sbint_to_irq)(sdev, sbint)
146
147extern void sbus_arch_bus_ranges_init(struct device_node *, struct sbus_bus *);
148extern void sbus_setup_iommu(struct sbus_bus *, struct device_node *);
149extern void sbus_setup_arch_props(struct sbus_bus *, struct device_node *);
150extern int sbus_arch_preinit(void);
151extern void sbus_arch_postinit(void);
152
153#endif /* !(_SPARC_SBUS_H) */
diff --git a/arch/sparc/include/asm/sbus_64.h b/arch/sparc/include/asm/sbus_64.h
deleted file mode 100644
index b606c14343fb..000000000000
--- a/arch/sparc/include/asm/sbus_64.h
+++ /dev/null
@@ -1,190 +0,0 @@
1/* sbus.h: Defines for the Sun SBus.
2 *
3 * Copyright (C) 1996, 1999, 2007 David S. Miller (davem@davemloft.net)
4 */
5
6#ifndef _SPARC64_SBUS_H
7#define _SPARC64_SBUS_H
8
9#include <linux/dma-mapping.h>
10#include <linux/ioport.h>
11#include <linux/of_device.h>
12
13#include <asm/oplib.h>
14#include <asm/prom.h>
15#include <asm/iommu.h>
16#include <asm/scatterlist.h>
17
18/* We scan which devices are on the SBus using the PROM node device
19 * tree. SBus devices are described in two different ways. You can
20 * either get an absolute address at which to access the device, or
21 * you can get a SBus 'slot' number and an offset within that slot.
22 */
23
24/* The base address at which to calculate device OBIO addresses. */
25#define SUN_SBUS_BVADDR 0x00000000
26#define SBUS_OFF_MASK 0x0fffffff
27
28/* These routines are used to calculate device address from slot
29 * numbers + offsets, and vice versa.
30 */
31
32static inline unsigned long sbus_devaddr(int slotnum, unsigned long offset)
33{
34 return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<28)+(offset));
35}
36
37static inline int sbus_dev_slot(unsigned long dev_addr)
38{
39 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>28);
40}
41
42struct sbus_bus;
43
44/* Linux SBUS device tables */
45struct sbus_dev {
46 struct of_device ofdev;
47 struct sbus_bus *bus;
48 struct sbus_dev *next;
49 struct sbus_dev *child;
50 struct sbus_dev *parent;
51 int prom_node;
52 char prom_name[64];
53 int slot;
54
55 struct resource resource[PROMREG_MAX];
56
57 struct linux_prom_registers reg_addrs[PROMREG_MAX];
58 int num_registers;
59
60 struct linux_prom_ranges device_ranges[PROMREG_MAX];
61 int num_device_ranges;
62
63 unsigned int irqs[4];
64 int num_irqs;
65};
66#define to_sbus_device(d) container_of(d, struct sbus_dev, ofdev.dev)
67
68/* This struct describes the SBus(s) found on this machine. */
69struct sbus_bus {
70 struct of_device ofdev;
71 struct sbus_dev *devices; /* Tree of SBUS devices */
72 struct sbus_bus *next; /* Next SBUS in system */
73 int prom_node; /* OBP node of SBUS */
74 char prom_name[64]; /* Usually "sbus" or "sbi" */
75 int clock_freq;
76
77 struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
78 int num_sbus_ranges;
79
80 int portid;
81};
82#define to_sbus(d) container_of(d, struct sbus_bus, ofdev.dev)
83
84extern struct sbus_bus *sbus_root;
85
86/* Device probing routines could find these handy */
87#define for_each_sbus(bus) \
88 for((bus) = sbus_root; (bus); (bus)=(bus)->next)
89
90#define for_each_sbusdev(device, bus) \
91 for((device) = (bus)->devices; (device); (device)=(device)->next)
92
93#define for_all_sbusdev(device, bus) \
94 for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
95 for ((device) = (bus)->devices; (device); (device) = (device)->next)
96
97/* Driver DVMA interfaces. */
98#define sbus_can_dma_64bit(sdev) (1)
99#define sbus_can_burst64(sdev) (1)
100extern void sbus_set_sbus64(struct sbus_dev *, int);
101extern void sbus_fill_device_irq(struct sbus_dev *);
102
103static inline void *sbus_alloc_consistent(struct sbus_dev *sdev , size_t size,
104 dma_addr_t *dma_handle)
105{
106 return dma_alloc_coherent(&sdev->ofdev.dev, size,
107 dma_handle, GFP_ATOMIC);
108}
109
110static inline void sbus_free_consistent(struct sbus_dev *sdev, size_t size,
111 void *vaddr, dma_addr_t dma_handle)
112{
113 return dma_free_coherent(&sdev->ofdev.dev, size, vaddr, dma_handle);
114}
115
116#define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL
117#define SBUS_DMA_TODEVICE DMA_TO_DEVICE
118#define SBUS_DMA_FROMDEVICE DMA_FROM_DEVICE
119#define SBUS_DMA_NONE DMA_NONE
120
121/* All the rest use streaming mode mappings. */
122static inline dma_addr_t sbus_map_single(struct sbus_dev *sdev, void *ptr,
123 size_t size, int direction)
124{
125 return dma_map_single(&sdev->ofdev.dev, ptr, size,
126 (enum dma_data_direction) direction);
127}
128
129static inline void sbus_unmap_single(struct sbus_dev *sdev,
130 dma_addr_t dma_addr, size_t size,
131 int direction)
132{
133 dma_unmap_single(&sdev->ofdev.dev, dma_addr, size,
134 (enum dma_data_direction) direction);
135}
136
137static inline int sbus_map_sg(struct sbus_dev *sdev, struct scatterlist *sg,
138 int nents, int direction)
139{
140 return dma_map_sg(&sdev->ofdev.dev, sg, nents,
141 (enum dma_data_direction) direction);
142}
143
144static inline void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sg,
145 int nents, int direction)
146{
147 dma_unmap_sg(&sdev->ofdev.dev, sg, nents,
148 (enum dma_data_direction) direction);
149}
150
151/* Finally, allow explicit synchronization of streamable mappings. */
152static inline void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev,
153 dma_addr_t dma_handle,
154 size_t size, int direction)
155{
156 dma_sync_single_for_cpu(&sdev->ofdev.dev, dma_handle, size,
157 (enum dma_data_direction) direction);
158}
159#define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
160
161static inline void sbus_dma_sync_single_for_device(struct sbus_dev *sdev,
162 dma_addr_t dma_handle,
163 size_t size, int direction)
164{
165 /* No flushing needed to sync cpu writes to the device. */
166}
167
168static inline void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev,
169 struct scatterlist *sg,
170 int nents, int direction)
171{
172 dma_sync_sg_for_cpu(&sdev->ofdev.dev, sg, nents,
173 (enum dma_data_direction) direction);
174}
175#define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
176
177static inline void sbus_dma_sync_sg_for_device(struct sbus_dev *sdev,
178 struct scatterlist *sg,
179 int nents, int direction)
180{
181 /* No flushing needed to sync cpu writes to the device. */
182}
183
184extern void sbus_arch_bus_ranges_init(struct device_node *, struct sbus_bus *);
185extern void sbus_setup_iommu(struct sbus_bus *, struct device_node *);
186extern void sbus_setup_arch_props(struct sbus_bus *, struct device_node *);
187extern int sbus_arch_preinit(void);
188extern void sbus_arch_postinit(void);
189
190#endif /* !(_SPARC64_SBUS_H) */
diff --git a/arch/sparc/include/asm/spinlock_32.h b/arch/sparc/include/asm/spinlock_32.h
index de2249b267c6..bf2d532593e3 100644
--- a/arch/sparc/include/asm/spinlock_32.h
+++ b/arch/sparc/include/asm/spinlock_32.h
@@ -6,8 +6,6 @@
6#ifndef __SPARC_SPINLOCK_H 6#ifndef __SPARC_SPINLOCK_H
7#define __SPARC_SPINLOCK_H 7#define __SPARC_SPINLOCK_H
8 8
9#include <linux/threads.h> /* For NR_CPUS */
10
11#ifndef __ASSEMBLY__ 9#ifndef __ASSEMBLY__
12 10
13#include <asm/psr.h> 11#include <asm/psr.h>
diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
index 0006fe9f8c7a..120cfe4577c7 100644
--- a/arch/sparc/include/asm/spinlock_64.h
+++ b/arch/sparc/include/asm/spinlock_64.h
@@ -6,8 +6,6 @@
6#ifndef __SPARC64_SPINLOCK_H 6#ifndef __SPARC64_SPINLOCK_H
7#define __SPARC64_SPINLOCK_H 7#define __SPARC64_SPINLOCK_H
8 8
9#include <linux/threads.h> /* For NR_CPUS */
10
11#ifndef __ASSEMBLY__ 9#ifndef __ASSEMBLY__
12 10
13/* To get debugging spinlocks which detect and catch 11/* To get debugging spinlocks which detect and catch
diff --git a/arch/sparc/include/asm/sstate.h b/arch/sparc/include/asm/sstate.h
deleted file mode 100644
index a7c35dbcb281..000000000000
--- a/arch/sparc/include/asm/sstate.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#ifndef _SPARC64_SSTATE_H
2#define _SPARC64_SSTATE_H
3
4extern void sstate_booting(void);
5extern void sstate_running(void);
6extern void sstate_halt(void);
7extern void sstate_poweroff(void);
8extern void sstate_panic(void);
9extern void sstate_reboot(void);
10
11extern void sun4v_sstate_init(void);
12
13#endif /* _SPARC64_SSTATE_H */
diff --git a/arch/sparc/include/asm/starfire.h b/arch/sparc/include/asm/starfire.h
index 07bafd31e33c..d56ce60a5992 100644
--- a/arch/sparc/include/asm/starfire.h
+++ b/arch/sparc/include/asm/starfire.h
@@ -12,7 +12,6 @@
12extern int this_is_starfire; 12extern int this_is_starfire;
13 13
14extern void check_if_starfire(void); 14extern void check_if_starfire(void);
15extern void starfire_cpu_setup(void);
16extern int starfire_hard_smp_processor_id(void); 15extern int starfire_hard_smp_processor_id(void);
17extern void starfire_hookup(int); 16extern void starfire_hookup(int);
18extern unsigned int starfire_translate(unsigned long imap, unsigned int upaid); 17extern unsigned int starfire_translate(unsigned long imap, unsigned int upaid);
diff --git a/arch/sparc/include/asm/sun4paddr.h b/arch/sparc/include/asm/sun4paddr.h
deleted file mode 100644
index d52985f19f42..000000000000
--- a/arch/sparc/include/asm/sun4paddr.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * sun4paddr.h: Various physical addresses on sun4 machines
3 *
4 * Copyright (C) 1997 Anton Blanchard (anton@progsoc.uts.edu.au)
5 * Copyright (C) 1998 Chris Davis (cdavis@cois.on.ca)
6 *
7 * Now supports more sun4's
8 */
9
10#ifndef _SPARC_SUN4PADDR_H
11#define _SPARC_SUN4PADDR_H
12
13#define SUN4_IE_PHYSADDR 0xf5000000
14#define SUN4_UNUSED_PHYSADDR 0
15
16/* these work for me */
17#define SUN4_200_MEMREG_PHYSADDR 0xf4000000
18#define SUN4_200_CLOCK_PHYSADDR 0xf3000000
19#define SUN4_200_BWTWO_PHYSADDR 0xfd000000
20#define SUN4_200_ETH_PHYSADDR 0xf6000000
21#define SUN4_200_SI_PHYSADDR 0xff200000
22
23/* these were here before */
24#define SUN4_300_MEMREG_PHYSADDR 0xf4000000
25#define SUN4_300_CLOCK_PHYSADDR 0xf2000000
26#define SUN4_300_TIMER_PHYSADDR 0xef000000
27#define SUN4_300_ETH_PHYSADDR 0xf9000000
28#define SUN4_300_BWTWO_PHYSADDR 0xfb400000
29#define SUN4_300_DMA_PHYSADDR 0xfa001000
30#define SUN4_300_ESP_PHYSADDR 0xfa000000
31
32/* Are these right? */
33#define SUN4_400_MEMREG_PHYSADDR 0xf4000000
34#define SUN4_400_CLOCK_PHYSADDR 0xf2000000
35#define SUN4_400_TIMER_PHYSADDR 0xef000000
36#define SUN4_400_ETH_PHYSADDR 0xf9000000
37#define SUN4_400_BWTWO_PHYSADDR 0xfb400000
38#define SUN4_400_DMA_PHYSADDR 0xfa001000
39#define SUN4_400_ESP_PHYSADDR 0xfa000000
40
41/*
42 these are the actual values set and used in the code. Unused items set
43 to SUN_UNUSED_PHYSADDR
44 */
45
46extern int sun4_memreg_physaddr; /* memory register (ecc?) */
47extern int sun4_clock_physaddr; /* system clock */
48extern int sun4_timer_physaddr; /* timer, where applicable */
49extern int sun4_eth_physaddr; /* onboard ethernet (ie/le) */
50extern int sun4_si_physaddr; /* sun3 scsi adapter */
51extern int sun4_bwtwo_physaddr; /* onboard bw2 */
52extern int sun4_dma_physaddr; /* scsi dma */
53extern int sun4_esp_physaddr; /* esp scsi */
54extern int sun4_ie_physaddr; /* interrupt enable */
55
56#endif /* !(_SPARC_SUN4PADDR_H) */
diff --git a/arch/sparc/include/asm/sun4prom.h b/arch/sparc/include/asm/sun4prom.h
deleted file mode 100644
index 9c8b4cbf629a..000000000000
--- a/arch/sparc/include/asm/sun4prom.h
+++ /dev/null
@@ -1,83 +0,0 @@
1/*
2 * sun4prom.h -- interface to sun4 PROM monitor. We don't use most of this,
3 * so most of these are just placeholders.
4 */
5
6#ifndef _SUN4PROM_H_
7#define _SUN4PROM_H_
8
9/*
10 * Although this looks similar to an romvec for a OpenProm machine, it is
11 * actually closer to what was used in the Sun2 and Sun3.
12 *
13 * V2 entries exist only in version 2 PROMs and later, V3 in version 3 and later.
14 *
15 * Many of the function prototypes are guesses. Some are certainly wrong.
16 * Use with care.
17 */
18
19typedef struct {
20 char *initSP; /* Initial system stack ptr */
21 void (*startmon)(void); /* Initial PC for hardware */
22 int *diagberr; /* Bus err handler for diags */
23 struct linux_arguments_v0 **bootParam; /* Info for bootstrapped pgm */
24 unsigned int *memorysize; /* Usable memory in bytes */
25 unsigned char (*getchar)(void); /* Get char from input device */
26 void (*putchar)(char); /* Put char to output device */
27 int (*mayget)(void); /* Maybe get char, or -1 */
28 int (*mayput)(int); /* Maybe put char, or -1 */
29 unsigned char *echo; /* Should getchar echo? */
30 unsigned char *insource; /* Input source selector */
31 unsigned char *outsink; /* Output sink selector */
32 int (*getkey)(void); /* Get next key if one exists */
33 void (*initgetkey)(void); /* Initialize get key */
34 unsigned int *translation; /* Kbd translation selector */
35 unsigned char *keybid; /* Keyboard ID byte */
36 int *screen_x; /* V2: Screen x pos (r/o) */
37 int *screen_y; /* V2: Screen y pos (r/o) */
38 struct keybuf *keybuf; /* Up/down keycode buffer */
39 char *monid; /* Monitor version ID */
40 void (*fbwritechar)(char); /* Write a character to FB */
41 int *fbAddr; /* Address of frame buffer */
42 char **font; /* Font table for FB */
43 void (*fbwritestr)(char *); /* Write string to FB */
44 void (*reboot)(char *); /* e.g. reboot("sd()vmlinux") */
45 unsigned char *linebuf; /* The line input buffer */
46 unsigned char **lineptr; /* Cur pointer into linebuf */
47 int *linesize; /* length of line in linebuf */
48 void (*getline)(char *); /* Get line from user */
49 unsigned char (*getnextchar)(void); /* Get next char from linebuf */
50 unsigned char (*peeknextchar)(void); /* Peek at next char */
51 int *fbthere; /* =1 if frame buffer there */
52 int (*getnum)(void); /* Grab hex num from line */
53 int (*printf)(char *, ...); /* See prom_printf() instead */
54 void (*printhex)(int); /* Format N digits in hex */
55 unsigned char *leds; /* RAM copy of LED register */
56 void (*setLEDs)(unsigned char *); /* Sets LED's and RAM copy */
57 void (*NMIaddr)(void *); /* Addr for level 7 vector */
58 void (*abortentry)(void); /* Entry for keyboard abort */
59 int *nmiclock; /* Counts up in msec */
60 int *FBtype; /* Frame buffer type */
61 unsigned int romvecversion; /* Version number for this romvec */
62 struct globram *globram; /* monitor global variables ??? */
63 void * kbdaddr; /* Addr of keyboard in use */
64 int *keyrinit; /* ms before kbd repeat */
65 unsigned char *keyrtick; /* ms between repetitions */
66 unsigned int *memoryavail; /* V1: Main mem usable size */
67 long *resetaddr; /* where to jump on a reset */
68 long *resetmap; /* pgmap entry for resetaddr */
69 void (*exittomon)(void); /* Exit from user program */
70 unsigned char **memorybitmap; /* V1: &{0 or &bits} */
71 void (*setcxsegmap)(int ctxt, char *va, int pmeg); /* Set seg in any context */
72 void (**vector_cmd)(void *); /* V2: Handler for 'v' cmd */
73 unsigned long *expectedtrapsig; /* V3: Location of the expected trap signal */
74 unsigned long *trapvectorbasetable; /* V3: Address of the trap vector table */
75 int unused1;
76 int unused2;
77 int unused3;
78 int unused4;
79} linux_sun4_romvec;
80
81extern linux_sun4_romvec *sun4_romvec;
82
83#endif /* _SUN4PROM_H_ */
diff --git a/arch/sparc/include/asm/system_32.h b/arch/sparc/include/asm/system_32.h
index b4b024445fc9..8623fc48fe24 100644
--- a/arch/sparc/include/asm/system_32.h
+++ b/arch/sparc/include/asm/system_32.h
@@ -34,13 +34,7 @@ enum sparc_cpu {
34 34
35extern enum sparc_cpu sparc_cpu_model; 35extern enum sparc_cpu sparc_cpu_model;
36 36
37#ifndef CONFIG_SUN4 37#define ARCH_SUN4C (sparc_cpu_model==sun4c)
38#define ARCH_SUN4C_SUN4 (sparc_cpu_model==sun4c)
39#define ARCH_SUN4 0
40#else
41#define ARCH_SUN4C_SUN4 1
42#define ARCH_SUN4 1
43#endif
44 38
45#define SUN4M_NCPUS 4 /* Architectural limit of sun4m. */ 39#define SUN4M_NCPUS 4 /* Architectural limit of sun4m. */
46 40
@@ -55,6 +49,7 @@ extern unsigned long empty_zero_page;
55extern void sun_do_break(void); 49extern void sun_do_break(void);
56extern int serial_console; 50extern int serial_console;
57extern int stop_a_enabled; 51extern int stop_a_enabled;
52extern int scons_pwroff;
58 53
59static inline int con_is_present(void) 54static inline int con_is_present(void)
60{ 55{
diff --git a/arch/sparc/include/asm/system_64.h b/arch/sparc/include/asm/system_64.h
index db9e742a406a..8759f2a1b837 100644
--- a/arch/sparc/include/asm/system_64.h
+++ b/arch/sparc/include/asm/system_64.h
@@ -26,9 +26,8 @@ enum sparc_cpu {
26 26
27#define sparc_cpu_model sun4u 27#define sparc_cpu_model sun4u
28 28
29/* This cannot ever be a sun4c nor sun4 :) That's just history. */ 29/* This cannot ever be a sun4c :) That's just history. */
30#define ARCH_SUN4C_SUN4 0 30#define ARCH_SUN4C 0
31#define ARCH_SUN4 0
32 31
33extern char reboot_command[]; 32extern char reboot_command[];
34 33
@@ -118,6 +117,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
118 117
119extern void sun_do_break(void); 118extern void sun_do_break(void);
120extern int stop_a_enabled; 119extern int stop_a_enabled;
120extern int scons_pwroff;
121 121
122extern void fault_in_user_windows(void); 122extern void fault_in_user_windows(void);
123extern void synchronize_user_stack(void); 123extern void synchronize_user_stack(void);
diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
index cbb892d0dff0..29899fd5b1b2 100644
--- a/arch/sparc/include/asm/thread_info_32.h
+++ b/arch/sparc/include/asm/thread_info_32.h
@@ -80,11 +80,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
80/* 80/*
81 * thread information allocation 81 * thread information allocation
82 */ 82 */
83#if PAGE_SHIFT == 13
84#define THREAD_INFO_ORDER 0
85#else /* PAGE_SHIFT */
86#define THREAD_INFO_ORDER 1 83#define THREAD_INFO_ORDER 1
87#endif
88 84
89#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR 85#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
90 86
diff --git a/arch/sparc/include/asm/timer_32.h b/arch/sparc/include/asm/timer_32.h
index 361e53898dd7..2ec030ef3810 100644
--- a/arch/sparc/include/asm/timer_32.h
+++ b/arch/sparc/include/asm/timer_32.h
@@ -9,96 +9,9 @@
9#define _SPARC_TIMER_H 9#define _SPARC_TIMER_H
10 10
11#include <asm/system.h> /* For SUN4M_NCPUS */ 11#include <asm/system.h> /* For SUN4M_NCPUS */
12#include <asm/sun4paddr.h>
13#include <asm/btfixup.h> 12#include <asm/btfixup.h>
14 13
15/* Timer structures. The interrupt timer has two properties which
16 * are the counter (which is handled in do_timer in sched.c) and the limit.
17 * This limit is where the timer's counter 'wraps' around. Oddly enough,
18 * the sun4c timer when it hits the limit wraps back to 1 and not zero
19 * thus when calculating the value at which it will fire a microsecond you
20 * must adjust by one. Thanks SUN for designing such great hardware ;(
21 */
22
23/* Note that I am only going to use the timer that interrupts at
24 * Sparc IRQ 10. There is another one available that can fire at
25 * IRQ 14. Currently it is left untouched, we keep the PROM's limit
26 * register value and let the prom take these interrupts. This allows
27 * L1-A to work.
28 */
29
30struct sun4c_timer_info {
31 __volatile__ unsigned int cur_count10;
32 __volatile__ unsigned int timer_limit10;
33 __volatile__ unsigned int cur_count14;
34 __volatile__ unsigned int timer_limit14;
35};
36
37#define SUN4C_TIMER_PHYSADDR 0xf3000000
38#ifdef CONFIG_SUN4
39#define SUN_TIMER_PHYSADDR SUN4_300_TIMER_PHYSADDR
40#else
41#define SUN_TIMER_PHYSADDR SUN4C_TIMER_PHYSADDR
42#endif
43
44/* A sun4m has two blocks of registers which are probably of the same
45 * structure. LSI Logic's L64851 is told to _decrement_ from the limit
46 * value. Aurora behaves similarly but its limit value is compacted in
47 * other fashion (it's wider). Documented fields are defined here.
48 */
49
50/* As with the interrupt register, we have two classes of timer registers
51 * which are per-cpu and master. Per-cpu timers only hit that cpu and are
52 * only level 14 ticks, master timer hits all cpus and is level 10.
53 */
54
55#define SUN4M_PRM_CNT_L 0x80000000
56#define SUN4M_PRM_CNT_LVALUE 0x7FFFFC00
57
58struct sun4m_timer_percpu_info {
59 __volatile__ unsigned int l14_timer_limit; /* Initial value is 0x009c4000 */
60 __volatile__ unsigned int l14_cur_count;
61
62 /* This register appears to be write only and/or inaccessible
63 * on Uni-Processor sun4m machines.
64 */
65 __volatile__ unsigned int l14_limit_noclear; /* Data access error is here */
66
67 __volatile__ unsigned int cntrl; /* =1 after POST on Aurora */
68 __volatile__ unsigned char space[PAGE_SIZE - 16];
69};
70
71struct sun4m_timer_regs {
72 struct sun4m_timer_percpu_info cpu_timers[SUN4M_NCPUS];
73 volatile unsigned int l10_timer_limit;
74 volatile unsigned int l10_cur_count;
75
76 /* Again, this appears to be write only and/or inaccessible
77 * on uni-processor sun4m machines.
78 */
79 volatile unsigned int l10_limit_noclear;
80
81 /* This register too, it must be magic. */
82 volatile unsigned int foobar;
83
84 volatile unsigned int cfg; /* equals zero at boot time... */
85};
86
87#define SUN4D_PRM_CNT_L 0x80000000
88#define SUN4D_PRM_CNT_LVALUE 0x7FFFFC00
89
90struct sun4d_timer_regs {
91 volatile unsigned int l10_timer_limit;
92 volatile unsigned int l10_cur_countx;
93 volatile unsigned int l10_limit_noclear;
94 volatile unsigned int ctrl;
95 volatile unsigned int l10_cur_count;
96};
97
98extern struct sun4d_timer_regs *sun4d_timers;
99
100extern __volatile__ unsigned int *master_l10_counter; 14extern __volatile__ unsigned int *master_l10_counter;
101extern __volatile__ unsigned int *master_l10_limit;
102 15
103/* FIXME: Make do_[gs]ettimeofday btfixup calls */ 16/* FIXME: Make do_[gs]ettimeofday btfixup calls */
104BTFIXUPDEF_CALL(int, bus_do_settimeofday, struct timespec *tv) 17BTFIXUPDEF_CALL(int, bus_do_settimeofday, struct timespec *tv)
diff --git a/arch/sparc/include/asm/vac-ops.h b/arch/sparc/include/asm/vac-ops.h
index d10527611f11..a63e88ef0426 100644
--- a/arch/sparc/include/asm/vac-ops.h
+++ b/arch/sparc/include/asm/vac-ops.h
@@ -76,11 +76,7 @@
76 * cacheable bit in the pte's of all such pages. 76 * cacheable bit in the pte's of all such pages.
77 */ 77 */
78 78
79#ifdef CONFIG_SUN4
80#define S4CVAC_BADBITS 0x0001e000
81#else
82#define S4CVAC_BADBITS 0x0000f000 79#define S4CVAC_BADBITS 0x0000f000
83#endif
84 80
85/* The following is true if vaddr1 and vaddr2 would cause 81/* The following is true if vaddr1 and vaddr2 would cause
86 * a 'bad alias'. 82 * a 'bad alias'.
@@ -94,10 +90,7 @@
94 */ 90 */
95struct sun4c_vac_props { 91struct sun4c_vac_props {
96 unsigned int num_bytes; /* Size of the cache */ 92 unsigned int num_bytes; /* Size of the cache */
97 unsigned int num_lines; /* Number of cache lines */
98 unsigned int do_hwflushes; /* Hardware flushing available? */ 93 unsigned int do_hwflushes; /* Hardware flushing available? */
99 enum { VAC_NONE, VAC_WRITE_THROUGH,
100 VAC_WRITE_BACK } type; /* What type of VAC? */
101 unsigned int linesize; /* Size of each line in bytes */ 94 unsigned int linesize; /* Size of each line in bytes */
102 unsigned int log2lsize; /* log2(linesize) */ 95 unsigned int log2lsize; /* log2(linesize) */
103 unsigned int on; /* VAC is enabled */ 96 unsigned int on; /* VAC is enabled */
diff --git a/arch/sparc/include/asm/vfc_ioctls.h b/arch/sparc/include/asm/vfc_ioctls.h
deleted file mode 100644
index af8b69007b22..000000000000
--- a/arch/sparc/include/asm/vfc_ioctls.h
+++ /dev/null
@@ -1,58 +0,0 @@
1/* Copyright (c) 1996 by Manish Vachharajani */
2
3#ifndef _LINUX_VFC_IOCTLS_H_
4#define _LINUX_VFC_IOCTLS_H_
5
6 /* IOCTLs */
7#define VFC_IOCTL(a) (('j' << 8) | a)
8#define VFCGCTRL (VFC_IOCTL (0)) /* get vfc attributes */
9#define VFCSCTRL (VFC_IOCTL (1)) /* set vfc attributes */
10#define VFCGVID (VFC_IOCTL (2)) /* get video decoder attributes */
11#define VFCSVID (VFC_IOCTL (3)) /* set video decoder attributes */
12#define VFCHUE (VFC_IOCTL (4)) /* set hue */
13#define VFCPORTCHG (VFC_IOCTL (5)) /* change port */
14#define VFCRDINFO (VFC_IOCTL (6)) /* read info */
15
16 /* Options for setting the vfc attributes and status */
17#define MEMPRST 0x1 /* reset FIFO ptr. */
18#define CAPTRCMD 0x2 /* start capture and wait */
19#define DIAGMODE 0x3 /* diag mode */
20#define NORMMODE 0x4 /* normal mode */
21#define CAPTRSTR 0x5 /* start capture */
22#define CAPTRWAIT 0x6 /* wait for capture to finish */
23
24
25 /* Options for the decoder */
26#define STD_NTSC 0x1 /* NTSC mode */
27#define STD_PAL 0x2 /* PAL mode */
28#define COLOR_ON 0x3 /* force color ON */
29#define MONO 0x4 /* force color OFF */
30
31 /* Values returned by ioctl 2 */
32
33#define NO_LOCK 1
34#define NTSC_COLOR 2
35#define NTSC_NOCOLOR 3
36#define PAL_COLOR 4
37#define PAL_NOCOLOR 5
38
39/* Not too sure what this does yet */
40 /* Options for setting Field number */
41#define ODD_FIELD 0x1
42#define EVEN_FIELD 0x0
43#define ACTIVE_ONLY 0x2
44#define NON_ACTIVE 0x0
45
46/* Debug options */
47#define VFC_I2C_SEND 0
48#define VFC_I2C_RECV 1
49
50struct vfc_debug_inout
51{
52 unsigned long addr;
53 unsigned long ret;
54 unsigned long len;
55 unsigned char __user *buffer;
56};
57
58#endif /* _LINUX_VFC_IOCTLS_H_ */
diff --git a/arch/sparc/include/asm/visasm.h b/arch/sparc/include/asm/visasm.h
index de797b9bf552..39ca301920db 100644
--- a/arch/sparc/include/asm/visasm.h
+++ b/arch/sparc/include/asm/visasm.h
@@ -57,6 +57,7 @@ static inline void save_and_clear_fpu(void) {
57" " : : "i" (FPRS_FEF|FPRS_DU) : 57" " : : "i" (FPRS_FEF|FPRS_DU) :
58 "o5", "g1", "g2", "g3", "g7", "cc"); 58 "o5", "g1", "g2", "g3", "g7", "cc");
59} 59}
60extern int vis_emul(struct pt_regs *, unsigned int);
60#endif 61#endif
61 62
62#endif /* _SPARC64_ASI_H */ 63#endif /* _SPARC64_ASI_H */
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 6e03a2a7863c..2d6582095099 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -13,15 +13,13 @@ obj-y := entry.o wof.o wuf.o etrap.o rtrap.o traps.o $(IRQ_OBJS) \
13 time.o windows.o cpu.o devices.o \ 13 time.o windows.o cpu.o devices.o \
14 tadpole.o tick14.o ptrace.o \ 14 tadpole.o tick14.o ptrace.o \
15 unaligned.o una_asm.o muldiv.o \ 15 unaligned.o una_asm.o muldiv.o \
16 prom.o of_device.o devres.o 16 prom.o of_device.o devres.o dma.o
17 17
18devres-y = ../../../kernel/irq/devres.o 18devres-y = ../../../kernel/irq/devres.o
19 19
20obj-$(CONFIG_PCI) += pcic.o 20obj-$(CONFIG_PCI) += pcic.o
21obj-$(CONFIG_SUN4) += sun4setup.o
22obj-$(CONFIG_SMP) += trampoline.o smp.o sun4m_smp.o sun4d_smp.o 21obj-$(CONFIG_SMP) += trampoline.o smp.o sun4m_smp.o sun4d_smp.o
23obj-$(CONFIG_SUN_AUXIO) += auxio.o 22obj-$(CONFIG_SUN_AUXIO) += auxio.o
24obj-$(CONFIG_PCI) += ebus.o
25obj-$(CONFIG_SUN_PM) += apc.o pmc.o 23obj-$(CONFIG_SUN_PM) += apc.o pmc.o
26obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o 24obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o
27obj-$(CONFIG_SPARC_LED) += led.o 25obj-$(CONFIG_SPARC_LED) += led.o
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
index 5267d48fb2c6..4dd1ba752ce6 100644
--- a/arch/sparc/kernel/apc.c
+++ b/arch/sparc/kernel/apc.c
@@ -12,9 +12,10 @@
12#include <linux/miscdevice.h> 12#include <linux/miscdevice.h>
13#include <linux/smp_lock.h> 13#include <linux/smp_lock.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/of.h>
16#include <linux/of_device.h>
15 17
16#include <asm/io.h> 18#include <asm/io.h>
17#include <asm/sbus.h>
18#include <asm/oplib.h> 19#include <asm/oplib.h>
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
20#include <asm/auxio.h> 21#include <asm/auxio.h>
@@ -29,11 +30,10 @@
29#define APC_OBPNAME "power-management" 30#define APC_OBPNAME "power-management"
30#define APC_DEVNAME "apc" 31#define APC_DEVNAME "apc"
31 32
32volatile static u8 __iomem *regs; 33static u8 __iomem *regs;
33static int apc_regsize;
34static int apc_no_idle __initdata = 0; 34static int apc_no_idle __initdata = 0;
35 35
36#define apc_readb(offs) (sbus_readb(regs+offs)) 36#define apc_readb(offs) (sbus_readb(regs+offs))
37#define apc_writeb(val, offs) (sbus_writeb(val, regs+offs)) 37#define apc_writeb(val, offs) (sbus_writeb(val, regs+offs))
38 38
39/* Specify "apc=noidle" on the kernel command line to 39/* Specify "apc=noidle" on the kernel command line to
@@ -69,9 +69,9 @@ static void apc_swift_idle(void)
69#endif 69#endif
70} 70}
71 71
72static inline void apc_free(void) 72static inline void apc_free(struct of_device *op)
73{ 73{
74 sbus_iounmap(regs, apc_regsize); 74 of_iounmap(&op->resource[0], regs, resource_size(&op->resource[0]));
75} 75}
76 76
77static int apc_open(struct inode *inode, struct file *f) 77static int apc_open(struct inode *inode, struct file *f)
@@ -153,52 +153,56 @@ static const struct file_operations apc_fops = {
153 153
154static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops }; 154static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops };
155 155
156static int __init apc_probe(void) 156static int __devinit apc_probe(struct of_device *op,
157 const struct of_device_id *match)
157{ 158{
158 struct sbus_bus *sbus = NULL; 159 int err;
159 struct sbus_dev *sdev = NULL;
160 int iTmp = 0;
161
162 for_each_sbus(sbus) {
163 for_each_sbusdev(sdev, sbus) {
164 if (!strcmp(sdev->prom_name, APC_OBPNAME)) {
165 goto sbus_done;
166 }
167 }
168 }
169 160
170sbus_done: 161 regs = of_ioremap(&op->resource[0], 0,
171 if (!sdev) { 162 resource_size(&op->resource[0]), APC_OBPNAME);
172 return -ENODEV; 163 if (!regs) {
173 }
174
175 apc_regsize = sdev->reg_addrs[0].reg_size;
176 regs = sbus_ioremap(&sdev->resource[0], 0,
177 apc_regsize, APC_OBPNAME);
178 if(!regs) {
179 printk(KERN_ERR "%s: unable to map registers\n", APC_DEVNAME); 164 printk(KERN_ERR "%s: unable to map registers\n", APC_DEVNAME);
180 return -ENODEV; 165 return -ENODEV;
181 } 166 }
182 167
183 iTmp = misc_register(&apc_miscdev); 168 err = misc_register(&apc_miscdev);
184 if (iTmp != 0) { 169 if (err) {
185 printk(KERN_ERR "%s: unable to register device\n", APC_DEVNAME); 170 printk(KERN_ERR "%s: unable to register device\n", APC_DEVNAME);
186 apc_free(); 171 apc_free(op);
187 return -ENODEV; 172 return -ENODEV;
188 } 173 }
189 174
190 /* Assign power management IDLE handler */ 175 /* Assign power management IDLE handler */
191 if(!apc_no_idle) 176 if (!apc_no_idle)
192 pm_idle = apc_swift_idle; 177 pm_idle = apc_swift_idle;
193 178
194 printk(KERN_INFO "%s: power management initialized%s\n", 179 printk(KERN_INFO "%s: power management initialized%s\n",
195 APC_DEVNAME, apc_no_idle ? " (CPU idle disabled)" : ""); 180 APC_DEVNAME, apc_no_idle ? " (CPU idle disabled)" : "");
181
196 return 0; 182 return 0;
197} 183}
198 184
185static struct of_device_id __initdata apc_match[] = {
186 {
187 .name = APC_OBPNAME,
188 },
189 {},
190};
191MODULE_DEVICE_TABLE(of, apc_match);
192
193static struct of_platform_driver apc_driver = {
194 .name = "apc",
195 .match_table = apc_match,
196 .probe = apc_probe,
197};
198
199static int __init apc_init(void)
200{
201 return of_register_driver(&apc_driver, &of_bus_type);
202}
203
199/* This driver is not critical to the boot process 204/* This driver is not critical to the boot process
200 * and is easiest to ioremap when SBus is already 205 * and is easiest to ioremap when SBus is already
201 * initialized, so we install ourselves thusly: 206 * initialized, so we install ourselves thusly:
202 */ 207 */
203__initcall(apc_probe); 208__initcall(apc_init);
204
diff --git a/arch/sparc/kernel/auxio.c b/arch/sparc/kernel/auxio.c
index baf4ed3fb0f3..09c857215a52 100644
--- a/arch/sparc/kernel/auxio.c
+++ b/arch/sparc/kernel/auxio.c
@@ -6,6 +6,8 @@
6#include <linux/stddef.h> 6#include <linux/stddef.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/spinlock.h> 8#include <linux/spinlock.h>
9#include <linux/of.h>
10#include <linux/of_device.h>
9#include <asm/oplib.h> 11#include <asm/oplib.h>
10#include <asm/io.h> 12#include <asm/io.h>
11#include <asm/auxio.h> 13#include <asm/auxio.h>
@@ -59,7 +61,7 @@ void __init auxio_probe(void)
59 r.flags = auxregs[0].which_io & 0xF; 61 r.flags = auxregs[0].which_io & 0xF;
60 r.start = auxregs[0].phys_addr; 62 r.start = auxregs[0].phys_addr;
61 r.end = auxregs[0].phys_addr + auxregs[0].reg_size - 1; 63 r.end = auxregs[0].phys_addr + auxregs[0].reg_size - 1;
62 auxio_register = sbus_ioremap(&r, 0, auxregs[0].reg_size, "auxio"); 64 auxio_register = of_ioremap(&r, 0, auxregs[0].reg_size, "auxio");
63 /* Fix the address on sun4m and sun4c. */ 65 /* Fix the address on sun4m and sun4c. */
64 if((((unsigned long) auxregs[0].phys_addr) & 3) == 3 || 66 if((((unsigned long) auxregs[0].phys_addr) & 3) == 3 ||
65 sparc_cpu_model == sun4c) 67 sparc_cpu_model == sun4c)
@@ -128,7 +130,7 @@ void __init auxio_power_probe(void)
128 r.flags = regs.which_io & 0xF; 130 r.flags = regs.which_io & 0xF;
129 r.start = regs.phys_addr; 131 r.start = regs.phys_addr;
130 r.end = regs.phys_addr + regs.reg_size - 1; 132 r.end = regs.phys_addr + regs.reg_size - 1;
131 auxio_power_register = (unsigned char *) sbus_ioremap(&r, 0, 133 auxio_power_register = (unsigned char *) of_ioremap(&r, 0,
132 regs.reg_size, "auxpower"); 134 regs.reg_size, "auxpower");
133 135
134 /* Display a quick message on the console. */ 136 /* Display a quick message on the console. */
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c
index b240b8863fd0..ad656b044b8c 100644
--- a/arch/sparc/kernel/devices.c
+++ b/arch/sparc/kernel/devices.c
@@ -143,7 +143,7 @@ void __init device_scan(void)
143#endif 143#endif
144 clock_stop_probe(); 144 clock_stop_probe();
145 145
146 if (ARCH_SUN4C_SUN4) 146 if (ARCH_SUN4C)
147 sun4c_probe_memerr_reg(); 147 sun4c_probe_memerr_reg();
148 148
149 return; 149 return;
diff --git a/arch/sparc/kernel/dma.c b/arch/sparc/kernel/dma.c
new file mode 100644
index 000000000000..ebc8403b035e
--- /dev/null
+++ b/arch/sparc/kernel/dma.c
@@ -0,0 +1,227 @@
1/* dma.c: PCI and SBUS DMA accessors for 32-bit sparc.
2 *
3 * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
4 */
5
6#include <linux/kernel.h>
7#include <linux/module.h>
8#include <linux/dma-mapping.h>
9#include <linux/scatterlist.h>
10#include <linux/mm.h>
11
12#ifdef CONFIG_PCI
13#include <linux/pci.h>
14#endif
15
16#include "dma.h"
17
18int dma_supported(struct device *dev, u64 mask)
19{
20#ifdef CONFIG_PCI
21 if (dev->bus == &pci_bus_type)
22 return pci_dma_supported(to_pci_dev(dev), mask);
23#endif
24 return 0;
25}
26EXPORT_SYMBOL(dma_supported);
27
28int dma_set_mask(struct device *dev, u64 dma_mask)
29{
30#ifdef CONFIG_PCI
31 if (dev->bus == &pci_bus_type)
32 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
33#endif
34 return -EOPNOTSUPP;
35}
36EXPORT_SYMBOL(dma_set_mask);
37
38void *dma_alloc_coherent(struct device *dev, size_t size,
39 dma_addr_t *dma_handle, gfp_t flag)
40{
41#ifdef CONFIG_PCI
42 if (dev->bus == &pci_bus_type)
43 return pci_alloc_consistent(to_pci_dev(dev), size, dma_handle);
44#endif
45 return sbus_alloc_consistent(dev, size, dma_handle);
46}
47EXPORT_SYMBOL(dma_alloc_coherent);
48
49void dma_free_coherent(struct device *dev, size_t size,
50 void *cpu_addr, dma_addr_t dma_handle)
51{
52#ifdef CONFIG_PCI
53 if (dev->bus == &pci_bus_type) {
54 pci_free_consistent(to_pci_dev(dev), size,
55 cpu_addr, dma_handle);
56 return;
57 }
58#endif
59 sbus_free_consistent(dev, size, cpu_addr, dma_handle);
60}
61EXPORT_SYMBOL(dma_free_coherent);
62
63dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
64 size_t size, enum dma_data_direction direction)
65{
66#ifdef CONFIG_PCI
67 if (dev->bus == &pci_bus_type)
68 return pci_map_single(to_pci_dev(dev), cpu_addr,
69 size, (int)direction);
70#endif
71 return sbus_map_single(dev, cpu_addr, size, (int)direction);
72}
73EXPORT_SYMBOL(dma_map_single);
74
75void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
76 size_t size,
77 enum dma_data_direction direction)
78{
79#ifdef CONFIG_PCI
80 if (dev->bus == &pci_bus_type) {
81 pci_unmap_single(to_pci_dev(dev), dma_addr,
82 size, (int)direction);
83 return;
84 }
85#endif
86 sbus_unmap_single(dev, dma_addr, size, (int)direction);
87}
88EXPORT_SYMBOL(dma_unmap_single);
89
90dma_addr_t dma_map_page(struct device *dev, struct page *page,
91 unsigned long offset, size_t size,
92 enum dma_data_direction direction)
93{
94#ifdef CONFIG_PCI
95 if (dev->bus == &pci_bus_type)
96 return pci_map_page(to_pci_dev(dev), page, offset,
97 size, (int)direction);
98#endif
99 return sbus_map_single(dev, page_address(page) + offset,
100 size, (int)direction);
101}
102EXPORT_SYMBOL(dma_map_page);
103
104void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
105 size_t size, enum dma_data_direction direction)
106{
107#ifdef CONFIG_PCI
108 if (dev->bus == &pci_bus_type) {
109 pci_unmap_page(to_pci_dev(dev), dma_address,
110 size, (int)direction);
111 return;
112 }
113#endif
114 sbus_unmap_single(dev, dma_address, size, (int)direction);
115}
116EXPORT_SYMBOL(dma_unmap_page);
117
118int dma_map_sg(struct device *dev, struct scatterlist *sg,
119 int nents, enum dma_data_direction direction)
120{
121#ifdef CONFIG_PCI
122 if (dev->bus == &pci_bus_type)
123 return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
124#endif
125 return sbus_map_sg(dev, sg, nents, direction);
126}
127EXPORT_SYMBOL(dma_map_sg);
128
129void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
130 int nents, enum dma_data_direction direction)
131{
132#ifdef CONFIG_PCI
133 if (dev->bus == &pci_bus_type) {
134 pci_unmap_sg(to_pci_dev(dev), sg, nents, (int)direction);
135 return;
136 }
137#endif
138 sbus_unmap_sg(dev, sg, nents, (int)direction);
139}
140EXPORT_SYMBOL(dma_unmap_sg);
141
142void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
143 size_t size, enum dma_data_direction direction)
144{
145#ifdef CONFIG_PCI
146 if (dev->bus == &pci_bus_type) {
147 pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle,
148 size, (int)direction);
149 return;
150 }
151#endif
152 sbus_dma_sync_single_for_cpu(dev, dma_handle, size, (int) direction);
153}
154EXPORT_SYMBOL(dma_sync_single_for_cpu);
155
156void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
157 size_t size, enum dma_data_direction direction)
158{
159#ifdef CONFIG_PCI
160 if (dev->bus == &pci_bus_type) {
161 pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle,
162 size, (int)direction);
163 return;
164 }
165#endif
166 sbus_dma_sync_single_for_device(dev, dma_handle, size, (int) direction);
167}
168EXPORT_SYMBOL(dma_sync_single_for_device);
169
170void dma_sync_single_range_for_cpu(struct device *dev,
171 dma_addr_t dma_handle,
172 unsigned long offset,
173 size_t size,
174 enum dma_data_direction direction)
175{
176 dma_sync_single_for_cpu(dev, dma_handle+offset, size, direction);
177}
178EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
179
180void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
181 unsigned long offset, size_t size,
182 enum dma_data_direction direction)
183{
184 dma_sync_single_for_device(dev, dma_handle+offset, size, direction);
185}
186EXPORT_SYMBOL(dma_sync_single_range_for_device);
187
188void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
189 int nelems, enum dma_data_direction direction)
190{
191#ifdef CONFIG_PCI
192 if (dev->bus == &pci_bus_type) {
193 pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg,
194 nelems, (int)direction);
195 return;
196 }
197#endif
198 BUG();
199}
200EXPORT_SYMBOL(dma_sync_sg_for_cpu);
201
202void dma_sync_sg_for_device(struct device *dev,
203 struct scatterlist *sg, int nelems,
204 enum dma_data_direction direction)
205{
206#ifdef CONFIG_PCI
207 if (dev->bus == &pci_bus_type) {
208 pci_dma_sync_sg_for_device(to_pci_dev(dev), sg,
209 nelems, (int)direction);
210 return;
211 }
212#endif
213 BUG();
214}
215EXPORT_SYMBOL(dma_sync_sg_for_device);
216
217int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
218{
219 return (dma_addr == DMA_ERROR_CODE);
220}
221EXPORT_SYMBOL(dma_mapping_error);
222
223int dma_get_cache_alignment(void)
224{
225 return 32;
226}
227EXPORT_SYMBOL(dma_get_cache_alignment);
diff --git a/arch/sparc/kernel/dma.h b/arch/sparc/kernel/dma.h
new file mode 100644
index 000000000000..f8d8951adb53
--- /dev/null
+++ b/arch/sparc/kernel/dma.h
@@ -0,0 +1,14 @@
1void *sbus_alloc_consistent(struct device *dev, long len, u32 *dma_addrp);
2void sbus_free_consistent(struct device *dev, long n, void *p, u32 ba);
3dma_addr_t sbus_map_single(struct device *dev, void *va,
4 size_t len, int direction);
5void sbus_unmap_single(struct device *dev, dma_addr_t ba,
6 size_t n, int direction);
7int sbus_map_sg(struct device *dev, struct scatterlist *sg,
8 int n, int direction);
9void sbus_unmap_sg(struct device *dev, struct scatterlist *sg,
10 int n, int direction);
11void sbus_dma_sync_single_for_cpu(struct device *dev, dma_addr_t ba,
12 size_t size, int direction);
13void sbus_dma_sync_single_for_device(struct device *dev, dma_addr_t ba,
14 size_t size, int direction);
diff --git a/arch/sparc/kernel/ebus.c b/arch/sparc/kernel/ebus.c
deleted file mode 100644
index 97294232259c..000000000000
--- a/arch/sparc/kernel/ebus.c
+++ /dev/null
@@ -1,393 +0,0 @@
1/*
2 * ebus.c: PCI to EBus bridge device.
3 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 *
6 * Adopted for sparc by V. Roganov and G. Raiko.
7 * Fixes for different platforms by Pete Zaitcev.
8 */
9
10#include <linux/kernel.h>
11#include <linux/types.h>
12#include <linux/init.h>
13#include <linux/slab.h>
14#include <linux/string.h>
15
16#include <asm/system.h>
17#include <asm/page.h>
18#include <asm/pbm.h>
19#include <asm/ebus.h>
20#include <asm/io.h>
21#include <asm/oplib.h>
22#include <asm/prom.h>
23#include <asm/bpp.h>
24
25struct linux_ebus *ebus_chain = NULL;
26
27/* We are together with pcic.c under CONFIG_PCI. */
28extern unsigned int pcic_pin_to_irq(unsigned int, const char *name);
29
30/*
31 * IRQ Blacklist
32 * Here we list PROMs and systems that are known to supply crap as IRQ numbers.
33 */
34struct ebus_device_irq {
35 char *name;
36 unsigned int pin;
37};
38
39struct ebus_system_entry {
40 char *esname;
41 struct ebus_device_irq *ipt;
42};
43
44static struct ebus_device_irq je1_1[] = {
45 { "8042", 3 },
46 { "SUNW,CS4231", 0 },
47 { "parallel", 0 },
48 { "se", 2 },
49 { NULL, 0 }
50};
51
52/*
53 * Gleb's JE1 supplied reasonable pin numbers, but mine did not (OBP 2.32).
54 * Blacklist the sucker... Note that Gleb's system will work.
55 */
56static struct ebus_system_entry ebus_blacklist[] = {
57 { "SUNW,JavaEngine1", je1_1 },
58 { NULL, NULL }
59};
60
61static struct ebus_device_irq *ebus_blackp = NULL;
62
63/*
64 */
65static inline unsigned long ebus_alloc(size_t size)
66{
67 return (unsigned long)kmalloc(size, GFP_ATOMIC);
68}
69
70/*
71 */
72static int __init ebus_blacklist_irq(const char *name)
73{
74 struct ebus_device_irq *dp;
75
76 if ((dp = ebus_blackp) != NULL) {
77 for (; dp->name != NULL; dp++) {
78 if (strcmp(name, dp->name) == 0) {
79 return pcic_pin_to_irq(dp->pin, name);
80 }
81 }
82 }
83 return 0;
84}
85
86static void __init fill_ebus_child(struct device_node *dp,
87 struct linux_ebus_child *dev)
88{
89 const int *regs;
90 const int *irqs;
91 int i, len;
92
93 dev->prom_node = dp;
94 regs = of_get_property(dp, "reg", &len);
95 if (!regs)
96 len = 0;
97 dev->num_addrs = len / sizeof(regs[0]);
98
99 for (i = 0; i < dev->num_addrs; i++) {
100 if (regs[i] >= dev->parent->num_addrs) {
101 prom_printf("UGH: property for %s was %d, need < %d\n",
102 dev->prom_node->name, len,
103 dev->parent->num_addrs);
104 panic(__func__);
105 }
106
107 /* XXX resource */
108 dev->resource[i].start =
109 dev->parent->resource[regs[i]].start;
110 }
111
112 for (i = 0; i < PROMINTR_MAX; i++)
113 dev->irqs[i] = PCI_IRQ_NONE;
114
115 if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) {
116 dev->num_irqs = 1;
117 } else {
118 irqs = of_get_property(dp, "interrupts", &len);
119 if (!irqs) {
120 dev->num_irqs = 0;
121 dev->irqs[0] = 0;
122 if (dev->parent->num_irqs != 0) {
123 dev->num_irqs = 1;
124 dev->irqs[0] = dev->parent->irqs[0];
125 }
126 } else {
127 dev->num_irqs = len / sizeof(irqs[0]);
128 if (irqs[0] == 0 || irqs[0] >= 8) {
129 /*
130 * XXX Zero is a valid pin number...
131 * This works as long as Ebus is not wired
132 * to INTA#.
133 */
134 printk("EBUS: %s got bad irq %d from PROM\n",
135 dev->prom_node->name, irqs[0]);
136 dev->num_irqs = 0;
137 dev->irqs[0] = 0;
138 } else {
139 dev->irqs[0] =
140 pcic_pin_to_irq(irqs[0],
141 dev->prom_node->name);
142 }
143 }
144 }
145}
146
147static void __init fill_ebus_device(struct device_node *dp,
148 struct linux_ebus_device *dev)
149{
150 const struct linux_prom_registers *regs;
151 struct linux_ebus_child *child;
152 struct dev_archdata *sd;
153 const int *irqs;
154 int i, n, len;
155 unsigned long baseaddr;
156
157 dev->prom_node = dp;
158
159 regs = of_get_property(dp, "reg", &len);
160 if (!regs)
161 len = 0;
162 if (len % sizeof(struct linux_prom_registers)) {
163 prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
164 dev->prom_node->name, len,
165 (int)sizeof(struct linux_prom_registers));
166 panic(__func__);
167 }
168 dev->num_addrs = len / sizeof(struct linux_prom_registers);
169
170 for (i = 0; i < dev->num_addrs; i++) {
171 /*
172 * XXX Collect JE-1 PROM
173 *
174 * Example - JS-E with 3.11:
175 * /ebus
176 * regs
177 * 0x00000000, 0x0, 0x00000000, 0x0, 0x00000000,
178 * 0x82000010, 0x0, 0xf0000000, 0x0, 0x01000000,
179 * 0x82000014, 0x0, 0x38800000, 0x0, 0x00800000,
180 * ranges
181 * 0x00, 0x00000000, 0x02000010, 0x0, 0x0, 0x01000000,
182 * 0x01, 0x01000000, 0x02000014, 0x0, 0x0, 0x00800000,
183 * /ebus/8042
184 * regs
185 * 0x00000001, 0x00300060, 0x00000008,
186 * 0x00000001, 0x00300060, 0x00000008,
187 */
188 n = regs[i].which_io;
189 if (n >= 4) {
190 /* XXX This is copied from old JE-1 by Gleb. */
191 n = (regs[i].which_io - 0x10) >> 2;
192 } else {
193 ;
194 }
195
196/*
197 * XXX Now as we have regions, why don't we make an on-demand allocation...
198 */
199 dev->resource[i].start = 0;
200 if ((baseaddr = dev->bus->self->resource[n].start +
201 regs[i].phys_addr) != 0) {
202 /* dev->resource[i].name = dev->prom_name; */
203 if ((baseaddr = (unsigned long) ioremap(baseaddr,
204 regs[i].reg_size)) == 0) {
205 panic("ebus: unable to remap dev %s",
206 dev->prom_node->name);
207 }
208 }
209 dev->resource[i].start = baseaddr; /* XXX Unaligned */
210 }
211
212 for (i = 0; i < PROMINTR_MAX; i++)
213 dev->irqs[i] = PCI_IRQ_NONE;
214
215 if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) {
216 dev->num_irqs = 1;
217 } else {
218 irqs = of_get_property(dp, "interrupts", &len);
219 if (!irqs) {
220 dev->num_irqs = 0;
221 if ((dev->irqs[0] = dev->bus->self->irq) != 0) {
222 dev->num_irqs = 1;
223/* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */
224 }
225 } else {
226 dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */
227 if (irqs[0] == 0 || irqs[0] >= 8) {
228 /* See above for the parent. XXX */
229 printk("EBUS: %s got bad irq %d from PROM\n",
230 dev->prom_node->name, irqs[0]);
231 dev->num_irqs = 0;
232 dev->irqs[0] = 0;
233 } else {
234 dev->irqs[0] =
235 pcic_pin_to_irq(irqs[0],
236 dev->prom_node->name);
237 }
238 }
239 }
240
241 sd = &dev->ofdev.dev.archdata;
242 sd->prom_node = dp;
243 sd->op = &dev->ofdev;
244 sd->iommu = dev->bus->ofdev.dev.parent->archdata.iommu;
245
246 dev->ofdev.node = dp;
247 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
248 dev->ofdev.dev.bus = &ebus_bus_type;
249 sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
250
251 /* Register with core */
252 if (of_device_register(&dev->ofdev) != 0)
253 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
254 dp->path_component_name);
255
256 if ((dp = dp->child) != NULL) {
257 dev->children = (struct linux_ebus_child *)
258 ebus_alloc(sizeof(struct linux_ebus_child));
259
260 child = dev->children;
261 child->next = NULL;
262 child->parent = dev;
263 child->bus = dev->bus;
264 fill_ebus_child(dp, child);
265
266 while ((dp = dp->sibling) != NULL) {
267 child->next = (struct linux_ebus_child *)
268 ebus_alloc(sizeof(struct linux_ebus_child));
269
270 child = child->next;
271 child->next = NULL;
272 child->parent = dev;
273 child->bus = dev->bus;
274 fill_ebus_child(dp, child);
275 }
276 }
277}
278
279void __init ebus_init(void)
280{
281 const struct linux_prom_pci_registers *regs;
282 struct linux_pbm_info *pbm;
283 struct linux_ebus_device *dev;
284 struct linux_ebus *ebus;
285 struct ebus_system_entry *sp;
286 struct pci_dev *pdev;
287 struct pcidev_cookie *cookie;
288 struct device_node *dp;
289 struct resource *p;
290 unsigned short pci_command;
291 int len, reg, nreg;
292 int num_ebus = 0;
293
294 dp = of_find_node_by_path("/");
295 for (sp = ebus_blacklist; sp->esname != NULL; sp++) {
296 if (strcmp(dp->name, sp->esname) == 0) {
297 ebus_blackp = sp->ipt;
298 break;
299 }
300 }
301
302 pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL);
303 if (!pdev)
304 return;
305
306 cookie = pdev->sysdata;
307 dp = cookie->prom_node;
308
309 ebus_chain = ebus = (struct linux_ebus *)
310 ebus_alloc(sizeof(struct linux_ebus));
311 ebus->next = NULL;
312
313 while (dp) {
314 struct device_node *nd;
315
316 ebus->prom_node = dp;
317 ebus->self = pdev;
318 ebus->parent = pbm = cookie->pbm;
319
320 /* Enable BUS Master. */
321 pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
322 pci_command |= PCI_COMMAND_MASTER;
323 pci_write_config_word(pdev, PCI_COMMAND, pci_command);
324
325 regs = of_get_property(dp, "reg", &len);
326 if (!regs) {
327 prom_printf("%s: can't find reg property\n",
328 __func__);
329 prom_halt();
330 }
331 nreg = len / sizeof(struct linux_prom_pci_registers);
332
333 p = &ebus->self->resource[0];
334 for (reg = 0; reg < nreg; reg++) {
335 if (!(regs[reg].which_io & 0x03000000))
336 continue;
337
338 (p++)->start = regs[reg].phys_lo;
339 }
340
341 ebus->ofdev.node = dp;
342 ebus->ofdev.dev.parent = &pdev->dev;
343 ebus->ofdev.dev.bus = &ebus_bus_type;
344 sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
345
346 /* Register with core */
347 if (of_device_register(&ebus->ofdev) != 0)
348 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
349 dp->path_component_name);
350
351
352 nd = dp->child;
353 if (!nd)
354 goto next_ebus;
355
356 ebus->devices = (struct linux_ebus_device *)
357 ebus_alloc(sizeof(struct linux_ebus_device));
358
359 dev = ebus->devices;
360 dev->next = NULL;
361 dev->children = NULL;
362 dev->bus = ebus;
363 fill_ebus_device(nd, dev);
364
365 while ((nd = nd->sibling) != NULL) {
366 dev->next = (struct linux_ebus_device *)
367 ebus_alloc(sizeof(struct linux_ebus_device));
368
369 dev = dev->next;
370 dev->next = NULL;
371 dev->children = NULL;
372 dev->bus = ebus;
373 fill_ebus_device(nd, dev);
374 }
375
376 next_ebus:
377 pdev = pci_get_device(PCI_VENDOR_ID_SUN,
378 PCI_DEVICE_ID_SUN_EBUS, pdev);
379 if (!pdev)
380 break;
381
382 cookie = pdev->sysdata;
383 dp = cookie->prom_node;
384
385 ebus->next = (struct linux_ebus *)
386 ebus_alloc(sizeof(struct linux_ebus));
387 ebus = ebus->next;
388 ebus->next = NULL;
389 ++num_ebus;
390 }
391 if (pdev)
392 pci_dev_put(pdev);
393}
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index e8cdf715a546..faf9ccd9ef5d 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -20,11 +20,7 @@
20#include <asm/memreg.h> 20#include <asm/memreg.h>
21#include <asm/page.h> 21#include <asm/page.h>
22#include <asm/pgtable.h> 22#include <asm/pgtable.h>
23#ifdef CONFIG_SUN4
24#include <asm/pgtsun4.h>
25#else
26#include <asm/pgtsun4c.h> 23#include <asm/pgtsun4c.h>
27#endif
28#include <asm/winmacro.h> 24#include <asm/winmacro.h>
29#include <asm/signal.h> 25#include <asm/signal.h>
30#include <asm/obio.h> 26#include <asm/obio.h>
@@ -276,17 +272,18 @@ smp4m_ticker:
276 */ 272 */
277maybe_smp4m_msg: 273maybe_smp4m_msg:
278 GET_PROCESSOR4M_ID(o3) 274 GET_PROCESSOR4M_ID(o3)
279 set sun4m_interrupts, %l5 275 sethi %hi(sun4m_irq_percpu), %l5
280 ld [%l5], %o5 276 sll %o3, 2, %o3
277 or %l5, %lo(sun4m_irq_percpu), %o5
281 sethi %hi(0x40000000), %o2 278 sethi %hi(0x40000000), %o2
282 sll %o3, 12, %o3
283 ld [%o5 + %o3], %o1 279 ld [%o5 + %o3], %o1
284 andcc %o1, %o2, %g0 280 ld [%o1 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
281 andcc %o3, %o2, %g0
285 be,a smp4m_ticker 282 be,a smp4m_ticker
286 cmp %l7, 14 283 cmp %l7, 14
287 st %o2, [%o5 + 0x4] 284 st %o2, [%o1 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x40000000
288 WRITE_PAUSE 285 WRITE_PAUSE
289 ld [%o5], %g0 286 ld [%o1 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
290 WRITE_PAUSE 287 WRITE_PAUSE
291 or %l0, PSR_PIL, %l4 288 or %l0, PSR_PIL, %l4
292 wr %l4, 0x0, %psr 289 wr %l4, 0x0, %psr
@@ -304,16 +301,16 @@ linux_trap_ipi15_sun4m:
304 SAVE_ALL 301 SAVE_ALL
305 sethi %hi(0x80000000), %o2 302 sethi %hi(0x80000000), %o2
306 GET_PROCESSOR4M_ID(o0) 303 GET_PROCESSOR4M_ID(o0)
307 set sun4m_interrupts, %l5 304 sethi %hi(sun4m_irq_percpu), %l5
308 ld [%l5], %o5 305 or %l5, %lo(sun4m_irq_percpu), %o5
309 sll %o0, 12, %o0 306 sll %o0, 2, %o0
310 add %o5, %o0, %o5 307 ld [%o5 + %o0], %o5
311 ld [%o5], %o3 308 ld [%o5 + 0x00], %o3 ! sun4m_irq_percpu[cpu]->pending
312 andcc %o3, %o2, %g0 309 andcc %o3, %o2, %g0
313 be 1f ! Must be an NMI async memory error 310 be 1f ! Must be an NMI async memory error
314 st %o2, [%o5 + 4] 311 st %o2, [%o5 + 0x04] ! sun4m_irq_percpu[cpu]->clear=0x80000000
315 WRITE_PAUSE 312 WRITE_PAUSE
316 ld [%o5], %g0 313 ld [%o5 + 0x00], %g0 ! sun4m_irq_percpu[cpu]->pending
317 WRITE_PAUSE 314 WRITE_PAUSE
318 or %l0, PSR_PIL, %l4 315 or %l0, PSR_PIL, %l4
319 wr %l4, 0x0, %psr 316 wr %l4, 0x0, %psr
@@ -327,12 +324,11 @@ linux_trap_ipi15_sun4m:
3271: 3241:
328 /* NMI async memory error handling. */ 325 /* NMI async memory error handling. */
329 sethi %hi(0x80000000), %l4 326 sethi %hi(0x80000000), %l4
330 sethi %hi(0x4000), %o3 327 sethi %hi(sun4m_irq_global), %o5
331 sub %o5, %o0, %o5 328 ld [%o5 + %lo(sun4m_irq_global)], %l5
332 add %o5, %o3, %l5 329 st %l4, [%l5 + 0x0c] ! sun4m_irq_global->mask_set=0x80000000
333 st %l4, [%l5 + 0xc]
334 WRITE_PAUSE 330 WRITE_PAUSE
335 ld [%l5], %g0 331 ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
336 WRITE_PAUSE 332 WRITE_PAUSE
337 or %l0, PSR_PIL, %l4 333 or %l0, PSR_PIL, %l4
338 wr %l4, 0x0, %psr 334 wr %l4, 0x0, %psr
@@ -341,9 +337,9 @@ linux_trap_ipi15_sun4m:
341 WRITE_PAUSE 337 WRITE_PAUSE
342 call sun4m_nmi 338 call sun4m_nmi
343 nop 339 nop
344 st %l4, [%l5 + 0x8] 340 st %l4, [%l5 + 0x08] ! sun4m_irq_global->mask_clear=0x80000000
345 WRITE_PAUSE 341 WRITE_PAUSE
346 ld [%l5], %g0 342 ld [%l5 + 0x00], %g0 ! sun4m_irq_global->pending
347 WRITE_PAUSE 343 WRITE_PAUSE
348 RESTORE_ALL 344 RESTORE_ALL
349 345
@@ -775,11 +771,7 @@ vac_linesize_patch_32: subcc %l7, 32, %l7
775 * Ugly, but we cant use hardware flushing on the sun4 and we'd require 771 * Ugly, but we cant use hardware flushing on the sun4 and we'd require
776 * two instructions (Anton) 772 * two instructions (Anton)
777 */ 773 */
778#ifdef CONFIG_SUN4
779vac_hwflush_patch1_on: nop
780#else
781vac_hwflush_patch1_on: addcc %l7, -PAGE_SIZE, %l7 774vac_hwflush_patch1_on: addcc %l7, -PAGE_SIZE, %l7
782#endif
783 775
784vac_hwflush_patch2_on: sta %g0, [%l3 + %l7] ASI_HWFLUSHSEG 776vac_hwflush_patch2_on: sta %g0, [%l3 + %l7] ASI_HWFLUSHSEG
785 777
@@ -798,42 +790,10 @@ vac_hwflush_patch2_on: sta %g0, [%l3 + %l7] ASI_HWFLUSHSEG
798! %l7 = 1 for textfault 790! %l7 = 1 for textfault
799! We want error in %l5, vaddr in %l6 791! We want error in %l5, vaddr in %l6
800sun4c_fault: 792sun4c_fault:
801#ifdef CONFIG_SUN4
802 sethi %hi(sun4c_memerr_reg), %l4
803 ld [%l4+%lo(sun4c_memerr_reg)], %l4 ! memerr ctrl reg addr
804 ld [%l4], %l6 ! memerr ctrl reg
805 ld [%l4 + 4], %l5 ! memerr vaddr reg
806 andcc %l6, 0x80, %g0 ! check for error type
807 st %g0, [%l4 + 4] ! clear the error
808 be 0f ! normal error
809 sethi %hi(AC_BUS_ERROR), %l4 ! bus err reg addr
810
811 call prom_halt ! something weird happened
812 ! what exactly did happen?
813 ! what should we do here?
814
8150: or %l4, %lo(AC_BUS_ERROR), %l4 ! bus err reg addr
816 lduba [%l4] ASI_CONTROL, %l6 ! bus err reg
817
818 cmp %l7, 1 ! text fault?
819 be 1f ! yes
820 nop
821
822 ld [%l1], %l4 ! load instruction that caused fault
823 srl %l4, 21, %l4
824 andcc %l4, 1, %g0 ! store instruction?
825
826 be 1f ! no
827 sethi %hi(SUN4C_SYNC_BADWRITE), %l4 ! yep
828 ! %lo(SUN4C_SYNC_BADWRITE) = 0
829 or %l4, %l6, %l6 ! set write bit to emulate sun4c
8301:
831#else
832 sethi %hi(AC_SYNC_ERR), %l4 793 sethi %hi(AC_SYNC_ERR), %l4
833 add %l4, 0x4, %l6 ! AC_SYNC_VA in %l6 794 add %l4, 0x4, %l6 ! AC_SYNC_VA in %l6
834 lda [%l6] ASI_CONTROL, %l5 ! Address 795 lda [%l6] ASI_CONTROL, %l5 ! Address
835 lda [%l4] ASI_CONTROL, %l6 ! Error, retained for a bit 796 lda [%l4] ASI_CONTROL, %l6 ! Error, retained for a bit
836#endif
837 797
838 andn %l5, 0xfff, %l5 ! Encode all info into l7 798 andn %l5, 0xfff, %l5 ! Encode all info into l7
839 srl %l6, 14, %l4 799 srl %l6, 14, %l4
@@ -880,12 +840,7 @@ sun4c_fault:
880 or %l4, %lo(swapper_pg_dir), %l4 840 or %l4, %lo(swapper_pg_dir), %l4
881 sll %l6, 2, %l6 841 sll %l6, 2, %l6
882 ld [%l4 + %l6], %l4 842 ld [%l4 + %l6], %l4
883#ifdef CONFIG_SUN4
884 sethi %hi(PAGE_MASK), %l6
885 andcc %l4, %l6, %g0
886#else
887 andcc %l4, PAGE_MASK, %g0 843 andcc %l4, PAGE_MASK, %g0
888#endif
889 be sun4c_fault_fromuser 844 be sun4c_fault_fromuser
890 lduXa [%l5] ASI_SEGMAP, %l4 845 lduXa [%l5] ASI_SEGMAP, %l4
891 846
@@ -937,11 +892,7 @@ invalid_segment_patch1:
937 ld [%l6 + 0x08], %l3 ! tmp = entry->vaddr 892 ld [%l6 + 0x08], %l3 ! tmp = entry->vaddr
938 893
939 ! Flush segment from the cache. 894 ! Flush segment from the cache.
940#ifdef CONFIG_SUN4
941 sethi %hi((128 * 1024)), %l7
942#else
943 sethi %hi((64 * 1024)), %l7 895 sethi %hi((64 * 1024)), %l7
944#endif
9459: 8969:
946vac_hwflush_patch1: 897vac_hwflush_patch1:
947vac_linesize_patch: 898vac_linesize_patch:
@@ -1029,12 +980,7 @@ invalid_segment_patch2:
1029 or %l4, %lo(swapper_pg_dir), %l4 980 or %l4, %lo(swapper_pg_dir), %l4
1030 sll %l3, 2, %l3 981 sll %l3, 2, %l3
1031 ld [%l4 + %l3], %l4 982 ld [%l4 + %l3], %l4
1032#ifndef CONFIG_SUN4
1033 and %l4, PAGE_MASK, %l4 983 and %l4, PAGE_MASK, %l4
1034#else
1035 sethi %hi(PAGE_MASK), %l6
1036 and %l4, %l6, %l4
1037#endif
1038 984
1039 srl %l5, (PAGE_SHIFT - 2), %l6 985 srl %l5, (PAGE_SHIFT - 2), %l6
1040 and %l6, ((SUN4C_PTRS_PER_PTE - 1) << 2), %l6 986 and %l6, ((SUN4C_PTRS_PER_PTE - 1) << 2), %l6
diff --git a/arch/sparc/kernel/head.S b/arch/sparc/kernel/head.S
index 50d9a16af795..2d325fd84579 100644
--- a/arch/sparc/kernel/head.S
+++ b/arch/sparc/kernel/head.S
@@ -63,15 +63,9 @@ cputypvar_sun4m:
63 63
64 .align 4 64 .align 4
65 65
66#ifndef CONFIG_SUN4
67sun4_notsup: 66sun4_notsup:
68 .asciz "Sparc-Linux sun4 needs a specially compiled kernel, turn CONFIG_SUN4 on.\n\n" 67 .asciz "Sparc-Linux sun4 support does no longer exist.\n\n"
69 .align 4 68 .align 4
70#else
71sun4cdm_notsup:
72 .asciz "Kernel compiled with CONFIG_SUN4 cannot run on SUN4C/SUN4M/SUN4D\nTurn CONFIG_SUN4 off.\n\n"
73 .align 4
74#endif
75 69
76sun4e_notsup: 70sun4e_notsup:
77 .asciz "Sparc-Linux sun4e support does not exist\n\n" 71 .asciz "Sparc-Linux sun4e support does not exist\n\n"
@@ -780,15 +774,6 @@ execute_in_high_mem:
780 nop 774 nop
781 775
782found_version: 776found_version:
783#ifdef CONFIG_SUN4
784/* For people who try sun4 kernels, even if Configure.help advises them. */
785 ld [%g7 + 0x68], %o1
786 set sun4cdm_notsup, %o0
787 call %o1
788 nop
789 b halt_me
790 nop
791#endif
792/* Get the machine type via the mysterious romvec node operations. */ 777/* Get the machine type via the mysterious romvec node operations. */
793 778
794 add %g7, 0x1c, %l1 779 add %g7, 0x1c, %l1
@@ -1150,15 +1135,6 @@ sun4c_continue_boot:
1150 nop 1135 nop
1151 1136
1152sun4_init: 1137sun4_init:
1153#ifdef CONFIG_SUN4
1154/* There, happy now Adrian? */
1155 set cputypval, %o2 ! Let everyone know we
1156 set ' ', %o0 ! are a "sun4 " architecture
1157 stb %o0, [%o2 + 0x4]
1158
1159 b got_prop
1160 nop
1161#else
1162 sethi %hi(SUN4_PROM_VECTOR+0x84), %o1 1138 sethi %hi(SUN4_PROM_VECTOR+0x84), %o1
1163 ld [%o1 + %lo(SUN4_PROM_VECTOR+0x84)], %o1 1139 ld [%o1 + %lo(SUN4_PROM_VECTOR+0x84)], %o1
1164 set sun4_notsup, %o0 1140 set sun4_notsup, %o0
@@ -1170,7 +1146,7 @@ sun4_init:
1170 nop 1146 nop
11711: ba 1b ! Cannot exit into KMON 11471: ba 1b ! Cannot exit into KMON
1172 nop 1148 nop
1173#endif 1149
1174no_sun4e_here: 1150no_sun4e_here:
1175 ld [%g7 + 0x68], %o1 1151 ld [%g7 + 0x68], %o1
1176 set sun4e_notsup, %o0 1152 set sun4e_notsup, %o0
diff --git a/arch/sparc/kernel/idprom.c b/arch/sparc/kernel/idprom.c
index fc511f3c4c18..223a6582e1e2 100644
--- a/arch/sparc/kernel/idprom.c
+++ b/arch/sparc/kernel/idprom.c
@@ -12,10 +12,6 @@
12#include <asm/oplib.h> 12#include <asm/oplib.h>
13#include <asm/idprom.h> 13#include <asm/idprom.h>
14#include <asm/machines.h> /* Fun with Sun released architectures. */ 14#include <asm/machines.h> /* Fun with Sun released architectures. */
15#ifdef CONFIG_SUN4
16#include <asm/sun4paddr.h>
17extern void sun4setup(void);
18#endif
19 15
20struct idprom *idprom; 16struct idprom *idprom;
21static struct idprom idprom_buffer; 17static struct idprom idprom_buffer;
@@ -101,7 +97,4 @@ void __init idprom_init(void)
101 idprom->id_ethaddr[0], idprom->id_ethaddr[1], 97 idprom->id_ethaddr[0], idprom->id_ethaddr[1],
102 idprom->id_ethaddr[2], idprom->id_ethaddr[3], 98 idprom->id_ethaddr[2], idprom->id_ethaddr[3],
103 idprom->id_ethaddr[4], idprom->id_ethaddr[5]); 99 idprom->id_ethaddr[4], idprom->id_ethaddr[5]);
104#ifdef CONFIG_SUN4
105 sun4setup();
106#endif
107} 100}
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 2a8a847764d8..4f025b36934b 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -42,10 +42,13 @@
42#include <asm/vaddrs.h> 42#include <asm/vaddrs.h>
43#include <asm/oplib.h> 43#include <asm/oplib.h>
44#include <asm/prom.h> 44#include <asm/prom.h>
45#include <asm/sbus.h>
46#include <asm/page.h> 45#include <asm/page.h>
47#include <asm/pgalloc.h> 46#include <asm/pgalloc.h>
48#include <asm/dma.h> 47#include <asm/dma.h>
48#include <asm/iommu.h>
49#include <asm/io-unit.h>
50
51#include "dma.h"
49 52
50#define mmu_inval_dma_area(p, l) /* Anton pulled it out for 2.4.0-xx */ 53#define mmu_inval_dma_area(p, l) /* Anton pulled it out for 2.4.0-xx */
51 54
@@ -139,15 +142,6 @@ void iounmap(volatile void __iomem *virtual)
139 } 142 }
140} 143}
141 144
142/*
143 */
144void __iomem *sbus_ioremap(struct resource *phyres, unsigned long offset,
145 unsigned long size, char *name)
146{
147 return _sparc_alloc_io(phyres->flags & 0xF,
148 phyres->start + offset, size, name);
149}
150
151void __iomem *of_ioremap(struct resource *res, unsigned long offset, 145void __iomem *of_ioremap(struct resource *res, unsigned long offset,
152 unsigned long size, char *name) 146 unsigned long size, char *name)
153{ 147{
@@ -164,13 +158,6 @@ void of_iounmap(struct resource *res, void __iomem *base, unsigned long size)
164EXPORT_SYMBOL(of_iounmap); 158EXPORT_SYMBOL(of_iounmap);
165 159
166/* 160/*
167 */
168void sbus_iounmap(volatile void __iomem *addr, unsigned long size)
169{
170 iounmap(addr);
171}
172
173/*
174 * Meat of mapping 161 * Meat of mapping
175 */ 162 */
176static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys, 163static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
@@ -246,63 +233,19 @@ static void _sparc_free_io(struct resource *res)
246 233
247#ifdef CONFIG_SBUS 234#ifdef CONFIG_SBUS
248 235
249void sbus_set_sbus64(struct sbus_dev *sdev, int x) 236void sbus_set_sbus64(struct device *dev, int x)
250{ 237{
251 printk("sbus_set_sbus64: unsupported\n"); 238 printk("sbus_set_sbus64: unsupported\n");
252} 239}
253 240
254extern unsigned int sun4d_build_irq(struct sbus_dev *sdev, int irq);
255void __init sbus_fill_device_irq(struct sbus_dev *sdev)
256{
257 struct linux_prom_irqs irqs[PROMINTR_MAX];
258 int len;
259
260 len = prom_getproperty(sdev->prom_node, "intr",
261 (char *)irqs, sizeof(irqs));
262 if (len != -1) {
263 sdev->num_irqs = len / 8;
264 if (sdev->num_irqs == 0) {
265 sdev->irqs[0] = 0;
266 } else if (sparc_cpu_model == sun4d) {
267 for (len = 0; len < sdev->num_irqs; len++)
268 sdev->irqs[len] =
269 sun4d_build_irq(sdev, irqs[len].pri);
270 } else {
271 for (len = 0; len < sdev->num_irqs; len++)
272 sdev->irqs[len] = irqs[len].pri;
273 }
274 } else {
275 int interrupts[PROMINTR_MAX];
276
277 /* No "intr" node found-- check for "interrupts" node.
278 * This node contains SBus interrupt levels, not IPLs
279 * as in "intr", and no vector values. We convert
280 * SBus interrupt levels to PILs (platform specific).
281 */
282 len = prom_getproperty(sdev->prom_node, "interrupts",
283 (char *)interrupts, sizeof(interrupts));
284 if (len == -1) {
285 sdev->irqs[0] = 0;
286 sdev->num_irqs = 0;
287 } else {
288 sdev->num_irqs = len / sizeof(int);
289 for (len = 0; len < sdev->num_irqs; len++) {
290 sdev->irqs[len] =
291 sbint_to_irq(sdev, interrupts[len]);
292 }
293 }
294 }
295}
296
297/* 241/*
298 * Allocate a chunk of memory suitable for DMA. 242 * Allocate a chunk of memory suitable for DMA.
299 * Typically devices use them for control blocks. 243 * Typically devices use them for control blocks.
300 * CPU may access them without any explicit flushing. 244 * CPU may access them without any explicit flushing.
301 *
302 * XXX Some clever people know that sdev is not used and supply NULL. Watch.
303 */ 245 */
304void *sbus_alloc_consistent(struct sbus_dev *sdev, long len, u32 *dma_addrp) 246void *sbus_alloc_consistent(struct device *dev, long len, u32 *dma_addrp)
305{ 247{
248 struct of_device *op = to_of_device(dev);
306 unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK; 249 unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK;
307 unsigned long va; 250 unsigned long va;
308 struct resource *res; 251 struct resource *res;
@@ -336,13 +279,10 @@ void *sbus_alloc_consistent(struct sbus_dev *sdev, long len, u32 *dma_addrp)
336 * XXX That's where sdev would be used. Currently we load 279 * XXX That's where sdev would be used. Currently we load
337 * all iommu tables with the same translations. 280 * all iommu tables with the same translations.
338 */ 281 */
339 if (mmu_map_dma_area(dma_addrp, va, res->start, len_total) != 0) 282 if (mmu_map_dma_area(dev, dma_addrp, va, res->start, len_total) != 0)
340 goto err_noiommu; 283 goto err_noiommu;
341 284
342 /* Set the resource name, if known. */ 285 res->name = op->node->name;
343 if (sdev) {
344 res->name = sdev->prom_name;
345 }
346 286
347 return (void *)(unsigned long)res->start; 287 return (void *)(unsigned long)res->start;
348 288
@@ -356,7 +296,7 @@ err_nopages:
356 return NULL; 296 return NULL;
357} 297}
358 298
359void sbus_free_consistent(struct sbus_dev *sdev, long n, void *p, u32 ba) 299void sbus_free_consistent(struct device *dev, long n, void *p, u32 ba)
360{ 300{
361 struct resource *res; 301 struct resource *res;
362 struct page *pgv; 302 struct page *pgv;
@@ -383,8 +323,8 @@ void sbus_free_consistent(struct sbus_dev *sdev, long n, void *p, u32 ba)
383 kfree(res); 323 kfree(res);
384 324
385 /* mmu_inval_dma_area(va, n); */ /* it's consistent, isn't it */ 325 /* mmu_inval_dma_area(va, n); */ /* it's consistent, isn't it */
386 pgv = mmu_translate_dvma(ba); 326 pgv = virt_to_page(p);
387 mmu_unmap_dma_area(ba, n); 327 mmu_unmap_dma_area(dev, ba, n);
388 328
389 __free_pages(pgv, get_order(n)); 329 __free_pages(pgv, get_order(n));
390} 330}
@@ -394,7 +334,7 @@ void sbus_free_consistent(struct sbus_dev *sdev, long n, void *p, u32 ba)
394 * CPU view of this memory may be inconsistent with 334 * CPU view of this memory may be inconsistent with
395 * a device view and explicit flushing is necessary. 335 * a device view and explicit flushing is necessary.
396 */ 336 */
397dma_addr_t sbus_map_single(struct sbus_dev *sdev, void *va, size_t len, int direction) 337dma_addr_t sbus_map_single(struct device *dev, void *va, size_t len, int direction)
398{ 338{
399 /* XXX why are some lengths signed, others unsigned? */ 339 /* XXX why are some lengths signed, others unsigned? */
400 if (len <= 0) { 340 if (len <= 0) {
@@ -404,17 +344,17 @@ dma_addr_t sbus_map_single(struct sbus_dev *sdev, void *va, size_t len, int dire
404 if (len > 256*1024) { /* __get_free_pages() limit */ 344 if (len > 256*1024) { /* __get_free_pages() limit */
405 return 0; 345 return 0;
406 } 346 }
407 return mmu_get_scsi_one(va, len, sdev->bus); 347 return mmu_get_scsi_one(dev, va, len);
408} 348}
409 349
410void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t ba, size_t n, int direction) 350void sbus_unmap_single(struct device *dev, dma_addr_t ba, size_t n, int direction)
411{ 351{
412 mmu_release_scsi_one(ba, n, sdev->bus); 352 mmu_release_scsi_one(dev, ba, n);
413} 353}
414 354
415int sbus_map_sg(struct sbus_dev *sdev, struct scatterlist *sg, int n, int direction) 355int sbus_map_sg(struct device *dev, struct scatterlist *sg, int n, int direction)
416{ 356{
417 mmu_get_scsi_sgl(sg, n, sdev->bus); 357 mmu_get_scsi_sgl(dev, sg, n);
418 358
419 /* 359 /*
420 * XXX sparc64 can return a partial length here. sun4c should do this 360 * XXX sparc64 can return a partial length here. sun4c should do this
@@ -423,145 +363,28 @@ int sbus_map_sg(struct sbus_dev *sdev, struct scatterlist *sg, int n, int direct
423 return n; 363 return n;
424} 364}
425 365
426void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sg, int n, int direction) 366void sbus_unmap_sg(struct device *dev, struct scatterlist *sg, int n, int direction)
427{
428 mmu_release_scsi_sgl(sg, n, sdev->bus);
429}
430
431/*
432 */
433void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev, dma_addr_t ba, size_t size, int direction)
434{
435#if 0
436 unsigned long va;
437 struct resource *res;
438
439 /* We do not need the resource, just print a message if invalid. */
440 res = _sparc_find_resource(&_sparc_dvma, ba);
441 if (res == NULL)
442 panic("sbus_dma_sync_single: 0x%x\n", ba);
443
444 va = page_address(mmu_translate_dvma(ba)); /* XXX higmem */
445 /*
446 * XXX This bogosity will be fixed with the iommu rewrite coming soon
447 * to a kernel near you. - Anton
448 */
449 /* mmu_inval_dma_area(va, (size + PAGE_SIZE-1) & PAGE_MASK); */
450#endif
451}
452
453void sbus_dma_sync_single_for_device(struct sbus_dev *sdev, dma_addr_t ba, size_t size, int direction)
454{ 367{
455#if 0 368 mmu_release_scsi_sgl(dev, sg, n);
456 unsigned long va;
457 struct resource *res;
458
459 /* We do not need the resource, just print a message if invalid. */
460 res = _sparc_find_resource(&_sparc_dvma, ba);
461 if (res == NULL)
462 panic("sbus_dma_sync_single: 0x%x\n", ba);
463
464 va = page_address(mmu_translate_dvma(ba)); /* XXX higmem */
465 /*
466 * XXX This bogosity will be fixed with the iommu rewrite coming soon
467 * to a kernel near you. - Anton
468 */
469 /* mmu_inval_dma_area(va, (size + PAGE_SIZE-1) & PAGE_MASK); */
470#endif
471} 369}
472 370
473void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev, struct scatterlist *sg, int n, int direction) 371void sbus_dma_sync_single_for_cpu(struct device *dev, dma_addr_t ba, size_t size, int direction)
474{ 372{
475 printk("sbus_dma_sync_sg_for_cpu: not implemented yet\n");
476} 373}
477 374
478void sbus_dma_sync_sg_for_device(struct sbus_dev *sdev, struct scatterlist *sg, int n, int direction) 375void sbus_dma_sync_single_for_device(struct device *dev, dma_addr_t ba, size_t size, int direction)
479{ 376{
480 printk("sbus_dma_sync_sg_for_device: not implemented yet\n");
481}
482
483/* Support code for sbus_init(). */
484/*
485 * XXX This functions appears to be a distorted version of
486 * prom_sbus_ranges_init(), with all sun4d stuff cut away.
487 * Ask DaveM what is going on here, how is sun4d supposed to work... XXX
488 */
489/* added back sun4d patch from Thomas Bogendoerfer - should be OK (crn) */
490void __init sbus_arch_bus_ranges_init(struct device_node *pn, struct sbus_bus *sbus)
491{
492 int parent_node = pn->node;
493
494 if (sparc_cpu_model == sun4d) {
495 struct linux_prom_ranges iounit_ranges[PROMREG_MAX];
496 int num_iounit_ranges, len;
497
498 len = prom_getproperty(parent_node, "ranges",
499 (char *) iounit_ranges,
500 sizeof (iounit_ranges));
501 if (len != -1) {
502 num_iounit_ranges =
503 (len / sizeof(struct linux_prom_ranges));
504 prom_adjust_ranges(sbus->sbus_ranges,
505 sbus->num_sbus_ranges,
506 iounit_ranges, num_iounit_ranges);
507 }
508 }
509} 377}
510 378
511void __init sbus_setup_iommu(struct sbus_bus *sbus, struct device_node *dp) 379static int __init sparc_register_ioport(void)
512{
513#ifndef CONFIG_SUN4
514 struct device_node *parent = dp->parent;
515
516 if (sparc_cpu_model != sun4d &&
517 parent != NULL &&
518 !strcmp(parent->name, "iommu")) {
519 extern void iommu_init(int iommu_node, struct sbus_bus *sbus);
520
521 iommu_init(parent->node, sbus);
522 }
523
524 if (sparc_cpu_model == sun4d) {
525 extern void iounit_init(int sbi_node, int iounit_node,
526 struct sbus_bus *sbus);
527
528 iounit_init(dp->node, parent->node, sbus);
529 }
530#endif
531}
532
533void __init sbus_setup_arch_props(struct sbus_bus *sbus, struct device_node *dp)
534{
535 if (sparc_cpu_model == sun4d) {
536 struct device_node *parent = dp->parent;
537
538 sbus->devid = of_getintprop_default(parent, "device-id", 0);
539 sbus->board = of_getintprop_default(parent, "board#", 0);
540 }
541}
542
543int __init sbus_arch_preinit(void)
544{ 380{
545 register_proc_sparc_ioport(); 381 register_proc_sparc_ioport();
546 382
547#ifdef CONFIG_SUN4
548 {
549 extern void sun4_dvma_init(void);
550 sun4_dvma_init();
551 }
552 return 1;
553#else
554 return 0; 383 return 0;
555#endif
556} 384}
557 385
558void __init sbus_arch_postinit(void) 386arch_initcall(sparc_register_ioport);
559{ 387
560 if (sparc_cpu_model == sun4d) {
561 extern void sun4d_init_sbi_irq(void);
562 sun4d_init_sbi_irq();
563 }
564}
565#endif /* CONFIG_SBUS */ 388#endif /* CONFIG_SBUS */
566 389
567#ifdef CONFIG_PCI 390#ifdef CONFIG_PCI
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
index 32ef3ebd0a88..db7513881530 100644
--- a/arch/sparc/kernel/irq.h
+++ b/arch/sparc/kernel/irq.h
@@ -13,7 +13,6 @@ BTFIXUPDEF_CALL(void, enable_irq, unsigned int)
13BTFIXUPDEF_CALL(void, disable_pil_irq, unsigned int) 13BTFIXUPDEF_CALL(void, disable_pil_irq, unsigned int)
14BTFIXUPDEF_CALL(void, enable_pil_irq, unsigned int) 14BTFIXUPDEF_CALL(void, enable_pil_irq, unsigned int)
15BTFIXUPDEF_CALL(void, clear_clock_irq, void) 15BTFIXUPDEF_CALL(void, clear_clock_irq, void)
16BTFIXUPDEF_CALL(void, clear_profile_irq, int)
17BTFIXUPDEF_CALL(void, load_profile_irq, int, unsigned int) 16BTFIXUPDEF_CALL(void, load_profile_irq, int, unsigned int)
18 17
19static inline void __disable_irq(unsigned int irq) 18static inline void __disable_irq(unsigned int irq)
@@ -41,11 +40,6 @@ static inline void clear_clock_irq(void)
41 BTFIXUP_CALL(clear_clock_irq)(); 40 BTFIXUP_CALL(clear_clock_irq)();
42} 41}
43 42
44static inline void clear_profile_irq(int irq)
45{
46 BTFIXUP_CALL(clear_profile_irq)(irq);
47}
48
49static inline void load_profile_irq(int cpu, int limit) 43static inline void load_profile_irq(int cpu, int limit)
50{ 44{
51 BTFIXUP_CALL(load_profile_irq)(cpu, limit); 45 BTFIXUP_CALL(load_profile_irq)(cpu, limit);
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c
index f58c537446a8..0837bd52e28f 100644
--- a/arch/sparc/kernel/of_device.c
+++ b/arch/sparc/kernel/of_device.c
@@ -29,15 +29,38 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
29} 29}
30EXPORT_SYMBOL(of_find_device_by_node); 30EXPORT_SYMBOL(of_find_device_by_node);
31 31
32#ifdef CONFIG_PCI 32unsigned int irq_of_parse_and_map(struct device_node *node, int index)
33struct bus_type ebus_bus_type; 33{
34EXPORT_SYMBOL(ebus_bus_type); 34 struct of_device *op = of_find_device_by_node(node);
35#endif 35
36 if (!op || index >= op->num_irqs)
37 return 0;
38
39 return op->irqs[index];
40}
41EXPORT_SYMBOL(irq_of_parse_and_map);
42
43/* Take the archdata values for IOMMU, STC, and HOSTDATA found in
44 * BUS and propagate to all child of_device objects.
45 */
46void of_propagate_archdata(struct of_device *bus)
47{
48 struct dev_archdata *bus_sd = &bus->dev.archdata;
49 struct device_node *bus_dp = bus->node;
50 struct device_node *dp;
51
52 for (dp = bus_dp->child; dp; dp = dp->sibling) {
53 struct of_device *op = of_find_device_by_node(dp);
36 54
37#ifdef CONFIG_SBUS 55 op->dev.archdata.iommu = bus_sd->iommu;
38struct bus_type sbus_bus_type; 56 op->dev.archdata.stc = bus_sd->stc;
39EXPORT_SYMBOL(sbus_bus_type); 57 op->dev.archdata.host_controller = bus_sd->host_controller;
40#endif 58 op->dev.archdata.numa_node = bus_sd->numa_node;
59
60 if (dp->child)
61 of_propagate_archdata(op);
62 }
63}
41 64
42struct bus_type of_platform_bus_type; 65struct bus_type of_platform_bus_type;
43EXPORT_SYMBOL(of_platform_bus_type); 66EXPORT_SYMBOL(of_platform_bus_type);
@@ -327,6 +350,27 @@ static int __init build_one_resource(struct device_node *parent,
327 return 1; 350 return 1;
328} 351}
329 352
353static int __init use_1to1_mapping(struct device_node *pp)
354{
355 /* If we have a ranges property in the parent, use it. */
356 if (of_find_property(pp, "ranges", NULL) != NULL)
357 return 0;
358
359 /* Some SBUS devices use intermediate nodes to express
360 * hierarchy within the device itself. These aren't
361 * real bus nodes, and don't have a 'ranges' property.
362 * But, we should still pass the translation work up
363 * to the SBUS itself.
364 */
365 if (!strcmp(pp->name, "dma") ||
366 !strcmp(pp->name, "espdma") ||
367 !strcmp(pp->name, "ledma") ||
368 !strcmp(pp->name, "lebuffer"))
369 return 0;
370
371 return 1;
372}
373
330static int of_resource_verbose; 374static int of_resource_verbose;
331 375
332static void __init build_device_resources(struct of_device *op, 376static void __init build_device_resources(struct of_device *op,
@@ -373,10 +417,7 @@ static void __init build_device_resources(struct of_device *op,
373 417
374 flags = bus->get_flags(reg, 0); 418 flags = bus->get_flags(reg, 0);
375 419
376 /* If the immediate parent has no ranges property to apply, 420 if (use_1to1_mapping(pp)) {
377 * just use a 1<->1 mapping.
378 */
379 if (of_find_property(pp, "ranges", NULL) == NULL) {
380 result = of_read_addr(addr, na); 421 result = of_read_addr(addr, na);
381 goto build_res; 422 goto build_res;
382 } 423 }
@@ -565,15 +606,6 @@ static int __init of_bus_driver_init(void)
565 int err; 606 int err;
566 607
567 err = of_bus_type_init(&of_platform_bus_type, "of"); 608 err = of_bus_type_init(&of_platform_bus_type, "of");
568#ifdef CONFIG_PCI
569 if (!err)
570 err = of_bus_type_init(&ebus_bus_type, "ebus");
571#endif
572#ifdef CONFIG_SBUS
573 if (!err)
574 err = of_bus_type_init(&sbus_bus_type, "sbus");
575#endif
576
577 if (!err) 609 if (!err)
578 scan_of_devices(); 610 scan_of_devices();
579 611
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index a6a6f9823370..462584e55fba 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -17,8 +17,6 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/jiffies.h> 18#include <linux/jiffies.h>
19 19
20#include <asm/ebus.h>
21#include <asm/sbus.h> /* for sanity check... */
22#include <asm/swift.h> /* for cache flushing. */ 20#include <asm/swift.h> /* for cache flushing. */
23#include <asm/io.h> 21#include <asm/io.h>
24 22
@@ -430,7 +428,6 @@ static int __init pcic_init(void)
430 428
431 pcic_pbm_scan_bus(pcic); 429 pcic_pbm_scan_bus(pcic);
432 430
433 ebus_init();
434 return 0; 431 return 0;
435} 432}
436 433
@@ -493,10 +490,6 @@ static void pcic_map_pci_device(struct linux_pcic *pcic,
493 * do ioremap() before accessing PC-style I/O, 490 * do ioremap() before accessing PC-style I/O,
494 * we supply virtual, ready to access address. 491 * we supply virtual, ready to access address.
495 * 492 *
496 * Ebus devices do not come here even if
497 * CheerIO makes a similar conversion.
498 * See ebus.c for details.
499 *
500 * Note that request_region() 493 * Note that request_region()
501 * works for these devices. 494 * works for these devices.
502 * 495 *
@@ -677,7 +670,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
677} 670}
678 671
679/* 672/*
680 * pcic_pin_to_irq() is exported to ebus.c. 673 * pcic_pin_to_irq() is exported to bus probing code
681 */ 674 */
682unsigned int 675unsigned int
683pcic_pin_to_irq(unsigned int pin, const char *name) 676pcic_pin_to_irq(unsigned int pin, const char *name)
@@ -904,11 +897,6 @@ static void pcic_enable_irq(unsigned int irq_nr)
904 local_irq_restore(flags); 897 local_irq_restore(flags);
905} 898}
906 899
907static void pcic_clear_profile_irq(int cpu)
908{
909 printk("PCIC: unimplemented code: FILE=%s LINE=%d", __FILE__, __LINE__);
910}
911
912static void pcic_load_profile_irq(int cpu, unsigned int limit) 900static void pcic_load_profile_irq(int cpu, unsigned int limit)
913{ 901{
914 printk("PCIC: unimplemented code: FILE=%s LINE=%d", __FILE__, __LINE__); 902 printk("PCIC: unimplemented code: FILE=%s LINE=%d", __FILE__, __LINE__);
@@ -934,7 +922,6 @@ void __init sun4m_pci_init_IRQ(void)
934 BTFIXUPSET_CALL(enable_pil_irq, pcic_enable_pil_irq, BTFIXUPCALL_NORM); 922 BTFIXUPSET_CALL(enable_pil_irq, pcic_enable_pil_irq, BTFIXUPCALL_NORM);
935 BTFIXUPSET_CALL(disable_pil_irq, pcic_disable_pil_irq, BTFIXUPCALL_NORM); 923 BTFIXUPSET_CALL(disable_pil_irq, pcic_disable_pil_irq, BTFIXUPCALL_NORM);
936 BTFIXUPSET_CALL(clear_clock_irq, pcic_clear_clock_irq, BTFIXUPCALL_NORM); 924 BTFIXUPSET_CALL(clear_clock_irq, pcic_clear_clock_irq, BTFIXUPCALL_NORM);
937 BTFIXUPSET_CALL(clear_profile_irq, pcic_clear_profile_irq, BTFIXUPCALL_NORM);
938 BTFIXUPSET_CALL(load_profile_irq, pcic_load_profile_irq, BTFIXUPCALL_NORM); 925 BTFIXUPSET_CALL(load_profile_irq, pcic_load_profile_irq, BTFIXUPCALL_NORM);
939} 926}
940 927
diff --git a/arch/sparc/kernel/pmc.c b/arch/sparc/kernel/pmc.c
index 7eca8871ff47..2afcfab4f11c 100644
--- a/arch/sparc/kernel/pmc.c
+++ b/arch/sparc/kernel/pmc.c
@@ -8,11 +8,11 @@
8#include <linux/fs.h> 8#include <linux/fs.h>
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/miscdevice.h>
12#include <linux/pm.h> 11#include <linux/pm.h>
12#include <linux/of.h>
13#include <linux/of_device.h>
13 14
14#include <asm/io.h> 15#include <asm/io.h>
15#include <asm/sbus.h>
16#include <asm/oplib.h> 16#include <asm/oplib.h>
17#include <asm/uaccess.h> 17#include <asm/uaccess.h>
18#include <asm/auxio.h> 18#include <asm/auxio.h>
@@ -23,17 +23,15 @@
23 * #define PMC_NO_IDLE 23 * #define PMC_NO_IDLE
24 */ 24 */
25 25
26#define PMC_MINOR MISC_DYNAMIC_MINOR
27#define PMC_OBPNAME "SUNW,pmc" 26#define PMC_OBPNAME "SUNW,pmc"
28#define PMC_DEVNAME "pmc" 27#define PMC_DEVNAME "pmc"
29 28
30#define PMC_IDLE_REG 0x00 29#define PMC_IDLE_REG 0x00
31#define PMC_IDLE_ON 0x01 30#define PMC_IDLE_ON 0x01
32 31
33volatile static u8 __iomem *regs; 32static u8 __iomem *regs;
34static int pmc_regsize;
35 33
36#define pmc_readb(offs) (sbus_readb(regs+offs)) 34#define pmc_readb(offs) (sbus_readb(regs+offs))
37#define pmc_writeb(val, offs) (sbus_writeb(val, regs+offs)) 35#define pmc_writeb(val, offs) (sbus_writeb(val, regs+offs))
38 36
39/* 37/*
@@ -53,31 +51,11 @@ void pmc_swift_idle(void)
53#endif 51#endif
54} 52}
55 53
56static inline void pmc_free(void) 54static int __devinit pmc_probe(struct of_device *op,
55 const struct of_device_id *match)
57{ 56{
58 sbus_iounmap(regs, pmc_regsize); 57 regs = of_ioremap(&op->resource[0], 0,
59} 58 resource_size(&op->resource[0]), PMC_OBPNAME);
60
61static int __init pmc_probe(void)
62{
63 struct sbus_bus *sbus = NULL;
64 struct sbus_dev *sdev = NULL;
65 for_each_sbus(sbus) {
66 for_each_sbusdev(sdev, sbus) {
67 if (!strcmp(sdev->prom_name, PMC_OBPNAME)) {
68 goto sbus_done;
69 }
70 }
71 }
72
73sbus_done:
74 if (!sdev) {
75 return -ENODEV;
76 }
77
78 pmc_regsize = sdev->reg_addrs[0].reg_size;
79 regs = sbus_ioremap(&sdev->resource[0], 0,
80 pmc_regsize, PMC_OBPNAME);
81 if (!regs) { 59 if (!regs) {
82 printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME); 60 printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME);
83 return -ENODEV; 61 return -ENODEV;
@@ -92,8 +70,27 @@ sbus_done:
92 return 0; 70 return 0;
93} 71}
94 72
73static struct of_device_id __initdata pmc_match[] = {
74 {
75 .name = PMC_OBPNAME,
76 },
77 {},
78};
79MODULE_DEVICE_TABLE(of, pmc_match);
80
81static struct of_platform_driver pmc_driver = {
82 .name = "pmc",
83 .match_table = pmc_match,
84 .probe = pmc_probe,
85};
86
87static int __init pmc_init(void)
88{
89 return of_register_driver(&pmc_driver, &of_bus_type);
90}
91
95/* This driver is not critical to the boot process 92/* This driver is not critical to the boot process
96 * and is easiest to ioremap when SBus is already 93 * and is easiest to ioremap when SBus is already
97 * initialized, so we install ourselves thusly: 94 * initialized, so we install ourselves thusly:
98 */ 95 */
99__initcall(pmc_probe); 96__initcall(pmc_init);
diff --git a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c
index 4bb430940a61..e8c43ffe317e 100644
--- a/arch/sparc/kernel/process.c
+++ b/arch/sparc/kernel/process.c
@@ -75,7 +75,7 @@ void cpu_idle(void)
75{ 75{
76 /* endless idle loop with no priority at all */ 76 /* endless idle loop with no priority at all */
77 for (;;) { 77 for (;;) {
78 if (ARCH_SUN4C_SUN4) { 78 if (ARCH_SUN4C) {
79 static int count = HZ; 79 static int count = HZ;
80 static unsigned long last_jiffies; 80 static unsigned long last_jiffies;
81 static unsigned long last_faults; 81 static unsigned long last_faults;
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index cd4fb79aa3a8..eee5efcfe50e 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -54,6 +54,9 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
54} 54}
55EXPORT_SYMBOL(of_getintprop_default); 55EXPORT_SYMBOL(of_getintprop_default);
56 56
57DEFINE_MUTEX(of_set_property_mutex);
58EXPORT_SYMBOL(of_set_property_mutex);
59
57int of_set_property(struct device_node *dp, const char *name, void *val, int len) 60int of_set_property(struct device_node *dp, const char *name, void *val, int len)
58{ 61{
59 struct property **prevp; 62 struct property **prevp;
@@ -77,7 +80,10 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
77 void *old_val = prop->value; 80 void *old_val = prop->value;
78 int ret; 81 int ret;
79 82
83 mutex_lock(&of_set_property_mutex);
80 ret = prom_setprop(dp->node, (char *) name, val, len); 84 ret = prom_setprop(dp->node, (char *) name, val, len);
85 mutex_unlock(&of_set_property_mutex);
86
81 err = -EINVAL; 87 err = -EINVAL;
82 if (ret >= 0) { 88 if (ret >= 0) {
83 prop->value = new_val; 89 prop->value = new_val;
@@ -436,7 +442,6 @@ static void __init of_console_init(void)
436 442
437 switch (prom_vers) { 443 switch (prom_vers) {
438 case PROM_V0: 444 case PROM_V0:
439 case PROM_SUN4:
440 skip = 0; 445 skip = 0;
441 switch (*romvec->pv_stdout) { 446 switch (*romvec->pv_stdout) {
442 case PROMDEV_SCREEN: 447 case PROMDEV_SCREEN:
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 9e451b21202e..24fe3078bd4b 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -213,23 +213,25 @@ void __init setup_arch(char **cmdline_p)
213 /* Initialize PROM console and command line. */ 213 /* Initialize PROM console and command line. */
214 *cmdline_p = prom_getbootargs(); 214 *cmdline_p = prom_getbootargs();
215 strcpy(boot_command_line, *cmdline_p); 215 strcpy(boot_command_line, *cmdline_p);
216 parse_early_param();
216 217
217 /* Set sparc_cpu_model */ 218 /* Set sparc_cpu_model */
218 sparc_cpu_model = sun_unknown; 219 sparc_cpu_model = sun_unknown;
219 if(!strcmp(&cputypval,"sun4 ")) { sparc_cpu_model=sun4; } 220 if (!strcmp(&cputypval,"sun4 "))
220 if(!strcmp(&cputypval,"sun4c")) { sparc_cpu_model=sun4c; } 221 sparc_cpu_model = sun4;
221 if(!strcmp(&cputypval,"sun4m")) { sparc_cpu_model=sun4m; } 222 if (!strcmp(&cputypval,"sun4c"))
222 if(!strcmp(&cputypval,"sun4s")) { sparc_cpu_model=sun4m; } /* CP-1200 with PROM 2.30 -E */ 223 sparc_cpu_model = sun4c;
223 if(!strcmp(&cputypval,"sun4d")) { sparc_cpu_model=sun4d; } 224 if (!strcmp(&cputypval,"sun4m"))
224 if(!strcmp(&cputypval,"sun4e")) { sparc_cpu_model=sun4e; } 225 sparc_cpu_model = sun4m;
225 if(!strcmp(&cputypval,"sun4u")) { sparc_cpu_model=sun4u; } 226 if (!strcmp(&cputypval,"sun4s"))
226 227 sparc_cpu_model = sun4m; /* CP-1200 with PROM 2.30 -E */
227#ifdef CONFIG_SUN4 228 if (!strcmp(&cputypval,"sun4d"))
228 if (sparc_cpu_model != sun4) { 229 sparc_cpu_model = sun4d;
229 prom_printf("This kernel is for Sun4 architecture only.\n"); 230 if (!strcmp(&cputypval,"sun4e"))
230 prom_halt(); 231 sparc_cpu_model = sun4e;
231 } 232 if (!strcmp(&cputypval,"sun4u"))
232#endif 233 sparc_cpu_model = sun4u;
234
233 printk("ARCH: "); 235 printk("ARCH: ");
234 switch(sparc_cpu_model) { 236 switch(sparc_cpu_model) {
235 case sun4: 237 case sun4:
@@ -263,7 +265,7 @@ void __init setup_arch(char **cmdline_p)
263 boot_flags_init(*cmdline_p); 265 boot_flags_init(*cmdline_p);
264 266
265 idprom_init(); 267 idprom_init();
266 if (ARCH_SUN4C_SUN4) 268 if (ARCH_SUN4C)
267 sun4c_probe_vac(); 269 sun4c_probe_vac();
268 load_mmu(); 270 load_mmu();
269 271
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index b23cea5ca5d1..b0dfff848653 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -38,17 +38,12 @@
38#include <asm/idprom.h> 38#include <asm/idprom.h>
39#include <asm/head.h> 39#include <asm/head.h>
40#include <asm/smp.h> 40#include <asm/smp.h>
41#include <asm/mostek.h>
42#include <asm/ptrace.h> 41#include <asm/ptrace.h>
43#include <asm/uaccess.h> 42#include <asm/uaccess.h>
44#include <asm/checksum.h> 43#include <asm/checksum.h>
45#ifdef CONFIG_SBUS 44#ifdef CONFIG_SBUS
46#include <asm/sbus.h>
47#include <asm/dma.h> 45#include <asm/dma.h>
48#endif 46#endif
49#ifdef CONFIG_PCI
50#include <asm/ebus.h>
51#endif
52#include <asm/io-unit.h> 47#include <asm/io-unit.h>
53#include <asm/bug.h> 48#include <asm/bug.h>
54 49
@@ -127,16 +122,11 @@ EXPORT_SYMBOL(phys_cpu_present_map);
127EXPORT_SYMBOL(__udelay); 122EXPORT_SYMBOL(__udelay);
128EXPORT_SYMBOL(__ndelay); 123EXPORT_SYMBOL(__ndelay);
129EXPORT_SYMBOL(rtc_lock); 124EXPORT_SYMBOL(rtc_lock);
130EXPORT_SYMBOL(mostek_lock);
131EXPORT_SYMBOL(mstk48t02_regs);
132#ifdef CONFIG_SUN_AUXIO 125#ifdef CONFIG_SUN_AUXIO
133EXPORT_SYMBOL(set_auxio); 126EXPORT_SYMBOL(set_auxio);
134EXPORT_SYMBOL(get_auxio); 127EXPORT_SYMBOL(get_auxio);
135#endif 128#endif
136EXPORT_SYMBOL(io_remap_pfn_range); 129EXPORT_SYMBOL(io_remap_pfn_range);
137 /* P3: iounit_xxx may be needed, sun4d users */
138/* EXPORT_SYMBOL(iounit_map_dma_init); */
139/* EXPORT_SYMBOL(iounit_map_dma_page); */
140 130
141#ifndef CONFIG_SMP 131#ifndef CONFIG_SMP
142EXPORT_SYMBOL(BTFIXUP_CALL(___xchg32)); 132EXPORT_SYMBOL(BTFIXUP_CALL(___xchg32));
@@ -153,24 +143,9 @@ EXPORT_SYMBOL(BTFIXUP_CALL(mmu_release_scsi_one));
153EXPORT_SYMBOL(BTFIXUP_CALL(pgprot_noncached)); 143EXPORT_SYMBOL(BTFIXUP_CALL(pgprot_noncached));
154 144
155#ifdef CONFIG_SBUS 145#ifdef CONFIG_SBUS
156EXPORT_SYMBOL(sbus_root);
157EXPORT_SYMBOL(dma_chain);
158EXPORT_SYMBOL(sbus_set_sbus64); 146EXPORT_SYMBOL(sbus_set_sbus64);
159EXPORT_SYMBOL(sbus_alloc_consistent);
160EXPORT_SYMBOL(sbus_free_consistent);
161EXPORT_SYMBOL(sbus_map_single);
162EXPORT_SYMBOL(sbus_unmap_single);
163EXPORT_SYMBOL(sbus_map_sg);
164EXPORT_SYMBOL(sbus_unmap_sg);
165EXPORT_SYMBOL(sbus_dma_sync_single_for_cpu);
166EXPORT_SYMBOL(sbus_dma_sync_single_for_device);
167EXPORT_SYMBOL(sbus_dma_sync_sg_for_cpu);
168EXPORT_SYMBOL(sbus_dma_sync_sg_for_device);
169EXPORT_SYMBOL(sbus_iounmap);
170EXPORT_SYMBOL(sbus_ioremap);
171#endif 147#endif
172#ifdef CONFIG_PCI 148#ifdef CONFIG_PCI
173EXPORT_SYMBOL(ebus_chain);
174EXPORT_SYMBOL(insb); 149EXPORT_SYMBOL(insb);
175EXPORT_SYMBOL(outsb); 150EXPORT_SYMBOL(outsb);
176EXPORT_SYMBOL(insw); 151EXPORT_SYMBOL(insw);
diff --git a/arch/sparc/kernel/sun4c_irq.c b/arch/sparc/kernel/sun4c_irq.c
index 340fc395fe2d..5dc8a5769489 100644
--- a/arch/sparc/kernel/sun4c_irq.c
+++ b/arch/sparc/kernel/sun4c_irq.c
@@ -18,6 +18,8 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/of.h>
22#include <linux/of_device.h>
21#include "irq.h" 23#include "irq.h"
22 24
23#include <asm/ptrace.h> 25#include <asm/ptrace.h>
@@ -31,15 +33,8 @@
31#include <asm/traps.h> 33#include <asm/traps.h>
32#include <asm/irq.h> 34#include <asm/irq.h>
33#include <asm/io.h> 35#include <asm/io.h>
34#include <asm/sun4paddr.h>
35#include <asm/idprom.h> 36#include <asm/idprom.h>
36#include <asm/machines.h> 37#include <asm/machines.h>
37#include <asm/sbus.h>
38
39#if 0
40static struct resource sun4c_timer_eb = { "sun4c_timer" };
41static struct resource sun4c_intr_eb = { "sun4c_intr" };
42#endif
43 38
44/* 39/*
45 * Bit field defines for the interrupt registers on various 40 * Bit field defines for the interrupt registers on various
@@ -64,19 +59,7 @@ static struct resource sun4c_intr_eb = { "sun4c_intr" };
64 * 59 *
65 * so don't go making it static, like I tried. sigh. 60 * so don't go making it static, like I tried. sigh.
66 */ 61 */
67unsigned char *interrupt_enable = NULL; 62unsigned char __iomem *interrupt_enable = NULL;
68
69static int sun4c_pil_map[] = { 0, 1, 2, 3, 5, 7, 8, 9 };
70
71static unsigned int sun4c_sbint_to_irq(struct sbus_dev *sdev,
72 unsigned int sbint)
73{
74 if (sbint >= sizeof(sun4c_pil_map)) {
75 printk(KERN_ERR "%s: bogus SBINT %d\n", sdev->prom_name, sbint);
76 BUG();
77 }
78 return sun4c_pil_map[sbint];
79}
80 63
81static void sun4c_disable_irq(unsigned int irq_nr) 64static void sun4c_disable_irq(unsigned int irq_nr)
82{ 65{
@@ -85,7 +68,7 @@ static void sun4c_disable_irq(unsigned int irq_nr)
85 68
86 local_irq_save(flags); 69 local_irq_save(flags);
87 irq_nr &= (NR_IRQS - 1); 70 irq_nr &= (NR_IRQS - 1);
88 current_mask = *interrupt_enable; 71 current_mask = sbus_readb(interrupt_enable);
89 switch(irq_nr) { 72 switch(irq_nr) {
90 case 1: 73 case 1:
91 new_mask = ((current_mask) & (~(SUN4C_INT_E1))); 74 new_mask = ((current_mask) & (~(SUN4C_INT_E1)));
@@ -103,7 +86,7 @@ static void sun4c_disable_irq(unsigned int irq_nr)
103 local_irq_restore(flags); 86 local_irq_restore(flags);
104 return; 87 return;
105 } 88 }
106 *interrupt_enable = new_mask; 89 sbus_writeb(new_mask, interrupt_enable);
107 local_irq_restore(flags); 90 local_irq_restore(flags);
108} 91}
109 92
@@ -114,7 +97,7 @@ static void sun4c_enable_irq(unsigned int irq_nr)
114 97
115 local_irq_save(flags); 98 local_irq_save(flags);
116 irq_nr &= (NR_IRQS - 1); 99 irq_nr &= (NR_IRQS - 1);
117 current_mask = *interrupt_enable; 100 current_mask = sbus_readb(interrupt_enable);
118 switch(irq_nr) { 101 switch(irq_nr) {
119 case 1: 102 case 1:
120 new_mask = ((current_mask) | SUN4C_INT_E1); 103 new_mask = ((current_mask) | SUN4C_INT_E1);
@@ -132,37 +115,22 @@ static void sun4c_enable_irq(unsigned int irq_nr)
132 local_irq_restore(flags); 115 local_irq_restore(flags);
133 return; 116 return;
134 } 117 }
135 *interrupt_enable = new_mask; 118 sbus_writeb(new_mask, interrupt_enable);
136 local_irq_restore(flags); 119 local_irq_restore(flags);
137} 120}
138 121
139#define TIMER_IRQ 10 /* Also at level 14, but we ignore that one. */ 122struct sun4c_timer_info {
140#define PROFILE_IRQ 14 /* Level14 ticker.. used by OBP for polling */ 123 u32 l10_count;
141 124 u32 l10_limit;
142volatile struct sun4c_timer_info *sun4c_timers; 125 u32 l14_count;
126 u32 l14_limit;
127};
143 128
144#ifdef CONFIG_SUN4 129static struct sun4c_timer_info __iomem *sun4c_timers;
145/* This is an ugly hack to work around the
146 current timer code, and make it work with
147 the sun4/260 intersil
148 */
149volatile struct sun4c_timer_info sun4_timer;
150#endif
151 130
152static void sun4c_clear_clock_irq(void) 131static void sun4c_clear_clock_irq(void)
153{ 132{
154 volatile unsigned int clear_intr; 133 sbus_readl(&sun4c_timers->l10_limit);
155#ifdef CONFIG_SUN4
156 if (idprom->id_machtype == (SM_SUN4 | SM_4_260))
157 clear_intr = sun4_timer.timer_limit10;
158 else
159#endif
160 clear_intr = sun4c_timers->timer_limit10;
161}
162
163static void sun4c_clear_profile_irq(int cpu)
164{
165 /* Errm.. not sure how to do this.. */
166} 134}
167 135
168static void sun4c_load_profile_irq(int cpu, unsigned int limit) 136static void sun4c_load_profile_irq(int cpu, unsigned int limit)
@@ -172,41 +140,48 @@ static void sun4c_load_profile_irq(int cpu, unsigned int limit)
172 140
173static void __init sun4c_init_timers(irq_handler_t counter_fn) 141static void __init sun4c_init_timers(irq_handler_t counter_fn)
174{ 142{
175 int irq; 143 const struct linux_prom_irqs *irq;
144 struct device_node *dp;
145 const u32 *addr;
146 int err;
147
148 dp = of_find_node_by_name(NULL, "counter-timer");
149 if (!dp) {
150 prom_printf("sun4c_init_timers: Unable to find counter-timer\n");
151 prom_halt();
152 }
176 153
177 /* Map the Timer chip, this is implemented in hardware inside 154 addr = of_get_property(dp, "address", NULL);
178 * the cache chip on the sun4c. 155 if (!addr) {
179 */ 156 prom_printf("sun4c_init_timers: No address property\n");
180#ifdef CONFIG_SUN4 157 prom_halt();
181 if (idprom->id_machtype == (SM_SUN4 | SM_4_260)) 158 }
182 sun4c_timers = &sun4_timer; 159
183 else 160 sun4c_timers = (void __iomem *) (unsigned long) addr[0];
184#endif 161
185 sun4c_timers = ioremap(SUN_TIMER_PHYSADDR, 162 irq = of_get_property(dp, "intr", NULL);
186 sizeof(struct sun4c_timer_info)); 163 if (!irq) {
164 prom_printf("sun4c_init_timers: No intr property\n");
165 prom_halt();
166 }
187 167
188 /* Have the level 10 timer tick at 100HZ. We don't touch the 168 /* Have the level 10 timer tick at 100HZ. We don't touch the
189 * level 14 timer limit since we are letting the prom handle 169 * level 14 timer limit since we are letting the prom handle
190 * them until we have a real console driver so L1-A works. 170 * them until we have a real console driver so L1-A works.
191 */ 171 */
192 sun4c_timers->timer_limit10 = (((1000000/HZ) + 1) << 10); 172 sbus_writel((((1000000/HZ) + 1) << 10), &sun4c_timers->l10_limit);
193 master_l10_counter = &sun4c_timers->cur_count10;
194 master_l10_limit = &sun4c_timers->timer_limit10;
195 173
196 irq = request_irq(TIMER_IRQ, 174 master_l10_counter = &sun4c_timers->l10_count;
197 counter_fn, 175
176 err = request_irq(irq[0].pri, counter_fn,
198 (IRQF_DISABLED | SA_STATIC_ALLOC), 177 (IRQF_DISABLED | SA_STATIC_ALLOC),
199 "timer", NULL); 178 "timer", NULL);
200 if (irq) { 179 if (err) {
201 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ); 180 prom_printf("sun4c_init_timers: request_irq() fails with %d\n", err);
202 prom_halt(); 181 prom_halt();
203 } 182 }
204 183
205#if 0 184 sun4c_disable_irq(irq[1].pri);
206 /* This does not work on 4/330 */
207 sun4c_enable_irq(10);
208#endif
209 claim_ticker14(NULL, PROFILE_IRQ, 0);
210} 185}
211 186
212#ifdef CONFIG_SMP 187#ifdef CONFIG_SMP
@@ -215,41 +190,28 @@ static void sun4c_nop(void) {}
215 190
216void __init sun4c_init_IRQ(void) 191void __init sun4c_init_IRQ(void)
217{ 192{
218 struct linux_prom_registers int_regs[2]; 193 struct device_node *dp;
219 int ie_node; 194 const u32 *addr;
220 195
221 if (ARCH_SUN4) { 196 dp = of_find_node_by_name(NULL, "interrupt-enable");
222 interrupt_enable = (char *) 197 if (!dp) {
223 ioremap(sun4_ie_physaddr, PAGE_SIZE); 198 prom_printf("sun4c_init_IRQ: Unable to find interrupt-enable\n");
224 } else { 199 prom_halt();
225 struct resource phyres; 200 }
226
227 ie_node = prom_searchsiblings (prom_getchild(prom_root_node),
228 "interrupt-enable");
229 if(ie_node == 0)
230 panic("Cannot find /interrupt-enable node");
231 201
232 /* Depending on the "address" property is bad news... */ 202 addr = of_get_property(dp, "address", NULL);
233 interrupt_enable = NULL; 203 if (!addr) {
234 if (prom_getproperty(ie_node, "reg", (char *) int_regs, 204 prom_printf("sun4c_init_IRQ: No address property\n");
235 sizeof(int_regs)) != -1) { 205 prom_halt();
236 memset(&phyres, 0, sizeof(struct resource));
237 phyres.flags = int_regs[0].which_io;
238 phyres.start = int_regs[0].phys_addr;
239 interrupt_enable = (char *) sbus_ioremap(&phyres, 0,
240 int_regs[0].reg_size, "sun4c_intr");
241 }
242 } 206 }
243 if (!interrupt_enable)
244 panic("Cannot map interrupt_enable");
245 207
246 BTFIXUPSET_CALL(sbint_to_irq, sun4c_sbint_to_irq, BTFIXUPCALL_NORM); 208 interrupt_enable = (void __iomem *) (unsigned long) addr[0];
209
247 BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM); 210 BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
248 BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM); 211 BTFIXUPSET_CALL(disable_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
249 BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM); 212 BTFIXUPSET_CALL(enable_pil_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
250 BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM); 213 BTFIXUPSET_CALL(disable_pil_irq, sun4c_disable_irq, BTFIXUPCALL_NORM);
251 BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM); 214 BTFIXUPSET_CALL(clear_clock_irq, sun4c_clear_clock_irq, BTFIXUPCALL_NORM);
252 BTFIXUPSET_CALL(clear_profile_irq, sun4c_clear_profile_irq, BTFIXUPCALL_NOP);
253 BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP); 215 BTFIXUPSET_CALL(load_profile_irq, sun4c_load_profile_irq, BTFIXUPCALL_NOP);
254 sparc_init_timers = sun4c_init_timers; 216 sparc_init_timers = sun4c_init_timers;
255#ifdef CONFIG_SMP 217#ifdef CONFIG_SMP
@@ -257,6 +219,6 @@ void __init sun4c_init_IRQ(void)
257 BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP); 219 BTFIXUPSET_CALL(clear_cpu_int, sun4c_nop, BTFIXUPCALL_NOP);
258 BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP); 220 BTFIXUPSET_CALL(set_irq_udt, sun4c_nop, BTFIXUPCALL_NOP);
259#endif 221#endif
260 *interrupt_enable = (SUN4C_INT_ENABLE); 222 sbus_writeb(SUN4C_INT_ENABLE, interrupt_enable);
261 /* Cannot enable interrupts until OBP ticker is disabled. */ 223 /* Cannot enable interrupts until OBP ticker is disabled. */
262} 224}
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index 1290b5998f83..d3cb76ce418b 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -19,6 +19,8 @@
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/of.h>
23#include <linux/of_device.h>
22 24
23#include <asm/ptrace.h> 25#include <asm/ptrace.h>
24#include <asm/processor.h> 26#include <asm/processor.h>
@@ -34,7 +36,6 @@
34#include <asm/io.h> 36#include <asm/io.h>
35#include <asm/pgalloc.h> 37#include <asm/pgalloc.h>
36#include <asm/pgtable.h> 38#include <asm/pgtable.h>
37#include <asm/sbus.h>
38#include <asm/sbi.h> 39#include <asm/sbi.h>
39#include <asm/cacheflush.h> 40#include <asm/cacheflush.h>
40#include <asm/irq_regs.h> 41#include <asm/irq_regs.h>
@@ -44,16 +45,22 @@
44/* If you trust current SCSI layer to handle different SCSI IRQs, enable this. I don't trust it... -jj */ 45/* If you trust current SCSI layer to handle different SCSI IRQs, enable this. I don't trust it... -jj */
45/* #define DISTRIBUTE_IRQS */ 46/* #define DISTRIBUTE_IRQS */
46 47
47struct sun4d_timer_regs *sun4d_timers; 48struct sun4d_timer_regs {
49 u32 l10_timer_limit;
50 u32 l10_cur_countx;
51 u32 l10_limit_noclear;
52 u32 ctrl;
53 u32 l10_cur_count;
54};
55
56static struct sun4d_timer_regs __iomem *sun4d_timers;
57
48#define TIMER_IRQ 10 58#define TIMER_IRQ 10
49 59
50#define MAX_STATIC_ALLOC 4 60#define MAX_STATIC_ALLOC 4
51extern struct irqaction static_irqaction[MAX_STATIC_ALLOC]; 61extern struct irqaction static_irqaction[MAX_STATIC_ALLOC];
52extern int static_irq_count; 62extern int static_irq_count;
53unsigned char cpu_leds[32];
54#ifdef CONFIG_SMP
55static unsigned char sbus_tid[32]; 63static unsigned char sbus_tid[32];
56#endif
57 64
58static struct irqaction *irq_action[NR_IRQS]; 65static struct irqaction *irq_action[NR_IRQS];
59extern spinlock_t irq_action_lock; 66extern spinlock_t irq_action_lock;
@@ -72,9 +79,9 @@ static int sbus_to_pil[] = {
72}; 79};
73 80
74static int nsbi; 81static int nsbi;
75#ifdef CONFIG_SMP 82
83/* Exported for sun4d_smp.c */
76DEFINE_SPINLOCK(sun4d_imsk_lock); 84DEFINE_SPINLOCK(sun4d_imsk_lock);
77#endif
78 85
79int show_sun4d_interrupts(struct seq_file *p, void *v) 86int show_sun4d_interrupts(struct seq_file *p, void *v)
80{ 87{
@@ -257,26 +264,6 @@ void sun4d_handler_irq(int irq, struct pt_regs * regs)
257 set_irq_regs(old_regs); 264 set_irq_regs(old_regs);
258} 265}
259 266
260unsigned int sun4d_build_irq(struct sbus_dev *sdev, int irq)
261{
262 int sbusl = pil_to_sbus[irq];
263
264 if (sbusl)
265 return ((sdev->bus->board + 1) << 5) + (sbusl << 2) + sdev->slot;
266 else
267 return irq;
268}
269
270static unsigned int sun4d_sbint_to_irq(struct sbus_dev *sdev,
271 unsigned int sbint)
272{
273 if (sbint >= sizeof(sbus_to_pil)) {
274 printk(KERN_ERR "%s: bogus SBINT %d\n", sdev->prom_name, sbint);
275 BUG();
276 }
277 return sun4d_build_irq(sdev, sbus_to_pil[sbint]);
278}
279
280int sun4d_request_irq(unsigned int irq, 267int sun4d_request_irq(unsigned int irq,
281 irq_handler_t handler, 268 irq_handler_t handler,
282 unsigned long irqflags, const char * devname, void *dev_id) 269 unsigned long irqflags, const char * devname, void *dev_id)
@@ -360,36 +347,28 @@ out:
360 347
361static void sun4d_disable_irq(unsigned int irq) 348static void sun4d_disable_irq(unsigned int irq)
362{ 349{
363#ifdef CONFIG_SMP
364 int tid = sbus_tid[(irq >> 5) - 1]; 350 int tid = sbus_tid[(irq >> 5) - 1];
365 unsigned long flags; 351 unsigned long flags;
366#endif
367 352
368 if (irq < NR_IRQS) return; 353 if (irq < NR_IRQS)
369#ifdef CONFIG_SMP 354 return;
355
370 spin_lock_irqsave(&sun4d_imsk_lock, flags); 356 spin_lock_irqsave(&sun4d_imsk_lock, flags);
371 cc_set_imsk_other(tid, cc_get_imsk_other(tid) | (1 << sbus_to_pil[(irq >> 2) & 7])); 357 cc_set_imsk_other(tid, cc_get_imsk_other(tid) | (1 << sbus_to_pil[(irq >> 2) & 7]));
372 spin_unlock_irqrestore(&sun4d_imsk_lock, flags); 358 spin_unlock_irqrestore(&sun4d_imsk_lock, flags);
373#else
374 cc_set_imsk(cc_get_imsk() | (1 << sbus_to_pil[(irq >> 2) & 7]));
375#endif
376} 359}
377 360
378static void sun4d_enable_irq(unsigned int irq) 361static void sun4d_enable_irq(unsigned int irq)
379{ 362{
380#ifdef CONFIG_SMP
381 int tid = sbus_tid[(irq >> 5) - 1]; 363 int tid = sbus_tid[(irq >> 5) - 1];
382 unsigned long flags; 364 unsigned long flags;
383#endif
384 365
385 if (irq < NR_IRQS) return; 366 if (irq < NR_IRQS)
386#ifdef CONFIG_SMP 367 return;
368
387 spin_lock_irqsave(&sun4d_imsk_lock, flags); 369 spin_lock_irqsave(&sun4d_imsk_lock, flags);
388 cc_set_imsk_other(tid, cc_get_imsk_other(tid) & ~(1 << sbus_to_pil[(irq >> 2) & 7])); 370 cc_set_imsk_other(tid, cc_get_imsk_other(tid) & ~(1 << sbus_to_pil[(irq >> 2) & 7]));
389 spin_unlock_irqrestore(&sun4d_imsk_lock, flags); 371 spin_unlock_irqrestore(&sun4d_imsk_lock, flags);
390#else
391 cc_set_imsk(cc_get_imsk() & ~(1 << sbus_to_pil[(irq >> 2) & 7]));
392#endif
393} 372}
394 373
395#ifdef CONFIG_SMP 374#ifdef CONFIG_SMP
@@ -409,47 +388,55 @@ static void sun4d_set_udt(int cpu)
409/* Setup IRQ distribution scheme. */ 388/* Setup IRQ distribution scheme. */
410void __init sun4d_distribute_irqs(void) 389void __init sun4d_distribute_irqs(void)
411{ 390{
391 struct device_node *dp;
392
412#ifdef DISTRIBUTE_IRQS 393#ifdef DISTRIBUTE_IRQS
413 struct sbus_bus *sbus; 394 cpumask_t sbus_serving_map;
414 unsigned long sbus_serving_map;
415 395
416 sbus_serving_map = cpu_present_map; 396 sbus_serving_map = cpu_present_map;
417 for_each_sbus(sbus) { 397 for_each_node_by_name(dp, "sbi") {
418 if ((sbus->board * 2) == boot_cpu_id && (cpu_present_map & (1 << (sbus->board * 2 + 1)))) 398 int board = of_getintprop_default(dp, "board#", 0);
419 sbus_tid[sbus->board] = (sbus->board * 2 + 1); 399
420 else if (cpu_present_map & (1 << (sbus->board * 2))) 400 if ((board * 2) == boot_cpu_id && cpu_isset(board * 2 + 1, cpu_present_map))
421 sbus_tid[sbus->board] = (sbus->board * 2); 401 sbus_tid[board] = (board * 2 + 1);
422 else if (cpu_present_map & (1 << (sbus->board * 2 + 1))) 402 else if (cpu_isset(board * 2, cpu_present_map))
423 sbus_tid[sbus->board] = (sbus->board * 2 + 1); 403 sbus_tid[board] = (board * 2);
404 else if (cpu_isset(board * 2 + 1, cpu_present_map))
405 sbus_tid[board] = (board * 2 + 1);
424 else 406 else
425 sbus_tid[sbus->board] = 0xff; 407 sbus_tid[board] = 0xff;
426 if (sbus_tid[sbus->board] != 0xff) 408 if (sbus_tid[board] != 0xff)
427 sbus_serving_map &= ~(1 << sbus_tid[sbus->board]); 409 cpu_clear(sbus_tid[board], sbus_serving_map);
428 } 410 }
429 for_each_sbus(sbus) 411 for_each_node_by_name(dp, "sbi") {
430 if (sbus_tid[sbus->board] == 0xff) { 412 int board = of_getintprop_default(dp, "board#", 0);
413 if (sbus_tid[board] == 0xff) {
431 int i = 31; 414 int i = 31;
432 415
433 if (!sbus_serving_map) 416 if (cpus_empty(sbus_serving_map))
434 sbus_serving_map = cpu_present_map; 417 sbus_serving_map = cpu_present_map;
435 while (!(sbus_serving_map & (1 << i))) 418 while (cpu_isset(i, sbus_serving_map))
436 i--; 419 i--;
437 sbus_tid[sbus->board] = i; 420 sbus_tid[board] = i;
438 sbus_serving_map &= ~(1 << i); 421 cpu_clear(i, sbus_serving_map);
439 } 422 }
440 for_each_sbus(sbus) { 423 }
441 printk("sbus%d IRQs directed to CPU%d\n", sbus->board, sbus_tid[sbus->board]); 424 for_each_node_by_name(dp, "sbi") {
442 set_sbi_tid(sbus->devid, sbus_tid[sbus->board] << 3); 425 int devid = of_getintprop_default(dp, "device-id", 0);
426 int board = of_getintprop_default(dp, "board#", 0);
427 printk("sbus%d IRQs directed to CPU%d\n", board, sbus_tid[board]);
428 set_sbi_tid(devid, sbus_tid[board] << 3);
443 } 429 }
444#else 430#else
445 struct sbus_bus *sbus;
446 int cpuid = cpu_logical_map(1); 431 int cpuid = cpu_logical_map(1);
447 432
448 if (cpuid == -1) 433 if (cpuid == -1)
449 cpuid = cpu_logical_map(0); 434 cpuid = cpu_logical_map(0);
450 for_each_sbus(sbus) { 435 for_each_node_by_name(dp, "sbi") {
451 sbus_tid[sbus->board] = cpuid; 436 int devid = of_getintprop_default(dp, "device-id", 0);
452 set_sbi_tid(sbus->devid, cpuid << 3); 437 int board = of_getintprop_default(dp, "board#", 0);
438 sbus_tid[board] = cpuid;
439 set_sbi_tid(devid, cpuid << 3);
453 } 440 }
454 printk("All sbus IRQs directed to CPU%d\n", cpuid); 441 printk("All sbus IRQs directed to CPU%d\n", cpuid);
455#endif 442#endif
@@ -458,13 +445,7 @@ void __init sun4d_distribute_irqs(void)
458 445
459static void sun4d_clear_clock_irq(void) 446static void sun4d_clear_clock_irq(void)
460{ 447{
461 volatile unsigned int clear_intr; 448 sbus_readl(&sun4d_timers->l10_timer_limit);
462 clear_intr = sun4d_timers->l10_timer_limit;
463}
464
465static void sun4d_clear_profile_irq(int cpu)
466{
467 bw_get_prof_limit(cpu);
468} 449}
469 450
470static void sun4d_load_profile_irq(int cpu, unsigned int limit) 451static void sun4d_load_profile_irq(int cpu, unsigned int limit)
@@ -472,98 +453,121 @@ static void sun4d_load_profile_irq(int cpu, unsigned int limit)
472 bw_set_prof_limit(cpu, limit); 453 bw_set_prof_limit(cpu, limit);
473} 454}
474 455
475static void __init sun4d_init_timers(irq_handler_t counter_fn) 456static void __init sun4d_load_profile_irqs(void)
476{ 457{
477 int irq; 458 int cpu = 0, mid;
478 int cpu;
479 struct resource r;
480 int mid;
481 459
482 /* Map the User Timer registers. */ 460 while (!cpu_find_by_instance(cpu, NULL, &mid)) {
483 memset(&r, 0, sizeof(r)); 461 sun4d_load_profile_irq(mid >> 3, 0);
462 cpu++;
463 }
464}
465
466static void __init sun4d_fixup_trap_table(void)
467{
484#ifdef CONFIG_SMP 468#ifdef CONFIG_SMP
485 r.start = CSR_BASE(boot_cpu_id)+BW_TIMER_LIMIT; 469 unsigned long flags;
486#else 470 extern unsigned long lvl14_save[4];
487 r.start = CSR_BASE(0)+BW_TIMER_LIMIT; 471 struct tt_entry *trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (14 - 1)];
472 extern unsigned int real_irq_entry[], smp4d_ticker[];
473 extern unsigned int patchme_maybe_smp_msg[];
474
475 /* Adjust so that we jump directly to smp4d_ticker */
476 lvl14_save[2] += smp4d_ticker - real_irq_entry;
477
478 /* For SMP we use the level 14 ticker, however the bootup code
479 * has copied the firmware's level 14 vector into the boot cpu's
480 * trap table, we must fix this now or we get squashed.
481 */
482 local_irq_save(flags);
483 patchme_maybe_smp_msg[0] = 0x01000000; /* NOP out the branch */
484 trap_table->inst_one = lvl14_save[0];
485 trap_table->inst_two = lvl14_save[1];
486 trap_table->inst_three = lvl14_save[2];
487 trap_table->inst_four = lvl14_save[3];
488 local_flush_cache_all();
489 local_irq_restore(flags);
488#endif 490#endif
489 r.flags = 0xf; 491}
490 sun4d_timers = (struct sun4d_timer_regs *) sbus_ioremap(&r, 0,
491 PAGE_SIZE, "user timer");
492 492
493 sun4d_timers->l10_timer_limit = (((1000000/HZ) + 1) << 10); 493static void __init sun4d_init_timers(irq_handler_t counter_fn)
494 master_l10_counter = &sun4d_timers->l10_cur_count; 494{
495 master_l10_limit = &sun4d_timers->l10_timer_limit; 495 struct device_node *dp;
496 struct resource res;
497 const u32 *reg;
498 int err;
499
500 dp = of_find_node_by_name(NULL, "cpu-unit");
501 if (!dp) {
502 prom_printf("sun4d_init_timers: Unable to find cpu-unit\n");
503 prom_halt();
504 }
496 505
497 irq = request_irq(TIMER_IRQ, 506 /* Which cpu-unit we use is arbitrary, we can view the bootbus timer
498 counter_fn, 507 * registers via any cpu's mapping. The first 'reg' property is the
499 (IRQF_DISABLED | SA_STATIC_ALLOC), 508 * bootbus.
500 "timer", NULL); 509 */
501 if (irq) { 510 reg = of_get_property(dp, "reg", NULL);
502 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ); 511 if (!reg) {
512 prom_printf("sun4d_init_timers: No reg property\n");
503 prom_halt(); 513 prom_halt();
504 } 514 }
505
506 /* Enable user timer free run for CPU 0 in BW */
507 /* bw_set_ctrl(0, bw_get_ctrl(0) | BW_CTRL_USER_TIMER); */
508 515
509 cpu = 0; 516 res.start = reg[1];
510 while (!cpu_find_by_instance(cpu, NULL, &mid)) { 517 res.end = reg[2] - 1;
511 sun4d_load_profile_irq(mid >> 3, 0); 518 res.flags = reg[0] & 0xff;
512 cpu++; 519 sun4d_timers = of_ioremap(&res, BW_TIMER_LIMIT,
520 sizeof(struct sun4d_timer_regs), "user timer");
521 if (!sun4d_timers) {
522 prom_printf("sun4d_init_timers: Can't map timer regs\n");
523 prom_halt();
513 } 524 }
514 525
515#ifdef CONFIG_SMP 526 sbus_writel((((1000000/HZ) + 1) << 10), &sun4d_timers->l10_timer_limit);
516 { 527
517 unsigned long flags; 528 master_l10_counter = &sun4d_timers->l10_cur_count;
518 extern unsigned long lvl14_save[4]; 529
519 struct tt_entry *trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (14 - 1)]; 530 err = request_irq(TIMER_IRQ, counter_fn,
520 extern unsigned int real_irq_entry[], smp4d_ticker[]; 531 (IRQF_DISABLED | SA_STATIC_ALLOC),
521 extern unsigned int patchme_maybe_smp_msg[]; 532 "timer", NULL);
522 533 if (err) {
523 /* Adjust so that we jump directly to smp4d_ticker */ 534 prom_printf("sun4d_init_timers: request_irq() failed with %d\n", err);
524 lvl14_save[2] += smp4d_ticker - real_irq_entry; 535 prom_halt();
525
526 /* For SMP we use the level 14 ticker, however the bootup code
527 * has copied the firmware's level 14 vector into the boot cpu's
528 * trap table, we must fix this now or we get squashed.
529 */
530 local_irq_save(flags);
531 patchme_maybe_smp_msg[0] = 0x01000000; /* NOP out the branch */
532 trap_table->inst_one = lvl14_save[0];
533 trap_table->inst_two = lvl14_save[1];
534 trap_table->inst_three = lvl14_save[2];
535 trap_table->inst_four = lvl14_save[3];
536 local_flush_cache_all();
537 local_irq_restore(flags);
538 } 536 }
539#endif 537 sun4d_load_profile_irqs();
538 sun4d_fixup_trap_table();
540} 539}
541 540
542void __init sun4d_init_sbi_irq(void) 541void __init sun4d_init_sbi_irq(void)
543{ 542{
544 struct sbus_bus *sbus; 543 struct device_node *dp;
545 unsigned mask; 544 int target_cpu = 0;
545
546#ifdef CONFIG_SMP
547 target_cpu = boot_cpu_id;
548#endif
546 549
547 nsbi = 0; 550 nsbi = 0;
548 for_each_sbus(sbus) 551 for_each_node_by_name(dp, "sbi")
549 nsbi++; 552 nsbi++;
550 sbus_actions = kzalloc (nsbi * 8 * 4 * sizeof(struct sbus_action), GFP_ATOMIC); 553 sbus_actions = kzalloc (nsbi * 8 * 4 * sizeof(struct sbus_action), GFP_ATOMIC);
551 if (!sbus_actions) { 554 if (!sbus_actions) {
552 prom_printf("SUN4D: Cannot allocate sbus_actions, halting.\n"); 555 prom_printf("SUN4D: Cannot allocate sbus_actions, halting.\n");
553 prom_halt(); 556 prom_halt();
554 } 557 }
555 for_each_sbus(sbus) { 558 for_each_node_by_name(dp, "sbi") {
556#ifdef CONFIG_SMP 559 int devid = of_getintprop_default(dp, "device-id", 0);
557 extern unsigned char boot_cpu_id; 560 int board = of_getintprop_default(dp, "board#", 0);
558 561 unsigned int mask;
559 set_sbi_tid(sbus->devid, boot_cpu_id << 3); 562
560 sbus_tid[sbus->board] = boot_cpu_id; 563 set_sbi_tid(devid, target_cpu << 3);
561#endif 564 sbus_tid[board] = target_cpu;
565
562 /* Get rid of pending irqs from PROM */ 566 /* Get rid of pending irqs from PROM */
563 mask = acquire_sbi(sbus->devid, 0xffffffff); 567 mask = acquire_sbi(devid, 0xffffffff);
564 if (mask) { 568 if (mask) {
565 printk ("Clearing pending IRQs %08x on SBI %d\n", mask, sbus->board); 569 printk ("Clearing pending IRQs %08x on SBI %d\n", mask, board);
566 release_sbi(sbus->devid, mask); 570 release_sbi(devid, mask);
567 } 571 }
568 } 572 }
569} 573}
@@ -572,11 +576,9 @@ void __init sun4d_init_IRQ(void)
572{ 576{
573 local_irq_disable(); 577 local_irq_disable();
574 578
575 BTFIXUPSET_CALL(sbint_to_irq, sun4d_sbint_to_irq, BTFIXUPCALL_NORM);
576 BTFIXUPSET_CALL(enable_irq, sun4d_enable_irq, BTFIXUPCALL_NORM); 579 BTFIXUPSET_CALL(enable_irq, sun4d_enable_irq, BTFIXUPCALL_NORM);
577 BTFIXUPSET_CALL(disable_irq, sun4d_disable_irq, BTFIXUPCALL_NORM); 580 BTFIXUPSET_CALL(disable_irq, sun4d_disable_irq, BTFIXUPCALL_NORM);
578 BTFIXUPSET_CALL(clear_clock_irq, sun4d_clear_clock_irq, BTFIXUPCALL_NORM); 581 BTFIXUPSET_CALL(clear_clock_irq, sun4d_clear_clock_irq, BTFIXUPCALL_NORM);
579 BTFIXUPSET_CALL(clear_profile_irq, sun4d_clear_profile_irq, BTFIXUPCALL_NORM);
580 BTFIXUPSET_CALL(load_profile_irq, sun4d_load_profile_irq, BTFIXUPCALL_NORM); 582 BTFIXUPSET_CALL(load_profile_irq, sun4d_load_profile_irq, BTFIXUPCALL_NORM);
581 sparc_init_timers = sun4d_init_timers; 583 sparc_init_timers = sun4d_init_timers;
582#ifdef CONFIG_SMP 584#ifdef CONFIG_SMP
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index 69596402a500..ce3d45db94e9 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -30,7 +30,6 @@
30#include <asm/pgalloc.h> 30#include <asm/pgalloc.h>
31#include <asm/pgtable.h> 31#include <asm/pgtable.h>
32#include <asm/oplib.h> 32#include <asm/oplib.h>
33#include <asm/sbus.h>
34#include <asm/sbi.h> 33#include <asm/sbi.h>
35#include <asm/tlbflush.h> 34#include <asm/tlbflush.h>
36#include <asm/cacheflush.h> 35#include <asm/cacheflush.h>
@@ -72,6 +71,17 @@ static void smp_setup_percpu_timer(void);
72extern void cpu_probe(void); 71extern void cpu_probe(void);
73extern void sun4d_distribute_irqs(void); 72extern void sun4d_distribute_irqs(void);
74 73
74static unsigned char cpu_leds[32];
75
76static inline void show_leds(int cpuid)
77{
78 cpuid &= 0x1e;
79 __asm__ __volatile__ ("stba %0, [%1] %2" : :
80 "r" ((cpu_leds[cpuid] << 4) | cpu_leds[cpuid+1]),
81 "r" (ECSR_BASE(cpuid) | BB_LEDS),
82 "i" (ASI_M_CTL));
83}
84
75void __init smp4d_callin(void) 85void __init smp4d_callin(void)
76{ 86{
77 int cpuid = hard_smp4d_processor_id(); 87 int cpuid = hard_smp4d_processor_id();
@@ -88,6 +98,7 @@ void __init smp4d_callin(void)
88 local_flush_cache_all(); 98 local_flush_cache_all();
89 local_flush_tlb_all(); 99 local_flush_tlb_all();
90 100
101 notify_cpu_starting(cpuid);
91 /* 102 /*
92 * Unblock the master CPU _only_ when the scheduler state 103 * Unblock the master CPU _only_ when the scheduler state
93 * of all secondary CPUs will be up-to-date, so after 104 * of all secondary CPUs will be up-to-date, so after
diff --git a/arch/sparc/kernel/sun4m_irq.c b/arch/sparc/kernel/sun4m_irq.c
index 94e02de960ea..f10317179ee6 100644
--- a/arch/sparc/kernel/sun4m_irq.c
+++ b/arch/sparc/kernel/sun4m_irq.c
@@ -20,6 +20,8 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/of.h>
24#include <linux/of_device.h>
23 25
24#include <asm/ptrace.h> 26#include <asm/ptrace.h>
25#include <asm/processor.h> 27#include <asm/processor.h>
@@ -35,59 +37,27 @@
35#include <asm/smp.h> 37#include <asm/smp.h>
36#include <asm/irq.h> 38#include <asm/irq.h>
37#include <asm/io.h> 39#include <asm/io.h>
38#include <asm/sbus.h>
39#include <asm/cacheflush.h> 40#include <asm/cacheflush.h>
40 41
41#include "irq.h" 42#include "irq.h"
42 43
43/* On the sun4m, just like the timers, we have both per-cpu and master 44struct sun4m_irq_percpu {
44 * interrupt registers. 45 u32 pending;
45 */ 46 u32 clear;
46 47 u32 set;
47/* These registers are used for sending/receiving irqs from/to
48 * different cpu's.
49 */
50struct sun4m_intreg_percpu {
51 unsigned int tbt; /* Interrupts still pending for this cpu. */
52
53 /* These next two registers are WRITE-ONLY and are only
54 * "on bit" sensitive, "off bits" written have NO affect.
55 */
56 unsigned int clear; /* Clear this cpus irqs here. */
57 unsigned int set; /* Set this cpus irqs here. */
58 unsigned char space[PAGE_SIZE - 12];
59}; 48};
60 49
61/* 50struct sun4m_irq_global {
62 * djhr 51 u32 pending;
63 * Actually the clear and set fields in this struct are misleading.. 52 u32 mask;
64 * according to the SLAVIO manual (and the same applies for the SEC) 53 u32 mask_clear;
65 * the clear field clears bits in the mask which will ENABLE that IRQ 54 u32 mask_set;
66 * the set field sets bits in the mask to DISABLE the IRQ. 55 u32 interrupt_target;
67 *
68 * Also the undirected_xx address in the SLAVIO is defined as
69 * RESERVED and write only..
70 *
71 * DAVEM_NOTE: The SLAVIO only specifies behavior on uniprocessor
72 * sun4m machines, for MP the layout makes more sense.
73 */
74struct sun4m_intregs {
75 struct sun4m_intreg_percpu cpu_intregs[SUN4M_NCPUS];
76 unsigned int tbt; /* IRQ's that are still pending. */
77 unsigned int irqs; /* Master IRQ bits. */
78
79 /* Again, like the above, two these registers are WRITE-ONLY. */
80 unsigned int clear; /* Clear master IRQ's by setting bits here. */
81 unsigned int set; /* Set master IRQ's by setting bits here. */
82
83 /* This register is both READ and WRITE. */
84 unsigned int undirected_target; /* Which cpu gets undirected irqs. */
85}; 56};
86 57
87static unsigned long dummy; 58/* Code in entry.S needs to get at these register mappings. */
88 59struct sun4m_irq_percpu __iomem *sun4m_irq_percpu[SUN4M_NCPUS];
89struct sun4m_intregs *sun4m_interrupts; 60struct sun4m_irq_global __iomem *sun4m_irq_global;
90unsigned long *irq_rcvreg = &dummy;
91 61
92/* Dave Redman (djhr@tadpole.co.uk) 62/* Dave Redman (djhr@tadpole.co.uk)
93 * The sun4m interrupt registers. 63 * The sun4m interrupt registers.
@@ -101,8 +71,9 @@ unsigned long *irq_rcvreg = &dummy;
101 71
102#define SUN4M_INT_MASKALL 0x80000000 /* mask all interrupts */ 72#define SUN4M_INT_MASKALL 0x80000000 /* mask all interrupts */
103#define SUN4M_INT_MODULE_ERR 0x40000000 /* module error */ 73#define SUN4M_INT_MODULE_ERR 0x40000000 /* module error */
104#define SUN4M_INT_M2S_WRITE 0x20000000 /* write buffer error */ 74#define SUN4M_INT_M2S_WRITE_ERR 0x20000000 /* write buffer error */
105#define SUN4M_INT_ECC 0x10000000 /* ecc memory error */ 75#define SUN4M_INT_ECC_ERR 0x10000000 /* ecc memory error */
76#define SUN4M_INT_VME_ERR 0x08000000 /* vme async error */
106#define SUN4M_INT_FLOPPY 0x00400000 /* floppy disk */ 77#define SUN4M_INT_FLOPPY 0x00400000 /* floppy disk */
107#define SUN4M_INT_MODULE 0x00200000 /* module interrupt */ 78#define SUN4M_INT_MODULE 0x00200000 /* module interrupt */
108#define SUN4M_INT_VIDEO 0x00100000 /* onboard video */ 79#define SUN4M_INT_VIDEO 0x00100000 /* onboard video */
@@ -113,75 +84,126 @@ unsigned long *irq_rcvreg = &dummy;
113#define SUN4M_INT_SERIAL 0x00008000 /* serial ports */ 84#define SUN4M_INT_SERIAL 0x00008000 /* serial ports */
114#define SUN4M_INT_KBDMS 0x00004000 /* keyboard/mouse */ 85#define SUN4M_INT_KBDMS 0x00004000 /* keyboard/mouse */
115#define SUN4M_INT_SBUSBITS 0x00003F80 /* sbus int bits */ 86#define SUN4M_INT_SBUSBITS 0x00003F80 /* sbus int bits */
87#define SUN4M_INT_VMEBITS 0x0000007F /* vme int bits */
88
89#define SUN4M_INT_ERROR (SUN4M_INT_MODULE_ERR | \
90 SUN4M_INT_M2S_WRITE_ERR | \
91 SUN4M_INT_ECC_ERR | \
92 SUN4M_INT_VME_ERR)
116 93
117#define SUN4M_INT_SBUS(x) (1 << (x+7)) 94#define SUN4M_INT_SBUS(x) (1 << (x+7))
118#define SUN4M_INT_VME(x) (1 << (x)) 95#define SUN4M_INT_VME(x) (1 << (x))
119 96
120/* These tables only apply for interrupts greater than 15.. 97/* Interrupt levels used by OBP */
121 * 98#define OBP_INT_LEVEL_SOFT 0x10
122 * any intr value below 0x10 is considered to be a soft-int 99#define OBP_INT_LEVEL_ONBOARD 0x20
123 * this may be useful or it may not.. but that's how I've done it. 100#define OBP_INT_LEVEL_SBUS 0x30
124 * and it won't clash with what OBP is telling us about devices. 101#define OBP_INT_LEVEL_VME 0x40
102
103/* Interrupt level assignment on sun4m:
104 *
105 * level source
106 * ------------------------------------------------------------
107 * 1 softint-1
108 * 2 softint-2, VME/SBUS level 1
109 * 3 softint-3, VME/SBUS level 2
110 * 4 softint-4, onboard SCSI
111 * 5 softint-5, VME/SBUS level 3
112 * 6 softint-6, onboard ETHERNET
113 * 7 softint-7, VME/SBUS level 4
114 * 8 softint-8, onboard VIDEO
115 * 9 softint-9, VME/SBUS level 5, Module Interrupt
116 * 10 softint-10, system counter/timer
117 * 11 softint-11, VME/SBUS level 6, Floppy
118 * 12 softint-12, Keyboard/Mouse, Serial
119 * 13 softint-13, VME/SBUS level 7, ISDN Audio
120 * 14 softint-14, per-processor counter/timer
121 * 15 softint-15, Asynchronous Errors (broadcast)
125 * 122 *
126 * take an encoded intr value and lookup if it's valid 123 * Each interrupt source is masked distinctly in the sun4m interrupt
127 * then get the mask bits that match from irq_mask 124 * registers. The PIL level alone is therefore ambiguous, since multiple
125 * interrupt sources map to a single PIL.
128 * 126 *
129 * P3: Translation from irq 0x0d to mask 0x2000 is for MrCoffee. 127 * This ambiguity is resolved in the 'intr' property for device nodes
128 * in the OF device tree. Each 'intr' property entry is composed of
129 * two 32-bit words. The first word is the IRQ priority value, which
130 * is what we're intersted in. The second word is the IRQ vector, which
131 * is unused.
132 *
133 * The low 4 bits of the IRQ priority indicate the PIL, and the upper
134 * 4 bits indicate onboard vs. SBUS leveled vs. VME leveled. 0x20
135 * means onboard, 0x30 means SBUS leveled, and 0x40 means VME leveled.
136 *
137 * For example, an 'intr' IRQ priority value of 0x24 is onboard SCSI
138 * whereas a value of 0x33 is SBUS level 2. Here are some sample
139 * 'intr' property IRQ priority values from ss4, ss5, ss10, ss20, and
140 * Tadpole S3 GX systems.
141 *
142 * esp: 0x24 onboard ESP SCSI
143 * le: 0x26 onboard Lance ETHERNET
144 * p9100: 0x32 SBUS level 1 P9100 video
145 * bpp: 0x33 SBUS level 2 BPP parallel port device
146 * DBRI: 0x39 SBUS level 5 DBRI ISDN audio
147 * SUNW,leo: 0x39 SBUS level 5 LEO video
148 * pcmcia: 0x3b SBUS level 6 PCMCIA controller
149 * uctrl: 0x3b SBUS level 6 UCTRL device
150 * modem: 0x3d SBUS level 7 MODEM
151 * zs: 0x2c onboard keyboard/mouse/serial
152 * floppy: 0x2b onboard Floppy
153 * power: 0x22 onboard power device (XXX unknown mask bit XXX)
130 */ 154 */
131static unsigned char irq_xlate[32] = {
132 /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f */
133 0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 5, 6, 14, 0, 7,
134 0, 0, 8, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 0
135};
136 155
137static unsigned long irq_mask[] = { 156static unsigned long irq_mask[0x50] = {
138 0, /* illegal index */ 157 /* SMP */
139 SUN4M_INT_SCSI, /* 1 irq 4 */ 158 0, SUN4M_SOFT_INT(1),
140 SUN4M_INT_ETHERNET, /* 2 irq 6 */ 159 SUN4M_SOFT_INT(2), SUN4M_SOFT_INT(3),
141 SUN4M_INT_VIDEO, /* 3 irq 8 */ 160 SUN4M_SOFT_INT(4), SUN4M_SOFT_INT(5),
142 SUN4M_INT_REALTIME, /* 4 irq 10 */ 161 SUN4M_SOFT_INT(6), SUN4M_SOFT_INT(7),
143 SUN4M_INT_FLOPPY, /* 5 irq 11 */ 162 SUN4M_SOFT_INT(8), SUN4M_SOFT_INT(9),
144 (SUN4M_INT_SERIAL | SUN4M_INT_KBDMS), /* 6 irq 12 */ 163 SUN4M_SOFT_INT(10), SUN4M_SOFT_INT(11),
145 SUN4M_INT_MODULE_ERR, /* 7 irq 15 */ 164 SUN4M_SOFT_INT(12), SUN4M_SOFT_INT(13),
146 SUN4M_INT_SBUS(0), /* 8 irq 2 */ 165 SUN4M_SOFT_INT(14), SUN4M_SOFT_INT(15),
147 SUN4M_INT_SBUS(1), /* 9 irq 3 */ 166 /* soft */
148 SUN4M_INT_SBUS(2), /* 10 irq 5 */ 167 0, SUN4M_SOFT_INT(1),
149 SUN4M_INT_SBUS(3), /* 11 irq 7 */ 168 SUN4M_SOFT_INT(2), SUN4M_SOFT_INT(3),
150 SUN4M_INT_SBUS(4), /* 12 irq 9 */ 169 SUN4M_SOFT_INT(4), SUN4M_SOFT_INT(5),
151 SUN4M_INT_SBUS(5), /* 13 irq 11 */ 170 SUN4M_SOFT_INT(6), SUN4M_SOFT_INT(7),
152 SUN4M_INT_SBUS(6) /* 14 irq 13 */ 171 SUN4M_SOFT_INT(8), SUN4M_SOFT_INT(9),
172 SUN4M_SOFT_INT(10), SUN4M_SOFT_INT(11),
173 SUN4M_SOFT_INT(12), SUN4M_SOFT_INT(13),
174 SUN4M_SOFT_INT(14), SUN4M_SOFT_INT(15),
175 /* onboard */
176 0, 0, 0, 0,
177 SUN4M_INT_SCSI, 0, SUN4M_INT_ETHERNET, 0,
178 SUN4M_INT_VIDEO, SUN4M_INT_MODULE,
179 SUN4M_INT_REALTIME, SUN4M_INT_FLOPPY,
180 (SUN4M_INT_SERIAL | SUN4M_INT_KBDMS),
181 SUN4M_INT_AUDIO, 0, SUN4M_INT_MODULE_ERR,
182 /* sbus */
183 0, 0, SUN4M_INT_SBUS(0), SUN4M_INT_SBUS(1),
184 0, SUN4M_INT_SBUS(2), 0, SUN4M_INT_SBUS(3),
185 0, SUN4M_INT_SBUS(4), 0, SUN4M_INT_SBUS(5),
186 0, SUN4M_INT_SBUS(6), 0, 0,
187 /* vme */
188 0, 0, SUN4M_INT_VME(0), SUN4M_INT_VME(1),
189 0, SUN4M_INT_VME(2), 0, SUN4M_INT_VME(3),
190 0, SUN4M_INT_VME(4), 0, SUN4M_INT_VME(5),
191 0, SUN4M_INT_VME(6), 0, 0
153}; 192};
154 193
155static int sun4m_pil_map[] = { 0, 2, 3, 5, 7, 9, 11, 13 };
156
157static unsigned int sun4m_sbint_to_irq(struct sbus_dev *sdev,
158 unsigned int sbint)
159{
160 if (sbint >= sizeof(sun4m_pil_map)) {
161 printk(KERN_ERR "%s: bogus SBINT %d\n", sdev->prom_name, sbint);
162 BUG();
163 }
164 return sun4m_pil_map[sbint] | 0x30;
165}
166
167static unsigned long sun4m_get_irqmask(unsigned int irq) 194static unsigned long sun4m_get_irqmask(unsigned int irq)
168{ 195{
169 unsigned long mask; 196 unsigned long mask;
170 197
171 if (irq > 0x20) { 198 if (irq < 0x50)
172 /* OBIO/SBUS interrupts */ 199 mask = irq_mask[irq];
173 irq &= 0x1f; 200 else
174 mask = irq_mask[irq_xlate[irq]]; 201 mask = 0;
175 if (!mask) 202
176 printk("sun4m_get_irqmask: IRQ%d has no valid mask!\n",irq); 203 if (!mask)
177 } else { 204 printk(KERN_ERR "sun4m_get_irqmask: IRQ%d has no valid mask!\n",
178 /* Soft Interrupts will come here. 205 irq);
179 * Currently there is no way to trigger them but I'm sure 206
180 * something could be cooked up.
181 */
182 irq &= 0xf;
183 mask = SUN4M_SOFT_INT(irq);
184 }
185 return mask; 207 return mask;
186} 208}
187 209
@@ -193,9 +215,9 @@ static void sun4m_disable_irq(unsigned int irq_nr)
193 mask = sun4m_get_irqmask(irq_nr); 215 mask = sun4m_get_irqmask(irq_nr);
194 local_irq_save(flags); 216 local_irq_save(flags);
195 if (irq_nr > 15) 217 if (irq_nr > 15)
196 sun4m_interrupts->set = mask; 218 sbus_writel(mask, &sun4m_irq_global->mask_set);
197 else 219 else
198 sun4m_interrupts->cpu_intregs[cpu].set = mask; 220 sbus_writel(mask, &sun4m_irq_percpu[cpu]->set);
199 local_irq_restore(flags); 221 local_irq_restore(flags);
200} 222}
201 223
@@ -212,13 +234,13 @@ static void sun4m_enable_irq(unsigned int irq_nr)
212 mask = sun4m_get_irqmask(irq_nr); 234 mask = sun4m_get_irqmask(irq_nr);
213 local_irq_save(flags); 235 local_irq_save(flags);
214 if (irq_nr > 15) 236 if (irq_nr > 15)
215 sun4m_interrupts->clear = mask; 237 sbus_writel(mask, &sun4m_irq_global->mask_clear);
216 else 238 else
217 sun4m_interrupts->cpu_intregs[cpu].clear = mask; 239 sbus_writel(mask, &sun4m_irq_percpu[cpu]->clear);
218 local_irq_restore(flags); 240 local_irq_restore(flags);
219 } else { 241 } else {
220 local_irq_save(flags); 242 local_irq_save(flags);
221 sun4m_interrupts->clear = SUN4M_INT_FLOPPY; 243 sbus_writel(SUN4M_INT_FLOPPY, &sun4m_irq_global->mask_clear);
222 local_irq_restore(flags); 244 local_irq_restore(flags);
223 } 245 }
224} 246}
@@ -236,10 +258,10 @@ static unsigned long cpu_pil_to_imask[16] = {
236/*9*/ SUN4M_INT_SBUS(4) | SUN4M_INT_VME(4) | SUN4M_INT_MODULE_ERR, 258/*9*/ SUN4M_INT_SBUS(4) | SUN4M_INT_VME(4) | SUN4M_INT_MODULE_ERR,
237/*10*/ SUN4M_INT_REALTIME, 259/*10*/ SUN4M_INT_REALTIME,
238/*11*/ SUN4M_INT_SBUS(5) | SUN4M_INT_VME(5) | SUN4M_INT_FLOPPY, 260/*11*/ SUN4M_INT_SBUS(5) | SUN4M_INT_VME(5) | SUN4M_INT_FLOPPY,
239/*12*/ SUN4M_INT_SERIAL | SUN4M_INT_KBDMS, 261/*12*/ SUN4M_INT_SERIAL | SUN4M_INT_KBDMS,
240/*13*/ SUN4M_INT_AUDIO, 262/*13*/ SUN4M_INT_SBUS(6) | SUN4M_INT_VME(6) | SUN4M_INT_AUDIO,
241/*14*/ SUN4M_INT_E14, 263/*14*/ SUN4M_INT_E14,
242/*15*/ 0x00000000 264/*15*/ SUN4M_INT_ERROR
243}; 265};
244 266
245/* We assume the caller has disabled local interrupts when these are called, 267/* We assume the caller has disabled local interrupts when these are called,
@@ -247,126 +269,141 @@ static unsigned long cpu_pil_to_imask[16] = {
247 */ 269 */
248static void sun4m_disable_pil_irq(unsigned int pil) 270static void sun4m_disable_pil_irq(unsigned int pil)
249{ 271{
250 sun4m_interrupts->set = cpu_pil_to_imask[pil]; 272 sbus_writel(cpu_pil_to_imask[pil], &sun4m_irq_global->mask_set);
251} 273}
252 274
253static void sun4m_enable_pil_irq(unsigned int pil) 275static void sun4m_enable_pil_irq(unsigned int pil)
254{ 276{
255 sun4m_interrupts->clear = cpu_pil_to_imask[pil]; 277 sbus_writel(cpu_pil_to_imask[pil], &sun4m_irq_global->mask_clear);
256} 278}
257 279
258#ifdef CONFIG_SMP 280#ifdef CONFIG_SMP
259static void sun4m_send_ipi(int cpu, int level) 281static void sun4m_send_ipi(int cpu, int level)
260{ 282{
261 unsigned long mask; 283 unsigned long mask = sun4m_get_irqmask(level);
262 284 sbus_writel(mask, &sun4m_irq_percpu[cpu]->set);
263 mask = sun4m_get_irqmask(level);
264 sun4m_interrupts->cpu_intregs[cpu].set = mask;
265} 285}
266 286
267static void sun4m_clear_ipi(int cpu, int level) 287static void sun4m_clear_ipi(int cpu, int level)
268{ 288{
269 unsigned long mask; 289 unsigned long mask = sun4m_get_irqmask(level);
270 290 sbus_writel(mask, &sun4m_irq_percpu[cpu]->clear);
271 mask = sun4m_get_irqmask(level);
272 sun4m_interrupts->cpu_intregs[cpu].clear = mask;
273} 291}
274 292
275static void sun4m_set_udt(int cpu) 293static void sun4m_set_udt(int cpu)
276{ 294{
277 sun4m_interrupts->undirected_target = cpu; 295 sbus_writel(cpu, &sun4m_irq_global->interrupt_target);
278} 296}
279#endif 297#endif
280 298
281#define OBIO_INTR 0x20 299struct sun4m_timer_percpu {
282#define TIMER_IRQ (OBIO_INTR | 10) 300 u32 l14_limit;
283#define PROFILE_IRQ (OBIO_INTR | 14) 301 u32 l14_count;
302 u32 l14_limit_noclear;
303 u32 user_timer_start_stop;
304};
305
306static struct sun4m_timer_percpu __iomem *timers_percpu[SUN4M_NCPUS];
307
308struct sun4m_timer_global {
309 u32 l10_limit;
310 u32 l10_count;
311 u32 l10_limit_noclear;
312 u32 reserved;
313 u32 timer_config;
314};
315
316static struct sun4m_timer_global __iomem *timers_global;
317
318#define TIMER_IRQ (OBP_INT_LEVEL_ONBOARD | 10)
284 319
285static struct sun4m_timer_regs *sun4m_timers;
286unsigned int lvl14_resolution = (((1000000/HZ) + 1) << 10); 320unsigned int lvl14_resolution = (((1000000/HZ) + 1) << 10);
287 321
288static void sun4m_clear_clock_irq(void) 322static void sun4m_clear_clock_irq(void)
289{ 323{
290 volatile unsigned int clear_intr; 324 sbus_readl(&timers_global->l10_limit);
291 clear_intr = sun4m_timers->l10_timer_limit;
292} 325}
293 326
294static void sun4m_clear_profile_irq(int cpu) 327void sun4m_nmi(struct pt_regs *regs)
295{ 328{
296 volatile unsigned int clear; 329 unsigned long afsr, afar, si;
297 330
298 clear = sun4m_timers->cpu_timers[cpu].l14_timer_limit; 331 printk(KERN_ERR "Aieee: sun4m NMI received!\n");
332 /* XXX HyperSparc hack XXX */
333 __asm__ __volatile__("mov 0x500, %%g1\n\t"
334 "lda [%%g1] 0x4, %0\n\t"
335 "mov 0x600, %%g1\n\t"
336 "lda [%%g1] 0x4, %1\n\t" :
337 "=r" (afsr), "=r" (afar));
338 printk(KERN_ERR "afsr=%08lx afar=%08lx\n", afsr, afar);
339 si = sbus_readl(&sun4m_irq_global->pending);
340 printk(KERN_ERR "si=%08lx\n", si);
341 if (si & SUN4M_INT_MODULE_ERR)
342 printk(KERN_ERR "Module async error\n");
343 if (si & SUN4M_INT_M2S_WRITE_ERR)
344 printk(KERN_ERR "MBus/SBus async error\n");
345 if (si & SUN4M_INT_ECC_ERR)
346 printk(KERN_ERR "ECC memory error\n");
347 if (si & SUN4M_INT_VME_ERR)
348 printk(KERN_ERR "VME async error\n");
349 printk(KERN_ERR "you lose buddy boy...\n");
350 show_regs(regs);
351 prom_halt();
352}
353
354/* Exported for sun4m_smp.c */
355void sun4m_clear_profile_irq(int cpu)
356{
357 sbus_readl(&timers_percpu[cpu]->l14_limit);
299} 358}
300 359
301static void sun4m_load_profile_irq(int cpu, unsigned int limit) 360static void sun4m_load_profile_irq(int cpu, unsigned int limit)
302{ 361{
303 sun4m_timers->cpu_timers[cpu].l14_timer_limit = limit; 362 sbus_writel(limit, &timers_percpu[cpu]->l14_limit);
304} 363}
305 364
306static void __init sun4m_init_timers(irq_handler_t counter_fn) 365static void __init sun4m_init_timers(irq_handler_t counter_fn)
307{ 366{
308 int reg_count, irq, cpu; 367 struct device_node *dp = of_find_node_by_name(NULL, "counter");
309 struct linux_prom_registers cnt_regs[PROMREG_MAX]; 368 int i, err, len, num_cpu_timers;
310 int obio_node, cnt_node; 369 const u32 *addr;
311 struct resource r; 370
312 371 if (!dp) {
313 cnt_node = 0; 372 printk(KERN_ERR "sun4m_init_timers: No 'counter' node.\n");
314 if((obio_node = 373 return;
315 prom_searchsiblings (prom_getchild(prom_root_node), "obio")) == 0 ||
316 (obio_node = prom_getchild (obio_node)) == 0 ||
317 (cnt_node = prom_searchsiblings (obio_node, "counter")) == 0) {
318 prom_printf("Cannot find /obio/counter node\n");
319 prom_halt();
320 } 374 }
321 reg_count = prom_getproperty(cnt_node, "reg", 375
322 (void *) cnt_regs, sizeof(cnt_regs)); 376 addr = of_get_property(dp, "address", &len);
323 reg_count = (reg_count/sizeof(struct linux_prom_registers)); 377 if (!addr) {
324 378 printk(KERN_ERR "sun4m_init_timers: No 'address' prop.\n");
325 /* Apply the obio ranges to the timer registers. */ 379 return;
326 prom_apply_obio_ranges(cnt_regs, reg_count);
327
328 cnt_regs[4].phys_addr = cnt_regs[reg_count-1].phys_addr;
329 cnt_regs[4].reg_size = cnt_regs[reg_count-1].reg_size;
330 cnt_regs[4].which_io = cnt_regs[reg_count-1].which_io;
331 for(obio_node = 1; obio_node < 4; obio_node++) {
332 cnt_regs[obio_node].phys_addr =
333 cnt_regs[obio_node-1].phys_addr + PAGE_SIZE;
334 cnt_regs[obio_node].reg_size = cnt_regs[obio_node-1].reg_size;
335 cnt_regs[obio_node].which_io = cnt_regs[obio_node-1].which_io;
336 } 380 }
337 381
338 memset((char*)&r, 0, sizeof(struct resource)); 382 num_cpu_timers = (len / sizeof(u32)) - 1;
339 /* Map the per-cpu Counter registers. */ 383 for (i = 0; i < num_cpu_timers; i++) {
340 r.flags = cnt_regs[0].which_io; 384 timers_percpu[i] = (void __iomem *)
341 r.start = cnt_regs[0].phys_addr; 385 (unsigned long) addr[i];
342 sun4m_timers = (struct sun4m_timer_regs *) sbus_ioremap(&r, 0,
343 PAGE_SIZE*SUN4M_NCPUS, "sun4m_cpu_cnt");
344 /* Map the system Counter register. */
345 /* XXX Here we expect consequent calls to yeld adjusent maps. */
346 r.flags = cnt_regs[4].which_io;
347 r.start = cnt_regs[4].phys_addr;
348 sbus_ioremap(&r, 0, cnt_regs[4].reg_size, "sun4m_sys_cnt");
349
350 sun4m_timers->l10_timer_limit = (((1000000/HZ) + 1) << 10);
351 master_l10_counter = &sun4m_timers->l10_cur_count;
352 master_l10_limit = &sun4m_timers->l10_timer_limit;
353
354 irq = request_irq(TIMER_IRQ,
355 counter_fn,
356 (IRQF_DISABLED | SA_STATIC_ALLOC),
357 "timer", NULL);
358 if (irq) {
359 prom_printf("time_init: unable to attach IRQ%d\n",TIMER_IRQ);
360 prom_halt();
361 } 386 }
362 387 timers_global = (void __iomem *)
363 if (!cpu_find_by_instance(1, NULL, NULL)) { 388 (unsigned long) addr[num_cpu_timers];
364 for(cpu = 0; cpu < 4; cpu++) 389
365 sun4m_timers->cpu_timers[cpu].l14_timer_limit = 0; 390 sbus_writel((((1000000/HZ) + 1) << 10), &timers_global->l10_limit);
366 sun4m_interrupts->set = SUN4M_INT_E14; 391
367 } else { 392 master_l10_counter = &timers_global->l10_count;
368 sun4m_timers->cpu_timers[0].l14_timer_limit = 0; 393
394 err = request_irq(TIMER_IRQ, counter_fn,
395 (IRQF_DISABLED | SA_STATIC_ALLOC), "timer", NULL);
396 if (err) {
397 printk(KERN_ERR "sun4m_init_timers: Register IRQ error %d.\n",
398 err);
399 return;
369 } 400 }
401
402 for (i = 0; i < num_cpu_timers; i++)
403 sbus_writel(0, &timers_percpu[i]->l14_limit);
404 if (num_cpu_timers == 4)
405 sbus_writel(SUN4M_INT_E14, &sun4m_irq_global->mask_set);
406
370#ifdef CONFIG_SMP 407#ifdef CONFIG_SMP
371 { 408 {
372 unsigned long flags; 409 unsigned long flags;
@@ -390,70 +427,43 @@ static void __init sun4m_init_timers(irq_handler_t counter_fn)
390 427
391void __init sun4m_init_IRQ(void) 428void __init sun4m_init_IRQ(void)
392{ 429{
393 int ie_node,i; 430 struct device_node *dp = of_find_node_by_name(NULL, "interrupt");
394 struct linux_prom_registers int_regs[PROMREG_MAX]; 431 int len, i, mid, num_cpu_iregs;
395 int num_regs; 432 const u32 *addr;
396 struct resource r; 433
397 int mid; 434 if (!dp) {
398 435 printk(KERN_ERR "sun4m_init_IRQ: No 'interrupt' node.\n");
399 local_irq_disable(); 436 return;
400 if((ie_node = prom_searchsiblings(prom_getchild(prom_root_node), "obio")) == 0 ||
401 (ie_node = prom_getchild (ie_node)) == 0 ||
402 (ie_node = prom_searchsiblings (ie_node, "interrupt")) == 0) {
403 prom_printf("Cannot find /obio/interrupt node\n");
404 prom_halt();
405 } 437 }
406 num_regs = prom_getproperty(ie_node, "reg", (char *) int_regs, 438
407 sizeof(int_regs)); 439 addr = of_get_property(dp, "address", &len);
408 num_regs = (num_regs/sizeof(struct linux_prom_registers)); 440 if (!addr) {
409 441 printk(KERN_ERR "sun4m_init_IRQ: No 'address' prop.\n");
410 /* Apply the obio ranges to these registers. */ 442 return;
411 prom_apply_obio_ranges(int_regs, num_regs);
412
413 int_regs[4].phys_addr = int_regs[num_regs-1].phys_addr;
414 int_regs[4].reg_size = int_regs[num_regs-1].reg_size;
415 int_regs[4].which_io = int_regs[num_regs-1].which_io;
416 for(ie_node = 1; ie_node < 4; ie_node++) {
417 int_regs[ie_node].phys_addr = int_regs[ie_node-1].phys_addr + PAGE_SIZE;
418 int_regs[ie_node].reg_size = int_regs[ie_node-1].reg_size;
419 int_regs[ie_node].which_io = int_regs[ie_node-1].which_io;
420 } 443 }
421 444
422 memset((char *)&r, 0, sizeof(struct resource)); 445 num_cpu_iregs = (len / sizeof(u32)) - 1;
423 /* Map the interrupt registers for all possible cpus. */ 446 for (i = 0; i < num_cpu_iregs; i++) {
424 r.flags = int_regs[0].which_io; 447 sun4m_irq_percpu[i] = (void __iomem *)
425 r.start = int_regs[0].phys_addr; 448 (unsigned long) addr[i];
426 sun4m_interrupts = (struct sun4m_intregs *) sbus_ioremap(&r, 0, 449 }
427 PAGE_SIZE*SUN4M_NCPUS, "interrupts_percpu"); 450 sun4m_irq_global = (void __iomem *)
451 (unsigned long) addr[num_cpu_iregs];
428 452
429 /* Map the system interrupt control registers. */ 453 local_irq_disable();
430 r.flags = int_regs[4].which_io;
431 r.start = int_regs[4].phys_addr;
432 sbus_ioremap(&r, 0, int_regs[4].reg_size, "interrupts_system");
433 454
434 sun4m_interrupts->set = ~SUN4M_INT_MASKALL; 455 sbus_writel(~SUN4M_INT_MASKALL, &sun4m_irq_global->mask_set);
435 for (i = 0; !cpu_find_by_instance(i, NULL, &mid); i++) 456 for (i = 0; !cpu_find_by_instance(i, NULL, &mid); i++)
436 sun4m_interrupts->cpu_intregs[mid].clear = ~0x17fff; 457 sbus_writel(~0x17fff, &sun4m_irq_percpu[mid]->clear);
437 458
438 if (!cpu_find_by_instance(1, NULL, NULL)) { 459 if (num_cpu_iregs == 4)
439 /* system wide interrupts go to cpu 0, this should always 460 sbus_writel(0, &sun4m_irq_global->interrupt_target);
440 * be safe because it is guaranteed to be fitted or OBP doesn't 461
441 * come up
442 *
443 * Not sure, but writing here on SLAVIO systems may puke
444 * so I don't do it unless there is more than 1 cpu.
445 */
446 irq_rcvreg = (unsigned long *)
447 &sun4m_interrupts->undirected_target;
448 sun4m_interrupts->undirected_target = 0;
449 }
450 BTFIXUPSET_CALL(sbint_to_irq, sun4m_sbint_to_irq, BTFIXUPCALL_NORM);
451 BTFIXUPSET_CALL(enable_irq, sun4m_enable_irq, BTFIXUPCALL_NORM); 462 BTFIXUPSET_CALL(enable_irq, sun4m_enable_irq, BTFIXUPCALL_NORM);
452 BTFIXUPSET_CALL(disable_irq, sun4m_disable_irq, BTFIXUPCALL_NORM); 463 BTFIXUPSET_CALL(disable_irq, sun4m_disable_irq, BTFIXUPCALL_NORM);
453 BTFIXUPSET_CALL(enable_pil_irq, sun4m_enable_pil_irq, BTFIXUPCALL_NORM); 464 BTFIXUPSET_CALL(enable_pil_irq, sun4m_enable_pil_irq, BTFIXUPCALL_NORM);
454 BTFIXUPSET_CALL(disable_pil_irq, sun4m_disable_pil_irq, BTFIXUPCALL_NORM); 465 BTFIXUPSET_CALL(disable_pil_irq, sun4m_disable_pil_irq, BTFIXUPCALL_NORM);
455 BTFIXUPSET_CALL(clear_clock_irq, sun4m_clear_clock_irq, BTFIXUPCALL_NORM); 466 BTFIXUPSET_CALL(clear_clock_irq, sun4m_clear_clock_irq, BTFIXUPCALL_NORM);
456 BTFIXUPSET_CALL(clear_profile_irq, sun4m_clear_profile_irq, BTFIXUPCALL_NORM);
457 BTFIXUPSET_CALL(load_profile_irq, sun4m_load_profile_irq, BTFIXUPCALL_NORM); 467 BTFIXUPSET_CALL(load_profile_irq, sun4m_load_profile_irq, BTFIXUPCALL_NORM);
458 sparc_init_timers = sun4m_init_timers; 468 sparc_init_timers = sun4m_init_timers;
459#ifdef CONFIG_SMP 469#ifdef CONFIG_SMP
@@ -461,5 +471,6 @@ void __init sun4m_init_IRQ(void)
461 BTFIXUPSET_CALL(clear_cpu_int, sun4m_clear_ipi, BTFIXUPCALL_NORM); 471 BTFIXUPSET_CALL(clear_cpu_int, sun4m_clear_ipi, BTFIXUPCALL_NORM);
462 BTFIXUPSET_CALL(set_irq_udt, sun4m_set_udt, BTFIXUPCALL_NORM); 472 BTFIXUPSET_CALL(set_irq_udt, sun4m_set_udt, BTFIXUPCALL_NORM);
463#endif 473#endif
474
464 /* Cannot enable interrupts until OBP ticker is disabled. */ 475 /* Cannot enable interrupts until OBP ticker is disabled. */
465} 476}
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index a14a76ac7f36..0c564ba9e709 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -71,6 +71,8 @@ void __cpuinit smp4m_callin(void)
71 local_flush_cache_all(); 71 local_flush_cache_all();
72 local_flush_tlb_all(); 72 local_flush_tlb_all();
73 73
74 notify_cpu_starting(cpuid);
75
74 /* Get our local ticker going. */ 76 /* Get our local ticker going. */
75 smp_setup_percpu_timer(); 77 smp_setup_percpu_timer();
76 78
@@ -313,6 +315,8 @@ void smp4m_cross_call_irq(void)
313 ccall_info.processors_out[i] = 1; 315 ccall_info.processors_out[i] = 1;
314} 316}
315 317
318extern void sun4m_clear_profile_irq(int cpu);
319
316void smp4m_percpu_timer_interrupt(struct pt_regs *regs) 320void smp4m_percpu_timer_interrupt(struct pt_regs *regs)
317{ 321{
318 struct pt_regs *old_regs; 322 struct pt_regs *old_regs;
@@ -320,7 +324,7 @@ void smp4m_percpu_timer_interrupt(struct pt_regs *regs)
320 324
321 old_regs = set_irq_regs(regs); 325 old_regs = set_irq_regs(regs);
322 326
323 clear_profile_irq(cpu); 327 sun4m_clear_profile_irq(cpu);
324 328
325 profile_tick(CPU_PROFILING); 329 profile_tick(CPU_PROFILING);
326 330
diff --git a/arch/sparc/kernel/sun4setup.c b/arch/sparc/kernel/sun4setup.c
deleted file mode 100644
index 229a52f55f16..000000000000
--- a/arch/sparc/kernel/sun4setup.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/* sun4setup.c: Setup the hardware address of various items in the sun4
2 * architecture. Called from idprom_init
3 *
4 * Copyright (C) 1998 Chris G. Davis (cdavis@cois.on.ca)
5 */
6
7#include <asm/page.h>
8#include <asm/oplib.h>
9#include <asm/idprom.h>
10#include <asm/sun4paddr.h>
11#include <asm/machines.h>
12
13int sun4_memreg_physaddr;
14int sun4_ie_physaddr;
15int sun4_clock_physaddr;
16int sun4_timer_physaddr;
17int sun4_eth_physaddr;
18int sun4_si_physaddr;
19int sun4_bwtwo_physaddr;
20int sun4_zs0_physaddr;
21int sun4_zs1_physaddr;
22int sun4_dma_physaddr;
23int sun4_esp_physaddr;
24int sun4_ie_physaddr;
25
26void __init sun4setup(void)
27{
28 printk("Sun4 Hardware Setup v1.0 18/May/98 Chris Davis (cdavis@cois.on.ca). ");
29 /*
30 setup standard sun4 info
31 */
32 sun4_ie_physaddr=SUN4_IE_PHYSADDR;
33
34 /*
35 setup model specific info
36 */
37 switch(idprom->id_machtype) {
38 case (SM_SUN4 | SM_4_260 ):
39 printk("Setup for a SUN4/260\n");
40 sun4_memreg_physaddr=SUN4_200_MEMREG_PHYSADDR;
41 sun4_clock_physaddr=SUN4_200_CLOCK_PHYSADDR;
42 sun4_timer_physaddr=SUN4_UNUSED_PHYSADDR;
43 sun4_eth_physaddr=SUN4_200_ETH_PHYSADDR;
44 sun4_si_physaddr=SUN4_200_SI_PHYSADDR;
45 sun4_bwtwo_physaddr=SUN4_200_BWTWO_PHYSADDR;
46 sun4_dma_physaddr=SUN4_UNUSED_PHYSADDR;
47 sun4_esp_physaddr=SUN4_UNUSED_PHYSADDR;
48 break;
49 case (SM_SUN4 | SM_4_330 ):
50 printk("Setup for a SUN4/330\n");
51 sun4_memreg_physaddr=SUN4_300_MEMREG_PHYSADDR;
52 sun4_clock_physaddr=SUN4_300_CLOCK_PHYSADDR;
53 sun4_timer_physaddr=SUN4_300_TIMER_PHYSADDR;
54 sun4_eth_physaddr=SUN4_300_ETH_PHYSADDR;
55 sun4_si_physaddr=SUN4_UNUSED_PHYSADDR;
56 sun4_bwtwo_physaddr=SUN4_300_BWTWO_PHYSADDR;
57 sun4_dma_physaddr=SUN4_300_DMA_PHYSADDR;
58 sun4_esp_physaddr=SUN4_300_ESP_PHYSADDR;
59 break;
60 case (SM_SUN4 | SM_4_470 ):
61 printk("Setup for a SUN4/470\n");
62 sun4_memreg_physaddr=SUN4_400_MEMREG_PHYSADDR;
63 sun4_clock_physaddr=SUN4_400_CLOCK_PHYSADDR;
64 sun4_timer_physaddr=SUN4_400_TIMER_PHYSADDR;
65 sun4_eth_physaddr=SUN4_400_ETH_PHYSADDR;
66 sun4_si_physaddr=SUN4_UNUSED_PHYSADDR;
67 sun4_bwtwo_physaddr=SUN4_400_BWTWO_PHYSADDR;
68 sun4_dma_physaddr=SUN4_400_DMA_PHYSADDR;
69 sun4_esp_physaddr=SUN4_400_ESP_PHYSADDR;
70 break;
71 default:
72 ;
73 }
74}
75
diff --git a/arch/sparc/kernel/sys_sparc.c b/arch/sparc/kernel/sys_sparc.c
index 4d73421559c3..03035c852a43 100644
--- a/arch/sparc/kernel/sys_sparc.c
+++ b/arch/sparc/kernel/sys_sparc.c
@@ -53,7 +53,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
53 /* See asm-sparc/uaccess.h */ 53 /* See asm-sparc/uaccess.h */
54 if (len > TASK_SIZE - PAGE_SIZE) 54 if (len > TASK_SIZE - PAGE_SIZE)
55 return -ENOMEM; 55 return -ENOMEM;
56 if (ARCH_SUN4C_SUN4 && len > 0x20000000) 56 if (ARCH_SUN4C && len > 0x20000000)
57 return -ENOMEM; 57 return -ENOMEM;
58 if (!addr) 58 if (!addr)
59 addr = TASK_UNMAPPED_BASE; 59 addr = TASK_UNMAPPED_BASE;
@@ -65,7 +65,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
65 65
66 for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) { 66 for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
67 /* At this point: (!vmm || addr < vmm->vm_end). */ 67 /* At this point: (!vmm || addr < vmm->vm_end). */
68 if (ARCH_SUN4C_SUN4 && addr < 0xe0000000 && 0x20000000 - len < addr) { 68 if (ARCH_SUN4C && addr < 0xe0000000 && 0x20000000 - len < addr) {
69 addr = PAGE_OFFSET; 69 addr = PAGE_OFFSET;
70 vmm = find_vma(current->mm, PAGE_OFFSET); 70 vmm = find_vma(current->mm, PAGE_OFFSET);
71 } 71 }
@@ -81,7 +81,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
81 81
82asmlinkage unsigned long sparc_brk(unsigned long brk) 82asmlinkage unsigned long sparc_brk(unsigned long brk)
83{ 83{
84 if(ARCH_SUN4C_SUN4) { 84 if(ARCH_SUN4C) {
85 if ((brk & 0xe0000000) != (current->mm->brk & 0xe0000000)) 85 if ((brk & 0xe0000000) != (current->mm->brk & 0xe0000000))
86 return current->mm->brk; 86 return current->mm->brk;
87 } 87 }
@@ -221,7 +221,7 @@ out:
221 221
222int sparc_mmap_check(unsigned long addr, unsigned long len) 222int sparc_mmap_check(unsigned long addr, unsigned long len)
223{ 223{
224 if (ARCH_SUN4C_SUN4 && 224 if (ARCH_SUN4C &&
225 (len > 0x20000000 || 225 (len > 0x20000000 ||
226 (addr < 0xe0000000 && addr + len > 0x20000000))) 226 (addr < 0xe0000000 && addr + len > 0x20000000)))
227 return -EINVAL; 227 return -EINVAL;
diff --git a/arch/sparc/kernel/tick14.c b/arch/sparc/kernel/tick14.c
index 707bfda86570..138bbf5f8724 100644
--- a/arch/sparc/kernel/tick14.c
+++ b/arch/sparc/kernel/tick14.c
@@ -1,31 +1,12 @@
1/* tick14.c 1/* tick14.c
2 * linux/arch/sparc/kernel/tick14.c
3 * 2 *
4 * Copyright (C) 1996 David Redman (djhr@tadpole.co.uk) 3 * Copyright (C) 1996 David Redman (djhr@tadpole.co.uk)
5 * 4 *
6 * This file handles the Sparc specific level14 ticker 5 * This file handles the Sparc specific level14 ticker
7 * This is really useful for profiling OBP uses it for keyboard 6 * This is really useful for profiling OBP uses it for keyboard
8 * aborts and other stuff. 7 * aborts and other stuff.
9 *
10 *
11 */ 8 */
12#include <linux/errno.h>
13#include <linux/sched.h>
14#include <linux/kernel.h> 9#include <linux/kernel.h>
15#include <linux/param.h>
16#include <linux/string.h>
17#include <linux/mm.h>
18#include <linux/timex.h>
19#include <linux/interrupt.h>
20
21#include <asm/oplib.h>
22#include <asm/timer.h>
23#include <asm/mostek.h>
24#include <asm/system.h>
25#include <asm/irq.h>
26#include <asm/io.h>
27
28#include "irq.h"
29 10
30extern unsigned long lvl14_save[5]; 11extern unsigned long lvl14_save[5];
31static unsigned long *linux_lvl14 = NULL; 12static unsigned long *linux_lvl14 = NULL;
@@ -56,31 +37,3 @@ void install_obp_ticker(void)
56 linux_lvl14[2] = obp_lvl14[2]; 37 linux_lvl14[2] = obp_lvl14[2];
57 linux_lvl14[3] = obp_lvl14[3]; 38 linux_lvl14[3] = obp_lvl14[3];
58} 39}
59
60void claim_ticker14(irq_handler_t handler,
61 int irq_nr, unsigned int timeout )
62{
63 int cpu = smp_processor_id();
64
65 /* first we copy the obp handler instructions
66 */
67 __disable_irq(irq_nr);
68 if (!handler)
69 return;
70
71 linux_lvl14 = (unsigned long *)lvl14_save[4];
72 obp_lvl14[0] = linux_lvl14[0];
73 obp_lvl14[1] = linux_lvl14[1];
74 obp_lvl14[2] = linux_lvl14[2];
75 obp_lvl14[3] = linux_lvl14[3];
76
77 if (!request_irq(irq_nr,
78 handler,
79 (IRQF_DISABLED | SA_STATIC_ALLOC),
80 "counter14",
81 NULL)) {
82 install_linux_ticker();
83 load_profile_irq(cpu, timeout);
84 __enable_irq(irq_nr);
85 }
86}
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
index 0762f5db1924..62c1d94cb434 100644
--- a/arch/sparc/kernel/time.c
+++ b/arch/sparc/kernel/time.c
@@ -23,22 +23,24 @@
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/time.h> 25#include <linux/time.h>
26#include <linux/rtc.h>
27#include <linux/rtc/m48t59.h>
26#include <linux/timex.h> 28#include <linux/timex.h>
27#include <linux/init.h> 29#include <linux/init.h>
28#include <linux/pci.h> 30#include <linux/pci.h>
29#include <linux/ioport.h> 31#include <linux/ioport.h>
30#include <linux/profile.h> 32#include <linux/profile.h>
33#include <linux/of.h>
31#include <linux/of_device.h> 34#include <linux/of_device.h>
35#include <linux/platform_device.h>
32 36
33#include <asm/oplib.h> 37#include <asm/oplib.h>
34#include <asm/timer.h> 38#include <asm/timer.h>
35#include <asm/mostek.h>
36#include <asm/system.h> 39#include <asm/system.h>
37#include <asm/irq.h> 40#include <asm/irq.h>
38#include <asm/io.h> 41#include <asm/io.h>
39#include <asm/idprom.h> 42#include <asm/idprom.h>
40#include <asm/machines.h> 43#include <asm/machines.h>
41#include <asm/sun4paddr.h>
42#include <asm/page.h> 44#include <asm/page.h>
43#include <asm/pcic.h> 45#include <asm/pcic.h>
44#include <asm/irq_regs.h> 46#include <asm/irq_regs.h>
@@ -46,34 +48,9 @@
46#include "irq.h" 48#include "irq.h"
47 49
48DEFINE_SPINLOCK(rtc_lock); 50DEFINE_SPINLOCK(rtc_lock);
49static enum sparc_clock_type sp_clock_typ;
50DEFINE_SPINLOCK(mostek_lock);
51void __iomem *mstk48t02_regs = NULL;
52static struct mostek48t08 __iomem *mstk48t08_regs = NULL;
53static int set_rtc_mmss(unsigned long); 51static int set_rtc_mmss(unsigned long);
54static int sbus_do_settimeofday(struct timespec *tv); 52static int sbus_do_settimeofday(struct timespec *tv);
55 53
56#ifdef CONFIG_SUN4
57struct intersil *intersil_clock;
58#define intersil_cmd(intersil_reg, intsil_cmd) intersil_reg->int_cmd_reg = \
59 (intsil_cmd)
60
61#define intersil_intr(intersil_reg, intsil_cmd) intersil_reg->int_intr_reg = \
62 (intsil_cmd)
63
64#define intersil_start(intersil_reg) intersil_cmd(intersil_reg, \
65 ( INTERSIL_START | INTERSIL_32K | INTERSIL_NORMAL | INTERSIL_24H |\
66 INTERSIL_INTR_ENABLE))
67
68#define intersil_stop(intersil_reg) intersil_cmd(intersil_reg, \
69 ( INTERSIL_STOP | INTERSIL_32K | INTERSIL_NORMAL | INTERSIL_24H |\
70 INTERSIL_INTR_ENABLE))
71
72#define intersil_read_intr(intersil_reg, towhere) towhere = \
73 intersil_reg->int_intr_reg
74
75#endif
76
77unsigned long profile_pc(struct pt_regs *regs) 54unsigned long profile_pc(struct pt_regs *regs)
78{ 55{
79 extern char __copy_user_begin[], __copy_user_end[]; 56 extern char __copy_user_begin[], __copy_user_end[];
@@ -96,7 +73,6 @@ unsigned long profile_pc(struct pt_regs *regs)
96EXPORT_SYMBOL(profile_pc); 73EXPORT_SYMBOL(profile_pc);
97 74
98__volatile__ unsigned int *master_l10_counter; 75__volatile__ unsigned int *master_l10_counter;
99__volatile__ unsigned int *master_l10_limit;
100 76
101/* 77/*
102 * timer_interrupt() needs to keep up the real-time clock, 78 * timer_interrupt() needs to keep up the real-time clock,
@@ -116,15 +92,7 @@ static irqreturn_t timer_interrupt(int dummy, void *dev_id)
116 92
117 /* Protect counter clear so that do_gettimeoffset works */ 93 /* Protect counter clear so that do_gettimeoffset works */
118 write_seqlock(&xtime_lock); 94 write_seqlock(&xtime_lock);
119#ifdef CONFIG_SUN4 95
120 if((idprom->id_machtype == (SM_SUN4 | SM_4_260)) ||
121 (idprom->id_machtype == (SM_SUN4 | SM_4_110))) {
122 int temp;
123 intersil_read_intr(intersil_clock, temp);
124 /* re-enable the irq */
125 enable_pil_irq(10);
126 }
127#endif
128 clear_clock_irq(); 96 clear_clock_irq();
129 97
130 do_timer(1); 98 do_timer(1);
@@ -147,157 +115,56 @@ static irqreturn_t timer_interrupt(int dummy, void *dev_id)
147 return IRQ_HANDLED; 115 return IRQ_HANDLED;
148} 116}
149 117
150/* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ 118static unsigned char mostek_read_byte(struct device *dev, u32 ofs)
151static void __devinit kick_start_clock(void)
152{ 119{
153 struct mostek48t02 *regs = (struct mostek48t02 *)mstk48t02_regs; 120 struct platform_device *pdev = to_platform_device(dev);
154 unsigned char sec; 121 struct m48t59_plat_data *pdata = pdev->dev.platform_data;
155 int i, count; 122 void __iomem *regs = pdata->ioaddr;
156 123 unsigned char val = readb(regs + ofs);
157 prom_printf("CLOCK: Clock was stopped. Kick start "); 124
158 125 /* the year 0 is 1968 */
159 spin_lock_irq(&mostek_lock); 126 if (ofs == pdata->offset + M48T59_YEAR) {
160 127 val += 0x68;
161 /* Turn on the kick start bit to start the oscillator. */ 128 if ((val & 0xf) > 9)
162 regs->creg |= MSTK_CREG_WRITE; 129 val += 6;
163 regs->sec &= ~MSTK_STOP;
164 regs->hour |= MSTK_KICK_START;
165 regs->creg &= ~MSTK_CREG_WRITE;
166
167 spin_unlock_irq(&mostek_lock);
168
169 /* Delay to allow the clock oscillator to start. */
170 sec = MSTK_REG_SEC(regs);
171 for (i = 0; i < 3; i++) {
172 while (sec == MSTK_REG_SEC(regs))
173 for (count = 0; count < 100000; count++)
174 /* nothing */ ;
175 prom_printf(".");
176 sec = regs->sec;
177 }
178 prom_printf("\n");
179
180 spin_lock_irq(&mostek_lock);
181
182 /* Turn off kick start and set a "valid" time and date. */
183 regs->creg |= MSTK_CREG_WRITE;
184 regs->hour &= ~MSTK_KICK_START;
185 MSTK_SET_REG_SEC(regs,0);
186 MSTK_SET_REG_MIN(regs,0);
187 MSTK_SET_REG_HOUR(regs,0);
188 MSTK_SET_REG_DOW(regs,5);
189 MSTK_SET_REG_DOM(regs,1);
190 MSTK_SET_REG_MONTH(regs,8);
191 MSTK_SET_REG_YEAR(regs,1996 - MSTK_YEAR_ZERO);
192 regs->creg &= ~MSTK_CREG_WRITE;
193
194 spin_unlock_irq(&mostek_lock);
195
196 /* Ensure the kick start bit is off. If it isn't, turn it off. */
197 while (regs->hour & MSTK_KICK_START) {
198 prom_printf("CLOCK: Kick start still on!\n");
199
200 spin_lock_irq(&mostek_lock);
201 regs->creg |= MSTK_CREG_WRITE;
202 regs->hour &= ~MSTK_KICK_START;
203 regs->creg &= ~MSTK_CREG_WRITE;
204 spin_unlock_irq(&mostek_lock);
205 } 130 }
206 131 return val;
207 prom_printf("CLOCK: Kick start procedure successful.\n");
208}
209
210/* Return nonzero if the clock chip battery is low. */
211static inline int has_low_battery(void)
212{
213 struct mostek48t02 *regs = (struct mostek48t02 *)mstk48t02_regs;
214 unsigned char data1, data2;
215
216 spin_lock_irq(&mostek_lock);
217 data1 = regs->eeprom[0]; /* Read some data. */
218 regs->eeprom[0] = ~data1; /* Write back the complement. */
219 data2 = regs->eeprom[0]; /* Read back the complement. */
220 regs->eeprom[0] = data1; /* Restore the original value. */
221 spin_unlock_irq(&mostek_lock);
222
223 return (data1 == data2); /* Was the write blocked? */
224} 132}
225 133
226static void __devinit mostek_set_system_time(void) 134static void mostek_write_byte(struct device *dev, u32 ofs, u8 val)
227{ 135{
228 unsigned int year, mon, day, hour, min, sec; 136 struct platform_device *pdev = to_platform_device(dev);
229 struct mostek48t02 *mregs; 137 struct m48t59_plat_data *pdata = pdev->dev.platform_data;
230 138 void __iomem *regs = pdata->ioaddr;
231 mregs = (struct mostek48t02 *)mstk48t02_regs; 139
232 if(!mregs) { 140 if (ofs == pdata->offset + M48T59_YEAR) {
233 prom_printf("Something wrong, clock regs not mapped yet.\n"); 141 if (val < 0x68)
234 prom_halt(); 142 val += 0x32;
235 } 143 else
236 spin_lock_irq(&mostek_lock); 144 val -= 0x68;
237 mregs->creg |= MSTK_CREG_READ; 145 if ((val & 0xf) > 9)
238 sec = MSTK_REG_SEC(mregs); 146 val += 6;
239 min = MSTK_REG_MIN(mregs); 147 if ((val & 0xf0) > 0x9A)
240 hour = MSTK_REG_HOUR(mregs); 148 val += 0x60;
241 day = MSTK_REG_DOM(mregs); 149 }
242 mon = MSTK_REG_MONTH(mregs); 150 writeb(val, regs + ofs);
243 year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) );
244 xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
245 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
246 set_normalized_timespec(&wall_to_monotonic,
247 -xtime.tv_sec, -xtime.tv_nsec);
248 mregs->creg &= ~MSTK_CREG_READ;
249 spin_unlock_irq(&mostek_lock);
250} 151}
251 152
252/* Probe for the real time clock chip on Sun4 */ 153static struct m48t59_plat_data m48t59_data = {
253static inline void sun4_clock_probe(void) 154 .read_byte = mostek_read_byte,
254{ 155 .write_byte = mostek_write_byte,
255#ifdef CONFIG_SUN4 156};
256 int temp;
257 struct resource r;
258
259 memset(&r, 0, sizeof(r));
260 if( idprom->id_machtype == (SM_SUN4 | SM_4_330) ) {
261 sp_clock_typ = MSTK48T02;
262 r.start = sun4_clock_physaddr;
263 mstk48t02_regs = sbus_ioremap(&r, 0,
264 sizeof(struct mostek48t02), NULL);
265 mstk48t08_regs = NULL; /* To catch weirdness */
266 intersil_clock = NULL; /* just in case */
267
268 /* Kick start the clock if it is completely stopped. */
269 if (mostek_read(mstk48t02_regs + MOSTEK_SEC) & MSTK_STOP)
270 kick_start_clock();
271 } else if( idprom->id_machtype == (SM_SUN4 | SM_4_260)) {
272 /* intersil setup code */
273 printk("Clock: INTERSIL at %8x ",sun4_clock_physaddr);
274 sp_clock_typ = INTERSIL;
275 r.start = sun4_clock_physaddr;
276 intersil_clock = (struct intersil *)
277 sbus_ioremap(&r, 0, sizeof(*intersil_clock), "intersil");
278 mstk48t02_regs = 0; /* just be sure */
279 mstk48t08_regs = NULL; /* ditto */
280 /* initialise the clock */
281
282 intersil_intr(intersil_clock,INTERSIL_INT_100HZ);
283
284 intersil_start(intersil_clock);
285
286 intersil_read_intr(intersil_clock, temp);
287 while (!(temp & 0x80))
288 intersil_read_intr(intersil_clock, temp);
289
290 intersil_read_intr(intersil_clock, temp);
291 while (!(temp & 0x80))
292 intersil_read_intr(intersil_clock, temp);
293
294 intersil_stop(intersil_clock);
295 157
296 } 158/* resource is set at runtime */
297#endif 159static struct platform_device m48t59_rtc = {
298} 160 .name = "rtc-m48t59",
161 .id = 0,
162 .num_resources = 1,
163 .dev = {
164 .platform_data = &m48t59_data,
165 },
166};
299 167
300#ifndef CONFIG_SUN4
301static int __devinit clock_probe(struct of_device *op, const struct of_device_id *match) 168static int __devinit clock_probe(struct of_device *op, const struct of_device_id *match)
302{ 169{
303 struct device_node *dp = op->node; 170 struct device_node *dp = op->node;
@@ -306,38 +173,26 @@ static int __devinit clock_probe(struct of_device *op, const struct of_device_id
306 if (!model) 173 if (!model)
307 return -ENODEV; 174 return -ENODEV;
308 175
176 m48t59_rtc.resource = &op->resource[0];
309 if (!strcmp(model, "mk48t02")) { 177 if (!strcmp(model, "mk48t02")) {
310 sp_clock_typ = MSTK48T02;
311
312 /* Map the clock register io area read-only */ 178 /* Map the clock register io area read-only */
313 mstk48t02_regs = of_ioremap(&op->resource[0], 0, 179 m48t59_data.ioaddr = of_ioremap(&op->resource[0], 0,
314 sizeof(struct mostek48t02), 180 2048, "rtc-m48t59");
315 "mk48t02"); 181 m48t59_data.type = M48T59RTC_TYPE_M48T02;
316 mstk48t08_regs = NULL; /* To catch weirdness */
317 } else if (!strcmp(model, "mk48t08")) { 182 } else if (!strcmp(model, "mk48t08")) {
318 sp_clock_typ = MSTK48T08; 183 m48t59_data.ioaddr = of_ioremap(&op->resource[0], 0,
319 mstk48t08_regs = of_ioremap(&op->resource[0], 0, 184 8192, "rtc-m48t59");
320 sizeof(struct mostek48t08), 185 m48t59_data.type = M48T59RTC_TYPE_M48T08;
321 "mk48t08");
322
323 mstk48t02_regs = &mstk48t08_regs->regs;
324 } else 186 } else
325 return -ENODEV; 187 return -ENODEV;
326 188
327 /* Report a low battery voltage condition. */ 189 if (platform_device_register(&m48t59_rtc) < 0)
328 if (has_low_battery()) 190 printk(KERN_ERR "Registering RTC device failed\n");
329 printk(KERN_CRIT "NVRAM: Low battery voltage!\n");
330
331 /* Kick start the clock if it is completely stopped. */
332 if (mostek_read(mstk48t02_regs + MOSTEK_SEC) & MSTK_STOP)
333 kick_start_clock();
334
335 mostek_set_system_time();
336 191
337 return 0; 192 return 0;
338} 193}
339 194
340static struct of_device_id clock_match[] = { 195static struct of_device_id __initdata clock_match[] = {
341 { 196 {
342 .name = "eeprom", 197 .name = "eeprom",
343 }, 198 },
@@ -348,7 +203,7 @@ static struct of_platform_driver clock_driver = {
348 .match_table = clock_match, 203 .match_table = clock_match,
349 .probe = clock_probe, 204 .probe = clock_probe,
350 .driver = { 205 .driver = {
351 .name = "clock", 206 .name = "rtc",
352 }, 207 },
353}; 208};
354 209
@@ -364,7 +219,6 @@ static int __init clock_init(void)
364 * need to see the clock registers. 219 * need to see the clock registers.
365 */ 220 */
366fs_initcall(clock_init); 221fs_initcall(clock_init);
367#endif /* !CONFIG_SUN4 */
368 222
369static void __init sbus_time_init(void) 223static void __init sbus_time_init(void)
370{ 224{
@@ -372,51 +226,8 @@ static void __init sbus_time_init(void)
372 BTFIXUPSET_CALL(bus_do_settimeofday, sbus_do_settimeofday, BTFIXUPCALL_NORM); 226 BTFIXUPSET_CALL(bus_do_settimeofday, sbus_do_settimeofday, BTFIXUPCALL_NORM);
373 btfixup(); 227 btfixup();
374 228
375 if (ARCH_SUN4)
376 sun4_clock_probe();
377
378 sparc_init_timers(timer_interrupt); 229 sparc_init_timers(timer_interrupt);
379 230
380#ifdef CONFIG_SUN4
381 if(idprom->id_machtype == (SM_SUN4 | SM_4_330)) {
382 mostek_set_system_time();
383 } else if(idprom->id_machtype == (SM_SUN4 | SM_4_260) ) {
384 /* initialise the intersil on sun4 */
385 unsigned int year, mon, day, hour, min, sec;
386 int temp;
387 struct intersil *iregs;
388
389 iregs=intersil_clock;
390 if(!iregs) {
391 prom_printf("Something wrong, clock regs not mapped yet.\n");
392 prom_halt();
393 }
394
395 intersil_intr(intersil_clock,INTERSIL_INT_100HZ);
396 disable_pil_irq(10);
397 intersil_stop(iregs);
398 intersil_read_intr(intersil_clock, temp);
399
400 temp = iregs->clk.int_csec;
401
402 sec = iregs->clk.int_sec;
403 min = iregs->clk.int_min;
404 hour = iregs->clk.int_hour;
405 day = iregs->clk.int_day;
406 mon = iregs->clk.int_month;
407 year = MSTK_CVT_YEAR(iregs->clk.int_year);
408
409 enable_pil_irq(10);
410 intersil_start(iregs);
411
412 xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
413 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
414 set_normalized_timespec(&wall_to_monotonic,
415 -xtime.tv_sec, -xtime.tv_nsec);
416 printk("%u/%u/%u %u:%u:%u\n",day,mon,year,hour,min,sec);
417 }
418#endif
419
420 /* Now that OBP ticker has been silenced, it is safe to enable IRQ. */ 231 /* Now that OBP ticker has been silenced, it is safe to enable IRQ. */
421 local_irq_enable(); 232 local_irq_enable();
422} 233}
@@ -522,80 +333,15 @@ static int sbus_do_settimeofday(struct timespec *tv)
522 return 0; 333 return 0;
523} 334}
524 335
525/* 336static int set_rtc_mmss(unsigned long secs)
526 * BUG: This routine does not handle hour overflow properly; it just
527 * sets the minutes. Usually you won't notice until after reboot!
528 */
529static int set_rtc_mmss(unsigned long nowtime)
530{ 337{
531 int real_seconds, real_minutes, mostek_minutes; 338 struct rtc_device *rtc = rtc_class_open("rtc0");
532 struct mostek48t02 *regs = (struct mostek48t02 *)mstk48t02_regs; 339 int err = -1;
533 unsigned long flags;
534#ifdef CONFIG_SUN4
535 struct intersil *iregs = intersil_clock;
536 int temp;
537#endif
538 340
539 /* Not having a register set can lead to trouble. */ 341 if (rtc) {
540 if (!regs) { 342 err = rtc_set_mmss(rtc, secs);
541#ifdef CONFIG_SUN4 343 rtc_class_close(rtc);
542 if(!iregs)
543 return -1;
544 else {
545 temp = iregs->clk.int_csec;
546
547 mostek_minutes = iregs->clk.int_min;
548
549 real_seconds = nowtime % 60;
550 real_minutes = nowtime / 60;
551 if (((abs(real_minutes - mostek_minutes) + 15)/30) & 1)
552 real_minutes += 30; /* correct for half hour time zone */
553 real_minutes %= 60;
554
555 if (abs(real_minutes - mostek_minutes) < 30) {
556 intersil_stop(iregs);
557 iregs->clk.int_sec=real_seconds;
558 iregs->clk.int_min=real_minutes;
559 intersil_start(iregs);
560 } else {
561 printk(KERN_WARNING
562 "set_rtc_mmss: can't update from %d to %d\n",
563 mostek_minutes, real_minutes);
564 return -1;
565 }
566
567 return 0;
568 }
569#endif
570 } 344 }
571 345
572 spin_lock_irqsave(&mostek_lock, flags); 346 return err;
573 /* Read the current RTC minutes. */
574 regs->creg |= MSTK_CREG_READ;
575 mostek_minutes = MSTK_REG_MIN(regs);
576 regs->creg &= ~MSTK_CREG_READ;
577
578 /*
579 * since we're only adjusting minutes and seconds,
580 * don't interfere with hour overflow. This avoids
581 * messing with unknown time zones but requires your
582 * RTC not to be off by more than 15 minutes
583 */
584 real_seconds = nowtime % 60;
585 real_minutes = nowtime / 60;
586 if (((abs(real_minutes - mostek_minutes) + 15)/30) & 1)
587 real_minutes += 30; /* correct for half hour time zone */
588 real_minutes %= 60;
589
590 if (abs(real_minutes - mostek_minutes) < 30) {
591 regs->creg |= MSTK_CREG_WRITE;
592 MSTK_SET_REG_SEC(regs,real_seconds);
593 MSTK_SET_REG_MIN(regs,real_minutes);
594 regs->creg &= ~MSTK_CREG_WRITE;
595 spin_unlock_irqrestore(&mostek_lock, flags);
596 return 0;
597 } else {
598 spin_unlock_irqrestore(&mostek_lock, flags);
599 return -1;
600 }
601} 347}
diff --git a/arch/sparc/kernel/traps.c b/arch/sparc/kernel/traps.c
index 5d45d5fd8c99..2b7d50659036 100644
--- a/arch/sparc/kernel/traps.c
+++ b/arch/sparc/kernel/traps.c
@@ -43,23 +43,6 @@ void syscall_trace_exit(struct pt_regs *regs)
43{ 43{
44} 44}
45 45
46void sun4m_nmi(struct pt_regs *regs)
47{
48 unsigned long afsr, afar;
49
50 printk("Aieee: sun4m NMI received!\n");
51 /* XXX HyperSparc hack XXX */
52 __asm__ __volatile__("mov 0x500, %%g1\n\t"
53 "lda [%%g1] 0x4, %0\n\t"
54 "mov 0x600, %%g1\n\t"
55 "lda [%%g1] 0x4, %1\n\t" :
56 "=r" (afsr), "=r" (afar));
57 printk("afsr=%08lx afar=%08lx\n", afsr, afar);
58 printk("you lose buddy boy...\n");
59 show_regs(regs);
60 prom_halt();
61}
62
63void sun4d_nmi(struct pt_regs *regs) 46void sun4d_nmi(struct pt_regs *regs)
64{ 47{
65 printk("Aieee: sun4d NMI received!\n"); 48 printk("Aieee: sun4d NMI received!\n");
diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
index 109c8b22cb38..ea88955d97ff 100644
--- a/arch/sparc/mm/Makefile
+++ b/arch/sparc/mm/Makefile
@@ -3,13 +3,8 @@
3 3
4EXTRA_AFLAGS := -ansi 4EXTRA_AFLAGS := -ansi
5 5
6obj-y := fault.o init.o loadmmu.o generic.o extable.o btfixup.o 6obj-y := fault.o init.o loadmmu.o generic.o extable.o btfixup.o \
7 7 srmmu.o iommu.o io-unit.o hypersparc.o viking.o tsunami.o swift.o
8ifeq ($(CONFIG_SUN4),y)
9obj-y += nosrmmu.o
10else
11obj-y += srmmu.o iommu.o io-unit.o hypersparc.o viking.o tsunami.o swift.o
12endif
13 8
14ifdef CONFIG_HIGHMEM 9ifdef CONFIG_HIGHMEM
15obj-y += highmem.o 10obj-y += highmem.o
diff --git a/arch/sparc/mm/btfixup.c b/arch/sparc/mm/btfixup.c
index a312d127d47a..5175ac2f4820 100644
--- a/arch/sparc/mm/btfixup.c
+++ b/arch/sparc/mm/btfixup.c
@@ -20,11 +20,7 @@
20 20
21extern char *srmmu_name; 21extern char *srmmu_name;
22static char version[] __initdata = "Boot time fixup v1.6. 4/Mar/98 Jakub Jelinek (jj@ultra.linux.cz). Patching kernel for "; 22static char version[] __initdata = "Boot time fixup v1.6. 4/Mar/98 Jakub Jelinek (jj@ultra.linux.cz). Patching kernel for ";
23#ifdef CONFIG_SUN4
24static char str_sun4c[] __initdata = "sun4\n";
25#else
26static char str_sun4c[] __initdata = "sun4c\n"; 23static char str_sun4c[] __initdata = "sun4c\n";
27#endif
28static char str_srmmu[] __initdata = "srmmu[%s]/"; 24static char str_srmmu[] __initdata = "srmmu[%s]/";
29static char str_iommu[] __initdata = "iommu\n"; 25static char str_iommu[] __initdata = "iommu\n";
30static char str_iounit[] __initdata = "io-unit\n"; 26static char str_iounit[] __initdata = "io-unit\n";
@@ -86,7 +82,7 @@ void __init btfixup(void)
86 if (!visited) { 82 if (!visited) {
87 visited++; 83 visited++;
88 printk(version); 84 printk(version);
89 if (ARCH_SUN4C_SUN4) 85 if (ARCH_SUN4C)
90 printk(str_sun4c); 86 printk(str_sun4c);
91 else { 87 else {
92 printk(str_srmmu, srmmu_name); 88 printk(str_srmmu, srmmu_name);
diff --git a/arch/sparc/mm/fault.c b/arch/sparc/mm/fault.c
index 3604c2e86709..a507e1174662 100644
--- a/arch/sparc/mm/fault.c
+++ b/arch/sparc/mm/fault.c
@@ -191,7 +191,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
191 * only copy the information from the master page table, 191 * only copy the information from the master page table,
192 * nothing more. 192 * nothing more.
193 */ 193 */
194 if (!ARCH_SUN4C_SUN4 && address >= TASK_SIZE) 194 if (!ARCH_SUN4C && address >= TASK_SIZE)
195 goto vmalloc_fault; 195 goto vmalloc_fault;
196 196
197 info.si_code = SEGV_MAPERR; 197 info.si_code = SEGV_MAPERR;
diff --git a/arch/sparc/mm/init.c b/arch/sparc/mm/init.c
index e103f1bb3777..677c1e187a23 100644
--- a/arch/sparc/mm/init.c
+++ b/arch/sparc/mm/init.c
@@ -23,6 +23,7 @@
23#include <linux/highmem.h> 23#include <linux/highmem.h>
24#include <linux/bootmem.h> 24#include <linux/bootmem.h>
25#include <linux/pagemap.h> 25#include <linux/pagemap.h>
26#include <linux/poison.h>
26 27
27#include <asm/system.h> 28#include <asm/system.h>
28#include <asm/vac-ops.h> 29#include <asm/vac-ops.h>
@@ -480,6 +481,7 @@ void free_initmem (void)
480 for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) { 481 for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
481 struct page *p; 482 struct page *p;
482 483
484 memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
483 p = virt_to_page(addr); 485 p = virt_to_page(addr);
484 486
485 ClearPageReserved(p); 487 ClearPageReserved(p);
@@ -488,20 +490,26 @@ void free_initmem (void)
488 totalram_pages++; 490 totalram_pages++;
489 num_physpages++; 491 num_physpages++;
490 } 492 }
491 printk (KERN_INFO "Freeing unused kernel memory: %dk freed\n", (&__init_end - &__init_begin) >> 10); 493 printk(KERN_INFO "Freeing unused kernel memory: %dk freed\n",
494 (&__init_end - &__init_begin) >> 10);
492} 495}
493 496
494#ifdef CONFIG_BLK_DEV_INITRD 497#ifdef CONFIG_BLK_DEV_INITRD
495void free_initrd_mem(unsigned long start, unsigned long end) 498void free_initrd_mem(unsigned long start, unsigned long end)
496{ 499{
497 if (start < end) 500 if (start < end)
498 printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10); 501 printk(KERN_INFO "Freeing initrd memory: %ldk freed\n",
502 (end - start) >> 10);
499 for (; start < end; start += PAGE_SIZE) { 503 for (; start < end; start += PAGE_SIZE) {
500 struct page *p = virt_to_page(start); 504 struct page *p;
505
506 memset((void *)start, POISON_FREE_INITMEM, PAGE_SIZE);
507 p = virt_to_page(start);
501 508
502 ClearPageReserved(p); 509 ClearPageReserved(p);
503 init_page_count(p); 510 init_page_count(p);
504 __free_page(p); 511 __free_page(p);
512 totalram_pages++;
505 num_physpages++; 513 num_physpages++;
506 } 514 }
507} 515}
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
index f167835db3df..daadf5f88050 100644
--- a/arch/sparc/mm/io-unit.c
+++ b/arch/sparc/mm/io-unit.c
@@ -12,10 +12,11 @@
12#include <linux/highmem.h> /* pte_offset_map => kmap_atomic */ 12#include <linux/highmem.h> /* pte_offset_map => kmap_atomic */
13#include <linux/bitops.h> 13#include <linux/bitops.h>
14#include <linux/scatterlist.h> 14#include <linux/scatterlist.h>
15#include <linux/of.h>
16#include <linux/of_device.h>
15 17
16#include <asm/pgalloc.h> 18#include <asm/pgalloc.h>
17#include <asm/pgtable.h> 19#include <asm/pgtable.h>
18#include <asm/sbus.h>
19#include <asm/io.h> 20#include <asm/io.h>
20#include <asm/io-unit.h> 21#include <asm/io-unit.h>
21#include <asm/mxcc.h> 22#include <asm/mxcc.h>
@@ -34,13 +35,10 @@
34#define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID) 35#define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID)
35#define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM) 36#define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM)
36 37
37void __init 38static void __init iounit_iommu_init(struct of_device *op)
38iounit_init(int sbi_node, int io_node, struct sbus_bus *sbus)
39{ 39{
40 iopte_t *xpt, *xptend;
41 struct iounit_struct *iounit; 40 struct iounit_struct *iounit;
42 struct linux_prom_registers iommu_promregs[PROMREG_MAX]; 41 iopte_t *xpt, *xptend;
43 struct resource r;
44 42
45 iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC); 43 iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC);
46 if (!iounit) { 44 if (!iounit) {
@@ -55,18 +53,13 @@ iounit_init(int sbi_node, int io_node, struct sbus_bus *sbus)
55 iounit->rotor[1] = IOUNIT_BMAP2_START; 53 iounit->rotor[1] = IOUNIT_BMAP2_START;
56 iounit->rotor[2] = IOUNIT_BMAPM_START; 54 iounit->rotor[2] = IOUNIT_BMAPM_START;
57 55
58 xpt = NULL; 56 xpt = of_ioremap(&op->resource[2], 0, PAGE_SIZE * 16, "XPT");
59 if(prom_getproperty(sbi_node, "reg", (void *) iommu_promregs, 57 if (!xpt) {
60 sizeof(iommu_promregs)) != -1) { 58 prom_printf("SUN4D: Cannot map External Page Table.");
61 prom_apply_generic_ranges(io_node, 0, iommu_promregs, 3); 59 prom_halt();
62 memset(&r, 0, sizeof(r));
63 r.flags = iommu_promregs[2].which_io;
64 r.start = iommu_promregs[2].phys_addr;
65 xpt = (iopte_t *) sbus_ioremap(&r, 0, PAGE_SIZE * 16, "XPT");
66 } 60 }
67 if(!xpt) panic("Cannot map External Page Table.");
68 61
69 sbus->ofdev.dev.archdata.iommu = iounit; 62 op->dev.archdata.iommu = iounit;
70 iounit->page_table = xpt; 63 iounit->page_table = xpt;
71 spin_lock_init(&iounit->lock); 64 spin_lock_init(&iounit->lock);
72 65
@@ -75,6 +68,25 @@ iounit_init(int sbi_node, int io_node, struct sbus_bus *sbus)
75 iopte_val(*xpt++) = 0; 68 iopte_val(*xpt++) = 0;
76} 69}
77 70
71static int __init iounit_init(void)
72{
73 extern void sun4d_init_sbi_irq(void);
74 struct device_node *dp;
75
76 for_each_node_by_name(dp, "sbi") {
77 struct of_device *op = of_find_device_by_node(dp);
78
79 iounit_iommu_init(op);
80 of_propagate_archdata(op);
81 }
82
83 sun4d_init_sbi_irq();
84
85 return 0;
86}
87
88subsys_initcall(iounit_init);
89
78/* One has to hold iounit->lock to call this */ 90/* One has to hold iounit->lock to call this */
79static unsigned long iounit_get_area(struct iounit_struct *iounit, unsigned long vaddr, int size) 91static unsigned long iounit_get_area(struct iounit_struct *iounit, unsigned long vaddr, int size)
80{ 92{
@@ -124,10 +136,10 @@ nexti: scan = find_next_zero_bit(iounit->bmap, limit, scan);
124 return vaddr; 136 return vaddr;
125} 137}
126 138
127static __u32 iounit_get_scsi_one(char *vaddr, unsigned long len, struct sbus_bus *sbus) 139static __u32 iounit_get_scsi_one(struct device *dev, char *vaddr, unsigned long len)
128{ 140{
141 struct iounit_struct *iounit = dev->archdata.iommu;
129 unsigned long ret, flags; 142 unsigned long ret, flags;
130 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
131 143
132 spin_lock_irqsave(&iounit->lock, flags); 144 spin_lock_irqsave(&iounit->lock, flags);
133 ret = iounit_get_area(iounit, (unsigned long)vaddr, len); 145 ret = iounit_get_area(iounit, (unsigned long)vaddr, len);
@@ -135,10 +147,10 @@ static __u32 iounit_get_scsi_one(char *vaddr, unsigned long len, struct sbus_bus
135 return ret; 147 return ret;
136} 148}
137 149
138static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 150static void iounit_get_scsi_sgl(struct device *dev, struct scatterlist *sg, int sz)
139{ 151{
152 struct iounit_struct *iounit = dev->archdata.iommu;
140 unsigned long flags; 153 unsigned long flags;
141 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
142 154
143 /* FIXME: Cache some resolved pages - often several sg entries are to the same page */ 155 /* FIXME: Cache some resolved pages - often several sg entries are to the same page */
144 spin_lock_irqsave(&iounit->lock, flags); 156 spin_lock_irqsave(&iounit->lock, flags);
@@ -151,10 +163,10 @@ static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus
151 spin_unlock_irqrestore(&iounit->lock, flags); 163 spin_unlock_irqrestore(&iounit->lock, flags);
152} 164}
153 165
154static void iounit_release_scsi_one(__u32 vaddr, unsigned long len, struct sbus_bus *sbus) 166static void iounit_release_scsi_one(struct device *dev, __u32 vaddr, unsigned long len)
155{ 167{
168 struct iounit_struct *iounit = dev->archdata.iommu;
156 unsigned long flags; 169 unsigned long flags;
157 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
158 170
159 spin_lock_irqsave(&iounit->lock, flags); 171 spin_lock_irqsave(&iounit->lock, flags);
160 len = ((vaddr & ~PAGE_MASK) + len + (PAGE_SIZE-1)) >> PAGE_SHIFT; 172 len = ((vaddr & ~PAGE_MASK) + len + (PAGE_SIZE-1)) >> PAGE_SHIFT;
@@ -165,11 +177,11 @@ static void iounit_release_scsi_one(__u32 vaddr, unsigned long len, struct sbus_
165 spin_unlock_irqrestore(&iounit->lock, flags); 177 spin_unlock_irqrestore(&iounit->lock, flags);
166} 178}
167 179
168static void iounit_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 180static void iounit_release_scsi_sgl(struct device *dev, struct scatterlist *sg, int sz)
169{ 181{
182 struct iounit_struct *iounit = dev->archdata.iommu;
170 unsigned long flags; 183 unsigned long flags;
171 unsigned long vaddr, len; 184 unsigned long vaddr, len;
172 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
173 185
174 spin_lock_irqsave(&iounit->lock, flags); 186 spin_lock_irqsave(&iounit->lock, flags);
175 while (sz != 0) { 187 while (sz != 0) {
@@ -185,12 +197,12 @@ static void iounit_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_
185} 197}
186 198
187#ifdef CONFIG_SBUS 199#ifdef CONFIG_SBUS
188static int iounit_map_dma_area(dma_addr_t *pba, unsigned long va, __u32 addr, int len) 200static int iounit_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long va, __u32 addr, int len)
189{ 201{
202 struct iounit_struct *iounit = dev->archdata.iommu;
190 unsigned long page, end; 203 unsigned long page, end;
191 pgprot_t dvma_prot; 204 pgprot_t dvma_prot;
192 iopte_t *iopte; 205 iopte_t *iopte;
193 struct sbus_bus *sbus;
194 206
195 *pba = addr; 207 *pba = addr;
196 208
@@ -212,12 +224,8 @@ static int iounit_map_dma_area(dma_addr_t *pba, unsigned long va, __u32 addr, in
212 224
213 i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT); 225 i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT);
214 226
215 for_each_sbus(sbus) { 227 iopte = (iopte_t *)(iounit->page_table + i);
216 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu; 228 *iopte = MKIOPTE(__pa(page));
217
218 iopte = (iopte_t *)(iounit->page_table + i);
219 *iopte = MKIOPTE(__pa(page));
220 }
221 } 229 }
222 addr += PAGE_SIZE; 230 addr += PAGE_SIZE;
223 va += PAGE_SIZE; 231 va += PAGE_SIZE;
@@ -228,23 +236,10 @@ static int iounit_map_dma_area(dma_addr_t *pba, unsigned long va, __u32 addr, in
228 return 0; 236 return 0;
229} 237}
230 238
231static void iounit_unmap_dma_area(unsigned long addr, int len) 239static void iounit_unmap_dma_area(struct device *dev, unsigned long addr, int len)
232{ 240{
233 /* XXX Somebody please fill this in */ 241 /* XXX Somebody please fill this in */
234} 242}
235
236/* XXX We do not pass sbus device here, bad. */
237static struct page *iounit_translate_dvma(unsigned long addr)
238{
239 struct sbus_bus *sbus = sbus_root; /* They are all the same */
240 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
241 int i;
242 iopte_t *iopte;
243
244 i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT);
245 iopte = (iopte_t *)(iounit->page_table + i);
246 return pfn_to_page(iopte_val(*iopte) >> (PAGE_SHIFT-4)); /* XXX sun4d guru, help */
247}
248#endif 243#endif
249 244
250static char *iounit_lockarea(char *vaddr, unsigned long len) 245static char *iounit_lockarea(char *vaddr, unsigned long len)
@@ -271,54 +266,5 @@ void __init ld_mmu_iounit(void)
271#ifdef CONFIG_SBUS 266#ifdef CONFIG_SBUS
272 BTFIXUPSET_CALL(mmu_map_dma_area, iounit_map_dma_area, BTFIXUPCALL_NORM); 267 BTFIXUPSET_CALL(mmu_map_dma_area, iounit_map_dma_area, BTFIXUPCALL_NORM);
273 BTFIXUPSET_CALL(mmu_unmap_dma_area, iounit_unmap_dma_area, BTFIXUPCALL_NORM); 268 BTFIXUPSET_CALL(mmu_unmap_dma_area, iounit_unmap_dma_area, BTFIXUPCALL_NORM);
274 BTFIXUPSET_CALL(mmu_translate_dvma, iounit_translate_dvma, BTFIXUPCALL_NORM);
275#endif 269#endif
276} 270}
277
278__u32 iounit_map_dma_init(struct sbus_bus *sbus, int size)
279{
280 int i, j, k, npages;
281 unsigned long rotor, scan, limit;
282 unsigned long flags;
283 __u32 ret;
284 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
285
286 npages = (size + (PAGE_SIZE-1)) >> PAGE_SHIFT;
287 i = 0x0213;
288 spin_lock_irqsave(&iounit->lock, flags);
289next: j = (i & 15);
290 rotor = iounit->rotor[j - 1];
291 limit = iounit->limit[j];
292 scan = rotor;
293nexti: scan = find_next_zero_bit(iounit->bmap, limit, scan);
294 if (scan + npages > limit) {
295 if (limit != rotor) {
296 limit = rotor;
297 scan = iounit->limit[j - 1];
298 goto nexti;
299 }
300 i >>= 4;
301 if (!(i & 15))
302 panic("iounit_map_dma_init: Couldn't find free iopte slots for %d bytes\n", size);
303 goto next;
304 }
305 for (k = 1, scan++; k < npages; k++)
306 if (test_bit(scan++, iounit->bmap))
307 goto nexti;
308 iounit->rotor[j - 1] = (scan < limit) ? scan : iounit->limit[j - 1];
309 scan -= npages;
310 ret = IOUNIT_DMA_BASE + (scan << PAGE_SHIFT);
311 for (k = 0; k < npages; k++, scan++)
312 set_bit(scan, iounit->bmap);
313 spin_unlock_irqrestore(&iounit->lock, flags);
314 return ret;
315}
316
317__u32 iounit_map_dma_page(__u32 vaddr, void *addr, struct sbus_bus *sbus)
318{
319 int scan = (vaddr - IOUNIT_DMA_BASE) >> PAGE_SHIFT;
320 struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
321
322 iounit->page_table[scan] = MKIOPTE(__pa(((unsigned long)addr) & PAGE_MASK));
323 return vaddr + (((unsigned long)addr) & ~PAGE_MASK);
324}
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index 4b934270f05e..e7a499e3aa3c 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -13,10 +13,11 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/highmem.h> /* pte_offset_map => kmap_atomic */ 14#include <linux/highmem.h> /* pte_offset_map => kmap_atomic */
15#include <linux/scatterlist.h> 15#include <linux/scatterlist.h>
16#include <linux/of.h>
17#include <linux/of_device.h>
16 18
17#include <asm/pgalloc.h> 19#include <asm/pgalloc.h>
18#include <asm/pgtable.h> 20#include <asm/pgtable.h>
19#include <asm/sbus.h>
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/mxcc.h> 22#include <asm/mxcc.h>
22#include <asm/mbus.h> 23#include <asm/mbus.h>
@@ -55,30 +56,21 @@ static pgprot_t dvma_prot; /* Consistent mapping pte flags */
55#define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID) 56#define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID)
56#define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ) 57#define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ)
57 58
58void __init 59static void __init sbus_iommu_init(struct of_device *op)
59iommu_init(int iommund, struct sbus_bus *sbus)
60{ 60{
61 unsigned int impl, vers;
62 unsigned long tmp;
63 struct iommu_struct *iommu; 61 struct iommu_struct *iommu;
64 struct linux_prom_registers iommu_promregs[PROMREG_MAX]; 62 unsigned int impl, vers;
65 struct resource r;
66 unsigned long *bitmap; 63 unsigned long *bitmap;
64 unsigned long tmp;
67 65
68 iommu = kmalloc(sizeof(struct iommu_struct), GFP_ATOMIC); 66 iommu = kmalloc(sizeof(struct iommu_struct), GFP_ATOMIC);
69 if (!iommu) { 67 if (!iommu) {
70 prom_printf("Unable to allocate iommu structure\n"); 68 prom_printf("Unable to allocate iommu structure\n");
71 prom_halt(); 69 prom_halt();
72 } 70 }
73 iommu->regs = NULL; 71
74 if (prom_getproperty(iommund, "reg", (void *) iommu_promregs, 72 iommu->regs = of_ioremap(&op->resource[0], 0, PAGE_SIZE * 3,
75 sizeof(iommu_promregs)) != -1) { 73 "iommu_regs");
76 memset(&r, 0, sizeof(r));
77 r.flags = iommu_promregs[0].which_io;
78 r.start = iommu_promregs[0].phys_addr;
79 iommu->regs = (struct iommu_regs *)
80 sbus_ioremap(&r, 0, PAGE_SIZE * 3, "iommu_regs");
81 }
82 if (!iommu->regs) { 74 if (!iommu->regs) {
83 prom_printf("Cannot map IOMMU registers\n"); 75 prom_printf("Cannot map IOMMU registers\n");
84 prom_halt(); 76 prom_halt();
@@ -128,13 +120,29 @@ iommu_init(int iommund, struct sbus_bus *sbus)
128 else 120 else
129 iommu->usemap.num_colors = 1; 121 iommu->usemap.num_colors = 1;
130 122
131 printk("IOMMU: impl %d vers %d table 0x%p[%d B] map [%d b]\n", 123 printk(KERN_INFO "IOMMU: impl %d vers %d table 0x%p[%d B] map [%d b]\n",
132 impl, vers, iommu->page_table, 124 impl, vers, iommu->page_table,
133 (int)(IOMMU_NPTES*sizeof(iopte_t)), (int)IOMMU_NPTES); 125 (int)(IOMMU_NPTES*sizeof(iopte_t)), (int)IOMMU_NPTES);
126
127 op->dev.archdata.iommu = iommu;
128}
129
130static int __init iommu_init(void)
131{
132 struct device_node *dp;
133
134 for_each_node_by_name(dp, "iommu") {
135 struct of_device *op = of_find_device_by_node(dp);
136
137 sbus_iommu_init(op);
138 of_propagate_archdata(op);
139 }
134 140
135 sbus->ofdev.dev.archdata.iommu = iommu; 141 return 0;
136} 142}
137 143
144subsys_initcall(iommu_init);
145
138/* This begs to be btfixup-ed by srmmu. */ 146/* This begs to be btfixup-ed by srmmu. */
139/* Flush the iotlb entries to ram. */ 147/* Flush the iotlb entries to ram. */
140/* This could be better if we didn't have to flush whole pages. */ 148/* This could be better if we didn't have to flush whole pages. */
@@ -164,9 +172,9 @@ static void iommu_flush_iotlb(iopte_t *iopte, unsigned int niopte)
164 } 172 }
165} 173}
166 174
167static u32 iommu_get_one(struct page *page, int npages, struct sbus_bus *sbus) 175static u32 iommu_get_one(struct device *dev, struct page *page, int npages)
168{ 176{
169 struct iommu_struct *iommu = sbus->ofdev.dev.archdata.iommu; 177 struct iommu_struct *iommu = dev->archdata.iommu;
170 int ioptex; 178 int ioptex;
171 iopte_t *iopte, *iopte0; 179 iopte_t *iopte, *iopte0;
172 unsigned int busa, busa0; 180 unsigned int busa, busa0;
@@ -194,8 +202,7 @@ static u32 iommu_get_one(struct page *page, int npages, struct sbus_bus *sbus)
194 return busa0; 202 return busa0;
195} 203}
196 204
197static u32 iommu_get_scsi_one(char *vaddr, unsigned int len, 205static u32 iommu_get_scsi_one(struct device *dev, char *vaddr, unsigned int len)
198 struct sbus_bus *sbus)
199{ 206{
200 unsigned long off; 207 unsigned long off;
201 int npages; 208 int npages;
@@ -205,22 +212,22 @@ static u32 iommu_get_scsi_one(char *vaddr, unsigned int len,
205 off = (unsigned long)vaddr & ~PAGE_MASK; 212 off = (unsigned long)vaddr & ~PAGE_MASK;
206 npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT; 213 npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT;
207 page = virt_to_page((unsigned long)vaddr & PAGE_MASK); 214 page = virt_to_page((unsigned long)vaddr & PAGE_MASK);
208 busa = iommu_get_one(page, npages, sbus); 215 busa = iommu_get_one(dev, page, npages);
209 return busa + off; 216 return busa + off;
210} 217}
211 218
212static __u32 iommu_get_scsi_one_noflush(char *vaddr, unsigned long len, struct sbus_bus *sbus) 219static __u32 iommu_get_scsi_one_noflush(struct device *dev, char *vaddr, unsigned long len)
213{ 220{
214 return iommu_get_scsi_one(vaddr, len, sbus); 221 return iommu_get_scsi_one(dev, vaddr, len);
215} 222}
216 223
217static __u32 iommu_get_scsi_one_gflush(char *vaddr, unsigned long len, struct sbus_bus *sbus) 224static __u32 iommu_get_scsi_one_gflush(struct device *dev, char *vaddr, unsigned long len)
218{ 225{
219 flush_page_for_dma(0); 226 flush_page_for_dma(0);
220 return iommu_get_scsi_one(vaddr, len, sbus); 227 return iommu_get_scsi_one(dev, vaddr, len);
221} 228}
222 229
223static __u32 iommu_get_scsi_one_pflush(char *vaddr, unsigned long len, struct sbus_bus *sbus) 230static __u32 iommu_get_scsi_one_pflush(struct device *dev, char *vaddr, unsigned long len)
224{ 231{
225 unsigned long page = ((unsigned long) vaddr) & PAGE_MASK; 232 unsigned long page = ((unsigned long) vaddr) & PAGE_MASK;
226 233
@@ -228,23 +235,23 @@ static __u32 iommu_get_scsi_one_pflush(char *vaddr, unsigned long len, struct sb
228 flush_page_for_dma(page); 235 flush_page_for_dma(page);
229 page += PAGE_SIZE; 236 page += PAGE_SIZE;
230 } 237 }
231 return iommu_get_scsi_one(vaddr, len, sbus); 238 return iommu_get_scsi_one(dev, vaddr, len);
232} 239}
233 240
234static void iommu_get_scsi_sgl_noflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 241static void iommu_get_scsi_sgl_noflush(struct device *dev, struct scatterlist *sg, int sz)
235{ 242{
236 int n; 243 int n;
237 244
238 while (sz != 0) { 245 while (sz != 0) {
239 --sz; 246 --sz;
240 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; 247 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
241 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; 248 sg->dvma_address = iommu_get_one(dev, sg_page(sg), n) + sg->offset;
242 sg->dvma_length = (__u32) sg->length; 249 sg->dvma_length = (__u32) sg->length;
243 sg = sg_next(sg); 250 sg = sg_next(sg);
244 } 251 }
245} 252}
246 253
247static void iommu_get_scsi_sgl_gflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 254static void iommu_get_scsi_sgl_gflush(struct device *dev, struct scatterlist *sg, int sz)
248{ 255{
249 int n; 256 int n;
250 257
@@ -252,13 +259,13 @@ static void iommu_get_scsi_sgl_gflush(struct scatterlist *sg, int sz, struct sbu
252 while (sz != 0) { 259 while (sz != 0) {
253 --sz; 260 --sz;
254 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; 261 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
255 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; 262 sg->dvma_address = iommu_get_one(dev, sg_page(sg), n) + sg->offset;
256 sg->dvma_length = (__u32) sg->length; 263 sg->dvma_length = (__u32) sg->length;
257 sg = sg_next(sg); 264 sg = sg_next(sg);
258 } 265 }
259} 266}
260 267
261static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 268static void iommu_get_scsi_sgl_pflush(struct device *dev, struct scatterlist *sg, int sz)
262{ 269{
263 unsigned long page, oldpage = 0; 270 unsigned long page, oldpage = 0;
264 int n, i; 271 int n, i;
@@ -283,15 +290,15 @@ static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbu
283 } 290 }
284 } 291 }
285 292
286 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; 293 sg->dvma_address = iommu_get_one(dev, sg_page(sg), n) + sg->offset;
287 sg->dvma_length = (__u32) sg->length; 294 sg->dvma_length = (__u32) sg->length;
288 sg = sg_next(sg); 295 sg = sg_next(sg);
289 } 296 }
290} 297}
291 298
292static void iommu_release_one(u32 busa, int npages, struct sbus_bus *sbus) 299static void iommu_release_one(struct device *dev, u32 busa, int npages)
293{ 300{
294 struct iommu_struct *iommu = sbus->ofdev.dev.archdata.iommu; 301 struct iommu_struct *iommu = dev->archdata.iommu;
295 int ioptex; 302 int ioptex;
296 int i; 303 int i;
297 304
@@ -305,17 +312,17 @@ static void iommu_release_one(u32 busa, int npages, struct sbus_bus *sbus)
305 bit_map_clear(&iommu->usemap, ioptex, npages); 312 bit_map_clear(&iommu->usemap, ioptex, npages);
306} 313}
307 314
308static void iommu_release_scsi_one(__u32 vaddr, unsigned long len, struct sbus_bus *sbus) 315static void iommu_release_scsi_one(struct device *dev, __u32 vaddr, unsigned long len)
309{ 316{
310 unsigned long off; 317 unsigned long off;
311 int npages; 318 int npages;
312 319
313 off = vaddr & ~PAGE_MASK; 320 off = vaddr & ~PAGE_MASK;
314 npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT; 321 npages = (off + len + PAGE_SIZE-1) >> PAGE_SHIFT;
315 iommu_release_one(vaddr & PAGE_MASK, npages, sbus); 322 iommu_release_one(dev, vaddr & PAGE_MASK, npages);
316} 323}
317 324
318static void iommu_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 325static void iommu_release_scsi_sgl(struct device *dev, struct scatterlist *sg, int sz)
319{ 326{
320 int n; 327 int n;
321 328
@@ -323,18 +330,18 @@ static void iommu_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_b
323 --sz; 330 --sz;
324 331
325 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; 332 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
326 iommu_release_one(sg->dvma_address & PAGE_MASK, n, sbus); 333 iommu_release_one(dev, sg->dvma_address & PAGE_MASK, n);
327 sg->dvma_address = 0x21212121; 334 sg->dvma_address = 0x21212121;
328 sg = sg_next(sg); 335 sg = sg_next(sg);
329 } 336 }
330} 337}
331 338
332#ifdef CONFIG_SBUS 339#ifdef CONFIG_SBUS
333static int iommu_map_dma_area(dma_addr_t *pba, unsigned long va, 340static int iommu_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long va,
334 unsigned long addr, int len) 341 unsigned long addr, int len)
335{ 342{
343 struct iommu_struct *iommu = dev->archdata.iommu;
336 unsigned long page, end; 344 unsigned long page, end;
337 struct iommu_struct *iommu = sbus_root->ofdev.dev.archdata.iommu;
338 iopte_t *iopte = iommu->page_table; 345 iopte_t *iopte = iommu->page_table;
339 iopte_t *first; 346 iopte_t *first;
340 int ioptex; 347 int ioptex;
@@ -397,9 +404,9 @@ static int iommu_map_dma_area(dma_addr_t *pba, unsigned long va,
397 return 0; 404 return 0;
398} 405}
399 406
400static void iommu_unmap_dma_area(unsigned long busa, int len) 407static void iommu_unmap_dma_area(struct device *dev, unsigned long busa, int len)
401{ 408{
402 struct iommu_struct *iommu = sbus_root->ofdev.dev.archdata.iommu; 409 struct iommu_struct *iommu = dev->archdata.iommu;
403 iopte_t *iopte = iommu->page_table; 410 iopte_t *iopte = iommu->page_table;
404 unsigned long end; 411 unsigned long end;
405 int ioptex = (busa - iommu->start) >> PAGE_SHIFT; 412 int ioptex = (busa - iommu->start) >> PAGE_SHIFT;
@@ -417,15 +424,6 @@ static void iommu_unmap_dma_area(unsigned long busa, int len)
417 iommu_invalidate(iommu->regs); 424 iommu_invalidate(iommu->regs);
418 bit_map_clear(&iommu->usemap, ioptex, len >> PAGE_SHIFT); 425 bit_map_clear(&iommu->usemap, ioptex, len >> PAGE_SHIFT);
419} 426}
420
421static struct page *iommu_translate_dvma(unsigned long busa)
422{
423 struct iommu_struct *iommu = sbus_root->ofdev.dev.archdata.iommu;
424 iopte_t *iopte = iommu->page_table;
425
426 iopte += ((busa - iommu->start) >> PAGE_SHIFT);
427 return pfn_to_page((iopte_val(*iopte) & IOPTE_PAGE) >> (PAGE_SHIFT-4));
428}
429#endif 427#endif
430 428
431static char *iommu_lockarea(char *vaddr, unsigned long len) 429static char *iommu_lockarea(char *vaddr, unsigned long len)
@@ -461,7 +459,6 @@ void __init ld_mmu_iommu(void)
461#ifdef CONFIG_SBUS 459#ifdef CONFIG_SBUS
462 BTFIXUPSET_CALL(mmu_map_dma_area, iommu_map_dma_area, BTFIXUPCALL_NORM); 460 BTFIXUPSET_CALL(mmu_map_dma_area, iommu_map_dma_area, BTFIXUPCALL_NORM);
463 BTFIXUPSET_CALL(mmu_unmap_dma_area, iommu_unmap_dma_area, BTFIXUPCALL_NORM); 461 BTFIXUPSET_CALL(mmu_unmap_dma_area, iommu_unmap_dma_area, BTFIXUPCALL_NORM);
464 BTFIXUPSET_CALL(mmu_translate_dvma, iommu_translate_dvma, BTFIXUPCALL_NORM);
465#endif 462#endif
466 463
467 if (viking_mxcc_present || srmmu_modtype == HyperSparc) { 464 if (viking_mxcc_present || srmmu_modtype == HyperSparc) {
diff --git a/arch/sparc/mm/nosrmmu.c b/arch/sparc/mm/nosrmmu.c
deleted file mode 100644
index 3701f70fc30a..000000000000
--- a/arch/sparc/mm/nosrmmu.c
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * nosrmmu.c: This file is a bunch of dummies for sun4 compiles,
3 * so that it does not need srmmu and avoid ifdefs.
4 *
5 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 */
7
8#include <linux/kernel.h>
9#include <linux/mm.h>
10#include <linux/init.h>
11#include <asm/mbus.h>
12#include <asm/sbus.h>
13
14static char shouldnothappen[] __initdata = "SUN4 kernel can only run on SUN4\n";
15
16enum mbus_module srmmu_modtype;
17void *srmmu_nocache_pool;
18
19int vac_cache_size = 0;
20
21static void __init should_not_happen(void)
22{
23 prom_printf(shouldnothappen);
24 prom_halt();
25}
26
27void __init srmmu_frob_mem_map(unsigned long start_mem)
28{
29 should_not_happen();
30}
31
32unsigned long __init srmmu_paging_init(unsigned long start_mem, unsigned long end_mem)
33{
34 should_not_happen();
35 return 0;
36}
37
38void __init ld_mmu_srmmu(void)
39{
40 should_not_happen();
41}
42
43void srmmu_mapioaddr(unsigned long physaddr, unsigned long virt_addr, int bus_type, int rdonly)
44{
45}
46
47void srmmu_unmapioaddr(unsigned long virt_addr)
48{
49}
50
51__u32 iounit_map_dma_init(struct sbus_bus *sbus, int size)
52{
53 return 0;
54}
55
56__u32 iounit_map_dma_page(__u32 vaddr, void *addr, struct sbus_bus *sbus)
57{
58 return 0;
59}
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index ee30462598fc..6a5d7cabc044 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -31,7 +31,6 @@
31#include <asm/mbus.h> 31#include <asm/mbus.h>
32#include <asm/cache.h> 32#include <asm/cache.h>
33#include <asm/oplib.h> 33#include <asm/oplib.h>
34#include <asm/sbus.h>
35#include <asm/asi.h> 34#include <asm/asi.h>
36#include <asm/msi.h> 35#include <asm/msi.h>
37#include <asm/mmu_context.h> 36#include <asm/mmu_context.h>
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
index d1782f6368be..fe65aeeb3947 100644
--- a/arch/sparc/mm/sun4c.c
+++ b/arch/sparc/mm/sun4c.c
@@ -31,7 +31,6 @@
31#include <asm/oplib.h> 31#include <asm/oplib.h>
32#include <asm/openprom.h> 32#include <asm/openprom.h>
33#include <asm/mmu_context.h> 33#include <asm/mmu_context.h>
34#include <asm/sun4paddr.h>
35#include <asm/highmem.h> 34#include <asm/highmem.h>
36#include <asm/btfixup.h> 35#include <asm/btfixup.h>
37#include <asm/cacheflush.h> 36#include <asm/cacheflush.h>
@@ -52,15 +51,11 @@ extern int num_segmaps, num_contexts;
52 51
53extern unsigned long page_kernel; 52extern unsigned long page_kernel;
54 53
55#ifdef CONFIG_SUN4
56#define SUN4C_VAC_SIZE sun4c_vacinfo.num_bytes
57#else
58/* That's it, we prom_halt() on sun4c if the cache size is something other than 65536. 54/* That's it, we prom_halt() on sun4c if the cache size is something other than 65536.
59 * So let's save some cycles and just use that everywhere except for that bootup 55 * So let's save some cycles and just use that everywhere except for that bootup
60 * sanity check. 56 * sanity check.
61 */ 57 */
62#define SUN4C_VAC_SIZE 65536 58#define SUN4C_VAC_SIZE 65536
63#endif
64 59
65#define SUN4C_KERNEL_BUCKETS 32 60#define SUN4C_KERNEL_BUCKETS 32
66 61
@@ -285,75 +280,32 @@ void __init sun4c_probe_vac(void)
285{ 280{
286 sun4c_disable_vac(); 281 sun4c_disable_vac();
287 282
288 if (ARCH_SUN4) { 283 if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS1)) ||
289 switch (idprom->id_machtype) { 284 (idprom->id_machtype == (SM_SUN4C | SM_4C_SS1PLUS))) {
290 285 /* PROM on SS1 lacks this info, to be super safe we
291 case (SM_SUN4|SM_4_110): 286 * hard code it here since this arch is cast in stone.
292 sun4c_vacinfo.type = VAC_NONE; 287 */
293 sun4c_vacinfo.num_bytes = 0; 288 sun4c_vacinfo.num_bytes = 65536;
294 sun4c_vacinfo.linesize = 0; 289 sun4c_vacinfo.linesize = 16;
295 sun4c_vacinfo.do_hwflushes = 0;
296 prom_printf("No VAC. Get some bucks and buy a real computer.");
297 prom_halt();
298 break;
299
300 case (SM_SUN4|SM_4_260):
301 sun4c_vacinfo.type = VAC_WRITE_BACK;
302 sun4c_vacinfo.num_bytes = 128 * 1024;
303 sun4c_vacinfo.linesize = 16;
304 sun4c_vacinfo.do_hwflushes = 0;
305 break;
306
307 case (SM_SUN4|SM_4_330):
308 sun4c_vacinfo.type = VAC_WRITE_THROUGH;
309 sun4c_vacinfo.num_bytes = 128 * 1024;
310 sun4c_vacinfo.linesize = 16;
311 sun4c_vacinfo.do_hwflushes = 0;
312 break;
313
314 case (SM_SUN4|SM_4_470):
315 sun4c_vacinfo.type = VAC_WRITE_BACK;
316 sun4c_vacinfo.num_bytes = 128 * 1024;
317 sun4c_vacinfo.linesize = 32;
318 sun4c_vacinfo.do_hwflushes = 0;
319 break;
320
321 default:
322 prom_printf("Cannot initialize VAC - weird sun4 model idprom->id_machtype = %d", idprom->id_machtype);
323 prom_halt();
324 };
325 } else { 290 } else {
326 sun4c_vacinfo.type = VAC_WRITE_THROUGH; 291 sun4c_vacinfo.num_bytes =
292 prom_getintdefault(prom_root_node, "vac-size", 65536);
293 sun4c_vacinfo.linesize =
294 prom_getintdefault(prom_root_node, "vac-linesize", 16);
295 }
296 sun4c_vacinfo.do_hwflushes =
297 prom_getintdefault(prom_root_node, "vac-hwflush", 0);
327 298
328 if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS1)) || 299 if (sun4c_vacinfo.do_hwflushes == 0)
329 (idprom->id_machtype == (SM_SUN4C | SM_4C_SS1PLUS))) {
330 /* PROM on SS1 lacks this info, to be super safe we
331 * hard code it here since this arch is cast in stone.
332 */
333 sun4c_vacinfo.num_bytes = 65536;
334 sun4c_vacinfo.linesize = 16;
335 } else {
336 sun4c_vacinfo.num_bytes =
337 prom_getintdefault(prom_root_node, "vac-size", 65536);
338 sun4c_vacinfo.linesize =
339 prom_getintdefault(prom_root_node, "vac-linesize", 16);
340 }
341 sun4c_vacinfo.do_hwflushes = 300 sun4c_vacinfo.do_hwflushes =
342 prom_getintdefault(prom_root_node, "vac-hwflush", 0); 301 prom_getintdefault(prom_root_node, "vac_hwflush", 0);
343
344 if (sun4c_vacinfo.do_hwflushes == 0)
345 sun4c_vacinfo.do_hwflushes =
346 prom_getintdefault(prom_root_node, "vac_hwflush", 0);
347 302
348 if (sun4c_vacinfo.num_bytes != 65536) { 303 if (sun4c_vacinfo.num_bytes != 65536) {
349 prom_printf("WEIRD Sun4C VAC cache size, " 304 prom_printf("WEIRD Sun4C VAC cache size, "
350 "tell sparclinux@vger.kernel.org"); 305 "tell sparclinux@vger.kernel.org");
351 prom_halt(); 306 prom_halt();
352 }
353 } 307 }
354 308
355 sun4c_vacinfo.num_lines =
356 (sun4c_vacinfo.num_bytes / sun4c_vacinfo.linesize);
357 switch (sun4c_vacinfo.linesize) { 309 switch (sun4c_vacinfo.linesize) {
358 case 16: 310 case 16:
359 sun4c_vacinfo.log2lsize = 4; 311 sun4c_vacinfo.log2lsize = 4;
@@ -447,49 +399,18 @@ static void __init patch_kernel_fault_handler(void)
447 399
448static void __init sun4c_probe_mmu(void) 400static void __init sun4c_probe_mmu(void)
449{ 401{
450 if (ARCH_SUN4) { 402 if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS1)) ||
451 switch (idprom->id_machtype) { 403 (idprom->id_machtype == (SM_SUN4C | SM_4C_SS1PLUS))) {
452 case (SM_SUN4|SM_4_110): 404 /* Hardcode these just to be safe, PROM on SS1 does
453 prom_printf("No support for 4100 yet\n"); 405 * not have this info available in the root node.
454 prom_halt(); 406 */
455 num_segmaps = 256; 407 num_segmaps = 128;
456 num_contexts = 8; 408 num_contexts = 8;
457 break;
458
459 case (SM_SUN4|SM_4_260):
460 /* should be 512 segmaps. when it get fixed */
461 num_segmaps = 256;
462 num_contexts = 16;
463 break;
464
465 case (SM_SUN4|SM_4_330):
466 num_segmaps = 256;
467 num_contexts = 16;
468 break;
469
470 case (SM_SUN4|SM_4_470):
471 /* should be 1024 segmaps. when it get fixed */
472 num_segmaps = 256;
473 num_contexts = 64;
474 break;
475 default:
476 prom_printf("Invalid SUN4 model\n");
477 prom_halt();
478 };
479 } else { 409 } else {
480 if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS1)) || 410 num_segmaps =
481 (idprom->id_machtype == (SM_SUN4C | SM_4C_SS1PLUS))) { 411 prom_getintdefault(prom_root_node, "mmu-npmg", 128);
482 /* Hardcode these just to be safe, PROM on SS1 does 412 num_contexts =
483 * not have this info available in the root node. 413 prom_getintdefault(prom_root_node, "mmu-nctx", 0x8);
484 */
485 num_segmaps = 128;
486 num_contexts = 8;
487 } else {
488 num_segmaps =
489 prom_getintdefault(prom_root_node, "mmu-npmg", 128);
490 num_contexts =
491 prom_getintdefault(prom_root_node, "mmu-nctx", 0x8);
492 }
493 } 414 }
494 patch_kernel_fault_handler(); 415 patch_kernel_fault_handler();
495} 416}
@@ -501,18 +422,14 @@ void __init sun4c_probe_memerr_reg(void)
501 int node; 422 int node;
502 struct linux_prom_registers regs[1]; 423 struct linux_prom_registers regs[1];
503 424
504 if (ARCH_SUN4) { 425 node = prom_getchild(prom_root_node);
505 sun4c_memerr_reg = ioremap(sun4_memreg_physaddr, PAGE_SIZE); 426 node = prom_searchsiblings(prom_root_node, "memory-error");
506 } else { 427 if (!node)
507 node = prom_getchild(prom_root_node); 428 return;
508 node = prom_searchsiblings(prom_root_node, "memory-error"); 429 if (prom_getproperty(node, "reg", (char *)regs, sizeof(regs)) <= 0)
509 if (!node) 430 return;
510 return; 431 /* hmm I think regs[0].which_io is zero here anyways */
511 if (prom_getproperty(node, "reg", (char *)regs, sizeof(regs)) <= 0) 432 sun4c_memerr_reg = ioremap(regs[0].phys_addr, regs[0].reg_size);
512 return;
513 /* hmm I think regs[0].which_io is zero here anyways */
514 sun4c_memerr_reg = ioremap(regs[0].phys_addr, regs[0].reg_size);
515 }
516} 433}
517 434
518static inline void sun4c_init_ss2_cache_bug(void) 435static inline void sun4c_init_ss2_cache_bug(void)
@@ -521,7 +438,6 @@ static inline void sun4c_init_ss2_cache_bug(void)
521 438
522 if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS2)) || 439 if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS2)) ||
523 (idprom->id_machtype == (SM_SUN4C | SM_4C_IPX)) || 440 (idprom->id_machtype == (SM_SUN4C | SM_4C_IPX)) ||
524 (idprom->id_machtype == (SM_SUN4 | SM_4_330)) ||
525 (idprom->id_machtype == (SM_SUN4C | SM_4C_ELC))) { 441 (idprom->id_machtype == (SM_SUN4C | SM_4C_ELC))) {
526 /* Whee.. */ 442 /* Whee.. */
527 printk("SS2 cache bug detected, uncaching trap table page\n"); 443 printk("SS2 cache bug detected, uncaching trap table page\n");
@@ -532,8 +448,8 @@ static inline void sun4c_init_ss2_cache_bug(void)
532} 448}
533 449
534/* Addr is always aligned on a page boundary for us already. */ 450/* Addr is always aligned on a page boundary for us already. */
535static int sun4c_map_dma_area(dma_addr_t *pba, unsigned long va, 451static int sun4c_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long va,
536 unsigned long addr, int len) 452 unsigned long addr, int len)
537{ 453{
538 unsigned long page, end; 454 unsigned long page, end;
539 455
@@ -555,14 +471,7 @@ static int sun4c_map_dma_area(dma_addr_t *pba, unsigned long va,
555 return 0; 471 return 0;
556} 472}
557 473
558static struct page *sun4c_translate_dvma(unsigned long busa) 474static void sun4c_unmap_dma_area(struct device *dev, unsigned long busa, int len)
559{
560 /* Fortunately for us, bus_addr == uncached_virt in sun4c. */
561 unsigned long pte = sun4c_get_pte(busa);
562 return pfn_to_page(pte & SUN4C_PFN_MASK);
563}
564
565static void sun4c_unmap_dma_area(unsigned long busa, int len)
566{ 475{
567 /* Fortunately for us, bus_addr == uncached_virt in sun4c. */ 476 /* Fortunately for us, bus_addr == uncached_virt in sun4c. */
568 /* XXX Implement this */ 477 /* XXX Implement this */
@@ -624,11 +533,7 @@ static inline void sun4c_init_map_kernelprom(unsigned long kernel_end)
624{ 533{
625 unsigned long vaddr; 534 unsigned long vaddr;
626 unsigned char pseg, ctx; 535 unsigned char pseg, ctx;
627#ifdef CONFIG_SUN4 536
628 /* sun4/110 and 260 have no kadb. */
629 if ((idprom->id_machtype != (SM_SUN4 | SM_4_260)) &&
630 (idprom->id_machtype != (SM_SUN4 | SM_4_110))) {
631#endif
632 for (vaddr = KADB_DEBUGGER_BEGVM; 537 for (vaddr = KADB_DEBUGGER_BEGVM;
633 vaddr < LINUX_OPPROM_ENDVM; 538 vaddr < LINUX_OPPROM_ENDVM;
634 vaddr += SUN4C_REAL_PGDIR_SIZE) { 539 vaddr += SUN4C_REAL_PGDIR_SIZE) {
@@ -640,9 +545,7 @@ static inline void sun4c_init_map_kernelprom(unsigned long kernel_end)
640 fix_permissions(vaddr, _SUN4C_PAGE_PRIV, 0); 545 fix_permissions(vaddr, _SUN4C_PAGE_PRIV, 0);
641 } 546 }
642 } 547 }
643#ifdef CONFIG_SUN4 548
644 }
645#endif
646 for (vaddr = KERNBASE; vaddr < kernel_end; vaddr += SUN4C_REAL_PGDIR_SIZE) { 549 for (vaddr = KERNBASE; vaddr < kernel_end; vaddr += SUN4C_REAL_PGDIR_SIZE) {
647 pseg = sun4c_get_segmap(vaddr); 550 pseg = sun4c_get_segmap(vaddr);
648 mmu_entry_pool[pseg].locked = 1; 551 mmu_entry_pool[pseg].locked = 1;
@@ -1048,14 +951,10 @@ static struct thread_info *sun4c_alloc_thread_info(void)
1048 * so we must flush the cache to guarantee consistency. 951 * so we must flush the cache to guarantee consistency.
1049 */ 952 */
1050 sun4c_flush_page(pages); 953 sun4c_flush_page(pages);
1051#ifndef CONFIG_SUN4
1052 sun4c_flush_page(pages + PAGE_SIZE); 954 sun4c_flush_page(pages + PAGE_SIZE);
1053#endif
1054 955
1055 sun4c_put_pte(addr, BUCKET_PTE(pages)); 956 sun4c_put_pte(addr, BUCKET_PTE(pages));
1056#ifndef CONFIG_SUN4
1057 sun4c_put_pte(addr + PAGE_SIZE, BUCKET_PTE(pages + PAGE_SIZE)); 957 sun4c_put_pte(addr + PAGE_SIZE, BUCKET_PTE(pages + PAGE_SIZE));
1058#endif
1059 958
1060#ifdef CONFIG_DEBUG_STACK_USAGE 959#ifdef CONFIG_DEBUG_STACK_USAGE
1061 memset((void *)addr, 0, PAGE_SIZE << THREAD_INFO_ORDER); 960 memset((void *)addr, 0, PAGE_SIZE << THREAD_INFO_ORDER);
@@ -1072,13 +971,11 @@ static void sun4c_free_thread_info(struct thread_info *ti)
1072 971
1073 /* We are deleting a mapping, so the flush here is mandatory. */ 972 /* We are deleting a mapping, so the flush here is mandatory. */
1074 sun4c_flush_page(tiaddr); 973 sun4c_flush_page(tiaddr);
1075#ifndef CONFIG_SUN4
1076 sun4c_flush_page(tiaddr + PAGE_SIZE); 974 sun4c_flush_page(tiaddr + PAGE_SIZE);
1077#endif 975
1078 sun4c_put_pte(tiaddr, 0); 976 sun4c_put_pte(tiaddr, 0);
1079#ifndef CONFIG_SUN4
1080 sun4c_put_pte(tiaddr + PAGE_SIZE, 0); 977 sun4c_put_pte(tiaddr + PAGE_SIZE, 0);
1081#endif 978
1082 sun4c_bucket[entry] = BUCKET_EMPTY; 979 sun4c_bucket[entry] = BUCKET_EMPTY;
1083 if (entry < sun4c_lowbucket_avail) 980 if (entry < sun4c_lowbucket_avail)
1084 sun4c_lowbucket_avail = entry; 981 sun4c_lowbucket_avail = entry;
@@ -1211,7 +1108,7 @@ static void sun4c_unlockarea(char *vaddr, unsigned long size)
1211 * by implication and fool the page locking code above 1108 * by implication and fool the page locking code above
1212 * if passed to by mistake. 1109 * if passed to by mistake.
1213 */ 1110 */
1214static __u32 sun4c_get_scsi_one(char *bufptr, unsigned long len, struct sbus_bus *sbus) 1111static __u32 sun4c_get_scsi_one(struct device *dev, char *bufptr, unsigned long len)
1215{ 1112{
1216 unsigned long page; 1113 unsigned long page;
1217 1114
@@ -1223,7 +1120,7 @@ static __u32 sun4c_get_scsi_one(char *bufptr, unsigned long len, struct sbus_bus
1223 return (__u32)sun4c_lockarea(bufptr, len); 1120 return (__u32)sun4c_lockarea(bufptr, len);
1224} 1121}
1225 1122
1226static void sun4c_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 1123static void sun4c_get_scsi_sgl(struct device *dev, struct scatterlist *sg, int sz)
1227{ 1124{
1228 while (sz != 0) { 1125 while (sz != 0) {
1229 --sz; 1126 --sz;
@@ -1233,14 +1130,14 @@ static void sun4c_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *
1233 } 1130 }
1234} 1131}
1235 1132
1236static void sun4c_release_scsi_one(__u32 bufptr, unsigned long len, struct sbus_bus *sbus) 1133static void sun4c_release_scsi_one(struct device *dev, __u32 bufptr, unsigned long len)
1237{ 1134{
1238 if (bufptr < sun4c_iobuffer_start) 1135 if (bufptr < sun4c_iobuffer_start)
1239 return; /* On kernel stack or similar, see above */ 1136 return; /* On kernel stack or similar, see above */
1240 sun4c_unlockarea((char *)bufptr, len); 1137 sun4c_unlockarea((char *)bufptr, len);
1241} 1138}
1242 1139
1243static void sun4c_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) 1140static void sun4c_release_scsi_sgl(struct device *dev, struct scatterlist *sg, int sz)
1244{ 1141{
1245 while (sz != 0) { 1142 while (sz != 0) {
1246 --sz; 1143 --sz;
@@ -2263,7 +2160,6 @@ void __init ld_mmu_sun4c(void)
2263 2160
2264 BTFIXUPSET_CALL(mmu_map_dma_area, sun4c_map_dma_area, BTFIXUPCALL_NORM); 2161 BTFIXUPSET_CALL(mmu_map_dma_area, sun4c_map_dma_area, BTFIXUPCALL_NORM);
2265 BTFIXUPSET_CALL(mmu_unmap_dma_area, sun4c_unmap_dma_area, BTFIXUPCALL_NORM); 2162 BTFIXUPSET_CALL(mmu_unmap_dma_area, sun4c_unmap_dma_area, BTFIXUPCALL_NORM);
2266 BTFIXUPSET_CALL(mmu_translate_dvma, sun4c_translate_dvma, BTFIXUPCALL_NORM);
2267 2163
2268 BTFIXUPSET_CALL(sparc_mapiorange, sun4c_mapiorange, BTFIXUPCALL_NORM); 2164 BTFIXUPSET_CALL(sparc_mapiorange, sun4c_mapiorange, BTFIXUPCALL_NORM);
2269 BTFIXUPSET_CALL(sparc_unmapiorange, sun4c_unmapiorange, BTFIXUPCALL_NORM); 2165 BTFIXUPSET_CALL(sparc_unmapiorange, sun4c_unmapiorange, BTFIXUPCALL_NORM);
diff --git a/arch/sparc/prom/Makefile b/arch/sparc/prom/Makefile
index 7f5eacfcfbcf..8f7e18546c97 100644
--- a/arch/sparc/prom/Makefile
+++ b/arch/sparc/prom/Makefile
@@ -4,5 +4,3 @@
4 4
5lib-y := bootstr.o devmap.o devops.o init.o memory.o misc.o mp.o \ 5lib-y := bootstr.o devmap.o devops.o init.o memory.o misc.o mp.o \
6 palloc.o ranges.o segment.o console.o printf.o tree.o 6 palloc.o ranges.o segment.o console.o printf.o tree.o
7
8lib-$(CONFIG_SUN4) += sun4prom.o
diff --git a/arch/sparc/prom/bootstr.c b/arch/sparc/prom/bootstr.c
index 5a35c768ff7c..916831da7e67 100644
--- a/arch/sparc/prom/bootstr.c
+++ b/arch/sparc/prom/bootstr.c
@@ -6,15 +6,12 @@
6 6
7#include <linux/string.h> 7#include <linux/string.h>
8#include <asm/oplib.h> 8#include <asm/oplib.h>
9#include <asm/sun4prom.h>
10#include <linux/init.h> 9#include <linux/init.h>
11 10
12#define BARG_LEN 256 11#define BARG_LEN 256
13static char barg_buf[BARG_LEN] = { 0 }; 12static char barg_buf[BARG_LEN] = { 0 };
14static char fetched __initdata = 0; 13static char fetched __initdata = 0;
15 14
16extern linux_sun4_romvec *sun4_romvec;
17
18char * __init 15char * __init
19prom_getbootargs(void) 16prom_getbootargs(void)
20{ 17{
@@ -28,7 +25,6 @@ prom_getbootargs(void)
28 25
29 switch(prom_vers) { 26 switch(prom_vers) {
30 case PROM_V0: 27 case PROM_V0:
31 case PROM_SUN4:
32 cp = barg_buf; 28 cp = barg_buf;
33 /* Start from 1 and go over fd(0,0,0)kernel */ 29 /* Start from 1 and go over fd(0,0,0)kernel */
34 for(iter = 1; iter < 8; iter++) { 30 for(iter = 1; iter < 8; iter++) {
diff --git a/arch/sparc/prom/console.c b/arch/sparc/prom/console.c
index 790057a34616..b3075d73fc19 100644
--- a/arch/sparc/prom/console.c
+++ b/arch/sparc/prom/console.c
@@ -10,7 +10,6 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <asm/openprom.h> 12#include <asm/openprom.h>
13#include <asm/sun4prom.h>
14#include <asm/oplib.h> 13#include <asm/oplib.h>
15#include <asm/system.h> 14#include <asm/system.h>
16#include <linux/string.h> 15#include <linux/string.h>
@@ -30,7 +29,6 @@ prom_nbgetchar(void)
30 spin_lock_irqsave(&prom_lock, flags); 29 spin_lock_irqsave(&prom_lock, flags);
31 switch(prom_vers) { 30 switch(prom_vers) {
32 case PROM_V0: 31 case PROM_V0:
33 case PROM_SUN4:
34 i = (*(romvec->pv_nbgetchar))(); 32 i = (*(romvec->pv_nbgetchar))();
35 break; 33 break;
36 case PROM_V2: 34 case PROM_V2:
@@ -63,7 +61,6 @@ prom_nbputchar(char c)
63 spin_lock_irqsave(&prom_lock, flags); 61 spin_lock_irqsave(&prom_lock, flags);
64 switch(prom_vers) { 62 switch(prom_vers) {
65 case PROM_V0: 63 case PROM_V0:
66 case PROM_SUN4:
67 i = (*(romvec->pv_nbputchar))(c); 64 i = (*(romvec->pv_nbputchar))(c);
68 break; 65 break;
69 case PROM_V2: 66 case PROM_V2:
diff --git a/arch/sparc/prom/init.c b/arch/sparc/prom/init.c
index 729f87066945..873217c6d823 100644
--- a/arch/sparc/prom/init.c
+++ b/arch/sparc/prom/init.c
@@ -11,12 +11,10 @@
11 11
12#include <asm/openprom.h> 12#include <asm/openprom.h>
13#include <asm/oplib.h> 13#include <asm/oplib.h>
14#include <asm/sun4prom.h>
15 14
16struct linux_romvec *romvec; 15struct linux_romvec *romvec;
17enum prom_major_version prom_vers; 16enum prom_major_version prom_vers;
18unsigned int prom_rev, prom_prev; 17unsigned int prom_rev, prom_prev;
19linux_sun4_romvec *sun4_romvec;
20 18
21/* The root node of the prom device tree. */ 19/* The root node of the prom device tree. */
22int prom_root_node; 20int prom_root_node;
@@ -34,10 +32,6 @@ extern void prom_ranges_init(void);
34 32
35void __init prom_init(struct linux_romvec *rp) 33void __init prom_init(struct linux_romvec *rp)
36{ 34{
37#ifdef CONFIG_SUN4
38 extern struct linux_romvec *sun4_prom_init(void);
39 rp = sun4_prom_init();
40#endif
41 romvec = rp; 35 romvec = rp;
42 36
43 switch(romvec->pv_romvers) { 37 switch(romvec->pv_romvers) {
@@ -50,9 +44,6 @@ void __init prom_init(struct linux_romvec *rp)
50 case 3: 44 case 3:
51 prom_vers = PROM_V3; 45 prom_vers = PROM_V3;
52 break; 46 break;
53 case 40:
54 prom_vers = PROM_SUN4;
55 break;
56 default: 47 default:
57 prom_printf("PROMLIB: Bad PROM version %d\n", 48 prom_printf("PROMLIB: Bad PROM version %d\n",
58 romvec->pv_romvers); 49 romvec->pv_romvers);
@@ -76,11 +67,8 @@ void __init prom_init(struct linux_romvec *rp)
76 67
77 prom_ranges_init(); 68 prom_ranges_init();
78 69
79#ifndef CONFIG_SUN4
80 /* SUN4 prints this in sun4_prom_init */
81 printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n", 70 printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n",
82 romvec->pv_romvers, prom_rev); 71 romvec->pv_romvers, prom_rev);
83#endif
84 72
85 /* Initialization successful. */ 73 /* Initialization successful. */
86 return; 74 return;
diff --git a/arch/sparc/prom/memory.c b/arch/sparc/prom/memory.c
index 947f047dc95a..fac7899a29c3 100644
--- a/arch/sparc/prom/memory.c
+++ b/arch/sparc/prom/memory.c
@@ -10,7 +10,6 @@
10#include <linux/init.h> 10#include <linux/init.h>
11 11
12#include <asm/openprom.h> 12#include <asm/openprom.h>
13#include <asm/sun4prom.h>
14#include <asm/oplib.h> 13#include <asm/oplib.h>
15#include <asm/page.h> 14#include <asm/page.h>
16 15
@@ -46,15 +45,6 @@ static int __init prom_meminit_v2(void)
46 return num_ents; 45 return num_ents;
47} 46}
48 47
49static int __init prom_meminit_sun4(void)
50{
51#ifdef CONFIG_SUN4
52 sp_banks[0].base_addr = 0;
53 sp_banks[0].num_bytes = *(sun4_romvec->memoryavail);
54#endif
55 return 1;
56}
57
58static int sp_banks_cmp(const void *a, const void *b) 48static int sp_banks_cmp(const void *a, const void *b)
59{ 49{
60 const struct sparc_phys_banks *x = a, *y = b; 50 const struct sparc_phys_banks *x = a, *y = b;
@@ -81,10 +71,6 @@ void __init prom_meminit(void)
81 num_ents = prom_meminit_v2(); 71 num_ents = prom_meminit_v2();
82 break; 72 break;
83 73
84 case PROM_SUN4:
85 num_ents = prom_meminit_sun4();
86 break;
87
88 default: 74 default:
89 break; 75 break;
90 } 76 }
diff --git a/arch/sparc/prom/ranges.c b/arch/sparc/prom/ranges.c
index f9b7def35f6e..64579a376419 100644
--- a/arch/sparc/prom/ranges.c
+++ b/arch/sparc/prom/ranges.c
@@ -9,7 +9,6 @@
9#include <asm/openprom.h> 9#include <asm/openprom.h>
10#include <asm/oplib.h> 10#include <asm/oplib.h>
11#include <asm/types.h> 11#include <asm/types.h>
12#include <asm/sbus.h>
13#include <asm/system.h> 12#include <asm/system.h>
14 13
15struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX]; 14struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX];
diff --git a/arch/sparc/prom/sun4prom.c b/arch/sparc/prom/sun4prom.c
deleted file mode 100644
index 00390a2652aa..000000000000
--- a/arch/sparc/prom/sun4prom.c
+++ /dev/null
@@ -1,161 +0,0 @@
1/*
2 * Copyright (C) 1996 The Australian National University.
3 * Copyright (C) 1996 Fujitsu Laboratories Limited
4 * Copyright (C) 1997 Michael A. Griffith (grif@acm.org)
5 * Copyright (C) 1997 Sun Weenie (ko@ko.reno.nv.us)
6 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 *
8 * This software may be distributed under the terms of the Gnu
9 * Public License version 2 or later
10 *
11 * fake a really simple Sun prom for the SUN4
12 */
13
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <asm/oplib.h>
17#include <asm/idprom.h>
18#include <asm/machines.h>
19#include <asm/sun4prom.h>
20#include <asm/asi.h>
21#include <asm/contregs.h>
22#include <linux/init.h>
23
24static struct linux_romvec sun4romvec;
25static struct idprom sun4_idprom;
26
27struct property {
28 char *name;
29 char *value;
30 int length;
31};
32
33struct node {
34 int level;
35 struct property *properties;
36};
37
38struct property null_properties = { NULL, NULL, -1 };
39
40struct property root_properties[] = {
41 {"device_type", "cpu", 4},
42 {"idprom", (char *)&sun4_idprom, sizeof(struct idprom)},
43 {NULL, NULL, -1}
44};
45
46struct node nodes[] = {
47 { 0, &null_properties },
48 { 0, root_properties },
49 { -1,&null_properties }
50};
51
52
53static int no_nextnode(int node)
54{
55 if (nodes[node].level == nodes[node+1].level)
56 return node+1;
57 return -1;
58}
59
60static int no_child(int node)
61{
62 if (nodes[node].level == nodes[node+1].level-1)
63 return node+1;
64 return -1;
65}
66
67static struct property *find_property(int node,char *name)
68{
69 struct property *prop = &nodes[node].properties[0];
70 while (prop && prop->name) {
71 if (strcmp(prop->name,name) == 0) return prop;
72 prop++;
73 }
74 return NULL;
75}
76
77static int no_proplen(int node,char *name)
78{
79 struct property *prop = find_property(node,name);
80 if (prop) return prop->length;
81 return -1;
82}
83
84static int no_getprop(int node,char *name,char *value)
85{
86 struct property *prop = find_property(node,name);
87 if (prop) {
88 memcpy(value,prop->value,prop->length);
89 return 1;
90 }
91 return -1;
92}
93
94static int no_setprop(int node,char *name,char *value,int len)
95{
96 return -1;
97}
98
99static char *no_nextprop(int node,char *name)
100{
101 struct property *prop = find_property(node,name);
102 if (prop) return prop[1].name;
103 return NULL;
104}
105
106static struct linux_nodeops sun4_nodeops = {
107 no_nextnode,
108 no_child,
109 no_proplen,
110 no_getprop,
111 no_setprop,
112 no_nextprop
113};
114
115static int synch_hook;
116
117struct linux_romvec * __init sun4_prom_init(void)
118{
119 int i;
120 unsigned char x;
121 char *p;
122
123 p = (char *)&sun4_idprom;
124 for (i = 0; i < sizeof(sun4_idprom); i++) {
125 __asm__ __volatile__ ("lduba [%1] %2, %0" : "=r" (x) :
126 "r" (AC_IDPROM + i), "i" (ASI_CONTROL));
127 *p++ = x;
128 }
129
130 memset(&sun4romvec,0,sizeof(sun4romvec));
131
132 sun4_romvec = (linux_sun4_romvec *) SUN4_PROM_VECTOR;
133
134 sun4romvec.pv_romvers = 40;
135 sun4romvec.pv_nodeops = &sun4_nodeops;
136 sun4romvec.pv_reboot = sun4_romvec->reboot;
137 sun4romvec.pv_abort = sun4_romvec->abortentry;
138 sun4romvec.pv_halt = sun4_romvec->exittomon;
139 sun4romvec.pv_synchook = (void (**)(void))&synch_hook;
140 sun4romvec.pv_setctxt = sun4_romvec->setcxsegmap;
141 sun4romvec.pv_v0bootargs = sun4_romvec->bootParam;
142 sun4romvec.pv_nbgetchar = sun4_romvec->mayget;
143 sun4romvec.pv_nbputchar = sun4_romvec->mayput;
144 sun4romvec.pv_stdin = sun4_romvec->insource;
145 sun4romvec.pv_stdout = sun4_romvec->outsink;
146
147 /*
148 * We turn on the LEDs to let folks without monitors or
149 * terminals know we booted. Nothing too fancy now. They
150 * are all on, except for LED 5, which blinks. When we
151 * have more time, we can teach the penguin to say "By your
152 * command" or "Activating turbo boost, Michael". :-)
153 */
154 sun4_romvec->setLEDs(NULL);
155
156 printk("PROMLIB: Old Sun4 boot PROM monitor %s, romvec version %d\n",
157 sun4_romvec->monid,
158 sun4_romvec->romvecversion);
159
160 return &sun4romvec;
161}
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index 36b4b7ab9cfb..5446e2a499b1 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -18,6 +18,13 @@ config SPARC64
18 select HAVE_ARCH_KGDB 18 select HAVE_ARCH_KGDB
19 select USE_GENERIC_SMP_HELPERS if SMP 19 select USE_GENERIC_SMP_HELPERS if SMP
20 select HAVE_ARCH_TRACEHOOK 20 select HAVE_ARCH_TRACEHOOK
21 select ARCH_WANT_OPTIONAL_GPIOLIB
22 select RTC_CLASS
23 select RTC_DRV_M48T59
24 select RTC_DRV_CMOS
25 select RTC_DRV_BQ4802
26 select RTC_DRV_SUN4V
27 select RTC_DRV_STARFIRE
21 28
22config GENERIC_TIME 29config GENERIC_TIME
23 bool 30 bool
@@ -31,6 +38,11 @@ config GENERIC_CLOCKEVENTS
31 bool 38 bool
32 default y 39 default y
33 40
41config GENERIC_GPIO
42 bool
43 help
44 Generic GPIO API support
45
34config 64BIT 46config 64BIT
35 def_bool y 47 def_bool y
36 48
@@ -185,6 +197,17 @@ config US2E_FREQ
185 197
186 If in doubt, say N. 198 If in doubt, say N.
187 199
200config US3_MC
201 tristate "UltraSPARC-III Memory Controller driver"
202 default y
203 help
204 This adds a driver for the UltraSPARC-III memory controller.
205 Loading this driver allows exact mnemonic strings to be
206 printed in the event of a memory error, so that the faulty DIMM
207 on the motherboard can be matched to the error.
208
209 If in doubt, say Y, as this information can be very useful.
210
188# Global things across all Sun machines. 211# Global things across all Sun machines.
189config GENERIC_LOCKBREAK 212config GENERIC_LOCKBREAK
190 bool 213 bool
diff --git a/arch/sparc64/Makefile b/arch/sparc64/Makefile
index b785a395b12f..c7214abc0d84 100644
--- a/arch/sparc64/Makefile
+++ b/arch/sparc64/Makefile
@@ -7,7 +7,7 @@
7# Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz) 7# Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
8# 8#
9 9
10CHECKFLAGS += -D__sparc__ -D__sparc_v9__ -m64 10CHECKFLAGS += -D__sparc__ -D__sparc_v9__ -D__arch64__ -m64
11 11
12# Undefine sparc when processing vmlinux.lds - it is used 12# Undefine sparc when processing vmlinux.lds - it is used
13# And teach CPP we are doing 64 bit builds (for this case) 13# And teach CPP we are doing 64 bit builds (for this case)
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile
index 418b5782096e..c0b8009ab196 100644
--- a/arch/sparc64/kernel/Makefile
+++ b/arch/sparc64/kernel/Makefile
@@ -7,16 +7,16 @@ EXTRA_CFLAGS := -Werror
7 7
8extra-y := head.o init_task.o vmlinux.lds 8extra-y := head.o init_task.o vmlinux.lds
9 9
10obj-y := process.o setup.o cpu.o idprom.o \ 10obj-y := process.o setup.o cpu.o idprom.o reboot.o \
11 traps.o auxio.o una_asm.o sysfs.o iommu.o \ 11 traps.o auxio.o una_asm.o sysfs.o iommu.o \
12 irq.o ptrace.o time.o sys_sparc.o signal.o \ 12 irq.o ptrace.o time.o sys_sparc.o signal.o \
13 unaligned.o central.o pci.o starfire.o \ 13 unaligned.o central.o starfire.o \
14 power.o sbus.o sparc64_ksyms.o chmc.o \ 14 power.o sbus.o sparc64_ksyms.o ebus.o \
15 visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o 15 visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o
16 16
17obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o 17obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
18obj-$(CONFIG_STACKTRACE) += stacktrace.o 18obj-$(CONFIG_STACKTRACE) += stacktrace.o
19obj-$(CONFIG_PCI) += ebus.o pci_common.o \ 19obj-$(CONFIG_PCI) += pci.o pci_common.o psycho_common.o \
20 pci_psycho.o pci_sabre.o pci_schizo.o \ 20 pci_psycho.o pci_sabre.o pci_schizo.o \
21 pci_sun4v.o pci_sun4v_asm.o pci_fire.o 21 pci_sun4v.o pci_sun4v_asm.o pci_fire.o
22obj-$(CONFIG_PCI_MSI) += pci_msi.o 22obj-$(CONFIG_PCI_MSI) += pci_msi.o
@@ -25,6 +25,7 @@ obj-$(CONFIG_COMPAT) += sys32.o sys_sparc32.o signal32.o
25obj-$(CONFIG_MODULES) += module.o 25obj-$(CONFIG_MODULES) += module.o
26obj-$(CONFIG_US3_FREQ) += us3_cpufreq.o 26obj-$(CONFIG_US3_FREQ) += us3_cpufreq.o
27obj-$(CONFIG_US2E_FREQ) += us2e_cpufreq.o 27obj-$(CONFIG_US2E_FREQ) += us2e_cpufreq.o
28obj-$(CONFIG_US3_MC) += chmc.o
28obj-$(CONFIG_KPROBES) += kprobes.o 29obj-$(CONFIG_KPROBES) += kprobes.o
29obj-$(CONFIG_SUN_LDOMS) += ldc.o vio.o viohs.o ds.o 30obj-$(CONFIG_SUN_LDOMS) += ldc.o vio.o viohs.o ds.o
30obj-$(CONFIG_AUDIT) += audit.o 31obj-$(CONFIG_AUDIT) += audit.o
diff --git a/arch/sparc64/kernel/auxio.c b/arch/sparc64/kernel/auxio.c
index dd5c7bf87619..858beda86524 100644
--- a/arch/sparc64/kernel/auxio.c
+++ b/arch/sparc64/kernel/auxio.c
@@ -109,7 +109,7 @@ void auxio_set_lte(int on)
109 } 109 }
110} 110}
111 111
112static struct of_device_id auxio_match[] = { 112static struct of_device_id __initdata auxio_match[] = {
113 { 113 {
114 .name = "auxio", 114 .name = "auxio",
115 }, 115 },
diff --git a/arch/sparc64/kernel/central.c b/arch/sparc64/kernel/central.c
index f2e87d0d7e1d..05f1c916db06 100644
--- a/arch/sparc64/kernel/central.c
+++ b/arch/sparc64/kernel/central.c
@@ -1,461 +1,268 @@
1/* central.c: Central FHC driver for Sunfire/Starfire/Wildfire. 1/* central.c: Central FHC driver for Sunfire/Starfire/Wildfire.
2 * 2 *
3 * Copyright (C) 1997, 1999 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 1997, 1999, 2008 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/string.h> 8#include <linux/string.h>
9#include <linux/timer.h>
10#include <linux/sched.h>
11#include <linux/delay.h>
12#include <linux/init.h> 9#include <linux/init.h>
13#include <linux/bootmem.h> 10#include <linux/of_device.h>
11#include <linux/platform_device.h>
14 12
15#include <asm/page.h>
16#include <asm/fhc.h> 13#include <asm/fhc.h>
17#include <asm/starfire.h> 14#include <asm/upa.h>
18 15
19static struct linux_central *central_bus = NULL; 16struct clock_board {
20static struct linux_fhc *fhc_list = NULL; 17 void __iomem *clock_freq_regs;
18 void __iomem *clock_regs;
19 void __iomem *clock_ver_reg;
20 int num_slots;
21 struct resource leds_resource;
22 struct platform_device leds_pdev;
23};
24
25struct fhc {
26 void __iomem *pregs;
27 bool central;
28 bool jtag_master;
29 int board_num;
30 struct resource leds_resource;
31 struct platform_device leds_pdev;
32};
33
34static int __devinit clock_board_calc_nslots(struct clock_board *p)
35{
36 u8 reg = upa_readb(p->clock_regs + CLOCK_STAT1) & 0xc0;
21 37
22#define IS_CENTRAL_FHC(__fhc) ((__fhc) == central_bus->child) 38 switch (reg) {
39 case 0x40:
40 return 16;
23 41
24static void central_probe_failure(int line) 42 case 0xc0:
25{ 43 return 8;
26 prom_printf("CENTRAL: Critical device probe failure at central.c:%d\n",
27 line);
28 prom_halt();
29}
30 44
31static void central_ranges_init(struct linux_central *central) 45 case 0x80:
32{ 46 reg = 0;
33 struct device_node *dp = central->prom_node; 47 if (p->clock_ver_reg)
34 const void *pval; 48 reg = upa_readb(p->clock_ver_reg);
35 int len; 49 if (reg) {
36 50 if (reg & 0x80)
37 central->num_central_ranges = 0; 51 return 4;
38 pval = of_get_property(dp, "ranges", &len); 52 else
39 if (pval) { 53 return 5;
40 memcpy(central->central_ranges, pval, len); 54 }
41 central->num_central_ranges = 55 /* Fallthrough */
42 (len / sizeof(struct linux_prom_ranges)); 56 default:
57 return 4;
43 } 58 }
44} 59}
45 60
46static void fhc_ranges_init(struct linux_fhc *fhc) 61static int __devinit clock_board_probe(struct of_device *op,
62 const struct of_device_id *match)
47{ 63{
48 struct device_node *dp = fhc->prom_node; 64 struct clock_board *p = kzalloc(sizeof(*p), GFP_KERNEL);
49 const void *pval; 65 int err = -ENOMEM;
50 int len;
51
52 fhc->num_fhc_ranges = 0;
53 pval = of_get_property(dp, "ranges", &len);
54 if (pval) {
55 memcpy(fhc->fhc_ranges, pval, len);
56 fhc->num_fhc_ranges =
57 (len / sizeof(struct linux_prom_ranges));
58 }
59}
60 66
61/* Range application routines are exported to various drivers, 67 if (!p) {
62 * so do not __init this. 68 printk(KERN_ERR "clock_board: Cannot allocate struct clock_board\n");
63 */ 69 goto out;
64static void adjust_regs(struct linux_prom_registers *regp, int nregs,
65 struct linux_prom_ranges *rangep, int nranges)
66{
67 int regc, rngc;
68
69 for (regc = 0; regc < nregs; regc++) {
70 for (rngc = 0; rngc < nranges; rngc++)
71 if (regp[regc].which_io == rangep[rngc].ot_child_space)
72 break; /* Fount it */
73 if (rngc == nranges) /* oops */
74 central_probe_failure(__LINE__);
75 regp[regc].which_io = rangep[rngc].ot_parent_space;
76 regp[regc].phys_addr -= rangep[rngc].ot_child_base;
77 regp[regc].phys_addr += rangep[rngc].ot_parent_base;
78 } 70 }
79}
80 71
81/* Apply probed fhc ranges to registers passed, if no ranges return. */ 72 p->clock_freq_regs = of_ioremap(&op->resource[0], 0,
82static void apply_fhc_ranges(struct linux_fhc *fhc, 73 resource_size(&op->resource[0]),
83 struct linux_prom_registers *regs, 74 "clock_board_freq");
84 int nregs) 75 if (!p->clock_freq_regs) {
85{ 76 printk(KERN_ERR "clock_board: Cannot map clock_freq_regs\n");
86 if (fhc->num_fhc_ranges) 77 goto out_free;
87 adjust_regs(regs, nregs, fhc->fhc_ranges, 78 }
88 fhc->num_fhc_ranges);
89}
90 79
91/* Apply probed central ranges to registers passed, if no ranges return. */ 80 p->clock_regs = of_ioremap(&op->resource[1], 0,
92static void apply_central_ranges(struct linux_central *central, 81 resource_size(&op->resource[1]),
93 struct linux_prom_registers *regs, int nregs) 82 "clock_board_regs");
94{ 83 if (!p->clock_regs) {
95 if (central->num_central_ranges) 84 printk(KERN_ERR "clock_board: Cannot map clock_regs\n");
96 adjust_regs(regs, nregs, central->central_ranges, 85 goto out_unmap_clock_freq_regs;
97 central->num_central_ranges); 86 }
98}
99 87
100static void * __init central_alloc_bootmem(unsigned long size) 88 if (op->resource[2].flags) {
101{ 89 p->clock_ver_reg = of_ioremap(&op->resource[2], 0,
102 void *ret; 90 resource_size(&op->resource[2]),
91 "clock_ver_reg");
92 if (!p->clock_ver_reg) {
93 printk(KERN_ERR "clock_board: Cannot map clock_ver_reg\n");
94 goto out_unmap_clock_regs;
95 }
96 }
103 97
104 ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL); 98 p->num_slots = clock_board_calc_nslots(p);
105 if (ret != NULL)
106 memset(ret, 0, size);
107 99
108 return ret; 100 p->leds_resource.start = (unsigned long)
109} 101 (p->clock_regs + CLOCK_CTRL);
102 p->leds_resource.end = p->leds_resource.end;
103 p->leds_resource.name = "leds";
110 104
111static unsigned long prom_reg_to_paddr(struct linux_prom_registers *r) 105 p->leds_pdev.name = "sunfire-clockboard-leds";
112{ 106 p->leds_pdev.resource = &p->leds_resource;
113 unsigned long ret = ((unsigned long) r->which_io) << 32; 107 p->leds_pdev.num_resources = 1;
108 p->leds_pdev.dev.parent = &op->dev;
114 109
115 return ret | (unsigned long) r->phys_addr; 110 err = platform_device_register(&p->leds_pdev);
116} 111 if (err) {
117 112 printk(KERN_ERR "clock_board: Could not register LEDS "
118static void __init probe_other_fhcs(void) 113 "platform device\n");
119{ 114 goto out_unmap_clock_ver_reg;
120 struct device_node *dp;
121 const struct linux_prom64_registers *fpregs;
122
123 for_each_node_by_name(dp, "fhc") {
124 struct linux_fhc *fhc;
125 int board;
126 u32 tmp;
127
128 if (dp->parent &&
129 dp->parent->parent != NULL)
130 continue;
131
132 fhc = (struct linux_fhc *)
133 central_alloc_bootmem(sizeof(struct linux_fhc));
134 if (fhc == NULL)
135 central_probe_failure(__LINE__);
136
137 /* Link it into the FHC chain. */
138 fhc->next = fhc_list;
139 fhc_list = fhc;
140
141 /* Toplevel FHCs have no parent. */
142 fhc->parent = NULL;
143
144 fhc->prom_node = dp;
145 fhc_ranges_init(fhc);
146
147 /* Non-central FHC's have 64-bit OBP format registers. */
148 fpregs = of_get_property(dp, "reg", NULL);
149 if (!fpregs)
150 central_probe_failure(__LINE__);
151
152 /* Only central FHC needs special ranges applied. */
153 fhc->fhc_regs.pregs = fpregs[0].phys_addr;
154 fhc->fhc_regs.ireg = fpregs[1].phys_addr;
155 fhc->fhc_regs.ffregs = fpregs[2].phys_addr;
156 fhc->fhc_regs.sregs = fpregs[3].phys_addr;
157 fhc->fhc_regs.uregs = fpregs[4].phys_addr;
158 fhc->fhc_regs.tregs = fpregs[5].phys_addr;
159
160 board = of_getintprop_default(dp, "board#", -1);
161 fhc->board = board;
162
163 tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_JCTRL);
164 if ((tmp & FHC_JTAG_CTRL_MENAB) != 0)
165 fhc->jtag_master = 1;
166 else
167 fhc->jtag_master = 0;
168
169 tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_ID);
170 printk("FHC(board %d): Version[%x] PartID[%x] Manuf[%x] %s\n",
171 board,
172 (tmp & FHC_ID_VERS) >> 28,
173 (tmp & FHC_ID_PARTID) >> 12,
174 (tmp & FHC_ID_MANUF) >> 1,
175 (fhc->jtag_master ? "(JTAG Master)" : ""));
176
177 /* This bit must be set in all non-central FHC's in
178 * the system. When it is clear, this identifies
179 * the central board.
180 */
181 tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL);
182 tmp |= FHC_CONTROL_IXIST;
183 upa_writel(tmp, fhc->fhc_regs.pregs + FHC_PREGS_CTRL);
184 } 115 }
185}
186 116
187static void probe_clock_board(struct linux_central *central, 117 printk(KERN_INFO "clock_board: Detected %d slot Enterprise system.\n",
188 struct linux_fhc *fhc, 118 p->num_slots);
189 struct device_node *fp)
190{
191 struct device_node *dp;
192 struct linux_prom_registers cregs[3];
193 const struct linux_prom_registers *pr;
194 int nslots, tmp, nregs;
195
196 dp = fp->child;
197 while (dp) {
198 if (!strcmp(dp->name, "clock-board"))
199 break;
200 dp = dp->sibling;
201 }
202 if (!dp)
203 central_probe_failure(__LINE__);
204 119
205 pr = of_get_property(dp, "reg", &nregs); 120 err = 0;
206 if (!pr) 121out:
207 central_probe_failure(__LINE__); 122 return err;
208 123
209 memcpy(cregs, pr, nregs); 124out_unmap_clock_ver_reg:
210 nregs /= sizeof(struct linux_prom_registers); 125 if (p->clock_ver_reg)
126 of_iounmap(&op->resource[2], p->clock_ver_reg,
127 resource_size(&op->resource[2]));
211 128
212 apply_fhc_ranges(fhc, &cregs[0], nregs); 129out_unmap_clock_regs:
213 apply_central_ranges(central, &cregs[0], nregs); 130 of_iounmap(&op->resource[1], p->clock_regs,
214 central->cfreg = prom_reg_to_paddr(&cregs[0]); 131 resource_size(&op->resource[1]));
215 central->clkregs = prom_reg_to_paddr(&cregs[1]);
216 132
217 if (nregs == 2) 133out_unmap_clock_freq_regs:
218 central->clkver = 0UL; 134 of_iounmap(&op->resource[0], p->clock_freq_regs,
219 else 135 resource_size(&op->resource[0]));
220 central->clkver = prom_reg_to_paddr(&cregs[2]);
221 136
222 tmp = upa_readb(central->clkregs + CLOCK_STAT1); 137out_free:
223 tmp &= 0xc0; 138 kfree(p);
224 switch(tmp) { 139 goto out;
225 case 0x40:
226 nslots = 16;
227 break;
228 case 0xc0:
229 nslots = 8;
230 break;
231 case 0x80:
232 if (central->clkver != 0UL &&
233 upa_readb(central->clkver) != 0) {
234 if ((upa_readb(central->clkver) & 0x80) != 0)
235 nslots = 4;
236 else
237 nslots = 5;
238 break;
239 }
240 default:
241 nslots = 4;
242 break;
243 };
244 central->slots = nslots;
245 printk("CENTRAL: Detected %d slot Enterprise system. cfreg[%02x] cver[%02x]\n",
246 central->slots, upa_readb(central->cfreg),
247 (central->clkver ? upa_readb(central->clkver) : 0x00));
248} 140}
249 141
250static void ZAP(unsigned long iclr, unsigned long imap) 142static struct of_device_id __initdata clock_board_match[] = {
143 {
144 .name = "clock-board",
145 },
146 {},
147};
148
149static struct of_platform_driver clock_board_driver = {
150 .match_table = clock_board_match,
151 .probe = clock_board_probe,
152 .driver = {
153 .name = "clock_board",
154 },
155};
156
157static int __devinit fhc_probe(struct of_device *op,
158 const struct of_device_id *match)
251{ 159{
252 u32 imap_tmp; 160 struct fhc *p = kzalloc(sizeof(*p), GFP_KERNEL);
253 161 int err = -ENOMEM;
254 upa_writel(0, iclr); 162 u32 reg;
255 upa_readl(iclr);
256 imap_tmp = upa_readl(imap);
257 imap_tmp &= ~(0x80000000);
258 upa_writel(imap_tmp, imap);
259 upa_readl(imap);
260}
261 163
262static void init_all_fhc_hw(void) 164 if (!p) {
263{ 165 printk(KERN_ERR "fhc: Cannot allocate struct fhc\n");
264 struct linux_fhc *fhc; 166 goto out;
265
266 for (fhc = fhc_list; fhc != NULL; fhc = fhc->next) {
267 u32 tmp;
268
269 /* Clear all of the interrupt mapping registers
270 * just in case OBP left them in a foul state.
271 */
272 ZAP(fhc->fhc_regs.ffregs + FHC_FFREGS_ICLR,
273 fhc->fhc_regs.ffregs + FHC_FFREGS_IMAP);
274 ZAP(fhc->fhc_regs.sregs + FHC_SREGS_ICLR,
275 fhc->fhc_regs.sregs + FHC_SREGS_IMAP);
276 ZAP(fhc->fhc_regs.uregs + FHC_UREGS_ICLR,
277 fhc->fhc_regs.uregs + FHC_UREGS_IMAP);
278 ZAP(fhc->fhc_regs.tregs + FHC_TREGS_ICLR,
279 fhc->fhc_regs.tregs + FHC_TREGS_IMAP);
280
281 /* Setup FHC control register. */
282 tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL);
283
284 /* All non-central boards have this bit set. */
285 if (! IS_CENTRAL_FHC(fhc))
286 tmp |= FHC_CONTROL_IXIST;
287
288 /* For all FHCs, clear the firmware synchronization
289 * line and both low power mode enables.
290 */
291 tmp &= ~(FHC_CONTROL_AOFF | FHC_CONTROL_BOFF |
292 FHC_CONTROL_SLINE);
293
294 upa_writel(tmp, fhc->fhc_regs.pregs + FHC_PREGS_CTRL);
295 upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL);
296 } 167 }
297 168
298} 169 if (!strcmp(op->node->parent->name, "central"))
170 p->central = true;
299 171
300void __init central_probe(void) 172 p->pregs = of_ioremap(&op->resource[0], 0,
301{ 173 resource_size(&op->resource[0]),
302 struct linux_prom_registers fpregs[6]; 174 "fhc_pregs");
303 const struct linux_prom_registers *pr; 175 if (!p->pregs) {
304 struct linux_fhc *fhc; 176 printk(KERN_ERR "fhc: Cannot map pregs\n");
305 struct device_node *dp, *fp; 177 goto out_free;
306 int err;
307
308 dp = of_find_node_by_name(NULL, "central");
309 if (!dp) {
310 if (this_is_starfire)
311 starfire_cpu_setup();
312 return;
313 } 178 }
314 179
315 /* Ok we got one, grab some memory for software state. */ 180 if (p->central) {
316 central_bus = (struct linux_central *) 181 reg = upa_readl(p->pregs + FHC_PREGS_BSR);
317 central_alloc_bootmem(sizeof(struct linux_central)); 182 p->board_num = ((reg >> 16) & 1) | ((reg >> 12) & 0x0e);
318 if (central_bus == NULL) 183 } else {
319 central_probe_failure(__LINE__); 184 p->board_num = of_getintprop_default(op->node, "board#", -1);
320 185 if (p->board_num == -1) {
321 fhc = (struct linux_fhc *) 186 printk(KERN_ERR "fhc: No board# property\n");
322 central_alloc_bootmem(sizeof(struct linux_fhc)); 187 goto out_unmap_pregs;
323 if (fhc == NULL) 188 }
324 central_probe_failure(__LINE__); 189 if (upa_readl(p->pregs + FHC_PREGS_JCTRL) & FHC_JTAG_CTRL_MENAB)
325 190 p->jtag_master = true;
326 /* First init central. */
327 central_bus->child = fhc;
328 central_bus->prom_node = dp;
329 central_ranges_init(central_bus);
330
331 /* And then central's FHC. */
332 fhc->next = fhc_list;
333 fhc_list = fhc;
334
335 fhc->parent = central_bus;
336 fp = dp->child;
337 while (fp) {
338 if (!strcmp(fp->name, "fhc"))
339 break;
340 fp = fp->sibling;
341 } 191 }
342 if (!fp)
343 central_probe_failure(__LINE__);
344
345 fhc->prom_node = fp;
346 fhc_ranges_init(fhc);
347
348 /* Now, map in FHC register set. */
349 pr = of_get_property(fp, "reg", NULL);
350 if (!pr)
351 central_probe_failure(__LINE__);
352 memcpy(fpregs, pr, sizeof(fpregs));
353
354 apply_central_ranges(central_bus, &fpregs[0], 6);
355
356 fhc->fhc_regs.pregs = prom_reg_to_paddr(&fpregs[0]);
357 fhc->fhc_regs.ireg = prom_reg_to_paddr(&fpregs[1]);
358 fhc->fhc_regs.ffregs = prom_reg_to_paddr(&fpregs[2]);
359 fhc->fhc_regs.sregs = prom_reg_to_paddr(&fpregs[3]);
360 fhc->fhc_regs.uregs = prom_reg_to_paddr(&fpregs[4]);
361 fhc->fhc_regs.tregs = prom_reg_to_paddr(&fpregs[5]);
362
363 /* Obtain board number from board status register, Central's
364 * FHC lacks "board#" property.
365 */
366 err = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_BSR);
367 fhc->board = (((err >> 16) & 0x01) |
368 ((err >> 12) & 0x0e));
369
370 fhc->jtag_master = 0;
371
372 /* Attach the clock board registers for CENTRAL. */
373 probe_clock_board(central_bus, fhc, fp);
374
375 err = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_ID);
376 printk("FHC(board %d): Version[%x] PartID[%x] Manuf[%x] (CENTRAL)\n",
377 fhc->board,
378 ((err & FHC_ID_VERS) >> 28),
379 ((err & FHC_ID_PARTID) >> 12),
380 ((err & FHC_ID_MANUF) >> 1));
381
382 probe_other_fhcs();
383
384 init_all_fhc_hw();
385}
386 192
387static inline void fhc_ledblink(struct linux_fhc *fhc, int on) 193 if (!p->central) {
388{ 194 p->leds_resource.start = (unsigned long)
389 u32 tmp; 195 (p->pregs + FHC_PREGS_CTRL);
196 p->leds_resource.end = p->leds_resource.end;
197 p->leds_resource.name = "leds";
198
199 p->leds_pdev.name = "sunfire-fhc-leds";
200 p->leds_pdev.resource = &p->leds_resource;
201 p->leds_pdev.num_resources = 1;
202 p->leds_pdev.dev.parent = &op->dev;
203
204 err = platform_device_register(&p->leds_pdev);
205 if (err) {
206 printk(KERN_ERR "fhc: Could not register LEDS "
207 "platform device\n");
208 goto out_unmap_pregs;
209 }
210 }
211 reg = upa_readl(p->pregs + FHC_PREGS_CTRL);
390 212
391 tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL); 213 if (!p->central)
214 reg |= FHC_CONTROL_IXIST;
392 215
393 /* NOTE: reverse logic on this bit */ 216 reg &= ~(FHC_CONTROL_AOFF |
394 if (on) 217 FHC_CONTROL_BOFF |
395 tmp &= ~(FHC_CONTROL_RLED); 218 FHC_CONTROL_SLINE);
396 else
397 tmp |= FHC_CONTROL_RLED;
398 tmp &= ~(FHC_CONTROL_AOFF | FHC_CONTROL_BOFF | FHC_CONTROL_SLINE);
399 219
400 upa_writel(tmp, fhc->fhc_regs.pregs + FHC_PREGS_CTRL); 220 upa_writel(reg, p->pregs + FHC_PREGS_CTRL);
401 upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL); 221 upa_readl(p->pregs + FHC_PREGS_CTRL);
402}
403 222
404static inline void central_ledblink(struct linux_central *central, int on) 223 reg = upa_readl(p->pregs + FHC_PREGS_ID);
405{ 224 printk(KERN_INFO "fhc: Board #%d, Version[%x] PartID[%x] Manuf[%x] %s\n",
406 u8 tmp; 225 p->board_num,
407 226 (reg & FHC_ID_VERS) >> 28,
408 tmp = upa_readb(central->clkregs + CLOCK_CTRL); 227 (reg & FHC_ID_PARTID) >> 12,
228 (reg & FHC_ID_MANUF) >> 1,
229 (p->jtag_master ?
230 "(JTAG Master)" :
231 (p->central ? "(Central)" : "")));
409 232
410 /* NOTE: reverse logic on this bit */ 233 err = 0;
411 if (on)
412 tmp &= ~(CLOCK_CTRL_RLED);
413 else
414 tmp |= CLOCK_CTRL_RLED;
415 234
416 upa_writeb(tmp, central->clkregs + CLOCK_CTRL); 235out:
417 upa_readb(central->clkregs + CLOCK_CTRL); 236 return err;
418}
419 237
420static struct timer_list sftimer; 238out_unmap_pregs:
421static int led_state; 239 of_iounmap(&op->resource[0], p->pregs, resource_size(&op->resource[0]));
422 240
423static void sunfire_timer(unsigned long __ignored) 241out_free:
424{ 242 kfree(p);
425 struct linux_fhc *fhc; 243 goto out;
426
427 central_ledblink(central_bus, led_state);
428 for (fhc = fhc_list; fhc != NULL; fhc = fhc->next)
429 if (! IS_CENTRAL_FHC(fhc))
430 fhc_ledblink(fhc, led_state);
431 led_state = ! led_state;
432 sftimer.expires = jiffies + (HZ >> 1);
433 add_timer(&sftimer);
434} 244}
435 245
436/* After PCI/SBUS busses have been probed, this is called to perform 246static struct of_device_id __initdata fhc_match[] = {
437 * final initialization of all FireHose Controllers in the system. 247 {
438 */ 248 .name = "fhc",
439void firetruck_init(void) 249 },
250 {},
251};
252
253static struct of_platform_driver fhc_driver = {
254 .match_table = fhc_match,
255 .probe = fhc_probe,
256 .driver = {
257 .name = "fhc",
258 },
259};
260
261static int __init sunfire_init(void)
440{ 262{
441 struct linux_central *central = central_bus; 263 (void) of_register_driver(&fhc_driver, &of_platform_bus_type);
442 u8 ctrl; 264 (void) of_register_driver(&clock_board_driver, &of_platform_bus_type);
443 265 return 0;
444 /* No central bus, nothing to do. */
445 if (central == NULL)
446 return;
447
448 /* OBP leaves it on, turn it off so clock board timer LED
449 * is in sync with FHC ones.
450 */
451 ctrl = upa_readb(central->clkregs + CLOCK_CTRL);
452 ctrl &= ~(CLOCK_CTRL_RLED);
453 upa_writeb(ctrl, central->clkregs + CLOCK_CTRL);
454
455 led_state = 0;
456 init_timer(&sftimer);
457 sftimer.data = 0;
458 sftimer.function = &sunfire_timer;
459 sftimer.expires = jiffies + (HZ >> 1);
460 add_timer(&sftimer);
461} 266}
267
268subsys_initcall(sunfire_init);
diff --git a/arch/sparc64/kernel/chmc.c b/arch/sparc64/kernel/chmc.c
index 6d4f02e8a4cf..967b04886822 100644
--- a/arch/sparc64/kernel/chmc.c
+++ b/arch/sparc64/kernel/chmc.c
@@ -1,6 +1,6 @@
1/* memctrlr.c: Driver for UltraSPARC-III memory controller. 1/* chmc.c: Driver for UltraSPARC-III memory controller.
2 * 2 *
3 * Copyright (C) 2001, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2001, 2007, 2008 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#include <linux/module.h> 6#include <linux/module.h>
@@ -13,45 +13,64 @@
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/of.h>
17#include <linux/of_device.h>
16#include <asm/spitfire.h> 18#include <asm/spitfire.h>
17#include <asm/chmctrl.h> 19#include <asm/chmctrl.h>
18#include <asm/cpudata.h> 20#include <asm/cpudata.h>
19#include <asm/oplib.h> 21#include <asm/oplib.h>
20#include <asm/prom.h> 22#include <asm/prom.h>
23#include <asm/head.h>
21#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/memctrl.h>
26
27#define DRV_MODULE_NAME "chmc"
28#define PFX DRV_MODULE_NAME ": "
29#define DRV_MODULE_VERSION "0.2"
30
31MODULE_AUTHOR("David S. Miller (davem@davemloft.net)");
32MODULE_DESCRIPTION("UltraSPARC-III memory controller driver");
33MODULE_LICENSE("GPL");
34MODULE_VERSION(DRV_MODULE_VERSION);
35
36static int mc_type;
37#define MC_TYPE_SAFARI 1
38#define MC_TYPE_JBUS 2
39
40static dimm_printer_t us3mc_dimm_printer;
22 41
23#define CHMCTRL_NDGRPS 2 42#define CHMCTRL_NDGRPS 2
24#define CHMCTRL_NDIMMS 4 43#define CHMCTRL_NDIMMS 4
25 44
26#define DIMMS_PER_MC (CHMCTRL_NDGRPS * CHMCTRL_NDIMMS) 45#define CHMC_DIMMS_PER_MC (CHMCTRL_NDGRPS * CHMCTRL_NDIMMS)
27 46
28/* OBP memory-layout property format. */ 47/* OBP memory-layout property format. */
29struct obp_map { 48struct chmc_obp_map {
30 unsigned char dimm_map[144]; 49 unsigned char dimm_map[144];
31 unsigned char pin_map[576]; 50 unsigned char pin_map[576];
32}; 51};
33 52
34#define DIMM_LABEL_SZ 8 53#define DIMM_LABEL_SZ 8
35 54
36struct obp_mem_layout { 55struct chmc_obp_mem_layout {
37 /* One max 8-byte string label per DIMM. Usually 56 /* One max 8-byte string label per DIMM. Usually
38 * this matches the label on the motherboard where 57 * this matches the label on the motherboard where
39 * that DIMM resides. 58 * that DIMM resides.
40 */ 59 */
41 char dimm_labels[DIMMS_PER_MC][DIMM_LABEL_SZ]; 60 char dimm_labels[CHMC_DIMMS_PER_MC][DIMM_LABEL_SZ];
42 61
43 /* If symmetric use map[0], else it is 62 /* If symmetric use map[0], else it is
44 * asymmetric and map[1] should be used. 63 * asymmetric and map[1] should be used.
45 */ 64 */
46 char symmetric; 65 char symmetric;
47 66
48 struct obp_map map[2]; 67 struct chmc_obp_map map[2];
49}; 68};
50 69
51#define CHMCTRL_NBANKS 4 70#define CHMCTRL_NBANKS 4
52 71
53struct bank_info { 72struct chmc_bank_info {
54 struct mctrl_info *mp; 73 struct chmc *p;
55 int bank_id; 74 int bank_id;
56 75
57 u64 raw_reg; 76 u64 raw_reg;
@@ -65,28 +84,406 @@ struct bank_info {
65 unsigned long size; 84 unsigned long size;
66}; 85};
67 86
68struct mctrl_info { 87struct chmc {
69 struct list_head list; 88 struct list_head list;
70 int portid; 89 int portid;
90
91 struct chmc_obp_mem_layout layout_prop;
92 int layout_size;
93
94 void __iomem *regs;
71 95
72 struct obp_mem_layout layout_prop; 96 u64 timing_control1;
73 int layout_size; 97 u64 timing_control2;
98 u64 timing_control3;
99 u64 timing_control4;
100 u64 memaddr_control;
74 101
75 void __iomem *regs; 102 struct chmc_bank_info logical_banks[CHMCTRL_NBANKS];
103};
104
105#define JBUSMC_REGS_SIZE 8
106
107#define JB_MC_REG1_DIMM2_BANK3 0x8000000000000000UL
108#define JB_MC_REG1_DIMM1_BANK1 0x4000000000000000UL
109#define JB_MC_REG1_DIMM2_BANK2 0x2000000000000000UL
110#define JB_MC_REG1_DIMM1_BANK0 0x1000000000000000UL
111#define JB_MC_REG1_XOR 0x0000010000000000UL
112#define JB_MC_REG1_ADDR_GEN_2 0x000000e000000000UL
113#define JB_MC_REG1_ADDR_GEN_2_SHIFT 37
114#define JB_MC_REG1_ADDR_GEN_1 0x0000001c00000000UL
115#define JB_MC_REG1_ADDR_GEN_1_SHIFT 34
116#define JB_MC_REG1_INTERLEAVE 0x0000000001800000UL
117#define JB_MC_REG1_INTERLEAVE_SHIFT 23
118#define JB_MC_REG1_DIMM2_PTYPE 0x0000000000200000UL
119#define JB_MC_REG1_DIMM2_PTYPE_SHIFT 21
120#define JB_MC_REG1_DIMM1_PTYPE 0x0000000000100000UL
121#define JB_MC_REG1_DIMM1_PTYPE_SHIFT 20
122
123#define PART_TYPE_X8 0
124#define PART_TYPE_X4 1
125
126#define INTERLEAVE_NONE 0
127#define INTERLEAVE_SAME 1
128#define INTERLEAVE_INTERNAL 2
129#define INTERLEAVE_BOTH 3
130
131#define ADDR_GEN_128MB 0
132#define ADDR_GEN_256MB 1
133#define ADDR_GEN_512MB 2
134#define ADDR_GEN_1GB 3
135
136#define JB_NUM_DIMM_GROUPS 2
137#define JB_NUM_DIMMS_PER_GROUP 2
138#define JB_NUM_DIMMS (JB_NUM_DIMM_GROUPS * JB_NUM_DIMMS_PER_GROUP)
139
140struct jbusmc_obp_map {
141 unsigned char dimm_map[18];
142 unsigned char pin_map[144];
143};
144
145struct jbusmc_obp_mem_layout {
146 /* One max 8-byte string label per DIMM. Usually
147 * this matches the label on the motherboard where
148 * that DIMM resides.
149 */
150 char dimm_labels[JB_NUM_DIMMS][DIMM_LABEL_SZ];
151
152 /* If symmetric use map[0], else it is
153 * asymmetric and map[1] should be used.
154 */
155 char symmetric;
156
157 struct jbusmc_obp_map map;
158
159 char _pad;
160};
76 161
77 u64 timing_control1; 162struct jbusmc_dimm_group {
78 u64 timing_control2; 163 struct jbusmc *controller;
79 u64 timing_control3; 164 int index;
80 u64 timing_control4; 165 u64 base_addr;
81 u64 memaddr_control; 166 u64 size;
167};
82 168
83 struct bank_info logical_banks[CHMCTRL_NBANKS]; 169struct jbusmc {
170 void __iomem *regs;
171 u64 mc_reg_1;
172 u32 portid;
173 struct jbusmc_obp_mem_layout layout;
174 int layout_len;
175 int num_dimm_groups;
176 struct jbusmc_dimm_group dimm_groups[JB_NUM_DIMM_GROUPS];
177 struct list_head list;
84}; 178};
85 179
180static DEFINE_SPINLOCK(mctrl_list_lock);
86static LIST_HEAD(mctrl_list); 181static LIST_HEAD(mctrl_list);
87 182
183static void mc_list_add(struct list_head *list)
184{
185 spin_lock(&mctrl_list_lock);
186 list_add(list, &mctrl_list);
187 spin_unlock(&mctrl_list_lock);
188}
189
190static void mc_list_del(struct list_head *list)
191{
192 spin_lock(&mctrl_list_lock);
193 list_del_init(list);
194 spin_unlock(&mctrl_list_lock);
195}
196
197#define SYNDROME_MIN -1
198#define SYNDROME_MAX 144
199
200/* Covert syndrome code into the way the bits are positioned
201 * on the bus.
202 */
203static int syndrome_to_qword_code(int syndrome_code)
204{
205 if (syndrome_code < 128)
206 syndrome_code += 16;
207 else if (syndrome_code < 128 + 9)
208 syndrome_code -= (128 - 7);
209 else if (syndrome_code < (128 + 9 + 3))
210 syndrome_code -= (128 + 9 - 4);
211 else
212 syndrome_code -= (128 + 9 + 3);
213 return syndrome_code;
214}
215
216/* All this magic has to do with how a cache line comes over the wire
217 * on Safari and JBUS. A 64-bit line comes over in 1 or more quadword
218 * cycles, each of which transmit ECC/MTAG info as well as the actual
219 * data.
220 */
221#define L2_LINE_SIZE 64
222#define L2_LINE_ADDR_MSK (L2_LINE_SIZE - 1)
223#define QW_PER_LINE 4
224#define QW_BYTES (L2_LINE_SIZE / QW_PER_LINE)
225#define QW_BITS 144
226#define SAFARI_LAST_BIT (576 - 1)
227#define JBUS_LAST_BIT (144 - 1)
228
229static void get_pin_and_dimm_str(int syndrome_code, unsigned long paddr,
230 int *pin_p, char **dimm_str_p, void *_prop,
231 int base_dimm_offset)
232{
233 int qword_code = syndrome_to_qword_code(syndrome_code);
234 int cache_line_offset;
235 int offset_inverse;
236 int dimm_map_index;
237 int map_val;
238
239 if (mc_type == MC_TYPE_JBUS) {
240 struct jbusmc_obp_mem_layout *p = _prop;
241
242 /* JBUS */
243 cache_line_offset = qword_code;
244 offset_inverse = (JBUS_LAST_BIT - cache_line_offset);
245 dimm_map_index = offset_inverse / 8;
246 map_val = p->map.dimm_map[dimm_map_index];
247 map_val = ((map_val >> ((7 - (offset_inverse & 7)))) & 1);
248 *dimm_str_p = p->dimm_labels[base_dimm_offset + map_val];
249 *pin_p = p->map.pin_map[cache_line_offset];
250 } else {
251 struct chmc_obp_mem_layout *p = _prop;
252 struct chmc_obp_map *mp;
253 int qword;
254
255 /* Safari */
256 if (p->symmetric)
257 mp = &p->map[0];
258 else
259 mp = &p->map[1];
260
261 qword = (paddr & L2_LINE_ADDR_MSK) / QW_BYTES;
262 cache_line_offset = ((3 - qword) * QW_BITS) + qword_code;
263 offset_inverse = (SAFARI_LAST_BIT - cache_line_offset);
264 dimm_map_index = offset_inverse >> 2;
265 map_val = mp->dimm_map[dimm_map_index];
266 map_val = ((map_val >> ((3 - (offset_inverse & 3)) << 1)) & 0x3);
267 *dimm_str_p = p->dimm_labels[base_dimm_offset + map_val];
268 *pin_p = mp->pin_map[cache_line_offset];
269 }
270}
271
272static struct jbusmc_dimm_group *jbusmc_find_dimm_group(unsigned long phys_addr)
273{
274 struct jbusmc *p;
275
276 list_for_each_entry(p, &mctrl_list, list) {
277 int i;
278
279 for (i = 0; i < p->num_dimm_groups; i++) {
280 struct jbusmc_dimm_group *dp = &p->dimm_groups[i];
281
282 if (phys_addr < dp->base_addr ||
283 (dp->base_addr + dp->size) <= phys_addr)
284 continue;
285
286 return dp;
287 }
288 }
289 return NULL;
290}
291
292static int jbusmc_print_dimm(int syndrome_code,
293 unsigned long phys_addr,
294 char *buf, int buflen)
295{
296 struct jbusmc_obp_mem_layout *prop;
297 struct jbusmc_dimm_group *dp;
298 struct jbusmc *p;
299 int first_dimm;
300
301 dp = jbusmc_find_dimm_group(phys_addr);
302 if (dp == NULL ||
303 syndrome_code < SYNDROME_MIN ||
304 syndrome_code > SYNDROME_MAX) {
305 buf[0] = '?';
306 buf[1] = '?';
307 buf[2] = '?';
308 buf[3] = '\0';
309 }
310 p = dp->controller;
311 prop = &p->layout;
312
313 first_dimm = dp->index * JB_NUM_DIMMS_PER_GROUP;
314
315 if (syndrome_code != SYNDROME_MIN) {
316 char *dimm_str;
317 int pin;
318
319 get_pin_and_dimm_str(syndrome_code, phys_addr, &pin,
320 &dimm_str, prop, first_dimm);
321 sprintf(buf, "%s, pin %3d", dimm_str, pin);
322 } else {
323 int dimm;
324
325 /* Multi-bit error, we just dump out all the
326 * dimm labels associated with this dimm group.
327 */
328 for (dimm = 0; dimm < JB_NUM_DIMMS_PER_GROUP; dimm++) {
329 sprintf(buf, "%s ",
330 prop->dimm_labels[first_dimm + dimm]);
331 buf += strlen(buf);
332 }
333 }
334
335 return 0;
336}
337
338static u64 __devinit jbusmc_dimm_group_size(u64 base,
339 const struct linux_prom64_registers *mem_regs,
340 int num_mem_regs)
341{
342 u64 max = base + (8UL * 1024 * 1024 * 1024);
343 u64 max_seen = base;
344 int i;
345
346 for (i = 0; i < num_mem_regs; i++) {
347 const struct linux_prom64_registers *ent;
348 u64 this_base;
349 u64 this_end;
350
351 ent = &mem_regs[i];
352 this_base = ent->phys_addr;
353 this_end = this_base + ent->reg_size;
354 if (base < this_base || base >= this_end)
355 continue;
356 if (this_end > max)
357 this_end = max;
358 if (this_end > max_seen)
359 max_seen = this_end;
360 }
361
362 return max_seen - base;
363}
364
365static void __devinit jbusmc_construct_one_dimm_group(struct jbusmc *p,
366 unsigned long index,
367 const struct linux_prom64_registers *mem_regs,
368 int num_mem_regs)
369{
370 struct jbusmc_dimm_group *dp = &p->dimm_groups[index];
371
372 dp->controller = p;
373 dp->index = index;
374
375 dp->base_addr = (p->portid * (64UL * 1024 * 1024 * 1024));
376 dp->base_addr += (index * (8UL * 1024 * 1024 * 1024));
377 dp->size = jbusmc_dimm_group_size(dp->base_addr, mem_regs, num_mem_regs);
378}
379
380static void __devinit jbusmc_construct_dimm_groups(struct jbusmc *p,
381 const struct linux_prom64_registers *mem_regs,
382 int num_mem_regs)
383{
384 if (p->mc_reg_1 & JB_MC_REG1_DIMM1_BANK0) {
385 jbusmc_construct_one_dimm_group(p, 0, mem_regs, num_mem_regs);
386 p->num_dimm_groups++;
387 }
388 if (p->mc_reg_1 & JB_MC_REG1_DIMM2_BANK2) {
389 jbusmc_construct_one_dimm_group(p, 1, mem_regs, num_mem_regs);
390 p->num_dimm_groups++;
391 }
392}
393
394static int __devinit jbusmc_probe(struct of_device *op,
395 const struct of_device_id *match)
396{
397 const struct linux_prom64_registers *mem_regs;
398 struct device_node *mem_node;
399 int err, len, num_mem_regs;
400 struct jbusmc *p;
401 const u32 *prop;
402 const void *ml;
403
404 err = -ENODEV;
405 mem_node = of_find_node_by_path("/memory");
406 if (!mem_node) {
407 printk(KERN_ERR PFX "Cannot find /memory node.\n");
408 goto out;
409 }
410 mem_regs = of_get_property(mem_node, "reg", &len);
411 if (!mem_regs) {
412 printk(KERN_ERR PFX "Cannot get reg property of /memory node.\n");
413 goto out;
414 }
415 num_mem_regs = len / sizeof(*mem_regs);
416
417 err = -ENOMEM;
418 p = kzalloc(sizeof(*p), GFP_KERNEL);
419 if (!p) {
420 printk(KERN_ERR PFX "Cannot allocate struct jbusmc.\n");
421 goto out;
422 }
423
424 INIT_LIST_HEAD(&p->list);
425
426 err = -ENODEV;
427 prop = of_get_property(op->node, "portid", &len);
428 if (!prop || len != 4) {
429 printk(KERN_ERR PFX "Cannot find portid.\n");
430 goto out_free;
431 }
432
433 p->portid = *prop;
434
435 prop = of_get_property(op->node, "memory-control-register-1", &len);
436 if (!prop || len != 8) {
437 printk(KERN_ERR PFX "Cannot get memory control register 1.\n");
438 goto out_free;
439 }
440
441 p->mc_reg_1 = ((u64)prop[0] << 32) | (u64) prop[1];
442
443 err = -ENOMEM;
444 p->regs = of_ioremap(&op->resource[0], 0, JBUSMC_REGS_SIZE, "jbusmc");
445 if (!p->regs) {
446 printk(KERN_ERR PFX "Cannot map jbusmc regs.\n");
447 goto out_free;
448 }
449
450 err = -ENODEV;
451 ml = of_get_property(op->node, "memory-layout", &p->layout_len);
452 if (!ml) {
453 printk(KERN_ERR PFX "Cannot get memory layout property.\n");
454 goto out_iounmap;
455 }
456 if (p->layout_len > sizeof(p->layout)) {
457 printk(KERN_ERR PFX "Unexpected memory-layout size %d\n",
458 p->layout_len);
459 goto out_iounmap;
460 }
461 memcpy(&p->layout, ml, p->layout_len);
462
463 jbusmc_construct_dimm_groups(p, mem_regs, num_mem_regs);
464
465 mc_list_add(&p->list);
466
467 printk(KERN_INFO PFX "UltraSPARC-IIIi memory controller at %s\n",
468 op->node->full_name);
469
470 dev_set_drvdata(&op->dev, p);
471
472 err = 0;
473
474out:
475 return err;
476
477out_iounmap:
478 of_iounmap(&op->resource[0], p->regs, JBUSMC_REGS_SIZE);
479
480out_free:
481 kfree(p);
482 goto out;
483}
484
88/* Does BANK decode PHYS_ADDR? */ 485/* Does BANK decode PHYS_ADDR? */
89static int bank_match(struct bank_info *bp, unsigned long phys_addr) 486static int chmc_bank_match(struct chmc_bank_info *bp, unsigned long phys_addr)
90{ 487{
91 unsigned long upper_bits = (phys_addr & PA_UPPER_BITS) >> PA_UPPER_BITS_SHIFT; 488 unsigned long upper_bits = (phys_addr & PA_UPPER_BITS) >> PA_UPPER_BITS_SHIFT;
92 unsigned long lower_bits = (phys_addr & PA_LOWER_BITS) >> PA_LOWER_BITS_SHIFT; 489 unsigned long lower_bits = (phys_addr & PA_LOWER_BITS) >> PA_LOWER_BITS_SHIFT;
@@ -118,25 +515,18 @@ static int bank_match(struct bank_info *bp, unsigned long phys_addr)
118} 515}
119 516
120/* Given PHYS_ADDR, search memory controller banks for a match. */ 517/* Given PHYS_ADDR, search memory controller banks for a match. */
121static struct bank_info *find_bank(unsigned long phys_addr) 518static struct chmc_bank_info *chmc_find_bank(unsigned long phys_addr)
122{ 519{
123 struct list_head *mctrl_head = &mctrl_list; 520 struct chmc *p;
124 struct list_head *mctrl_entry = mctrl_head->next;
125 521
126 for (;;) { 522 list_for_each_entry(p, &mctrl_list, list) {
127 struct mctrl_info *mp =
128 list_entry(mctrl_entry, struct mctrl_info, list);
129 int bank_no; 523 int bank_no;
130 524
131 if (mctrl_entry == mctrl_head)
132 break;
133 mctrl_entry = mctrl_entry->next;
134
135 for (bank_no = 0; bank_no < CHMCTRL_NBANKS; bank_no++) { 525 for (bank_no = 0; bank_no < CHMCTRL_NBANKS; bank_no++) {
136 struct bank_info *bp; 526 struct chmc_bank_info *bp;
137 527
138 bp = &mp->logical_banks[bank_no]; 528 bp = &p->logical_banks[bank_no];
139 if (bank_match(bp, phys_addr)) 529 if (chmc_bank_match(bp, phys_addr))
140 return bp; 530 return bp;
141 } 531 }
142 } 532 }
@@ -145,17 +535,15 @@ static struct bank_info *find_bank(unsigned long phys_addr)
145} 535}
146 536
147/* This is the main purpose of this driver. */ 537/* This is the main purpose of this driver. */
148#define SYNDROME_MIN -1 538static int chmc_print_dimm(int syndrome_code,
149#define SYNDROME_MAX 144 539 unsigned long phys_addr,
150int chmc_getunumber(int syndrome_code, 540 char *buf, int buflen)
151 unsigned long phys_addr,
152 char *buf, int buflen)
153{ 541{
154 struct bank_info *bp; 542 struct chmc_bank_info *bp;
155 struct obp_mem_layout *prop; 543 struct chmc_obp_mem_layout *prop;
156 int bank_in_controller, first_dimm; 544 int bank_in_controller, first_dimm;
157 545
158 bp = find_bank(phys_addr); 546 bp = chmc_find_bank(phys_addr);
159 if (bp == NULL || 547 if (bp == NULL ||
160 syndrome_code < SYNDROME_MIN || 548 syndrome_code < SYNDROME_MIN ||
161 syndrome_code > SYNDROME_MAX) { 549 syndrome_code > SYNDROME_MAX) {
@@ -166,60 +554,18 @@ int chmc_getunumber(int syndrome_code,
166 return 0; 554 return 0;
167 } 555 }
168 556
169 prop = &bp->mp->layout_prop; 557 prop = &bp->p->layout_prop;
170 bank_in_controller = bp->bank_id & (CHMCTRL_NBANKS - 1); 558 bank_in_controller = bp->bank_id & (CHMCTRL_NBANKS - 1);
171 first_dimm = (bank_in_controller & (CHMCTRL_NDGRPS - 1)); 559 first_dimm = (bank_in_controller & (CHMCTRL_NDGRPS - 1));
172 first_dimm *= CHMCTRL_NDIMMS; 560 first_dimm *= CHMCTRL_NDIMMS;
173 561
174 if (syndrome_code != SYNDROME_MIN) { 562 if (syndrome_code != SYNDROME_MIN) {
175 struct obp_map *map; 563 char *dimm_str;
176 int qword, where_in_line, where, map_index, map_offset; 564 int pin;
177 unsigned int map_val;
178 565
179 /* Yaay, single bit error so we can figure out 566 get_pin_and_dimm_str(syndrome_code, phys_addr, &pin,
180 * the exact dimm. 567 &dimm_str, prop, first_dimm);
181 */ 568 sprintf(buf, "%s, pin %3d", dimm_str, pin);
182 if (prop->symmetric)
183 map = &prop->map[0];
184 else
185 map = &prop->map[1];
186
187 /* Covert syndrome code into the way the bits are
188 * positioned on the bus.
189 */
190 if (syndrome_code < 144 - 16)
191 syndrome_code += 16;
192 else if (syndrome_code < 144)
193 syndrome_code -= (144 - 7);
194 else if (syndrome_code < (144 + 3))
195 syndrome_code -= (144 + 3 - 4);
196 else
197 syndrome_code -= 144 + 3;
198
199 /* All this magic has to do with how a cache line
200 * comes over the wire on Safari. A 64-bit line
201 * comes over in 4 quadword cycles, each of which
202 * transmit ECC/MTAG info as well as the actual
203 * data. 144 bits per quadword, 576 total.
204 */
205#define LINE_SIZE 64
206#define LINE_ADDR_MSK (LINE_SIZE - 1)
207#define QW_PER_LINE 4
208#define QW_BYTES (LINE_SIZE / QW_PER_LINE)
209#define QW_BITS 144
210#define LAST_BIT (576 - 1)
211
212 qword = (phys_addr & LINE_ADDR_MSK) / QW_BYTES;
213 where_in_line = ((3 - qword) * QW_BITS) + syndrome_code;
214 where = (LAST_BIT - where_in_line);
215 map_index = where >> 2;
216 map_offset = where & 0x3;
217 map_val = map->dimm_map[map_index];
218 map_val = ((map_val >> ((3 - map_offset) << 1)) & (2 - 1));
219
220 sprintf(buf, "%s, pin %3d",
221 prop->dimm_labels[first_dimm + map_val],
222 map->pin_map[where_in_line]);
223 } else { 569 } else {
224 int dimm; 570 int dimm;
225 571
@@ -240,7 +586,7 @@ int chmc_getunumber(int syndrome_code,
240 * the code is executing, you must use special ASI load/store else 586 * the code is executing, you must use special ASI load/store else
241 * you go through the global mapping. 587 * you go through the global mapping.
242 */ 588 */
243static u64 read_mcreg(struct mctrl_info *mp, unsigned long offset) 589static u64 chmc_read_mcreg(struct chmc *p, unsigned long offset)
244{ 590{
245 unsigned long ret, this_cpu; 591 unsigned long ret, this_cpu;
246 592
@@ -248,14 +594,14 @@ static u64 read_mcreg(struct mctrl_info *mp, unsigned long offset)
248 594
249 this_cpu = real_hard_smp_processor_id(); 595 this_cpu = real_hard_smp_processor_id();
250 596
251 if (mp->portid == this_cpu) { 597 if (p->portid == this_cpu) {
252 __asm__ __volatile__("ldxa [%1] %2, %0" 598 __asm__ __volatile__("ldxa [%1] %2, %0"
253 : "=r" (ret) 599 : "=r" (ret)
254 : "r" (offset), "i" (ASI_MCU_CTRL_REG)); 600 : "r" (offset), "i" (ASI_MCU_CTRL_REG));
255 } else { 601 } else {
256 __asm__ __volatile__("ldxa [%1] %2, %0" 602 __asm__ __volatile__("ldxa [%1] %2, %0"
257 : "=r" (ret) 603 : "=r" (ret)
258 : "r" (mp->regs + offset), 604 : "r" (p->regs + offset),
259 "i" (ASI_PHYS_BYPASS_EC_E)); 605 "i" (ASI_PHYS_BYPASS_EC_E));
260 } 606 }
261 607
@@ -265,178 +611,253 @@ static u64 read_mcreg(struct mctrl_info *mp, unsigned long offset)
265} 611}
266 612
267#if 0 /* currently unused */ 613#if 0 /* currently unused */
268static void write_mcreg(struct mctrl_info *mp, unsigned long offset, u64 val) 614static void chmc_write_mcreg(struct chmc *p, unsigned long offset, u64 val)
269{ 615{
270 if (mp->portid == smp_processor_id()) { 616 if (p->portid == smp_processor_id()) {
271 __asm__ __volatile__("stxa %0, [%1] %2" 617 __asm__ __volatile__("stxa %0, [%1] %2"
272 : : "r" (val), 618 : : "r" (val),
273 "r" (offset), "i" (ASI_MCU_CTRL_REG)); 619 "r" (offset), "i" (ASI_MCU_CTRL_REG));
274 } else { 620 } else {
275 __asm__ __volatile__("ldxa %0, [%1] %2" 621 __asm__ __volatile__("ldxa %0, [%1] %2"
276 : : "r" (val), 622 : : "r" (val),
277 "r" (mp->regs + offset), 623 "r" (p->regs + offset),
278 "i" (ASI_PHYS_BYPASS_EC_E)); 624 "i" (ASI_PHYS_BYPASS_EC_E));
279 } 625 }
280} 626}
281#endif 627#endif
282 628
283static void interpret_one_decode_reg(struct mctrl_info *mp, int which_bank, u64 val) 629static void chmc_interpret_one_decode_reg(struct chmc *p, int which_bank, u64 val)
284{ 630{
285 struct bank_info *p = &mp->logical_banks[which_bank]; 631 struct chmc_bank_info *bp = &p->logical_banks[which_bank];
286 632
287 p->mp = mp; 633 bp->p = p;
288 p->bank_id = (CHMCTRL_NBANKS * mp->portid) + which_bank; 634 bp->bank_id = (CHMCTRL_NBANKS * p->portid) + which_bank;
289 p->raw_reg = val; 635 bp->raw_reg = val;
290 p->valid = (val & MEM_DECODE_VALID) >> MEM_DECODE_VALID_SHIFT; 636 bp->valid = (val & MEM_DECODE_VALID) >> MEM_DECODE_VALID_SHIFT;
291 p->uk = (val & MEM_DECODE_UK) >> MEM_DECODE_UK_SHIFT; 637 bp->uk = (val & MEM_DECODE_UK) >> MEM_DECODE_UK_SHIFT;
292 p->um = (val & MEM_DECODE_UM) >> MEM_DECODE_UM_SHIFT; 638 bp->um = (val & MEM_DECODE_UM) >> MEM_DECODE_UM_SHIFT;
293 p->lk = (val & MEM_DECODE_LK) >> MEM_DECODE_LK_SHIFT; 639 bp->lk = (val & MEM_DECODE_LK) >> MEM_DECODE_LK_SHIFT;
294 p->lm = (val & MEM_DECODE_LM) >> MEM_DECODE_LM_SHIFT; 640 bp->lm = (val & MEM_DECODE_LM) >> MEM_DECODE_LM_SHIFT;
295 641
296 p->base = (p->um); 642 bp->base = (bp->um);
297 p->base &= ~(p->uk); 643 bp->base &= ~(bp->uk);
298 p->base <<= PA_UPPER_BITS_SHIFT; 644 bp->base <<= PA_UPPER_BITS_SHIFT;
299 645
300 switch(p->lk) { 646 switch(bp->lk) {
301 case 0xf: 647 case 0xf:
302 default: 648 default:
303 p->interleave = 1; 649 bp->interleave = 1;
304 break; 650 break;
305 651
306 case 0xe: 652 case 0xe:
307 p->interleave = 2; 653 bp->interleave = 2;
308 break; 654 break;
309 655
310 case 0xc: 656 case 0xc:
311 p->interleave = 4; 657 bp->interleave = 4;
312 break; 658 break;
313 659
314 case 0x8: 660 case 0x8:
315 p->interleave = 8; 661 bp->interleave = 8;
316 break; 662 break;
317 663
318 case 0x0: 664 case 0x0:
319 p->interleave = 16; 665 bp->interleave = 16;
320 break; 666 break;
321 }; 667 };
322 668
323 /* UK[10] is reserved, and UK[11] is not set for the SDRAM 669 /* UK[10] is reserved, and UK[11] is not set for the SDRAM
324 * bank size definition. 670 * bank size definition.
325 */ 671 */
326 p->size = (((unsigned long)p->uk & 672 bp->size = (((unsigned long)bp->uk &
327 ((1UL << 10UL) - 1UL)) + 1UL) << PA_UPPER_BITS_SHIFT; 673 ((1UL << 10UL) - 1UL)) + 1UL) << PA_UPPER_BITS_SHIFT;
328 p->size /= p->interleave; 674 bp->size /= bp->interleave;
329} 675}
330 676
331static void fetch_decode_regs(struct mctrl_info *mp) 677static void chmc_fetch_decode_regs(struct chmc *p)
332{ 678{
333 if (mp->layout_size == 0) 679 if (p->layout_size == 0)
334 return; 680 return;
335 681
336 interpret_one_decode_reg(mp, 0, 682 chmc_interpret_one_decode_reg(p, 0,
337 read_mcreg(mp, CHMCTRL_DECODE1)); 683 chmc_read_mcreg(p, CHMCTRL_DECODE1));
338 interpret_one_decode_reg(mp, 1, 684 chmc_interpret_one_decode_reg(p, 1,
339 read_mcreg(mp, CHMCTRL_DECODE2)); 685 chmc_read_mcreg(p, CHMCTRL_DECODE2));
340 interpret_one_decode_reg(mp, 2, 686 chmc_interpret_one_decode_reg(p, 2,
341 read_mcreg(mp, CHMCTRL_DECODE3)); 687 chmc_read_mcreg(p, CHMCTRL_DECODE3));
342 interpret_one_decode_reg(mp, 3, 688 chmc_interpret_one_decode_reg(p, 3,
343 read_mcreg(mp, CHMCTRL_DECODE4)); 689 chmc_read_mcreg(p, CHMCTRL_DECODE4));
344} 690}
345 691
346static int init_one_mctrl(struct device_node *dp) 692static int __devinit chmc_probe(struct of_device *op,
693 const struct of_device_id *match)
347{ 694{
348 struct mctrl_info *mp = kzalloc(sizeof(*mp), GFP_KERNEL); 695 struct device_node *dp = op->node;
349 int portid = of_getintprop_default(dp, "portid", -1); 696 unsigned long ver;
350 const struct linux_prom64_registers *regs;
351 const void *pval; 697 const void *pval;
352 int len; 698 int len, portid;
699 struct chmc *p;
700 int err;
701
702 err = -ENODEV;
703 __asm__ ("rdpr %%ver, %0" : "=r" (ver));
704 if ((ver >> 32UL) == __JALAPENO_ID ||
705 (ver >> 32UL) == __SERRANO_ID)
706 goto out;
353 707
354 if (!mp) 708 portid = of_getintprop_default(dp, "portid", -1);
355 return -1;
356 if (portid == -1) 709 if (portid == -1)
357 goto fail; 710 goto out;
358 711
359 mp->portid = portid;
360 pval = of_get_property(dp, "memory-layout", &len); 712 pval = of_get_property(dp, "memory-layout", &len);
361 mp->layout_size = len; 713 if (pval && len > sizeof(p->layout_prop)) {
362 if (!pval) 714 printk(KERN_ERR PFX "Unexpected memory-layout property "
363 mp->layout_size = 0; 715 "size %d.\n", len);
364 else { 716 goto out;
365 if (mp->layout_size > sizeof(mp->layout_prop))
366 goto fail;
367 memcpy(&mp->layout_prop, pval, len);
368 } 717 }
369 718
370 regs = of_get_property(dp, "reg", NULL); 719 err = -ENOMEM;
371 if (!regs || regs->reg_size != 0x48) 720 p = kzalloc(sizeof(*p), GFP_KERNEL);
372 goto fail; 721 if (!p) {
722 printk(KERN_ERR PFX "Could not allocate struct chmc.\n");
723 goto out;
724 }
373 725
374 mp->regs = ioremap(regs->phys_addr, regs->reg_size); 726 p->portid = portid;
375 if (mp->regs == NULL) 727 p->layout_size = len;
376 goto fail; 728 if (!pval)
729 p->layout_size = 0;
730 else
731 memcpy(&p->layout_prop, pval, len);
732
733 p->regs = of_ioremap(&op->resource[0], 0, 0x48, "chmc");
734 if (!p->regs) {
735 printk(KERN_ERR PFX "Could not map registers.\n");
736 goto out_free;
737 }
377 738
378 if (mp->layout_size != 0UL) { 739 if (p->layout_size != 0UL) {
379 mp->timing_control1 = read_mcreg(mp, CHMCTRL_TCTRL1); 740 p->timing_control1 = chmc_read_mcreg(p, CHMCTRL_TCTRL1);
380 mp->timing_control2 = read_mcreg(mp, CHMCTRL_TCTRL2); 741 p->timing_control2 = chmc_read_mcreg(p, CHMCTRL_TCTRL2);
381 mp->timing_control3 = read_mcreg(mp, CHMCTRL_TCTRL3); 742 p->timing_control3 = chmc_read_mcreg(p, CHMCTRL_TCTRL3);
382 mp->timing_control4 = read_mcreg(mp, CHMCTRL_TCTRL4); 743 p->timing_control4 = chmc_read_mcreg(p, CHMCTRL_TCTRL4);
383 mp->memaddr_control = read_mcreg(mp, CHMCTRL_MACTRL); 744 p->memaddr_control = chmc_read_mcreg(p, CHMCTRL_MACTRL);
384 } 745 }
385 746
386 fetch_decode_regs(mp); 747 chmc_fetch_decode_regs(p);
387 748
388 list_add(&mp->list, &mctrl_list); 749 mc_list_add(&p->list);
389 750
390 /* Report the device. */ 751 printk(KERN_INFO PFX "UltraSPARC-III memory controller at %s [%s]\n",
391 printk(KERN_INFO "%s: US3 memory controller at %p [%s]\n",
392 dp->full_name, 752 dp->full_name,
393 mp->regs, (mp->layout_size ? "ACTIVE" : "INACTIVE")); 753 (p->layout_size ? "ACTIVE" : "INACTIVE"));
394 754
395 return 0; 755 dev_set_drvdata(&op->dev, p);
756
757 err = 0;
758
759out:
760 return err;
761
762out_free:
763 kfree(p);
764 goto out;
765}
396 766
397fail: 767static int __devinit us3mc_probe(struct of_device *op,
398 if (mp) { 768 const struct of_device_id *match)
399 if (mp->regs != NULL) 769{
400 iounmap(mp->regs); 770 if (mc_type == MC_TYPE_SAFARI)
401 kfree(mp); 771 return chmc_probe(op, match);
772 else if (mc_type == MC_TYPE_JBUS)
773 return jbusmc_probe(op, match);
774 return -ENODEV;
775}
776
777static void __devexit chmc_destroy(struct of_device *op, struct chmc *p)
778{
779 list_del(&p->list);
780 of_iounmap(&op->resource[0], p->regs, 0x48);
781 kfree(p);
782}
783
784static void __devexit jbusmc_destroy(struct of_device *op, struct jbusmc *p)
785{
786 mc_list_del(&p->list);
787 of_iounmap(&op->resource[0], p->regs, JBUSMC_REGS_SIZE);
788 kfree(p);
789}
790
791static int __devexit us3mc_remove(struct of_device *op)
792{
793 void *p = dev_get_drvdata(&op->dev);
794
795 if (p) {
796 if (mc_type == MC_TYPE_SAFARI)
797 chmc_destroy(op, p);
798 else if (mc_type == MC_TYPE_JBUS)
799 jbusmc_destroy(op, p);
402 } 800 }
403 return -1; 801 return 0;
802}
803
804static const struct of_device_id us3mc_match[] = {
805 {
806 .name = "memory-controller",
807 },
808 {},
809};
810MODULE_DEVICE_TABLE(of, us3mc_match);
811
812static struct of_platform_driver us3mc_driver = {
813 .name = "us3mc",
814 .match_table = us3mc_match,
815 .probe = us3mc_probe,
816 .remove = __devexit_p(us3mc_remove),
817};
818
819static inline bool us3mc_platform(void)
820{
821 if (tlb_type == cheetah || tlb_type == cheetah_plus)
822 return true;
823 return false;
404} 824}
405 825
406static int __init chmc_init(void) 826static int __init us3mc_init(void)
407{ 827{
408 struct device_node *dp; 828 unsigned long ver;
829 int ret;
409 830
410 /* This driver is only for cheetah platforms. */ 831 if (!us3mc_platform())
411 if (tlb_type != cheetah && tlb_type != cheetah_plus)
412 return -ENODEV; 832 return -ENODEV;
413 833
414 for_each_node_by_name(dp, "memory-controller") 834 __asm__ ("rdpr %%ver, %0" : "=r" (ver));
415 init_one_mctrl(dp); 835 if ((ver >> 32UL) == __JALAPENO_ID ||
836 (ver >> 32UL) == __SERRANO_ID) {
837 mc_type = MC_TYPE_JBUS;
838 us3mc_dimm_printer = jbusmc_print_dimm;
839 } else {
840 mc_type = MC_TYPE_SAFARI;
841 us3mc_dimm_printer = chmc_print_dimm;
842 }
416 843
417 for_each_node_by_name(dp, "mc-us3") 844 ret = register_dimm_printer(us3mc_dimm_printer);
418 init_one_mctrl(dp);
419 845
420 return 0; 846 if (!ret) {
847 ret = of_register_driver(&us3mc_driver, &of_bus_type);
848 if (ret)
849 unregister_dimm_printer(us3mc_dimm_printer);
850 }
851 return ret;
421} 852}
422 853
423static void __exit chmc_cleanup(void) 854static void __exit us3mc_cleanup(void)
424{ 855{
425 struct list_head *head = &mctrl_list; 856 if (us3mc_platform()) {
426 struct list_head *tmp = head->next; 857 unregister_dimm_printer(us3mc_dimm_printer);
427 858 of_unregister_driver(&us3mc_driver);
428 for (;;) {
429 struct mctrl_info *p =
430 list_entry(tmp, struct mctrl_info, list);
431 if (tmp == head)
432 break;
433 tmp = tmp->next;
434
435 list_del(&p->list);
436 iounmap(p->regs);
437 kfree(p);
438 } 859 }
439} 860}
440 861
441module_init(chmc_init); 862module_init(us3mc_init);
442module_exit(chmc_cleanup); 863module_exit(us3mc_cleanup);
diff --git a/arch/sparc64/kernel/cpu.c b/arch/sparc64/kernel/cpu.c
index 0097c08dc600..0c9ac83ed0a8 100644
--- a/arch/sparc64/kernel/cpu.c
+++ b/arch/sparc64/kernel/cpu.c
@@ -1,7 +1,7 @@
1/* cpu.c: Dinky routines to look for the kind of Sparc cpu 1/* cpu.c: Dinky routines to look for the kind of Sparc cpu
2 * we are on. 2 * we are on.
3 * 3 *
4 * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net) 4 * Copyright (C) 1996, 2007, 2008 David S. Miller (davem@davemloft.net)
5 */ 5 */
6 6
7#include <linux/kernel.h> 7#include <linux/kernel.h>
@@ -19,53 +19,86 @@
19 19
20DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 }; 20DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
21 21
22struct cpu_iu_info { 22struct cpu_chip_info {
23 short manuf; 23 unsigned short manuf;
24 short impl; 24 unsigned short impl;
25 char* cpu_name; /* should be enough I hope... */ 25 const char *cpu_name;
26 const char *fp_name;
26}; 27};
27 28
28struct cpu_fp_info { 29static const struct cpu_chip_info cpu_chips[] = {
29 short manuf; 30 {
30 short impl; 31 .manuf = 0x17,
31 char fpu_vers; 32 .impl = 0x10,
32 char* fp_name; 33 .cpu_name = "TI UltraSparc I (SpitFire)",
34 .fp_name = "UltraSparc I integrated FPU",
35 },
36 {
37 .manuf = 0x22,
38 .impl = 0x10,
39 .cpu_name = "TI UltraSparc I (SpitFire)",
40 .fp_name = "UltraSparc I integrated FPU",
41 },
42 {
43 .manuf = 0x17,
44 .impl = 0x11,
45 .cpu_name = "TI UltraSparc II (BlackBird)",
46 .fp_name = "UltraSparc II integrated FPU",
47 },
48 {
49 .manuf = 0x17,
50 .impl = 0x12,
51 .cpu_name = "TI UltraSparc IIi (Sabre)",
52 .fp_name = "UltraSparc IIi integrated FPU",
53 },
54 {
55 .manuf = 0x17,
56 .impl = 0x13,
57 .cpu_name = "TI UltraSparc IIe (Hummingbird)",
58 .fp_name = "UltraSparc IIe integrated FPU",
59 },
60 {
61 .manuf = 0x3e,
62 .impl = 0x14,
63 .cpu_name = "TI UltraSparc III (Cheetah)",
64 .fp_name = "UltraSparc III integrated FPU",
65 },
66 {
67 .manuf = 0x3e,
68 .impl = 0x15,
69 .cpu_name = "TI UltraSparc III+ (Cheetah+)",
70 .fp_name = "UltraSparc III+ integrated FPU",
71 },
72 {
73 .manuf = 0x3e,
74 .impl = 0x16,
75 .cpu_name = "TI UltraSparc IIIi (Jalapeno)",
76 .fp_name = "UltraSparc IIIi integrated FPU",
77 },
78 {
79 .manuf = 0x3e,
80 .impl = 0x18,
81 .cpu_name = "TI UltraSparc IV (Jaguar)",
82 .fp_name = "UltraSparc IV integrated FPU",
83 },
84 {
85 .manuf = 0x3e,
86 .impl = 0x19,
87 .cpu_name = "TI UltraSparc IV+ (Panther)",
88 .fp_name = "UltraSparc IV+ integrated FPU",
89 },
90 {
91 .manuf = 0x3e,
92 .impl = 0x22,
93 .cpu_name = "TI UltraSparc IIIi+ (Serrano)",
94 .fp_name = "UltraSparc IIIi+ integrated FPU",
95 },
33}; 96};
34 97
35static struct cpu_fp_info linux_sparc_fpu[] = { 98#define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips)
36 { 0x17, 0x10, 0, "UltraSparc I integrated FPU"},
37 { 0x22, 0x10, 0, "UltraSparc I integrated FPU"},
38 { 0x17, 0x11, 0, "UltraSparc II integrated FPU"},
39 { 0x17, 0x12, 0, "UltraSparc IIi integrated FPU"},
40 { 0x17, 0x13, 0, "UltraSparc IIe integrated FPU"},
41 { 0x3e, 0x14, 0, "UltraSparc III integrated FPU"},
42 { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"},
43 { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"},
44 { 0x3e, 0x18, 0, "UltraSparc IV integrated FPU"},
45 { 0x3e, 0x19, 0, "UltraSparc IV+ integrated FPU"},
46 { 0x3e, 0x22, 0, "UltraSparc IIIi+ integrated FPU"},
47};
48
49#define NSPARCFPU ARRAY_SIZE(linux_sparc_fpu)
50
51static struct cpu_iu_info linux_sparc_chips[] = {
52 { 0x17, 0x10, "TI UltraSparc I (SpitFire)"},
53 { 0x22, 0x10, "TI UltraSparc I (SpitFire)"},
54 { 0x17, 0x11, "TI UltraSparc II (BlackBird)"},
55 { 0x17, 0x12, "TI UltraSparc IIi (Sabre)"},
56 { 0x17, 0x13, "TI UltraSparc IIe (Hummingbird)"},
57 { 0x3e, 0x14, "TI UltraSparc III (Cheetah)"},
58 { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"},
59 { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"},
60 { 0x3e, 0x18, "TI UltraSparc IV (Jaguar)"},
61 { 0x3e, 0x19, "TI UltraSparc IV+ (Panther)"},
62 { 0x3e, 0x22, "TI UltraSparc IIIi+ (Serrano)"},
63};
64 99
65#define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips) 100const char *sparc_cpu_type;
66 101const char *sparc_fpu_type;
67char *sparc_cpu_type;
68char *sparc_fpu_type;
69 102
70static void __init sun4v_cpu_probe(void) 103static void __init sun4v_cpu_probe(void)
71{ 104{
@@ -89,68 +122,45 @@ static void __init sun4v_cpu_probe(void)
89 } 122 }
90} 123}
91 124
92void __init cpu_probe(void) 125static const struct cpu_chip_info * __init find_cpu_chip(unsigned short manuf,
126 unsigned short impl)
93{ 127{
94 unsigned long ver, fpu_vers, manuf, impl, fprs;
95 int i; 128 int i;
96
97 if (tlb_type == hypervisor) {
98 sun4v_cpu_probe();
99 return;
100 }
101 129
102 fprs = fprs_read(); 130 for (i = 0; i < ARRAY_SIZE(cpu_chips); i++) {
103 fprs_write(FPRS_FEF); 131 const struct cpu_chip_info *p = &cpu_chips[i];
104 __asm__ __volatile__ ("rdpr %%ver, %0; stx %%fsr, [%1]"
105 : "=&r" (ver)
106 : "r" (&fpu_vers));
107 fprs_write(fprs);
108
109 manuf = ((ver >> 48) & 0xffff);
110 impl = ((ver >> 32) & 0xffff);
111
112 fpu_vers = ((fpu_vers >> 17) & 0x7);
113
114retry:
115 for (i = 0; i < NSPARCCHIPS; i++) {
116 if (linux_sparc_chips[i].manuf == manuf) {
117 if (linux_sparc_chips[i].impl == impl) {
118 sparc_cpu_type =
119 linux_sparc_chips[i].cpu_name;
120 break;
121 }
122 }
123 }
124 132
125 if (i == NSPARCCHIPS) { 133 if (p->manuf == manuf && p->impl == impl)
126 /* Maybe it is a cheetah+ derivative, report it as cheetah+ 134 return p;
127 * in that case until we learn the real names.
128 */
129 if (manuf == 0x3e &&
130 impl > 0x15) {
131 impl = 0x15;
132 goto retry;
133 } else {
134 printk("DEBUG: manuf[%lx] impl[%lx]\n",
135 manuf, impl);
136 }
137 sparc_cpu_type = "Unknown CPU";
138 } 135 }
136 return NULL;
137}
139 138
140 for (i = 0; i < NSPARCFPU; i++) { 139static int __init cpu_type_probe(void)
141 if (linux_sparc_fpu[i].manuf == manuf && 140{
142 linux_sparc_fpu[i].impl == impl) { 141 if (tlb_type == hypervisor) {
143 if (linux_sparc_fpu[i].fpu_vers == fpu_vers) { 142 sun4v_cpu_probe();
144 sparc_fpu_type = 143 } else {
145 linux_sparc_fpu[i].fp_name; 144 unsigned long ver, manuf, impl;
146 break; 145 const struct cpu_chip_info *p;
147 } 146
147 __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
148
149 manuf = ((ver >> 48) & 0xffff);
150 impl = ((ver >> 32) & 0xffff);
151
152 p = find_cpu_chip(manuf, impl);
153 if (p) {
154 sparc_cpu_type = p->cpu_name;
155 sparc_fpu_type = p->fp_name;
156 } else {
157 printk(KERN_ERR "CPU: Unknown chip, manuf[%lx] impl[%lx]\n",
158 manuf, impl);
159 sparc_cpu_type = "Unknown CPU";
160 sparc_fpu_type = "Unknown FPU";
148 } 161 }
149 } 162 }
150 163 return 0;
151 if (i == NSPARCFPU) {
152 printk("DEBUG: manuf[%lx] impl[%lx] fsr.vers[%lx]\n",
153 manuf, impl, fpu_vers);
154 sparc_fpu_type = "Unknown FPU";
155 }
156} 164}
165
166arch_initcall(cpu_type_probe);
diff --git a/arch/sparc64/kernel/ds.c b/arch/sparc64/kernel/ds.c
index d0fa5aa38934..f52e0534d91d 100644
--- a/arch/sparc64/kernel/ds.c
+++ b/arch/sparc64/kernel/ds.c
@@ -1,6 +1,6 @@
1/* ds.c: Domain Services driver for Logical Domains 1/* ds.c: Domain Services driver for Logical Domains
2 * 2 *
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net> 3 * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net>
4 */ 4 */
5 5
6#include <linux/kernel.h> 6#include <linux/kernel.h>
@@ -1217,7 +1217,7 @@ static int ds_remove(struct vio_dev *vdev)
1217 return 0; 1217 return 0;
1218} 1218}
1219 1219
1220static struct vio_device_id ds_match[] = { 1220static struct vio_device_id __initdata ds_match[] = {
1221 { 1221 {
1222 .type = "domain-services-port", 1222 .type = "domain-services-port",
1223 }, 1223 },
diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c
index 60d36d142559..77dbf6d45faf 100644
--- a/arch/sparc64/kernel/ebus.c
+++ b/arch/sparc64/kernel/ebus.c
@@ -1,5 +1,4 @@
1/* 1/* ebus.c: EBUS DMA library code.
2 * ebus.c: PCI to EBus bridge device.
3 * 2 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) 3 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 * Copyright (C) 1999 David S. Miller (davem@redhat.com) 4 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
@@ -9,23 +8,11 @@
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/types.h> 9#include <linux/types.h>
11#include <linux/init.h> 10#include <linux/init.h>
12#include <linux/slab.h>
13#include <linux/string.h>
14#include <linux/interrupt.h> 11#include <linux/interrupt.h>
15#include <linux/delay.h> 12#include <linux/delay.h>
16#include <linux/pci.h>
17#include <linux/of_device.h>
18
19#include <asm/system.h>
20#include <asm/page.h>
21#include <asm/ebus.h>
22#include <asm/oplib.h>
23#include <asm/prom.h>
24#include <asm/bpp.h>
25#include <asm/irq.h>
26#include <asm/io.h>
27 13
28/* EBUS dma library. */ 14#include <asm/ebus_dma.h>
15#include <asm/io.h>
29 16
30#define EBDMA_CSR 0x00UL /* Control/Status */ 17#define EBDMA_CSR 0x00UL /* Control/Status */
31#define EBDMA_ADDR 0x04UL /* DMA Address */ 18#define EBDMA_ADDR 0x04UL /* DMA Address */
@@ -268,283 +255,3 @@ void ebus_dma_enable(struct ebus_dma_info *p, int on)
268 spin_unlock_irqrestore(&p->lock, flags); 255 spin_unlock_irqrestore(&p->lock, flags);
269} 256}
270EXPORT_SYMBOL(ebus_dma_enable); 257EXPORT_SYMBOL(ebus_dma_enable);
271
272struct linux_ebus *ebus_chain = NULL;
273
274static inline void *ebus_alloc(size_t size)
275{
276 void *mem;
277
278 mem = kzalloc(size, GFP_ATOMIC);
279 if (!mem)
280 panic("ebus_alloc: out of memory");
281 return mem;
282}
283
284static void __init fill_ebus_child(struct device_node *dp,
285 struct linux_ebus_child *dev,
286 int non_standard_regs)
287{
288 struct of_device *op;
289 const int *regs;
290 int i, len;
291
292 dev->prom_node = dp;
293 printk(" (%s)", dp->name);
294
295 regs = of_get_property(dp, "reg", &len);
296 if (!regs)
297 dev->num_addrs = 0;
298 else
299 dev->num_addrs = len / sizeof(regs[0]);
300
301 if (non_standard_regs) {
302 /* This is to handle reg properties which are not
303 * in the parent relative format. One example are
304 * children of the i2c device on CompactPCI systems.
305 *
306 * So, for such devices we just record the property
307 * raw in the child resources.
308 */
309 for (i = 0; i < dev->num_addrs; i++)
310 dev->resource[i].start = regs[i];
311 } else {
312 for (i = 0; i < dev->num_addrs; i++) {
313 int rnum = regs[i];
314 if (rnum >= dev->parent->num_addrs) {
315 prom_printf("UGH: property for %s was %d, need < %d\n",
316 dp->name, len, dev->parent->num_addrs);
317 prom_halt();
318 }
319 dev->resource[i].start = dev->parent->resource[i].start;
320 dev->resource[i].end = dev->parent->resource[i].end;
321 dev->resource[i].flags = IORESOURCE_MEM;
322 dev->resource[i].name = dp->name;
323 }
324 }
325
326 op = of_find_device_by_node(dp);
327 if (!op) {
328 dev->num_irqs = 0;
329 } else {
330 dev->num_irqs = op->num_irqs;
331 for (i = 0; i < dev->num_irqs; i++)
332 dev->irqs[i] = op->irqs[i];
333 }
334
335 if (!dev->num_irqs) {
336 /*
337 * Oh, well, some PROMs don't export interrupts
338 * property to children of EBus devices...
339 *
340 * Be smart about PS/2 keyboard and mouse.
341 */
342 if (!strcmp(dev->parent->prom_node->name, "8042")) {
343 if (!strcmp(dev->prom_node->name, "kb_ps2")) {
344 dev->num_irqs = 1;
345 dev->irqs[0] = dev->parent->irqs[0];
346 } else {
347 dev->num_irqs = 1;
348 dev->irqs[0] = dev->parent->irqs[1];
349 }
350 }
351 }
352}
353
354static int __init child_regs_nonstandard(struct linux_ebus_device *dev)
355{
356 if (!strcmp(dev->prom_node->name, "i2c") ||
357 !strcmp(dev->prom_node->name, "SUNW,lombus"))
358 return 1;
359 return 0;
360}
361
362static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev)
363{
364 struct linux_ebus_child *child;
365 struct dev_archdata *sd;
366 struct of_device *op;
367 int i, len;
368
369 dev->prom_node = dp;
370
371 printk(" [%s", dp->name);
372
373 op = of_find_device_by_node(dp);
374 if (!op) {
375 dev->num_addrs = 0;
376 dev->num_irqs = 0;
377 } else {
378 const int *regs = of_get_property(dp, "reg", &len);
379
380 if (!regs)
381 len = 0;
382 dev->num_addrs = len / sizeof(struct linux_prom_registers);
383
384 for (i = 0; i < dev->num_addrs; i++)
385 memcpy(&dev->resource[i],
386 &op->resource[i],
387 sizeof(struct resource));
388
389 dev->num_irqs = op->num_irqs;
390 for (i = 0; i < dev->num_irqs; i++)
391 dev->irqs[i] = op->irqs[i];
392 }
393
394 sd = &dev->ofdev.dev.archdata;
395 sd->prom_node = dp;
396 sd->op = &dev->ofdev;
397 sd->iommu = dev->bus->ofdev.dev.parent->archdata.iommu;
398 sd->stc = dev->bus->ofdev.dev.parent->archdata.stc;
399 sd->numa_node = dev->bus->ofdev.dev.parent->archdata.numa_node;
400
401 dev->ofdev.node = dp;
402 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
403 dev->ofdev.dev.bus = &ebus_bus_type;
404 dev_set_name(&dev->ofdev.dev, "ebus[%08x]", dp->node);
405
406 /* Register with core */
407 if (of_device_register(&dev->ofdev) != 0)
408 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
409 dp->path_component_name);
410
411 dp = dp->child;
412 if (dp) {
413 printk(" ->");
414 dev->children = ebus_alloc(sizeof(struct linux_ebus_child));
415
416 child = dev->children;
417 child->next = NULL;
418 child->parent = dev;
419 child->bus = dev->bus;
420 fill_ebus_child(dp, child,
421 child_regs_nonstandard(dev));
422
423 while ((dp = dp->sibling) != NULL) {
424 child->next = ebus_alloc(sizeof(struct linux_ebus_child));
425
426 child = child->next;
427 child->next = NULL;
428 child->parent = dev;
429 child->bus = dev->bus;
430 fill_ebus_child(dp, child,
431 child_regs_nonstandard(dev));
432 }
433 }
434 printk("]");
435}
436
437static struct pci_dev *find_next_ebus(struct pci_dev *start, int *is_rio_p)
438{
439 struct pci_dev *pdev = start;
440
441 while ((pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev)))
442 if (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
443 pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)
444 break;
445
446 *is_rio_p = !!(pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS));
447
448 return pdev;
449}
450
451void __init ebus_init(void)
452{
453 struct linux_ebus_device *dev;
454 struct linux_ebus *ebus;
455 struct pci_dev *pdev;
456 struct device_node *dp;
457 int is_rio;
458 int num_ebus = 0;
459
460 pdev = find_next_ebus(NULL, &is_rio);
461 if (!pdev) {
462 printk("ebus: No EBus's found.\n");
463 return;
464 }
465
466 dp = pci_device_to_OF_node(pdev);
467
468 ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
469 ebus->next = NULL;
470 ebus->is_rio = is_rio;
471
472 while (dp) {
473 struct device_node *child;
474
475 /* SUNW,pci-qfe uses four empty ebuses on it.
476 I think we should not consider them here,
477 as they have half of the properties this
478 code expects and once we do PCI hot-plug,
479 we'd have to tweak with the ebus_chain
480 in the runtime after initialization. -jj */
481 if (!dp->child) {
482 pdev = find_next_ebus(pdev, &is_rio);
483 if (!pdev) {
484 if (ebus == ebus_chain) {
485 ebus_chain = NULL;
486 printk("ebus: No EBus's found.\n");
487 return;
488 }
489 break;
490 }
491 ebus->is_rio = is_rio;
492 dp = pci_device_to_OF_node(pdev);
493 continue;
494 }
495 printk("ebus%d:", num_ebus);
496
497 ebus->index = num_ebus;
498 ebus->prom_node = dp;
499 ebus->self = pdev;
500
501 ebus->ofdev.node = dp;
502 ebus->ofdev.dev.parent = &pdev->dev;
503 ebus->ofdev.dev.bus = &ebus_bus_type;
504 dev_set_name(&ebus->ofdev.dev, "ebus%d", num_ebus);
505
506 /* Register with core */
507 if (of_device_register(&ebus->ofdev) != 0)
508 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
509 dp->path_component_name);
510
511
512 child = dp->child;
513 if (!child)
514 goto next_ebus;
515
516 ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device));
517
518 dev = ebus->devices;
519 dev->next = NULL;
520 dev->children = NULL;
521 dev->bus = ebus;
522 fill_ebus_device(child, dev);
523
524 while ((child = child->sibling) != NULL) {
525 dev->next = ebus_alloc(sizeof(struct linux_ebus_device));
526
527 dev = dev->next;
528 dev->next = NULL;
529 dev->children = NULL;
530 dev->bus = ebus;
531 fill_ebus_device(child, dev);
532 }
533
534 next_ebus:
535 printk("\n");
536
537 pdev = find_next_ebus(pdev, &is_rio);
538 if (!pdev)
539 break;
540
541 dp = pci_device_to_OF_node(pdev);
542
543 ebus->next = ebus_alloc(sizeof(struct linux_ebus));
544 ebus = ebus->next;
545 ebus->next = NULL;
546 ebus->is_rio = is_rio;
547 ++num_ebus;
548 }
549 pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */
550}
diff --git a/arch/sparc64/kernel/entry.h b/arch/sparc64/kernel/entry.h
index fc294a292899..34d7ab5e10d2 100644
--- a/arch/sparc64/kernel/entry.h
+++ b/arch/sparc64/kernel/entry.h
@@ -5,8 +5,8 @@
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/init.h> 6#include <linux/init.h>
7 7
8extern char *sparc_cpu_type; 8extern const char *sparc_cpu_type;
9extern char *sparc_fpu_type; 9extern const char *sparc_fpu_type;
10 10
11extern void __init per_cpu_patch(void); 11extern void __init per_cpu_patch(void);
12extern void __init sun4v_patch(void); 12extern void __init sun4v_patch(void);
@@ -22,7 +22,8 @@ extern void do_notify_resume(struct pt_regs *regs,
22 unsigned long orig_i0, 22 unsigned long orig_i0,
23 unsigned long thread_info_flags); 23 unsigned long thread_info_flags);
24 24
25extern asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p); 25extern asmlinkage int syscall_trace_enter(struct pt_regs *regs);
26extern asmlinkage void syscall_trace_leave(struct pt_regs *regs);
26 27
27extern void bad_trap_tl1(struct pt_regs *regs, long lvl); 28extern void bad_trap_tl1(struct pt_regs *regs, long lvl);
28 29
diff --git a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
index c9afef093d51..353226fa0239 100644
--- a/arch/sparc64/kernel/head.S
+++ b/arch/sparc64/kernel/head.S
@@ -10,6 +10,7 @@
10#include <linux/errno.h> 10#include <linux/errno.h>
11#include <linux/threads.h> 11#include <linux/threads.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/linkage.h>
13#include <asm/thread_info.h> 14#include <asm/thread_info.h>
14#include <asm/asi.h> 15#include <asm/asi.h>
15#include <asm/pstate.h> 16#include <asm/pstate.h>
diff --git a/arch/sparc64/kernel/hvapi.c b/arch/sparc64/kernel/hvapi.c
index 691760b5b012..1d272c3b5740 100644
--- a/arch/sparc64/kernel/hvapi.c
+++ b/arch/sparc64/kernel/hvapi.c
@@ -9,7 +9,6 @@
9 9
10#include <asm/hypervisor.h> 10#include <asm/hypervisor.h>
11#include <asm/oplib.h> 11#include <asm/oplib.h>
12#include <asm/sstate.h>
13 12
14/* If the hypervisor indicates that the API setting 13/* If the hypervisor indicates that the API setting
15 * calls are unsupported, by returning HV_EBADTRAP or 14 * calls are unsupported, by returning HV_EBADTRAP or
@@ -184,8 +183,6 @@ void __init sun4v_hvapi_init(void)
184 if (sun4v_hvapi_register(group, major, &minor)) 183 if (sun4v_hvapi_register(group, major, &minor))
185 goto bad; 184 goto bad;
186 185
187 sun4v_sstate_init();
188
189 return; 186 return;
190 187
191bad: 188bad:
diff --git a/arch/sparc64/kernel/hvcalls.S b/arch/sparc64/kernel/hvcalls.S
index a2810f3ac70f..e066269d1594 100644
--- a/arch/sparc64/kernel/hvcalls.S
+++ b/arch/sparc64/kernel/hvcalls.S
@@ -3,89 +3,75 @@
3 * 3 *
4 * returns %o0: sysino 4 * returns %o0: sysino
5 */ 5 */
6 .globl sun4v_devino_to_sysino 6ENTRY(sun4v_devino_to_sysino)
7 .type sun4v_devino_to_sysino,#function
8sun4v_devino_to_sysino:
9 mov HV_FAST_INTR_DEVINO2SYSINO, %o5 7 mov HV_FAST_INTR_DEVINO2SYSINO, %o5
10 ta HV_FAST_TRAP 8 ta HV_FAST_TRAP
11 retl 9 retl
12 mov %o1, %o0 10 mov %o1, %o0
13 .size sun4v_devino_to_sysino, .-sun4v_devino_to_sysino 11ENDPROC(sun4v_devino_to_sysino)
14 12
15 /* %o0: sysino 13 /* %o0: sysino
16 * 14 *
17 * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED}) 15 * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED})
18 */ 16 */
19 .globl sun4v_intr_getenabled 17ENTRY(sun4v_intr_getenabled)
20 .type sun4v_intr_getenabled,#function
21sun4v_intr_getenabled:
22 mov HV_FAST_INTR_GETENABLED, %o5 18 mov HV_FAST_INTR_GETENABLED, %o5
23 ta HV_FAST_TRAP 19 ta HV_FAST_TRAP
24 retl 20 retl
25 mov %o1, %o0 21 mov %o1, %o0
26 .size sun4v_intr_getenabled, .-sun4v_intr_getenabled 22ENDPROC(sun4v_intr_getenabled)
27 23
28 /* %o0: sysino 24 /* %o0: sysino
29 * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED}) 25 * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
30 */ 26 */
31 .globl sun4v_intr_setenabled 27ENTRY(sun4v_intr_setenabled)
32 .type sun4v_intr_setenabled,#function
33sun4v_intr_setenabled:
34 mov HV_FAST_INTR_SETENABLED, %o5 28 mov HV_FAST_INTR_SETENABLED, %o5
35 ta HV_FAST_TRAP 29 ta HV_FAST_TRAP
36 retl 30 retl
37 nop 31 nop
38 .size sun4v_intr_setenabled, .-sun4v_intr_setenabled 32ENDPROC(sun4v_intr_setenabled)
39 33
40 /* %o0: sysino 34 /* %o0: sysino
41 * 35 *
42 * returns %o0: intr_state (HV_INTR_STATE_*) 36 * returns %o0: intr_state (HV_INTR_STATE_*)
43 */ 37 */
44 .globl sun4v_intr_getstate 38ENTRY(sun4v_intr_getstate)
45 .type sun4v_intr_getstate,#function
46sun4v_intr_getstate:
47 mov HV_FAST_INTR_GETSTATE, %o5 39 mov HV_FAST_INTR_GETSTATE, %o5
48 ta HV_FAST_TRAP 40 ta HV_FAST_TRAP
49 retl 41 retl
50 mov %o1, %o0 42 mov %o1, %o0
51 .size sun4v_intr_getstate, .-sun4v_intr_getstate 43ENDPROC(sun4v_intr_getstate)
52 44
53 /* %o0: sysino 45 /* %o0: sysino
54 * %o1: intr_state (HV_INTR_STATE_*) 46 * %o1: intr_state (HV_INTR_STATE_*)
55 */ 47 */
56 .globl sun4v_intr_setstate 48ENTRY(sun4v_intr_setstate)
57 .type sun4v_intr_setstate,#function
58sun4v_intr_setstate:
59 mov HV_FAST_INTR_SETSTATE, %o5 49 mov HV_FAST_INTR_SETSTATE, %o5
60 ta HV_FAST_TRAP 50 ta HV_FAST_TRAP
61 retl 51 retl
62 nop 52 nop
63 .size sun4v_intr_setstate, .-sun4v_intr_setstate 53ENDPROC(sun4v_intr_setstate)
64 54
65 /* %o0: sysino 55 /* %o0: sysino
66 * 56 *
67 * returns %o0: cpuid 57 * returns %o0: cpuid
68 */ 58 */
69 .globl sun4v_intr_gettarget 59ENTRY(sun4v_intr_gettarget)
70 .type sun4v_intr_gettarget,#function
71sun4v_intr_gettarget:
72 mov HV_FAST_INTR_GETTARGET, %o5 60 mov HV_FAST_INTR_GETTARGET, %o5
73 ta HV_FAST_TRAP 61 ta HV_FAST_TRAP
74 retl 62 retl
75 mov %o1, %o0 63 mov %o1, %o0
76 .size sun4v_intr_gettarget, .-sun4v_intr_gettarget 64ENDPROC(sun4v_intr_gettarget)
77 65
78 /* %o0: sysino 66 /* %o0: sysino
79 * %o1: cpuid 67 * %o1: cpuid
80 */ 68 */
81 .globl sun4v_intr_settarget 69ENTRY(sun4v_intr_settarget)
82 .type sun4v_intr_settarget,#function
83sun4v_intr_settarget:
84 mov HV_FAST_INTR_SETTARGET, %o5 70 mov HV_FAST_INTR_SETTARGET, %o5
85 ta HV_FAST_TRAP 71 ta HV_FAST_TRAP
86 retl 72 retl
87 nop 73 nop
88 .size sun4v_intr_settarget, .-sun4v_intr_settarget 74ENDPROC(sun4v_intr_settarget)
89 75
90 /* %o0: cpuid 76 /* %o0: cpuid
91 * %o1: pc 77 * %o1: pc
@@ -94,37 +80,31 @@ sun4v_intr_settarget:
94 * 80 *
95 * returns %o0: status 81 * returns %o0: status
96 */ 82 */
97 .globl sun4v_cpu_start 83ENTRY(sun4v_cpu_start)
98 .type sun4v_cpu_start,#function
99sun4v_cpu_start:
100 mov HV_FAST_CPU_START, %o5 84 mov HV_FAST_CPU_START, %o5
101 ta HV_FAST_TRAP 85 ta HV_FAST_TRAP
102 retl 86 retl
103 nop 87 nop
104 .size sun4v_cpu_start, .-sun4v_cpu_start 88ENDPROC(sun4v_cpu_start)
105 89
106 /* %o0: cpuid 90 /* %o0: cpuid
107 * 91 *
108 * returns %o0: status 92 * returns %o0: status
109 */ 93 */
110 .globl sun4v_cpu_stop 94ENTRY(sun4v_cpu_stop)
111 .type sun4v_cpu_stop,#function
112sun4v_cpu_stop:
113 mov HV_FAST_CPU_STOP, %o5 95 mov HV_FAST_CPU_STOP, %o5
114 ta HV_FAST_TRAP 96 ta HV_FAST_TRAP
115 retl 97 retl
116 nop 98 nop
117 .size sun4v_cpu_stop, .-sun4v_cpu_stop 99ENDPROC(sun4v_cpu_stop)
118 100
119 /* returns %o0: status */ 101 /* returns %o0: status */
120 .globl sun4v_cpu_yield 102ENTRY(sun4v_cpu_yield)
121 .type sun4v_cpu_yield, #function
122sun4v_cpu_yield:
123 mov HV_FAST_CPU_YIELD, %o5 103 mov HV_FAST_CPU_YIELD, %o5
124 ta HV_FAST_TRAP 104 ta HV_FAST_TRAP
125 retl 105 retl
126 nop 106 nop
127 .size sun4v_cpu_yield, .-sun4v_cpu_yield 107ENDPROC(sun4v_cpu_yield)
128 108
129 /* %o0: type 109 /* %o0: type
130 * %o1: queue paddr 110 * %o1: queue paddr
@@ -132,14 +112,12 @@ sun4v_cpu_yield:
132 * 112 *
133 * returns %o0: status 113 * returns %o0: status
134 */ 114 */
135 .globl sun4v_cpu_qconf 115ENTRY(sun4v_cpu_qconf)
136 .type sun4v_cpu_qconf,#function
137sun4v_cpu_qconf:
138 mov HV_FAST_CPU_QCONF, %o5 116 mov HV_FAST_CPU_QCONF, %o5
139 ta HV_FAST_TRAP 117 ta HV_FAST_TRAP
140 retl 118 retl
141 nop 119 nop
142 .size sun4v_cpu_qconf, .-sun4v_cpu_qconf 120ENDPROC(sun4v_cpu_qconf)
143 121
144 /* %o0: num cpus in cpu list 122 /* %o0: num cpus in cpu list
145 * %o1: cpu list paddr 123 * %o1: cpu list paddr
@@ -147,23 +125,19 @@ sun4v_cpu_qconf:
147 * 125 *
148 * returns %o0: status 126 * returns %o0: status
149 */ 127 */
150 .globl sun4v_cpu_mondo_send 128ENTRY(sun4v_cpu_mondo_send)
151 .type sun4v_cpu_mondo_send,#function
152sun4v_cpu_mondo_send:
153 mov HV_FAST_CPU_MONDO_SEND, %o5 129 mov HV_FAST_CPU_MONDO_SEND, %o5
154 ta HV_FAST_TRAP 130 ta HV_FAST_TRAP
155 retl 131 retl
156 nop 132 nop
157 .size sun4v_cpu_mondo_send, .-sun4v_cpu_mondo_send 133ENDPROC(sun4v_cpu_mondo_send)
158 134
159 /* %o0: CPU ID 135 /* %o0: CPU ID
160 * 136 *
161 * returns %o0: -status if status non-zero, else 137 * returns %o0: -status if status non-zero, else
162 * %o0: cpu state as HV_CPU_STATE_* 138 * %o0: cpu state as HV_CPU_STATE_*
163 */ 139 */
164 .globl sun4v_cpu_state 140ENTRY(sun4v_cpu_state)
165 .type sun4v_cpu_state,#function
166sun4v_cpu_state:
167 mov HV_FAST_CPU_STATE, %o5 141 mov HV_FAST_CPU_STATE, %o5
168 ta HV_FAST_TRAP 142 ta HV_FAST_TRAP
169 brnz,pn %o0, 1f 143 brnz,pn %o0, 1f
@@ -171,7 +145,7 @@ sun4v_cpu_state:
171 mov %o1, %o0 145 mov %o1, %o0
1721: retl 1461: retl
173 nop 147 nop
174 .size sun4v_cpu_state, .-sun4v_cpu_state 148ENDPROC(sun4v_cpu_state)
175 149
176 /* %o0: virtual address 150 /* %o0: virtual address
177 * %o1: must be zero 151 * %o1: must be zero
@@ -180,28 +154,24 @@ sun4v_cpu_state:
180 * 154 *
181 * returns %o0: status 155 * returns %o0: status
182 */ 156 */
183 .globl sun4v_mmu_map_perm_addr 157ENTRY(sun4v_mmu_map_perm_addr)
184 .type sun4v_mmu_map_perm_addr,#function
185sun4v_mmu_map_perm_addr:
186 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5 158 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
187 ta HV_FAST_TRAP 159 ta HV_FAST_TRAP
188 retl 160 retl
189 nop 161 nop
190 .size sun4v_mmu_map_perm_addr, .-sun4v_mmu_map_perm_addr 162ENDPROC(sun4v_mmu_map_perm_addr)
191 163
192 /* %o0: number of TSB descriptions 164 /* %o0: number of TSB descriptions
193 * %o1: TSB descriptions real address 165 * %o1: TSB descriptions real address
194 * 166 *
195 * returns %o0: status 167 * returns %o0: status
196 */ 168 */
197 .globl sun4v_mmu_tsb_ctx0 169ENTRY(sun4v_mmu_tsb_ctx0)
198 .type sun4v_mmu_tsb_ctx0,#function
199sun4v_mmu_tsb_ctx0:
200 mov HV_FAST_MMU_TSB_CTX0, %o5 170 mov HV_FAST_MMU_TSB_CTX0, %o5
201 ta HV_FAST_TRAP 171 ta HV_FAST_TRAP
202 retl 172 retl
203 nop 173 nop
204 .size sun4v_mmu_tsb_ctx0, .-sun4v_mmu_tsb_ctx0 174ENDPROC(sun4v_mmu_tsb_ctx0)
205 175
206 /* %o0: API group number 176 /* %o0: API group number
207 * %o1: pointer to unsigned long major number storage 177 * %o1: pointer to unsigned long major number storage
@@ -209,9 +179,7 @@ sun4v_mmu_tsb_ctx0:
209 * 179 *
210 * returns %o0: status 180 * returns %o0: status
211 */ 181 */
212 .globl sun4v_get_version 182ENTRY(sun4v_get_version)
213 .type sun4v_get_version,#function
214sun4v_get_version:
215 mov HV_CORE_GET_VER, %o5 183 mov HV_CORE_GET_VER, %o5
216 mov %o1, %o3 184 mov %o1, %o3
217 mov %o2, %o4 185 mov %o2, %o4
@@ -219,7 +187,7 @@ sun4v_get_version:
219 stx %o1, [%o3] 187 stx %o1, [%o3]
220 retl 188 retl
221 stx %o2, [%o4] 189 stx %o2, [%o4]
222 .size sun4v_get_version, .-sun4v_get_version 190ENDPROC(sun4v_get_version)
223 191
224 /* %o0: API group number 192 /* %o0: API group number
225 * %o1: desired major number 193 * %o1: desired major number
@@ -228,51 +196,43 @@ sun4v_get_version:
228 * 196 *
229 * returns %o0: status 197 * returns %o0: status
230 */ 198 */
231 .globl sun4v_set_version 199ENTRY(sun4v_set_version)
232 .type sun4v_set_version,#function
233sun4v_set_version:
234 mov HV_CORE_SET_VER, %o5 200 mov HV_CORE_SET_VER, %o5
235 mov %o3, %o4 201 mov %o3, %o4
236 ta HV_CORE_TRAP 202 ta HV_CORE_TRAP
237 retl 203 retl
238 stx %o1, [%o4] 204 stx %o1, [%o4]
239 .size sun4v_set_version, .-sun4v_set_version 205ENDPROC(sun4v_set_version)
240 206
241 /* %o0: pointer to unsigned long time 207 /* %o0: pointer to unsigned long time
242 * 208 *
243 * returns %o0: status 209 * returns %o0: status
244 */ 210 */
245 .globl sun4v_tod_get 211ENTRY(sun4v_tod_get)
246 .type sun4v_tod_get,#function
247sun4v_tod_get:
248 mov %o0, %o4 212 mov %o0, %o4
249 mov HV_FAST_TOD_GET, %o5 213 mov HV_FAST_TOD_GET, %o5
250 ta HV_FAST_TRAP 214 ta HV_FAST_TRAP
251 stx %o1, [%o4] 215 stx %o1, [%o4]
252 retl 216 retl
253 nop 217 nop
254 .size sun4v_tod_get, .-sun4v_tod_get 218ENDPROC(sun4v_tod_get)
255 219
256 /* %o0: time 220 /* %o0: time
257 * 221 *
258 * returns %o0: status 222 * returns %o0: status
259 */ 223 */
260 .globl sun4v_tod_set 224ENTRY(sun4v_tod_set)
261 .type sun4v_tod_set,#function
262sun4v_tod_set:
263 mov HV_FAST_TOD_SET, %o5 225 mov HV_FAST_TOD_SET, %o5
264 ta HV_FAST_TRAP 226 ta HV_FAST_TRAP
265 retl 227 retl
266 nop 228 nop
267 .size sun4v_tod_set, .-sun4v_tod_set 229ENDPROC(sun4v_tod_set)
268 230
269 /* %o0: pointer to unsigned long status 231 /* %o0: pointer to unsigned long status
270 * 232 *
271 * returns %o0: signed character 233 * returns %o0: signed character
272 */ 234 */
273 .globl sun4v_con_getchar 235ENTRY(sun4v_con_getchar)
274 .type sun4v_con_getchar,#function
275sun4v_con_getchar:
276 mov %o0, %o4 236 mov %o0, %o4
277 mov HV_FAST_CONS_GETCHAR, %o5 237 mov HV_FAST_CONS_GETCHAR, %o5
278 clr %o0 238 clr %o0
@@ -281,20 +241,18 @@ sun4v_con_getchar:
281 stx %o0, [%o4] 241 stx %o0, [%o4]
282 retl 242 retl
283 sra %o1, 0, %o0 243 sra %o1, 0, %o0
284 .size sun4v_con_getchar, .-sun4v_con_getchar 244ENDPROC(sun4v_con_getchar)
285 245
286 /* %o0: signed long character 246 /* %o0: signed long character
287 * 247 *
288 * returns %o0: status 248 * returns %o0: status
289 */ 249 */
290 .globl sun4v_con_putchar 250ENTRY(sun4v_con_putchar)
291 .type sun4v_con_putchar,#function
292sun4v_con_putchar:
293 mov HV_FAST_CONS_PUTCHAR, %o5 251 mov HV_FAST_CONS_PUTCHAR, %o5
294 ta HV_FAST_TRAP 252 ta HV_FAST_TRAP
295 retl 253 retl
296 sra %o0, 0, %o0 254 sra %o0, 0, %o0
297 .size sun4v_con_putchar, .-sun4v_con_putchar 255ENDPROC(sun4v_con_putchar)
298 256
299 /* %o0: buffer real address 257 /* %o0: buffer real address
300 * %o1: buffer size 258 * %o1: buffer size
@@ -302,9 +260,7 @@ sun4v_con_putchar:
302 * 260 *
303 * returns %o0: status 261 * returns %o0: status
304 */ 262 */
305 .globl sun4v_con_read 263ENTRY(sun4v_con_read)
306 .type sun4v_con_read,#function
307sun4v_con_read:
308 mov %o2, %o4 264 mov %o2, %o4
309 mov HV_FAST_CONS_READ, %o5 265 mov HV_FAST_CONS_READ, %o5
310 ta HV_FAST_TRAP 266 ta HV_FAST_TRAP
@@ -318,7 +274,7 @@ sun4v_con_read:
318 stx %o1, [%o4] 274 stx %o1, [%o4]
3191: retl 2751: retl
320 nop 276 nop
321 .size sun4v_con_read, .-sun4v_con_read 277ENDPROC(sun4v_con_read)
322 278
323 /* %o0: buffer real address 279 /* %o0: buffer real address
324 * %o1: buffer size 280 * %o1: buffer size
@@ -326,43 +282,37 @@ sun4v_con_read:
326 * 282 *
327 * returns %o0: status 283 * returns %o0: status
328 */ 284 */
329 .globl sun4v_con_write 285ENTRY(sun4v_con_write)
330 .type sun4v_con_write,#function
331sun4v_con_write:
332 mov %o2, %o4 286 mov %o2, %o4
333 mov HV_FAST_CONS_WRITE, %o5 287 mov HV_FAST_CONS_WRITE, %o5
334 ta HV_FAST_TRAP 288 ta HV_FAST_TRAP
335 stx %o1, [%o4] 289 stx %o1, [%o4]
336 retl 290 retl
337 nop 291 nop
338 .size sun4v_con_write, .-sun4v_con_write 292ENDPROC(sun4v_con_write)
339 293
340 /* %o0: soft state 294 /* %o0: soft state
341 * %o1: address of description string 295 * %o1: address of description string
342 * 296 *
343 * returns %o0: status 297 * returns %o0: status
344 */ 298 */
345 .globl sun4v_mach_set_soft_state 299ENTRY(sun4v_mach_set_soft_state)
346 .type sun4v_mach_set_soft_state,#function
347sun4v_mach_set_soft_state:
348 mov HV_FAST_MACH_SET_SOFT_STATE, %o5 300 mov HV_FAST_MACH_SET_SOFT_STATE, %o5
349 ta HV_FAST_TRAP 301 ta HV_FAST_TRAP
350 retl 302 retl
351 nop 303 nop
352 .size sun4v_mach_set_soft_state, .-sun4v_mach_set_soft_state 304ENDPROC(sun4v_mach_set_soft_state)
353 305
354 /* %o0: exit code 306 /* %o0: exit code
355 * 307 *
356 * Does not return. 308 * Does not return.
357 */ 309 */
358 .globl sun4v_mach_exit 310ENTRY(sun4v_mach_exit)
359 .type sun4v_mach_exit,#function
360sun4v_mach_exit:
361 mov HV_FAST_MACH_EXIT, %o5 311 mov HV_FAST_MACH_EXIT, %o5
362 ta HV_FAST_TRAP 312 ta HV_FAST_TRAP
363 retl 313 retl
364 nop 314 nop
365 .size sun4v_mach_exit, .-sun4v_mach_exit 315ENDPROC(sun4v_mach_exit)
366 316
367 /* %o0: buffer real address 317 /* %o0: buffer real address
368 * %o1: buffer length 318 * %o1: buffer length
@@ -370,44 +320,38 @@ sun4v_mach_exit:
370 * 320 *
371 * returns %o0: status 321 * returns %o0: status
372 */ 322 */
373 .globl sun4v_mach_desc 323ENTRY(sun4v_mach_desc)
374 .type sun4v_mach_desc,#function
375sun4v_mach_desc:
376 mov %o2, %o4 324 mov %o2, %o4
377 mov HV_FAST_MACH_DESC, %o5 325 mov HV_FAST_MACH_DESC, %o5
378 ta HV_FAST_TRAP 326 ta HV_FAST_TRAP
379 stx %o1, [%o4] 327 stx %o1, [%o4]
380 retl 328 retl
381 nop 329 nop
382 .size sun4v_mach_desc, .-sun4v_mach_desc 330ENDPROC(sun4v_mach_desc)
383 331
384 /* %o0: new timeout in milliseconds 332 /* %o0: new timeout in milliseconds
385 * %o1: pointer to unsigned long orig_timeout 333 * %o1: pointer to unsigned long orig_timeout
386 * 334 *
387 * returns %o0: status 335 * returns %o0: status
388 */ 336 */
389 .globl sun4v_mach_set_watchdog 337ENTRY(sun4v_mach_set_watchdog)
390 .type sun4v_mach_set_watchdog,#function
391sun4v_mach_set_watchdog:
392 mov %o1, %o4 338 mov %o1, %o4
393 mov HV_FAST_MACH_SET_WATCHDOG, %o5 339 mov HV_FAST_MACH_SET_WATCHDOG, %o5
394 ta HV_FAST_TRAP 340 ta HV_FAST_TRAP
395 stx %o1, [%o4] 341 stx %o1, [%o4]
396 retl 342 retl
397 nop 343 nop
398 .size sun4v_mach_set_watchdog, .-sun4v_mach_set_watchdog 344ENDPROC(sun4v_mach_set_watchdog)
399 345
400 /* No inputs and does not return. */ 346 /* No inputs and does not return. */
401 .globl sun4v_mach_sir 347ENTRY(sun4v_mach_sir)
402 .type sun4v_mach_sir,#function
403sun4v_mach_sir:
404 mov %o1, %o4 348 mov %o1, %o4
405 mov HV_FAST_MACH_SIR, %o5 349 mov HV_FAST_MACH_SIR, %o5
406 ta HV_FAST_TRAP 350 ta HV_FAST_TRAP
407 stx %o1, [%o4] 351 stx %o1, [%o4]
408 retl 352 retl
409 nop 353 nop
410 .size sun4v_mach_sir, .-sun4v_mach_sir 354ENDPROC(sun4v_mach_sir)
411 355
412 /* %o0: channel 356 /* %o0: channel
413 * %o1: ra 357 * %o1: ra
@@ -415,14 +359,12 @@ sun4v_mach_sir:
415 * 359 *
416 * returns %o0: status 360 * returns %o0: status
417 */ 361 */
418 .globl sun4v_ldc_tx_qconf 362ENTRY(sun4v_ldc_tx_qconf)
419 .type sun4v_ldc_tx_qconf,#function
420sun4v_ldc_tx_qconf:
421 mov HV_FAST_LDC_TX_QCONF, %o5 363 mov HV_FAST_LDC_TX_QCONF, %o5
422 ta HV_FAST_TRAP 364 ta HV_FAST_TRAP
423 retl 365 retl
424 nop 366 nop
425 .size sun4v_ldc_tx_qconf, .-sun4v_ldc_tx_qconf 367ENDPROC(sun4v_ldc_tx_qconf)
426 368
427 /* %o0: channel 369 /* %o0: channel
428 * %o1: pointer to unsigned long ra 370 * %o1: pointer to unsigned long ra
@@ -430,9 +372,7 @@ sun4v_ldc_tx_qconf:
430 * 372 *
431 * returns %o0: status 373 * returns %o0: status
432 */ 374 */
433 .globl sun4v_ldc_tx_qinfo 375ENTRY(sun4v_ldc_tx_qinfo)
434 .type sun4v_ldc_tx_qinfo,#function
435sun4v_ldc_tx_qinfo:
436 mov %o1, %g1 376 mov %o1, %g1
437 mov %o2, %g2 377 mov %o2, %g2
438 mov HV_FAST_LDC_TX_QINFO, %o5 378 mov HV_FAST_LDC_TX_QINFO, %o5
@@ -441,7 +381,7 @@ sun4v_ldc_tx_qinfo:
441 stx %o2, [%g2] 381 stx %o2, [%g2]
442 retl 382 retl
443 nop 383 nop
444 .size sun4v_ldc_tx_qinfo, .-sun4v_ldc_tx_qinfo 384ENDPROC(sun4v_ldc_tx_qinfo)
445 385
446 /* %o0: channel 386 /* %o0: channel
447 * %o1: pointer to unsigned long head_off 387 * %o1: pointer to unsigned long head_off
@@ -450,9 +390,7 @@ sun4v_ldc_tx_qinfo:
450 * 390 *
451 * returns %o0: status 391 * returns %o0: status
452 */ 392 */
453 .globl sun4v_ldc_tx_get_state 393ENTRY(sun4v_ldc_tx_get_state)
454 .type sun4v_ldc_tx_get_state,#function
455sun4v_ldc_tx_get_state:
456 mov %o1, %g1 394 mov %o1, %g1
457 mov %o2, %g2 395 mov %o2, %g2
458 mov %o3, %g3 396 mov %o3, %g3
@@ -463,21 +401,19 @@ sun4v_ldc_tx_get_state:
463 stx %o3, [%g3] 401 stx %o3, [%g3]
464 retl 402 retl
465 nop 403 nop
466 .size sun4v_ldc_tx_get_state, .-sun4v_ldc_tx_get_state 404ENDPROC(sun4v_ldc_tx_get_state)
467 405
468 /* %o0: channel 406 /* %o0: channel
469 * %o1: tail_off 407 * %o1: tail_off
470 * 408 *
471 * returns %o0: status 409 * returns %o0: status
472 */ 410 */
473 .globl sun4v_ldc_tx_set_qtail 411ENTRY(sun4v_ldc_tx_set_qtail)
474 .type sun4v_ldc_tx_set_qtail,#function
475sun4v_ldc_tx_set_qtail:
476 mov HV_FAST_LDC_TX_SET_QTAIL, %o5 412 mov HV_FAST_LDC_TX_SET_QTAIL, %o5
477 ta HV_FAST_TRAP 413 ta HV_FAST_TRAP
478 retl 414 retl
479 nop 415 nop
480 .size sun4v_ldc_tx_set_qtail, .-sun4v_ldc_tx_set_qtail 416ENDPROC(sun4v_ldc_tx_set_qtail)
481 417
482 /* %o0: channel 418 /* %o0: channel
483 * %o1: ra 419 * %o1: ra
@@ -485,14 +421,12 @@ sun4v_ldc_tx_set_qtail:
485 * 421 *
486 * returns %o0: status 422 * returns %o0: status
487 */ 423 */
488 .globl sun4v_ldc_rx_qconf 424ENTRY(sun4v_ldc_rx_qconf)
489 .type sun4v_ldc_rx_qconf,#function
490sun4v_ldc_rx_qconf:
491 mov HV_FAST_LDC_RX_QCONF, %o5 425 mov HV_FAST_LDC_RX_QCONF, %o5
492 ta HV_FAST_TRAP 426 ta HV_FAST_TRAP
493 retl 427 retl
494 nop 428 nop
495 .size sun4v_ldc_rx_qconf, .-sun4v_ldc_rx_qconf 429ENDPROC(sun4v_ldc_rx_qconf)
496 430
497 /* %o0: channel 431 /* %o0: channel
498 * %o1: pointer to unsigned long ra 432 * %o1: pointer to unsigned long ra
@@ -500,9 +434,7 @@ sun4v_ldc_rx_qconf:
500 * 434 *
501 * returns %o0: status 435 * returns %o0: status
502 */ 436 */
503 .globl sun4v_ldc_rx_qinfo 437ENTRY(sun4v_ldc_rx_qinfo)
504 .type sun4v_ldc_rx_qinfo,#function
505sun4v_ldc_rx_qinfo:
506 mov %o1, %g1 438 mov %o1, %g1
507 mov %o2, %g2 439 mov %o2, %g2
508 mov HV_FAST_LDC_RX_QINFO, %o5 440 mov HV_FAST_LDC_RX_QINFO, %o5
@@ -511,7 +443,7 @@ sun4v_ldc_rx_qinfo:
511 stx %o2, [%g2] 443 stx %o2, [%g2]
512 retl 444 retl
513 nop 445 nop
514 .size sun4v_ldc_rx_qinfo, .-sun4v_ldc_rx_qinfo 446ENDPROC(sun4v_ldc_rx_qinfo)
515 447
516 /* %o0: channel 448 /* %o0: channel
517 * %o1: pointer to unsigned long head_off 449 * %o1: pointer to unsigned long head_off
@@ -520,9 +452,7 @@ sun4v_ldc_rx_qinfo:
520 * 452 *
521 * returns %o0: status 453 * returns %o0: status
522 */ 454 */
523 .globl sun4v_ldc_rx_get_state 455ENTRY(sun4v_ldc_rx_get_state)
524 .type sun4v_ldc_rx_get_state,#function
525sun4v_ldc_rx_get_state:
526 mov %o1, %g1 456 mov %o1, %g1
527 mov %o2, %g2 457 mov %o2, %g2
528 mov %o3, %g3 458 mov %o3, %g3
@@ -533,21 +463,19 @@ sun4v_ldc_rx_get_state:
533 stx %o3, [%g3] 463 stx %o3, [%g3]
534 retl 464 retl
535 nop 465 nop
536 .size sun4v_ldc_rx_get_state, .-sun4v_ldc_rx_get_state 466ENDPROC(sun4v_ldc_rx_get_state)
537 467
538 /* %o0: channel 468 /* %o0: channel
539 * %o1: head_off 469 * %o1: head_off
540 * 470 *
541 * returns %o0: status 471 * returns %o0: status
542 */ 472 */
543 .globl sun4v_ldc_rx_set_qhead 473ENTRY(sun4v_ldc_rx_set_qhead)
544 .type sun4v_ldc_rx_set_qhead,#function
545sun4v_ldc_rx_set_qhead:
546 mov HV_FAST_LDC_RX_SET_QHEAD, %o5 474 mov HV_FAST_LDC_RX_SET_QHEAD, %o5
547 ta HV_FAST_TRAP 475 ta HV_FAST_TRAP
548 retl 476 retl
549 nop 477 nop
550 .size sun4v_ldc_rx_set_qhead, .-sun4v_ldc_rx_set_qhead 478ENDPROC(sun4v_ldc_rx_set_qhead)
551 479
552 /* %o0: channel 480 /* %o0: channel
553 * %o1: ra 481 * %o1: ra
@@ -555,14 +483,12 @@ sun4v_ldc_rx_set_qhead:
555 * 483 *
556 * returns %o0: status 484 * returns %o0: status
557 */ 485 */
558 .globl sun4v_ldc_set_map_table 486ENTRY(sun4v_ldc_set_map_table)
559 .type sun4v_ldc_set_map_table,#function
560sun4v_ldc_set_map_table:
561 mov HV_FAST_LDC_SET_MAP_TABLE, %o5 487 mov HV_FAST_LDC_SET_MAP_TABLE, %o5
562 ta HV_FAST_TRAP 488 ta HV_FAST_TRAP
563 retl 489 retl
564 nop 490 nop
565 .size sun4v_ldc_set_map_table, .-sun4v_ldc_set_map_table 491ENDPROC(sun4v_ldc_set_map_table)
566 492
567 /* %o0: channel 493 /* %o0: channel
568 * %o1: pointer to unsigned long ra 494 * %o1: pointer to unsigned long ra
@@ -570,9 +496,7 @@ sun4v_ldc_set_map_table:
570 * 496 *
571 * returns %o0: status 497 * returns %o0: status
572 */ 498 */
573 .globl sun4v_ldc_get_map_table 499ENTRY(sun4v_ldc_get_map_table)
574 .type sun4v_ldc_get_map_table,#function
575sun4v_ldc_get_map_table:
576 mov %o1, %g1 500 mov %o1, %g1
577 mov %o2, %g2 501 mov %o2, %g2
578 mov HV_FAST_LDC_GET_MAP_TABLE, %o5 502 mov HV_FAST_LDC_GET_MAP_TABLE, %o5
@@ -581,7 +505,7 @@ sun4v_ldc_get_map_table:
581 stx %o2, [%g2] 505 stx %o2, [%g2]
582 retl 506 retl
583 nop 507 nop
584 .size sun4v_ldc_get_map_table, .-sun4v_ldc_get_map_table 508ENDPROC(sun4v_ldc_get_map_table)
585 509
586 /* %o0: channel 510 /* %o0: channel
587 * %o1: dir_code 511 * %o1: dir_code
@@ -592,16 +516,14 @@ sun4v_ldc_get_map_table:
592 * 516 *
593 * returns %o0: status 517 * returns %o0: status
594 */ 518 */
595 .globl sun4v_ldc_copy 519ENTRY(sun4v_ldc_copy)
596 .type sun4v_ldc_copy,#function
597sun4v_ldc_copy:
598 mov %o5, %g1 520 mov %o5, %g1
599 mov HV_FAST_LDC_COPY, %o5 521 mov HV_FAST_LDC_COPY, %o5
600 ta HV_FAST_TRAP 522 ta HV_FAST_TRAP
601 stx %o1, [%g1] 523 stx %o1, [%g1]
602 retl 524 retl
603 nop 525 nop
604 .size sun4v_ldc_copy, .-sun4v_ldc_copy 526ENDPROC(sun4v_ldc_copy)
605 527
606 /* %o0: channel 528 /* %o0: channel
607 * %o1: cookie 529 * %o1: cookie
@@ -610,9 +532,7 @@ sun4v_ldc_copy:
610 * 532 *
611 * returns %o0: status 533 * returns %o0: status
612 */ 534 */
613 .globl sun4v_ldc_mapin 535ENTRY(sun4v_ldc_mapin)
614 .type sun4v_ldc_mapin,#function
615sun4v_ldc_mapin:
616 mov %o2, %g1 536 mov %o2, %g1
617 mov %o3, %g2 537 mov %o3, %g2
618 mov HV_FAST_LDC_MAPIN, %o5 538 mov HV_FAST_LDC_MAPIN, %o5
@@ -621,20 +541,18 @@ sun4v_ldc_mapin:
621 stx %o2, [%g2] 541 stx %o2, [%g2]
622 retl 542 retl
623 nop 543 nop
624 .size sun4v_ldc_mapin, .-sun4v_ldc_mapin 544ENDPROC(sun4v_ldc_mapin)
625 545
626 /* %o0: ra 546 /* %o0: ra
627 * 547 *
628 * returns %o0: status 548 * returns %o0: status
629 */ 549 */
630 .globl sun4v_ldc_unmap 550ENTRY(sun4v_ldc_unmap)
631 .type sun4v_ldc_unmap,#function
632sun4v_ldc_unmap:
633 mov HV_FAST_LDC_UNMAP, %o5 551 mov HV_FAST_LDC_UNMAP, %o5
634 ta HV_FAST_TRAP 552 ta HV_FAST_TRAP
635 retl 553 retl
636 nop 554 nop
637 .size sun4v_ldc_unmap, .-sun4v_ldc_unmap 555ENDPROC(sun4v_ldc_unmap)
638 556
639 /* %o0: channel 557 /* %o0: channel
640 * %o1: cookie 558 * %o1: cookie
@@ -642,14 +560,12 @@ sun4v_ldc_unmap:
642 * 560 *
643 * returns %o0: status 561 * returns %o0: status
644 */ 562 */
645 .globl sun4v_ldc_revoke 563ENTRY(sun4v_ldc_revoke)
646 .type sun4v_ldc_revoke,#function
647sun4v_ldc_revoke:
648 mov HV_FAST_LDC_REVOKE, %o5 564 mov HV_FAST_LDC_REVOKE, %o5
649 ta HV_FAST_TRAP 565 ta HV_FAST_TRAP
650 retl 566 retl
651 nop 567 nop
652 .size sun4v_ldc_revoke, .-sun4v_ldc_revoke 568ENDPROC(sun4v_ldc_revoke)
653 569
654 /* %o0: device handle 570 /* %o0: device handle
655 * %o1: device INO 571 * %o1: device INO
@@ -657,16 +573,14 @@ sun4v_ldc_revoke:
657 * 573 *
658 * returns %o0: status 574 * returns %o0: status
659 */ 575 */
660 .globl sun4v_vintr_get_cookie 576ENTRY(sun4v_vintr_get_cookie)
661 .type sun4v_vintr_get_cookie,#function
662sun4v_vintr_get_cookie:
663 mov %o2, %g1 577 mov %o2, %g1
664 mov HV_FAST_VINTR_GET_COOKIE, %o5 578 mov HV_FAST_VINTR_GET_COOKIE, %o5
665 ta HV_FAST_TRAP 579 ta HV_FAST_TRAP
666 stx %o1, [%g1] 580 stx %o1, [%g1]
667 retl 581 retl
668 nop 582 nop
669 .size sun4v_vintr_get_cookie, .-sun4v_vintr_get_cookie 583ENDPROC(sun4v_vintr_get_cookie)
670 584
671 /* %o0: device handle 585 /* %o0: device handle
672 * %o1: device INO 586 * %o1: device INO
@@ -674,14 +588,12 @@ sun4v_vintr_get_cookie:
674 * 588 *
675 * returns %o0: status 589 * returns %o0: status
676 */ 590 */
677 .globl sun4v_vintr_set_cookie 591ENTRY(sun4v_vintr_set_cookie)
678 .type sun4v_vintr_set_cookie,#function
679sun4v_vintr_set_cookie:
680 mov HV_FAST_VINTR_SET_COOKIE, %o5 592 mov HV_FAST_VINTR_SET_COOKIE, %o5
681 ta HV_FAST_TRAP 593 ta HV_FAST_TRAP
682 retl 594 retl
683 nop 595 nop
684 .size sun4v_vintr_set_cookie, .-sun4v_vintr_set_cookie 596ENDPROC(sun4v_vintr_set_cookie)
685 597
686 /* %o0: device handle 598 /* %o0: device handle
687 * %o1: device INO 599 * %o1: device INO
@@ -689,16 +601,14 @@ sun4v_vintr_set_cookie:
689 * 601 *
690 * returns %o0: status 602 * returns %o0: status
691 */ 603 */
692 .globl sun4v_vintr_get_valid 604ENTRY(sun4v_vintr_get_valid)
693 .type sun4v_vintr_get_valid,#function
694sun4v_vintr_get_valid:
695 mov %o2, %g1 605 mov %o2, %g1
696 mov HV_FAST_VINTR_GET_VALID, %o5 606 mov HV_FAST_VINTR_GET_VALID, %o5
697 ta HV_FAST_TRAP 607 ta HV_FAST_TRAP
698 stx %o1, [%g1] 608 stx %o1, [%g1]
699 retl 609 retl
700 nop 610 nop
701 .size sun4v_vintr_get_valid, .-sun4v_vintr_get_valid 611ENDPROC(sun4v_vintr_get_valid)
702 612
703 /* %o0: device handle 613 /* %o0: device handle
704 * %o1: device INO 614 * %o1: device INO
@@ -706,14 +616,12 @@ sun4v_vintr_get_valid:
706 * 616 *
707 * returns %o0: status 617 * returns %o0: status
708 */ 618 */
709 .globl sun4v_vintr_set_valid 619ENTRY(sun4v_vintr_set_valid)
710 .type sun4v_vintr_set_valid,#function
711sun4v_vintr_set_valid:
712 mov HV_FAST_VINTR_SET_VALID, %o5 620 mov HV_FAST_VINTR_SET_VALID, %o5
713 ta HV_FAST_TRAP 621 ta HV_FAST_TRAP
714 retl 622 retl
715 nop 623 nop
716 .size sun4v_vintr_set_valid, .-sun4v_vintr_set_valid 624ENDPROC(sun4v_vintr_set_valid)
717 625
718 /* %o0: device handle 626 /* %o0: device handle
719 * %o1: device INO 627 * %o1: device INO
@@ -721,16 +629,14 @@ sun4v_vintr_set_valid:
721 * 629 *
722 * returns %o0: status 630 * returns %o0: status
723 */ 631 */
724 .globl sun4v_vintr_get_state 632ENTRY(sun4v_vintr_get_state)
725 .type sun4v_vintr_get_state,#function
726sun4v_vintr_get_state:
727 mov %o2, %g1 633 mov %o2, %g1
728 mov HV_FAST_VINTR_GET_STATE, %o5 634 mov HV_FAST_VINTR_GET_STATE, %o5
729 ta HV_FAST_TRAP 635 ta HV_FAST_TRAP
730 stx %o1, [%g1] 636 stx %o1, [%g1]
731 retl 637 retl
732 nop 638 nop
733 .size sun4v_vintr_get_state, .-sun4v_vintr_get_state 639ENDPROC(sun4v_vintr_get_state)
734 640
735 /* %o0: device handle 641 /* %o0: device handle
736 * %o1: device INO 642 * %o1: device INO
@@ -738,14 +644,12 @@ sun4v_vintr_get_state:
738 * 644 *
739 * returns %o0: status 645 * returns %o0: status
740 */ 646 */
741 .globl sun4v_vintr_set_state 647ENTRY(sun4v_vintr_set_state)
742 .type sun4v_vintr_set_state,#function
743sun4v_vintr_set_state:
744 mov HV_FAST_VINTR_SET_STATE, %o5 648 mov HV_FAST_VINTR_SET_STATE, %o5
745 ta HV_FAST_TRAP 649 ta HV_FAST_TRAP
746 retl 650 retl
747 nop 651 nop
748 .size sun4v_vintr_set_state, .-sun4v_vintr_set_state 652ENDPROC(sun4v_vintr_set_state)
749 653
750 /* %o0: device handle 654 /* %o0: device handle
751 * %o1: device INO 655 * %o1: device INO
@@ -753,16 +657,14 @@ sun4v_vintr_set_state:
753 * 657 *
754 * returns %o0: status 658 * returns %o0: status
755 */ 659 */
756 .globl sun4v_vintr_get_target 660ENTRY(sun4v_vintr_get_target)
757 .type sun4v_vintr_get_target,#function
758sun4v_vintr_get_target:
759 mov %o2, %g1 661 mov %o2, %g1
760 mov HV_FAST_VINTR_GET_TARGET, %o5 662 mov HV_FAST_VINTR_GET_TARGET, %o5
761 ta HV_FAST_TRAP 663 ta HV_FAST_TRAP
762 stx %o1, [%g1] 664 stx %o1, [%g1]
763 retl 665 retl
764 nop 666 nop
765 .size sun4v_vintr_get_target, .-sun4v_vintr_get_target 667ENDPROC(sun4v_vintr_get_target)
766 668
767 /* %o0: device handle 669 /* %o0: device handle
768 * %o1: device INO 670 * %o1: device INO
@@ -770,14 +672,12 @@ sun4v_vintr_get_target:
770 * 672 *
771 * returns %o0: status 673 * returns %o0: status
772 */ 674 */
773 .globl sun4v_vintr_set_target 675ENTRY(sun4v_vintr_set_target)
774 .type sun4v_vintr_set_target,#function
775sun4v_vintr_set_target:
776 mov HV_FAST_VINTR_SET_TARGET, %o5 676 mov HV_FAST_VINTR_SET_TARGET, %o5
777 ta HV_FAST_TRAP 677 ta HV_FAST_TRAP
778 retl 678 retl
779 nop 679 nop
780 .size sun4v_vintr_set_target, .-sun4v_vintr_set_target 680ENDPROC(sun4v_vintr_set_target)
781 681
782 /* %o0: NCS sub-function 682 /* %o0: NCS sub-function
783 * %o1: sub-function arg real-address 683 * %o1: sub-function arg real-address
@@ -785,18 +685,14 @@ sun4v_vintr_set_target:
785 * 685 *
786 * returns %o0: status 686 * returns %o0: status
787 */ 687 */
788 .globl sun4v_ncs_request 688ENTRY(sun4v_ncs_request)
789 .type sun4v_ncs_request,#function
790sun4v_ncs_request:
791 mov HV_FAST_NCS_REQUEST, %o5 689 mov HV_FAST_NCS_REQUEST, %o5
792 ta HV_FAST_TRAP 690 ta HV_FAST_TRAP
793 retl 691 retl
794 nop 692 nop
795 .size sun4v_ncs_request, .-sun4v_ncs_request 693ENDPROC(sun4v_ncs_request)
796 694
797 .globl sun4v_svc_send 695ENTRY(sun4v_svc_send)
798 .type sun4v_svc_send,#function
799sun4v_svc_send:
800 save %sp, -192, %sp 696 save %sp, -192, %sp
801 mov %i0, %o0 697 mov %i0, %o0
802 mov %i1, %o1 698 mov %i1, %o1
@@ -806,11 +702,9 @@ sun4v_svc_send:
806 stx %o1, [%i3] 702 stx %o1, [%i3]
807 ret 703 ret
808 restore 704 restore
809 .size sun4v_svc_send, .-sun4v_svc_send 705ENDPROC(sun4v_svc_send)
810 706
811 .globl sun4v_svc_recv 707ENTRY(sun4v_svc_recv)
812 .type sun4v_svc_recv,#function
813sun4v_svc_recv:
814 save %sp, -192, %sp 708 save %sp, -192, %sp
815 mov %i0, %o0 709 mov %i0, %o0
816 mov %i1, %o1 710 mov %i1, %o1
@@ -820,62 +714,50 @@ sun4v_svc_recv:
820 stx %o1, [%i3] 714 stx %o1, [%i3]
821 ret 715 ret
822 restore 716 restore
823 .size sun4v_svc_recv, .-sun4v_svc_recv 717ENDPROC(sun4v_svc_recv)
824 718
825 .globl sun4v_svc_getstatus 719ENTRY(sun4v_svc_getstatus)
826 .type sun4v_svc_getstatus,#function
827sun4v_svc_getstatus:
828 mov HV_FAST_SVC_GETSTATUS, %o5 720 mov HV_FAST_SVC_GETSTATUS, %o5
829 mov %o1, %o4 721 mov %o1, %o4
830 ta HV_FAST_TRAP 722 ta HV_FAST_TRAP
831 stx %o1, [%o4] 723 stx %o1, [%o4]
832 retl 724 retl
833 nop 725 nop
834 .size sun4v_svc_getstatus, .-sun4v_svc_getstatus 726ENDPROC(sun4v_svc_getstatus)
835 727
836 .globl sun4v_svc_setstatus 728ENTRY(sun4v_svc_setstatus)
837 .type sun4v_svc_setstatus,#function
838sun4v_svc_setstatus:
839 mov HV_FAST_SVC_SETSTATUS, %o5 729 mov HV_FAST_SVC_SETSTATUS, %o5
840 ta HV_FAST_TRAP 730 ta HV_FAST_TRAP
841 retl 731 retl
842 nop 732 nop
843 .size sun4v_svc_setstatus, .-sun4v_svc_setstatus 733ENDPROC(sun4v_svc_setstatus)
844 734
845 .globl sun4v_svc_clrstatus 735ENTRY(sun4v_svc_clrstatus)
846 .type sun4v_svc_clrstatus,#function
847sun4v_svc_clrstatus:
848 mov HV_FAST_SVC_CLRSTATUS, %o5 736 mov HV_FAST_SVC_CLRSTATUS, %o5
849 ta HV_FAST_TRAP 737 ta HV_FAST_TRAP
850 retl 738 retl
851 nop 739 nop
852 .size sun4v_svc_clrstatus, .-sun4v_svc_clrstatus 740ENDPROC(sun4v_svc_clrstatus)
853 741
854 .globl sun4v_mmustat_conf 742ENTRY(sun4v_mmustat_conf)
855 .type sun4v_mmustat_conf,#function
856sun4v_mmustat_conf:
857 mov %o1, %o4 743 mov %o1, %o4
858 mov HV_FAST_MMUSTAT_CONF, %o5 744 mov HV_FAST_MMUSTAT_CONF, %o5
859 ta HV_FAST_TRAP 745 ta HV_FAST_TRAP
860 stx %o1, [%o4] 746 stx %o1, [%o4]
861 retl 747 retl
862 nop 748 nop
863 .size sun4v_mmustat_conf, .-sun4v_mmustat_conf 749ENDPROC(sun4v_mmustat_conf)
864 750
865 .globl sun4v_mmustat_info 751ENTRY(sun4v_mmustat_info)
866 .type sun4v_mmustat_info,#function
867sun4v_mmustat_info:
868 mov %o0, %o4 752 mov %o0, %o4
869 mov HV_FAST_MMUSTAT_INFO, %o5 753 mov HV_FAST_MMUSTAT_INFO, %o5
870 ta HV_FAST_TRAP 754 ta HV_FAST_TRAP
871 stx %o1, [%o4] 755 stx %o1, [%o4]
872 retl 756 retl
873 nop 757 nop
874 .size sun4v_mmustat_info, .-sun4v_mmustat_info 758ENDPROC(sun4v_mmustat_info)
875 759
876 .globl sun4v_mmu_demap_all 760ENTRY(sun4v_mmu_demap_all)
877 .type sun4v_mmu_demap_all,#function
878sun4v_mmu_demap_all:
879 clr %o0 761 clr %o0
880 clr %o1 762 clr %o1
881 mov HV_MMU_ALL, %o2 763 mov HV_MMU_ALL, %o2
@@ -883,4 +765,4 @@ sun4v_mmu_demap_all:
883 ta HV_FAST_TRAP 765 ta HV_FAST_TRAP
884 retl 766 retl
885 nop 767 nop
886 .size sun4v_mmu_demap_all, .-sun4v_mmu_demap_all 768ENDPROC(sun4v_mmu_demap_all)
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index 7495bc774685..52fc836f464d 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -29,7 +29,6 @@
29#include <asm/system.h> 29#include <asm/system.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/sbus.h>
33#include <asm/iommu.h> 32#include <asm/iommu.h>
34#include <asm/upa.h> 33#include <asm/upa.h>
35#include <asm/oplib.h> 34#include <asm/oplib.h>
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index 100ebd527499..0f616ae3246c 100644
--- a/arch/sparc64/kernel/of_device.c
+++ b/arch/sparc64/kernel/of_device.c
@@ -55,15 +55,38 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
55} 55}
56EXPORT_SYMBOL(of_find_device_by_node); 56EXPORT_SYMBOL(of_find_device_by_node);
57 57
58#ifdef CONFIG_PCI 58unsigned int irq_of_parse_and_map(struct device_node *node, int index)
59struct bus_type ebus_bus_type; 59{
60EXPORT_SYMBOL(ebus_bus_type); 60 struct of_device *op = of_find_device_by_node(node);
61#endif 61
62 if (!op || index >= op->num_irqs)
63 return 0;
64
65 return op->irqs[index];
66}
67EXPORT_SYMBOL(irq_of_parse_and_map);
68
69/* Take the archdata values for IOMMU, STC, and HOSTDATA found in
70 * BUS and propagate to all child of_device objects.
71 */
72void of_propagate_archdata(struct of_device *bus)
73{
74 struct dev_archdata *bus_sd = &bus->dev.archdata;
75 struct device_node *bus_dp = bus->node;
76 struct device_node *dp;
62 77
63#ifdef CONFIG_SBUS 78 for (dp = bus_dp->child; dp; dp = dp->sibling) {
64struct bus_type sbus_bus_type; 79 struct of_device *op = of_find_device_by_node(dp);
65EXPORT_SYMBOL(sbus_bus_type); 80
66#endif 81 op->dev.archdata.iommu = bus_sd->iommu;
82 op->dev.archdata.stc = bus_sd->stc;
83 op->dev.archdata.host_controller = bus_sd->host_controller;
84 op->dev.archdata.numa_node = bus_sd->numa_node;
85
86 if (dp->child)
87 of_propagate_archdata(op);
88 }
89}
67 90
68struct bus_type of_platform_bus_type; 91struct bus_type of_platform_bus_type;
69EXPORT_SYMBOL(of_platform_bus_type); 92EXPORT_SYMBOL(of_platform_bus_type);
@@ -378,8 +401,7 @@ static int __init build_one_resource(struct device_node *parent,
378 int na, int ns, int pna) 401 int na, int ns, int pna)
379{ 402{
380 const u32 *ranges; 403 const u32 *ranges;
381 unsigned int rlen; 404 int rone, rlen;
382 int rone;
383 405
384 ranges = of_get_property(parent, "ranges", &rlen); 406 ranges = of_get_property(parent, "ranges", &rlen);
385 if (ranges == NULL || rlen == 0) { 407 if (ranges == NULL || rlen == 0) {
@@ -421,8 +443,17 @@ static int __init use_1to1_mapping(struct device_node *pp)
421 443
422 /* If the parent is the dma node of an ISA bus, pass 444 /* If the parent is the dma node of an ISA bus, pass
423 * the translation up to the root. 445 * the translation up to the root.
446 *
447 * Some SBUS devices use intermediate nodes to express
448 * hierarchy within the device itself. These aren't
449 * real bus nodes, and don't have a 'ranges' property.
450 * But, we should still pass the translation work up
451 * to the SBUS itself.
424 */ 452 */
425 if (!strcmp(pp->name, "dma")) 453 if (!strcmp(pp->name, "dma") ||
454 !strcmp(pp->name, "espdma") ||
455 !strcmp(pp->name, "ledma") ||
456 !strcmp(pp->name, "lebuffer"))
426 return 0; 457 return 0;
427 458
428 /* Similarly for all PCI bridges, if we get this far 459 /* Similarly for all PCI bridges, if we get this far
@@ -844,15 +875,6 @@ static int __init of_bus_driver_init(void)
844 int err; 875 int err;
845 876
846 err = of_bus_type_init(&of_platform_bus_type, "of"); 877 err = of_bus_type_init(&of_platform_bus_type, "of");
847#ifdef CONFIG_PCI
848 if (!err)
849 err = of_bus_type_init(&ebus_bus_type, "ebus");
850#endif
851#ifdef CONFIG_SBUS
852 if (!err)
853 err = of_bus_type_init(&sbus_bus_type, "sbus");
854#endif
855
856 if (!err) 878 if (!err)
857 scan_of_devices(); 879 scan_of_devices();
858 880
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 80dad76f8b81..242ac1ccae7d 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -18,32 +18,17 @@
18#include <linux/msi.h> 18#include <linux/msi.h>
19#include <linux/irq.h> 19#include <linux/irq.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/of.h>
22#include <linux/of_device.h>
21 23
22#include <asm/uaccess.h> 24#include <asm/uaccess.h>
23#include <asm/pgtable.h> 25#include <asm/pgtable.h>
24#include <asm/irq.h> 26#include <asm/irq.h>
25#include <asm/ebus.h>
26#include <asm/prom.h> 27#include <asm/prom.h>
27#include <asm/apb.h> 28#include <asm/apb.h>
28 29
29#include "pci_impl.h" 30#include "pci_impl.h"
30 31
31#ifndef CONFIG_PCI
32/* A "nop" PCI implementation. */
33asmlinkage int sys_pciconfig_read(unsigned long bus, unsigned long dfn,
34 unsigned long off, unsigned long len,
35 unsigned char *buf)
36{
37 return 0;
38}
39asmlinkage int sys_pciconfig_write(unsigned long bus, unsigned long dfn,
40 unsigned long off, unsigned long len,
41 unsigned char *buf)
42{
43 return 0;
44}
45#else
46
47/* List of all PCI controllers found in the system. */ 32/* List of all PCI controllers found in the system. */
48struct pci_pbm_info *pci_pbm_root = NULL; 33struct pci_pbm_info *pci_pbm_root = NULL;
49 34
@@ -179,97 +164,6 @@ void pci_config_write32(u32 *addr, u32 val)
179 spin_unlock_irqrestore(&pci_poke_lock, flags); 164 spin_unlock_irqrestore(&pci_poke_lock, flags);
180} 165}
181 166
182/* Probe for all PCI controllers in the system. */
183extern void sabre_init(struct device_node *, const char *);
184extern void psycho_init(struct device_node *, const char *);
185extern void schizo_init(struct device_node *, const char *);
186extern void schizo_plus_init(struct device_node *, const char *);
187extern void tomatillo_init(struct device_node *, const char *);
188extern void sun4v_pci_init(struct device_node *, const char *);
189extern void fire_pci_init(struct device_node *, const char *);
190
191static struct {
192 char *model_name;
193 void (*init)(struct device_node *, const char *);
194} pci_controller_table[] __initdata = {
195 { "SUNW,sabre", sabre_init },
196 { "pci108e,a000", sabre_init },
197 { "pci108e,a001", sabre_init },
198 { "SUNW,psycho", psycho_init },
199 { "pci108e,8000", psycho_init },
200 { "SUNW,schizo", schizo_init },
201 { "pci108e,8001", schizo_init },
202 { "SUNW,schizo+", schizo_plus_init },
203 { "pci108e,8002", schizo_plus_init },
204 { "SUNW,tomatillo", tomatillo_init },
205 { "pci108e,a801", tomatillo_init },
206 { "SUNW,sun4v-pci", sun4v_pci_init },
207 { "pciex108e,80f0", fire_pci_init },
208};
209#define PCI_NUM_CONTROLLER_TYPES ARRAY_SIZE(pci_controller_table)
210
211static int __init pci_controller_init(const char *model_name, int namelen, struct device_node *dp)
212{
213 int i;
214
215 for (i = 0; i < PCI_NUM_CONTROLLER_TYPES; i++) {
216 if (!strncmp(model_name,
217 pci_controller_table[i].model_name,
218 namelen)) {
219 pci_controller_table[i].init(dp, model_name);
220 return 1;
221 }
222 }
223
224 return 0;
225}
226
227static int __init pci_controller_scan(int (*handler)(const char *, int, struct device_node *))
228{
229 struct device_node *dp;
230 int count = 0;
231
232 for_each_node_by_name(dp, "pci") {
233 struct property *prop;
234 int len;
235
236 prop = of_find_property(dp, "model", &len);
237 if (!prop)
238 prop = of_find_property(dp, "compatible", &len);
239
240 if (prop) {
241 const char *model = prop->value;
242 int item_len = 0;
243
244 /* Our value may be a multi-valued string in the
245 * case of some compatible properties. For sanity,
246 * only try the first one.
247 */
248 while (model[item_len] && len) {
249 len--;
250 item_len++;
251 }
252
253 if (handler(model, item_len, dp))
254 count++;
255 }
256 }
257
258 return count;
259}
260
261/* Find each controller in the system, attach and initialize
262 * software state structure for each and link into the
263 * pci_pbm_root. Setup the controller enough such
264 * that bus scanning can be done.
265 */
266static void __init pci_controller_probe(void)
267{
268 printk("PCI: Probing for controllers.\n");
269
270 pci_controller_scan(pci_controller_init);
271}
272
273static int ofpci_verbose; 167static int ofpci_verbose;
274 168
275static int __init ofpci_debug(char *str) 169static int __init ofpci_debug(char *str)
@@ -348,11 +242,12 @@ static void pci_parse_of_addrs(struct of_device *op,
348 } 242 }
349} 243}
350 244
351struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, 245static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
352 struct device_node *node, 246 struct device_node *node,
353 struct pci_bus *bus, int devfn) 247 struct pci_bus *bus, int devfn)
354{ 248{
355 struct dev_archdata *sd; 249 struct dev_archdata *sd;
250 struct of_device *op;
356 struct pci_dev *dev; 251 struct pci_dev *dev;
357 const char *type; 252 const char *type;
358 u32 class; 253 u32 class;
@@ -366,14 +261,17 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
366 sd->stc = &pbm->stc; 261 sd->stc = &pbm->stc;
367 sd->host_controller = pbm; 262 sd->host_controller = pbm;
368 sd->prom_node = node; 263 sd->prom_node = node;
369 sd->op = of_find_device_by_node(node); 264 sd->op = op = of_find_device_by_node(node);
370 sd->numa_node = pbm->numa_node; 265 sd->numa_node = pbm->numa_node;
371 266
372 sd = &sd->op->dev.archdata; 267 sd = &op->dev.archdata;
373 sd->iommu = pbm->iommu; 268 sd->iommu = pbm->iommu;
374 sd->stc = &pbm->stc; 269 sd->stc = &pbm->stc;
375 sd->numa_node = pbm->numa_node; 270 sd->numa_node = pbm->numa_node;
376 271
272 if (!strcmp(node->name, "ebus"))
273 of_propagate_archdata(op);
274
377 type = of_get_property(node, "device_type", NULL); 275 type = of_get_property(node, "device_type", NULL);
378 if (type == NULL) 276 if (type == NULL)
379 type = ""; 277 type = "";
@@ -775,15 +673,15 @@ static void __devinit pci_bus_register_of_sysfs(struct pci_bus *bus)
775 pci_bus_register_of_sysfs(child_bus); 673 pci_bus_register_of_sysfs(child_bus);
776} 674}
777 675
778struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm) 676struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
677 struct device *parent)
779{ 678{
780 struct device_node *node = pbm->prom_node; 679 struct device_node *node = pbm->op->node;
781 struct pci_bus *bus; 680 struct pci_bus *bus;
782 681
783 printk("PCI: Scanning PBM %s\n", node->full_name); 682 printk("PCI: Scanning PBM %s\n", node->full_name);
784 683
785 /* XXX parent device? XXX */ 684 bus = pci_create_bus(parent, pbm->pci_first_busno, pbm->pci_ops, pbm);
786 bus = pci_create_bus(NULL, pbm->pci_first_busno, pbm->pci_ops, pbm);
787 if (!bus) { 685 if (!bus) {
788 printk(KERN_ERR "Failed to create bus for %s\n", 686 printk(KERN_ERR "Failed to create bus for %s\n",
789 node->full_name); 687 node->full_name);
@@ -802,32 +700,6 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm)
802 return bus; 700 return bus;
803} 701}
804 702
805static void __init pci_scan_each_controller_bus(void)
806{
807 struct pci_pbm_info *pbm;
808
809 for (pbm = pci_pbm_root; pbm; pbm = pbm->next)
810 pbm->scan_bus(pbm);
811}
812
813extern void power_init(void);
814
815static int __init pcibios_init(void)
816{
817 pci_controller_probe();
818 if (pci_pbm_root == NULL)
819 return 0;
820
821 pci_scan_each_controller_bus();
822
823 ebus_init();
824 power_init();
825
826 return 0;
827}
828
829subsys_initcall(pcibios_init);
830
831void __devinit pcibios_fixup_bus(struct pci_bus *pbus) 703void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
832{ 704{
833 struct pci_pbm_info *pbm = pbus->sysdata; 705 struct pci_pbm_info *pbm = pbus->sysdata;
@@ -1105,14 +977,14 @@ int pcibus_to_node(struct pci_bus *pbus)
1105EXPORT_SYMBOL(pcibus_to_node); 977EXPORT_SYMBOL(pcibus_to_node);
1106#endif 978#endif
1107 979
1108/* Return the domain nuber for this pci bus */ 980/* Return the domain number for this pci bus */
1109 981
1110int pci_domain_nr(struct pci_bus *pbus) 982int pci_domain_nr(struct pci_bus *pbus)
1111{ 983{
1112 struct pci_pbm_info *pbm = pbus->sysdata; 984 struct pci_pbm_info *pbm = pbus->sysdata;
1113 int ret; 985 int ret;
1114 986
1115 if (pbm == NULL || pbm->parent == NULL) { 987 if (!pbm) {
1116 ret = -ENXIO; 988 ret = -ENXIO;
1117 } else { 989 } else {
1118 ret = pbm->index; 990 ret = pbm->index;
@@ -1126,7 +998,7 @@ EXPORT_SYMBOL(pci_domain_nr);
1126int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc) 998int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1127{ 999{
1128 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; 1000 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller;
1129 int virt_irq; 1001 unsigned int virt_irq;
1130 1002
1131 if (!pbm->setup_msi_irq) 1003 if (!pbm->setup_msi_irq)
1132 return -EINVAL; 1004 return -EINVAL;
@@ -1140,10 +1012,8 @@ void arch_teardown_msi_irq(unsigned int virt_irq)
1140 struct pci_dev *pdev = entry->dev; 1012 struct pci_dev *pdev = entry->dev;
1141 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; 1013 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller;
1142 1014
1143 if (!pbm->teardown_msi_irq) 1015 if (pbm->teardown_msi_irq)
1144 return; 1016 pbm->teardown_msi_irq(virt_irq, pdev);
1145
1146 return pbm->teardown_msi_irq(virt_irq, pdev);
1147} 1017}
1148#endif /* !(CONFIG_PCI_MSI) */ 1018#endif /* !(CONFIG_PCI_MSI) */
1149 1019
@@ -1215,5 +1085,3 @@ void pci_resource_to_user(const struct pci_dev *pdev, int bar,
1215 *start = rp->start - offset; 1085 *start = rp->start - offset;
1216 *end = rp->end - offset; 1086 *end = rp->end - offset;
1217} 1087}
1218
1219#endif /* !(CONFIG_PCI) */
diff --git a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c
index 09a5ec200c61..23b88082d0b2 100644
--- a/arch/sparc64/kernel/pci_common.c
+++ b/arch/sparc64/kernel/pci_common.c
@@ -314,12 +314,12 @@ struct pci_ops sun4v_pci_ops = {
314 314
315void pci_get_pbm_props(struct pci_pbm_info *pbm) 315void pci_get_pbm_props(struct pci_pbm_info *pbm)
316{ 316{
317 const u32 *val = of_get_property(pbm->prom_node, "bus-range", NULL); 317 const u32 *val = of_get_property(pbm->op->node, "bus-range", NULL);
318 318
319 pbm->pci_first_busno = val[0]; 319 pbm->pci_first_busno = val[0];
320 pbm->pci_last_busno = val[1]; 320 pbm->pci_last_busno = val[1];
321 321
322 val = of_get_property(pbm->prom_node, "ino-bitmap", NULL); 322 val = of_get_property(pbm->op->node, "ino-bitmap", NULL);
323 if (val) { 323 if (val) {
324 pbm->ino_bitmap = (((u64)val[1] << 32UL) | 324 pbm->ino_bitmap = (((u64)val[1] << 32UL) |
325 ((u64)val[0] << 0UL)); 325 ((u64)val[0] << 0UL));
@@ -365,7 +365,7 @@ static void pci_register_legacy_regions(struct resource *io_res,
365 365
366static void pci_register_iommu_region(struct pci_pbm_info *pbm) 366static void pci_register_iommu_region(struct pci_pbm_info *pbm)
367{ 367{
368 const u32 *vdma = of_get_property(pbm->prom_node, "virtual-dma", NULL); 368 const u32 *vdma = of_get_property(pbm->op->node, "virtual-dma", NULL);
369 369
370 if (vdma) { 370 if (vdma) {
371 struct resource *rp = kmalloc(sizeof(*rp), GFP_KERNEL); 371 struct resource *rp = kmalloc(sizeof(*rp), GFP_KERNEL);
@@ -389,7 +389,7 @@ void pci_determine_mem_io_space(struct pci_pbm_info *pbm)
389 int num_pbm_ranges; 389 int num_pbm_ranges;
390 390
391 saw_mem = saw_io = 0; 391 saw_mem = saw_io = 0;
392 pbm_ranges = of_get_property(pbm->prom_node, "ranges", &i); 392 pbm_ranges = of_get_property(pbm->op->node, "ranges", &i);
393 if (!pbm_ranges) { 393 if (!pbm_ranges) {
394 prom_printf("PCI: Fatal error, missing PBM ranges property " 394 prom_printf("PCI: Fatal error, missing PBM ranges property "
395 " for %s\n", 395 " for %s\n",
diff --git a/arch/sparc64/kernel/pci_fire.c b/arch/sparc64/kernel/pci_fire.c
index d23bb6f53cda..9462b68f4894 100644
--- a/arch/sparc64/kernel/pci_fire.c
+++ b/arch/sparc64/kernel/pci_fire.c
@@ -8,34 +8,16 @@
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/msi.h> 9#include <linux/msi.h>
10#include <linux/irq.h> 10#include <linux/irq.h>
11#include <linux/of_device.h>
11 12
12#include <asm/oplib.h>
13#include <asm/prom.h> 13#include <asm/prom.h>
14#include <asm/irq.h> 14#include <asm/irq.h>
15#include <asm/upa.h>
15 16
16#include "pci_impl.h" 17#include "pci_impl.h"
17 18
18#define fire_read(__reg) \ 19#define DRIVER_NAME "fire"
19({ u64 __ret; \ 20#define PFX DRIVER_NAME ": "
20 __asm__ __volatile__("ldxa [%1] %2, %0" \
21 : "=r" (__ret) \
22 : "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \
23 : "memory"); \
24 __ret; \
25})
26#define fire_write(__reg, __val) \
27 __asm__ __volatile__("stxa %0, [%1] %2" \
28 : /* no outputs */ \
29 : "r" (__val), "r" (__reg), \
30 "i" (ASI_PHYS_BYPASS_EC_E) \
31 : "memory")
32
33static void __init pci_fire_scan_bus(struct pci_pbm_info *pbm)
34{
35 pbm->pci_bus = pci_scan_one_pbm(pbm);
36
37 /* XXX register error interrupt handlers XXX */
38}
39 21
40#define FIRE_IOMMU_CONTROL 0x40000UL 22#define FIRE_IOMMU_CONTROL 0x40000UL
41#define FIRE_IOMMU_TSBBASE 0x40008UL 23#define FIRE_IOMMU_TSBBASE 0x40008UL
@@ -69,21 +51,21 @@ static int pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm)
69 /* 51 /*
70 * Invalidate TLB Entries. 52 * Invalidate TLB Entries.
71 */ 53 */
72 fire_write(iommu->iommu_flushinv, ~(u64)0); 54 upa_writeq(~(u64)0, iommu->iommu_flushinv);
73 55
74 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask, 56 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask,
75 pbm->numa_node); 57 pbm->numa_node);
76 if (err) 58 if (err)
77 return err; 59 return err;
78 60
79 fire_write(iommu->iommu_tsbbase, __pa(iommu->page_table) | 0x7UL); 61 upa_writeq(__pa(iommu->page_table) | 0x7UL, iommu->iommu_tsbbase);
80 62
81 control = fire_read(iommu->iommu_control); 63 control = upa_readq(iommu->iommu_control);
82 control |= (0x00000400 /* TSB cache snoop enable */ | 64 control |= (0x00000400 /* TSB cache snoop enable */ |
83 0x00000300 /* Cache mode */ | 65 0x00000300 /* Cache mode */ |
84 0x00000002 /* Bypass enable */ | 66 0x00000002 /* Bypass enable */ |
85 0x00000001 /* Translation enable */); 67 0x00000001 /* Translation enable */);
86 fire_write(iommu->iommu_control, control); 68 upa_writeq(control, iommu->iommu_control);
87 69
88 return 0; 70 return 0;
89} 71}
@@ -165,7 +147,7 @@ struct pci_msiq_entry {
165static int pci_fire_get_head(struct pci_pbm_info *pbm, unsigned long msiqid, 147static int pci_fire_get_head(struct pci_pbm_info *pbm, unsigned long msiqid,
166 unsigned long *head) 148 unsigned long *head)
167{ 149{
168 *head = fire_read(pbm->pbm_regs + EVENT_QUEUE_HEAD(msiqid)); 150 *head = upa_readq(pbm->pbm_regs + EVENT_QUEUE_HEAD(msiqid));
169 return 0; 151 return 0;
170} 152}
171 153
@@ -191,8 +173,7 @@ static int pci_fire_dequeue_msi(struct pci_pbm_info *pbm, unsigned long msiqid,
191 *msi = msi_num = ((ep->word0 & MSIQ_WORD0_DATA0) >> 173 *msi = msi_num = ((ep->word0 & MSIQ_WORD0_DATA0) >>
192 MSIQ_WORD0_DATA0_SHIFT); 174 MSIQ_WORD0_DATA0_SHIFT);
193 175
194 fire_write(pbm->pbm_regs + MSI_CLEAR(msi_num), 176 upa_writeq(MSI_CLEAR_EQWR_N, pbm->pbm_regs + MSI_CLEAR(msi_num));
195 MSI_CLEAR_EQWR_N);
196 177
197 /* Clear the entry. */ 178 /* Clear the entry. */
198 ep->word0 &= ~MSIQ_WORD0_FMT_TYPE; 179 ep->word0 &= ~MSIQ_WORD0_FMT_TYPE;
@@ -208,7 +189,7 @@ static int pci_fire_dequeue_msi(struct pci_pbm_info *pbm, unsigned long msiqid,
208static int pci_fire_set_head(struct pci_pbm_info *pbm, unsigned long msiqid, 189static int pci_fire_set_head(struct pci_pbm_info *pbm, unsigned long msiqid,
209 unsigned long head) 190 unsigned long head)
210{ 191{
211 fire_write(pbm->pbm_regs + EVENT_QUEUE_HEAD(msiqid), head); 192 upa_writeq(head, pbm->pbm_regs + EVENT_QUEUE_HEAD(msiqid));
212 return 0; 193 return 0;
213} 194}
214 195
@@ -217,17 +198,16 @@ static int pci_fire_msi_setup(struct pci_pbm_info *pbm, unsigned long msiqid,
217{ 198{
218 u64 val; 199 u64 val;
219 200
220 val = fire_read(pbm->pbm_regs + MSI_MAP(msi)); 201 val = upa_readq(pbm->pbm_regs + MSI_MAP(msi));
221 val &= ~(MSI_MAP_EQNUM); 202 val &= ~(MSI_MAP_EQNUM);
222 val |= msiqid; 203 val |= msiqid;
223 fire_write(pbm->pbm_regs + MSI_MAP(msi), val); 204 upa_writeq(val, pbm->pbm_regs + MSI_MAP(msi));
224 205
225 fire_write(pbm->pbm_regs + MSI_CLEAR(msi), 206 upa_writeq(MSI_CLEAR_EQWR_N, pbm->pbm_regs + MSI_CLEAR(msi));
226 MSI_CLEAR_EQWR_N);
227 207
228 val = fire_read(pbm->pbm_regs + MSI_MAP(msi)); 208 val = upa_readq(pbm->pbm_regs + MSI_MAP(msi));
229 val |= MSI_MAP_VALID; 209 val |= MSI_MAP_VALID;
230 fire_write(pbm->pbm_regs + MSI_MAP(msi), val); 210 upa_writeq(val, pbm->pbm_regs + MSI_MAP(msi));
231 211
232 return 0; 212 return 0;
233} 213}
@@ -237,12 +217,12 @@ static int pci_fire_msi_teardown(struct pci_pbm_info *pbm, unsigned long msi)
237 unsigned long msiqid; 217 unsigned long msiqid;
238 u64 val; 218 u64 val;
239 219
240 val = fire_read(pbm->pbm_regs + MSI_MAP(msi)); 220 val = upa_readq(pbm->pbm_regs + MSI_MAP(msi));
241 msiqid = (val & MSI_MAP_EQNUM); 221 msiqid = (val & MSI_MAP_EQNUM);
242 222
243 val &= ~MSI_MAP_VALID; 223 val &= ~MSI_MAP_VALID;
244 224
245 fire_write(pbm->pbm_regs + MSI_MAP(msi), val); 225 upa_writeq(val, pbm->pbm_regs + MSI_MAP(msi));
246 226
247 return 0; 227 return 0;
248} 228}
@@ -261,22 +241,19 @@ static int pci_fire_msiq_alloc(struct pci_pbm_info *pbm)
261 memset((char *)pages, 0, PAGE_SIZE << order); 241 memset((char *)pages, 0, PAGE_SIZE << order);
262 pbm->msi_queues = (void *) pages; 242 pbm->msi_queues = (void *) pages;
263 243
264 fire_write(pbm->pbm_regs + EVENT_QUEUE_BASE_ADDR_REG, 244 upa_writeq((EVENT_QUEUE_BASE_ADDR_ALL_ONES |
265 (EVENT_QUEUE_BASE_ADDR_ALL_ONES | 245 __pa(pbm->msi_queues)),
266 __pa(pbm->msi_queues))); 246 pbm->pbm_regs + EVENT_QUEUE_BASE_ADDR_REG);
267 247
268 fire_write(pbm->pbm_regs + IMONDO_DATA0, 248 upa_writeq(pbm->portid << 6, pbm->pbm_regs + IMONDO_DATA0);
269 pbm->portid << 6); 249 upa_writeq(0, pbm->pbm_regs + IMONDO_DATA1);
270 fire_write(pbm->pbm_regs + IMONDO_DATA1, 0);
271 250
272 fire_write(pbm->pbm_regs + MSI_32BIT_ADDR, 251 upa_writeq(pbm->msi32_start, pbm->pbm_regs + MSI_32BIT_ADDR);
273 pbm->msi32_start); 252 upa_writeq(pbm->msi64_start, pbm->pbm_regs + MSI_64BIT_ADDR);
274 fire_write(pbm->pbm_regs + MSI_64BIT_ADDR,
275 pbm->msi64_start);
276 253
277 for (i = 0; i < pbm->msiq_num; i++) { 254 for (i = 0; i < pbm->msiq_num; i++) {
278 fire_write(pbm->pbm_regs + EVENT_QUEUE_HEAD(i), 0); 255 upa_writeq(0, pbm->pbm_regs + EVENT_QUEUE_HEAD(i));
279 fire_write(pbm->pbm_regs + EVENT_QUEUE_TAIL(i), 0); 256 upa_writeq(0, pbm->pbm_regs + EVENT_QUEUE_TAIL(i));
280 } 257 }
281 258
282 return 0; 259 return 0;
@@ -310,9 +287,9 @@ static int pci_fire_msiq_build_irq(struct pci_pbm_info *pbm,
310 /* XXX iterate amongst the 4 IRQ controllers XXX */ 287 /* XXX iterate amongst the 4 IRQ controllers XXX */
311 int_ctrlr = (1UL << 6); 288 int_ctrlr = (1UL << 6);
312 289
313 val = fire_read(imap_reg); 290 val = upa_readq(imap_reg);
314 val |= (1UL << 63) | int_ctrlr; 291 val |= (1UL << 63) | int_ctrlr;
315 fire_write(imap_reg, val); 292 upa_writeq(val, imap_reg);
316 293
317 fixup = ((pbm->portid << 6) | devino) - int_ctrlr; 294 fixup = ((pbm->portid << 6) | devino) - int_ctrlr;
318 295
@@ -320,9 +297,8 @@ static int pci_fire_msiq_build_irq(struct pci_pbm_info *pbm,
320 if (!virt_irq) 297 if (!virt_irq)
321 return -ENOMEM; 298 return -ENOMEM;
322 299
323 fire_write(pbm->pbm_regs + 300 upa_writeq(EVENT_QUEUE_CONTROL_SET_EN,
324 EVENT_QUEUE_CONTROL_SET(msiqid), 301 pbm->pbm_regs + EVENT_QUEUE_CONTROL_SET(msiqid));
325 EVENT_QUEUE_CONTROL_SET_EN);
326 302
327 return virt_irq; 303 return virt_irq;
328} 304}
@@ -390,77 +366,65 @@ static void pci_fire_hw_init(struct pci_pbm_info *pbm)
390{ 366{
391 u64 val; 367 u64 val;
392 368
393 fire_write(pbm->controller_regs + FIRE_PARITY_CONTROL, 369 upa_writeq(FIRE_PARITY_ENAB,
394 FIRE_PARITY_ENAB); 370 pbm->controller_regs + FIRE_PARITY_CONTROL);
395 371
396 fire_write(pbm->controller_regs + FIRE_FATAL_RESET_CTL, 372 upa_writeq((FIRE_FATAL_RESET_SPARE |
397 (FIRE_FATAL_RESET_SPARE |
398 FIRE_FATAL_RESET_MB | 373 FIRE_FATAL_RESET_MB |
399 FIRE_FATAL_RESET_CPE | 374 FIRE_FATAL_RESET_CPE |
400 FIRE_FATAL_RESET_APE | 375 FIRE_FATAL_RESET_APE |
401 FIRE_FATAL_RESET_PIO | 376 FIRE_FATAL_RESET_PIO |
402 FIRE_FATAL_RESET_JW | 377 FIRE_FATAL_RESET_JW |
403 FIRE_FATAL_RESET_JI | 378 FIRE_FATAL_RESET_JI |
404 FIRE_FATAL_RESET_JR)); 379 FIRE_FATAL_RESET_JR),
380 pbm->controller_regs + FIRE_FATAL_RESET_CTL);
405 381
406 fire_write(pbm->controller_regs + FIRE_CORE_INTR_ENABLE, ~(u64)0); 382 upa_writeq(~(u64)0, pbm->controller_regs + FIRE_CORE_INTR_ENABLE);
407 383
408 val = fire_read(pbm->pbm_regs + FIRE_TLU_CTRL); 384 val = upa_readq(pbm->pbm_regs + FIRE_TLU_CTRL);
409 val |= (FIRE_TLU_CTRL_TIM | 385 val |= (FIRE_TLU_CTRL_TIM |
410 FIRE_TLU_CTRL_QDET | 386 FIRE_TLU_CTRL_QDET |
411 FIRE_TLU_CTRL_CFG); 387 FIRE_TLU_CTRL_CFG);
412 fire_write(pbm->pbm_regs + FIRE_TLU_CTRL, val); 388 upa_writeq(val, pbm->pbm_regs + FIRE_TLU_CTRL);
413 fire_write(pbm->pbm_regs + FIRE_TLU_DEV_CTRL, 0); 389 upa_writeq(0, pbm->pbm_regs + FIRE_TLU_DEV_CTRL);
414 fire_write(pbm->pbm_regs + FIRE_TLU_LINK_CTRL, 390 upa_writeq(FIRE_TLU_LINK_CTRL_CLK,
415 FIRE_TLU_LINK_CTRL_CLK); 391 pbm->pbm_regs + FIRE_TLU_LINK_CTRL);
416 392
417 fire_write(pbm->pbm_regs + FIRE_LPU_RESET, 0); 393 upa_writeq(0, pbm->pbm_regs + FIRE_LPU_RESET);
418 fire_write(pbm->pbm_regs + FIRE_LPU_LLCFG, 394 upa_writeq(FIRE_LPU_LLCFG_VC0, pbm->pbm_regs + FIRE_LPU_LLCFG);
419 FIRE_LPU_LLCFG_VC0); 395 upa_writeq((FIRE_LPU_FCTRL_UCTRL_N | FIRE_LPU_FCTRL_UCTRL_P),
420 fire_write(pbm->pbm_regs + FIRE_LPU_FCTRL_UCTRL, 396 pbm->pbm_regs + FIRE_LPU_FCTRL_UCTRL);
421 (FIRE_LPU_FCTRL_UCTRL_N | 397 upa_writeq(((0xffff << 16) | (0x0000 << 0)),
422 FIRE_LPU_FCTRL_UCTRL_P)); 398 pbm->pbm_regs + FIRE_LPU_TXL_FIFOP);
423 fire_write(pbm->pbm_regs + FIRE_LPU_TXL_FIFOP, 399 upa_writeq(3000000, pbm->pbm_regs + FIRE_LPU_LTSSM_CFG2);
424 ((0xffff << 16) | (0x0000 << 0))); 400 upa_writeq(500000, pbm->pbm_regs + FIRE_LPU_LTSSM_CFG3);
425 fire_write(pbm->pbm_regs + FIRE_LPU_LTSSM_CFG2, 3000000); 401 upa_writeq((2 << 16) | (140 << 8),
426 fire_write(pbm->pbm_regs + FIRE_LPU_LTSSM_CFG3, 500000); 402 pbm->pbm_regs + FIRE_LPU_LTSSM_CFG4);
427 fire_write(pbm->pbm_regs + FIRE_LPU_LTSSM_CFG4, 403 upa_writeq(0, pbm->pbm_regs + FIRE_LPU_LTSSM_CFG5);
428 (2 << 16) | (140 << 8)); 404
429 fire_write(pbm->pbm_regs + FIRE_LPU_LTSSM_CFG5, 0); 405 upa_writeq(~(u64)0, pbm->pbm_regs + FIRE_DMC_IENAB);
430 406 upa_writeq(0, pbm->pbm_regs + FIRE_DMC_DBG_SEL_A);
431 fire_write(pbm->pbm_regs + FIRE_DMC_IENAB, ~(u64)0); 407 upa_writeq(0, pbm->pbm_regs + FIRE_DMC_DBG_SEL_B);
432 fire_write(pbm->pbm_regs + FIRE_DMC_DBG_SEL_A, 0); 408
433 fire_write(pbm->pbm_regs + FIRE_DMC_DBG_SEL_B, 0); 409 upa_writeq(~(u64)0, pbm->pbm_regs + FIRE_PEC_IENAB);
434
435 fire_write(pbm->pbm_regs + FIRE_PEC_IENAB, ~(u64)0);
436} 410}
437 411
438static int __init pci_fire_pbm_init(struct pci_controller_info *p, 412static int __init pci_fire_pbm_init(struct pci_pbm_info *pbm,
439 struct device_node *dp, u32 portid) 413 struct of_device *op, u32 portid)
440{ 414{
441 const struct linux_prom64_registers *regs; 415 const struct linux_prom64_registers *regs;
442 struct pci_pbm_info *pbm; 416 struct device_node *dp = op->node;
443 int err; 417 int err;
444 418
445 if ((portid & 1) == 0)
446 pbm = &p->pbm_A;
447 else
448 pbm = &p->pbm_B;
449
450 pbm->next = pci_pbm_root;
451 pci_pbm_root = pbm;
452
453 pbm->numa_node = -1; 419 pbm->numa_node = -1;
454 420
455 pbm->scan_bus = pci_fire_scan_bus;
456 pbm->pci_ops = &sun4u_pci_ops; 421 pbm->pci_ops = &sun4u_pci_ops;
457 pbm->config_space_reg_bits = 12; 422 pbm->config_space_reg_bits = 12;
458 423
459 pbm->index = pci_num_pbms++; 424 pbm->index = pci_num_pbms++;
460 425
461 pbm->portid = portid; 426 pbm->portid = portid;
462 pbm->parent = p; 427 pbm->op = op;
463 pbm->prom_node = dp;
464 pbm->name = dp->full_name; 428 pbm->name = dp->full_name;
465 429
466 regs = of_get_property(dp, "reg", NULL); 430 regs = of_get_property(dp, "reg", NULL);
@@ -481,53 +445,77 @@ static int __init pci_fire_pbm_init(struct pci_controller_info *p,
481 445
482 pci_fire_msi_init(pbm); 446 pci_fire_msi_init(pbm);
483 447
484 return 0; 448 pbm->pci_bus = pci_scan_one_pbm(pbm, &op->dev);
485} 449
450 /* XXX register error interrupt handlers XXX */
451
452 pbm->next = pci_pbm_root;
453 pci_pbm_root = pbm;
486 454
487static inline int portid_compare(u32 x, u32 y)
488{
489 if (x == (y ^ 1))
490 return 1;
491 return 0; 455 return 0;
492} 456}
493 457
494void __init fire_pci_init(struct device_node *dp, const char *model_name) 458static int __devinit fire_probe(struct of_device *op,
459 const struct of_device_id *match)
495{ 460{
496 struct pci_controller_info *p; 461 struct device_node *dp = op->node;
497 u32 portid = of_getintprop_default(dp, "portid", 0xff);
498 struct iommu *iommu;
499 struct pci_pbm_info *pbm; 462 struct pci_pbm_info *pbm;
463 struct iommu *iommu;
464 u32 portid;
465 int err;
500 466
501 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) { 467 portid = of_getintprop_default(dp, "portid", 0xff);
502 if (portid_compare(pbm->portid, portid)) { 468
503 if (pci_fire_pbm_init(pbm->parent, dp, portid)) 469 err = -ENOMEM;
504 goto fatal_memory_error; 470 pbm = kzalloc(sizeof(*pbm), GFP_KERNEL);
505 return; 471 if (!pbm) {
506 } 472 printk(KERN_ERR PFX "Cannot allocate pci_pbminfo.\n");
473 goto out_err;
507 } 474 }
508 475
509 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); 476 iommu = kzalloc(sizeof(struct iommu), GFP_KERNEL);
510 if (!p) 477 if (!iommu) {
511 goto fatal_memory_error; 478 printk(KERN_ERR PFX "Cannot allocate PBM iommu.\n");
479 goto out_free_controller;
480 }
512 481
513 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 482 pbm->iommu = iommu;
514 if (!iommu)
515 goto fatal_memory_error;
516 483
517 p->pbm_A.iommu = iommu; 484 err = pci_fire_pbm_init(pbm, op, portid);
485 if (err)
486 goto out_free_iommu;
518 487
519 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 488 dev_set_drvdata(&op->dev, pbm);
520 if (!iommu)
521 goto fatal_memory_error;
522 489
523 p->pbm_B.iommu = iommu; 490 return 0;
524 491
525 if (pci_fire_pbm_init(p, dp, portid)) 492out_free_iommu:
526 goto fatal_memory_error; 493 kfree(pbm->iommu);
494
495out_free_controller:
496 kfree(pbm);
527 497
528 return; 498out_err:
499 return err;
500}
501
502static struct of_device_id __initdata fire_match[] = {
503 {
504 .name = "pci",
505 .compatible = "pciex108e,80f0",
506 },
507 {},
508};
529 509
530fatal_memory_error: 510static struct of_platform_driver fire_driver = {
531 prom_printf("PCI_FIRE: Fatal memory allocation error.\n"); 511 .name = DRIVER_NAME,
532 prom_halt(); 512 .match_table = fire_match,
513 .probe = fire_probe,
514};
515
516static int __init fire_init(void)
517{
518 return of_register_driver(&fire_driver, &of_bus_type);
533} 519}
520
521subsys_initcall(fire_init);
diff --git a/arch/sparc64/kernel/pci_impl.h b/arch/sparc64/kernel/pci_impl.h
index c385d126be11..03186824327e 100644
--- a/arch/sparc64/kernel/pci_impl.h
+++ b/arch/sparc64/kernel/pci_impl.h
@@ -10,6 +10,7 @@
10#include <linux/spinlock.h> 10#include <linux/spinlock.h>
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/msi.h> 12#include <linux/msi.h>
13#include <linux/of_device.h>
13#include <asm/io.h> 14#include <asm/io.h>
14#include <asm/prom.h> 15#include <asm/prom.h>
15#include <asm/iommu.h> 16#include <asm/iommu.h>
@@ -56,15 +57,11 @@ struct sparc64_msiq_cookie {
56}; 57};
57#endif 58#endif
58 59
59struct pci_controller_info;
60
61struct pci_pbm_info { 60struct pci_pbm_info {
62 struct pci_pbm_info *next; 61 struct pci_pbm_info *next;
62 struct pci_pbm_info *sibling;
63 int index; 63 int index;
64 64
65 /* PCI controller we sit under. */
66 struct pci_controller_info *parent;
67
68 /* Physical address base of controller registers. */ 65 /* Physical address base of controller registers. */
69 unsigned long controller_regs; 66 unsigned long controller_regs;
70 67
@@ -94,7 +91,7 @@ struct pci_pbm_info {
94 char *name; 91 char *name;
95 92
96 /* OBP specific information. */ 93 /* OBP specific information. */
97 struct device_node *prom_node; 94 struct of_device *op;
98 u64 ino_bitmap; 95 u64 ino_bitmap;
99 96
100 /* PBM I/O and Memory space resources. */ 97 /* PBM I/O and Memory space resources. */
@@ -107,6 +104,10 @@ struct pci_pbm_info {
107 /* This will be 12 on PCI-E controllers, 8 elsewhere. */ 104 /* This will be 12 on PCI-E controllers, 8 elsewhere. */
108 unsigned long config_space_reg_bits; 105 unsigned long config_space_reg_bits;
109 106
107 unsigned long pci_afsr;
108 unsigned long pci_afar;
109 unsigned long pci_csr;
110
110 /* State of 66MHz capabilities on this PBM. */ 111 /* State of 66MHz capabilities on this PBM. */
111 int is_66mhz_capable; 112 int is_66mhz_capable;
112 int all_devs_66mhz; 113 int all_devs_66mhz;
@@ -146,25 +147,19 @@ struct pci_pbm_info {
146 unsigned int pci_first_busno; 147 unsigned int pci_first_busno;
147 unsigned int pci_last_busno; 148 unsigned int pci_last_busno;
148 struct pci_bus *pci_bus; 149 struct pci_bus *pci_bus;
149 void (*scan_bus)(struct pci_pbm_info *);
150 struct pci_ops *pci_ops; 150 struct pci_ops *pci_ops;
151 151
152 int numa_node; 152 int numa_node;
153}; 153};
154 154
155struct pci_controller_info {
156 /* The PCI bus modules controlled by us. */
157 struct pci_pbm_info pbm_A;
158 struct pci_pbm_info pbm_B;
159};
160
161extern struct pci_pbm_info *pci_pbm_root; 155extern struct pci_pbm_info *pci_pbm_root;
162 156
163extern int pci_num_pbms; 157extern int pci_num_pbms;
164 158
165/* PCI bus scanning and fixup support. */ 159/* PCI bus scanning and fixup support. */
166extern void pci_get_pbm_props(struct pci_pbm_info *pbm); 160extern void pci_get_pbm_props(struct pci_pbm_info *pbm);
167extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm); 161extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
162 struct device *parent);
168extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm); 163extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
169 164
170/* Error reporting support. */ 165/* Error reporting support. */
@@ -183,4 +178,8 @@ extern void pci_config_write32(u32 *addr, u32 val);
183extern struct pci_ops sun4u_pci_ops; 178extern struct pci_ops sun4u_pci_ops;
184extern struct pci_ops sun4v_pci_ops; 179extern struct pci_ops sun4v_pci_ops;
185 180
181extern volatile int pci_poke_in_progress;
182extern volatile int pci_poke_cpu;
183extern volatile int pci_poke_faulted;
184
186#endif /* !(PCI_IMPL_H) */ 185#endif /* !(PCI_IMPL_H) */
diff --git a/arch/sparc64/kernel/pci_msi.c b/arch/sparc64/kernel/pci_msi.c
index 60c71e350212..2e680f34f727 100644
--- a/arch/sparc64/kernel/pci_msi.c
+++ b/arch/sparc64/kernel/pci_msi.c
@@ -323,7 +323,7 @@ void sparc64_pbm_msi_init(struct pci_pbm_info *pbm,
323 const u32 *val; 323 const u32 *val;
324 int len; 324 int len;
325 325
326 val = of_get_property(pbm->prom_node, "#msi-eqs", &len); 326 val = of_get_property(pbm->op->node, "#msi-eqs", &len);
327 if (!val || len != 4) 327 if (!val || len != 4)
328 goto no_msi; 328 goto no_msi;
329 pbm->msiq_num = *val; 329 pbm->msiq_num = *val;
@@ -346,16 +346,16 @@ void sparc64_pbm_msi_init(struct pci_pbm_info *pbm,
346 u32 msi64_len; 346 u32 msi64_len;
347 } *arng; 347 } *arng;
348 348
349 val = of_get_property(pbm->prom_node, "msi-eq-size", &len); 349 val = of_get_property(pbm->op->node, "msi-eq-size", &len);
350 if (!val || len != 4) 350 if (!val || len != 4)
351 goto no_msi; 351 goto no_msi;
352 352
353 pbm->msiq_ent_count = *val; 353 pbm->msiq_ent_count = *val;
354 354
355 mqp = of_get_property(pbm->prom_node, 355 mqp = of_get_property(pbm->op->node,
356 "msi-eq-to-devino", &len); 356 "msi-eq-to-devino", &len);
357 if (!mqp) 357 if (!mqp)
358 mqp = of_get_property(pbm->prom_node, 358 mqp = of_get_property(pbm->op->node,
359 "msi-eq-devino", &len); 359 "msi-eq-devino", &len);
360 if (!mqp || len != sizeof(struct msiq_prop)) 360 if (!mqp || len != sizeof(struct msiq_prop))
361 goto no_msi; 361 goto no_msi;
@@ -363,27 +363,27 @@ void sparc64_pbm_msi_init(struct pci_pbm_info *pbm,
363 pbm->msiq_first = mqp->first_msiq; 363 pbm->msiq_first = mqp->first_msiq;
364 pbm->msiq_first_devino = mqp->first_devino; 364 pbm->msiq_first_devino = mqp->first_devino;
365 365
366 val = of_get_property(pbm->prom_node, "#msi", &len); 366 val = of_get_property(pbm->op->node, "#msi", &len);
367 if (!val || len != 4) 367 if (!val || len != 4)
368 goto no_msi; 368 goto no_msi;
369 pbm->msi_num = *val; 369 pbm->msi_num = *val;
370 370
371 mrng = of_get_property(pbm->prom_node, "msi-ranges", &len); 371 mrng = of_get_property(pbm->op->node, "msi-ranges", &len);
372 if (!mrng || len != sizeof(struct msi_range_prop)) 372 if (!mrng || len != sizeof(struct msi_range_prop))
373 goto no_msi; 373 goto no_msi;
374 pbm->msi_first = mrng->first_msi; 374 pbm->msi_first = mrng->first_msi;
375 375
376 val = of_get_property(pbm->prom_node, "msi-data-mask", &len); 376 val = of_get_property(pbm->op->node, "msi-data-mask", &len);
377 if (!val || len != 4) 377 if (!val || len != 4)
378 goto no_msi; 378 goto no_msi;
379 pbm->msi_data_mask = *val; 379 pbm->msi_data_mask = *val;
380 380
381 val = of_get_property(pbm->prom_node, "msix-data-width", &len); 381 val = of_get_property(pbm->op->node, "msix-data-width", &len);
382 if (!val || len != 4) 382 if (!val || len != 4)
383 goto no_msi; 383 goto no_msi;
384 pbm->msix_data_width = *val; 384 pbm->msix_data_width = *val;
385 385
386 arng = of_get_property(pbm->prom_node, "msi-address-ranges", 386 arng = of_get_property(pbm->op->node, "msi-address-ranges",
387 &len); 387 &len);
388 if (!arng || len != sizeof(struct addr_range_prop)) 388 if (!arng || len != sizeof(struct addr_range_prop))
389 goto no_msi; 389 goto no_msi;
diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
index f85b6bebb0be..dfb3ec892987 100644
--- a/arch/sparc64/kernel/pci_psycho.c
+++ b/arch/sparc64/kernel/pci_psycho.c
@@ -17,29 +17,14 @@
17#include <asm/irq.h> 17#include <asm/irq.h>
18#include <asm/starfire.h> 18#include <asm/starfire.h>
19#include <asm/prom.h> 19#include <asm/prom.h>
20#include <asm/oplib.h> 20#include <asm/upa.h>
21 21
22#include "pci_impl.h" 22#include "pci_impl.h"
23#include "iommu_common.h" 23#include "iommu_common.h"
24#include "psycho_common.h"
24 25
25/* All PSYCHO registers are 64-bits. The following accessor 26#define DRIVER_NAME "psycho"
26 * routines are how they are accessed. The REG parameter 27#define PFX DRIVER_NAME ": "
27 * is a physical address.
28 */
29#define psycho_read(__reg) \
30({ u64 __ret; \
31 __asm__ __volatile__("ldxa [%1] %2, %0" \
32 : "=r" (__ret) \
33 : "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \
34 : "memory"); \
35 __ret; \
36})
37#define psycho_write(__reg, __val) \
38 __asm__ __volatile__("stxa %0, [%1] %2" \
39 : /* no outputs */ \
40 : "r" (__val), "r" (__reg), \
41 "i" (ASI_PHYS_BYPASS_EC_E) \
42 : "memory")
43 28
44/* Misc. PSYCHO PCI controller register offsets and definitions. */ 29/* Misc. PSYCHO PCI controller register offsets and definitions. */
45#define PSYCHO_CONTROL 0x0010UL 30#define PSYCHO_CONTROL 0x0010UL
@@ -67,37 +52,7 @@
67#define PSYCHO_PCICTRL_RESV4 0x00000000000000c0UL /* Reserved */ 52#define PSYCHO_PCICTRL_RESV4 0x00000000000000c0UL /* Reserved */
68#define PSYCHO_PCICTRL_AEN 0x000000000000003fUL /* PCI DVMA Arbitration Enable */ 53#define PSYCHO_PCICTRL_AEN 0x000000000000003fUL /* PCI DVMA Arbitration Enable */
69 54
70/* U2P Programmer's Manual, page 13-55, configuration space
71 * address format:
72 *
73 * 32 24 23 16 15 11 10 8 7 2 1 0
74 * ---------------------------------------------------------
75 * |0 0 0 0 0 0 0 0 1| bus | device | function | reg | 0 0 |
76 * ---------------------------------------------------------
77 */
78#define PSYCHO_CONFIG_BASE(PBM) \
79 ((PBM)->config_space | (1UL << 24))
80#define PSYCHO_CONFIG_ENCODE(BUS, DEVFN, REG) \
81 (((unsigned long)(BUS) << 16) | \
82 ((unsigned long)(DEVFN) << 8) | \
83 ((unsigned long)(REG)))
84
85static void *psycho_pci_config_mkaddr(struct pci_pbm_info *pbm,
86 unsigned char bus,
87 unsigned int devfn,
88 int where)
89{
90 if (!pbm)
91 return NULL;
92 return (void *)
93 (PSYCHO_CONFIG_BASE(pbm) |
94 PSYCHO_CONFIG_ENCODE(bus, devfn, where));
95}
96
97/* PSYCHO error handling support. */ 55/* PSYCHO error handling support. */
98enum psycho_error_type {
99 UE_ERR, CE_ERR, PCI_ERR
100};
101 56
102/* Helper function of IOMMU error checking, which checks out 57/* Helper function of IOMMU error checking, which checks out
103 * the state of the streaming buffers. The IOMMU lock is 58 * the state of the streaming buffers. The IOMMU lock is
@@ -122,129 +77,10 @@ enum psycho_error_type {
122#define PSYCHO_STC_DATA_B 0xc000UL 77#define PSYCHO_STC_DATA_B 0xc000UL
123#define PSYCHO_STC_ERR_A 0xb400UL 78#define PSYCHO_STC_ERR_A 0xb400UL
124#define PSYCHO_STC_ERR_B 0xc400UL 79#define PSYCHO_STC_ERR_B 0xc400UL
125#define PSYCHO_STCERR_WRITE 0x0000000000000002UL /* Write Error */
126#define PSYCHO_STCERR_READ 0x0000000000000001UL /* Read Error */
127#define PSYCHO_STC_TAG_A 0xb800UL 80#define PSYCHO_STC_TAG_A 0xb800UL
128#define PSYCHO_STC_TAG_B 0xc800UL 81#define PSYCHO_STC_TAG_B 0xc800UL
129#define PSYCHO_STCTAG_PPN 0x0fffffff00000000UL /* Physical Page Number */
130#define PSYCHO_STCTAG_VPN 0x00000000ffffe000UL /* Virtual Page Number */
131#define PSYCHO_STCTAG_VALID 0x0000000000000002UL /* Valid */
132#define PSYCHO_STCTAG_WRITE 0x0000000000000001UL /* Writable */
133#define PSYCHO_STC_LINE_A 0xb900UL 82#define PSYCHO_STC_LINE_A 0xb900UL
134#define PSYCHO_STC_LINE_B 0xc900UL 83#define PSYCHO_STC_LINE_B 0xc900UL
135#define PSYCHO_STCLINE_LINDX 0x0000000001e00000UL /* LRU Index */
136#define PSYCHO_STCLINE_SPTR 0x00000000001f8000UL /* Dirty Data Start Pointer */
137#define PSYCHO_STCLINE_LADDR 0x0000000000007f00UL /* Line Address */
138#define PSYCHO_STCLINE_EPTR 0x00000000000000fcUL /* Dirty Data End Pointer */
139#define PSYCHO_STCLINE_VALID 0x0000000000000002UL /* Valid */
140#define PSYCHO_STCLINE_FOFN 0x0000000000000001UL /* Fetch Outstanding / Flush Necessary */
141
142static DEFINE_SPINLOCK(stc_buf_lock);
143static unsigned long stc_error_buf[128];
144static unsigned long stc_tag_buf[16];
145static unsigned long stc_line_buf[16];
146
147static void __psycho_check_one_stc(struct pci_pbm_info *pbm,
148 int is_pbm_a)
149{
150 struct strbuf *strbuf = &pbm->stc;
151 unsigned long regbase = pbm->controller_regs;
152 unsigned long err_base, tag_base, line_base;
153 u64 control;
154 int i;
155
156 if (is_pbm_a) {
157 err_base = regbase + PSYCHO_STC_ERR_A;
158 tag_base = regbase + PSYCHO_STC_TAG_A;
159 line_base = regbase + PSYCHO_STC_LINE_A;
160 } else {
161 err_base = regbase + PSYCHO_STC_ERR_B;
162 tag_base = regbase + PSYCHO_STC_TAG_B;
163 line_base = regbase + PSYCHO_STC_LINE_B;
164 }
165
166 spin_lock(&stc_buf_lock);
167
168 /* This is __REALLY__ dangerous. When we put the
169 * streaming buffer into diagnostic mode to probe
170 * it's tags and error status, we _must_ clear all
171 * of the line tag valid bits before re-enabling
172 * the streaming buffer. If any dirty data lives
173 * in the STC when we do this, we will end up
174 * invalidating it before it has a chance to reach
175 * main memory.
176 */
177 control = psycho_read(strbuf->strbuf_control);
178 psycho_write(strbuf->strbuf_control,
179 (control | PSYCHO_STRBUF_CTRL_DENAB));
180 for (i = 0; i < 128; i++) {
181 unsigned long val;
182
183 val = psycho_read(err_base + (i * 8UL));
184 psycho_write(err_base + (i * 8UL), 0UL);
185 stc_error_buf[i] = val;
186 }
187 for (i = 0; i < 16; i++) {
188 stc_tag_buf[i] = psycho_read(tag_base + (i * 8UL));
189 stc_line_buf[i] = psycho_read(line_base + (i * 8UL));
190 psycho_write(tag_base + (i * 8UL), 0UL);
191 psycho_write(line_base + (i * 8UL), 0UL);
192 }
193
194 /* OK, state is logged, exit diagnostic mode. */
195 psycho_write(strbuf->strbuf_control, control);
196
197 for (i = 0; i < 16; i++) {
198 int j, saw_error, first, last;
199
200 saw_error = 0;
201 first = i * 8;
202 last = first + 8;
203 for (j = first; j < last; j++) {
204 unsigned long errval = stc_error_buf[j];
205 if (errval != 0) {
206 saw_error++;
207 printk("%s: STC_ERR(%d)[wr(%d)rd(%d)]\n",
208 pbm->name,
209 j,
210 (errval & PSYCHO_STCERR_WRITE) ? 1 : 0,
211 (errval & PSYCHO_STCERR_READ) ? 1 : 0);
212 }
213 }
214 if (saw_error != 0) {
215 unsigned long tagval = stc_tag_buf[i];
216 unsigned long lineval = stc_line_buf[i];
217 printk("%s: STC_TAG(%d)[PA(%016lx)VA(%08lx)V(%d)W(%d)]\n",
218 pbm->name,
219 i,
220 ((tagval & PSYCHO_STCTAG_PPN) >> 19UL),
221 (tagval & PSYCHO_STCTAG_VPN),
222 ((tagval & PSYCHO_STCTAG_VALID) ? 1 : 0),
223 ((tagval & PSYCHO_STCTAG_WRITE) ? 1 : 0));
224 printk("%s: STC_LINE(%d)[LIDX(%lx)SP(%lx)LADDR(%lx)EP(%lx)"
225 "V(%d)FOFN(%d)]\n",
226 pbm->name,
227 i,
228 ((lineval & PSYCHO_STCLINE_LINDX) >> 21UL),
229 ((lineval & PSYCHO_STCLINE_SPTR) >> 15UL),
230 ((lineval & PSYCHO_STCLINE_LADDR) >> 8UL),
231 ((lineval & PSYCHO_STCLINE_EPTR) >> 2UL),
232 ((lineval & PSYCHO_STCLINE_VALID) ? 1 : 0),
233 ((lineval & PSYCHO_STCLINE_FOFN) ? 1 : 0));
234 }
235 }
236
237 spin_unlock(&stc_buf_lock);
238}
239
240static void __psycho_check_stc_error(struct pci_pbm_info *pbm,
241 unsigned long afsr,
242 unsigned long afar,
243 enum psycho_error_type type)
244{
245 __psycho_check_one_stc(pbm,
246 (pbm == &pbm->parent->pbm_A));
247}
248 84
249/* When an Uncorrectable Error or a PCI Error happens, we 85/* When an Uncorrectable Error or a PCI Error happens, we
250 * interrogate the IOMMU state to see if it is the cause. 86 * interrogate the IOMMU state to see if it is the cause.
@@ -271,122 +107,7 @@ static void __psycho_check_stc_error(struct pci_pbm_info *pbm,
271#define PSYCHO_IOMMU_TSBBASE 0x0208UL 107#define PSYCHO_IOMMU_TSBBASE 0x0208UL
272#define PSYCHO_IOMMU_FLUSH 0x0210UL 108#define PSYCHO_IOMMU_FLUSH 0x0210UL
273#define PSYCHO_IOMMU_TAG 0xa580UL 109#define PSYCHO_IOMMU_TAG 0xa580UL
274#define PSYCHO_IOMMU_TAG_ERRSTS (0x3UL << 23UL)
275#define PSYCHO_IOMMU_TAG_ERR (0x1UL << 22UL)
276#define PSYCHO_IOMMU_TAG_WRITE (0x1UL << 21UL)
277#define PSYCHO_IOMMU_TAG_STREAM (0x1UL << 20UL)
278#define PSYCHO_IOMMU_TAG_SIZE (0x1UL << 19UL)
279#define PSYCHO_IOMMU_TAG_VPAGE 0x7ffffUL
280#define PSYCHO_IOMMU_DATA 0xa600UL 110#define PSYCHO_IOMMU_DATA 0xa600UL
281#define PSYCHO_IOMMU_DATA_VALID (1UL << 30UL)
282#define PSYCHO_IOMMU_DATA_CACHE (1UL << 28UL)
283#define PSYCHO_IOMMU_DATA_PPAGE 0xfffffffUL
284static void psycho_check_iommu_error(struct pci_pbm_info *pbm,
285 unsigned long afsr,
286 unsigned long afar,
287 enum psycho_error_type type)
288{
289 struct iommu *iommu = pbm->iommu;
290 unsigned long iommu_tag[16];
291 unsigned long iommu_data[16];
292 unsigned long flags;
293 u64 control;
294 int i;
295
296 spin_lock_irqsave(&iommu->lock, flags);
297 control = psycho_read(iommu->iommu_control);
298 if (control & PSYCHO_IOMMU_CTRL_XLTEERR) {
299 char *type_string;
300
301 /* Clear the error encountered bit. */
302 control &= ~PSYCHO_IOMMU_CTRL_XLTEERR;
303 psycho_write(iommu->iommu_control, control);
304
305 switch((control & PSYCHO_IOMMU_CTRL_XLTESTAT) >> 25UL) {
306 case 0:
307 type_string = "Protection Error";
308 break;
309 case 1:
310 type_string = "Invalid Error";
311 break;
312 case 2:
313 type_string = "TimeOut Error";
314 break;
315 case 3:
316 default:
317 type_string = "ECC Error";
318 break;
319 };
320 printk("%s: IOMMU Error, type[%s]\n",
321 pbm->name, type_string);
322
323 /* Put the IOMMU into diagnostic mode and probe
324 * it's TLB for entries with error status.
325 *
326 * It is very possible for another DVMA to occur
327 * while we do this probe, and corrupt the system
328 * further. But we are so screwed at this point
329 * that we are likely to crash hard anyways, so
330 * get as much diagnostic information to the
331 * console as we can.
332 */
333 psycho_write(iommu->iommu_control,
334 control | PSYCHO_IOMMU_CTRL_DENAB);
335 for (i = 0; i < 16; i++) {
336 unsigned long base = pbm->controller_regs;
337
338 iommu_tag[i] =
339 psycho_read(base + PSYCHO_IOMMU_TAG + (i * 8UL));
340 iommu_data[i] =
341 psycho_read(base + PSYCHO_IOMMU_DATA + (i * 8UL));
342
343 /* Now clear out the entry. */
344 psycho_write(base + PSYCHO_IOMMU_TAG + (i * 8UL), 0);
345 psycho_write(base + PSYCHO_IOMMU_DATA + (i * 8UL), 0);
346 }
347
348 /* Leave diagnostic mode. */
349 psycho_write(iommu->iommu_control, control);
350
351 for (i = 0; i < 16; i++) {
352 unsigned long tag, data;
353
354 tag = iommu_tag[i];
355 if (!(tag & PSYCHO_IOMMU_TAG_ERR))
356 continue;
357
358 data = iommu_data[i];
359 switch((tag & PSYCHO_IOMMU_TAG_ERRSTS) >> 23UL) {
360 case 0:
361 type_string = "Protection Error";
362 break;
363 case 1:
364 type_string = "Invalid Error";
365 break;
366 case 2:
367 type_string = "TimeOut Error";
368 break;
369 case 3:
370 default:
371 type_string = "ECC Error";
372 break;
373 };
374 printk("%s: IOMMU TAG(%d)[error(%s) wr(%d) str(%d) sz(%dK) vpg(%08lx)]\n",
375 pbm->name, i, type_string,
376 ((tag & PSYCHO_IOMMU_TAG_WRITE) ? 1 : 0),
377 ((tag & PSYCHO_IOMMU_TAG_STREAM) ? 1 : 0),
378 ((tag & PSYCHO_IOMMU_TAG_SIZE) ? 64 : 8),
379 (tag & PSYCHO_IOMMU_TAG_VPAGE) << IOMMU_PAGE_SHIFT);
380 printk("%s: IOMMU DATA(%d)[valid(%d) cache(%d) ppg(%016lx)]\n",
381 pbm->name, i,
382 ((data & PSYCHO_IOMMU_DATA_VALID) ? 1 : 0),
383 ((data & PSYCHO_IOMMU_DATA_CACHE) ? 1 : 0),
384 (data & PSYCHO_IOMMU_DATA_PPAGE) << IOMMU_PAGE_SHIFT);
385 }
386 }
387 __psycho_check_stc_error(pbm, afsr, afar, type);
388 spin_unlock_irqrestore(&iommu->lock, flags);
389}
390 111
391/* Uncorrectable Errors. Cause of the error and the address are 112/* Uncorrectable Errors. Cause of the error and the address are
392 * recorded in the UE_AFSR and UE_AFAR of PSYCHO. They are errors 113 * recorded in the UE_AFSR and UE_AFAR of PSYCHO. They are errors
@@ -410,15 +131,14 @@ static void psycho_check_iommu_error(struct pci_pbm_info *pbm,
410static irqreturn_t psycho_ue_intr(int irq, void *dev_id) 131static irqreturn_t psycho_ue_intr(int irq, void *dev_id)
411{ 132{
412 struct pci_pbm_info *pbm = dev_id; 133 struct pci_pbm_info *pbm = dev_id;
413 struct pci_controller_info *p = pbm->parent;
414 unsigned long afsr_reg = pbm->controller_regs + PSYCHO_UE_AFSR; 134 unsigned long afsr_reg = pbm->controller_regs + PSYCHO_UE_AFSR;
415 unsigned long afar_reg = pbm->controller_regs + PSYCHO_UE_AFAR; 135 unsigned long afar_reg = pbm->controller_regs + PSYCHO_UE_AFAR;
416 unsigned long afsr, afar, error_bits; 136 unsigned long afsr, afar, error_bits;
417 int reported; 137 int reported;
418 138
419 /* Latch uncorrectable error status. */ 139 /* Latch uncorrectable error status. */
420 afar = psycho_read(afar_reg); 140 afar = upa_readq(afar_reg);
421 afsr = psycho_read(afsr_reg); 141 afsr = upa_readq(afsr_reg);
422 142
423 /* Clear the primary/secondary error status bits. */ 143 /* Clear the primary/secondary error status bits. */
424 error_bits = afsr & 144 error_bits = afsr &
@@ -426,7 +146,7 @@ static irqreturn_t psycho_ue_intr(int irq, void *dev_id)
426 PSYCHO_UEAFSR_SPIO | PSYCHO_UEAFSR_SDRD | PSYCHO_UEAFSR_SDWR); 146 PSYCHO_UEAFSR_SPIO | PSYCHO_UEAFSR_SDRD | PSYCHO_UEAFSR_SDWR);
427 if (!error_bits) 147 if (!error_bits)
428 return IRQ_NONE; 148 return IRQ_NONE;
429 psycho_write(afsr_reg, error_bits); 149 upa_writeq(error_bits, afsr_reg);
430 150
431 /* Log the error. */ 151 /* Log the error. */
432 printk("%s: Uncorrectable Error, primary error type[%s]\n", 152 printk("%s: Uncorrectable Error, primary error type[%s]\n",
@@ -463,8 +183,9 @@ static irqreturn_t psycho_ue_intr(int irq, void *dev_id)
463 printk("]\n"); 183 printk("]\n");
464 184
465 /* Interrogate both IOMMUs for error status. */ 185 /* Interrogate both IOMMUs for error status. */
466 psycho_check_iommu_error(&p->pbm_A, afsr, afar, UE_ERR); 186 psycho_check_iommu_error(pbm, afsr, afar, UE_ERR);
467 psycho_check_iommu_error(&p->pbm_B, afsr, afar, UE_ERR); 187 if (pbm->sibling)
188 psycho_check_iommu_error(pbm->sibling, afsr, afar, UE_ERR);
468 189
469 return IRQ_HANDLED; 190 return IRQ_HANDLED;
470} 191}
@@ -495,8 +216,8 @@ static irqreturn_t psycho_ce_intr(int irq, void *dev_id)
495 int reported; 216 int reported;
496 217
497 /* Latch error status. */ 218 /* Latch error status. */
498 afar = psycho_read(afar_reg); 219 afar = upa_readq(afar_reg);
499 afsr = psycho_read(afsr_reg); 220 afsr = upa_readq(afsr_reg);
500 221
501 /* Clear primary/secondary error status bits. */ 222 /* Clear primary/secondary error status bits. */
502 error_bits = afsr & 223 error_bits = afsr &
@@ -504,7 +225,7 @@ static irqreturn_t psycho_ce_intr(int irq, void *dev_id)
504 PSYCHO_CEAFSR_SPIO | PSYCHO_CEAFSR_SDRD | PSYCHO_CEAFSR_SDWR); 225 PSYCHO_CEAFSR_SPIO | PSYCHO_CEAFSR_SDRD | PSYCHO_CEAFSR_SDWR);
505 if (!error_bits) 226 if (!error_bits)
506 return IRQ_NONE; 227 return IRQ_NONE;
507 psycho_write(afsr_reg, error_bits); 228 upa_writeq(error_bits, afsr_reg);
508 229
509 /* Log the error. */ 230 /* Log the error. */
510 printk("%s: Correctable Error, primary error type[%s]\n", 231 printk("%s: Correctable Error, primary error type[%s]\n",
@@ -554,164 +275,9 @@ static irqreturn_t psycho_ce_intr(int irq, void *dev_id)
554 */ 275 */
555#define PSYCHO_PCI_AFSR_A 0x2010UL 276#define PSYCHO_PCI_AFSR_A 0x2010UL
556#define PSYCHO_PCI_AFSR_B 0x4010UL 277#define PSYCHO_PCI_AFSR_B 0x4010UL
557#define PSYCHO_PCIAFSR_PMA 0x8000000000000000UL /* Primary Master Abort Error */
558#define PSYCHO_PCIAFSR_PTA 0x4000000000000000UL /* Primary Target Abort Error */
559#define PSYCHO_PCIAFSR_PRTRY 0x2000000000000000UL /* Primary Excessive Retries */
560#define PSYCHO_PCIAFSR_PPERR 0x1000000000000000UL /* Primary Parity Error */
561#define PSYCHO_PCIAFSR_SMA 0x0800000000000000UL /* Secondary Master Abort Error */
562#define PSYCHO_PCIAFSR_STA 0x0400000000000000UL /* Secondary Target Abort Error */
563#define PSYCHO_PCIAFSR_SRTRY 0x0200000000000000UL /* Secondary Excessive Retries */
564#define PSYCHO_PCIAFSR_SPERR 0x0100000000000000UL /* Secondary Parity Error */
565#define PSYCHO_PCIAFSR_RESV1 0x00ff000000000000UL /* Reserved */
566#define PSYCHO_PCIAFSR_BMSK 0x0000ffff00000000UL /* Bytemask of failed transfer */
567#define PSYCHO_PCIAFSR_BLK 0x0000000080000000UL /* Trans was block operation */
568#define PSYCHO_PCIAFSR_RESV2 0x0000000040000000UL /* Reserved */
569#define PSYCHO_PCIAFSR_MID 0x000000003e000000UL /* MID causing the error */
570#define PSYCHO_PCIAFSR_RESV3 0x0000000001ffffffUL /* Reserved */
571#define PSYCHO_PCI_AFAR_A 0x2018UL 278#define PSYCHO_PCI_AFAR_A 0x2018UL
572#define PSYCHO_PCI_AFAR_B 0x4018UL 279#define PSYCHO_PCI_AFAR_B 0x4018UL
573 280
574static irqreturn_t psycho_pcierr_intr_other(struct pci_pbm_info *pbm, int is_pbm_a)
575{
576 unsigned long csr_reg, csr, csr_error_bits;
577 irqreturn_t ret = IRQ_NONE;
578 u16 stat, *addr;
579
580 if (is_pbm_a) {
581 csr_reg = pbm->controller_regs + PSYCHO_PCIA_CTRL;
582 } else {
583 csr_reg = pbm->controller_regs + PSYCHO_PCIB_CTRL;
584 }
585 csr = psycho_read(csr_reg);
586 csr_error_bits =
587 csr & (PSYCHO_PCICTRL_SBH_ERR | PSYCHO_PCICTRL_SERR);
588 if (csr_error_bits) {
589 /* Clear the errors. */
590 psycho_write(csr_reg, csr);
591
592 /* Log 'em. */
593 if (csr_error_bits & PSYCHO_PCICTRL_SBH_ERR)
594 printk("%s: PCI streaming byte hole error asserted.\n",
595 pbm->name);
596 if (csr_error_bits & PSYCHO_PCICTRL_SERR)
597 printk("%s: PCI SERR signal asserted.\n", pbm->name);
598 ret = IRQ_HANDLED;
599 }
600 addr = psycho_pci_config_mkaddr(pbm, pbm->pci_first_busno,
601 0, PCI_STATUS);
602 pci_config_read16(addr, &stat);
603 if (stat & (PCI_STATUS_PARITY |
604 PCI_STATUS_SIG_TARGET_ABORT |
605 PCI_STATUS_REC_TARGET_ABORT |
606 PCI_STATUS_REC_MASTER_ABORT |
607 PCI_STATUS_SIG_SYSTEM_ERROR)) {
608 printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
609 pbm->name, stat);
610 pci_config_write16(addr, 0xffff);
611 ret = IRQ_HANDLED;
612 }
613 return ret;
614}
615
616static irqreturn_t psycho_pcierr_intr(int irq, void *dev_id)
617{
618 struct pci_pbm_info *pbm = dev_id;
619 struct pci_controller_info *p = pbm->parent;
620 unsigned long afsr_reg, afar_reg;
621 unsigned long afsr, afar, error_bits;
622 int is_pbm_a, reported;
623
624 is_pbm_a = (pbm == &pbm->parent->pbm_A);
625 if (is_pbm_a) {
626 afsr_reg = p->pbm_A.controller_regs + PSYCHO_PCI_AFSR_A;
627 afar_reg = p->pbm_A.controller_regs + PSYCHO_PCI_AFAR_A;
628 } else {
629 afsr_reg = p->pbm_A.controller_regs + PSYCHO_PCI_AFSR_B;
630 afar_reg = p->pbm_A.controller_regs + PSYCHO_PCI_AFAR_B;
631 }
632
633 /* Latch error status. */
634 afar = psycho_read(afar_reg);
635 afsr = psycho_read(afsr_reg);
636
637 /* Clear primary/secondary error status bits. */
638 error_bits = afsr &
639 (PSYCHO_PCIAFSR_PMA | PSYCHO_PCIAFSR_PTA |
640 PSYCHO_PCIAFSR_PRTRY | PSYCHO_PCIAFSR_PPERR |
641 PSYCHO_PCIAFSR_SMA | PSYCHO_PCIAFSR_STA |
642 PSYCHO_PCIAFSR_SRTRY | PSYCHO_PCIAFSR_SPERR);
643 if (!error_bits)
644 return psycho_pcierr_intr_other(pbm, is_pbm_a);
645 psycho_write(afsr_reg, error_bits);
646
647 /* Log the error. */
648 printk("%s: PCI Error, primary error type[%s]\n",
649 pbm->name,
650 (((error_bits & PSYCHO_PCIAFSR_PMA) ?
651 "Master Abort" :
652 ((error_bits & PSYCHO_PCIAFSR_PTA) ?
653 "Target Abort" :
654 ((error_bits & PSYCHO_PCIAFSR_PRTRY) ?
655 "Excessive Retries" :
656 ((error_bits & PSYCHO_PCIAFSR_PPERR) ?
657 "Parity Error" : "???"))))));
658 printk("%s: bytemask[%04lx] UPA_MID[%02lx] was_block(%d)\n",
659 pbm->name,
660 (afsr & PSYCHO_PCIAFSR_BMSK) >> 32UL,
661 (afsr & PSYCHO_PCIAFSR_MID) >> 25UL,
662 (afsr & PSYCHO_PCIAFSR_BLK) ? 1 : 0);
663 printk("%s: PCI AFAR [%016lx]\n", pbm->name, afar);
664 printk("%s: PCI Secondary errors [", pbm->name);
665 reported = 0;
666 if (afsr & PSYCHO_PCIAFSR_SMA) {
667 reported++;
668 printk("(Master Abort)");
669 }
670 if (afsr & PSYCHO_PCIAFSR_STA) {
671 reported++;
672 printk("(Target Abort)");
673 }
674 if (afsr & PSYCHO_PCIAFSR_SRTRY) {
675 reported++;
676 printk("(Excessive Retries)");
677 }
678 if (afsr & PSYCHO_PCIAFSR_SPERR) {
679 reported++;
680 printk("(Parity Error)");
681 }
682 if (!reported)
683 printk("(none)");
684 printk("]\n");
685
686 /* For the error types shown, scan PBM's PCI bus for devices
687 * which have logged that error type.
688 */
689
690 /* If we see a Target Abort, this could be the result of an
691 * IOMMU translation error of some sort. It is extremely
692 * useful to log this information as usually it indicates
693 * a bug in the IOMMU support code or a PCI device driver.
694 */
695 if (error_bits & (PSYCHO_PCIAFSR_PTA | PSYCHO_PCIAFSR_STA)) {
696 psycho_check_iommu_error(pbm, afsr, afar, PCI_ERR);
697 pci_scan_for_target_abort(pbm, pbm->pci_bus);
698 }
699 if (error_bits & (PSYCHO_PCIAFSR_PMA | PSYCHO_PCIAFSR_SMA))
700 pci_scan_for_master_abort(pbm, pbm->pci_bus);
701
702 /* For excessive retries, PSYCHO/PBM will abort the device
703 * and there is no way to specifically check for excessive
704 * retries in the config space status registers. So what
705 * we hope is that we'll catch it via the master/target
706 * abort events.
707 */
708
709 if (error_bits & (PSYCHO_PCIAFSR_PPERR | PSYCHO_PCIAFSR_SPERR))
710 pci_scan_for_parity_error(pbm, pbm->pci_bus);
711
712 return IRQ_HANDLED;
713}
714
715/* XXX What about PowerFail/PowerManagement??? -DaveM */ 281/* XXX What about PowerFail/PowerManagement??? -DaveM */
716#define PSYCHO_ECC_CTRL 0x0020 282#define PSYCHO_ECC_CTRL 0x0020
717#define PSYCHO_ECCCTRL_EE 0x8000000000000000UL /* Enable ECC Checking */ 283#define PSYCHO_ECCCTRL_EE 0x8000000000000000UL /* Enable ECC Checking */
@@ -719,7 +285,7 @@ static irqreturn_t psycho_pcierr_intr(int irq, void *dev_id)
719#define PSYCHO_ECCCTRL_CE 0x2000000000000000UL /* Enable CE INterrupts */ 285#define PSYCHO_ECCCTRL_CE 0x2000000000000000UL /* Enable CE INterrupts */
720static void psycho_register_error_handlers(struct pci_pbm_info *pbm) 286static void psycho_register_error_handlers(struct pci_pbm_info *pbm)
721{ 287{
722 struct of_device *op = of_find_device_by_node(pbm->prom_node); 288 struct of_device *op = of_find_device_by_node(pbm->op->node);
723 unsigned long base = pbm->controller_regs; 289 unsigned long base = pbm->controller_regs;
724 u64 tmp; 290 u64 tmp;
725 int err; 291 int err;
@@ -762,27 +328,26 @@ static void psycho_register_error_handlers(struct pci_pbm_info *pbm)
762 "err=%d\n", pbm->name, err); 328 "err=%d\n", pbm->name, err);
763 329
764 /* Enable UE and CE interrupts for controller. */ 330 /* Enable UE and CE interrupts for controller. */
765 psycho_write(base + PSYCHO_ECC_CTRL, 331 upa_writeq((PSYCHO_ECCCTRL_EE |
766 (PSYCHO_ECCCTRL_EE | 332 PSYCHO_ECCCTRL_UE |
767 PSYCHO_ECCCTRL_UE | 333 PSYCHO_ECCCTRL_CE), base + PSYCHO_ECC_CTRL);
768 PSYCHO_ECCCTRL_CE));
769 334
770 /* Enable PCI Error interrupts and clear error 335 /* Enable PCI Error interrupts and clear error
771 * bits for each PBM. 336 * bits for each PBM.
772 */ 337 */
773 tmp = psycho_read(base + PSYCHO_PCIA_CTRL); 338 tmp = upa_readq(base + PSYCHO_PCIA_CTRL);
774 tmp |= (PSYCHO_PCICTRL_SERR | 339 tmp |= (PSYCHO_PCICTRL_SERR |
775 PSYCHO_PCICTRL_SBH_ERR | 340 PSYCHO_PCICTRL_SBH_ERR |
776 PSYCHO_PCICTRL_EEN); 341 PSYCHO_PCICTRL_EEN);
777 tmp &= ~(PSYCHO_PCICTRL_SBH_INT); 342 tmp &= ~(PSYCHO_PCICTRL_SBH_INT);
778 psycho_write(base + PSYCHO_PCIA_CTRL, tmp); 343 upa_writeq(tmp, base + PSYCHO_PCIA_CTRL);
779 344
780 tmp = psycho_read(base + PSYCHO_PCIB_CTRL); 345 tmp = upa_readq(base + PSYCHO_PCIB_CTRL);
781 tmp |= (PSYCHO_PCICTRL_SERR | 346 tmp |= (PSYCHO_PCICTRL_SERR |
782 PSYCHO_PCICTRL_SBH_ERR | 347 PSYCHO_PCICTRL_SBH_ERR |
783 PSYCHO_PCICTRL_EEN); 348 PSYCHO_PCICTRL_EEN);
784 tmp &= ~(PSYCHO_PCICTRL_SBH_INT); 349 tmp &= ~(PSYCHO_PCICTRL_SBH_INT);
785 psycho_write(base + PSYCHO_PCIB_CTRL, tmp); 350 upa_writeq(tmp, base + PSYCHO_PCIB_CTRL);
786} 351}
787 352
788/* PSYCHO boot time probing and initialization. */ 353/* PSYCHO boot time probing and initialization. */
@@ -803,11 +368,12 @@ static void pbm_config_busmastering(struct pci_pbm_info *pbm)
803 pci_config_write8(addr, 64); 368 pci_config_write8(addr, 64);
804} 369}
805 370
806static void __init psycho_scan_bus(struct pci_pbm_info *pbm) 371static void __init psycho_scan_bus(struct pci_pbm_info *pbm,
372 struct device *parent)
807{ 373{
808 pbm_config_busmastering(pbm); 374 pbm_config_busmastering(pbm);
809 pbm->is_66mhz_capable = 0; 375 pbm->is_66mhz_capable = 0;
810 pbm->pci_bus = pci_scan_one_pbm(pbm); 376 pbm->pci_bus = pci_scan_one_pbm(pbm, parent);
811 377
812 /* After the PCI bus scan is complete, we can register 378 /* After the PCI bus scan is complete, we can register
813 * the error interrupt handlers. 379 * the error interrupt handlers.
@@ -815,61 +381,6 @@ static void __init psycho_scan_bus(struct pci_pbm_info *pbm)
815 psycho_register_error_handlers(pbm); 381 psycho_register_error_handlers(pbm);
816} 382}
817 383
818static int psycho_iommu_init(struct pci_pbm_info *pbm)
819{
820 struct iommu *iommu = pbm->iommu;
821 unsigned long i;
822 u64 control;
823 int err;
824
825 /* Register addresses. */
826 iommu->iommu_control = pbm->controller_regs + PSYCHO_IOMMU_CONTROL;
827 iommu->iommu_tsbbase = pbm->controller_regs + PSYCHO_IOMMU_TSBBASE;
828 iommu->iommu_flush = pbm->controller_regs + PSYCHO_IOMMU_FLUSH;
829 iommu->iommu_tags = iommu->iommu_flush + (0xa580UL - 0x0210UL);
830
831 /* PSYCHO's IOMMU lacks ctx flushing. */
832 iommu->iommu_ctxflush = 0;
833
834 /* We use the main control register of PSYCHO as the write
835 * completion register.
836 */
837 iommu->write_complete_reg = pbm->controller_regs + PSYCHO_CONTROL;
838
839 /*
840 * Invalidate TLB Entries.
841 */
842 control = psycho_read(pbm->controller_regs + PSYCHO_IOMMU_CONTROL);
843 control |= PSYCHO_IOMMU_CTRL_DENAB;
844 psycho_write(pbm->controller_regs + PSYCHO_IOMMU_CONTROL, control);
845 for(i = 0; i < 16; i++) {
846 psycho_write(pbm->controller_regs + PSYCHO_IOMMU_TAG + (i * 8UL), 0);
847 psycho_write(pbm->controller_regs + PSYCHO_IOMMU_DATA + (i * 8UL), 0);
848 }
849
850 /* Leave diag mode enabled for full-flushing done
851 * in pci_iommu.c
852 */
853 err = iommu_table_init(iommu, IO_TSB_SIZE, 0xc0000000, 0xffffffff,
854 pbm->numa_node);
855 if (err)
856 return err;
857
858 psycho_write(pbm->controller_regs + PSYCHO_IOMMU_TSBBASE,
859 __pa(iommu->page_table));
860
861 control = psycho_read(pbm->controller_regs + PSYCHO_IOMMU_CONTROL);
862 control &= ~(PSYCHO_IOMMU_CTRL_TSBSZ | PSYCHO_IOMMU_CTRL_TBWSZ);
863 control |= (PSYCHO_IOMMU_TSBSZ_128K | PSYCHO_IOMMU_CTRL_ENAB);
864 psycho_write(pbm->controller_regs + PSYCHO_IOMMU_CONTROL, control);
865
866 /* If necessary, hook us up for starfire IRQ translations. */
867 if (this_is_starfire)
868 starfire_hookup(pbm->portid);
869
870 return 0;
871}
872
873#define PSYCHO_IRQ_RETRY 0x1a00UL 384#define PSYCHO_IRQ_RETRY 0x1a00UL
874#define PSYCHO_PCIA_DIAG 0x2020UL 385#define PSYCHO_PCIA_DIAG 0x2020UL
875#define PSYCHO_PCIB_DIAG 0x4020UL 386#define PSYCHO_PCIB_DIAG 0x4020UL
@@ -886,28 +397,28 @@ static void psycho_controller_hwinit(struct pci_pbm_info *pbm)
886{ 397{
887 u64 tmp; 398 u64 tmp;
888 399
889 psycho_write(pbm->controller_regs + PSYCHO_IRQ_RETRY, 5); 400 upa_writeq(5, pbm->controller_regs + PSYCHO_IRQ_RETRY);
890 401
891 /* Enable arbiter for all PCI slots. */ 402 /* Enable arbiter for all PCI slots. */
892 tmp = psycho_read(pbm->controller_regs + PSYCHO_PCIA_CTRL); 403 tmp = upa_readq(pbm->controller_regs + PSYCHO_PCIA_CTRL);
893 tmp |= PSYCHO_PCICTRL_AEN; 404 tmp |= PSYCHO_PCICTRL_AEN;
894 psycho_write(pbm->controller_regs + PSYCHO_PCIA_CTRL, tmp); 405 upa_writeq(tmp, pbm->controller_regs + PSYCHO_PCIA_CTRL);
895 406
896 tmp = psycho_read(pbm->controller_regs + PSYCHO_PCIB_CTRL); 407 tmp = upa_readq(pbm->controller_regs + PSYCHO_PCIB_CTRL);
897 tmp |= PSYCHO_PCICTRL_AEN; 408 tmp |= PSYCHO_PCICTRL_AEN;
898 psycho_write(pbm->controller_regs + PSYCHO_PCIB_CTRL, tmp); 409 upa_writeq(tmp, pbm->controller_regs + PSYCHO_PCIB_CTRL);
899 410
900 /* Disable DMA write / PIO read synchronization on 411 /* Disable DMA write / PIO read synchronization on
901 * both PCI bus segments. 412 * both PCI bus segments.
902 * [ U2P Erratum 1243770, STP2223BGA data sheet ] 413 * [ U2P Erratum 1243770, STP2223BGA data sheet ]
903 */ 414 */
904 tmp = psycho_read(pbm->controller_regs + PSYCHO_PCIA_DIAG); 415 tmp = upa_readq(pbm->controller_regs + PSYCHO_PCIA_DIAG);
905 tmp |= PSYCHO_PCIDIAG_DDWSYNC; 416 tmp |= PSYCHO_PCIDIAG_DDWSYNC;
906 psycho_write(pbm->controller_regs + PSYCHO_PCIA_DIAG, tmp); 417 upa_writeq(tmp, pbm->controller_regs + PSYCHO_PCIA_DIAG);
907 418
908 tmp = psycho_read(pbm->controller_regs + PSYCHO_PCIB_DIAG); 419 tmp = upa_readq(pbm->controller_regs + PSYCHO_PCIB_DIAG);
909 tmp |= PSYCHO_PCIDIAG_DDWSYNC; 420 tmp |= PSYCHO_PCIDIAG_DDWSYNC;
910 psycho_write(pbm->controller_regs + PSYCHO_PCIB_DIAG, tmp); 421 upa_writeq(tmp, pbm->controller_regs + PSYCHO_PCIB_DIAG);
911} 422}
912 423
913static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm, 424static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm,
@@ -920,10 +431,16 @@ static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm,
920 pbm->stc.strbuf_control = base + PSYCHO_STRBUF_CONTROL_A; 431 pbm->stc.strbuf_control = base + PSYCHO_STRBUF_CONTROL_A;
921 pbm->stc.strbuf_pflush = base + PSYCHO_STRBUF_FLUSH_A; 432 pbm->stc.strbuf_pflush = base + PSYCHO_STRBUF_FLUSH_A;
922 pbm->stc.strbuf_fsync = base + PSYCHO_STRBUF_FSYNC_A; 433 pbm->stc.strbuf_fsync = base + PSYCHO_STRBUF_FSYNC_A;
434 pbm->stc.strbuf_err_stat = base + PSYCHO_STC_ERR_A;
435 pbm->stc.strbuf_tag_diag = base + PSYCHO_STC_TAG_A;
436 pbm->stc.strbuf_line_diag= base + PSYCHO_STC_LINE_A;
923 } else { 437 } else {
924 pbm->stc.strbuf_control = base + PSYCHO_STRBUF_CONTROL_B; 438 pbm->stc.strbuf_control = base + PSYCHO_STRBUF_CONTROL_B;
925 pbm->stc.strbuf_pflush = base + PSYCHO_STRBUF_FLUSH_B; 439 pbm->stc.strbuf_pflush = base + PSYCHO_STRBUF_FLUSH_B;
926 pbm->stc.strbuf_fsync = base + PSYCHO_STRBUF_FSYNC_B; 440 pbm->stc.strbuf_fsync = base + PSYCHO_STRBUF_FSYNC_B;
441 pbm->stc.strbuf_err_stat = base + PSYCHO_STC_ERR_B;
442 pbm->stc.strbuf_tag_diag = base + PSYCHO_STC_TAG_B;
443 pbm->stc.strbuf_line_diag= base + PSYCHO_STC_LINE_B;
927 } 444 }
928 /* PSYCHO's streaming buffer lacks ctx flushing. */ 445 /* PSYCHO's streaming buffer lacks ctx flushing. */
929 pbm->stc.strbuf_ctxflush = 0; 446 pbm->stc.strbuf_ctxflush = 0;
@@ -946,7 +463,7 @@ static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm,
946 */ 463 */
947#undef PSYCHO_STRBUF_RERUN_ENABLE 464#undef PSYCHO_STRBUF_RERUN_ENABLE
948#undef PSYCHO_STRBUF_RERUN_DISABLE 465#undef PSYCHO_STRBUF_RERUN_DISABLE
949 control = psycho_read(pbm->stc.strbuf_control); 466 control = upa_readq(pbm->stc.strbuf_control);
950 control |= PSYCHO_STRBUF_CTRL_ENAB; 467 control |= PSYCHO_STRBUF_CTRL_ENAB;
951 control &= ~(PSYCHO_STRBUF_CTRL_LENAB | PSYCHO_STRBUF_CTRL_LPTR); 468 control &= ~(PSYCHO_STRBUF_CTRL_LENAB | PSYCHO_STRBUF_CTRL_LPTR);
952#ifdef PSYCHO_STRBUF_RERUN_ENABLE 469#ifdef PSYCHO_STRBUF_RERUN_ENABLE
@@ -956,7 +473,7 @@ static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm,
956 control |= PSYCHO_STRBUF_CTRL_RRDIS; 473 control |= PSYCHO_STRBUF_CTRL_RRDIS;
957#endif 474#endif
958#endif 475#endif
959 psycho_write(pbm->stc.strbuf_control, control); 476 upa_writeq(control, pbm->stc.strbuf_control);
960 477
961 pbm->stc.strbuf_enabled = 1; 478 pbm->stc.strbuf_enabled = 1;
962} 479}
@@ -968,111 +485,134 @@ static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm,
968#define PSYCHO_MEMSPACE_B 0x180000000UL 485#define PSYCHO_MEMSPACE_B 0x180000000UL
969#define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL 486#define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL
970 487
971static void __init psycho_pbm_init(struct pci_controller_info *p, 488static void __init psycho_pbm_init(struct pci_pbm_info *pbm,
972 struct device_node *dp, int is_pbm_a) 489 struct of_device *op, int is_pbm_a)
973{ 490{
974 struct property *prop; 491 psycho_pbm_init_common(pbm, op, "PSYCHO", PBM_CHIP_TYPE_PSYCHO);
975 struct pci_pbm_info *pbm; 492 psycho_pbm_strbuf_init(pbm, is_pbm_a);
976 493 psycho_scan_bus(pbm, &op->dev);
977 if (is_pbm_a) 494}
978 pbm = &p->pbm_A;
979 else
980 pbm = &p->pbm_B;
981
982 pbm->next = pci_pbm_root;
983 pci_pbm_root = pbm;
984
985 pbm->numa_node = -1;
986
987 pbm->scan_bus = psycho_scan_bus;
988 pbm->pci_ops = &sun4u_pci_ops;
989 pbm->config_space_reg_bits = 8;
990
991 pbm->index = pci_num_pbms++;
992
993 pbm->chip_type = PBM_CHIP_TYPE_PSYCHO;
994 pbm->chip_version = 0;
995 prop = of_find_property(dp, "version#", NULL);
996 if (prop)
997 pbm->chip_version = *(int *) prop->value;
998 pbm->chip_revision = 0;
999 prop = of_find_property(dp, "module-revision#", NULL);
1000 if (prop)
1001 pbm->chip_revision = *(int *) prop->value;
1002
1003 pbm->parent = p;
1004 pbm->prom_node = dp;
1005 pbm->name = dp->full_name;
1006
1007 printk("%s: PSYCHO PCI Bus Module ver[%x:%x]\n",
1008 pbm->name,
1009 pbm->chip_version, pbm->chip_revision);
1010
1011 pci_determine_mem_io_space(pbm);
1012 495
1013 pci_get_pbm_props(pbm); 496static struct pci_pbm_info * __devinit psycho_find_sibling(u32 upa_portid)
497{
498 struct pci_pbm_info *pbm;
1014 499
1015 psycho_pbm_strbuf_init(pbm, is_pbm_a); 500 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) {
501 if (pbm->portid == upa_portid)
502 return pbm;
503 }
504 return NULL;
1016} 505}
1017 506
1018#define PSYCHO_CONFIGSPACE 0x001000000UL 507#define PSYCHO_CONFIGSPACE 0x001000000UL
1019 508
1020void __init psycho_init(struct device_node *dp, char *model_name) 509static int __devinit psycho_probe(struct of_device *op,
510 const struct of_device_id *match)
1021{ 511{
1022 struct linux_prom64_registers *pr_regs; 512 const struct linux_prom64_registers *pr_regs;
1023 struct pci_controller_info *p; 513 struct device_node *dp = op->node;
1024 struct pci_pbm_info *pbm; 514 struct pci_pbm_info *pbm;
1025 struct iommu *iommu; 515 struct iommu *iommu;
1026 struct property *prop; 516 int is_pbm_a, err;
1027 u32 upa_portid; 517 u32 upa_portid;
1028 int is_pbm_a;
1029 518
1030 upa_portid = 0xff; 519 upa_portid = of_getintprop_default(dp, "upa-portid", 0xff);
1031 prop = of_find_property(dp, "upa-portid", NULL);
1032 if (prop)
1033 upa_portid = *(u32 *) prop->value;
1034 520
1035 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) { 521 err = -ENOMEM;
1036 struct pci_controller_info *p = pbm->parent; 522 pbm = kzalloc(sizeof(*pbm), GFP_KERNEL);
523 if (!pbm) {
524 printk(KERN_ERR PFX "Cannot allocate pci_pbm_info.\n");
525 goto out_err;
526 }
1037 527
1038 if (p->pbm_A.portid == upa_portid) { 528 pbm->sibling = psycho_find_sibling(upa_portid);
1039 is_pbm_a = (p->pbm_A.prom_node == NULL); 529 if (pbm->sibling) {
1040 psycho_pbm_init(p, dp, is_pbm_a); 530 iommu = pbm->sibling->iommu;
1041 return; 531 } else {
532 iommu = kzalloc(sizeof(struct iommu), GFP_KERNEL);
533 if (!iommu) {
534 printk(KERN_ERR PFX "Cannot allocate PBM iommu.\n");
535 goto out_free_controller;
1042 } 536 }
1043 } 537 }
1044 538
1045 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); 539 pbm->iommu = iommu;
1046 if (!p) 540 pbm->portid = upa_portid;
1047 goto fatal_memory_error;
1048 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
1049 if (!iommu)
1050 goto fatal_memory_error;
1051 541
1052 p->pbm_A.iommu = p->pbm_B.iommu = iommu; 542 pr_regs = of_get_property(dp, "reg", NULL);
543 err = -ENODEV;
544 if (!pr_regs) {
545 printk(KERN_ERR PFX "No reg property.\n");
546 goto out_free_iommu;
547 }
1053 548
1054 p->pbm_A.portid = upa_portid; 549 is_pbm_a = ((pr_regs[0].phys_addr & 0x6000) == 0x2000);
1055 p->pbm_B.portid = upa_portid;
1056 550
1057 prop = of_find_property(dp, "reg", NULL); 551 pbm->controller_regs = pr_regs[2].phys_addr;
1058 pr_regs = prop->value; 552 pbm->config_space = (pr_regs[2].phys_addr + PSYCHO_CONFIGSPACE);
1059 553
1060 p->pbm_A.controller_regs = pr_regs[2].phys_addr; 554 if (is_pbm_a) {
1061 p->pbm_B.controller_regs = pr_regs[2].phys_addr; 555 pbm->pci_afsr = pbm->controller_regs + PSYCHO_PCI_AFSR_A;
556 pbm->pci_afar = pbm->controller_regs + PSYCHO_PCI_AFAR_A;
557 pbm->pci_csr = pbm->controller_regs + PSYCHO_PCIA_CTRL;
558 } else {
559 pbm->pci_afsr = pbm->controller_regs + PSYCHO_PCI_AFSR_B;
560 pbm->pci_afar = pbm->controller_regs + PSYCHO_PCI_AFAR_B;
561 pbm->pci_csr = pbm->controller_regs + PSYCHO_PCIB_CTRL;
562 }
1062 563
1063 p->pbm_A.config_space = p->pbm_B.config_space = 564 psycho_controller_hwinit(pbm);
1064 (pr_regs[2].phys_addr + PSYCHO_CONFIGSPACE); 565 if (!pbm->sibling) {
566 err = psycho_iommu_init(pbm, 128, 0xc0000000,
567 0xffffffff, PSYCHO_CONTROL);
568 if (err)
569 goto out_free_iommu;
1065 570
1066 psycho_controller_hwinit(&p->pbm_A); 571 /* If necessary, hook us up for starfire IRQ translations. */
572 if (this_is_starfire)
573 starfire_hookup(pbm->portid);
574 }
1067 575
1068 if (psycho_iommu_init(&p->pbm_A)) 576 psycho_pbm_init(pbm, op, is_pbm_a);
1069 goto fatal_memory_error;
1070 577
1071 is_pbm_a = ((pr_regs[0].phys_addr & 0x6000) == 0x2000); 578 pbm->next = pci_pbm_root;
1072 psycho_pbm_init(p, dp, is_pbm_a); 579 pci_pbm_root = pbm;
1073 return; 580
581 if (pbm->sibling)
582 pbm->sibling->sibling = pbm;
583
584 dev_set_drvdata(&op->dev, pbm);
585
586 return 0;
587
588out_free_iommu:
589 if (!pbm->sibling)
590 kfree(pbm->iommu);
1074 591
1075fatal_memory_error: 592out_free_controller:
1076 prom_printf("PSYCHO: Fatal memory allocation error.\n"); 593 kfree(pbm);
1077 prom_halt(); 594
595out_err:
596 return err;
1078} 597}
598
599static struct of_device_id __initdata psycho_match[] = {
600 {
601 .name = "pci",
602 .compatible = "pci108e,8000",
603 },
604 {},
605};
606
607static struct of_platform_driver psycho_driver = {
608 .name = DRIVER_NAME,
609 .match_table = psycho_match,
610 .probe = psycho_probe,
611};
612
613static int __init psycho_init(void)
614{
615 return of_register_driver(&psycho_driver, &of_bus_type);
616}
617
618subsys_initcall(psycho_init);
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
index ade5184e75d1..713257b6963c 100644
--- a/arch/sparc64/kernel/pci_sabre.c
+++ b/arch/sparc64/kernel/pci_sabre.c
@@ -16,31 +16,15 @@
16#include <asm/apb.h> 16#include <asm/apb.h>
17#include <asm/iommu.h> 17#include <asm/iommu.h>
18#include <asm/irq.h> 18#include <asm/irq.h>
19#include <asm/smp.h>
20#include <asm/oplib.h>
21#include <asm/prom.h> 19#include <asm/prom.h>
20#include <asm/upa.h>
22 21
23#include "pci_impl.h" 22#include "pci_impl.h"
24#include "iommu_common.h" 23#include "iommu_common.h"
24#include "psycho_common.h"
25 25
26/* All SABRE registers are 64-bits. The following accessor 26#define DRIVER_NAME "sabre"
27 * routines are how they are accessed. The REG parameter 27#define PFX DRIVER_NAME ": "
28 * is a physical address.
29 */
30#define sabre_read(__reg) \
31({ u64 __ret; \
32 __asm__ __volatile__("ldxa [%1] %2, %0" \
33 : "=r" (__ret) \
34 : "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \
35 : "memory"); \
36 __ret; \
37})
38#define sabre_write(__reg, __val) \
39 __asm__ __volatile__("stxa %0, [%1] %2" \
40 : /* no outputs */ \
41 : "r" (__val), "r" (__reg), \
42 "i" (ASI_PHYS_BYPASS_EC_E) \
43 : "memory")
44 28
45/* SABRE PCI controller register offsets and definitions. */ 29/* SABRE PCI controller register offsets and definitions. */
46#define SABRE_UE_AFSR 0x0030UL 30#define SABRE_UE_AFSR 0x0030UL
@@ -208,95 +192,6 @@
208static int hummingbird_p; 192static int hummingbird_p;
209static struct pci_bus *sabre_root_bus; 193static struct pci_bus *sabre_root_bus;
210 194
211/* SABRE error handling support. */
212static void sabre_check_iommu_error(struct pci_pbm_info *pbm,
213 unsigned long afsr,
214 unsigned long afar)
215{
216 struct iommu *iommu = pbm->iommu;
217 unsigned long iommu_tag[16];
218 unsigned long iommu_data[16];
219 unsigned long flags;
220 u64 control;
221 int i;
222
223 spin_lock_irqsave(&iommu->lock, flags);
224 control = sabre_read(iommu->iommu_control);
225 if (control & SABRE_IOMMUCTRL_ERR) {
226 char *type_string;
227
228 /* Clear the error encountered bit.
229 * NOTE: On Sabre this is write 1 to clear,
230 * which is different from Psycho.
231 */
232 sabre_write(iommu->iommu_control, control);
233 switch((control & SABRE_IOMMUCTRL_ERRSTS) >> 25UL) {
234 case 1:
235 type_string = "Invalid Error";
236 break;
237 case 3:
238 type_string = "ECC Error";
239 break;
240 default:
241 type_string = "Unknown";
242 break;
243 };
244 printk("%s: IOMMU Error, type[%s]\n",
245 pbm->name, type_string);
246
247 /* Enter diagnostic mode and probe for error'd
248 * entries in the IOTLB.
249 */
250 control &= ~(SABRE_IOMMUCTRL_ERRSTS | SABRE_IOMMUCTRL_ERR);
251 sabre_write(iommu->iommu_control,
252 (control | SABRE_IOMMUCTRL_DENAB));
253 for (i = 0; i < 16; i++) {
254 unsigned long base = pbm->controller_regs;
255
256 iommu_tag[i] =
257 sabre_read(base + SABRE_IOMMU_TAG + (i * 8UL));
258 iommu_data[i] =
259 sabre_read(base + SABRE_IOMMU_DATA + (i * 8UL));
260 sabre_write(base + SABRE_IOMMU_TAG + (i * 8UL), 0);
261 sabre_write(base + SABRE_IOMMU_DATA + (i * 8UL), 0);
262 }
263 sabre_write(iommu->iommu_control, control);
264
265 for (i = 0; i < 16; i++) {
266 unsigned long tag, data;
267
268 tag = iommu_tag[i];
269 if (!(tag & SABRE_IOMMUTAG_ERR))
270 continue;
271
272 data = iommu_data[i];
273 switch((tag & SABRE_IOMMUTAG_ERRSTS) >> 23UL) {
274 case 1:
275 type_string = "Invalid Error";
276 break;
277 case 3:
278 type_string = "ECC Error";
279 break;
280 default:
281 type_string = "Unknown";
282 break;
283 };
284 printk("%s: IOMMU TAG(%d)[RAW(%016lx)error(%s)wr(%d)sz(%dK)vpg(%08lx)]\n",
285 pbm->name, i, tag, type_string,
286 ((tag & SABRE_IOMMUTAG_WRITE) ? 1 : 0),
287 ((tag & SABRE_IOMMUTAG_SIZE) ? 64 : 8),
288 ((tag & SABRE_IOMMUTAG_VPN) << IOMMU_PAGE_SHIFT));
289 printk("%s: IOMMU DATA(%d)[RAW(%016lx)valid(%d)used(%d)cache(%d)ppg(%016lx)\n",
290 pbm->name, i, data,
291 ((data & SABRE_IOMMUDATA_VALID) ? 1 : 0),
292 ((data & SABRE_IOMMUDATA_USED) ? 1 : 0),
293 ((data & SABRE_IOMMUDATA_CACHE) ? 1 : 0),
294 ((data & SABRE_IOMMUDATA_PPN) << IOMMU_PAGE_SHIFT));
295 }
296 }
297 spin_unlock_irqrestore(&iommu->lock, flags);
298}
299
300static irqreturn_t sabre_ue_intr(int irq, void *dev_id) 195static irqreturn_t sabre_ue_intr(int irq, void *dev_id)
301{ 196{
302 struct pci_pbm_info *pbm = dev_id; 197 struct pci_pbm_info *pbm = dev_id;
@@ -306,8 +201,8 @@ static irqreturn_t sabre_ue_intr(int irq, void *dev_id)
306 int reported; 201 int reported;
307 202
308 /* Latch uncorrectable error status. */ 203 /* Latch uncorrectable error status. */
309 afar = sabre_read(afar_reg); 204 afar = upa_readq(afar_reg);
310 afsr = sabre_read(afsr_reg); 205 afsr = upa_readq(afsr_reg);
311 206
312 /* Clear the primary/secondary error status bits. */ 207 /* Clear the primary/secondary error status bits. */
313 error_bits = afsr & 208 error_bits = afsr &
@@ -316,7 +211,7 @@ static irqreturn_t sabre_ue_intr(int irq, void *dev_id)
316 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE); 211 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE);
317 if (!error_bits) 212 if (!error_bits)
318 return IRQ_NONE; 213 return IRQ_NONE;
319 sabre_write(afsr_reg, error_bits); 214 upa_writeq(error_bits, afsr_reg);
320 215
321 /* Log the error. */ 216 /* Log the error. */
322 printk("%s: Uncorrectable Error, primary error type[%s%s]\n", 217 printk("%s: Uncorrectable Error, primary error type[%s%s]\n",
@@ -352,7 +247,7 @@ static irqreturn_t sabre_ue_intr(int irq, void *dev_id)
352 printk("]\n"); 247 printk("]\n");
353 248
354 /* Interrogate IOMMU for error status. */ 249 /* Interrogate IOMMU for error status. */
355 sabre_check_iommu_error(pbm, afsr, afar); 250 psycho_check_iommu_error(pbm, afsr, afar, UE_ERR);
356 251
357 return IRQ_HANDLED; 252 return IRQ_HANDLED;
358} 253}
@@ -366,8 +261,8 @@ static irqreturn_t sabre_ce_intr(int irq, void *dev_id)
366 int reported; 261 int reported;
367 262
368 /* Latch error status. */ 263 /* Latch error status. */
369 afar = sabre_read(afar_reg); 264 afar = upa_readq(afar_reg);
370 afsr = sabre_read(afsr_reg); 265 afsr = upa_readq(afsr_reg);
371 266
372 /* Clear primary/secondary error status bits. */ 267 /* Clear primary/secondary error status bits. */
373 error_bits = afsr & 268 error_bits = afsr &
@@ -375,7 +270,7 @@ static irqreturn_t sabre_ce_intr(int irq, void *dev_id)
375 SABRE_CEAFSR_SDRD | SABRE_CEAFSR_SDWR); 270 SABRE_CEAFSR_SDRD | SABRE_CEAFSR_SDWR);
376 if (!error_bits) 271 if (!error_bits)
377 return IRQ_NONE; 272 return IRQ_NONE;
378 sabre_write(afsr_reg, error_bits); 273 upa_writeq(error_bits, afsr_reg);
379 274
380 /* Log the error. */ 275 /* Log the error. */
381 printk("%s: Correctable Error, primary error type[%s]\n", 276 printk("%s: Correctable Error, primary error type[%s]\n",
@@ -413,136 +308,9 @@ static irqreturn_t sabre_ce_intr(int irq, void *dev_id)
413 return IRQ_HANDLED; 308 return IRQ_HANDLED;
414} 309}
415 310
416static irqreturn_t sabre_pcierr_intr_other(struct pci_pbm_info *pbm)
417{
418 unsigned long csr_reg, csr, csr_error_bits;
419 irqreturn_t ret = IRQ_NONE;
420 u16 stat;
421
422 csr_reg = pbm->controller_regs + SABRE_PCICTRL;
423 csr = sabre_read(csr_reg);
424 csr_error_bits =
425 csr & SABRE_PCICTRL_SERR;
426 if (csr_error_bits) {
427 /* Clear the errors. */
428 sabre_write(csr_reg, csr);
429
430 /* Log 'em. */
431 if (csr_error_bits & SABRE_PCICTRL_SERR)
432 printk("%s: PCI SERR signal asserted.\n",
433 pbm->name);
434 ret = IRQ_HANDLED;
435 }
436 pci_bus_read_config_word(sabre_root_bus, 0,
437 PCI_STATUS, &stat);
438 if (stat & (PCI_STATUS_PARITY |
439 PCI_STATUS_SIG_TARGET_ABORT |
440 PCI_STATUS_REC_TARGET_ABORT |
441 PCI_STATUS_REC_MASTER_ABORT |
442 PCI_STATUS_SIG_SYSTEM_ERROR)) {
443 printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
444 pbm->name, stat);
445 pci_bus_write_config_word(sabre_root_bus, 0,
446 PCI_STATUS, 0xffff);
447 ret = IRQ_HANDLED;
448 }
449 return ret;
450}
451
452static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id)
453{
454 struct pci_pbm_info *pbm = dev_id;
455 unsigned long afsr_reg, afar_reg;
456 unsigned long afsr, afar, error_bits;
457 int reported;
458
459 afsr_reg = pbm->controller_regs + SABRE_PIOAFSR;
460 afar_reg = pbm->controller_regs + SABRE_PIOAFAR;
461
462 /* Latch error status. */
463 afar = sabre_read(afar_reg);
464 afsr = sabre_read(afsr_reg);
465
466 /* Clear primary/secondary error status bits. */
467 error_bits = afsr &
468 (SABRE_PIOAFSR_PMA | SABRE_PIOAFSR_PTA |
469 SABRE_PIOAFSR_PRTRY | SABRE_PIOAFSR_PPERR |
470 SABRE_PIOAFSR_SMA | SABRE_PIOAFSR_STA |
471 SABRE_PIOAFSR_SRTRY | SABRE_PIOAFSR_SPERR);
472 if (!error_bits)
473 return sabre_pcierr_intr_other(pbm);
474 sabre_write(afsr_reg, error_bits);
475
476 /* Log the error. */
477 printk("%s: PCI Error, primary error type[%s]\n",
478 pbm->name,
479 (((error_bits & SABRE_PIOAFSR_PMA) ?
480 "Master Abort" :
481 ((error_bits & SABRE_PIOAFSR_PTA) ?
482 "Target Abort" :
483 ((error_bits & SABRE_PIOAFSR_PRTRY) ?
484 "Excessive Retries" :
485 ((error_bits & SABRE_PIOAFSR_PPERR) ?
486 "Parity Error" : "???"))))));
487 printk("%s: bytemask[%04lx] was_block(%d)\n",
488 pbm->name,
489 (afsr & SABRE_PIOAFSR_BMSK) >> 32UL,
490 (afsr & SABRE_PIOAFSR_BLK) ? 1 : 0);
491 printk("%s: PCI AFAR [%016lx]\n", pbm->name, afar);
492 printk("%s: PCI Secondary errors [", pbm->name);
493 reported = 0;
494 if (afsr & SABRE_PIOAFSR_SMA) {
495 reported++;
496 printk("(Master Abort)");
497 }
498 if (afsr & SABRE_PIOAFSR_STA) {
499 reported++;
500 printk("(Target Abort)");
501 }
502 if (afsr & SABRE_PIOAFSR_SRTRY) {
503 reported++;
504 printk("(Excessive Retries)");
505 }
506 if (afsr & SABRE_PIOAFSR_SPERR) {
507 reported++;
508 printk("(Parity Error)");
509 }
510 if (!reported)
511 printk("(none)");
512 printk("]\n");
513
514 /* For the error types shown, scan both PCI buses for devices
515 * which have logged that error type.
516 */
517
518 /* If we see a Target Abort, this could be the result of an
519 * IOMMU translation error of some sort. It is extremely
520 * useful to log this information as usually it indicates
521 * a bug in the IOMMU support code or a PCI device driver.
522 */
523 if (error_bits & (SABRE_PIOAFSR_PTA | SABRE_PIOAFSR_STA)) {
524 sabre_check_iommu_error(pbm, afsr, afar);
525 pci_scan_for_target_abort(pbm, pbm->pci_bus);
526 }
527 if (error_bits & (SABRE_PIOAFSR_PMA | SABRE_PIOAFSR_SMA))
528 pci_scan_for_master_abort(pbm, pbm->pci_bus);
529
530 /* For excessive retries, SABRE/PBM will abort the device
531 * and there is no way to specifically check for excessive
532 * retries in the config space status registers. So what
533 * we hope is that we'll catch it via the master/target
534 * abort events.
535 */
536
537 if (error_bits & (SABRE_PIOAFSR_PPERR | SABRE_PIOAFSR_SPERR))
538 pci_scan_for_parity_error(pbm, pbm->pci_bus);
539
540 return IRQ_HANDLED;
541}
542
543static void sabre_register_error_handlers(struct pci_pbm_info *pbm) 311static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
544{ 312{
545 struct device_node *dp = pbm->prom_node; 313 struct device_node *dp = pbm->op->node;
546 struct of_device *op; 314 struct of_device *op;
547 unsigned long base = pbm->controller_regs; 315 unsigned long base = pbm->controller_regs;
548 u64 tmp; 316 u64 tmp;
@@ -568,33 +336,34 @@ static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
568 * registering the handler so that we don't get spurious 336 * registering the handler so that we don't get spurious
569 * interrupts. 337 * interrupts.
570 */ 338 */
571 sabre_write(base + SABRE_UE_AFSR, 339 upa_writeq((SABRE_UEAFSR_PDRD | SABRE_UEAFSR_PDWR |
572 (SABRE_UEAFSR_PDRD | SABRE_UEAFSR_PDWR | 340 SABRE_UEAFSR_SDRD | SABRE_UEAFSR_SDWR |
573 SABRE_UEAFSR_SDRD | SABRE_UEAFSR_SDWR | 341 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE),
574 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE)); 342 base + SABRE_UE_AFSR);
575 343
576 err = request_irq(op->irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm); 344 err = request_irq(op->irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm);
577 if (err) 345 if (err)
578 printk(KERN_WARNING "%s: Couldn't register UE, err=%d.\n", 346 printk(KERN_WARNING "%s: Couldn't register UE, err=%d.\n",
579 pbm->name, err); 347 pbm->name, err);
580 348
581 sabre_write(base + SABRE_CE_AFSR, 349 upa_writeq((SABRE_CEAFSR_PDRD | SABRE_CEAFSR_PDWR |
582 (SABRE_CEAFSR_PDRD | SABRE_CEAFSR_PDWR | 350 SABRE_CEAFSR_SDRD | SABRE_CEAFSR_SDWR),
583 SABRE_CEAFSR_SDRD | SABRE_CEAFSR_SDWR)); 351 base + SABRE_CE_AFSR);
352
584 353
585 err = request_irq(op->irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm); 354 err = request_irq(op->irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm);
586 if (err) 355 if (err)
587 printk(KERN_WARNING "%s: Couldn't register CE, err=%d.\n", 356 printk(KERN_WARNING "%s: Couldn't register CE, err=%d.\n",
588 pbm->name, err); 357 pbm->name, err);
589 err = request_irq(op->irqs[0], sabre_pcierr_intr, 0, 358 err = request_irq(op->irqs[0], psycho_pcierr_intr, 0,
590 "SABRE_PCIERR", pbm); 359 "SABRE_PCIERR", pbm);
591 if (err) 360 if (err)
592 printk(KERN_WARNING "%s: Couldn't register PCIERR, err=%d.\n", 361 printk(KERN_WARNING "%s: Couldn't register PCIERR, err=%d.\n",
593 pbm->name, err); 362 pbm->name, err);
594 363
595 tmp = sabre_read(base + SABRE_PCICTRL); 364 tmp = upa_readq(base + SABRE_PCICTRL);
596 tmp |= SABRE_PCICTRL_ERREN; 365 tmp |= SABRE_PCICTRL_ERREN;
597 sabre_write(base + SABRE_PCICTRL, tmp); 366 upa_writeq(tmp, base + SABRE_PCICTRL);
598} 367}
599 368
600static void apb_init(struct pci_bus *sabre_bus) 369static void apb_init(struct pci_bus *sabre_bus)
@@ -633,7 +402,8 @@ static void apb_init(struct pci_bus *sabre_bus)
633 } 402 }
634} 403}
635 404
636static void __init sabre_scan_bus(struct pci_pbm_info *pbm) 405static void __init sabre_scan_bus(struct pci_pbm_info *pbm,
406 struct device *parent)
637{ 407{
638 static int once; 408 static int once;
639 409
@@ -656,12 +426,12 @@ static void __init sabre_scan_bus(struct pci_pbm_info *pbm)
656 * to live at bus 0. 426 * to live at bus 0.
657 */ 427 */
658 if (once != 0) { 428 if (once != 0) {
659 prom_printf("SABRE: Multiple controllers unsupported.\n"); 429 printk(KERN_ERR PFX "Multiple controllers unsupported.\n");
660 prom_halt(); 430 return;
661 } 431 }
662 once++; 432 once++;
663 433
664 pbm->pci_bus = pci_scan_one_pbm(pbm); 434 pbm->pci_bus = pci_scan_one_pbm(pbm, parent);
665 if (!pbm->pci_bus) 435 if (!pbm->pci_bus)
666 return; 436 return;
667 437
@@ -672,133 +442,58 @@ static void __init sabre_scan_bus(struct pci_pbm_info *pbm)
672 sabre_register_error_handlers(pbm); 442 sabre_register_error_handlers(pbm);
673} 443}
674 444
675static int sabre_iommu_init(struct pci_pbm_info *pbm, 445static void __init sabre_pbm_init(struct pci_pbm_info *pbm,
676 int tsbsize, unsigned long dvma_offset, 446 struct of_device *op)
677 u32 dma_mask)
678{
679 struct iommu *iommu = pbm->iommu;
680 unsigned long i;
681 u64 control;
682 int err;
683
684 /* Register addresses. */
685 iommu->iommu_control = pbm->controller_regs + SABRE_IOMMU_CONTROL;
686 iommu->iommu_tsbbase = pbm->controller_regs + SABRE_IOMMU_TSBBASE;
687 iommu->iommu_flush = pbm->controller_regs + SABRE_IOMMU_FLUSH;
688 iommu->iommu_tags = iommu->iommu_flush + (0xa580UL - 0x0210UL);
689 iommu->write_complete_reg = pbm->controller_regs + SABRE_WRSYNC;
690 /* Sabre's IOMMU lacks ctx flushing. */
691 iommu->iommu_ctxflush = 0;
692
693 /* Invalidate TLB Entries. */
694 control = sabre_read(pbm->controller_regs + SABRE_IOMMU_CONTROL);
695 control |= SABRE_IOMMUCTRL_DENAB;
696 sabre_write(pbm->controller_regs + SABRE_IOMMU_CONTROL, control);
697
698 for(i = 0; i < 16; i++) {
699 sabre_write(pbm->controller_regs + SABRE_IOMMU_TAG + (i * 8UL), 0);
700 sabre_write(pbm->controller_regs + SABRE_IOMMU_DATA + (i * 8UL), 0);
701 }
702
703 /* Leave diag mode enabled for full-flushing done
704 * in pci_iommu.c
705 */
706 err = iommu_table_init(iommu, tsbsize * 1024 * 8,
707 dvma_offset, dma_mask, pbm->numa_node);
708 if (err)
709 return err;
710
711 sabre_write(pbm->controller_regs + SABRE_IOMMU_TSBBASE,
712 __pa(iommu->page_table));
713
714 control = sabre_read(pbm->controller_regs + SABRE_IOMMU_CONTROL);
715 control &= ~(SABRE_IOMMUCTRL_TSBSZ | SABRE_IOMMUCTRL_TBWSZ);
716 control |= SABRE_IOMMUCTRL_ENAB;
717 switch(tsbsize) {
718 case 64:
719 control |= SABRE_IOMMU_TSBSZ_64K;
720 break;
721 case 128:
722 control |= SABRE_IOMMU_TSBSZ_128K;
723 break;
724 default:
725 prom_printf("iommu_init: Illegal TSB size %d\n", tsbsize);
726 prom_halt();
727 break;
728 }
729 sabre_write(pbm->controller_regs + SABRE_IOMMU_CONTROL, control);
730
731 return 0;
732}
733
734static void __init sabre_pbm_init(struct pci_controller_info *p,
735 struct pci_pbm_info *pbm, struct device_node *dp)
736{ 447{
737 pbm->name = dp->full_name; 448 psycho_pbm_init_common(pbm, op, "SABRE", PBM_CHIP_TYPE_SABRE);
738 printk("%s: SABRE PCI Bus Module\n", pbm->name); 449 pbm->pci_afsr = pbm->controller_regs + SABRE_PIOAFSR;
739 450 pbm->pci_afar = pbm->controller_regs + SABRE_PIOAFAR;
740 pbm->numa_node = -1; 451 pbm->pci_csr = pbm->controller_regs + SABRE_PCICTRL;
741 452 sabre_scan_bus(pbm, &op->dev);
742 pbm->scan_bus = sabre_scan_bus;
743 pbm->pci_ops = &sun4u_pci_ops;
744 pbm->config_space_reg_bits = 8;
745
746 pbm->index = pci_num_pbms++;
747
748 pbm->chip_type = PBM_CHIP_TYPE_SABRE;
749 pbm->parent = p;
750 pbm->prom_node = dp;
751 pci_get_pbm_props(pbm);
752
753 pci_determine_mem_io_space(pbm);
754} 453}
755 454
756void __init sabre_init(struct device_node *dp, char *model_name) 455static int __devinit sabre_probe(struct of_device *op,
456 const struct of_device_id *match)
757{ 457{
758 const struct linux_prom64_registers *pr_regs; 458 const struct linux_prom64_registers *pr_regs;
759 struct pci_controller_info *p; 459 struct device_node *dp = op->node;
760 struct pci_pbm_info *pbm; 460 struct pci_pbm_info *pbm;
461 u32 upa_portid, dma_mask;
761 struct iommu *iommu; 462 struct iommu *iommu;
762 int tsbsize; 463 int tsbsize, err;
763 const u32 *vdma; 464 const u32 *vdma;
764 u32 upa_portid, dma_mask;
765 u64 clear_irq; 465 u64 clear_irq;
766 466
767 hummingbird_p = 0; 467 hummingbird_p = (match->data != NULL);
768 if (!strcmp(model_name, "pci108e,a001")) 468 if (!hummingbird_p) {
769 hummingbird_p = 1; 469 struct device_node *cpu_dp;
770 else if (!strcmp(model_name, "SUNW,sabre")) { 470
771 const char *compat = of_get_property(dp, "compatible", NULL); 471 /* Of course, Sun has to encode things a thousand
772 if (compat && !strcmp(compat, "pci108e,a001")) 472 * different ways, inconsistently.
773 hummingbird_p = 1; 473 */
774 if (!hummingbird_p) { 474 for_each_node_by_type(cpu_dp, "cpu") {
775 struct device_node *dp; 475 if (!strcmp(cpu_dp->name, "SUNW,UltraSPARC-IIe"))
776 476 hummingbird_p = 1;
777 /* Of course, Sun has to encode things a thousand
778 * different ways, inconsistently.
779 */
780 for_each_node_by_type(dp, "cpu") {
781 if (!strcmp(dp->name, "SUNW,UltraSPARC-IIe"))
782 hummingbird_p = 1;
783 }
784 } 477 }
785 } 478 }
786 479
787 p = kzalloc(sizeof(*p), GFP_ATOMIC); 480 err = -ENOMEM;
788 if (!p) 481 pbm = kzalloc(sizeof(*pbm), GFP_KERNEL);
789 goto fatal_memory_error; 482 if (!pbm) {
483 printk(KERN_ERR PFX "Cannot allocate pci_pbm_info.\n");
484 goto out_err;
485 }
486
487 iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
488 if (!iommu) {
489 printk(KERN_ERR PFX "Cannot allocate PBM iommu.\n");
490 goto out_free_controller;
491 }
790 492
791 iommu = kzalloc(sizeof(*iommu), GFP_ATOMIC);
792 if (!iommu)
793 goto fatal_memory_error;
794 pbm = &p->pbm_A;
795 pbm->iommu = iommu; 493 pbm->iommu = iommu;
796 494
797 upa_portid = of_getintprop_default(dp, "upa-portid", 0xff); 495 upa_portid = of_getintprop_default(dp, "upa-portid", 0xff);
798 496
799 pbm->next = pci_pbm_root;
800 pci_pbm_root = pbm;
801
802 pbm->portid = upa_portid; 497 pbm->portid = upa_portid;
803 498
804 /* 499 /*
@@ -806,6 +501,11 @@ void __init sabre_init(struct device_node *dp, char *model_name)
806 */ 501 */
807 502
808 pr_regs = of_get_property(dp, "reg", NULL); 503 pr_regs = of_get_property(dp, "reg", NULL);
504 err = -ENODEV;
505 if (!pr_regs) {
506 printk(KERN_ERR PFX "No reg property\n");
507 goto out_free_iommu;
508 }
809 509
810 /* 510 /*
811 * First REG in property is base of entire SABRE register space. 511 * First REG in property is base of entire SABRE register space.
@@ -816,22 +516,25 @@ void __init sabre_init(struct device_node *dp, char *model_name)
816 516
817 /* PCI first */ 517 /* PCI first */
818 for (clear_irq = SABRE_ICLR_A_SLOT0; clear_irq < SABRE_ICLR_B_SLOT0 + 0x80; clear_irq += 8) 518 for (clear_irq = SABRE_ICLR_A_SLOT0; clear_irq < SABRE_ICLR_B_SLOT0 + 0x80; clear_irq += 8)
819 sabre_write(pbm->controller_regs + clear_irq, 0x0UL); 519 upa_writeq(0x0UL, pbm->controller_regs + clear_irq);
820 520
821 /* Then OBIO */ 521 /* Then OBIO */
822 for (clear_irq = SABRE_ICLR_SCSI; clear_irq < SABRE_ICLR_SCSI + 0x80; clear_irq += 8) 522 for (clear_irq = SABRE_ICLR_SCSI; clear_irq < SABRE_ICLR_SCSI + 0x80; clear_irq += 8)
823 sabre_write(pbm->controller_regs + clear_irq, 0x0UL); 523 upa_writeq(0x0UL, pbm->controller_regs + clear_irq);
824 524
825 /* Error interrupts are enabled later after the bus scan. */ 525 /* Error interrupts are enabled later after the bus scan. */
826 sabre_write(pbm->controller_regs + SABRE_PCICTRL, 526 upa_writeq((SABRE_PCICTRL_MRLEN | SABRE_PCICTRL_SERR |
827 (SABRE_PCICTRL_MRLEN | SABRE_PCICTRL_SERR | 527 SABRE_PCICTRL_ARBPARK | SABRE_PCICTRL_AEN),
828 SABRE_PCICTRL_ARBPARK | SABRE_PCICTRL_AEN)); 528 pbm->controller_regs + SABRE_PCICTRL);
829 529
830 /* Now map in PCI config space for entire SABRE. */ 530 /* Now map in PCI config space for entire SABRE. */
831 pbm->config_space = 531 pbm->config_space = pbm->controller_regs + SABRE_CONFIGSPACE;
832 (pbm->controller_regs + SABRE_CONFIGSPACE);
833 532
834 vdma = of_get_property(dp, "virtual-dma", NULL); 533 vdma = of_get_property(dp, "virtual-dma", NULL);
534 if (!vdma) {
535 printk(KERN_ERR PFX "No virtual-dma property\n");
536 goto out_free_iommu;
537 }
835 538
836 dma_mask = vdma[0]; 539 dma_mask = vdma[0];
837 switch(vdma[1]) { 540 switch(vdma[1]) {
@@ -849,20 +552,58 @@ void __init sabre_init(struct device_node *dp, char *model_name)
849 tsbsize = 128; 552 tsbsize = 128;
850 break; 553 break;
851 default: 554 default:
852 prom_printf("SABRE: strange virtual-dma size.\n"); 555 printk(KERN_ERR PFX "Strange virtual-dma size.\n");
853 prom_halt(); 556 goto out_free_iommu;
854 } 557 }
855 558
856 if (sabre_iommu_init(pbm, tsbsize, vdma[0], dma_mask)) 559 err = psycho_iommu_init(pbm, tsbsize, vdma[0], dma_mask, SABRE_WRSYNC);
857 goto fatal_memory_error; 560 if (err)
561 goto out_free_iommu;
858 562
859 /* 563 /*
860 * Look for APB underneath. 564 * Look for APB underneath.
861 */ 565 */
862 sabre_pbm_init(p, pbm, dp); 566 sabre_pbm_init(pbm, op);
863 return;
864 567
865fatal_memory_error: 568 pbm->next = pci_pbm_root;
866 prom_printf("SABRE: Fatal memory allocation error.\n"); 569 pci_pbm_root = pbm;
867 prom_halt(); 570
571 dev_set_drvdata(&op->dev, pbm);
572
573 return 0;
574
575out_free_iommu:
576 kfree(pbm->iommu);
577
578out_free_controller:
579 kfree(pbm);
580
581out_err:
582 return err;
583}
584
585static struct of_device_id __initdata sabre_match[] = {
586 {
587 .name = "pci",
588 .compatible = "pci108e,a001",
589 .data = (void *) 1,
590 },
591 {
592 .name = "pci",
593 .compatible = "pci108e,a000",
594 },
595 {},
596};
597
598static struct of_platform_driver sabre_driver = {
599 .name = DRIVER_NAME,
600 .match_table = sabre_match,
601 .probe = sabre_probe,
602};
603
604static int __init sabre_init(void)
605{
606 return of_register_driver(&sabre_driver, &of_bus_type);
868} 607}
608
609subsys_initcall(sabre_init);
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
index 9248c6737f0e..45d9dba1ba11 100644
--- a/arch/sparc64/kernel/pci_schizo.c
+++ b/arch/sparc64/kernel/pci_schizo.c
@@ -1,6 +1,6 @@
1/* pci_schizo.c: SCHIZO/TOMATILLO specific PCI controller support. 1/* pci_schizo.c: SCHIZO/TOMATILLO specific PCI controller support.
2 * 2 *
3 * Copyright (C) 2001, 2002, 2003, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2001, 2002, 2003, 2007, 2008 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#include <linux/kernel.h> 6#include <linux/kernel.h>
@@ -13,32 +13,15 @@
13 13
14#include <asm/iommu.h> 14#include <asm/iommu.h>
15#include <asm/irq.h> 15#include <asm/irq.h>
16#include <asm/upa.h>
17#include <asm/pstate.h> 16#include <asm/pstate.h>
18#include <asm/prom.h> 17#include <asm/prom.h>
19#include <asm/oplib.h> 18#include <asm/upa.h>
20 19
21#include "pci_impl.h" 20#include "pci_impl.h"
22#include "iommu_common.h" 21#include "iommu_common.h"
23 22
24/* All SCHIZO registers are 64-bits. The following accessor 23#define DRIVER_NAME "schizo"
25 * routines are how they are accessed. The REG parameter 24#define PFX DRIVER_NAME ": "
26 * is a physical address.
27 */
28#define schizo_read(__reg) \
29({ u64 __ret; \
30 __asm__ __volatile__("ldxa [%1] %2, %0" \
31 : "=r" (__ret) \
32 : "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \
33 : "memory"); \
34 __ret; \
35})
36#define schizo_write(__reg, __val) \
37 __asm__ __volatile__("stxa %0, [%1] %2" \
38 : /* no outputs */ \
39 : "r" (__val), "r" (__reg), \
40 "i" (ASI_PHYS_BYPASS_EC_E) \
41 : "memory")
42 25
43/* This is a convention that at least Excalibur and Merlin 26/* This is a convention that at least Excalibur and Merlin
44 * follow. I suppose the SCHIZO used in Starcat and friends 27 * follow. I suppose the SCHIZO used in Starcat and friends
@@ -163,25 +146,25 @@ static void __schizo_check_stc_error_pbm(struct pci_pbm_info *pbm,
163 * invalidating it before it has a chance to reach 146 * invalidating it before it has a chance to reach
164 * main memory. 147 * main memory.
165 */ 148 */
166 control = schizo_read(strbuf->strbuf_control); 149 control = upa_readq(strbuf->strbuf_control);
167 schizo_write(strbuf->strbuf_control, 150 upa_writeq((control | SCHIZO_STRBUF_CTRL_DENAB),
168 (control | SCHIZO_STRBUF_CTRL_DENAB)); 151 strbuf->strbuf_control);
169 for (i = 0; i < 128; i++) { 152 for (i = 0; i < 128; i++) {
170 unsigned long val; 153 unsigned long val;
171 154
172 val = schizo_read(err_base + (i * 8UL)); 155 val = upa_readq(err_base + (i * 8UL));
173 schizo_write(err_base + (i * 8UL), 0UL); 156 upa_writeq(0UL, err_base + (i * 8UL));
174 stc_error_buf[i] = val; 157 stc_error_buf[i] = val;
175 } 158 }
176 for (i = 0; i < 16; i++) { 159 for (i = 0; i < 16; i++) {
177 stc_tag_buf[i] = schizo_read(tag_base + (i * 8UL)); 160 stc_tag_buf[i] = upa_readq(tag_base + (i * 8UL));
178 stc_line_buf[i] = schizo_read(line_base + (i * 8UL)); 161 stc_line_buf[i] = upa_readq(line_base + (i * 8UL));
179 schizo_write(tag_base + (i * 8UL), 0UL); 162 upa_writeq(0UL, tag_base + (i * 8UL));
180 schizo_write(line_base + (i * 8UL), 0UL); 163 upa_writeq(0UL, line_base + (i * 8UL));
181 } 164 }
182 165
183 /* OK, state is logged, exit diagnostic mode. */ 166 /* OK, state is logged, exit diagnostic mode. */
184 schizo_write(strbuf->strbuf_control, control); 167 upa_writeq(control, strbuf->strbuf_control);
185 168
186 for (i = 0; i < 16; i++) { 169 for (i = 0; i < 16; i++) {
187 int j, saw_error, first, last; 170 int j, saw_error, first, last;
@@ -258,14 +241,14 @@ static void schizo_check_iommu_error_pbm(struct pci_pbm_info *pbm,
258 int i; 241 int i;
259 242
260 spin_lock_irqsave(&iommu->lock, flags); 243 spin_lock_irqsave(&iommu->lock, flags);
261 control = schizo_read(iommu->iommu_control); 244 control = upa_readq(iommu->iommu_control);
262 if (control & SCHIZO_IOMMU_CTRL_XLTEERR) { 245 if (control & SCHIZO_IOMMU_CTRL_XLTEERR) {
263 unsigned long base; 246 unsigned long base;
264 char *type_string; 247 char *type_string;
265 248
266 /* Clear the error encountered bit. */ 249 /* Clear the error encountered bit. */
267 control &= ~SCHIZO_IOMMU_CTRL_XLTEERR; 250 control &= ~SCHIZO_IOMMU_CTRL_XLTEERR;
268 schizo_write(iommu->iommu_control, control); 251 upa_writeq(control, iommu->iommu_control);
269 252
270 switch((control & SCHIZO_IOMMU_CTRL_XLTESTAT) >> 25UL) { 253 switch((control & SCHIZO_IOMMU_CTRL_XLTESTAT) >> 25UL) {
271 case 0: 254 case 0:
@@ -295,24 +278,24 @@ static void schizo_check_iommu_error_pbm(struct pci_pbm_info *pbm,
295 * get as much diagnostic information to the 278 * get as much diagnostic information to the
296 * console as we can. 279 * console as we can.
297 */ 280 */
298 schizo_write(iommu->iommu_control, 281 upa_writeq(control | SCHIZO_IOMMU_CTRL_DENAB,
299 control | SCHIZO_IOMMU_CTRL_DENAB); 282 iommu->iommu_control);
300 283
301 base = pbm->pbm_regs; 284 base = pbm->pbm_regs;
302 285
303 for (i = 0; i < 16; i++) { 286 for (i = 0; i < 16; i++) {
304 iommu_tag[i] = 287 iommu_tag[i] =
305 schizo_read(base + SCHIZO_IOMMU_TAG + (i * 8UL)); 288 upa_readq(base + SCHIZO_IOMMU_TAG + (i * 8UL));
306 iommu_data[i] = 289 iommu_data[i] =
307 schizo_read(base + SCHIZO_IOMMU_DATA + (i * 8UL)); 290 upa_readq(base + SCHIZO_IOMMU_DATA + (i * 8UL));
308 291
309 /* Now clear out the entry. */ 292 /* Now clear out the entry. */
310 schizo_write(base + SCHIZO_IOMMU_TAG + (i * 8UL), 0); 293 upa_writeq(0, base + SCHIZO_IOMMU_TAG + (i * 8UL));
311 schizo_write(base + SCHIZO_IOMMU_DATA + (i * 8UL), 0); 294 upa_writeq(0, base + SCHIZO_IOMMU_DATA + (i * 8UL));
312 } 295 }
313 296
314 /* Leave diagnostic mode. */ 297 /* Leave diagnostic mode. */
315 schizo_write(iommu->iommu_control, control); 298 upa_writeq(control, iommu->iommu_control);
316 299
317 for (i = 0; i < 16; i++) { 300 for (i = 0; i < 16; i++) {
318 unsigned long tag, data; 301 unsigned long tag, data;
@@ -357,11 +340,12 @@ static void schizo_check_iommu_error_pbm(struct pci_pbm_info *pbm,
357 spin_unlock_irqrestore(&iommu->lock, flags); 340 spin_unlock_irqrestore(&iommu->lock, flags);
358} 341}
359 342
360static void schizo_check_iommu_error(struct pci_controller_info *p, 343static void schizo_check_iommu_error(struct pci_pbm_info *pbm,
361 enum schizo_error_type type) 344 enum schizo_error_type type)
362{ 345{
363 schizo_check_iommu_error_pbm(&p->pbm_A, type); 346 schizo_check_iommu_error_pbm(pbm, type);
364 schizo_check_iommu_error_pbm(&p->pbm_B, type); 347 if (pbm->sibling)
348 schizo_check_iommu_error_pbm(pbm->sibling, type);
365} 349}
366 350
367/* Uncorrectable ECC error status gathering. */ 351/* Uncorrectable ECC error status gathering. */
@@ -386,14 +370,13 @@ static void schizo_check_iommu_error(struct pci_controller_info *p,
386static irqreturn_t schizo_ue_intr(int irq, void *dev_id) 370static irqreturn_t schizo_ue_intr(int irq, void *dev_id)
387{ 371{
388 struct pci_pbm_info *pbm = dev_id; 372 struct pci_pbm_info *pbm = dev_id;
389 struct pci_controller_info *p = pbm->parent;
390 unsigned long afsr_reg = pbm->controller_regs + SCHIZO_UE_AFSR; 373 unsigned long afsr_reg = pbm->controller_regs + SCHIZO_UE_AFSR;
391 unsigned long afar_reg = pbm->controller_regs + SCHIZO_UE_AFAR; 374 unsigned long afar_reg = pbm->controller_regs + SCHIZO_UE_AFAR;
392 unsigned long afsr, afar, error_bits; 375 unsigned long afsr, afar, error_bits;
393 int reported, limit; 376 int reported, limit;
394 377
395 /* Latch uncorrectable error status. */ 378 /* Latch uncorrectable error status. */
396 afar = schizo_read(afar_reg); 379 afar = upa_readq(afar_reg);
397 380
398 /* If either of the error pending bits are set in the 381 /* If either of the error pending bits are set in the
399 * AFSR, the error status is being actively updated by 382 * AFSR, the error status is being actively updated by
@@ -401,7 +384,7 @@ static irqreturn_t schizo_ue_intr(int irq, void *dev_id)
401 */ 384 */
402 limit = 1000; 385 limit = 1000;
403 do { 386 do {
404 afsr = schizo_read(afsr_reg); 387 afsr = upa_readq(afsr_reg);
405 } while ((afsr & SCHIZO_UEAFSR_ERRPNDG) != 0 && --limit); 388 } while ((afsr & SCHIZO_UEAFSR_ERRPNDG) != 0 && --limit);
406 389
407 /* Clear the primary/secondary error status bits. */ 390 /* Clear the primary/secondary error status bits. */
@@ -410,7 +393,7 @@ static irqreturn_t schizo_ue_intr(int irq, void *dev_id)
410 SCHIZO_UEAFSR_SPIO | SCHIZO_UEAFSR_SDMA); 393 SCHIZO_UEAFSR_SPIO | SCHIZO_UEAFSR_SDMA);
411 if (!error_bits) 394 if (!error_bits)
412 return IRQ_NONE; 395 return IRQ_NONE;
413 schizo_write(afsr_reg, error_bits); 396 upa_writeq(error_bits, afsr_reg);
414 397
415 /* Log the error. */ 398 /* Log the error. */
416 printk("%s: Uncorrectable Error, primary error type[%s]\n", 399 printk("%s: Uncorrectable Error, primary error type[%s]\n",
@@ -449,7 +432,7 @@ static irqreturn_t schizo_ue_intr(int irq, void *dev_id)
449 printk("]\n"); 432 printk("]\n");
450 433
451 /* Interrogate IOMMU for error status. */ 434 /* Interrogate IOMMU for error status. */
452 schizo_check_iommu_error(p, UE_ERR); 435 schizo_check_iommu_error(pbm, UE_ERR);
453 436
454 return IRQ_HANDLED; 437 return IRQ_HANDLED;
455} 438}
@@ -481,7 +464,7 @@ static irqreturn_t schizo_ce_intr(int irq, void *dev_id)
481 int reported, limit; 464 int reported, limit;
482 465
483 /* Latch error status. */ 466 /* Latch error status. */
484 afar = schizo_read(afar_reg); 467 afar = upa_readq(afar_reg);
485 468
486 /* If either of the error pending bits are set in the 469 /* If either of the error pending bits are set in the
487 * AFSR, the error status is being actively updated by 470 * AFSR, the error status is being actively updated by
@@ -489,7 +472,7 @@ static irqreturn_t schizo_ce_intr(int irq, void *dev_id)
489 */ 472 */
490 limit = 1000; 473 limit = 1000;
491 do { 474 do {
492 afsr = schizo_read(afsr_reg); 475 afsr = upa_readq(afsr_reg);
493 } while ((afsr & SCHIZO_UEAFSR_ERRPNDG) != 0 && --limit); 476 } while ((afsr & SCHIZO_UEAFSR_ERRPNDG) != 0 && --limit);
494 477
495 /* Clear primary/secondary error status bits. */ 478 /* Clear primary/secondary error status bits. */
@@ -498,7 +481,7 @@ static irqreturn_t schizo_ce_intr(int irq, void *dev_id)
498 SCHIZO_CEAFSR_SPIO | SCHIZO_CEAFSR_SDMA); 481 SCHIZO_CEAFSR_SPIO | SCHIZO_CEAFSR_SDMA);
499 if (!error_bits) 482 if (!error_bits)
500 return IRQ_NONE; 483 return IRQ_NONE;
501 schizo_write(afsr_reg, error_bits); 484 upa_writeq(error_bits, afsr_reg);
502 485
503 /* Log the error. */ 486 /* Log the error. */
504 printk("%s: Correctable Error, primary error type[%s]\n", 487 printk("%s: Correctable Error, primary error type[%s]\n",
@@ -600,7 +583,7 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
600 u16 stat; 583 u16 stat;
601 584
602 csr_reg = pbm->pbm_regs + SCHIZO_PCI_CTRL; 585 csr_reg = pbm->pbm_regs + SCHIZO_PCI_CTRL;
603 csr = schizo_read(csr_reg); 586 csr = upa_readq(csr_reg);
604 csr_error_bits = 587 csr_error_bits =
605 csr & (SCHIZO_PCICTRL_BUS_UNUS | 588 csr & (SCHIZO_PCICTRL_BUS_UNUS |
606 SCHIZO_PCICTRL_TTO_ERR | 589 SCHIZO_PCICTRL_TTO_ERR |
@@ -610,7 +593,7 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
610 SCHIZO_PCICTRL_SERR); 593 SCHIZO_PCICTRL_SERR);
611 if (csr_error_bits) { 594 if (csr_error_bits) {
612 /* Clear the errors. */ 595 /* Clear the errors. */
613 schizo_write(csr_reg, csr); 596 upa_writeq(csr, csr_reg);
614 597
615 /* Log 'em. */ 598 /* Log 'em. */
616 if (csr_error_bits & SCHIZO_PCICTRL_BUS_UNUS) 599 if (csr_error_bits & SCHIZO_PCICTRL_BUS_UNUS)
@@ -650,7 +633,6 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
650static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id) 633static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id)
651{ 634{
652 struct pci_pbm_info *pbm = dev_id; 635 struct pci_pbm_info *pbm = dev_id;
653 struct pci_controller_info *p = pbm->parent;
654 unsigned long afsr_reg, afar_reg, base; 636 unsigned long afsr_reg, afar_reg, base;
655 unsigned long afsr, afar, error_bits; 637 unsigned long afsr, afar, error_bits;
656 int reported; 638 int reported;
@@ -661,8 +643,8 @@ static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id)
661 afar_reg = base + SCHIZO_PCI_AFAR; 643 afar_reg = base + SCHIZO_PCI_AFAR;
662 644
663 /* Latch error status. */ 645 /* Latch error status. */
664 afar = schizo_read(afar_reg); 646 afar = upa_readq(afar_reg);
665 afsr = schizo_read(afsr_reg); 647 afsr = upa_readq(afsr_reg);
666 648
667 /* Clear primary/secondary error status bits. */ 649 /* Clear primary/secondary error status bits. */
668 error_bits = afsr & 650 error_bits = afsr &
@@ -674,7 +656,7 @@ static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id)
674 SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS); 656 SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS);
675 if (!error_bits) 657 if (!error_bits)
676 return schizo_pcierr_intr_other(pbm); 658 return schizo_pcierr_intr_other(pbm);
677 schizo_write(afsr_reg, error_bits); 659 upa_writeq(error_bits, afsr_reg);
678 660
679 /* Log the error. */ 661 /* Log the error. */
680 printk("%s: PCI Error, primary error type[%s]\n", 662 printk("%s: PCI Error, primary error type[%s]\n",
@@ -744,7 +726,7 @@ static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id)
744 * a bug in the IOMMU support code or a PCI device driver. 726 * a bug in the IOMMU support code or a PCI device driver.
745 */ 727 */
746 if (error_bits & (SCHIZO_PCIAFSR_PTA | SCHIZO_PCIAFSR_STA)) { 728 if (error_bits & (SCHIZO_PCIAFSR_PTA | SCHIZO_PCIAFSR_STA)) {
747 schizo_check_iommu_error(p, PCI_ERR); 729 schizo_check_iommu_error(pbm, PCI_ERR);
748 pci_scan_for_target_abort(pbm, pbm->pci_bus); 730 pci_scan_for_target_abort(pbm, pbm->pci_bus);
749 } 731 }
750 if (error_bits & (SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_SMA)) 732 if (error_bits & (SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_SMA))
@@ -805,12 +787,11 @@ static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id)
805static irqreturn_t schizo_safarierr_intr(int irq, void *dev_id) 787static irqreturn_t schizo_safarierr_intr(int irq, void *dev_id)
806{ 788{
807 struct pci_pbm_info *pbm = dev_id; 789 struct pci_pbm_info *pbm = dev_id;
808 struct pci_controller_info *p = pbm->parent;
809 u64 errlog; 790 u64 errlog;
810 791
811 errlog = schizo_read(pbm->controller_regs + SCHIZO_SAFARI_ERRLOG); 792 errlog = upa_readq(pbm->controller_regs + SCHIZO_SAFARI_ERRLOG);
812 schizo_write(pbm->controller_regs + SCHIZO_SAFARI_ERRLOG, 793 upa_writeq(errlog & ~(SAFARI_ERRLOG_ERROUT),
813 errlog & ~(SAFARI_ERRLOG_ERROUT)); 794 pbm->controller_regs + SCHIZO_SAFARI_ERRLOG);
814 795
815 if (!(errlog & BUS_ERROR_UNMAP)) { 796 if (!(errlog & BUS_ERROR_UNMAP)) {
816 printk("%s: Unexpected Safari/JBUS error interrupt, errlog[%016lx]\n", 797 printk("%s: Unexpected Safari/JBUS error interrupt, errlog[%016lx]\n",
@@ -821,7 +802,7 @@ static irqreturn_t schizo_safarierr_intr(int irq, void *dev_id)
821 802
822 printk("%s: Safari/JBUS interrupt, UNMAPPED error, interrogating IOMMUs.\n", 803 printk("%s: Safari/JBUS interrupt, UNMAPPED error, interrogating IOMMUs.\n",
823 pbm->name); 804 pbm->name);
824 schizo_check_iommu_error(p, SAFARI_ERR); 805 schizo_check_iommu_error(pbm, SAFARI_ERR);
825 806
826 return IRQ_HANDLED; 807 return IRQ_HANDLED;
827} 808}
@@ -863,7 +844,7 @@ static int pbm_routes_this_ino(struct pci_pbm_info *pbm, u32 ino)
863 */ 844 */
864static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm) 845static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
865{ 846{
866 struct of_device *op = of_find_device_by_node(pbm->prom_node); 847 struct of_device *op = of_find_device_by_node(pbm->op->node);
867 u64 tmp, err_mask, err_no_mask; 848 u64 tmp, err_mask, err_no_mask;
868 int err; 849 int err;
869 850
@@ -910,10 +891,9 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
910 } 891 }
911 892
912 /* Enable UE and CE interrupts for controller. */ 893 /* Enable UE and CE interrupts for controller. */
913 schizo_write(pbm->controller_regs + SCHIZO_ECC_CTRL, 894 upa_writeq((SCHIZO_ECCCTRL_EE |
914 (SCHIZO_ECCCTRL_EE | 895 SCHIZO_ECCCTRL_UE |
915 SCHIZO_ECCCTRL_UE | 896 SCHIZO_ECCCTRL_CE), pbm->controller_regs + SCHIZO_ECC_CTRL);
916 SCHIZO_ECCCTRL_CE));
917 897
918 /* Enable PCI Error interrupts and clear error 898 /* Enable PCI Error interrupts and clear error
919 * bits. 899 * bits.
@@ -926,10 +906,10 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
926 906
927 err_no_mask = SCHIZO_PCICTRL_DTO_ERR; 907 err_no_mask = SCHIZO_PCICTRL_DTO_ERR;
928 908
929 tmp = schizo_read(pbm->pbm_regs + SCHIZO_PCI_CTRL); 909 tmp = upa_readq(pbm->pbm_regs + SCHIZO_PCI_CTRL);
930 tmp |= err_mask; 910 tmp |= err_mask;
931 tmp &= ~err_no_mask; 911 tmp &= ~err_no_mask;
932 schizo_write(pbm->pbm_regs + SCHIZO_PCI_CTRL, tmp); 912 upa_writeq(tmp, pbm->pbm_regs + SCHIZO_PCI_CTRL);
933 913
934 err_mask = (SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_PTA | 914 err_mask = (SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_PTA |
935 SCHIZO_PCIAFSR_PRTRY | SCHIZO_PCIAFSR_PPERR | 915 SCHIZO_PCIAFSR_PRTRY | SCHIZO_PCIAFSR_PPERR |
@@ -938,7 +918,7 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
938 SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR | 918 SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
939 SCHIZO_PCIAFSR_STTO); 919 SCHIZO_PCIAFSR_STTO);
940 920
941 schizo_write(pbm->pbm_regs + SCHIZO_PCI_AFSR, err_mask); 921 upa_writeq(err_mask, pbm->pbm_regs + SCHIZO_PCI_AFSR);
942 922
943 err_mask = (BUS_ERROR_BADCMD | BUS_ERROR_SNOOP_GR | 923 err_mask = (BUS_ERROR_BADCMD | BUS_ERROR_SNOOP_GR |
944 BUS_ERROR_SNOOP_PCI | BUS_ERROR_SNOOP_RD | 924 BUS_ERROR_SNOOP_PCI | BUS_ERROR_SNOOP_RD |
@@ -950,16 +930,16 @@ static void tomatillo_register_error_handlers(struct pci_pbm_info *pbm)
950 BUS_ERROR_APERR | BUS_ERROR_UNMAP | 930 BUS_ERROR_APERR | BUS_ERROR_UNMAP |
951 BUS_ERROR_BUSERR | BUS_ERROR_TIMEOUT); 931 BUS_ERROR_BUSERR | BUS_ERROR_TIMEOUT);
952 932
953 schizo_write(pbm->controller_regs + SCHIZO_SAFARI_ERRCTRL, 933 upa_writeq((SCHIZO_SAFERRCTRL_EN | err_mask),
954 (SCHIZO_SAFERRCTRL_EN | err_mask)); 934 pbm->controller_regs + SCHIZO_SAFARI_ERRCTRL);
955 935
956 schizo_write(pbm->controller_regs + SCHIZO_SAFARI_IRQCTRL, 936 upa_writeq((SCHIZO_SAFIRQCTRL_EN | (BUS_ERROR_UNMAP)),
957 (SCHIZO_SAFIRQCTRL_EN | (BUS_ERROR_UNMAP))); 937 pbm->controller_regs + SCHIZO_SAFARI_IRQCTRL);
958} 938}
959 939
960static void schizo_register_error_handlers(struct pci_pbm_info *pbm) 940static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
961{ 941{
962 struct of_device *op = of_find_device_by_node(pbm->prom_node); 942 struct of_device *op = of_find_device_by_node(pbm->op->node);
963 u64 tmp, err_mask, err_no_mask; 943 u64 tmp, err_mask, err_no_mask;
964 int err; 944 int err;
965 945
@@ -1006,10 +986,9 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
1006 } 986 }
1007 987
1008 /* Enable UE and CE interrupts for controller. */ 988 /* Enable UE and CE interrupts for controller. */
1009 schizo_write(pbm->controller_regs + SCHIZO_ECC_CTRL, 989 upa_writeq((SCHIZO_ECCCTRL_EE |
1010 (SCHIZO_ECCCTRL_EE | 990 SCHIZO_ECCCTRL_UE |
1011 SCHIZO_ECCCTRL_UE | 991 SCHIZO_ECCCTRL_CE), pbm->controller_regs + SCHIZO_ECC_CTRL);
1012 SCHIZO_ECCCTRL_CE));
1013 992
1014 err_mask = (SCHIZO_PCICTRL_BUS_UNUS | 993 err_mask = (SCHIZO_PCICTRL_BUS_UNUS |
1015 SCHIZO_PCICTRL_ESLCK | 994 SCHIZO_PCICTRL_ESLCK |
@@ -1025,18 +1004,18 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
1025 /* Enable PCI Error interrupts and clear error 1004 /* Enable PCI Error interrupts and clear error
1026 * bits for each PBM. 1005 * bits for each PBM.
1027 */ 1006 */
1028 tmp = schizo_read(pbm->pbm_regs + SCHIZO_PCI_CTRL); 1007 tmp = upa_readq(pbm->pbm_regs + SCHIZO_PCI_CTRL);
1029 tmp |= err_mask; 1008 tmp |= err_mask;
1030 tmp &= ~err_no_mask; 1009 tmp &= ~err_no_mask;
1031 schizo_write(pbm->pbm_regs + SCHIZO_PCI_CTRL, tmp); 1010 upa_writeq(tmp, pbm->pbm_regs + SCHIZO_PCI_CTRL);
1032 1011
1033 schizo_write(pbm->pbm_regs + SCHIZO_PCI_AFSR, 1012 upa_writeq((SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_PTA |
1034 (SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_PTA | 1013 SCHIZO_PCIAFSR_PRTRY | SCHIZO_PCIAFSR_PPERR |
1035 SCHIZO_PCIAFSR_PRTRY | SCHIZO_PCIAFSR_PPERR | 1014 SCHIZO_PCIAFSR_PTTO | SCHIZO_PCIAFSR_PUNUS |
1036 SCHIZO_PCIAFSR_PTTO | SCHIZO_PCIAFSR_PUNUS | 1015 SCHIZO_PCIAFSR_SMA | SCHIZO_PCIAFSR_STA |
1037 SCHIZO_PCIAFSR_SMA | SCHIZO_PCIAFSR_STA | 1016 SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
1038 SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR | 1017 SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS),
1039 SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS)); 1018 pbm->pbm_regs + SCHIZO_PCI_AFSR);
1040 1019
1041 /* Make all Safari error conditions fatal except unmapped 1020 /* Make all Safari error conditions fatal except unmapped
1042 * errors which we make generate interrupts. 1021 * errors which we make generate interrupts.
@@ -1063,8 +1042,8 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
1063 BUS_ERROR_CPU0PS | BUS_ERROR_CPU0PB); 1042 BUS_ERROR_CPU0PS | BUS_ERROR_CPU0PB);
1064#endif 1043#endif
1065 1044
1066 schizo_write(pbm->controller_regs + SCHIZO_SAFARI_ERRCTRL, 1045 upa_writeq((SCHIZO_SAFERRCTRL_EN | err_mask),
1067 (SCHIZO_SAFERRCTRL_EN | err_mask)); 1046 pbm->controller_regs + SCHIZO_SAFARI_ERRCTRL);
1068} 1047}
1069 1048
1070static void pbm_config_busmastering(struct pci_pbm_info *pbm) 1049static void pbm_config_busmastering(struct pci_pbm_info *pbm)
@@ -1084,14 +1063,15 @@ static void pbm_config_busmastering(struct pci_pbm_info *pbm)
1084 pci_config_write8(addr, 64); 1063 pci_config_write8(addr, 64);
1085} 1064}
1086 1065
1087static void __init schizo_scan_bus(struct pci_pbm_info *pbm) 1066static void __devinit schizo_scan_bus(struct pci_pbm_info *pbm,
1067 struct device *parent)
1088{ 1068{
1089 pbm_config_busmastering(pbm); 1069 pbm_config_busmastering(pbm);
1090 pbm->is_66mhz_capable = 1070 pbm->is_66mhz_capable =
1091 (of_find_property(pbm->prom_node, "66mhz-capable", NULL) 1071 (of_find_property(pbm->op->node, "66mhz-capable", NULL)
1092 != NULL); 1072 != NULL);
1093 1073
1094 pbm->pci_bus = pci_scan_one_pbm(pbm); 1074 pbm->pci_bus = pci_scan_one_pbm(pbm, parent);
1095 1075
1096 if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO) 1076 if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO)
1097 tomatillo_register_error_handlers(pbm); 1077 tomatillo_register_error_handlers(pbm);
@@ -1133,12 +1113,12 @@ static void schizo_pbm_strbuf_init(struct pci_pbm_info *pbm)
1133 * streaming buffer and leave the rerun-disable 1113 * streaming buffer and leave the rerun-disable
1134 * setting however OBP set it. 1114 * setting however OBP set it.
1135 */ 1115 */
1136 control = schizo_read(pbm->stc.strbuf_control); 1116 control = upa_readq(pbm->stc.strbuf_control);
1137 control &= ~(SCHIZO_STRBUF_CTRL_LPTR | 1117 control &= ~(SCHIZO_STRBUF_CTRL_LPTR |
1138 SCHIZO_STRBUF_CTRL_LENAB | 1118 SCHIZO_STRBUF_CTRL_LENAB |
1139 SCHIZO_STRBUF_CTRL_DENAB); 1119 SCHIZO_STRBUF_CTRL_DENAB);
1140 control |= SCHIZO_STRBUF_CTRL_ENAB; 1120 control |= SCHIZO_STRBUF_CTRL_ENAB;
1141 schizo_write(pbm->stc.strbuf_control, control); 1121 upa_writeq(control, pbm->stc.strbuf_control);
1142 1122
1143 pbm->stc.strbuf_enabled = 1; 1123 pbm->stc.strbuf_enabled = 1;
1144} 1124}
@@ -1150,24 +1130,17 @@ static void schizo_pbm_strbuf_init(struct pci_pbm_info *pbm)
1150 1130
1151static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm) 1131static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1152{ 1132{
1153 struct iommu *iommu = pbm->iommu; 1133 static const u32 vdma_default[] = { 0xc0000000, 0x40000000 };
1154 unsigned long i, tagbase, database; 1134 unsigned long i, tagbase, database;
1155 struct property *prop; 1135 struct iommu *iommu = pbm->iommu;
1156 u32 vdma[2], dma_mask;
1157 int tsbsize, err; 1136 int tsbsize, err;
1137 const u32 *vdma;
1138 u32 dma_mask;
1158 u64 control; 1139 u64 control;
1159 1140
1160 prop = of_find_property(pbm->prom_node, "virtual-dma", NULL); 1141 vdma = of_get_property(pbm->op->node, "virtual-dma", NULL);
1161 if (prop) { 1142 if (!vdma)
1162 u32 *val = prop->value; 1143 vdma = vdma_default;
1163
1164 vdma[0] = val[0];
1165 vdma[1] = val[1];
1166 } else {
1167 /* No property, use default values. */
1168 vdma[0] = 0xc0000000;
1169 vdma[1] = 0x40000000;
1170 }
1171 1144
1172 dma_mask = vdma[0]; 1145 dma_mask = vdma[0];
1173 switch (vdma[1]) { 1146 switch (vdma[1]) {
@@ -1187,9 +1160,9 @@ static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1187 break; 1160 break;
1188 1161
1189 default: 1162 default:
1190 prom_printf("SCHIZO: strange virtual-dma size.\n"); 1163 printk(KERN_ERR PFX "Strange virtual-dma size.\n");
1191 prom_halt(); 1164 return -EINVAL;
1192 }; 1165 }
1193 1166
1194 /* Register addresses, SCHIZO has iommu ctx flushing. */ 1167 /* Register addresses, SCHIZO has iommu ctx flushing. */
1195 iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL; 1168 iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL;
@@ -1206,15 +1179,15 @@ static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1206 /* 1179 /*
1207 * Invalidate TLB Entries. 1180 * Invalidate TLB Entries.
1208 */ 1181 */
1209 control = schizo_read(iommu->iommu_control); 1182 control = upa_readq(iommu->iommu_control);
1210 control |= SCHIZO_IOMMU_CTRL_DENAB; 1183 control |= SCHIZO_IOMMU_CTRL_DENAB;
1211 schizo_write(iommu->iommu_control, control); 1184 upa_writeq(control, iommu->iommu_control);
1212 1185
1213 tagbase = SCHIZO_IOMMU_TAG, database = SCHIZO_IOMMU_DATA; 1186 tagbase = SCHIZO_IOMMU_TAG, database = SCHIZO_IOMMU_DATA;
1214 1187
1215 for(i = 0; i < 16; i++) { 1188 for (i = 0; i < 16; i++) {
1216 schizo_write(pbm->pbm_regs + tagbase + (i * 8UL), 0); 1189 upa_writeq(0, pbm->pbm_regs + tagbase + (i * 8UL));
1217 schizo_write(pbm->pbm_regs + database + (i * 8UL), 0); 1190 upa_writeq(0, pbm->pbm_regs + database + (i * 8UL));
1218 } 1191 }
1219 1192
1220 /* Leave diag mode enabled for full-flushing done 1193 /* Leave diag mode enabled for full-flushing done
@@ -1222,12 +1195,14 @@ static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1222 */ 1195 */
1223 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask, 1196 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask,
1224 pbm->numa_node); 1197 pbm->numa_node);
1225 if (err) 1198 if (err) {
1199 printk(KERN_ERR PFX "iommu_table_init() fails with %d\n", err);
1226 return err; 1200 return err;
1201 }
1227 1202
1228 schizo_write(iommu->iommu_tsbbase, __pa(iommu->page_table)); 1203 upa_writeq(__pa(iommu->page_table), iommu->iommu_tsbbase);
1229 1204
1230 control = schizo_read(iommu->iommu_control); 1205 control = upa_readq(iommu->iommu_control);
1231 control &= ~(SCHIZO_IOMMU_CTRL_TSBSZ | SCHIZO_IOMMU_CTRL_TBWSZ); 1206 control &= ~(SCHIZO_IOMMU_CTRL_TSBSZ | SCHIZO_IOMMU_CTRL_TBWSZ);
1232 switch (tsbsize) { 1207 switch (tsbsize) {
1233 case 64: 1208 case 64:
@@ -1236,10 +1211,10 @@ static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1236 case 128: 1211 case 128:
1237 control |= SCHIZO_IOMMU_TSBSZ_128K; 1212 control |= SCHIZO_IOMMU_TSBSZ_128K;
1238 break; 1213 break;
1239 }; 1214 }
1240 1215
1241 control |= SCHIZO_IOMMU_CTRL_ENAB; 1216 control |= SCHIZO_IOMMU_CTRL_ENAB;
1242 schizo_write(iommu->iommu_control, control); 1217 upa_writeq(control, iommu->iommu_control);
1243 1218
1244 return 0; 1219 return 0;
1245} 1220}
@@ -1280,12 +1255,11 @@ static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1280 1255
1281static void schizo_pbm_hw_init(struct pci_pbm_info *pbm) 1256static void schizo_pbm_hw_init(struct pci_pbm_info *pbm)
1282{ 1257{
1283 struct property *prop;
1284 u64 tmp; 1258 u64 tmp;
1285 1259
1286 schizo_write(pbm->pbm_regs + SCHIZO_PCI_IRQ_RETRY, 5); 1260 upa_writeq(5, pbm->pbm_regs + SCHIZO_PCI_IRQ_RETRY);
1287 1261
1288 tmp = schizo_read(pbm->pbm_regs + SCHIZO_PCI_CTRL); 1262 tmp = upa_readq(pbm->pbm_regs + SCHIZO_PCI_CTRL);
1289 1263
1290 /* Enable arbiter for all PCI slots. */ 1264 /* Enable arbiter for all PCI slots. */
1291 tmp |= 0xff; 1265 tmp |= 0xff;
@@ -1294,8 +1268,7 @@ static void schizo_pbm_hw_init(struct pci_pbm_info *pbm)
1294 pbm->chip_version >= 0x2) 1268 pbm->chip_version >= 0x2)
1295 tmp |= 0x3UL << SCHIZO_PCICTRL_PTO_SHIFT; 1269 tmp |= 0x3UL << SCHIZO_PCICTRL_PTO_SHIFT;
1296 1270
1297 prop = of_find_property(pbm->prom_node, "no-bus-parking", NULL); 1271 if (!of_find_property(pbm->op->node, "no-bus-parking", NULL))
1298 if (!prop)
1299 tmp |= SCHIZO_PCICTRL_PARK; 1272 tmp |= SCHIZO_PCICTRL_PARK;
1300 else 1273 else
1301 tmp &= ~SCHIZO_PCICTRL_PARK; 1274 tmp &= ~SCHIZO_PCICTRL_PARK;
@@ -1311,13 +1284,13 @@ static void schizo_pbm_hw_init(struct pci_pbm_info *pbm)
1311 SCHIZO_PCICTRL_RDO_PREF | 1284 SCHIZO_PCICTRL_RDO_PREF |
1312 SCHIZO_PCICTRL_RDL_PREF); 1285 SCHIZO_PCICTRL_RDL_PREF);
1313 1286
1314 schizo_write(pbm->pbm_regs + SCHIZO_PCI_CTRL, tmp); 1287 upa_writeq(tmp, pbm->pbm_regs + SCHIZO_PCI_CTRL);
1315 1288
1316 tmp = schizo_read(pbm->pbm_regs + SCHIZO_PCI_DIAG); 1289 tmp = upa_readq(pbm->pbm_regs + SCHIZO_PCI_DIAG);
1317 tmp &= ~(SCHIZO_PCIDIAG_D_RTRYARB | 1290 tmp &= ~(SCHIZO_PCIDIAG_D_RTRYARB |
1318 SCHIZO_PCIDIAG_D_RETRY | 1291 SCHIZO_PCIDIAG_D_RETRY |
1319 SCHIZO_PCIDIAG_D_INTSYNC); 1292 SCHIZO_PCIDIAG_D_INTSYNC);
1320 schizo_write(pbm->pbm_regs + SCHIZO_PCI_DIAG, tmp); 1293 upa_writeq(tmp, pbm->pbm_regs + SCHIZO_PCI_DIAG);
1321 1294
1322 if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO) { 1295 if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO) {
1323 /* Clear prefetch lengths to workaround a bug in 1296 /* Clear prefetch lengths to workaround a bug in
@@ -1329,17 +1302,16 @@ static void schizo_pbm_hw_init(struct pci_pbm_info *pbm)
1329 TOMATILLO_IOC_RDONE_CPENAB | 1302 TOMATILLO_IOC_RDONE_CPENAB |
1330 TOMATILLO_IOC_RDLINE_CPENAB); 1303 TOMATILLO_IOC_RDLINE_CPENAB);
1331 1304
1332 schizo_write(pbm->pbm_regs + TOMATILLO_PCI_IOC_CSR, 1305 upa_writeq(tmp, pbm->pbm_regs + TOMATILLO_PCI_IOC_CSR);
1333 tmp);
1334 } 1306 }
1335} 1307}
1336 1308
1337static int __init schizo_pbm_init(struct pci_controller_info *p, 1309static int __devinit schizo_pbm_init(struct pci_pbm_info *pbm,
1338 struct device_node *dp, u32 portid, 1310 struct of_device *op, u32 portid,
1339 int chip_type) 1311 int chip_type)
1340{ 1312{
1341 const struct linux_prom64_registers *regs; 1313 const struct linux_prom64_registers *regs;
1342 struct pci_pbm_info *pbm; 1314 struct device_node *dp = op->node;
1343 const char *chipset_name; 1315 const char *chipset_name;
1344 int is_pbm_a, err; 1316 int is_pbm_a, err;
1345 1317
@@ -1372,25 +1344,19 @@ static int __init schizo_pbm_init(struct pci_controller_info *p,
1372 regs = of_get_property(dp, "reg", NULL); 1344 regs = of_get_property(dp, "reg", NULL);
1373 1345
1374 is_pbm_a = ((regs[0].phys_addr & 0x00700000) == 0x00600000); 1346 is_pbm_a = ((regs[0].phys_addr & 0x00700000) == 0x00600000);
1375 if (is_pbm_a)
1376 pbm = &p->pbm_A;
1377 else
1378 pbm = &p->pbm_B;
1379 1347
1380 pbm->next = pci_pbm_root; 1348 pbm->next = pci_pbm_root;
1381 pci_pbm_root = pbm; 1349 pci_pbm_root = pbm;
1382 1350
1383 pbm->numa_node = -1; 1351 pbm->numa_node = -1;
1384 1352
1385 pbm->scan_bus = schizo_scan_bus;
1386 pbm->pci_ops = &sun4u_pci_ops; 1353 pbm->pci_ops = &sun4u_pci_ops;
1387 pbm->config_space_reg_bits = 8; 1354 pbm->config_space_reg_bits = 8;
1388 1355
1389 pbm->index = pci_num_pbms++; 1356 pbm->index = pci_num_pbms++;
1390 1357
1391 pbm->portid = portid; 1358 pbm->portid = portid;
1392 pbm->parent = p; 1359 pbm->op = op;
1393 pbm->prom_node = dp;
1394 1360
1395 pbm->chip_type = chip_type; 1361 pbm->chip_type = chip_type;
1396 pbm->chip_version = of_getintprop_default(dp, "version#", 0); 1362 pbm->chip_version = of_getintprop_default(dp, "version#", 0);
@@ -1420,6 +1386,8 @@ static int __init schizo_pbm_init(struct pci_controller_info *p,
1420 1386
1421 schizo_pbm_strbuf_init(pbm); 1387 schizo_pbm_strbuf_init(pbm);
1422 1388
1389 schizo_scan_bus(pbm, &op->dev);
1390
1423 return 0; 1391 return 0;
1424} 1392}
1425 1393
@@ -1433,62 +1401,104 @@ static inline int portid_compare(u32 x, u32 y, int chip_type)
1433 return (x == y); 1401 return (x == y);
1434} 1402}
1435 1403
1436static void __init __schizo_init(struct device_node *dp, char *model_name, 1404static struct pci_pbm_info * __devinit schizo_find_sibling(u32 portid,
1437 int chip_type) 1405 int chip_type)
1438{ 1406{
1439 struct pci_controller_info *p; 1407 struct pci_pbm_info *pbm;
1408
1409 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) {
1410 if (portid_compare(pbm->portid, portid, chip_type))
1411 return pbm;
1412 }
1413 return NULL;
1414}
1415
1416static int __devinit __schizo_init(struct of_device *op, unsigned long chip_type)
1417{
1418 struct device_node *dp = op->node;
1440 struct pci_pbm_info *pbm; 1419 struct pci_pbm_info *pbm;
1441 struct iommu *iommu; 1420 struct iommu *iommu;
1442 u32 portid; 1421 u32 portid;
1422 int err;
1443 1423
1444 portid = of_getintprop_default(dp, "portid", 0xff); 1424 portid = of_getintprop_default(dp, "portid", 0xff);
1445 1425
1446 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) { 1426 err = -ENOMEM;
1447 if (portid_compare(pbm->portid, portid, chip_type)) { 1427 pbm = kzalloc(sizeof(*pbm), GFP_KERNEL);
1448 if (schizo_pbm_init(pbm->parent, dp, 1428 if (!pbm) {
1449 portid, chip_type)) 1429 printk(KERN_ERR PFX "Cannot allocate pci_pbm_info.\n");
1450 goto fatal_memory_error; 1430 goto out_err;
1451 return; 1431 }
1452 } 1432
1433 pbm->sibling = schizo_find_sibling(portid, chip_type);
1434
1435 iommu = kzalloc(sizeof(struct iommu), GFP_KERNEL);
1436 if (!iommu) {
1437 printk(KERN_ERR PFX "Cannot allocate PBM A iommu.\n");
1438 goto out_free_pbm;
1453 } 1439 }
1454 1440
1455 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); 1441 pbm->iommu = iommu;
1456 if (!p)
1457 goto fatal_memory_error;
1458 1442
1459 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 1443 if (schizo_pbm_init(pbm, op, portid, chip_type))
1460 if (!iommu) 1444 goto out_free_iommu;
1461 goto fatal_memory_error;
1462 1445
1463 p->pbm_A.iommu = iommu; 1446 if (pbm->sibling)
1447 pbm->sibling->sibling = pbm;
1464 1448
1465 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 1449 dev_set_drvdata(&op->dev, pbm);
1466 if (!iommu)
1467 goto fatal_memory_error;
1468 1450
1469 p->pbm_B.iommu = iommu; 1451 return 0;
1470 1452
1471 if (schizo_pbm_init(p, dp, portid, chip_type)) 1453out_free_iommu:
1472 goto fatal_memory_error; 1454 kfree(pbm->iommu);
1473 1455
1474 return; 1456out_free_pbm:
1457 kfree(pbm);
1475 1458
1476fatal_memory_error: 1459out_err:
1477 prom_printf("SCHIZO: Fatal memory allocation error.\n"); 1460 return err;
1478 prom_halt();
1479} 1461}
1480 1462
1481void __init schizo_init(struct device_node *dp, char *model_name) 1463static int __devinit schizo_probe(struct of_device *op,
1464 const struct of_device_id *match)
1482{ 1465{
1483 __schizo_init(dp, model_name, PBM_CHIP_TYPE_SCHIZO); 1466 return __schizo_init(op, (unsigned long) match->data);
1484} 1467}
1485 1468
1486void __init schizo_plus_init(struct device_node *dp, char *model_name) 1469/* The ordering of this table is very important. Some Tomatillo
1487{ 1470 * nodes announce that they are compatible with both pci108e,a801
1488 __schizo_init(dp, model_name, PBM_CHIP_TYPE_SCHIZO_PLUS); 1471 * and pci108e,8001. So list the chips in reverse chronological
1489} 1472 * order.
1473 */
1474static struct of_device_id __initdata schizo_match[] = {
1475 {
1476 .name = "pci",
1477 .compatible = "pci108e,a801",
1478 .data = (void *) PBM_CHIP_TYPE_TOMATILLO,
1479 },
1480 {
1481 .name = "pci",
1482 .compatible = "pci108e,8002",
1483 .data = (void *) PBM_CHIP_TYPE_SCHIZO_PLUS,
1484 },
1485 {
1486 .name = "pci",
1487 .compatible = "pci108e,8001",
1488 .data = (void *) PBM_CHIP_TYPE_SCHIZO,
1489 },
1490 {},
1491};
1490 1492
1491void __init tomatillo_init(struct device_node *dp, char *model_name) 1493static struct of_platform_driver schizo_driver = {
1494 .name = DRIVER_NAME,
1495 .match_table = schizo_match,
1496 .probe = schizo_probe,
1497};
1498
1499static int __init schizo_init(void)
1492{ 1500{
1493 __schizo_init(dp, model_name, PBM_CHIP_TYPE_TOMATILLO); 1501 return of_register_driver(&schizo_driver, &of_bus_type);
1494} 1502}
1503
1504subsys_initcall(schizo_init);
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index a104c80d319d..e86c73ec167b 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -13,12 +13,10 @@
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/msi.h> 14#include <linux/msi.h>
15#include <linux/log2.h> 15#include <linux/log2.h>
16#include <linux/of_device.h>
16 17
17#include <asm/iommu.h> 18#include <asm/iommu.h>
18#include <asm/irq.h> 19#include <asm/irq.h>
19#include <asm/upa.h>
20#include <asm/pstate.h>
21#include <asm/oplib.h>
22#include <asm/hypervisor.h> 20#include <asm/hypervisor.h>
23#include <asm/prom.h> 21#include <asm/prom.h>
24 22
@@ -27,6 +25,9 @@
27 25
28#include "pci_sun4v.h" 26#include "pci_sun4v.h"
29 27
28#define DRIVER_NAME "pci_sun4v"
29#define PFX DRIVER_NAME ": "
30
30static unsigned long vpci_major = 1; 31static unsigned long vpci_major = 1;
31static unsigned long vpci_minor = 1; 32static unsigned long vpci_minor = 1;
32 33
@@ -41,6 +42,7 @@ struct iommu_batch {
41}; 42};
42 43
43static DEFINE_PER_CPU(struct iommu_batch, iommu_batch); 44static DEFINE_PER_CPU(struct iommu_batch, iommu_batch);
45static int iommu_batch_initialized;
44 46
45/* Interrupts must be disabled. */ 47/* Interrupts must be disabled. */
46static inline void iommu_batch_start(struct device *dev, unsigned long prot, unsigned long entry) 48static inline void iommu_batch_start(struct device *dev, unsigned long prot, unsigned long entry)
@@ -542,15 +544,16 @@ static const struct dma_ops sun4v_dma_ops = {
542 .sync_sg_for_cpu = dma_4v_sync_sg_for_cpu, 544 .sync_sg_for_cpu = dma_4v_sync_sg_for_cpu,
543}; 545};
544 546
545static void __init pci_sun4v_scan_bus(struct pci_pbm_info *pbm) 547static void __init pci_sun4v_scan_bus(struct pci_pbm_info *pbm,
548 struct device *parent)
546{ 549{
547 struct property *prop; 550 struct property *prop;
548 struct device_node *dp; 551 struct device_node *dp;
549 552
550 dp = pbm->prom_node; 553 dp = pbm->op->node;
551 prop = of_find_property(dp, "66mhz-capable", NULL); 554 prop = of_find_property(dp, "66mhz-capable", NULL);
552 pbm->is_66mhz_capable = (prop != NULL); 555 pbm->is_66mhz_capable = (prop != NULL);
553 pbm->pci_bus = pci_scan_one_pbm(pbm); 556 pbm->pci_bus = pci_scan_one_pbm(pbm, parent);
554 557
555 /* XXX register error interrupt handlers XXX */ 558 /* XXX register error interrupt handlers XXX */
556} 559}
@@ -583,29 +586,22 @@ static unsigned long __init probe_existing_entries(struct pci_pbm_info *pbm,
583 return cnt; 586 return cnt;
584} 587}
585 588
586static void __init pci_sun4v_iommu_init(struct pci_pbm_info *pbm) 589static int __init pci_sun4v_iommu_init(struct pci_pbm_info *pbm)
587{ 590{
591 static const u32 vdma_default[] = { 0x80000000, 0x80000000 };
588 struct iommu *iommu = pbm->iommu; 592 struct iommu *iommu = pbm->iommu;
589 struct property *prop;
590 unsigned long num_tsb_entries, sz, tsbsize; 593 unsigned long num_tsb_entries, sz, tsbsize;
591 u32 vdma[2], dma_mask, dma_offset; 594 u32 dma_mask, dma_offset;
592 595 const u32 *vdma;
593 prop = of_find_property(pbm->prom_node, "virtual-dma", NULL); 596
594 if (prop) { 597 vdma = of_get_property(pbm->op->node, "virtual-dma", NULL);
595 u32 *val = prop->value; 598 if (!vdma)
596 599 vdma = vdma_default;
597 vdma[0] = val[0];
598 vdma[1] = val[1];
599 } else {
600 /* No property, use default values. */
601 vdma[0] = 0x80000000;
602 vdma[1] = 0x80000000;
603 }
604 600
605 if ((vdma[0] | vdma[1]) & ~IO_PAGE_MASK) { 601 if ((vdma[0] | vdma[1]) & ~IO_PAGE_MASK) {
606 prom_printf("PCI-SUN4V: strange virtual-dma[%08x:%08x].\n", 602 printk(KERN_ERR PFX "Strange virtual-dma[%08x:%08x].\n",
607 vdma[0], vdma[1]); 603 vdma[0], vdma[1]);
608 prom_halt(); 604 return -EINVAL;
609 }; 605 };
610 606
611 dma_mask = (roundup_pow_of_two(vdma[1]) - 1UL); 607 dma_mask = (roundup_pow_of_two(vdma[1]) - 1UL);
@@ -625,8 +621,8 @@ static void __init pci_sun4v_iommu_init(struct pci_pbm_info *pbm)
625 sz = (sz + 7UL) & ~7UL; 621 sz = (sz + 7UL) & ~7UL;
626 iommu->arena.map = kzalloc(sz, GFP_KERNEL); 622 iommu->arena.map = kzalloc(sz, GFP_KERNEL);
627 if (!iommu->arena.map) { 623 if (!iommu->arena.map) {
628 prom_printf("PCI_IOMMU: Error, kmalloc(arena.map) failed.\n"); 624 printk(KERN_ERR PFX "Error, kmalloc(arena.map) failed.\n");
629 prom_halt(); 625 return -ENOMEM;
630 } 626 }
631 iommu->arena.limit = num_tsb_entries; 627 iommu->arena.limit = num_tsb_entries;
632 628
@@ -634,6 +630,8 @@ static void __init pci_sun4v_iommu_init(struct pci_pbm_info *pbm)
634 if (sz) 630 if (sz)
635 printk("%s: Imported %lu TSB entries from OBP\n", 631 printk("%s: Imported %lu TSB entries from OBP\n",
636 pbm->name, sz); 632 pbm->name, sz);
633
634 return 0;
637} 635}
638 636
639#ifdef CONFIG_PCI_MSI 637#ifdef CONFIG_PCI_MSI
@@ -890,29 +888,20 @@ static void pci_sun4v_msi_init(struct pci_pbm_info *pbm)
890} 888}
891#endif /* !(CONFIG_PCI_MSI) */ 889#endif /* !(CONFIG_PCI_MSI) */
892 890
893static void __init pci_sun4v_pbm_init(struct pci_controller_info *p, 891static int __init pci_sun4v_pbm_init(struct pci_pbm_info *pbm,
894 struct device_node *dp, u32 devhandle) 892 struct of_device *op, u32 devhandle)
895{ 893{
896 struct pci_pbm_info *pbm; 894 struct device_node *dp = op->node;
897 895 int err;
898 if (devhandle & 0x40)
899 pbm = &p->pbm_B;
900 else
901 pbm = &p->pbm_A;
902
903 pbm->next = pci_pbm_root;
904 pci_pbm_root = pbm;
905 896
906 pbm->numa_node = of_node_to_nid(dp); 897 pbm->numa_node = of_node_to_nid(dp);
907 898
908 pbm->scan_bus = pci_sun4v_scan_bus;
909 pbm->pci_ops = &sun4v_pci_ops; 899 pbm->pci_ops = &sun4v_pci_ops;
910 pbm->config_space_reg_bits = 12; 900 pbm->config_space_reg_bits = 12;
911 901
912 pbm->index = pci_num_pbms++; 902 pbm->index = pci_num_pbms++;
913 903
914 pbm->parent = p; 904 pbm->op = op;
915 pbm->prom_node = dp;
916 905
917 pbm->devhandle = devhandle; 906 pbm->devhandle = devhandle;
918 907
@@ -924,82 +913,120 @@ static void __init pci_sun4v_pbm_init(struct pci_controller_info *p,
924 pci_determine_mem_io_space(pbm); 913 pci_determine_mem_io_space(pbm);
925 914
926 pci_get_pbm_props(pbm); 915 pci_get_pbm_props(pbm);
927 pci_sun4v_iommu_init(pbm); 916
917 err = pci_sun4v_iommu_init(pbm);
918 if (err)
919 return err;
920
928 pci_sun4v_msi_init(pbm); 921 pci_sun4v_msi_init(pbm);
922
923 pci_sun4v_scan_bus(pbm, &op->dev);
924
925 pbm->next = pci_pbm_root;
926 pci_pbm_root = pbm;
927
928 return 0;
929} 929}
930 930
931void __init sun4v_pci_init(struct device_node *dp, char *model_name) 931static int __devinit pci_sun4v_probe(struct of_device *op,
932 const struct of_device_id *match)
932{ 933{
934 const struct linux_prom64_registers *regs;
933 static int hvapi_negotiated = 0; 935 static int hvapi_negotiated = 0;
934 struct pci_controller_info *p;
935 struct pci_pbm_info *pbm; 936 struct pci_pbm_info *pbm;
937 struct device_node *dp;
936 struct iommu *iommu; 938 struct iommu *iommu;
937 struct property *prop;
938 struct linux_prom64_registers *regs;
939 u32 devhandle; 939 u32 devhandle;
940 int i; 940 int i, err;
941
942 dp = op->node;
941 943
942 if (!hvapi_negotiated++) { 944 if (!hvapi_negotiated++) {
943 int err = sun4v_hvapi_register(HV_GRP_PCI, 945 err = sun4v_hvapi_register(HV_GRP_PCI,
944 vpci_major, 946 vpci_major,
945 &vpci_minor); 947 &vpci_minor);
946 948
947 if (err) { 949 if (err) {
948 prom_printf("SUN4V_PCI: Could not register hvapi, " 950 printk(KERN_ERR PFX "Could not register hvapi, "
949 "err=%d\n", err); 951 "err=%d\n", err);
950 prom_halt(); 952 return err;
951 } 953 }
952 printk("SUN4V_PCI: Registered hvapi major[%lu] minor[%lu]\n", 954 printk(KERN_INFO PFX "Registered hvapi major[%lu] minor[%lu]\n",
953 vpci_major, vpci_minor); 955 vpci_major, vpci_minor);
954 956
955 dma_ops = &sun4v_dma_ops; 957 dma_ops = &sun4v_dma_ops;
956 } 958 }
957 959
958 prop = of_find_property(dp, "reg", NULL); 960 regs = of_get_property(dp, "reg", NULL);
959 if (!prop) { 961 err = -ENODEV;
960 prom_printf("SUN4V_PCI: Could not find config registers\n"); 962 if (!regs) {
961 prom_halt(); 963 printk(KERN_ERR PFX "Could not find config registers\n");
964 goto out_err;
962 } 965 }
963 regs = prop->value;
964
965 devhandle = (regs->phys_addr >> 32UL) & 0x0fffffff; 966 devhandle = (regs->phys_addr >> 32UL) & 0x0fffffff;
966 967
967 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) { 968 err = -ENOMEM;
968 if (pbm->devhandle == (devhandle ^ 0x40)) { 969 if (!iommu_batch_initialized) {
969 pci_sun4v_pbm_init(pbm->parent, dp, devhandle); 970 for_each_possible_cpu(i) {
970 return; 971 unsigned long page = get_zeroed_page(GFP_KERNEL);
972
973 if (!page)
974 goto out_err;
975
976 per_cpu(iommu_batch, i).pglist = (u64 *) page;
971 } 977 }
978 iommu_batch_initialized = 1;
972 } 979 }
973 980
974 for_each_possible_cpu(i) { 981 pbm = kzalloc(sizeof(*pbm), GFP_KERNEL);
975 unsigned long page = get_zeroed_page(GFP_ATOMIC); 982 if (!pbm) {
976 983 printk(KERN_ERR PFX "Could not allocate pci_pbm_info\n");
977 if (!page) 984 goto out_err;
978 goto fatal_memory_error; 985 }
979 986
980 per_cpu(iommu_batch, i).pglist = (u64 *) page; 987 iommu = kzalloc(sizeof(struct iommu), GFP_KERNEL);
988 if (!iommu) {
989 printk(KERN_ERR PFX "Could not allocate pbm iommu\n");
990 goto out_free_controller;
981 } 991 }
982 992
983 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); 993 pbm->iommu = iommu;
984 if (!p)
985 goto fatal_memory_error;
986 994
987 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 995 err = pci_sun4v_pbm_init(pbm, op, devhandle);
988 if (!iommu) 996 if (err)
989 goto fatal_memory_error; 997 goto out_free_iommu;
998
999 dev_set_drvdata(&op->dev, pbm);
1000
1001 return 0;
1002
1003out_free_iommu:
1004 kfree(pbm->iommu);
990 1005
991 p->pbm_A.iommu = iommu; 1006out_free_controller:
1007 kfree(pbm);
992 1008
993 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 1009out_err:
994 if (!iommu) 1010 return err;
995 goto fatal_memory_error; 1011}
996 1012
997 p->pbm_B.iommu = iommu; 1013static struct of_device_id __initdata pci_sun4v_match[] = {
1014 {
1015 .name = "pci",
1016 .compatible = "SUNW,sun4v-pci",
1017 },
1018 {},
1019};
998 1020
999 pci_sun4v_pbm_init(p, dp, devhandle); 1021static struct of_platform_driver pci_sun4v_driver = {
1000 return; 1022 .name = DRIVER_NAME,
1023 .match_table = pci_sun4v_match,
1024 .probe = pci_sun4v_probe,
1025};
1001 1026
1002fatal_memory_error: 1027static int __init pci_sun4v_init(void)
1003 prom_printf("SUN4V_PCI: Fatal memory allocation error.\n"); 1028{
1004 prom_halt(); 1029 return of_register_driver(&pci_sun4v_driver, &of_bus_type);
1005} 1030}
1031
1032subsys_initcall(pci_sun4v_init);
diff --git a/arch/sparc64/kernel/pci_sun4v_asm.S b/arch/sparc64/kernel/pci_sun4v_asm.S
index ecb81f389b06..e606d46c6815 100644
--- a/arch/sparc64/kernel/pci_sun4v_asm.S
+++ b/arch/sparc64/kernel/pci_sun4v_asm.S
@@ -1,8 +1,9 @@
1/* pci_sun4v_asm: Hypervisor calls for PCI support. 1/* pci_sun4v_asm: Hypervisor calls for PCI support.
2 * 2 *
3 * Copyright (C) 2006 David S. Miller <davem@davemloft.net> 3 * Copyright (C) 2006, 2008 David S. Miller <davem@davemloft.net>
4 */ 4 */
5 5
6#include <linux/linkage.h>
6#include <asm/hypervisor.h> 7#include <asm/hypervisor.h>
7 8
8 /* %o0: devhandle 9 /* %o0: devhandle
@@ -14,8 +15,7 @@
14 * returns %o0: -status if status was non-zero, else 15 * returns %o0: -status if status was non-zero, else
15 * %o0: num pages mapped 16 * %o0: num pages mapped
16 */ 17 */
17 .globl pci_sun4v_iommu_map 18ENTRY(pci_sun4v_iommu_map)
18pci_sun4v_iommu_map:
19 mov %o5, %g1 19 mov %o5, %g1
20 mov HV_FAST_PCI_IOMMU_MAP, %o5 20 mov HV_FAST_PCI_IOMMU_MAP, %o5
21 ta HV_FAST_TRAP 21 ta HV_FAST_TRAP
@@ -24,6 +24,7 @@ pci_sun4v_iommu_map:
24 mov %o1, %o0 24 mov %o1, %o0
251: retl 251: retl
26 nop 26 nop
27ENDPROC(pci_sun4v_iommu_map)
27 28
28 /* %o0: devhandle 29 /* %o0: devhandle
29 * %o1: tsbid 30 * %o1: tsbid
@@ -31,12 +32,12 @@ pci_sun4v_iommu_map:
31 * 32 *
32 * returns %o0: num ttes demapped 33 * returns %o0: num ttes demapped
33 */ 34 */
34 .globl pci_sun4v_iommu_demap 35ENTRY(pci_sun4v_iommu_demap)
35pci_sun4v_iommu_demap:
36 mov HV_FAST_PCI_IOMMU_DEMAP, %o5 36 mov HV_FAST_PCI_IOMMU_DEMAP, %o5
37 ta HV_FAST_TRAP 37 ta HV_FAST_TRAP
38 retl 38 retl
39 mov %o1, %o0 39 mov %o1, %o0
40ENDPROC(pci_sun4v_iommu_demap)
40 41
41 /* %o0: devhandle 42 /* %o0: devhandle
42 * %o1: tsbid 43 * %o1: tsbid
@@ -45,8 +46,7 @@ pci_sun4v_iommu_demap:
45 * 46 *
46 * returns %o0: status 47 * returns %o0: status
47 */ 48 */
48 .globl pci_sun4v_iommu_getmap 49ENTRY(pci_sun4v_iommu_getmap)
49pci_sun4v_iommu_getmap:
50 mov %o2, %o4 50 mov %o2, %o4
51 mov HV_FAST_PCI_IOMMU_GETMAP, %o5 51 mov HV_FAST_PCI_IOMMU_GETMAP, %o5
52 ta HV_FAST_TRAP 52 ta HV_FAST_TRAP
@@ -54,6 +54,7 @@ pci_sun4v_iommu_getmap:
54 stx %o2, [%o3] 54 stx %o2, [%o3]
55 retl 55 retl
56 mov %o0, %o0 56 mov %o0, %o0
57ENDPROC(pci_sun4v_iommu_getmap)
57 58
58 /* %o0: devhandle 59 /* %o0: devhandle
59 * %o1: pci_device 60 * %o1: pci_device
@@ -65,14 +66,14 @@ pci_sun4v_iommu_getmap:
65 * If there is an error, the data will be returned 66 * If there is an error, the data will be returned
66 * as all 1's. 67 * as all 1's.
67 */ 68 */
68 .globl pci_sun4v_config_get 69ENTRY(pci_sun4v_config_get)
69pci_sun4v_config_get:
70 mov HV_FAST_PCI_CONFIG_GET, %o5 70 mov HV_FAST_PCI_CONFIG_GET, %o5
71 ta HV_FAST_TRAP 71 ta HV_FAST_TRAP
72 brnz,a,pn %o1, 1f 72 brnz,a,pn %o1, 1f
73 mov -1, %o2 73 mov -1, %o2
741: retl 741: retl
75 mov %o2, %o0 75 mov %o2, %o0
76ENDPROC(pci_sun4v_config_get)
76 77
77 /* %o0: devhandle 78 /* %o0: devhandle
78 * %o1: pci_device 79 * %o1: pci_device
@@ -85,14 +86,14 @@ pci_sun4v_config_get:
85 * status will be zero if the operation completed 86 * status will be zero if the operation completed
86 * successfully, else -1 if not 87 * successfully, else -1 if not
87 */ 88 */
88 .globl pci_sun4v_config_put 89ENTRY(pci_sun4v_config_put)
89pci_sun4v_config_put:
90 mov HV_FAST_PCI_CONFIG_PUT, %o5 90 mov HV_FAST_PCI_CONFIG_PUT, %o5
91 ta HV_FAST_TRAP 91 ta HV_FAST_TRAP
92 brnz,a,pn %o1, 1f 92 brnz,a,pn %o1, 1f
93 mov -1, %o1 93 mov -1, %o1
941: retl 941: retl
95 mov %o1, %o0 95 mov %o1, %o0
96ENDPROC(pci_sun4v_config_put)
96 97
97 /* %o0: devhandle 98 /* %o0: devhandle
98 * %o1: msiqid 99 * %o1: msiqid
@@ -104,12 +105,12 @@ pci_sun4v_config_put:
104 * status will be zero if the operation completed 105 * status will be zero if the operation completed
105 * successfully, else -1 if not 106 * successfully, else -1 if not
106 */ 107 */
107 .globl pci_sun4v_msiq_conf 108ENTRY(pci_sun4v_msiq_conf)
108pci_sun4v_msiq_conf:
109 mov HV_FAST_PCI_MSIQ_CONF, %o5 109 mov HV_FAST_PCI_MSIQ_CONF, %o5
110 ta HV_FAST_TRAP 110 ta HV_FAST_TRAP
111 retl 111 retl
112 mov %o0, %o0 112 mov %o0, %o0
113ENDPROC(pci_sun4v_msiq_conf)
113 114
114 /* %o0: devhandle 115 /* %o0: devhandle
115 * %o1: msiqid 116 * %o1: msiqid
@@ -118,8 +119,7 @@ pci_sun4v_msiq_conf:
118 * 119 *
119 * returns %o0: status 120 * returns %o0: status
120 */ 121 */
121 .globl pci_sun4v_msiq_info 122ENTRY(pci_sun4v_msiq_info)
122pci_sun4v_msiq_info:
123 mov %o2, %o4 123 mov %o2, %o4
124 mov HV_FAST_PCI_MSIQ_INFO, %o5 124 mov HV_FAST_PCI_MSIQ_INFO, %o5
125 ta HV_FAST_TRAP 125 ta HV_FAST_TRAP
@@ -127,6 +127,7 @@ pci_sun4v_msiq_info:
127 stx %o2, [%o3] 127 stx %o2, [%o3]
128 retl 128 retl
129 mov %o0, %o0 129 mov %o0, %o0
130ENDPROC(pci_sun4v_msiq_info)
130 131
131 /* %o0: devhandle 132 /* %o0: devhandle
132 * %o1: msiqid 133 * %o1: msiqid
@@ -134,13 +135,13 @@ pci_sun4v_msiq_info:
134 * 135 *
135 * returns %o0: status 136 * returns %o0: status
136 */ 137 */
137 .globl pci_sun4v_msiq_getvalid 138ENTRY(pci_sun4v_msiq_getvalid)
138pci_sun4v_msiq_getvalid:
139 mov HV_FAST_PCI_MSIQ_GETVALID, %o5 139 mov HV_FAST_PCI_MSIQ_GETVALID, %o5
140 ta HV_FAST_TRAP 140 ta HV_FAST_TRAP
141 stx %o1, [%o2] 141 stx %o1, [%o2]
142 retl 142 retl
143 mov %o0, %o0 143 mov %o0, %o0
144ENDPROC(pci_sun4v_msiq_getvalid)
144 145
145 /* %o0: devhandle 146 /* %o0: devhandle
146 * %o1: msiqid 147 * %o1: msiqid
@@ -148,12 +149,12 @@ pci_sun4v_msiq_getvalid:
148 * 149 *
149 * returns %o0: status 150 * returns %o0: status
150 */ 151 */
151 .globl pci_sun4v_msiq_setvalid 152ENTRY(pci_sun4v_msiq_setvalid)
152pci_sun4v_msiq_setvalid:
153 mov HV_FAST_PCI_MSIQ_SETVALID, %o5 153 mov HV_FAST_PCI_MSIQ_SETVALID, %o5
154 ta HV_FAST_TRAP 154 ta HV_FAST_TRAP
155 retl 155 retl
156 mov %o0, %o0 156 mov %o0, %o0
157ENDPROC(pci_sun4v_msiq_setvalid)
157 158
158 /* %o0: devhandle 159 /* %o0: devhandle
159 * %o1: msiqid 160 * %o1: msiqid
@@ -161,13 +162,13 @@ pci_sun4v_msiq_setvalid:
161 * 162 *
162 * returns %o0: status 163 * returns %o0: status
163 */ 164 */
164 .globl pci_sun4v_msiq_getstate 165ENTRY(pci_sun4v_msiq_getstate)
165pci_sun4v_msiq_getstate:
166 mov HV_FAST_PCI_MSIQ_GETSTATE, %o5 166 mov HV_FAST_PCI_MSIQ_GETSTATE, %o5
167 ta HV_FAST_TRAP 167 ta HV_FAST_TRAP
168 stx %o1, [%o2] 168 stx %o1, [%o2]
169 retl 169 retl
170 mov %o0, %o0 170 mov %o0, %o0
171ENDPROC(pci_sun4v_msiq_getstate)
171 172
172 /* %o0: devhandle 173 /* %o0: devhandle
173 * %o1: msiqid 174 * %o1: msiqid
@@ -175,12 +176,12 @@ pci_sun4v_msiq_getstate:
175 * 176 *
176 * returns %o0: status 177 * returns %o0: status
177 */ 178 */
178 .globl pci_sun4v_msiq_setstate 179ENTRY(pci_sun4v_msiq_setstate)
179pci_sun4v_msiq_setstate:
180 mov HV_FAST_PCI_MSIQ_SETSTATE, %o5 180 mov HV_FAST_PCI_MSIQ_SETSTATE, %o5
181 ta HV_FAST_TRAP 181 ta HV_FAST_TRAP
182 retl 182 retl
183 mov %o0, %o0 183 mov %o0, %o0
184ENDPROC(pci_sun4v_msiq_setstate)
184 185
185 /* %o0: devhandle 186 /* %o0: devhandle
186 * %o1: msiqid 187 * %o1: msiqid
@@ -188,13 +189,13 @@ pci_sun4v_msiq_setstate:
188 * 189 *
189 * returns %o0: status 190 * returns %o0: status
190 */ 191 */
191 .globl pci_sun4v_msiq_gethead 192ENTRY(pci_sun4v_msiq_gethead)
192pci_sun4v_msiq_gethead:
193 mov HV_FAST_PCI_MSIQ_GETHEAD, %o5 193 mov HV_FAST_PCI_MSIQ_GETHEAD, %o5
194 ta HV_FAST_TRAP 194 ta HV_FAST_TRAP
195 stx %o1, [%o2] 195 stx %o1, [%o2]
196 retl 196 retl
197 mov %o0, %o0 197 mov %o0, %o0
198ENDPROC(pci_sun4v_msiq_gethead)
198 199
199 /* %o0: devhandle 200 /* %o0: devhandle
200 * %o1: msiqid 201 * %o1: msiqid
@@ -202,12 +203,12 @@ pci_sun4v_msiq_gethead:
202 * 203 *
203 * returns %o0: status 204 * returns %o0: status
204 */ 205 */
205 .globl pci_sun4v_msiq_sethead 206ENTRY(pci_sun4v_msiq_sethead)
206pci_sun4v_msiq_sethead:
207 mov HV_FAST_PCI_MSIQ_SETHEAD, %o5 207 mov HV_FAST_PCI_MSIQ_SETHEAD, %o5
208 ta HV_FAST_TRAP 208 ta HV_FAST_TRAP
209 retl 209 retl
210 mov %o0, %o0 210 mov %o0, %o0
211ENDPROC(pci_sun4v_msiq_sethead)
211 212
212 /* %o0: devhandle 213 /* %o0: devhandle
213 * %o1: msiqid 214 * %o1: msiqid
@@ -215,13 +216,13 @@ pci_sun4v_msiq_sethead:
215 * 216 *
216 * returns %o0: status 217 * returns %o0: status
217 */ 218 */
218 .globl pci_sun4v_msiq_gettail 219ENTRY(pci_sun4v_msiq_gettail)
219pci_sun4v_msiq_gettail:
220 mov HV_FAST_PCI_MSIQ_GETTAIL, %o5 220 mov HV_FAST_PCI_MSIQ_GETTAIL, %o5
221 ta HV_FAST_TRAP 221 ta HV_FAST_TRAP
222 stx %o1, [%o2] 222 stx %o1, [%o2]
223 retl 223 retl
224 mov %o0, %o0 224 mov %o0, %o0
225ENDPROC(pci_sun4v_msiq_gettail)
225 226
226 /* %o0: devhandle 227 /* %o0: devhandle
227 * %o1: msinum 228 * %o1: msinum
@@ -229,13 +230,13 @@ pci_sun4v_msiq_gettail:
229 * 230 *
230 * returns %o0: status 231 * returns %o0: status
231 */ 232 */
232 .globl pci_sun4v_msi_getvalid 233ENTRY(pci_sun4v_msi_getvalid)
233pci_sun4v_msi_getvalid:
234 mov HV_FAST_PCI_MSI_GETVALID, %o5 234 mov HV_FAST_PCI_MSI_GETVALID, %o5
235 ta HV_FAST_TRAP 235 ta HV_FAST_TRAP
236 stx %o1, [%o2] 236 stx %o1, [%o2]
237 retl 237 retl
238 mov %o0, %o0 238 mov %o0, %o0
239ENDPROC(pci_sun4v_msi_getvalid)
239 240
240 /* %o0: devhandle 241 /* %o0: devhandle
241 * %o1: msinum 242 * %o1: msinum
@@ -243,12 +244,12 @@ pci_sun4v_msi_getvalid:
243 * 244 *
244 * returns %o0: status 245 * returns %o0: status
245 */ 246 */
246 .globl pci_sun4v_msi_setvalid 247ENTRY(pci_sun4v_msi_setvalid)
247pci_sun4v_msi_setvalid:
248 mov HV_FAST_PCI_MSI_SETVALID, %o5 248 mov HV_FAST_PCI_MSI_SETVALID, %o5
249 ta HV_FAST_TRAP 249 ta HV_FAST_TRAP
250 retl 250 retl
251 mov %o0, %o0 251 mov %o0, %o0
252ENDPROC(pci_sun4v_msi_setvalid)
252 253
253 /* %o0: devhandle 254 /* %o0: devhandle
254 * %o1: msinum 255 * %o1: msinum
@@ -256,13 +257,13 @@ pci_sun4v_msi_setvalid:
256 * 257 *
257 * returns %o0: status 258 * returns %o0: status
258 */ 259 */
259 .globl pci_sun4v_msi_getmsiq 260ENTRY(pci_sun4v_msi_getmsiq)
260pci_sun4v_msi_getmsiq:
261 mov HV_FAST_PCI_MSI_GETMSIQ, %o5 261 mov HV_FAST_PCI_MSI_GETMSIQ, %o5
262 ta HV_FAST_TRAP 262 ta HV_FAST_TRAP
263 stx %o1, [%o2] 263 stx %o1, [%o2]
264 retl 264 retl
265 mov %o0, %o0 265 mov %o0, %o0
266ENDPROC(pci_sun4v_msi_getmsiq)
266 267
267 /* %o0: devhandle 268 /* %o0: devhandle
268 * %o1: msinum 269 * %o1: msinum
@@ -271,12 +272,12 @@ pci_sun4v_msi_getmsiq:
271 * 272 *
272 * returns %o0: status 273 * returns %o0: status
273 */ 274 */
274 .globl pci_sun4v_msi_setmsiq 275ENTRY(pci_sun4v_msi_setmsiq)
275pci_sun4v_msi_setmsiq:
276 mov HV_FAST_PCI_MSI_SETMSIQ, %o5 276 mov HV_FAST_PCI_MSI_SETMSIQ, %o5
277 ta HV_FAST_TRAP 277 ta HV_FAST_TRAP
278 retl 278 retl
279 mov %o0, %o0 279 mov %o0, %o0
280ENDPROC(pci_sun4v_msi_setmsiq)
280 281
281 /* %o0: devhandle 282 /* %o0: devhandle
282 * %o1: msinum 283 * %o1: msinum
@@ -284,13 +285,13 @@ pci_sun4v_msi_setmsiq:
284 * 285 *
285 * returns %o0: status 286 * returns %o0: status
286 */ 287 */
287 .globl pci_sun4v_msi_getstate 288ENTRY(pci_sun4v_msi_getstate)
288pci_sun4v_msi_getstate:
289 mov HV_FAST_PCI_MSI_GETSTATE, %o5 289 mov HV_FAST_PCI_MSI_GETSTATE, %o5
290 ta HV_FAST_TRAP 290 ta HV_FAST_TRAP
291 stx %o1, [%o2] 291 stx %o1, [%o2]
292 retl 292 retl
293 mov %o0, %o0 293 mov %o0, %o0
294ENDPROC(pci_sun4v_msi_getstate)
294 295
295 /* %o0: devhandle 296 /* %o0: devhandle
296 * %o1: msinum 297 * %o1: msinum
@@ -298,12 +299,12 @@ pci_sun4v_msi_getstate:
298 * 299 *
299 * returns %o0: status 300 * returns %o0: status
300 */ 301 */
301 .globl pci_sun4v_msi_setstate 302ENTRY(pci_sun4v_msi_setstate)
302pci_sun4v_msi_setstate:
303 mov HV_FAST_PCI_MSI_SETSTATE, %o5 303 mov HV_FAST_PCI_MSI_SETSTATE, %o5
304 ta HV_FAST_TRAP 304 ta HV_FAST_TRAP
305 retl 305 retl
306 mov %o0, %o0 306 mov %o0, %o0
307ENDPROC(pci_sun4v_msi_setstate)
307 308
308 /* %o0: devhandle 309 /* %o0: devhandle
309 * %o1: msinum 310 * %o1: msinum
@@ -311,13 +312,13 @@ pci_sun4v_msi_setstate:
311 * 312 *
312 * returns %o0: status 313 * returns %o0: status
313 */ 314 */
314 .globl pci_sun4v_msg_getmsiq 315ENTRY(pci_sun4v_msg_getmsiq)
315pci_sun4v_msg_getmsiq:
316 mov HV_FAST_PCI_MSG_GETMSIQ, %o5 316 mov HV_FAST_PCI_MSG_GETMSIQ, %o5
317 ta HV_FAST_TRAP 317 ta HV_FAST_TRAP
318 stx %o1, [%o2] 318 stx %o1, [%o2]
319 retl 319 retl
320 mov %o0, %o0 320 mov %o0, %o0
321ENDPROC(pci_sun4v_msg_getmsiq)
321 322
322 /* %o0: devhandle 323 /* %o0: devhandle
323 * %o1: msinum 324 * %o1: msinum
@@ -325,12 +326,12 @@ pci_sun4v_msg_getmsiq:
325 * 326 *
326 * returns %o0: status 327 * returns %o0: status
327 */ 328 */
328 .globl pci_sun4v_msg_setmsiq 329ENTRY(pci_sun4v_msg_setmsiq)
329pci_sun4v_msg_setmsiq:
330 mov HV_FAST_PCI_MSG_SETMSIQ, %o5 330 mov HV_FAST_PCI_MSG_SETMSIQ, %o5
331 ta HV_FAST_TRAP 331 ta HV_FAST_TRAP
332 retl 332 retl
333 mov %o0, %o0 333 mov %o0, %o0
334ENDPROC(pci_sun4v_msg_setmsiq)
334 335
335 /* %o0: devhandle 336 /* %o0: devhandle
336 * %o1: msinum 337 * %o1: msinum
@@ -338,13 +339,13 @@ pci_sun4v_msg_setmsiq:
338 * 339 *
339 * returns %o0: status 340 * returns %o0: status
340 */ 341 */
341 .globl pci_sun4v_msg_getvalid 342ENTRY(pci_sun4v_msg_getvalid)
342pci_sun4v_msg_getvalid:
343 mov HV_FAST_PCI_MSG_GETVALID, %o5 343 mov HV_FAST_PCI_MSG_GETVALID, %o5
344 ta HV_FAST_TRAP 344 ta HV_FAST_TRAP
345 stx %o1, [%o2] 345 stx %o1, [%o2]
346 retl 346 retl
347 mov %o0, %o0 347 mov %o0, %o0
348ENDPROC(pci_sun4v_msg_getvalid)
348 349
349 /* %o0: devhandle 350 /* %o0: devhandle
350 * %o1: msinum 351 * %o1: msinum
@@ -352,10 +353,10 @@ pci_sun4v_msg_getvalid:
352 * 353 *
353 * returns %o0: status 354 * returns %o0: status
354 */ 355 */
355 .globl pci_sun4v_msg_setvalid 356ENTRY(pci_sun4v_msg_setvalid)
356pci_sun4v_msg_setvalid:
357 mov HV_FAST_PCI_MSG_SETVALID, %o5 357 mov HV_FAST_PCI_MSG_SETVALID, %o5
358 ta HV_FAST_TRAP 358 ta HV_FAST_TRAP
359 retl 359 retl
360 mov %o0, %o0 360 mov %o0, %o0
361ENDPROC(pci_sun4v_msg_setvalid)
361 362
diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c
index 3bb987a6d03c..076cad7f9757 100644
--- a/arch/sparc64/kernel/power.c
+++ b/arch/sparc64/kernel/power.c
@@ -1,34 +1,17 @@
1/* power.c: Power management driver. 1/* power.c: Power management driver.
2 * 2 *
3 * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 1999, 2007, 2008 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/sched.h>
10#include <linux/signal.h>
11#include <linux/delay.h>
12#include <linux/interrupt.h> 9#include <linux/interrupt.h>
13#include <linux/pm.h>
14#include <linux/syscalls.h>
15#include <linux/reboot.h> 10#include <linux/reboot.h>
16#include <linux/of_device.h> 11#include <linux/of_device.h>
17 12
18#include <asm/system.h>
19#include <asm/auxio.h>
20#include <asm/prom.h> 13#include <asm/prom.h>
21#include <asm/io.h> 14#include <asm/io.h>
22#include <asm/sstate.h>
23#include <asm/reboot.h>
24
25#include <linux/unistd.h>
26
27/*
28 * sysctl - toggle power-off restriction for serial console
29 * systems in machine_power_off()
30 */
31int scons_pwroff = 1;
32 15
33static void __iomem *power_reg; 16static void __iomem *power_reg;
34 17
@@ -40,31 +23,6 @@ static irqreturn_t power_handler(int irq, void *dev_id)
40 return IRQ_HANDLED; 23 return IRQ_HANDLED;
41} 24}
42 25
43static void (*poweroff_method)(void) = machine_alt_power_off;
44
45void machine_power_off(void)
46{
47 sstate_poweroff();
48 if (strcmp(of_console_device->type, "serial") || scons_pwroff) {
49 if (power_reg) {
50 /* Both register bits seem to have the
51 * same effect, so until I figure out
52 * what the difference is...
53 */
54 writel(AUXIO_PCIO_CPWR_OFF | AUXIO_PCIO_SPWR_OFF, power_reg);
55 } else {
56 if (poweroff_method != NULL) {
57 poweroff_method();
58 /* not reached */
59 }
60 }
61 }
62 machine_halt();
63}
64
65void (*pm_power_off)(void) = machine_power_off;
66EXPORT_SYMBOL(pm_power_off);
67
68static int __init has_button_interrupt(unsigned int irq, struct device_node *dp) 26static int __init has_button_interrupt(unsigned int irq, struct device_node *dp)
69{ 27{
70 if (irq == 0xffffffff) 28 if (irq == 0xffffffff)
@@ -85,8 +43,6 @@ static int __devinit power_probe(struct of_device *op, const struct of_device_id
85 printk(KERN_INFO "%s: Control reg at %lx\n", 43 printk(KERN_INFO "%s: Control reg at %lx\n",
86 op->node->name, res->start); 44 op->node->name, res->start);
87 45
88 poweroff_method = machine_halt; /* able to use the standard halt */
89
90 if (has_button_interrupt(irq, op->node)) { 46 if (has_button_interrupt(irq, op->node)) {
91 if (request_irq(irq, 47 if (request_irq(irq,
92 power_handler, 0, "power", NULL) < 0) 48 power_handler, 0, "power", NULL) < 0)
@@ -96,7 +52,7 @@ static int __devinit power_probe(struct of_device *op, const struct of_device_id
96 return 0; 52 return 0;
97} 53}
98 54
99static struct of_device_id power_match[] = { 55static struct of_device_id __initdata power_match[] = {
100 { 56 {
101 .name = "power", 57 .name = "power",
102 }, 58 },
@@ -111,8 +67,9 @@ static struct of_platform_driver power_driver = {
111 }, 67 },
112}; 68};
113 69
114void __init power_init(void) 70static int __init power_init(void)
115{ 71{
116 of_register_driver(&power_driver, &of_platform_bus_type); 72 return of_register_driver(&power_driver, &of_platform_bus_type);
117 return;
118} 73}
74
75device_initcall(power_init);
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index 15f4178592e7..d5e2acef9877 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -22,7 +22,6 @@
22#include <linux/ptrace.h> 22#include <linux/ptrace.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/user.h> 24#include <linux/user.h>
25#include <linux/reboot.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/compat.h> 26#include <linux/compat.h>
28#include <linux/tick.h> 27#include <linux/tick.h>
@@ -31,7 +30,6 @@
31#include <linux/elfcore.h> 30#include <linux/elfcore.h>
32#include <linux/sysrq.h> 31#include <linux/sysrq.h>
33 32
34#include <asm/oplib.h>
35#include <asm/uaccess.h> 33#include <asm/uaccess.h>
36#include <asm/system.h> 34#include <asm/system.h>
37#include <asm/page.h> 35#include <asm/page.h>
@@ -46,8 +44,6 @@
46#include <asm/mmu_context.h> 44#include <asm/mmu_context.h>
47#include <asm/unistd.h> 45#include <asm/unistd.h>
48#include <asm/hypervisor.h> 46#include <asm/hypervisor.h>
49#include <asm/sstate.h>
50#include <asm/reboot.h>
51#include <asm/syscalls.h> 47#include <asm/syscalls.h>
52#include <asm/irq_regs.h> 48#include <asm/irq_regs.h>
53#include <asm/smp.h> 49#include <asm/smp.h>
@@ -115,35 +111,6 @@ void cpu_idle(void)
115 } 111 }
116} 112}
117 113
118void machine_halt(void)
119{
120 sstate_halt();
121 prom_halt();
122 panic("Halt failed!");
123}
124
125void machine_alt_power_off(void)
126{
127 sstate_poweroff();
128 prom_halt_power_off();
129 panic("Power-off failed!");
130}
131
132void machine_restart(char * cmd)
133{
134 char *p;
135
136 sstate_reboot();
137 p = strchr (reboot_command, '\n');
138 if (p) *p = 0;
139 if (cmd)
140 prom_reboot(cmd);
141 if (*reboot_command)
142 prom_reboot(reboot_command);
143 prom_reboot("");
144 panic("Reboot failed!");
145}
146
147#ifdef CONFIG_COMPAT 114#ifdef CONFIG_COMPAT
148static void show_regwindow32(struct pt_regs *regs) 115static void show_regwindow32(struct pt_regs *regs)
149{ 116{
@@ -248,7 +215,6 @@ static void __global_reg_self(struct thread_info *tp, struct pt_regs *regs,
248 global_reg_snapshot[this_cpu].o7 = regs->u_regs[UREG_I7]; 215 global_reg_snapshot[this_cpu].o7 = regs->u_regs[UREG_I7];
249 216
250 if (regs->tstate & TSTATE_PRIV) { 217 if (regs->tstate & TSTATE_PRIV) {
251 struct thread_info *tp = current_thread_info();
252 struct reg_window *rw; 218 struct reg_window *rw;
253 219
254 rw = (struct reg_window *) 220 rw = (struct reg_window *)
@@ -304,7 +270,6 @@ void __trigger_all_cpu_backtrace(void)
304 270
305 for_each_online_cpu(cpu) { 271 for_each_online_cpu(cpu) {
306 struct global_reg_snapshot *gp = &global_reg_snapshot[cpu]; 272 struct global_reg_snapshot *gp = &global_reg_snapshot[cpu];
307 struct thread_info *tp;
308 273
309 __global_reg_poll(gp); 274 __global_reg_poll(gp);
310 275
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index 7151513f156e..dbba82f9b142 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -38,7 +38,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
38{ 38{
39 struct device_node *np; 39 struct device_node *np;
40 40
41 for (np = allnodes; np != 0; np = np->allnext) 41 for (np = allnodes; np; np = np->allnext)
42 if (np->node == handle) 42 if (np->node == handle)
43 break; 43 break;
44 44
@@ -59,6 +59,9 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
59} 59}
60EXPORT_SYMBOL(of_getintprop_default); 60EXPORT_SYMBOL(of_getintprop_default);
61 61
62DEFINE_MUTEX(of_set_property_mutex);
63EXPORT_SYMBOL(of_set_property_mutex);
64
62int of_set_property(struct device_node *dp, const char *name, void *val, int len) 65int of_set_property(struct device_node *dp, const char *name, void *val, int len)
63{ 66{
64 struct property **prevp; 67 struct property **prevp;
@@ -82,7 +85,10 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
82 void *old_val = prop->value; 85 void *old_val = prop->value;
83 int ret; 86 int ret;
84 87
88 mutex_lock(&of_set_property_mutex);
85 ret = prom_setprop(dp->node, name, val, len); 89 ret = prom_setprop(dp->node, name, val, len);
90 mutex_unlock(&of_set_property_mutex);
91
86 err = -EINVAL; 92 err = -EINVAL;
87 if (ret >= 0) { 93 if (ret >= 0) {
88 prop->value = new_val; 94 prop->value = new_val;
@@ -945,22 +951,30 @@ static void __init irq_trans_init(struct device_node *dp)
945 for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) { 951 for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) {
946 struct irq_trans *t = &pci_irq_trans_table[i]; 952 struct irq_trans *t = &pci_irq_trans_table[i];
947 953
948 if (!strcmp(model, t->name)) 954 if (!strcmp(model, t->name)) {
949 return t->init(dp); 955 t->init(dp);
956 return;
957 }
950 } 958 }
951 } 959 }
952#endif 960#endif
953#ifdef CONFIG_SBUS 961#ifdef CONFIG_SBUS
954 if (!strcmp(dp->name, "sbus") || 962 if (!strcmp(dp->name, "sbus") ||
955 !strcmp(dp->name, "sbi")) 963 !strcmp(dp->name, "sbi")) {
956 return sbus_irq_trans_init(dp); 964 sbus_irq_trans_init(dp);
965 return;
966 }
957#endif 967#endif
958 if (!strcmp(dp->name, "fhc") && 968 if (!strcmp(dp->name, "fhc") &&
959 !strcmp(dp->parent->name, "central")) 969 !strcmp(dp->parent->name, "central")) {
960 return central_irq_trans_init(dp); 970 central_irq_trans_init(dp);
971 return;
972 }
961 if (!strcmp(dp->name, "virtual-devices") || 973 if (!strcmp(dp->name, "virtual-devices") ||
962 !strcmp(dp->name, "niu")) 974 !strcmp(dp->name, "niu")) {
963 return sun4v_vdev_irq_trans_init(dp); 975 sun4v_vdev_irq_trans_init(dp);
976 return;
977 }
964} 978}
965 979
966static int is_root_node(const struct device_node *dp) 980static int is_root_node(const struct device_node *dp)
@@ -1231,32 +1245,49 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
1231 1245
1232 if (parent != NULL) { 1246 if (parent != NULL) {
1233 if (!strcmp(parent->type, "pci") || 1247 if (!strcmp(parent->type, "pci") ||
1234 !strcmp(parent->type, "pciex")) 1248 !strcmp(parent->type, "pciex")) {
1235 return pci_path_component(dp, tmp_buf); 1249 pci_path_component(dp, tmp_buf);
1236 if (!strcmp(parent->type, "sbus")) 1250 return;
1237 return sbus_path_component(dp, tmp_buf); 1251 }
1238 if (!strcmp(parent->type, "upa")) 1252 if (!strcmp(parent->type, "sbus")) {
1239 return upa_path_component(dp, tmp_buf); 1253 sbus_path_component(dp, tmp_buf);
1240 if (!strcmp(parent->type, "ebus")) 1254 return;
1241 return ebus_path_component(dp, tmp_buf); 1255 }
1256 if (!strcmp(parent->type, "upa")) {
1257 upa_path_component(dp, tmp_buf);
1258 return;
1259 }
1260 if (!strcmp(parent->type, "ebus")) {
1261 ebus_path_component(dp, tmp_buf);
1262 return;
1263 }
1242 if (!strcmp(parent->name, "usb") || 1264 if (!strcmp(parent->name, "usb") ||
1243 !strcmp(parent->name, "hub")) 1265 !strcmp(parent->name, "hub")) {
1244 return usb_path_component(dp, tmp_buf); 1266 usb_path_component(dp, tmp_buf);
1245 if (!strcmp(parent->type, "i2c")) 1267 return;
1246 return i2c_path_component(dp, tmp_buf); 1268 }
1247 if (!strcmp(parent->type, "firewire")) 1269 if (!strcmp(parent->type, "i2c")) {
1248 return ieee1394_path_component(dp, tmp_buf); 1270 i2c_path_component(dp, tmp_buf);
1249 if (!strcmp(parent->type, "virtual-devices")) 1271 return;
1250 return vdev_path_component(dp, tmp_buf); 1272 }
1251 1273 if (!strcmp(parent->type, "firewire")) {
1274 ieee1394_path_component(dp, tmp_buf);
1275 return;
1276 }
1277 if (!strcmp(parent->type, "virtual-devices")) {
1278 vdev_path_component(dp, tmp_buf);
1279 return;
1280 }
1252 /* "isa" is handled with platform naming */ 1281 /* "isa" is handled with platform naming */
1253 } 1282 }
1254 1283
1255 /* Use platform naming convention. */ 1284 /* Use platform naming convention. */
1256 if (tlb_type == hypervisor) 1285 if (tlb_type == hypervisor) {
1257 return sun4v_path_component(dp, tmp_buf); 1286 sun4v_path_component(dp, tmp_buf);
1258 else 1287 return;
1259 return sun4u_path_component(dp, tmp_buf); 1288 } else {
1289 sun4u_path_component(dp, tmp_buf);
1290 }
1260} 1291}
1261 1292
1262static char * __init build_path_component(struct device_node *dp) 1293static char * __init build_path_component(struct device_node *dp)
diff --git a/arch/sparc64/kernel/psycho_common.c b/arch/sparc64/kernel/psycho_common.c
new file mode 100644
index 000000000000..790996428c14
--- /dev/null
+++ b/arch/sparc64/kernel/psycho_common.c
@@ -0,0 +1,470 @@
1/* psycho_common.c: Code common to PSYCHO and derivative PCI controllers.
2 *
3 * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
4 */
5#include <linux/kernel.h>
6#include <linux/interrupt.h>
7
8#include <asm/upa.h>
9
10#include "pci_impl.h"
11#include "iommu_common.h"
12#include "psycho_common.h"
13
14#define PSYCHO_STRBUF_CTRL_DENAB 0x0000000000000002UL
15#define PSYCHO_STCERR_WRITE 0x0000000000000002UL
16#define PSYCHO_STCERR_READ 0x0000000000000001UL
17#define PSYCHO_STCTAG_PPN 0x0fffffff00000000UL
18#define PSYCHO_STCTAG_VPN 0x00000000ffffe000UL
19#define PSYCHO_STCTAG_VALID 0x0000000000000002UL
20#define PSYCHO_STCTAG_WRITE 0x0000000000000001UL
21#define PSYCHO_STCLINE_LINDX 0x0000000001e00000UL
22#define PSYCHO_STCLINE_SPTR 0x00000000001f8000UL
23#define PSYCHO_STCLINE_LADDR 0x0000000000007f00UL
24#define PSYCHO_STCLINE_EPTR 0x00000000000000fcUL
25#define PSYCHO_STCLINE_VALID 0x0000000000000002UL
26#define PSYCHO_STCLINE_FOFN 0x0000000000000001UL
27
28static DEFINE_SPINLOCK(stc_buf_lock);
29static unsigned long stc_error_buf[128];
30static unsigned long stc_tag_buf[16];
31static unsigned long stc_line_buf[16];
32
33static void psycho_check_stc_error(struct pci_pbm_info *pbm)
34{
35 unsigned long err_base, tag_base, line_base;
36 struct strbuf *strbuf = &pbm->stc;
37 u64 control;
38 int i;
39
40 if (!strbuf->strbuf_control)
41 return;
42
43 err_base = strbuf->strbuf_err_stat;
44 tag_base = strbuf->strbuf_tag_diag;
45 line_base = strbuf->strbuf_line_diag;
46
47 spin_lock(&stc_buf_lock);
48
49 /* This is __REALLY__ dangerous. When we put the streaming
50 * buffer into diagnostic mode to probe it's tags and error
51 * status, we _must_ clear all of the line tag valid bits
52 * before re-enabling the streaming buffer. If any dirty data
53 * lives in the STC when we do this, we will end up
54 * invalidating it before it has a chance to reach main
55 * memory.
56 */
57 control = upa_readq(strbuf->strbuf_control);
58 upa_writeq(control | PSYCHO_STRBUF_CTRL_DENAB, strbuf->strbuf_control);
59 for (i = 0; i < 128; i++) {
60 u64 val;
61
62 val = upa_readq(err_base + (i * 8UL));
63 upa_writeq(0UL, err_base + (i * 8UL));
64 stc_error_buf[i] = val;
65 }
66 for (i = 0; i < 16; i++) {
67 stc_tag_buf[i] = upa_readq(tag_base + (i * 8UL));
68 stc_line_buf[i] = upa_readq(line_base + (i * 8UL));
69 upa_writeq(0UL, tag_base + (i * 8UL));
70 upa_writeq(0UL, line_base + (i * 8UL));
71 }
72
73 /* OK, state is logged, exit diagnostic mode. */
74 upa_writeq(control, strbuf->strbuf_control);
75
76 for (i = 0; i < 16; i++) {
77 int j, saw_error, first, last;
78
79 saw_error = 0;
80 first = i * 8;
81 last = first + 8;
82 for (j = first; j < last; j++) {
83 u64 errval = stc_error_buf[j];
84 if (errval != 0) {
85 saw_error++;
86 printk(KERN_ERR "%s: STC_ERR(%d)[wr(%d)"
87 "rd(%d)]\n",
88 pbm->name,
89 j,
90 (errval & PSYCHO_STCERR_WRITE) ? 1 : 0,
91 (errval & PSYCHO_STCERR_READ) ? 1 : 0);
92 }
93 }
94 if (saw_error != 0) {
95 u64 tagval = stc_tag_buf[i];
96 u64 lineval = stc_line_buf[i];
97 printk(KERN_ERR "%s: STC_TAG(%d)[PA(%016lx)VA(%08lx)"
98 "V(%d)W(%d)]\n",
99 pbm->name,
100 i,
101 ((tagval & PSYCHO_STCTAG_PPN) >> 19UL),
102 (tagval & PSYCHO_STCTAG_VPN),
103 ((tagval & PSYCHO_STCTAG_VALID) ? 1 : 0),
104 ((tagval & PSYCHO_STCTAG_WRITE) ? 1 : 0));
105 printk(KERN_ERR "%s: STC_LINE(%d)[LIDX(%lx)SP(%lx)"
106 "LADDR(%lx)EP(%lx)V(%d)FOFN(%d)]\n",
107 pbm->name,
108 i,
109 ((lineval & PSYCHO_STCLINE_LINDX) >> 21UL),
110 ((lineval & PSYCHO_STCLINE_SPTR) >> 15UL),
111 ((lineval & PSYCHO_STCLINE_LADDR) >> 8UL),
112 ((lineval & PSYCHO_STCLINE_EPTR) >> 2UL),
113 ((lineval & PSYCHO_STCLINE_VALID) ? 1 : 0),
114 ((lineval & PSYCHO_STCLINE_FOFN) ? 1 : 0));
115 }
116 }
117
118 spin_unlock(&stc_buf_lock);
119}
120
121#define PSYCHO_IOMMU_TAG 0xa580UL
122#define PSYCHO_IOMMU_DATA 0xa600UL
123
124static void psycho_record_iommu_tags_and_data(struct pci_pbm_info *pbm,
125 u64 *tag, u64 *data)
126{
127 int i;
128
129 for (i = 0; i < 16; i++) {
130 unsigned long base = pbm->controller_regs;
131 unsigned long off = i * 8UL;
132
133 tag[i] = upa_readq(base + PSYCHO_IOMMU_TAG+off);
134 data[i] = upa_readq(base + PSYCHO_IOMMU_DATA+off);
135
136 /* Now clear out the entry. */
137 upa_writeq(0, base + PSYCHO_IOMMU_TAG + off);
138 upa_writeq(0, base + PSYCHO_IOMMU_DATA + off);
139 }
140}
141
142#define PSYCHO_IOMMU_TAG_ERRSTS (0x3UL << 23UL)
143#define PSYCHO_IOMMU_TAG_ERR (0x1UL << 22UL)
144#define PSYCHO_IOMMU_TAG_WRITE (0x1UL << 21UL)
145#define PSYCHO_IOMMU_TAG_STREAM (0x1UL << 20UL)
146#define PSYCHO_IOMMU_TAG_SIZE (0x1UL << 19UL)
147#define PSYCHO_IOMMU_TAG_VPAGE 0x7ffffUL
148#define PSYCHO_IOMMU_DATA_VALID (1UL << 30UL)
149#define PSYCHO_IOMMU_DATA_CACHE (1UL << 28UL)
150#define PSYCHO_IOMMU_DATA_PPAGE 0xfffffffUL
151
152static void psycho_dump_iommu_tags_and_data(struct pci_pbm_info *pbm,
153 u64 *tag, u64 *data)
154{
155 int i;
156
157 for (i = 0; i < 16; i++) {
158 u64 tag_val, data_val;
159 const char *type_str;
160 tag_val = tag[i];
161 if (!(tag_val & PSYCHO_IOMMU_TAG_ERR))
162 continue;
163
164 data_val = data[i];
165 switch((tag_val & PSYCHO_IOMMU_TAG_ERRSTS) >> 23UL) {
166 case 0:
167 type_str = "Protection Error";
168 break;
169 case 1:
170 type_str = "Invalid Error";
171 break;
172 case 2:
173 type_str = "TimeOut Error";
174 break;
175 case 3:
176 default:
177 type_str = "ECC Error";
178 break;
179 }
180
181 printk(KERN_ERR "%s: IOMMU TAG(%d)[error(%s) wr(%d) "
182 "str(%d) sz(%dK) vpg(%08lx)]\n",
183 pbm->name, i, type_str,
184 ((tag_val & PSYCHO_IOMMU_TAG_WRITE) ? 1 : 0),
185 ((tag_val & PSYCHO_IOMMU_TAG_STREAM) ? 1 : 0),
186 ((tag_val & PSYCHO_IOMMU_TAG_SIZE) ? 64 : 8),
187 (tag_val & PSYCHO_IOMMU_TAG_VPAGE) << IOMMU_PAGE_SHIFT);
188 printk(KERN_ERR "%s: IOMMU DATA(%d)[valid(%d) cache(%d) "
189 "ppg(%016lx)]\n",
190 pbm->name, i,
191 ((data_val & PSYCHO_IOMMU_DATA_VALID) ? 1 : 0),
192 ((data_val & PSYCHO_IOMMU_DATA_CACHE) ? 1 : 0),
193 (data_val & PSYCHO_IOMMU_DATA_PPAGE)<<IOMMU_PAGE_SHIFT);
194 }
195}
196
197#define PSYCHO_IOMMU_CTRL_XLTESTAT 0x0000000006000000UL
198#define PSYCHO_IOMMU_CTRL_XLTEERR 0x0000000001000000UL
199
200void psycho_check_iommu_error(struct pci_pbm_info *pbm,
201 unsigned long afsr,
202 unsigned long afar,
203 enum psycho_error_type type)
204{
205 u64 control, iommu_tag[16], iommu_data[16];
206 struct iommu *iommu = pbm->iommu;
207 unsigned long flags;
208
209 spin_lock_irqsave(&iommu->lock, flags);
210 control = upa_readq(iommu->iommu_control);
211 if (control & PSYCHO_IOMMU_CTRL_XLTEERR) {
212 const char *type_str;
213
214 control &= ~PSYCHO_IOMMU_CTRL_XLTEERR;
215 upa_writeq(control, iommu->iommu_control);
216
217 switch ((control & PSYCHO_IOMMU_CTRL_XLTESTAT) >> 25UL) {
218 case 0:
219 type_str = "Protection Error";
220 break;
221 case 1:
222 type_str = "Invalid Error";
223 break;
224 case 2:
225 type_str = "TimeOut Error";
226 break;
227 case 3:
228 default:
229 type_str = "ECC Error";
230 break;
231 };
232 printk(KERN_ERR "%s: IOMMU Error, type[%s]\n",
233 pbm->name, type_str);
234
235 /* It is very possible for another DVMA to occur while
236 * we do this probe, and corrupt the system further.
237 * But we are so screwed at this point that we are
238 * likely to crash hard anyways, so get as much
239 * diagnostic information to the console as we can.
240 */
241 psycho_record_iommu_tags_and_data(pbm, iommu_tag, iommu_data);
242 psycho_dump_iommu_tags_and_data(pbm, iommu_tag, iommu_data);
243 }
244 psycho_check_stc_error(pbm);
245 spin_unlock_irqrestore(&iommu->lock, flags);
246}
247
248#define PSYCHO_PCICTRL_SBH_ERR 0x0000000800000000UL
249#define PSYCHO_PCICTRL_SERR 0x0000000400000000UL
250
251static irqreturn_t psycho_pcierr_intr_other(struct pci_pbm_info *pbm)
252{
253 irqreturn_t ret = IRQ_NONE;
254 u64 csr, csr_error_bits;
255 u16 stat, *addr;
256
257 csr = upa_readq(pbm->pci_csr);
258 csr_error_bits = csr & (PSYCHO_PCICTRL_SBH_ERR | PSYCHO_PCICTRL_SERR);
259 if (csr_error_bits) {
260 /* Clear the errors. */
261 upa_writeq(csr, pbm->pci_csr);
262
263 /* Log 'em. */
264 if (csr_error_bits & PSYCHO_PCICTRL_SBH_ERR)
265 printk(KERN_ERR "%s: PCI streaming byte hole "
266 "error asserted.\n", pbm->name);
267 if (csr_error_bits & PSYCHO_PCICTRL_SERR)
268 printk(KERN_ERR "%s: PCI SERR signal asserted.\n",
269 pbm->name);
270 ret = IRQ_HANDLED;
271 }
272 addr = psycho_pci_config_mkaddr(pbm, pbm->pci_first_busno,
273 0, PCI_STATUS);
274 pci_config_read16(addr, &stat);
275 if (stat & (PCI_STATUS_PARITY |
276 PCI_STATUS_SIG_TARGET_ABORT |
277 PCI_STATUS_REC_TARGET_ABORT |
278 PCI_STATUS_REC_MASTER_ABORT |
279 PCI_STATUS_SIG_SYSTEM_ERROR)) {
280 printk(KERN_ERR "%s: PCI bus error, PCI_STATUS[%04x]\n",
281 pbm->name, stat);
282 pci_config_write16(addr, 0xffff);
283 ret = IRQ_HANDLED;
284 }
285 return ret;
286}
287
288#define PSYCHO_PCIAFSR_PMA 0x8000000000000000UL
289#define PSYCHO_PCIAFSR_PTA 0x4000000000000000UL
290#define PSYCHO_PCIAFSR_PRTRY 0x2000000000000000UL
291#define PSYCHO_PCIAFSR_PPERR 0x1000000000000000UL
292#define PSYCHO_PCIAFSR_SMA 0x0800000000000000UL
293#define PSYCHO_PCIAFSR_STA 0x0400000000000000UL
294#define PSYCHO_PCIAFSR_SRTRY 0x0200000000000000UL
295#define PSYCHO_PCIAFSR_SPERR 0x0100000000000000UL
296#define PSYCHO_PCIAFSR_RESV1 0x00ff000000000000UL
297#define PSYCHO_PCIAFSR_BMSK 0x0000ffff00000000UL
298#define PSYCHO_PCIAFSR_BLK 0x0000000080000000UL
299#define PSYCHO_PCIAFSR_RESV2 0x0000000040000000UL
300#define PSYCHO_PCIAFSR_MID 0x000000003e000000UL
301#define PSYCHO_PCIAFSR_RESV3 0x0000000001ffffffUL
302
303irqreturn_t psycho_pcierr_intr(int irq, void *dev_id)
304{
305 struct pci_pbm_info *pbm = dev_id;
306 u64 afsr, afar, error_bits;
307 int reported;
308
309 afsr = upa_readq(pbm->pci_afsr);
310 afar = upa_readq(pbm->pci_afar);
311 error_bits = afsr &
312 (PSYCHO_PCIAFSR_PMA | PSYCHO_PCIAFSR_PTA |
313 PSYCHO_PCIAFSR_PRTRY | PSYCHO_PCIAFSR_PPERR |
314 PSYCHO_PCIAFSR_SMA | PSYCHO_PCIAFSR_STA |
315 PSYCHO_PCIAFSR_SRTRY | PSYCHO_PCIAFSR_SPERR);
316 if (!error_bits)
317 return psycho_pcierr_intr_other(pbm);
318 upa_writeq(error_bits, pbm->pci_afsr);
319 printk(KERN_ERR "%s: PCI Error, primary error type[%s]\n",
320 pbm->name,
321 (((error_bits & PSYCHO_PCIAFSR_PMA) ?
322 "Master Abort" :
323 ((error_bits & PSYCHO_PCIAFSR_PTA) ?
324 "Target Abort" :
325 ((error_bits & PSYCHO_PCIAFSR_PRTRY) ?
326 "Excessive Retries" :
327 ((error_bits & PSYCHO_PCIAFSR_PPERR) ?
328 "Parity Error" : "???"))))));
329 printk(KERN_ERR "%s: bytemask[%04lx] UPA_MID[%02lx] was_block(%d)\n",
330 pbm->name,
331 (afsr & PSYCHO_PCIAFSR_BMSK) >> 32UL,
332 (afsr & PSYCHO_PCIAFSR_MID) >> 25UL,
333 (afsr & PSYCHO_PCIAFSR_BLK) ? 1 : 0);
334 printk(KERN_ERR "%s: PCI AFAR [%016lx]\n", pbm->name, afar);
335 printk(KERN_ERR "%s: PCI Secondary errors [", pbm->name);
336 reported = 0;
337 if (afsr & PSYCHO_PCIAFSR_SMA) {
338 reported++;
339 printk("(Master Abort)");
340 }
341 if (afsr & PSYCHO_PCIAFSR_STA) {
342 reported++;
343 printk("(Target Abort)");
344 }
345 if (afsr & PSYCHO_PCIAFSR_SRTRY) {
346 reported++;
347 printk("(Excessive Retries)");
348 }
349 if (afsr & PSYCHO_PCIAFSR_SPERR) {
350 reported++;
351 printk("(Parity Error)");
352 }
353 if (!reported)
354 printk("(none)");
355 printk("]\n");
356
357 if (error_bits & (PSYCHO_PCIAFSR_PTA | PSYCHO_PCIAFSR_STA)) {
358 psycho_check_iommu_error(pbm, afsr, afar, PCI_ERR);
359 pci_scan_for_target_abort(pbm, pbm->pci_bus);
360 }
361 if (error_bits & (PSYCHO_PCIAFSR_PMA | PSYCHO_PCIAFSR_SMA))
362 pci_scan_for_master_abort(pbm, pbm->pci_bus);
363
364 if (error_bits & (PSYCHO_PCIAFSR_PPERR | PSYCHO_PCIAFSR_SPERR))
365 pci_scan_for_parity_error(pbm, pbm->pci_bus);
366
367 return IRQ_HANDLED;
368}
369
370static void psycho_iommu_flush(struct pci_pbm_info *pbm)
371{
372 int i;
373
374 for (i = 0; i < 16; i++) {
375 unsigned long off = i * 8;
376
377 upa_writeq(0, pbm->controller_regs + PSYCHO_IOMMU_TAG + off);
378 upa_writeq(0, pbm->controller_regs + PSYCHO_IOMMU_DATA + off);
379 }
380}
381
382#define PSYCHO_IOMMU_CONTROL 0x0200UL
383#define PSYCHO_IOMMU_CTRL_TSBSZ 0x0000000000070000UL
384#define PSYCHO_IOMMU_TSBSZ_1K 0x0000000000000000UL
385#define PSYCHO_IOMMU_TSBSZ_2K 0x0000000000010000UL
386#define PSYCHO_IOMMU_TSBSZ_4K 0x0000000000020000UL
387#define PSYCHO_IOMMU_TSBSZ_8K 0x0000000000030000UL
388#define PSYCHO_IOMMU_TSBSZ_16K 0x0000000000040000UL
389#define PSYCHO_IOMMU_TSBSZ_32K 0x0000000000050000UL
390#define PSYCHO_IOMMU_TSBSZ_64K 0x0000000000060000UL
391#define PSYCHO_IOMMU_TSBSZ_128K 0x0000000000070000UL
392#define PSYCHO_IOMMU_CTRL_TBWSZ 0x0000000000000004UL
393#define PSYCHO_IOMMU_CTRL_DENAB 0x0000000000000002UL
394#define PSYCHO_IOMMU_CTRL_ENAB 0x0000000000000001UL
395#define PSYCHO_IOMMU_FLUSH 0x0210UL
396#define PSYCHO_IOMMU_TSBBASE 0x0208UL
397
398int psycho_iommu_init(struct pci_pbm_info *pbm, int tsbsize,
399 u32 dvma_offset, u32 dma_mask,
400 unsigned long write_complete_offset)
401{
402 struct iommu *iommu = pbm->iommu;
403 u64 control;
404 int err;
405
406 iommu->iommu_control = pbm->controller_regs + PSYCHO_IOMMU_CONTROL;
407 iommu->iommu_tsbbase = pbm->controller_regs + PSYCHO_IOMMU_TSBBASE;
408 iommu->iommu_flush = pbm->controller_regs + PSYCHO_IOMMU_FLUSH;
409 iommu->iommu_tags = pbm->controller_regs + PSYCHO_IOMMU_TAG;
410 iommu->write_complete_reg = (pbm->controller_regs +
411 write_complete_offset);
412
413 iommu->iommu_ctxflush = 0;
414
415 control = upa_readq(iommu->iommu_control);
416 control |= PSYCHO_IOMMU_CTRL_DENAB;
417 upa_writeq(control, iommu->iommu_control);
418
419 psycho_iommu_flush(pbm);
420
421 /* Leave diag mode enabled for full-flushing done in pci_iommu.c */
422 err = iommu_table_init(iommu, tsbsize * 1024 * 8,
423 dvma_offset, dma_mask, pbm->numa_node);
424 if (err)
425 return err;
426
427 upa_writeq(__pa(iommu->page_table), iommu->iommu_tsbbase);
428
429 control = upa_readq(iommu->iommu_control);
430 control &= ~(PSYCHO_IOMMU_CTRL_TSBSZ | PSYCHO_IOMMU_CTRL_TBWSZ);
431 control |= PSYCHO_IOMMU_CTRL_ENAB;
432
433 switch (tsbsize) {
434 case 64:
435 control |= PSYCHO_IOMMU_TSBSZ_64K;
436 break;
437 case 128:
438 control |= PSYCHO_IOMMU_TSBSZ_128K;
439 break;
440 default:
441 return -EINVAL;
442 }
443
444 upa_writeq(control, iommu->iommu_control);
445
446 return 0;
447
448}
449
450void psycho_pbm_init_common(struct pci_pbm_info *pbm, struct of_device *op,
451 const char *chip_name, int chip_type)
452{
453 struct device_node *dp = op->node;
454
455 pbm->name = dp->full_name;
456 pbm->numa_node = -1;
457 pbm->chip_type = chip_type;
458 pbm->chip_version = of_getintprop_default(dp, "version#", 0);
459 pbm->chip_revision = of_getintprop_default(dp, "module-revision#", 0);
460 pbm->op = op;
461 pbm->pci_ops = &sun4u_pci_ops;
462 pbm->config_space_reg_bits = 8;
463 pbm->index = pci_num_pbms++;
464 pci_get_pbm_props(pbm);
465 pci_determine_mem_io_space(pbm);
466
467 printk(KERN_INFO "%s: %s PCI Bus Module ver[%x:%x]\n",
468 pbm->name, chip_name,
469 pbm->chip_version, pbm->chip_revision);
470}
diff --git a/arch/sparc64/kernel/psycho_common.h b/arch/sparc64/kernel/psycho_common.h
new file mode 100644
index 000000000000..092c278ef28d
--- /dev/null
+++ b/arch/sparc64/kernel/psycho_common.h
@@ -0,0 +1,48 @@
1#ifndef _PSYCHO_COMMON_H
2#define _PSYCHO_COMMON_H
3
4/* U2P Programmer's Manual, page 13-55, configuration space
5 * address format:
6 *
7 * 32 24 23 16 15 11 10 8 7 2 1 0
8 * ---------------------------------------------------------
9 * |0 0 0 0 0 0 0 0 1| bus | device | function | reg | 0 0 |
10 * ---------------------------------------------------------
11 */
12#define PSYCHO_CONFIG_BASE(PBM) \
13 ((PBM)->config_space | (1UL << 24))
14#define PSYCHO_CONFIG_ENCODE(BUS, DEVFN, REG) \
15 (((unsigned long)(BUS) << 16) | \
16 ((unsigned long)(DEVFN) << 8) | \
17 ((unsigned long)(REG)))
18
19static inline void *psycho_pci_config_mkaddr(struct pci_pbm_info *pbm,
20 unsigned char bus,
21 unsigned int devfn,
22 int where)
23{
24 return (void *)
25 (PSYCHO_CONFIG_BASE(pbm) |
26 PSYCHO_CONFIG_ENCODE(bus, devfn, where));
27}
28
29enum psycho_error_type {
30 UE_ERR, CE_ERR, PCI_ERR
31};
32
33extern void psycho_check_iommu_error(struct pci_pbm_info *pbm,
34 unsigned long afsr,
35 unsigned long afar,
36 enum psycho_error_type type);
37
38extern irqreturn_t psycho_pcierr_intr(int irq, void *dev_id);
39
40extern int psycho_iommu_init(struct pci_pbm_info *pbm, int tsbsize,
41 u32 dvma_offset, u32 dma_mask,
42 unsigned long write_complete_offset);
43
44extern void psycho_pbm_init_common(struct pci_pbm_info *pbm,
45 struct of_device *op,
46 const char *chip_name, int chip_type);
47
48#endif /* _PSYCHO_COMMON_H */
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
index 10306e476e38..f43adbc773ca 100644
--- a/arch/sparc64/kernel/ptrace.c
+++ b/arch/sparc64/kernel/ptrace.c
@@ -1050,31 +1050,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1050 return ret; 1050 return ret;
1051} 1051}
1052 1052
1053asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p) 1053asmlinkage int syscall_trace_enter(struct pt_regs *regs)
1054{ 1054{
1055 int ret = 0; 1055 int ret = 0;
1056 1056
1057 /* do the secure computing check first */ 1057 /* do the secure computing check first */
1058 secure_computing(regs->u_regs[UREG_G1]); 1058 secure_computing(regs->u_regs[UREG_G1]);
1059 1059
1060 if (unlikely(current->audit_context) && syscall_exit_p) { 1060 if (test_thread_flag(TIF_SYSCALL_TRACE))
1061 unsigned long tstate = regs->tstate; 1061 ret = tracehook_report_syscall_entry(regs);
1062 int result = AUDITSC_SUCCESS;
1063
1064 if (unlikely(tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
1065 result = AUDITSC_FAILURE;
1066
1067 audit_syscall_exit(result, regs->u_regs[UREG_I0]);
1068 }
1069
1070 if (test_thread_flag(TIF_SYSCALL_TRACE)) {
1071 if (syscall_exit_p)
1072 tracehook_report_syscall_exit(regs, 0);
1073 else
1074 ret = tracehook_report_syscall_entry(regs);
1075 }
1076 1062
1077 if (unlikely(current->audit_context) && !syscall_exit_p && !ret) 1063 if (unlikely(current->audit_context) && !ret)
1078 audit_syscall_entry((test_thread_flag(TIF_32BIT) ? 1064 audit_syscall_entry((test_thread_flag(TIF_32BIT) ?
1079 AUDIT_ARCH_SPARC : 1065 AUDIT_ARCH_SPARC :
1080 AUDIT_ARCH_SPARC64), 1066 AUDIT_ARCH_SPARC64),
@@ -1086,3 +1072,19 @@ asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p)
1086 1072
1087 return ret; 1073 return ret;
1088} 1074}
1075
1076asmlinkage void syscall_trace_leave(struct pt_regs *regs)
1077{
1078 if (unlikely(current->audit_context)) {
1079 unsigned long tstate = regs->tstate;
1080 int result = AUDITSC_SUCCESS;
1081
1082 if (unlikely(tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
1083 result = AUDITSC_FAILURE;
1084
1085 audit_syscall_exit(result, regs->u_regs[UREG_I0]);
1086 }
1087
1088 if (test_thread_flag(TIF_SYSCALL_TRACE))
1089 tracehook_report_syscall_exit(regs, 0);
1090}
diff --git a/arch/sparc64/kernel/reboot.c b/arch/sparc64/kernel/reboot.c
new file mode 100644
index 000000000000..ef89d3d69748
--- /dev/null
+++ b/arch/sparc64/kernel/reboot.c
@@ -0,0 +1,53 @@
1/* reboot.c: reboot/shutdown/halt/poweroff handling
2 *
3 * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
4 */
5#include <linux/kernel.h>
6#include <linux/reboot.h>
7#include <linux/module.h>
8#include <linux/pm.h>
9
10#include <asm/system.h>
11#include <asm/oplib.h>
12#include <asm/prom.h>
13
14/* sysctl - toggle power-off restriction for serial console
15 * systems in machine_power_off()
16 */
17int scons_pwroff = 1;
18
19/* This isn't actually used, it exists merely to satisfy the
20 * reference in kernel/sys.c
21 */
22void (*pm_power_off)(void) = machine_power_off;
23EXPORT_SYMBOL(pm_power_off);
24
25void machine_power_off(void)
26{
27 if (strcmp(of_console_device->type, "serial") || scons_pwroff)
28 prom_halt_power_off();
29
30 prom_halt();
31}
32
33void machine_halt(void)
34{
35 prom_halt();
36 panic("Halt failed!");
37}
38
39void machine_restart(char *cmd)
40{
41 char *p;
42
43 p = strchr(reboot_command, '\n');
44 if (p)
45 *p = 0;
46 if (cmd)
47 prom_reboot(cmd);
48 if (*reboot_command)
49 prom_reboot(reboot_command);
50 prom_reboot("");
51 panic("Reboot failed!");
52}
53
diff --git a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c
index e33a8a660e9e..2ead310066d1 100644
--- a/arch/sparc64/kernel/sbus.c
+++ b/arch/sparc64/kernel/sbus.c
@@ -11,15 +11,17 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/of.h>
15#include <linux/of_device.h>
14 16
15#include <asm/page.h> 17#include <asm/page.h>
16#include <asm/sbus.h>
17#include <asm/io.h> 18#include <asm/io.h>
18#include <asm/upa.h> 19#include <asm/upa.h>
19#include <asm/cache.h> 20#include <asm/cache.h>
20#include <asm/dma.h> 21#include <asm/dma.h>
21#include <asm/irq.h> 22#include <asm/irq.h>
22#include <asm/prom.h> 23#include <asm/prom.h>
24#include <asm/oplib.h>
23#include <asm/starfire.h> 25#include <asm/starfire.h>
24 26
25#include "iommu_common.h" 27#include "iommu_common.h"
@@ -52,13 +54,23 @@
52#define STRBUF_TAG_VALID 0x02UL 54#define STRBUF_TAG_VALID 0x02UL
53 55
54/* Enable 64-bit DVMA mode for the given device. */ 56/* Enable 64-bit DVMA mode for the given device. */
55void sbus_set_sbus64(struct sbus_dev *sdev, int bursts) 57void sbus_set_sbus64(struct device *dev, int bursts)
56{ 58{
57 struct iommu *iommu = sdev->ofdev.dev.archdata.iommu; 59 struct iommu *iommu = dev->archdata.iommu;
58 int slot = sdev->slot; 60 struct of_device *op = to_of_device(dev);
61 const struct linux_prom_registers *regs;
59 unsigned long cfg_reg; 62 unsigned long cfg_reg;
63 int slot;
60 u64 val; 64 u64 val;
61 65
66 regs = of_get_property(op->node, "reg", NULL);
67 if (!regs) {
68 printk(KERN_ERR "sbus_set_sbus64: Cannot find regs for %s\n",
69 op->node->full_name);
70 return;
71 }
72 slot = regs->which_io;
73
62 cfg_reg = iommu->write_complete_reg; 74 cfg_reg = iommu->write_complete_reg;
63 switch (slot) { 75 switch (slot) {
64 case 0: 76 case 0:
@@ -191,10 +203,9 @@ static unsigned long sysio_imap_to_iclr(unsigned long imap)
191 return imap + diff; 203 return imap + diff;
192} 204}
193 205
194unsigned int sbus_build_irq(void *buscookie, unsigned int ino) 206static unsigned int sbus_build_irq(struct of_device *op, unsigned int ino)
195{ 207{
196 struct sbus_bus *sbus = (struct sbus_bus *)buscookie; 208 struct iommu *iommu = op->dev.archdata.iommu;
197 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu;
198 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 209 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
199 unsigned long imap, iclr; 210 unsigned long imap, iclr;
200 int sbus_level = 0; 211 int sbus_level = 0;
@@ -255,12 +266,12 @@ unsigned int sbus_build_irq(void *buscookie, unsigned int ino)
255#define SYSIO_UEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ 266#define SYSIO_UEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */
256static irqreturn_t sysio_ue_handler(int irq, void *dev_id) 267static irqreturn_t sysio_ue_handler(int irq, void *dev_id)
257{ 268{
258 struct sbus_bus *sbus = dev_id; 269 struct of_device *op = dev_id;
259 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 270 struct iommu *iommu = op->dev.archdata.iommu;
260 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 271 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
261 unsigned long afsr_reg, afar_reg; 272 unsigned long afsr_reg, afar_reg;
262 unsigned long afsr, afar, error_bits; 273 unsigned long afsr, afar, error_bits;
263 int reported; 274 int reported, portid;
264 275
265 afsr_reg = reg_base + SYSIO_UE_AFSR; 276 afsr_reg = reg_base + SYSIO_UE_AFSR;
266 afar_reg = reg_base + SYSIO_UE_AFAR; 277 afar_reg = reg_base + SYSIO_UE_AFAR;
@@ -275,9 +286,11 @@ static irqreturn_t sysio_ue_handler(int irq, void *dev_id)
275 SYSIO_UEAFSR_SPIO | SYSIO_UEAFSR_SDRD | SYSIO_UEAFSR_SDWR); 286 SYSIO_UEAFSR_SPIO | SYSIO_UEAFSR_SDRD | SYSIO_UEAFSR_SDWR);
276 upa_writeq(error_bits, afsr_reg); 287 upa_writeq(error_bits, afsr_reg);
277 288
289 portid = of_getintprop_default(op->node, "portid", -1);
290
278 /* Log the error. */ 291 /* Log the error. */
279 printk("SYSIO[%x]: Uncorrectable ECC Error, primary error type[%s]\n", 292 printk("SYSIO[%x]: Uncorrectable ECC Error, primary error type[%s]\n",
280 sbus->portid, 293 portid,
281 (((error_bits & SYSIO_UEAFSR_PPIO) ? 294 (((error_bits & SYSIO_UEAFSR_PPIO) ?
282 "PIO" : 295 "PIO" :
283 ((error_bits & SYSIO_UEAFSR_PDRD) ? 296 ((error_bits & SYSIO_UEAFSR_PDRD) ?
@@ -285,12 +298,12 @@ static irqreturn_t sysio_ue_handler(int irq, void *dev_id)
285 ((error_bits & SYSIO_UEAFSR_PDWR) ? 298 ((error_bits & SYSIO_UEAFSR_PDWR) ?
286 "DVMA Write" : "???"))))); 299 "DVMA Write" : "???")))));
287 printk("SYSIO[%x]: DOFF[%lx] SIZE[%lx] MID[%lx]\n", 300 printk("SYSIO[%x]: DOFF[%lx] SIZE[%lx] MID[%lx]\n",
288 sbus->portid, 301 portid,
289 (afsr & SYSIO_UEAFSR_DOFF) >> 45UL, 302 (afsr & SYSIO_UEAFSR_DOFF) >> 45UL,
290 (afsr & SYSIO_UEAFSR_SIZE) >> 42UL, 303 (afsr & SYSIO_UEAFSR_SIZE) >> 42UL,
291 (afsr & SYSIO_UEAFSR_MID) >> 37UL); 304 (afsr & SYSIO_UEAFSR_MID) >> 37UL);
292 printk("SYSIO[%x]: AFAR[%016lx]\n", sbus->portid, afar); 305 printk("SYSIO[%x]: AFAR[%016lx]\n", portid, afar);
293 printk("SYSIO[%x]: Secondary UE errors [", sbus->portid); 306 printk("SYSIO[%x]: Secondary UE errors [", portid);
294 reported = 0; 307 reported = 0;
295 if (afsr & SYSIO_UEAFSR_SPIO) { 308 if (afsr & SYSIO_UEAFSR_SPIO) {
296 reported++; 309 reported++;
@@ -327,12 +340,12 @@ static irqreturn_t sysio_ue_handler(int irq, void *dev_id)
327#define SYSIO_CEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ 340#define SYSIO_CEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */
328static irqreturn_t sysio_ce_handler(int irq, void *dev_id) 341static irqreturn_t sysio_ce_handler(int irq, void *dev_id)
329{ 342{
330 struct sbus_bus *sbus = dev_id; 343 struct of_device *op = dev_id;
331 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 344 struct iommu *iommu = op->dev.archdata.iommu;
332 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 345 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
333 unsigned long afsr_reg, afar_reg; 346 unsigned long afsr_reg, afar_reg;
334 unsigned long afsr, afar, error_bits; 347 unsigned long afsr, afar, error_bits;
335 int reported; 348 int reported, portid;
336 349
337 afsr_reg = reg_base + SYSIO_CE_AFSR; 350 afsr_reg = reg_base + SYSIO_CE_AFSR;
338 afar_reg = reg_base + SYSIO_CE_AFAR; 351 afar_reg = reg_base + SYSIO_CE_AFAR;
@@ -347,8 +360,10 @@ static irqreturn_t sysio_ce_handler(int irq, void *dev_id)
347 SYSIO_CEAFSR_SPIO | SYSIO_CEAFSR_SDRD | SYSIO_CEAFSR_SDWR); 360 SYSIO_CEAFSR_SPIO | SYSIO_CEAFSR_SDRD | SYSIO_CEAFSR_SDWR);
348 upa_writeq(error_bits, afsr_reg); 361 upa_writeq(error_bits, afsr_reg);
349 362
363 portid = of_getintprop_default(op->node, "portid", -1);
364
350 printk("SYSIO[%x]: Correctable ECC Error, primary error type[%s]\n", 365 printk("SYSIO[%x]: Correctable ECC Error, primary error type[%s]\n",
351 sbus->portid, 366 portid,
352 (((error_bits & SYSIO_CEAFSR_PPIO) ? 367 (((error_bits & SYSIO_CEAFSR_PPIO) ?
353 "PIO" : 368 "PIO" :
354 ((error_bits & SYSIO_CEAFSR_PDRD) ? 369 ((error_bits & SYSIO_CEAFSR_PDRD) ?
@@ -360,14 +375,14 @@ static irqreturn_t sysio_ce_handler(int irq, void *dev_id)
360 * XXX UDB CE trap handler does... -DaveM 375 * XXX UDB CE trap handler does... -DaveM
361 */ 376 */
362 printk("SYSIO[%x]: DOFF[%lx] ECC Syndrome[%lx] Size[%lx] MID[%lx]\n", 377 printk("SYSIO[%x]: DOFF[%lx] ECC Syndrome[%lx] Size[%lx] MID[%lx]\n",
363 sbus->portid, 378 portid,
364 (afsr & SYSIO_CEAFSR_DOFF) >> 45UL, 379 (afsr & SYSIO_CEAFSR_DOFF) >> 45UL,
365 (afsr & SYSIO_CEAFSR_ESYND) >> 48UL, 380 (afsr & SYSIO_CEAFSR_ESYND) >> 48UL,
366 (afsr & SYSIO_CEAFSR_SIZE) >> 42UL, 381 (afsr & SYSIO_CEAFSR_SIZE) >> 42UL,
367 (afsr & SYSIO_CEAFSR_MID) >> 37UL); 382 (afsr & SYSIO_CEAFSR_MID) >> 37UL);
368 printk("SYSIO[%x]: AFAR[%016lx]\n", sbus->portid, afar); 383 printk("SYSIO[%x]: AFAR[%016lx]\n", portid, afar);
369 384
370 printk("SYSIO[%x]: Secondary CE errors [", sbus->portid); 385 printk("SYSIO[%x]: Secondary CE errors [", portid);
371 reported = 0; 386 reported = 0;
372 if (afsr & SYSIO_CEAFSR_SPIO) { 387 if (afsr & SYSIO_CEAFSR_SPIO) {
373 reported++; 388 reported++;
@@ -404,11 +419,11 @@ static irqreturn_t sysio_ce_handler(int irq, void *dev_id)
404#define SYSIO_SBAFSR_RESV3 0x0000001fffffffffUL /* Reserved */ 419#define SYSIO_SBAFSR_RESV3 0x0000001fffffffffUL /* Reserved */
405static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id) 420static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id)
406{ 421{
407 struct sbus_bus *sbus = dev_id; 422 struct of_device *op = dev_id;
408 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 423 struct iommu *iommu = op->dev.archdata.iommu;
409 unsigned long afsr_reg, afar_reg, reg_base; 424 unsigned long afsr_reg, afar_reg, reg_base;
410 unsigned long afsr, afar, error_bits; 425 unsigned long afsr, afar, error_bits;
411 int reported; 426 int reported, portid;
412 427
413 reg_base = iommu->write_complete_reg - 0x2000UL; 428 reg_base = iommu->write_complete_reg - 0x2000UL;
414 afsr_reg = reg_base + SYSIO_SBUS_AFSR; 429 afsr_reg = reg_base + SYSIO_SBUS_AFSR;
@@ -423,9 +438,11 @@ static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id)
423 SYSIO_SBAFSR_SLE | SYSIO_SBAFSR_STO | SYSIO_SBAFSR_SBERR); 438 SYSIO_SBAFSR_SLE | SYSIO_SBAFSR_STO | SYSIO_SBAFSR_SBERR);
424 upa_writeq(error_bits, afsr_reg); 439 upa_writeq(error_bits, afsr_reg);
425 440
441 portid = of_getintprop_default(op->node, "portid", -1);
442
426 /* Log the error. */ 443 /* Log the error. */
427 printk("SYSIO[%x]: SBUS Error, primary error type[%s] read(%d)\n", 444 printk("SYSIO[%x]: SBUS Error, primary error type[%s] read(%d)\n",
428 sbus->portid, 445 portid,
429 (((error_bits & SYSIO_SBAFSR_PLE) ? 446 (((error_bits & SYSIO_SBAFSR_PLE) ?
430 "Late PIO Error" : 447 "Late PIO Error" :
431 ((error_bits & SYSIO_SBAFSR_PTO) ? 448 ((error_bits & SYSIO_SBAFSR_PTO) ?
@@ -434,11 +451,11 @@ static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id)
434 "Error Ack" : "???")))), 451 "Error Ack" : "???")))),
435 (afsr & SYSIO_SBAFSR_RD) ? 1 : 0); 452 (afsr & SYSIO_SBAFSR_RD) ? 1 : 0);
436 printk("SYSIO[%x]: size[%lx] MID[%lx]\n", 453 printk("SYSIO[%x]: size[%lx] MID[%lx]\n",
437 sbus->portid, 454 portid,
438 (afsr & SYSIO_SBAFSR_SIZE) >> 42UL, 455 (afsr & SYSIO_SBAFSR_SIZE) >> 42UL,
439 (afsr & SYSIO_SBAFSR_MID) >> 37UL); 456 (afsr & SYSIO_SBAFSR_MID) >> 37UL);
440 printk("SYSIO[%x]: AFAR[%016lx]\n", sbus->portid, afar); 457 printk("SYSIO[%x]: AFAR[%016lx]\n", portid, afar);
441 printk("SYSIO[%x]: Secondary SBUS errors [", sbus->portid); 458 printk("SYSIO[%x]: Secondary SBUS errors [", portid);
442 reported = 0; 459 reported = 0;
443 if (afsr & SYSIO_SBAFSR_SLE) { 460 if (afsr & SYSIO_SBAFSR_SLE) {
444 reported++; 461 reported++;
@@ -470,34 +487,37 @@ static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id)
470#define SYSIO_CE_INO 0x35 487#define SYSIO_CE_INO 0x35
471#define SYSIO_SBUSERR_INO 0x36 488#define SYSIO_SBUSERR_INO 0x36
472 489
473static void __init sysio_register_error_handlers(struct sbus_bus *sbus) 490static void __init sysio_register_error_handlers(struct of_device *op)
474{ 491{
475 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 492 struct iommu *iommu = op->dev.archdata.iommu;
476 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 493 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
477 unsigned int irq; 494 unsigned int irq;
478 u64 control; 495 u64 control;
496 int portid;
497
498 portid = of_getintprop_default(op->node, "portid", -1);
479 499
480 irq = sbus_build_irq(sbus, SYSIO_UE_INO); 500 irq = sbus_build_irq(op, SYSIO_UE_INO);
481 if (request_irq(irq, sysio_ue_handler, 0, 501 if (request_irq(irq, sysio_ue_handler, 0,
482 "SYSIO_UE", sbus) < 0) { 502 "SYSIO_UE", op) < 0) {
483 prom_printf("SYSIO[%x]: Cannot register UE interrupt.\n", 503 prom_printf("SYSIO[%x]: Cannot register UE interrupt.\n",
484 sbus->portid); 504 portid);
485 prom_halt(); 505 prom_halt();
486 } 506 }
487 507
488 irq = sbus_build_irq(sbus, SYSIO_CE_INO); 508 irq = sbus_build_irq(op, SYSIO_CE_INO);
489 if (request_irq(irq, sysio_ce_handler, 0, 509 if (request_irq(irq, sysio_ce_handler, 0,
490 "SYSIO_CE", sbus) < 0) { 510 "SYSIO_CE", op) < 0) {
491 prom_printf("SYSIO[%x]: Cannot register CE interrupt.\n", 511 prom_printf("SYSIO[%x]: Cannot register CE interrupt.\n",
492 sbus->portid); 512 portid);
493 prom_halt(); 513 prom_halt();
494 } 514 }
495 515
496 irq = sbus_build_irq(sbus, SYSIO_SBUSERR_INO); 516 irq = sbus_build_irq(op, SYSIO_SBUSERR_INO);
497 if (request_irq(irq, sysio_sbus_error_handler, 0, 517 if (request_irq(irq, sysio_sbus_error_handler, 0,
498 "SYSIO_SBERR", sbus) < 0) { 518 "SYSIO_SBERR", op) < 0) {
499 prom_printf("SYSIO[%x]: Cannot register SBUS Error interrupt.\n", 519 prom_printf("SYSIO[%x]: Cannot register SBUS Error interrupt.\n",
500 sbus->portid); 520 portid);
501 prom_halt(); 521 prom_halt();
502 } 522 }
503 523
@@ -513,19 +533,15 @@ static void __init sysio_register_error_handlers(struct sbus_bus *sbus)
513} 533}
514 534
515/* Boot time initialization. */ 535/* Boot time initialization. */
516static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus) 536static void __init sbus_iommu_init(struct of_device *op)
517{ 537{
518 const struct linux_prom64_registers *pr; 538 const struct linux_prom64_registers *pr;
519 struct device_node *dp; 539 struct device_node *dp = op->node;
520 struct iommu *iommu; 540 struct iommu *iommu;
521 struct strbuf *strbuf; 541 struct strbuf *strbuf;
522 unsigned long regs, reg_base; 542 unsigned long regs, reg_base;
543 int i, portid;
523 u64 control; 544 u64 control;
524 int i;
525
526 dp = of_find_node_by_phandle(__node);
527
528 sbus->portid = of_getintprop_default(dp, "upa-portid", -1);
529 545
530 pr = of_get_property(dp, "reg", NULL); 546 pr = of_get_property(dp, "reg", NULL);
531 if (!pr) { 547 if (!pr) {
@@ -542,9 +558,9 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
542 if (!strbuf) 558 if (!strbuf)
543 goto fatal_memory_error; 559 goto fatal_memory_error;
544 560
545 sbus->ofdev.dev.archdata.iommu = iommu; 561 op->dev.archdata.iommu = iommu;
546 sbus->ofdev.dev.archdata.stc = strbuf; 562 op->dev.archdata.stc = strbuf;
547 sbus->ofdev.dev.archdata.numa_node = -1; 563 op->dev.archdata.numa_node = -1;
548 564
549 reg_base = regs + SYSIO_IOMMUREG_BASE; 565 reg_base = regs + SYSIO_IOMMUREG_BASE;
550 iommu->iommu_control = reg_base + IOMMU_CONTROL; 566 iommu->iommu_control = reg_base + IOMMU_CONTROL;
@@ -572,8 +588,9 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
572 */ 588 */
573 iommu->write_complete_reg = regs + 0x2000UL; 589 iommu->write_complete_reg = regs + 0x2000UL;
574 590
575 printk("SYSIO: UPA portID %x, at %016lx\n", 591 portid = of_getintprop_default(op->node, "portid", -1);
576 sbus->portid, regs); 592 printk(KERN_INFO "SYSIO: UPA portID %x, at %016lx\n",
593 portid, regs);
577 594
578 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */ 595 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */
579 if (iommu_table_init(iommu, IO_TSB_SIZE, MAP_BASE, 0xffffffff, -1)) 596 if (iommu_table_init(iommu, IO_TSB_SIZE, MAP_BASE, 0xffffffff, -1))
@@ -631,56 +648,27 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
631 648
632 /* Now some Xfire specific grot... */ 649 /* Now some Xfire specific grot... */
633 if (this_is_starfire) 650 if (this_is_starfire)
634 starfire_hookup(sbus->portid); 651 starfire_hookup(portid);
635 652
636 sysio_register_error_handlers(sbus); 653 sysio_register_error_handlers(op);
637 return; 654 return;
638 655
639fatal_memory_error: 656fatal_memory_error:
640 prom_printf("sbus_iommu_init: Fatal memory allocation error.\n"); 657 prom_printf("sbus_iommu_init: Fatal memory allocation error.\n");
641} 658}
642 659
643void sbus_fill_device_irq(struct sbus_dev *sdev) 660static int __init sbus_init(void)
644{ 661{
645 struct device_node *dp = of_find_node_by_phandle(sdev->prom_node); 662 struct device_node *dp;
646 const struct linux_prom_irqs *irqs;
647
648 irqs = of_get_property(dp, "interrupts", NULL);
649 if (!irqs) {
650 sdev->irqs[0] = 0;
651 sdev->num_irqs = 0;
652 } else {
653 unsigned int pri = irqs[0].pri;
654 663
655 sdev->num_irqs = 1; 664 for_each_node_by_name(dp, "sbus") {
656 if (pri < 0x20) 665 struct of_device *op = of_find_device_by_node(dp);
657 pri += sdev->slot * 8;
658 666
659 sdev->irqs[0] = sbus_build_irq(sdev->bus, pri); 667 sbus_iommu_init(op);
668 of_propagate_archdata(op);
660 } 669 }
661}
662 670
663void __init sbus_arch_bus_ranges_init(struct device_node *pn, struct sbus_bus *sbus)
664{
665}
666
667void __init sbus_setup_iommu(struct sbus_bus *sbus, struct device_node *dp)
668{
669 sbus_iommu_init(dp->node, sbus);
670}
671
672void __init sbus_setup_arch_props(struct sbus_bus *sbus, struct device_node *dp)
673{
674}
675
676int __init sbus_arch_preinit(void)
677{
678 return 0; 671 return 0;
679} 672}
680 673
681void __init sbus_arch_postinit(void) 674subsys_initcall(sbus_init);
682{
683 extern void firetruck_init(void);
684
685 firetruck_init();
686}
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index 0804f71df6cb..30bba8b0a3b0 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -36,7 +36,6 @@
36#include <asm/elf.h> 36#include <asm/elf.h>
37#include <asm/head.h> 37#include <asm/head.h>
38#include <asm/smp.h> 38#include <asm/smp.h>
39#include <asm/mostek.h>
40#include <asm/ptrace.h> 39#include <asm/ptrace.h>
41#include <asm/uaccess.h> 40#include <asm/uaccess.h>
42#include <asm/checksum.h> 41#include <asm/checksum.h>
@@ -44,12 +43,8 @@
44#include <asm/pgalloc.h> 43#include <asm/pgalloc.h>
45#include <asm/cacheflush.h> 44#include <asm/cacheflush.h>
46#ifdef CONFIG_SBUS 45#ifdef CONFIG_SBUS
47#include <asm/sbus.h>
48#include <asm/dma.h> 46#include <asm/dma.h>
49#endif 47#endif
50#ifdef CONFIG_PCI
51#include <asm/ebus.h>
52#endif
53#include <asm/ns87303.h> 48#include <asm/ns87303.h>
54#include <asm/timer.h> 49#include <asm/timer.h>
55#include <asm/cpudata.h> 50#include <asm/cpudata.h>
@@ -68,7 +63,6 @@ extern void *__memscan_zero(void *, size_t);
68extern void *__memscan_generic(void *, int, size_t); 63extern void *__memscan_generic(void *, int, size_t);
69extern int __memcmp(const void *, const void *, __kernel_size_t); 64extern int __memcmp(const void *, const void *, __kernel_size_t);
70extern __kernel_size_t strlen(const char *); 65extern __kernel_size_t strlen(const char *);
71extern void syscall_trace(struct pt_regs *, int);
72extern void sys_sigsuspend(void); 66extern void sys_sigsuspend(void);
73extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg); 67extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
74extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *); 68extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *);
@@ -154,26 +148,12 @@ EXPORT_SYMBOL(flush_dcache_page);
154EXPORT_SYMBOL(__flush_dcache_range); 148EXPORT_SYMBOL(__flush_dcache_range);
155#endif 149#endif
156 150
157EXPORT_SYMBOL(mostek_lock);
158EXPORT_SYMBOL(mstk48t02_regs);
159#ifdef CONFIG_SUN_AUXIO 151#ifdef CONFIG_SUN_AUXIO
160EXPORT_SYMBOL(auxio_set_led); 152EXPORT_SYMBOL(auxio_set_led);
161EXPORT_SYMBOL(auxio_set_lte); 153EXPORT_SYMBOL(auxio_set_lte);
162#endif 154#endif
163#ifdef CONFIG_SBUS 155#ifdef CONFIG_SBUS
164EXPORT_SYMBOL(sbus_root);
165EXPORT_SYMBOL(dma_chain);
166EXPORT_SYMBOL(sbus_set_sbus64); 156EXPORT_SYMBOL(sbus_set_sbus64);
167EXPORT_SYMBOL(sbus_alloc_consistent);
168EXPORT_SYMBOL(sbus_free_consistent);
169EXPORT_SYMBOL(sbus_map_single);
170EXPORT_SYMBOL(sbus_unmap_single);
171EXPORT_SYMBOL(sbus_map_sg);
172EXPORT_SYMBOL(sbus_unmap_sg);
173EXPORT_SYMBOL(sbus_dma_sync_single_for_cpu);
174EXPORT_SYMBOL(sbus_dma_sync_single_for_device);
175EXPORT_SYMBOL(sbus_dma_sync_sg_for_cpu);
176EXPORT_SYMBOL(sbus_dma_sync_sg_for_device);
177#endif 157#endif
178EXPORT_SYMBOL(outsb); 158EXPORT_SYMBOL(outsb);
179EXPORT_SYMBOL(outsw); 159EXPORT_SYMBOL(outsw);
@@ -182,7 +162,6 @@ EXPORT_SYMBOL(insb);
182EXPORT_SYMBOL(insw); 162EXPORT_SYMBOL(insw);
183EXPORT_SYMBOL(insl); 163EXPORT_SYMBOL(insl);
184#ifdef CONFIG_PCI 164#ifdef CONFIG_PCI
185EXPORT_SYMBOL(ebus_chain);
186EXPORT_SYMBOL(pci_alloc_consistent); 165EXPORT_SYMBOL(pci_alloc_consistent);
187EXPORT_SYMBOL(pci_free_consistent); 166EXPORT_SYMBOL(pci_free_consistent);
188EXPORT_SYMBOL(pci_map_single); 167EXPORT_SYMBOL(pci_map_single);
@@ -300,3 +279,5 @@ EXPORT_SYMBOL(xor_niagara_2);
300EXPORT_SYMBOL(xor_niagara_3); 279EXPORT_SYMBOL(xor_niagara_3);
301EXPORT_SYMBOL(xor_niagara_4); 280EXPORT_SYMBOL(xor_niagara_4);
302EXPORT_SYMBOL(xor_niagara_5); 281EXPORT_SYMBOL(xor_niagara_5);
282
283EXPORT_SYMBOL_GPL(real_hard_smp_processor_id);
diff --git a/arch/sparc64/kernel/sstate.c b/arch/sparc64/kernel/sstate.c
index 5b6e75b7f052..8cdbe5946b43 100644
--- a/arch/sparc64/kernel/sstate.c
+++ b/arch/sparc64/kernel/sstate.c
@@ -1,14 +1,15 @@
1/* sstate.c: System soft state support. 1/* sstate.c: System soft state support.
2 * 2 *
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net> 3 * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net>
4 */ 4 */
5 5
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/notifier.h> 7#include <linux/notifier.h>
8#include <linux/reboot.h>
8#include <linux/init.h> 9#include <linux/init.h>
9 10
10#include <asm/hypervisor.h> 11#include <asm/hypervisor.h>
11#include <asm/sstate.h> 12#include <asm/spitfire.h>
12#include <asm/oplib.h> 13#include <asm/oplib.h>
13#include <asm/head.h> 14#include <asm/head.h>
14#include <asm/io.h> 15#include <asm/io.h>
@@ -50,31 +51,34 @@ static const char rebooting_msg[32] __attribute__((aligned(32))) =
50static const char panicing_msg[32] __attribute__((aligned(32))) = 51static const char panicing_msg[32] __attribute__((aligned(32))) =
51 "Linux panicing"; 52 "Linux panicing";
52 53
53void sstate_booting(void) 54static int sstate_reboot_call(struct notifier_block *np, unsigned long type, void *_unused)
54{ 55{
55 do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg); 56 const char *msg;
56}
57 57
58void sstate_running(void) 58 switch (type) {
59{ 59 case SYS_DOWN:
60 do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg); 60 default:
61} 61 msg = rebooting_msg;
62 break;
62 63
63void sstate_halt(void) 64 case SYS_HALT:
64{ 65 msg = halting_msg;
65 do_set_sstate(HV_SOFT_STATE_TRANSITION, halting_msg); 66 break;
66}
67 67
68void sstate_poweroff(void) 68 case SYS_POWER_OFF:
69{ 69 msg = poweroff_msg;
70 do_set_sstate(HV_SOFT_STATE_TRANSITION, poweroff_msg); 70 break;
71} 71 }
72 72
73void sstate_reboot(void) 73 do_set_sstate(HV_SOFT_STATE_TRANSITION, msg);
74{ 74
75 do_set_sstate(HV_SOFT_STATE_TRANSITION, rebooting_msg); 75 return NOTIFY_OK;
76} 76}
77 77
78static struct notifier_block sstate_reboot_notifier = {
79 .notifier_call = sstate_reboot_call,
80};
81
78static int sstate_panic_event(struct notifier_block *n, unsigned long event, void *ptr) 82static int sstate_panic_event(struct notifier_block *n, unsigned long event, void *ptr)
79{ 83{
80 do_set_sstate(HV_SOFT_STATE_TRANSITION, panicing_msg); 84 do_set_sstate(HV_SOFT_STATE_TRANSITION, panicing_msg);
@@ -87,18 +91,37 @@ static struct notifier_block sstate_panic_block = {
87 .priority = INT_MAX, 91 .priority = INT_MAX,
88}; 92};
89 93
90void __init sun4v_sstate_init(void) 94static int __init sstate_init(void)
91{ 95{
92 unsigned long major, minor; 96 unsigned long major, minor;
93 97
98 if (tlb_type != hypervisor)
99 return 0;
100
94 major = 1; 101 major = 1;
95 minor = 0; 102 minor = 0;
96 if (sun4v_hvapi_register(HV_GRP_SOFT_STATE, major, &minor)) 103 if (sun4v_hvapi_register(HV_GRP_SOFT_STATE, major, &minor))
97 return; 104 return 0;
98 105
99 hv_supports_soft_state = 1; 106 hv_supports_soft_state = 1;
100 107
101 prom_sun4v_guest_soft_state(); 108 prom_sun4v_guest_soft_state();
109
110 do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg);
111
102 atomic_notifier_chain_register(&panic_notifier_list, 112 atomic_notifier_chain_register(&panic_notifier_list,
103 &sstate_panic_block); 113 &sstate_panic_block);
114 register_reboot_notifier(&sstate_reboot_notifier);
115
116 return 0;
104} 117}
118
119core_initcall(sstate_init);
120
121static int __init sstate_running(void)
122{
123 do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg);
124 return 0;
125}
126
127late_initcall(sstate_running);
diff --git a/arch/sparc64/kernel/starfire.c b/arch/sparc64/kernel/starfire.c
index 7461581b3bb9..060d0f3a6151 100644
--- a/arch/sparc64/kernel/starfire.c
+++ b/arch/sparc64/kernel/starfire.c
@@ -28,11 +28,6 @@ void check_if_starfire(void)
28 this_is_starfire = 1; 28 this_is_starfire = 1;
29} 29}
30 30
31void starfire_cpu_setup(void)
32{
33 /* Currently, nothing to do. */
34}
35
36int starfire_hard_smp_processor_id(void) 31int starfire_hard_smp_processor_id(void)
37{ 32{
38 return upa_readl(0x1fff40000d0UL); 33 return upa_readl(0x1fff40000d0UL);
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
index 3d118531baff..3320c9d0075f 100644
--- a/arch/sparc64/kernel/sys_sparc32.c
+++ b/arch/sparc64/kernel/sys_sparc32.c
@@ -575,14 +575,6 @@ asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv,
575 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); 575 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
576} 576}
577 577
578/* These are here just in case some old sparc32 binary calls it. */
579asmlinkage long sys32_pause(void)
580{
581 current->state = TASK_INTERRUPTIBLE;
582 schedule();
583 return -ERESTARTNOHAND;
584}
585
586asmlinkage compat_ssize_t sys32_pread64(unsigned int fd, 578asmlinkage compat_ssize_t sys32_pread64(unsigned int fd,
587 char __user *ubuf, 579 char __user *ubuf,
588 compat_size_t count, 580 compat_size_t count,
diff --git a/arch/sparc64/kernel/syscalls.S b/arch/sparc64/kernel/syscalls.S
index a2f24270ed8a..7a6786a71363 100644
--- a/arch/sparc64/kernel/syscalls.S
+++ b/arch/sparc64/kernel/syscalls.S
@@ -65,9 +65,8 @@ sys32_rt_sigreturn:
65 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 65 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
66 be,pt %icc, rtrap 66 be,pt %icc, rtrap
67 nop 67 nop
68 add %sp, PTREGS_OFF, %o0 68 call syscall_trace_leave
69 call syscall_trace 69 add %sp, PTREGS_OFF, %o0
70 mov 1, %o1
71 ba,pt %xcc, rtrap 70 ba,pt %xcc, rtrap
72 nop 71 nop
73 72
@@ -159,9 +158,8 @@ linux_sparc_ni_syscall:
159 or %l7, %lo(sys_ni_syscall), %l7 158 or %l7, %lo(sys_ni_syscall), %l7
160 159
161linux_syscall_trace32: 160linux_syscall_trace32:
162 add %sp, PTREGS_OFF, %o0 161 call syscall_trace_enter
163 call syscall_trace 162 add %sp, PTREGS_OFF, %o0
164 clr %o1
165 brnz,pn %o0, 3f 163 brnz,pn %o0, 3f
166 mov -ENOSYS, %o0 164 mov -ENOSYS, %o0
167 srl %i0, 0, %o0 165 srl %i0, 0, %o0
@@ -172,9 +170,8 @@ linux_syscall_trace32:
172 srl %i3, 0, %o3 170 srl %i3, 0, %o3
173 171
174linux_syscall_trace: 172linux_syscall_trace:
175 add %sp, PTREGS_OFF, %o0 173 call syscall_trace_enter
176 call syscall_trace 174 add %sp, PTREGS_OFF, %o0
177 clr %o1
178 brnz,pn %o0, 3f 175 brnz,pn %o0, 3f
179 mov -ENOSYS, %o0 176 mov -ENOSYS, %o0
180 mov %i0, %o0 177 mov %i0, %o0
@@ -275,9 +272,8 @@ ret_sys_call:
275 b,pt %xcc, rtrap 272 b,pt %xcc, rtrap
276 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] 273 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
277linux_syscall_trace2: 274linux_syscall_trace2:
278 add %sp, PTREGS_OFF, %o0 275 call syscall_trace_leave
279 call syscall_trace 276 add %sp, PTREGS_OFF, %o0
280 mov 1, %o1
281 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] 277 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
282 ba,pt %xcc, rtrap 278 ba,pt %xcc, rtrap
283 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] 279 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index 0fdbf3ba956e..5daee4b04dd5 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -23,7 +23,7 @@ sys_call_table32:
23/*10*/ .word sys_unlink, sunos_execv, sys_chdir, sys_chown16, sys32_mknod 23/*10*/ .word sys_unlink, sunos_execv, sys_chdir, sys_chown16, sys32_mknod
24/*15*/ .word sys_chmod, sys_lchown16, sparc_brk, sys32_perfctr, sys32_lseek 24/*15*/ .word sys_chmod, sys_lchown16, sparc_brk, sys32_perfctr, sys32_lseek
25/*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16 25/*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16
26/*25*/ .word sys32_vmsplice, compat_sys_ptrace, sys_alarm, sys32_sigaltstack, sys32_pause 26/*25*/ .word sys32_vmsplice, compat_sys_ptrace, sys_alarm, sys32_sigaltstack, sys_pause
27/*30*/ .word compat_sys_utime, sys_lchown, sys_fchown, sys32_access, sys32_nice 27/*30*/ .word compat_sys_utime, sys_lchown, sys_fchown, sys32_access, sys32_nice
28 .word sys_chown, sys_sync, sys32_kill, compat_sys_newstat, sys32_sendfile 28 .word sys_chown, sys_sync, sys32_kill, compat_sys_newstat, sys32_sendfile
29/*40*/ .word compat_sys_newlstat, sys_dup, sys_pipe, compat_sys_times, sys_getuid 29/*40*/ .word compat_sys_newlstat, sys_dup, sys_pipe, compat_sys_times, sys_getuid
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index cc16fdcf98af..80d71a5ce1e3 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -30,13 +30,14 @@
30#include <linux/percpu.h> 30#include <linux/percpu.h>
31#include <linux/miscdevice.h> 31#include <linux/miscdevice.h>
32#include <linux/rtc.h> 32#include <linux/rtc.h>
33#include <linux/rtc/m48t59.h>
33#include <linux/kernel_stat.h> 34#include <linux/kernel_stat.h>
34#include <linux/clockchips.h> 35#include <linux/clockchips.h>
35#include <linux/clocksource.h> 36#include <linux/clocksource.h>
36#include <linux/of_device.h> 37#include <linux/of_device.h>
38#include <linux/platform_device.h>
37 39
38#include <asm/oplib.h> 40#include <asm/oplib.h>
39#include <asm/mostek.h>
40#include <asm/timer.h> 41#include <asm/timer.h>
41#include <asm/irq.h> 42#include <asm/irq.h>
42#include <asm/io.h> 43#include <asm/io.h>
@@ -50,18 +51,7 @@
50 51
51#include "entry.h" 52#include "entry.h"
52 53
53DEFINE_SPINLOCK(mostek_lock);
54DEFINE_SPINLOCK(rtc_lock); 54DEFINE_SPINLOCK(rtc_lock);
55void __iomem *mstk48t02_regs = NULL;
56#ifdef CONFIG_PCI
57unsigned long ds1287_regs = 0UL;
58static void __iomem *bq4802_regs;
59#endif
60
61static void __iomem *mstk48t08_regs;
62static void __iomem *mstk48t59_regs;
63
64static int set_rtc_mmss(unsigned long);
65 55
66#define TICK_PRIV_BIT (1UL << 63) 56#define TICK_PRIV_BIT (1UL << 63)
67#define TICKCMP_IRQ_BIT (1UL << 63) 57#define TICKCMP_IRQ_BIT (1UL << 63)
@@ -405,313 +395,167 @@ static unsigned long timer_ticks_per_nsec_quotient __read_mostly;
405 395
406int update_persistent_clock(struct timespec now) 396int update_persistent_clock(struct timespec now)
407{ 397{
408 return set_rtc_mmss(now.tv_sec); 398 struct rtc_device *rtc = rtc_class_open("rtc0");
409} 399 int err = -1;
410 400
411/* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ 401 if (rtc) {
412static void __init kick_start_clock(void) 402 err = rtc_set_mmss(rtc, now.tv_sec);
413{ 403 rtc_class_close(rtc);
414 void __iomem *regs = mstk48t02_regs;
415 u8 sec, tmp;
416 int i, count;
417
418 prom_printf("CLOCK: Clock was stopped. Kick start ");
419
420 spin_lock_irq(&mostek_lock);
421
422 /* Turn on the kick start bit to start the oscillator. */
423 tmp = mostek_read(regs + MOSTEK_CREG);
424 tmp |= MSTK_CREG_WRITE;
425 mostek_write(regs + MOSTEK_CREG, tmp);
426 tmp = mostek_read(regs + MOSTEK_SEC);
427 tmp &= ~MSTK_STOP;
428 mostek_write(regs + MOSTEK_SEC, tmp);
429 tmp = mostek_read(regs + MOSTEK_HOUR);
430 tmp |= MSTK_KICK_START;
431 mostek_write(regs + MOSTEK_HOUR, tmp);
432 tmp = mostek_read(regs + MOSTEK_CREG);
433 tmp &= ~MSTK_CREG_WRITE;
434 mostek_write(regs + MOSTEK_CREG, tmp);
435
436 spin_unlock_irq(&mostek_lock);
437
438 /* Delay to allow the clock oscillator to start. */
439 sec = MSTK_REG_SEC(regs);
440 for (i = 0; i < 3; i++) {
441 while (sec == MSTK_REG_SEC(regs))
442 for (count = 0; count < 100000; count++)
443 /* nothing */ ;
444 prom_printf(".");
445 sec = MSTK_REG_SEC(regs);
446 }
447 prom_printf("\n");
448
449 spin_lock_irq(&mostek_lock);
450
451 /* Turn off kick start and set a "valid" time and date. */
452 tmp = mostek_read(regs + MOSTEK_CREG);
453 tmp |= MSTK_CREG_WRITE;
454 mostek_write(regs + MOSTEK_CREG, tmp);
455 tmp = mostek_read(regs + MOSTEK_HOUR);
456 tmp &= ~MSTK_KICK_START;
457 mostek_write(regs + MOSTEK_HOUR, tmp);
458 MSTK_SET_REG_SEC(regs,0);
459 MSTK_SET_REG_MIN(regs,0);
460 MSTK_SET_REG_HOUR(regs,0);
461 MSTK_SET_REG_DOW(regs,5);
462 MSTK_SET_REG_DOM(regs,1);
463 MSTK_SET_REG_MONTH(regs,8);
464 MSTK_SET_REG_YEAR(regs,1996 - MSTK_YEAR_ZERO);
465 tmp = mostek_read(regs + MOSTEK_CREG);
466 tmp &= ~MSTK_CREG_WRITE;
467 mostek_write(regs + MOSTEK_CREG, tmp);
468
469 spin_unlock_irq(&mostek_lock);
470
471 /* Ensure the kick start bit is off. If it isn't, turn it off. */
472 while (mostek_read(regs + MOSTEK_HOUR) & MSTK_KICK_START) {
473 prom_printf("CLOCK: Kick start still on!\n");
474
475 spin_lock_irq(&mostek_lock);
476
477 tmp = mostek_read(regs + MOSTEK_CREG);
478 tmp |= MSTK_CREG_WRITE;
479 mostek_write(regs + MOSTEK_CREG, tmp);
480
481 tmp = mostek_read(regs + MOSTEK_HOUR);
482 tmp &= ~MSTK_KICK_START;
483 mostek_write(regs + MOSTEK_HOUR, tmp);
484
485 tmp = mostek_read(regs + MOSTEK_CREG);
486 tmp &= ~MSTK_CREG_WRITE;
487 mostek_write(regs + MOSTEK_CREG, tmp);
488
489 spin_unlock_irq(&mostek_lock);
490 } 404 }
491 405
492 prom_printf("CLOCK: Kick start procedure successful.\n"); 406 return err;
493} 407}
494 408
495/* Return nonzero if the clock chip battery is low. */ 409unsigned long cmos_regs;
496static int __init has_low_battery(void) 410EXPORT_SYMBOL(cmos_regs);
497{
498 void __iomem *regs = mstk48t02_regs;
499 u8 data1, data2;
500
501 spin_lock_irq(&mostek_lock);
502 411
503 data1 = mostek_read(regs + MOSTEK_EEPROM); /* Read some data. */ 412static struct resource rtc_cmos_resource;
504 mostek_write(regs + MOSTEK_EEPROM, ~data1); /* Write back the complement. */
505 data2 = mostek_read(regs + MOSTEK_EEPROM); /* Read back the complement. */
506 mostek_write(regs + MOSTEK_EEPROM, data1); /* Restore original value. */
507 413
508 spin_unlock_irq(&mostek_lock); 414static struct platform_device rtc_cmos_device = {
509 415 .name = "rtc_cmos",
510 return (data1 == data2); /* Was the write blocked? */ 416 .id = -1,
511} 417 .resource = &rtc_cmos_resource,
418 .num_resources = 1,
419};
512 420
513static void __init mostek_set_system_time(void __iomem *mregs) 421static int __devinit rtc_probe(struct of_device *op, const struct of_device_id *match)
514{ 422{
515 unsigned int year, mon, day, hour, min, sec; 423 struct resource *r;
516 u8 tmp;
517
518 spin_lock_irq(&mostek_lock);
519 424
520 /* Traditional Mostek chip. */ 425 printk(KERN_INFO "%s: RTC regs at 0x%lx\n",
521 tmp = mostek_read(mregs + MOSTEK_CREG); 426 op->node->full_name, op->resource[0].start);
522 tmp |= MSTK_CREG_READ;
523 mostek_write(mregs + MOSTEK_CREG, tmp);
524 427
525 sec = MSTK_REG_SEC(mregs); 428 /* The CMOS RTC driver only accepts IORESOURCE_IO, so cons
526 min = MSTK_REG_MIN(mregs); 429 * up a fake resource so that the probe works for all cases.
527 hour = MSTK_REG_HOUR(mregs); 430 * When the RTC is behind an ISA bus it will have IORESOURCE_IO
528 day = MSTK_REG_DOM(mregs); 431 * already, whereas when it's behind EBUS is will be IORESOURCE_MEM.
529 mon = MSTK_REG_MONTH(mregs); 432 */
530 year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) );
531
532 xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
533 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
534 set_normalized_timespec(&wall_to_monotonic,
535 -xtime.tv_sec, -xtime.tv_nsec);
536 433
537 tmp = mostek_read(mregs + MOSTEK_CREG); 434 r = &rtc_cmos_resource;
538 tmp &= ~MSTK_CREG_READ; 435 r->flags = IORESOURCE_IO;
539 mostek_write(mregs + MOSTEK_CREG, tmp); 436 r->name = op->resource[0].name;
437 r->start = op->resource[0].start;
438 r->end = op->resource[0].end;
540 439
541 spin_unlock_irq(&mostek_lock); 440 cmos_regs = op->resource[0].start;
441 return platform_device_register(&rtc_cmos_device);
542} 442}
543 443
544/* Probe for the real time clock chip. */ 444static struct of_device_id __initdata rtc_match[] = {
545static void __init set_system_time(void) 445 {
546{ 446 .name = "rtc",
547 unsigned int year, mon, day, hour, min, sec; 447 .compatible = "m5819",
548 void __iomem *mregs = mstk48t02_regs; 448 },
549#ifdef CONFIG_PCI 449 {
550 unsigned long dregs = ds1287_regs; 450 .name = "rtc",
551 void __iomem *bregs = bq4802_regs; 451 .compatible = "isa-m5819p",
552#else 452 },
553 unsigned long dregs = 0UL; 453 {
554 void __iomem *bregs = 0UL; 454 .name = "rtc",
555#endif 455 .compatible = "isa-m5823p",
556 456 },
557 if (!mregs && !dregs && !bregs) { 457 {
558 prom_printf("Something wrong, clock regs not mapped yet.\n"); 458 .name = "rtc",
559 prom_halt(); 459 .compatible = "ds1287",
560 } 460 },
561 461 {},
562 if (mregs) { 462};
563 mostek_set_system_time(mregs);
564 return;
565 }
566
567 if (bregs) {
568 unsigned char val = readb(bregs + 0x0e);
569 unsigned int century;
570 463
571 /* BQ4802 RTC chip. */ 464static struct of_platform_driver rtc_driver = {
465 .match_table = rtc_match,
466 .probe = rtc_probe,
467 .driver = {
468 .name = "rtc",
469 },
470};
572 471
573 writeb(val | 0x08, bregs + 0x0e); 472static struct platform_device rtc_bq4802_device = {
473 .name = "rtc-bq4802",
474 .id = -1,
475 .num_resources = 1,
476};
574 477
575 sec = readb(bregs + 0x00); 478static int __devinit bq4802_probe(struct of_device *op, const struct of_device_id *match)
576 min = readb(bregs + 0x02); 479{
577 hour = readb(bregs + 0x04);
578 day = readb(bregs + 0x06);
579 mon = readb(bregs + 0x09);
580 year = readb(bregs + 0x0a);
581 century = readb(bregs + 0x0f);
582 480
583 writeb(val, bregs + 0x0e); 481 printk(KERN_INFO "%s: BQ4802 regs at 0x%lx\n",
482 op->node->full_name, op->resource[0].start);
584 483
585 BCD_TO_BIN(sec); 484 rtc_bq4802_device.resource = &op->resource[0];
586 BCD_TO_BIN(min); 485 return platform_device_register(&rtc_bq4802_device);
587 BCD_TO_BIN(hour); 486}
588 BCD_TO_BIN(day);
589 BCD_TO_BIN(mon);
590 BCD_TO_BIN(year);
591 BCD_TO_BIN(century);
592 487
593 year += (century * 100); 488static struct of_device_id __initdata bq4802_match[] = {
594 } else { 489 {
595 /* Dallas 12887 RTC chip. */ 490 .name = "rtc",
596 491 .compatible = "bq4802",
597 do { 492 },
598 sec = CMOS_READ(RTC_SECONDS); 493};
599 min = CMOS_READ(RTC_MINUTES);
600 hour = CMOS_READ(RTC_HOURS);
601 day = CMOS_READ(RTC_DAY_OF_MONTH);
602 mon = CMOS_READ(RTC_MONTH);
603 year = CMOS_READ(RTC_YEAR);
604 } while (sec != CMOS_READ(RTC_SECONDS));
605
606 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
607 BCD_TO_BIN(sec);
608 BCD_TO_BIN(min);
609 BCD_TO_BIN(hour);
610 BCD_TO_BIN(day);
611 BCD_TO_BIN(mon);
612 BCD_TO_BIN(year);
613 }
614 if ((year += 1900) < 1970)
615 year += 100;
616 }
617 494
618 xtime.tv_sec = mktime(year, mon, day, hour, min, sec); 495static struct of_platform_driver bq4802_driver = {
619 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ); 496 .match_table = bq4802_match,
620 set_normalized_timespec(&wall_to_monotonic, 497 .probe = bq4802_probe,
621 -xtime.tv_sec, -xtime.tv_nsec); 498 .driver = {
622} 499 .name = "bq4802",
500 },
501};
623 502
624/* davem suggests we keep this within the 4M locked kernel image */ 503static unsigned char mostek_read_byte(struct device *dev, u32 ofs)
625static u32 starfire_get_time(void)
626{ 504{
627 static char obp_gettod[32]; 505 struct platform_device *pdev = to_platform_device(dev);
628 static u32 unix_tod; 506 struct m48t59_plat_data *pdata = pdev->dev.platform_data;
507 void __iomem *regs;
508 unsigned char val;
629 509
630 sprintf(obp_gettod, "h# %08x unix-gettod", 510 regs = (void __iomem *) pdev->resource[0].start;
631 (unsigned int) (long) &unix_tod); 511 val = readb(regs + ofs);
632 prom_feval(obp_gettod);
633 512
634 return unix_tod; 513 /* the year 0 is 1968 */
514 if (ofs == pdata->offset + M48T59_YEAR) {
515 val += 0x68;
516 if ((val & 0xf) > 9)
517 val += 6;
518 }
519 return val;
635} 520}
636 521
637static int starfire_set_time(u32 val) 522static void mostek_write_byte(struct device *dev, u32 ofs, u8 val)
638{ 523{
639 /* Do nothing, time is set using the service processor 524 struct platform_device *pdev = to_platform_device(dev);
640 * console on this platform. 525 struct m48t59_plat_data *pdata = pdev->dev.platform_data;
641 */ 526 void __iomem *regs;
642 return 0;
643}
644 527
645static u32 hypervisor_get_time(void) 528 regs = (void __iomem *) pdev->resource[0].start;
646{ 529 if (ofs == pdata->offset + M48T59_YEAR) {
647 unsigned long ret, time; 530 if (val < 0x68)
648 int retries = 10000; 531 val += 0x32;
649 532 else
650retry: 533 val -= 0x68;
651 ret = sun4v_tod_get(&time); 534 if ((val & 0xf) > 9)
652 if (ret == HV_EOK) 535 val += 6;
653 return time; 536 if ((val & 0xf0) > 0x9A)
654 if (ret == HV_EWOULDBLOCK) { 537 val += 0x60;
655 if (--retries > 0) {
656 udelay(100);
657 goto retry;
658 }
659 printk(KERN_WARNING "SUN4V: tod_get() timed out.\n");
660 return 0;
661 } 538 }
662 printk(KERN_WARNING "SUN4V: tod_get() not supported.\n"); 539 writeb(val, regs + ofs);
663 return 0;
664} 540}
665 541
666static int hypervisor_set_time(u32 secs) 542static struct m48t59_plat_data m48t59_data = {
667{ 543 .read_byte = mostek_read_byte,
668 unsigned long ret; 544 .write_byte = mostek_write_byte,
669 int retries = 10000; 545};
670
671retry:
672 ret = sun4v_tod_set(secs);
673 if (ret == HV_EOK)
674 return 0;
675 if (ret == HV_EWOULDBLOCK) {
676 if (--retries > 0) {
677 udelay(100);
678 goto retry;
679 }
680 printk(KERN_WARNING "SUN4V: tod_set() timed out.\n");
681 return -EAGAIN;
682 }
683 printk(KERN_WARNING "SUN4V: tod_set() not supported.\n");
684 return -EOPNOTSUPP;
685}
686 546
687static int __init clock_model_matches(const char *model) 547static struct platform_device m48t59_rtc = {
688{ 548 .name = "rtc-m48t59",
689 if (strcmp(model, "mk48t02") && 549 .id = 0,
690 strcmp(model, "mk48t08") && 550 .num_resources = 1,
691 strcmp(model, "mk48t59") && 551 .dev = {
692 strcmp(model, "m5819") && 552 .platform_data = &m48t59_data,
693 strcmp(model, "m5819p") && 553 },
694 strcmp(model, "m5823") && 554};
695 strcmp(model, "ds1287") &&
696 strcmp(model, "bq4802"))
697 return 0;
698
699 return 1;
700}
701 555
702static int __devinit clock_probe(struct of_device *op, const struct of_device_id *match) 556static int __devinit mostek_probe(struct of_device *op, const struct of_device_id *match)
703{ 557{
704 struct device_node *dp = op->node; 558 struct device_node *dp = op->node;
705 const char *model = of_get_property(dp, "model", NULL);
706 const char *compat = of_get_property(dp, "compatible", NULL);
707 unsigned long size, flags;
708 void __iomem *regs;
709
710 if (!model)
711 model = compat;
712
713 if (!model || !clock_model_matches(model))
714 return -ENODEV;
715 559
716 /* On an Enterprise system there can be multiple mostek clocks. 560 /* On an Enterprise system there can be multiple mostek clocks.
717 * We should only match the one that is on the central FHC bus. 561 * We should only match the one that is on the central FHC bus.
@@ -720,88 +564,51 @@ static int __devinit clock_probe(struct of_device *op, const struct of_device_id
720 strcmp(dp->parent->parent->name, "central") != 0) 564 strcmp(dp->parent->parent->name, "central") != 0)
721 return -ENODEV; 565 return -ENODEV;
722 566
723 size = (op->resource[0].end - op->resource[0].start) + 1; 567 printk(KERN_INFO "%s: Mostek regs at 0x%lx\n",
724 regs = of_ioremap(&op->resource[0], 0, size, "clock"); 568 dp->full_name, op->resource[0].start);
725 if (!regs)
726 return -ENOMEM;
727
728#ifdef CONFIG_PCI
729 if (!strcmp(model, "ds1287") ||
730 !strcmp(model, "m5819") ||
731 !strcmp(model, "m5819p") ||
732 !strcmp(model, "m5823")) {
733 ds1287_regs = (unsigned long) regs;
734 } else if (!strcmp(model, "bq4802")) {
735 bq4802_regs = regs;
736 } else
737#endif
738 if (model[5] == '0' && model[6] == '2') {
739 mstk48t02_regs = regs;
740 } else if(model[5] == '0' && model[6] == '8') {
741 mstk48t08_regs = regs;
742 mstk48t02_regs = mstk48t08_regs + MOSTEK_48T08_48T02;
743 } else {
744 mstk48t59_regs = regs;
745 mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02;
746 }
747
748 printk(KERN_INFO "%s: Clock regs at %p\n", dp->full_name, regs);
749
750 local_irq_save(flags);
751
752 if (mstk48t02_regs != NULL) {
753 /* Report a low battery voltage condition. */
754 if (has_low_battery())
755 prom_printf("NVRAM: Low battery voltage!\n");
756
757 /* Kick start the clock if it is completely stopped. */
758 if (mostek_read(mstk48t02_regs + MOSTEK_SEC) & MSTK_STOP)
759 kick_start_clock();
760 }
761
762 set_system_time();
763
764 local_irq_restore(flags);
765 569
766 return 0; 570 m48t59_rtc.resource = &op->resource[0];
571 return platform_device_register(&m48t59_rtc);
767} 572}
768 573
769static struct of_device_id clock_match[] = { 574static struct of_device_id __initdata mostek_match[] = {
770 { 575 {
771 .name = "eeprom", 576 .name = "eeprom",
772 }, 577 },
773 {
774 .name = "rtc",
775 },
776 {}, 578 {},
777}; 579};
778 580
779static struct of_platform_driver clock_driver = { 581static struct of_platform_driver mostek_driver = {
780 .match_table = clock_match, 582 .match_table = mostek_match,
781 .probe = clock_probe, 583 .probe = mostek_probe,
782 .driver = { 584 .driver = {
783 .name = "clock", 585 .name = "mostek",
784 }, 586 },
785}; 587};
786 588
589static struct platform_device rtc_sun4v_device = {
590 .name = "rtc-sun4v",
591 .id = -1,
592};
593
594static struct platform_device rtc_starfire_device = {
595 .name = "rtc-starfire",
596 .id = -1,
597};
598
787static int __init clock_init(void) 599static int __init clock_init(void)
788{ 600{
789 if (this_is_starfire) { 601 if (this_is_starfire)
790 xtime.tv_sec = starfire_get_time(); 602 return platform_device_register(&rtc_starfire_device);
791 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ); 603
792 set_normalized_timespec(&wall_to_monotonic, 604 if (tlb_type == hypervisor)
793 -xtime.tv_sec, -xtime.tv_nsec); 605 return platform_device_register(&rtc_sun4v_device);
794 return 0; 606
795 } 607 (void) of_register_driver(&rtc_driver, &of_platform_bus_type);
796 if (tlb_type == hypervisor) { 608 (void) of_register_driver(&mostek_driver, &of_platform_bus_type);
797 xtime.tv_sec = hypervisor_get_time(); 609 (void) of_register_driver(&bq4802_driver, &of_platform_bus_type);
798 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
799 set_normalized_timespec(&wall_to_monotonic,
800 -xtime.tv_sec, -xtime.tv_nsec);
801 return 0;
802 }
803 610
804 return of_register_driver(&clock_driver, &of_platform_bus_type); 611 return 0;
805} 612}
806 613
807/* Must be after subsys_initcall() so that busses are probed. Must 614/* Must be after subsys_initcall() so that busses are probed. Must
@@ -814,7 +621,7 @@ fs_initcall(clock_init);
814static unsigned long sparc64_init_timers(void) 621static unsigned long sparc64_init_timers(void)
815{ 622{
816 struct device_node *dp; 623 struct device_node *dp;
817 unsigned long clock; 624 unsigned long freq;
818 625
819 dp = of_find_node_by_path("/"); 626 dp = of_find_node_by_path("/");
820 if (tlb_type == spitfire) { 627 if (tlb_type == spitfire) {
@@ -827,17 +634,17 @@ static unsigned long sparc64_init_timers(void)
827 if (manuf == 0x17 && impl == 0x13) { 634 if (manuf == 0x17 && impl == 0x13) {
828 /* Hummingbird, aka Ultra-IIe */ 635 /* Hummingbird, aka Ultra-IIe */
829 tick_ops = &hbtick_operations; 636 tick_ops = &hbtick_operations;
830 clock = of_getintprop_default(dp, "stick-frequency", 0); 637 freq = of_getintprop_default(dp, "stick-frequency", 0);
831 } else { 638 } else {
832 tick_ops = &tick_operations; 639 tick_ops = &tick_operations;
833 clock = local_cpu_data().clock_tick; 640 freq = local_cpu_data().clock_tick;
834 } 641 }
835 } else { 642 } else {
836 tick_ops = &stick_operations; 643 tick_ops = &stick_operations;
837 clock = of_getintprop_default(dp, "stick-frequency", 0); 644 freq = of_getintprop_default(dp, "stick-frequency", 0);
838 } 645 }
839 646
840 return clock; 647 return freq;
841} 648}
842 649
843struct freq_table { 650struct freq_table {
@@ -1029,16 +836,16 @@ EXPORT_SYMBOL(udelay);
1029 836
1030void __init time_init(void) 837void __init time_init(void)
1031{ 838{
1032 unsigned long clock = sparc64_init_timers(); 839 unsigned long freq = sparc64_init_timers();
1033 840
1034 tb_ticks_per_usec = clock / USEC_PER_SEC; 841 tb_ticks_per_usec = freq / USEC_PER_SEC;
1035 842
1036 timer_ticks_per_nsec_quotient = 843 timer_ticks_per_nsec_quotient =
1037 clocksource_hz2mult(clock, SPARC64_NSEC_PER_CYC_SHIFT); 844 clocksource_hz2mult(freq, SPARC64_NSEC_PER_CYC_SHIFT);
1038 845
1039 clocksource_tick.name = tick_ops->name; 846 clocksource_tick.name = tick_ops->name;
1040 clocksource_tick.mult = 847 clocksource_tick.mult =
1041 clocksource_hz2mult(clock, 848 clocksource_hz2mult(freq,
1042 clocksource_tick.shift); 849 clocksource_tick.shift);
1043 clocksource_tick.read = tick_ops->get_tick; 850 clocksource_tick.read = tick_ops->get_tick;
1044 851
@@ -1049,7 +856,7 @@ void __init time_init(void)
1049 856
1050 sparc64_clockevent.name = tick_ops->name; 857 sparc64_clockevent.name = tick_ops->name;
1051 858
1052 setup_clockevent_multiplier(clock); 859 setup_clockevent_multiplier(freq);
1053 860
1054 sparc64_clockevent.max_delta_ns = 861 sparc64_clockevent.max_delta_ns =
1055 clockevent_delta2ns(0x7fffffffffffffffUL, &sparc64_clockevent); 862 clockevent_delta2ns(0x7fffffffffffffffUL, &sparc64_clockevent);
@@ -1070,672 +877,8 @@ unsigned long long sched_clock(void)
1070 >> SPARC64_NSEC_PER_CYC_SHIFT; 877 >> SPARC64_NSEC_PER_CYC_SHIFT;
1071} 878}
1072 879
1073static int set_rtc_mmss(unsigned long nowtime)
1074{
1075 int real_seconds, real_minutes, chip_minutes;
1076 void __iomem *mregs = mstk48t02_regs;
1077#ifdef CONFIG_PCI
1078 unsigned long dregs = ds1287_regs;
1079 void __iomem *bregs = bq4802_regs;
1080#else
1081 unsigned long dregs = 0UL;
1082 void __iomem *bregs = 0UL;
1083#endif
1084 unsigned long flags;
1085 u8 tmp;
1086
1087 /*
1088 * Not having a register set can lead to trouble.
1089 * Also starfire doesn't have a tod clock.
1090 */
1091 if (!mregs && !dregs && !bregs)
1092 return -1;
1093
1094 if (mregs) {
1095 spin_lock_irqsave(&mostek_lock, flags);
1096
1097 /* Read the current RTC minutes. */
1098 tmp = mostek_read(mregs + MOSTEK_CREG);
1099 tmp |= MSTK_CREG_READ;
1100 mostek_write(mregs + MOSTEK_CREG, tmp);
1101
1102 chip_minutes = MSTK_REG_MIN(mregs);
1103
1104 tmp = mostek_read(mregs + MOSTEK_CREG);
1105 tmp &= ~MSTK_CREG_READ;
1106 mostek_write(mregs + MOSTEK_CREG, tmp);
1107
1108 /*
1109 * since we're only adjusting minutes and seconds,
1110 * don't interfere with hour overflow. This avoids
1111 * messing with unknown time zones but requires your
1112 * RTC not to be off by more than 15 minutes
1113 */
1114 real_seconds = nowtime % 60;
1115 real_minutes = nowtime / 60;
1116 if (((abs(real_minutes - chip_minutes) + 15)/30) & 1)
1117 real_minutes += 30; /* correct for half hour time zone */
1118 real_minutes %= 60;
1119
1120 if (abs(real_minutes - chip_minutes) < 30) {
1121 tmp = mostek_read(mregs + MOSTEK_CREG);
1122 tmp |= MSTK_CREG_WRITE;
1123 mostek_write(mregs + MOSTEK_CREG, tmp);
1124
1125 MSTK_SET_REG_SEC(mregs,real_seconds);
1126 MSTK_SET_REG_MIN(mregs,real_minutes);
1127
1128 tmp = mostek_read(mregs + MOSTEK_CREG);
1129 tmp &= ~MSTK_CREG_WRITE;
1130 mostek_write(mregs + MOSTEK_CREG, tmp);
1131
1132 spin_unlock_irqrestore(&mostek_lock, flags);
1133
1134 return 0;
1135 } else {
1136 spin_unlock_irqrestore(&mostek_lock, flags);
1137
1138 return -1;
1139 }
1140 } else if (bregs) {
1141 int retval = 0;
1142 unsigned char val = readb(bregs + 0x0e);
1143
1144 /* BQ4802 RTC chip. */
1145
1146 writeb(val | 0x08, bregs + 0x0e);
1147
1148 chip_minutes = readb(bregs + 0x02);
1149 BCD_TO_BIN(chip_minutes);
1150 real_seconds = nowtime % 60;
1151 real_minutes = nowtime / 60;
1152 if (((abs(real_minutes - chip_minutes) + 15)/30) & 1)
1153 real_minutes += 30;
1154 real_minutes %= 60;
1155
1156 if (abs(real_minutes - chip_minutes) < 30) {
1157 BIN_TO_BCD(real_seconds);
1158 BIN_TO_BCD(real_minutes);
1159 writeb(real_seconds, bregs + 0x00);
1160 writeb(real_minutes, bregs + 0x02);
1161 } else {
1162 printk(KERN_WARNING
1163 "set_rtc_mmss: can't update from %d to %d\n",
1164 chip_minutes, real_minutes);
1165 retval = -1;
1166 }
1167
1168 writeb(val, bregs + 0x0e);
1169
1170 return retval;
1171 } else {
1172 int retval = 0;
1173 unsigned char save_control, save_freq_select;
1174
1175 /* Stolen from arch/i386/kernel/time.c, see there for
1176 * credits and descriptive comments.
1177 */
1178 spin_lock_irqsave(&rtc_lock, flags);
1179 save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
1180 CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
1181
1182 save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
1183 CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
1184
1185 chip_minutes = CMOS_READ(RTC_MINUTES);
1186 if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
1187 BCD_TO_BIN(chip_minutes);
1188 real_seconds = nowtime % 60;
1189 real_minutes = nowtime / 60;
1190 if (((abs(real_minutes - chip_minutes) + 15)/30) & 1)
1191 real_minutes += 30;
1192 real_minutes %= 60;
1193
1194 if (abs(real_minutes - chip_minutes) < 30) {
1195 if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
1196 BIN_TO_BCD(real_seconds);
1197 BIN_TO_BCD(real_minutes);
1198 }
1199 CMOS_WRITE(real_seconds,RTC_SECONDS);
1200 CMOS_WRITE(real_minutes,RTC_MINUTES);
1201 } else {
1202 printk(KERN_WARNING
1203 "set_rtc_mmss: can't update from %d to %d\n",
1204 chip_minutes, real_minutes);
1205 retval = -1;
1206 }
1207
1208 CMOS_WRITE(save_control, RTC_CONTROL);
1209 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
1210 spin_unlock_irqrestore(&rtc_lock, flags);
1211
1212 return retval;
1213 }
1214}
1215
1216#define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */
1217static unsigned char mini_rtc_status; /* bitmapped status byte. */
1218
1219#define FEBRUARY 2
1220#define STARTOFTIME 1970
1221#define SECDAY 86400L
1222#define SECYR (SECDAY * 365)
1223#define leapyear(year) ((year) % 4 == 0 && \
1224 ((year) % 100 != 0 || (year) % 400 == 0))
1225#define days_in_year(a) (leapyear(a) ? 366 : 365)
1226#define days_in_month(a) (month_days[(a) - 1])
1227
1228static int month_days[12] = {
1229 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
1230};
1231
1232/*
1233 * This only works for the Gregorian calendar - i.e. after 1752 (in the UK)
1234 */
1235static void GregorianDay(struct rtc_time * tm)
1236{
1237 int leapsToDate;
1238 int lastYear;
1239 int day;
1240 int MonthOffset[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
1241
1242 lastYear = tm->tm_year - 1;
1243
1244 /*
1245 * Number of leap corrections to apply up to end of last year
1246 */
1247 leapsToDate = lastYear / 4 - lastYear / 100 + lastYear / 400;
1248
1249 /*
1250 * This year is a leap year if it is divisible by 4 except when it is
1251 * divisible by 100 unless it is divisible by 400
1252 *
1253 * e.g. 1904 was a leap year, 1900 was not, 1996 is, and 2000 was
1254 */
1255 day = tm->tm_mon > 2 && leapyear(tm->tm_year);
1256
1257 day += lastYear*365 + leapsToDate + MonthOffset[tm->tm_mon-1] +
1258 tm->tm_mday;
1259
1260 tm->tm_wday = day % 7;
1261}
1262
1263static void to_tm(int tim, struct rtc_time *tm)
1264{
1265 register int i;
1266 register long hms, day;
1267
1268 day = tim / SECDAY;
1269 hms = tim % SECDAY;
1270
1271 /* Hours, minutes, seconds are easy */
1272 tm->tm_hour = hms / 3600;
1273 tm->tm_min = (hms % 3600) / 60;
1274 tm->tm_sec = (hms % 3600) % 60;
1275
1276 /* Number of years in days */
1277 for (i = STARTOFTIME; day >= days_in_year(i); i++)
1278 day -= days_in_year(i);
1279 tm->tm_year = i;
1280
1281 /* Number of months in days left */
1282 if (leapyear(tm->tm_year))
1283 days_in_month(FEBRUARY) = 29;
1284 for (i = 1; day >= days_in_month(i); i++)
1285 day -= days_in_month(i);
1286 days_in_month(FEBRUARY) = 28;
1287 tm->tm_mon = i;
1288
1289 /* Days are what is left over (+1) from all that. */
1290 tm->tm_mday = day + 1;
1291
1292 /*
1293 * Determine the day of week
1294 */
1295 GregorianDay(tm);
1296}
1297
1298/* Both Starfire and SUN4V give us seconds since Jan 1st, 1970,
1299 * aka Unix time. So we have to convert to/from rtc_time.
1300 */
1301static void starfire_get_rtc_time(struct rtc_time *time)
1302{
1303 u32 seconds = starfire_get_time();
1304
1305 to_tm(seconds, time);
1306 time->tm_year -= 1900;
1307 time->tm_mon -= 1;
1308}
1309
1310static int starfire_set_rtc_time(struct rtc_time *time)
1311{
1312 u32 seconds = mktime(time->tm_year + 1900, time->tm_mon + 1,
1313 time->tm_mday, time->tm_hour,
1314 time->tm_min, time->tm_sec);
1315
1316 return starfire_set_time(seconds);
1317}
1318
1319static void hypervisor_get_rtc_time(struct rtc_time *time)
1320{
1321 u32 seconds = hypervisor_get_time();
1322
1323 to_tm(seconds, time);
1324 time->tm_year -= 1900;
1325 time->tm_mon -= 1;
1326}
1327
1328static int hypervisor_set_rtc_time(struct rtc_time *time)
1329{
1330 u32 seconds = mktime(time->tm_year + 1900, time->tm_mon + 1,
1331 time->tm_mday, time->tm_hour,
1332 time->tm_min, time->tm_sec);
1333
1334 return hypervisor_set_time(seconds);
1335}
1336
1337#ifdef CONFIG_PCI
1338static void bq4802_get_rtc_time(struct rtc_time *time)
1339{
1340 unsigned char val = readb(bq4802_regs + 0x0e);
1341 unsigned int century;
1342
1343 writeb(val | 0x08, bq4802_regs + 0x0e);
1344
1345 time->tm_sec = readb(bq4802_regs + 0x00);
1346 time->tm_min = readb(bq4802_regs + 0x02);
1347 time->tm_hour = readb(bq4802_regs + 0x04);
1348 time->tm_mday = readb(bq4802_regs + 0x06);
1349 time->tm_mon = readb(bq4802_regs + 0x09);
1350 time->tm_year = readb(bq4802_regs + 0x0a);
1351 time->tm_wday = readb(bq4802_regs + 0x08);
1352 century = readb(bq4802_regs + 0x0f);
1353
1354 writeb(val, bq4802_regs + 0x0e);
1355
1356 BCD_TO_BIN(time->tm_sec);
1357 BCD_TO_BIN(time->tm_min);
1358 BCD_TO_BIN(time->tm_hour);
1359 BCD_TO_BIN(time->tm_mday);
1360 BCD_TO_BIN(time->tm_mon);
1361 BCD_TO_BIN(time->tm_year);
1362 BCD_TO_BIN(time->tm_wday);
1363 BCD_TO_BIN(century);
1364
1365 time->tm_year += (century * 100);
1366 time->tm_year -= 1900;
1367
1368 time->tm_mon--;
1369}
1370
1371static int bq4802_set_rtc_time(struct rtc_time *time)
1372{
1373 unsigned char val = readb(bq4802_regs + 0x0e);
1374 unsigned char sec, min, hrs, day, mon, yrs, century;
1375 unsigned int year;
1376
1377 year = time->tm_year + 1900;
1378 century = year / 100;
1379 yrs = year % 100;
1380
1381 mon = time->tm_mon + 1; /* tm_mon starts at zero */
1382 day = time->tm_mday;
1383 hrs = time->tm_hour;
1384 min = time->tm_min;
1385 sec = time->tm_sec;
1386
1387 BIN_TO_BCD(sec);
1388 BIN_TO_BCD(min);
1389 BIN_TO_BCD(hrs);
1390 BIN_TO_BCD(day);
1391 BIN_TO_BCD(mon);
1392 BIN_TO_BCD(yrs);
1393 BIN_TO_BCD(century);
1394
1395 writeb(val | 0x08, bq4802_regs + 0x0e);
1396
1397 writeb(sec, bq4802_regs + 0x00);
1398 writeb(min, bq4802_regs + 0x02);
1399 writeb(hrs, bq4802_regs + 0x04);
1400 writeb(day, bq4802_regs + 0x06);
1401 writeb(mon, bq4802_regs + 0x09);
1402 writeb(yrs, bq4802_regs + 0x0a);
1403 writeb(century, bq4802_regs + 0x0f);
1404
1405 writeb(val, bq4802_regs + 0x0e);
1406
1407 return 0;
1408}
1409
1410static void cmos_get_rtc_time(struct rtc_time *rtc_tm)
1411{
1412 unsigned char ctrl;
1413
1414 rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);
1415 rtc_tm->tm_min = CMOS_READ(RTC_MINUTES);
1416 rtc_tm->tm_hour = CMOS_READ(RTC_HOURS);
1417 rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
1418 rtc_tm->tm_mon = CMOS_READ(RTC_MONTH);
1419 rtc_tm->tm_year = CMOS_READ(RTC_YEAR);
1420 rtc_tm->tm_wday = CMOS_READ(RTC_DAY_OF_WEEK);
1421
1422 ctrl = CMOS_READ(RTC_CONTROL);
1423 if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
1424 BCD_TO_BIN(rtc_tm->tm_sec);
1425 BCD_TO_BIN(rtc_tm->tm_min);
1426 BCD_TO_BIN(rtc_tm->tm_hour);
1427 BCD_TO_BIN(rtc_tm->tm_mday);
1428 BCD_TO_BIN(rtc_tm->tm_mon);
1429 BCD_TO_BIN(rtc_tm->tm_year);
1430 BCD_TO_BIN(rtc_tm->tm_wday);
1431 }
1432
1433 if (rtc_tm->tm_year <= 69)
1434 rtc_tm->tm_year += 100;
1435
1436 rtc_tm->tm_mon--;
1437}
1438
1439static int cmos_set_rtc_time(struct rtc_time *rtc_tm)
1440{
1441 unsigned char mon, day, hrs, min, sec;
1442 unsigned char save_control, save_freq_select;
1443 unsigned int yrs;
1444
1445 yrs = rtc_tm->tm_year;
1446 mon = rtc_tm->tm_mon + 1;
1447 day = rtc_tm->tm_mday;
1448 hrs = rtc_tm->tm_hour;
1449 min = rtc_tm->tm_min;
1450 sec = rtc_tm->tm_sec;
1451
1452 if (yrs >= 100)
1453 yrs -= 100;
1454
1455 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
1456 BIN_TO_BCD(sec);
1457 BIN_TO_BCD(min);
1458 BIN_TO_BCD(hrs);
1459 BIN_TO_BCD(day);
1460 BIN_TO_BCD(mon);
1461 BIN_TO_BCD(yrs);
1462 }
1463
1464 save_control = CMOS_READ(RTC_CONTROL);
1465 CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
1466 save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
1467 CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
1468
1469 CMOS_WRITE(yrs, RTC_YEAR);
1470 CMOS_WRITE(mon, RTC_MONTH);
1471 CMOS_WRITE(day, RTC_DAY_OF_MONTH);
1472 CMOS_WRITE(hrs, RTC_HOURS);
1473 CMOS_WRITE(min, RTC_MINUTES);
1474 CMOS_WRITE(sec, RTC_SECONDS);
1475
1476 CMOS_WRITE(save_control, RTC_CONTROL);
1477 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
1478
1479 return 0;
1480}
1481#endif /* CONFIG_PCI */
1482
1483static void mostek_get_rtc_time(struct rtc_time *rtc_tm)
1484{
1485 void __iomem *regs = mstk48t02_regs;
1486 u8 tmp;
1487
1488 spin_lock_irq(&mostek_lock);
1489
1490 tmp = mostek_read(regs + MOSTEK_CREG);
1491 tmp |= MSTK_CREG_READ;
1492 mostek_write(regs + MOSTEK_CREG, tmp);
1493
1494 rtc_tm->tm_sec = MSTK_REG_SEC(regs);
1495 rtc_tm->tm_min = MSTK_REG_MIN(regs);
1496 rtc_tm->tm_hour = MSTK_REG_HOUR(regs);
1497 rtc_tm->tm_mday = MSTK_REG_DOM(regs);
1498 rtc_tm->tm_mon = MSTK_REG_MONTH(regs);
1499 rtc_tm->tm_year = MSTK_CVT_YEAR( MSTK_REG_YEAR(regs) );
1500 rtc_tm->tm_wday = MSTK_REG_DOW(regs);
1501
1502 tmp = mostek_read(regs + MOSTEK_CREG);
1503 tmp &= ~MSTK_CREG_READ;
1504 mostek_write(regs + MOSTEK_CREG, tmp);
1505
1506 spin_unlock_irq(&mostek_lock);
1507
1508 rtc_tm->tm_mon--;
1509 rtc_tm->tm_wday--;
1510 rtc_tm->tm_year -= 1900;
1511}
1512
1513static int mostek_set_rtc_time(struct rtc_time *rtc_tm)
1514{
1515 unsigned char mon, day, hrs, min, sec, wday;
1516 void __iomem *regs = mstk48t02_regs;
1517 unsigned int yrs;
1518 u8 tmp;
1519
1520 yrs = rtc_tm->tm_year + 1900;
1521 mon = rtc_tm->tm_mon + 1;
1522 day = rtc_tm->tm_mday;
1523 wday = rtc_tm->tm_wday + 1;
1524 hrs = rtc_tm->tm_hour;
1525 min = rtc_tm->tm_min;
1526 sec = rtc_tm->tm_sec;
1527
1528 spin_lock_irq(&mostek_lock);
1529
1530 tmp = mostek_read(regs + MOSTEK_CREG);
1531 tmp |= MSTK_CREG_WRITE;
1532 mostek_write(regs + MOSTEK_CREG, tmp);
1533
1534 MSTK_SET_REG_SEC(regs, sec);
1535 MSTK_SET_REG_MIN(regs, min);
1536 MSTK_SET_REG_HOUR(regs, hrs);
1537 MSTK_SET_REG_DOW(regs, wday);
1538 MSTK_SET_REG_DOM(regs, day);
1539 MSTK_SET_REG_MONTH(regs, mon);
1540 MSTK_SET_REG_YEAR(regs, yrs - MSTK_YEAR_ZERO);
1541
1542 tmp = mostek_read(regs + MOSTEK_CREG);
1543 tmp &= ~MSTK_CREG_WRITE;
1544 mostek_write(regs + MOSTEK_CREG, tmp);
1545
1546 spin_unlock_irq(&mostek_lock);
1547
1548 return 0;
1549}
1550
1551struct mini_rtc_ops {
1552 void (*get_rtc_time)(struct rtc_time *);
1553 int (*set_rtc_time)(struct rtc_time *);
1554};
1555
1556static struct mini_rtc_ops starfire_rtc_ops = {
1557 .get_rtc_time = starfire_get_rtc_time,
1558 .set_rtc_time = starfire_set_rtc_time,
1559};
1560
1561static struct mini_rtc_ops hypervisor_rtc_ops = {
1562 .get_rtc_time = hypervisor_get_rtc_time,
1563 .set_rtc_time = hypervisor_set_rtc_time,
1564};
1565
1566#ifdef CONFIG_PCI
1567static struct mini_rtc_ops bq4802_rtc_ops = {
1568 .get_rtc_time = bq4802_get_rtc_time,
1569 .set_rtc_time = bq4802_set_rtc_time,
1570};
1571
1572static struct mini_rtc_ops cmos_rtc_ops = {
1573 .get_rtc_time = cmos_get_rtc_time,
1574 .set_rtc_time = cmos_set_rtc_time,
1575};
1576#endif /* CONFIG_PCI */
1577
1578static struct mini_rtc_ops mostek_rtc_ops = {
1579 .get_rtc_time = mostek_get_rtc_time,
1580 .set_rtc_time = mostek_set_rtc_time,
1581};
1582
1583static struct mini_rtc_ops *mini_rtc_ops;
1584
1585static inline void mini_get_rtc_time(struct rtc_time *time)
1586{
1587 unsigned long flags;
1588
1589 spin_lock_irqsave(&rtc_lock, flags);
1590 mini_rtc_ops->get_rtc_time(time);
1591 spin_unlock_irqrestore(&rtc_lock, flags);
1592}
1593
1594static inline int mini_set_rtc_time(struct rtc_time *time)
1595{
1596 unsigned long flags;
1597 int err;
1598
1599 spin_lock_irqsave(&rtc_lock, flags);
1600 err = mini_rtc_ops->set_rtc_time(time);
1601 spin_unlock_irqrestore(&rtc_lock, flags);
1602
1603 return err;
1604}
1605
1606static int mini_rtc_ioctl(struct inode *inode, struct file *file,
1607 unsigned int cmd, unsigned long arg)
1608{
1609 struct rtc_time wtime;
1610 void __user *argp = (void __user *)arg;
1611
1612 switch (cmd) {
1613
1614 case RTC_PLL_GET:
1615 return -EINVAL;
1616
1617 case RTC_PLL_SET:
1618 return -EINVAL;
1619
1620 case RTC_UIE_OFF: /* disable ints from RTC updates. */
1621 return 0;
1622
1623 case RTC_UIE_ON: /* enable ints for RTC updates. */
1624 return -EINVAL;
1625
1626 case RTC_RD_TIME: /* Read the time/date from RTC */
1627 /* this doesn't get week-day, who cares */
1628 memset(&wtime, 0, sizeof(wtime));
1629 mini_get_rtc_time(&wtime);
1630
1631 return copy_to_user(argp, &wtime, sizeof(wtime)) ? -EFAULT : 0;
1632
1633 case RTC_SET_TIME: /* Set the RTC */
1634 {
1635 int year, days;
1636
1637 if (!capable(CAP_SYS_TIME))
1638 return -EACCES;
1639
1640 if (copy_from_user(&wtime, argp, sizeof(wtime)))
1641 return -EFAULT;
1642
1643 year = wtime.tm_year + 1900;
1644 days = month_days[wtime.tm_mon] +
1645 ((wtime.tm_mon == 1) && leapyear(year));
1646
1647 if ((wtime.tm_mon < 0 || wtime.tm_mon > 11) ||
1648 (wtime.tm_mday < 1))
1649 return -EINVAL;
1650
1651 if (wtime.tm_mday < 0 || wtime.tm_mday > days)
1652 return -EINVAL;
1653
1654 if (wtime.tm_hour < 0 || wtime.tm_hour >= 24 ||
1655 wtime.tm_min < 0 || wtime.tm_min >= 60 ||
1656 wtime.tm_sec < 0 || wtime.tm_sec >= 60)
1657 return -EINVAL;
1658
1659 return mini_set_rtc_time(&wtime);
1660 }
1661 }
1662
1663 return -EINVAL;
1664}
1665
1666static int mini_rtc_open(struct inode *inode, struct file *file)
1667{
1668 lock_kernel();
1669 if (mini_rtc_status & RTC_IS_OPEN) {
1670 unlock_kernel();
1671 return -EBUSY;
1672 }
1673
1674 mini_rtc_status |= RTC_IS_OPEN;
1675 unlock_kernel();
1676
1677 return 0;
1678}
1679
1680static int mini_rtc_release(struct inode *inode, struct file *file)
1681{
1682 mini_rtc_status &= ~RTC_IS_OPEN;
1683 return 0;
1684}
1685
1686
1687static const struct file_operations mini_rtc_fops = {
1688 .owner = THIS_MODULE,
1689 .ioctl = mini_rtc_ioctl,
1690 .open = mini_rtc_open,
1691 .release = mini_rtc_release,
1692};
1693
1694static struct miscdevice rtc_mini_dev =
1695{
1696 .minor = RTC_MINOR,
1697 .name = "rtc",
1698 .fops = &mini_rtc_fops,
1699};
1700
1701static int __init rtc_mini_init(void)
1702{
1703 int retval;
1704
1705 if (tlb_type == hypervisor)
1706 mini_rtc_ops = &hypervisor_rtc_ops;
1707 else if (this_is_starfire)
1708 mini_rtc_ops = &starfire_rtc_ops;
1709#ifdef CONFIG_PCI
1710 else if (bq4802_regs)
1711 mini_rtc_ops = &bq4802_rtc_ops;
1712 else if (ds1287_regs)
1713 mini_rtc_ops = &cmos_rtc_ops;
1714#endif /* CONFIG_PCI */
1715 else if (mstk48t02_regs)
1716 mini_rtc_ops = &mostek_rtc_ops;
1717 else
1718 return -ENODEV;
1719
1720 printk(KERN_INFO "Mini RTC Driver\n");
1721
1722 retval = misc_register(&rtc_mini_dev);
1723 if (retval < 0)
1724 return retval;
1725
1726 return 0;
1727}
1728
1729static void __exit rtc_mini_exit(void)
1730{
1731 misc_deregister(&rtc_mini_dev);
1732}
1733
1734int __devinit read_current_timer(unsigned long *timer_val) 880int __devinit read_current_timer(unsigned long *timer_val)
1735{ 881{
1736 *timer_val = tick_ops->get_tick(); 882 *timer_val = tick_ops->get_tick();
1737 return 0; 883 return 0;
1738} 884}
1739
1740module_init(rtc_mini_init);
1741module_exit(rtc_mini_exit);
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index c824df13f589..81ccd22e78d4 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -38,6 +38,7 @@
38#include <asm/timer.h> 38#include <asm/timer.h>
39#include <asm/head.h> 39#include <asm/head.h>
40#include <asm/prom.h> 40#include <asm/prom.h>
41#include <asm/memctrl.h>
41 42
42#include "entry.h" 43#include "entry.h"
43#include "kstack.h" 44#include "kstack.h"
@@ -129,6 +130,56 @@ void do_BUG(const char *file, int line)
129} 130}
130#endif 131#endif
131 132
133static DEFINE_SPINLOCK(dimm_handler_lock);
134static dimm_printer_t dimm_handler;
135
136static int sprintf_dimm(int synd_code, unsigned long paddr, char *buf, int buflen)
137{
138 unsigned long flags;
139 int ret = -ENODEV;
140
141 spin_lock_irqsave(&dimm_handler_lock, flags);
142 if (dimm_handler) {
143 ret = dimm_handler(synd_code, paddr, buf, buflen);
144 } else if (tlb_type == spitfire) {
145 if (prom_getunumber(synd_code, paddr, buf, buflen) == -1)
146 ret = -EINVAL;
147 else
148 ret = 0;
149 } else
150 ret = -ENODEV;
151 spin_unlock_irqrestore(&dimm_handler_lock, flags);
152
153 return ret;
154}
155
156int register_dimm_printer(dimm_printer_t func)
157{
158 unsigned long flags;
159 int ret = 0;
160
161 spin_lock_irqsave(&dimm_handler_lock, flags);
162 if (!dimm_handler)
163 dimm_handler = func;
164 else
165 ret = -EEXIST;
166 spin_unlock_irqrestore(&dimm_handler_lock, flags);
167
168 return ret;
169}
170EXPORT_SYMBOL_GPL(register_dimm_printer);
171
172void unregister_dimm_printer(dimm_printer_t func)
173{
174 unsigned long flags;
175
176 spin_lock_irqsave(&dimm_handler_lock, flags);
177 if (dimm_handler == func)
178 dimm_handler = NULL;
179 spin_unlock_irqrestore(&dimm_handler_lock, flags);
180}
181EXPORT_SYMBOL_GPL(unregister_dimm_printer);
182
132void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar) 183void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar)
133{ 184{
134 siginfo_t info; 185 siginfo_t info;
@@ -291,10 +342,7 @@ void sun4v_data_access_exception_tl1(struct pt_regs *regs, unsigned long addr, u
291} 342}
292 343
293#ifdef CONFIG_PCI 344#ifdef CONFIG_PCI
294/* This is really pathetic... */ 345#include "pci_impl.h"
295extern volatile int pci_poke_in_progress;
296extern volatile int pci_poke_cpu;
297extern volatile int pci_poke_faulted;
298#endif 346#endif
299 347
300/* When access exceptions happen, we must do this. */ 348/* When access exceptions happen, we must do this. */
@@ -376,8 +424,7 @@ static void spitfire_log_udb_syndrome(unsigned long afar, unsigned long udbh, un
376 424
377 if (udbl & bit) { 425 if (udbl & bit) {
378 scode = ecc_syndrome_table[udbl & 0xff]; 426 scode = ecc_syndrome_table[udbl & 0xff];
379 if (prom_getunumber(scode, afar, 427 if (sprintf_dimm(scode, afar, memmod_str, sizeof(memmod_str)) < 0)
380 memmod_str, sizeof(memmod_str)) == -1)
381 p = syndrome_unknown; 428 p = syndrome_unknown;
382 else 429 else
383 p = memmod_str; 430 p = memmod_str;
@@ -388,8 +435,7 @@ static void spitfire_log_udb_syndrome(unsigned long afar, unsigned long udbh, un
388 435
389 if (udbh & bit) { 436 if (udbh & bit) {
390 scode = ecc_syndrome_table[udbh & 0xff]; 437 scode = ecc_syndrome_table[udbh & 0xff];
391 if (prom_getunumber(scode, afar, 438 if (sprintf_dimm(scode, afar, memmod_str, sizeof(memmod_str)) < 0)
392 memmod_str, sizeof(memmod_str)) == -1)
393 p = syndrome_unknown; 439 p = syndrome_unknown;
394 else 440 else
395 p = memmod_str; 441 p = memmod_str;
@@ -1062,8 +1108,6 @@ static const char *cheetah_get_string(unsigned long bit)
1062 return "???"; 1108 return "???";
1063} 1109}
1064 1110
1065extern int chmc_getunumber(int, unsigned long, char *, int);
1066
1067static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *info, 1111static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *info,
1068 unsigned long afsr, unsigned long afar, int recoverable) 1112 unsigned long afsr, unsigned long afar, int recoverable)
1069{ 1113{
@@ -1105,7 +1149,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
1105 1149
1106 syndrome = (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT; 1150 syndrome = (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT;
1107 syndrome = cheetah_ecc_syntab[syndrome]; 1151 syndrome = cheetah_ecc_syntab[syndrome];
1108 ret = chmc_getunumber(syndrome, afar, unum, sizeof(unum)); 1152 ret = sprintf_dimm(syndrome, afar, unum, sizeof(unum));
1109 if (ret != -1) 1153 if (ret != -1)
1110 printk("%s" "ERROR(%d): AFAR E-syndrome [%s]\n", 1154 printk("%s" "ERROR(%d): AFAR E-syndrome [%s]\n",
1111 (recoverable ? KERN_WARNING : KERN_CRIT), 1155 (recoverable ? KERN_WARNING : KERN_CRIT),
@@ -1116,7 +1160,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
1116 1160
1117 syndrome = (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT; 1161 syndrome = (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT;
1118 syndrome = cheetah_mtag_syntab[syndrome]; 1162 syndrome = cheetah_mtag_syntab[syndrome];
1119 ret = chmc_getunumber(syndrome, afar, unum, sizeof(unum)); 1163 ret = sprintf_dimm(syndrome, afar, unum, sizeof(unum));
1120 if (ret != -1) 1164 if (ret != -1)
1121 printk("%s" "ERROR(%d): AFAR M-syndrome [%s]\n", 1165 printk("%s" "ERROR(%d): AFAR M-syndrome [%s]\n",
1122 (recoverable ? KERN_WARNING : KERN_CRIT), 1166 (recoverable ? KERN_WARNING : KERN_CRIT),
@@ -2224,7 +2268,6 @@ void die_if_kernel(char *str, struct pt_regs *regs)
2224 2268
2225extern int handle_popc(u32 insn, struct pt_regs *regs); 2269extern int handle_popc(u32 insn, struct pt_regs *regs);
2226extern int handle_ldf_stq(u32 insn, struct pt_regs *regs); 2270extern int handle_ldf_stq(u32 insn, struct pt_regs *regs);
2227extern int vis_emul(struct pt_regs *, unsigned int);
2228 2271
2229void do_illegal_instruction(struct pt_regs *regs) 2272void do_illegal_instruction(struct pt_regs *regs)
2230{ 2273{
diff --git a/arch/sparc64/kernel/vio.c b/arch/sparc64/kernel/vio.c
index a490077891a4..92b1f8ec01de 100644
--- a/arch/sparc64/kernel/vio.c
+++ b/arch/sparc64/kernel/vio.c
@@ -152,7 +152,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr,
152static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, 152static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH,
153 show_pciobppath_attr, NULL); 153 show_pciobppath_attr, NULL);
154 154
155struct device_node *cdev_node; 155static struct device_node *cdev_node;
156 156
157static struct vio_dev *root_vdev; 157static struct vio_dev *root_vdev;
158static u64 cdev_cfg_handle; 158static u64 cdev_cfg_handle;
@@ -371,9 +371,9 @@ static struct mdesc_notifier_client vio_ds_notifier = {
371 .node_name = "domain-services-port", 371 .node_name = "domain-services-port",
372}; 372};
373 373
374const char *channel_devices_node = "channel-devices"; 374static const char *channel_devices_node = "channel-devices";
375const char *channel_devices_compat = "SUNW,sun4v-channel-devices"; 375static const char *channel_devices_compat = "SUNW,sun4v-channel-devices";
376const char *cfg_handle_prop = "cfg-handle"; 376static const char *cfg_handle_prop = "cfg-handle";
377 377
378static int __init vio_init(void) 378static int __init vio_init(void)
379{ 379{
diff --git a/arch/sparc64/kernel/visemul.c b/arch/sparc64/kernel/visemul.c
index c3fd64706b53..9e05cb5cb855 100644
--- a/arch/sparc64/kernel/visemul.c
+++ b/arch/sparc64/kernel/visemul.c
@@ -243,7 +243,7 @@ static inline unsigned int *fps_regaddr(struct fpustate *f,
243struct edge_tab { 243struct edge_tab {
244 u16 left, right; 244 u16 left, right;
245}; 245};
246struct edge_tab edge8_tab[8] = { 246static struct edge_tab edge8_tab[8] = {
247 { 0xff, 0x80 }, 247 { 0xff, 0x80 },
248 { 0x7f, 0xc0 }, 248 { 0x7f, 0xc0 },
249 { 0x3f, 0xe0 }, 249 { 0x3f, 0xe0 },
@@ -253,7 +253,7 @@ struct edge_tab edge8_tab[8] = {
253 { 0x03, 0xfe }, 253 { 0x03, 0xfe },
254 { 0x01, 0xff }, 254 { 0x01, 0xff },
255}; 255};
256struct edge_tab edge8_tab_l[8] = { 256static struct edge_tab edge8_tab_l[8] = {
257 { 0xff, 0x01 }, 257 { 0xff, 0x01 },
258 { 0xfe, 0x03 }, 258 { 0xfe, 0x03 },
259 { 0xfc, 0x07 }, 259 { 0xfc, 0x07 },
@@ -263,23 +263,23 @@ struct edge_tab edge8_tab_l[8] = {
263 { 0xc0, 0x7f }, 263 { 0xc0, 0x7f },
264 { 0x80, 0xff }, 264 { 0x80, 0xff },
265}; 265};
266struct edge_tab edge16_tab[4] = { 266static struct edge_tab edge16_tab[4] = {
267 { 0xf, 0x8 }, 267 { 0xf, 0x8 },
268 { 0x7, 0xc }, 268 { 0x7, 0xc },
269 { 0x3, 0xe }, 269 { 0x3, 0xe },
270 { 0x1, 0xf }, 270 { 0x1, 0xf },
271}; 271};
272struct edge_tab edge16_tab_l[4] = { 272static struct edge_tab edge16_tab_l[4] = {
273 { 0xf, 0x1 }, 273 { 0xf, 0x1 },
274 { 0xe, 0x3 }, 274 { 0xe, 0x3 },
275 { 0xc, 0x7 }, 275 { 0xc, 0x7 },
276 { 0x8, 0xf }, 276 { 0x8, 0xf },
277}; 277};
278struct edge_tab edge32_tab[2] = { 278static struct edge_tab edge32_tab[2] = {
279 { 0x3, 0x2 }, 279 { 0x3, 0x2 },
280 { 0x1, 0x3 }, 280 { 0x1, 0x3 },
281}; 281};
282struct edge_tab edge32_tab_l[2] = { 282static struct edge_tab edge32_tab_l[2] = {
283 { 0x3, 0x1 }, 283 { 0x3, 0x1 },
284 { 0x2, 0x3 }, 284 { 0x2, 0x3 },
285}; 285};
diff --git a/arch/sparc64/mm/fault.c b/arch/sparc64/mm/fault.c
index ea7d7ae76bc2..a9e474bf6385 100644
--- a/arch/sparc64/mm/fault.c
+++ b/arch/sparc64/mm/fault.c
@@ -51,43 +51,6 @@ static inline int notify_page_fault(struct pt_regs *regs)
51} 51}
52#endif 52#endif
53 53
54/*
55 * To debug kernel to catch accesses to certain virtual/physical addresses.
56 * Mode = 0 selects physical watchpoints, mode = 1 selects virtual watchpoints.
57 * flags = VM_READ watches memread accesses, flags = VM_WRITE watches memwrite accesses.
58 * Caller passes in a 64bit aligned addr, with mask set to the bytes that need to be
59 * watched. This is only useful on a single cpu machine for now. After the watchpoint
60 * is detected, the process causing it will be killed, thus preventing an infinite loop.
61 */
62void set_brkpt(unsigned long addr, unsigned char mask, int flags, int mode)
63{
64 unsigned long lsubits;
65
66 __asm__ __volatile__("ldxa [%%g0] %1, %0"
67 : "=r" (lsubits)
68 : "i" (ASI_LSU_CONTROL));
69 lsubits &= ~(LSU_CONTROL_PM | LSU_CONTROL_VM |
70 LSU_CONTROL_PR | LSU_CONTROL_VR |
71 LSU_CONTROL_PW | LSU_CONTROL_VW);
72
73 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
74 "membar #Sync"
75 : /* no outputs */
76 : "r" (addr), "r" (mode ? VIRT_WATCHPOINT : PHYS_WATCHPOINT),
77 "i" (ASI_DMMU));
78
79 lsubits |= ((unsigned long)mask << (mode ? 25 : 33));
80 if (flags & VM_READ)
81 lsubits |= (mode ? LSU_CONTROL_VR : LSU_CONTROL_PR);
82 if (flags & VM_WRITE)
83 lsubits |= (mode ? LSU_CONTROL_VW : LSU_CONTROL_PW);
84 __asm__ __volatile__("stxa %0, [%%g0] %1\n\t"
85 "membar #Sync"
86 : /* no outputs */
87 : "r" (lsubits), "i" (ASI_LSU_CONTROL)
88 : "memory");
89}
90
91static void __kprobes unhandled_fault(unsigned long address, 54static void __kprobes unhandled_fault(unsigned long address,
92 struct task_struct *tsk, 55 struct task_struct *tsk,
93 struct pt_regs *regs) 56 struct pt_regs *regs)
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index a41df7bef035..3c10daf8fc01 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -46,15 +46,11 @@
46#include <asm/tsb.h> 46#include <asm/tsb.h>
47#include <asm/hypervisor.h> 47#include <asm/hypervisor.h>
48#include <asm/prom.h> 48#include <asm/prom.h>
49#include <asm/sstate.h>
50#include <asm/mdesc.h> 49#include <asm/mdesc.h>
51#include <asm/cpudata.h> 50#include <asm/cpudata.h>
52#include <asm/irq.h> 51#include <asm/irq.h>
53 52
54#define MAX_PHYS_ADDRESS (1UL << 42UL) 53#include "init.h"
55#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL)
56#define KPTE_BITMAP_BYTES \
57 ((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 8)
58 54
59unsigned long kern_linear_pte_xor[2] __read_mostly; 55unsigned long kern_linear_pte_xor[2] __read_mostly;
60 56
@@ -416,17 +412,9 @@ void mmu_info(struct seq_file *m)
416#endif /* CONFIG_DEBUG_DCFLUSH */ 412#endif /* CONFIG_DEBUG_DCFLUSH */
417} 413}
418 414
419struct linux_prom_translation {
420 unsigned long virt;
421 unsigned long size;
422 unsigned long data;
423};
424
425/* Exported for kernel TLB miss handling in ktlb.S */
426struct linux_prom_translation prom_trans[512] __read_mostly; 415struct linux_prom_translation prom_trans[512] __read_mostly;
427unsigned int prom_trans_ents __read_mostly; 416unsigned int prom_trans_ents __read_mostly;
428 417
429/* Exported for SMP bootup purposes. */
430unsigned long kern_locked_tte_data; 418unsigned long kern_locked_tte_data;
431 419
432/* The obp translations are saved based on 8k pagesize, since obp can 420/* The obp translations are saved based on 8k pagesize, since obp can
@@ -938,6 +926,10 @@ int of_node_to_nid(struct device_node *dp)
938 int count, nid; 926 int count, nid;
939 u64 grp; 927 u64 grp;
940 928
929 /* This is the right thing to do on currently supported
930 * SUN4U NUMA platforms as well, as the PCI controller does
931 * not sit behind any particular memory controller.
932 */
941 if (!mlgroups) 933 if (!mlgroups)
942 return -1; 934 return -1;
943 935
@@ -1206,8 +1198,44 @@ out:
1206 return err; 1198 return err;
1207} 1199}
1208 1200
1201static int __init numa_parse_jbus(void)
1202{
1203 unsigned long cpu, index;
1204
1205 /* NUMA node id is encoded in bits 36 and higher, and there is
1206 * a 1-to-1 mapping from CPU ID to NUMA node ID.
1207 */
1208 index = 0;
1209 for_each_present_cpu(cpu) {
1210 numa_cpu_lookup_table[cpu] = index;
1211 numa_cpumask_lookup_table[index] = cpumask_of_cpu(cpu);
1212 node_masks[index].mask = ~((1UL << 36UL) - 1UL);
1213 node_masks[index].val = cpu << 36UL;
1214
1215 index++;
1216 }
1217 num_node_masks = index;
1218
1219 add_node_ranges();
1220
1221 for (index = 0; index < num_node_masks; index++) {
1222 allocate_node_data(index);
1223 node_set_online(index);
1224 }
1225
1226 return 0;
1227}
1228
1209static int __init numa_parse_sun4u(void) 1229static int __init numa_parse_sun4u(void)
1210{ 1230{
1231 if (tlb_type == cheetah || tlb_type == cheetah_plus) {
1232 unsigned long ver;
1233
1234 __asm__ ("rdpr %%ver, %0" : "=r" (ver));
1235 if ((ver >> 32UL) == __JALAPENO_ID ||
1236 (ver >> 32UL) == __SERRANO_ID)
1237 return numa_parse_jbus();
1238 }
1211 return -1; 1239 return -1;
1212} 1240}
1213 1241
@@ -1633,8 +1661,6 @@ void __cpuinit sun4v_ktsb_register(void)
1633 1661
1634/* paging_init() sets up the page tables */ 1662/* paging_init() sets up the page tables */
1635 1663
1636extern void central_probe(void);
1637
1638static unsigned long last_valid_pfn; 1664static unsigned long last_valid_pfn;
1639pgd_t swapper_pg_dir[2048]; 1665pgd_t swapper_pg_dir[2048];
1640 1666
@@ -1679,8 +1705,6 @@ void __init paging_init(void)
1679 kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL; 1705 kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
1680 kern_size = (unsigned long)&_end - (unsigned long)KERNBASE; 1706 kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
1681 1707
1682 sstate_booting();
1683
1684 /* Invalidate both kernel TSBs. */ 1708 /* Invalidate both kernel TSBs. */
1685 memset(swapper_tsb, 0x40, sizeof(swapper_tsb)); 1709 memset(swapper_tsb, 0x40, sizeof(swapper_tsb));
1686#ifndef CONFIG_DEBUG_PAGEALLOC 1710#ifndef CONFIG_DEBUG_PAGEALLOC
@@ -1803,9 +1827,6 @@ void __init paging_init(void)
1803 } 1827 }
1804 1828
1805 printk("Booting Linux...\n"); 1829 printk("Booting Linux...\n");
1806
1807 central_probe();
1808 cpu_probe();
1809} 1830}
1810 1831
1811int __init page_in_phys_avail(unsigned long paddr) 1832int __init page_in_phys_avail(unsigned long paddr)
@@ -2032,7 +2053,6 @@ pgprot_t PAGE_COPY __read_mostly;
2032pgprot_t PAGE_SHARED __read_mostly; 2053pgprot_t PAGE_SHARED __read_mostly;
2033EXPORT_SYMBOL(PAGE_SHARED); 2054EXPORT_SYMBOL(PAGE_SHARED);
2034 2055
2035pgprot_t PAGE_EXEC __read_mostly;
2036unsigned long pg_iobits __read_mostly; 2056unsigned long pg_iobits __read_mostly;
2037 2057
2038unsigned long _PAGE_IE __read_mostly; 2058unsigned long _PAGE_IE __read_mostly;
@@ -2045,14 +2065,6 @@ unsigned long _PAGE_CACHE __read_mostly;
2045EXPORT_SYMBOL(_PAGE_CACHE); 2065EXPORT_SYMBOL(_PAGE_CACHE);
2046 2066
2047#ifdef CONFIG_SPARSEMEM_VMEMMAP 2067#ifdef CONFIG_SPARSEMEM_VMEMMAP
2048
2049#define VMEMMAP_CHUNK_SHIFT 22
2050#define VMEMMAP_CHUNK (1UL << VMEMMAP_CHUNK_SHIFT)
2051#define VMEMMAP_CHUNK_MASK ~(VMEMMAP_CHUNK - 1UL)
2052#define VMEMMAP_ALIGN(x) (((x)+VMEMMAP_CHUNK-1UL)&VMEMMAP_CHUNK_MASK)
2053
2054#define VMEMMAP_SIZE ((((1UL << MAX_PHYSADDR_BITS) >> PAGE_SHIFT) * \
2055 sizeof(struct page *)) >> VMEMMAP_CHUNK_SHIFT)
2056unsigned long vmemmap_table[VMEMMAP_SIZE]; 2068unsigned long vmemmap_table[VMEMMAP_SIZE];
2057 2069
2058int __meminit vmemmap_populate(struct page *start, unsigned long nr, int node) 2070int __meminit vmemmap_populate(struct page *start, unsigned long nr, int node)
@@ -2136,7 +2148,6 @@ static void __init sun4u_pgprot_init(void)
2136 _PAGE_CACHE_4U | _PAGE_P_4U | 2148 _PAGE_CACHE_4U | _PAGE_P_4U |
2137 __ACCESS_BITS_4U | __DIRTY_BITS_4U | 2149 __ACCESS_BITS_4U | __DIRTY_BITS_4U |
2138 _PAGE_EXEC_4U | _PAGE_L_4U); 2150 _PAGE_EXEC_4U | _PAGE_L_4U);
2139 PAGE_EXEC = __pgprot(_PAGE_EXEC_4U);
2140 2151
2141 _PAGE_IE = _PAGE_IE_4U; 2152 _PAGE_IE = _PAGE_IE_4U;
2142 _PAGE_E = _PAGE_E_4U; 2153 _PAGE_E = _PAGE_E_4U;
@@ -2147,10 +2158,10 @@ static void __init sun4u_pgprot_init(void)
2147 2158
2148#ifdef CONFIG_DEBUG_PAGEALLOC 2159#ifdef CONFIG_DEBUG_PAGEALLOC
2149 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZBITS_4U) ^ 2160 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZBITS_4U) ^
2150 0xfffff80000000000; 2161 0xfffff80000000000UL;
2151#else 2162#else
2152 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZ4MB_4U) ^ 2163 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZ4MB_4U) ^
2153 0xfffff80000000000; 2164 0xfffff80000000000UL;
2154#endif 2165#endif
2155 kern_linear_pte_xor[0] |= (_PAGE_CP_4U | _PAGE_CV_4U | 2166 kern_linear_pte_xor[0] |= (_PAGE_CP_4U | _PAGE_CV_4U |
2156 _PAGE_P_4U | _PAGE_W_4U); 2167 _PAGE_P_4U | _PAGE_W_4U);
@@ -2188,7 +2199,6 @@ static void __init sun4v_pgprot_init(void)
2188 __ACCESS_BITS_4V | __DIRTY_BITS_4V | 2199 __ACCESS_BITS_4V | __DIRTY_BITS_4V |
2189 _PAGE_EXEC_4V); 2200 _PAGE_EXEC_4V);
2190 PAGE_KERNEL_LOCKED = PAGE_KERNEL; 2201 PAGE_KERNEL_LOCKED = PAGE_KERNEL;
2191 PAGE_EXEC = __pgprot(_PAGE_EXEC_4V);
2192 2202
2193 _PAGE_IE = _PAGE_IE_4V; 2203 _PAGE_IE = _PAGE_IE_4V;
2194 _PAGE_E = _PAGE_E_4V; 2204 _PAGE_E = _PAGE_E_4V;
@@ -2196,20 +2206,20 @@ static void __init sun4v_pgprot_init(void)
2196 2206
2197#ifdef CONFIG_DEBUG_PAGEALLOC 2207#ifdef CONFIG_DEBUG_PAGEALLOC
2198 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZBITS_4V) ^ 2208 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZBITS_4V) ^
2199 0xfffff80000000000; 2209 0xfffff80000000000UL;
2200#else 2210#else
2201 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZ4MB_4V) ^ 2211 kern_linear_pte_xor[0] = (_PAGE_VALID | _PAGE_SZ4MB_4V) ^
2202 0xfffff80000000000; 2212 0xfffff80000000000UL;
2203#endif 2213#endif
2204 kern_linear_pte_xor[0] |= (_PAGE_CP_4V | _PAGE_CV_4V | 2214 kern_linear_pte_xor[0] |= (_PAGE_CP_4V | _PAGE_CV_4V |
2205 _PAGE_P_4V | _PAGE_W_4V); 2215 _PAGE_P_4V | _PAGE_W_4V);
2206 2216
2207#ifdef CONFIG_DEBUG_PAGEALLOC 2217#ifdef CONFIG_DEBUG_PAGEALLOC
2208 kern_linear_pte_xor[1] = (_PAGE_VALID | _PAGE_SZBITS_4V) ^ 2218 kern_linear_pte_xor[1] = (_PAGE_VALID | _PAGE_SZBITS_4V) ^
2209 0xfffff80000000000; 2219 0xfffff80000000000UL;
2210#else 2220#else
2211 kern_linear_pte_xor[1] = (_PAGE_VALID | _PAGE_SZ256MB_4V) ^ 2221 kern_linear_pte_xor[1] = (_PAGE_VALID | _PAGE_SZ256MB_4V) ^
2212 0xfffff80000000000; 2222 0xfffff80000000000UL;
2213#endif 2223#endif
2214 kern_linear_pte_xor[1] |= (_PAGE_CP_4V | _PAGE_CV_4V | 2224 kern_linear_pte_xor[1] |= (_PAGE_CP_4V | _PAGE_CV_4V |
2215 _PAGE_P_4V | _PAGE_W_4V); 2225 _PAGE_P_4V | _PAGE_W_4V);
diff --git a/arch/sparc64/mm/init.h b/arch/sparc64/mm/init.h
new file mode 100644
index 000000000000..16063870a489
--- /dev/null
+++ b/arch/sparc64/mm/init.h
@@ -0,0 +1,49 @@
1#ifndef _SPARC64_MM_INIT_H
2#define _SPARC64_MM_INIT_H
3
4/* Most of the symbols in this file are defined in init.c and
5 * marked non-static so that assembler code can get at them.
6 */
7
8#define MAX_PHYS_ADDRESS (1UL << 42UL)
9#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL)
10#define KPTE_BITMAP_BYTES \
11 ((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 8)
12
13extern unsigned long kern_linear_pte_xor[2];
14extern unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)];
15extern unsigned int sparc64_highest_unlocked_tlb_ent;
16extern unsigned long sparc64_kern_pri_context;
17extern unsigned long sparc64_kern_pri_nuc_bits;
18extern unsigned long sparc64_kern_sec_context;
19extern void mmu_info(struct seq_file *m);
20
21struct linux_prom_translation {
22 unsigned long virt;
23 unsigned long size;
24 unsigned long data;
25};
26
27/* Exported for kernel TLB miss handling in ktlb.S */
28extern struct linux_prom_translation prom_trans[512];
29extern unsigned int prom_trans_ents;
30
31/* Exported for SMP bootup purposes. */
32extern unsigned long kern_locked_tte_data;
33
34extern void prom_world(int enter);
35
36extern void free_initmem(void);
37
38#ifdef CONFIG_SPARSEMEM_VMEMMAP
39#define VMEMMAP_CHUNK_SHIFT 22
40#define VMEMMAP_CHUNK (1UL << VMEMMAP_CHUNK_SHIFT)
41#define VMEMMAP_CHUNK_MASK ~(VMEMMAP_CHUNK - 1UL)
42#define VMEMMAP_ALIGN(x) (((x)+VMEMMAP_CHUNK-1UL)&VMEMMAP_CHUNK_MASK)
43
44#define VMEMMAP_SIZE ((((1UL << MAX_PHYSADDR_BITS) >> PAGE_SHIFT) * \
45 sizeof(struct page *)) >> VMEMMAP_CHUNK_SHIFT)
46extern unsigned long vmemmap_table[VMEMMAP_SIZE];
47#endif
48
49#endif /* _SPARC64_MM_INIT_H */
diff --git a/arch/sparc64/mm/tlb.c b/arch/sparc64/mm/tlb.c
index ae24919cba7c..d8f21e24a82f 100644
--- a/arch/sparc64/mm/tlb.c
+++ b/arch/sparc64/mm/tlb.c
@@ -19,7 +19,7 @@
19 19
20/* Heavily inspired by the ppc64 code. */ 20/* Heavily inspired by the ppc64 code. */
21 21
22DEFINE_PER_CPU(struct mmu_gather, mmu_gathers) = { 0, }; 22DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
23 23
24void flush_tlb_pending(void) 24void flush_tlb_pending(void)
25{ 25{
diff --git a/arch/um/Kconfig.char b/arch/um/Kconfig.char
index 1b238ebae6b3..70dabd1e0652 100644
--- a/arch/um/Kconfig.char
+++ b/arch/um/Kconfig.char
@@ -203,6 +203,10 @@ config SOUND
203 tristate 203 tristate
204 default UML_SOUND 204 default UML_SOUND
205 205
206config SOUND_OSS_CORE
207 bool
208 default UML_SOUND
209
206config HOSTAUDIO 210config HOSTAUDIO
207 tristate 211 tristate
208 default UML_SOUND 212 default UML_SOUND
diff --git a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c
index be2d50c3aa95..045772142844 100644
--- a/arch/um/kernel/smp.c
+++ b/arch/um/kernel/smp.c
@@ -85,6 +85,7 @@ static int idle_proc(void *cpup)
85 while (!cpu_isset(cpu, smp_commenced_mask)) 85 while (!cpu_isset(cpu, smp_commenced_mask))
86 cpu_relax(); 86 cpu_relax();
87 87
88 notify_cpu_starting(cpu);
88 cpu_set(cpu, cpu_online_map); 89 cpu_set(cpu, cpu_online_map);
89 default_idle(); 90 default_idle();
90 return 0; 91 return 0;
diff --git a/arch/um/sys-x86_64/syscall_table.c b/arch/um/sys-x86_64/syscall_table.c
index c128eb897008..32f5fbe2d0d2 100644
--- a/arch/um/sys-x86_64/syscall_table.c
+++ b/arch/um/sys-x86_64/syscall_table.c
@@ -41,12 +41,12 @@
41#define stub_rt_sigreturn sys_rt_sigreturn 41#define stub_rt_sigreturn sys_rt_sigreturn
42 42
43#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ; 43#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ;
44#undef _ASM_X86_64_UNISTD_H_ 44#undef ASM_X86__UNISTD_64_H
45#include <asm-x86/unistd_64.h> 45#include <asm-x86/unistd_64.h>
46 46
47#undef __SYSCALL 47#undef __SYSCALL
48#define __SYSCALL(nr, sym) [ nr ] = sym, 48#define __SYSCALL(nr, sym) [ nr ] = sym,
49#undef _ASM_X86_64_UNISTD_H_ 49#undef ASM_X86__UNISTD_64_H
50 50
51typedef void (*sys_call_ptr_t)(void); 51typedef void (*sys_call_ptr_t)(void);
52 52
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ed92864d1325..fc8351f374fd 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -29,6 +29,7 @@ config X86
29 select HAVE_FTRACE 29 select HAVE_FTRACE
30 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) 30 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64)
31 select HAVE_ARCH_KGDB if !X86_VOYAGER 31 select HAVE_ARCH_KGDB if !X86_VOYAGER
32 select HAVE_ARCH_TRACEHOOK
32 select HAVE_GENERIC_DMA_COHERENT if X86_32 33 select HAVE_GENERIC_DMA_COHERENT if X86_32
33 select HAVE_EFFICIENT_UNALIGNED_ACCESS 34 select HAVE_EFFICIENT_UNALIGNED_ACCESS
34 35
@@ -553,6 +554,7 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT
553config AMD_IOMMU 554config AMD_IOMMU
554 bool "AMD IOMMU support" 555 bool "AMD IOMMU support"
555 select SWIOTLB 556 select SWIOTLB
557 select PCI_MSI
556 depends on X86_64 && PCI && ACPI 558 depends on X86_64 && PCI && ACPI
557 help 559 help
558 With this option you can enable support for AMD IOMMU hardware in 560 With this option you can enable support for AMD IOMMU hardware in
@@ -776,23 +778,45 @@ config X86_REBOOTFIXUPS
776 Say N otherwise. 778 Say N otherwise.
777 779
778config MICROCODE 780config MICROCODE
779 tristate "/dev/cpu/microcode - Intel IA32 CPU microcode support" 781 tristate "/dev/cpu/microcode - microcode support"
780 select FW_LOADER 782 select FW_LOADER
781 ---help--- 783 ---help---
782 If you say Y here, you will be able to update the microcode on 784 If you say Y here, you will be able to update the microcode on
783 Intel processors in the IA32 family, e.g. Pentium Pro, Pentium II, 785 certain Intel and AMD processors. The Intel support is for the
784 Pentium III, Pentium 4, Xeon etc. You will obviously need the 786 IA32 family, e.g. Pentium Pro, Pentium II, Pentium III,
785 actual microcode binary data itself which is not shipped with the 787 Pentium 4, Xeon etc. The AMD support is for family 0x10 and
786 Linux kernel. 788 0x11 processors, e.g. Opteron, Phenom and Turion 64 Ultra.
789 You will obviously need the actual microcode binary data itself
790 which is not shipped with the Linux kernel.
787 791
788 For latest news and information on obtaining all the required 792 This option selects the general module only, you need to select
789 ingredients for this driver, check: 793 at least one vendor specific module as well.
790 <http://www.urbanmyth.org/microcode/>.
791 794
792 To compile this driver as a module, choose M here: the 795 To compile this driver as a module, choose M here: the
793 module will be called microcode. 796 module will be called microcode.
794 797
795config MICROCODE_OLD_INTERFACE 798config MICROCODE_INTEL
799 bool "Intel microcode patch loading support"
800 depends on MICROCODE
801 default MICROCODE
802 select FW_LOADER
803 --help---
804 This options enables microcode patch loading support for Intel
805 processors.
806
807 For latest news and information on obtaining all the required
808 Intel ingredients for this driver, check:
809 <http://www.urbanmyth.org/microcode/>.
810
811config MICROCODE_AMD
812 bool "AMD microcode patch loading support"
813 depends on MICROCODE
814 select FW_LOADER
815 --help---
816 If you select this option, microcode patch loading support for AMD
817 processors will be enabled.
818
819 config MICROCODE_OLD_INTERFACE
796 def_bool y 820 def_bool y
797 depends on MICROCODE 821 depends on MICROCODE
798 822
@@ -1020,7 +1044,7 @@ config HAVE_ARCH_ALLOC_REMAP
1020 1044
1021config ARCH_FLATMEM_ENABLE 1045config ARCH_FLATMEM_ENABLE
1022 def_bool y 1046 def_bool y
1023 depends on X86_32 && ARCH_SELECT_MEMORY_MODEL && X86_PC && !NUMA 1047 depends on X86_32 && ARCH_SELECT_MEMORY_MODEL && !NUMA
1024 1048
1025config ARCH_DISCONTIGMEM_ENABLE 1049config ARCH_DISCONTIGMEM_ENABLE
1026 def_bool y 1050 def_bool y
@@ -1036,7 +1060,7 @@ config ARCH_SPARSEMEM_DEFAULT
1036 1060
1037config ARCH_SPARSEMEM_ENABLE 1061config ARCH_SPARSEMEM_ENABLE
1038 def_bool y 1062 def_bool y
1039 depends on X86_64 || NUMA || (EXPERIMENTAL && X86_PC) 1063 depends on X86_64 || NUMA || (EXPERIMENTAL && X86_PC) || X86_GENERICARCH
1040 select SPARSEMEM_STATIC if X86_32 1064 select SPARSEMEM_STATIC if X86_32
1041 select SPARSEMEM_VMEMMAP_ENABLE if X86_64 1065 select SPARSEMEM_VMEMMAP_ENABLE if X86_64
1042 1066
@@ -1059,6 +1083,56 @@ config HIGHPTE
1059 low memory. Setting this option will put user-space page table 1083 low memory. Setting this option will put user-space page table
1060 entries in high memory. 1084 entries in high memory.
1061 1085
1086config X86_CHECK_BIOS_CORRUPTION
1087 bool "Check for low memory corruption"
1088 help
1089 Periodically check for memory corruption in low memory, which
1090 is suspected to be caused by BIOS. Even when enabled in the
1091 configuration, it is disabled at runtime. Enable it by
1092 setting "memory_corruption_check=1" on the kernel command
1093 line. By default it scans the low 64k of memory every 60
1094 seconds; see the memory_corruption_check_size and
1095 memory_corruption_check_period parameters in
1096 Documentation/kernel-parameters.txt to adjust this.
1097
1098 When enabled with the default parameters, this option has
1099 almost no overhead, as it reserves a relatively small amount
1100 of memory and scans it infrequently. It both detects corruption
1101 and prevents it from affecting the running system.
1102
1103 It is, however, intended as a diagnostic tool; if repeatable
1104 BIOS-originated corruption always affects the same memory,
1105 you can use memmap= to prevent the kernel from using that
1106 memory.
1107
1108config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
1109 bool "Set the default setting of memory_corruption_check"
1110 depends on X86_CHECK_BIOS_CORRUPTION
1111 default y
1112 help
1113 Set whether the default state of memory_corruption_check is
1114 on or off.
1115
1116config X86_RESERVE_LOW_64K
1117 bool "Reserve low 64K of RAM on AMI/Phoenix BIOSen"
1118 default y
1119 help
1120 Reserve the first 64K of physical RAM on BIOSes that are known
1121 to potentially corrupt that memory range. A numbers of BIOSes are
1122 known to utilize this area during suspend/resume, so it must not
1123 be used by the kernel.
1124
1125 Set this to N if you are absolutely sure that you trust the BIOS
1126 to get all its memory reservations and usages right.
1127
1128 If you have doubts about the BIOS (e.g. suspend/resume does not
1129 work or there's kernel crashes after certain hardware hotplug
1130 events) and it's not AMI or Phoenix, then you might want to enable
1131 X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check typical
1132 corruption patterns.
1133
1134 Say Y if unsure.
1135
1062config MATH_EMULATION 1136config MATH_EMULATION
1063 bool 1137 bool
1064 prompt "Math emulation" if X86_32 1138 prompt "Math emulation" if X86_32
@@ -1117,10 +1191,10 @@ config MTRR
1117 You can safely say Y even if your machine doesn't have MTRRs, you'll 1191 You can safely say Y even if your machine doesn't have MTRRs, you'll
1118 just add about 9 KB to your kernel. 1192 just add about 9 KB to your kernel.
1119 1193
1120 See <file:Documentation/mtrr.txt> for more information. 1194 See <file:Documentation/x86/mtrr.txt> for more information.
1121 1195
1122config MTRR_SANITIZER 1196config MTRR_SANITIZER
1123 bool 1197 def_bool y
1124 prompt "MTRR cleanup support" 1198 prompt "MTRR cleanup support"
1125 depends on MTRR 1199 depends on MTRR
1126 help 1200 help
@@ -1131,7 +1205,7 @@ config MTRR_SANITIZER
1131 The largest mtrr entry size for a continous block can be set with 1205 The largest mtrr entry size for a continous block can be set with
1132 mtrr_chunk_size. 1206 mtrr_chunk_size.
1133 1207
1134 If unsure, say N. 1208 If unsure, say Y.
1135 1209
1136config MTRR_SANITIZER_ENABLE_DEFAULT 1210config MTRR_SANITIZER_ENABLE_DEFAULT
1137 int "MTRR cleanup enable value (0-1)" 1211 int "MTRR cleanup enable value (0-1)"
@@ -1191,7 +1265,6 @@ config IRQBALANCE
1191config SECCOMP 1265config SECCOMP
1192 def_bool y 1266 def_bool y
1193 prompt "Enable seccomp to safely compute untrusted bytecode" 1267 prompt "Enable seccomp to safely compute untrusted bytecode"
1194 depends on PROC_FS
1195 help 1268 help
1196 This kernel feature is useful for number crunching applications 1269 This kernel feature is useful for number crunching applications
1197 that may need to compute untrusted bytecode during their 1270 that may need to compute untrusted bytecode during their
@@ -1199,7 +1272,7 @@ config SECCOMP
1199 the process as file descriptors supporting the read/write 1272 the process as file descriptors supporting the read/write
1200 syscalls, it's possible to isolate those applications in 1273 syscalls, it's possible to isolate those applications in
1201 their own address space using seccomp. Once seccomp is 1274 their own address space using seccomp. Once seccomp is
1202 enabled via /proc/<pid>/seccomp, it cannot be disabled 1275 enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
1203 and the task is only allowed to execute a few safe syscalls 1276 and the task is only allowed to execute a few safe syscalls
1204 defined by each seccomp mode. 1277 defined by each seccomp mode.
1205 1278
@@ -1356,14 +1429,14 @@ config PHYSICAL_ALIGN
1356 Don't change this unless you know what you are doing. 1429 Don't change this unless you know what you are doing.
1357 1430
1358config HOTPLUG_CPU 1431config HOTPLUG_CPU
1359 bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)" 1432 bool "Support for hot-pluggable CPUs"
1360 depends on SMP && HOTPLUG && EXPERIMENTAL && !X86_VOYAGER 1433 depends on SMP && HOTPLUG && !X86_VOYAGER
1361 ---help--- 1434 ---help---
1362 Say Y here to experiment with turning CPUs off and on, and to 1435 Say Y here to allow turning CPUs off and on. CPUs can be
1363 enable suspend on SMP systems. CPUs can be controlled through 1436 controlled through /sys/devices/system/cpu.
1364 /sys/devices/system/cpu. 1437 ( Note: power management support will enable this option
1365 Say N if you want to disable CPU hotplug and don't need to 1438 automatically on SMP systems. )
1366 suspend. 1439 Say N if you want to disable CPU hotplug.
1367 1440
1368config COMPAT_VDSO 1441config COMPAT_VDSO
1369 def_bool y 1442 def_bool y
@@ -1378,6 +1451,51 @@ config COMPAT_VDSO
1378 1451
1379 If unsure, say Y. 1452 If unsure, say Y.
1380 1453
1454config CMDLINE_BOOL
1455 bool "Built-in kernel command line"
1456 default n
1457 help
1458 Allow for specifying boot arguments to the kernel at
1459 build time. On some systems (e.g. embedded ones), it is
1460 necessary or convenient to provide some or all of the
1461 kernel boot arguments with the kernel itself (that is,
1462 to not rely on the boot loader to provide them.)
1463
1464 To compile command line arguments into the kernel,
1465 set this option to 'Y', then fill in the
1466 the boot arguments in CONFIG_CMDLINE.
1467
1468 Systems with fully functional boot loaders (i.e. non-embedded)
1469 should leave this option set to 'N'.
1470
1471config CMDLINE
1472 string "Built-in kernel command string"
1473 depends on CMDLINE_BOOL
1474 default ""
1475 help
1476 Enter arguments here that should be compiled into the kernel
1477 image and used at boot time. If the boot loader provides a
1478 command line at boot time, it is appended to this string to
1479 form the full kernel command line, when the system boots.
1480
1481 However, you can use the CONFIG_CMDLINE_OVERRIDE option to
1482 change this behavior.
1483
1484 In most cases, the command line (whether built-in or provided
1485 by the boot loader) should specify the device for the root
1486 file system.
1487
1488config CMDLINE_OVERRIDE
1489 bool "Built-in command line overrides boot loader arguments"
1490 default n
1491 depends on CMDLINE_BOOL
1492 help
1493 Set this option to 'Y' to have the kernel ignore the boot loader
1494 command line, and use ONLY the built-in command line.
1495
1496 This is used to work around broken boot loaders. This should
1497 be set to 'N' under normal conditions.
1498
1381endmenu 1499endmenu
1382 1500
1383config ARCH_ENABLE_MEMORY_HOTPLUG 1501config ARCH_ENABLE_MEMORY_HOTPLUG
@@ -1643,6 +1761,14 @@ config DMAR_FLOPPY_WA
1643 workaround will setup a 1:1 mapping for the first 1761 workaround will setup a 1:1 mapping for the first
1644 16M to make floppy (an ISA device) work. 1762 16M to make floppy (an ISA device) work.
1645 1763
1764config INTR_REMAP
1765 bool "Support for Interrupt Remapping (EXPERIMENTAL)"
1766 depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI && EXPERIMENTAL
1767 help
1768 Supports Interrupt remapping for IO-APIC and MSI devices.
1769 To use x2apic mode in the CPU's which support x2APIC enhancements or
1770 to support platforms with CPU's having > 8 bit APIC ID, say Y.
1771
1646source "drivers/pci/pcie/Kconfig" 1772source "drivers/pci/pcie/Kconfig"
1647 1773
1648source "drivers/pci/Kconfig" 1774source "drivers/pci/Kconfig"
@@ -1773,7 +1899,7 @@ config COMPAT_FOR_U64_ALIGNMENT
1773 1899
1774config SYSVIPC_COMPAT 1900config SYSVIPC_COMPAT
1775 def_bool y 1901 def_bool y
1776 depends on X86_64 && COMPAT && SYSVIPC 1902 depends on COMPAT && SYSVIPC
1777 1903
1778endmenu 1904endmenu
1779 1905
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index b225219c448c..c5f101360520 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -418,3 +418,123 @@ config X86_MINIMUM_CPU_FAMILY
418config X86_DEBUGCTLMSR 418config X86_DEBUGCTLMSR
419 def_bool y 419 def_bool y
420 depends on !(MK6 || MWINCHIPC6 || MWINCHIP2 || MWINCHIP3D || MCYRIXIII || M586MMX || M586TSC || M586 || M486 || M386) 420 depends on !(MK6 || MWINCHIPC6 || MWINCHIP2 || MWINCHIP3D || MCYRIXIII || M586MMX || M586TSC || M586 || M486 || M386)
421
422menuconfig PROCESSOR_SELECT
423 bool "Supported processor vendors" if EMBEDDED
424 help
425 This lets you choose what x86 vendor support code your kernel
426 will include.
427
428config CPU_SUP_INTEL
429 default y
430 bool "Support Intel processors" if PROCESSOR_SELECT
431 help
432 This enables detection, tunings and quirks for Intel processors
433
434 You need this enabled if you want your kernel to run on an
435 Intel CPU. Disabling this option on other types of CPUs
436 makes the kernel a tiny bit smaller. Disabling it on an Intel
437 CPU might render the kernel unbootable.
438
439 If unsure, say N.
440
441config CPU_SUP_CYRIX_32
442 default y
443 bool "Support Cyrix processors" if PROCESSOR_SELECT
444 depends on !64BIT
445 help
446 This enables detection, tunings and quirks for Cyrix processors
447
448 You need this enabled if you want your kernel to run on a
449 Cyrix CPU. Disabling this option on other types of CPUs
450 makes the kernel a tiny bit smaller. Disabling it on a Cyrix
451 CPU might render the kernel unbootable.
452
453 If unsure, say N.
454
455config CPU_SUP_AMD
456 default y
457 bool "Support AMD processors" if PROCESSOR_SELECT
458 help
459 This enables detection, tunings and quirks for AMD processors
460
461 You need this enabled if you want your kernel to run on an
462 AMD CPU. Disabling this option on other types of CPUs
463 makes the kernel a tiny bit smaller. Disabling it on an AMD
464 CPU might render the kernel unbootable.
465
466 If unsure, say N.
467
468config CPU_SUP_CENTAUR_32
469 default y
470 bool "Support Centaur processors" if PROCESSOR_SELECT
471 depends on !64BIT
472 help
473 This enables detection, tunings and quirks for Centaur processors
474
475 You need this enabled if you want your kernel to run on a
476 Centaur CPU. Disabling this option on other types of CPUs
477 makes the kernel a tiny bit smaller. Disabling it on a Centaur
478 CPU might render the kernel unbootable.
479
480 If unsure, say N.
481
482config CPU_SUP_CENTAUR_64
483 default y
484 bool "Support Centaur processors" if PROCESSOR_SELECT
485 depends on 64BIT
486 help
487 This enables detection, tunings and quirks for Centaur processors
488
489 You need this enabled if you want your kernel to run on a
490 Centaur CPU. Disabling this option on other types of CPUs
491 makes the kernel a tiny bit smaller. Disabling it on a Centaur
492 CPU might render the kernel unbootable.
493
494 If unsure, say N.
495
496config CPU_SUP_TRANSMETA_32
497 default y
498 bool "Support Transmeta processors" if PROCESSOR_SELECT
499 depends on !64BIT
500 help
501 This enables detection, tunings and quirks for Transmeta processors
502
503 You need this enabled if you want your kernel to run on a
504 Transmeta CPU. Disabling this option on other types of CPUs
505 makes the kernel a tiny bit smaller. Disabling it on a Transmeta
506 CPU might render the kernel unbootable.
507
508 If unsure, say N.
509
510config CPU_SUP_UMC_32
511 default y
512 bool "Support UMC processors" if PROCESSOR_SELECT
513 depends on !64BIT
514 help
515 This enables detection, tunings and quirks for UMC processors
516
517 You need this enabled if you want your kernel to run on a
518 UMC CPU. Disabling this option on other types of CPUs
519 makes the kernel a tiny bit smaller. Disabling it on a UMC
520 CPU might render the kernel unbootable.
521
522 If unsure, say N.
523
524config X86_DS
525 bool "Debug Store support"
526 default y
527 help
528 Add support for Debug Store.
529 This allows the kernel to provide a memory buffer to the hardware
530 to store various profiling and tracing events.
531
532config X86_PTRACE_BTS
533 bool "ptrace interface to Branch Trace Store"
534 default y
535 depends on (X86_DS && X86_DEBUGCTLMSR)
536 help
537 Add a ptrace interface to allow collecting an execution trace
538 of the traced task.
539 This collects control flow changes in a (cyclic) buffer and allows
540 debuggers to fill in the gaps and show an execution trace of the debuggee.
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 092f019e033a..2a3dfbd5e677 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -43,6 +43,19 @@ config EARLY_PRINTK
43 with klogd/syslogd or the X server. You should normally N here, 43 with klogd/syslogd or the X server. You should normally N here,
44 unless you want to debug such a crash. 44 unless you want to debug such a crash.
45 45
46config EARLY_PRINTK_DBGP
47 bool "Early printk via EHCI debug port"
48 default n
49 depends on EARLY_PRINTK && PCI
50 help
51 Write kernel log output directly into the EHCI debug port.
52
53 This is useful for kernel debugging when your machine crashes very
54 early before the console code is initialized. For normal operation
55 it is not recommended because it looks ugly and doesn't cooperate
56 with klogd/syslogd or the X server. You should normally N here,
57 unless you want to debug such a crash. You need usb debug device.
58
46config DEBUG_STACKOVERFLOW 59config DEBUG_STACKOVERFLOW
47 bool "Check for stack overflows" 60 bool "Check for stack overflows"
48 depends on DEBUG_KERNEL 61 depends on DEBUG_KERNEL
diff --git a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu
index e372b584e919..b72b4f753113 100644
--- a/arch/x86/Makefile_32.cpu
+++ b/arch/x86/Makefile_32.cpu
@@ -45,3 +45,8 @@ cflags-$(CONFIG_MGEODEGX1) += -march=pentium-mmx
45# cpu entries 45# cpu entries
46cflags-$(CONFIG_X86_GENERIC) += $(call tune,generic,$(call tune,i686)) 46cflags-$(CONFIG_X86_GENERIC) += $(call tune,generic,$(call tune,i686))
47 47
48# Bug fix for binutils: this option is required in order to keep
49# binutils from generating NOPL instructions against our will.
50ifneq ($(CONFIG_X86_P6_NOP),y)
51cflags-y += $(call cc-option,-Wa$(comma)-mtune=generic32,)
52endif
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 7ee102f9c4f8..cd48c7210016 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -72,9 +72,7 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
72KBUILD_CFLAGS += $(call cc-option,-m32) 72KBUILD_CFLAGS += $(call cc-option,-m32)
73KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ 73KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
74 74
75$(obj)/zImage: IMAGE_OFFSET := 0x1000
76$(obj)/zImage: asflags-y := $(SVGA_MODE) $(RAMDISK) 75$(obj)/zImage: asflags-y := $(SVGA_MODE) $(RAMDISK)
77$(obj)/bzImage: IMAGE_OFFSET := 0x100000
78$(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__ 76$(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__
79$(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__ 77$(obj)/bzImage: asflags-y := $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
80$(obj)/bzImage: BUILDFLAGS := -b 78$(obj)/bzImage: BUILDFLAGS := -b
@@ -117,7 +115,7 @@ $(obj)/setup.bin: $(obj)/setup.elf FORCE
117 $(call if_changed,objcopy) 115 $(call if_changed,objcopy)
118 116
119$(obj)/compressed/vmlinux: FORCE 117$(obj)/compressed/vmlinux: FORCE
120 $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@ 118 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
121 119
122# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel 120# Set this if you want to pass append arguments to the zdisk/fdimage/isoimage kernel
123FDARGS = 121FDARGS =
@@ -181,6 +179,7 @@ isoimage: $(BOOTIMAGE)
181 mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \ 179 mkisofs -J -r -o $(obj)/image.iso -b isolinux.bin -c boot.cat \
182 -no-emul-boot -boot-load-size 4 -boot-info-table \ 180 -no-emul-boot -boot-load-size 4 -boot-info-table \
183 $(obj)/isoimage 181 $(obj)/isoimage
182 isohybrid $(obj)/image.iso 2>/dev/null || true
184 rm -rf $(obj)/isoimage 183 rm -rf $(obj)/isoimage
185 184
186zlilo: $(BOOTIMAGE) 185zlilo: $(BOOTIMAGE)
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 92fdd35bd93e..1771c804e02f 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -27,9 +27,8 @@ $(obj)/vmlinux.bin: vmlinux FORCE
27 $(call if_changed,objcopy) 27 $(call if_changed,objcopy)
28 28
29 29
30ifeq ($(CONFIG_X86_32),y) 30targets += vmlinux.bin.all vmlinux.relocs relocs
31targets += vmlinux.bin.all vmlinux.relocs 31hostprogs-$(CONFIG_X86_32) += relocs
32hostprogs-y := relocs
33 32
34quiet_cmd_relocs = RELOCS $@ 33quiet_cmd_relocs = RELOCS $@
35 cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $< 34 cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
@@ -43,6 +42,8 @@ quiet_cmd_relocbin = BUILD $@
43$(obj)/vmlinux.bin.all: $(vmlinux.bin.all-y) FORCE 42$(obj)/vmlinux.bin.all: $(vmlinux.bin.all-y) FORCE
44 $(call if_changed,relocbin) 43 $(call if_changed,relocbin)
45 44
45ifeq ($(CONFIG_X86_32),y)
46
46ifdef CONFIG_RELOCATABLE 47ifdef CONFIG_RELOCATABLE
47$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE 48$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
48 $(call if_changed,gzip) 49 $(call if_changed,gzip)
@@ -59,6 +60,5 @@ $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
59LDFLAGS_piggy.o := -r --format binary --oformat elf64-x86-64 -T 60LDFLAGS_piggy.o := -r --format binary --oformat elf64-x86-64 -T
60endif 61endif
61 62
62
63$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE 63$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
64 $(call if_changed,ld) 64 $(call if_changed,ld)
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index ba7736cf2ec7..29c5fbf08392 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -137,14 +137,15 @@ relocated:
137 */ 137 */
138 movl output_len(%ebx), %eax 138 movl output_len(%ebx), %eax
139 pushl %eax 139 pushl %eax
140 # push arguments for decompress_kernel:
140 pushl %ebp # output address 141 pushl %ebp # output address
141 movl input_len(%ebx), %eax 142 movl input_len(%ebx), %eax
142 pushl %eax # input_len 143 pushl %eax # input_len
143 leal input_data(%ebx), %eax 144 leal input_data(%ebx), %eax
144 pushl %eax # input_data 145 pushl %eax # input_data
145 leal boot_heap(%ebx), %eax 146 leal boot_heap(%ebx), %eax
146 pushl %eax # heap area as third argument 147 pushl %eax # heap area
147 pushl %esi # real mode pointer as second arg 148 pushl %esi # real mode pointer
148 call decompress_kernel 149 call decompress_kernel
149 addl $20, %esp 150 addl $20, %esp
150 popl %ecx 151 popl %ecx
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 9fea73706479..5780d361105b 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -16,7 +16,7 @@
16 */ 16 */
17#undef CONFIG_PARAVIRT 17#undef CONFIG_PARAVIRT
18#ifdef CONFIG_X86_32 18#ifdef CONFIG_X86_32
19#define _ASM_DESC_H_ 1 19#define ASM_X86__DESC_H 1
20#endif 20#endif
21 21
22#ifdef CONFIG_X86_64 22#ifdef CONFIG_X86_64
@@ -27,7 +27,7 @@
27#include <linux/linkage.h> 27#include <linux/linkage.h>
28#include <linux/screen_info.h> 28#include <linux/screen_info.h>
29#include <linux/elf.h> 29#include <linux/elf.h>
30#include <asm/io.h> 30#include <linux/io.h>
31#include <asm/page.h> 31#include <asm/page.h>
32#include <asm/boot.h> 32#include <asm/boot.h>
33#include <asm/bootparam.h> 33#include <asm/bootparam.h>
@@ -251,7 +251,7 @@ static void __putstr(int error, const char *s)
251 y--; 251 y--;
252 } 252 }
253 } else { 253 } else {
254 vidmem [(x + cols * y) * 2] = c; 254 vidmem[(x + cols * y) * 2] = c;
255 if (++x >= cols) { 255 if (++x >= cols) {
256 x = 0; 256 x = 0;
257 if (++y >= lines) { 257 if (++y >= lines) {
@@ -277,7 +277,8 @@ static void *memset(void *s, int c, unsigned n)
277 int i; 277 int i;
278 char *ss = s; 278 char *ss = s;
279 279
280 for (i = 0; i < n; i++) ss[i] = c; 280 for (i = 0; i < n; i++)
281 ss[i] = c;
281 return s; 282 return s;
282} 283}
283 284
@@ -287,7 +288,8 @@ static void *memcpy(void *dest, const void *src, unsigned n)
287 const char *s = src; 288 const char *s = src;
288 char *d = dest; 289 char *d = dest;
289 290
290 for (i = 0; i < n; i++) d[i] = s[i]; 291 for (i = 0; i < n; i++)
292 d[i] = s[i];
291 return dest; 293 return dest;
292} 294}
293 295
diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c
index a1310c52fc0c..857e492c571e 100644
--- a/arch/x86/boot/compressed/relocs.c
+++ b/arch/x86/boot/compressed/relocs.c
@@ -492,7 +492,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
492 continue; 492 continue;
493 } 493 }
494 sh_symtab = sec_symtab->symtab; 494 sh_symtab = sec_symtab->symtab;
495 sym_strtab = sec->link->strtab; 495 sym_strtab = sec_symtab->link->strtab;
496 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) { 496 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
497 Elf32_Rel *rel; 497 Elf32_Rel *rel;
498 Elf32_Sym *sym; 498 Elf32_Sym *sym;
diff --git a/arch/x86/boot/cpu.c b/arch/x86/boot/cpu.c
index 75298fe2edca..6ec6bb6e9957 100644
--- a/arch/x86/boot/cpu.c
+++ b/arch/x86/boot/cpu.c
@@ -59,17 +59,18 @@ int validate_cpu(void)
59 u32 e = err_flags[i]; 59 u32 e = err_flags[i];
60 60
61 for (j = 0; j < 32; j++) { 61 for (j = 0; j < 32; j++) {
62 int n = (i << 5)+j; 62 if (msg_strs[0] < i ||
63 if (*msg_strs < n) { 63 (msg_strs[0] == i && msg_strs[1] < j)) {
64 /* Skip to the next string */ 64 /* Skip to the next string */
65 do { 65 msg_strs += 2;
66 msg_strs++; 66 while (*msg_strs++)
67 } while (*msg_strs); 67 ;
68 msg_strs++;
69 } 68 }
70 if (e & 1) { 69 if (e & 1) {
71 if (*msg_strs == n && msg_strs[1]) 70 if (msg_strs[0] == i &&
72 printf("%s ", msg_strs+1); 71 msg_strs[1] == j &&
72 msg_strs[2])
73 printf("%s ", msg_strs+2);
73 else 74 else
74 printf("%d:%d ", i, j); 75 printf("%d:%d ", i, j);
75 } 76 }
diff --git a/arch/x86/boot/edd.c b/arch/x86/boot/edd.c
index d93cbc6464d0..1aae8f3e5ca1 100644
--- a/arch/x86/boot/edd.c
+++ b/arch/x86/boot/edd.c
@@ -41,6 +41,7 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig)
41 char *mbrbuf_ptr, *mbrbuf_end; 41 char *mbrbuf_ptr, *mbrbuf_end;
42 u32 buf_base, mbr_base; 42 u32 buf_base, mbr_base;
43 extern char _end[]; 43 extern char _end[];
44 u16 mbr_magic;
44 45
45 sector_size = ei->params.bytes_per_sector; 46 sector_size = ei->params.bytes_per_sector;
46 if (!sector_size) 47 if (!sector_size)
@@ -58,11 +59,15 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig)
58 if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr) 59 if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr)
59 return -1; 60 return -1;
60 61
62 memset(mbrbuf_ptr, 0, sector_size);
61 if (read_mbr(devno, mbrbuf_ptr)) 63 if (read_mbr(devno, mbrbuf_ptr))
62 return -1; 64 return -1;
63 65
64 *mbrsig = *(u32 *)&mbrbuf_ptr[EDD_MBR_SIG_OFFSET]; 66 *mbrsig = *(u32 *)&mbrbuf_ptr[EDD_MBR_SIG_OFFSET];
65 return 0; 67 mbr_magic = *(u16 *)&mbrbuf_ptr[510];
68
69 /* check for valid MBR magic */
70 return mbr_magic == 0xAA55 ? 0 : -1;
66} 71}
67 72
68static int get_edd_info(u8 devno, struct edd_info *ei) 73static int get_edd_info(u8 devno, struct edd_info *ei)
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index af86e431acfa..b993062e9a5f 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -30,7 +30,6 @@ SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
30SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */ 30SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
31 /* to be loaded */ 31 /* to be loaded */
32ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */ 32ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
33SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
34 33
35#ifndef SVGA_MODE 34#ifndef SVGA_MODE
36#define SVGA_MODE ASK_VGA 35#define SVGA_MODE ASK_VGA
diff --git a/arch/x86/boot/mkcpustr.c b/arch/x86/boot/mkcpustr.c
index bbe76953bae9..8ef60f20b371 100644
--- a/arch/x86/boot/mkcpustr.c
+++ b/arch/x86/boot/mkcpustr.c
@@ -15,33 +15,33 @@
15 15
16#include <stdio.h> 16#include <stdio.h>
17 17
18#include "../kernel/cpu/feature_names.c" 18#include "../kernel/cpu/capflags.c"
19
20#if NCAPFLAGS > 8
21# error "Need to adjust the boot code handling of CPUID strings"
22#endif
23 19
24int main(void) 20int main(void)
25{ 21{
26 int i; 22 int i, j;
27 const char *str; 23 const char *str;
28 24
29 printf("static const char x86_cap_strs[] = \n"); 25 printf("static const char x86_cap_strs[] = \n");
30 26
31 for (i = 0; i < NCAPINTS*32; i++) { 27 for (i = 0; i < NCAPINTS; i++) {
32 str = x86_cap_flags[i]; 28 for (j = 0; j < 32; j++) {
33 29 str = x86_cap_flags[i*32+j];
34 if (i == NCAPINTS*32-1) { 30
35 /* The last entry must be unconditional; this 31 if (i == NCAPINTS-1 && j == 31) {
36 also consumes the compiler-added null character */ 32 /* The last entry must be unconditional; this
37 if (!str) 33 also consumes the compiler-added null
38 str = ""; 34 character */
39 printf("\t\"\\x%02x\"\"%s\"\n", i, str); 35 if (!str)
40 } else if (str) { 36 str = "";
41 printf("#if REQUIRED_MASK%d & (1 << %d)\n" 37 printf("\t\"\\x%02x\\x%02x\"\"%s\"\n",
42 "\t\"\\x%02x\"\"%s\\0\"\n" 38 i, j, str);
43 "#endif\n", 39 } else if (str) {
44 i >> 5, i & 31, i, str); 40 printf("#if REQUIRED_MASK%d & (1 << %d)\n"
41 "\t\"\\x%02x\\x%02x\"\"%s\\0\"\n"
42 "#endif\n",
43 i, j, i, j, str);
44 }
45 } 45 }
46 } 46 }
47 printf("\t;\n"); 47 printf("\t;\n");
diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
index 401ad998ad08..1e6fe0214c85 100644
--- a/arch/x86/boot/video-vesa.c
+++ b/arch/x86/boot/video-vesa.c
@@ -224,7 +224,7 @@ static void vesa_store_pm_info(void)
224static void vesa_store_mode_params_graphics(void) 224static void vesa_store_mode_params_graphics(void)
225{ 225{
226 /* Tell the kernel we're in VESA graphics mode */ 226 /* Tell the kernel we're in VESA graphics mode */
227 boot_params.screen_info.orig_video_isVGA = 0x23; 227 boot_params.screen_info.orig_video_isVGA = VIDEO_TYPE_VLFB;
228 228
229 /* Mode parameters */ 229 /* Mode parameters */
230 boot_params.screen_info.vesa_attributes = vminfo.mode_attr; 230 boot_params.screen_info.vesa_attributes = vminfo.mode_attr;
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
index 104275e191a8..ca226ca31288 100644
--- a/arch/x86/configs/i386_defconfig
+++ b/arch/x86/configs/i386_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc4 3# Linux kernel version: 2.6.27-rc5
4# Mon Aug 25 15:04:00 2008 4# Wed Sep 3 17:23:09 2008
5# 5#
6# CONFIG_64BIT is not set 6# CONFIG_64BIT is not set
7CONFIG_X86_32=y 7CONFIG_X86_32=y
@@ -202,7 +202,7 @@ CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
202# CONFIG_M586 is not set 202# CONFIG_M586 is not set
203# CONFIG_M586TSC is not set 203# CONFIG_M586TSC is not set
204# CONFIG_M586MMX is not set 204# CONFIG_M586MMX is not set
205# CONFIG_M686 is not set 205CONFIG_M686=y
206# CONFIG_MPENTIUMII is not set 206# CONFIG_MPENTIUMII is not set
207# CONFIG_MPENTIUMIII is not set 207# CONFIG_MPENTIUMIII is not set
208# CONFIG_MPENTIUMM is not set 208# CONFIG_MPENTIUMM is not set
@@ -221,13 +221,14 @@ CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
221# CONFIG_MVIAC3_2 is not set 221# CONFIG_MVIAC3_2 is not set
222# CONFIG_MVIAC7 is not set 222# CONFIG_MVIAC7 is not set
223# CONFIG_MPSC is not set 223# CONFIG_MPSC is not set
224CONFIG_MCORE2=y 224# CONFIG_MCORE2 is not set
225# CONFIG_GENERIC_CPU is not set 225# CONFIG_GENERIC_CPU is not set
226CONFIG_X86_GENERIC=y 226CONFIG_X86_GENERIC=y
227CONFIG_X86_CPU=y 227CONFIG_X86_CPU=y
228CONFIG_X86_CMPXCHG=y 228CONFIG_X86_CMPXCHG=y
229CONFIG_X86_L1_CACHE_SHIFT=7 229CONFIG_X86_L1_CACHE_SHIFT=7
230CONFIG_X86_XADD=y 230CONFIG_X86_XADD=y
231# CONFIG_X86_PPRO_FENCE is not set
231CONFIG_X86_WP_WORKS_OK=y 232CONFIG_X86_WP_WORKS_OK=y
232CONFIG_X86_INVLPG=y 233CONFIG_X86_INVLPG=y
233CONFIG_X86_BSWAP=y 234CONFIG_X86_BSWAP=y
@@ -235,14 +236,15 @@ CONFIG_X86_POPAD_OK=y
235CONFIG_X86_INTEL_USERCOPY=y 236CONFIG_X86_INTEL_USERCOPY=y
236CONFIG_X86_USE_PPRO_CHECKSUM=y 237CONFIG_X86_USE_PPRO_CHECKSUM=y
237CONFIG_X86_TSC=y 238CONFIG_X86_TSC=y
239CONFIG_X86_CMOV=y
238CONFIG_X86_MINIMUM_CPU_FAMILY=4 240CONFIG_X86_MINIMUM_CPU_FAMILY=4
239CONFIG_X86_DEBUGCTLMSR=y 241CONFIG_X86_DEBUGCTLMSR=y
240CONFIG_HPET_TIMER=y 242CONFIG_HPET_TIMER=y
241CONFIG_HPET_EMULATE_RTC=y 243CONFIG_HPET_EMULATE_RTC=y
242CONFIG_DMI=y 244CONFIG_DMI=y
243# CONFIG_IOMMU_HELPER is not set 245# CONFIG_IOMMU_HELPER is not set
244CONFIG_NR_CPUS=4 246CONFIG_NR_CPUS=64
245# CONFIG_SCHED_SMT is not set 247CONFIG_SCHED_SMT=y
246CONFIG_SCHED_MC=y 248CONFIG_SCHED_MC=y
247# CONFIG_PREEMPT_NONE is not set 249# CONFIG_PREEMPT_NONE is not set
248CONFIG_PREEMPT_VOLUNTARY=y 250CONFIG_PREEMPT_VOLUNTARY=y
@@ -254,7 +256,8 @@ CONFIG_VM86=y
254# CONFIG_TOSHIBA is not set 256# CONFIG_TOSHIBA is not set
255# CONFIG_I8K is not set 257# CONFIG_I8K is not set
256CONFIG_X86_REBOOTFIXUPS=y 258CONFIG_X86_REBOOTFIXUPS=y
257# CONFIG_MICROCODE is not set 259CONFIG_MICROCODE=y
260CONFIG_MICROCODE_OLD_INTERFACE=y
258CONFIG_X86_MSR=y 261CONFIG_X86_MSR=y
259CONFIG_X86_CPUID=y 262CONFIG_X86_CPUID=y
260# CONFIG_NOHIGHMEM is not set 263# CONFIG_NOHIGHMEM is not set
@@ -1532,7 +1535,6 @@ CONFIG_BACKLIGHT_CLASS_DEVICE=y
1532CONFIG_VGA_CONSOLE=y 1535CONFIG_VGA_CONSOLE=y
1533CONFIG_VGACON_SOFT_SCROLLBACK=y 1536CONFIG_VGACON_SOFT_SCROLLBACK=y
1534CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64 1537CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
1535CONFIG_VIDEO_SELECT=y
1536CONFIG_DUMMY_CONSOLE=y 1538CONFIG_DUMMY_CONSOLE=y
1537# CONFIG_FRAMEBUFFER_CONSOLE is not set 1539# CONFIG_FRAMEBUFFER_CONSOLE is not set
1538CONFIG_LOGO=y 1540CONFIG_LOGO=y
@@ -2115,7 +2117,7 @@ CONFIG_IO_DELAY_0X80=y
2115CONFIG_DEFAULT_IO_DELAY_TYPE=0 2117CONFIG_DEFAULT_IO_DELAY_TYPE=0
2116CONFIG_DEBUG_BOOT_PARAMS=y 2118CONFIG_DEBUG_BOOT_PARAMS=y
2117# CONFIG_CPA_DEBUG is not set 2119# CONFIG_CPA_DEBUG is not set
2118# CONFIG_OPTIMIZE_INLINING is not set 2120CONFIG_OPTIMIZE_INLINING=y
2119 2121
2120# 2122#
2121# Security options 2123# Security options
diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig
index 678c8acefe04..2c4b1c771e28 100644
--- a/arch/x86/configs/x86_64_defconfig
+++ b/arch/x86/configs/x86_64_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.27-rc4 3# Linux kernel version: 2.6.27-rc5
4# Mon Aug 25 14:40:46 2008 4# Wed Sep 3 17:13:39 2008
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7# CONFIG_X86_32 is not set 7# CONFIG_X86_32 is not set
@@ -218,17 +218,14 @@ CONFIG_X86_PC=y
218# CONFIG_MVIAC3_2 is not set 218# CONFIG_MVIAC3_2 is not set
219# CONFIG_MVIAC7 is not set 219# CONFIG_MVIAC7 is not set
220# CONFIG_MPSC is not set 220# CONFIG_MPSC is not set
221CONFIG_MCORE2=y 221# CONFIG_MCORE2 is not set
222# CONFIG_GENERIC_CPU is not set 222CONFIG_GENERIC_CPU=y
223CONFIG_X86_CPU=y 223CONFIG_X86_CPU=y
224CONFIG_X86_L1_CACHE_BYTES=64 224CONFIG_X86_L1_CACHE_BYTES=128
225CONFIG_X86_INTERNODE_CACHE_BYTES=64 225CONFIG_X86_INTERNODE_CACHE_BYTES=128
226CONFIG_X86_CMPXCHG=y 226CONFIG_X86_CMPXCHG=y
227CONFIG_X86_L1_CACHE_SHIFT=6 227CONFIG_X86_L1_CACHE_SHIFT=7
228CONFIG_X86_WP_WORKS_OK=y 228CONFIG_X86_WP_WORKS_OK=y
229CONFIG_X86_INTEL_USERCOPY=y
230CONFIG_X86_USE_PPRO_CHECKSUM=y
231CONFIG_X86_P6_NOP=y
232CONFIG_X86_TSC=y 229CONFIG_X86_TSC=y
233CONFIG_X86_CMPXCHG64=y 230CONFIG_X86_CMPXCHG64=y
234CONFIG_X86_CMOV=y 231CONFIG_X86_CMOV=y
@@ -243,9 +240,8 @@ CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT=y
243CONFIG_AMD_IOMMU=y 240CONFIG_AMD_IOMMU=y
244CONFIG_SWIOTLB=y 241CONFIG_SWIOTLB=y
245CONFIG_IOMMU_HELPER=y 242CONFIG_IOMMU_HELPER=y
246# CONFIG_MAXSMP is not set 243CONFIG_NR_CPUS=64
247CONFIG_NR_CPUS=4 244CONFIG_SCHED_SMT=y
248# CONFIG_SCHED_SMT is not set
249CONFIG_SCHED_MC=y 245CONFIG_SCHED_MC=y
250# CONFIG_PREEMPT_NONE is not set 246# CONFIG_PREEMPT_NONE is not set
251CONFIG_PREEMPT_VOLUNTARY=y 247CONFIG_PREEMPT_VOLUNTARY=y
@@ -254,7 +250,8 @@ CONFIG_X86_LOCAL_APIC=y
254CONFIG_X86_IO_APIC=y 250CONFIG_X86_IO_APIC=y
255# CONFIG_X86_MCE is not set 251# CONFIG_X86_MCE is not set
256# CONFIG_I8K is not set 252# CONFIG_I8K is not set
257# CONFIG_MICROCODE is not set 253CONFIG_MICROCODE=y
254CONFIG_MICROCODE_OLD_INTERFACE=y
258CONFIG_X86_MSR=y 255CONFIG_X86_MSR=y
259CONFIG_X86_CPUID=y 256CONFIG_X86_CPUID=y
260CONFIG_NUMA=y 257CONFIG_NUMA=y
@@ -290,7 +287,7 @@ CONFIG_BOUNCE=y
290CONFIG_VIRT_TO_BUS=y 287CONFIG_VIRT_TO_BUS=y
291CONFIG_MTRR=y 288CONFIG_MTRR=y
292# CONFIG_MTRR_SANITIZER is not set 289# CONFIG_MTRR_SANITIZER is not set
293# CONFIG_X86_PAT is not set 290CONFIG_X86_PAT=y
294CONFIG_EFI=y 291CONFIG_EFI=y
295CONFIG_SECCOMP=y 292CONFIG_SECCOMP=y
296# CONFIG_HZ_100 is not set 293# CONFIG_HZ_100 is not set
@@ -1508,7 +1505,6 @@ CONFIG_BACKLIGHT_CLASS_DEVICE=y
1508CONFIG_VGA_CONSOLE=y 1505CONFIG_VGA_CONSOLE=y
1509CONFIG_VGACON_SOFT_SCROLLBACK=y 1506CONFIG_VGACON_SOFT_SCROLLBACK=y
1510CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64 1507CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
1511CONFIG_VIDEO_SELECT=y
1512CONFIG_DUMMY_CONSOLE=y 1508CONFIG_DUMMY_CONSOLE=y
1513# CONFIG_FRAMEBUFFER_CONSOLE is not set 1509# CONFIG_FRAMEBUFFER_CONSOLE is not set
1514CONFIG_LOGO=y 1510CONFIG_LOGO=y
@@ -2089,7 +2085,7 @@ CONFIG_IO_DELAY_0X80=y
2089CONFIG_DEFAULT_IO_DELAY_TYPE=0 2085CONFIG_DEFAULT_IO_DELAY_TYPE=0
2090CONFIG_DEBUG_BOOT_PARAMS=y 2086CONFIG_DEBUG_BOOT_PARAMS=y
2091# CONFIG_CPA_DEBUG is not set 2087# CONFIG_CPA_DEBUG is not set
2092# CONFIG_OPTIMIZE_INLINING is not set 2088CONFIG_OPTIMIZE_INLINING=y
2093 2089
2094# 2090#
2095# Security options 2091# Security options
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
index 3874c2de5403..903de4aa5094 100644
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -10,6 +10,8 @@ obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o
10obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o 10obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o
11obj-$(CONFIG_CRYPTO_SALSA20_X86_64) += salsa20-x86_64.o 11obj-$(CONFIG_CRYPTO_SALSA20_X86_64) += salsa20-x86_64.o
12 12
13obj-$(CONFIG_CRYPTO_CRC32C_INTEL) += crc32c-intel.o
14
13aes-i586-y := aes-i586-asm_32.o aes_glue.o 15aes-i586-y := aes-i586-asm_32.o aes_glue.o
14twofish-i586-y := twofish-i586-asm_32.o twofish_glue.o 16twofish-i586-y := twofish-i586-asm_32.o twofish_glue.o
15salsa20-i586-y := salsa20-i586-asm_32.o salsa20_glue.o 17salsa20-i586-y := salsa20-i586-asm_32.o salsa20_glue.o
diff --git a/arch/x86/crypto/crc32c-intel.c b/arch/x86/crypto/crc32c-intel.c
new file mode 100644
index 000000000000..070afc5b6c94
--- /dev/null
+++ b/arch/x86/crypto/crc32c-intel.c
@@ -0,0 +1,197 @@
1/*
2 * Using hardware provided CRC32 instruction to accelerate the CRC32 disposal.
3 * CRC32C polynomial:0x1EDC6F41(BE)/0x82F63B78(LE)
4 * CRC32 is a new instruction in Intel SSE4.2, the reference can be found at:
5 * http://www.intel.com/products/processor/manuals/
6 * Intel(R) 64 and IA-32 Architectures Software Developer's Manual
7 * Volume 2A: Instruction Set Reference, A-M
8 *
9 * Copyright (c) 2008 Austin Zhang <austin_zhang@linux.intel.com>
10 * Copyright (c) 2008 Kent Liu <kent.liu@intel.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option)
15 * any later version.
16 *
17 */
18#include <linux/init.h>
19#include <linux/module.h>
20#include <linux/string.h>
21#include <linux/kernel.h>
22#include <crypto/internal/hash.h>
23
24#include <asm/cpufeature.h>
25
26#define CHKSUM_BLOCK_SIZE 1
27#define CHKSUM_DIGEST_SIZE 4
28
29#define SCALE_F sizeof(unsigned long)
30
31#ifdef CONFIG_X86_64
32#define REX_PRE "0x48, "
33#else
34#define REX_PRE
35#endif
36
37static u32 crc32c_intel_le_hw_byte(u32 crc, unsigned char const *data, size_t length)
38{
39 while (length--) {
40 __asm__ __volatile__(
41 ".byte 0xf2, 0xf, 0x38, 0xf0, 0xf1"
42 :"=S"(crc)
43 :"0"(crc), "c"(*data)
44 );
45 data++;
46 }
47
48 return crc;
49}
50
51static u32 __pure crc32c_intel_le_hw(u32 crc, unsigned char const *p, size_t len)
52{
53 unsigned int iquotient = len / SCALE_F;
54 unsigned int iremainder = len % SCALE_F;
55 unsigned long *ptmp = (unsigned long *)p;
56
57 while (iquotient--) {
58 __asm__ __volatile__(
59 ".byte 0xf2, " REX_PRE "0xf, 0x38, 0xf1, 0xf1;"
60 :"=S"(crc)
61 :"0"(crc), "c"(*ptmp)
62 );
63 ptmp++;
64 }
65
66 if (iremainder)
67 crc = crc32c_intel_le_hw_byte(crc, (unsigned char *)ptmp,
68 iremainder);
69
70 return crc;
71}
72
73/*
74 * Setting the seed allows arbitrary accumulators and flexible XOR policy
75 * If your algorithm starts with ~0, then XOR with ~0 before you set
76 * the seed.
77 */
78static int crc32c_intel_setkey(struct crypto_ahash *hash, const u8 *key,
79 unsigned int keylen)
80{
81 u32 *mctx = crypto_ahash_ctx(hash);
82
83 if (keylen != sizeof(u32)) {
84 crypto_ahash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
85 return -EINVAL;
86 }
87 *mctx = le32_to_cpup((__le32 *)key);
88 return 0;
89}
90
91static int crc32c_intel_init(struct ahash_request *req)
92{
93 u32 *mctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
94 u32 *crcp = ahash_request_ctx(req);
95
96 *crcp = *mctx;
97
98 return 0;
99}
100
101static int crc32c_intel_update(struct ahash_request *req)
102{
103 struct crypto_hash_walk walk;
104 u32 *crcp = ahash_request_ctx(req);
105 u32 crc = *crcp;
106 int nbytes;
107
108 for (nbytes = crypto_hash_walk_first(req, &walk); nbytes;
109 nbytes = crypto_hash_walk_done(&walk, 0))
110 crc = crc32c_intel_le_hw(crc, walk.data, nbytes);
111
112 *crcp = crc;
113 return 0;
114}
115
116static int crc32c_intel_final(struct ahash_request *req)
117{
118 u32 *crcp = ahash_request_ctx(req);
119
120 *(__le32 *)req->result = ~cpu_to_le32p(crcp);
121 return 0;
122}
123
124static int crc32c_intel_digest(struct ahash_request *req)
125{
126 struct crypto_hash_walk walk;
127 u32 *mctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
128 u32 crc = *mctx;
129 int nbytes;
130
131 for (nbytes = crypto_hash_walk_first(req, &walk); nbytes;
132 nbytes = crypto_hash_walk_done(&walk, 0))
133 crc = crc32c_intel_le_hw(crc, walk.data, nbytes);
134
135 *(__le32 *)req->result = ~cpu_to_le32(crc);
136 return 0;
137}
138
139static int crc32c_intel_cra_init(struct crypto_tfm *tfm)
140{
141 u32 *key = crypto_tfm_ctx(tfm);
142
143 *key = ~0;
144
145 tfm->crt_ahash.reqsize = sizeof(u32);
146
147 return 0;
148}
149
150static struct crypto_alg alg = {
151 .cra_name = "crc32c",
152 .cra_driver_name = "crc32c-intel",
153 .cra_priority = 200,
154 .cra_flags = CRYPTO_ALG_TYPE_AHASH,
155 .cra_blocksize = CHKSUM_BLOCK_SIZE,
156 .cra_alignmask = 3,
157 .cra_ctxsize = sizeof(u32),
158 .cra_module = THIS_MODULE,
159 .cra_list = LIST_HEAD_INIT(alg.cra_list),
160 .cra_init = crc32c_intel_cra_init,
161 .cra_type = &crypto_ahash_type,
162 .cra_u = {
163 .ahash = {
164 .digestsize = CHKSUM_DIGEST_SIZE,
165 .setkey = crc32c_intel_setkey,
166 .init = crc32c_intel_init,
167 .update = crc32c_intel_update,
168 .final = crc32c_intel_final,
169 .digest = crc32c_intel_digest,
170 }
171 }
172};
173
174
175static int __init crc32c_intel_mod_init(void)
176{
177 if (cpu_has_xmm4_2)
178 return crypto_register_alg(&alg);
179 else
180 return -ENODEV;
181}
182
183static void __exit crc32c_intel_mod_fini(void)
184{
185 crypto_unregister_alg(&alg);
186}
187
188module_init(crc32c_intel_mod_init);
189module_exit(crc32c_intel_mod_fini);
190
191MODULE_AUTHOR("Austin Zhang <austin.zhang@intel.com>, Kent Liu <kent.liu@intel.com>");
192MODULE_DESCRIPTION("CRC32c (Castagnoli) optimization using Intel Hardware.");
193MODULE_LICENSE("GPL");
194
195MODULE_ALIAS("crc32c");
196MODULE_ALIAS("crc32c-intel");
197
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
index a0e1dbe67dc1..127ec3f07214 100644
--- a/arch/x86/ia32/ia32_aout.c
+++ b/arch/x86/ia32/ia32_aout.c
@@ -85,8 +85,10 @@ static void dump_thread32(struct pt_regs *regs, struct user32 *dump)
85 dump->regs.ax = regs->ax; 85 dump->regs.ax = regs->ax;
86 dump->regs.ds = current->thread.ds; 86 dump->regs.ds = current->thread.ds;
87 dump->regs.es = current->thread.es; 87 dump->regs.es = current->thread.es;
88 asm("movl %%fs,%0" : "=r" (fs)); dump->regs.fs = fs; 88 savesegment(fs, fs);
89 asm("movl %%gs,%0" : "=r" (gs)); dump->regs.gs = gs; 89 dump->regs.fs = fs;
90 savesegment(gs, gs);
91 dump->regs.gs = gs;
90 dump->regs.orig_ax = regs->orig_ax; 92 dump->regs.orig_ax = regs->orig_ax;
91 dump->regs.ip = regs->ip; 93 dump->regs.ip = regs->ip;
92 dump->regs.cs = regs->cs; 94 dump->regs.cs = regs->cs;
@@ -430,8 +432,9 @@ beyond_if:
430 current->mm->start_stack = 432 current->mm->start_stack =
431 (unsigned long)create_aout_tables((char __user *)bprm->p, bprm); 433 (unsigned long)create_aout_tables((char __user *)bprm->p, bprm);
432 /* start thread */ 434 /* start thread */
433 asm volatile("movl %0,%%fs" :: "r" (0)); \ 435 loadsegment(fs, 0);
434 asm volatile("movl %0,%%es; movl %0,%%ds": :"r" (__USER32_DS)); 436 loadsegment(ds, __USER32_DS);
437 loadsegment(es, __USER32_DS);
435 load_gs_index(0); 438 load_gs_index(0);
436 (regs)->ip = ex.a_entry; 439 (regs)->ip = ex.a_entry;
437 (regs)->sp = current->mm->start_stack; 440 (regs)->sp = current->mm->start_stack;
diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 20af4c79579a..4bc02b23674b 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -179,9 +179,10 @@ struct sigframe
179 u32 pretcode; 179 u32 pretcode;
180 int sig; 180 int sig;
181 struct sigcontext_ia32 sc; 181 struct sigcontext_ia32 sc;
182 struct _fpstate_ia32 fpstate; 182 struct _fpstate_ia32 fpstate_unused; /* look at kernel/sigframe.h */
183 unsigned int extramask[_COMPAT_NSIG_WORDS-1]; 183 unsigned int extramask[_COMPAT_NSIG_WORDS-1];
184 char retcode[8]; 184 char retcode[8];
185 /* fp state follows here */
185}; 186};
186 187
187struct rt_sigframe 188struct rt_sigframe
@@ -192,8 +193,8 @@ struct rt_sigframe
192 u32 puc; 193 u32 puc;
193 compat_siginfo_t info; 194 compat_siginfo_t info;
194 struct ucontext_ia32 uc; 195 struct ucontext_ia32 uc;
195 struct _fpstate_ia32 fpstate;
196 char retcode[8]; 196 char retcode[8];
197 /* fp state follows here */
197}; 198};
198 199
199#define COPY(x) { \ 200#define COPY(x) { \
@@ -206,7 +207,7 @@ struct rt_sigframe
206 { unsigned int cur; \ 207 { unsigned int cur; \
207 unsigned short pre; \ 208 unsigned short pre; \
208 err |= __get_user(pre, &sc->seg); \ 209 err |= __get_user(pre, &sc->seg); \
209 asm volatile("movl %%" #seg ",%0" : "=r" (cur)); \ 210 savesegment(seg, cur); \
210 pre |= mask; \ 211 pre |= mask; \
211 if (pre != cur) loadsegment(seg, pre); } 212 if (pre != cur) loadsegment(seg, pre); }
212 213
@@ -215,7 +216,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
215 unsigned int *peax) 216 unsigned int *peax)
216{ 217{
217 unsigned int tmpflags, gs, oldgs, err = 0; 218 unsigned int tmpflags, gs, oldgs, err = 0;
218 struct _fpstate_ia32 __user *buf; 219 void __user *buf;
219 u32 tmp; 220 u32 tmp;
220 221
221 /* Always make any pending restarted system calls return -EINTR */ 222 /* Always make any pending restarted system calls return -EINTR */
@@ -235,7 +236,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
235 */ 236 */
236 err |= __get_user(gs, &sc->gs); 237 err |= __get_user(gs, &sc->gs);
237 gs |= 3; 238 gs |= 3;
238 asm("movl %%gs,%0" : "=r" (oldgs)); 239 savesegment(gs, oldgs);
239 if (gs != oldgs) 240 if (gs != oldgs)
240 load_gs_index(gs); 241 load_gs_index(gs);
241 242
@@ -259,26 +260,12 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
259 260
260 err |= __get_user(tmp, &sc->fpstate); 261 err |= __get_user(tmp, &sc->fpstate);
261 buf = compat_ptr(tmp); 262 buf = compat_ptr(tmp);
262 if (buf) { 263 err |= restore_i387_xstate_ia32(buf);
263 if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
264 goto badframe;
265 err |= restore_i387_ia32(buf);
266 } else {
267 struct task_struct *me = current;
268
269 if (used_math()) {
270 clear_fpu(me);
271 clear_used_math();
272 }
273 }
274 264
275 err |= __get_user(tmp, &sc->ax); 265 err |= __get_user(tmp, &sc->ax);
276 *peax = tmp; 266 *peax = tmp;
277 267
278 return err; 268 return err;
279
280badframe:
281 return 1;
282} 269}
283 270
284asmlinkage long sys32_sigreturn(struct pt_regs *regs) 271asmlinkage long sys32_sigreturn(struct pt_regs *regs)
@@ -350,46 +337,42 @@ badframe:
350 */ 337 */
351 338
352static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc, 339static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
353 struct _fpstate_ia32 __user *fpstate, 340 void __user *fpstate,
354 struct pt_regs *regs, unsigned int mask) 341 struct pt_regs *regs, unsigned int mask)
355{ 342{
356 int tmp, err = 0; 343 int tmp, err = 0;
357 344
358 tmp = 0; 345 savesegment(gs, tmp);
359 __asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp));
360 err |= __put_user(tmp, (unsigned int __user *)&sc->gs); 346 err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
361 __asm__("movl %%fs,%0" : "=r"(tmp): "0"(tmp)); 347 savesegment(fs, tmp);
362 err |= __put_user(tmp, (unsigned int __user *)&sc->fs); 348 err |= __put_user(tmp, (unsigned int __user *)&sc->fs);
363 __asm__("movl %%ds,%0" : "=r"(tmp): "0"(tmp)); 349 savesegment(ds, tmp);
364 err |= __put_user(tmp, (unsigned int __user *)&sc->ds); 350 err |= __put_user(tmp, (unsigned int __user *)&sc->ds);
365 __asm__("movl %%es,%0" : "=r"(tmp): "0"(tmp)); 351 savesegment(es, tmp);
366 err |= __put_user(tmp, (unsigned int __user *)&sc->es); 352 err |= __put_user(tmp, (unsigned int __user *)&sc->es);
367 353
368 err |= __put_user((u32)regs->di, &sc->di); 354 err |= __put_user(regs->di, &sc->di);
369 err |= __put_user((u32)regs->si, &sc->si); 355 err |= __put_user(regs->si, &sc->si);
370 err |= __put_user((u32)regs->bp, &sc->bp); 356 err |= __put_user(regs->bp, &sc->bp);
371 err |= __put_user((u32)regs->sp, &sc->sp); 357 err |= __put_user(regs->sp, &sc->sp);
372 err |= __put_user((u32)regs->bx, &sc->bx); 358 err |= __put_user(regs->bx, &sc->bx);
373 err |= __put_user((u32)regs->dx, &sc->dx); 359 err |= __put_user(regs->dx, &sc->dx);
374 err |= __put_user((u32)regs->cx, &sc->cx); 360 err |= __put_user(regs->cx, &sc->cx);
375 err |= __put_user((u32)regs->ax, &sc->ax); 361 err |= __put_user(regs->ax, &sc->ax);
376 err |= __put_user((u32)regs->cs, &sc->cs); 362 err |= __put_user(regs->cs, &sc->cs);
377 err |= __put_user((u32)regs->ss, &sc->ss); 363 err |= __put_user(regs->ss, &sc->ss);
378 err |= __put_user(current->thread.trap_no, &sc->trapno); 364 err |= __put_user(current->thread.trap_no, &sc->trapno);
379 err |= __put_user(current->thread.error_code, &sc->err); 365 err |= __put_user(current->thread.error_code, &sc->err);
380 err |= __put_user((u32)regs->ip, &sc->ip); 366 err |= __put_user(regs->ip, &sc->ip);
381 err |= __put_user((u32)regs->flags, &sc->flags); 367 err |= __put_user(regs->flags, &sc->flags);
382 err |= __put_user((u32)regs->sp, &sc->sp_at_signal); 368 err |= __put_user(regs->sp, &sc->sp_at_signal);
383 369
384 tmp = save_i387_ia32(fpstate); 370 tmp = save_i387_xstate_ia32(fpstate);
385 if (tmp < 0) 371 if (tmp < 0)
386 err = -EFAULT; 372 err = -EFAULT;
387 else { 373 else
388 clear_used_math();
389 stts();
390 err |= __put_user(ptr_to_compat(tmp ? fpstate : NULL), 374 err |= __put_user(ptr_to_compat(tmp ? fpstate : NULL),
391 &sc->fpstate); 375 &sc->fpstate);
392 }
393 376
394 /* non-iBCS2 extensions.. */ 377 /* non-iBCS2 extensions.. */
395 err |= __put_user(mask, &sc->oldmask); 378 err |= __put_user(mask, &sc->oldmask);
@@ -402,7 +385,8 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
402 * Determine which stack to use.. 385 * Determine which stack to use..
403 */ 386 */
404static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, 387static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
405 size_t frame_size) 388 size_t frame_size,
389 void **fpstate)
406{ 390{
407 unsigned long sp; 391 unsigned long sp;
408 392
@@ -421,6 +405,11 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
421 ka->sa.sa_restorer) 405 ka->sa.sa_restorer)
422 sp = (unsigned long) ka->sa.sa_restorer; 406 sp = (unsigned long) ka->sa.sa_restorer;
423 407
408 if (used_math()) {
409 sp = sp - sig_xstate_ia32_size;
410 *fpstate = (struct _fpstate_ia32 *) sp;
411 }
412
424 sp -= frame_size; 413 sp -= frame_size;
425 /* Align the stack pointer according to the i386 ABI, 414 /* Align the stack pointer according to the i386 ABI,
426 * i.e. so that on function entry ((sp + 4) & 15) == 0. */ 415 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
@@ -434,6 +423,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
434 struct sigframe __user *frame; 423 struct sigframe __user *frame;
435 void __user *restorer; 424 void __user *restorer;
436 int err = 0; 425 int err = 0;
426 void __user *fpstate = NULL;
437 427
438 /* copy_to_user optimizes that into a single 8 byte store */ 428 /* copy_to_user optimizes that into a single 8 byte store */
439 static const struct { 429 static const struct {
@@ -448,25 +438,21 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
448 0, 438 0,
449 }; 439 };
450 440
451 frame = get_sigframe(ka, regs, sizeof(*frame)); 441 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
452 442
453 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 443 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
454 goto give_sigsegv; 444 return -EFAULT;
455 445
456 err |= __put_user(sig, &frame->sig); 446 if (__put_user(sig, &frame->sig))
457 if (err) 447 return -EFAULT;
458 goto give_sigsegv;
459 448
460 err |= ia32_setup_sigcontext(&frame->sc, &frame->fpstate, regs, 449 if (ia32_setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]))
461 set->sig[0]); 450 return -EFAULT;
462 if (err)
463 goto give_sigsegv;
464 451
465 if (_COMPAT_NSIG_WORDS > 1) { 452 if (_COMPAT_NSIG_WORDS > 1) {
466 err |= __copy_to_user(frame->extramask, &set->sig[1], 453 if (__copy_to_user(frame->extramask, &set->sig[1],
467 sizeof(frame->extramask)); 454 sizeof(frame->extramask)))
468 if (err) 455 return -EFAULT;
469 goto give_sigsegv;
470 } 456 }
471 457
472 if (ka->sa.sa_flags & SA_RESTORER) { 458 if (ka->sa.sa_flags & SA_RESTORER) {
@@ -487,7 +473,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
487 */ 473 */
488 err |= __copy_to_user(frame->retcode, &code, 8); 474 err |= __copy_to_user(frame->retcode, &code, 8);
489 if (err) 475 if (err)
490 goto give_sigsegv; 476 return -EFAULT;
491 477
492 /* Set up registers for signal handler */ 478 /* Set up registers for signal handler */
493 regs->sp = (unsigned long) frame; 479 regs->sp = (unsigned long) frame;
@@ -498,8 +484,8 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
498 regs->dx = 0; 484 regs->dx = 0;
499 regs->cx = 0; 485 regs->cx = 0;
500 486
501 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 487 loadsegment(ds, __USER32_DS);
502 asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 488 loadsegment(es, __USER32_DS);
503 489
504 regs->cs = __USER32_CS; 490 regs->cs = __USER32_CS;
505 regs->ss = __USER32_DS; 491 regs->ss = __USER32_DS;
@@ -510,10 +496,6 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
510#endif 496#endif
511 497
512 return 0; 498 return 0;
513
514give_sigsegv:
515 force_sigsegv(sig, current);
516 return -EFAULT;
517} 499}
518 500
519int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 501int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
@@ -522,6 +504,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
522 struct rt_sigframe __user *frame; 504 struct rt_sigframe __user *frame;
523 void __user *restorer; 505 void __user *restorer;
524 int err = 0; 506 int err = 0;
507 void __user *fpstate = NULL;
525 508
526 /* __copy_to_user optimizes that into a single 8 byte store */ 509 /* __copy_to_user optimizes that into a single 8 byte store */
527 static const struct { 510 static const struct {
@@ -537,30 +520,33 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
537 0, 520 0,
538 }; 521 };
539 522
540 frame = get_sigframe(ka, regs, sizeof(*frame)); 523 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
541 524
542 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 525 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
543 goto give_sigsegv; 526 return -EFAULT;
544 527
545 err |= __put_user(sig, &frame->sig); 528 err |= __put_user(sig, &frame->sig);
546 err |= __put_user(ptr_to_compat(&frame->info), &frame->pinfo); 529 err |= __put_user(ptr_to_compat(&frame->info), &frame->pinfo);
547 err |= __put_user(ptr_to_compat(&frame->uc), &frame->puc); 530 err |= __put_user(ptr_to_compat(&frame->uc), &frame->puc);
548 err |= copy_siginfo_to_user32(&frame->info, info); 531 err |= copy_siginfo_to_user32(&frame->info, info);
549 if (err) 532 if (err)
550 goto give_sigsegv; 533 return -EFAULT;
551 534
552 /* Create the ucontext. */ 535 /* Create the ucontext. */
553 err |= __put_user(0, &frame->uc.uc_flags); 536 if (cpu_has_xsave)
537 err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags);
538 else
539 err |= __put_user(0, &frame->uc.uc_flags);
554 err |= __put_user(0, &frame->uc.uc_link); 540 err |= __put_user(0, &frame->uc.uc_link);
555 err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 541 err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
556 err |= __put_user(sas_ss_flags(regs->sp), 542 err |= __put_user(sas_ss_flags(regs->sp),
557 &frame->uc.uc_stack.ss_flags); 543 &frame->uc.uc_stack.ss_flags);
558 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); 544 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
559 err |= ia32_setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate, 545 err |= ia32_setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
560 regs, set->sig[0]); 546 regs, set->sig[0]);
561 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); 547 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
562 if (err) 548 if (err)
563 goto give_sigsegv; 549 return -EFAULT;
564 550
565 if (ka->sa.sa_flags & SA_RESTORER) 551 if (ka->sa.sa_flags & SA_RESTORER)
566 restorer = ka->sa.sa_restorer; 552 restorer = ka->sa.sa_restorer;
@@ -575,7 +561,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
575 */ 561 */
576 err |= __copy_to_user(frame->retcode, &code, 8); 562 err |= __copy_to_user(frame->retcode, &code, 8);
577 if (err) 563 if (err)
578 goto give_sigsegv; 564 return -EFAULT;
579 565
580 /* Set up registers for signal handler */ 566 /* Set up registers for signal handler */
581 regs->sp = (unsigned long) frame; 567 regs->sp = (unsigned long) frame;
@@ -591,8 +577,8 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
591 regs->dx = (unsigned long) &frame->info; 577 regs->dx = (unsigned long) &frame->info;
592 regs->cx = (unsigned long) &frame->uc; 578 regs->cx = (unsigned long) &frame->uc;
593 579
594 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 580 loadsegment(ds, __USER32_DS);
595 asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 581 loadsegment(es, __USER32_DS);
596 582
597 regs->cs = __USER32_CS; 583 regs->cs = __USER32_CS;
598 regs->ss = __USER32_DS; 584 regs->ss = __USER32_DS;
@@ -603,8 +589,4 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
603#endif 589#endif
604 590
605 return 0; 591 return 0;
606
607give_sigsegv:
608 force_sigsegv(sig, current);
609 return -EFAULT;
610} 592}
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index d3c64088b981..beda4232ce69 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -556,15 +556,6 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
556 return ret; 556 return ret;
557} 557}
558 558
559/* These are here just in case some old ia32 binary calls it. */
560asmlinkage long sys32_pause(void)
561{
562 current->state = TASK_INTERRUPTIBLE;
563 schedule();
564 return -ERESTARTNOHAND;
565}
566
567
568#ifdef CONFIG_SYSCTL_SYSCALL 559#ifdef CONFIG_SYSCTL_SYSCALL
569struct sysctl_ia32 { 560struct sysctl_ia32 {
570 unsigned int name; 561 unsigned int name;
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 3db651fc8ec5..5098585f87ce 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -10,7 +10,7 @@ ifdef CONFIG_FTRACE
10# Do not profile debug and lowlevel utilities 10# Do not profile debug and lowlevel utilities
11CFLAGS_REMOVE_tsc.o = -pg 11CFLAGS_REMOVE_tsc.o = -pg
12CFLAGS_REMOVE_rtc.o = -pg 12CFLAGS_REMOVE_rtc.o = -pg
13CFLAGS_REMOVE_paravirt.o = -pg 13CFLAGS_REMOVE_paravirt-spinlocks.o = -pg
14endif 14endif
15 15
16# 16#
@@ -38,7 +38,7 @@ obj-y += tsc.o io_delay.o rtc.o
38 38
39obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o 39obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o
40obj-y += process.o 40obj-y += process.o
41obj-y += i387.o 41obj-y += i387.o xsave.o
42obj-y += ptrace.o 42obj-y += ptrace.o
43obj-y += ds.o 43obj-y += ds.o
44obj-$(CONFIG_X86_32) += tls.o 44obj-$(CONFIG_X86_32) += tls.o
@@ -51,7 +51,6 @@ obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o
51obj-$(CONFIG_MCA) += mca_32.o 51obj-$(CONFIG_MCA) += mca_32.o
52obj-$(CONFIG_X86_MSR) += msr.o 52obj-$(CONFIG_X86_MSR) += msr.o
53obj-$(CONFIG_X86_CPUID) += cpuid.o 53obj-$(CONFIG_X86_CPUID) += cpuid.o
54obj-$(CONFIG_MICROCODE) += microcode.o
55obj-$(CONFIG_PCI) += early-quirks.o 54obj-$(CONFIG_PCI) += early-quirks.o
56apm-y := apm_32.o 55apm-y := apm_32.o
57obj-$(CONFIG_APM) += apm.o 56obj-$(CONFIG_APM) += apm.o
@@ -69,6 +68,7 @@ obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o
69obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o 68obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
70obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o 69obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
71obj-$(CONFIG_X86_NUMAQ) += numaq_32.o 70obj-$(CONFIG_X86_NUMAQ) += numaq_32.o
71obj-$(CONFIG_X86_ES7000) += es7000_32.o
72obj-$(CONFIG_X86_SUMMIT_NUMA) += summit_32.o 72obj-$(CONFIG_X86_SUMMIT_NUMA) += summit_32.o
73obj-y += vsmp_64.o 73obj-y += vsmp_64.o
74obj-$(CONFIG_KPROBES) += kprobes.o 74obj-$(CONFIG_KPROBES) += kprobes.o
@@ -89,7 +89,7 @@ obj-$(CONFIG_DEBUG_NX_TEST) += test_nx.o
89obj-$(CONFIG_VMI) += vmi_32.o vmiclock_32.o 89obj-$(CONFIG_VMI) += vmi_32.o vmiclock_32.o
90obj-$(CONFIG_KVM_GUEST) += kvm.o 90obj-$(CONFIG_KVM_GUEST) += kvm.o
91obj-$(CONFIG_KVM_CLOCK) += kvmclock.o 91obj-$(CONFIG_KVM_CLOCK) += kvmclock.o
92obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o 92obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o paravirt-spinlocks.o
93obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o 93obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o
94 94
95obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o 95obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o
@@ -99,11 +99,18 @@ scx200-y += scx200_32.o
99 99
100obj-$(CONFIG_OLPC) += olpc.o 100obj-$(CONFIG_OLPC) += olpc.o
101 101
102microcode-y := microcode_core.o
103microcode-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o
104microcode-$(CONFIG_MICROCODE_AMD) += microcode_amd.o
105obj-$(CONFIG_MICROCODE) += microcode.o
106
102### 107###
103# 64 bit specific files 108# 64 bit specific files
104ifeq ($(CONFIG_X86_64),y) 109ifeq ($(CONFIG_X86_64),y)
105 obj-y += genapic_64.o genapic_flat_64.o genx2apic_uv_x.o tlb_uv.o 110 obj-y += genapic_64.o genapic_flat_64.o genx2apic_uv_x.o tlb_uv.o
106 obj-y += bios_uv.o 111 obj-y += bios_uv.o
112 obj-y += genx2apic_cluster.o
113 obj-y += genx2apic_phys.o
107 obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o 114 obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o
108 obj-$(CONFIG_AUDIT) += audit_64.o 115 obj-$(CONFIG_AUDIT) += audit_64.o
109 116
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index bfd10fd211cd..eb875cdc7367 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -58,7 +58,6 @@ EXPORT_SYMBOL(acpi_disabled);
58#ifdef CONFIG_X86_64 58#ifdef CONFIG_X86_64
59 59
60#include <asm/proto.h> 60#include <asm/proto.h>
61#include <asm/genapic.h>
62 61
63#else /* X86 */ 62#else /* X86 */
64 63
@@ -97,8 +96,6 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
97#warning ACPI uses CMPXCHG, i486 and later hardware 96#warning ACPI uses CMPXCHG, i486 and later hardware
98#endif 97#endif
99 98
100static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
101
102/* -------------------------------------------------------------------------- 99/* --------------------------------------------------------------------------
103 Boot-time Configuration 100 Boot-time Configuration
104 -------------------------------------------------------------------------- */ 101 -------------------------------------------------------------------------- */
@@ -160,6 +157,8 @@ char *__init __acpi_map_table(unsigned long phys, unsigned long size)
160struct acpi_mcfg_allocation *pci_mmcfg_config; 157struct acpi_mcfg_allocation *pci_mmcfg_config;
161int pci_mmcfg_config_num; 158int pci_mmcfg_config_num;
162 159
160static int acpi_mcfg_64bit_base_addr __initdata = FALSE;
161
163static int __init acpi_mcfg_oem_check(struct acpi_table_mcfg *mcfg) 162static int __init acpi_mcfg_oem_check(struct acpi_table_mcfg *mcfg)
164{ 163{
165 if (!strcmp(mcfg->header.oem_id, "SGI")) 164 if (!strcmp(mcfg->header.oem_id, "SGI"))
@@ -253,10 +252,8 @@ static void __cpuinit acpi_register_lapic(int id, u8 enabled)
253 return; 252 return;
254 } 253 }
255 254
256#ifdef CONFIG_X86_32
257 if (boot_cpu_physical_apicid != -1U) 255 if (boot_cpu_physical_apicid != -1U)
258 ver = apic_version[boot_cpu_physical_apicid]; 256 ver = apic_version[boot_cpu_physical_apicid];
259#endif
260 257
261 generic_processor_info(id, ver); 258 generic_processor_info(id, ver);
262} 259}
@@ -775,11 +772,9 @@ static void __init acpi_register_lapic_address(unsigned long address)
775 772
776 set_fixmap_nocache(FIX_APIC_BASE, address); 773 set_fixmap_nocache(FIX_APIC_BASE, address);
777 if (boot_cpu_physical_apicid == -1U) { 774 if (boot_cpu_physical_apicid == -1U) {
778 boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); 775 boot_cpu_physical_apicid = read_apic_id();
779#ifdef CONFIG_X86_32
780 apic_version[boot_cpu_physical_apicid] = 776 apic_version[boot_cpu_physical_apicid] =
781 GET_APIC_VERSION(apic_read(APIC_LVR)); 777 GET_APIC_VERSION(apic_read(APIC_LVR));
782#endif
783 } 778 }
784} 779}
785 780
@@ -1351,7 +1346,9 @@ static void __init acpi_process_madt(void)
1351 acpi_ioapic = 1; 1346 acpi_ioapic = 1;
1352 1347
1353 smp_found_config = 1; 1348 smp_found_config = 1;
1349#ifdef CONFIG_X86_32
1354 setup_apic_routing(); 1350 setup_apic_routing();
1351#endif
1355 } 1352 }
1356 } 1353 }
1357 if (error == -EINVAL) { 1354 if (error == -EINVAL) {
@@ -1421,8 +1418,16 @@ static int __init force_acpi_ht(const struct dmi_system_id *d)
1421 */ 1418 */
1422static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d) 1419static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
1423{ 1420{
1424 pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n", d->ident); 1421 /*
1425 acpi_skip_timer_override = 1; 1422 * The ati_ixp4x0_rev() early PCI quirk should have set
1423 * the acpi_skip_timer_override flag already:
1424 */
1425 if (!acpi_skip_timer_override) {
1426 WARN(1, KERN_ERR "ati_ixp4x0 quirk not complete.\n");
1427 pr_notice("%s detected: Ignoring BIOS IRQ0 pin2 override\n",
1428 d->ident);
1429 acpi_skip_timer_override = 1;
1430 }
1426 return 0; 1431 return 0;
1427} 1432}
1428 1433
@@ -1605,6 +1610,14 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
1605 */ 1610 */
1606 { 1611 {
1607 .callback = dmi_ignore_irq0_timer_override, 1612 .callback = dmi_ignore_irq0_timer_override,
1613 .ident = "HP nx6115 laptop",
1614 .matches = {
1615 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1616 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6115"),
1617 },
1618 },
1619 {
1620 .callback = dmi_ignore_irq0_timer_override,
1608 .ident = "HP NX6125 laptop", 1621 .ident = "HP NX6125 laptop",
1609 .matches = { 1622 .matches = {
1610 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 1623 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
@@ -1619,6 +1632,14 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
1619 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"), 1632 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nx6325"),
1620 }, 1633 },
1621 }, 1634 },
1635 {
1636 .callback = dmi_ignore_irq0_timer_override,
1637 .ident = "HP 6715b laptop",
1638 .matches = {
1639 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
1640 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 6715b"),
1641 },
1642 },
1622 {} 1643 {}
1623}; 1644};
1624 1645
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 65a0c1b48696..fb04e49776ba 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -231,25 +231,25 @@ static void alternatives_smp_lock(u8 **start, u8 **end, u8 *text, u8 *text_end)
231 continue; 231 continue;
232 if (*ptr > text_end) 232 if (*ptr > text_end)
233 continue; 233 continue;
234 text_poke(*ptr, ((unsigned char []){0xf0}), 1); /* add lock prefix */ 234 /* turn DS segment override prefix into lock prefix */
235 text_poke(*ptr, ((unsigned char []){0xf0}), 1);
235 }; 236 };
236} 237}
237 238
238static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end) 239static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end)
239{ 240{
240 u8 **ptr; 241 u8 **ptr;
241 char insn[1];
242 242
243 if (noreplace_smp) 243 if (noreplace_smp)
244 return; 244 return;
245 245
246 add_nops(insn, 1);
247 for (ptr = start; ptr < end; ptr++) { 246 for (ptr = start; ptr < end; ptr++) {
248 if (*ptr < text) 247 if (*ptr < text)
249 continue; 248 continue;
250 if (*ptr > text_end) 249 if (*ptr > text_end)
251 continue; 250 continue;
252 text_poke(*ptr, insn, 1); 251 /* turn lock prefix into DS segment override prefix */
252 text_poke(*ptr, ((unsigned char []){0x3E}), 1);
253 }; 253 };
254} 254}
255 255
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 042fdc27bc92..34e4d112b1ef 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -33,6 +33,10 @@
33 33
34static DEFINE_RWLOCK(amd_iommu_devtable_lock); 34static DEFINE_RWLOCK(amd_iommu_devtable_lock);
35 35
36/* A list of preallocated protection domains */
37static LIST_HEAD(iommu_pd_list);
38static DEFINE_SPINLOCK(iommu_pd_list_lock);
39
36/* 40/*
37 * general struct to manage commands send to an IOMMU 41 * general struct to manage commands send to an IOMMU
38 */ 42 */
@@ -51,6 +55,102 @@ static int iommu_has_npcache(struct amd_iommu *iommu)
51 55
52/**************************************************************************** 56/****************************************************************************
53 * 57 *
58 * Interrupt handling functions
59 *
60 ****************************************************************************/
61
62static void iommu_print_event(void *__evt)
63{
64 u32 *event = __evt;
65 int type = (event[1] >> EVENT_TYPE_SHIFT) & EVENT_TYPE_MASK;
66 int devid = (event[0] >> EVENT_DEVID_SHIFT) & EVENT_DEVID_MASK;
67 int domid = (event[1] >> EVENT_DOMID_SHIFT) & EVENT_DOMID_MASK;
68 int flags = (event[1] >> EVENT_FLAGS_SHIFT) & EVENT_FLAGS_MASK;
69 u64 address = (u64)(((u64)event[3]) << 32) | event[2];
70
71 printk(KERN_ERR "AMD IOMMU: Event logged [");
72
73 switch (type) {
74 case EVENT_TYPE_ILL_DEV:
75 printk("ILLEGAL_DEV_TABLE_ENTRY device=%02x:%02x.%x "
76 "address=0x%016llx flags=0x%04x]\n",
77 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid),
78 address, flags);
79 break;
80 case EVENT_TYPE_IO_FAULT:
81 printk("IO_PAGE_FAULT device=%02x:%02x.%x "
82 "domain=0x%04x address=0x%016llx flags=0x%04x]\n",
83 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid),
84 domid, address, flags);
85 break;
86 case EVENT_TYPE_DEV_TAB_ERR:
87 printk("DEV_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
88 "address=0x%016llx flags=0x%04x]\n",
89 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid),
90 address, flags);
91 break;
92 case EVENT_TYPE_PAGE_TAB_ERR:
93 printk("PAGE_TAB_HARDWARE_ERROR device=%02x:%02x.%x "
94 "domain=0x%04x address=0x%016llx flags=0x%04x]\n",
95 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid),
96 domid, address, flags);
97 break;
98 case EVENT_TYPE_ILL_CMD:
99 printk("ILLEGAL_COMMAND_ERROR address=0x%016llx]\n", address);
100 break;
101 case EVENT_TYPE_CMD_HARD_ERR:
102 printk("COMMAND_HARDWARE_ERROR address=0x%016llx "
103 "flags=0x%04x]\n", address, flags);
104 break;
105 case EVENT_TYPE_IOTLB_INV_TO:
106 printk("IOTLB_INV_TIMEOUT device=%02x:%02x.%x "
107 "address=0x%016llx]\n",
108 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid),
109 address);
110 break;
111 case EVENT_TYPE_INV_DEV_REQ:
112 printk("INVALID_DEVICE_REQUEST device=%02x:%02x.%x "
113 "address=0x%016llx flags=0x%04x]\n",
114 PCI_BUS(devid), PCI_SLOT(devid), PCI_FUNC(devid),
115 address, flags);
116 break;
117 default:
118 printk(KERN_ERR "UNKNOWN type=0x%02x]\n", type);
119 }
120}
121
122static void iommu_poll_events(struct amd_iommu *iommu)
123{
124 u32 head, tail;
125 unsigned long flags;
126
127 spin_lock_irqsave(&iommu->lock, flags);
128
129 head = readl(iommu->mmio_base + MMIO_EVT_HEAD_OFFSET);
130 tail = readl(iommu->mmio_base + MMIO_EVT_TAIL_OFFSET);
131
132 while (head != tail) {
133 iommu_print_event(iommu->evt_buf + head);
134 head = (head + EVENT_ENTRY_SIZE) % iommu->evt_buf_size;
135 }
136
137 writel(head, iommu->mmio_base + MMIO_EVT_HEAD_OFFSET);
138
139 spin_unlock_irqrestore(&iommu->lock, flags);
140}
141
142irqreturn_t amd_iommu_int_handler(int irq, void *data)
143{
144 struct amd_iommu *iommu;
145
146 list_for_each_entry(iommu, &amd_iommu_list, list)
147 iommu_poll_events(iommu);
148
149 return IRQ_HANDLED;
150}
151
152/****************************************************************************
153 *
54 * IOMMU command queuing functions 154 * IOMMU command queuing functions
55 * 155 *
56 ****************************************************************************/ 156 ****************************************************************************/
@@ -213,6 +313,14 @@ static int iommu_flush_pages(struct amd_iommu *iommu, u16 domid,
213 return 0; 313 return 0;
214} 314}
215 315
316/* Flush the whole IO/TLB for a given protection domain */
317static void iommu_flush_tlb(struct amd_iommu *iommu, u16 domid)
318{
319 u64 address = CMD_INV_IOMMU_ALL_PAGES_ADDRESS;
320
321 iommu_queue_inv_iommu_pages(iommu, address, domid, 0, 1);
322}
323
216/**************************************************************************** 324/****************************************************************************
217 * 325 *
218 * The functions below are used the create the page table mappings for 326 * The functions below are used the create the page table mappings for
@@ -372,11 +480,6 @@ static int init_unity_mappings_for_device(struct dma_ops_domain *dma_dom,
372 * efficient allocator. 480 * efficient allocator.
373 * 481 *
374 ****************************************************************************/ 482 ****************************************************************************/
375static unsigned long dma_mask_to_pages(unsigned long mask)
376{
377 return (mask >> PAGE_SHIFT) +
378 (PAGE_ALIGN(mask & ~PAGE_MASK) >> PAGE_SHIFT);
379}
380 483
381/* 484/*
382 * The address allocator core function. 485 * The address allocator core function.
@@ -385,25 +488,31 @@ static unsigned long dma_mask_to_pages(unsigned long mask)
385 */ 488 */
386static unsigned long dma_ops_alloc_addresses(struct device *dev, 489static unsigned long dma_ops_alloc_addresses(struct device *dev,
387 struct dma_ops_domain *dom, 490 struct dma_ops_domain *dom,
388 unsigned int pages) 491 unsigned int pages,
492 unsigned long align_mask,
493 u64 dma_mask)
389{ 494{
390 unsigned long limit = dma_mask_to_pages(*dev->dma_mask); 495 unsigned long limit;
391 unsigned long address; 496 unsigned long address;
392 unsigned long size = dom->aperture_size >> PAGE_SHIFT;
393 unsigned long boundary_size; 497 unsigned long boundary_size;
394 498
395 boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1, 499 boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
396 PAGE_SIZE) >> PAGE_SHIFT; 500 PAGE_SIZE) >> PAGE_SHIFT;
397 limit = limit < size ? limit : size; 501 limit = iommu_device_max_index(dom->aperture_size >> PAGE_SHIFT, 0,
502 dma_mask >> PAGE_SHIFT);
398 503
399 if (dom->next_bit >= limit) 504 if (dom->next_bit >= limit) {
400 dom->next_bit = 0; 505 dom->next_bit = 0;
506 dom->need_flush = true;
507 }
401 508
402 address = iommu_area_alloc(dom->bitmap, limit, dom->next_bit, pages, 509 address = iommu_area_alloc(dom->bitmap, limit, dom->next_bit, pages,
403 0 , boundary_size, 0); 510 0 , boundary_size, align_mask);
404 if (address == -1) 511 if (address == -1) {
405 address = iommu_area_alloc(dom->bitmap, limit, 0, pages, 512 address = iommu_area_alloc(dom->bitmap, limit, 0, pages,
406 0, boundary_size, 0); 513 0, boundary_size, align_mask);
514 dom->need_flush = true;
515 }
407 516
408 if (likely(address != -1)) { 517 if (likely(address != -1)) {
409 dom->next_bit = address + pages; 518 dom->next_bit = address + pages;
@@ -469,7 +578,7 @@ static void dma_ops_reserve_addresses(struct dma_ops_domain *dom,
469 if (start_page + pages > last_page) 578 if (start_page + pages > last_page)
470 pages = last_page - start_page; 579 pages = last_page - start_page;
471 580
472 set_bit_string(dom->bitmap, start_page, pages); 581 iommu_area_reserve(dom->bitmap, start_page, pages);
473} 582}
474 583
475static void dma_ops_free_pagetable(struct dma_ops_domain *dma_dom) 584static void dma_ops_free_pagetable(struct dma_ops_domain *dma_dom)
@@ -563,6 +672,9 @@ static struct dma_ops_domain *dma_ops_domain_alloc(struct amd_iommu *iommu,
563 dma_dom->bitmap[0] = 1; 672 dma_dom->bitmap[0] = 1;
564 dma_dom->next_bit = 0; 673 dma_dom->next_bit = 0;
565 674
675 dma_dom->need_flush = false;
676 dma_dom->target_dev = 0xffff;
677
566 /* Intialize the exclusion range if necessary */ 678 /* Intialize the exclusion range if necessary */
567 if (iommu->exclusion_start && 679 if (iommu->exclusion_start &&
568 iommu->exclusion_start < dma_dom->aperture_size) { 680 iommu->exclusion_start < dma_dom->aperture_size) {
@@ -633,12 +745,13 @@ static void set_device_domain(struct amd_iommu *iommu,
633 745
634 u64 pte_root = virt_to_phys(domain->pt_root); 746 u64 pte_root = virt_to_phys(domain->pt_root);
635 747
636 pte_root |= (domain->mode & 0x07) << 9; 748 pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK)
637 pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | 2; 749 << DEV_ENTRY_MODE_SHIFT;
750 pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | IOMMU_PTE_TV;
638 751
639 write_lock_irqsave(&amd_iommu_devtable_lock, flags); 752 write_lock_irqsave(&amd_iommu_devtable_lock, flags);
640 amd_iommu_dev_table[devid].data[0] = pte_root; 753 amd_iommu_dev_table[devid].data[0] = lower_32_bits(pte_root);
641 amd_iommu_dev_table[devid].data[1] = pte_root >> 32; 754 amd_iommu_dev_table[devid].data[1] = upper_32_bits(pte_root);
642 amd_iommu_dev_table[devid].data[2] = domain->id; 755 amd_iommu_dev_table[devid].data[2] = domain->id;
643 756
644 amd_iommu_pd_table[devid] = domain; 757 amd_iommu_pd_table[devid] = domain;
@@ -656,6 +769,45 @@ static void set_device_domain(struct amd_iommu *iommu,
656 *****************************************************************************/ 769 *****************************************************************************/
657 770
658/* 771/*
772 * This function checks if the driver got a valid device from the caller to
773 * avoid dereferencing invalid pointers.
774 */
775static bool check_device(struct device *dev)
776{
777 if (!dev || !dev->dma_mask)
778 return false;
779
780 return true;
781}
782
783/*
784 * In this function the list of preallocated protection domains is traversed to
785 * find the domain for a specific device
786 */
787static struct dma_ops_domain *find_protection_domain(u16 devid)
788{
789 struct dma_ops_domain *entry, *ret = NULL;
790 unsigned long flags;
791
792 if (list_empty(&iommu_pd_list))
793 return NULL;
794
795 spin_lock_irqsave(&iommu_pd_list_lock, flags);
796
797 list_for_each_entry(entry, &iommu_pd_list, list) {
798 if (entry->target_dev == devid) {
799 ret = entry;
800 list_del(&ret->list);
801 break;
802 }
803 }
804
805 spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
806
807 return ret;
808}
809
810/*
659 * In the dma_ops path we only have the struct device. This function 811 * In the dma_ops path we only have the struct device. This function
660 * finds the corresponding IOMMU, the protection domain and the 812 * finds the corresponding IOMMU, the protection domain and the
661 * requestor id for a given device. 813 * requestor id for a given device.
@@ -671,27 +823,30 @@ static int get_device_resources(struct device *dev,
671 struct pci_dev *pcidev; 823 struct pci_dev *pcidev;
672 u16 _bdf; 824 u16 _bdf;
673 825
674 BUG_ON(!dev || dev->bus != &pci_bus_type || !dev->dma_mask); 826 *iommu = NULL;
827 *domain = NULL;
828 *bdf = 0xffff;
829
830 if (dev->bus != &pci_bus_type)
831 return 0;
675 832
676 pcidev = to_pci_dev(dev); 833 pcidev = to_pci_dev(dev);
677 _bdf = calc_devid(pcidev->bus->number, pcidev->devfn); 834 _bdf = calc_devid(pcidev->bus->number, pcidev->devfn);
678 835
679 /* device not translated by any IOMMU in the system? */ 836 /* device not translated by any IOMMU in the system? */
680 if (_bdf > amd_iommu_last_bdf) { 837 if (_bdf > amd_iommu_last_bdf)
681 *iommu = NULL;
682 *domain = NULL;
683 *bdf = 0xffff;
684 return 0; 838 return 0;
685 }
686 839
687 *bdf = amd_iommu_alias_table[_bdf]; 840 *bdf = amd_iommu_alias_table[_bdf];
688 841
689 *iommu = amd_iommu_rlookup_table[*bdf]; 842 *iommu = amd_iommu_rlookup_table[*bdf];
690 if (*iommu == NULL) 843 if (*iommu == NULL)
691 return 0; 844 return 0;
692 dma_dom = (*iommu)->default_dom;
693 *domain = domain_for_device(*bdf); 845 *domain = domain_for_device(*bdf);
694 if (*domain == NULL) { 846 if (*domain == NULL) {
847 dma_dom = find_protection_domain(*bdf);
848 if (!dma_dom)
849 dma_dom = (*iommu)->default_dom;
695 *domain = &dma_dom->domain; 850 *domain = &dma_dom->domain;
696 set_device_domain(*iommu, *domain, *bdf); 851 set_device_domain(*iommu, *domain, *bdf);
697 printk(KERN_INFO "AMD IOMMU: Using protection domain %d for " 852 printk(KERN_INFO "AMD IOMMU: Using protection domain %d for "
@@ -770,17 +925,24 @@ static dma_addr_t __map_single(struct device *dev,
770 struct dma_ops_domain *dma_dom, 925 struct dma_ops_domain *dma_dom,
771 phys_addr_t paddr, 926 phys_addr_t paddr,
772 size_t size, 927 size_t size,
773 int dir) 928 int dir,
929 bool align,
930 u64 dma_mask)
774{ 931{
775 dma_addr_t offset = paddr & ~PAGE_MASK; 932 dma_addr_t offset = paddr & ~PAGE_MASK;
776 dma_addr_t address, start; 933 dma_addr_t address, start;
777 unsigned int pages; 934 unsigned int pages;
935 unsigned long align_mask = 0;
778 int i; 936 int i;
779 937
780 pages = iommu_num_pages(paddr, size); 938 pages = iommu_num_pages(paddr, size);
781 paddr &= PAGE_MASK; 939 paddr &= PAGE_MASK;
782 940
783 address = dma_ops_alloc_addresses(dev, dma_dom, pages); 941 if (align)
942 align_mask = (1UL << get_order(size)) - 1;
943
944 address = dma_ops_alloc_addresses(dev, dma_dom, pages, align_mask,
945 dma_mask);
784 if (unlikely(address == bad_dma_address)) 946 if (unlikely(address == bad_dma_address))
785 goto out; 947 goto out;
786 948
@@ -792,6 +954,12 @@ static dma_addr_t __map_single(struct device *dev,
792 } 954 }
793 address += offset; 955 address += offset;
794 956
957 if (unlikely(dma_dom->need_flush && !amd_iommu_unmap_flush)) {
958 iommu_flush_tlb(iommu, dma_dom->domain.id);
959 dma_dom->need_flush = false;
960 } else if (unlikely(iommu_has_npcache(iommu)))
961 iommu_flush_pages(iommu, dma_dom->domain.id, address, size);
962
795out: 963out:
796 return address; 964 return address;
797} 965}
@@ -822,6 +990,9 @@ static void __unmap_single(struct amd_iommu *iommu,
822 } 990 }
823 991
824 dma_ops_free_addresses(dma_dom, dma_addr, pages); 992 dma_ops_free_addresses(dma_dom, dma_addr, pages);
993
994 if (amd_iommu_unmap_flush)
995 iommu_flush_pages(iommu, dma_dom->domain.id, dma_addr, size);
825} 996}
826 997
827/* 998/*
@@ -835,6 +1006,12 @@ static dma_addr_t map_single(struct device *dev, phys_addr_t paddr,
835 struct protection_domain *domain; 1006 struct protection_domain *domain;
836 u16 devid; 1007 u16 devid;
837 dma_addr_t addr; 1008 dma_addr_t addr;
1009 u64 dma_mask;
1010
1011 if (!check_device(dev))
1012 return bad_dma_address;
1013
1014 dma_mask = *dev->dma_mask;
838 1015
839 get_device_resources(dev, &iommu, &domain, &devid); 1016 get_device_resources(dev, &iommu, &domain, &devid);
840 1017
@@ -843,14 +1020,12 @@ static dma_addr_t map_single(struct device *dev, phys_addr_t paddr,
843 return (dma_addr_t)paddr; 1020 return (dma_addr_t)paddr;
844 1021
845 spin_lock_irqsave(&domain->lock, flags); 1022 spin_lock_irqsave(&domain->lock, flags);
846 addr = __map_single(dev, iommu, domain->priv, paddr, size, dir); 1023 addr = __map_single(dev, iommu, domain->priv, paddr, size, dir, false,
1024 dma_mask);
847 if (addr == bad_dma_address) 1025 if (addr == bad_dma_address)
848 goto out; 1026 goto out;
849 1027
850 if (iommu_has_npcache(iommu)) 1028 if (unlikely(iommu->need_sync))
851 iommu_flush_pages(iommu, domain->id, addr, size);
852
853 if (iommu->need_sync)
854 iommu_completion_wait(iommu); 1029 iommu_completion_wait(iommu);
855 1030
856out: 1031out:
@@ -870,7 +1045,8 @@ static void unmap_single(struct device *dev, dma_addr_t dma_addr,
870 struct protection_domain *domain; 1045 struct protection_domain *domain;
871 u16 devid; 1046 u16 devid;
872 1047
873 if (!get_device_resources(dev, &iommu, &domain, &devid)) 1048 if (!check_device(dev) ||
1049 !get_device_resources(dev, &iommu, &domain, &devid))
874 /* device not handled by any AMD IOMMU */ 1050 /* device not handled by any AMD IOMMU */
875 return; 1051 return;
876 1052
@@ -878,9 +1054,7 @@ static void unmap_single(struct device *dev, dma_addr_t dma_addr,
878 1054
879 __unmap_single(iommu, domain->priv, dma_addr, size, dir); 1055 __unmap_single(iommu, domain->priv, dma_addr, size, dir);
880 1056
881 iommu_flush_pages(iommu, domain->id, dma_addr, size); 1057 if (unlikely(iommu->need_sync))
882
883 if (iommu->need_sync)
884 iommu_completion_wait(iommu); 1058 iommu_completion_wait(iommu);
885 1059
886 spin_unlock_irqrestore(&domain->lock, flags); 1060 spin_unlock_irqrestore(&domain->lock, flags);
@@ -919,6 +1093,12 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
919 struct scatterlist *s; 1093 struct scatterlist *s;
920 phys_addr_t paddr; 1094 phys_addr_t paddr;
921 int mapped_elems = 0; 1095 int mapped_elems = 0;
1096 u64 dma_mask;
1097
1098 if (!check_device(dev))
1099 return 0;
1100
1101 dma_mask = *dev->dma_mask;
922 1102
923 get_device_resources(dev, &iommu, &domain, &devid); 1103 get_device_resources(dev, &iommu, &domain, &devid);
924 1104
@@ -931,19 +1111,17 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
931 paddr = sg_phys(s); 1111 paddr = sg_phys(s);
932 1112
933 s->dma_address = __map_single(dev, iommu, domain->priv, 1113 s->dma_address = __map_single(dev, iommu, domain->priv,
934 paddr, s->length, dir); 1114 paddr, s->length, dir, false,
1115 dma_mask);
935 1116
936 if (s->dma_address) { 1117 if (s->dma_address) {
937 s->dma_length = s->length; 1118 s->dma_length = s->length;
938 mapped_elems++; 1119 mapped_elems++;
939 } else 1120 } else
940 goto unmap; 1121 goto unmap;
941 if (iommu_has_npcache(iommu))
942 iommu_flush_pages(iommu, domain->id, s->dma_address,
943 s->dma_length);
944 } 1122 }
945 1123
946 if (iommu->need_sync) 1124 if (unlikely(iommu->need_sync))
947 iommu_completion_wait(iommu); 1125 iommu_completion_wait(iommu);
948 1126
949out: 1127out:
@@ -977,7 +1155,8 @@ static void unmap_sg(struct device *dev, struct scatterlist *sglist,
977 u16 devid; 1155 u16 devid;
978 int i; 1156 int i;
979 1157
980 if (!get_device_resources(dev, &iommu, &domain, &devid)) 1158 if (!check_device(dev) ||
1159 !get_device_resources(dev, &iommu, &domain, &devid))
981 return; 1160 return;
982 1161
983 spin_lock_irqsave(&domain->lock, flags); 1162 spin_lock_irqsave(&domain->lock, flags);
@@ -985,12 +1164,10 @@ static void unmap_sg(struct device *dev, struct scatterlist *sglist,
985 for_each_sg(sglist, s, nelems, i) { 1164 for_each_sg(sglist, s, nelems, i) {
986 __unmap_single(iommu, domain->priv, s->dma_address, 1165 __unmap_single(iommu, domain->priv, s->dma_address,
987 s->dma_length, dir); 1166 s->dma_length, dir);
988 iommu_flush_pages(iommu, domain->id, s->dma_address,
989 s->dma_length);
990 s->dma_address = s->dma_length = 0; 1167 s->dma_address = s->dma_length = 0;
991 } 1168 }
992 1169
993 if (iommu->need_sync) 1170 if (unlikely(iommu->need_sync))
994 iommu_completion_wait(iommu); 1171 iommu_completion_wait(iommu);
995 1172
996 spin_unlock_irqrestore(&domain->lock, flags); 1173 spin_unlock_irqrestore(&domain->lock, flags);
@@ -1008,25 +1185,33 @@ static void *alloc_coherent(struct device *dev, size_t size,
1008 struct protection_domain *domain; 1185 struct protection_domain *domain;
1009 u16 devid; 1186 u16 devid;
1010 phys_addr_t paddr; 1187 phys_addr_t paddr;
1188 u64 dma_mask = dev->coherent_dma_mask;
1189
1190 if (!check_device(dev))
1191 return NULL;
1192
1193 if (!get_device_resources(dev, &iommu, &domain, &devid))
1194 flag &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
1011 1195
1196 flag |= __GFP_ZERO;
1012 virt_addr = (void *)__get_free_pages(flag, get_order(size)); 1197 virt_addr = (void *)__get_free_pages(flag, get_order(size));
1013 if (!virt_addr) 1198 if (!virt_addr)
1014 return 0; 1199 return 0;
1015 1200
1016 memset(virt_addr, 0, size);
1017 paddr = virt_to_phys(virt_addr); 1201 paddr = virt_to_phys(virt_addr);
1018 1202
1019 get_device_resources(dev, &iommu, &domain, &devid);
1020
1021 if (!iommu || !domain) { 1203 if (!iommu || !domain) {
1022 *dma_addr = (dma_addr_t)paddr; 1204 *dma_addr = (dma_addr_t)paddr;
1023 return virt_addr; 1205 return virt_addr;
1024 } 1206 }
1025 1207
1208 if (!dma_mask)
1209 dma_mask = *dev->dma_mask;
1210
1026 spin_lock_irqsave(&domain->lock, flags); 1211 spin_lock_irqsave(&domain->lock, flags);
1027 1212
1028 *dma_addr = __map_single(dev, iommu, domain->priv, paddr, 1213 *dma_addr = __map_single(dev, iommu, domain->priv, paddr,
1029 size, DMA_BIDIRECTIONAL); 1214 size, DMA_BIDIRECTIONAL, true, dma_mask);
1030 1215
1031 if (*dma_addr == bad_dma_address) { 1216 if (*dma_addr == bad_dma_address) {
1032 free_pages((unsigned long)virt_addr, get_order(size)); 1217 free_pages((unsigned long)virt_addr, get_order(size));
@@ -1034,10 +1219,7 @@ static void *alloc_coherent(struct device *dev, size_t size,
1034 goto out; 1219 goto out;
1035 } 1220 }
1036 1221
1037 if (iommu_has_npcache(iommu)) 1222 if (unlikely(iommu->need_sync))
1038 iommu_flush_pages(iommu, domain->id, *dma_addr, size);
1039
1040 if (iommu->need_sync)
1041 iommu_completion_wait(iommu); 1223 iommu_completion_wait(iommu);
1042 1224
1043out: 1225out:
@@ -1048,8 +1230,6 @@ out:
1048 1230
1049/* 1231/*
1050 * The exported free_coherent function for dma_ops. 1232 * The exported free_coherent function for dma_ops.
1051 * FIXME: fix the generic x86 DMA layer so that it actually calls that
1052 * function.
1053 */ 1233 */
1054static void free_coherent(struct device *dev, size_t size, 1234static void free_coherent(struct device *dev, size_t size,
1055 void *virt_addr, dma_addr_t dma_addr) 1235 void *virt_addr, dma_addr_t dma_addr)
@@ -1059,6 +1239,9 @@ static void free_coherent(struct device *dev, size_t size,
1059 struct protection_domain *domain; 1239 struct protection_domain *domain;
1060 u16 devid; 1240 u16 devid;
1061 1241
1242 if (!check_device(dev))
1243 return;
1244
1062 get_device_resources(dev, &iommu, &domain, &devid); 1245 get_device_resources(dev, &iommu, &domain, &devid);
1063 1246
1064 if (!iommu || !domain) 1247 if (!iommu || !domain)
@@ -1067,9 +1250,8 @@ static void free_coherent(struct device *dev, size_t size,
1067 spin_lock_irqsave(&domain->lock, flags); 1250 spin_lock_irqsave(&domain->lock, flags);
1068 1251
1069 __unmap_single(iommu, domain->priv, dma_addr, size, DMA_BIDIRECTIONAL); 1252 __unmap_single(iommu, domain->priv, dma_addr, size, DMA_BIDIRECTIONAL);
1070 iommu_flush_pages(iommu, domain->id, dma_addr, size);
1071 1253
1072 if (iommu->need_sync) 1254 if (unlikely(iommu->need_sync))
1073 iommu_completion_wait(iommu); 1255 iommu_completion_wait(iommu);
1074 1256
1075 spin_unlock_irqrestore(&domain->lock, flags); 1257 spin_unlock_irqrestore(&domain->lock, flags);
@@ -1079,6 +1261,30 @@ free_mem:
1079} 1261}
1080 1262
1081/* 1263/*
1264 * This function is called by the DMA layer to find out if we can handle a
1265 * particular device. It is part of the dma_ops.
1266 */
1267static int amd_iommu_dma_supported(struct device *dev, u64 mask)
1268{
1269 u16 bdf;
1270 struct pci_dev *pcidev;
1271
1272 /* No device or no PCI device */
1273 if (!dev || dev->bus != &pci_bus_type)
1274 return 0;
1275
1276 pcidev = to_pci_dev(dev);
1277
1278 bdf = calc_devid(pcidev->bus->number, pcidev->devfn);
1279
1280 /* Out of our scope? */
1281 if (bdf > amd_iommu_last_bdf)
1282 return 0;
1283
1284 return 1;
1285}
1286
1287/*
1082 * The function for pre-allocating protection domains. 1288 * The function for pre-allocating protection domains.
1083 * 1289 *
1084 * If the driver core informs the DMA layer if a driver grabs a device 1290 * If the driver core informs the DMA layer if a driver grabs a device
@@ -1107,10 +1313,9 @@ void prealloc_protection_domains(void)
1107 if (!dma_dom) 1313 if (!dma_dom)
1108 continue; 1314 continue;
1109 init_unity_mappings_for_device(dma_dom, devid); 1315 init_unity_mappings_for_device(dma_dom, devid);
1110 set_device_domain(iommu, &dma_dom->domain, devid); 1316 dma_dom->target_dev = devid;
1111 printk(KERN_INFO "AMD IOMMU: Allocated domain %d for device ", 1317
1112 dma_dom->domain.id); 1318 list_add_tail(&dma_dom->list, &iommu_pd_list);
1113 print_devid(devid, 1);
1114 } 1319 }
1115} 1320}
1116 1321
@@ -1121,6 +1326,7 @@ static struct dma_mapping_ops amd_iommu_dma_ops = {
1121 .unmap_single = unmap_single, 1326 .unmap_single = unmap_single,
1122 .map_sg = map_sg, 1327 .map_sg = map_sg,
1123 .unmap_sg = unmap_sg, 1328 .unmap_sg = unmap_sg,
1329 .dma_supported = amd_iommu_dma_supported,
1124}; 1330};
1125 1331
1126/* 1332/*
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index a69cc0f52042..4cd8083c58be 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -22,6 +22,8 @@
22#include <linux/gfp.h> 22#include <linux/gfp.h>
23#include <linux/list.h> 23#include <linux/list.h>
24#include <linux/sysdev.h> 24#include <linux/sysdev.h>
25#include <linux/interrupt.h>
26#include <linux/msi.h>
25#include <asm/pci-direct.h> 27#include <asm/pci-direct.h>
26#include <asm/amd_iommu_types.h> 28#include <asm/amd_iommu_types.h>
27#include <asm/amd_iommu.h> 29#include <asm/amd_iommu.h>
@@ -30,7 +32,6 @@
30/* 32/*
31 * definitions for the ACPI scanning code 33 * definitions for the ACPI scanning code
32 */ 34 */
33#define PCI_BUS(x) (((x) >> 8) & 0xff)
34#define IVRS_HEADER_LENGTH 48 35#define IVRS_HEADER_LENGTH 48
35 36
36#define ACPI_IVHD_TYPE 0x10 37#define ACPI_IVHD_TYPE 0x10
@@ -121,6 +122,7 @@ LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings
121 we find in ACPI */ 122 we find in ACPI */
122unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */ 123unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */
123int amd_iommu_isolate; /* if 1, device isolation is enabled */ 124int amd_iommu_isolate; /* if 1, device isolation is enabled */
125bool amd_iommu_unmap_flush; /* if true, flush on every unmap */
124 126
125LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the 127LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the
126 system */ 128 system */
@@ -234,7 +236,7 @@ static void __init iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
234{ 236{
235 u32 ctrl; 237 u32 ctrl;
236 238
237 ctrl = (u64)readl(iommu->mmio_base + MMIO_CONTROL_OFFSET); 239 ctrl = readl(iommu->mmio_base + MMIO_CONTROL_OFFSET);
238 ctrl &= ~(1 << bit); 240 ctrl &= ~(1 << bit);
239 writel(ctrl, iommu->mmio_base + MMIO_CONTROL_OFFSET); 241 writel(ctrl, iommu->mmio_base + MMIO_CONTROL_OFFSET);
240} 242}
@@ -242,13 +244,23 @@ static void __init iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
242/* Function to enable the hardware */ 244/* Function to enable the hardware */
243void __init iommu_enable(struct amd_iommu *iommu) 245void __init iommu_enable(struct amd_iommu *iommu)
244{ 246{
245 printk(KERN_INFO "AMD IOMMU: Enabling IOMMU at "); 247 printk(KERN_INFO "AMD IOMMU: Enabling IOMMU "
246 print_devid(iommu->devid, 0); 248 "at %02x:%02x.%x cap 0x%hx\n",
247 printk(" cap 0x%hx\n", iommu->cap_ptr); 249 iommu->dev->bus->number,
250 PCI_SLOT(iommu->dev->devfn),
251 PCI_FUNC(iommu->dev->devfn),
252 iommu->cap_ptr);
248 253
249 iommu_feature_enable(iommu, CONTROL_IOMMU_EN); 254 iommu_feature_enable(iommu, CONTROL_IOMMU_EN);
250} 255}
251 256
257/* Function to enable IOMMU event logging and event interrupts */
258void __init iommu_enable_event_logging(struct amd_iommu *iommu)
259{
260 iommu_feature_enable(iommu, CONTROL_EVT_LOG_EN);
261 iommu_feature_enable(iommu, CONTROL_EVT_INT_EN);
262}
263
252/* 264/*
253 * mapping and unmapping functions for the IOMMU MMIO space. Each AMD IOMMU in 265 * mapping and unmapping functions for the IOMMU MMIO space. Each AMD IOMMU in
254 * the system has one. 266 * the system has one.
@@ -286,6 +298,14 @@ static void __init iommu_unmap_mmio_space(struct amd_iommu *iommu)
286 ****************************************************************************/ 298 ****************************************************************************/
287 299
288/* 300/*
301 * This function calculates the length of a given IVHD entry
302 */
303static inline int ivhd_entry_length(u8 *ivhd)
304{
305 return 0x04 << (*ivhd >> 6);
306}
307
308/*
289 * This function reads the last device id the IOMMU has to handle from the PCI 309 * This function reads the last device id the IOMMU has to handle from the PCI
290 * capability header for this IOMMU 310 * capability header for this IOMMU
291 */ 311 */
@@ -329,7 +349,7 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h)
329 default: 349 default:
330 break; 350 break;
331 } 351 }
332 p += 0x04 << (*p >> 6); 352 p += ivhd_entry_length(p);
333 } 353 }
334 354
335 WARN_ON(p != end); 355 WARN_ON(p != end);
@@ -414,7 +434,32 @@ static u8 * __init alloc_command_buffer(struct amd_iommu *iommu)
414 434
415static void __init free_command_buffer(struct amd_iommu *iommu) 435static void __init free_command_buffer(struct amd_iommu *iommu)
416{ 436{
417 free_pages((unsigned long)iommu->cmd_buf, get_order(CMD_BUFFER_SIZE)); 437 free_pages((unsigned long)iommu->cmd_buf,
438 get_order(iommu->cmd_buf_size));
439}
440
441/* allocates the memory where the IOMMU will log its events to */
442static u8 * __init alloc_event_buffer(struct amd_iommu *iommu)
443{
444 u64 entry;
445 iommu->evt_buf = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
446 get_order(EVT_BUFFER_SIZE));
447
448 if (iommu->evt_buf == NULL)
449 return NULL;
450
451 entry = (u64)virt_to_phys(iommu->evt_buf) | EVT_LEN_MASK;
452 memcpy_toio(iommu->mmio_base + MMIO_EVT_BUF_OFFSET,
453 &entry, sizeof(entry));
454
455 iommu->evt_buf_size = EVT_BUFFER_SIZE;
456
457 return iommu->evt_buf;
458}
459
460static void __init free_event_buffer(struct amd_iommu *iommu)
461{
462 free_pages((unsigned long)iommu->evt_buf, get_order(EVT_BUFFER_SIZE));
418} 463}
419 464
420/* sets a specific bit in the device table entry. */ 465/* sets a specific bit in the device table entry. */
@@ -487,19 +532,21 @@ static void __init set_device_exclusion_range(u16 devid, struct ivmd_header *m)
487 */ 532 */
488static void __init init_iommu_from_pci(struct amd_iommu *iommu) 533static void __init init_iommu_from_pci(struct amd_iommu *iommu)
489{ 534{
490 int bus = PCI_BUS(iommu->devid);
491 int dev = PCI_SLOT(iommu->devid);
492 int fn = PCI_FUNC(iommu->devid);
493 int cap_ptr = iommu->cap_ptr; 535 int cap_ptr = iommu->cap_ptr;
494 u32 range; 536 u32 range, misc;
495 537
496 iommu->cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_CAP_HDR_OFFSET); 538 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_CAP_HDR_OFFSET,
539 &iommu->cap);
540 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_RANGE_OFFSET,
541 &range);
542 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_MISC_OFFSET,
543 &misc);
497 544
498 range = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET);
499 iommu->first_device = calc_devid(MMIO_GET_BUS(range), 545 iommu->first_device = calc_devid(MMIO_GET_BUS(range),
500 MMIO_GET_FD(range)); 546 MMIO_GET_FD(range));
501 iommu->last_device = calc_devid(MMIO_GET_BUS(range), 547 iommu->last_device = calc_devid(MMIO_GET_BUS(range),
502 MMIO_GET_LD(range)); 548 MMIO_GET_LD(range));
549 iommu->evt_msi_num = MMIO_MSI_NUM(misc);
503} 550}
504 551
505/* 552/*
@@ -604,7 +651,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
604 break; 651 break;
605 } 652 }
606 653
607 p += 0x04 << (e->type >> 6); 654 p += ivhd_entry_length(p);
608 } 655 }
609} 656}
610 657
@@ -622,6 +669,7 @@ static int __init init_iommu_devices(struct amd_iommu *iommu)
622static void __init free_iommu_one(struct amd_iommu *iommu) 669static void __init free_iommu_one(struct amd_iommu *iommu)
623{ 670{
624 free_command_buffer(iommu); 671 free_command_buffer(iommu);
672 free_event_buffer(iommu);
625 iommu_unmap_mmio_space(iommu); 673 iommu_unmap_mmio_space(iommu);
626} 674}
627 675
@@ -649,8 +697,12 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
649 /* 697 /*
650 * Copy data from ACPI table entry to the iommu struct 698 * Copy data from ACPI table entry to the iommu struct
651 */ 699 */
652 iommu->devid = h->devid; 700 iommu->dev = pci_get_bus_and_slot(PCI_BUS(h->devid), h->devid & 0xff);
701 if (!iommu->dev)
702 return 1;
703
653 iommu->cap_ptr = h->cap_ptr; 704 iommu->cap_ptr = h->cap_ptr;
705 iommu->pci_seg = h->pci_seg;
654 iommu->mmio_phys = h->mmio_phys; 706 iommu->mmio_phys = h->mmio_phys;
655 iommu->mmio_base = iommu_map_mmio_space(h->mmio_phys); 707 iommu->mmio_base = iommu_map_mmio_space(h->mmio_phys);
656 if (!iommu->mmio_base) 708 if (!iommu->mmio_base)
@@ -661,11 +713,17 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
661 if (!iommu->cmd_buf) 713 if (!iommu->cmd_buf)
662 return -ENOMEM; 714 return -ENOMEM;
663 715
716 iommu->evt_buf = alloc_event_buffer(iommu);
717 if (!iommu->evt_buf)
718 return -ENOMEM;
719
720 iommu->int_enabled = false;
721
664 init_iommu_from_pci(iommu); 722 init_iommu_from_pci(iommu);
665 init_iommu_from_acpi(iommu, h); 723 init_iommu_from_acpi(iommu, h);
666 init_iommu_devices(iommu); 724 init_iommu_devices(iommu);
667 725
668 return 0; 726 return pci_enable_device(iommu->dev);
669} 727}
670 728
671/* 729/*
@@ -706,6 +764,95 @@ static int __init init_iommu_all(struct acpi_table_header *table)
706 764
707/**************************************************************************** 765/****************************************************************************
708 * 766 *
767 * The following functions initialize the MSI interrupts for all IOMMUs
768 * in the system. Its a bit challenging because there could be multiple
769 * IOMMUs per PCI BDF but we can call pci_enable_msi(x) only once per
770 * pci_dev.
771 *
772 ****************************************************************************/
773
774static int __init iommu_setup_msix(struct amd_iommu *iommu)
775{
776 struct amd_iommu *curr;
777 struct msix_entry entries[32]; /* only 32 supported by AMD IOMMU */
778 int nvec = 0, i;
779
780 list_for_each_entry(curr, &amd_iommu_list, list) {
781 if (curr->dev == iommu->dev) {
782 entries[nvec].entry = curr->evt_msi_num;
783 entries[nvec].vector = 0;
784 curr->int_enabled = true;
785 nvec++;
786 }
787 }
788
789 if (pci_enable_msix(iommu->dev, entries, nvec)) {
790 pci_disable_msix(iommu->dev);
791 return 1;
792 }
793
794 for (i = 0; i < nvec; ++i) {
795 int r = request_irq(entries->vector, amd_iommu_int_handler,
796 IRQF_SAMPLE_RANDOM,
797 "AMD IOMMU",
798 NULL);
799 if (r)
800 goto out_free;
801 }
802
803 return 0;
804
805out_free:
806 for (i -= 1; i >= 0; --i)
807 free_irq(entries->vector, NULL);
808
809 pci_disable_msix(iommu->dev);
810
811 return 1;
812}
813
814static int __init iommu_setup_msi(struct amd_iommu *iommu)
815{
816 int r;
817 struct amd_iommu *curr;
818
819 list_for_each_entry(curr, &amd_iommu_list, list) {
820 if (curr->dev == iommu->dev)
821 curr->int_enabled = true;
822 }
823
824
825 if (pci_enable_msi(iommu->dev))
826 return 1;
827
828 r = request_irq(iommu->dev->irq, amd_iommu_int_handler,
829 IRQF_SAMPLE_RANDOM,
830 "AMD IOMMU",
831 NULL);
832
833 if (r) {
834 pci_disable_msi(iommu->dev);
835 return 1;
836 }
837
838 return 0;
839}
840
841static int __init iommu_init_msi(struct amd_iommu *iommu)
842{
843 if (iommu->int_enabled)
844 return 0;
845
846 if (pci_find_capability(iommu->dev, PCI_CAP_ID_MSIX))
847 return iommu_setup_msix(iommu);
848 else if (pci_find_capability(iommu->dev, PCI_CAP_ID_MSI))
849 return iommu_setup_msi(iommu);
850
851 return 1;
852}
853
854/****************************************************************************
855 *
709 * The next functions belong to the third pass of parsing the ACPI 856 * The next functions belong to the third pass of parsing the ACPI
710 * table. In this last pass the memory mapping requirements are 857 * table. In this last pass the memory mapping requirements are
711 * gathered (like exclusion and unity mapping reanges). 858 * gathered (like exclusion and unity mapping reanges).
@@ -811,7 +958,6 @@ static void init_device_table(void)
811 for (devid = 0; devid <= amd_iommu_last_bdf; ++devid) { 958 for (devid = 0; devid <= amd_iommu_last_bdf; ++devid) {
812 set_dev_entry_bit(devid, DEV_ENTRY_VALID); 959 set_dev_entry_bit(devid, DEV_ENTRY_VALID);
813 set_dev_entry_bit(devid, DEV_ENTRY_TRANSLATION); 960 set_dev_entry_bit(devid, DEV_ENTRY_TRANSLATION);
814 set_dev_entry_bit(devid, DEV_ENTRY_NO_PAGE_FAULT);
815 } 961 }
816} 962}
817 963
@@ -825,6 +971,8 @@ static void __init enable_iommus(void)
825 971
826 list_for_each_entry(iommu, &amd_iommu_list, list) { 972 list_for_each_entry(iommu, &amd_iommu_list, list) {
827 iommu_set_exclusion_range(iommu); 973 iommu_set_exclusion_range(iommu);
974 iommu_init_msi(iommu);
975 iommu_enable_event_logging(iommu);
828 iommu_enable(iommu); 976 iommu_enable(iommu);
829 } 977 }
830} 978}
@@ -995,11 +1143,17 @@ int __init amd_iommu_init(void)
995 else 1143 else
996 printk("disabled\n"); 1144 printk("disabled\n");
997 1145
1146 if (amd_iommu_unmap_flush)
1147 printk(KERN_INFO "AMD IOMMU: IO/TLB flush on unmap enabled\n");
1148 else
1149 printk(KERN_INFO "AMD IOMMU: Lazy IO/TLB flushing enabled\n");
1150
998out: 1151out:
999 return ret; 1152 return ret;
1000 1153
1001free: 1154free:
1002 free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, 1); 1155 free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,
1156 get_order(MAX_DOMAIN_ID/8));
1003 1157
1004 free_pages((unsigned long)amd_iommu_pd_table, 1158 free_pages((unsigned long)amd_iommu_pd_table,
1005 get_order(rlookup_table_size)); 1159 get_order(rlookup_table_size));
@@ -1057,8 +1211,10 @@ void __init amd_iommu_detect(void)
1057static int __init parse_amd_iommu_options(char *str) 1211static int __init parse_amd_iommu_options(char *str)
1058{ 1212{
1059 for (; *str; ++str) { 1213 for (; *str; ++str) {
1060 if (strcmp(str, "isolate") == 0) 1214 if (strncmp(str, "isolate", 7) == 0)
1061 amd_iommu_isolate = 1; 1215 amd_iommu_isolate = 1;
1216 if (strncmp(str, "fullflush", 11) == 0)
1217 amd_iommu_unmap_flush = true;
1062 } 1218 }
1063 1219
1064 return 1; 1220 return 1;
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index 44e21826db11..9a32b37ee2ee 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -455,11 +455,11 @@ out:
455 force_iommu || 455 force_iommu ||
456 valid_agp || 456 valid_agp ||
457 fallback_aper_force) { 457 fallback_aper_force) {
458 printk(KERN_ERR 458 printk(KERN_INFO
459 "Your BIOS doesn't leave a aperture memory hole\n"); 459 "Your BIOS doesn't leave a aperture memory hole\n");
460 printk(KERN_ERR 460 printk(KERN_INFO
461 "Please enable the IOMMU option in the BIOS setup\n"); 461 "Please enable the IOMMU option in the BIOS setup\n");
462 printk(KERN_ERR 462 printk(KERN_INFO
463 "This costs you %d MB of RAM\n", 463 "This costs you %d MB of RAM\n",
464 32 << fallback_aper_order); 464 32 << fallback_aper_order);
465 465
diff --git a/arch/x86/kernel/apic_32.c b/arch/x86/kernel/apic_32.c
index 0ff576d026a4..21c831d96af3 100644
--- a/arch/x86/kernel/apic_32.c
+++ b/arch/x86/kernel/apic_32.c
@@ -60,10 +60,8 @@ unsigned long mp_lapic_addr;
60static int force_enable_local_apic; 60static int force_enable_local_apic;
61int disable_apic; 61int disable_apic;
62 62
63/* Local APIC timer verification ok */
64static int local_apic_timer_verify_ok;
65/* Disable local APIC timer from the kernel commandline or via dmi quirk */ 63/* Disable local APIC timer from the kernel commandline or via dmi quirk */
66static int local_apic_timer_disabled; 64static int disable_apic_timer __cpuinitdata;
67/* Local APIC timer works in C2 */ 65/* Local APIC timer works in C2 */
68int local_apic_timer_c2_ok; 66int local_apic_timer_c2_ok;
69EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok); 67EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
@@ -130,7 +128,11 @@ static inline int lapic_get_version(void)
130 */ 128 */
131static inline int lapic_is_integrated(void) 129static inline int lapic_is_integrated(void)
132{ 130{
131#ifdef CONFIG_X86_64
132 return 1;
133#else
133 return APIC_INTEGRATED(lapic_get_version()); 134 return APIC_INTEGRATED(lapic_get_version());
135#endif
134} 136}
135 137
136/* 138/*
@@ -145,13 +147,18 @@ static int modern_apic(void)
145 return lapic_get_version() >= 0x14; 147 return lapic_get_version() >= 0x14;
146} 148}
147 149
148void apic_wait_icr_idle(void) 150/*
151 * Paravirt kernels also might be using these below ops. So we still
152 * use generic apic_read()/apic_write(), which might be pointing to different
153 * ops in PARAVIRT case.
154 */
155void xapic_wait_icr_idle(void)
149{ 156{
150 while (apic_read(APIC_ICR) & APIC_ICR_BUSY) 157 while (apic_read(APIC_ICR) & APIC_ICR_BUSY)
151 cpu_relax(); 158 cpu_relax();
152} 159}
153 160
154u32 safe_apic_wait_icr_idle(void) 161u32 safe_xapic_wait_icr_idle(void)
155{ 162{
156 u32 send_status; 163 u32 send_status;
157 int timeout; 164 int timeout;
@@ -167,16 +174,48 @@ u32 safe_apic_wait_icr_idle(void)
167 return send_status; 174 return send_status;
168} 175}
169 176
177void xapic_icr_write(u32 low, u32 id)
178{
179 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(id));
180 apic_write(APIC_ICR, low);
181}
182
183u64 xapic_icr_read(void)
184{
185 u32 icr1, icr2;
186
187 icr2 = apic_read(APIC_ICR2);
188 icr1 = apic_read(APIC_ICR);
189
190 return icr1 | ((u64)icr2 << 32);
191}
192
193static struct apic_ops xapic_ops = {
194 .read = native_apic_mem_read,
195 .write = native_apic_mem_write,
196 .icr_read = xapic_icr_read,
197 .icr_write = xapic_icr_write,
198 .wait_icr_idle = xapic_wait_icr_idle,
199 .safe_wait_icr_idle = safe_xapic_wait_icr_idle,
200};
201
202struct apic_ops __read_mostly *apic_ops = &xapic_ops;
203EXPORT_SYMBOL_GPL(apic_ops);
204
170/** 205/**
171 * enable_NMI_through_LVT0 - enable NMI through local vector table 0 206 * enable_NMI_through_LVT0 - enable NMI through local vector table 0
172 */ 207 */
173void __cpuinit enable_NMI_through_LVT0(void) 208void __cpuinit enable_NMI_through_LVT0(void)
174{ 209{
175 unsigned int v = APIC_DM_NMI; 210 unsigned int v;
211
212 /* unmask and set to NMI */
213 v = APIC_DM_NMI;
176 214
177 /* Level triggered for 82489DX */ 215 /* Level triggered for 82489DX (32bit mode) */
178 if (!lapic_is_integrated()) 216 if (!lapic_is_integrated())
179 v |= APIC_LVT_LEVEL_TRIGGER; 217 v |= APIC_LVT_LEVEL_TRIGGER;
218
180 apic_write(APIC_LVT0, v); 219 apic_write(APIC_LVT0, v);
181} 220}
182 221
@@ -193,9 +232,13 @@ int get_physical_broadcast(void)
193 */ 232 */
194int lapic_get_maxlvt(void) 233int lapic_get_maxlvt(void)
195{ 234{
196 unsigned int v = apic_read(APIC_LVR); 235 unsigned int v;
197 236
198 /* 82489DXs do not report # of LVT entries. */ 237 v = apic_read(APIC_LVR);
238 /*
239 * - we always have APIC integrated on 64bit mode
240 * - 82489DXs do not report # of LVT entries
241 */
199 return APIC_INTEGRATED(GET_APIC_VERSION(v)) ? GET_APIC_MAXLVT(v) : 2; 242 return APIC_INTEGRATED(GET_APIC_VERSION(v)) ? GET_APIC_MAXLVT(v) : 2;
200} 243}
201 244
@@ -203,8 +246,12 @@ int lapic_get_maxlvt(void)
203 * Local APIC timer 246 * Local APIC timer
204 */ 247 */
205 248
206/* Clock divisor is set to 16 */ 249/* Clock divisor */
250#ifdef CONFG_X86_64
251#define APIC_DIVISOR 1
252#else
207#define APIC_DIVISOR 16 253#define APIC_DIVISOR 16
254#endif
208 255
209/* 256/*
210 * This function sets up the local APIC timer, with a timeout of 257 * This function sets up the local APIC timer, with a timeout of
@@ -212,6 +259,9 @@ int lapic_get_maxlvt(void)
212 * this function twice on the boot CPU, once with a bogus timeout 259 * this function twice on the boot CPU, once with a bogus timeout
213 * value, second time for real. The other (noncalibrating) CPUs 260 * value, second time for real. The other (noncalibrating) CPUs
214 * call this function only once, with the real, calibrated value. 261 * call this function only once, with the real, calibrated value.
262 *
263 * We do reads before writes even if unnecessary, to get around the
264 * P5 APIC double write bug.
215 */ 265 */
216static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen) 266static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
217{ 267{
@@ -233,14 +283,48 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
233 */ 283 */
234 tmp_value = apic_read(APIC_TDCR); 284 tmp_value = apic_read(APIC_TDCR);
235 apic_write(APIC_TDCR, 285 apic_write(APIC_TDCR,
236 (tmp_value & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) | 286 (tmp_value & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) |
237 APIC_TDR_DIV_16); 287 APIC_TDR_DIV_16);
238 288
239 if (!oneshot) 289 if (!oneshot)
240 apic_write(APIC_TMICT, clocks / APIC_DIVISOR); 290 apic_write(APIC_TMICT, clocks / APIC_DIVISOR);
241} 291}
242 292
243/* 293/*
294 * Setup extended LVT, AMD specific (K8, family 10h)
295 *
296 * Vector mappings are hard coded. On K8 only offset 0 (APIC500) and
297 * MCE interrupts are supported. Thus MCE offset must be set to 0.
298 *
299 * If mask=1, the LVT entry does not generate interrupts while mask=0
300 * enables the vector. See also the BKDGs.
301 */
302
303#define APIC_EILVT_LVTOFF_MCE 0
304#define APIC_EILVT_LVTOFF_IBS 1
305
306static void setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask)
307{
308 unsigned long reg = (lvt_off << 4) + APIC_EILVT0;
309 unsigned int v = (mask << 16) | (msg_type << 8) | vector;
310
311 apic_write(reg, v);
312}
313
314u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask)
315{
316 setup_APIC_eilvt(APIC_EILVT_LVTOFF_MCE, vector, msg_type, mask);
317 return APIC_EILVT_LVTOFF_MCE;
318}
319
320u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask)
321{
322 setup_APIC_eilvt(APIC_EILVT_LVTOFF_IBS, vector, msg_type, mask);
323 return APIC_EILVT_LVTOFF_IBS;
324}
325EXPORT_SYMBOL_GPL(setup_APIC_eilvt_ibs);
326
327/*
244 * Program the next event, relative to now 328 * Program the next event, relative to now
245 */ 329 */
246static int lapic_next_event(unsigned long delta, 330static int lapic_next_event(unsigned long delta,
@@ -259,8 +343,8 @@ static void lapic_timer_setup(enum clock_event_mode mode,
259 unsigned long flags; 343 unsigned long flags;
260 unsigned int v; 344 unsigned int v;
261 345
262 /* Lapic used for broadcast ? */ 346 /* Lapic used as dummy for broadcast ? */
263 if (!local_apic_timer_verify_ok) 347 if (evt->features & CLOCK_EVT_FEAT_DUMMY)
264 return; 348 return;
265 349
266 local_irq_save(flags); 350 local_irq_save(flags);
@@ -473,7 +557,7 @@ static int __init calibrate_APIC_clock(void)
473 return -1; 557 return -1;
474 } 558 }
475 559
476 local_apic_timer_verify_ok = 1; 560 levt->features &= ~CLOCK_EVT_FEAT_DUMMY;
477 561
478 /* We trust the pm timer based calibration */ 562 /* We trust the pm timer based calibration */
479 if (!pm_referenced) { 563 if (!pm_referenced) {
@@ -507,11 +591,11 @@ static int __init calibrate_APIC_clock(void)
507 if (deltaj >= LAPIC_CAL_LOOPS-2 && deltaj <= LAPIC_CAL_LOOPS+2) 591 if (deltaj >= LAPIC_CAL_LOOPS-2 && deltaj <= LAPIC_CAL_LOOPS+2)
508 apic_printk(APIC_VERBOSE, "... jiffies result ok\n"); 592 apic_printk(APIC_VERBOSE, "... jiffies result ok\n");
509 else 593 else
510 local_apic_timer_verify_ok = 0; 594 levt->features |= CLOCK_EVT_FEAT_DUMMY;
511 } else 595 } else
512 local_irq_enable(); 596 local_irq_enable();
513 597
514 if (!local_apic_timer_verify_ok) { 598 if (levt->features & CLOCK_EVT_FEAT_DUMMY) {
515 printk(KERN_WARNING 599 printk(KERN_WARNING
516 "APIC timer disabled due to verification failure.\n"); 600 "APIC timer disabled due to verification failure.\n");
517 return -1; 601 return -1;
@@ -533,7 +617,8 @@ void __init setup_boot_APIC_clock(void)
533 * timer as a dummy clock event source on SMP systems, so the 617 * timer as a dummy clock event source on SMP systems, so the
534 * broadcast mechanism is used. On UP systems simply ignore it. 618 * broadcast mechanism is used. On UP systems simply ignore it.
535 */ 619 */
536 if (local_apic_timer_disabled) { 620 if (disable_apic_timer) {
621 printk(KERN_INFO "Disabling APIC timer\n");
537 /* No broadcast on UP ! */ 622 /* No broadcast on UP ! */
538 if (num_possible_cpus() > 1) { 623 if (num_possible_cpus() > 1) {
539 lapic_clockevent.mult = 1; 624 lapic_clockevent.mult = 1;
@@ -602,7 +687,11 @@ static void local_apic_timer_interrupt(void)
602 /* 687 /*
603 * the NMI deadlock-detector uses this. 688 * the NMI deadlock-detector uses this.
604 */ 689 */
690#ifdef CONFIG_X86_64
691 add_pda(apic_timer_irqs, 1);
692#else
605 per_cpu(irq_stat, cpu).apic_timer_irqs++; 693 per_cpu(irq_stat, cpu).apic_timer_irqs++;
694#endif
606 695
607 evt->event_handler(evt); 696 evt->event_handler(evt);
608} 697}
@@ -642,39 +731,6 @@ int setup_profiling_timer(unsigned int multiplier)
642} 731}
643 732
644/* 733/*
645 * Setup extended LVT, AMD specific (K8, family 10h)
646 *
647 * Vector mappings are hard coded. On K8 only offset 0 (APIC500) and
648 * MCE interrupts are supported. Thus MCE offset must be set to 0.
649 *
650 * If mask=1, the LVT entry does not generate interrupts while mask=0
651 * enables the vector. See also the BKDGs.
652 */
653
654#define APIC_EILVT_LVTOFF_MCE 0
655#define APIC_EILVT_LVTOFF_IBS 1
656
657static void setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask)
658{
659 unsigned long reg = (lvt_off << 4) + APIC_EILVT0;
660 unsigned int v = (mask << 16) | (msg_type << 8) | vector;
661 apic_write(reg, v);
662}
663
664u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask)
665{
666 setup_APIC_eilvt(APIC_EILVT_LVTOFF_MCE, vector, msg_type, mask);
667 return APIC_EILVT_LVTOFF_MCE;
668}
669
670u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask)
671{
672 setup_APIC_eilvt(APIC_EILVT_LVTOFF_IBS, vector, msg_type, mask);
673 return APIC_EILVT_LVTOFF_IBS;
674}
675EXPORT_SYMBOL_GPL(setup_APIC_eilvt_ibs);
676
677/*
678 * Local APIC start and shutdown 734 * Local APIC start and shutdown
679 */ 735 */
680 736
@@ -719,7 +775,7 @@ void clear_local_APIC(void)
719 } 775 }
720 776
721 /* lets not touch this if we didn't frob it */ 777 /* lets not touch this if we didn't frob it */
722#ifdef CONFIG_X86_MCE_P4THERMAL 778#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(X86_MCE_INTEL)
723 if (maxlvt >= 5) { 779 if (maxlvt >= 5) {
724 v = apic_read(APIC_LVTTHMR); 780 v = apic_read(APIC_LVTTHMR);
725 apic_write(APIC_LVTTHMR, v | APIC_LVT_MASKED); 781 apic_write(APIC_LVTTHMR, v | APIC_LVT_MASKED);
@@ -736,10 +792,6 @@ void clear_local_APIC(void)
736 if (maxlvt >= 4) 792 if (maxlvt >= 4)
737 apic_write(APIC_LVTPC, APIC_LVT_MASKED); 793 apic_write(APIC_LVTPC, APIC_LVT_MASKED);
738 794
739#ifdef CONFIG_X86_MCE_P4THERMAL
740 if (maxlvt >= 5)
741 apic_write(APIC_LVTTHMR, APIC_LVT_MASKED);
742#endif
743 /* Integrated APIC (!82489DX) ? */ 795 /* Integrated APIC (!82489DX) ? */
744 if (lapic_is_integrated()) { 796 if (lapic_is_integrated()) {
745 if (maxlvt > 3) 797 if (maxlvt > 3)
@@ -754,7 +806,7 @@ void clear_local_APIC(void)
754 */ 806 */
755void disable_local_APIC(void) 807void disable_local_APIC(void)
756{ 808{
757 unsigned long value; 809 unsigned int value;
758 810
759 clear_local_APIC(); 811 clear_local_APIC();
760 812
@@ -766,6 +818,7 @@ void disable_local_APIC(void)
766 value &= ~APIC_SPIV_APIC_ENABLED; 818 value &= ~APIC_SPIV_APIC_ENABLED;
767 apic_write(APIC_SPIV, value); 819 apic_write(APIC_SPIV, value);
768 820
821#ifdef CONFIG_X86_32
769 /* 822 /*
770 * When LAPIC was disabled by the BIOS and enabled by the kernel, 823 * When LAPIC was disabled by the BIOS and enabled by the kernel,
771 * restore the disabled state. 824 * restore the disabled state.
@@ -777,6 +830,7 @@ void disable_local_APIC(void)
777 l &= ~MSR_IA32_APICBASE_ENABLE; 830 l &= ~MSR_IA32_APICBASE_ENABLE;
778 wrmsr(MSR_IA32_APICBASE, l, h); 831 wrmsr(MSR_IA32_APICBASE, l, h);
779 } 832 }
833#endif
780} 834}
781 835
782/* 836/*
@@ -793,11 +847,15 @@ void lapic_shutdown(void)
793 return; 847 return;
794 848
795 local_irq_save(flags); 849 local_irq_save(flags);
796 clear_local_APIC();
797 850
798 if (enabled_via_apicbase) 851#ifdef CONFIG_X86_32
852 if (!enabled_via_apicbase)
853 clear_local_APIC();
854 else
855#endif
799 disable_local_APIC(); 856 disable_local_APIC();
800 857
858
801 local_irq_restore(flags); 859 local_irq_restore(flags);
802} 860}
803 861
@@ -842,6 +900,12 @@ int __init verify_local_APIC(void)
842 */ 900 */
843 reg0 = apic_read(APIC_ID); 901 reg0 = apic_read(APIC_ID);
844 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0); 902 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0);
903 apic_write(APIC_ID, reg0 ^ APIC_ID_MASK);
904 reg1 = apic_read(APIC_ID);
905 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1);
906 apic_write(APIC_ID, reg0);
907 if (reg1 != (reg0 ^ APIC_ID_MASK))
908 return 0;
845 909
846 /* 910 /*
847 * The next two are just to see if we have sane values. 911 * The next two are just to see if we have sane values.
@@ -867,14 +931,15 @@ void __init sync_Arb_IDs(void)
867 */ 931 */
868 if (modern_apic() || boot_cpu_data.x86_vendor == X86_VENDOR_AMD) 932 if (modern_apic() || boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
869 return; 933 return;
934
870 /* 935 /*
871 * Wait for idle. 936 * Wait for idle.
872 */ 937 */
873 apic_wait_icr_idle(); 938 apic_wait_icr_idle();
874 939
875 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n"); 940 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n");
876 apic_write(APIC_ICR, 941 apic_write(APIC_ICR, APIC_DEST_ALLINC |
877 APIC_DEST_ALLINC | APIC_INT_LEVELTRIG | APIC_DM_INIT); 942 APIC_INT_LEVELTRIG | APIC_DM_INIT);
878} 943}
879 944
880/* 945/*
@@ -882,7 +947,7 @@ void __init sync_Arb_IDs(void)
882 */ 947 */
883void __init init_bsp_APIC(void) 948void __init init_bsp_APIC(void)
884{ 949{
885 unsigned long value; 950 unsigned int value;
886 951
887 /* 952 /*
888 * Don't do the setup now if we have a SMP BIOS as the 953 * Don't do the setup now if we have a SMP BIOS as the
@@ -903,11 +968,13 @@ void __init init_bsp_APIC(void)
903 value &= ~APIC_VECTOR_MASK; 968 value &= ~APIC_VECTOR_MASK;
904 value |= APIC_SPIV_APIC_ENABLED; 969 value |= APIC_SPIV_APIC_ENABLED;
905 970
971#ifdef CONFIG_X86_32
906 /* This bit is reserved on P4/Xeon and should be cleared */ 972 /* This bit is reserved on P4/Xeon and should be cleared */
907 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && 973 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
908 (boot_cpu_data.x86 == 15)) 974 (boot_cpu_data.x86 == 15))
909 value &= ~APIC_SPIV_FOCUS_DISABLED; 975 value &= ~APIC_SPIV_FOCUS_DISABLED;
910 else 976 else
977#endif
911 value |= APIC_SPIV_FOCUS_DISABLED; 978 value |= APIC_SPIV_FOCUS_DISABLED;
912 value |= SPURIOUS_APIC_VECTOR; 979 value |= SPURIOUS_APIC_VECTOR;
913 apic_write(APIC_SPIV, value); 980 apic_write(APIC_SPIV, value);
@@ -926,6 +993,16 @@ static void __cpuinit lapic_setup_esr(void)
926{ 993{
927 unsigned long oldvalue, value, maxlvt; 994 unsigned long oldvalue, value, maxlvt;
928 if (lapic_is_integrated() && !esr_disable) { 995 if (lapic_is_integrated() && !esr_disable) {
996 if (esr_disable) {
997 /*
998 * Something untraceable is creating bad interrupts on
999 * secondary quads ... for the moment, just leave the
1000 * ESR disabled - we can't do anything useful with the
1001 * errors anyway - mbligh
1002 */
1003 printk(KERN_INFO "Leaving ESR disabled.\n");
1004 return;
1005 }
929 /* !82489DX */ 1006 /* !82489DX */
930 maxlvt = lapic_get_maxlvt(); 1007 maxlvt = lapic_get_maxlvt();
931 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ 1008 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
@@ -946,16 +1023,7 @@ static void __cpuinit lapic_setup_esr(void)
946 "vector: 0x%08lx after: 0x%08lx\n", 1023 "vector: 0x%08lx after: 0x%08lx\n",
947 oldvalue, value); 1024 oldvalue, value);
948 } else { 1025 } else {
949 if (esr_disable) 1026 printk(KERN_INFO "No ESR for 82489DX.\n");
950 /*
951 * Something untraceable is creating bad interrupts on
952 * secondary quads ... for the moment, just leave the
953 * ESR disabled - we can't do anything useful with the
954 * errors anyway - mbligh
955 */
956 printk(KERN_INFO "Leaving ESR disabled.\n");
957 else
958 printk(KERN_INFO "No ESR for 82489DX.\n");
959 } 1027 }
960} 1028}
961 1029
@@ -1093,13 +1161,17 @@ void __cpuinit setup_local_APIC(void)
1093 1161
1094void __cpuinit end_local_APIC_setup(void) 1162void __cpuinit end_local_APIC_setup(void)
1095{ 1163{
1096 unsigned long value;
1097
1098 lapic_setup_esr(); 1164 lapic_setup_esr();
1099 /* Disable the local apic timer */ 1165
1100 value = apic_read(APIC_LVTT); 1166#ifdef CONFIG_X86_32
1101 value |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR); 1167 {
1102 apic_write(APIC_LVTT, value); 1168 unsigned int value;
1169 /* Disable the local apic timer */
1170 value = apic_read(APIC_LVTT);
1171 value |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
1172 apic_write(APIC_LVTT, value);
1173 }
1174#endif
1103 1175
1104 setup_apic_nmi_watchdog(NULL); 1176 setup_apic_nmi_watchdog(NULL);
1105 apic_pm_activate(); 1177 apic_pm_activate();
@@ -1209,7 +1281,7 @@ void __init init_apic_mappings(void)
1209 * default configuration (or the MP table is broken). 1281 * default configuration (or the MP table is broken).
1210 */ 1282 */
1211 if (boot_cpu_physical_apicid == -1U) 1283 if (boot_cpu_physical_apicid == -1U)
1212 boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); 1284 boot_cpu_physical_apicid = read_apic_id();
1213 1285
1214} 1286}
1215 1287
@@ -1246,7 +1318,7 @@ int __init APIC_init_uniprocessor(void)
1246 * might be zero if read from MP tables. Get it from LAPIC. 1318 * might be zero if read from MP tables. Get it from LAPIC.
1247 */ 1319 */
1248#ifdef CONFIG_CRASH_DUMP 1320#ifdef CONFIG_CRASH_DUMP
1249 boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); 1321 boot_cpu_physical_apicid = read_apic_id();
1250#endif 1322#endif
1251 physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); 1323 physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
1252 1324
@@ -1325,59 +1397,12 @@ void smp_error_interrupt(struct pt_regs *regs)
1325 irq_exit(); 1397 irq_exit();
1326} 1398}
1327 1399
1328#ifdef CONFIG_SMP
1329void __init smp_intr_init(void)
1330{
1331 /*
1332 * IRQ0 must be given a fixed assignment and initialized,
1333 * because it's used before the IO-APIC is set up.
1334 */
1335 set_intr_gate(FIRST_DEVICE_VECTOR, interrupt[0]);
1336
1337 /*
1338 * The reschedule interrupt is a CPU-to-CPU reschedule-helper
1339 * IPI, driven by wakeup.
1340 */
1341 alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
1342
1343 /* IPI for invalidation */
1344 alloc_intr_gate(INVALIDATE_TLB_VECTOR, invalidate_interrupt);
1345
1346 /* IPI for generic function call */
1347 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
1348
1349 /* IPI for single call function */
1350 set_intr_gate(CALL_FUNCTION_SINGLE_VECTOR,
1351 call_function_single_interrupt);
1352}
1353#endif
1354
1355/*
1356 * Initialize APIC interrupts
1357 */
1358void __init apic_intr_init(void)
1359{
1360#ifdef CONFIG_SMP
1361 smp_intr_init();
1362#endif
1363 /* self generated IPI for local APIC timer */
1364 alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
1365
1366 /* IPI vectors for APIC spurious and error interrupts */
1367 alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
1368 alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
1369
1370 /* thermal monitor LVT interrupt */
1371#ifdef CONFIG_X86_MCE_P4THERMAL
1372 alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
1373#endif
1374}
1375
1376/** 1400/**
1377 * connect_bsp_APIC - attach the APIC to the interrupt system 1401 * connect_bsp_APIC - attach the APIC to the interrupt system
1378 */ 1402 */
1379void __init connect_bsp_APIC(void) 1403void __init connect_bsp_APIC(void)
1380{ 1404{
1405#ifdef CONFIG_X86_32
1381 if (pic_mode) { 1406 if (pic_mode) {
1382 /* 1407 /*
1383 * Do not trust the local APIC being empty at bootup. 1408 * Do not trust the local APIC being empty at bootup.
@@ -1392,6 +1417,7 @@ void __init connect_bsp_APIC(void)
1392 outb(0x70, 0x22); 1417 outb(0x70, 0x22);
1393 outb(0x01, 0x23); 1418 outb(0x01, 0x23);
1394 } 1419 }
1420#endif
1395 enable_apic_mode(); 1421 enable_apic_mode();
1396} 1422}
1397 1423
@@ -1404,6 +1430,9 @@ void __init connect_bsp_APIC(void)
1404 */ 1430 */
1405void disconnect_bsp_APIC(int virt_wire_setup) 1431void disconnect_bsp_APIC(int virt_wire_setup)
1406{ 1432{
1433 unsigned int value;
1434
1435#ifdef CONFIG_X86_32
1407 if (pic_mode) { 1436 if (pic_mode) {
1408 /* 1437 /*
1409 * Put the board back into PIC mode (has an effect only on 1438 * Put the board back into PIC mode (has an effect only on
@@ -1415,54 +1444,53 @@ void disconnect_bsp_APIC(int virt_wire_setup)
1415 "entering PIC mode.\n"); 1444 "entering PIC mode.\n");
1416 outb(0x70, 0x22); 1445 outb(0x70, 0x22);
1417 outb(0x00, 0x23); 1446 outb(0x00, 0x23);
1418 } else { 1447 return;
1419 /* Go back to Virtual Wire compatibility mode */ 1448 }
1420 unsigned long value; 1449#endif
1421 1450
1422 /* For the spurious interrupt use vector F, and enable it */ 1451 /* Go back to Virtual Wire compatibility mode */
1423 value = apic_read(APIC_SPIV);
1424 value &= ~APIC_VECTOR_MASK;
1425 value |= APIC_SPIV_APIC_ENABLED;
1426 value |= 0xf;
1427 apic_write(APIC_SPIV, value);
1428 1452
1429 if (!virt_wire_setup) { 1453 /* For the spurious interrupt use vector F, and enable it */
1430 /* 1454 value = apic_read(APIC_SPIV);
1431 * For LVT0 make it edge triggered, active high, 1455 value &= ~APIC_VECTOR_MASK;
1432 * external and enabled 1456 value |= APIC_SPIV_APIC_ENABLED;
1433 */ 1457 value |= 0xf;
1434 value = apic_read(APIC_LVT0); 1458 apic_write(APIC_SPIV, value);
1435 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
1436 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
1437 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
1438 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
1439 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
1440 apic_write(APIC_LVT0, value);
1441 } else {
1442 /* Disable LVT0 */
1443 apic_write(APIC_LVT0, APIC_LVT_MASKED);
1444 }
1445 1459
1460 if (!virt_wire_setup) {
1446 /* 1461 /*
1447 * For LVT1 make it edge triggered, active high, nmi and 1462 * For LVT0 make it edge triggered, active high,
1448 * enabled 1463 * external and enabled
1449 */ 1464 */
1450 value = apic_read(APIC_LVT1); 1465 value = apic_read(APIC_LVT0);
1451 value &= ~( 1466 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
1452 APIC_MODE_MASK | APIC_SEND_PENDING |
1453 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR | 1467 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
1454 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED); 1468 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
1455 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING; 1469 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
1456 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI); 1470 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
1457 apic_write(APIC_LVT1, value); 1471 apic_write(APIC_LVT0, value);
1472 } else {
1473 /* Disable LVT0 */
1474 apic_write(APIC_LVT0, APIC_LVT_MASKED);
1458 } 1475 }
1476
1477 /*
1478 * For LVT1 make it edge triggered, active high,
1479 * nmi and enabled
1480 */
1481 value = apic_read(APIC_LVT1);
1482 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
1483 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
1484 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
1485 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
1486 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
1487 apic_write(APIC_LVT1, value);
1459} 1488}
1460 1489
1461void __cpuinit generic_processor_info(int apicid, int version) 1490void __cpuinit generic_processor_info(int apicid, int version)
1462{ 1491{
1463 int cpu; 1492 int cpu;
1464 cpumask_t tmp_map; 1493 cpumask_t tmp_map;
1465 physid_mask_t phys_cpu;
1466 1494
1467 /* 1495 /*
1468 * Validate version 1496 * Validate version
@@ -1475,9 +1503,6 @@ void __cpuinit generic_processor_info(int apicid, int version)
1475 } 1503 }
1476 apic_version[apicid] = version; 1504 apic_version[apicid] = version;
1477 1505
1478 phys_cpu = apicid_to_cpu_present(apicid);
1479 physids_or(phys_cpu_present_map, phys_cpu_present_map, phys_cpu);
1480
1481 if (num_processors >= NR_CPUS) { 1506 if (num_processors >= NR_CPUS) {
1482 printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached." 1507 printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
1483 " Processor ignored.\n", NR_CPUS); 1508 " Processor ignored.\n", NR_CPUS);
@@ -1488,17 +1513,19 @@ void __cpuinit generic_processor_info(int apicid, int version)
1488 cpus_complement(tmp_map, cpu_present_map); 1513 cpus_complement(tmp_map, cpu_present_map);
1489 cpu = first_cpu(tmp_map); 1514 cpu = first_cpu(tmp_map);
1490 1515
1491 if (apicid == boot_cpu_physical_apicid) 1516 physid_set(apicid, phys_cpu_present_map);
1517 if (apicid == boot_cpu_physical_apicid) {
1492 /* 1518 /*
1493 * x86_bios_cpu_apicid is required to have processors listed 1519 * x86_bios_cpu_apicid is required to have processors listed
1494 * in same order as logical cpu numbers. Hence the first 1520 * in same order as logical cpu numbers. Hence the first
1495 * entry is BSP, and so on. 1521 * entry is BSP, and so on.
1496 */ 1522 */
1497 cpu = 0; 1523 cpu = 0;
1498 1524 }
1499 if (apicid > max_physical_apicid) 1525 if (apicid > max_physical_apicid)
1500 max_physical_apicid = apicid; 1526 max_physical_apicid = apicid;
1501 1527
1528#ifdef CONFIG_X86_32
1502 /* 1529 /*
1503 * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y 1530 * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
1504 * but we need to work other dependencies like SMP_SUSPEND etc 1531 * but we need to work other dependencies like SMP_SUSPEND etc
@@ -1518,7 +1545,9 @@ void __cpuinit generic_processor_info(int apicid, int version)
1518 def_to_bigsmp = 1; 1545 def_to_bigsmp = 1;
1519 } 1546 }
1520 } 1547 }
1521#ifdef CONFIG_SMP 1548#endif
1549
1550#if defined(CONFIG_X86_SMP) || defined(CONFIG_X86_64)
1522 /* are we being called early in kernel startup? */ 1551 /* are we being called early in kernel startup? */
1523 if (early_per_cpu_ptr(x86_cpu_to_apicid)) { 1552 if (early_per_cpu_ptr(x86_cpu_to_apicid)) {
1524 u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid); 1553 u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid);
@@ -1531,6 +1560,7 @@ void __cpuinit generic_processor_info(int apicid, int version)
1531 per_cpu(x86_bios_cpu_apicid, cpu) = apicid; 1560 per_cpu(x86_bios_cpu_apicid, cpu) = apicid;
1532 } 1561 }
1533#endif 1562#endif
1563
1534 cpu_set(cpu, cpu_possible_map); 1564 cpu_set(cpu, cpu_possible_map);
1535 cpu_set(cpu, cpu_present_map); 1565 cpu_set(cpu, cpu_present_map);
1536} 1566}
@@ -1541,6 +1571,11 @@ void __cpuinit generic_processor_info(int apicid, int version)
1541#ifdef CONFIG_PM 1571#ifdef CONFIG_PM
1542 1572
1543static struct { 1573static struct {
1574 /*
1575 * 'active' is true if the local APIC was enabled by us and
1576 * not the BIOS; this signifies that we are also responsible
1577 * for disabling it before entering apm/acpi suspend
1578 */
1544 int active; 1579 int active;
1545 /* r/w apic fields */ 1580 /* r/w apic fields */
1546 unsigned int apic_id; 1581 unsigned int apic_id;
@@ -1581,7 +1616,7 @@ static int lapic_suspend(struct sys_device *dev, pm_message_t state)
1581 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR); 1616 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
1582 apic_pm_state.apic_tmict = apic_read(APIC_TMICT); 1617 apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
1583 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR); 1618 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
1584#ifdef CONFIG_X86_MCE_P4THERMAL 1619#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(CONFIG_X86_MCE_INTEL)
1585 if (maxlvt >= 5) 1620 if (maxlvt >= 5)
1586 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR); 1621 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
1587#endif 1622#endif
@@ -1605,16 +1640,23 @@ static int lapic_resume(struct sys_device *dev)
1605 1640
1606 local_irq_save(flags); 1641 local_irq_save(flags);
1607 1642
1608 /* 1643#ifdef CONFIG_X86_64
1609 * Make sure the APICBASE points to the right address 1644 if (x2apic)
1610 * 1645 enable_x2apic();
1611 * FIXME! This will be wrong if we ever support suspend on 1646 else
1612 * SMP! We'll need to do this as part of the CPU restore! 1647#endif
1613 */ 1648 {
1614 rdmsr(MSR_IA32_APICBASE, l, h); 1649 /*
1615 l &= ~MSR_IA32_APICBASE_BASE; 1650 * Make sure the APICBASE points to the right address
1616 l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr; 1651 *
1617 wrmsr(MSR_IA32_APICBASE, l, h); 1652 * FIXME! This will be wrong if we ever support suspend on
1653 * SMP! We'll need to do this as part of the CPU restore!
1654 */
1655 rdmsr(MSR_IA32_APICBASE, l, h);
1656 l &= ~MSR_IA32_APICBASE_BASE;
1657 l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
1658 wrmsr(MSR_IA32_APICBASE, l, h);
1659 }
1618 1660
1619 apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED); 1661 apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED);
1620 apic_write(APIC_ID, apic_pm_state.apic_id); 1662 apic_write(APIC_ID, apic_pm_state.apic_id);
@@ -1624,7 +1666,7 @@ static int lapic_resume(struct sys_device *dev)
1624 apic_write(APIC_SPIV, apic_pm_state.apic_spiv); 1666 apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
1625 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0); 1667 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
1626 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1); 1668 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
1627#ifdef CONFIG_X86_MCE_P4THERMAL 1669#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(CONFIG_X86_MCE_INTEL)
1628 if (maxlvt >= 5) 1670 if (maxlvt >= 5)
1629 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr); 1671 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
1630#endif 1672#endif
@@ -1638,7 +1680,9 @@ static int lapic_resume(struct sys_device *dev)
1638 apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr); 1680 apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr);
1639 apic_write(APIC_ESR, 0); 1681 apic_write(APIC_ESR, 0);
1640 apic_read(APIC_ESR); 1682 apic_read(APIC_ESR);
1683
1641 local_irq_restore(flags); 1684 local_irq_restore(flags);
1685
1642 return 0; 1686 return 0;
1643} 1687}
1644 1688
@@ -1694,20 +1738,20 @@ static int __init parse_lapic(char *arg)
1694} 1738}
1695early_param("lapic", parse_lapic); 1739early_param("lapic", parse_lapic);
1696 1740
1697static int __init parse_nolapic(char *arg) 1741static int __init setup_disableapic(char *arg)
1698{ 1742{
1699 disable_apic = 1; 1743 disable_apic = 1;
1700 setup_clear_cpu_cap(X86_FEATURE_APIC); 1744 setup_clear_cpu_cap(X86_FEATURE_APIC);
1701 return 0; 1745 return 0;
1702} 1746}
1703early_param("nolapic", parse_nolapic); 1747early_param("disableapic", setup_disableapic);
1704 1748
1705static int __init parse_disable_lapic_timer(char *arg) 1749/* same as disableapic, for compatibility */
1750static int __init setup_nolapic(char *arg)
1706{ 1751{
1707 local_apic_timer_disabled = 1; 1752 return setup_disableapic(arg);
1708 return 0;
1709} 1753}
1710early_param("nolapic_timer", parse_disable_lapic_timer); 1754early_param("nolapic", setup_nolapic);
1711 1755
1712static int __init parse_lapic_timer_c2_ok(char *arg) 1756static int __init parse_lapic_timer_c2_ok(char *arg)
1713{ 1757{
@@ -1716,15 +1760,40 @@ static int __init parse_lapic_timer_c2_ok(char *arg)
1716} 1760}
1717early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok); 1761early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok);
1718 1762
1763static int __init parse_disable_apic_timer(char *arg)
1764{
1765 disable_apic_timer = 1;
1766 return 0;
1767}
1768early_param("noapictimer", parse_disable_apic_timer);
1769
1770static int __init parse_nolapic_timer(char *arg)
1771{
1772 disable_apic_timer = 1;
1773 return 0;
1774}
1775early_param("nolapic_timer", parse_nolapic_timer);
1776
1719static int __init apic_set_verbosity(char *arg) 1777static int __init apic_set_verbosity(char *arg)
1720{ 1778{
1721 if (!arg) 1779 if (!arg) {
1780#ifdef CONFIG_X86_64
1781 skip_ioapic_setup = 0;
1782 ioapic_force = 1;
1783 return 0;
1784#endif
1722 return -EINVAL; 1785 return -EINVAL;
1786 }
1723 1787
1724 if (strcmp(arg, "debug") == 0) 1788 if (strcmp("debug", arg) == 0)
1725 apic_verbosity = APIC_DEBUG; 1789 apic_verbosity = APIC_DEBUG;
1726 else if (strcmp(arg, "verbose") == 0) 1790 else if (strcmp("verbose", arg) == 0)
1727 apic_verbosity = APIC_VERBOSE; 1791 apic_verbosity = APIC_VERBOSE;
1792 else {
1793 printk(KERN_WARNING "APIC Verbosity level %s not recognised"
1794 " use apic=verbose or apic=debug\n", arg);
1795 return -EINVAL;
1796 }
1728 1797
1729 return 0; 1798 return 0;
1730} 1799}
diff --git a/arch/x86/kernel/apic_64.c b/arch/x86/kernel/apic_64.c
index 57744f4a75b4..94ddb69ae15e 100644
--- a/arch/x86/kernel/apic_64.c
+++ b/arch/x86/kernel/apic_64.c
@@ -27,6 +27,7 @@
27#include <linux/clockchips.h> 27#include <linux/clockchips.h>
28#include <linux/acpi_pmtmr.h> 28#include <linux/acpi_pmtmr.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/dmar.h>
30 31
31#include <asm/atomic.h> 32#include <asm/atomic.h>
32#include <asm/smp.h> 33#include <asm/smp.h>
@@ -39,13 +40,20 @@
39#include <asm/proto.h> 40#include <asm/proto.h>
40#include <asm/timex.h> 41#include <asm/timex.h>
41#include <asm/apic.h> 42#include <asm/apic.h>
43#include <asm/i8259.h>
42 44
43#include <mach_ipi.h> 45#include <mach_ipi.h>
44#include <mach_apic.h> 46#include <mach_apic.h>
45 47
48/* Disable local APIC timer from the kernel commandline or via dmi quirk */
46static int disable_apic_timer __cpuinitdata; 49static int disable_apic_timer __cpuinitdata;
47static int apic_calibrate_pmtmr __initdata; 50static int apic_calibrate_pmtmr __initdata;
48int disable_apic; 51int disable_apic;
52int disable_x2apic;
53int x2apic;
54
55/* x2apic enabled before OS handover */
56int x2apic_preenabled;
49 57
50/* Local APIC timer works in C2 */ 58/* Local APIC timer works in C2 */
51int local_apic_timer_c2_ok; 59int local_apic_timer_c2_ok;
@@ -73,6 +81,9 @@ static void lapic_timer_setup(enum clock_event_mode mode,
73static void lapic_timer_broadcast(cpumask_t mask); 81static void lapic_timer_broadcast(cpumask_t mask);
74static void apic_pm_activate(void); 82static void apic_pm_activate(void);
75 83
84/*
85 * The local apic timer can be used for any function which is CPU local.
86 */
76static struct clock_event_device lapic_clockevent = { 87static struct clock_event_device lapic_clockevent = {
77 .name = "lapic", 88 .name = "lapic",
78 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT 89 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT
@@ -99,11 +110,15 @@ static inline int lapic_get_version(void)
99} 110}
100 111
101/* 112/*
102 * Check, if the APIC is integrated or a seperate chip 113 * Check, if the APIC is integrated or a separate chip
103 */ 114 */
104static inline int lapic_is_integrated(void) 115static inline int lapic_is_integrated(void)
105{ 116{
117#ifdef CONFIG_X86_64
106 return 1; 118 return 1;
119#else
120 return APIC_INTEGRATED(lapic_get_version());
121#endif
107} 122}
108 123
109/* 124/*
@@ -118,13 +133,18 @@ static int modern_apic(void)
118 return lapic_get_version() >= 0x14; 133 return lapic_get_version() >= 0x14;
119} 134}
120 135
121void apic_wait_icr_idle(void) 136/*
137 * Paravirt kernels also might be using these below ops. So we still
138 * use generic apic_read()/apic_write(), which might be pointing to different
139 * ops in PARAVIRT case.
140 */
141void xapic_wait_icr_idle(void)
122{ 142{
123 while (apic_read(APIC_ICR) & APIC_ICR_BUSY) 143 while (apic_read(APIC_ICR) & APIC_ICR_BUSY)
124 cpu_relax(); 144 cpu_relax();
125} 145}
126 146
127u32 safe_apic_wait_icr_idle(void) 147u32 safe_xapic_wait_icr_idle(void)
128{ 148{
129 u32 send_status; 149 u32 send_status;
130 int timeout; 150 int timeout;
@@ -140,6 +160,68 @@ u32 safe_apic_wait_icr_idle(void)
140 return send_status; 160 return send_status;
141} 161}
142 162
163void xapic_icr_write(u32 low, u32 id)
164{
165 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(id));
166 apic_write(APIC_ICR, low);
167}
168
169u64 xapic_icr_read(void)
170{
171 u32 icr1, icr2;
172
173 icr2 = apic_read(APIC_ICR2);
174 icr1 = apic_read(APIC_ICR);
175
176 return icr1 | ((u64)icr2 << 32);
177}
178
179static struct apic_ops xapic_ops = {
180 .read = native_apic_mem_read,
181 .write = native_apic_mem_write,
182 .icr_read = xapic_icr_read,
183 .icr_write = xapic_icr_write,
184 .wait_icr_idle = xapic_wait_icr_idle,
185 .safe_wait_icr_idle = safe_xapic_wait_icr_idle,
186};
187
188struct apic_ops __read_mostly *apic_ops = &xapic_ops;
189EXPORT_SYMBOL_GPL(apic_ops);
190
191static void x2apic_wait_icr_idle(void)
192{
193 /* no need to wait for icr idle in x2apic */
194 return;
195}
196
197static u32 safe_x2apic_wait_icr_idle(void)
198{
199 /* no need to wait for icr idle in x2apic */
200 return 0;
201}
202
203void x2apic_icr_write(u32 low, u32 id)
204{
205 wrmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), ((__u64) id) << 32 | low);
206}
207
208u64 x2apic_icr_read(void)
209{
210 unsigned long val;
211
212 rdmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), val);
213 return val;
214}
215
216static struct apic_ops x2apic_ops = {
217 .read = native_apic_msr_read,
218 .write = native_apic_msr_write,
219 .icr_read = x2apic_icr_read,
220 .icr_write = x2apic_icr_write,
221 .wait_icr_idle = x2apic_wait_icr_idle,
222 .safe_wait_icr_idle = safe_x2apic_wait_icr_idle,
223};
224
143/** 225/**
144 * enable_NMI_through_LVT0 - enable NMI through local vector table 0 226 * enable_NMI_through_LVT0 - enable NMI through local vector table 0
145 */ 227 */
@@ -149,6 +231,11 @@ void __cpuinit enable_NMI_through_LVT0(void)
149 231
150 /* unmask and set to NMI */ 232 /* unmask and set to NMI */
151 v = APIC_DM_NMI; 233 v = APIC_DM_NMI;
234
235 /* Level triggered for 82489DX (32bit mode) */
236 if (!lapic_is_integrated())
237 v |= APIC_LVT_LEVEL_TRIGGER;
238
152 apic_write(APIC_LVT0, v); 239 apic_write(APIC_LVT0, v);
153} 240}
154 241
@@ -157,14 +244,28 @@ void __cpuinit enable_NMI_through_LVT0(void)
157 */ 244 */
158int lapic_get_maxlvt(void) 245int lapic_get_maxlvt(void)
159{ 246{
160 unsigned int v, maxlvt; 247 unsigned int v;
161 248
162 v = apic_read(APIC_LVR); 249 v = apic_read(APIC_LVR);
163 maxlvt = GET_APIC_MAXLVT(v); 250 /*
164 return maxlvt; 251 * - we always have APIC integrated on 64bit mode
252 * - 82489DXs do not report # of LVT entries
253 */
254 return APIC_INTEGRATED(GET_APIC_VERSION(v)) ? GET_APIC_MAXLVT(v) : 2;
165} 255}
166 256
167/* 257/*
258 * Local APIC timer
259 */
260
261/* Clock divisor */
262#ifdef CONFG_X86_64
263#define APIC_DIVISOR 1
264#else
265#define APIC_DIVISOR 16
266#endif
267
268/*
168 * This function sets up the local APIC timer, with a timeout of 269 * This function sets up the local APIC timer, with a timeout of
169 * 'clocks' APIC bus clock. During calibration we actually call 270 * 'clocks' APIC bus clock. During calibration we actually call
170 * this function twice on the boot CPU, once with a bogus timeout 271 * this function twice on the boot CPU, once with a bogus timeout
@@ -174,7 +275,6 @@ int lapic_get_maxlvt(void)
174 * We do reads before writes even if unnecessary, to get around the 275 * We do reads before writes even if unnecessary, to get around the
175 * P5 APIC double write bug. 276 * P5 APIC double write bug.
176 */ 277 */
177
178static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen) 278static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
179{ 279{
180 unsigned int lvtt_value, tmp_value; 280 unsigned int lvtt_value, tmp_value;
@@ -182,6 +282,9 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
182 lvtt_value = LOCAL_TIMER_VECTOR; 282 lvtt_value = LOCAL_TIMER_VECTOR;
183 if (!oneshot) 283 if (!oneshot)
184 lvtt_value |= APIC_LVT_TIMER_PERIODIC; 284 lvtt_value |= APIC_LVT_TIMER_PERIODIC;
285 if (!lapic_is_integrated())
286 lvtt_value |= SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV);
287
185 if (!irqen) 288 if (!irqen)
186 lvtt_value |= APIC_LVT_MASKED; 289 lvtt_value |= APIC_LVT_MASKED;
187 290
@@ -191,12 +294,12 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
191 * Divide PICLK by 16 294 * Divide PICLK by 16
192 */ 295 */
193 tmp_value = apic_read(APIC_TDCR); 296 tmp_value = apic_read(APIC_TDCR);
194 apic_write(APIC_TDCR, (tmp_value 297 apic_write(APIC_TDCR,
195 & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) 298 (tmp_value & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) |
196 | APIC_TDR_DIV_16); 299 APIC_TDR_DIV_16);
197 300
198 if (!oneshot) 301 if (!oneshot)
199 apic_write(APIC_TMICT, clocks); 302 apic_write(APIC_TMICT, clocks / APIC_DIVISOR);
200} 303}
201 304
202/* 305/*
@@ -370,7 +473,7 @@ static int __init calibrate_APIC_clock(void)
370 lapic_clockevent.min_delta_ns = 473 lapic_clockevent.min_delta_ns =
371 clockevent_delta2ns(0xF, &lapic_clockevent); 474 clockevent_delta2ns(0xF, &lapic_clockevent);
372 475
373 calibration_result = result / HZ; 476 calibration_result = (result * APIC_DIVISOR) / HZ;
374 477
375 /* 478 /*
376 * Do a sanity check on the APIC calibration result 479 * Do a sanity check on the APIC calibration result
@@ -392,10 +495,10 @@ static int __init calibrate_APIC_clock(void)
392void __init setup_boot_APIC_clock(void) 495void __init setup_boot_APIC_clock(void)
393{ 496{
394 /* 497 /*
395 * The local apic timer can be disabled via the kernel commandline. 498 * The local apic timer can be disabled via the kernel
396 * Register the lapic timer as a dummy clock event source on SMP 499 * commandline or from the CPU detection code. Register the lapic
397 * systems, so the broadcast mechanism is used. On UP systems simply 500 * timer as a dummy clock event source on SMP systems, so the
398 * ignore it. 501 * broadcast mechanism is used. On UP systems simply ignore it.
399 */ 502 */
400 if (disable_apic_timer) { 503 if (disable_apic_timer) {
401 printk(KERN_INFO "Disabling APIC timer\n"); 504 printk(KERN_INFO "Disabling APIC timer\n");
@@ -407,7 +510,9 @@ void __init setup_boot_APIC_clock(void)
407 return; 510 return;
408 } 511 }
409 512
410 printk(KERN_INFO "Using local APIC timer interrupts.\n"); 513 apic_printk(APIC_VERBOSE, "Using local APIC timer interrupts.\n"
514 "calibrating APIC timer ...\n");
515
411 if (calibrate_APIC_clock()) { 516 if (calibrate_APIC_clock()) {
412 /* No broadcast on UP ! */ 517 /* No broadcast on UP ! */
413 if (num_possible_cpus() > 1) 518 if (num_possible_cpus() > 1)
@@ -426,6 +531,7 @@ void __init setup_boot_APIC_clock(void)
426 printk(KERN_WARNING "APIC timer registered as dummy," 531 printk(KERN_WARNING "APIC timer registered as dummy,"
427 " due to nmi_watchdog=%d!\n", nmi_watchdog); 532 " due to nmi_watchdog=%d!\n", nmi_watchdog);
428 533
534 /* Setup the lapic or request the broadcast */
429 setup_APIC_timer(); 535 setup_APIC_timer();
430} 536}
431 537
@@ -464,7 +570,11 @@ static void local_apic_timer_interrupt(void)
464 /* 570 /*
465 * the NMI deadlock-detector uses this. 571 * the NMI deadlock-detector uses this.
466 */ 572 */
573#ifdef CONFIG_X86_64
467 add_pda(apic_timer_irqs, 1); 574 add_pda(apic_timer_irqs, 1);
575#else
576 per_cpu(irq_stat, cpu).apic_timer_irqs++;
577#endif
468 578
469 evt->event_handler(evt); 579 evt->event_handler(evt);
470} 580}
@@ -495,6 +605,7 @@ void smp_apic_timer_interrupt(struct pt_regs *regs)
495 irq_enter(); 605 irq_enter();
496 local_apic_timer_interrupt(); 606 local_apic_timer_interrupt();
497 irq_exit(); 607 irq_exit();
608
498 set_irq_regs(old_regs); 609 set_irq_regs(old_regs);
499} 610}
500 611
@@ -548,6 +659,13 @@ void clear_local_APIC(void)
548 apic_write(APIC_LVTPC, v | APIC_LVT_MASKED); 659 apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
549 } 660 }
550 661
662 /* lets not touch this if we didn't frob it */
663#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(X86_MCE_INTEL)
664 if (maxlvt >= 5) {
665 v = apic_read(APIC_LVTTHMR);
666 apic_write(APIC_LVTTHMR, v | APIC_LVT_MASKED);
667 }
668#endif
551 /* 669 /*
552 * Clean APIC state for other OSs: 670 * Clean APIC state for other OSs:
553 */ 671 */
@@ -558,8 +676,14 @@ void clear_local_APIC(void)
558 apic_write(APIC_LVTERR, APIC_LVT_MASKED); 676 apic_write(APIC_LVTERR, APIC_LVT_MASKED);
559 if (maxlvt >= 4) 677 if (maxlvt >= 4)
560 apic_write(APIC_LVTPC, APIC_LVT_MASKED); 678 apic_write(APIC_LVTPC, APIC_LVT_MASKED);
561 apic_write(APIC_ESR, 0); 679
562 apic_read(APIC_ESR); 680 /* Integrated APIC (!82489DX) ? */
681 if (lapic_is_integrated()) {
682 if (maxlvt > 3)
683 /* Clear ESR due to Pentium errata 3AP and 11AP */
684 apic_write(APIC_ESR, 0);
685 apic_read(APIC_ESR);
686 }
563} 687}
564 688
565/** 689/**
@@ -578,8 +702,28 @@ void disable_local_APIC(void)
578 value = apic_read(APIC_SPIV); 702 value = apic_read(APIC_SPIV);
579 value &= ~APIC_SPIV_APIC_ENABLED; 703 value &= ~APIC_SPIV_APIC_ENABLED;
580 apic_write(APIC_SPIV, value); 704 apic_write(APIC_SPIV, value);
705
706#ifdef CONFIG_X86_32
707 /*
708 * When LAPIC was disabled by the BIOS and enabled by the kernel,
709 * restore the disabled state.
710 */
711 if (enabled_via_apicbase) {
712 unsigned int l, h;
713
714 rdmsr(MSR_IA32_APICBASE, l, h);
715 l &= ~MSR_IA32_APICBASE_ENABLE;
716 wrmsr(MSR_IA32_APICBASE, l, h);
717 }
718#endif
581} 719}
582 720
721/*
722 * If Linux enabled the LAPIC against the BIOS default disable it down before
723 * re-entering the BIOS on shutdown. Otherwise the BIOS may get confused and
724 * not power-off. Additionally clear all LVT entries before disable_local_APIC
725 * for the case where Linux didn't enable the LAPIC.
726 */
583void lapic_shutdown(void) 727void lapic_shutdown(void)
584{ 728{
585 unsigned long flags; 729 unsigned long flags;
@@ -589,7 +733,13 @@ void lapic_shutdown(void)
589 733
590 local_irq_save(flags); 734 local_irq_save(flags);
591 735
592 disable_local_APIC(); 736#ifdef CONFIG_X86_32
737 if (!enabled_via_apicbase)
738 clear_local_APIC();
739 else
740#endif
741 disable_local_APIC();
742
593 743
594 local_irq_restore(flags); 744 local_irq_restore(flags);
595} 745}
@@ -633,10 +783,10 @@ int __init verify_local_APIC(void)
633 /* 783 /*
634 * The ID register is read/write in a real APIC. 784 * The ID register is read/write in a real APIC.
635 */ 785 */
636 reg0 = read_apic_id(); 786 reg0 = apic_read(APIC_ID);
637 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0); 787 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0);
638 apic_write(APIC_ID, reg0 ^ APIC_ID_MASK); 788 apic_write(APIC_ID, reg0 ^ APIC_ID_MASK);
639 reg1 = read_apic_id(); 789 reg1 = apic_read(APIC_ID);
640 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1); 790 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1);
641 apic_write(APIC_ID, reg0); 791 apic_write(APIC_ID, reg0);
642 if (reg1 != (reg0 ^ APIC_ID_MASK)) 792 if (reg1 != (reg0 ^ APIC_ID_MASK))
@@ -660,8 +810,11 @@ int __init verify_local_APIC(void)
660 */ 810 */
661void __init sync_Arb_IDs(void) 811void __init sync_Arb_IDs(void)
662{ 812{
663 /* Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 */ 813 /*
664 if (modern_apic()) 814 * Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 And not
815 * needed on AMD.
816 */
817 if (modern_apic() || boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
665 return; 818 return;
666 819
667 /* 820 /*
@@ -670,8 +823,8 @@ void __init sync_Arb_IDs(void)
670 apic_wait_icr_idle(); 823 apic_wait_icr_idle();
671 824
672 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n"); 825 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n");
673 apic_write(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG 826 apic_write(APIC_ICR, APIC_DEST_ALLINC |
674 | APIC_DM_INIT); 827 APIC_INT_LEVELTRIG | APIC_DM_INIT);
675} 828}
676 829
677/* 830/*
@@ -688,8 +841,6 @@ void __init init_bsp_APIC(void)
688 if (smp_found_config || !cpu_has_apic) 841 if (smp_found_config || !cpu_has_apic)
689 return; 842 return;
690 843
691 value = apic_read(APIC_LVR);
692
693 /* 844 /*
694 * Do not trust the local APIC being empty at bootup. 845 * Do not trust the local APIC being empty at bootup.
695 */ 846 */
@@ -701,7 +852,15 @@ void __init init_bsp_APIC(void)
701 value = apic_read(APIC_SPIV); 852 value = apic_read(APIC_SPIV);
702 value &= ~APIC_VECTOR_MASK; 853 value &= ~APIC_VECTOR_MASK;
703 value |= APIC_SPIV_APIC_ENABLED; 854 value |= APIC_SPIV_APIC_ENABLED;
704 value |= APIC_SPIV_FOCUS_DISABLED; 855
856#ifdef CONFIG_X86_32
857 /* This bit is reserved on P4/Xeon and should be cleared */
858 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
859 (boot_cpu_data.x86 == 15))
860 value &= ~APIC_SPIV_FOCUS_DISABLED;
861 else
862#endif
863 value |= APIC_SPIV_FOCUS_DISABLED;
705 value |= SPURIOUS_APIC_VECTOR; 864 value |= SPURIOUS_APIC_VECTOR;
706 apic_write(APIC_SPIV, value); 865 apic_write(APIC_SPIV, value);
707 866
@@ -710,9 +869,50 @@ void __init init_bsp_APIC(void)
710 */ 869 */
711 apic_write(APIC_LVT0, APIC_DM_EXTINT); 870 apic_write(APIC_LVT0, APIC_DM_EXTINT);
712 value = APIC_DM_NMI; 871 value = APIC_DM_NMI;
872 if (!lapic_is_integrated()) /* 82489DX */
873 value |= APIC_LVT_LEVEL_TRIGGER;
713 apic_write(APIC_LVT1, value); 874 apic_write(APIC_LVT1, value);
714} 875}
715 876
877static void __cpuinit lapic_setup_esr(void)
878{
879 unsigned long oldvalue, value, maxlvt;
880 if (lapic_is_integrated() && !esr_disable) {
881 if (esr_disable) {
882 /*
883 * Something untraceable is creating bad interrupts on
884 * secondary quads ... for the moment, just leave the
885 * ESR disabled - we can't do anything useful with the
886 * errors anyway - mbligh
887 */
888 printk(KERN_INFO "Leaving ESR disabled.\n");
889 return;
890 }
891 /* !82489DX */
892 maxlvt = lapic_get_maxlvt();
893 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
894 apic_write(APIC_ESR, 0);
895 oldvalue = apic_read(APIC_ESR);
896
897 /* enables sending errors */
898 value = ERROR_APIC_VECTOR;
899 apic_write(APIC_LVTERR, value);
900 /*
901 * spec says clear errors after enabling vector.
902 */
903 if (maxlvt > 3)
904 apic_write(APIC_ESR, 0);
905 value = apic_read(APIC_ESR);
906 if (value != oldvalue)
907 apic_printk(APIC_VERBOSE, "ESR value before enabling "
908 "vector: 0x%08lx after: 0x%08lx\n",
909 oldvalue, value);
910 } else {
911 printk(KERN_INFO "No ESR for 82489DX.\n");
912 }
913}
914
915
716/** 916/**
717 * setup_local_APIC - setup the local APIC 917 * setup_local_APIC - setup the local APIC
718 */ 918 */
@@ -818,25 +1018,143 @@ void __cpuinit setup_local_APIC(void)
818 preempt_enable(); 1018 preempt_enable();
819} 1019}
820 1020
821static void __cpuinit lapic_setup_esr(void)
822{
823 unsigned maxlvt = lapic_get_maxlvt();
824
825 apic_write(APIC_LVTERR, ERROR_APIC_VECTOR);
826 /*
827 * spec says clear errors after enabling vector.
828 */
829 if (maxlvt > 3)
830 apic_write(APIC_ESR, 0);
831}
832
833void __cpuinit end_local_APIC_setup(void) 1021void __cpuinit end_local_APIC_setup(void)
834{ 1022{
835 lapic_setup_esr(); 1023 lapic_setup_esr();
1024
1025#ifdef CONFIG_X86_32
1026 {
1027 unsigned int value;
1028 /* Disable the local apic timer */
1029 value = apic_read(APIC_LVTT);
1030 value |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
1031 apic_write(APIC_LVTT, value);
1032 }
1033#endif
1034
836 setup_apic_nmi_watchdog(NULL); 1035 setup_apic_nmi_watchdog(NULL);
837 apic_pm_activate(); 1036 apic_pm_activate();
838} 1037}
839 1038
1039void check_x2apic(void)
1040{
1041 int msr, msr2;
1042
1043 rdmsr(MSR_IA32_APICBASE, msr, msr2);
1044
1045 if (msr & X2APIC_ENABLE) {
1046 printk("x2apic enabled by BIOS, switching to x2apic ops\n");
1047 x2apic_preenabled = x2apic = 1;
1048 apic_ops = &x2apic_ops;
1049 }
1050}
1051
1052void enable_x2apic(void)
1053{
1054 int msr, msr2;
1055
1056 rdmsr(MSR_IA32_APICBASE, msr, msr2);
1057 if (!(msr & X2APIC_ENABLE)) {
1058 printk("Enabling x2apic\n");
1059 wrmsr(MSR_IA32_APICBASE, msr | X2APIC_ENABLE, 0);
1060 }
1061}
1062
1063void enable_IR_x2apic(void)
1064{
1065#ifdef CONFIG_INTR_REMAP
1066 int ret;
1067 unsigned long flags;
1068
1069 if (!cpu_has_x2apic)
1070 return;
1071
1072 if (!x2apic_preenabled && disable_x2apic) {
1073 printk(KERN_INFO
1074 "Skipped enabling x2apic and Interrupt-remapping "
1075 "because of nox2apic\n");
1076 return;
1077 }
1078
1079 if (x2apic_preenabled && disable_x2apic)
1080 panic("Bios already enabled x2apic, can't enforce nox2apic");
1081
1082 if (!x2apic_preenabled && skip_ioapic_setup) {
1083 printk(KERN_INFO
1084 "Skipped enabling x2apic and Interrupt-remapping "
1085 "because of skipping io-apic setup\n");
1086 return;
1087 }
1088
1089 ret = dmar_table_init();
1090 if (ret) {
1091 printk(KERN_INFO
1092 "dmar_table_init() failed with %d:\n", ret);
1093
1094 if (x2apic_preenabled)
1095 panic("x2apic enabled by bios. But IR enabling failed");
1096 else
1097 printk(KERN_INFO
1098 "Not enabling x2apic,Intr-remapping\n");
1099 return;
1100 }
1101
1102 local_irq_save(flags);
1103 mask_8259A();
1104 save_mask_IO_APIC_setup();
1105
1106 ret = enable_intr_remapping(1);
1107
1108 if (ret && x2apic_preenabled) {
1109 local_irq_restore(flags);
1110 panic("x2apic enabled by bios. But IR enabling failed");
1111 }
1112
1113 if (ret)
1114 goto end;
1115
1116 if (!x2apic) {
1117 x2apic = 1;
1118 apic_ops = &x2apic_ops;
1119 enable_x2apic();
1120 }
1121end:
1122 if (ret)
1123 /*
1124 * IR enabling failed
1125 */
1126 restore_IO_APIC_setup();
1127 else
1128 reinit_intr_remapped_IO_APIC(x2apic_preenabled);
1129
1130 unmask_8259A();
1131 local_irq_restore(flags);
1132
1133 if (!ret) {
1134 if (!x2apic_preenabled)
1135 printk(KERN_INFO
1136 "Enabled x2apic and interrupt-remapping\n");
1137 else
1138 printk(KERN_INFO
1139 "Enabled Interrupt-remapping\n");
1140 } else
1141 printk(KERN_ERR
1142 "Failed to enable Interrupt-remapping and x2apic\n");
1143#else
1144 if (!cpu_has_x2apic)
1145 return;
1146
1147 if (x2apic_preenabled)
1148 panic("x2apic enabled prior OS handover,"
1149 " enable CONFIG_INTR_REMAP");
1150
1151 printk(KERN_INFO "Enable CONFIG_INTR_REMAP for enabling intr-remapping "
1152 " and x2apic\n");
1153#endif
1154
1155 return;
1156}
1157
840/* 1158/*
841 * Detect and enable local APICs on non-SMP boards. 1159 * Detect and enable local APICs on non-SMP boards.
842 * Original code written by Keir Fraser. 1160 * Original code written by Keir Fraser.
@@ -876,7 +1194,7 @@ void __init early_init_lapic_mapping(void)
876 * Fetch the APIC ID of the BSP in case we have a 1194 * Fetch the APIC ID of the BSP in case we have a
877 * default configuration (or the MP table is broken). 1195 * default configuration (or the MP table is broken).
878 */ 1196 */
879 boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); 1197 boot_cpu_physical_apicid = read_apic_id();
880} 1198}
881 1199
882/** 1200/**
@@ -884,6 +1202,11 @@ void __init early_init_lapic_mapping(void)
884 */ 1202 */
885void __init init_apic_mappings(void) 1203void __init init_apic_mappings(void)
886{ 1204{
1205 if (x2apic) {
1206 boot_cpu_physical_apicid = read_apic_id();
1207 return;
1208 }
1209
887 /* 1210 /*
888 * If no local APIC can be found then set up a fake all 1211 * If no local APIC can be found then set up a fake all
889 * zeroes page to simulate the local APIC and another 1212 * zeroes page to simulate the local APIC and another
@@ -903,13 +1226,15 @@ void __init init_apic_mappings(void)
903 * Fetch the APIC ID of the BSP in case we have a 1226 * Fetch the APIC ID of the BSP in case we have a
904 * default configuration (or the MP table is broken). 1227 * default configuration (or the MP table is broken).
905 */ 1228 */
906 boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); 1229 boot_cpu_physical_apicid = read_apic_id();
907} 1230}
908 1231
909/* 1232/*
910 * This initializes the IO-APIC and APIC hardware if this is 1233 * This initializes the IO-APIC and APIC hardware if this is
911 * a UP kernel. 1234 * a UP kernel.
912 */ 1235 */
1236int apic_version[MAX_APICS];
1237
913int __init APIC_init_uniprocessor(void) 1238int __init APIC_init_uniprocessor(void)
914{ 1239{
915 if (disable_apic) { 1240 if (disable_apic) {
@@ -922,6 +1247,9 @@ int __init APIC_init_uniprocessor(void)
922 return -1; 1247 return -1;
923 } 1248 }
924 1249
1250 enable_IR_x2apic();
1251 setup_apic_routing();
1252
925 verify_local_APIC(); 1253 verify_local_APIC();
926 1254
927 connect_bsp_APIC(); 1255 connect_bsp_APIC();
@@ -1008,17 +1336,57 @@ asmlinkage void smp_error_interrupt(void)
1008} 1336}
1009 1337
1010/** 1338/**
1011 * * connect_bsp_APIC - attach the APIC to the interrupt system 1339 * connect_bsp_APIC - attach the APIC to the interrupt system
1012 * */ 1340 */
1013void __init connect_bsp_APIC(void) 1341void __init connect_bsp_APIC(void)
1014{ 1342{
1343#ifdef CONFIG_X86_32
1344 if (pic_mode) {
1345 /*
1346 * Do not trust the local APIC being empty at bootup.
1347 */
1348 clear_local_APIC();
1349 /*
1350 * PIC mode, enable APIC mode in the IMCR, i.e. connect BSP's
1351 * local APIC to INT and NMI lines.
1352 */
1353 apic_printk(APIC_VERBOSE, "leaving PIC mode, "
1354 "enabling APIC mode.\n");
1355 outb(0x70, 0x22);
1356 outb(0x01, 0x23);
1357 }
1358#endif
1015 enable_apic_mode(); 1359 enable_apic_mode();
1016} 1360}
1017 1361
1362/**
1363 * disconnect_bsp_APIC - detach the APIC from the interrupt system
1364 * @virt_wire_setup: indicates, whether virtual wire mode is selected
1365 *
1366 * Virtual wire mode is necessary to deliver legacy interrupts even when the
1367 * APIC is disabled.
1368 */
1018void disconnect_bsp_APIC(int virt_wire_setup) 1369void disconnect_bsp_APIC(int virt_wire_setup)
1019{ 1370{
1371 unsigned int value;
1372
1373#ifdef CONFIG_X86_32
1374 if (pic_mode) {
1375 /*
1376 * Put the board back into PIC mode (has an effect only on
1377 * certain older boards). Note that APIC interrupts, including
1378 * IPIs, won't work beyond this point! The only exception are
1379 * INIT IPIs.
1380 */
1381 apic_printk(APIC_VERBOSE, "disabling APIC mode, "
1382 "entering PIC mode.\n");
1383 outb(0x70, 0x22);
1384 outb(0x00, 0x23);
1385 return;
1386 }
1387#endif
1388
1020 /* Go back to Virtual Wire compatibility mode */ 1389 /* Go back to Virtual Wire compatibility mode */
1021 unsigned long value;
1022 1390
1023 /* For the spurious interrupt use vector F, and enable it */ 1391 /* For the spurious interrupt use vector F, and enable it */
1024 value = apic_read(APIC_SPIV); 1392 value = apic_read(APIC_SPIV);
@@ -1044,7 +1412,10 @@ void disconnect_bsp_APIC(int virt_wire_setup)
1044 apic_write(APIC_LVT0, APIC_LVT_MASKED); 1412 apic_write(APIC_LVT0, APIC_LVT_MASKED);
1045 } 1413 }
1046 1414
1047 /* For LVT1 make it edge triggered, active high, nmi and enabled */ 1415 /*
1416 * For LVT1 make it edge triggered, active high,
1417 * nmi and enabled
1418 */
1048 value = apic_read(APIC_LVT1); 1419 value = apic_read(APIC_LVT1);
1049 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING | 1420 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
1050 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR | 1421 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
@@ -1059,9 +1430,20 @@ void __cpuinit generic_processor_info(int apicid, int version)
1059 int cpu; 1430 int cpu;
1060 cpumask_t tmp_map; 1431 cpumask_t tmp_map;
1061 1432
1433 /*
1434 * Validate version
1435 */
1436 if (version == 0x0) {
1437 printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! "
1438 "fixing up to 0x10. (tell your hw vendor)\n",
1439 version);
1440 version = 0x10;
1441 }
1442 apic_version[apicid] = version;
1443
1062 if (num_processors >= NR_CPUS) { 1444 if (num_processors >= NR_CPUS) {
1063 printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached." 1445 printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
1064 " Processor ignored.\n", NR_CPUS); 1446 " Processor ignored.\n", NR_CPUS);
1065 return; 1447 return;
1066 } 1448 }
1067 1449
@@ -1081,6 +1463,29 @@ void __cpuinit generic_processor_info(int apicid, int version)
1081 if (apicid > max_physical_apicid) 1463 if (apicid > max_physical_apicid)
1082 max_physical_apicid = apicid; 1464 max_physical_apicid = apicid;
1083 1465
1466#ifdef CONFIG_X86_32
1467 /*
1468 * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
1469 * but we need to work other dependencies like SMP_SUSPEND etc
1470 * before this can be done without some confusion.
1471 * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
1472 * - Ashok Raj <ashok.raj@intel.com>
1473 */
1474 if (max_physical_apicid >= 8) {
1475 switch (boot_cpu_data.x86_vendor) {
1476 case X86_VENDOR_INTEL:
1477 if (!APIC_XAPIC(version)) {
1478 def_to_bigsmp = 0;
1479 break;
1480 }
1481 /* If P4 and above fall through */
1482 case X86_VENDOR_AMD:
1483 def_to_bigsmp = 1;
1484 }
1485 }
1486#endif
1487
1488#if defined(CONFIG_X86_SMP) || defined(CONFIG_X86_64)
1084 /* are we being called early in kernel startup? */ 1489 /* are we being called early in kernel startup? */
1085 if (early_per_cpu_ptr(x86_cpu_to_apicid)) { 1490 if (early_per_cpu_ptr(x86_cpu_to_apicid)) {
1086 u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid); 1491 u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid);
@@ -1092,20 +1497,28 @@ void __cpuinit generic_processor_info(int apicid, int version)
1092 per_cpu(x86_cpu_to_apicid, cpu) = apicid; 1497 per_cpu(x86_cpu_to_apicid, cpu) = apicid;
1093 per_cpu(x86_bios_cpu_apicid, cpu) = apicid; 1498 per_cpu(x86_bios_cpu_apicid, cpu) = apicid;
1094 } 1499 }
1500#endif
1095 1501
1096 cpu_set(cpu, cpu_possible_map); 1502 cpu_set(cpu, cpu_possible_map);
1097 cpu_set(cpu, cpu_present_map); 1503 cpu_set(cpu, cpu_present_map);
1098} 1504}
1099 1505
1506int hard_smp_processor_id(void)
1507{
1508 return read_apic_id();
1509}
1510
1100/* 1511/*
1101 * Power management 1512 * Power management
1102 */ 1513 */
1103#ifdef CONFIG_PM 1514#ifdef CONFIG_PM
1104 1515
1105static struct { 1516static struct {
1106 /* 'active' is true if the local APIC was enabled by us and 1517 /*
1107 not the BIOS; this signifies that we are also responsible 1518 * 'active' is true if the local APIC was enabled by us and
1108 for disabling it before entering apm/acpi suspend */ 1519 * not the BIOS; this signifies that we are also responsible
1520 * for disabling it before entering apm/acpi suspend
1521 */
1109 int active; 1522 int active;
1110 /* r/w apic fields */ 1523 /* r/w apic fields */
1111 unsigned int apic_id; 1524 unsigned int apic_id;
@@ -1133,7 +1546,7 @@ static int lapic_suspend(struct sys_device *dev, pm_message_t state)
1133 1546
1134 maxlvt = lapic_get_maxlvt(); 1547 maxlvt = lapic_get_maxlvt();
1135 1548
1136 apic_pm_state.apic_id = read_apic_id(); 1549 apic_pm_state.apic_id = apic_read(APIC_ID);
1137 apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI); 1550 apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI);
1138 apic_pm_state.apic_ldr = apic_read(APIC_LDR); 1551 apic_pm_state.apic_ldr = apic_read(APIC_LDR);
1139 apic_pm_state.apic_dfr = apic_read(APIC_DFR); 1552 apic_pm_state.apic_dfr = apic_read(APIC_DFR);
@@ -1146,10 +1559,11 @@ static int lapic_suspend(struct sys_device *dev, pm_message_t state)
1146 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR); 1559 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
1147 apic_pm_state.apic_tmict = apic_read(APIC_TMICT); 1560 apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
1148 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR); 1561 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
1149#ifdef CONFIG_X86_MCE_INTEL 1562#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(CONFIG_X86_MCE_INTEL)
1150 if (maxlvt >= 5) 1563 if (maxlvt >= 5)
1151 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR); 1564 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
1152#endif 1565#endif
1566
1153 local_irq_save(flags); 1567 local_irq_save(flags);
1154 disable_local_APIC(); 1568 disable_local_APIC();
1155 local_irq_restore(flags); 1569 local_irq_restore(flags);
@@ -1168,10 +1582,25 @@ static int lapic_resume(struct sys_device *dev)
1168 maxlvt = lapic_get_maxlvt(); 1582 maxlvt = lapic_get_maxlvt();
1169 1583
1170 local_irq_save(flags); 1584 local_irq_save(flags);
1171 rdmsr(MSR_IA32_APICBASE, l, h); 1585
1172 l &= ~MSR_IA32_APICBASE_BASE; 1586#ifdef CONFIG_X86_64
1173 l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr; 1587 if (x2apic)
1174 wrmsr(MSR_IA32_APICBASE, l, h); 1588 enable_x2apic();
1589 else
1590#endif
1591 {
1592 /*
1593 * Make sure the APICBASE points to the right address
1594 *
1595 * FIXME! This will be wrong if we ever support suspend on
1596 * SMP! We'll need to do this as part of the CPU restore!
1597 */
1598 rdmsr(MSR_IA32_APICBASE, l, h);
1599 l &= ~MSR_IA32_APICBASE_BASE;
1600 l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
1601 wrmsr(MSR_IA32_APICBASE, l, h);
1602 }
1603
1175 apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED); 1604 apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED);
1176 apic_write(APIC_ID, apic_pm_state.apic_id); 1605 apic_write(APIC_ID, apic_pm_state.apic_id);
1177 apic_write(APIC_DFR, apic_pm_state.apic_dfr); 1606 apic_write(APIC_DFR, apic_pm_state.apic_dfr);
@@ -1180,7 +1609,7 @@ static int lapic_resume(struct sys_device *dev)
1180 apic_write(APIC_SPIV, apic_pm_state.apic_spiv); 1609 apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
1181 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0); 1610 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
1182 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1); 1611 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
1183#ifdef CONFIG_X86_MCE_INTEL 1612#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(CONFIG_X86_MCE_INTEL)
1184 if (maxlvt >= 5) 1613 if (maxlvt >= 5)
1185 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr); 1614 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
1186#endif 1615#endif
@@ -1194,10 +1623,17 @@ static int lapic_resume(struct sys_device *dev)
1194 apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr); 1623 apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr);
1195 apic_write(APIC_ESR, 0); 1624 apic_write(APIC_ESR, 0);
1196 apic_read(APIC_ESR); 1625 apic_read(APIC_ESR);
1626
1197 local_irq_restore(flags); 1627 local_irq_restore(flags);
1628
1198 return 0; 1629 return 0;
1199} 1630}
1200 1631
1632/*
1633 * This device has no shutdown method - fully functioning local APICs
1634 * are needed on every CPU up until machine_halt/restart/poweroff.
1635 */
1636
1201static struct sysdev_class lapic_sysclass = { 1637static struct sysdev_class lapic_sysclass = {
1202 .name = "lapic", 1638 .name = "lapic",
1203 .resume = lapic_resume, 1639 .resume = lapic_resume,
@@ -1311,31 +1747,19 @@ __cpuinit int apic_is_clustered_box(void)
1311 return (clusters > 2); 1747 return (clusters > 2);
1312} 1748}
1313 1749
1314/* 1750static __init int setup_nox2apic(char *str)
1315 * APIC command line parameters
1316 */
1317static int __init apic_set_verbosity(char *str)
1318{ 1751{
1319 if (str == NULL) { 1752 disable_x2apic = 1;
1320 skip_ioapic_setup = 0; 1753 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_X2APIC);
1321 ioapic_force = 1;
1322 return 0;
1323 }
1324 if (strcmp("debug", str) == 0)
1325 apic_verbosity = APIC_DEBUG;
1326 else if (strcmp("verbose", str) == 0)
1327 apic_verbosity = APIC_VERBOSE;
1328 else {
1329 printk(KERN_WARNING "APIC Verbosity level %s not recognised"
1330 " use apic=verbose or apic=debug\n", str);
1331 return -EINVAL;
1332 }
1333
1334 return 0; 1754 return 0;
1335} 1755}
1336early_param("apic", apic_set_verbosity); 1756early_param("nox2apic", setup_nox2apic);
1757
1337 1758
1338static __init int setup_disableapic(char *str) 1759/*
1760 * APIC command line parameters
1761 */
1762static int __init setup_disableapic(char *arg)
1339{ 1763{
1340 disable_apic = 1; 1764 disable_apic = 1;
1341 setup_clear_cpu_cap(X86_FEATURE_APIC); 1765 setup_clear_cpu_cap(X86_FEATURE_APIC);
@@ -1344,9 +1768,9 @@ static __init int setup_disableapic(char *str)
1344early_param("disableapic", setup_disableapic); 1768early_param("disableapic", setup_disableapic);
1345 1769
1346/* same as disableapic, for compatibility */ 1770/* same as disableapic, for compatibility */
1347static __init int setup_nolapic(char *str) 1771static int __init setup_nolapic(char *arg)
1348{ 1772{
1349 return setup_disableapic(str); 1773 return setup_disableapic(arg);
1350} 1774}
1351early_param("nolapic", setup_nolapic); 1775early_param("nolapic", setup_nolapic);
1352 1776
@@ -1357,14 +1781,19 @@ static int __init parse_lapic_timer_c2_ok(char *arg)
1357} 1781}
1358early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok); 1782early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok);
1359 1783
1360static __init int setup_noapictimer(char *str) 1784static int __init parse_disable_apic_timer(char *arg)
1361{ 1785{
1362 if (str[0] != ' ' && str[0] != 0)
1363 return 0;
1364 disable_apic_timer = 1; 1786 disable_apic_timer = 1;
1365 return 1; 1787 return 0;
1366} 1788}
1367__setup("noapictimer", setup_noapictimer); 1789early_param("noapictimer", parse_disable_apic_timer);
1790
1791static int __init parse_nolapic_timer(char *arg)
1792{
1793 disable_apic_timer = 1;
1794 return 0;
1795}
1796early_param("nolapic_timer", parse_nolapic_timer);
1368 1797
1369static __init int setup_apicpmtimer(char *s) 1798static __init int setup_apicpmtimer(char *s)
1370{ 1799{
@@ -1374,6 +1803,31 @@ static __init int setup_apicpmtimer(char *s)
1374} 1803}
1375__setup("apicpmtimer", setup_apicpmtimer); 1804__setup("apicpmtimer", setup_apicpmtimer);
1376 1805
1806static int __init apic_set_verbosity(char *arg)
1807{
1808 if (!arg) {
1809#ifdef CONFIG_X86_64
1810 skip_ioapic_setup = 0;
1811 ioapic_force = 1;
1812 return 0;
1813#endif
1814 return -EINVAL;
1815 }
1816
1817 if (strcmp("debug", arg) == 0)
1818 apic_verbosity = APIC_DEBUG;
1819 else if (strcmp("verbose", arg) == 0)
1820 apic_verbosity = APIC_VERBOSE;
1821 else {
1822 printk(KERN_WARNING "APIC Verbosity level %s not recognised"
1823 " use apic=verbose or apic=debug\n", arg);
1824 return -EINVAL;
1825 }
1826
1827 return 0;
1828}
1829early_param("apic", apic_set_verbosity);
1830
1377static int __init lapic_insert_resource(void) 1831static int __init lapic_insert_resource(void)
1378{ 1832{
1379 if (!apic_phys) 1833 if (!apic_phys)
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 732d1f4e10ee..5145a6e72bbb 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -228,7 +228,6 @@
228#include <linux/suspend.h> 228#include <linux/suspend.h>
229#include <linux/kthread.h> 229#include <linux/kthread.h>
230#include <linux/jiffies.h> 230#include <linux/jiffies.h>
231#include <linux/smp_lock.h>
232 231
233#include <asm/system.h> 232#include <asm/system.h>
234#include <asm/uaccess.h> 233#include <asm/uaccess.h>
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index aa89387006fe..505543a75a56 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -22,7 +22,7 @@
22 22
23#define __NO_STUBS 1 23#define __NO_STUBS 1
24#undef __SYSCALL 24#undef __SYSCALL
25#undef _ASM_X86_64_UNISTD_H_ 25#undef ASM_X86__UNISTD_64_H
26#define __SYSCALL(nr, sym) [nr] = 1, 26#define __SYSCALL(nr, sym) [nr] = 1,
27static char syscalls[] = { 27static char syscalls[] = {
28#include <asm/unistd.h> 28#include <asm/unistd.h>
diff --git a/arch/x86/kernel/bios_uv.c b/arch/x86/kernel/bios_uv.c
index c639bd55391c..fdd585f9c53d 100644
--- a/arch/x86/kernel/bios_uv.c
+++ b/arch/x86/kernel/bios_uv.c
@@ -25,11 +25,11 @@ x86_bios_strerror(long status)
25{ 25{
26 const char *str; 26 const char *str;
27 switch (status) { 27 switch (status) {
28 case 0: str = "Call completed without error"; break; 28 case 0: str = "Call completed without error"; break;
29 case -1: str = "Not implemented"; break; 29 case -1: str = "Not implemented"; break;
30 case -2: str = "Invalid argument"; break; 30 case -2: str = "Invalid argument"; break;
31 case -3: str = "Call completed with error"; break; 31 case -3: str = "Call completed with error"; break;
32 default: str = "Unknown BIOS status code"; break; 32 default: str = "Unknown BIOS status code"; break;
33 } 33 }
34 return str; 34 return str;
35} 35}
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index ee76eaad3001..7f0b45a5d788 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -3,22 +3,30 @@
3# 3#
4 4
5obj-y := intel_cacheinfo.o addon_cpuid_features.o 5obj-y := intel_cacheinfo.o addon_cpuid_features.o
6obj-y += proc.o feature_names.o 6obj-y += proc.o capflags.o powerflags.o common.o
7 7
8obj-$(CONFIG_X86_32) += common.o bugs.o 8obj-$(CONFIG_X86_32) += bugs.o cmpxchg.o
9obj-$(CONFIG_X86_64) += common_64.o bugs_64.o 9obj-$(CONFIG_X86_64) += bugs_64.o
10obj-$(CONFIG_X86_32) += amd.o 10
11obj-$(CONFIG_X86_64) += amd_64.o 11obj-$(CONFIG_CPU_SUP_INTEL) += intel.o
12obj-$(CONFIG_X86_32) += cyrix.o 12obj-$(CONFIG_CPU_SUP_AMD) += amd.o
13obj-$(CONFIG_X86_32) += centaur.o 13obj-$(CONFIG_CPU_SUP_CYRIX_32) += cyrix.o
14obj-$(CONFIG_X86_64) += centaur_64.o 14obj-$(CONFIG_CPU_SUP_CENTAUR_32) += centaur.o
15obj-$(CONFIG_X86_32) += transmeta.o 15obj-$(CONFIG_CPU_SUP_CENTAUR_64) += centaur_64.o
16obj-$(CONFIG_X86_32) += intel.o 16obj-$(CONFIG_CPU_SUP_TRANSMETA_32) += transmeta.o
17obj-$(CONFIG_X86_64) += intel_64.o 17obj-$(CONFIG_CPU_SUP_UMC_32) += umc.o
18obj-$(CONFIG_X86_32) += umc.o
19 18
20obj-$(CONFIG_X86_MCE) += mcheck/ 19obj-$(CONFIG_X86_MCE) += mcheck/
21obj-$(CONFIG_MTRR) += mtrr/ 20obj-$(CONFIG_MTRR) += mtrr/
22obj-$(CONFIG_CPU_FREQ) += cpufreq/ 21obj-$(CONFIG_CPU_FREQ) += cpufreq/
23 22
24obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o 23obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
24
25quiet_cmd_mkcapflags = MKCAP $@
26 cmd_mkcapflags = $(PERL) $(srctree)/$(src)/mkcapflags.pl $< $@
27
28cpufeature = $(src)/../../../../include/asm-x86/cpufeature.h
29
30targets += capflags.c
31$(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.pl FORCE
32 $(call if_changed,mkcapflags)
diff --git a/arch/x86/kernel/cpu/addon_cpuid_features.c b/arch/x86/kernel/cpu/addon_cpuid_features.c
index a6ef672adbba..0d9c993aa93e 100644
--- a/arch/x86/kernel/cpu/addon_cpuid_features.c
+++ b/arch/x86/kernel/cpu/addon_cpuid_features.c
@@ -7,6 +7,8 @@
7#include <asm/pat.h> 7#include <asm/pat.h>
8#include <asm/processor.h> 8#include <asm/processor.h>
9 9
10#include <mach_apic.h>
11
10struct cpuid_bit { 12struct cpuid_bit {
11 u16 feature; 13 u16 feature;
12 u8 reg; 14 u8 reg;
@@ -48,6 +50,92 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
48 } 50 }
49} 51}
50 52
53/* leaf 0xb SMT level */
54#define SMT_LEVEL 0
55
56/* leaf 0xb sub-leaf types */
57#define INVALID_TYPE 0
58#define SMT_TYPE 1
59#define CORE_TYPE 2
60
61#define LEAFB_SUBTYPE(ecx) (((ecx) >> 8) & 0xff)
62#define BITS_SHIFT_NEXT_LEVEL(eax) ((eax) & 0x1f)
63#define LEVEL_MAX_SIBLINGS(ebx) ((ebx) & 0xffff)
64
65/*
66 * Check for extended topology enumeration cpuid leaf 0xb and if it
67 * exists, use it for populating initial_apicid and cpu topology
68 * detection.
69 */
70void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
71{
72#ifdef CONFIG_SMP
73 unsigned int eax, ebx, ecx, edx, sub_index;
74 unsigned int ht_mask_width, core_plus_mask_width;
75 unsigned int core_select_mask, core_level_siblings;
76
77 if (c->cpuid_level < 0xb)
78 return;
79
80 cpuid_count(0xb, SMT_LEVEL, &eax, &ebx, &ecx, &edx);
81
82 /*
83 * check if the cpuid leaf 0xb is actually implemented.
84 */
85 if (ebx == 0 || (LEAFB_SUBTYPE(ecx) != SMT_TYPE))
86 return;
87
88 set_cpu_cap(c, X86_FEATURE_XTOPOLOGY);
89
90 /*
91 * initial apic id, which also represents 32-bit extended x2apic id.
92 */
93 c->initial_apicid = edx;
94
95 /*
96 * Populate HT related information from sub-leaf level 0.
97 */
98 core_level_siblings = smp_num_siblings = LEVEL_MAX_SIBLINGS(ebx);
99 core_plus_mask_width = ht_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
100
101 sub_index = 1;
102 do {
103 cpuid_count(0xb, sub_index, &eax, &ebx, &ecx, &edx);
104
105 /*
106 * Check for the Core type in the implemented sub leaves.
107 */
108 if (LEAFB_SUBTYPE(ecx) == CORE_TYPE) {
109 core_level_siblings = LEVEL_MAX_SIBLINGS(ebx);
110 core_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
111 break;
112 }
113
114 sub_index++;
115 } while (LEAFB_SUBTYPE(ecx) != INVALID_TYPE);
116
117 core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width;
118
119#ifdef CONFIG_X86_32
120 c->cpu_core_id = phys_pkg_id(c->initial_apicid, ht_mask_width)
121 & core_select_mask;
122 c->phys_proc_id = phys_pkg_id(c->initial_apicid, core_plus_mask_width);
123#else
124 c->cpu_core_id = phys_pkg_id(ht_mask_width) & core_select_mask;
125 c->phys_proc_id = phys_pkg_id(core_plus_mask_width);
126#endif
127 c->x86_max_cores = (core_level_siblings / smp_num_siblings);
128
129
130 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
131 c->phys_proc_id);
132 if (c->x86_max_cores > 1)
133 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
134 c->cpu_core_id);
135 return;
136#endif
137}
138
51#ifdef CONFIG_X86_PAT 139#ifdef CONFIG_X86_PAT
52void __cpuinit validate_pat_support(struct cpuinfo_x86 *c) 140void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
53{ 141{
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 18514ed26104..32e73520adf7 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -1,13 +1,22 @@
1#include <linux/init.h> 1#include <linux/init.h>
2#include <linux/bitops.h> 2#include <linux/bitops.h>
3#include <linux/mm.h> 3#include <linux/mm.h>
4
4#include <asm/io.h> 5#include <asm/io.h>
5#include <asm/processor.h> 6#include <asm/processor.h>
6#include <asm/apic.h> 7#include <asm/apic.h>
7 8
9#ifdef CONFIG_X86_64
10# include <asm/numa_64.h>
11# include <asm/mmconfig.h>
12# include <asm/cacheflush.h>
13#endif
14
8#include <mach_apic.h> 15#include <mach_apic.h>
16
9#include "cpu.h" 17#include "cpu.h"
10 18
19#ifdef CONFIG_X86_32
11/* 20/*
12 * B step AMD K6 before B 9730xxxx have hardware bugs that can cause 21 * B step AMD K6 before B 9730xxxx have hardware bugs that can cause
13 * misexecution of code under Linux. Owners of such processors should 22 * misexecution of code under Linux. Owners of such processors should
@@ -24,26 +33,273 @@
24extern void vide(void); 33extern void vide(void);
25__asm__(".align 4\nvide: ret"); 34__asm__(".align 4\nvide: ret");
26 35
27static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) 36static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
28{ 37{
29 if (cpuid_eax(0x80000000) >= 0x80000007) { 38/*
30 c->x86_power = cpuid_edx(0x80000007); 39 * General Systems BIOSen alias the cpu frequency registers
31 if (c->x86_power & (1<<8)) 40 * of the Elan at 0x000df000. Unfortuantly, one of the Linux
32 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 41 * drivers subsequently pokes it, and changes the CPU speed.
42 * Workaround : Remove the unneeded alias.
43 */
44#define CBAR (0xfffc) /* Configuration Base Address (32-bit) */
45#define CBAR_ENB (0x80000000)
46#define CBAR_KEY (0X000000CB)
47 if (c->x86_model == 9 || c->x86_model == 10) {
48 if (inl (CBAR) & CBAR_ENB)
49 outl (0 | CBAR_KEY, CBAR);
33 } 50 }
34
35 /* Set MTRR capability flag if appropriate */
36 if (c->x86_model == 13 || c->x86_model == 9 ||
37 (c->x86_model == 8 && c->x86_mask >= 8))
38 set_cpu_cap(c, X86_FEATURE_K6_MTRR);
39} 51}
40 52
41static void __cpuinit init_amd(struct cpuinfo_x86 *c) 53
54static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
42{ 55{
43 u32 l, h; 56 u32 l, h;
44 int mbytes = num_physpages >> (20-PAGE_SHIFT); 57 int mbytes = num_physpages >> (20-PAGE_SHIFT);
45 int r;
46 58
59 if (c->x86_model < 6) {
60 /* Based on AMD doc 20734R - June 2000 */
61 if (c->x86_model == 0) {
62 clear_cpu_cap(c, X86_FEATURE_APIC);
63 set_cpu_cap(c, X86_FEATURE_PGE);
64 }
65 return;
66 }
67
68 if (c->x86_model == 6 && c->x86_mask == 1) {
69 const int K6_BUG_LOOP = 1000000;
70 int n;
71 void (*f_vide)(void);
72 unsigned long d, d2;
73
74 printk(KERN_INFO "AMD K6 stepping B detected - ");
75
76 /*
77 * It looks like AMD fixed the 2.6.2 bug and improved indirect
78 * calls at the same time.
79 */
80
81 n = K6_BUG_LOOP;
82 f_vide = vide;
83 rdtscl(d);
84 while (n--)
85 f_vide();
86 rdtscl(d2);
87 d = d2-d;
88
89 if (d > 20*K6_BUG_LOOP)
90 printk("system stability may be impaired when more than 32 MB are used.\n");
91 else
92 printk("probably OK (after B9730xxxx).\n");
93 printk(KERN_INFO "Please see http://membres.lycos.fr/poulot/k6bug.html\n");
94 }
95
96 /* K6 with old style WHCR */
97 if (c->x86_model < 8 ||
98 (c->x86_model == 8 && c->x86_mask < 8)) {
99 /* We can only write allocate on the low 508Mb */
100 if (mbytes > 508)
101 mbytes = 508;
102
103 rdmsr(MSR_K6_WHCR, l, h);
104 if ((l&0x0000FFFF) == 0) {
105 unsigned long flags;
106 l = (1<<0)|((mbytes/4)<<1);
107 local_irq_save(flags);
108 wbinvd();
109 wrmsr(MSR_K6_WHCR, l, h);
110 local_irq_restore(flags);
111 printk(KERN_INFO "Enabling old style K6 write allocation for %d Mb\n",
112 mbytes);
113 }
114 return;
115 }
116
117 if ((c->x86_model == 8 && c->x86_mask > 7) ||
118 c->x86_model == 9 || c->x86_model == 13) {
119 /* The more serious chips .. */
120
121 if (mbytes > 4092)
122 mbytes = 4092;
123
124 rdmsr(MSR_K6_WHCR, l, h);
125 if ((l&0xFFFF0000) == 0) {
126 unsigned long flags;
127 l = ((mbytes>>2)<<22)|(1<<16);
128 local_irq_save(flags);
129 wbinvd();
130 wrmsr(MSR_K6_WHCR, l, h);
131 local_irq_restore(flags);
132 printk(KERN_INFO "Enabling new style K6 write allocation for %d Mb\n",
133 mbytes);
134 }
135
136 return;
137 }
138
139 if (c->x86_model == 10) {
140 /* AMD Geode LX is model 10 */
141 /* placeholder for any needed mods */
142 return;
143 }
144}
145
146static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
147{
148 u32 l, h;
149
150 /*
151 * Bit 15 of Athlon specific MSR 15, needs to be 0
152 * to enable SSE on Palomino/Morgan/Barton CPU's.
153 * If the BIOS didn't enable it already, enable it here.
154 */
155 if (c->x86_model >= 6 && c->x86_model <= 10) {
156 if (!cpu_has(c, X86_FEATURE_XMM)) {
157 printk(KERN_INFO "Enabling disabled K7/SSE Support.\n");
158 rdmsr(MSR_K7_HWCR, l, h);
159 l &= ~0x00008000;
160 wrmsr(MSR_K7_HWCR, l, h);
161 set_cpu_cap(c, X86_FEATURE_XMM);
162 }
163 }
164
165 /*
166 * It's been determined by AMD that Athlons since model 8 stepping 1
167 * are more robust with CLK_CTL set to 200xxxxx instead of 600xxxxx
168 * As per AMD technical note 27212 0.2
169 */
170 if ((c->x86_model == 8 && c->x86_mask >= 1) || (c->x86_model > 8)) {
171 rdmsr(MSR_K7_CLK_CTL, l, h);
172 if ((l & 0xfff00000) != 0x20000000) {
173 printk ("CPU: CLK_CTL MSR was %x. Reprogramming to %x\n", l,
174 ((l & 0x000fffff)|0x20000000));
175 wrmsr(MSR_K7_CLK_CTL, (l & 0x000fffff)|0x20000000, h);
176 }
177 }
178
179 set_cpu_cap(c, X86_FEATURE_K7);
180}
181#endif
182
183#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64)
184static int __cpuinit nearby_node(int apicid)
185{
186 int i, node;
187
188 for (i = apicid - 1; i >= 0; i--) {
189 node = apicid_to_node[i];
190 if (node != NUMA_NO_NODE && node_online(node))
191 return node;
192 }
193 for (i = apicid + 1; i < MAX_LOCAL_APIC; i++) {
194 node = apicid_to_node[i];
195 if (node != NUMA_NO_NODE && node_online(node))
196 return node;
197 }
198 return first_node(node_online_map); /* Shouldn't happen */
199}
200#endif
201
202/*
203 * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
204 * Assumes number of cores is a power of two.
205 */
206static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
207{
208#ifdef CONFIG_X86_HT
209 unsigned bits;
210
211 bits = c->x86_coreid_bits;
212
213 /* Low order bits define the core id (index of core in socket) */
214 c->cpu_core_id = c->initial_apicid & ((1 << bits)-1);
215 /* Convert the initial APIC ID into the socket ID */
216 c->phys_proc_id = c->initial_apicid >> bits;
217#endif
218}
219
220static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
221{
222#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64)
223 int cpu = smp_processor_id();
224 int node;
225 unsigned apicid = hard_smp_processor_id();
226
227 node = c->phys_proc_id;
228 if (apicid_to_node[apicid] != NUMA_NO_NODE)
229 node = apicid_to_node[apicid];
230 if (!node_online(node)) {
231 /* Two possibilities here:
232 - The CPU is missing memory and no node was created.
233 In that case try picking one from a nearby CPU
234 - The APIC IDs differ from the HyperTransport node IDs
235 which the K8 northbridge parsing fills in.
236 Assume they are all increased by a constant offset,
237 but in the same order as the HT nodeids.
238 If that doesn't result in a usable node fall back to the
239 path for the previous case. */
240
241 int ht_nodeid = c->initial_apicid;
242
243 if (ht_nodeid >= 0 &&
244 apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
245 node = apicid_to_node[ht_nodeid];
246 /* Pick a nearby node */
247 if (!node_online(node))
248 node = nearby_node(apicid);
249 }
250 numa_set_node(cpu, node);
251
252 printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
253#endif
254}
255
256static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
257{
258#ifdef CONFIG_X86_HT
259 unsigned bits, ecx;
260
261 /* Multi core CPU? */
262 if (c->extended_cpuid_level < 0x80000008)
263 return;
264
265 ecx = cpuid_ecx(0x80000008);
266
267 c->x86_max_cores = (ecx & 0xff) + 1;
268
269 /* CPU telling us the core id bits shift? */
270 bits = (ecx >> 12) & 0xF;
271
272 /* Otherwise recompute */
273 if (bits == 0) {
274 while ((1 << bits) < c->x86_max_cores)
275 bits++;
276 }
277
278 c->x86_coreid_bits = bits;
279#endif
280}
281
282static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
283{
284 early_init_amd_mc(c);
285
286 /* c->x86_power is 8000_0007 edx. Bit 8 is constant TSC */
287 if (c->x86_power & (1<<8))
288 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
289
290#ifdef CONFIG_X86_64
291 set_cpu_cap(c, X86_FEATURE_SYSCALL32);
292#else
293 /* Set MTRR capability flag if appropriate */
294 if (c->x86 == 5)
295 if (c->x86_model == 13 || c->x86_model == 9 ||
296 (c->x86_model == 8 && c->x86_mask >= 8))
297 set_cpu_cap(c, X86_FEATURE_K6_MTRR);
298#endif
299}
300
301static void __cpuinit init_amd(struct cpuinfo_x86 *c)
302{
47#ifdef CONFIG_SMP 303#ifdef CONFIG_SMP
48 unsigned long long value; 304 unsigned long long value;
49 305
@@ -54,7 +310,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
54 * Errata 63 for SH-B3 steppings 310 * Errata 63 for SH-B3 steppings
55 * Errata 122 for all steppings (F+ have it disabled by default) 311 * Errata 122 for all steppings (F+ have it disabled by default)
56 */ 312 */
57 if (c->x86 == 15) { 313 if (c->x86 == 0xf) {
58 rdmsrl(MSR_K7_HWCR, value); 314 rdmsrl(MSR_K7_HWCR, value);
59 value |= 1 << 6; 315 value |= 1 << 6;
60 wrmsrl(MSR_K7_HWCR, value); 316 wrmsrl(MSR_K7_HWCR, value);
@@ -64,209 +320,119 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
64 early_init_amd(c); 320 early_init_amd(c);
65 321
66 /* 322 /*
67 * FIXME: We should handle the K5 here. Set up the write
68 * range and also turn on MSR 83 bits 4 and 31 (write alloc,
69 * no bus pipeline)
70 */
71
72 /*
73 * Bit 31 in normal CPUID used for nonstandard 3DNow ID; 323 * Bit 31 in normal CPUID used for nonstandard 3DNow ID;
74 * 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway 324 * 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway
75 */ 325 */
76 clear_cpu_cap(c, 0*32+31); 326 clear_cpu_cap(c, 0*32+31);
77 327
78 r = get_model_name(c); 328#ifdef CONFIG_X86_64
329 /* On C+ stepping K8 rep microcode works well for copy/memset */
330 if (c->x86 == 0xf) {
331 u32 level;
79 332
80 switch (c->x86) { 333 level = cpuid_eax(1);
81 case 4: 334 if((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)
82 /* 335 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
83 * General Systems BIOSen alias the cpu frequency registers
84 * of the Elan at 0x000df000. Unfortuantly, one of the Linux
85 * drivers subsequently pokes it, and changes the CPU speed.
86 * Workaround : Remove the unneeded alias.
87 */
88#define CBAR (0xfffc) /* Configuration Base Address (32-bit) */
89#define CBAR_ENB (0x80000000)
90#define CBAR_KEY (0X000000CB)
91 if (c->x86_model == 9 || c->x86_model == 10) {
92 if (inl (CBAR) & CBAR_ENB)
93 outl (0 | CBAR_KEY, CBAR);
94 }
95 break;
96 case 5:
97 if (c->x86_model < 6) {
98 /* Based on AMD doc 20734R - June 2000 */
99 if (c->x86_model == 0) {
100 clear_cpu_cap(c, X86_FEATURE_APIC);
101 set_cpu_cap(c, X86_FEATURE_PGE);
102 }
103 break;
104 }
105
106 if (c->x86_model == 6 && c->x86_mask == 1) {
107 const int K6_BUG_LOOP = 1000000;
108 int n;
109 void (*f_vide)(void);
110 unsigned long d, d2;
111
112 printk(KERN_INFO "AMD K6 stepping B detected - ");
113
114 /*
115 * It looks like AMD fixed the 2.6.2 bug and improved indirect
116 * calls at the same time.
117 */
118
119 n = K6_BUG_LOOP;
120 f_vide = vide;
121 rdtscl(d);
122 while (n--)
123 f_vide();
124 rdtscl(d2);
125 d = d2-d;
126
127 if (d > 20*K6_BUG_LOOP)
128 printk("system stability may be impaired when more than 32 MB are used.\n");
129 else
130 printk("probably OK (after B9730xxxx).\n");
131 printk(KERN_INFO "Please see http://membres.lycos.fr/poulot/k6bug.html\n");
132 }
133
134 /* K6 with old style WHCR */
135 if (c->x86_model < 8 ||
136 (c->x86_model == 8 && c->x86_mask < 8)) {
137 /* We can only write allocate on the low 508Mb */
138 if (mbytes > 508)
139 mbytes = 508;
140
141 rdmsr(MSR_K6_WHCR, l, h);
142 if ((l&0x0000FFFF) == 0) {
143 unsigned long flags;
144 l = (1<<0)|((mbytes/4)<<1);
145 local_irq_save(flags);
146 wbinvd();
147 wrmsr(MSR_K6_WHCR, l, h);
148 local_irq_restore(flags);
149 printk(KERN_INFO "Enabling old style K6 write allocation for %d Mb\n",
150 mbytes);
151 }
152 break;
153 }
154
155 if ((c->x86_model == 8 && c->x86_mask > 7) ||
156 c->x86_model == 9 || c->x86_model == 13) {
157 /* The more serious chips .. */
158
159 if (mbytes > 4092)
160 mbytes = 4092;
161
162 rdmsr(MSR_K6_WHCR, l, h);
163 if ((l&0xFFFF0000) == 0) {
164 unsigned long flags;
165 l = ((mbytes>>2)<<22)|(1<<16);
166 local_irq_save(flags);
167 wbinvd();
168 wrmsr(MSR_K6_WHCR, l, h);
169 local_irq_restore(flags);
170 printk(KERN_INFO "Enabling new style K6 write allocation for %d Mb\n",
171 mbytes);
172 }
173
174 break;
175 }
176
177 if (c->x86_model == 10) {
178 /* AMD Geode LX is model 10 */
179 /* placeholder for any needed mods */
180 break;
181 }
182 break;
183 case 6: /* An Athlon/Duron */
184
185 /*
186 * Bit 15 of Athlon specific MSR 15, needs to be 0
187 * to enable SSE on Palomino/Morgan/Barton CPU's.
188 * If the BIOS didn't enable it already, enable it here.
189 */
190 if (c->x86_model >= 6 && c->x86_model <= 10) {
191 if (!cpu_has(c, X86_FEATURE_XMM)) {
192 printk(KERN_INFO "Enabling disabled K7/SSE Support.\n");
193 rdmsr(MSR_K7_HWCR, l, h);
194 l &= ~0x00008000;
195 wrmsr(MSR_K7_HWCR, l, h);
196 set_cpu_cap(c, X86_FEATURE_XMM);
197 }
198 }
199
200 /*
201 * It's been determined by AMD that Athlons since model 8 stepping 1
202 * are more robust with CLK_CTL set to 200xxxxx instead of 600xxxxx
203 * As per AMD technical note 27212 0.2
204 */
205 if ((c->x86_model == 8 && c->x86_mask >= 1) || (c->x86_model > 8)) {
206 rdmsr(MSR_K7_CLK_CTL, l, h);
207 if ((l & 0xfff00000) != 0x20000000) {
208 printk ("CPU: CLK_CTL MSR was %x. Reprogramming to %x\n", l,
209 ((l & 0x000fffff)|0x20000000));
210 wrmsr(MSR_K7_CLK_CTL, (l & 0x000fffff)|0x20000000, h);
211 }
212 }
213 break;
214 } 336 }
337 if (c->x86 == 0x10 || c->x86 == 0x11)
338 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
339#else
340
341 /*
342 * FIXME: We should handle the K5 here. Set up the write
343 * range and also turn on MSR 83 bits 4 and 31 (write alloc,
344 * no bus pipeline)
345 */
215 346
216 switch (c->x86) { 347 switch (c->x86) {
217 case 15: 348 case 4:
218 /* Use K8 tuning for Fam10h and Fam11h */ 349 init_amd_k5(c);
219 case 0x10:
220 case 0x11:
221 set_cpu_cap(c, X86_FEATURE_K8);
222 break; 350 break;
223 case 6: 351 case 5:
224 set_cpu_cap(c, X86_FEATURE_K7); 352 init_amd_k6(c);
353 break;
354 case 6: /* An Athlon/Duron */
355 init_amd_k7(c);
225 break; 356 break;
226 } 357 }
358
359 /* K6s reports MCEs but don't actually have all the MSRs */
360 if (c->x86 < 6)
361 clear_cpu_cap(c, X86_FEATURE_MCE);
362#endif
363
364 /* Enable workaround for FXSAVE leak */
227 if (c->x86 >= 6) 365 if (c->x86 >= 6)
228 set_cpu_cap(c, X86_FEATURE_FXSAVE_LEAK); 366 set_cpu_cap(c, X86_FEATURE_FXSAVE_LEAK);
229 367
230 display_cacheinfo(c); 368 if (!c->x86_model_id[0]) {
231 369 switch (c->x86) {
232 if (cpuid_eax(0x80000000) >= 0x80000008) 370 case 0xf:
233 c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1; 371 /* Should distinguish Models here, but this is only
372 a fallback anyways. */
373 strcpy(c->x86_model_id, "Hammer");
374 break;
375 }
376 }
234 377
235#ifdef CONFIG_X86_HT 378 display_cacheinfo(c);
236 /*
237 * On a AMD multi core setup the lower bits of the APIC id
238 * distinguish the cores.
239 */
240 if (c->x86_max_cores > 1) {
241 int cpu = smp_processor_id();
242 unsigned bits = (cpuid_ecx(0x80000008) >> 12) & 0xf;
243 379
244 if (bits == 0) { 380 /* Multi core CPU? */
245 while ((1 << bits) < c->x86_max_cores) 381 if (c->extended_cpuid_level >= 0x80000008) {
246 bits++; 382 amd_detect_cmp(c);
247 } 383 srat_detect_node(c);
248 c->cpu_core_id = c->phys_proc_id & ((1<<bits)-1);
249 c->phys_proc_id >>= bits;
250 printk(KERN_INFO "CPU %d(%d) -> Core %d\n",
251 cpu, c->x86_max_cores, c->cpu_core_id);
252 } 384 }
385
386#ifdef CONFIG_X86_32
387 detect_ht(c);
253#endif 388#endif
254 389
255 if (cpuid_eax(0x80000000) >= 0x80000006) { 390 if (c->extended_cpuid_level >= 0x80000006) {
256 if ((c->x86 == 0x10) && (cpuid_edx(0x80000006) & 0xf000)) 391 if ((c->x86 >= 0x0f) && (cpuid_edx(0x80000006) & 0xf000))
257 num_cache_leaves = 4; 392 num_cache_leaves = 4;
258 else 393 else
259 num_cache_leaves = 3; 394 num_cache_leaves = 3;
260 } 395 }
261 396
262 /* K6s reports MCEs but don't actually have all the MSRs */ 397 if (c->x86 >= 0xf && c->x86 <= 0x11)
263 if (c->x86 < 6) 398 set_cpu_cap(c, X86_FEATURE_K8);
264 clear_cpu_cap(c, X86_FEATURE_MCE);
265 399
266 if (cpu_has_xmm2) 400 if (cpu_has_xmm2) {
401 /* MFENCE stops RDTSC speculation */
267 set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC); 402 set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC);
403 }
404
405#ifdef CONFIG_X86_64
406 if (c->x86 == 0x10) {
407 /* do this for boot cpu */
408 if (c == &boot_cpu_data)
409 check_enable_amd_mmconf_dmi();
410
411 fam10h_check_enable_mmcfg();
412 }
413
414 if (c == &boot_cpu_data && c->x86 >= 0xf && c->x86 <= 0x11) {
415 unsigned long long tseg;
416
417 /*
418 * Split up direct mapping around the TSEG SMM area.
419 * Don't do it for gbpages because there seems very little
420 * benefit in doing so.
421 */
422 if (!rdmsrl_safe(MSR_K8_TSEG_ADDR, &tseg)) {
423 printk(KERN_DEBUG "tseg: %010llx\n", tseg);
424 if ((tseg>>PMD_SHIFT) <
425 (max_low_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) ||
426 ((tseg>>PMD_SHIFT) <
427 (max_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) &&
428 (tseg>>PMD_SHIFT) >= (1ULL<<(32 - PMD_SHIFT))))
429 set_memory_4k((unsigned long)__va(tseg), 1);
430 }
431 }
432#endif
268} 433}
269 434
435#ifdef CONFIG_X86_32
270static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c, unsigned int size) 436static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
271{ 437{
272 /* AMD errata T13 (order #21922) */ 438 /* AMD errata T13 (order #21922) */
@@ -279,10 +445,12 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c, unsigned int
279 } 445 }
280 return size; 446 return size;
281} 447}
448#endif
282 449
283static struct cpu_dev amd_cpu_dev __cpuinitdata = { 450static struct cpu_dev amd_cpu_dev __cpuinitdata = {
284 .c_vendor = "AMD", 451 .c_vendor = "AMD",
285 .c_ident = { "AuthenticAMD" }, 452 .c_ident = { "AuthenticAMD" },
453#ifdef CONFIG_X86_32
286 .c_models = { 454 .c_models = {
287 { .vendor = X86_VENDOR_AMD, .family = 4, .model_names = 455 { .vendor = X86_VENDOR_AMD, .family = 4, .model_names =
288 { 456 {
@@ -295,9 +463,11 @@ static struct cpu_dev amd_cpu_dev __cpuinitdata = {
295 } 463 }
296 }, 464 },
297 }, 465 },
466 .c_size_cache = amd_size_cache,
467#endif
298 .c_early_init = early_init_amd, 468 .c_early_init = early_init_amd,
299 .c_init = init_amd, 469 .c_init = init_amd,
300 .c_size_cache = amd_size_cache, 470 .c_x86_vendor = X86_VENDOR_AMD,
301}; 471};
302 472
303cpu_vendor_dev_register(X86_VENDOR_AMD, &amd_cpu_dev); 473cpu_dev_register(amd_cpu_dev);
diff --git a/arch/x86/kernel/cpu/amd_64.c b/arch/x86/kernel/cpu/amd_64.c
deleted file mode 100644
index d1692b2a41ff..000000000000
--- a/arch/x86/kernel/cpu/amd_64.c
+++ /dev/null
@@ -1,224 +0,0 @@
1#include <linux/init.h>
2#include <linux/mm.h>
3
4#include <asm/numa_64.h>
5#include <asm/mmconfig.h>
6#include <asm/cacheflush.h>
7
8#include <mach_apic.h>
9
10#include "cpu.h"
11
12int force_mwait __cpuinitdata;
13
14#ifdef CONFIG_NUMA
15static int __cpuinit nearby_node(int apicid)
16{
17 int i, node;
18
19 for (i = apicid - 1; i >= 0; i--) {
20 node = apicid_to_node[i];
21 if (node != NUMA_NO_NODE && node_online(node))
22 return node;
23 }
24 for (i = apicid + 1; i < MAX_LOCAL_APIC; i++) {
25 node = apicid_to_node[i];
26 if (node != NUMA_NO_NODE && node_online(node))
27 return node;
28 }
29 return first_node(node_online_map); /* Shouldn't happen */
30}
31#endif
32
33/*
34 * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
35 * Assumes number of cores is a power of two.
36 */
37static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
38{
39#ifdef CONFIG_SMP
40 unsigned bits;
41#ifdef CONFIG_NUMA
42 int cpu = smp_processor_id();
43 int node = 0;
44 unsigned apicid = hard_smp_processor_id();
45#endif
46 bits = c->x86_coreid_bits;
47
48 /* Low order bits define the core id (index of core in socket) */
49 c->cpu_core_id = c->initial_apicid & ((1 << bits)-1);
50 /* Convert the initial APIC ID into the socket ID */
51 c->phys_proc_id = c->initial_apicid >> bits;
52
53#ifdef CONFIG_NUMA
54 node = c->phys_proc_id;
55 if (apicid_to_node[apicid] != NUMA_NO_NODE)
56 node = apicid_to_node[apicid];
57 if (!node_online(node)) {
58 /* Two possibilities here:
59 - The CPU is missing memory and no node was created.
60 In that case try picking one from a nearby CPU
61 - The APIC IDs differ from the HyperTransport node IDs
62 which the K8 northbridge parsing fills in.
63 Assume they are all increased by a constant offset,
64 but in the same order as the HT nodeids.
65 If that doesn't result in a usable node fall back to the
66 path for the previous case. */
67
68 int ht_nodeid = c->initial_apicid;
69
70 if (ht_nodeid >= 0 &&
71 apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
72 node = apicid_to_node[ht_nodeid];
73 /* Pick a nearby node */
74 if (!node_online(node))
75 node = nearby_node(apicid);
76 }
77 numa_set_node(cpu, node);
78
79 printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
80#endif
81#endif
82}
83
84static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
85{
86#ifdef CONFIG_SMP
87 unsigned bits, ecx;
88
89 /* Multi core CPU? */
90 if (c->extended_cpuid_level < 0x80000008)
91 return;
92
93 ecx = cpuid_ecx(0x80000008);
94
95 c->x86_max_cores = (ecx & 0xff) + 1;
96
97 /* CPU telling us the core id bits shift? */
98 bits = (ecx >> 12) & 0xF;
99
100 /* Otherwise recompute */
101 if (bits == 0) {
102 while ((1 << bits) < c->x86_max_cores)
103 bits++;
104 }
105
106 c->x86_coreid_bits = bits;
107
108#endif
109}
110
111static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
112{
113 early_init_amd_mc(c);
114
115 /* c->x86_power is 8000_0007 edx. Bit 8 is constant TSC */
116 if (c->x86_power & (1<<8))
117 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
118
119 set_cpu_cap(c, X86_FEATURE_SYSCALL32);
120}
121
122static void __cpuinit init_amd(struct cpuinfo_x86 *c)
123{
124 unsigned level;
125
126#ifdef CONFIG_SMP
127 unsigned long value;
128
129 /*
130 * Disable TLB flush filter by setting HWCR.FFDIS on K8
131 * bit 6 of msr C001_0015
132 *
133 * Errata 63 for SH-B3 steppings
134 * Errata 122 for all steppings (F+ have it disabled by default)
135 */
136 if (c->x86 == 0xf) {
137 rdmsrl(MSR_K8_HWCR, value);
138 value |= 1 << 6;
139 wrmsrl(MSR_K8_HWCR, value);
140 }
141#endif
142
143 /* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
144 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
145 clear_cpu_cap(c, 0*32+31);
146
147 /* On C+ stepping K8 rep microcode works well for copy/memset */
148 if (c->x86 == 0xf) {
149 level = cpuid_eax(1);
150 if((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)
151 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
152 }
153 if (c->x86 == 0x10 || c->x86 == 0x11)
154 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
155
156 /* Enable workaround for FXSAVE leak */
157 if (c->x86 >= 6)
158 set_cpu_cap(c, X86_FEATURE_FXSAVE_LEAK);
159
160 level = get_model_name(c);
161 if (!level) {
162 switch (c->x86) {
163 case 0xf:
164 /* Should distinguish Models here, but this is only
165 a fallback anyways. */
166 strcpy(c->x86_model_id, "Hammer");
167 break;
168 }
169 }
170 display_cacheinfo(c);
171
172 /* Multi core CPU? */
173 if (c->extended_cpuid_level >= 0x80000008)
174 amd_detect_cmp(c);
175
176 if (c->extended_cpuid_level >= 0x80000006 &&
177 (cpuid_edx(0x80000006) & 0xf000))
178 num_cache_leaves = 4;
179 else
180 num_cache_leaves = 3;
181
182 if (c->x86 >= 0xf && c->x86 <= 0x11)
183 set_cpu_cap(c, X86_FEATURE_K8);
184
185 /* MFENCE stops RDTSC speculation */
186 set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC);
187
188 if (c->x86 == 0x10) {
189 /* do this for boot cpu */
190 if (c == &boot_cpu_data)
191 check_enable_amd_mmconf_dmi();
192
193 fam10h_check_enable_mmcfg();
194 }
195
196 if (c == &boot_cpu_data && c->x86 >= 0xf && c->x86 <= 0x11) {
197 unsigned long long tseg;
198
199 /*
200 * Split up direct mapping around the TSEG SMM area.
201 * Don't do it for gbpages because there seems very little
202 * benefit in doing so.
203 */
204 if (!rdmsrl_safe(MSR_K8_TSEG_ADDR, &tseg)) {
205 printk(KERN_DEBUG "tseg: %010llx\n", tseg);
206 if ((tseg>>PMD_SHIFT) <
207 (max_low_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) ||
208 ((tseg>>PMD_SHIFT) <
209 (max_pfn_mapped>>(PMD_SHIFT-PAGE_SHIFT)) &&
210 (tseg>>PMD_SHIFT) >= (1ULL<<(32 - PMD_SHIFT))))
211 set_memory_4k((unsigned long)__va(tseg), 1);
212 }
213 }
214}
215
216static struct cpu_dev amd_cpu_dev __cpuinitdata = {
217 .c_vendor = "AMD",
218 .c_ident = { "AuthenticAMD" },
219 .c_early_init = early_init_amd,
220 .c_init = init_amd,
221};
222
223cpu_vendor_dev_register(X86_VENDOR_AMD, &amd_cpu_dev);
224
diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index a0534c04d38a..89bfdd9cacc6 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -289,7 +289,6 @@ static void __cpuinit init_c3(struct cpuinfo_x86 *c)
289 if (c->x86_model >= 6 && c->x86_model < 9) 289 if (c->x86_model >= 6 && c->x86_model < 9)
290 set_cpu_cap(c, X86_FEATURE_3DNOW); 290 set_cpu_cap(c, X86_FEATURE_3DNOW);
291 291
292 get_model_name(c);
293 display_cacheinfo(c); 292 display_cacheinfo(c);
294} 293}
295 294
@@ -475,6 +474,7 @@ static struct cpu_dev centaur_cpu_dev __cpuinitdata = {
475 .c_early_init = early_init_centaur, 474 .c_early_init = early_init_centaur,
476 .c_init = init_centaur, 475 .c_init = init_centaur,
477 .c_size_cache = centaur_size_cache, 476 .c_size_cache = centaur_size_cache,
477 .c_x86_vendor = X86_VENDOR_CENTAUR,
478}; 478};
479 479
480cpu_vendor_dev_register(X86_VENDOR_CENTAUR, &centaur_cpu_dev); 480cpu_dev_register(centaur_cpu_dev);
diff --git a/arch/x86/kernel/cpu/centaur_64.c b/arch/x86/kernel/cpu/centaur_64.c
index 1d181c40e2e1..a1625f5a1e78 100644
--- a/arch/x86/kernel/cpu/centaur_64.c
+++ b/arch/x86/kernel/cpu/centaur_64.c
@@ -16,9 +16,10 @@ static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
16 16
17static void __cpuinit init_centaur(struct cpuinfo_x86 *c) 17static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
18{ 18{
19 early_init_centaur(c);
20
19 if (c->x86 == 0x6 && c->x86_model >= 0xf) { 21 if (c->x86 == 0x6 && c->x86_model >= 0xf) {
20 c->x86_cache_alignment = c->x86_clflush_size * 2; 22 c->x86_cache_alignment = c->x86_clflush_size * 2;
21 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
22 set_cpu_cap(c, X86_FEATURE_REP_GOOD); 23 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
23 } 24 }
24 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC); 25 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
@@ -29,7 +30,8 @@ static struct cpu_dev centaur_cpu_dev __cpuinitdata = {
29 .c_ident = { "CentaurHauls" }, 30 .c_ident = { "CentaurHauls" },
30 .c_early_init = early_init_centaur, 31 .c_early_init = early_init_centaur,
31 .c_init = init_centaur, 32 .c_init = init_centaur,
33 .c_x86_vendor = X86_VENDOR_CENTAUR,
32}; 34};
33 35
34cpu_vendor_dev_register(X86_VENDOR_CENTAUR, &centaur_cpu_dev); 36cpu_dev_register(centaur_cpu_dev);
35 37
diff --git a/arch/x86/kernel/cpu/cmpxchg.c b/arch/x86/kernel/cpu/cmpxchg.c
new file mode 100644
index 000000000000..2056ccf572cc
--- /dev/null
+++ b/arch/x86/kernel/cpu/cmpxchg.c
@@ -0,0 +1,72 @@
1/*
2 * cmpxchg*() fallbacks for CPU not supporting these instructions
3 */
4
5#include <linux/kernel.h>
6#include <linux/smp.h>
7#include <linux/module.h>
8
9#ifndef CONFIG_X86_CMPXCHG
10unsigned long cmpxchg_386_u8(volatile void *ptr, u8 old, u8 new)
11{
12 u8 prev;
13 unsigned long flags;
14
15 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
16 local_irq_save(flags);
17 prev = *(u8 *)ptr;
18 if (prev == old)
19 *(u8 *)ptr = new;
20 local_irq_restore(flags);
21 return prev;
22}
23EXPORT_SYMBOL(cmpxchg_386_u8);
24
25unsigned long cmpxchg_386_u16(volatile void *ptr, u16 old, u16 new)
26{
27 u16 prev;
28 unsigned long flags;
29
30 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
31 local_irq_save(flags);
32 prev = *(u16 *)ptr;
33 if (prev == old)
34 *(u16 *)ptr = new;
35 local_irq_restore(flags);
36 return prev;
37}
38EXPORT_SYMBOL(cmpxchg_386_u16);
39
40unsigned long cmpxchg_386_u32(volatile void *ptr, u32 old, u32 new)
41{
42 u32 prev;
43 unsigned long flags;
44
45 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
46 local_irq_save(flags);
47 prev = *(u32 *)ptr;
48 if (prev == old)
49 *(u32 *)ptr = new;
50 local_irq_restore(flags);
51 return prev;
52}
53EXPORT_SYMBOL(cmpxchg_386_u32);
54#endif
55
56#ifndef CONFIG_X86_CMPXCHG64
57unsigned long long cmpxchg_486_u64(volatile void *ptr, u64 old, u64 new)
58{
59 u64 prev;
60 unsigned long flags;
61
62 /* Poor man's cmpxchg8b for 386 and 486. Unsuitable for SMP */
63 local_irq_save(flags);
64 prev = *(u64 *)ptr;
65 if (prev == old)
66 *(u64 *)ptr = new;
67 local_irq_restore(flags);
68 return prev;
69}
70EXPORT_SYMBOL(cmpxchg_486_u64);
71#endif
72
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 4e456bd955bb..fb789dd9e691 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1,28 +1,62 @@
1#include <linux/init.h> 1#include <linux/init.h>
2#include <linux/kernel.h>
3#include <linux/sched.h>
2#include <linux/string.h> 4#include <linux/string.h>
5#include <linux/bootmem.h>
6#include <linux/bitops.h>
7#include <linux/module.h>
8#include <linux/kgdb.h>
9#include <linux/topology.h>
3#include <linux/delay.h> 10#include <linux/delay.h>
4#include <linux/smp.h> 11#include <linux/smp.h>
5#include <linux/module.h>
6#include <linux/percpu.h> 12#include <linux/percpu.h>
7#include <linux/bootmem.h>
8#include <asm/processor.h>
9#include <asm/i387.h> 13#include <asm/i387.h>
10#include <asm/msr.h> 14#include <asm/msr.h>
11#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/linkage.h>
12#include <asm/mmu_context.h> 17#include <asm/mmu_context.h>
13#include <asm/mtrr.h> 18#include <asm/mtrr.h>
14#include <asm/mce.h> 19#include <asm/mce.h>
15#include <asm/pat.h> 20#include <asm/pat.h>
16#include <asm/asm.h> 21#include <asm/asm.h>
22#include <asm/numa.h>
17#ifdef CONFIG_X86_LOCAL_APIC 23#ifdef CONFIG_X86_LOCAL_APIC
18#include <asm/mpspec.h> 24#include <asm/mpspec.h>
19#include <asm/apic.h> 25#include <asm/apic.h>
20#include <mach_apic.h> 26#include <mach_apic.h>
27#include <asm/genapic.h>
21#endif 28#endif
22 29
30#include <asm/pda.h>
31#include <asm/pgtable.h>
32#include <asm/processor.h>
33#include <asm/desc.h>
34#include <asm/atomic.h>
35#include <asm/proto.h>
36#include <asm/sections.h>
37#include <asm/setup.h>
38
23#include "cpu.h" 39#include "cpu.h"
24 40
41static struct cpu_dev *this_cpu __cpuinitdata;
42
43#ifdef CONFIG_X86_64
44/* We need valid kernel segments for data and code in long mode too
45 * IRET will check the segment types kkeil 2000/10/28
46 * Also sysret mandates a special GDT layout
47 */
48/* The TLS descriptors are currently at a different place compared to i386.
49 Hopefully nobody expects them at a fixed place (Wine?) */
25DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = { 50DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = {
51 [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } },
52 [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00af9b00 } } },
53 [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9300 } } },
54 [GDT_ENTRY_DEFAULT_USER32_CS] = { { { 0x0000ffff, 0x00cffb00 } } },
55 [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff300 } } },
56 [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00affb00 } } },
57} };
58#else
59DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
26 [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00cf9a00 } } }, 60 [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00cf9a00 } } },
27 [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9200 } } }, 61 [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9200 } } },
28 [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00cffa00 } } }, 62 [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00cffa00 } } },
@@ -56,17 +90,150 @@ DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = {
56 [GDT_ENTRY_ESPFIX_SS] = { { { 0x00000000, 0x00c09200 } } }, 90 [GDT_ENTRY_ESPFIX_SS] = { { { 0x00000000, 0x00c09200 } } },
57 [GDT_ENTRY_PERCPU] = { { { 0x00000000, 0x00000000 } } }, 91 [GDT_ENTRY_PERCPU] = { { { 0x00000000, 0x00000000 } } },
58} }; 92} };
93#endif
59EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); 94EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
60 95
61__u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata; 96#ifdef CONFIG_X86_32
62
63static int cachesize_override __cpuinitdata = -1; 97static int cachesize_override __cpuinitdata = -1;
64static int disable_x86_serial_nr __cpuinitdata = 1; 98static int disable_x86_serial_nr __cpuinitdata = 1;
65 99
66struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {}; 100static int __init cachesize_setup(char *str)
101{
102 get_option(&str, &cachesize_override);
103 return 1;
104}
105__setup("cachesize=", cachesize_setup);
106
107static int __init x86_fxsr_setup(char *s)
108{
109 setup_clear_cpu_cap(X86_FEATURE_FXSR);
110 setup_clear_cpu_cap(X86_FEATURE_XMM);
111 return 1;
112}
113__setup("nofxsr", x86_fxsr_setup);
114
115static int __init x86_sep_setup(char *s)
116{
117 setup_clear_cpu_cap(X86_FEATURE_SEP);
118 return 1;
119}
120__setup("nosep", x86_sep_setup);
121
122/* Standard macro to see if a specific flag is changeable */
123static inline int flag_is_changeable_p(u32 flag)
124{
125 u32 f1, f2;
126
127 asm("pushfl\n\t"
128 "pushfl\n\t"
129 "popl %0\n\t"
130 "movl %0,%1\n\t"
131 "xorl %2,%0\n\t"
132 "pushl %0\n\t"
133 "popfl\n\t"
134 "pushfl\n\t"
135 "popl %0\n\t"
136 "popfl\n\t"
137 : "=&r" (f1), "=&r" (f2)
138 : "ir" (flag));
139
140 return ((f1^f2) & flag) != 0;
141}
142
143/* Probe for the CPUID instruction */
144static int __cpuinit have_cpuid_p(void)
145{
146 return flag_is_changeable_p(X86_EFLAGS_ID);
147}
148
149static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
150{
151 if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr) {
152 /* Disable processor serial number */
153 unsigned long lo, hi;
154 rdmsr(MSR_IA32_BBL_CR_CTL, lo, hi);
155 lo |= 0x200000;
156 wrmsr(MSR_IA32_BBL_CR_CTL, lo, hi);
157 printk(KERN_NOTICE "CPU serial number disabled.\n");
158 clear_cpu_cap(c, X86_FEATURE_PN);
159
160 /* Disabling the serial number may affect the cpuid level */
161 c->cpuid_level = cpuid_eax(0);
162 }
163}
164
165static int __init x86_serial_nr_setup(char *s)
166{
167 disable_x86_serial_nr = 0;
168 return 1;
169}
170__setup("serialnumber", x86_serial_nr_setup);
171#else
172static inline int flag_is_changeable_p(u32 flag)
173{
174 return 1;
175}
176/* Probe for the CPUID instruction */
177static inline int have_cpuid_p(void)
178{
179 return 1;
180}
181static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
182{
183}
184#endif
185
186/*
187 * Naming convention should be: <Name> [(<Codename>)]
188 * This table only is used unless init_<vendor>() below doesn't set it;
189 * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used
190 *
191 */
192
193/* Look up CPU names by table lookup. */
194static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c)
195{
196 struct cpu_model_info *info;
197
198 if (c->x86_model >= 16)
199 return NULL; /* Range check */
200
201 if (!this_cpu)
202 return NULL;
203
204 info = this_cpu->c_models;
205
206 while (info && info->family) {
207 if (info->family == c->x86)
208 return info->model_names[c->x86_model];
209 info++;
210 }
211 return NULL; /* Not found */
212}
213
214__u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata;
215
216/* Current gdt points %fs at the "master" per-cpu area: after this,
217 * it's on the real one. */
218void switch_to_new_gdt(void)
219{
220 struct desc_ptr gdt_descr;
221
222 gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id());
223 gdt_descr.size = GDT_SIZE - 1;
224 load_gdt(&gdt_descr);
225#ifdef CONFIG_X86_32
226 asm("mov %0, %%fs" : : "r" (__KERNEL_PERCPU) : "memory");
227#endif
228}
229
230static struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
67 231
68static void __cpuinit default_init(struct cpuinfo_x86 *c) 232static void __cpuinit default_init(struct cpuinfo_x86 *c)
69{ 233{
234#ifdef CONFIG_X86_64
235 display_cacheinfo(c);
236#else
70 /* Not much we can do here... */ 237 /* Not much we can do here... */
71 /* Check if at least it has cpuid */ 238 /* Check if at least it has cpuid */
72 if (c->cpuid_level == -1) { 239 if (c->cpuid_level == -1) {
@@ -76,28 +243,22 @@ static void __cpuinit default_init(struct cpuinfo_x86 *c)
76 else if (c->x86 == 3) 243 else if (c->x86 == 3)
77 strcpy(c->x86_model_id, "386"); 244 strcpy(c->x86_model_id, "386");
78 } 245 }
246#endif
79} 247}
80 248
81static struct cpu_dev __cpuinitdata default_cpu = { 249static struct cpu_dev __cpuinitdata default_cpu = {
82 .c_init = default_init, 250 .c_init = default_init,
83 .c_vendor = "Unknown", 251 .c_vendor = "Unknown",
252 .c_x86_vendor = X86_VENDOR_UNKNOWN,
84}; 253};
85static struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
86 254
87static int __init cachesize_setup(char *str) 255static void __cpuinit get_model_name(struct cpuinfo_x86 *c)
88{
89 get_option(&str, &cachesize_override);
90 return 1;
91}
92__setup("cachesize=", cachesize_setup);
93
94int __cpuinit get_model_name(struct cpuinfo_x86 *c)
95{ 256{
96 unsigned int *v; 257 unsigned int *v;
97 char *p, *q; 258 char *p, *q;
98 259
99 if (cpuid_eax(0x80000000) < 0x80000004) 260 if (c->extended_cpuid_level < 0x80000004)
100 return 0; 261 return;
101 262
102 v = (unsigned int *) c->x86_model_id; 263 v = (unsigned int *) c->x86_model_id;
103 cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]); 264 cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
@@ -116,30 +277,34 @@ int __cpuinit get_model_name(struct cpuinfo_x86 *c)
116 while (q <= &c->x86_model_id[48]) 277 while (q <= &c->x86_model_id[48])
117 *q++ = '\0'; /* Zero-pad the rest */ 278 *q++ = '\0'; /* Zero-pad the rest */
118 } 279 }
119
120 return 1;
121} 280}
122 281
123
124void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c) 282void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
125{ 283{
126 unsigned int n, dummy, ecx, edx, l2size; 284 unsigned int n, dummy, ebx, ecx, edx, l2size;
127 285
128 n = cpuid_eax(0x80000000); 286 n = c->extended_cpuid_level;
129 287
130 if (n >= 0x80000005) { 288 if (n >= 0x80000005) {
131 cpuid(0x80000005, &dummy, &dummy, &ecx, &edx); 289 cpuid(0x80000005, &dummy, &ebx, &ecx, &edx);
132 printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), D cache %dK (%d bytes/line)\n", 290 printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), D cache %dK (%d bytes/line)\n",
133 edx>>24, edx&0xFF, ecx>>24, ecx&0xFF); 291 edx>>24, edx&0xFF, ecx>>24, ecx&0xFF);
134 c->x86_cache_size = (ecx>>24)+(edx>>24); 292 c->x86_cache_size = (ecx>>24) + (edx>>24);
293#ifdef CONFIG_X86_64
294 /* On K8 L1 TLB is inclusive, so don't count it */
295 c->x86_tlbsize = 0;
296#endif
135 } 297 }
136 298
137 if (n < 0x80000006) /* Some chips just has a large L1. */ 299 if (n < 0x80000006) /* Some chips just has a large L1. */
138 return; 300 return;
139 301
140 ecx = cpuid_ecx(0x80000006); 302 cpuid(0x80000006, &dummy, &ebx, &ecx, &edx);
141 l2size = ecx >> 16; 303 l2size = ecx >> 16;
142 304
305#ifdef CONFIG_X86_64
306 c->x86_tlbsize += ((ebx >> 16) & 0xfff) + (ebx & 0xfff);
307#else
143 /* do processor-specific cache resizing */ 308 /* do processor-specific cache resizing */
144 if (this_cpu->c_size_cache) 309 if (this_cpu->c_size_cache)
145 l2size = this_cpu->c_size_cache(c, l2size); 310 l2size = this_cpu->c_size_cache(c, l2size);
@@ -150,116 +315,106 @@ void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
150 315
151 if (l2size == 0) 316 if (l2size == 0)
152 return; /* Again, no L2 cache is possible */ 317 return; /* Again, no L2 cache is possible */
318#endif
153 319
154 c->x86_cache_size = l2size; 320 c->x86_cache_size = l2size;
155 321
156 printk(KERN_INFO "CPU: L2 Cache: %dK (%d bytes/line)\n", 322 printk(KERN_INFO "CPU: L2 Cache: %dK (%d bytes/line)\n",
157 l2size, ecx & 0xFF); 323 l2size, ecx & 0xFF);
158} 324}
159 325
160/* 326void __cpuinit detect_ht(struct cpuinfo_x86 *c)
161 * Naming convention should be: <Name> [(<Codename>)]
162 * This table only is used unless init_<vendor>() below doesn't set it;
163 * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used
164 *
165 */
166
167/* Look up CPU names by table lookup. */
168static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c)
169{ 327{
170 struct cpu_model_info *info; 328#ifdef CONFIG_X86_HT
329 u32 eax, ebx, ecx, edx;
330 int index_msb, core_bits;
171 331
172 if (c->x86_model >= 16) 332 if (!cpu_has(c, X86_FEATURE_HT))
173 return NULL; /* Range check */ 333 return;
174 334
175 if (!this_cpu) 335 if (cpu_has(c, X86_FEATURE_CMP_LEGACY))
176 return NULL; 336 goto out;
177 337
178 info = this_cpu->c_models; 338 if (cpu_has(c, X86_FEATURE_XTOPOLOGY))
339 return;
179 340
180 while (info && info->family) { 341 cpuid(1, &eax, &ebx, &ecx, &edx);
181 if (info->family == c->x86) 342
182 return info->model_names[c->x86_model]; 343 smp_num_siblings = (ebx & 0xff0000) >> 16;
183 info++; 344
345 if (smp_num_siblings == 1) {
346 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
347 } else if (smp_num_siblings > 1) {
348
349 if (smp_num_siblings > NR_CPUS) {
350 printk(KERN_WARNING "CPU: Unsupported number of siblings %d",
351 smp_num_siblings);
352 smp_num_siblings = 1;
353 return;
354 }
355
356 index_msb = get_count_order(smp_num_siblings);
357#ifdef CONFIG_X86_64
358 c->phys_proc_id = phys_pkg_id(index_msb);
359#else
360 c->phys_proc_id = phys_pkg_id(c->initial_apicid, index_msb);
361#endif
362
363 smp_num_siblings = smp_num_siblings / c->x86_max_cores;
364
365 index_msb = get_count_order(smp_num_siblings);
366
367 core_bits = get_count_order(c->x86_max_cores);
368
369#ifdef CONFIG_X86_64
370 c->cpu_core_id = phys_pkg_id(index_msb) &
371 ((1 << core_bits) - 1);
372#else
373 c->cpu_core_id = phys_pkg_id(c->initial_apicid, index_msb) &
374 ((1 << core_bits) - 1);
375#endif
184 } 376 }
185 return NULL; /* Not found */
186}
187 377
378out:
379 if ((c->x86_max_cores * smp_num_siblings) > 1) {
380 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
381 c->phys_proc_id);
382 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
383 c->cpu_core_id);
384 }
385#endif
386}
188 387
189static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c, int early) 388static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
190{ 389{
191 char *v = c->x86_vendor_id; 390 char *v = c->x86_vendor_id;
192 int i; 391 int i;
193 static int printed; 392 static int printed;
194 393
195 for (i = 0; i < X86_VENDOR_NUM; i++) { 394 for (i = 0; i < X86_VENDOR_NUM; i++) {
196 if (cpu_devs[i]) { 395 if (!cpu_devs[i])
197 if (!strcmp(v, cpu_devs[i]->c_ident[0]) || 396 break;
198 (cpu_devs[i]->c_ident[1] && 397
199 !strcmp(v, cpu_devs[i]->c_ident[1]))) { 398 if (!strcmp(v, cpu_devs[i]->c_ident[0]) ||
200 c->x86_vendor = i; 399 (cpu_devs[i]->c_ident[1] &&
201 if (!early) 400 !strcmp(v, cpu_devs[i]->c_ident[1]))) {
202 this_cpu = cpu_devs[i]; 401 this_cpu = cpu_devs[i];
203 return; 402 c->x86_vendor = this_cpu->c_x86_vendor;
204 } 403 return;
205 } 404 }
206 } 405 }
406
207 if (!printed) { 407 if (!printed) {
208 printed++; 408 printed++;
209 printk(KERN_ERR "CPU: Vendor unknown, using generic init.\n"); 409 printk(KERN_ERR "CPU: vendor_id '%s' unknown, using generic init.\n", v);
210 printk(KERN_ERR "CPU: Your system may be unstable.\n"); 410 printk(KERN_ERR "CPU: Your system may be unstable.\n");
211 } 411 }
412
212 c->x86_vendor = X86_VENDOR_UNKNOWN; 413 c->x86_vendor = X86_VENDOR_UNKNOWN;
213 this_cpu = &default_cpu; 414 this_cpu = &default_cpu;
214} 415}
215 416
216 417void __cpuinit cpu_detect(struct cpuinfo_x86 *c)
217static int __init x86_fxsr_setup(char *s)
218{
219 setup_clear_cpu_cap(X86_FEATURE_FXSR);
220 setup_clear_cpu_cap(X86_FEATURE_XMM);
221 return 1;
222}
223__setup("nofxsr", x86_fxsr_setup);
224
225
226static int __init x86_sep_setup(char *s)
227{
228 setup_clear_cpu_cap(X86_FEATURE_SEP);
229 return 1;
230}
231__setup("nosep", x86_sep_setup);
232
233
234/* Standard macro to see if a specific flag is changeable */
235static inline int flag_is_changeable_p(u32 flag)
236{
237 u32 f1, f2;
238
239 asm("pushfl\n\t"
240 "pushfl\n\t"
241 "popl %0\n\t"
242 "movl %0,%1\n\t"
243 "xorl %2,%0\n\t"
244 "pushl %0\n\t"
245 "popfl\n\t"
246 "pushfl\n\t"
247 "popl %0\n\t"
248 "popfl\n\t"
249 : "=&r" (f1), "=&r" (f2)
250 : "ir" (flag));
251
252 return ((f1^f2) & flag) != 0;
253}
254
255
256/* Probe for the CPUID instruction */
257static int __cpuinit have_cpuid_p(void)
258{
259 return flag_is_changeable_p(X86_EFLAGS_ID);
260}
261
262void __init cpu_detect(struct cpuinfo_x86 *c)
263{ 418{
264 /* Get vendor name */ 419 /* Get vendor name */
265 cpuid(0x00000000, (unsigned int *)&c->cpuid_level, 420 cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
@@ -268,50 +423,87 @@ void __init cpu_detect(struct cpuinfo_x86 *c)
268 (unsigned int *)&c->x86_vendor_id[4]); 423 (unsigned int *)&c->x86_vendor_id[4]);
269 424
270 c->x86 = 4; 425 c->x86 = 4;
426 /* Intel-defined flags: level 0x00000001 */
271 if (c->cpuid_level >= 0x00000001) { 427 if (c->cpuid_level >= 0x00000001) {
272 u32 junk, tfms, cap0, misc; 428 u32 junk, tfms, cap0, misc;
273 cpuid(0x00000001, &tfms, &misc, &junk, &cap0); 429 cpuid(0x00000001, &tfms, &misc, &junk, &cap0);
274 c->x86 = (tfms >> 8) & 15; 430 c->x86 = (tfms >> 8) & 0xf;
275 c->x86_model = (tfms >> 4) & 15; 431 c->x86_model = (tfms >> 4) & 0xf;
432 c->x86_mask = tfms & 0xf;
276 if (c->x86 == 0xf) 433 if (c->x86 == 0xf)
277 c->x86 += (tfms >> 20) & 0xff; 434 c->x86 += (tfms >> 20) & 0xff;
278 if (c->x86 >= 0x6) 435 if (c->x86 >= 0x6)
279 c->x86_model += ((tfms >> 16) & 0xF) << 4; 436 c->x86_model += ((tfms >> 16) & 0xf) << 4;
280 c->x86_mask = tfms & 15;
281 if (cap0 & (1<<19)) { 437 if (cap0 & (1<<19)) {
282 c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8;
283 c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; 438 c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
439 c->x86_cache_alignment = c->x86_clflush_size;
284 } 440 }
285 } 441 }
286} 442}
287static void __cpuinit early_get_cap(struct cpuinfo_x86 *c) 443
444static void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
288{ 445{
289 u32 tfms, xlvl; 446 u32 tfms, xlvl;
290 unsigned int ebx; 447 u32 ebx;
291 448
292 memset(&c->x86_capability, 0, sizeof c->x86_capability); 449 /* Intel-defined flags: level 0x00000001 */
293 if (have_cpuid_p()) { 450 if (c->cpuid_level >= 0x00000001) {
294 /* Intel-defined flags: level 0x00000001 */ 451 u32 capability, excap;
295 if (c->cpuid_level >= 0x00000001) { 452 cpuid(0x00000001, &tfms, &ebx, &excap, &capability);
296 u32 capability, excap; 453 c->x86_capability[0] = capability;
297 cpuid(0x00000001, &tfms, &ebx, &excap, &capability); 454 c->x86_capability[4] = excap;
298 c->x86_capability[0] = capability; 455 }
299 c->x86_capability[4] = excap;
300 }
301 456
302 /* AMD-defined flags: level 0x80000001 */ 457 /* AMD-defined flags: level 0x80000001 */
303 xlvl = cpuid_eax(0x80000000); 458 xlvl = cpuid_eax(0x80000000);
304 if ((xlvl & 0xffff0000) == 0x80000000) { 459 c->extended_cpuid_level = xlvl;
305 if (xlvl >= 0x80000001) { 460 if ((xlvl & 0xffff0000) == 0x80000000) {
306 c->x86_capability[1] = cpuid_edx(0x80000001); 461 if (xlvl >= 0x80000001) {
307 c->x86_capability[6] = cpuid_ecx(0x80000001); 462 c->x86_capability[1] = cpuid_edx(0x80000001);
308 } 463 c->x86_capability[6] = cpuid_ecx(0x80000001);
309 } 464 }
465 }
310 466
467#ifdef CONFIG_X86_64
468 if (c->extended_cpuid_level >= 0x80000008) {
469 u32 eax = cpuid_eax(0x80000008);
470
471 c->x86_virt_bits = (eax >> 8) & 0xff;
472 c->x86_phys_bits = eax & 0xff;
311 } 473 }
474#endif
475
476 if (c->extended_cpuid_level >= 0x80000007)
477 c->x86_power = cpuid_edx(0x80000007);
312 478
313} 479}
314 480
481static void __cpuinit identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
482{
483#ifdef CONFIG_X86_32
484 int i;
485
486 /*
487 * First of all, decide if this is a 486 or higher
488 * It's a 486 if we can modify the AC flag
489 */
490 if (flag_is_changeable_p(X86_EFLAGS_AC))
491 c->x86 = 4;
492 else
493 c->x86 = 3;
494
495 for (i = 0; i < X86_VENDOR_NUM; i++)
496 if (cpu_devs[i] && cpu_devs[i]->c_identify) {
497 c->x86_vendor_id[0] = 0;
498 cpu_devs[i]->c_identify(c);
499 if (c->x86_vendor_id[0]) {
500 get_cpu_vendor(c);
501 break;
502 }
503 }
504#endif
505}
506
315/* 507/*
316 * Do minimum CPU detection early. 508 * Do minimum CPU detection early.
317 * Fields really needed: vendor, cpuid_level, family, model, mask, 509 * Fields really needed: vendor, cpuid_level, family, model, mask,
@@ -321,25 +513,61 @@ static void __cpuinit early_get_cap(struct cpuinfo_x86 *c)
321 * WARNING: this function is only called on the BP. Don't add code here 513 * WARNING: this function is only called on the BP. Don't add code here
322 * that is supposed to run on all CPUs. 514 * that is supposed to run on all CPUs.
323 */ 515 */
324static void __init early_cpu_detect(void) 516static void __init early_identify_cpu(struct cpuinfo_x86 *c)
325{ 517{
326 struct cpuinfo_x86 *c = &boot_cpu_data; 518#ifdef CONFIG_X86_64
327 519 c->x86_clflush_size = 64;
328 c->x86_cache_alignment = 32; 520#else
329 c->x86_clflush_size = 32; 521 c->x86_clflush_size = 32;
522#endif
523 c->x86_cache_alignment = c->x86_clflush_size;
524
525 memset(&c->x86_capability, 0, sizeof c->x86_capability);
526 c->extended_cpuid_level = 0;
330 527
331 if (!have_cpuid_p()) 528 if (!have_cpuid_p())
529 identify_cpu_without_cpuid(c);
530
531 /* cyrix could have cpuid enabled via c_identify()*/
532 if (!have_cpuid_p())
332 return; 533 return;
333 534
334 cpu_detect(c); 535 cpu_detect(c);
335 536
336 get_cpu_vendor(c, 1); 537 get_cpu_vendor(c);
337 538
338 early_get_cap(c); 539 get_cpu_cap(c);
339 540
340 if (c->x86_vendor != X86_VENDOR_UNKNOWN && 541 if (this_cpu->c_early_init)
341 cpu_devs[c->x86_vendor]->c_early_init) 542 this_cpu->c_early_init(c);
342 cpu_devs[c->x86_vendor]->c_early_init(c); 543
544 validate_pat_support(c);
545}
546
547void __init early_cpu_init(void)
548{
549 struct cpu_dev **cdev;
550 int count = 0;
551
552 printk("KERNEL supported cpus:\n");
553 for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
554 struct cpu_dev *cpudev = *cdev;
555 unsigned int j;
556
557 if (count >= X86_VENDOR_NUM)
558 break;
559 cpu_devs[count] = cpudev;
560 count++;
561
562 for (j = 0; j < 2; j++) {
563 if (!cpudev->c_ident[j])
564 continue;
565 printk(" %s %s\n", cpudev->c_vendor,
566 cpudev->c_ident[j]);
567 }
568 }
569
570 early_identify_cpu(&boot_cpu_data);
343} 571}
344 572
345/* 573/*
@@ -357,86 +585,41 @@ static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
357 585
358static void __cpuinit generic_identify(struct cpuinfo_x86 *c) 586static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
359{ 587{
360 u32 tfms, xlvl; 588 c->extended_cpuid_level = 0;
361 unsigned int ebx;
362
363 if (have_cpuid_p()) {
364 /* Get vendor name */
365 cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
366 (unsigned int *)&c->x86_vendor_id[0],
367 (unsigned int *)&c->x86_vendor_id[8],
368 (unsigned int *)&c->x86_vendor_id[4]);
369
370 get_cpu_vendor(c, 0);
371 /* Initialize the standard set of capabilities */
372 /* Note that the vendor-specific code below might override */
373 /* Intel-defined flags: level 0x00000001 */
374 if (c->cpuid_level >= 0x00000001) {
375 u32 capability, excap;
376 cpuid(0x00000001, &tfms, &ebx, &excap, &capability);
377 c->x86_capability[0] = capability;
378 c->x86_capability[4] = excap;
379 c->x86 = (tfms >> 8) & 15;
380 c->x86_model = (tfms >> 4) & 15;
381 if (c->x86 == 0xf)
382 c->x86 += (tfms >> 20) & 0xff;
383 if (c->x86 >= 0x6)
384 c->x86_model += ((tfms >> 16) & 0xF) << 4;
385 c->x86_mask = tfms & 15;
386 c->initial_apicid = (ebx >> 24) & 0xFF;
387#ifdef CONFIG_X86_HT
388 c->apicid = phys_pkg_id(c->initial_apicid, 0);
389 c->phys_proc_id = c->initial_apicid;
390#else
391 c->apicid = c->initial_apicid;
392#endif
393 if (test_cpu_cap(c, X86_FEATURE_CLFLSH))
394 c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
395 } else {
396 /* Have CPUID level 0 only - unheard of */
397 c->x86 = 4;
398 }
399 589
400 /* AMD-defined flags: level 0x80000001 */ 590 if (!have_cpuid_p())
401 xlvl = cpuid_eax(0x80000000); 591 identify_cpu_without_cpuid(c);
402 if ((xlvl & 0xffff0000) == 0x80000000) {
403 if (xlvl >= 0x80000001) {
404 c->x86_capability[1] = cpuid_edx(0x80000001);
405 c->x86_capability[6] = cpuid_ecx(0x80000001);
406 }
407 if (xlvl >= 0x80000004)
408 get_model_name(c); /* Default name */
409 }
410 592
411 init_scattered_cpuid_features(c); 593 /* cyrix could have cpuid enabled via c_identify()*/
412 detect_nopl(c); 594 if (!have_cpuid_p())
413 } 595 return;
414}
415 596
416static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) 597 cpu_detect(c);
417{
418 if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr) {
419 /* Disable processor serial number */
420 unsigned long lo, hi;
421 rdmsr(MSR_IA32_BBL_CR_CTL, lo, hi);
422 lo |= 0x200000;
423 wrmsr(MSR_IA32_BBL_CR_CTL, lo, hi);
424 printk(KERN_NOTICE "CPU serial number disabled.\n");
425 clear_cpu_cap(c, X86_FEATURE_PN);
426 598
427 /* Disabling the serial number may affect the cpuid level */ 599 get_cpu_vendor(c);
428 c->cpuid_level = cpuid_eax(0);
429 }
430}
431 600
432static int __init x86_serial_nr_setup(char *s) 601 get_cpu_cap(c);
433{
434 disable_x86_serial_nr = 0;
435 return 1;
436}
437__setup("serialnumber", x86_serial_nr_setup);
438 602
603 if (c->cpuid_level >= 0x00000001) {
604 c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xFF;
605#ifdef CONFIG_X86_32
606# ifdef CONFIG_X86_HT
607 c->apicid = phys_pkg_id(c->initial_apicid, 0);
608# else
609 c->apicid = c->initial_apicid;
610# endif
611#endif
439 612
613#ifdef CONFIG_X86_HT
614 c->phys_proc_id = c->initial_apicid;
615#endif
616 }
617
618 get_model_name(c); /* Default name */
619
620 init_scattered_cpuid_features(c);
621 detect_nopl(c);
622}
440 623
441/* 624/*
442 * This does the hard work of actually picking apart the CPU stuff... 625 * This does the hard work of actually picking apart the CPU stuff...
@@ -448,30 +631,29 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
448 c->loops_per_jiffy = loops_per_jiffy; 631 c->loops_per_jiffy = loops_per_jiffy;
449 c->x86_cache_size = -1; 632 c->x86_cache_size = -1;
450 c->x86_vendor = X86_VENDOR_UNKNOWN; 633 c->x86_vendor = X86_VENDOR_UNKNOWN;
451 c->cpuid_level = -1; /* CPUID not detected */
452 c->x86_model = c->x86_mask = 0; /* So far unknown... */ 634 c->x86_model = c->x86_mask = 0; /* So far unknown... */
453 c->x86_vendor_id[0] = '\0'; /* Unset */ 635 c->x86_vendor_id[0] = '\0'; /* Unset */
454 c->x86_model_id[0] = '\0'; /* Unset */ 636 c->x86_model_id[0] = '\0'; /* Unset */
455 c->x86_max_cores = 1; 637 c->x86_max_cores = 1;
638 c->x86_coreid_bits = 0;
639#ifdef CONFIG_X86_64
640 c->x86_clflush_size = 64;
641#else
642 c->cpuid_level = -1; /* CPUID not detected */
456 c->x86_clflush_size = 32; 643 c->x86_clflush_size = 32;
644#endif
645 c->x86_cache_alignment = c->x86_clflush_size;
457 memset(&c->x86_capability, 0, sizeof c->x86_capability); 646 memset(&c->x86_capability, 0, sizeof c->x86_capability);
458 647
459 if (!have_cpuid_p()) {
460 /*
461 * First of all, decide if this is a 486 or higher
462 * It's a 486 if we can modify the AC flag
463 */
464 if (flag_is_changeable_p(X86_EFLAGS_AC))
465 c->x86 = 4;
466 else
467 c->x86 = 3;
468 }
469
470 generic_identify(c); 648 generic_identify(c);
471 649
472 if (this_cpu->c_identify) 650 if (this_cpu->c_identify)
473 this_cpu->c_identify(c); 651 this_cpu->c_identify(c);
474 652
653#ifdef CONFIG_X86_64
654 c->apicid = phys_pkg_id(0);
655#endif
656
475 /* 657 /*
476 * Vendor-specific initialization. In this section we 658 * Vendor-specific initialization. In this section we
477 * canonicalize the feature flags, meaning if there are 659 * canonicalize the feature flags, meaning if there are
@@ -505,6 +687,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
505 c->x86, c->x86_model); 687 c->x86, c->x86_model);
506 } 688 }
507 689
690#ifdef CONFIG_X86_64
691 detect_ht(c);
692#endif
693
508 /* 694 /*
509 * On SMP, boot_cpu_data holds the common feature set between 695 * On SMP, boot_cpu_data holds the common feature set between
510 * all CPUs; so make sure that we indicate which features are 696 * all CPUs; so make sure that we indicate which features are
@@ -513,7 +699,7 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
513 */ 699 */
514 if (c != &boot_cpu_data) { 700 if (c != &boot_cpu_data) {
515 /* AND the already accumulated flags with these */ 701 /* AND the already accumulated flags with these */
516 for (i = 0 ; i < NCAPINTS ; i++) 702 for (i = 0; i < NCAPINTS; i++)
517 boot_cpu_data.x86_capability[i] &= c->x86_capability[i]; 703 boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
518 } 704 }
519 705
@@ -521,72 +707,79 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
521 for (i = 0; i < NCAPINTS; i++) 707 for (i = 0; i < NCAPINTS; i++)
522 c->x86_capability[i] &= ~cleared_cpu_caps[i]; 708 c->x86_capability[i] &= ~cleared_cpu_caps[i];
523 709
710#ifdef CONFIG_X86_MCE
524 /* Init Machine Check Exception if available. */ 711 /* Init Machine Check Exception if available. */
525 mcheck_init(c); 712 mcheck_init(c);
713#endif
526 714
527 select_idle_routine(c); 715 select_idle_routine(c);
716
717#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64)
718 numa_add_cpu(smp_processor_id());
719#endif
528} 720}
529 721
530void __init identify_boot_cpu(void) 722void __init identify_boot_cpu(void)
531{ 723{
532 identify_cpu(&boot_cpu_data); 724 identify_cpu(&boot_cpu_data);
725#ifdef CONFIG_X86_32
533 sysenter_setup(); 726 sysenter_setup();
534 enable_sep_cpu(); 727 enable_sep_cpu();
728#endif
535} 729}
536 730
537void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c) 731void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
538{ 732{
539 BUG_ON(c == &boot_cpu_data); 733 BUG_ON(c == &boot_cpu_data);
540 identify_cpu(c); 734 identify_cpu(c);
735#ifdef CONFIG_X86_32
541 enable_sep_cpu(); 736 enable_sep_cpu();
737#endif
542 mtrr_ap_init(); 738 mtrr_ap_init();
543} 739}
544 740
545#ifdef CONFIG_X86_HT 741struct msr_range {
546void __cpuinit detect_ht(struct cpuinfo_x86 *c) 742 unsigned min;
547{ 743 unsigned max;
548 u32 eax, ebx, ecx, edx; 744};
549 int index_msb, core_bits;
550
551 cpuid(1, &eax, &ebx, &ecx, &edx);
552
553 if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
554 return;
555
556 smp_num_siblings = (ebx & 0xff0000) >> 16;
557 745
558 if (smp_num_siblings == 1) { 746static struct msr_range msr_range_array[] __cpuinitdata = {
559 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); 747 { 0x00000000, 0x00000418},
560 } else if (smp_num_siblings > 1) { 748 { 0xc0000000, 0xc000040b},
749 { 0xc0010000, 0xc0010142},
750 { 0xc0011000, 0xc001103b},
751};
561 752
562 if (smp_num_siblings > NR_CPUS) { 753static void __cpuinit print_cpu_msr(void)
563 printk(KERN_WARNING "CPU: Unsupported number of the " 754{
564 "siblings %d", smp_num_siblings); 755 unsigned index;
565 smp_num_siblings = 1; 756 u64 val;
566 return; 757 int i;
758 unsigned index_min, index_max;
759
760 for (i = 0; i < ARRAY_SIZE(msr_range_array); i++) {
761 index_min = msr_range_array[i].min;
762 index_max = msr_range_array[i].max;
763 for (index = index_min; index < index_max; index++) {
764 if (rdmsrl_amd_safe(index, &val))
765 continue;
766 printk(KERN_INFO " MSR%08x: %016llx\n", index, val);
567 } 767 }
768 }
769}
568 770
569 index_msb = get_count_order(smp_num_siblings); 771static int show_msr __cpuinitdata;
570 c->phys_proc_id = phys_pkg_id(c->initial_apicid, index_msb); 772static __init int setup_show_msr(char *arg)
571 773{
572 printk(KERN_INFO "CPU: Physical Processor ID: %d\n", 774 int num;
573 c->phys_proc_id);
574
575 smp_num_siblings = smp_num_siblings / c->x86_max_cores;
576
577 index_msb = get_count_order(smp_num_siblings) ;
578 775
579 core_bits = get_count_order(c->x86_max_cores); 776 get_option(&arg, &num);
580 777
581 c->cpu_core_id = phys_pkg_id(c->initial_apicid, index_msb) & 778 if (num > 0)
582 ((1 << core_bits) - 1); 779 show_msr = num;
583 780 return 1;
584 if (c->x86_max_cores > 1)
585 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
586 c->cpu_core_id);
587 }
588} 781}
589#endif 782__setup("show_msr=", setup_show_msr);
590 783
591static __init int setup_noclflush(char *arg) 784static __init int setup_noclflush(char *arg)
592{ 785{
@@ -605,17 +798,25 @@ void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
605 vendor = c->x86_vendor_id; 798 vendor = c->x86_vendor_id;
606 799
607 if (vendor && strncmp(c->x86_model_id, vendor, strlen(vendor))) 800 if (vendor && strncmp(c->x86_model_id, vendor, strlen(vendor)))
608 printk("%s ", vendor); 801 printk(KERN_CONT "%s ", vendor);
609 802
610 if (!c->x86_model_id[0]) 803 if (c->x86_model_id[0])
611 printk("%d86", c->x86); 804 printk(KERN_CONT "%s", c->x86_model_id);
612 else 805 else
613 printk("%s", c->x86_model_id); 806 printk(KERN_CONT "%d86", c->x86);
614 807
615 if (c->x86_mask || c->cpuid_level >= 0) 808 if (c->x86_mask || c->cpuid_level >= 0)
616 printk(" stepping %02x\n", c->x86_mask); 809 printk(KERN_CONT " stepping %02x\n", c->x86_mask);
617 else 810 else
618 printk("\n"); 811 printk(KERN_CONT "\n");
812
813#ifdef CONFIG_SMP
814 if (c->cpu_index < show_msr)
815 print_cpu_msr();
816#else
817 if (show_msr)
818 print_cpu_msr();
819#endif
619} 820}
620 821
621static __init int setup_disablecpuid(char *arg) 822static __init int setup_disablecpuid(char *arg)
@@ -631,19 +832,89 @@ __setup("clearcpuid=", setup_disablecpuid);
631 832
632cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE; 833cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
633 834
634void __init early_cpu_init(void) 835#ifdef CONFIG_X86_64
836struct x8664_pda **_cpu_pda __read_mostly;
837EXPORT_SYMBOL(_cpu_pda);
838
839struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
840
841char boot_cpu_stack[IRQSTACKSIZE] __page_aligned_bss;
842
843void __cpuinit pda_init(int cpu)
844{
845 struct x8664_pda *pda = cpu_pda(cpu);
846
847 /* Setup up data that may be needed in __get_free_pages early */
848 loadsegment(fs, 0);
849 loadsegment(gs, 0);
850 /* Memory clobbers used to order PDA accessed */
851 mb();
852 wrmsrl(MSR_GS_BASE, pda);
853 mb();
854
855 pda->cpunumber = cpu;
856 pda->irqcount = -1;
857 pda->kernelstack = (unsigned long)stack_thread_info() -
858 PDA_STACKOFFSET + THREAD_SIZE;
859 pda->active_mm = &init_mm;
860 pda->mmu_state = 0;
861
862 if (cpu == 0) {
863 /* others are initialized in smpboot.c */
864 pda->pcurrent = &init_task;
865 pda->irqstackptr = boot_cpu_stack;
866 pda->irqstackptr += IRQSTACKSIZE - 64;
867 } else {
868 if (!pda->irqstackptr) {
869 pda->irqstackptr = (char *)
870 __get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
871 if (!pda->irqstackptr)
872 panic("cannot allocate irqstack for cpu %d",
873 cpu);
874 pda->irqstackptr += IRQSTACKSIZE - 64;
875 }
876
877 if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE)
878 pda->nodenumber = cpu_to_node(cpu);
879 }
880}
881
882char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ +
883 DEBUG_STKSZ] __page_aligned_bss;
884
885extern asmlinkage void ignore_sysret(void);
886
887/* May not be marked __init: used by software suspend */
888void syscall_init(void)
635{ 889{
636 struct cpu_vendor_dev *cvdev; 890 /*
891 * LSTAR and STAR live in a bit strange symbiosis.
892 * They both write to the same internal register. STAR allows to
893 * set CS/DS but only a 32bit target. LSTAR sets the 64bit rip.
894 */
895 wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32);
896 wrmsrl(MSR_LSTAR, system_call);
897 wrmsrl(MSR_CSTAR, ignore_sysret);
637 898
638 for (cvdev = __x86cpuvendor_start ; 899#ifdef CONFIG_IA32_EMULATION
639 cvdev < __x86cpuvendor_end ; 900 syscall32_cpu_init();
640 cvdev++) 901#endif
641 cpu_devs[cvdev->vendor] = cvdev->cpu_dev;
642 902
643 early_cpu_detect(); 903 /* Flags to clear on syscall */
644 validate_pat_support(&boot_cpu_data); 904 wrmsrl(MSR_SYSCALL_MASK,
905 X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|X86_EFLAGS_IOPL);
645} 906}
646 907
908unsigned long kernel_eflags;
909
910/*
911 * Copies of the original ist values from the tss are only accessed during
912 * debugging, no special alignment required.
913 */
914DEFINE_PER_CPU(struct orig_ist, orig_ist);
915
916#else
917
647/* Make sure %fs is initialized properly in idle threads */ 918/* Make sure %fs is initialized properly in idle threads */
648struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs) 919struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs)
649{ 920{
@@ -651,25 +922,136 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs)
651 regs->fs = __KERNEL_PERCPU; 922 regs->fs = __KERNEL_PERCPU;
652 return regs; 923 return regs;
653} 924}
654 925#endif
655/* Current gdt points %fs at the "master" per-cpu area: after this,
656 * it's on the real one. */
657void switch_to_new_gdt(void)
658{
659 struct desc_ptr gdt_descr;
660
661 gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id());
662 gdt_descr.size = GDT_SIZE - 1;
663 load_gdt(&gdt_descr);
664 asm("mov %0, %%fs" : : "r" (__KERNEL_PERCPU) : "memory");
665}
666 926
667/* 927/*
668 * cpu_init() initializes state that is per-CPU. Some data is already 928 * cpu_init() initializes state that is per-CPU. Some data is already
669 * initialized (naturally) in the bootstrap process, such as the GDT 929 * initialized (naturally) in the bootstrap process, such as the GDT
670 * and IDT. We reload them nevertheless, this function acts as a 930 * and IDT. We reload them nevertheless, this function acts as a
671 * 'CPU state barrier', nothing should get across. 931 * 'CPU state barrier', nothing should get across.
932 * A lot of state is already set up in PDA init for 64 bit
672 */ 933 */
934#ifdef CONFIG_X86_64
935void __cpuinit cpu_init(void)
936{
937 int cpu = stack_smp_processor_id();
938 struct tss_struct *t = &per_cpu(init_tss, cpu);
939 struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu);
940 unsigned long v;
941 char *estacks = NULL;
942 struct task_struct *me;
943 int i;
944
945 /* CPU 0 is initialised in head64.c */
946 if (cpu != 0)
947 pda_init(cpu);
948 else
949 estacks = boot_exception_stacks;
950
951 me = current;
952
953 if (cpu_test_and_set(cpu, cpu_initialized))
954 panic("CPU#%d already initialized!\n", cpu);
955
956 printk(KERN_INFO "Initializing CPU#%d\n", cpu);
957
958 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
959
960 /*
961 * Initialize the per-CPU GDT with the boot GDT,
962 * and set up the GDT descriptor:
963 */
964
965 switch_to_new_gdt();
966 load_idt((const struct desc_ptr *)&idt_descr);
967
968 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
969 syscall_init();
970
971 wrmsrl(MSR_FS_BASE, 0);
972 wrmsrl(MSR_KERNEL_GS_BASE, 0);
973 barrier();
974
975 check_efer();
976 if (cpu != 0 && x2apic)
977 enable_x2apic();
978
979 /*
980 * set up and load the per-CPU TSS
981 */
982 if (!orig_ist->ist[0]) {
983 static const unsigned int order[N_EXCEPTION_STACKS] = {
984 [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
985 [DEBUG_STACK - 1] = DEBUG_STACK_ORDER
986 };
987 for (v = 0; v < N_EXCEPTION_STACKS; v++) {
988 if (cpu) {
989 estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
990 if (!estacks)
991 panic("Cannot allocate exception "
992 "stack %ld %d\n", v, cpu);
993 }
994 estacks += PAGE_SIZE << order[v];
995 orig_ist->ist[v] = t->x86_tss.ist[v] =
996 (unsigned long)estacks;
997 }
998 }
999
1000 t->x86_tss.io_bitmap_base = offsetof(struct tss_struct, io_bitmap);
1001 /*
1002 * <= is required because the CPU will access up to
1003 * 8 bits beyond the end of the IO permission bitmap.
1004 */
1005 for (i = 0; i <= IO_BITMAP_LONGS; i++)
1006 t->io_bitmap[i] = ~0UL;
1007
1008 atomic_inc(&init_mm.mm_count);
1009 me->active_mm = &init_mm;
1010 if (me->mm)
1011 BUG();
1012 enter_lazy_tlb(&init_mm, me);
1013
1014 load_sp0(t, &current->thread);
1015 set_tss_desc(cpu, t);
1016 load_TR_desc();
1017 load_LDT(&init_mm.context);
1018
1019#ifdef CONFIG_KGDB
1020 /*
1021 * If the kgdb is connected no debug regs should be altered. This
1022 * is only applicable when KGDB and a KGDB I/O module are built
1023 * into the kernel and you are using early debugging with
1024 * kgdbwait. KGDB will control the kernel HW breakpoint registers.
1025 */
1026 if (kgdb_connected && arch_kgdb_ops.correct_hw_break)
1027 arch_kgdb_ops.correct_hw_break();
1028 else {
1029#endif
1030 /*
1031 * Clear all 6 debug registers:
1032 */
1033
1034 set_debugreg(0UL, 0);
1035 set_debugreg(0UL, 1);
1036 set_debugreg(0UL, 2);
1037 set_debugreg(0UL, 3);
1038 set_debugreg(0UL, 6);
1039 set_debugreg(0UL, 7);
1040#ifdef CONFIG_KGDB
1041 /* If the kgdb is connected no debug regs should be altered. */
1042 }
1043#endif
1044
1045 fpu_init();
1046
1047 raw_local_save_flags(kernel_eflags);
1048
1049 if (is_uv_system())
1050 uv_cpu_init();
1051}
1052
1053#else
1054
673void __cpuinit cpu_init(void) 1055void __cpuinit cpu_init(void)
674{ 1056{
675 int cpu = smp_processor_id(); 1057 int cpu = smp_processor_id();
@@ -723,19 +1105,21 @@ void __cpuinit cpu_init(void)
723 /* 1105 /*
724 * Force FPU initialization: 1106 * Force FPU initialization:
725 */ 1107 */
726 current_thread_info()->status = 0; 1108 if (cpu_has_xsave)
1109 current_thread_info()->status = TS_XSAVE;
1110 else
1111 current_thread_info()->status = 0;
727 clear_used_math(); 1112 clear_used_math();
728 mxcsr_feature_mask_init(); 1113 mxcsr_feature_mask_init();
729}
730 1114
731#ifdef CONFIG_HOTPLUG_CPU 1115 /*
732void __cpuinit cpu_uninit(void) 1116 * Boot processor to setup the FP and extended state context info.
733{ 1117 */
734 int cpu = raw_smp_processor_id(); 1118 if (!smp_processor_id())
735 cpu_clear(cpu, cpu_initialized); 1119 init_thread_xstate();
736 1120
737 /* lazy TLB state */ 1121 xsave_init();
738 per_cpu(cpu_tlbstate, cpu).state = 0;
739 per_cpu(cpu_tlbstate, cpu).active_mm = &init_mm;
740} 1122}
1123
1124
741#endif 1125#endif
diff --git a/arch/x86/kernel/cpu/common_64.c b/arch/x86/kernel/cpu/common_64.c
deleted file mode 100644
index a11f5d4477cd..000000000000
--- a/arch/x86/kernel/cpu/common_64.c
+++ /dev/null
@@ -1,712 +0,0 @@
1#include <linux/init.h>
2#include <linux/kernel.h>
3#include <linux/sched.h>
4#include <linux/string.h>
5#include <linux/bootmem.h>
6#include <linux/bitops.h>
7#include <linux/module.h>
8#include <linux/kgdb.h>
9#include <linux/topology.h>
10#include <linux/delay.h>
11#include <linux/smp.h>
12#include <linux/percpu.h>
13#include <asm/i387.h>
14#include <asm/msr.h>
15#include <asm/io.h>
16#include <asm/linkage.h>
17#include <asm/mmu_context.h>
18#include <asm/mtrr.h>
19#include <asm/mce.h>
20#include <asm/pat.h>
21#include <asm/asm.h>
22#include <asm/numa.h>
23#ifdef CONFIG_X86_LOCAL_APIC
24#include <asm/mpspec.h>
25#include <asm/apic.h>
26#include <mach_apic.h>
27#endif
28#include <asm/pda.h>
29#include <asm/pgtable.h>
30#include <asm/processor.h>
31#include <asm/desc.h>
32#include <asm/atomic.h>
33#include <asm/proto.h>
34#include <asm/sections.h>
35#include <asm/setup.h>
36#include <asm/genapic.h>
37
38#include "cpu.h"
39
40/* We need valid kernel segments for data and code in long mode too
41 * IRET will check the segment types kkeil 2000/10/28
42 * Also sysret mandates a special GDT layout
43 */
44/* The TLS descriptors are currently at a different place compared to i386.
45 Hopefully nobody expects them at a fixed place (Wine?) */
46DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = {
47 [GDT_ENTRY_KERNEL32_CS] = { { { 0x0000ffff, 0x00cf9b00 } } },
48 [GDT_ENTRY_KERNEL_CS] = { { { 0x0000ffff, 0x00af9b00 } } },
49 [GDT_ENTRY_KERNEL_DS] = { { { 0x0000ffff, 0x00cf9300 } } },
50 [GDT_ENTRY_DEFAULT_USER32_CS] = { { { 0x0000ffff, 0x00cffb00 } } },
51 [GDT_ENTRY_DEFAULT_USER_DS] = { { { 0x0000ffff, 0x00cff300 } } },
52 [GDT_ENTRY_DEFAULT_USER_CS] = { { { 0x0000ffff, 0x00affb00 } } },
53} };
54EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
55
56__u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata;
57
58/* Current gdt points %fs at the "master" per-cpu area: after this,
59 * it's on the real one. */
60void switch_to_new_gdt(void)
61{
62 struct desc_ptr gdt_descr;
63
64 gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id());
65 gdt_descr.size = GDT_SIZE - 1;
66 load_gdt(&gdt_descr);
67}
68
69struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
70
71static void __cpuinit default_init(struct cpuinfo_x86 *c)
72{
73 display_cacheinfo(c);
74}
75
76static struct cpu_dev __cpuinitdata default_cpu = {
77 .c_init = default_init,
78 .c_vendor = "Unknown",
79};
80static struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
81
82int __cpuinit get_model_name(struct cpuinfo_x86 *c)
83{
84 unsigned int *v;
85
86 if (c->extended_cpuid_level < 0x80000004)
87 return 0;
88
89 v = (unsigned int *) c->x86_model_id;
90 cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
91 cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
92 cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
93 c->x86_model_id[48] = 0;
94 return 1;
95}
96
97
98void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
99{
100 unsigned int n, dummy, ebx, ecx, edx;
101
102 n = c->extended_cpuid_level;
103
104 if (n >= 0x80000005) {
105 cpuid(0x80000005, &dummy, &ebx, &ecx, &edx);
106 printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), "
107 "D cache %dK (%d bytes/line)\n",
108 edx>>24, edx&0xFF, ecx>>24, ecx&0xFF);
109 c->x86_cache_size = (ecx>>24) + (edx>>24);
110 /* On K8 L1 TLB is inclusive, so don't count it */
111 c->x86_tlbsize = 0;
112 }
113
114 if (n >= 0x80000006) {
115 cpuid(0x80000006, &dummy, &ebx, &ecx, &edx);
116 ecx = cpuid_ecx(0x80000006);
117 c->x86_cache_size = ecx >> 16;
118 c->x86_tlbsize += ((ebx >> 16) & 0xfff) + (ebx & 0xfff);
119
120 printk(KERN_INFO "CPU: L2 Cache: %dK (%d bytes/line)\n",
121 c->x86_cache_size, ecx & 0xFF);
122 }
123}
124
125void __cpuinit detect_ht(struct cpuinfo_x86 *c)
126{
127#ifdef CONFIG_SMP
128 u32 eax, ebx, ecx, edx;
129 int index_msb, core_bits;
130
131 cpuid(1, &eax, &ebx, &ecx, &edx);
132
133
134 if (!cpu_has(c, X86_FEATURE_HT))
135 return;
136 if (cpu_has(c, X86_FEATURE_CMP_LEGACY))
137 goto out;
138
139 smp_num_siblings = (ebx & 0xff0000) >> 16;
140
141 if (smp_num_siblings == 1) {
142 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
143 } else if (smp_num_siblings > 1) {
144
145 if (smp_num_siblings > NR_CPUS) {
146 printk(KERN_WARNING "CPU: Unsupported number of "
147 "siblings %d", smp_num_siblings);
148 smp_num_siblings = 1;
149 return;
150 }
151
152 index_msb = get_count_order(smp_num_siblings);
153 c->phys_proc_id = phys_pkg_id(index_msb);
154
155 smp_num_siblings = smp_num_siblings / c->x86_max_cores;
156
157 index_msb = get_count_order(smp_num_siblings);
158
159 core_bits = get_count_order(c->x86_max_cores);
160
161 c->cpu_core_id = phys_pkg_id(index_msb) &
162 ((1 << core_bits) - 1);
163 }
164out:
165 if ((c->x86_max_cores * smp_num_siblings) > 1) {
166 printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
167 c->phys_proc_id);
168 printk(KERN_INFO "CPU: Processor Core ID: %d\n",
169 c->cpu_core_id);
170 }
171
172#endif
173}
174
175static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
176{
177 char *v = c->x86_vendor_id;
178 int i;
179 static int printed;
180
181 for (i = 0; i < X86_VENDOR_NUM; i++) {
182 if (cpu_devs[i]) {
183 if (!strcmp(v, cpu_devs[i]->c_ident[0]) ||
184 (cpu_devs[i]->c_ident[1] &&
185 !strcmp(v, cpu_devs[i]->c_ident[1]))) {
186 c->x86_vendor = i;
187 this_cpu = cpu_devs[i];
188 return;
189 }
190 }
191 }
192 if (!printed) {
193 printed++;
194 printk(KERN_ERR "CPU: Vendor unknown, using generic init.\n");
195 printk(KERN_ERR "CPU: Your system may be unstable.\n");
196 }
197 c->x86_vendor = X86_VENDOR_UNKNOWN;
198}
199
200static void __init early_cpu_support_print(void)
201{
202 int i,j;
203 struct cpu_dev *cpu_devx;
204
205 printk("KERNEL supported cpus:\n");
206 for (i = 0; i < X86_VENDOR_NUM; i++) {
207 cpu_devx = cpu_devs[i];
208 if (!cpu_devx)
209 continue;
210 for (j = 0; j < 2; j++) {
211 if (!cpu_devx->c_ident[j])
212 continue;
213 printk(" %s %s\n", cpu_devx->c_vendor,
214 cpu_devx->c_ident[j]);
215 }
216 }
217}
218
219/*
220 * The NOPL instruction is supposed to exist on all CPUs with
221 * family >= 6, unfortunately, that's not true in practice because
222 * of early VIA chips and (more importantly) broken virtualizers that
223 * are not easy to detect. Hence, probe for it based on first
224 * principles.
225 *
226 * Note: no 64-bit chip is known to lack these, but put the code here
227 * for consistency with 32 bits, and to make it utterly trivial to
228 * diagnose the problem should it ever surface.
229 */
230static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
231{
232 const u32 nopl_signature = 0x888c53b1; /* Random number */
233 u32 has_nopl = nopl_signature;
234
235 clear_cpu_cap(c, X86_FEATURE_NOPL);
236 if (c->x86 >= 6) {
237 asm volatile("\n"
238 "1: .byte 0x0f,0x1f,0xc0\n" /* nopl %eax */
239 "2:\n"
240 " .section .fixup,\"ax\"\n"
241 "3: xor %0,%0\n"
242 " jmp 2b\n"
243 " .previous\n"
244 _ASM_EXTABLE(1b,3b)
245 : "+a" (has_nopl));
246
247 if (has_nopl == nopl_signature)
248 set_cpu_cap(c, X86_FEATURE_NOPL);
249 }
250}
251
252static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c);
253
254void __init early_cpu_init(void)
255{
256 struct cpu_vendor_dev *cvdev;
257
258 for (cvdev = __x86cpuvendor_start ;
259 cvdev < __x86cpuvendor_end ;
260 cvdev++)
261 cpu_devs[cvdev->vendor] = cvdev->cpu_dev;
262 early_cpu_support_print();
263 early_identify_cpu(&boot_cpu_data);
264}
265
266/* Do some early cpuid on the boot CPU to get some parameter that are
267 needed before check_bugs. Everything advanced is in identify_cpu
268 below. */
269static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
270{
271 u32 tfms, xlvl;
272
273 c->loops_per_jiffy = loops_per_jiffy;
274 c->x86_cache_size = -1;
275 c->x86_vendor = X86_VENDOR_UNKNOWN;
276 c->x86_model = c->x86_mask = 0; /* So far unknown... */
277 c->x86_vendor_id[0] = '\0'; /* Unset */
278 c->x86_model_id[0] = '\0'; /* Unset */
279 c->x86_clflush_size = 64;
280 c->x86_cache_alignment = c->x86_clflush_size;
281 c->x86_max_cores = 1;
282 c->x86_coreid_bits = 0;
283 c->extended_cpuid_level = 0;
284 memset(&c->x86_capability, 0, sizeof c->x86_capability);
285
286 /* Get vendor name */
287 cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
288 (unsigned int *)&c->x86_vendor_id[0],
289 (unsigned int *)&c->x86_vendor_id[8],
290 (unsigned int *)&c->x86_vendor_id[4]);
291
292 get_cpu_vendor(c);
293
294 /* Initialize the standard set of capabilities */
295 /* Note that the vendor-specific code below might override */
296
297 /* Intel-defined flags: level 0x00000001 */
298 if (c->cpuid_level >= 0x00000001) {
299 __u32 misc;
300 cpuid(0x00000001, &tfms, &misc, &c->x86_capability[4],
301 &c->x86_capability[0]);
302 c->x86 = (tfms >> 8) & 0xf;
303 c->x86_model = (tfms >> 4) & 0xf;
304 c->x86_mask = tfms & 0xf;
305 if (c->x86 == 0xf)
306 c->x86 += (tfms >> 20) & 0xff;
307 if (c->x86 >= 0x6)
308 c->x86_model += ((tfms >> 16) & 0xF) << 4;
309 if (test_cpu_cap(c, X86_FEATURE_CLFLSH))
310 c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
311 } else {
312 /* Have CPUID level 0 only - unheard of */
313 c->x86 = 4;
314 }
315
316 c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xff;
317#ifdef CONFIG_SMP
318 c->phys_proc_id = c->initial_apicid;
319#endif
320 /* AMD-defined flags: level 0x80000001 */
321 xlvl = cpuid_eax(0x80000000);
322 c->extended_cpuid_level = xlvl;
323 if ((xlvl & 0xffff0000) == 0x80000000) {
324 if (xlvl >= 0x80000001) {
325 c->x86_capability[1] = cpuid_edx(0x80000001);
326 c->x86_capability[6] = cpuid_ecx(0x80000001);
327 }
328 if (xlvl >= 0x80000004)
329 get_model_name(c); /* Default name */
330 }
331
332 /* Transmeta-defined flags: level 0x80860001 */
333 xlvl = cpuid_eax(0x80860000);
334 if ((xlvl & 0xffff0000) == 0x80860000) {
335 /* Don't set x86_cpuid_level here for now to not confuse. */
336 if (xlvl >= 0x80860001)
337 c->x86_capability[2] = cpuid_edx(0x80860001);
338 }
339
340 if (c->extended_cpuid_level >= 0x80000007)
341 c->x86_power = cpuid_edx(0x80000007);
342
343 if (c->extended_cpuid_level >= 0x80000008) {
344 u32 eax = cpuid_eax(0x80000008);
345
346 c->x86_virt_bits = (eax >> 8) & 0xff;
347 c->x86_phys_bits = eax & 0xff;
348 }
349
350 detect_nopl(c);
351
352 if (c->x86_vendor != X86_VENDOR_UNKNOWN &&
353 cpu_devs[c->x86_vendor]->c_early_init)
354 cpu_devs[c->x86_vendor]->c_early_init(c);
355
356 validate_pat_support(c);
357}
358
359/*
360 * This does the hard work of actually picking apart the CPU stuff...
361 */
362static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
363{
364 int i;
365
366 early_identify_cpu(c);
367
368 init_scattered_cpuid_features(c);
369
370 c->apicid = phys_pkg_id(0);
371
372 /*
373 * Vendor-specific initialization. In this section we
374 * canonicalize the feature flags, meaning if there are
375 * features a certain CPU supports which CPUID doesn't
376 * tell us, CPUID claiming incorrect flags, or other bugs,
377 * we handle them here.
378 *
379 * At the end of this section, c->x86_capability better
380 * indicate the features this CPU genuinely supports!
381 */
382 if (this_cpu->c_init)
383 this_cpu->c_init(c);
384
385 detect_ht(c);
386
387 /*
388 * On SMP, boot_cpu_data holds the common feature set between
389 * all CPUs; so make sure that we indicate which features are
390 * common between the CPUs. The first time this routine gets
391 * executed, c == &boot_cpu_data.
392 */
393 if (c != &boot_cpu_data) {
394 /* AND the already accumulated flags with these */
395 for (i = 0; i < NCAPINTS; i++)
396 boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
397 }
398
399 /* Clear all flags overriden by options */
400 for (i = 0; i < NCAPINTS; i++)
401 c->x86_capability[i] &= ~cleared_cpu_caps[i];
402
403#ifdef CONFIG_X86_MCE
404 mcheck_init(c);
405#endif
406 select_idle_routine(c);
407
408#ifdef CONFIG_NUMA
409 numa_add_cpu(smp_processor_id());
410#endif
411
412}
413
414void __cpuinit identify_boot_cpu(void)
415{
416 identify_cpu(&boot_cpu_data);
417}
418
419void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
420{
421 BUG_ON(c == &boot_cpu_data);
422 identify_cpu(c);
423 mtrr_ap_init();
424}
425
426static __init int setup_noclflush(char *arg)
427{
428 setup_clear_cpu_cap(X86_FEATURE_CLFLSH);
429 return 1;
430}
431__setup("noclflush", setup_noclflush);
432
433void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
434{
435 if (c->x86_model_id[0])
436 printk(KERN_CONT "%s", c->x86_model_id);
437
438 if (c->x86_mask || c->cpuid_level >= 0)
439 printk(KERN_CONT " stepping %02x\n", c->x86_mask);
440 else
441 printk(KERN_CONT "\n");
442}
443
444static __init int setup_disablecpuid(char *arg)
445{
446 int bit;
447 if (get_option(&arg, &bit) && bit < NCAPINTS*32)
448 setup_clear_cpu_cap(bit);
449 else
450 return 0;
451 return 1;
452}
453__setup("clearcpuid=", setup_disablecpuid);
454
455cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
456
457struct x8664_pda **_cpu_pda __read_mostly;
458EXPORT_SYMBOL(_cpu_pda);
459
460struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
461
462char boot_cpu_stack[IRQSTACKSIZE] __page_aligned_bss;
463
464unsigned long __supported_pte_mask __read_mostly = ~0UL;
465EXPORT_SYMBOL_GPL(__supported_pte_mask);
466
467static int do_not_nx __cpuinitdata;
468
469/* noexec=on|off
470Control non executable mappings for 64bit processes.
471
472on Enable(default)
473off Disable
474*/
475static int __init nonx_setup(char *str)
476{
477 if (!str)
478 return -EINVAL;
479 if (!strncmp(str, "on", 2)) {
480 __supported_pte_mask |= _PAGE_NX;
481 do_not_nx = 0;
482 } else if (!strncmp(str, "off", 3)) {
483 do_not_nx = 1;
484 __supported_pte_mask &= ~_PAGE_NX;
485 }
486 return 0;
487}
488early_param("noexec", nonx_setup);
489
490int force_personality32;
491
492/* noexec32=on|off
493Control non executable heap for 32bit processes.
494To control the stack too use noexec=off
495
496on PROT_READ does not imply PROT_EXEC for 32bit processes (default)
497off PROT_READ implies PROT_EXEC
498*/
499static int __init nonx32_setup(char *str)
500{
501 if (!strcmp(str, "on"))
502 force_personality32 &= ~READ_IMPLIES_EXEC;
503 else if (!strcmp(str, "off"))
504 force_personality32 |= READ_IMPLIES_EXEC;
505 return 1;
506}
507__setup("noexec32=", nonx32_setup);
508
509void pda_init(int cpu)
510{
511 struct x8664_pda *pda = cpu_pda(cpu);
512
513 /* Setup up data that may be needed in __get_free_pages early */
514 loadsegment(fs, 0);
515 loadsegment(gs, 0);
516 /* Memory clobbers used to order PDA accessed */
517 mb();
518 wrmsrl(MSR_GS_BASE, pda);
519 mb();
520
521 pda->cpunumber = cpu;
522 pda->irqcount = -1;
523 pda->kernelstack = (unsigned long)stack_thread_info() -
524 PDA_STACKOFFSET + THREAD_SIZE;
525 pda->active_mm = &init_mm;
526 pda->mmu_state = 0;
527
528 if (cpu == 0) {
529 /* others are initialized in smpboot.c */
530 pda->pcurrent = &init_task;
531 pda->irqstackptr = boot_cpu_stack;
532 pda->irqstackptr += IRQSTACKSIZE - 64;
533 } else {
534 if (!pda->irqstackptr) {
535 pda->irqstackptr = (char *)
536 __get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
537 if (!pda->irqstackptr)
538 panic("cannot allocate irqstack for cpu %d",
539 cpu);
540 pda->irqstackptr += IRQSTACKSIZE - 64;
541 }
542
543 if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE)
544 pda->nodenumber = cpu_to_node(cpu);
545 }
546}
547
548char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ +
549 DEBUG_STKSZ] __page_aligned_bss;
550
551extern asmlinkage void ignore_sysret(void);
552
553/* May not be marked __init: used by software suspend */
554void syscall_init(void)
555{
556 /*
557 * LSTAR and STAR live in a bit strange symbiosis.
558 * They both write to the same internal register. STAR allows to
559 * set CS/DS but only a 32bit target. LSTAR sets the 64bit rip.
560 */
561 wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32);
562 wrmsrl(MSR_LSTAR, system_call);
563 wrmsrl(MSR_CSTAR, ignore_sysret);
564
565#ifdef CONFIG_IA32_EMULATION
566 syscall32_cpu_init();
567#endif
568
569 /* Flags to clear on syscall */
570 wrmsrl(MSR_SYSCALL_MASK,
571 X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|X86_EFLAGS_IOPL);
572}
573
574void __cpuinit check_efer(void)
575{
576 unsigned long efer;
577
578 rdmsrl(MSR_EFER, efer);
579 if (!(efer & EFER_NX) || do_not_nx)
580 __supported_pte_mask &= ~_PAGE_NX;
581}
582
583unsigned long kernel_eflags;
584
585/*
586 * Copies of the original ist values from the tss are only accessed during
587 * debugging, no special alignment required.
588 */
589DEFINE_PER_CPU(struct orig_ist, orig_ist);
590
591/*
592 * cpu_init() initializes state that is per-CPU. Some data is already
593 * initialized (naturally) in the bootstrap process, such as the GDT
594 * and IDT. We reload them nevertheless, this function acts as a
595 * 'CPU state barrier', nothing should get across.
596 * A lot of state is already set up in PDA init.
597 */
598void __cpuinit cpu_init(void)
599{
600 int cpu = stack_smp_processor_id();
601 struct tss_struct *t = &per_cpu(init_tss, cpu);
602 struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu);
603 unsigned long v;
604 char *estacks = NULL;
605 struct task_struct *me;
606 int i;
607
608 /* CPU 0 is initialised in head64.c */
609 if (cpu != 0)
610 pda_init(cpu);
611 else
612 estacks = boot_exception_stacks;
613
614 me = current;
615
616 if (cpu_test_and_set(cpu, cpu_initialized))
617 panic("CPU#%d already initialized!\n", cpu);
618
619 printk(KERN_INFO "Initializing CPU#%d\n", cpu);
620
621 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
622
623 /*
624 * Initialize the per-CPU GDT with the boot GDT,
625 * and set up the GDT descriptor:
626 */
627
628 switch_to_new_gdt();
629 load_idt((const struct desc_ptr *)&idt_descr);
630
631 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
632 syscall_init();
633
634 wrmsrl(MSR_FS_BASE, 0);
635 wrmsrl(MSR_KERNEL_GS_BASE, 0);
636 barrier();
637
638 check_efer();
639
640 /*
641 * set up and load the per-CPU TSS
642 */
643 if (!orig_ist->ist[0]) {
644 static const unsigned int order[N_EXCEPTION_STACKS] = {
645 [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
646 [DEBUG_STACK - 1] = DEBUG_STACK_ORDER
647 };
648 for (v = 0; v < N_EXCEPTION_STACKS; v++) {
649 if (cpu) {
650 estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
651 if (!estacks)
652 panic("Cannot allocate exception "
653 "stack %ld %d\n", v, cpu);
654 }
655 estacks += PAGE_SIZE << order[v];
656 orig_ist->ist[v] = t->x86_tss.ist[v] =
657 (unsigned long)estacks;
658 }
659 }
660
661 t->x86_tss.io_bitmap_base = offsetof(struct tss_struct, io_bitmap);
662 /*
663 * <= is required because the CPU will access up to
664 * 8 bits beyond the end of the IO permission bitmap.
665 */
666 for (i = 0; i <= IO_BITMAP_LONGS; i++)
667 t->io_bitmap[i] = ~0UL;
668
669 atomic_inc(&init_mm.mm_count);
670 me->active_mm = &init_mm;
671 if (me->mm)
672 BUG();
673 enter_lazy_tlb(&init_mm, me);
674
675 load_sp0(t, &current->thread);
676 set_tss_desc(cpu, t);
677 load_TR_desc();
678 load_LDT(&init_mm.context);
679
680#ifdef CONFIG_KGDB
681 /*
682 * If the kgdb is connected no debug regs should be altered. This
683 * is only applicable when KGDB and a KGDB I/O module are built
684 * into the kernel and you are using early debugging with
685 * kgdbwait. KGDB will control the kernel HW breakpoint registers.
686 */
687 if (kgdb_connected && arch_kgdb_ops.correct_hw_break)
688 arch_kgdb_ops.correct_hw_break();
689 else {
690#endif
691 /*
692 * Clear all 6 debug registers:
693 */
694
695 set_debugreg(0UL, 0);
696 set_debugreg(0UL, 1);
697 set_debugreg(0UL, 2);
698 set_debugreg(0UL, 3);
699 set_debugreg(0UL, 6);
700 set_debugreg(0UL, 7);
701#ifdef CONFIG_KGDB
702 /* If the kgdb is connected no debug regs should be altered. */
703 }
704#endif
705
706 fpu_init();
707
708 raw_local_save_flags(kernel_eflags);
709
710 if (is_uv_system())
711 uv_cpu_init();
712}
diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
index 4d894e8565fe..de4094a39210 100644
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -21,23 +21,16 @@ struct cpu_dev {
21 void (*c_init)(struct cpuinfo_x86 * c); 21 void (*c_init)(struct cpuinfo_x86 * c);
22 void (*c_identify)(struct cpuinfo_x86 * c); 22 void (*c_identify)(struct cpuinfo_x86 * c);
23 unsigned int (*c_size_cache)(struct cpuinfo_x86 * c, unsigned int size); 23 unsigned int (*c_size_cache)(struct cpuinfo_x86 * c, unsigned int size);
24 int c_x86_vendor;
24}; 25};
25 26
26extern struct cpu_dev * cpu_devs [X86_VENDOR_NUM]; 27#define cpu_dev_register(cpu_devX) \
28 static struct cpu_dev *__cpu_dev_##cpu_devX __used \
29 __attribute__((__section__(".x86_cpu_dev.init"))) = \
30 &cpu_devX;
27 31
28struct cpu_vendor_dev { 32extern struct cpu_dev *__x86_cpu_dev_start[], *__x86_cpu_dev_end[];
29 int vendor;
30 struct cpu_dev *cpu_dev;
31};
32
33#define cpu_vendor_dev_register(cpu_vendor_id, cpu_dev) \
34 static struct cpu_vendor_dev __cpu_vendor_dev_##cpu_vendor_id __used \
35 __attribute__((__section__(".x86cpuvendor.init"))) = \
36 { cpu_vendor_id, cpu_dev }
37
38extern struct cpu_vendor_dev __x86cpuvendor_start[], __x86cpuvendor_end[];
39 33
40extern int get_model_name(struct cpuinfo_x86 *c);
41extern void display_cacheinfo(struct cpuinfo_x86 *c); 34extern void display_cacheinfo(struct cpuinfo_x86 *c);
42 35
43#endif 36#endif
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index dd097b835839..c24c4a487b7c 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -256,7 +256,8 @@ static u32 get_cur_val(const cpumask_t *mask)
256 * Only IA32_APERF/IA32_MPERF ratio is architecturally defined and 256 * Only IA32_APERF/IA32_MPERF ratio is architecturally defined and
257 * no meaning should be associated with absolute values of these MSRs. 257 * no meaning should be associated with absolute values of these MSRs.
258 */ 258 */
259static unsigned int get_measured_perf(unsigned int cpu) 259static unsigned int get_measured_perf(struct cpufreq_policy *policy,
260 unsigned int cpu)
260{ 261{
261 union { 262 union {
262 struct { 263 struct {
@@ -326,7 +327,7 @@ static unsigned int get_measured_perf(unsigned int cpu)
326 327
327#endif 328#endif
328 329
329 retval = per_cpu(drv_data, cpu)->max_freq * perf_percent / 100; 330 retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100;
330 331
331 put_cpu(); 332 put_cpu();
332 set_cpus_allowed_ptr(current, &saved_mask); 333 set_cpus_allowed_ptr(current, &saved_mask);
@@ -785,7 +786,11 @@ static int __init acpi_cpufreq_init(void)
785 if (ret) 786 if (ret)
786 return ret; 787 return ret;
787 788
788 return cpufreq_register_driver(&acpi_cpufreq_driver); 789 ret = cpufreq_register_driver(&acpi_cpufreq_driver);
790 if (ret)
791 free_percpu(acpi_perf_data);
792
793 return ret;
789} 794}
790 795
791static void __exit acpi_cpufreq_exit(void) 796static void __exit acpi_cpufreq_exit(void)
@@ -795,8 +800,6 @@ static void __exit acpi_cpufreq_exit(void)
795 cpufreq_unregister_driver(&acpi_cpufreq_driver); 800 cpufreq_unregister_driver(&acpi_cpufreq_driver);
796 801
797 free_percpu(acpi_perf_data); 802 free_percpu(acpi_perf_data);
798
799 return;
800} 803}
801 804
802module_param(acpi_pstate_strict, uint, 0644); 805module_param(acpi_pstate_strict, uint, 0644);
diff --git a/arch/x86/kernel/cpu/cpufreq/elanfreq.c b/arch/x86/kernel/cpu/cpufreq/elanfreq.c
index e4a4bf870e94..fe613c93b366 100644
--- a/arch/x86/kernel/cpu/cpufreq/elanfreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/elanfreq.c
@@ -25,8 +25,8 @@
25#include <linux/cpufreq.h> 25#include <linux/cpufreq.h>
26 26
27#include <asm/msr.h> 27#include <asm/msr.h>
28#include <asm/timex.h> 28#include <linux/timex.h>
29#include <asm/io.h> 29#include <linux/io.h>
30 30
31#define REG_CSCIR 0x22 /* Chip Setup and Control Index Register */ 31#define REG_CSCIR 0x22 /* Chip Setup and Control Index Register */
32#define REG_CSCDR 0x23 /* Chip Setup and Control Data Register */ 32#define REG_CSCDR 0x23 /* Chip Setup and Control Data Register */
@@ -82,7 +82,7 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
82 u8 clockspeed_reg; /* Clock Speed Register */ 82 u8 clockspeed_reg; /* Clock Speed Register */
83 83
84 local_irq_disable(); 84 local_irq_disable();
85 outb_p(0x80,REG_CSCIR); 85 outb_p(0x80, REG_CSCIR);
86 clockspeed_reg = inb_p(REG_CSCDR); 86 clockspeed_reg = inb_p(REG_CSCDR);
87 local_irq_enable(); 87 local_irq_enable();
88 88
@@ -98,10 +98,10 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
98 } 98 }
99 99
100 /* 33 MHz is not 32 MHz... */ 100 /* 33 MHz is not 32 MHz... */
101 if ((clockspeed_reg & 0xE0)==0xA0) 101 if ((clockspeed_reg & 0xE0) == 0xA0)
102 return 33000; 102 return 33000;
103 103
104 return ((1<<((clockspeed_reg & 0xE0) >> 5)) * 1000); 104 return (1<<((clockspeed_reg & 0xE0) >> 5)) * 1000;
105} 105}
106 106
107 107
@@ -117,7 +117,7 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)
117 * There is no return value. 117 * There is no return value.
118 */ 118 */
119 119
120static void elanfreq_set_cpu_state (unsigned int state) 120static void elanfreq_set_cpu_state(unsigned int state)
121{ 121{
122 struct cpufreq_freqs freqs; 122 struct cpufreq_freqs freqs;
123 123
@@ -144,20 +144,20 @@ static void elanfreq_set_cpu_state (unsigned int state)
144 */ 144 */
145 145
146 local_irq_disable(); 146 local_irq_disable();
147 outb_p(0x40,REG_CSCIR); /* Disable hyperspeed mode */ 147 outb_p(0x40, REG_CSCIR); /* Disable hyperspeed mode */
148 outb_p(0x00,REG_CSCDR); 148 outb_p(0x00, REG_CSCDR);
149 local_irq_enable(); /* wait till internal pipelines and */ 149 local_irq_enable(); /* wait till internal pipelines and */
150 udelay(1000); /* buffers have cleaned up */ 150 udelay(1000); /* buffers have cleaned up */
151 151
152 local_irq_disable(); 152 local_irq_disable();
153 153
154 /* now, set the CPU clock speed register (0x80) */ 154 /* now, set the CPU clock speed register (0x80) */
155 outb_p(0x80,REG_CSCIR); 155 outb_p(0x80, REG_CSCIR);
156 outb_p(elan_multiplier[state].val80h,REG_CSCDR); 156 outb_p(elan_multiplier[state].val80h, REG_CSCDR);
157 157
158 /* now, the hyperspeed bit in PMU Force Mode Register (0x40) */ 158 /* now, the hyperspeed bit in PMU Force Mode Register (0x40) */
159 outb_p(0x40,REG_CSCIR); 159 outb_p(0x40, REG_CSCIR);
160 outb_p(elan_multiplier[state].val40h,REG_CSCDR); 160 outb_p(elan_multiplier[state].val40h, REG_CSCDR);
161 udelay(10000); 161 udelay(10000);
162 local_irq_enable(); 162 local_irq_enable();
163 163
@@ -173,12 +173,12 @@ static void elanfreq_set_cpu_state (unsigned int state)
173 * for the hardware supported by the driver. 173 * for the hardware supported by the driver.
174 */ 174 */
175 175
176static int elanfreq_verify (struct cpufreq_policy *policy) 176static int elanfreq_verify(struct cpufreq_policy *policy)
177{ 177{
178 return cpufreq_frequency_table_verify(policy, &elanfreq_table[0]); 178 return cpufreq_frequency_table_verify(policy, &elanfreq_table[0]);
179} 179}
180 180
181static int elanfreq_target (struct cpufreq_policy *policy, 181static int elanfreq_target(struct cpufreq_policy *policy,
182 unsigned int target_freq, 182 unsigned int target_freq,
183 unsigned int relation) 183 unsigned int relation)
184{ 184{
@@ -205,7 +205,7 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
205 205
206 /* capability check */ 206 /* capability check */
207 if ((c->x86_vendor != X86_VENDOR_AMD) || 207 if ((c->x86_vendor != X86_VENDOR_AMD) ||
208 (c->x86 != 4) || (c->x86_model!=10)) 208 (c->x86 != 4) || (c->x86_model != 10))
209 return -ENODEV; 209 return -ENODEV;
210 210
211 /* max freq */ 211 /* max freq */
@@ -213,7 +213,7 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
213 max_freq = elanfreq_get_cpu_frequency(0); 213 max_freq = elanfreq_get_cpu_frequency(0);
214 214
215 /* table init */ 215 /* table init */
216 for (i=0; (elanfreq_table[i].frequency != CPUFREQ_TABLE_END); i++) { 216 for (i = 0; (elanfreq_table[i].frequency != CPUFREQ_TABLE_END); i++) {
217 if (elanfreq_table[i].frequency > max_freq) 217 if (elanfreq_table[i].frequency > max_freq)
218 elanfreq_table[i].frequency = CPUFREQ_ENTRY_INVALID; 218 elanfreq_table[i].frequency = CPUFREQ_ENTRY_INVALID;
219 } 219 }
@@ -224,7 +224,7 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
224 224
225 result = cpufreq_frequency_table_cpuinfo(policy, elanfreq_table); 225 result = cpufreq_frequency_table_cpuinfo(policy, elanfreq_table);
226 if (result) 226 if (result)
227 return (result); 227 return result;
228 228
229 cpufreq_frequency_table_get_attr(elanfreq_table, policy->cpu); 229 cpufreq_frequency_table_get_attr(elanfreq_table, policy->cpu);
230 return 0; 230 return 0;
@@ -260,7 +260,7 @@ __setup("elanfreq=", elanfreq_setup);
260#endif 260#endif
261 261
262 262
263static struct freq_attr* elanfreq_attr[] = { 263static struct freq_attr *elanfreq_attr[] = {
264 &cpufreq_freq_attr_scaling_available_freqs, 264 &cpufreq_freq_attr_scaling_available_freqs,
265 NULL, 265 NULL,
266}; 266};
@@ -284,9 +284,9 @@ static int __init elanfreq_init(void)
284 284
285 /* Test if we have the right hardware */ 285 /* Test if we have the right hardware */
286 if ((c->x86_vendor != X86_VENDOR_AMD) || 286 if ((c->x86_vendor != X86_VENDOR_AMD) ||
287 (c->x86 != 4) || (c->x86_model!=10)) { 287 (c->x86 != 4) || (c->x86_model != 10)) {
288 printk(KERN_INFO "elanfreq: error: no Elan processor found!\n"); 288 printk(KERN_INFO "elanfreq: error: no Elan processor found!\n");
289 return -ENODEV; 289 return -ENODEV;
290 } 290 }
291 return cpufreq_register_driver(&elanfreq_driver); 291 return cpufreq_register_driver(&elanfreq_driver);
292} 292}
@@ -298,7 +298,7 @@ static void __exit elanfreq_exit(void)
298} 298}
299 299
300 300
301module_param (max_freq, int, 0444); 301module_param(max_freq, int, 0444);
302 302
303MODULE_LICENSE("GPL"); 303MODULE_LICENSE("GPL");
304MODULE_AUTHOR("Robert Schwebel <r.schwebel@pengutronix.de>, Sven Geggus <sven@geggus.net>"); 304MODULE_AUTHOR("Robert Schwebel <r.schwebel@pengutronix.de>, Sven Geggus <sven@geggus.net>");
diff --git a/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c b/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
index f1685fb91fbd..b8e05ee4f736 100644
--- a/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
+++ b/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
@@ -171,7 +171,7 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
171 } 171 }
172 172
173 if (c->x86 != 0xF) { 173 if (c->x86 != 0xF) {
174 printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <cpufreq@lists.linux.org.uk>\n"); 174 printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <cpufreq@vger.kernel.org>\n");
175 return 0; 175 return 0;
176 } 176 }
177 177
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k6.c b/arch/x86/kernel/cpu/cpufreq/powernow-k6.c
index eb9b62b0830c..b5ced806a316 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k6.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k6.c
@@ -15,12 +15,11 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16 16
17#include <asm/msr.h> 17#include <asm/msr.h>
18#include <asm/timex.h> 18#include <linux/timex.h>
19#include <asm/io.h> 19#include <linux/io.h>
20 20
21 21#define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long
22#define POWERNOW_IOPORT 0xfff0 /* it doesn't matter where, as long 22 as it is unused */
23 as it is unused */
24 23
25static unsigned int busfreq; /* FSB, in 10 kHz */ 24static unsigned int busfreq; /* FSB, in 10 kHz */
26static unsigned int max_multiplier; 25static unsigned int max_multiplier;
@@ -53,7 +52,7 @@ static int powernow_k6_get_cpu_multiplier(void)
53 52
54 msrval = POWERNOW_IOPORT + 0x1; 53 msrval = POWERNOW_IOPORT + 0x1;
55 wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */ 54 wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
56 invalue=inl(POWERNOW_IOPORT + 0x8); 55 invalue = inl(POWERNOW_IOPORT + 0x8);
57 msrval = POWERNOW_IOPORT + 0x0; 56 msrval = POWERNOW_IOPORT + 0x0;
58 wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ 57 wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */
59 58
@@ -67,9 +66,9 @@ static int powernow_k6_get_cpu_multiplier(void)
67 * 66 *
68 * Tries to change the PowerNow! multiplier 67 * Tries to change the PowerNow! multiplier
69 */ 68 */
70static void powernow_k6_set_state (unsigned int best_i) 69static void powernow_k6_set_state(unsigned int best_i)
71{ 70{
72 unsigned long outvalue=0, invalue=0; 71 unsigned long outvalue = 0, invalue = 0;
73 unsigned long msrval; 72 unsigned long msrval;
74 struct cpufreq_freqs freqs; 73 struct cpufreq_freqs freqs;
75 74
@@ -90,10 +89,10 @@ static void powernow_k6_set_state (unsigned int best_i)
90 89
91 msrval = POWERNOW_IOPORT + 0x1; 90 msrval = POWERNOW_IOPORT + 0x1;
92 wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */ 91 wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
93 invalue=inl(POWERNOW_IOPORT + 0x8); 92 invalue = inl(POWERNOW_IOPORT + 0x8);
94 invalue = invalue & 0xf; 93 invalue = invalue & 0xf;
95 outvalue = outvalue | invalue; 94 outvalue = outvalue | invalue;
96 outl(outvalue ,(POWERNOW_IOPORT + 0x8)); 95 outl(outvalue , (POWERNOW_IOPORT + 0x8));
97 msrval = POWERNOW_IOPORT + 0x0; 96 msrval = POWERNOW_IOPORT + 0x0;
98 wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ 97 wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */
99 98
@@ -124,7 +123,7 @@ static int powernow_k6_verify(struct cpufreq_policy *policy)
124 * 123 *
125 * sets a new CPUFreq policy 124 * sets a new CPUFreq policy
126 */ 125 */
127static int powernow_k6_target (struct cpufreq_policy *policy, 126static int powernow_k6_target(struct cpufreq_policy *policy,
128 unsigned int target_freq, 127 unsigned int target_freq,
129 unsigned int relation) 128 unsigned int relation)
130{ 129{
@@ -152,7 +151,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
152 busfreq = cpu_khz / max_multiplier; 151 busfreq = cpu_khz / max_multiplier;
153 152
154 /* table init */ 153 /* table init */
155 for (i=0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { 154 for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
156 if (clock_ratio[i].index > max_multiplier) 155 if (clock_ratio[i].index > max_multiplier)
157 clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; 156 clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID;
158 else 157 else
@@ -165,7 +164,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
165 164
166 result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio); 165 result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio);
167 if (result) 166 if (result)
168 return (result); 167 return result;
169 168
170 cpufreq_frequency_table_get_attr(clock_ratio, policy->cpu); 169 cpufreq_frequency_table_get_attr(clock_ratio, policy->cpu);
171 170
@@ -176,8 +175,8 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
176static int powernow_k6_cpu_exit(struct cpufreq_policy *policy) 175static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
177{ 176{
178 unsigned int i; 177 unsigned int i;
179 for (i=0; i<8; i++) { 178 for (i = 0; i < 8; i++) {
180 if (i==max_multiplier) 179 if (i == max_multiplier)
181 powernow_k6_set_state(i); 180 powernow_k6_set_state(i);
182 } 181 }
183 cpufreq_frequency_table_put_attr(policy->cpu); 182 cpufreq_frequency_table_put_attr(policy->cpu);
@@ -189,7 +188,7 @@ static unsigned int powernow_k6_get(unsigned int cpu)
189 return busfreq * powernow_k6_get_cpu_multiplier(); 188 return busfreq * powernow_k6_get_cpu_multiplier();
190} 189}
191 190
192static struct freq_attr* powernow_k6_attr[] = { 191static struct freq_attr *powernow_k6_attr[] = {
193 &cpufreq_freq_attr_scaling_available_freqs, 192 &cpufreq_freq_attr_scaling_available_freqs,
194 NULL, 193 NULL,
195}; 194};
@@ -227,7 +226,7 @@ static int __init powernow_k6_init(void)
227 } 226 }
228 227
229 if (cpufreq_register_driver(&powernow_k6_driver)) { 228 if (cpufreq_register_driver(&powernow_k6_driver)) {
230 release_region (POWERNOW_IOPORT, 16); 229 release_region(POWERNOW_IOPORT, 16);
231 return -EINVAL; 230 return -EINVAL;
232 } 231 }
233 232
@@ -243,13 +242,13 @@ static int __init powernow_k6_init(void)
243static void __exit powernow_k6_exit(void) 242static void __exit powernow_k6_exit(void)
244{ 243{
245 cpufreq_unregister_driver(&powernow_k6_driver); 244 cpufreq_unregister_driver(&powernow_k6_driver);
246 release_region (POWERNOW_IOPORT, 16); 245 release_region(POWERNOW_IOPORT, 16);
247} 246}
248 247
249 248
250MODULE_AUTHOR ("Arjan van de Ven <arjanv@redhat.com>, Dave Jones <davej@codemonkey.org.uk>, Dominik Brodowski <linux@brodo.de>"); 249MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>, Dave Jones <davej@codemonkey.org.uk>, Dominik Brodowski <linux@brodo.de>");
251MODULE_DESCRIPTION ("PowerNow! driver for AMD K6-2+ / K6-3+ processors."); 250MODULE_DESCRIPTION("PowerNow! driver for AMD K6-2+ / K6-3+ processors.");
252MODULE_LICENSE ("GPL"); 251MODULE_LICENSE("GPL");
253 252
254module_init(powernow_k6_init); 253module_init(powernow_k6_init);
255module_exit(powernow_k6_exit); 254module_exit(powernow_k6_exit);
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
index 15e13c01cc36..3b5f06423e77 100644
--- a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -26,7 +26,7 @@
26#include <asm/cpufeature.h> 26#include <asm/cpufeature.h>
27 27
28#define PFX "speedstep-centrino: " 28#define PFX "speedstep-centrino: "
29#define MAINTAINER "cpufreq@lists.linux.org.uk" 29#define MAINTAINER "cpufreq@vger.kernel.org"
30 30
31#define dprintk(msg...) \ 31#define dprintk(msg...) \
32 cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg) 32 cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "speedstep-centrino", msg)
diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c
index 898a5a2002ed..ffd0f5ed071a 100644
--- a/arch/x86/kernel/cpu/cyrix.c
+++ b/arch/x86/kernel/cpu/cyrix.c
@@ -121,7 +121,7 @@ static void __cpuinit set_cx86_reorder(void)
121 setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ 121 setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */
122 122
123 /* Load/Store Serialize to mem access disable (=reorder it) */ 123 /* Load/Store Serialize to mem access disable (=reorder it) */
124 setCx86(CX86_PCR0, getCx86(CX86_PCR0) & ~0x80); 124 setCx86_old(CX86_PCR0, getCx86_old(CX86_PCR0) & ~0x80);
125 /* set load/store serialize from 1GB to 4GB */ 125 /* set load/store serialize from 1GB to 4GB */
126 ccr3 |= 0xe0; 126 ccr3 |= 0xe0;
127 setCx86(CX86_CCR3, ccr3); 127 setCx86(CX86_CCR3, ccr3);
@@ -132,11 +132,11 @@ static void __cpuinit set_cx86_memwb(void)
132 printk(KERN_INFO "Enable Memory-Write-back mode on Cyrix/NSC processor.\n"); 132 printk(KERN_INFO "Enable Memory-Write-back mode on Cyrix/NSC processor.\n");
133 133
134 /* CCR2 bit 2: unlock NW bit */ 134 /* CCR2 bit 2: unlock NW bit */
135 setCx86(CX86_CCR2, getCx86(CX86_CCR2) & ~0x04); 135 setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) & ~0x04);
136 /* set 'Not Write-through' */ 136 /* set 'Not Write-through' */
137 write_cr0(read_cr0() | X86_CR0_NW); 137 write_cr0(read_cr0() | X86_CR0_NW);
138 /* CCR2 bit 2: lock NW bit and set WT1 */ 138 /* CCR2 bit 2: lock NW bit and set WT1 */
139 setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x14); 139 setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) | 0x14);
140} 140}
141 141
142/* 142/*
@@ -150,14 +150,14 @@ static void __cpuinit geode_configure(void)
150 local_irq_save(flags); 150 local_irq_save(flags);
151 151
152 /* Suspend on halt power saving and enable #SUSP pin */ 152 /* Suspend on halt power saving and enable #SUSP pin */
153 setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88); 153 setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) | 0x88);
154 154
155 ccr3 = getCx86(CX86_CCR3); 155 ccr3 = getCx86(CX86_CCR3);
156 setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ 156 setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */
157 157
158 158
159 /* FPU fast, DTE cache, Mem bypass */ 159 /* FPU fast, DTE cache, Mem bypass */
160 setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x38); 160 setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x38);
161 setCx86(CX86_CCR3, ccr3); /* disable MAPEN */ 161 setCx86(CX86_CCR3, ccr3); /* disable MAPEN */
162 162
163 set_cx86_memwb(); 163 set_cx86_memwb();
@@ -291,7 +291,7 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
291 /* GXm supports extended cpuid levels 'ala' AMD */ 291 /* GXm supports extended cpuid levels 'ala' AMD */
292 if (c->cpuid_level == 2) { 292 if (c->cpuid_level == 2) {
293 /* Enable cxMMX extensions (GX1 Datasheet 54) */ 293 /* Enable cxMMX extensions (GX1 Datasheet 54) */
294 setCx86(CX86_CCR7, getCx86(CX86_CCR7) | 1); 294 setCx86_old(CX86_CCR7, getCx86_old(CX86_CCR7) | 1);
295 295
296 /* 296 /*
297 * GXm : 0x30 ... 0x5f GXm datasheet 51 297 * GXm : 0x30 ... 0x5f GXm datasheet 51
@@ -301,7 +301,6 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
301 */ 301 */
302 if ((0x30 <= dir1 && dir1 <= 0x6f) || (0x80 <= dir1 && dir1 <= 0x8f)) 302 if ((0x30 <= dir1 && dir1 <= 0x6f) || (0x80 <= dir1 && dir1 <= 0x8f))
303 geode_configure(); 303 geode_configure();
304 get_model_name(c); /* get CPU marketing name */
305 return; 304 return;
306 } else { /* MediaGX */ 305 } else { /* MediaGX */
307 Cx86_cb[2] = (dir0_lsn & 1) ? '3' : '4'; 306 Cx86_cb[2] = (dir0_lsn & 1) ? '3' : '4';
@@ -314,7 +313,7 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
314 if (dir1 > 7) { 313 if (dir1 > 7) {
315 dir0_msn++; /* M II */ 314 dir0_msn++; /* M II */
316 /* Enable MMX extensions (App note 108) */ 315 /* Enable MMX extensions (App note 108) */
317 setCx86(CX86_CCR7, getCx86(CX86_CCR7)|1); 316 setCx86_old(CX86_CCR7, getCx86_old(CX86_CCR7)|1);
318 } else { 317 } else {
319 c->coma_bug = 1; /* 6x86MX, it has the bug. */ 318 c->coma_bug = 1; /* 6x86MX, it has the bug. */
320 } 319 }
@@ -429,7 +428,7 @@ static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c)
429 local_irq_save(flags); 428 local_irq_save(flags);
430 ccr3 = getCx86(CX86_CCR3); 429 ccr3 = getCx86(CX86_CCR3);
431 setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ 430 setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */
432 setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x80); /* enable cpuid */ 431 setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80); /* enable cpuid */
433 setCx86(CX86_CCR3, ccr3); /* disable MAPEN */ 432 setCx86(CX86_CCR3, ccr3); /* disable MAPEN */
434 local_irq_restore(flags); 433 local_irq_restore(flags);
435 } 434 }
@@ -442,14 +441,16 @@ static struct cpu_dev cyrix_cpu_dev __cpuinitdata = {
442 .c_early_init = early_init_cyrix, 441 .c_early_init = early_init_cyrix,
443 .c_init = init_cyrix, 442 .c_init = init_cyrix,
444 .c_identify = cyrix_identify, 443 .c_identify = cyrix_identify,
444 .c_x86_vendor = X86_VENDOR_CYRIX,
445}; 445};
446 446
447cpu_vendor_dev_register(X86_VENDOR_CYRIX, &cyrix_cpu_dev); 447cpu_dev_register(cyrix_cpu_dev);
448 448
449static struct cpu_dev nsc_cpu_dev __cpuinitdata = { 449static struct cpu_dev nsc_cpu_dev __cpuinitdata = {
450 .c_vendor = "NSC", 450 .c_vendor = "NSC",
451 .c_ident = { "Geode by NSC" }, 451 .c_ident = { "Geode by NSC" },
452 .c_init = init_nsc, 452 .c_init = init_nsc,
453 .c_x86_vendor = X86_VENDOR_NSC,
453}; 454};
454 455
455cpu_vendor_dev_register(X86_VENDOR_NSC, &nsc_cpu_dev); 456cpu_dev_register(nsc_cpu_dev);
diff --git a/arch/x86/kernel/cpu/feature_names.c b/arch/x86/kernel/cpu/feature_names.c
deleted file mode 100644
index c9017799497c..000000000000
--- a/arch/x86/kernel/cpu/feature_names.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/*
2 * Strings for the various x86 capability flags.
3 *
4 * This file must not contain any executable code.
5 */
6
7#include <asm/cpufeature.h>
8
9/*
10 * These flag bits must match the definitions in <asm/cpufeature.h>.
11 * NULL means this bit is undefined or reserved; either way it doesn't
12 * have meaning as far as Linux is concerned. Note that it's important
13 * to realize there is a difference between this table and CPUID -- if
14 * applications want to get the raw CPUID data, they should access
15 * /dev/cpu/<cpu_nr>/cpuid instead.
16 */
17const char * const x86_cap_flags[NCAPINTS*32] = {
18 /* Intel-defined */
19 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
20 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
21 "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
22 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
23
24 /* AMD-defined */
25 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
26 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
27 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
28 NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm",
29 "3dnowext", "3dnow",
30
31 /* Transmeta-defined */
32 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
33 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
34 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
35 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
36
37 /* Other (Linux-defined) */
38 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
39 NULL, NULL, NULL, NULL,
40 "constant_tsc", "up", NULL, "arch_perfmon",
41 "pebs", "bts", NULL, NULL,
42 "rep_good", NULL, NULL, NULL,
43 "nopl", NULL, NULL, NULL,
44 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
45
46 /* Intel-defined (#2) */
47 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
48 "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
49 NULL, NULL, "dca", "sse4_1", "sse4_2", NULL, NULL, "popcnt",
50 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
51
52 /* VIA/Cyrix/Centaur-defined */
53 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
54 "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
55 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
56 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
57
58 /* AMD-defined (#2) */
59 "lahf_lm", "cmp_legacy", "svm", "extapic",
60 "cr8_legacy", "abm", "sse4a", "misalignsse",
61 "3dnowprefetch", "osvw", "ibs", "sse5",
62 "skinit", "wdt", NULL, NULL,
63 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
64 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
65
66 /* Auxiliary (Linux-defined) */
67 "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
68 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
69 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
70 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
71};
72
73const char *const x86_power_flags[32] = {
74 "ts", /* temperature sensor */
75 "fid", /* frequency id control */
76 "vid", /* voltage id control */
77 "ttp", /* thermal trip */
78 "tm",
79 "stc",
80 "100mhzsteps",
81 "hwpstate",
82 "", /* tsc invariant mapped to constant_tsc */
83 /* nothing */
84};
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index b75f2569b8f8..99468dbd08da 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -15,6 +15,11 @@
15#include <asm/ds.h> 15#include <asm/ds.h>
16#include <asm/bugs.h> 16#include <asm/bugs.h>
17 17
18#ifdef CONFIG_X86_64
19#include <asm/topology.h>
20#include <asm/numa_64.h>
21#endif
22
18#include "cpu.h" 23#include "cpu.h"
19 24
20#ifdef CONFIG_X86_LOCAL_APIC 25#ifdef CONFIG_X86_LOCAL_APIC
@@ -23,23 +28,22 @@
23#include <mach_apic.h> 28#include <mach_apic.h>
24#endif 29#endif
25 30
26#ifdef CONFIG_X86_INTEL_USERCOPY
27/*
28 * Alignment at which movsl is preferred for bulk memory copies.
29 */
30struct movsl_mask movsl_mask __read_mostly;
31#endif
32
33static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) 31static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
34{ 32{
35 /* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
36 if (c->x86 == 15 && c->x86_cache_alignment == 64)
37 c->x86_cache_alignment = 128;
38 if ((c->x86 == 0xf && c->x86_model >= 0x03) || 33 if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
39 (c->x86 == 0x6 && c->x86_model >= 0x0e)) 34 (c->x86 == 0x6 && c->x86_model >= 0x0e))
40 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 35 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
36
37#ifdef CONFIG_X86_64
38 set_cpu_cap(c, X86_FEATURE_SYSENTER32);
39#else
40 /* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
41 if (c->x86 == 15 && c->x86_cache_alignment == 64)
42 c->x86_cache_alignment = 128;
43#endif
41} 44}
42 45
46#ifdef CONFIG_X86_32
43/* 47/*
44 * Early probe support logic for ppro memory erratum #50 48 * Early probe support logic for ppro memory erratum #50
45 * 49 *
@@ -59,15 +63,54 @@ int __cpuinit ppro_with_ram_bug(void)
59 return 0; 63 return 0;
60} 64}
61 65
66#ifdef CONFIG_X86_F00F_BUG
67static void __cpuinit trap_init_f00f_bug(void)
68{
69 __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO);
62 70
63/* 71 /*
64 * P4 Xeon errata 037 workaround. 72 * Update the IDT descriptor and reload the IDT so that
65 * Hardware prefetcher may cause stale data to be loaded into the cache. 73 * it uses the read-only mapped virtual address.
66 */ 74 */
67static void __cpuinit Intel_errata_workarounds(struct cpuinfo_x86 *c) 75 idt_descr.address = fix_to_virt(FIX_F00F_IDT);
76 load_idt(&idt_descr);
77}
78#endif
79
80static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
68{ 81{
69 unsigned long lo, hi; 82 unsigned long lo, hi;
70 83
84#ifdef CONFIG_X86_F00F_BUG
85 /*
86 * All current models of Pentium and Pentium with MMX technology CPUs
87 * have the F0 0F bug, which lets nonprivileged users lock up the system.
88 * Note that the workaround only should be initialized once...
89 */
90 c->f00f_bug = 0;
91 if (!paravirt_enabled() && c->x86 == 5) {
92 static int f00f_workaround_enabled;
93
94 c->f00f_bug = 1;
95 if (!f00f_workaround_enabled) {
96 trap_init_f00f_bug();
97 printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n");
98 f00f_workaround_enabled = 1;
99 }
100 }
101#endif
102
103 /*
104 * SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until
105 * model 3 mask 3
106 */
107 if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633)
108 clear_cpu_cap(c, X86_FEATURE_SEP);
109
110 /*
111 * P4 Xeon errata 037 workaround.
112 * Hardware prefetcher may cause stale data to be loaded into the cache.
113 */
71 if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_mask == 1)) { 114 if ((c->x86 == 15) && (c->x86_model == 1) && (c->x86_mask == 1)) {
72 rdmsr(MSR_IA32_MISC_ENABLE, lo, hi); 115 rdmsr(MSR_IA32_MISC_ENABLE, lo, hi);
73 if ((lo & (1<<9)) == 0) { 116 if ((lo & (1<<9)) == 0) {
@@ -77,13 +120,68 @@ static void __cpuinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
77 wrmsr (MSR_IA32_MISC_ENABLE, lo, hi); 120 wrmsr (MSR_IA32_MISC_ENABLE, lo, hi);
78 } 121 }
79 } 122 }
123
124 /*
125 * See if we have a good local APIC by checking for buggy Pentia,
126 * i.e. all B steppings and the C2 stepping of P54C when using their
127 * integrated APIC (see 11AP erratum in "Pentium Processor
128 * Specification Update").
129 */
130 if (cpu_has_apic && (c->x86<<8 | c->x86_model<<4) == 0x520 &&
131 (c->x86_mask < 0x6 || c->x86_mask == 0xb))
132 set_cpu_cap(c, X86_FEATURE_11AP);
133
134
135#ifdef CONFIG_X86_INTEL_USERCOPY
136 /*
137 * Set up the preferred alignment for movsl bulk memory moves
138 */
139 switch (c->x86) {
140 case 4: /* 486: untested */
141 break;
142 case 5: /* Old Pentia: untested */
143 break;
144 case 6: /* PII/PIII only like movsl with 8-byte alignment */
145 movsl_mask.mask = 7;
146 break;
147 case 15: /* P4 is OK down to 8-byte alignment */
148 movsl_mask.mask = 7;
149 break;
150 }
151#endif
152
153#ifdef CONFIG_X86_NUMAQ
154 numaq_tsc_disable();
155#endif
80} 156}
157#else
158static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
159{
160}
161#endif
81 162
163static void __cpuinit srat_detect_node(void)
164{
165#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64)
166 unsigned node;
167 int cpu = smp_processor_id();
168 int apicid = hard_smp_processor_id();
169
170 /* Don't do the funky fallback heuristics the AMD version employs
171 for now. */
172 node = apicid_to_node[apicid];
173 if (node == NUMA_NO_NODE || !node_online(node))
174 node = first_node(node_online_map);
175 numa_set_node(cpu, node);
176
177 printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
178#endif
179}
82 180
83/* 181/*
84 * find out the number of processor cores on the die 182 * find out the number of processor cores on the die
85 */ 183 */
86static int __cpuinit num_cpu_cores(struct cpuinfo_x86 *c) 184static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
87{ 185{
88 unsigned int eax, ebx, ecx, edx; 186 unsigned int eax, ebx, ecx, edx;
89 187
@@ -98,45 +196,51 @@ static int __cpuinit num_cpu_cores(struct cpuinfo_x86 *c)
98 return 1; 196 return 1;
99} 197}
100 198
101#ifdef CONFIG_X86_F00F_BUG 199static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c)
102static void __cpuinit trap_init_f00f_bug(void)
103{ 200{
104 __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO); 201 /* Intel VMX MSR indicated features */
105 202#define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW 0x00200000
106 /* 203#define X86_VMX_FEATURE_PROC_CTLS_VNMI 0x00400000
107 * Update the IDT descriptor and reload the IDT so that 204#define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS 0x80000000
108 * it uses the read-only mapped virtual address. 205#define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC 0x00000001
109 */ 206#define X86_VMX_FEATURE_PROC_CTLS2_EPT 0x00000002
110 idt_descr.address = fix_to_virt(FIX_F00F_IDT); 207#define X86_VMX_FEATURE_PROC_CTLS2_VPID 0x00000020
111 load_idt(&idt_descr); 208
209 u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2;
210
211 clear_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
212 clear_cpu_cap(c, X86_FEATURE_VNMI);
213 clear_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
214 clear_cpu_cap(c, X86_FEATURE_EPT);
215 clear_cpu_cap(c, X86_FEATURE_VPID);
216
217 rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, vmx_msr_low, vmx_msr_high);
218 msr_ctl = vmx_msr_high | vmx_msr_low;
219 if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW)
220 set_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
221 if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_VNMI)
222 set_cpu_cap(c, X86_FEATURE_VNMI);
223 if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS) {
224 rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2,
225 vmx_msr_low, vmx_msr_high);
226 msr_ctl2 = vmx_msr_high | vmx_msr_low;
227 if ((msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC) &&
228 (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW))
229 set_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
230 if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_EPT)
231 set_cpu_cap(c, X86_FEATURE_EPT);
232 if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VPID)
233 set_cpu_cap(c, X86_FEATURE_VPID);
234 }
112} 235}
113#endif
114 236
115static void __cpuinit init_intel(struct cpuinfo_x86 *c) 237static void __cpuinit init_intel(struct cpuinfo_x86 *c)
116{ 238{
117 unsigned int l2 = 0; 239 unsigned int l2 = 0;
118 char *p = NULL;
119 240
120 early_init_intel(c); 241 early_init_intel(c);
121 242
122#ifdef CONFIG_X86_F00F_BUG 243 intel_workarounds(c);
123 /*
124 * All current models of Pentium and Pentium with MMX technology CPUs
125 * have the F0 0F bug, which lets nonprivileged users lock up the system.
126 * Note that the workaround only should be initialized once...
127 */
128 c->f00f_bug = 0;
129 if (!paravirt_enabled() && c->x86 == 5) {
130 static int f00f_workaround_enabled;
131
132 c->f00f_bug = 1;
133 if (!f00f_workaround_enabled) {
134 trap_init_f00f_bug();
135 printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n");
136 f00f_workaround_enabled = 1;
137 }
138 }
139#endif
140 244
141 l2 = init_intel_cacheinfo(c); 245 l2 = init_intel_cacheinfo(c);
142 if (c->cpuid_level > 9) { 246 if (c->cpuid_level > 9) {
@@ -146,16 +250,32 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
146 set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON); 250 set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
147 } 251 }
148 252
149 /* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until model 3 mask 3 */ 253 if (cpu_has_xmm2)
150 if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633) 254 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
151 clear_cpu_cap(c, X86_FEATURE_SEP); 255 if (cpu_has_ds) {
256 unsigned int l1;
257 rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
258 if (!(l1 & (1<<11)))
259 set_cpu_cap(c, X86_FEATURE_BTS);
260 if (!(l1 & (1<<12)))
261 set_cpu_cap(c, X86_FEATURE_PEBS);
262 ds_init_intel(c);
263 }
152 264
265#ifdef CONFIG_X86_64
266 if (c->x86 == 15)
267 c->x86_cache_alignment = c->x86_clflush_size * 2;
268 if (c->x86 == 6)
269 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
270#else
153 /* 271 /*
154 * Names for the Pentium II/Celeron processors 272 * Names for the Pentium II/Celeron processors
155 * detectable only by also checking the cache size. 273 * detectable only by also checking the cache size.
156 * Dixon is NOT a Celeron. 274 * Dixon is NOT a Celeron.
157 */ 275 */
158 if (c->x86 == 6) { 276 if (c->x86 == 6) {
277 char *p = NULL;
278
159 switch (c->x86_model) { 279 switch (c->x86_model) {
160 case 5: 280 case 5:
161 if (c->x86_mask == 0) { 281 if (c->x86_mask == 0) {
@@ -178,70 +298,41 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
178 p = "Celeron (Coppermine)"; 298 p = "Celeron (Coppermine)";
179 break; 299 break;
180 } 300 }
181 }
182
183 if (p)
184 strcpy(c->x86_model_id, p);
185
186 c->x86_max_cores = num_cpu_cores(c);
187
188 detect_ht(c);
189 301
190 /* Work around errata */ 302 if (p)
191 Intel_errata_workarounds(c); 303 strcpy(c->x86_model_id, p);
192
193#ifdef CONFIG_X86_INTEL_USERCOPY
194 /*
195 * Set up the preferred alignment for movsl bulk memory moves
196 */
197 switch (c->x86) {
198 case 4: /* 486: untested */
199 break;
200 case 5: /* Old Pentia: untested */
201 break;
202 case 6: /* PII/PIII only like movsl with 8-byte alignment */
203 movsl_mask.mask = 7;
204 break;
205 case 15: /* P4 is OK down to 8-byte alignment */
206 movsl_mask.mask = 7;
207 break;
208 } 304 }
209#endif
210 305
211 if (cpu_has_xmm2) 306 if (c->x86 == 15)
212 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
213 if (c->x86 == 15) {
214 set_cpu_cap(c, X86_FEATURE_P4); 307 set_cpu_cap(c, X86_FEATURE_P4);
215 }
216 if (c->x86 == 6) 308 if (c->x86 == 6)
217 set_cpu_cap(c, X86_FEATURE_P3); 309 set_cpu_cap(c, X86_FEATURE_P3);
218 if (cpu_has_ds) {
219 unsigned int l1;
220 rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
221 if (!(l1 & (1<<11)))
222 set_cpu_cap(c, X86_FEATURE_BTS);
223 if (!(l1 & (1<<12)))
224 set_cpu_cap(c, X86_FEATURE_PEBS);
225 }
226 310
227 if (cpu_has_bts) 311 if (cpu_has_bts)
228 ds_init_intel(c); 312 ptrace_bts_init_intel(c);
229 313
230 /* 314#endif
231 * See if we have a good local APIC by checking for buggy Pentia,
232 * i.e. all B steppings and the C2 stepping of P54C when using their
233 * integrated APIC (see 11AP erratum in "Pentium Processor
234 * Specification Update").
235 */
236 if (cpu_has_apic && (c->x86<<8 | c->x86_model<<4) == 0x520 &&
237 (c->x86_mask < 0x6 || c->x86_mask == 0xb))
238 set_cpu_cap(c, X86_FEATURE_11AP);
239 315
240#ifdef CONFIG_X86_NUMAQ 316 detect_extended_topology(c);
241 numaq_tsc_disable(); 317 if (!cpu_has(c, X86_FEATURE_XTOPOLOGY)) {
318 /*
319 * let's use the legacy cpuid vector 0x1 and 0x4 for topology
320 * detection.
321 */
322 c->x86_max_cores = intel_num_cpu_cores(c);
323#ifdef CONFIG_X86_32
324 detect_ht(c);
242#endif 325#endif
326 }
327
328 /* Work around errata */
329 srat_detect_node();
330
331 if (cpu_has(c, X86_FEATURE_VMX))
332 detect_vmx_virtcap(c);
243} 333}
244 334
335#ifdef CONFIG_X86_32
245static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned int size) 336static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
246{ 337{
247 /* 338 /*
@@ -254,10 +345,12 @@ static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned i
254 size = 256; 345 size = 256;
255 return size; 346 return size;
256} 347}
348#endif
257 349
258static struct cpu_dev intel_cpu_dev __cpuinitdata = { 350static struct cpu_dev intel_cpu_dev __cpuinitdata = {
259 .c_vendor = "Intel", 351 .c_vendor = "Intel",
260 .c_ident = { "GenuineIntel" }, 352 .c_ident = { "GenuineIntel" },
353#ifdef CONFIG_X86_32
261 .c_models = { 354 .c_models = {
262 { .vendor = X86_VENDOR_INTEL, .family = 4, .model_names = 355 { .vendor = X86_VENDOR_INTEL, .family = 4, .model_names =
263 { 356 {
@@ -307,76 +400,12 @@ static struct cpu_dev intel_cpu_dev __cpuinitdata = {
307 } 400 }
308 }, 401 },
309 }, 402 },
403 .c_size_cache = intel_size_cache,
404#endif
310 .c_early_init = early_init_intel, 405 .c_early_init = early_init_intel,
311 .c_init = init_intel, 406 .c_init = init_intel,
312 .c_size_cache = intel_size_cache, 407 .c_x86_vendor = X86_VENDOR_INTEL,
313}; 408};
314 409
315cpu_vendor_dev_register(X86_VENDOR_INTEL, &intel_cpu_dev); 410cpu_dev_register(intel_cpu_dev);
316
317#ifndef CONFIG_X86_CMPXCHG
318unsigned long cmpxchg_386_u8(volatile void *ptr, u8 old, u8 new)
319{
320 u8 prev;
321 unsigned long flags;
322
323 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
324 local_irq_save(flags);
325 prev = *(u8 *)ptr;
326 if (prev == old)
327 *(u8 *)ptr = new;
328 local_irq_restore(flags);
329 return prev;
330}
331EXPORT_SYMBOL(cmpxchg_386_u8);
332
333unsigned long cmpxchg_386_u16(volatile void *ptr, u16 old, u16 new)
334{
335 u16 prev;
336 unsigned long flags;
337
338 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
339 local_irq_save(flags);
340 prev = *(u16 *)ptr;
341 if (prev == old)
342 *(u16 *)ptr = new;
343 local_irq_restore(flags);
344 return prev;
345}
346EXPORT_SYMBOL(cmpxchg_386_u16);
347
348unsigned long cmpxchg_386_u32(volatile void *ptr, u32 old, u32 new)
349{
350 u32 prev;
351 unsigned long flags;
352
353 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
354 local_irq_save(flags);
355 prev = *(u32 *)ptr;
356 if (prev == old)
357 *(u32 *)ptr = new;
358 local_irq_restore(flags);
359 return prev;
360}
361EXPORT_SYMBOL(cmpxchg_386_u32);
362#endif
363
364#ifndef CONFIG_X86_CMPXCHG64
365unsigned long long cmpxchg_486_u64(volatile void *ptr, u64 old, u64 new)
366{
367 u64 prev;
368 unsigned long flags;
369
370 /* Poor man's cmpxchg8b for 386 and 486. Unsuitable for SMP */
371 local_irq_save(flags);
372 prev = *(u64 *)ptr;
373 if (prev == old)
374 *(u64 *)ptr = new;
375 local_irq_restore(flags);
376 return prev;
377}
378EXPORT_SYMBOL(cmpxchg_486_u64);
379#endif
380
381/* arch_initcall(intel_cpu_init); */
382 411
diff --git a/arch/x86/kernel/cpu/intel_64.c b/arch/x86/kernel/cpu/intel_64.c
deleted file mode 100644
index 1019c58d39f0..000000000000
--- a/arch/x86/kernel/cpu/intel_64.c
+++ /dev/null
@@ -1,95 +0,0 @@
1#include <linux/init.h>
2#include <linux/smp.h>
3#include <asm/processor.h>
4#include <asm/ptrace.h>
5#include <asm/topology.h>
6#include <asm/numa_64.h>
7
8#include "cpu.h"
9
10static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
11{
12 if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
13 (c->x86 == 0x6 && c->x86_model >= 0x0e))
14 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
15
16 set_cpu_cap(c, X86_FEATURE_SYSENTER32);
17}
18
19/*
20 * find out the number of processor cores on the die
21 */
22static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
23{
24 unsigned int eax, t;
25
26 if (c->cpuid_level < 4)
27 return 1;
28
29 cpuid_count(4, 0, &eax, &t, &t, &t);
30
31 if (eax & 0x1f)
32 return ((eax >> 26) + 1);
33 else
34 return 1;
35}
36
37static void __cpuinit srat_detect_node(void)
38{
39#ifdef CONFIG_NUMA
40 unsigned node;
41 int cpu = smp_processor_id();
42 int apicid = hard_smp_processor_id();
43
44 /* Don't do the funky fallback heuristics the AMD version employs
45 for now. */
46 node = apicid_to_node[apicid];
47 if (node == NUMA_NO_NODE || !node_online(node))
48 node = first_node(node_online_map);
49 numa_set_node(cpu, node);
50
51 printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
52#endif
53}
54
55static void __cpuinit init_intel(struct cpuinfo_x86 *c)
56{
57 init_intel_cacheinfo(c);
58 if (c->cpuid_level > 9) {
59 unsigned eax = cpuid_eax(10);
60 /* Check for version and the number of counters */
61 if ((eax & 0xff) && (((eax>>8) & 0xff) > 1))
62 set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
63 }
64
65 if (cpu_has_ds) {
66 unsigned int l1, l2;
67 rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
68 if (!(l1 & (1<<11)))
69 set_cpu_cap(c, X86_FEATURE_BTS);
70 if (!(l1 & (1<<12)))
71 set_cpu_cap(c, X86_FEATURE_PEBS);
72 }
73
74
75 if (cpu_has_bts)
76 ds_init_intel(c);
77
78 if (c->x86 == 15)
79 c->x86_cache_alignment = c->x86_clflush_size * 2;
80 if (c->x86 == 6)
81 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
82 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
83 c->x86_max_cores = intel_num_cpu_cores(c);
84
85 srat_detect_node();
86}
87
88static struct cpu_dev intel_cpu_dev __cpuinitdata = {
89 .c_vendor = "Intel",
90 .c_ident = { "GenuineIntel" },
91 .c_early_init = early_init_intel,
92 .c_init = init_intel,
93};
94cpu_vendor_dev_register(X86_VENDOR_INTEL, &intel_cpu_dev);
95
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 6b0a10b002f1..3f46afbb1cf1 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Routines to indentify caches on Intel CPU. 2 * Routines to indentify caches on Intel CPU.
3 * 3 *
4 * Changes: 4 * Changes:
5 * Venkatesh Pallipadi : Adding cache identification through cpuid(4) 5 * Venkatesh Pallipadi : Adding cache identification through cpuid(4)
6 * Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure. 6 * Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure.
7 * Andi Kleen / Andreas Herrmann : CPUID4 emulation on AMD. 7 * Andi Kleen / Andreas Herrmann : CPUID4 emulation on AMD.
8 */ 8 */
@@ -13,6 +13,7 @@
13#include <linux/compiler.h> 13#include <linux/compiler.h>
14#include <linux/cpu.h> 14#include <linux/cpu.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/pci.h>
16 17
17#include <asm/processor.h> 18#include <asm/processor.h>
18#include <asm/smp.h> 19#include <asm/smp.h>
@@ -130,9 +131,18 @@ struct _cpuid4_info {
130 union _cpuid4_leaf_ebx ebx; 131 union _cpuid4_leaf_ebx ebx;
131 union _cpuid4_leaf_ecx ecx; 132 union _cpuid4_leaf_ecx ecx;
132 unsigned long size; 133 unsigned long size;
134 unsigned long can_disable;
133 cpumask_t shared_cpu_map; /* future?: only cpus/node is needed */ 135 cpumask_t shared_cpu_map; /* future?: only cpus/node is needed */
134}; 136};
135 137
138#ifdef CONFIG_PCI
139static struct pci_device_id k8_nb_id[] = {
140 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) },
141 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1203) },
142 {}
143};
144#endif
145
136unsigned short num_cache_leaves; 146unsigned short num_cache_leaves;
137 147
138/* AMD doesn't have CPUID4. Emulate it here to report the same 148/* AMD doesn't have CPUID4. Emulate it here to report the same
@@ -182,9 +192,10 @@ static unsigned short assocs[] __cpuinitdata = {
182static unsigned char levels[] __cpuinitdata = { 1, 1, 2, 3 }; 192static unsigned char levels[] __cpuinitdata = { 1, 1, 2, 3 };
183static unsigned char types[] __cpuinitdata = { 1, 2, 3, 3 }; 193static unsigned char types[] __cpuinitdata = { 1, 2, 3, 3 };
184 194
185static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, 195static void __cpuinit
186 union _cpuid4_leaf_ebx *ebx, 196amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
187 union _cpuid4_leaf_ecx *ecx) 197 union _cpuid4_leaf_ebx *ebx,
198 union _cpuid4_leaf_ecx *ecx)
188{ 199{
189 unsigned dummy; 200 unsigned dummy;
190 unsigned line_size, lines_per_tag, assoc, size_in_kb; 201 unsigned line_size, lines_per_tag, assoc, size_in_kb;
@@ -251,27 +262,40 @@ static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
251 (ebx->split.ways_of_associativity + 1) - 1; 262 (ebx->split.ways_of_associativity + 1) - 1;
252} 263}
253 264
254static int __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) 265static void __cpuinit
266amd_check_l3_disable(int index, struct _cpuid4_info *this_leaf)
267{
268 if (index < 3)
269 return;
270 this_leaf->can_disable = 1;
271}
272
273static int
274__cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf)
255{ 275{
256 union _cpuid4_leaf_eax eax; 276 union _cpuid4_leaf_eax eax;
257 union _cpuid4_leaf_ebx ebx; 277 union _cpuid4_leaf_ebx ebx;
258 union _cpuid4_leaf_ecx ecx; 278 union _cpuid4_leaf_ecx ecx;
259 unsigned edx; 279 unsigned edx;
260 280
261 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) 281 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
262 amd_cpuid4(index, &eax, &ebx, &ecx); 282 amd_cpuid4(index, &eax, &ebx, &ecx);
263 else 283 if (boot_cpu_data.x86 >= 0x10)
264 cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &edx); 284 amd_check_l3_disable(index, this_leaf);
285 } else {
286 cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &edx);
287 }
288
265 if (eax.split.type == CACHE_TYPE_NULL) 289 if (eax.split.type == CACHE_TYPE_NULL)
266 return -EIO; /* better error ? */ 290 return -EIO; /* better error ? */
267 291
268 this_leaf->eax = eax; 292 this_leaf->eax = eax;
269 this_leaf->ebx = ebx; 293 this_leaf->ebx = ebx;
270 this_leaf->ecx = ecx; 294 this_leaf->ecx = ecx;
271 this_leaf->size = (ecx.split.number_of_sets + 1) * 295 this_leaf->size = (ecx.split.number_of_sets + 1) *
272 (ebx.split.coherency_line_size + 1) * 296 (ebx.split.coherency_line_size + 1) *
273 (ebx.split.physical_line_partition + 1) * 297 (ebx.split.physical_line_partition + 1) *
274 (ebx.split.ways_of_associativity + 1); 298 (ebx.split.ways_of_associativity + 1);
275 return 0; 299 return 0;
276} 300}
277 301
@@ -453,7 +477,7 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
453 477
454/* pointer to _cpuid4_info array (for each cache leaf) */ 478/* pointer to _cpuid4_info array (for each cache leaf) */
455static DEFINE_PER_CPU(struct _cpuid4_info *, cpuid4_info); 479static DEFINE_PER_CPU(struct _cpuid4_info *, cpuid4_info);
456#define CPUID4_INFO_IDX(x, y) (&((per_cpu(cpuid4_info, x))[y])) 480#define CPUID4_INFO_IDX(x, y) (&((per_cpu(cpuid4_info, x))[y]))
457 481
458#ifdef CONFIG_SMP 482#ifdef CONFIG_SMP
459static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) 483static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
@@ -490,7 +514,7 @@ static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
490 514
491 this_leaf = CPUID4_INFO_IDX(cpu, index); 515 this_leaf = CPUID4_INFO_IDX(cpu, index);
492 for_each_cpu_mask_nr(sibling, this_leaf->shared_cpu_map) { 516 for_each_cpu_mask_nr(sibling, this_leaf->shared_cpu_map) {
493 sibling_leaf = CPUID4_INFO_IDX(sibling, index); 517 sibling_leaf = CPUID4_INFO_IDX(sibling, index);
494 cpu_clear(cpu, sibling_leaf->shared_cpu_map); 518 cpu_clear(cpu, sibling_leaf->shared_cpu_map);
495 } 519 }
496} 520}
@@ -572,7 +596,7 @@ struct _index_kobject {
572 596
573/* pointer to array of kobjects for cpuX/cache/indexY */ 597/* pointer to array of kobjects for cpuX/cache/indexY */
574static DEFINE_PER_CPU(struct _index_kobject *, index_kobject); 598static DEFINE_PER_CPU(struct _index_kobject *, index_kobject);
575#define INDEX_KOBJECT_PTR(x, y) (&((per_cpu(index_kobject, x))[y])) 599#define INDEX_KOBJECT_PTR(x, y) (&((per_cpu(index_kobject, x))[y]))
576 600
577#define show_one_plus(file_name, object, val) \ 601#define show_one_plus(file_name, object, val) \
578static ssize_t show_##file_name \ 602static ssize_t show_##file_name \
@@ -637,6 +661,99 @@ static ssize_t show_type(struct _cpuid4_info *this_leaf, char *buf) {
637 } 661 }
638} 662}
639 663
664#define to_object(k) container_of(k, struct _index_kobject, kobj)
665#define to_attr(a) container_of(a, struct _cache_attr, attr)
666
667#ifdef CONFIG_PCI
668static struct pci_dev *get_k8_northbridge(int node)
669{
670 struct pci_dev *dev = NULL;
671 int i;
672
673 for (i = 0; i <= node; i++) {
674 do {
675 dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
676 if (!dev)
677 break;
678 } while (!pci_match_id(&k8_nb_id[0], dev));
679 if (!dev)
680 break;
681 }
682 return dev;
683}
684#else
685static struct pci_dev *get_k8_northbridge(int node)
686{
687 return NULL;
688}
689#endif
690
691static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf)
692{
693 int node = cpu_to_node(first_cpu(this_leaf->shared_cpu_map));
694 struct pci_dev *dev = NULL;
695 ssize_t ret = 0;
696 int i;
697
698 if (!this_leaf->can_disable)
699 return sprintf(buf, "Feature not enabled\n");
700
701 dev = get_k8_northbridge(node);
702 if (!dev) {
703 printk(KERN_ERR "Attempting AMD northbridge operation on a system with no northbridge\n");
704 return -EINVAL;
705 }
706
707 for (i = 0; i < 2; i++) {
708 unsigned int reg;
709
710 pci_read_config_dword(dev, 0x1BC + i * 4, &reg);
711
712 ret += sprintf(buf, "%sEntry: %d\n", buf, i);
713 ret += sprintf(buf, "%sReads: %s\tNew Entries: %s\n",
714 buf,
715 reg & 0x80000000 ? "Disabled" : "Allowed",
716 reg & 0x40000000 ? "Disabled" : "Allowed");
717 ret += sprintf(buf, "%sSubCache: %x\tIndex: %x\n",
718 buf, (reg & 0x30000) >> 16, reg & 0xfff);
719 }
720 return ret;
721}
722
723static ssize_t
724store_cache_disable(struct _cpuid4_info *this_leaf, const char *buf,
725 size_t count)
726{
727 int node = cpu_to_node(first_cpu(this_leaf->shared_cpu_map));
728 struct pci_dev *dev = NULL;
729 unsigned int ret, index, val;
730
731 if (!this_leaf->can_disable)
732 return 0;
733
734 if (strlen(buf) > 15)
735 return -EINVAL;
736
737 ret = sscanf(buf, "%x %x", &index, &val);
738 if (ret != 2)
739 return -EINVAL;
740 if (index > 1)
741 return -EINVAL;
742
743 val |= 0xc0000000;
744 dev = get_k8_northbridge(node);
745 if (!dev) {
746 printk(KERN_ERR "Attempting AMD northbridge operation on a system with no northbridge\n");
747 return -EINVAL;
748 }
749
750 pci_write_config_dword(dev, 0x1BC + index * 4, val & ~0x40000000);
751 wbinvd();
752 pci_write_config_dword(dev, 0x1BC + index * 4, val);
753
754 return 1;
755}
756
640struct _cache_attr { 757struct _cache_attr {
641 struct attribute attr; 758 struct attribute attr;
642 ssize_t (*show)(struct _cpuid4_info *, char *); 759 ssize_t (*show)(struct _cpuid4_info *, char *);
@@ -657,6 +774,8 @@ define_one_ro(size);
657define_one_ro(shared_cpu_map); 774define_one_ro(shared_cpu_map);
658define_one_ro(shared_cpu_list); 775define_one_ro(shared_cpu_list);
659 776
777static struct _cache_attr cache_disable = __ATTR(cache_disable, 0644, show_cache_disable, store_cache_disable);
778
660static struct attribute * default_attrs[] = { 779static struct attribute * default_attrs[] = {
661 &type.attr, 780 &type.attr,
662 &level.attr, 781 &level.attr,
@@ -667,12 +786,10 @@ static struct attribute * default_attrs[] = {
667 &size.attr, 786 &size.attr,
668 &shared_cpu_map.attr, 787 &shared_cpu_map.attr,
669 &shared_cpu_list.attr, 788 &shared_cpu_list.attr,
789 &cache_disable.attr,
670 NULL 790 NULL
671}; 791};
672 792
673#define to_object(k) container_of(k, struct _index_kobject, kobj)
674#define to_attr(a) container_of(a, struct _cache_attr, attr)
675
676static ssize_t show(struct kobject * kobj, struct attribute * attr, char * buf) 793static ssize_t show(struct kobject * kobj, struct attribute * attr, char * buf)
677{ 794{
678 struct _cache_attr *fattr = to_attr(attr); 795 struct _cache_attr *fattr = to_attr(attr);
@@ -682,14 +799,22 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr, char * buf)
682 ret = fattr->show ? 799 ret = fattr->show ?
683 fattr->show(CPUID4_INFO_IDX(this_leaf->cpu, this_leaf->index), 800 fattr->show(CPUID4_INFO_IDX(this_leaf->cpu, this_leaf->index),
684 buf) : 801 buf) :
685 0; 802 0;
686 return ret; 803 return ret;
687} 804}
688 805
689static ssize_t store(struct kobject * kobj, struct attribute * attr, 806static ssize_t store(struct kobject * kobj, struct attribute * attr,
690 const char * buf, size_t count) 807 const char * buf, size_t count)
691{ 808{
692 return 0; 809 struct _cache_attr *fattr = to_attr(attr);
810 struct _index_kobject *this_leaf = to_object(kobj);
811 ssize_t ret;
812
813 ret = fattr->store ?
814 fattr->store(CPUID4_INFO_IDX(this_leaf->cpu, this_leaf->index),
815 buf, count) :
816 0;
817 return ret;
693} 818}
694 819
695static struct sysfs_ops sysfs_ops = { 820static struct sysfs_ops sysfs_ops = {
diff --git a/arch/x86/kernel/cpu/mcheck/mce_64.c b/arch/x86/kernel/cpu/mcheck/mce_64.c
index 726a5fcdf341..4b031a4ac856 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_64.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_64.c
@@ -860,7 +860,7 @@ error:
860 return err; 860 return err;
861} 861}
862 862
863static void mce_remove_device(unsigned int cpu) 863static __cpuinit void mce_remove_device(unsigned int cpu)
864{ 864{
865 int i; 865 int i;
866 866
diff --git a/arch/x86/kernel/cpu/mkcapflags.pl b/arch/x86/kernel/cpu/mkcapflags.pl
new file mode 100644
index 000000000000..dfea390e1608
--- /dev/null
+++ b/arch/x86/kernel/cpu/mkcapflags.pl
@@ -0,0 +1,32 @@
1#!/usr/bin/perl
2#
3# Generate the x86_cap_flags[] array from include/asm-x86/cpufeature.h
4#
5
6($in, $out) = @ARGV;
7
8open(IN, "< $in\0") or die "$0: cannot open: $in: $!\n";
9open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n";
10
11print OUT "#include <asm/cpufeature.h>\n\n";
12print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n";
13
14while (defined($line = <IN>)) {
15 if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) {
16 $macro = $1;
17 $feature = $2;
18 $tail = $3;
19 if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) {
20 $feature = $1;
21 }
22
23 if ($feature ne '') {
24 printf OUT "\t%-32s = \"%s\",\n",
25 "[$macro]", "\L$feature";
26 }
27 }
28}
29print OUT "};\n";
30
31close(IN);
32close(OUT);
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
index cb7d3b6a80eb..4e8d77f01eeb 100644
--- a/arch/x86/kernel/cpu/mtrr/generic.c
+++ b/arch/x86/kernel/cpu/mtrr/generic.c
@@ -401,12 +401,7 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base,
401 tmp |= ~((1<<(hi - 1)) - 1); 401 tmp |= ~((1<<(hi - 1)) - 1);
402 402
403 if (tmp != mask_lo) { 403 if (tmp != mask_lo) {
404 static int once = 1; 404 WARN_ONCE(1, KERN_INFO "mtrr: your BIOS has set up an incorrect mask, fixing it up.\n");
405
406 if (once) {
407 printk(KERN_INFO "mtrr: your BIOS has set up an incorrect mask, fixing it up.\n");
408 once = 0;
409 }
410 mask_lo = tmp; 405 mask_lo = tmp;
411 } 406 }
412 } 407 }
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index 84c480bb3715..4c4214690dd1 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -405,9 +405,9 @@ static int mtrr_seq_show(struct seq_file *seq, void *offset)
405 } 405 }
406 /* RED-PEN: base can be > 32bit */ 406 /* RED-PEN: base can be > 32bit */
407 len += seq_printf(seq, 407 len += seq_printf(seq,
408 "reg%02i: base=0x%05lx000 (%4luMB), size=%4lu%cB: %s, count=%d\n", 408 "reg%02i: base=0x%06lx000 (%5luMB), size=%5lu%cB, count=%d: %s\n",
409 i, base, base >> (20 - PAGE_SHIFT), size, factor, 409 i, base, base >> (20 - PAGE_SHIFT), size, factor,
410 mtrr_attrib_to_str(type), mtrr_usage_table[i]); 410 mtrr_usage_table[i], mtrr_attrib_to_str(type));
411 } 411 }
412 } 412 }
413 return 0; 413 return 0;
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index b117d7f8a564..c78c04821ea1 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -729,7 +729,7 @@ struct var_mtrr_range_state {
729 mtrr_type type; 729 mtrr_type type;
730}; 730};
731 731
732struct var_mtrr_range_state __initdata range_state[RANGE_NUM]; 732static struct var_mtrr_range_state __initdata range_state[RANGE_NUM];
733static int __initdata debug_print; 733static int __initdata debug_print;
734 734
735static int __init 735static int __init
@@ -759,7 +759,8 @@ x86_get_mtrr_mem_range(struct res_range *range, int nr_range,
759 /* take out UC ranges */ 759 /* take out UC ranges */
760 for (i = 0; i < num_var_ranges; i++) { 760 for (i = 0; i < num_var_ranges; i++) {
761 type = range_state[i].type; 761 type = range_state[i].type;
762 if (type != MTRR_TYPE_UNCACHABLE) 762 if (type != MTRR_TYPE_UNCACHABLE &&
763 type != MTRR_TYPE_WRPROT)
763 continue; 764 continue;
764 size = range_state[i].size_pfn; 765 size = range_state[i].size_pfn;
765 if (!size) 766 if (!size)
@@ -834,7 +835,14 @@ static int __init enable_mtrr_cleanup_setup(char *str)
834 enable_mtrr_cleanup = 1; 835 enable_mtrr_cleanup = 1;
835 return 0; 836 return 0;
836} 837}
837early_param("enble_mtrr_cleanup", enable_mtrr_cleanup_setup); 838early_param("enable_mtrr_cleanup", enable_mtrr_cleanup_setup);
839
840static int __init mtrr_cleanup_debug_setup(char *str)
841{
842 debug_print = 1;
843 return 0;
844}
845early_param("mtrr_cleanup_debug", mtrr_cleanup_debug_setup);
838 846
839struct var_mtrr_state { 847struct var_mtrr_state {
840 unsigned long range_startk; 848 unsigned long range_startk;
@@ -898,6 +906,27 @@ set_var_mtrr_all(unsigned int address_bits)
898 } 906 }
899} 907}
900 908
909static unsigned long to_size_factor(unsigned long sizek, char *factorp)
910{
911 char factor;
912 unsigned long base = sizek;
913
914 if (base & ((1<<10) - 1)) {
915 /* not MB alignment */
916 factor = 'K';
917 } else if (base & ((1<<20) - 1)){
918 factor = 'M';
919 base >>= 10;
920 } else {
921 factor = 'G';
922 base >>= 20;
923 }
924
925 *factorp = factor;
926
927 return base;
928}
929
901static unsigned int __init 930static unsigned int __init
902range_to_mtrr(unsigned int reg, unsigned long range_startk, 931range_to_mtrr(unsigned int reg, unsigned long range_startk,
903 unsigned long range_sizek, unsigned char type) 932 unsigned long range_sizek, unsigned char type)
@@ -919,13 +948,21 @@ range_to_mtrr(unsigned int reg, unsigned long range_startk,
919 align = max_align; 948 align = max_align;
920 949
921 sizek = 1 << align; 950 sizek = 1 << align;
922 if (debug_print) 951 if (debug_print) {
952 char start_factor = 'K', size_factor = 'K';
953 unsigned long start_base, size_base;
954
955 start_base = to_size_factor(range_startk, &start_factor),
956 size_base = to_size_factor(sizek, &size_factor),
957
923 printk(KERN_DEBUG "Setting variable MTRR %d, " 958 printk(KERN_DEBUG "Setting variable MTRR %d, "
924 "base: %ldMB, range: %ldMB, type %s\n", 959 "base: %ld%cB, range: %ld%cB, type %s\n",
925 reg, range_startk >> 10, sizek >> 10, 960 reg, start_base, start_factor,
961 size_base, size_factor,
926 (type == MTRR_TYPE_UNCACHABLE)?"UC": 962 (type == MTRR_TYPE_UNCACHABLE)?"UC":
927 ((type == MTRR_TYPE_WRBACK)?"WB":"Other") 963 ((type == MTRR_TYPE_WRBACK)?"WB":"Other")
928 ); 964 );
965 }
929 save_var_mtrr(reg++, range_startk, sizek, type); 966 save_var_mtrr(reg++, range_startk, sizek, type);
930 range_startk += sizek; 967 range_startk += sizek;
931 range_sizek -= sizek; 968 range_sizek -= sizek;
@@ -970,6 +1007,8 @@ range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek,
970 /* try to append some small hole */ 1007 /* try to append some small hole */
971 range0_basek = state->range_startk; 1008 range0_basek = state->range_startk;
972 range0_sizek = ALIGN(state->range_sizek, chunk_sizek); 1009 range0_sizek = ALIGN(state->range_sizek, chunk_sizek);
1010
1011 /* no increase */
973 if (range0_sizek == state->range_sizek) { 1012 if (range0_sizek == state->range_sizek) {
974 if (debug_print) 1013 if (debug_print)
975 printk(KERN_DEBUG "rangeX: %016lx - %016lx\n", 1014 printk(KERN_DEBUG "rangeX: %016lx - %016lx\n",
@@ -980,13 +1019,40 @@ range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek,
980 return 0; 1019 return 0;
981 } 1020 }
982 1021
983 range0_sizek -= chunk_sizek; 1022 /* only cut back, when it is not the last */
984 if (range0_sizek && sizek) { 1023 if (sizek) {
985 while (range0_basek + range0_sizek > (basek + sizek)) { 1024 while (range0_basek + range0_sizek > (basek + sizek)) {
986 range0_sizek -= chunk_sizek; 1025 if (range0_sizek >= chunk_sizek)
987 if (!range0_sizek) 1026 range0_sizek -= chunk_sizek;
988 break; 1027 else
989 } 1028 range0_sizek = 0;
1029
1030 if (!range0_sizek)
1031 break;
1032 }
1033 }
1034
1035second_try:
1036 range_basek = range0_basek + range0_sizek;
1037
1038 /* one hole in the middle */
1039 if (range_basek > basek && range_basek <= (basek + sizek))
1040 second_sizek = range_basek - basek;
1041
1042 if (range0_sizek > state->range_sizek) {
1043
1044 /* one hole in middle or at end */
1045 hole_sizek = range0_sizek - state->range_sizek - second_sizek;
1046
1047 /* hole size should be less than half of range0 size */
1048 if (hole_sizek >= (range0_sizek >> 1) &&
1049 range0_sizek >= chunk_sizek) {
1050 range0_sizek -= chunk_sizek;
1051 second_sizek = 0;
1052 hole_sizek = 0;
1053
1054 goto second_try;
1055 }
990 } 1056 }
991 1057
992 if (range0_sizek) { 1058 if (range0_sizek) {
@@ -996,50 +1062,28 @@ range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek,
996 (range0_basek + range0_sizek)<<10); 1062 (range0_basek + range0_sizek)<<10);
997 state->reg = range_to_mtrr(state->reg, range0_basek, 1063 state->reg = range_to_mtrr(state->reg, range0_basek,
998 range0_sizek, MTRR_TYPE_WRBACK); 1064 range0_sizek, MTRR_TYPE_WRBACK);
999
1000 }
1001
1002 range_basek = range0_basek + range0_sizek;
1003 range_sizek = chunk_sizek;
1004
1005 if (range_basek + range_sizek > basek &&
1006 range_basek + range_sizek <= (basek + sizek)) {
1007 /* one hole */
1008 second_basek = basek;
1009 second_sizek = range_basek + range_sizek - basek;
1010 } 1065 }
1011 1066
1012 /* if last piece, only could one hole near end */ 1067 if (range0_sizek < state->range_sizek) {
1013 if ((second_basek || !basek) && 1068 /* need to handle left over */
1014 range_sizek - (state->range_sizek - range0_sizek) - second_sizek <
1015 (chunk_sizek >> 1)) {
1016 /*
1017 * one hole in middle (second_sizek is 0) or at end
1018 * (second_sizek is 0 )
1019 */
1020 hole_sizek = range_sizek - (state->range_sizek - range0_sizek)
1021 - second_sizek;
1022 hole_basek = range_basek + range_sizek - hole_sizek
1023 - second_sizek;
1024 } else {
1025 /* fallback for big hole, or several holes */
1026 range_sizek = state->range_sizek - range0_sizek; 1069 range_sizek = state->range_sizek - range0_sizek;
1027 second_basek = 0; 1070
1028 second_sizek = 0; 1071 if (debug_print)
1072 printk(KERN_DEBUG "range: %016lx - %016lx\n",
1073 range_basek<<10,
1074 (range_basek + range_sizek)<<10);
1075 state->reg = range_to_mtrr(state->reg, range_basek,
1076 range_sizek, MTRR_TYPE_WRBACK);
1029 } 1077 }
1030 1078
1031 if (debug_print)
1032 printk(KERN_DEBUG "range: %016lx - %016lx\n", range_basek<<10,
1033 (range_basek + range_sizek)<<10);
1034 state->reg = range_to_mtrr(state->reg, range_basek, range_sizek,
1035 MTRR_TYPE_WRBACK);
1036 if (hole_sizek) { 1079 if (hole_sizek) {
1080 hole_basek = range_basek - hole_sizek - second_sizek;
1037 if (debug_print) 1081 if (debug_print)
1038 printk(KERN_DEBUG "hole: %016lx - %016lx\n", 1082 printk(KERN_DEBUG "hole: %016lx - %016lx\n",
1039 hole_basek<<10, (hole_basek + hole_sizek)<<10); 1083 hole_basek<<10,
1040 state->reg = range_to_mtrr(state->reg, hole_basek, hole_sizek, 1084 (hole_basek + hole_sizek)<<10);
1041 MTRR_TYPE_UNCACHABLE); 1085 state->reg = range_to_mtrr(state->reg, hole_basek,
1042 1086 hole_sizek, MTRR_TYPE_UNCACHABLE);
1043 } 1087 }
1044 1088
1045 return second_sizek; 1089 return second_sizek;
@@ -1154,11 +1198,11 @@ struct mtrr_cleanup_result {
1154}; 1198};
1155 1199
1156/* 1200/*
1157 * gran_size: 1M, 2M, ..., 2G 1201 * gran_size: 64K, 128K, 256K, 512K, 1M, 2M, ..., 2G
1158 * chunk size: gran_size, ..., 4G 1202 * chunk size: gran_size, ..., 2G
1159 * so we need (2+13)*6 1203 * so we need (1+16)*8
1160 */ 1204 */
1161#define NUM_RESULT 90 1205#define NUM_RESULT 136
1162#define PSHIFT (PAGE_SHIFT - 10) 1206#define PSHIFT (PAGE_SHIFT - 10)
1163 1207
1164static struct mtrr_cleanup_result __initdata result[NUM_RESULT]; 1208static struct mtrr_cleanup_result __initdata result[NUM_RESULT];
@@ -1168,13 +1212,14 @@ static unsigned long __initdata min_loss_pfn[RANGE_NUM];
1168static int __init mtrr_cleanup(unsigned address_bits) 1212static int __init mtrr_cleanup(unsigned address_bits)
1169{ 1213{
1170 unsigned long extra_remove_base, extra_remove_size; 1214 unsigned long extra_remove_base, extra_remove_size;
1171 unsigned long i, base, size, def, dummy; 1215 unsigned long base, size, def, dummy;
1172 mtrr_type type; 1216 mtrr_type type;
1173 int nr_range, nr_range_new; 1217 int nr_range, nr_range_new;
1174 u64 chunk_size, gran_size; 1218 u64 chunk_size, gran_size;
1175 unsigned long range_sums, range_sums_new; 1219 unsigned long range_sums, range_sums_new;
1176 int index_good; 1220 int index_good;
1177 int num_reg_good; 1221 int num_reg_good;
1222 int i;
1178 1223
1179 /* extra one for all 0 */ 1224 /* extra one for all 0 */
1180 int num[MTRR_NUM_TYPES + 1]; 1225 int num[MTRR_NUM_TYPES + 1];
@@ -1204,6 +1249,8 @@ static int __init mtrr_cleanup(unsigned address_bits)
1204 continue; 1249 continue;
1205 if (!size) 1250 if (!size)
1206 type = MTRR_NUM_TYPES; 1251 type = MTRR_NUM_TYPES;
1252 if (type == MTRR_TYPE_WRPROT)
1253 type = MTRR_TYPE_UNCACHABLE;
1207 num[type]++; 1254 num[type]++;
1208 } 1255 }
1209 1256
@@ -1216,23 +1263,57 @@ static int __init mtrr_cleanup(unsigned address_bits)
1216 num_var_ranges - num[MTRR_NUM_TYPES]) 1263 num_var_ranges - num[MTRR_NUM_TYPES])
1217 return 0; 1264 return 0;
1218 1265
1266 /* print original var MTRRs at first, for debugging: */
1267 printk(KERN_DEBUG "original variable MTRRs\n");
1268 for (i = 0; i < num_var_ranges; i++) {
1269 char start_factor = 'K', size_factor = 'K';
1270 unsigned long start_base, size_base;
1271
1272 size_base = range_state[i].size_pfn << (PAGE_SHIFT - 10);
1273 if (!size_base)
1274 continue;
1275
1276 size_base = to_size_factor(size_base, &size_factor),
1277 start_base = range_state[i].base_pfn << (PAGE_SHIFT - 10);
1278 start_base = to_size_factor(start_base, &start_factor),
1279 type = range_state[i].type;
1280
1281 printk(KERN_DEBUG "reg %d, base: %ld%cB, range: %ld%cB, type %s\n",
1282 i, start_base, start_factor,
1283 size_base, size_factor,
1284 (type == MTRR_TYPE_UNCACHABLE) ? "UC" :
1285 ((type == MTRR_TYPE_WRPROT) ? "WP" :
1286 ((type == MTRR_TYPE_WRBACK) ? "WB" : "Other"))
1287 );
1288 }
1289
1219 memset(range, 0, sizeof(range)); 1290 memset(range, 0, sizeof(range));
1220 extra_remove_size = 0; 1291 extra_remove_size = 0;
1221 if (mtrr_tom2) { 1292 extra_remove_base = 1 << (32 - PAGE_SHIFT);
1222 extra_remove_base = 1 << (32 - PAGE_SHIFT); 1293 if (mtrr_tom2)
1223 extra_remove_size = 1294 extra_remove_size =
1224 (mtrr_tom2 >> PAGE_SHIFT) - extra_remove_base; 1295 (mtrr_tom2 >> PAGE_SHIFT) - extra_remove_base;
1225 }
1226 nr_range = x86_get_mtrr_mem_range(range, 0, extra_remove_base, 1296 nr_range = x86_get_mtrr_mem_range(range, 0, extra_remove_base,
1227 extra_remove_size); 1297 extra_remove_size);
1298 /*
1299 * [0, 1M) should always be coverred by var mtrr with WB
1300 * and fixed mtrrs should take effective before var mtrr for it
1301 */
1302 nr_range = add_range_with_merge(range, nr_range, 0,
1303 (1ULL<<(20 - PAGE_SHIFT)) - 1);
1304 /* sort the ranges */
1305 sort(range, nr_range, sizeof(struct res_range), cmp_range, NULL);
1306
1228 range_sums = sum_ranges(range, nr_range); 1307 range_sums = sum_ranges(range, nr_range);
1229 printk(KERN_INFO "total RAM coverred: %ldM\n", 1308 printk(KERN_INFO "total RAM coverred: %ldM\n",
1230 range_sums >> (20 - PAGE_SHIFT)); 1309 range_sums >> (20 - PAGE_SHIFT));
1231 1310
1232 if (mtrr_chunk_size && mtrr_gran_size) { 1311 if (mtrr_chunk_size && mtrr_gran_size) {
1233 int num_reg; 1312 int num_reg;
1313 char gran_factor, chunk_factor, lose_factor;
1314 unsigned long gran_base, chunk_base, lose_base;
1234 1315
1235 debug_print = 1; 1316 debug_print++;
1236 /* convert ranges to var ranges state */ 1317 /* convert ranges to var ranges state */
1237 num_reg = x86_setup_var_mtrrs(range, nr_range, mtrr_chunk_size, 1318 num_reg = x86_setup_var_mtrrs(range, nr_range, mtrr_chunk_size,
1238 mtrr_gran_size); 1319 mtrr_gran_size);
@@ -1256,34 +1337,48 @@ static int __init mtrr_cleanup(unsigned address_bits)
1256 result[i].lose_cover_sizek = 1337 result[i].lose_cover_sizek =
1257 (range_sums - range_sums_new) << PSHIFT; 1338 (range_sums - range_sums_new) << PSHIFT;
1258 1339
1259 printk(KERN_INFO "%sgran_size: %ldM \tchunk_size: %ldM \t", 1340 gran_base = to_size_factor(result[i].gran_sizek, &gran_factor),
1260 result[i].bad?"*BAD*":" ", result[i].gran_sizek >> 10, 1341 chunk_base = to_size_factor(result[i].chunk_sizek, &chunk_factor),
1261 result[i].chunk_sizek >> 10); 1342 lose_base = to_size_factor(result[i].lose_cover_sizek, &lose_factor),
1262 printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ldM \n", 1343 printk(KERN_INFO "%sgran_size: %ld%c \tchunk_size: %ld%c \t",
1344 result[i].bad?"*BAD*":" ",
1345 gran_base, gran_factor, chunk_base, chunk_factor);
1346 printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ld%c\n",
1263 result[i].num_reg, result[i].bad?"-":"", 1347 result[i].num_reg, result[i].bad?"-":"",
1264 result[i].lose_cover_sizek >> 10); 1348 lose_base, lose_factor);
1265 if (!result[i].bad) { 1349 if (!result[i].bad) {
1266 set_var_mtrr_all(address_bits); 1350 set_var_mtrr_all(address_bits);
1267 return 1; 1351 return 1;
1268 } 1352 }
1269 printk(KERN_INFO "invalid mtrr_gran_size or mtrr_chunk_size, " 1353 printk(KERN_INFO "invalid mtrr_gran_size or mtrr_chunk_size, "
1270 "will find optimal one\n"); 1354 "will find optimal one\n");
1271 debug_print = 0; 1355 debug_print--;
1272 memset(result, 0, sizeof(result[0])); 1356 memset(result, 0, sizeof(result[0]));
1273 } 1357 }
1274 1358
1275 i = 0; 1359 i = 0;
1276 memset(min_loss_pfn, 0xff, sizeof(min_loss_pfn)); 1360 memset(min_loss_pfn, 0xff, sizeof(min_loss_pfn));
1277 memset(result, 0, sizeof(result)); 1361 memset(result, 0, sizeof(result));
1278 for (gran_size = (1ULL<<20); gran_size < (1ULL<<32); gran_size <<= 1) { 1362 for (gran_size = (1ULL<<16); gran_size < (1ULL<<32); gran_size <<= 1) {
1279 for (chunk_size = gran_size; chunk_size < (1ULL<<33); 1363 char gran_factor;
1364 unsigned long gran_base;
1365
1366 if (debug_print)
1367 gran_base = to_size_factor(gran_size >> 10, &gran_factor);
1368
1369 for (chunk_size = gran_size; chunk_size < (1ULL<<32);
1280 chunk_size <<= 1) { 1370 chunk_size <<= 1) {
1281 int num_reg; 1371 int num_reg;
1282 1372
1283 if (debug_print) 1373 if (debug_print) {
1284 printk(KERN_INFO 1374 char chunk_factor;
1285 "\ngran_size: %lldM chunk_size_size: %lldM\n", 1375 unsigned long chunk_base;
1286 gran_size >> 20, chunk_size >> 20); 1376
1377 chunk_base = to_size_factor(chunk_size>>10, &chunk_factor),
1378 printk(KERN_INFO "\n");
1379 printk(KERN_INFO "gran_size: %ld%c chunk_size: %ld%c \n",
1380 gran_base, gran_factor, chunk_base, chunk_factor);
1381 }
1287 if (i >= NUM_RESULT) 1382 if (i >= NUM_RESULT)
1288 continue; 1383 continue;
1289 1384
@@ -1326,12 +1421,18 @@ static int __init mtrr_cleanup(unsigned address_bits)
1326 1421
1327 /* print out all */ 1422 /* print out all */
1328 for (i = 0; i < NUM_RESULT; i++) { 1423 for (i = 0; i < NUM_RESULT; i++) {
1329 printk(KERN_INFO "%sgran_size: %ldM \tchunk_size: %ldM \t", 1424 char gran_factor, chunk_factor, lose_factor;
1330 result[i].bad?"*BAD* ":" ", result[i].gran_sizek >> 10, 1425 unsigned long gran_base, chunk_base, lose_base;
1331 result[i].chunk_sizek >> 10); 1426
1332 printk(KERN_CONT "num_reg: %d \tlose RAM: %s%ldM\n", 1427 gran_base = to_size_factor(result[i].gran_sizek, &gran_factor),
1333 result[i].num_reg, result[i].bad?"-":"", 1428 chunk_base = to_size_factor(result[i].chunk_sizek, &chunk_factor),
1334 result[i].lose_cover_sizek >> 10); 1429 lose_base = to_size_factor(result[i].lose_cover_sizek, &lose_factor),
1430 printk(KERN_INFO "%sgran_size: %ld%c \tchunk_size: %ld%c \t",
1431 result[i].bad?"*BAD*":" ",
1432 gran_base, gran_factor, chunk_base, chunk_factor);
1433 printk(KERN_CONT "num_reg: %d \tlose cover RAM: %s%ld%c\n",
1434 result[i].num_reg, result[i].bad?"-":"",
1435 lose_base, lose_factor);
1335 } 1436 }
1336 1437
1337 /* try to find the optimal index */ 1438 /* try to find the optimal index */
@@ -1339,10 +1440,8 @@ static int __init mtrr_cleanup(unsigned address_bits)
1339 nr_mtrr_spare_reg = num_var_ranges - 1; 1440 nr_mtrr_spare_reg = num_var_ranges - 1;
1340 num_reg_good = -1; 1441 num_reg_good = -1;
1341 for (i = num_var_ranges - nr_mtrr_spare_reg; i > 0; i--) { 1442 for (i = num_var_ranges - nr_mtrr_spare_reg; i > 0; i--) {
1342 if (!min_loss_pfn[i]) { 1443 if (!min_loss_pfn[i])
1343 num_reg_good = i; 1444 num_reg_good = i;
1344 break;
1345 }
1346 } 1445 }
1347 1446
1348 index_good = -1; 1447 index_good = -1;
@@ -1358,21 +1457,26 @@ static int __init mtrr_cleanup(unsigned address_bits)
1358 } 1457 }
1359 1458
1360 if (index_good != -1) { 1459 if (index_good != -1) {
1460 char gran_factor, chunk_factor, lose_factor;
1461 unsigned long gran_base, chunk_base, lose_base;
1462
1361 printk(KERN_INFO "Found optimal setting for mtrr clean up\n"); 1463 printk(KERN_INFO "Found optimal setting for mtrr clean up\n");
1362 i = index_good; 1464 i = index_good;
1363 printk(KERN_INFO "gran_size: %ldM \tchunk_size: %ldM \t", 1465 gran_base = to_size_factor(result[i].gran_sizek, &gran_factor),
1364 result[i].gran_sizek >> 10, 1466 chunk_base = to_size_factor(result[i].chunk_sizek, &chunk_factor),
1365 result[i].chunk_sizek >> 10); 1467 lose_base = to_size_factor(result[i].lose_cover_sizek, &lose_factor),
1366 printk(KERN_CONT "num_reg: %d \tlose RAM: %ldM\n", 1468 printk(KERN_INFO "gran_size: %ld%c \tchunk_size: %ld%c \t",
1367 result[i].num_reg, 1469 gran_base, gran_factor, chunk_base, chunk_factor);
1368 result[i].lose_cover_sizek >> 10); 1470 printk(KERN_CONT "num_reg: %d \tlose RAM: %ld%c\n",
1471 result[i].num_reg, lose_base, lose_factor);
1369 /* convert ranges to var ranges state */ 1472 /* convert ranges to var ranges state */
1370 chunk_size = result[i].chunk_sizek; 1473 chunk_size = result[i].chunk_sizek;
1371 chunk_size <<= 10; 1474 chunk_size <<= 10;
1372 gran_size = result[i].gran_sizek; 1475 gran_size = result[i].gran_sizek;
1373 gran_size <<= 10; 1476 gran_size <<= 10;
1374 debug_print = 1; 1477 debug_print++;
1375 x86_setup_var_mtrrs(range, nr_range, chunk_size, gran_size); 1478 x86_setup_var_mtrrs(range, nr_range, chunk_size, gran_size);
1479 debug_print--;
1376 set_var_mtrr_all(address_bits); 1480 set_var_mtrr_all(address_bits);
1377 return 1; 1481 return 1;
1378 } 1482 }
diff --git a/arch/x86/kernel/cpu/perfctr-watchdog.c b/arch/x86/kernel/cpu/perfctr-watchdog.c
index 05cc22dbd4ff..6bff382094f5 100644
--- a/arch/x86/kernel/cpu/perfctr-watchdog.c
+++ b/arch/x86/kernel/cpu/perfctr-watchdog.c
@@ -295,13 +295,19 @@ static int setup_k7_watchdog(unsigned nmi_hz)
295 /* setup the timer */ 295 /* setup the timer */
296 wrmsr(evntsel_msr, evntsel, 0); 296 wrmsr(evntsel_msr, evntsel, 0);
297 write_watchdog_counter(perfctr_msr, "K7_PERFCTR0",nmi_hz); 297 write_watchdog_counter(perfctr_msr, "K7_PERFCTR0",nmi_hz);
298 apic_write(APIC_LVTPC, APIC_DM_NMI);
299 evntsel |= K7_EVNTSEL_ENABLE;
300 wrmsr(evntsel_msr, evntsel, 0);
301 298
299 /* initialize the wd struct before enabling */
302 wd->perfctr_msr = perfctr_msr; 300 wd->perfctr_msr = perfctr_msr;
303 wd->evntsel_msr = evntsel_msr; 301 wd->evntsel_msr = evntsel_msr;
304 wd->cccr_msr = 0; /* unused */ 302 wd->cccr_msr = 0; /* unused */
303
304 /* ok, everything is initialized, announce that we're set */
305 cpu_nmi_set_wd_enabled();
306
307 apic_write(APIC_LVTPC, APIC_DM_NMI);
308 evntsel |= K7_EVNTSEL_ENABLE;
309 wrmsr(evntsel_msr, evntsel, 0);
310
305 return 1; 311 return 1;
306} 312}
307 313
@@ -379,13 +385,19 @@ static int setup_p6_watchdog(unsigned nmi_hz)
379 wrmsr(evntsel_msr, evntsel, 0); 385 wrmsr(evntsel_msr, evntsel, 0);
380 nmi_hz = adjust_for_32bit_ctr(nmi_hz); 386 nmi_hz = adjust_for_32bit_ctr(nmi_hz);
381 write_watchdog_counter32(perfctr_msr, "P6_PERFCTR0",nmi_hz); 387 write_watchdog_counter32(perfctr_msr, "P6_PERFCTR0",nmi_hz);
382 apic_write(APIC_LVTPC, APIC_DM_NMI);
383 evntsel |= P6_EVNTSEL0_ENABLE;
384 wrmsr(evntsel_msr, evntsel, 0);
385 388
389 /* initialize the wd struct before enabling */
386 wd->perfctr_msr = perfctr_msr; 390 wd->perfctr_msr = perfctr_msr;
387 wd->evntsel_msr = evntsel_msr; 391 wd->evntsel_msr = evntsel_msr;
388 wd->cccr_msr = 0; /* unused */ 392 wd->cccr_msr = 0; /* unused */
393
394 /* ok, everything is initialized, announce that we're set */
395 cpu_nmi_set_wd_enabled();
396
397 apic_write(APIC_LVTPC, APIC_DM_NMI);
398 evntsel |= P6_EVNTSEL0_ENABLE;
399 wrmsr(evntsel_msr, evntsel, 0);
400
389 return 1; 401 return 1;
390} 402}
391 403
@@ -432,6 +444,27 @@ static const struct wd_ops p6_wd_ops = {
432#define P4_CCCR_ENABLE (1 << 12) 444#define P4_CCCR_ENABLE (1 << 12)
433#define P4_CCCR_OVF (1 << 31) 445#define P4_CCCR_OVF (1 << 31)
434 446
447#define P4_CONTROLS 18
448static unsigned int p4_controls[18] = {
449 MSR_P4_BPU_CCCR0,
450 MSR_P4_BPU_CCCR1,
451 MSR_P4_BPU_CCCR2,
452 MSR_P4_BPU_CCCR3,
453 MSR_P4_MS_CCCR0,
454 MSR_P4_MS_CCCR1,
455 MSR_P4_MS_CCCR2,
456 MSR_P4_MS_CCCR3,
457 MSR_P4_FLAME_CCCR0,
458 MSR_P4_FLAME_CCCR1,
459 MSR_P4_FLAME_CCCR2,
460 MSR_P4_FLAME_CCCR3,
461 MSR_P4_IQ_CCCR0,
462 MSR_P4_IQ_CCCR1,
463 MSR_P4_IQ_CCCR2,
464 MSR_P4_IQ_CCCR3,
465 MSR_P4_IQ_CCCR4,
466 MSR_P4_IQ_CCCR5,
467};
435/* 468/*
436 * Set up IQ_COUNTER0 to behave like a clock, by having IQ_CCCR0 filter 469 * Set up IQ_COUNTER0 to behave like a clock, by having IQ_CCCR0 filter
437 * CRU_ESCR0 (with any non-null event selector) through a complemented 470 * CRU_ESCR0 (with any non-null event selector) through a complemented
@@ -473,6 +506,26 @@ static int setup_p4_watchdog(unsigned nmi_hz)
473 evntsel_msr = MSR_P4_CRU_ESCR0; 506 evntsel_msr = MSR_P4_CRU_ESCR0;
474 cccr_msr = MSR_P4_IQ_CCCR0; 507 cccr_msr = MSR_P4_IQ_CCCR0;
475 cccr_val = P4_CCCR_OVF_PMI0 | P4_CCCR_ESCR_SELECT(4); 508 cccr_val = P4_CCCR_OVF_PMI0 | P4_CCCR_ESCR_SELECT(4);
509
510 /*
511 * If we're on the kdump kernel or other situation, we may
512 * still have other performance counter registers set to
513 * interrupt and they'll keep interrupting forever because
514 * of the P4_CCCR_OVF quirk. So we need to ACK all the
515 * pending interrupts and disable all the registers here,
516 * before reenabling the NMI delivery. Refer to p4_rearm()
517 * about the P4_CCCR_OVF quirk.
518 */
519 if (reset_devices) {
520 unsigned int low, high;
521 int i;
522
523 for (i = 0; i < P4_CONTROLS; i++) {
524 rdmsr(p4_controls[i], low, high);
525 low &= ~(P4_CCCR_ENABLE | P4_CCCR_OVF);
526 wrmsr(p4_controls[i], low, high);
527 }
528 }
476 } else { 529 } else {
477 /* logical cpu 1 */ 530 /* logical cpu 1 */
478 perfctr_msr = MSR_P4_IQ_PERFCTR1; 531 perfctr_msr = MSR_P4_IQ_PERFCTR1;
@@ -499,12 +552,17 @@ static int setup_p4_watchdog(unsigned nmi_hz)
499 wrmsr(evntsel_msr, evntsel, 0); 552 wrmsr(evntsel_msr, evntsel, 0);
500 wrmsr(cccr_msr, cccr_val, 0); 553 wrmsr(cccr_msr, cccr_val, 0);
501 write_watchdog_counter(perfctr_msr, "P4_IQ_COUNTER0", nmi_hz); 554 write_watchdog_counter(perfctr_msr, "P4_IQ_COUNTER0", nmi_hz);
502 apic_write(APIC_LVTPC, APIC_DM_NMI); 555
503 cccr_val |= P4_CCCR_ENABLE;
504 wrmsr(cccr_msr, cccr_val, 0);
505 wd->perfctr_msr = perfctr_msr; 556 wd->perfctr_msr = perfctr_msr;
506 wd->evntsel_msr = evntsel_msr; 557 wd->evntsel_msr = evntsel_msr;
507 wd->cccr_msr = cccr_msr; 558 wd->cccr_msr = cccr_msr;
559
560 /* ok, everything is initialized, announce that we're set */
561 cpu_nmi_set_wd_enabled();
562
563 apic_write(APIC_LVTPC, APIC_DM_NMI);
564 cccr_val |= P4_CCCR_ENABLE;
565 wrmsr(cccr_msr, cccr_val, 0);
508 return 1; 566 return 1;
509} 567}
510 568
@@ -620,13 +678,17 @@ static int setup_intel_arch_watchdog(unsigned nmi_hz)
620 wrmsr(evntsel_msr, evntsel, 0); 678 wrmsr(evntsel_msr, evntsel, 0);
621 nmi_hz = adjust_for_32bit_ctr(nmi_hz); 679 nmi_hz = adjust_for_32bit_ctr(nmi_hz);
622 write_watchdog_counter32(perfctr_msr, "INTEL_ARCH_PERFCTR0", nmi_hz); 680 write_watchdog_counter32(perfctr_msr, "INTEL_ARCH_PERFCTR0", nmi_hz);
623 apic_write(APIC_LVTPC, APIC_DM_NMI);
624 evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE;
625 wrmsr(evntsel_msr, evntsel, 0);
626 681
627 wd->perfctr_msr = perfctr_msr; 682 wd->perfctr_msr = perfctr_msr;
628 wd->evntsel_msr = evntsel_msr; 683 wd->evntsel_msr = evntsel_msr;
629 wd->cccr_msr = 0; /* unused */ 684 wd->cccr_msr = 0; /* unused */
685
686 /* ok, everything is initialized, announce that we're set */
687 cpu_nmi_set_wd_enabled();
688
689 apic_write(APIC_LVTPC, APIC_DM_NMI);
690 evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE;
691 wrmsr(evntsel_msr, evntsel, 0);
630 intel_arch_wd_ops.checkbit = 1ULL << (eax.split.bit_width - 1); 692 intel_arch_wd_ops.checkbit = 1ULL << (eax.split.bit_width - 1);
631 return 1; 693 return 1;
632} 694}
diff --git a/arch/x86/kernel/cpu/powerflags.c b/arch/x86/kernel/cpu/powerflags.c
new file mode 100644
index 000000000000..5abbea297e0c
--- /dev/null
+++ b/arch/x86/kernel/cpu/powerflags.c
@@ -0,0 +1,20 @@
1/*
2 * Strings for the various x86 power flags
3 *
4 * This file must not contain any executable code.
5 */
6
7#include <asm/cpufeature.h>
8
9const char *const x86_power_flags[32] = {
10 "ts", /* temperature sensor */
11 "fid", /* frequency id control */
12 "vid", /* voltage id control */
13 "ttp", /* thermal trip */
14 "tm",
15 "stc",
16 "100mhzsteps",
17 "hwpstate",
18 "", /* tsc invariant mapped to constant_tsc */
19 /* nothing */
20};
diff --git a/arch/x86/kernel/cpu/transmeta.c b/arch/x86/kernel/cpu/transmeta.c
index b911a2c61b8f..52b3fefbd5af 100644
--- a/arch/x86/kernel/cpu/transmeta.c
+++ b/arch/x86/kernel/cpu/transmeta.c
@@ -5,6 +5,18 @@
5#include <asm/msr.h> 5#include <asm/msr.h>
6#include "cpu.h" 6#include "cpu.h"
7 7
8static void __cpuinit early_init_transmeta(struct cpuinfo_x86 *c)
9{
10 u32 xlvl;
11
12 /* Transmeta-defined flags: level 0x80860001 */
13 xlvl = cpuid_eax(0x80860000);
14 if ((xlvl & 0xffff0000) == 0x80860000) {
15 if (xlvl >= 0x80860001)
16 c->x86_capability[2] = cpuid_edx(0x80860001);
17 }
18}
19
8static void __cpuinit init_transmeta(struct cpuinfo_x86 *c) 20static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
9{ 21{
10 unsigned int cap_mask, uk, max, dummy; 22 unsigned int cap_mask, uk, max, dummy;
@@ -12,7 +24,8 @@ static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
12 unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev; 24 unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev;
13 char cpu_info[65]; 25 char cpu_info[65];
14 26
15 get_model_name(c); /* Same as AMD/Cyrix */ 27 early_init_transmeta(c);
28
16 display_cacheinfo(c); 29 display_cacheinfo(c);
17 30
18 /* Print CMS and CPU revision */ 31 /* Print CMS and CPU revision */
@@ -85,23 +98,12 @@ static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
85#endif 98#endif
86} 99}
87 100
88static void __cpuinit transmeta_identify(struct cpuinfo_x86 *c)
89{
90 u32 xlvl;
91
92 /* Transmeta-defined flags: level 0x80860001 */
93 xlvl = cpuid_eax(0x80860000);
94 if ((xlvl & 0xffff0000) == 0x80860000) {
95 if (xlvl >= 0x80860001)
96 c->x86_capability[2] = cpuid_edx(0x80860001);
97 }
98}
99
100static struct cpu_dev transmeta_cpu_dev __cpuinitdata = { 101static struct cpu_dev transmeta_cpu_dev __cpuinitdata = {
101 .c_vendor = "Transmeta", 102 .c_vendor = "Transmeta",
102 .c_ident = { "GenuineTMx86", "TransmetaCPU" }, 103 .c_ident = { "GenuineTMx86", "TransmetaCPU" },
104 .c_early_init = early_init_transmeta,
103 .c_init = init_transmeta, 105 .c_init = init_transmeta,
104 .c_identify = transmeta_identify, 106 .c_x86_vendor = X86_VENDOR_TRANSMETA,
105}; 107};
106 108
107cpu_vendor_dev_register(X86_VENDOR_TRANSMETA, &transmeta_cpu_dev); 109cpu_dev_register(transmeta_cpu_dev);
diff --git a/arch/x86/kernel/cpu/umc.c b/arch/x86/kernel/cpu/umc.c
index b1fc90989d75..e777f79e0960 100644
--- a/arch/x86/kernel/cpu/umc.c
+++ b/arch/x86/kernel/cpu/umc.c
@@ -19,7 +19,8 @@ static struct cpu_dev umc_cpu_dev __cpuinitdata = {
19 } 19 }
20 }, 20 },
21 }, 21 },
22 .c_x86_vendor = X86_VENDOR_UMC,
22}; 23};
23 24
24cpu_vendor_dev_register(X86_VENDOR_UMC, &umc_cpu_dev); 25cpu_dev_register(umc_cpu_dev);
25 26
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 8e9cd6a8ec12..6a44d6465991 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -36,7 +36,6 @@
36#include <linux/smp_lock.h> 36#include <linux/smp_lock.h>
37#include <linux/major.h> 37#include <linux/major.h>
38#include <linux/fs.h> 38#include <linux/fs.h>
39#include <linux/smp_lock.h>
40#include <linux/device.h> 39#include <linux/device.h>
41#include <linux/cpu.h> 40#include <linux/cpu.h>
42#include <linux/notifier.h> 41#include <linux/notifier.h>
diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
index 15e6c6bc4a46..e90a60ef10c2 100644
--- a/arch/x86/kernel/crash_dump_64.c
+++ b/arch/x86/kernel/crash_dump_64.c
@@ -7,9 +7,8 @@
7 7
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/crash_dump.h> 9#include <linux/crash_dump.h>
10 10#include <linux/uaccess.h>
11#include <asm/uaccess.h> 11#include <linux/io.h>
12#include <asm/io.h>
13 12
14/** 13/**
15 * copy_oldmem_page - copy one page from "oldmem" 14 * copy_oldmem_page - copy one page from "oldmem"
@@ -25,7 +24,7 @@
25 * in the current kernel. We stitch up a pte, similar to kmap_atomic. 24 * in the current kernel. We stitch up a pte, similar to kmap_atomic.
26 */ 25 */
27ssize_t copy_oldmem_page(unsigned long pfn, char *buf, 26ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
28 size_t csize, unsigned long offset, int userbuf) 27 size_t csize, unsigned long offset, int userbuf)
29{ 28{
30 void *vaddr; 29 void *vaddr;
31 30
@@ -33,14 +32,16 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
33 return 0; 32 return 0;
34 33
35 vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE); 34 vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
35 if (!vaddr)
36 return -ENOMEM;
36 37
37 if (userbuf) { 38 if (userbuf) {
38 if (copy_to_user(buf, (vaddr + offset), csize)) { 39 if (copy_to_user(buf, vaddr + offset, csize)) {
39 iounmap(vaddr); 40 iounmap(vaddr);
40 return -EFAULT; 41 return -EFAULT;
41 } 42 }
42 } else 43 } else
43 memcpy(buf, (vaddr + offset), csize); 44 memcpy(buf, vaddr + offset, csize);
44 45
45 iounmap(vaddr); 46 iounmap(vaddr);
46 return csize; 47 return csize;
diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
index a47798b59f07..395acb12b0d1 100644
--- a/arch/x86/kernel/doublefault_32.c
+++ b/arch/x86/kernel/doublefault_32.c
@@ -66,6 +66,6 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
66 .ds = __USER_DS, 66 .ds = __USER_DS,
67 .fs = __KERNEL_PERCPU, 67 .fs = __KERNEL_PERCPU,
68 68
69 .__cr3 = __pa(swapper_pg_dir) 69 .__cr3 = __phys_addr_const((unsigned long)swapper_pg_dir)
70 } 70 }
71}; 71};
diff --git a/arch/x86/kernel/ds.c b/arch/x86/kernel/ds.c
index 11c11b8ec48d..2b69994fd3a8 100644
--- a/arch/x86/kernel/ds.c
+++ b/arch/x86/kernel/ds.c
@@ -2,26 +2,49 @@
2 * Debug Store support 2 * Debug Store support
3 * 3 *
4 * This provides a low-level interface to the hardware's Debug Store 4 * This provides a low-level interface to the hardware's Debug Store
5 * feature that is used for last branch recording (LBR) and 5 * feature that is used for branch trace store (BTS) and
6 * precise-event based sampling (PEBS). 6 * precise-event based sampling (PEBS).
7 * 7 *
8 * Different architectures use a different DS layout/pointer size. 8 * It manages:
9 * The below functions therefore work on a void*. 9 * - per-thread and per-cpu allocation of BTS and PEBS
10 * - buffer memory allocation (optional)
11 * - buffer overflow handling
12 * - buffer access
10 * 13 *
14 * It assumes:
15 * - get_task_struct on all parameter tasks
16 * - current is allowed to trace parameter tasks
11 * 17 *
12 * Since there is no user for PEBS, yet, only LBR (or branch
13 * trace store, BTS) is supported.
14 * 18 *
15 * 19 * Copyright (C) 2007-2008 Intel Corporation.
16 * Copyright (C) 2007 Intel Corporation. 20 * Markus Metzger <markus.t.metzger@intel.com>, 2007-2008
17 * Markus Metzger <markus.t.metzger@intel.com>, Dec 2007
18 */ 21 */
19 22
23
24#ifdef CONFIG_X86_DS
25
20#include <asm/ds.h> 26#include <asm/ds.h>
21 27
22#include <linux/errno.h> 28#include <linux/errno.h>
23#include <linux/string.h> 29#include <linux/string.h>
24#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/sched.h>
32#include <linux/mm.h>
33
34
35/*
36 * The configuration for a particular DS hardware implementation.
37 */
38struct ds_configuration {
39 /* the size of the DS structure in bytes */
40 unsigned char sizeof_ds;
41 /* the size of one pointer-typed field in the DS structure in bytes;
42 this covers the first 8 fields related to buffer management. */
43 unsigned char sizeof_field;
44 /* the size of a BTS/PEBS record in bytes */
45 unsigned char sizeof_rec[2];
46};
47static struct ds_configuration ds_cfg;
25 48
26 49
27/* 50/*
@@ -44,378 +67,747 @@
44 * (interrupt occurs when write pointer passes interrupt pointer) 67 * (interrupt occurs when write pointer passes interrupt pointer)
45 * - value to which counter is reset following counter overflow 68 * - value to which counter is reset following counter overflow
46 * 69 *
47 * On later architectures, the last branch recording hardware uses 70 * Later architectures use 64bit pointers throughout, whereas earlier
48 * 64bit pointers even in 32bit mode. 71 * architectures use 32bit pointers in 32bit mode.
49 *
50 *
51 * Branch Trace Store (BTS) records store information about control
52 * flow changes. They at least provide the following information:
53 * - source linear address
54 * - destination linear address
55 * 72 *
56 * Netburst supported a predicated bit that had been dropped in later
57 * architectures. We do not suppor it.
58 * 73 *
74 * We compute the base address for the first 8 fields based on:
75 * - the field size stored in the DS configuration
76 * - the relative field position
77 * - an offset giving the start of the respective region
59 * 78 *
60 * In order to abstract from the actual DS and BTS layout, we describe 79 * This offset is further used to index various arrays holding
61 * the access to the relevant fields. 80 * information for BTS and PEBS at the respective index.
62 * Thanks to Andi Kleen for proposing this design.
63 * 81 *
64 * The implementation, however, is not as general as it might seem. In 82 * On later 32bit processors, we only access the lower 32bit of the
65 * order to stay somewhat simple and efficient, we assume an 83 * 64bit pointer fields. The upper halves will be zeroed out.
66 * underlying unsigned type (mostly a pointer type) and we expect the
67 * field to be at least as big as that type.
68 */ 84 */
69 85
70/* 86enum ds_field {
71 * A special from_ip address to indicate that the BTS record is an 87 ds_buffer_base = 0,
72 * info record that needs to be interpreted or skipped. 88 ds_index,
73 */ 89 ds_absolute_maximum,
74#define BTS_ESCAPE_ADDRESS (-1) 90 ds_interrupt_threshold,
91};
75 92
76/* 93enum ds_qualifier {
77 * A field access descriptor 94 ds_bts = 0,
78 */ 95 ds_pebs
79struct access_desc {
80 unsigned char offset;
81 unsigned char size;
82}; 96};
83 97
98static inline unsigned long ds_get(const unsigned char *base,
99 enum ds_qualifier qual, enum ds_field field)
100{
101 base += (ds_cfg.sizeof_field * (field + (4 * qual)));
102 return *(unsigned long *)base;
103}
104
105static inline void ds_set(unsigned char *base, enum ds_qualifier qual,
106 enum ds_field field, unsigned long value)
107{
108 base += (ds_cfg.sizeof_field * (field + (4 * qual)));
109 (*(unsigned long *)base) = value;
110}
111
112
84/* 113/*
85 * The configuration for a particular DS/BTS hardware implementation. 114 * Locking is done only for allocating BTS or PEBS resources and for
115 * guarding context and buffer memory allocation.
116 *
117 * Most functions require the current task to own the ds context part
118 * they are going to access. All the locking is done when validating
119 * access to the context.
86 */ 120 */
87struct ds_configuration { 121static spinlock_t ds_lock = __SPIN_LOCK_UNLOCKED(ds_lock);
88 /* the DS configuration */
89 unsigned char sizeof_ds;
90 struct access_desc bts_buffer_base;
91 struct access_desc bts_index;
92 struct access_desc bts_absolute_maximum;
93 struct access_desc bts_interrupt_threshold;
94 /* the BTS configuration */
95 unsigned char sizeof_bts;
96 struct access_desc from_ip;
97 struct access_desc to_ip;
98 /* BTS variants used to store additional information like
99 timestamps */
100 struct access_desc info_type;
101 struct access_desc info_data;
102 unsigned long debugctl_mask;
103};
104 122
105/* 123/*
106 * The global configuration used by the below accessor functions 124 * Validate that the current task is allowed to access the BTS/PEBS
125 * buffer of the parameter task.
126 *
127 * Returns 0, if access is granted; -Eerrno, otherwise.
107 */ 128 */
108static struct ds_configuration ds_cfg; 129static inline int ds_validate_access(struct ds_context *context,
130 enum ds_qualifier qual)
131{
132 if (!context)
133 return -EPERM;
134
135 if (context->owner[qual] == current)
136 return 0;
137
138 return -EPERM;
139}
140
109 141
110/* 142/*
111 * Accessor functions for some DS and BTS fields using the above 143 * We either support (system-wide) per-cpu or per-thread allocation.
112 * global ptrace_bts_cfg. 144 * We distinguish the two based on the task_struct pointer, where a
145 * NULL pointer indicates per-cpu allocation for the current cpu.
146 *
147 * Allocations are use-counted. As soon as resources are allocated,
148 * further allocations must be of the same type (per-cpu or
149 * per-thread). We model this by counting allocations (i.e. the number
150 * of tracers of a certain type) for one type negatively:
151 * =0 no tracers
152 * >0 number of per-thread tracers
153 * <0 number of per-cpu tracers
154 *
155 * The below functions to get and put tracers and to check the
156 * allocation type require the ds_lock to be held by the caller.
157 *
158 * Tracers essentially gives the number of ds contexts for a certain
159 * type of allocation.
113 */ 160 */
114static inline unsigned long get_bts_buffer_base(char *base) 161static long tracers;
162
163static inline void get_tracer(struct task_struct *task)
115{ 164{
116 return *(unsigned long *)(base + ds_cfg.bts_buffer_base.offset); 165 tracers += (task ? 1 : -1);
117} 166}
118static inline void set_bts_buffer_base(char *base, unsigned long value) 167
168static inline void put_tracer(struct task_struct *task)
119{ 169{
120 (*(unsigned long *)(base + ds_cfg.bts_buffer_base.offset)) = value; 170 tracers -= (task ? 1 : -1);
121} 171}
122static inline unsigned long get_bts_index(char *base) 172
173static inline int check_tracer(struct task_struct *task)
123{ 174{
124 return *(unsigned long *)(base + ds_cfg.bts_index.offset); 175 return (task ? (tracers >= 0) : (tracers <= 0));
125} 176}
126static inline void set_bts_index(char *base, unsigned long value) 177
178
179/*
180 * The DS context is either attached to a thread or to a cpu:
181 * - in the former case, the thread_struct contains a pointer to the
182 * attached context.
183 * - in the latter case, we use a static array of per-cpu context
184 * pointers.
185 *
186 * Contexts are use-counted. They are allocated on first access and
187 * deallocated when the last user puts the context.
188 *
189 * We distinguish between an allocating and a non-allocating get of a
190 * context:
191 * - the allocating get is used for requesting BTS/PEBS resources. It
192 * requires the caller to hold the global ds_lock.
193 * - the non-allocating get is used for all other cases. A
194 * non-existing context indicates an error. It acquires and releases
195 * the ds_lock itself for obtaining the context.
196 *
197 * A context and its DS configuration are allocated and deallocated
198 * together. A context always has a DS configuration of the
199 * appropriate size.
200 */
201static DEFINE_PER_CPU(struct ds_context *, system_context);
202
203#define this_system_context per_cpu(system_context, smp_processor_id())
204
205/*
206 * Returns the pointer to the parameter task's context or to the
207 * system-wide context, if task is NULL.
208 *
209 * Increases the use count of the returned context, if not NULL.
210 */
211static inline struct ds_context *ds_get_context(struct task_struct *task)
127{ 212{
128 (*(unsigned long *)(base + ds_cfg.bts_index.offset)) = value; 213 struct ds_context *context;
214
215 spin_lock(&ds_lock);
216
217 context = (task ? task->thread.ds_ctx : this_system_context);
218 if (context)
219 context->count++;
220
221 spin_unlock(&ds_lock);
222
223 return context;
129} 224}
130static inline unsigned long get_bts_absolute_maximum(char *base) 225
226/*
227 * Same as ds_get_context, but allocates the context and it's DS
228 * structure, if necessary; returns NULL; if out of memory.
229 *
230 * pre: requires ds_lock to be held
231 */
232static inline struct ds_context *ds_alloc_context(struct task_struct *task)
131{ 233{
132 return *(unsigned long *)(base + ds_cfg.bts_absolute_maximum.offset); 234 struct ds_context **p_context =
235 (task ? &task->thread.ds_ctx : &this_system_context);
236 struct ds_context *context = *p_context;
237
238 if (!context) {
239 context = kzalloc(sizeof(*context), GFP_KERNEL);
240
241 if (!context)
242 return NULL;
243
244 context->ds = kzalloc(ds_cfg.sizeof_ds, GFP_KERNEL);
245 if (!context->ds) {
246 kfree(context);
247 return NULL;
248 }
249
250 *p_context = context;
251
252 context->this = p_context;
253 context->task = task;
254
255 if (task)
256 set_tsk_thread_flag(task, TIF_DS_AREA_MSR);
257
258 if (!task || (task == current))
259 wrmsr(MSR_IA32_DS_AREA, (unsigned long)context->ds, 0);
260
261 get_tracer(task);
262 }
263
264 context->count++;
265
266 return context;
133} 267}
134static inline void set_bts_absolute_maximum(char *base, unsigned long value) 268
269/*
270 * Decreases the use count of the parameter context, if not NULL.
271 * Deallocates the context, if the use count reaches zero.
272 */
273static inline void ds_put_context(struct ds_context *context)
135{ 274{
136 (*(unsigned long *)(base + ds_cfg.bts_absolute_maximum.offset)) = value; 275 if (!context)
276 return;
277
278 spin_lock(&ds_lock);
279
280 if (--context->count)
281 goto out;
282
283 *(context->this) = NULL;
284
285 if (context->task)
286 clear_tsk_thread_flag(context->task, TIF_DS_AREA_MSR);
287
288 if (!context->task || (context->task == current))
289 wrmsrl(MSR_IA32_DS_AREA, 0);
290
291 put_tracer(context->task);
292
293 /* free any leftover buffers from tracers that did not
294 * deallocate them properly. */
295 kfree(context->buffer[ds_bts]);
296 kfree(context->buffer[ds_pebs]);
297 kfree(context->ds);
298 kfree(context);
299 out:
300 spin_unlock(&ds_lock);
137} 301}
138static inline unsigned long get_bts_interrupt_threshold(char *base) 302
303
304/*
305 * Handle a buffer overflow
306 *
307 * task: the task whose buffers are overflowing;
308 * NULL for a buffer overflow on the current cpu
309 * context: the ds context
310 * qual: the buffer type
311 */
312static void ds_overflow(struct task_struct *task, struct ds_context *context,
313 enum ds_qualifier qual)
139{ 314{
140 return *(unsigned long *)(base + ds_cfg.bts_interrupt_threshold.offset); 315 if (!context)
316 return;
317
318 if (context->callback[qual])
319 (*context->callback[qual])(task);
320
321 /* todo: do some more overflow handling */
141} 322}
142static inline void set_bts_interrupt_threshold(char *base, unsigned long value) 323
324
325/*
326 * Allocate a non-pageable buffer of the parameter size.
327 * Checks the memory and the locked memory rlimit.
328 *
329 * Returns the buffer, if successful;
330 * NULL, if out of memory or rlimit exceeded.
331 *
332 * size: the requested buffer size in bytes
333 * pages (out): if not NULL, contains the number of pages reserved
334 */
335static inline void *ds_allocate_buffer(size_t size, unsigned int *pages)
143{ 336{
144 (*(unsigned long *)(base + ds_cfg.bts_interrupt_threshold.offset)) = value; 337 unsigned long rlim, vm, pgsz;
338 void *buffer;
339
340 pgsz = PAGE_ALIGN(size) >> PAGE_SHIFT;
341
342 rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
343 vm = current->mm->total_vm + pgsz;
344 if (rlim < vm)
345 return NULL;
346
347 rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
348 vm = current->mm->locked_vm + pgsz;
349 if (rlim < vm)
350 return NULL;
351
352 buffer = kzalloc(size, GFP_KERNEL);
353 if (!buffer)
354 return NULL;
355
356 current->mm->total_vm += pgsz;
357 current->mm->locked_vm += pgsz;
358
359 if (pages)
360 *pages = pgsz;
361
362 return buffer;
145} 363}
146static inline unsigned long get_from_ip(char *base) 364
365static int ds_request(struct task_struct *task, void *base, size_t size,
366 ds_ovfl_callback_t ovfl, enum ds_qualifier qual)
147{ 367{
148 return *(unsigned long *)(base + ds_cfg.from_ip.offset); 368 struct ds_context *context;
369 unsigned long buffer, adj;
370 const unsigned long alignment = (1 << 3);
371 int error = 0;
372
373 if (!ds_cfg.sizeof_ds)
374 return -EOPNOTSUPP;
375
376 /* we require some space to do alignment adjustments below */
377 if (size < (alignment + ds_cfg.sizeof_rec[qual]))
378 return -EINVAL;
379
380 /* buffer overflow notification is not yet implemented */
381 if (ovfl)
382 return -EOPNOTSUPP;
383
384
385 spin_lock(&ds_lock);
386
387 if (!check_tracer(task))
388 return -EPERM;
389
390 error = -ENOMEM;
391 context = ds_alloc_context(task);
392 if (!context)
393 goto out_unlock;
394
395 error = -EALREADY;
396 if (context->owner[qual] == current)
397 goto out_unlock;
398 error = -EPERM;
399 if (context->owner[qual] != NULL)
400 goto out_unlock;
401 context->owner[qual] = current;
402
403 spin_unlock(&ds_lock);
404
405
406 error = -ENOMEM;
407 if (!base) {
408 base = ds_allocate_buffer(size, &context->pages[qual]);
409 if (!base)
410 goto out_release;
411
412 context->buffer[qual] = base;
413 }
414 error = 0;
415
416 context->callback[qual] = ovfl;
417
418 /* adjust the buffer address and size to meet alignment
419 * constraints:
420 * - buffer is double-word aligned
421 * - size is multiple of record size
422 *
423 * We checked the size at the very beginning; we have enough
424 * space to do the adjustment.
425 */
426 buffer = (unsigned long)base;
427
428 adj = ALIGN(buffer, alignment) - buffer;
429 buffer += adj;
430 size -= adj;
431
432 size /= ds_cfg.sizeof_rec[qual];
433 size *= ds_cfg.sizeof_rec[qual];
434
435 ds_set(context->ds, qual, ds_buffer_base, buffer);
436 ds_set(context->ds, qual, ds_index, buffer);
437 ds_set(context->ds, qual, ds_absolute_maximum, buffer + size);
438
439 if (ovfl) {
440 /* todo: select a suitable interrupt threshold */
441 } else
442 ds_set(context->ds, qual,
443 ds_interrupt_threshold, buffer + size + 1);
444
445 /* we keep the context until ds_release */
446 return error;
447
448 out_release:
449 context->owner[qual] = NULL;
450 ds_put_context(context);
451 return error;
452
453 out_unlock:
454 spin_unlock(&ds_lock);
455 ds_put_context(context);
456 return error;
149} 457}
150static inline void set_from_ip(char *base, unsigned long value) 458
459int ds_request_bts(struct task_struct *task, void *base, size_t size,
460 ds_ovfl_callback_t ovfl)
151{ 461{
152 (*(unsigned long *)(base + ds_cfg.from_ip.offset)) = value; 462 return ds_request(task, base, size, ovfl, ds_bts);
153} 463}
154static inline unsigned long get_to_ip(char *base) 464
465int ds_request_pebs(struct task_struct *task, void *base, size_t size,
466 ds_ovfl_callback_t ovfl)
155{ 467{
156 return *(unsigned long *)(base + ds_cfg.to_ip.offset); 468 return ds_request(task, base, size, ovfl, ds_pebs);
157} 469}
158static inline void set_to_ip(char *base, unsigned long value) 470
471static int ds_release(struct task_struct *task, enum ds_qualifier qual)
159{ 472{
160 (*(unsigned long *)(base + ds_cfg.to_ip.offset)) = value; 473 struct ds_context *context;
474 int error;
475
476 context = ds_get_context(task);
477 error = ds_validate_access(context, qual);
478 if (error < 0)
479 goto out;
480
481 kfree(context->buffer[qual]);
482 context->buffer[qual] = NULL;
483
484 current->mm->total_vm -= context->pages[qual];
485 current->mm->locked_vm -= context->pages[qual];
486 context->pages[qual] = 0;
487 context->owner[qual] = NULL;
488
489 /*
490 * we put the context twice:
491 * once for the ds_get_context
492 * once for the corresponding ds_request
493 */
494 ds_put_context(context);
495 out:
496 ds_put_context(context);
497 return error;
161} 498}
162static inline unsigned char get_info_type(char *base) 499
500int ds_release_bts(struct task_struct *task)
163{ 501{
164 return *(unsigned char *)(base + ds_cfg.info_type.offset); 502 return ds_release(task, ds_bts);
165} 503}
166static inline void set_info_type(char *base, unsigned char value) 504
505int ds_release_pebs(struct task_struct *task)
167{ 506{
168 (*(unsigned char *)(base + ds_cfg.info_type.offset)) = value; 507 return ds_release(task, ds_pebs);
169} 508}
170static inline unsigned long get_info_data(char *base) 509
510static int ds_get_index(struct task_struct *task, size_t *pos,
511 enum ds_qualifier qual)
171{ 512{
172 return *(unsigned long *)(base + ds_cfg.info_data.offset); 513 struct ds_context *context;
514 unsigned long base, index;
515 int error;
516
517 context = ds_get_context(task);
518 error = ds_validate_access(context, qual);
519 if (error < 0)
520 goto out;
521
522 base = ds_get(context->ds, qual, ds_buffer_base);
523 index = ds_get(context->ds, qual, ds_index);
524
525 error = ((index - base) / ds_cfg.sizeof_rec[qual]);
526 if (pos)
527 *pos = error;
528 out:
529 ds_put_context(context);
530 return error;
173} 531}
174static inline void set_info_data(char *base, unsigned long value) 532
533int ds_get_bts_index(struct task_struct *task, size_t *pos)
175{ 534{
176 (*(unsigned long *)(base + ds_cfg.info_data.offset)) = value; 535 return ds_get_index(task, pos, ds_bts);
177} 536}
178 537
538int ds_get_pebs_index(struct task_struct *task, size_t *pos)
539{
540 return ds_get_index(task, pos, ds_pebs);
541}
179 542
180int ds_allocate(void **dsp, size_t bts_size_in_bytes) 543static int ds_get_end(struct task_struct *task, size_t *pos,
544 enum ds_qualifier qual)
181{ 545{
182 size_t bts_size_in_records; 546 struct ds_context *context;
183 unsigned long bts; 547 unsigned long base, end;
184 void *ds; 548 int error;
549
550 context = ds_get_context(task);
551 error = ds_validate_access(context, qual);
552 if (error < 0)
553 goto out;
554
555 base = ds_get(context->ds, qual, ds_buffer_base);
556 end = ds_get(context->ds, qual, ds_absolute_maximum);
557
558 error = ((end - base) / ds_cfg.sizeof_rec[qual]);
559 if (pos)
560 *pos = error;
561 out:
562 ds_put_context(context);
563 return error;
564}
185 565
186 if (!ds_cfg.sizeof_ds || !ds_cfg.sizeof_bts) 566int ds_get_bts_end(struct task_struct *task, size_t *pos)
187 return -EOPNOTSUPP; 567{
568 return ds_get_end(task, pos, ds_bts);
569}
188 570
189 if (bts_size_in_bytes < 0) 571int ds_get_pebs_end(struct task_struct *task, size_t *pos)
190 return -EINVAL; 572{
573 return ds_get_end(task, pos, ds_pebs);
574}
191 575
192 bts_size_in_records = 576static int ds_access(struct task_struct *task, size_t index,
193 bts_size_in_bytes / ds_cfg.sizeof_bts; 577 const void **record, enum ds_qualifier qual)
194 bts_size_in_bytes = 578{
195 bts_size_in_records * ds_cfg.sizeof_bts; 579 struct ds_context *context;
580 unsigned long base, idx;
581 int error;
196 582
197 if (bts_size_in_bytes <= 0) 583 if (!record)
198 return -EINVAL; 584 return -EINVAL;
199 585
200 bts = (unsigned long)kzalloc(bts_size_in_bytes, GFP_KERNEL); 586 context = ds_get_context(task);
201 587 error = ds_validate_access(context, qual);
202 if (!bts) 588 if (error < 0)
203 return -ENOMEM; 589 goto out;
204 590
205 ds = kzalloc(ds_cfg.sizeof_ds, GFP_KERNEL); 591 base = ds_get(context->ds, qual, ds_buffer_base);
592 idx = base + (index * ds_cfg.sizeof_rec[qual]);
206 593
207 if (!ds) { 594 error = -EINVAL;
208 kfree((void *)bts); 595 if (idx > ds_get(context->ds, qual, ds_absolute_maximum))
209 return -ENOMEM; 596 goto out;
210 }
211
212 set_bts_buffer_base(ds, bts);
213 set_bts_index(ds, bts);
214 set_bts_absolute_maximum(ds, bts + bts_size_in_bytes);
215 set_bts_interrupt_threshold(ds, bts + bts_size_in_bytes + 1);
216 597
217 *dsp = ds; 598 *record = (const void *)idx;
218 return 0; 599 error = ds_cfg.sizeof_rec[qual];
600 out:
601 ds_put_context(context);
602 return error;
219} 603}
220 604
221int ds_free(void **dsp) 605int ds_access_bts(struct task_struct *task, size_t index, const void **record)
222{ 606{
223 if (*dsp) { 607 return ds_access(task, index, record, ds_bts);
224 kfree((void *)get_bts_buffer_base(*dsp));
225 kfree(*dsp);
226 *dsp = NULL;
227 }
228 return 0;
229} 608}
230 609
231int ds_get_bts_size(void *ds) 610int ds_access_pebs(struct task_struct *task, size_t index, const void **record)
232{ 611{
233 int size_in_bytes; 612 return ds_access(task, index, record, ds_pebs);
234
235 if (!ds_cfg.sizeof_ds || !ds_cfg.sizeof_bts)
236 return -EOPNOTSUPP;
237
238 if (!ds)
239 return 0;
240
241 size_in_bytes =
242 get_bts_absolute_maximum(ds) -
243 get_bts_buffer_base(ds);
244 return size_in_bytes;
245} 613}
246 614
247int ds_get_bts_end(void *ds) 615static int ds_write(struct task_struct *task, const void *record, size_t size,
616 enum ds_qualifier qual, int force)
248{ 617{
249 int size_in_bytes = ds_get_bts_size(ds); 618 struct ds_context *context;
250 619 int error;
251 if (size_in_bytes <= 0)
252 return size_in_bytes;
253 620
254 return size_in_bytes / ds_cfg.sizeof_bts; 621 if (!record)
255} 622 return -EINVAL;
256 623
257int ds_get_bts_index(void *ds) 624 error = -EPERM;
258{ 625 context = ds_get_context(task);
259 int index_offset_in_bytes; 626 if (!context)
627 goto out;
260 628
261 if (!ds_cfg.sizeof_ds || !ds_cfg.sizeof_bts) 629 if (!force) {
262 return -EOPNOTSUPP; 630 error = ds_validate_access(context, qual);
631 if (error < 0)
632 goto out;
633 }
263 634
264 index_offset_in_bytes = 635 error = 0;
265 get_bts_index(ds) - 636 while (size) {
266 get_bts_buffer_base(ds); 637 unsigned long base, index, end, write_end, int_th;
638 unsigned long write_size, adj_write_size;
639
640 /*
641 * write as much as possible without producing an
642 * overflow interrupt.
643 *
644 * interrupt_threshold must either be
645 * - bigger than absolute_maximum or
646 * - point to a record between buffer_base and absolute_maximum
647 *
648 * index points to a valid record.
649 */
650 base = ds_get(context->ds, qual, ds_buffer_base);
651 index = ds_get(context->ds, qual, ds_index);
652 end = ds_get(context->ds, qual, ds_absolute_maximum);
653 int_th = ds_get(context->ds, qual, ds_interrupt_threshold);
654
655 write_end = min(end, int_th);
656
657 /* if we are already beyond the interrupt threshold,
658 * we fill the entire buffer */
659 if (write_end <= index)
660 write_end = end;
661
662 if (write_end <= index)
663 goto out;
664
665 write_size = min((unsigned long) size, write_end - index);
666 memcpy((void *)index, record, write_size);
667
668 record = (const char *)record + write_size;
669 size -= write_size;
670 error += write_size;
671
672 adj_write_size = write_size / ds_cfg.sizeof_rec[qual];
673 adj_write_size *= ds_cfg.sizeof_rec[qual];
674
675 /* zero out trailing bytes */
676 memset((char *)index + write_size, 0,
677 adj_write_size - write_size);
678 index += adj_write_size;
679
680 if (index >= end)
681 index = base;
682 ds_set(context->ds, qual, ds_index, index);
683
684 if (index >= int_th)
685 ds_overflow(task, context, qual);
686 }
267 687
268 return index_offset_in_bytes / ds_cfg.sizeof_bts; 688 out:
689 ds_put_context(context);
690 return error;
269} 691}
270 692
271int ds_set_overflow(void *ds, int method) 693int ds_write_bts(struct task_struct *task, const void *record, size_t size)
272{ 694{
273 switch (method) { 695 return ds_write(task, record, size, ds_bts, /* force = */ 0);
274 case DS_O_SIGNAL:
275 return -EOPNOTSUPP;
276 case DS_O_WRAP:
277 return 0;
278 default:
279 return -EINVAL;
280 }
281} 696}
282 697
283int ds_get_overflow(void *ds) 698int ds_write_pebs(struct task_struct *task, const void *record, size_t size)
284{ 699{
285 return DS_O_WRAP; 700 return ds_write(task, record, size, ds_pebs, /* force = */ 0);
286} 701}
287 702
288int ds_clear(void *ds) 703int ds_unchecked_write_bts(struct task_struct *task,
704 const void *record, size_t size)
289{ 705{
290 int bts_size = ds_get_bts_size(ds); 706 return ds_write(task, record, size, ds_bts, /* force = */ 1);
291 unsigned long bts_base;
292
293 if (bts_size <= 0)
294 return bts_size;
295
296 bts_base = get_bts_buffer_base(ds);
297 memset((void *)bts_base, 0, bts_size);
298
299 set_bts_index(ds, bts_base);
300 return 0;
301} 707}
302 708
303int ds_read_bts(void *ds, int index, struct bts_struct *out) 709int ds_unchecked_write_pebs(struct task_struct *task,
710 const void *record, size_t size)
304{ 711{
305 void *bts; 712 return ds_write(task, record, size, ds_pebs, /* force = */ 1);
713}
306 714
307 if (!ds_cfg.sizeof_ds || !ds_cfg.sizeof_bts) 715static int ds_reset_or_clear(struct task_struct *task,
308 return -EOPNOTSUPP; 716 enum ds_qualifier qual, int clear)
717{
718 struct ds_context *context;
719 unsigned long base, end;
720 int error;
309 721
310 if (index < 0) 722 context = ds_get_context(task);
311 return -EINVAL; 723 error = ds_validate_access(context, qual);
724 if (error < 0)
725 goto out;
312 726
313 if (index >= ds_get_bts_size(ds)) 727 base = ds_get(context->ds, qual, ds_buffer_base);
314 return -EINVAL; 728 end = ds_get(context->ds, qual, ds_absolute_maximum);
315 729
316 bts = (void *)(get_bts_buffer_base(ds) + (index * ds_cfg.sizeof_bts)); 730 if (clear)
731 memset((void *)base, 0, end - base);
317 732
318 memset(out, 0, sizeof(*out)); 733 ds_set(context->ds, qual, ds_index, base);
319 if (get_from_ip(bts) == BTS_ESCAPE_ADDRESS) {
320 out->qualifier = get_info_type(bts);
321 out->variant.jiffies = get_info_data(bts);
322 } else {
323 out->qualifier = BTS_BRANCH;
324 out->variant.lbr.from_ip = get_from_ip(bts);
325 out->variant.lbr.to_ip = get_to_ip(bts);
326 }
327 734
328 return sizeof(*out);; 735 error = 0;
736 out:
737 ds_put_context(context);
738 return error;
329} 739}
330 740
331int ds_write_bts(void *ds, const struct bts_struct *in) 741int ds_reset_bts(struct task_struct *task)
332{ 742{
333 unsigned long bts; 743 return ds_reset_or_clear(task, ds_bts, /* clear = */ 0);
334 744}
335 if (!ds_cfg.sizeof_ds || !ds_cfg.sizeof_bts)
336 return -EOPNOTSUPP;
337
338 if (ds_get_bts_size(ds) <= 0)
339 return -ENXIO;
340 745
341 bts = get_bts_index(ds); 746int ds_reset_pebs(struct task_struct *task)
747{
748 return ds_reset_or_clear(task, ds_pebs, /* clear = */ 0);
749}
342 750
343 memset((void *)bts, 0, ds_cfg.sizeof_bts); 751int ds_clear_bts(struct task_struct *task)
344 switch (in->qualifier) { 752{
345 case BTS_INVALID: 753 return ds_reset_or_clear(task, ds_bts, /* clear = */ 1);
346 break; 754}
347 755
348 case BTS_BRANCH: 756int ds_clear_pebs(struct task_struct *task)
349 set_from_ip((void *)bts, in->variant.lbr.from_ip); 757{
350 set_to_ip((void *)bts, in->variant.lbr.to_ip); 758 return ds_reset_or_clear(task, ds_pebs, /* clear = */ 1);
351 break; 759}
352 760
353 case BTS_TASK_ARRIVES: 761int ds_get_pebs_reset(struct task_struct *task, u64 *value)
354 case BTS_TASK_DEPARTS: 762{
355 set_from_ip((void *)bts, BTS_ESCAPE_ADDRESS); 763 struct ds_context *context;
356 set_info_type((void *)bts, in->qualifier); 764 int error;
357 set_info_data((void *)bts, in->variant.jiffies);
358 break;
359 765
360 default: 766 if (!value)
361 return -EINVAL; 767 return -EINVAL;
362 }
363 768
364 bts = bts + ds_cfg.sizeof_bts; 769 context = ds_get_context(task);
365 if (bts >= get_bts_absolute_maximum(ds)) 770 error = ds_validate_access(context, ds_pebs);
366 bts = get_bts_buffer_base(ds); 771 if (error < 0)
367 set_bts_index(ds, bts); 772 goto out;
368 773
369 return ds_cfg.sizeof_bts; 774 *value = *(u64 *)(context->ds + (ds_cfg.sizeof_field * 8));
775
776 error = 0;
777 out:
778 ds_put_context(context);
779 return error;
370} 780}
371 781
372unsigned long ds_debugctl_mask(void) 782int ds_set_pebs_reset(struct task_struct *task, u64 value)
373{ 783{
374 return ds_cfg.debugctl_mask; 784 struct ds_context *context;
375} 785 int error;
376 786
377#ifdef __i386__ 787 context = ds_get_context(task);
378static const struct ds_configuration ds_cfg_netburst = { 788 error = ds_validate_access(context, ds_pebs);
379 .sizeof_ds = 9 * 4, 789 if (error < 0)
380 .bts_buffer_base = { 0, 4 }, 790 goto out;
381 .bts_index = { 4, 4 },
382 .bts_absolute_maximum = { 8, 4 },
383 .bts_interrupt_threshold = { 12, 4 },
384 .sizeof_bts = 3 * 4,
385 .from_ip = { 0, 4 },
386 .to_ip = { 4, 4 },
387 .info_type = { 4, 1 },
388 .info_data = { 8, 4 },
389 .debugctl_mask = (1<<2)|(1<<3)
390};
391 791
392static const struct ds_configuration ds_cfg_pentium_m = { 792 *(u64 *)(context->ds + (ds_cfg.sizeof_field * 8)) = value;
393 .sizeof_ds = 9 * 4, 793
394 .bts_buffer_base = { 0, 4 }, 794 error = 0;
395 .bts_index = { 4, 4 }, 795 out:
396 .bts_absolute_maximum = { 8, 4 }, 796 ds_put_context(context);
397 .bts_interrupt_threshold = { 12, 4 }, 797 return error;
398 .sizeof_bts = 3 * 4, 798}
399 .from_ip = { 0, 4 }, 799
400 .to_ip = { 4, 4 }, 800static const struct ds_configuration ds_cfg_var = {
401 .info_type = { 4, 1 }, 801 .sizeof_ds = sizeof(long) * 12,
402 .info_data = { 8, 4 }, 802 .sizeof_field = sizeof(long),
403 .debugctl_mask = (1<<6)|(1<<7) 803 .sizeof_rec[ds_bts] = sizeof(long) * 3,
804 .sizeof_rec[ds_pebs] = sizeof(long) * 10
404}; 805};
405#endif /* _i386_ */ 806static const struct ds_configuration ds_cfg_64 = {
406 807 .sizeof_ds = 8 * 12,
407static const struct ds_configuration ds_cfg_core2 = { 808 .sizeof_field = 8,
408 .sizeof_ds = 9 * 8, 809 .sizeof_rec[ds_bts] = 8 * 3,
409 .bts_buffer_base = { 0, 8 }, 810 .sizeof_rec[ds_pebs] = 8 * 10
410 .bts_index = { 8, 8 },
411 .bts_absolute_maximum = { 16, 8 },
412 .bts_interrupt_threshold = { 24, 8 },
413 .sizeof_bts = 3 * 8,
414 .from_ip = { 0, 8 },
415 .to_ip = { 8, 8 },
416 .info_type = { 8, 1 },
417 .info_data = { 16, 8 },
418 .debugctl_mask = (1<<6)|(1<<7)|(1<<9)
419}; 811};
420 812
421static inline void 813static inline void
@@ -429,14 +821,13 @@ void __cpuinit ds_init_intel(struct cpuinfo_x86 *c)
429 switch (c->x86) { 821 switch (c->x86) {
430 case 0x6: 822 case 0x6:
431 switch (c->x86_model) { 823 switch (c->x86_model) {
432#ifdef __i386__
433 case 0xD: 824 case 0xD:
434 case 0xE: /* Pentium M */ 825 case 0xE: /* Pentium M */
435 ds_configure(&ds_cfg_pentium_m); 826 ds_configure(&ds_cfg_var);
436 break; 827 break;
437#endif /* _i386_ */
438 case 0xF: /* Core2 */ 828 case 0xF: /* Core2 */
439 ds_configure(&ds_cfg_core2); 829 case 0x1C: /* Atom */
830 ds_configure(&ds_cfg_64);
440 break; 831 break;
441 default: 832 default:
442 /* sorry, don't know about them */ 833 /* sorry, don't know about them */
@@ -445,13 +836,11 @@ void __cpuinit ds_init_intel(struct cpuinfo_x86 *c)
445 break; 836 break;
446 case 0xF: 837 case 0xF:
447 switch (c->x86_model) { 838 switch (c->x86_model) {
448#ifdef __i386__
449 case 0x0: 839 case 0x0:
450 case 0x1: 840 case 0x1:
451 case 0x2: /* Netburst */ 841 case 0x2: /* Netburst */
452 ds_configure(&ds_cfg_netburst); 842 ds_configure(&ds_cfg_var);
453 break; 843 break;
454#endif /* _i386_ */
455 default: 844 default:
456 /* sorry, don't know about them */ 845 /* sorry, don't know about them */
457 break; 846 break;
@@ -462,3 +851,14 @@ void __cpuinit ds_init_intel(struct cpuinfo_x86 *c)
462 break; 851 break;
463 } 852 }
464} 853}
854
855void ds_free(struct ds_context *context)
856{
857 /* This is called when the task owning the parameter context
858 * is dying. There should not be any user of that context left
859 * to disturb us, anymore. */
860 unsigned long leftovers = context->count;
861 while (leftovers--)
862 ds_put_context(context);
863}
864#endif /* CONFIG_X86_DS */
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 66e48aa2dd1b..78e642feac30 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -148,6 +148,9 @@ void __init e820_print_map(char *who)
148 case E820_NVS: 148 case E820_NVS:
149 printk(KERN_CONT "(ACPI NVS)\n"); 149 printk(KERN_CONT "(ACPI NVS)\n");
150 break; 150 break;
151 case E820_UNUSABLE:
152 printk("(unusable)\n");
153 break;
151 default: 154 default:
152 printk(KERN_CONT "type %u\n", e820.map[i].type); 155 printk(KERN_CONT "type %u\n", e820.map[i].type);
153 break; 156 break;
@@ -1260,6 +1263,7 @@ static inline const char *e820_type_to_string(int e820_type)
1260 case E820_RAM: return "System RAM"; 1263 case E820_RAM: return "System RAM";
1261 case E820_ACPI: return "ACPI Tables"; 1264 case E820_ACPI: return "ACPI Tables";
1262 case E820_NVS: return "ACPI Non-volatile Storage"; 1265 case E820_NVS: return "ACPI Non-volatile Storage";
1266 case E820_UNUSABLE: return "Unusable memory";
1263 default: return "reserved"; 1267 default: return "reserved";
1264 } 1268 }
1265} 1269}
@@ -1267,6 +1271,7 @@ static inline const char *e820_type_to_string(int e820_type)
1267/* 1271/*
1268 * Mark e820 reserved areas as busy for the resource manager. 1272 * Mark e820 reserved areas as busy for the resource manager.
1269 */ 1273 */
1274static struct resource __initdata *e820_res;
1270void __init e820_reserve_resources(void) 1275void __init e820_reserve_resources(void)
1271{ 1276{
1272 int i; 1277 int i;
@@ -1274,6 +1279,7 @@ void __init e820_reserve_resources(void)
1274 u64 end; 1279 u64 end;
1275 1280
1276 res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map); 1281 res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map);
1282 e820_res = res;
1277 for (i = 0; i < e820.nr_map; i++) { 1283 for (i = 0; i < e820.nr_map; i++) {
1278 end = e820.map[i].addr + e820.map[i].size - 1; 1284 end = e820.map[i].addr + e820.map[i].size - 1;
1279#ifndef CONFIG_RESOURCES_64BIT 1285#ifndef CONFIG_RESOURCES_64BIT
@@ -1287,7 +1293,14 @@ void __init e820_reserve_resources(void)
1287 res->end = end; 1293 res->end = end;
1288 1294
1289 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; 1295 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
1290 insert_resource(&iomem_resource, res); 1296
1297 /*
1298 * don't register the region that could be conflicted with
1299 * pci device BAR resource and insert them later in
1300 * pcibios_resource_survey()
1301 */
1302 if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20))
1303 insert_resource(&iomem_resource, res);
1291 res++; 1304 res++;
1292 } 1305 }
1293 1306
@@ -1299,6 +1312,19 @@ void __init e820_reserve_resources(void)
1299 } 1312 }
1300} 1313}
1301 1314
1315void __init e820_reserve_resources_late(void)
1316{
1317 int i;
1318 struct resource *res;
1319
1320 res = e820_res;
1321 for (i = 0; i < e820.nr_map; i++) {
1322 if (!res->parent && res->end)
1323 reserve_region_with_split(&iomem_resource, res->start, res->end, res->name);
1324 res++;
1325 }
1326}
1327
1302char *__init default_machine_specific_memory_setup(void) 1328char *__init default_machine_specific_memory_setup(void)
1303{ 1329{
1304 char *who = "BIOS-e820"; 1330 char *who = "BIOS-e820";
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 4353cf5e6fac..733c4f8d42ea 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -95,6 +95,66 @@ static void __init nvidia_bugs(int num, int slot, int func)
95 95
96} 96}
97 97
98static u32 ati_ixp4x0_rev(int num, int slot, int func)
99{
100 u32 d;
101 u8 b;
102
103 b = read_pci_config_byte(num, slot, func, 0xac);
104 b &= ~(1<<5);
105 write_pci_config_byte(num, slot, func, 0xac, b);
106
107 d = read_pci_config(num, slot, func, 0x70);
108 d |= 1<<8;
109 write_pci_config(num, slot, func, 0x70, d);
110
111 d = read_pci_config(num, slot, func, 0x8);
112 d &= 0xff;
113 return d;
114}
115
116static void __init ati_bugs(int num, int slot, int func)
117{
118#if defined(CONFIG_ACPI) && defined (CONFIG_X86_IO_APIC)
119 u32 d;
120 u8 b;
121
122 if (acpi_use_timer_override)
123 return;
124
125 d = ati_ixp4x0_rev(num, slot, func);
126 if (d < 0x82)
127 acpi_skip_timer_override = 1;
128 else {
129 /* check for IRQ0 interrupt swap */
130 outb(0x72, 0xcd6); b = inb(0xcd7);
131 if (!(b & 0x2))
132 acpi_skip_timer_override = 1;
133 }
134
135 if (acpi_skip_timer_override) {
136 printk(KERN_INFO "SB4X0 revision 0x%x\n", d);
137 printk(KERN_INFO "Ignoring ACPI timer override.\n");
138 printk(KERN_INFO "If you got timer trouble "
139 "try acpi_use_timer_override\n");
140 }
141#endif
142}
143
144#ifdef CONFIG_DMAR
145static void __init intel_g33_dmar(int num, int slot, int func)
146{
147 struct acpi_table_header *dmar_tbl;
148 acpi_status status;
149
150 status = acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_tbl);
151 if (ACPI_SUCCESS(status)) {
152 printk(KERN_INFO "BIOS BUG: DMAR advertised on Intel G31/G33 chipset -- ignoring\n");
153 dmar_disabled = 1;
154 }
155}
156#endif
157
98#define QFLAG_APPLY_ONCE 0x1 158#define QFLAG_APPLY_ONCE 0x1
99#define QFLAG_APPLIED 0x2 159#define QFLAG_APPLIED 0x2
100#define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED) 160#define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED)
@@ -114,6 +174,12 @@ static struct chipset early_qrk[] __initdata = {
114 PCI_CLASS_BRIDGE_PCI, PCI_ANY_ID, QFLAG_APPLY_ONCE, via_bugs }, 174 PCI_CLASS_BRIDGE_PCI, PCI_ANY_ID, QFLAG_APPLY_ONCE, via_bugs },
115 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB, 175 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB,
116 PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, fix_hypertransport_config }, 176 PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, fix_hypertransport_config },
177 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS,
178 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs },
179#ifdef CONFIG_DMAR
180 { PCI_VENDOR_ID_INTEL, 0x29c0,
181 PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, intel_g33_dmar },
182#endif
117 {} 183 {}
118}; 184};
119 185
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index ff9e7350da54..34ad997d3834 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -3,11 +3,19 @@
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/string.h> 4#include <linux/string.h>
5#include <linux/screen_info.h> 5#include <linux/screen_info.h>
6#include <linux/usb/ch9.h>
7#include <linux/pci_regs.h>
8#include <linux/pci_ids.h>
9#include <linux/errno.h>
6#include <asm/io.h> 10#include <asm/io.h>
7#include <asm/processor.h> 11#include <asm/processor.h>
8#include <asm/fcntl.h> 12#include <asm/fcntl.h>
9#include <asm/setup.h> 13#include <asm/setup.h>
10#include <xen/hvc-console.h> 14#include <xen/hvc-console.h>
15#include <asm/pci-direct.h>
16#include <asm/pgtable.h>
17#include <asm/fixmap.h>
18#include <linux/usb/ehci_def.h>
11 19
12/* Simple VGA output */ 20/* Simple VGA output */
13#define VGABASE (__ISA_IO_base + 0xb8000) 21#define VGABASE (__ISA_IO_base + 0xb8000)
@@ -78,6 +86,7 @@ static int early_serial_base = 0x3f8; /* ttyS0 */
78static int early_serial_putc(unsigned char ch) 86static int early_serial_putc(unsigned char ch)
79{ 87{
80 unsigned timeout = 0xffff; 88 unsigned timeout = 0xffff;
89
81 while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout) 90 while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
82 cpu_relax(); 91 cpu_relax();
83 outb(ch, early_serial_base + TXR); 92 outb(ch, early_serial_base + TXR);
@@ -111,7 +120,7 @@ static __init void early_serial_init(char *s)
111 if (!strncmp(s, "0x", 2)) { 120 if (!strncmp(s, "0x", 2)) {
112 early_serial_base = simple_strtoul(s, &e, 16); 121 early_serial_base = simple_strtoul(s, &e, 16);
113 } else { 122 } else {
114 static int bases[] = { 0x3f8, 0x2f8 }; 123 static const int __initconst bases[] = { 0x3f8, 0x2f8 };
115 124
116 if (!strncmp(s, "ttyS", 4)) 125 if (!strncmp(s, "ttyS", 4))
117 s += 4; 126 s += 4;
@@ -151,6 +160,721 @@ static struct console early_serial_console = {
151 .index = -1, 160 .index = -1,
152}; 161};
153 162
163#ifdef CONFIG_EARLY_PRINTK_DBGP
164
165static struct ehci_caps __iomem *ehci_caps;
166static struct ehci_regs __iomem *ehci_regs;
167static struct ehci_dbg_port __iomem *ehci_debug;
168static unsigned int dbgp_endpoint_out;
169
170struct ehci_dev {
171 u32 bus;
172 u32 slot;
173 u32 func;
174};
175
176static struct ehci_dev ehci_dev;
177
178#define USB_DEBUG_DEVNUM 127
179
180#define DBGP_DATA_TOGGLE 0x8800
181
182static inline u32 dbgp_pid_update(u32 x, u32 tok)
183{
184 return ((x ^ DBGP_DATA_TOGGLE) & 0xffff00) | (tok & 0xff);
185}
186
187static inline u32 dbgp_len_update(u32 x, u32 len)
188{
189 return (x & ~0x0f) | (len & 0x0f);
190}
191
192/*
193 * USB Packet IDs (PIDs)
194 */
195
196/* token */
197#define USB_PID_OUT 0xe1
198#define USB_PID_IN 0x69
199#define USB_PID_SOF 0xa5
200#define USB_PID_SETUP 0x2d
201/* handshake */
202#define USB_PID_ACK 0xd2
203#define USB_PID_NAK 0x5a
204#define USB_PID_STALL 0x1e
205#define USB_PID_NYET 0x96
206/* data */
207#define USB_PID_DATA0 0xc3
208#define USB_PID_DATA1 0x4b
209#define USB_PID_DATA2 0x87
210#define USB_PID_MDATA 0x0f
211/* Special */
212#define USB_PID_PREAMBLE 0x3c
213#define USB_PID_ERR 0x3c
214#define USB_PID_SPLIT 0x78
215#define USB_PID_PING 0xb4
216#define USB_PID_UNDEF_0 0xf0
217
218#define USB_PID_DATA_TOGGLE 0x88
219#define DBGP_CLAIM (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE)
220
221#define PCI_CAP_ID_EHCI_DEBUG 0xa
222
223#define HUB_ROOT_RESET_TIME 50 /* times are in msec */
224#define HUB_SHORT_RESET_TIME 10
225#define HUB_LONG_RESET_TIME 200
226#define HUB_RESET_TIMEOUT 500
227
228#define DBGP_MAX_PACKET 8
229
230static int dbgp_wait_until_complete(void)
231{
232 u32 ctrl;
233 int loop = 0x100000;
234
235 do {
236 ctrl = readl(&ehci_debug->control);
237 /* Stop when the transaction is finished */
238 if (ctrl & DBGP_DONE)
239 break;
240 } while (--loop > 0);
241
242 if (!loop)
243 return -1;
244
245 /*
246 * Now that we have observed the completed transaction,
247 * clear the done bit.
248 */
249 writel(ctrl | DBGP_DONE, &ehci_debug->control);
250 return (ctrl & DBGP_ERROR) ? -DBGP_ERRCODE(ctrl) : DBGP_LEN(ctrl);
251}
252
253static void dbgp_mdelay(int ms)
254{
255 int i;
256
257 while (ms--) {
258 for (i = 0; i < 1000; i++)
259 outb(0x1, 0x80);
260 }
261}
262
263static void dbgp_breath(void)
264{
265 /* Sleep to give the debug port a chance to breathe */
266}
267
268static int dbgp_wait_until_done(unsigned ctrl)
269{
270 u32 pids, lpid;
271 int ret;
272 int loop = 3;
273
274retry:
275 writel(ctrl | DBGP_GO, &ehci_debug->control);
276 ret = dbgp_wait_until_complete();
277 pids = readl(&ehci_debug->pids);
278 lpid = DBGP_PID_GET(pids);
279
280 if (ret < 0)
281 return ret;
282
283 /*
284 * If the port is getting full or it has dropped data
285 * start pacing ourselves, not necessary but it's friendly.
286 */
287 if ((lpid == USB_PID_NAK) || (lpid == USB_PID_NYET))
288 dbgp_breath();
289
290 /* If I get a NACK reissue the transmission */
291 if (lpid == USB_PID_NAK) {
292 if (--loop > 0)
293 goto retry;
294 }
295
296 return ret;
297}
298
299static void dbgp_set_data(const void *buf, int size)
300{
301 const unsigned char *bytes = buf;
302 u32 lo, hi;
303 int i;
304
305 lo = hi = 0;
306 for (i = 0; i < 4 && i < size; i++)
307 lo |= bytes[i] << (8*i);
308 for (; i < 8 && i < size; i++)
309 hi |= bytes[i] << (8*(i - 4));
310 writel(lo, &ehci_debug->data03);
311 writel(hi, &ehci_debug->data47);
312}
313
314static void dbgp_get_data(void *buf, int size)
315{
316 unsigned char *bytes = buf;
317 u32 lo, hi;
318 int i;
319
320 lo = readl(&ehci_debug->data03);
321 hi = readl(&ehci_debug->data47);
322 for (i = 0; i < 4 && i < size; i++)
323 bytes[i] = (lo >> (8*i)) & 0xff;
324 for (; i < 8 && i < size; i++)
325 bytes[i] = (hi >> (8*(i - 4))) & 0xff;
326}
327
328static int dbgp_bulk_write(unsigned devnum, unsigned endpoint,
329 const char *bytes, int size)
330{
331 u32 pids, addr, ctrl;
332 int ret;
333
334 if (size > DBGP_MAX_PACKET)
335 return -1;
336
337 addr = DBGP_EPADDR(devnum, endpoint);
338
339 pids = readl(&ehci_debug->pids);
340 pids = dbgp_pid_update(pids, USB_PID_OUT);
341
342 ctrl = readl(&ehci_debug->control);
343 ctrl = dbgp_len_update(ctrl, size);
344 ctrl |= DBGP_OUT;
345 ctrl |= DBGP_GO;
346
347 dbgp_set_data(bytes, size);
348 writel(addr, &ehci_debug->address);
349 writel(pids, &ehci_debug->pids);
350
351 ret = dbgp_wait_until_done(ctrl);
352 if (ret < 0)
353 return ret;
354
355 return ret;
356}
357
358static int dbgp_bulk_read(unsigned devnum, unsigned endpoint, void *data,
359 int size)
360{
361 u32 pids, addr, ctrl;
362 int ret;
363
364 if (size > DBGP_MAX_PACKET)
365 return -1;
366
367 addr = DBGP_EPADDR(devnum, endpoint);
368
369 pids = readl(&ehci_debug->pids);
370 pids = dbgp_pid_update(pids, USB_PID_IN);
371
372 ctrl = readl(&ehci_debug->control);
373 ctrl = dbgp_len_update(ctrl, size);
374 ctrl &= ~DBGP_OUT;
375 ctrl |= DBGP_GO;
376
377 writel(addr, &ehci_debug->address);
378 writel(pids, &ehci_debug->pids);
379 ret = dbgp_wait_until_done(ctrl);
380 if (ret < 0)
381 return ret;
382
383 if (size > ret)
384 size = ret;
385 dbgp_get_data(data, size);
386 return ret;
387}
388
389static int dbgp_control_msg(unsigned devnum, int requesttype, int request,
390 int value, int index, void *data, int size)
391{
392 u32 pids, addr, ctrl;
393 struct usb_ctrlrequest req;
394 int read;
395 int ret;
396
397 read = (requesttype & USB_DIR_IN) != 0;
398 if (size > (read ? DBGP_MAX_PACKET:0))
399 return -1;
400
401 /* Compute the control message */
402 req.bRequestType = requesttype;
403 req.bRequest = request;
404 req.wValue = cpu_to_le16(value);
405 req.wIndex = cpu_to_le16(index);
406 req.wLength = cpu_to_le16(size);
407
408 pids = DBGP_PID_SET(USB_PID_DATA0, USB_PID_SETUP);
409 addr = DBGP_EPADDR(devnum, 0);
410
411 ctrl = readl(&ehci_debug->control);
412 ctrl = dbgp_len_update(ctrl, sizeof(req));
413 ctrl |= DBGP_OUT;
414 ctrl |= DBGP_GO;
415
416 /* Send the setup message */
417 dbgp_set_data(&req, sizeof(req));
418 writel(addr, &ehci_debug->address);
419 writel(pids, &ehci_debug->pids);
420 ret = dbgp_wait_until_done(ctrl);
421 if (ret < 0)
422 return ret;
423
424 /* Read the result */
425 return dbgp_bulk_read(devnum, 0, data, size);
426}
427
428
429/* Find a PCI capability */
430static u32 __init find_cap(u32 num, u32 slot, u32 func, int cap)
431{
432 u8 pos;
433 int bytes;
434
435 if (!(read_pci_config_16(num, slot, func, PCI_STATUS) &
436 PCI_STATUS_CAP_LIST))
437 return 0;
438
439 pos = read_pci_config_byte(num, slot, func, PCI_CAPABILITY_LIST);
440 for (bytes = 0; bytes < 48 && pos >= 0x40; bytes++) {
441 u8 id;
442
443 pos &= ~3;
444 id = read_pci_config_byte(num, slot, func, pos+PCI_CAP_LIST_ID);
445 if (id == 0xff)
446 break;
447 if (id == cap)
448 return pos;
449
450 pos = read_pci_config_byte(num, slot, func,
451 pos+PCI_CAP_LIST_NEXT);
452 }
453 return 0;
454}
455
456static u32 __init __find_dbgp(u32 bus, u32 slot, u32 func)
457{
458 u32 class;
459
460 class = read_pci_config(bus, slot, func, PCI_CLASS_REVISION);
461 if ((class >> 8) != PCI_CLASS_SERIAL_USB_EHCI)
462 return 0;
463
464 return find_cap(bus, slot, func, PCI_CAP_ID_EHCI_DEBUG);
465}
466
467static u32 __init find_dbgp(int ehci_num, u32 *rbus, u32 *rslot, u32 *rfunc)
468{
469 u32 bus, slot, func;
470
471 for (bus = 0; bus < 256; bus++) {
472 for (slot = 0; slot < 32; slot++) {
473 for (func = 0; func < 8; func++) {
474 unsigned cap;
475
476 cap = __find_dbgp(bus, slot, func);
477
478 if (!cap)
479 continue;
480 if (ehci_num-- != 0)
481 continue;
482 *rbus = bus;
483 *rslot = slot;
484 *rfunc = func;
485 return cap;
486 }
487 }
488 }
489 return 0;
490}
491
492static int ehci_reset_port(int port)
493{
494 u32 portsc;
495 u32 delay_time, delay;
496 int loop;
497
498 /* Reset the usb debug port */
499 portsc = readl(&ehci_regs->port_status[port - 1]);
500 portsc &= ~PORT_PE;
501 portsc |= PORT_RESET;
502 writel(portsc, &ehci_regs->port_status[port - 1]);
503
504 delay = HUB_ROOT_RESET_TIME;
505 for (delay_time = 0; delay_time < HUB_RESET_TIMEOUT;
506 delay_time += delay) {
507 dbgp_mdelay(delay);
508
509 portsc = readl(&ehci_regs->port_status[port - 1]);
510 if (portsc & PORT_RESET) {
511 /* force reset to complete */
512 loop = 2;
513 writel(portsc & ~(PORT_RWC_BITS | PORT_RESET),
514 &ehci_regs->port_status[port - 1]);
515 do {
516 portsc = readl(&ehci_regs->port_status[port-1]);
517 } while ((portsc & PORT_RESET) && (--loop > 0));
518 }
519
520 /* Device went away? */
521 if (!(portsc & PORT_CONNECT))
522 return -ENOTCONN;
523
524 /* bomb out completely if something weird happend */
525 if ((portsc & PORT_CSC))
526 return -EINVAL;
527
528 /* If we've finished resetting, then break out of the loop */
529 if (!(portsc & PORT_RESET) && (portsc & PORT_PE))
530 return 0;
531 }
532 return -EBUSY;
533}
534
535static int ehci_wait_for_port(int port)
536{
537 u32 status;
538 int ret, reps;
539
540 for (reps = 0; reps < 3; reps++) {
541 dbgp_mdelay(100);
542 status = readl(&ehci_regs->status);
543 if (status & STS_PCD) {
544 ret = ehci_reset_port(port);
545 if (ret == 0)
546 return 0;
547 }
548 }
549 return -ENOTCONN;
550}
551
552#ifdef DBGP_DEBUG
553# define dbgp_printk early_printk
554#else
555static inline void dbgp_printk(const char *fmt, ...) { }
556#endif
557
558typedef void (*set_debug_port_t)(int port);
559
560static void default_set_debug_port(int port)
561{
562}
563
564static set_debug_port_t set_debug_port = default_set_debug_port;
565
566static void nvidia_set_debug_port(int port)
567{
568 u32 dword;
569 dword = read_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func,
570 0x74);
571 dword &= ~(0x0f<<12);
572 dword |= ((port & 0x0f)<<12);
573 write_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func, 0x74,
574 dword);
575 dbgp_printk("set debug port to %d\n", port);
576}
577
578static void __init detect_set_debug_port(void)
579{
580 u32 vendorid;
581
582 vendorid = read_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func,
583 0x00);
584
585 if ((vendorid & 0xffff) == 0x10de) {
586 dbgp_printk("using nvidia set_debug_port\n");
587 set_debug_port = nvidia_set_debug_port;
588 }
589}
590
591static int __init ehci_setup(void)
592{
593 struct usb_debug_descriptor dbgp_desc;
594 u32 cmd, ctrl, status, portsc, hcs_params;
595 u32 debug_port, new_debug_port = 0, n_ports;
596 u32 devnum;
597 int ret, i;
598 int loop;
599 int port_map_tried;
600 int playtimes = 3;
601
602try_next_time:
603 port_map_tried = 0;
604
605try_next_port:
606
607 hcs_params = readl(&ehci_caps->hcs_params);
608 debug_port = HCS_DEBUG_PORT(hcs_params);
609 n_ports = HCS_N_PORTS(hcs_params);
610
611 dbgp_printk("debug_port: %d\n", debug_port);
612 dbgp_printk("n_ports: %d\n", n_ports);
613
614 for (i = 1; i <= n_ports; i++) {
615 portsc = readl(&ehci_regs->port_status[i-1]);
616 dbgp_printk("portstatus%d: %08x\n", i, portsc);
617 }
618
619 if (port_map_tried && (new_debug_port != debug_port)) {
620 if (--playtimes) {
621 set_debug_port(new_debug_port);
622 goto try_next_time;
623 }
624 return -1;
625 }
626
627 loop = 10;
628 /* Reset the EHCI controller */
629 cmd = readl(&ehci_regs->command);
630 cmd |= CMD_RESET;
631 writel(cmd, &ehci_regs->command);
632 do {
633 cmd = readl(&ehci_regs->command);
634 } while ((cmd & CMD_RESET) && (--loop > 0));
635
636 if (!loop) {
637 dbgp_printk("can not reset ehci\n");
638 return -1;
639 }
640 dbgp_printk("ehci reset done\n");
641
642 /* Claim ownership, but do not enable yet */
643 ctrl = readl(&ehci_debug->control);
644 ctrl |= DBGP_OWNER;
645 ctrl &= ~(DBGP_ENABLED | DBGP_INUSE);
646 writel(ctrl, &ehci_debug->control);
647
648 /* Start the ehci running */
649 cmd = readl(&ehci_regs->command);
650 cmd &= ~(CMD_LRESET | CMD_IAAD | CMD_PSE | CMD_ASE | CMD_RESET);
651 cmd |= CMD_RUN;
652 writel(cmd, &ehci_regs->command);
653
654 /* Ensure everything is routed to the EHCI */
655 writel(FLAG_CF, &ehci_regs->configured_flag);
656
657 /* Wait until the controller is no longer halted */
658 loop = 10;
659 do {
660 status = readl(&ehci_regs->status);
661 } while ((status & STS_HALT) && (--loop > 0));
662
663 if (!loop) {
664 dbgp_printk("ehci can be started\n");
665 return -1;
666 }
667 dbgp_printk("ehci started\n");
668
669 /* Wait for a device to show up in the debug port */
670 ret = ehci_wait_for_port(debug_port);
671 if (ret < 0) {
672 dbgp_printk("No device found in debug port\n");
673 goto next_debug_port;
674 }
675 dbgp_printk("ehci wait for port done\n");
676
677 /* Enable the debug port */
678 ctrl = readl(&ehci_debug->control);
679 ctrl |= DBGP_CLAIM;
680 writel(ctrl, &ehci_debug->control);
681 ctrl = readl(&ehci_debug->control);
682 if ((ctrl & DBGP_CLAIM) != DBGP_CLAIM) {
683 dbgp_printk("No device in debug port\n");
684 writel(ctrl & ~DBGP_CLAIM, &ehci_debug->control);
685 goto err;
686 }
687 dbgp_printk("debug ported enabled\n");
688
689 /* Completely transfer the debug device to the debug controller */
690 portsc = readl(&ehci_regs->port_status[debug_port - 1]);
691 portsc &= ~PORT_PE;
692 writel(portsc, &ehci_regs->port_status[debug_port - 1]);
693
694 dbgp_mdelay(100);
695
696 /* Find the debug device and make it device number 127 */
697 for (devnum = 0; devnum <= 127; devnum++) {
698 ret = dbgp_control_msg(devnum,
699 USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
700 USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0,
701 &dbgp_desc, sizeof(dbgp_desc));
702 if (ret > 0)
703 break;
704 }
705 if (devnum > 127) {
706 dbgp_printk("Could not find attached debug device\n");
707 goto err;
708 }
709 if (ret < 0) {
710 dbgp_printk("Attached device is not a debug device\n");
711 goto err;
712 }
713 dbgp_endpoint_out = dbgp_desc.bDebugOutEndpoint;
714
715 /* Move the device to 127 if it isn't already there */
716 if (devnum != USB_DEBUG_DEVNUM) {
717 ret = dbgp_control_msg(devnum,
718 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
719 USB_REQ_SET_ADDRESS, USB_DEBUG_DEVNUM, 0, NULL, 0);
720 if (ret < 0) {
721 dbgp_printk("Could not move attached device to %d\n",
722 USB_DEBUG_DEVNUM);
723 goto err;
724 }
725 devnum = USB_DEBUG_DEVNUM;
726 dbgp_printk("debug device renamed to 127\n");
727 }
728
729 /* Enable the debug interface */
730 ret = dbgp_control_msg(USB_DEBUG_DEVNUM,
731 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
732 USB_REQ_SET_FEATURE, USB_DEVICE_DEBUG_MODE, 0, NULL, 0);
733 if (ret < 0) {
734 dbgp_printk(" Could not enable the debug device\n");
735 goto err;
736 }
737 dbgp_printk("debug interface enabled\n");
738
739 /* Perform a small write to get the even/odd data state in sync
740 */
741 ret = dbgp_bulk_write(USB_DEBUG_DEVNUM, dbgp_endpoint_out, " ", 1);
742 if (ret < 0) {
743 dbgp_printk("dbgp_bulk_write failed: %d\n", ret);
744 goto err;
745 }
746 dbgp_printk("small write doned\n");
747
748 return 0;
749err:
750 /* Things didn't work so remove my claim */
751 ctrl = readl(&ehci_debug->control);
752 ctrl &= ~(DBGP_CLAIM | DBGP_OUT);
753 writel(ctrl, &ehci_debug->control);
754 return -1;
755
756next_debug_port:
757 port_map_tried |= (1<<(debug_port - 1));
758 new_debug_port = ((debug_port-1+1)%n_ports) + 1;
759 if (port_map_tried != ((1<<n_ports) - 1)) {
760 set_debug_port(new_debug_port);
761 goto try_next_port;
762 }
763 if (--playtimes) {
764 set_debug_port(new_debug_port);
765 goto try_next_time;
766 }
767
768 return -1;
769}
770
771static int __init early_dbgp_init(char *s)
772{
773 u32 debug_port, bar, offset;
774 u32 bus, slot, func, cap;
775 void __iomem *ehci_bar;
776 u32 dbgp_num;
777 u32 bar_val;
778 char *e;
779 int ret;
780 u8 byte;
781
782 if (!early_pci_allowed())
783 return -1;
784
785 dbgp_num = 0;
786 if (*s)
787 dbgp_num = simple_strtoul(s, &e, 10);
788 dbgp_printk("dbgp_num: %d\n", dbgp_num);
789
790 cap = find_dbgp(dbgp_num, &bus, &slot, &func);
791 if (!cap)
792 return -1;
793
794 dbgp_printk("Found EHCI debug port on %02x:%02x.%1x\n", bus, slot,
795 func);
796
797 debug_port = read_pci_config(bus, slot, func, cap);
798 bar = (debug_port >> 29) & 0x7;
799 bar = (bar * 4) + 0xc;
800 offset = (debug_port >> 16) & 0xfff;
801 dbgp_printk("bar: %02x offset: %03x\n", bar, offset);
802 if (bar != PCI_BASE_ADDRESS_0) {
803 dbgp_printk("only debug ports on bar 1 handled.\n");
804
805 return -1;
806 }
807
808 bar_val = read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_0);
809 dbgp_printk("bar_val: %02x offset: %03x\n", bar_val, offset);
810 if (bar_val & ~PCI_BASE_ADDRESS_MEM_MASK) {
811 dbgp_printk("only simple 32bit mmio bars supported\n");
812
813 return -1;
814 }
815
816 /* double check if the mem space is enabled */
817 byte = read_pci_config_byte(bus, slot, func, 0x04);
818 if (!(byte & 0x2)) {
819 byte |= 0x02;
820 write_pci_config_byte(bus, slot, func, 0x04, byte);
821 dbgp_printk("mmio for ehci enabled\n");
822 }
823
824 /*
825 * FIXME I don't have the bar size so just guess PAGE_SIZE is more
826 * than enough. 1K is the biggest I have seen.
827 */
828 set_fixmap_nocache(FIX_DBGP_BASE, bar_val & PAGE_MASK);
829 ehci_bar = (void __iomem *)__fix_to_virt(FIX_DBGP_BASE);
830 ehci_bar += bar_val & ~PAGE_MASK;
831 dbgp_printk("ehci_bar: %p\n", ehci_bar);
832
833 ehci_caps = ehci_bar;
834 ehci_regs = ehci_bar + HC_LENGTH(readl(&ehci_caps->hc_capbase));
835 ehci_debug = ehci_bar + offset;
836 ehci_dev.bus = bus;
837 ehci_dev.slot = slot;
838 ehci_dev.func = func;
839
840 detect_set_debug_port();
841
842 ret = ehci_setup();
843 if (ret < 0) {
844 dbgp_printk("ehci_setup failed\n");
845 ehci_debug = NULL;
846
847 return -1;
848 }
849
850 return 0;
851}
852
853static void early_dbgp_write(struct console *con, const char *str, u32 n)
854{
855 int chunk, ret;
856
857 if (!ehci_debug)
858 return;
859 while (n > 0) {
860 chunk = n;
861 if (chunk > DBGP_MAX_PACKET)
862 chunk = DBGP_MAX_PACKET;
863 ret = dbgp_bulk_write(USB_DEBUG_DEVNUM,
864 dbgp_endpoint_out, str, chunk);
865 str += chunk;
866 n -= chunk;
867 }
868}
869
870static struct console early_dbgp_console = {
871 .name = "earlydbg",
872 .write = early_dbgp_write,
873 .flags = CON_PRINTBUFFER,
874 .index = -1,
875};
876#endif
877
154/* Console interface to a host file on AMD's SimNow! */ 878/* Console interface to a host file on AMD's SimNow! */
155 879
156static int simnow_fd; 880static int simnow_fd;
@@ -165,6 +889,7 @@ enum {
165static noinline long simnow(long cmd, long a, long b, long c) 889static noinline long simnow(long cmd, long a, long b, long c)
166{ 890{
167 long ret; 891 long ret;
892
168 asm volatile("cpuid" : 893 asm volatile("cpuid" :
169 "=a" (ret) : 894 "=a" (ret) :
170 "b" (a), "c" (b), "d" (c), "0" (MAGIC1), "D" (cmd + MAGIC2)); 895 "b" (a), "c" (b), "d" (c), "0" (MAGIC1), "D" (cmd + MAGIC2));
@@ -174,6 +899,7 @@ static noinline long simnow(long cmd, long a, long b, long c)
174static void __init simnow_init(char *str) 899static void __init simnow_init(char *str)
175{ 900{
176 char *fn = "klog"; 901 char *fn = "klog";
902
177 if (*str == '=') 903 if (*str == '=')
178 fn = ++str; 904 fn = ++str;
179 /* error ignored */ 905 /* error ignored */
@@ -194,7 +920,7 @@ static struct console simnow_console = {
194 920
195/* Direct interface for emergencies */ 921/* Direct interface for emergencies */
196static struct console *early_console = &early_vga_console; 922static struct console *early_console = &early_vga_console;
197static int early_console_initialized; 923static int __initdata early_console_initialized;
198 924
199asmlinkage void early_printk(const char *fmt, ...) 925asmlinkage void early_printk(const char *fmt, ...)
200{ 926{
@@ -208,10 +934,11 @@ asmlinkage void early_printk(const char *fmt, ...)
208 va_end(ap); 934 va_end(ap);
209} 935}
210 936
211static int __initdata keep_early;
212 937
213static int __init setup_early_printk(char *buf) 938static int __init setup_early_printk(char *buf)
214{ 939{
940 int keep_early;
941
215 if (!buf) 942 if (!buf)
216 return 0; 943 return 0;
217 944
@@ -219,8 +946,7 @@ static int __init setup_early_printk(char *buf)
219 return 0; 946 return 0;
220 early_console_initialized = 1; 947 early_console_initialized = 1;
221 948
222 if (strstr(buf, "keep")) 949 keep_early = (strstr(buf, "keep") != NULL);
223 keep_early = 1;
224 950
225 if (!strncmp(buf, "serial", 6)) { 951 if (!strncmp(buf, "serial", 6)) {
226 early_serial_init(buf + 6); 952 early_serial_init(buf + 6);
@@ -238,6 +964,17 @@ static int __init setup_early_printk(char *buf)
238 simnow_init(buf + 6); 964 simnow_init(buf + 6);
239 early_console = &simnow_console; 965 early_console = &simnow_console;
240 keep_early = 1; 966 keep_early = 1;
967#ifdef CONFIG_EARLY_PRINTK_DBGP
968 } else if (!strncmp(buf, "dbgp", 4)) {
969 if (early_dbgp_init(buf+4) < 0)
970 return 0;
971 early_console = &early_dbgp_console;
972 /*
973 * usb subsys will reset ehci controller, so don't keep
974 * that early console
975 */
976 keep_early = 0;
977#endif
241#ifdef CONFIG_HVC_XEN 978#ifdef CONFIG_HVC_XEN
242 } else if (!strncmp(buf, "xen", 3)) { 979 } else if (!strncmp(buf, "xen", 3)) {
243 early_console = &xenboot_console; 980 early_console = &xenboot_console;
@@ -251,4 +988,5 @@ static int __init setup_early_printk(char *buf)
251 register_console(early_console); 988 register_console(early_console);
252 return 0; 989 return 0;
253} 990}
991
254early_param("earlyprintk", setup_early_printk); 992early_param("earlyprintk", setup_early_printk);
diff --git a/arch/x86/kernel/efi.c b/arch/x86/kernel/efi.c
index 06cc8d4254b1..945a31cdd81f 100644
--- a/arch/x86/kernel/efi.c
+++ b/arch/x86/kernel/efi.c
@@ -414,9 +414,11 @@ void __init efi_init(void)
414 if (memmap.map == NULL) 414 if (memmap.map == NULL)
415 printk(KERN_ERR "Could not map the EFI memory map!\n"); 415 printk(KERN_ERR "Could not map the EFI memory map!\n");
416 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size); 416 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
417
417 if (memmap.desc_size != sizeof(efi_memory_desc_t)) 418 if (memmap.desc_size != sizeof(efi_memory_desc_t))
418 printk(KERN_WARNING "Kernel-defined memdesc" 419 printk(KERN_WARNING
419 "doesn't match the one from EFI!\n"); 420 "Kernel-defined memdesc doesn't match the one from EFI!\n");
421
420 if (add_efi_memmap) 422 if (add_efi_memmap)
421 do_add_efi_memmap(); 423 do_add_efi_memmap();
422 424
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 89434d439605..cf3a0b2d0059 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -275,9 +275,9 @@ ENTRY(native_usergs_sysret64)
275ENTRY(ret_from_fork) 275ENTRY(ret_from_fork)
276 CFI_DEFAULT_STACK 276 CFI_DEFAULT_STACK
277 push kernel_eflags(%rip) 277 push kernel_eflags(%rip)
278 CFI_ADJUST_CFA_OFFSET 4 278 CFI_ADJUST_CFA_OFFSET 8
279 popf # reset kernel eflags 279 popf # reset kernel eflags
280 CFI_ADJUST_CFA_OFFSET -4 280 CFI_ADJUST_CFA_OFFSET -8
281 call schedule_tail 281 call schedule_tail
282 GET_THREAD_INFO(%rcx) 282 GET_THREAD_INFO(%rcx)
283 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%rcx) 283 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
diff --git a/arch/x86/mach-es7000/es7000plat.c b/arch/x86/kernel/es7000_32.c
index 50189af14b85..849e5cd485b8 100644
--- a/arch/x86/mach-es7000/es7000plat.c
+++ b/arch/x86/kernel/es7000_32.c
@@ -39,10 +39,93 @@
39#include <asm/nmi.h> 39#include <asm/nmi.h>
40#include <asm/smp.h> 40#include <asm/smp.h>
41#include <asm/apicdef.h> 41#include <asm/apicdef.h>
42#include "es7000.h"
43#include <mach_mpparse.h> 42#include <mach_mpparse.h>
44 43
45/* 44/*
45 * ES7000 chipsets
46 */
47
48#define NON_UNISYS 0
49#define ES7000_CLASSIC 1
50#define ES7000_ZORRO 2
51
52
53#define MIP_REG 1
54#define MIP_PSAI_REG 4
55
56#define MIP_BUSY 1
57#define MIP_SPIN 0xf0000
58#define MIP_VALID 0x0100000000000000ULL
59#define MIP_PORT(VALUE) ((VALUE >> 32) & 0xffff)
60
61#define MIP_RD_LO(VALUE) (VALUE & 0xffffffff)
62
63struct mip_reg_info {
64 unsigned long long mip_info;
65 unsigned long long delivery_info;
66 unsigned long long host_reg;
67 unsigned long long mip_reg;
68};
69
70struct part_info {
71 unsigned char type;
72 unsigned char length;
73 unsigned char part_id;
74 unsigned char apic_mode;
75 unsigned long snum;
76 char ptype[16];
77 char sname[64];
78 char pname[64];
79};
80
81struct psai {
82 unsigned long long entry_type;
83 unsigned long long addr;
84 unsigned long long bep_addr;
85};
86
87struct es7000_mem_info {
88 unsigned char type;
89 unsigned char length;
90 unsigned char resv[6];
91 unsigned long long start;
92 unsigned long long size;
93};
94
95struct es7000_oem_table {
96 unsigned long long hdr;
97 struct mip_reg_info mip;
98 struct part_info pif;
99 struct es7000_mem_info shm;
100 struct psai psai;
101};
102
103#ifdef CONFIG_ACPI
104
105struct oem_table {
106 struct acpi_table_header Header;
107 u32 OEMTableAddr;
108 u32 OEMTableSize;
109};
110
111extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
112#endif
113
114struct mip_reg {
115 unsigned long long off_0;
116 unsigned long long off_8;
117 unsigned long long off_10;
118 unsigned long long off_18;
119 unsigned long long off_20;
120 unsigned long long off_28;
121 unsigned long long off_30;
122 unsigned long long off_38;
123};
124
125#define MIP_SW_APIC 0x1020b
126#define MIP_FUNC(VALUE) (VALUE & 0xff)
127
128/*
46 * ES7000 Globals 129 * ES7000 Globals
47 */ 130 */
48 131
@@ -72,7 +155,7 @@ es7000_rename_gsi(int ioapic, int gsi)
72 base += nr_ioapic_registers[i]; 155 base += nr_ioapic_registers[i];
73 } 156 }
74 157
75 if (!ioapic && (gsi < 16)) 158 if (!ioapic && (gsi < 16))
76 gsi += base; 159 gsi += base;
77 return gsi; 160 return gsi;
78} 161}
diff --git a/arch/x86/kernel/genapic_64.c b/arch/x86/kernel/genapic_64.c
index eaff0bbb1444..6c9bfc9e1e95 100644
--- a/arch/x86/kernel/genapic_64.c
+++ b/arch/x86/kernel/genapic_64.c
@@ -16,87 +16,63 @@
16#include <linux/ctype.h> 16#include <linux/ctype.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/hardirq.h> 18#include <linux/hardirq.h>
19#include <linux/dmar.h>
19 20
20#include <asm/smp.h> 21#include <asm/smp.h>
21#include <asm/ipi.h> 22#include <asm/ipi.h>
22#include <asm/genapic.h> 23#include <asm/genapic.h>
23 24
24#ifdef CONFIG_ACPI 25extern struct genapic apic_flat;
25#include <acpi/acpi_bus.h> 26extern struct genapic apic_physflat;
26#endif 27extern struct genapic apic_x2xpic_uv_x;
27 28extern struct genapic apic_x2apic_phys;
28DEFINE_PER_CPU(int, x2apic_extra_bits); 29extern struct genapic apic_x2apic_cluster;
29 30
30struct genapic __read_mostly *genapic = &apic_flat; 31struct genapic __read_mostly *genapic = &apic_flat;
31 32
32static enum uv_system_type uv_system_type; 33static struct genapic *apic_probe[] __initdata = {
34 &apic_x2apic_uv_x,
35 &apic_x2apic_phys,
36 &apic_x2apic_cluster,
37 &apic_physflat,
38 NULL,
39};
33 40
34/* 41/*
35 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. 42 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
36 */ 43 */
37void __init setup_apic_routing(void) 44void __init setup_apic_routing(void)
38{ 45{
39 if (uv_system_type == UV_NON_UNIQUE_APIC) 46 if (genapic == &apic_x2apic_phys || genapic == &apic_x2apic_cluster) {
40 genapic = &apic_x2apic_uv_x; 47 if (!intr_remapping_enabled)
41 else 48 genapic = &apic_flat;
42#ifdef CONFIG_ACPI 49 }
43 /*
44 * Quirk: some x86_64 machines can only use physical APIC mode
45 * regardless of how many processors are present (x86_64 ES7000
46 * is an example).
47 */
48 if (acpi_gbl_FADT.header.revision > FADT2_REVISION_ID &&
49 (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL))
50 genapic = &apic_physflat;
51 else
52#endif
53
54 if (max_physical_apicid < 8)
55 genapic = &apic_flat;
56 else
57 genapic = &apic_physflat;
58 50
59 printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name); 51 if (genapic == &apic_flat) {
52 if (max_physical_apicid >= 8)
53 genapic = &apic_physflat;
54 printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
55 }
60} 56}
61 57
62/* Same for both flat and physical. */ 58/* Same for both flat and physical. */
63 59
64void send_IPI_self(int vector) 60void apic_send_IPI_self(int vector)
65{ 61{
66 __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); 62 __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
67} 63}
68 64
69int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id) 65int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
70{ 66{
71 if (!strcmp(oem_id, "SGI")) { 67 int i;
72 if (!strcmp(oem_table_id, "UVL")) 68
73 uv_system_type = UV_LEGACY_APIC; 69 for (i = 0; apic_probe[i]; ++i) {
74 else if (!strcmp(oem_table_id, "UVX")) 70 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
75 uv_system_type = UV_X2APIC; 71 genapic = apic_probe[i];
76 else if (!strcmp(oem_table_id, "UVH")) 72 printk(KERN_INFO "Setting APIC routing to %s.\n",
77 uv_system_type = UV_NON_UNIQUE_APIC; 73 genapic->name);
74 return 1;
75 }
78 } 76 }
79 return 0; 77 return 0;
80} 78}
81
82unsigned int read_apic_id(void)
83{
84 unsigned int id;
85
86 WARN_ON(preemptible() && num_online_cpus() > 1);
87 id = apic_read(APIC_ID);
88 if (uv_system_type >= UV_X2APIC)
89 id |= __get_cpu_var(x2apic_extra_bits);
90 return id;
91}
92
93enum uv_system_type get_uv_system_type(void)
94{
95 return uv_system_type;
96}
97
98int is_uv_system(void)
99{
100 return uv_system_type != UV_NONE;
101}
102EXPORT_SYMBOL_GPL(is_uv_system);
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c
index 786548a62d38..9eca5ba7a6b1 100644
--- a/arch/x86/kernel/genapic_flat_64.c
+++ b/arch/x86/kernel/genapic_flat_64.c
@@ -15,9 +15,20 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/ctype.h> 16#include <linux/ctype.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/hardirq.h>
18#include <asm/smp.h> 19#include <asm/smp.h>
19#include <asm/ipi.h> 20#include <asm/ipi.h>
20#include <asm/genapic.h> 21#include <asm/genapic.h>
22#include <mach_apicdef.h>
23
24#ifdef CONFIG_ACPI
25#include <acpi/acpi_bus.h>
26#endif
27
28static int __init flat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
29{
30 return 1;
31}
21 32
22static cpumask_t flat_target_cpus(void) 33static cpumask_t flat_target_cpus(void)
23{ 34{
@@ -95,9 +106,33 @@ static void flat_send_IPI_all(int vector)
95 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); 106 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
96} 107}
97 108
109static unsigned int get_apic_id(unsigned long x)
110{
111 unsigned int id;
112
113 id = (((x)>>24) & 0xFFu);
114 return id;
115}
116
117static unsigned long set_apic_id(unsigned int id)
118{
119 unsigned long x;
120
121 x = ((id & 0xFFu)<<24);
122 return x;
123}
124
125static unsigned int read_xapic_id(void)
126{
127 unsigned int id;
128
129 id = get_apic_id(apic_read(APIC_ID));
130 return id;
131}
132
98static int flat_apic_id_registered(void) 133static int flat_apic_id_registered(void)
99{ 134{
100 return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map); 135 return physid_isset(read_xapic_id(), phys_cpu_present_map);
101} 136}
102 137
103static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask) 138static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask)
@@ -112,6 +147,7 @@ static unsigned int phys_pkg_id(int index_msb)
112 147
113struct genapic apic_flat = { 148struct genapic apic_flat = {
114 .name = "flat", 149 .name = "flat",
150 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
115 .int_delivery_mode = dest_LowestPrio, 151 .int_delivery_mode = dest_LowestPrio,
116 .int_dest_mode = (APIC_DEST_LOGICAL != 0), 152 .int_dest_mode = (APIC_DEST_LOGICAL != 0),
117 .target_cpus = flat_target_cpus, 153 .target_cpus = flat_target_cpus,
@@ -121,8 +157,12 @@ struct genapic apic_flat = {
121 .send_IPI_all = flat_send_IPI_all, 157 .send_IPI_all = flat_send_IPI_all,
122 .send_IPI_allbutself = flat_send_IPI_allbutself, 158 .send_IPI_allbutself = flat_send_IPI_allbutself,
123 .send_IPI_mask = flat_send_IPI_mask, 159 .send_IPI_mask = flat_send_IPI_mask,
160 .send_IPI_self = apic_send_IPI_self,
124 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, 161 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
125 .phys_pkg_id = phys_pkg_id, 162 .phys_pkg_id = phys_pkg_id,
163 .get_apic_id = get_apic_id,
164 .set_apic_id = set_apic_id,
165 .apic_id_mask = (0xFFu<<24),
126}; 166};
127 167
128/* 168/*
@@ -130,6 +170,21 @@ struct genapic apic_flat = {
130 * We cannot use logical delivery in this case because the mask 170 * We cannot use logical delivery in this case because the mask
131 * overflows, so use physical mode. 171 * overflows, so use physical mode.
132 */ 172 */
173static int __init physflat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
174{
175#ifdef CONFIG_ACPI
176 /*
177 * Quirk: some x86_64 machines can only use physical APIC mode
178 * regardless of how many processors are present (x86_64 ES7000
179 * is an example).
180 */
181 if (acpi_gbl_FADT.header.revision > FADT2_REVISION_ID &&
182 (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL))
183 return 1;
184#endif
185
186 return 0;
187}
133 188
134static cpumask_t physflat_target_cpus(void) 189static cpumask_t physflat_target_cpus(void)
135{ 190{
@@ -176,6 +231,7 @@ static unsigned int physflat_cpu_mask_to_apicid(cpumask_t cpumask)
176 231
177struct genapic apic_physflat = { 232struct genapic apic_physflat = {
178 .name = "physical flat", 233 .name = "physical flat",
234 .acpi_madt_oem_check = physflat_acpi_madt_oem_check,
179 .int_delivery_mode = dest_Fixed, 235 .int_delivery_mode = dest_Fixed,
180 .int_dest_mode = (APIC_DEST_PHYSICAL != 0), 236 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
181 .target_cpus = physflat_target_cpus, 237 .target_cpus = physflat_target_cpus,
@@ -185,6 +241,10 @@ struct genapic apic_physflat = {
185 .send_IPI_all = physflat_send_IPI_all, 241 .send_IPI_all = physflat_send_IPI_all,
186 .send_IPI_allbutself = physflat_send_IPI_allbutself, 242 .send_IPI_allbutself = physflat_send_IPI_allbutself,
187 .send_IPI_mask = physflat_send_IPI_mask, 243 .send_IPI_mask = physflat_send_IPI_mask,
244 .send_IPI_self = apic_send_IPI_self,
188 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, 245 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
189 .phys_pkg_id = phys_pkg_id, 246 .phys_pkg_id = phys_pkg_id,
247 .get_apic_id = get_apic_id,
248 .set_apic_id = set_apic_id,
249 .apic_id_mask = (0xFFu<<24),
190}; 250};
diff --git a/arch/x86/kernel/genx2apic_cluster.c b/arch/x86/kernel/genx2apic_cluster.c
new file mode 100644
index 000000000000..e4bf2cc0d743
--- /dev/null
+++ b/arch/x86/kernel/genx2apic_cluster.c
@@ -0,0 +1,159 @@
1#include <linux/threads.h>
2#include <linux/cpumask.h>
3#include <linux/string.h>
4#include <linux/kernel.h>
5#include <linux/ctype.h>
6#include <linux/init.h>
7#include <linux/dmar.h>
8
9#include <asm/smp.h>
10#include <asm/ipi.h>
11#include <asm/genapic.h>
12
13DEFINE_PER_CPU(u32, x86_cpu_to_logical_apicid);
14
15static int __init x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
16{
17 if (cpu_has_x2apic)
18 return 1;
19
20 return 0;
21}
22
23/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */
24
25static cpumask_t x2apic_target_cpus(void)
26{
27 return cpumask_of_cpu(0);
28}
29
30/*
31 * for now each logical cpu is in its own vector allocation domain.
32 */
33static cpumask_t x2apic_vector_allocation_domain(int cpu)
34{
35 cpumask_t domain = CPU_MASK_NONE;
36 cpu_set(cpu, domain);
37 return domain;
38}
39
40static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
41 unsigned int dest)
42{
43 unsigned long cfg;
44
45 cfg = __prepare_ICR(0, vector, dest);
46
47 /*
48 * send the IPI.
49 */
50 x2apic_icr_write(cfg, apicid);
51}
52
53/*
54 * for now, we send the IPI's one by one in the cpumask.
55 * TBD: Based on the cpu mask, we can send the IPI's to the cluster group
56 * at once. We have 16 cpu's in a cluster. This will minimize IPI register
57 * writes.
58 */
59static void x2apic_send_IPI_mask(cpumask_t mask, int vector)
60{
61 unsigned long flags;
62 unsigned long query_cpu;
63
64 local_irq_save(flags);
65 for_each_cpu_mask(query_cpu, mask) {
66 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_logical_apicid, query_cpu),
67 vector, APIC_DEST_LOGICAL);
68 }
69 local_irq_restore(flags);
70}
71
72static void x2apic_send_IPI_allbutself(int vector)
73{
74 cpumask_t mask = cpu_online_map;
75
76 cpu_clear(smp_processor_id(), mask);
77
78 if (!cpus_empty(mask))
79 x2apic_send_IPI_mask(mask, vector);
80}
81
82static void x2apic_send_IPI_all(int vector)
83{
84 x2apic_send_IPI_mask(cpu_online_map, vector);
85}
86
87static int x2apic_apic_id_registered(void)
88{
89 return 1;
90}
91
92static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
93{
94 int cpu;
95
96 /*
97 * We're using fixed IRQ delivery, can only return one phys APIC ID.
98 * May as well be the first.
99 */
100 cpu = first_cpu(cpumask);
101 if ((unsigned)cpu < NR_CPUS)
102 return per_cpu(x86_cpu_to_logical_apicid, cpu);
103 else
104 return BAD_APICID;
105}
106
107static unsigned int get_apic_id(unsigned long x)
108{
109 unsigned int id;
110
111 id = x;
112 return id;
113}
114
115static unsigned long set_apic_id(unsigned int id)
116{
117 unsigned long x;
118
119 x = id;
120 return x;
121}
122
123static unsigned int phys_pkg_id(int index_msb)
124{
125 return current_cpu_data.initial_apicid >> index_msb;
126}
127
128static void x2apic_send_IPI_self(int vector)
129{
130 apic_write(APIC_SELF_IPI, vector);
131}
132
133static void init_x2apic_ldr(void)
134{
135 int cpu = smp_processor_id();
136
137 per_cpu(x86_cpu_to_logical_apicid, cpu) = apic_read(APIC_LDR);
138 return;
139}
140
141struct genapic apic_x2apic_cluster = {
142 .name = "cluster x2apic",
143 .acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
144 .int_delivery_mode = dest_LowestPrio,
145 .int_dest_mode = (APIC_DEST_LOGICAL != 0),
146 .target_cpus = x2apic_target_cpus,
147 .vector_allocation_domain = x2apic_vector_allocation_domain,
148 .apic_id_registered = x2apic_apic_id_registered,
149 .init_apic_ldr = init_x2apic_ldr,
150 .send_IPI_all = x2apic_send_IPI_all,
151 .send_IPI_allbutself = x2apic_send_IPI_allbutself,
152 .send_IPI_mask = x2apic_send_IPI_mask,
153 .send_IPI_self = x2apic_send_IPI_self,
154 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
155 .phys_pkg_id = phys_pkg_id,
156 .get_apic_id = get_apic_id,
157 .set_apic_id = set_apic_id,
158 .apic_id_mask = (0xFFFFFFFFu),
159};
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c
new file mode 100644
index 000000000000..8f1343df2627
--- /dev/null
+++ b/arch/x86/kernel/genx2apic_phys.c
@@ -0,0 +1,154 @@
1#include <linux/threads.h>
2#include <linux/cpumask.h>
3#include <linux/string.h>
4#include <linux/kernel.h>
5#include <linux/ctype.h>
6#include <linux/init.h>
7#include <linux/dmar.h>
8
9#include <asm/smp.h>
10#include <asm/ipi.h>
11#include <asm/genapic.h>
12
13static int x2apic_phys;
14
15static int set_x2apic_phys_mode(char *arg)
16{
17 x2apic_phys = 1;
18 return 0;
19}
20early_param("x2apic_phys", set_x2apic_phys_mode);
21
22static int __init x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
23{
24 if (cpu_has_x2apic && x2apic_phys)
25 return 1;
26
27 return 0;
28}
29
30/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */
31
32static cpumask_t x2apic_target_cpus(void)
33{
34 return cpumask_of_cpu(0);
35}
36
37static cpumask_t x2apic_vector_allocation_domain(int cpu)
38{
39 cpumask_t domain = CPU_MASK_NONE;
40 cpu_set(cpu, domain);
41 return domain;
42}
43
44static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
45 unsigned int dest)
46{
47 unsigned long cfg;
48
49 cfg = __prepare_ICR(0, vector, dest);
50
51 /*
52 * send the IPI.
53 */
54 x2apic_icr_write(cfg, apicid);
55}
56
57static void x2apic_send_IPI_mask(cpumask_t mask, int vector)
58{
59 unsigned long flags;
60 unsigned long query_cpu;
61
62 local_irq_save(flags);
63 for_each_cpu_mask(query_cpu, mask) {
64 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
65 vector, APIC_DEST_PHYSICAL);
66 }
67 local_irq_restore(flags);
68}
69
70static void x2apic_send_IPI_allbutself(int vector)
71{
72 cpumask_t mask = cpu_online_map;
73
74 cpu_clear(smp_processor_id(), mask);
75
76 if (!cpus_empty(mask))
77 x2apic_send_IPI_mask(mask, vector);
78}
79
80static void x2apic_send_IPI_all(int vector)
81{
82 x2apic_send_IPI_mask(cpu_online_map, vector);
83}
84
85static int x2apic_apic_id_registered(void)
86{
87 return 1;
88}
89
90static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
91{
92 int cpu;
93
94 /*
95 * We're using fixed IRQ delivery, can only return one phys APIC ID.
96 * May as well be the first.
97 */
98 cpu = first_cpu(cpumask);
99 if ((unsigned)cpu < NR_CPUS)
100 return per_cpu(x86_cpu_to_apicid, cpu);
101 else
102 return BAD_APICID;
103}
104
105static unsigned int get_apic_id(unsigned long x)
106{
107 unsigned int id;
108
109 id = x;
110 return id;
111}
112
113static unsigned long set_apic_id(unsigned int id)
114{
115 unsigned long x;
116
117 x = id;
118 return x;
119}
120
121static unsigned int phys_pkg_id(int index_msb)
122{
123 return current_cpu_data.initial_apicid >> index_msb;
124}
125
126void x2apic_send_IPI_self(int vector)
127{
128 apic_write(APIC_SELF_IPI, vector);
129}
130
131void init_x2apic_ldr(void)
132{
133 return;
134}
135
136struct genapic apic_x2apic_phys = {
137 .name = "physical x2apic",
138 .acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
139 .int_delivery_mode = dest_Fixed,
140 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
141 .target_cpus = x2apic_target_cpus,
142 .vector_allocation_domain = x2apic_vector_allocation_domain,
143 .apic_id_registered = x2apic_apic_id_registered,
144 .init_apic_ldr = init_x2apic_ldr,
145 .send_IPI_all = x2apic_send_IPI_all,
146 .send_IPI_allbutself = x2apic_send_IPI_allbutself,
147 .send_IPI_mask = x2apic_send_IPI_mask,
148 .send_IPI_self = x2apic_send_IPI_self,
149 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
150 .phys_pkg_id = phys_pkg_id,
151 .get_apic_id = get_apic_id,
152 .set_apic_id = set_apic_id,
153 .apic_id_mask = (0xFFFFFFFFu),
154};
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
index bfa837cb16be..ae2ffc8a400c 100644
--- a/arch/x86/kernel/genx2apic_uv_x.c
+++ b/arch/x86/kernel/genx2apic_uv_x.c
@@ -12,12 +12,12 @@
12#include <linux/threads.h> 12#include <linux/threads.h>
13#include <linux/cpumask.h> 13#include <linux/cpumask.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/kernel.h>
16#include <linux/ctype.h> 15#include <linux/ctype.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/sched.h> 17#include <linux/sched.h>
19#include <linux/bootmem.h> 18#include <linux/bootmem.h>
20#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/hardirq.h>
21#include <asm/smp.h> 21#include <asm/smp.h>
22#include <asm/ipi.h> 22#include <asm/ipi.h>
23#include <asm/genapic.h> 23#include <asm/genapic.h>
@@ -26,6 +26,36 @@
26#include <asm/uv/uv_hub.h> 26#include <asm/uv/uv_hub.h>
27#include <asm/uv/bios.h> 27#include <asm/uv/bios.h>
28 28
29DEFINE_PER_CPU(int, x2apic_extra_bits);
30
31static enum uv_system_type uv_system_type;
32
33static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
34{
35 if (!strcmp(oem_id, "SGI")) {
36 if (!strcmp(oem_table_id, "UVL"))
37 uv_system_type = UV_LEGACY_APIC;
38 else if (!strcmp(oem_table_id, "UVX"))
39 uv_system_type = UV_X2APIC;
40 else if (!strcmp(oem_table_id, "UVH")) {
41 uv_system_type = UV_NON_UNIQUE_APIC;
42 return 1;
43 }
44 }
45 return 0;
46}
47
48enum uv_system_type get_uv_system_type(void)
49{
50 return uv_system_type;
51}
52
53int is_uv_system(void)
54{
55 return uv_system_type != UV_NONE;
56}
57EXPORT_SYMBOL_GPL(is_uv_system);
58
29DEFINE_PER_CPU(struct uv_hub_info_s, __uv_hub_info); 59DEFINE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
30EXPORT_PER_CPU_SYMBOL_GPL(__uv_hub_info); 60EXPORT_PER_CPU_SYMBOL_GPL(__uv_hub_info);
31 61
@@ -123,6 +153,10 @@ static int uv_apic_id_registered(void)
123 return 1; 153 return 1;
124} 154}
125 155
156static void uv_init_apic_ldr(void)
157{
158}
159
126static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask) 160static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask)
127{ 161{
128 int cpu; 162 int cpu;
@@ -138,9 +172,34 @@ static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask)
138 return BAD_APICID; 172 return BAD_APICID;
139} 173}
140 174
175static unsigned int get_apic_id(unsigned long x)
176{
177 unsigned int id;
178
179 WARN_ON(preemptible() && num_online_cpus() > 1);
180 id = x | __get_cpu_var(x2apic_extra_bits);
181
182 return id;
183}
184
185static unsigned long set_apic_id(unsigned int id)
186{
187 unsigned long x;
188
189 /* maskout x2apic_extra_bits ? */
190 x = id;
191 return x;
192}
193
194static unsigned int uv_read_apic_id(void)
195{
196
197 return get_apic_id(apic_read(APIC_ID));
198}
199
141static unsigned int phys_pkg_id(int index_msb) 200static unsigned int phys_pkg_id(int index_msb)
142{ 201{
143 return GET_APIC_ID(read_apic_id()) >> index_msb; 202 return uv_read_apic_id() >> index_msb;
144} 203}
145 204
146#ifdef ZZZ /* Needs x2apic patch */ 205#ifdef ZZZ /* Needs x2apic patch */
@@ -152,17 +211,22 @@ static void uv_send_IPI_self(int vector)
152 211
153struct genapic apic_x2apic_uv_x = { 212struct genapic apic_x2apic_uv_x = {
154 .name = "UV large system", 213 .name = "UV large system",
214 .acpi_madt_oem_check = uv_acpi_madt_oem_check,
155 .int_delivery_mode = dest_Fixed, 215 .int_delivery_mode = dest_Fixed,
156 .int_dest_mode = (APIC_DEST_PHYSICAL != 0), 216 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
157 .target_cpus = uv_target_cpus, 217 .target_cpus = uv_target_cpus,
158 .vector_allocation_domain = uv_vector_allocation_domain,/* Fixme ZZZ */ 218 .vector_allocation_domain = uv_vector_allocation_domain,/* Fixme ZZZ */
159 .apic_id_registered = uv_apic_id_registered, 219 .apic_id_registered = uv_apic_id_registered,
220 .init_apic_ldr = uv_init_apic_ldr,
160 .send_IPI_all = uv_send_IPI_all, 221 .send_IPI_all = uv_send_IPI_all,
161 .send_IPI_allbutself = uv_send_IPI_allbutself, 222 .send_IPI_allbutself = uv_send_IPI_allbutself,
162 .send_IPI_mask = uv_send_IPI_mask, 223 .send_IPI_mask = uv_send_IPI_mask,
163 /* ZZZ.send_IPI_self = uv_send_IPI_self, */ 224 /* ZZZ.send_IPI_self = uv_send_IPI_self, */
164 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, 225 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
165 .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */ 226 .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */
227 .get_apic_id = get_apic_id,
228 .set_apic_id = set_apic_id,
229 .apic_id_mask = (0xFFFFFFFFu),
166}; 230};
167 231
168static __cpuinit void set_x2apic_extra_bits(int pnode) 232static __cpuinit void set_x2apic_extra_bits(int pnode)
@@ -401,3 +465,5 @@ void __cpuinit uv_cpu_init(void)
401 if (get_uv_system_type() == UV_NON_UNIQUE_APIC) 465 if (get_uv_system_type() == UV_NON_UNIQUE_APIC)
402 set_x2apic_extra_bits(uv_hub_info->pnode); 466 set_x2apic_extra_bits(uv_hub_info->pnode);
403} 467}
468
469
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 9bfc4d72fb2e..d16084f90649 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -108,12 +108,11 @@ void __init x86_64_start_kernel(char * real_mode_data)
108 } 108 }
109 load_idt((const struct desc_ptr *)&idt_descr); 109 load_idt((const struct desc_ptr *)&idt_descr);
110 110
111 early_printk("Kernel alive\n"); 111 if (console_loglevel == 10)
112 early_printk("Kernel alive\n");
112 113
113 x86_64_init_pda(); 114 x86_64_init_pda();
114 115
115 early_printk("Kernel really alive\n");
116
117 x86_64_start_reservations(real_mode_data); 116 x86_64_start_reservations(real_mode_data);
118} 117}
119 118
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index a7010c3a377a..e835b4eea70b 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -172,10 +172,6 @@ num_subarch_entries = (. - subarch_entries) / 4
172 * 172 *
173 * Note that the stack is not yet set up! 173 * Note that the stack is not yet set up!
174 */ 174 */
175#define PTE_ATTR 0x007 /* PRESENT+RW+USER */
176#define PDE_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
177#define PGD_ATTR 0x001 /* PRESENT (no other attributes) */
178
179default_entry: 175default_entry:
180#ifdef CONFIG_X86_PAE 176#ifdef CONFIG_X86_PAE
181 177
@@ -196,9 +192,9 @@ default_entry:
196 movl $pa(pg0), %edi 192 movl $pa(pg0), %edi
197 movl %edi, pa(init_pg_tables_start) 193 movl %edi, pa(init_pg_tables_start)
198 movl $pa(swapper_pg_pmd), %edx 194 movl $pa(swapper_pg_pmd), %edx
199 movl $PTE_ATTR, %eax 195 movl $PTE_IDENT_ATTR, %eax
20010: 19610:
201 leal PDE_ATTR(%edi),%ecx /* Create PMD entry */ 197 leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */
202 movl %ecx,(%edx) /* Store PMD entry */ 198 movl %ecx,(%edx) /* Store PMD entry */
203 /* Upper half already zero */ 199 /* Upper half already zero */
204 addl $8,%edx 200 addl $8,%edx
@@ -215,7 +211,7 @@ default_entry:
215 * End condition: we must map up to and including INIT_MAP_BEYOND_END 211 * End condition: we must map up to and including INIT_MAP_BEYOND_END
216 * bytes beyond the end of our own page tables. 212 * bytes beyond the end of our own page tables.
217 */ 213 */
218 leal (INIT_MAP_BEYOND_END+PTE_ATTR)(%edi),%ebp 214 leal (INIT_MAP_BEYOND_END+PTE_IDENT_ATTR)(%edi),%ebp
219 cmpl %ebp,%eax 215 cmpl %ebp,%eax
220 jb 10b 216 jb 10b
2211: 2171:
@@ -224,7 +220,7 @@ default_entry:
224 movl %eax, pa(max_pfn_mapped) 220 movl %eax, pa(max_pfn_mapped)
225 221
226 /* Do early initialization of the fixmap area */ 222 /* Do early initialization of the fixmap area */
227 movl $pa(swapper_pg_fixmap)+PDE_ATTR,%eax 223 movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax
228 movl %eax,pa(swapper_pg_pmd+0x1000*KPMDS-8) 224 movl %eax,pa(swapper_pg_pmd+0x1000*KPMDS-8)
229#else /* Not PAE */ 225#else /* Not PAE */
230 226
@@ -233,9 +229,9 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
233 movl $pa(pg0), %edi 229 movl $pa(pg0), %edi
234 movl %edi, pa(init_pg_tables_start) 230 movl %edi, pa(init_pg_tables_start)
235 movl $pa(swapper_pg_dir), %edx 231 movl $pa(swapper_pg_dir), %edx
236 movl $PTE_ATTR, %eax 232 movl $PTE_IDENT_ATTR, %eax
23710: 23310:
238 leal PDE_ATTR(%edi),%ecx /* Create PDE entry */ 234 leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */
239 movl %ecx,(%edx) /* Store identity PDE entry */ 235 movl %ecx,(%edx) /* Store identity PDE entry */
240 movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */ 236 movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */
241 addl $4,%edx 237 addl $4,%edx
@@ -249,7 +245,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
249 * bytes beyond the end of our own page tables; the +0x007 is 245 * bytes beyond the end of our own page tables; the +0x007 is
250 * the attribute bits 246 * the attribute bits
251 */ 247 */
252 leal (INIT_MAP_BEYOND_END+PTE_ATTR)(%edi),%ebp 248 leal (INIT_MAP_BEYOND_END+PTE_IDENT_ATTR)(%edi),%ebp
253 cmpl %ebp,%eax 249 cmpl %ebp,%eax
254 jb 10b 250 jb 10b
255 movl %edi,pa(init_pg_tables_end) 251 movl %edi,pa(init_pg_tables_end)
@@ -257,7 +253,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
257 movl %eax, pa(max_pfn_mapped) 253 movl %eax, pa(max_pfn_mapped)
258 254
259 /* Do early initialization of the fixmap area */ 255 /* Do early initialization of the fixmap area */
260 movl $pa(swapper_pg_fixmap)+PDE_ATTR,%eax 256 movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax
261 movl %eax,pa(swapper_pg_dir+0xffc) 257 movl %eax,pa(swapper_pg_dir+0xffc)
262#endif 258#endif
263 jmp 3f 259 jmp 3f
@@ -634,19 +630,19 @@ ENTRY(empty_zero_page)
634 /* Page-aligned for the benefit of paravirt? */ 630 /* Page-aligned for the benefit of paravirt? */
635 .align PAGE_SIZE_asm 631 .align PAGE_SIZE_asm
636ENTRY(swapper_pg_dir) 632ENTRY(swapper_pg_dir)
637 .long pa(swapper_pg_pmd+PGD_ATTR),0 /* low identity map */ 633 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
638# if KPMDS == 3 634# if KPMDS == 3
639 .long pa(swapper_pg_pmd+PGD_ATTR),0 635 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
640 .long pa(swapper_pg_pmd+PGD_ATTR+0x1000),0 636 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
641 .long pa(swapper_pg_pmd+PGD_ATTR+0x2000),0 637 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x2000),0
642# elif KPMDS == 2 638# elif KPMDS == 2
643 .long 0,0 639 .long 0,0
644 .long pa(swapper_pg_pmd+PGD_ATTR),0 640 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
645 .long pa(swapper_pg_pmd+PGD_ATTR+0x1000),0 641 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
646# elif KPMDS == 1 642# elif KPMDS == 1
647 .long 0,0 643 .long 0,0
648 .long 0,0 644 .long 0,0
649 .long pa(swapper_pg_pmd+PGD_ATTR),0 645 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
650# else 646# else
651# error "Kernel PMDs should be 1, 2 or 3" 647# error "Kernel PMDs should be 1, 2 or 3"
652# endif 648# endif
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index db3280afe886..26cfdc1d7c7f 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -110,7 +110,7 @@ startup_64:
110 movq %rdi, %rax 110 movq %rdi, %rax
111 shrq $PMD_SHIFT, %rax 111 shrq $PMD_SHIFT, %rax
112 andq $(PTRS_PER_PMD - 1), %rax 112 andq $(PTRS_PER_PMD - 1), %rax
113 leaq __PAGE_KERNEL_LARGE_EXEC(%rdi), %rdx 113 leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
114 leaq level2_spare_pgt(%rip), %rbx 114 leaq level2_spare_pgt(%rip), %rbx
115 movq %rdx, 0(%rbx, %rax, 8) 115 movq %rdx, 0(%rbx, %rax, 8)
116ident_complete: 116ident_complete:
@@ -374,7 +374,7 @@ NEXT_PAGE(level2_ident_pgt)
374 /* Since I easily can, map the first 1G. 374 /* Since I easily can, map the first 1G.
375 * Don't set NX because code runs from these pages. 375 * Don't set NX because code runs from these pages.
376 */ 376 */
377 PMDS(0, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD) 377 PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
378 378
379NEXT_PAGE(level2_kernel_pgt) 379NEXT_PAGE(level2_kernel_pgt)
380 /* 380 /*
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index eb9ddd8efb82..1f20608d4ca8 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -21,9 +21,12 @@
21# include <asm/sigcontext32.h> 21# include <asm/sigcontext32.h>
22# include <asm/user32.h> 22# include <asm/user32.h>
23#else 23#else
24# define save_i387_ia32 save_i387 24# define save_i387_xstate_ia32 save_i387_xstate
25# define restore_i387_ia32 restore_i387 25# define restore_i387_xstate_ia32 restore_i387_xstate
26# define _fpstate_ia32 _fpstate 26# define _fpstate_ia32 _fpstate
27# define _xstate_ia32 _xstate
28# define sig_xstate_ia32_size sig_xstate_size
29# define fx_sw_reserved_ia32 fx_sw_reserved
27# define user_i387_ia32_struct user_i387_struct 30# define user_i387_ia32_struct user_i387_struct
28# define user32_fxsr_struct user_fxsr_struct 31# define user32_fxsr_struct user_fxsr_struct
29#endif 32#endif
@@ -36,6 +39,7 @@
36 39
37static unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu; 40static unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu;
38unsigned int xstate_size; 41unsigned int xstate_size;
42unsigned int sig_xstate_ia32_size = sizeof(struct _fpstate_ia32);
39static struct i387_fxsave_struct fx_scratch __cpuinitdata; 43static struct i387_fxsave_struct fx_scratch __cpuinitdata;
40 44
41void __cpuinit mxcsr_feature_mask_init(void) 45void __cpuinit mxcsr_feature_mask_init(void)
@@ -61,6 +65,11 @@ void __init init_thread_xstate(void)
61 return; 65 return;
62 } 66 }
63 67
68 if (cpu_has_xsave) {
69 xsave_cntxt_init();
70 return;
71 }
72
64 if (cpu_has_fxsr) 73 if (cpu_has_fxsr)
65 xstate_size = sizeof(struct i387_fxsave_struct); 74 xstate_size = sizeof(struct i387_fxsave_struct);
66#ifdef CONFIG_X86_32 75#ifdef CONFIG_X86_32
@@ -83,9 +92,19 @@ void __cpuinit fpu_init(void)
83 92
84 write_cr0(oldcr0 & ~(X86_CR0_TS|X86_CR0_EM)); /* clear TS and EM */ 93 write_cr0(oldcr0 & ~(X86_CR0_TS|X86_CR0_EM)); /* clear TS and EM */
85 94
95 /*
96 * Boot processor to setup the FP and extended state context info.
97 */
98 if (!smp_processor_id())
99 init_thread_xstate();
100 xsave_init();
101
86 mxcsr_feature_mask_init(); 102 mxcsr_feature_mask_init();
87 /* clean state in init */ 103 /* clean state in init */
88 current_thread_info()->status = 0; 104 if (cpu_has_xsave)
105 current_thread_info()->status = TS_XSAVE;
106 else
107 current_thread_info()->status = 0;
89 clear_used_math(); 108 clear_used_math();
90} 109}
91#endif /* CONFIG_X86_64 */ 110#endif /* CONFIG_X86_64 */
@@ -195,6 +214,13 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
195 */ 214 */
196 target->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask; 215 target->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask;
197 216
217 /*
218 * update the header bits in the xsave header, indicating the
219 * presence of FP and SSE state.
220 */
221 if (cpu_has_xsave)
222 target->thread.xstate->xsave.xsave_hdr.xstate_bv |= XSTATE_FPSSE;
223
198 return ret; 224 return ret;
199} 225}
200 226
@@ -395,6 +421,12 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
395 if (!ret) 421 if (!ret)
396 convert_to_fxsr(target, &env); 422 convert_to_fxsr(target, &env);
397 423
424 /*
425 * update the header bit in the xsave header, indicating the
426 * presence of FP.
427 */
428 if (cpu_has_xsave)
429 target->thread.xstate->xsave.xsave_hdr.xstate_bv |= XSTATE_FP;
398 return ret; 430 return ret;
399} 431}
400 432
@@ -407,7 +439,6 @@ static inline int save_i387_fsave(struct _fpstate_ia32 __user *buf)
407 struct task_struct *tsk = current; 439 struct task_struct *tsk = current;
408 struct i387_fsave_struct *fp = &tsk->thread.xstate->fsave; 440 struct i387_fsave_struct *fp = &tsk->thread.xstate->fsave;
409 441
410 unlazy_fpu(tsk);
411 fp->status = fp->swd; 442 fp->status = fp->swd;
412 if (__copy_to_user(buf, fp, sizeof(struct i387_fsave_struct))) 443 if (__copy_to_user(buf, fp, sizeof(struct i387_fsave_struct)))
413 return -1; 444 return -1;
@@ -421,8 +452,6 @@ static int save_i387_fxsave(struct _fpstate_ia32 __user *buf)
421 struct user_i387_ia32_struct env; 452 struct user_i387_ia32_struct env;
422 int err = 0; 453 int err = 0;
423 454
424 unlazy_fpu(tsk);
425
426 convert_from_fxsr(&env, tsk); 455 convert_from_fxsr(&env, tsk);
427 if (__copy_to_user(buf, &env, sizeof(env))) 456 if (__copy_to_user(buf, &env, sizeof(env)))
428 return -1; 457 return -1;
@@ -432,16 +461,54 @@ static int save_i387_fxsave(struct _fpstate_ia32 __user *buf)
432 if (err) 461 if (err)
433 return -1; 462 return -1;
434 463
435 if (__copy_to_user(&buf->_fxsr_env[0], fx, 464 if (__copy_to_user(&buf->_fxsr_env[0], fx, xstate_size))
436 sizeof(struct i387_fxsave_struct))) 465 return -1;
466 return 1;
467}
468
469static int save_i387_xsave(void __user *buf)
470{
471 struct task_struct *tsk = current;
472 struct _fpstate_ia32 __user *fx = buf;
473 int err = 0;
474
475 /*
476 * For legacy compatible, we always set FP/SSE bits in the bit
477 * vector while saving the state to the user context.
478 * This will enable us capturing any changes(during sigreturn) to
479 * the FP/SSE bits by the legacy applications which don't touch
480 * xstate_bv in the xsave header.
481 *
482 * xsave aware applications can change the xstate_bv in the xsave
483 * header as well as change any contents in the memory layout.
484 * xrestore as part of sigreturn will capture all the changes.
485 */
486 tsk->thread.xstate->xsave.xsave_hdr.xstate_bv |= XSTATE_FPSSE;
487
488 if (save_i387_fxsave(fx) < 0)
489 return -1;
490
491 err = __copy_to_user(&fx->sw_reserved, &fx_sw_reserved_ia32,
492 sizeof(struct _fpx_sw_bytes));
493 err |= __put_user(FP_XSTATE_MAGIC2,
494 (__u32 __user *) (buf + sig_xstate_ia32_size
495 - FP_XSTATE_MAGIC2_SIZE));
496 if (err)
437 return -1; 497 return -1;
498
438 return 1; 499 return 1;
439} 500}
440 501
441int save_i387_ia32(struct _fpstate_ia32 __user *buf) 502int save_i387_xstate_ia32(void __user *buf)
442{ 503{
504 struct _fpstate_ia32 __user *fp = (struct _fpstate_ia32 __user *) buf;
505 struct task_struct *tsk = current;
506
443 if (!used_math()) 507 if (!used_math())
444 return 0; 508 return 0;
509
510 if (!access_ok(VERIFY_WRITE, buf, sig_xstate_ia32_size))
511 return -EACCES;
445 /* 512 /*
446 * This will cause a "finit" to be triggered by the next 513 * This will cause a "finit" to be triggered by the next
447 * attempted FPU operation by the 'current' process. 514 * attempted FPU operation by the 'current' process.
@@ -451,13 +518,17 @@ int save_i387_ia32(struct _fpstate_ia32 __user *buf)
451 if (!HAVE_HWFP) { 518 if (!HAVE_HWFP) {
452 return fpregs_soft_get(current, NULL, 519 return fpregs_soft_get(current, NULL,
453 0, sizeof(struct user_i387_ia32_struct), 520 0, sizeof(struct user_i387_ia32_struct),
454 NULL, buf) ? -1 : 1; 521 NULL, fp) ? -1 : 1;
455 } 522 }
456 523
524 unlazy_fpu(tsk);
525
526 if (cpu_has_xsave)
527 return save_i387_xsave(fp);
457 if (cpu_has_fxsr) 528 if (cpu_has_fxsr)
458 return save_i387_fxsave(buf); 529 return save_i387_fxsave(fp);
459 else 530 else
460 return save_i387_fsave(buf); 531 return save_i387_fsave(fp);
461} 532}
462 533
463static inline int restore_i387_fsave(struct _fpstate_ia32 __user *buf) 534static inline int restore_i387_fsave(struct _fpstate_ia32 __user *buf)
@@ -468,14 +539,15 @@ static inline int restore_i387_fsave(struct _fpstate_ia32 __user *buf)
468 sizeof(struct i387_fsave_struct)); 539 sizeof(struct i387_fsave_struct));
469} 540}
470 541
471static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf) 542static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf,
543 unsigned int size)
472{ 544{
473 struct task_struct *tsk = current; 545 struct task_struct *tsk = current;
474 struct user_i387_ia32_struct env; 546 struct user_i387_ia32_struct env;
475 int err; 547 int err;
476 548
477 err = __copy_from_user(&tsk->thread.xstate->fxsave, &buf->_fxsr_env[0], 549 err = __copy_from_user(&tsk->thread.xstate->fxsave, &buf->_fxsr_env[0],
478 sizeof(struct i387_fxsave_struct)); 550 size);
479 /* mxcsr reserved bits must be masked to zero for security reasons */ 551 /* mxcsr reserved bits must be masked to zero for security reasons */
480 tsk->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask; 552 tsk->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask;
481 if (err || __copy_from_user(&env, buf, sizeof(env))) 553 if (err || __copy_from_user(&env, buf, sizeof(env)))
@@ -485,14 +557,69 @@ static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf)
485 return 0; 557 return 0;
486} 558}
487 559
488int restore_i387_ia32(struct _fpstate_ia32 __user *buf) 560static int restore_i387_xsave(void __user *buf)
561{
562 struct _fpx_sw_bytes fx_sw_user;
563 struct _fpstate_ia32 __user *fx_user =
564 ((struct _fpstate_ia32 __user *) buf);
565 struct i387_fxsave_struct __user *fx =
566 (struct i387_fxsave_struct __user *) &fx_user->_fxsr_env[0];
567 struct xsave_hdr_struct *xsave_hdr =
568 &current->thread.xstate->xsave.xsave_hdr;
569 u64 mask;
570 int err;
571
572 if (check_for_xstate(fx, buf, &fx_sw_user))
573 goto fx_only;
574
575 mask = fx_sw_user.xstate_bv;
576
577 err = restore_i387_fxsave(buf, fx_sw_user.xstate_size);
578
579 xsave_hdr->xstate_bv &= pcntxt_mask;
580 /*
581 * These bits must be zero.
582 */
583 xsave_hdr->reserved1[0] = xsave_hdr->reserved1[1] = 0;
584
585 /*
586 * Init the state that is not present in the memory layout
587 * and enabled by the OS.
588 */
589 mask = ~(pcntxt_mask & ~mask);
590 xsave_hdr->xstate_bv &= mask;
591
592 return err;
593fx_only:
594 /*
595 * Couldn't find the extended state information in the memory
596 * layout. Restore the FP/SSE and init the other extended state
597 * enabled by the OS.
598 */
599 xsave_hdr->xstate_bv = XSTATE_FPSSE;
600 return restore_i387_fxsave(buf, sizeof(struct i387_fxsave_struct));
601}
602
603int restore_i387_xstate_ia32(void __user *buf)
489{ 604{
490 int err; 605 int err;
491 struct task_struct *tsk = current; 606 struct task_struct *tsk = current;
607 struct _fpstate_ia32 __user *fp = (struct _fpstate_ia32 __user *) buf;
492 608
493 if (HAVE_HWFP) 609 if (HAVE_HWFP)
494 clear_fpu(tsk); 610 clear_fpu(tsk);
495 611
612 if (!buf) {
613 if (used_math()) {
614 clear_fpu(tsk);
615 clear_used_math();
616 }
617
618 return 0;
619 } else
620 if (!access_ok(VERIFY_READ, buf, sig_xstate_ia32_size))
621 return -EACCES;
622
496 if (!used_math()) { 623 if (!used_math()) {
497 err = init_fpu(tsk); 624 err = init_fpu(tsk);
498 if (err) 625 if (err)
@@ -500,14 +627,17 @@ int restore_i387_ia32(struct _fpstate_ia32 __user *buf)
500 } 627 }
501 628
502 if (HAVE_HWFP) { 629 if (HAVE_HWFP) {
503 if (cpu_has_fxsr) 630 if (cpu_has_xsave)
504 err = restore_i387_fxsave(buf); 631 err = restore_i387_xsave(buf);
632 else if (cpu_has_fxsr)
633 err = restore_i387_fxsave(fp, sizeof(struct
634 i387_fxsave_struct));
505 else 635 else
506 err = restore_i387_fsave(buf); 636 err = restore_i387_fsave(fp);
507 } else { 637 } else {
508 err = fpregs_soft_set(current, NULL, 638 err = fpregs_soft_set(current, NULL,
509 0, sizeof(struct user_i387_ia32_struct), 639 0, sizeof(struct user_i387_ia32_struct),
510 NULL, buf) != 0; 640 NULL, fp) != 0;
511 } 641 }
512 set_used_math(); 642 set_used_math();
513 643
diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
index dc92b49d9204..4b8a53d841f7 100644
--- a/arch/x86/kernel/i8259.c
+++ b/arch/x86/kernel/i8259.c
@@ -282,6 +282,30 @@ static int __init i8259A_init_sysfs(void)
282 282
283device_initcall(i8259A_init_sysfs); 283device_initcall(i8259A_init_sysfs);
284 284
285void mask_8259A(void)
286{
287 unsigned long flags;
288
289 spin_lock_irqsave(&i8259A_lock, flags);
290
291 outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
292 outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */
293
294 spin_unlock_irqrestore(&i8259A_lock, flags);
295}
296
297void unmask_8259A(void)
298{
299 unsigned long flags;
300
301 spin_lock_irqsave(&i8259A_lock, flags);
302
303 outb(cached_master_mask, PIC_MASTER_IMR); /* restore master IRQ mask */
304 outb(cached_slave_mask, PIC_SLAVE_IMR); /* restore slave IRQ mask */
305
306 spin_unlock_irqrestore(&i8259A_lock, flags);
307}
308
285void init_8259A(int auto_eoi) 309void init_8259A(int auto_eoi)
286{ 310{
287 unsigned long flags; 311 unsigned long flags;
diff --git a/arch/x86/kernel/io_apic_32.c b/arch/x86/kernel/io_apic_32.c
index 09cddb57bec4..e710289f673e 100644
--- a/arch/x86/kernel/io_apic_32.c
+++ b/arch/x86/kernel/io_apic_32.c
@@ -46,10 +46,13 @@
46#include <asm/nmi.h> 46#include <asm/nmi.h>
47#include <asm/msidef.h> 47#include <asm/msidef.h>
48#include <asm/hypertransport.h> 48#include <asm/hypertransport.h>
49#include <asm/setup.h>
49 50
50#include <mach_apic.h> 51#include <mach_apic.h>
51#include <mach_apicdef.h> 52#include <mach_apicdef.h>
52 53
54#define __apicdebuginit(type) static type __init
55
53int (*ioapic_renumber_irq)(int ioapic, int irq); 56int (*ioapic_renumber_irq)(int ioapic, int irq);
54atomic_t irq_mis_count; 57atomic_t irq_mis_count;
55 58
@@ -1341,7 +1344,8 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin,
1341 ioapic_write_entry(apic, pin, entry); 1344 ioapic_write_entry(apic, pin, entry);
1342} 1345}
1343 1346
1344void __init print_IO_APIC(void) 1347
1348__apicdebuginit(void) print_IO_APIC(void)
1345{ 1349{
1346 int apic, i; 1350 int apic, i;
1347 union IO_APIC_reg_00 reg_00; 1351 union IO_APIC_reg_00 reg_00;
@@ -1456,9 +1460,7 @@ void __init print_IO_APIC(void)
1456 return; 1460 return;
1457} 1461}
1458 1462
1459#if 0 1463__apicdebuginit(void) print_APIC_bitfield(int base)
1460
1461static void print_APIC_bitfield(int base)
1462{ 1464{
1463 unsigned int v; 1465 unsigned int v;
1464 int i, j; 1466 int i, j;
@@ -1479,9 +1481,10 @@ static void print_APIC_bitfield(int base)
1479 } 1481 }
1480} 1482}
1481 1483
1482void /*__init*/ print_local_APIC(void *dummy) 1484__apicdebuginit(void) print_local_APIC(void *dummy)
1483{ 1485{
1484 unsigned int v, ver, maxlvt; 1486 unsigned int v, ver, maxlvt;
1487 u64 icr;
1485 1488
1486 if (apic_verbosity == APIC_QUIET) 1489 if (apic_verbosity == APIC_QUIET)
1487 return; 1490 return;
@@ -1490,7 +1493,7 @@ void /*__init*/ print_local_APIC(void *dummy)
1490 smp_processor_id(), hard_smp_processor_id()); 1493 smp_processor_id(), hard_smp_processor_id());
1491 v = apic_read(APIC_ID); 1494 v = apic_read(APIC_ID);
1492 printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, 1495 printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v,
1493 GET_APIC_ID(read_apic_id())); 1496 GET_APIC_ID(v));
1494 v = apic_read(APIC_LVR); 1497 v = apic_read(APIC_LVR);
1495 printk(KERN_INFO "... APIC VERSION: %08x\n", v); 1498 printk(KERN_INFO "... APIC VERSION: %08x\n", v);
1496 ver = GET_APIC_VERSION(v); 1499 ver = GET_APIC_VERSION(v);
@@ -1532,10 +1535,9 @@ void /*__init*/ print_local_APIC(void *dummy)
1532 printk(KERN_DEBUG "... APIC ESR: %08x\n", v); 1535 printk(KERN_DEBUG "... APIC ESR: %08x\n", v);
1533 } 1536 }
1534 1537
1535 v = apic_read(APIC_ICR); 1538 icr = apic_icr_read();
1536 printk(KERN_DEBUG "... APIC ICR: %08x\n", v); 1539 printk(KERN_DEBUG "... APIC ICR: %08x\n", icr);
1537 v = apic_read(APIC_ICR2); 1540 printk(KERN_DEBUG "... APIC ICR2: %08x\n", icr >> 32);
1538 printk(KERN_DEBUG "... APIC ICR2: %08x\n", v);
1539 1541
1540 v = apic_read(APIC_LVTT); 1542 v = apic_read(APIC_LVTT);
1541 printk(KERN_DEBUG "... APIC LVTT: %08x\n", v); 1543 printk(KERN_DEBUG "... APIC LVTT: %08x\n", v);
@@ -1563,12 +1565,12 @@ void /*__init*/ print_local_APIC(void *dummy)
1563 printk("\n"); 1565 printk("\n");
1564} 1566}
1565 1567
1566void print_all_local_APICs(void) 1568__apicdebuginit(void) print_all_local_APICs(void)
1567{ 1569{
1568 on_each_cpu(print_local_APIC, NULL, 1); 1570 on_each_cpu(print_local_APIC, NULL, 1);
1569} 1571}
1570 1572
1571void /*__init*/ print_PIC(void) 1573__apicdebuginit(void) print_PIC(void)
1572{ 1574{
1573 unsigned int v; 1575 unsigned int v;
1574 unsigned long flags; 1576 unsigned long flags;
@@ -1600,7 +1602,17 @@ void /*__init*/ print_PIC(void)
1600 printk(KERN_DEBUG "... PIC ELCR: %04x\n", v); 1602 printk(KERN_DEBUG "... PIC ELCR: %04x\n", v);
1601} 1603}
1602 1604
1603#endif /* 0 */ 1605__apicdebuginit(int) print_all_ICs(void)
1606{
1607 print_PIC();
1608 print_all_local_APICs();
1609 print_IO_APIC();
1610
1611 return 0;
1612}
1613
1614fs_initcall(print_all_ICs);
1615
1604 1616
1605static void __init enable_IO_APIC(void) 1617static void __init enable_IO_APIC(void)
1606{ 1618{
@@ -1698,8 +1710,7 @@ void disable_IO_APIC(void)
1698 entry.dest_mode = 0; /* Physical */ 1710 entry.dest_mode = 0; /* Physical */
1699 entry.delivery_mode = dest_ExtINT; /* ExtInt */ 1711 entry.delivery_mode = dest_ExtINT; /* ExtInt */
1700 entry.vector = 0; 1712 entry.vector = 0;
1701 entry.dest.physical.physical_dest = 1713 entry.dest.physical.physical_dest = read_apic_id();
1702 GET_APIC_ID(read_apic_id());
1703 1714
1704 /* 1715 /*
1705 * Add it to the IO-APIC irq-routing table: 1716 * Add it to the IO-APIC irq-routing table:
@@ -1725,10 +1736,8 @@ static void __init setup_ioapic_ids_from_mpc(void)
1725 unsigned char old_id; 1736 unsigned char old_id;
1726 unsigned long flags; 1737 unsigned long flags;
1727 1738
1728#ifdef CONFIG_X86_NUMAQ 1739 if (x86_quirks->setup_ioapic_ids && x86_quirks->setup_ioapic_ids())
1729 if (found_numaq)
1730 return; 1740 return;
1731#endif
1732 1741
1733 /* 1742 /*
1734 * Don't check I/O APIC IDs for xAPIC systems. They have 1743 * Don't check I/O APIC IDs for xAPIC systems. They have
@@ -2329,8 +2338,6 @@ void __init setup_IO_APIC(void)
2329 setup_IO_APIC_irqs(); 2338 setup_IO_APIC_irqs();
2330 init_IO_APIC_traps(); 2339 init_IO_APIC_traps();
2331 check_timer(); 2340 check_timer();
2332 if (!acpi_ioapic)
2333 print_IO_APIC();
2334} 2341}
2335 2342
2336/* 2343/*
diff --git a/arch/x86/kernel/io_apic_64.c b/arch/x86/kernel/io_apic_64.c
index 61a83b70c18f..02063ae042f7 100644
--- a/arch/x86/kernel/io_apic_64.c
+++ b/arch/x86/kernel/io_apic_64.c
@@ -37,6 +37,7 @@
37#include <acpi/acpi_bus.h> 37#include <acpi/acpi_bus.h>
38#endif 38#endif
39#include <linux/bootmem.h> 39#include <linux/bootmem.h>
40#include <linux/dmar.h>
40 41
41#include <asm/idle.h> 42#include <asm/idle.h>
42#include <asm/io.h> 43#include <asm/io.h>
@@ -49,10 +50,13 @@
49#include <asm/nmi.h> 50#include <asm/nmi.h>
50#include <asm/msidef.h> 51#include <asm/msidef.h>
51#include <asm/hypertransport.h> 52#include <asm/hypertransport.h>
53#include <asm/irq_remapping.h>
52 54
53#include <mach_ipi.h> 55#include <mach_ipi.h>
54#include <mach_apic.h> 56#include <mach_apic.h>
55 57
58#define __apicdebuginit(type) static type __init
59
56struct irq_cfg { 60struct irq_cfg {
57 cpumask_t domain; 61 cpumask_t domain;
58 cpumask_t old_domain; 62 cpumask_t old_domain;
@@ -87,8 +91,6 @@ int first_system_vector = 0xfe;
87 91
88char system_vectors[NR_VECTORS] = { [0 ... NR_VECTORS-1] = SYS_VECTOR_FREE}; 92char system_vectors[NR_VECTORS] = { [0 ... NR_VECTORS-1] = SYS_VECTOR_FREE};
89 93
90#define __apicdebuginit __init
91
92int sis_apic_bug; /* not actually supported, dummy for compile */ 94int sis_apic_bug; /* not actually supported, dummy for compile */
93 95
94static int no_timer_check; 96static int no_timer_check;
@@ -108,6 +110,9 @@ static DEFINE_SPINLOCK(vector_lock);
108 */ 110 */
109int nr_ioapic_registers[MAX_IO_APICS]; 111int nr_ioapic_registers[MAX_IO_APICS];
110 112
113/* I/O APIC RTE contents at the OS boot up */
114struct IO_APIC_route_entry *early_ioapic_entries[MAX_IO_APICS];
115
111/* I/O APIC entries */ 116/* I/O APIC entries */
112struct mp_config_ioapic mp_ioapics[MAX_IO_APICS]; 117struct mp_config_ioapic mp_ioapics[MAX_IO_APICS];
113int nr_ioapics; 118int nr_ioapics;
@@ -303,7 +308,12 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, u8 vector)
303 pin = entry->pin; 308 pin = entry->pin;
304 if (pin == -1) 309 if (pin == -1)
305 break; 310 break;
306 io_apic_write(apic, 0x11 + pin*2, dest); 311 /*
312 * With interrupt-remapping, destination information comes
313 * from interrupt-remapping table entry.
314 */
315 if (!irq_remapped(irq))
316 io_apic_write(apic, 0x11 + pin*2, dest);
307 reg = io_apic_read(apic, 0x10 + pin*2); 317 reg = io_apic_read(apic, 0x10 + pin*2);
308 reg &= ~IO_APIC_REDIR_VECTOR_MASK; 318 reg &= ~IO_APIC_REDIR_VECTOR_MASK;
309 reg |= vector; 319 reg |= vector;
@@ -440,6 +450,69 @@ static void clear_IO_APIC (void)
440 clear_IO_APIC_pin(apic, pin); 450 clear_IO_APIC_pin(apic, pin);
441} 451}
442 452
453/*
454 * Saves and masks all the unmasked IO-APIC RTE's
455 */
456int save_mask_IO_APIC_setup(void)
457{
458 union IO_APIC_reg_01 reg_01;
459 unsigned long flags;
460 int apic, pin;
461
462 /*
463 * The number of IO-APIC IRQ registers (== #pins):
464 */
465 for (apic = 0; apic < nr_ioapics; apic++) {
466 spin_lock_irqsave(&ioapic_lock, flags);
467 reg_01.raw = io_apic_read(apic, 1);
468 spin_unlock_irqrestore(&ioapic_lock, flags);
469 nr_ioapic_registers[apic] = reg_01.bits.entries+1;
470 }
471
472 for (apic = 0; apic < nr_ioapics; apic++) {
473 early_ioapic_entries[apic] =
474 kzalloc(sizeof(struct IO_APIC_route_entry) *
475 nr_ioapic_registers[apic], GFP_KERNEL);
476 if (!early_ioapic_entries[apic])
477 return -ENOMEM;
478 }
479
480 for (apic = 0; apic < nr_ioapics; apic++)
481 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
482 struct IO_APIC_route_entry entry;
483
484 entry = early_ioapic_entries[apic][pin] =
485 ioapic_read_entry(apic, pin);
486 if (!entry.mask) {
487 entry.mask = 1;
488 ioapic_write_entry(apic, pin, entry);
489 }
490 }
491 return 0;
492}
493
494void restore_IO_APIC_setup(void)
495{
496 int apic, pin;
497
498 for (apic = 0; apic < nr_ioapics; apic++)
499 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++)
500 ioapic_write_entry(apic, pin,
501 early_ioapic_entries[apic][pin]);
502}
503
504void reinit_intr_remapped_IO_APIC(int intr_remapping)
505{
506 /*
507 * for now plain restore of previous settings.
508 * TBD: In the case of OS enabling interrupt-remapping,
509 * IO-APIC RTE's need to be setup to point to interrupt-remapping
510 * table entries. for now, do a plain restore, and wait for
511 * the setup_IO_APIC_irqs() to do proper initialization.
512 */
513 restore_IO_APIC_setup();
514}
515
443int skip_ioapic_setup; 516int skip_ioapic_setup;
444int ioapic_force; 517int ioapic_force;
445 518
@@ -839,18 +912,98 @@ void __setup_vector_irq(int cpu)
839} 912}
840 913
841static struct irq_chip ioapic_chip; 914static struct irq_chip ioapic_chip;
915#ifdef CONFIG_INTR_REMAP
916static struct irq_chip ir_ioapic_chip;
917#endif
842 918
843static void ioapic_register_intr(int irq, unsigned long trigger) 919static void ioapic_register_intr(int irq, unsigned long trigger)
844{ 920{
845 if (trigger) { 921 if (trigger)
846 irq_desc[irq].status |= IRQ_LEVEL; 922 irq_desc[irq].status |= IRQ_LEVEL;
847 set_irq_chip_and_handler_name(irq, &ioapic_chip, 923 else
848 handle_fasteoi_irq, "fasteoi");
849 } else {
850 irq_desc[irq].status &= ~IRQ_LEVEL; 924 irq_desc[irq].status &= ~IRQ_LEVEL;
925
926#ifdef CONFIG_INTR_REMAP
927 if (irq_remapped(irq)) {
928 irq_desc[irq].status |= IRQ_MOVE_PCNTXT;
929 if (trigger)
930 set_irq_chip_and_handler_name(irq, &ir_ioapic_chip,
931 handle_fasteoi_irq,
932 "fasteoi");
933 else
934 set_irq_chip_and_handler_name(irq, &ir_ioapic_chip,
935 handle_edge_irq, "edge");
936 return;
937 }
938#endif
939 if (trigger)
940 set_irq_chip_and_handler_name(irq, &ioapic_chip,
941 handle_fasteoi_irq,
942 "fasteoi");
943 else
851 set_irq_chip_and_handler_name(irq, &ioapic_chip, 944 set_irq_chip_and_handler_name(irq, &ioapic_chip,
852 handle_edge_irq, "edge"); 945 handle_edge_irq, "edge");
946}
947
948static int setup_ioapic_entry(int apic, int irq,
949 struct IO_APIC_route_entry *entry,
950 unsigned int destination, int trigger,
951 int polarity, int vector)
952{
953 /*
954 * add it to the IO-APIC irq-routing table:
955 */
956 memset(entry,0,sizeof(*entry));
957
958#ifdef CONFIG_INTR_REMAP
959 if (intr_remapping_enabled) {
960 struct intel_iommu *iommu = map_ioapic_to_ir(apic);
961 struct irte irte;
962 struct IR_IO_APIC_route_entry *ir_entry =
963 (struct IR_IO_APIC_route_entry *) entry;
964 int index;
965
966 if (!iommu)
967 panic("No mapping iommu for ioapic %d\n", apic);
968
969 index = alloc_irte(iommu, irq, 1);
970 if (index < 0)
971 panic("Failed to allocate IRTE for ioapic %d\n", apic);
972
973 memset(&irte, 0, sizeof(irte));
974
975 irte.present = 1;
976 irte.dst_mode = INT_DEST_MODE;
977 irte.trigger_mode = trigger;
978 irte.dlvry_mode = INT_DELIVERY_MODE;
979 irte.vector = vector;
980 irte.dest_id = IRTE_DEST(destination);
981
982 modify_irte(irq, &irte);
983
984 ir_entry->index2 = (index >> 15) & 0x1;
985 ir_entry->zero = 0;
986 ir_entry->format = 1;
987 ir_entry->index = (index & 0x7fff);
988 } else
989#endif
990 {
991 entry->delivery_mode = INT_DELIVERY_MODE;
992 entry->dest_mode = INT_DEST_MODE;
993 entry->dest = destination;
853 } 994 }
995
996 entry->mask = 0; /* enable IRQ */
997 entry->trigger = trigger;
998 entry->polarity = polarity;
999 entry->vector = vector;
1000
1001 /* Mask level triggered irqs.
1002 * Use IRQ_DELAYED_DISABLE for edge triggered irqs.
1003 */
1004 if (trigger)
1005 entry->mask = 1;
1006 return 0;
854} 1007}
855 1008
856static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, 1009static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq,
@@ -875,24 +1028,15 @@ static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq,
875 apic, mp_ioapics[apic].mp_apicid, pin, cfg->vector, 1028 apic, mp_ioapics[apic].mp_apicid, pin, cfg->vector,
876 irq, trigger, polarity); 1029 irq, trigger, polarity);
877 1030
878 /*
879 * add it to the IO-APIC irq-routing table:
880 */
881 memset(&entry,0,sizeof(entry));
882
883 entry.delivery_mode = INT_DELIVERY_MODE;
884 entry.dest_mode = INT_DEST_MODE;
885 entry.dest = cpu_mask_to_apicid(mask);
886 entry.mask = 0; /* enable IRQ */
887 entry.trigger = trigger;
888 entry.polarity = polarity;
889 entry.vector = cfg->vector;
890 1031
891 /* Mask level triggered irqs. 1032 if (setup_ioapic_entry(mp_ioapics[apic].mp_apicid, irq, &entry,
892 * Use IRQ_DELAYED_DISABLE for edge triggered irqs. 1033 cpu_mask_to_apicid(mask), trigger, polarity,
893 */ 1034 cfg->vector)) {
894 if (trigger) 1035 printk("Failed to setup ioapic entry for ioapic %d, pin %d\n",
895 entry.mask = 1; 1036 mp_ioapics[apic].mp_apicid, pin);
1037 __clear_irq_vector(irq);
1038 return;
1039 }
896 1040
897 ioapic_register_intr(irq, trigger); 1041 ioapic_register_intr(irq, trigger);
898 if (irq < 16) 1042 if (irq < 16)
@@ -944,6 +1088,9 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin,
944{ 1088{
945 struct IO_APIC_route_entry entry; 1089 struct IO_APIC_route_entry entry;
946 1090
1091 if (intr_remapping_enabled)
1092 return;
1093
947 memset(&entry, 0, sizeof(entry)); 1094 memset(&entry, 0, sizeof(entry));
948 1095
949 /* 1096 /*
@@ -970,7 +1117,8 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin,
970 ioapic_write_entry(apic, pin, entry); 1117 ioapic_write_entry(apic, pin, entry);
971} 1118}
972 1119
973void __apicdebuginit print_IO_APIC(void) 1120
1121__apicdebuginit(void) print_IO_APIC(void)
974{ 1122{
975 int apic, i; 1123 int apic, i;
976 union IO_APIC_reg_00 reg_00; 1124 union IO_APIC_reg_00 reg_00;
@@ -1064,9 +1212,7 @@ void __apicdebuginit print_IO_APIC(void)
1064 return; 1212 return;
1065} 1213}
1066 1214
1067#if 0 1215__apicdebuginit(void) print_APIC_bitfield(int base)
1068
1069static __apicdebuginit void print_APIC_bitfield (int base)
1070{ 1216{
1071 unsigned int v; 1217 unsigned int v;
1072 int i, j; 1218 int i, j;
@@ -1087,9 +1233,10 @@ static __apicdebuginit void print_APIC_bitfield (int base)
1087 } 1233 }
1088} 1234}
1089 1235
1090void __apicdebuginit print_local_APIC(void * dummy) 1236__apicdebuginit(void) print_local_APIC(void *dummy)
1091{ 1237{
1092 unsigned int v, ver, maxlvt; 1238 unsigned int v, ver, maxlvt;
1239 unsigned long icr;
1093 1240
1094 if (apic_verbosity == APIC_QUIET) 1241 if (apic_verbosity == APIC_QUIET)
1095 return; 1242 return;
@@ -1097,7 +1244,7 @@ void __apicdebuginit print_local_APIC(void * dummy)
1097 printk("\n" KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n", 1244 printk("\n" KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n",
1098 smp_processor_id(), hard_smp_processor_id()); 1245 smp_processor_id(), hard_smp_processor_id());
1099 v = apic_read(APIC_ID); 1246 v = apic_read(APIC_ID);
1100 printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, GET_APIC_ID(read_apic_id())); 1247 printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, read_apic_id());
1101 v = apic_read(APIC_LVR); 1248 v = apic_read(APIC_LVR);
1102 printk(KERN_INFO "... APIC VERSION: %08x\n", v); 1249 printk(KERN_INFO "... APIC VERSION: %08x\n", v);
1103 ver = GET_APIC_VERSION(v); 1250 ver = GET_APIC_VERSION(v);
@@ -1133,10 +1280,9 @@ void __apicdebuginit print_local_APIC(void * dummy)
1133 v = apic_read(APIC_ESR); 1280 v = apic_read(APIC_ESR);
1134 printk(KERN_DEBUG "... APIC ESR: %08x\n", v); 1281 printk(KERN_DEBUG "... APIC ESR: %08x\n", v);
1135 1282
1136 v = apic_read(APIC_ICR); 1283 icr = apic_icr_read();
1137 printk(KERN_DEBUG "... APIC ICR: %08x\n", v); 1284 printk(KERN_DEBUG "... APIC ICR: %08x\n", (u32)icr);
1138 v = apic_read(APIC_ICR2); 1285 printk(KERN_DEBUG "... APIC ICR2: %08x\n", (u32)(icr >> 32));
1139 printk(KERN_DEBUG "... APIC ICR2: %08x\n", v);
1140 1286
1141 v = apic_read(APIC_LVTT); 1287 v = apic_read(APIC_LVTT);
1142 printk(KERN_DEBUG "... APIC LVTT: %08x\n", v); 1288 printk(KERN_DEBUG "... APIC LVTT: %08x\n", v);
@@ -1164,12 +1310,12 @@ void __apicdebuginit print_local_APIC(void * dummy)
1164 printk("\n"); 1310 printk("\n");
1165} 1311}
1166 1312
1167void print_all_local_APICs (void) 1313__apicdebuginit(void) print_all_local_APICs(void)
1168{ 1314{
1169 on_each_cpu(print_local_APIC, NULL, 1); 1315 on_each_cpu(print_local_APIC, NULL, 1);
1170} 1316}
1171 1317
1172void __apicdebuginit print_PIC(void) 1318__apicdebuginit(void) print_PIC(void)
1173{ 1319{
1174 unsigned int v; 1320 unsigned int v;
1175 unsigned long flags; 1321 unsigned long flags;
@@ -1201,7 +1347,17 @@ void __apicdebuginit print_PIC(void)
1201 printk(KERN_DEBUG "... PIC ELCR: %04x\n", v); 1347 printk(KERN_DEBUG "... PIC ELCR: %04x\n", v);
1202} 1348}
1203 1349
1204#endif /* 0 */ 1350__apicdebuginit(int) print_all_ICs(void)
1351{
1352 print_PIC();
1353 print_all_local_APICs();
1354 print_IO_APIC();
1355
1356 return 0;
1357}
1358
1359fs_initcall(print_all_ICs);
1360
1205 1361
1206void __init enable_IO_APIC(void) 1362void __init enable_IO_APIC(void)
1207{ 1363{
@@ -1291,7 +1447,7 @@ void disable_IO_APIC(void)
1291 entry.dest_mode = 0; /* Physical */ 1447 entry.dest_mode = 0; /* Physical */
1292 entry.delivery_mode = dest_ExtINT; /* ExtInt */ 1448 entry.delivery_mode = dest_ExtINT; /* ExtInt */
1293 entry.vector = 0; 1449 entry.vector = 0;
1294 entry.dest = GET_APIC_ID(read_apic_id()); 1450 entry.dest = read_apic_id();
1295 1451
1296 /* 1452 /*
1297 * Add it to the IO-APIC irq-routing table: 1453 * Add it to the IO-APIC irq-routing table:
@@ -1397,6 +1553,147 @@ static int ioapic_retrigger_irq(unsigned int irq)
1397 */ 1553 */
1398 1554
1399#ifdef CONFIG_SMP 1555#ifdef CONFIG_SMP
1556
1557#ifdef CONFIG_INTR_REMAP
1558static void ir_irq_migration(struct work_struct *work);
1559
1560static DECLARE_DELAYED_WORK(ir_migration_work, ir_irq_migration);
1561
1562/*
1563 * Migrate the IO-APIC irq in the presence of intr-remapping.
1564 *
1565 * For edge triggered, irq migration is a simple atomic update(of vector
1566 * and cpu destination) of IRTE and flush the hardware cache.
1567 *
1568 * For level triggered, we need to modify the io-apic RTE aswell with the update
1569 * vector information, along with modifying IRTE with vector and destination.
1570 * So irq migration for level triggered is little bit more complex compared to
1571 * edge triggered migration. But the good news is, we use the same algorithm
1572 * for level triggered migration as we have today, only difference being,
1573 * we now initiate the irq migration from process context instead of the
1574 * interrupt context.
1575 *
1576 * In future, when we do a directed EOI (combined with cpu EOI broadcast
1577 * suppression) to the IO-APIC, level triggered irq migration will also be
1578 * as simple as edge triggered migration and we can do the irq migration
1579 * with a simple atomic update to IO-APIC RTE.
1580 */
1581static void migrate_ioapic_irq(int irq, cpumask_t mask)
1582{
1583 struct irq_cfg *cfg = irq_cfg + irq;
1584 struct irq_desc *desc = irq_desc + irq;
1585 cpumask_t tmp, cleanup_mask;
1586 struct irte irte;
1587 int modify_ioapic_rte = desc->status & IRQ_LEVEL;
1588 unsigned int dest;
1589 unsigned long flags;
1590
1591 cpus_and(tmp, mask, cpu_online_map);
1592 if (cpus_empty(tmp))
1593 return;
1594
1595 if (get_irte(irq, &irte))
1596 return;
1597
1598 if (assign_irq_vector(irq, mask))
1599 return;
1600
1601 cpus_and(tmp, cfg->domain, mask);
1602 dest = cpu_mask_to_apicid(tmp);
1603
1604 if (modify_ioapic_rte) {
1605 spin_lock_irqsave(&ioapic_lock, flags);
1606 __target_IO_APIC_irq(irq, dest, cfg->vector);
1607 spin_unlock_irqrestore(&ioapic_lock, flags);
1608 }
1609
1610 irte.vector = cfg->vector;
1611 irte.dest_id = IRTE_DEST(dest);
1612
1613 /*
1614 * Modified the IRTE and flushes the Interrupt entry cache.
1615 */
1616 modify_irte(irq, &irte);
1617
1618 if (cfg->move_in_progress) {
1619 cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
1620 cfg->move_cleanup_count = cpus_weight(cleanup_mask);
1621 send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
1622 cfg->move_in_progress = 0;
1623 }
1624
1625 irq_desc[irq].affinity = mask;
1626}
1627
1628static int migrate_irq_remapped_level(int irq)
1629{
1630 int ret = -1;
1631
1632 mask_IO_APIC_irq(irq);
1633
1634 if (io_apic_level_ack_pending(irq)) {
1635 /*
1636 * Interrupt in progress. Migrating irq now will change the
1637 * vector information in the IO-APIC RTE and that will confuse
1638 * the EOI broadcast performed by cpu.
1639 * So, delay the irq migration to the next instance.
1640 */
1641 schedule_delayed_work(&ir_migration_work, 1);
1642 goto unmask;
1643 }
1644
1645 /* everthing is clear. we have right of way */
1646 migrate_ioapic_irq(irq, irq_desc[irq].pending_mask);
1647
1648 ret = 0;
1649 irq_desc[irq].status &= ~IRQ_MOVE_PENDING;
1650 cpus_clear(irq_desc[irq].pending_mask);
1651
1652unmask:
1653 unmask_IO_APIC_irq(irq);
1654 return ret;
1655}
1656
1657static void ir_irq_migration(struct work_struct *work)
1658{
1659 int irq;
1660
1661 for (irq = 0; irq < NR_IRQS; irq++) {
1662 struct irq_desc *desc = irq_desc + irq;
1663 if (desc->status & IRQ_MOVE_PENDING) {
1664 unsigned long flags;
1665
1666 spin_lock_irqsave(&desc->lock, flags);
1667 if (!desc->chip->set_affinity ||
1668 !(desc->status & IRQ_MOVE_PENDING)) {
1669 desc->status &= ~IRQ_MOVE_PENDING;
1670 spin_unlock_irqrestore(&desc->lock, flags);
1671 continue;
1672 }
1673
1674 desc->chip->set_affinity(irq,
1675 irq_desc[irq].pending_mask);
1676 spin_unlock_irqrestore(&desc->lock, flags);
1677 }
1678 }
1679}
1680
1681/*
1682 * Migrates the IRQ destination in the process context.
1683 */
1684static void set_ir_ioapic_affinity_irq(unsigned int irq, cpumask_t mask)
1685{
1686 if (irq_desc[irq].status & IRQ_LEVEL) {
1687 irq_desc[irq].status |= IRQ_MOVE_PENDING;
1688 irq_desc[irq].pending_mask = mask;
1689 migrate_irq_remapped_level(irq);
1690 return;
1691 }
1692
1693 migrate_ioapic_irq(irq, mask);
1694}
1695#endif
1696
1400asmlinkage void smp_irq_move_cleanup_interrupt(void) 1697asmlinkage void smp_irq_move_cleanup_interrupt(void)
1401{ 1698{
1402 unsigned vector, me; 1699 unsigned vector, me;
@@ -1453,6 +1750,17 @@ static void irq_complete_move(unsigned int irq)
1453#else 1750#else
1454static inline void irq_complete_move(unsigned int irq) {} 1751static inline void irq_complete_move(unsigned int irq) {}
1455#endif 1752#endif
1753#ifdef CONFIG_INTR_REMAP
1754static void ack_x2apic_level(unsigned int irq)
1755{
1756 ack_x2APIC_irq();
1757}
1758
1759static void ack_x2apic_edge(unsigned int irq)
1760{
1761 ack_x2APIC_irq();
1762}
1763#endif
1456 1764
1457static void ack_apic_edge(unsigned int irq) 1765static void ack_apic_edge(unsigned int irq)
1458{ 1766{
@@ -1527,6 +1835,21 @@ static struct irq_chip ioapic_chip __read_mostly = {
1527 .retrigger = ioapic_retrigger_irq, 1835 .retrigger = ioapic_retrigger_irq,
1528}; 1836};
1529 1837
1838#ifdef CONFIG_INTR_REMAP
1839static struct irq_chip ir_ioapic_chip __read_mostly = {
1840 .name = "IR-IO-APIC",
1841 .startup = startup_ioapic_irq,
1842 .mask = mask_IO_APIC_irq,
1843 .unmask = unmask_IO_APIC_irq,
1844 .ack = ack_x2apic_edge,
1845 .eoi = ack_x2apic_level,
1846#ifdef CONFIG_SMP
1847 .set_affinity = set_ir_ioapic_affinity_irq,
1848#endif
1849 .retrigger = ioapic_retrigger_irq,
1850};
1851#endif
1852
1530static inline void init_IO_APIC_traps(void) 1853static inline void init_IO_APIC_traps(void)
1531{ 1854{
1532 int irq; 1855 int irq;
@@ -1712,6 +2035,8 @@ static inline void __init check_timer(void)
1712 * 8259A. 2035 * 8259A.
1713 */ 2036 */
1714 if (pin1 == -1) { 2037 if (pin1 == -1) {
2038 if (intr_remapping_enabled)
2039 panic("BIOS bug: timer not connected to IO-APIC");
1715 pin1 = pin2; 2040 pin1 = pin2;
1716 apic1 = apic2; 2041 apic1 = apic2;
1717 no_pin1 = 1; 2042 no_pin1 = 1;
@@ -1738,6 +2063,8 @@ static inline void __init check_timer(void)
1738 clear_IO_APIC_pin(0, pin1); 2063 clear_IO_APIC_pin(0, pin1);
1739 goto out; 2064 goto out;
1740 } 2065 }
2066 if (intr_remapping_enabled)
2067 panic("timer doesn't work through Interrupt-remapped IO-APIC");
1741 clear_IO_APIC_pin(apic1, pin1); 2068 clear_IO_APIC_pin(apic1, pin1);
1742 if (!no_pin1) 2069 if (!no_pin1)
1743 apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: " 2070 apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: "
@@ -1854,8 +2181,6 @@ void __init setup_IO_APIC(void)
1854 setup_IO_APIC_irqs(); 2181 setup_IO_APIC_irqs();
1855 init_IO_APIC_traps(); 2182 init_IO_APIC_traps();
1856 check_timer(); 2183 check_timer();
1857 if (!acpi_ioapic)
1858 print_IO_APIC();
1859} 2184}
1860 2185
1861struct sysfs_ioapic_data { 2186struct sysfs_ioapic_data {
@@ -1977,6 +2302,9 @@ void destroy_irq(unsigned int irq)
1977 2302
1978 dynamic_irq_cleanup(irq); 2303 dynamic_irq_cleanup(irq);
1979 2304
2305#ifdef CONFIG_INTR_REMAP
2306 free_irte(irq);
2307#endif
1980 spin_lock_irqsave(&vector_lock, flags); 2308 spin_lock_irqsave(&vector_lock, flags);
1981 __clear_irq_vector(irq); 2309 __clear_irq_vector(irq);
1982 spin_unlock_irqrestore(&vector_lock, flags); 2310 spin_unlock_irqrestore(&vector_lock, flags);
@@ -1995,11 +2323,42 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
1995 2323
1996 tmp = TARGET_CPUS; 2324 tmp = TARGET_CPUS;
1997 err = assign_irq_vector(irq, tmp); 2325 err = assign_irq_vector(irq, tmp);
1998 if (!err) { 2326 if (err)
1999 cpus_and(tmp, cfg->domain, tmp); 2327 return err;
2000 dest = cpu_mask_to_apicid(tmp); 2328
2329 cpus_and(tmp, cfg->domain, tmp);
2330 dest = cpu_mask_to_apicid(tmp);
2331
2332#ifdef CONFIG_INTR_REMAP
2333 if (irq_remapped(irq)) {
2334 struct irte irte;
2335 int ir_index;
2336 u16 sub_handle;
2337
2338 ir_index = map_irq_to_irte_handle(irq, &sub_handle);
2339 BUG_ON(ir_index == -1);
2340
2341 memset (&irte, 0, sizeof(irte));
2342
2343 irte.present = 1;
2344 irte.dst_mode = INT_DEST_MODE;
2345 irte.trigger_mode = 0; /* edge */
2346 irte.dlvry_mode = INT_DELIVERY_MODE;
2347 irte.vector = cfg->vector;
2348 irte.dest_id = IRTE_DEST(dest);
2349
2350 modify_irte(irq, &irte);
2001 2351
2002 msg->address_hi = MSI_ADDR_BASE_HI; 2352 msg->address_hi = MSI_ADDR_BASE_HI;
2353 msg->data = sub_handle;
2354 msg->address_lo = MSI_ADDR_BASE_LO | MSI_ADDR_IR_EXT_INT |
2355 MSI_ADDR_IR_SHV |
2356 MSI_ADDR_IR_INDEX1(ir_index) |
2357 MSI_ADDR_IR_INDEX2(ir_index);
2358 } else
2359#endif
2360 {
2361 msg->address_hi = MSI_ADDR_BASE_HI;
2003 msg->address_lo = 2362 msg->address_lo =
2004 MSI_ADDR_BASE_LO | 2363 MSI_ADDR_BASE_LO |
2005 ((INT_DEST_MODE == 0) ? 2364 ((INT_DEST_MODE == 0) ?
@@ -2049,6 +2408,55 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
2049 write_msi_msg(irq, &msg); 2408 write_msi_msg(irq, &msg);
2050 irq_desc[irq].affinity = mask; 2409 irq_desc[irq].affinity = mask;
2051} 2410}
2411
2412#ifdef CONFIG_INTR_REMAP
2413/*
2414 * Migrate the MSI irq to another cpumask. This migration is
2415 * done in the process context using interrupt-remapping hardware.
2416 */
2417static void ir_set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
2418{
2419 struct irq_cfg *cfg = irq_cfg + irq;
2420 unsigned int dest;
2421 cpumask_t tmp, cleanup_mask;
2422 struct irte irte;
2423
2424 cpus_and(tmp, mask, cpu_online_map);
2425 if (cpus_empty(tmp))
2426 return;
2427
2428 if (get_irte(irq, &irte))
2429 return;
2430
2431 if (assign_irq_vector(irq, mask))
2432 return;
2433
2434 cpus_and(tmp, cfg->domain, mask);
2435 dest = cpu_mask_to_apicid(tmp);
2436
2437 irte.vector = cfg->vector;
2438 irte.dest_id = IRTE_DEST(dest);
2439
2440 /*
2441 * atomically update the IRTE with the new destination and vector.
2442 */
2443 modify_irte(irq, &irte);
2444
2445 /*
2446 * After this point, all the interrupts will start arriving
2447 * at the new destination. So, time to cleanup the previous
2448 * vector allocation.
2449 */
2450 if (cfg->move_in_progress) {
2451 cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
2452 cfg->move_cleanup_count = cpus_weight(cleanup_mask);
2453 send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
2454 cfg->move_in_progress = 0;
2455 }
2456
2457 irq_desc[irq].affinity = mask;
2458}
2459#endif
2052#endif /* CONFIG_SMP */ 2460#endif /* CONFIG_SMP */
2053 2461
2054/* 2462/*
@@ -2066,26 +2474,157 @@ static struct irq_chip msi_chip = {
2066 .retrigger = ioapic_retrigger_irq, 2474 .retrigger = ioapic_retrigger_irq,
2067}; 2475};
2068 2476
2069int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) 2477#ifdef CONFIG_INTR_REMAP
2478static struct irq_chip msi_ir_chip = {
2479 .name = "IR-PCI-MSI",
2480 .unmask = unmask_msi_irq,
2481 .mask = mask_msi_irq,
2482 .ack = ack_x2apic_edge,
2483#ifdef CONFIG_SMP
2484 .set_affinity = ir_set_msi_irq_affinity,
2485#endif
2486 .retrigger = ioapic_retrigger_irq,
2487};
2488
2489/*
2490 * Map the PCI dev to the corresponding remapping hardware unit
2491 * and allocate 'nvec' consecutive interrupt-remapping table entries
2492 * in it.
2493 */
2494static int msi_alloc_irte(struct pci_dev *dev, int irq, int nvec)
2070{ 2495{
2496 struct intel_iommu *iommu;
2497 int index;
2498
2499 iommu = map_dev_to_ir(dev);
2500 if (!iommu) {
2501 printk(KERN_ERR
2502 "Unable to map PCI %s to iommu\n", pci_name(dev));
2503 return -ENOENT;
2504 }
2505
2506 index = alloc_irte(iommu, irq, nvec);
2507 if (index < 0) {
2508 printk(KERN_ERR
2509 "Unable to allocate %d IRTE for PCI %s\n", nvec,
2510 pci_name(dev));
2511 return -ENOSPC;
2512 }
2513 return index;
2514}
2515#endif
2516
2517static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc, int irq)
2518{
2519 int ret;
2071 struct msi_msg msg; 2520 struct msi_msg msg;
2521
2522 ret = msi_compose_msg(dev, irq, &msg);
2523 if (ret < 0)
2524 return ret;
2525
2526 set_irq_msi(irq, desc);
2527 write_msi_msg(irq, &msg);
2528
2529#ifdef CONFIG_INTR_REMAP
2530 if (irq_remapped(irq)) {
2531 struct irq_desc *desc = irq_desc + irq;
2532 /*
2533 * irq migration in process context
2534 */
2535 desc->status |= IRQ_MOVE_PCNTXT;
2536 set_irq_chip_and_handler_name(irq, &msi_ir_chip, handle_edge_irq, "edge");
2537 } else
2538#endif
2539 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge");
2540
2541 return 0;
2542}
2543
2544int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
2545{
2072 int irq, ret; 2546 int irq, ret;
2547
2073 irq = create_irq(); 2548 irq = create_irq();
2074 if (irq < 0) 2549 if (irq < 0)
2075 return irq; 2550 return irq;
2076 2551
2077 ret = msi_compose_msg(dev, irq, &msg); 2552#ifdef CONFIG_INTR_REMAP
2553 if (!intr_remapping_enabled)
2554 goto no_ir;
2555
2556 ret = msi_alloc_irte(dev, irq, 1);
2557 if (ret < 0)
2558 goto error;
2559no_ir:
2560#endif
2561 ret = setup_msi_irq(dev, desc, irq);
2078 if (ret < 0) { 2562 if (ret < 0) {
2079 destroy_irq(irq); 2563 destroy_irq(irq);
2080 return ret; 2564 return ret;
2081 } 2565 }
2566 return 0;
2082 2567
2083 set_irq_msi(irq, desc); 2568#ifdef CONFIG_INTR_REMAP
2084 write_msi_msg(irq, &msg); 2569error:
2570 destroy_irq(irq);
2571 return ret;
2572#endif
2573}
2085 2574
2086 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); 2575int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
2576{
2577 int irq, ret, sub_handle;
2578 struct msi_desc *desc;
2579#ifdef CONFIG_INTR_REMAP
2580 struct intel_iommu *iommu = 0;
2581 int index = 0;
2582#endif
2583
2584 sub_handle = 0;
2585 list_for_each_entry(desc, &dev->msi_list, list) {
2586 irq = create_irq();
2587 if (irq < 0)
2588 return irq;
2589#ifdef CONFIG_INTR_REMAP
2590 if (!intr_remapping_enabled)
2591 goto no_ir;
2087 2592
2593 if (!sub_handle) {
2594 /*
2595 * allocate the consecutive block of IRTE's
2596 * for 'nvec'
2597 */
2598 index = msi_alloc_irte(dev, irq, nvec);
2599 if (index < 0) {
2600 ret = index;
2601 goto error;
2602 }
2603 } else {
2604 iommu = map_dev_to_ir(dev);
2605 if (!iommu) {
2606 ret = -ENOENT;
2607 goto error;
2608 }
2609 /*
2610 * setup the mapping between the irq and the IRTE
2611 * base index, the sub_handle pointing to the
2612 * appropriate interrupt remap table entry.
2613 */
2614 set_irte_irq(irq, iommu, index, sub_handle);
2615 }
2616no_ir:
2617#endif
2618 ret = setup_msi_irq(dev, desc, irq);
2619 if (ret < 0)
2620 goto error;
2621 sub_handle++;
2622 }
2088 return 0; 2623 return 0;
2624
2625error:
2626 destroy_irq(irq);
2627 return ret;
2089} 2628}
2090 2629
2091void arch_teardown_msi_irq(unsigned int irq) 2630void arch_teardown_msi_irq(unsigned int irq)
@@ -2333,6 +2872,10 @@ void __init setup_ioapic_dest(void)
2333 setup_IO_APIC_irq(ioapic, pin, irq, 2872 setup_IO_APIC_irq(ioapic, pin, irq,
2334 irq_trigger(irq_entry), 2873 irq_trigger(irq_entry),
2335 irq_polarity(irq_entry)); 2874 irq_polarity(irq_entry));
2875#ifdef CONFIG_INTR_REMAP
2876 else if (intr_remapping_enabled)
2877 set_ir_ioapic_affinity_irq(irq, TARGET_CPUS);
2878#endif
2336 else 2879 else
2337 set_ioapic_affinity_irq(irq, TARGET_CPUS); 2880 set_ioapic_affinity_irq(irq, TARGET_CPUS);
2338 } 2881 }
diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
index 50e5e4a31c85..191914302744 100644
--- a/arch/x86/kernel/ioport.c
+++ b/arch/x86/kernel/ioport.c
@@ -14,6 +14,7 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/thread_info.h> 15#include <linux/thread_info.h>
16#include <linux/syscalls.h> 16#include <linux/syscalls.h>
17#include <asm/syscalls.h>
17 18
18/* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */ 19/* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
19static void set_bitmap(unsigned long *bitmap, unsigned int base, 20static void set_bitmap(unsigned long *bitmap, unsigned int base,
diff --git a/arch/x86/kernel/ipi.c b/arch/x86/kernel/ipi.c
index 3f7537b669d3..f1c688e46f35 100644
--- a/arch/x86/kernel/ipi.c
+++ b/arch/x86/kernel/ipi.c
@@ -20,6 +20,8 @@
20 20
21#ifdef CONFIG_X86_32 21#ifdef CONFIG_X86_32
22#include <mach_apic.h> 22#include <mach_apic.h>
23#include <mach_ipi.h>
24
23/* 25/*
24 * the following functions deal with sending IPIs between CPUs. 26 * the following functions deal with sending IPIs between CPUs.
25 * 27 *
@@ -147,7 +149,6 @@ void send_IPI_mask_sequence(cpumask_t mask, int vector)
147} 149}
148 150
149/* must come after the send_IPI functions above for inlining */ 151/* must come after the send_IPI functions above for inlining */
150#include <mach_ipi.h>
151static int convert_apicid_to_cpu(int apic_id) 152static int convert_apicid_to_cpu(int apic_id)
152{ 153{
153 int i; 154 int i;
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 1cf8c1fcc088..b71e02d42f4f 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -325,7 +325,7 @@ skip:
325 for_each_online_cpu(j) 325 for_each_online_cpu(j)
326 seq_printf(p, "%10u ", 326 seq_printf(p, "%10u ",
327 per_cpu(irq_stat,j).irq_call_count); 327 per_cpu(irq_stat,j).irq_call_count);
328 seq_printf(p, " function call interrupts\n"); 328 seq_printf(p, " Function call interrupts\n");
329 seq_printf(p, "TLB: "); 329 seq_printf(p, "TLB: ");
330 for_each_online_cpu(j) 330 for_each_online_cpu(j)
331 seq_printf(p, "%10u ", 331 seq_printf(p, "%10u ",
diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
index 1f78b238d8d2..f065fe9071b9 100644
--- a/arch/x86/kernel/irq_64.c
+++ b/arch/x86/kernel/irq_64.c
@@ -129,7 +129,7 @@ skip:
129 seq_printf(p, "CAL: "); 129 seq_printf(p, "CAL: ");
130 for_each_online_cpu(j) 130 for_each_online_cpu(j)
131 seq_printf(p, "%10u ", cpu_pda(j)->irq_call_count); 131 seq_printf(p, "%10u ", cpu_pda(j)->irq_call_count);
132 seq_printf(p, " function call interrupts\n"); 132 seq_printf(p, " Function call interrupts\n");
133 seq_printf(p, "TLB: "); 133 seq_printf(p, "TLB: ");
134 for_each_online_cpu(j) 134 for_each_online_cpu(j)
135 seq_printf(p, "%10u ", cpu_pda(j)->irq_tlb_count); 135 seq_printf(p, "%10u ", cpu_pda(j)->irq_tlb_count);
diff --git a/arch/x86/kernel/irqinit_32.c b/arch/x86/kernel/irqinit_32.c
index d66914287ee1..9200a1e2752d 100644
--- a/arch/x86/kernel/irqinit_32.c
+++ b/arch/x86/kernel/irqinit_32.c
@@ -74,6 +74,15 @@ void __init init_ISA_irqs (void)
74 } 74 }
75} 75}
76 76
77/*
78 * IRQ2 is cascade interrupt to second interrupt controller
79 */
80static struct irqaction irq2 = {
81 .handler = no_action,
82 .mask = CPU_MASK_NONE,
83 .name = "cascade",
84};
85
77/* Overridden in paravirt.c */ 86/* Overridden in paravirt.c */
78void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ"))); 87void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
79 88
@@ -98,6 +107,46 @@ void __init native_init_IRQ(void)
98 set_intr_gate(vector, interrupt[i]); 107 set_intr_gate(vector, interrupt[i]);
99 } 108 }
100 109
110#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_SMP)
111 /*
112 * IRQ0 must be given a fixed assignment and initialized,
113 * because it's used before the IO-APIC is set up.
114 */
115 set_intr_gate(FIRST_DEVICE_VECTOR, interrupt[0]);
116
117 /*
118 * The reschedule interrupt is a CPU-to-CPU reschedule-helper
119 * IPI, driven by wakeup.
120 */
121 alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
122
123 /* IPI for invalidation */
124 alloc_intr_gate(INVALIDATE_TLB_VECTOR, invalidate_interrupt);
125
126 /* IPI for generic function call */
127 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
128
129 /* IPI for single call function */
130 set_intr_gate(CALL_FUNCTION_SINGLE_VECTOR, call_function_single_interrupt);
131#endif
132
133#ifdef CONFIG_X86_LOCAL_APIC
134 /* self generated IPI for local APIC timer */
135 alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
136
137 /* IPI vectors for APIC spurious and error interrupts */
138 alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
139 alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
140#endif
141
142#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_MCE_P4THERMAL)
143 /* thermal monitor LVT interrupt */
144 alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
145#endif
146
147 if (!acpi_ioapic)
148 setup_irq(2, &irq2);
149
101 /* setup after call gates are initialised (usually add in 150 /* setup after call gates are initialised (usually add in
102 * the architecture specific gates) 151 * the architecture specific gates)
103 */ 152 */
diff --git a/arch/x86/kernel/k8.c b/arch/x86/kernel/k8.c
index 7377ccb21335..304d8bad6559 100644
--- a/arch/x86/kernel/k8.c
+++ b/arch/x86/kernel/k8.c
@@ -16,8 +16,9 @@ EXPORT_SYMBOL(num_k8_northbridges);
16static u32 *flush_words; 16static u32 *flush_words;
17 17
18struct pci_device_id k8_nb_ids[] = { 18struct pci_device_id k8_nb_ids[] = {
19 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) }, 19 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
20 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1203) }, 20 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
21 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
21 {} 22 {}
22}; 23};
23EXPORT_SYMBOL(k8_nb_ids); 24EXPORT_SYMBOL(k8_nb_ids);
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 8282a2139681..10435a120d22 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -455,12 +455,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
455 return NOTIFY_DONE; 455 return NOTIFY_DONE;
456 456
457 case DIE_NMI_IPI: 457 case DIE_NMI_IPI:
458 if (atomic_read(&kgdb_active) != -1) { 458 /* Just ignore, we will handle the roundup on DIE_NMI. */
459 /* KGDB CPU roundup */
460 kgdb_nmicallback(raw_smp_processor_id(), regs);
461 was_in_debug_nmi[raw_smp_processor_id()] = 1;
462 touch_nmi_watchdog();
463 }
464 return NOTIFY_DONE; 459 return NOTIFY_DONE;
465 460
466 case DIE_NMIUNKNOWN: 461 case DIE_NMIUNKNOWN:
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 8b7a3cf37d2b..478bca986eca 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -178,7 +178,7 @@ static void kvm_flush_tlb(void)
178 kvm_deferred_mmu_op(&ftlb, sizeof ftlb); 178 kvm_deferred_mmu_op(&ftlb, sizeof ftlb);
179} 179}
180 180
181static void kvm_release_pt(u32 pfn) 181static void kvm_release_pt(unsigned long pfn)
182{ 182{
183 struct kvm_mmu_op_release_pt rpt = { 183 struct kvm_mmu_op_release_pt rpt = {
184 .header.op = KVM_MMU_OP_RELEASE_PT, 184 .header.op = KVM_MMU_OP_RELEASE_PT,
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index b68e21f06f4f..eee32b43fee3 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -18,6 +18,7 @@
18#include <asm/ldt.h> 18#include <asm/ldt.h>
19#include <asm/desc.h> 19#include <asm/desc.h>
20#include <asm/mmu_context.h> 20#include <asm/mmu_context.h>
21#include <asm/syscalls.h>
21 22
22#ifdef CONFIG_SMP 23#ifdef CONFIG_SMP
23static void flush_ldt(void *current_mm) 24static void flush_ldt(void *current_mm)
@@ -51,6 +52,8 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
51 memset(newldt + oldsize * LDT_ENTRY_SIZE, 0, 52 memset(newldt + oldsize * LDT_ENTRY_SIZE, 0,
52 (mincount - oldsize) * LDT_ENTRY_SIZE); 53 (mincount - oldsize) * LDT_ENTRY_SIZE);
53 54
55 paravirt_alloc_ldt(newldt, mincount);
56
54#ifdef CONFIG_X86_64 57#ifdef CONFIG_X86_64
55 /* CHECKME: Do we really need this ? */ 58 /* CHECKME: Do we really need this ? */
56 wmb(); 59 wmb();
@@ -73,6 +76,7 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
73#endif 76#endif
74 } 77 }
75 if (oldsize) { 78 if (oldsize) {
79 paravirt_free_ldt(oldldt, oldsize);
76 if (oldsize * LDT_ENTRY_SIZE > PAGE_SIZE) 80 if (oldsize * LDT_ENTRY_SIZE > PAGE_SIZE)
77 vfree(oldldt); 81 vfree(oldldt);
78 else 82 else
@@ -84,10 +88,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
84static inline int copy_ldt(mm_context_t *new, mm_context_t *old) 88static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
85{ 89{
86 int err = alloc_ldt(new, old->size, 0); 90 int err = alloc_ldt(new, old->size, 0);
91 int i;
87 92
88 if (err < 0) 93 if (err < 0)
89 return err; 94 return err;
90 memcpy(new->ldt, old->ldt, old->size * LDT_ENTRY_SIZE); 95
96 for(i = 0; i < old->size; i++)
97 write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
91 return 0; 98 return 0;
92} 99}
93 100
@@ -124,6 +131,7 @@ void destroy_context(struct mm_struct *mm)
124 if (mm == current->active_mm) 131 if (mm == current->active_mm)
125 clear_LDT(); 132 clear_LDT();
126#endif 133#endif
134 paravirt_free_ldt(mm->context.ldt, mm->context.size);
127 if (mm->context.size * LDT_ENTRY_SIZE > PAGE_SIZE) 135 if (mm->context.size * LDT_ENTRY_SIZE > PAGE_SIZE)
128 vfree(mm->context.ldt); 136 vfree(mm->context.ldt);
129 else 137 else
diff --git a/arch/x86/kernel/microcode.c b/arch/x86/kernel/microcode.c
deleted file mode 100644
index 652fa5c38ebe..000000000000
--- a/arch/x86/kernel/microcode.c
+++ /dev/null
@@ -1,853 +0,0 @@
1/*
2 * Intel CPU Microcode Update Driver for Linux
3 *
4 * Copyright (C) 2000-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
5 * 2006 Shaohua Li <shaohua.li@intel.com>
6 *
7 * This driver allows to upgrade microcode on Intel processors
8 * belonging to IA-32 family - PentiumPro, Pentium II,
9 * Pentium III, Xeon, Pentium 4, etc.
10 *
11 * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture
12 * Software Developer's Manual
13 * Order Number 253668 or free download from:
14 *
15 * http://developer.intel.com/design/pentium4/manuals/253668.htm
16 *
17 * For more information, go to http://www.urbanmyth.org/microcode
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version
22 * 2 of the License, or (at your option) any later version.
23 *
24 * 1.0 16 Feb 2000, Tigran Aivazian <tigran@sco.com>
25 * Initial release.
26 * 1.01 18 Feb 2000, Tigran Aivazian <tigran@sco.com>
27 * Added read() support + cleanups.
28 * 1.02 21 Feb 2000, Tigran Aivazian <tigran@sco.com>
29 * Added 'device trimming' support. open(O_WRONLY) zeroes
30 * and frees the saved copy of applied microcode.
31 * 1.03 29 Feb 2000, Tigran Aivazian <tigran@sco.com>
32 * Made to use devfs (/dev/cpu/microcode) + cleanups.
33 * 1.04 06 Jun 2000, Simon Trimmer <simon@veritas.com>
34 * Added misc device support (now uses both devfs and misc).
35 * Added MICROCODE_IOCFREE ioctl to clear memory.
36 * 1.05 09 Jun 2000, Simon Trimmer <simon@veritas.com>
37 * Messages for error cases (non Intel & no suitable microcode).
38 * 1.06 03 Aug 2000, Tigran Aivazian <tigran@veritas.com>
39 * Removed ->release(). Removed exclusive open and status bitmap.
40 * Added microcode_rwsem to serialize read()/write()/ioctl().
41 * Removed global kernel lock usage.
42 * 1.07 07 Sep 2000, Tigran Aivazian <tigran@veritas.com>
43 * Write 0 to 0x8B msr and then cpuid before reading revision,
44 * so that it works even if there were no update done by the
45 * BIOS. Otherwise, reading from 0x8B gives junk (which happened
46 * to be 0 on my machine which is why it worked even when I
47 * disabled update by the BIOS)
48 * Thanks to Eric W. Biederman <ebiederman@lnxi.com> for the fix.
49 * 1.08 11 Dec 2000, Richard Schaal <richard.schaal@intel.com> and
50 * Tigran Aivazian <tigran@veritas.com>
51 * Intel Pentium 4 processor support and bugfixes.
52 * 1.09 30 Oct 2001, Tigran Aivazian <tigran@veritas.com>
53 * Bugfix for HT (Hyper-Threading) enabled processors
54 * whereby processor resources are shared by all logical processors
55 * in a single CPU package.
56 * 1.10 28 Feb 2002 Asit K Mallick <asit.k.mallick@intel.com> and
57 * Tigran Aivazian <tigran@veritas.com>,
58 * Serialize updates as required on HT processors due to speculative
59 * nature of implementation.
60 * 1.11 22 Mar 2002 Tigran Aivazian <tigran@veritas.com>
61 * Fix the panic when writing zero-length microcode chunk.
62 * 1.12 29 Sep 2003 Nitin Kamble <nitin.a.kamble@intel.com>,
63 * Jun Nakajima <jun.nakajima@intel.com>
64 * Support for the microcode updates in the new format.
65 * 1.13 10 Oct 2003 Tigran Aivazian <tigran@veritas.com>
66 * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl
67 * because we no longer hold a copy of applied microcode
68 * in kernel memory.
69 * 1.14 25 Jun 2004 Tigran Aivazian <tigran@veritas.com>
70 * Fix sigmatch() macro to handle old CPUs with pf == 0.
71 * Thanks to Stuart Swales for pointing out this bug.
72 */
73
74//#define DEBUG /* pr_debug */
75#include <linux/capability.h>
76#include <linux/kernel.h>
77#include <linux/init.h>
78#include <linux/sched.h>
79#include <linux/smp_lock.h>
80#include <linux/cpumask.h>
81#include <linux/module.h>
82#include <linux/slab.h>
83#include <linux/vmalloc.h>
84#include <linux/miscdevice.h>
85#include <linux/spinlock.h>
86#include <linux/mm.h>
87#include <linux/fs.h>
88#include <linux/mutex.h>
89#include <linux/cpu.h>
90#include <linux/firmware.h>
91#include <linux/platform_device.h>
92
93#include <asm/msr.h>
94#include <asm/uaccess.h>
95#include <asm/processor.h>
96
97MODULE_DESCRIPTION("Intel CPU (IA-32) Microcode Update Driver");
98MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");
99MODULE_LICENSE("GPL");
100
101#define MICROCODE_VERSION "1.14a"
102
103#define DEFAULT_UCODE_DATASIZE (2000) /* 2000 bytes */
104#define MC_HEADER_SIZE (sizeof (microcode_header_t)) /* 48 bytes */
105#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) /* 2048 bytes */
106#define EXT_HEADER_SIZE (sizeof (struct extended_sigtable)) /* 20 bytes */
107#define EXT_SIGNATURE_SIZE (sizeof (struct extended_signature)) /* 12 bytes */
108#define DWSIZE (sizeof (u32))
109#define get_totalsize(mc) \
110 (((microcode_t *)mc)->hdr.totalsize ? \
111 ((microcode_t *)mc)->hdr.totalsize : DEFAULT_UCODE_TOTALSIZE)
112#define get_datasize(mc) \
113 (((microcode_t *)mc)->hdr.datasize ? \
114 ((microcode_t *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)
115
116#define sigmatch(s1, s2, p1, p2) \
117 (((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0))))
118
119#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE)
120
121/* serialize access to the physical write to MSR 0x79 */
122static DEFINE_SPINLOCK(microcode_update_lock);
123
124/* no concurrent ->write()s are allowed on /dev/cpu/microcode */
125static DEFINE_MUTEX(microcode_mutex);
126
127static struct ucode_cpu_info {
128 int valid;
129 unsigned int sig;
130 unsigned int pf;
131 unsigned int rev;
132 microcode_t *mc;
133} ucode_cpu_info[NR_CPUS];
134
135static void collect_cpu_info(int cpu_num)
136{
137 struct cpuinfo_x86 *c = &cpu_data(cpu_num);
138 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
139 unsigned int val[2];
140
141 /* We should bind the task to the CPU */
142 BUG_ON(raw_smp_processor_id() != cpu_num);
143 uci->pf = uci->rev = 0;
144 uci->mc = NULL;
145 uci->valid = 1;
146
147 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
148 cpu_has(c, X86_FEATURE_IA64)) {
149 printk(KERN_ERR "microcode: CPU%d not a capable Intel "
150 "processor\n", cpu_num);
151 uci->valid = 0;
152 return;
153 }
154
155 uci->sig = cpuid_eax(0x00000001);
156
157 if ((c->x86_model >= 5) || (c->x86 > 6)) {
158 /* get processor flags from MSR 0x17 */
159 rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
160 uci->pf = 1 << ((val[1] >> 18) & 7);
161 }
162
163 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
164 /* see notes above for revision 1.07. Apparent chip bug */
165 sync_core();
166 /* get the current revision from MSR 0x8B */
167 rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev);
168 pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
169 uci->sig, uci->pf, uci->rev);
170}
171
172static inline int microcode_update_match(int cpu_num,
173 microcode_header_t *mc_header, int sig, int pf)
174{
175 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
176
177 if (!sigmatch(sig, uci->sig, pf, uci->pf)
178 || mc_header->rev <= uci->rev)
179 return 0;
180 return 1;
181}
182
183static int microcode_sanity_check(void *mc)
184{
185 microcode_header_t *mc_header = mc;
186 struct extended_sigtable *ext_header = NULL;
187 struct extended_signature *ext_sig;
188 unsigned long total_size, data_size, ext_table_size;
189 int sum, orig_sum, ext_sigcount = 0, i;
190
191 total_size = get_totalsize(mc_header);
192 data_size = get_datasize(mc_header);
193 if (data_size + MC_HEADER_SIZE > total_size) {
194 printk(KERN_ERR "microcode: error! "
195 "Bad data size in microcode data file\n");
196 return -EINVAL;
197 }
198
199 if (mc_header->ldrver != 1 || mc_header->hdrver != 1) {
200 printk(KERN_ERR "microcode: error! "
201 "Unknown microcode update format\n");
202 return -EINVAL;
203 }
204 ext_table_size = total_size - (MC_HEADER_SIZE + data_size);
205 if (ext_table_size) {
206 if ((ext_table_size < EXT_HEADER_SIZE)
207 || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) {
208 printk(KERN_ERR "microcode: error! "
209 "Small exttable size in microcode data file\n");
210 return -EINVAL;
211 }
212 ext_header = mc + MC_HEADER_SIZE + data_size;
213 if (ext_table_size != exttable_size(ext_header)) {
214 printk(KERN_ERR "microcode: error! "
215 "Bad exttable size in microcode data file\n");
216 return -EFAULT;
217 }
218 ext_sigcount = ext_header->count;
219 }
220
221 /* check extended table checksum */
222 if (ext_table_size) {
223 int ext_table_sum = 0;
224 int *ext_tablep = (int *)ext_header;
225
226 i = ext_table_size / DWSIZE;
227 while (i--)
228 ext_table_sum += ext_tablep[i];
229 if (ext_table_sum) {
230 printk(KERN_WARNING "microcode: aborting, "
231 "bad extended signature table checksum\n");
232 return -EINVAL;
233 }
234 }
235
236 /* calculate the checksum */
237 orig_sum = 0;
238 i = (MC_HEADER_SIZE + data_size) / DWSIZE;
239 while (i--)
240 orig_sum += ((int *)mc)[i];
241 if (orig_sum) {
242 printk(KERN_ERR "microcode: aborting, bad checksum\n");
243 return -EINVAL;
244 }
245 if (!ext_table_size)
246 return 0;
247 /* check extended signature checksum */
248 for (i = 0; i < ext_sigcount; i++) {
249 ext_sig = (void *)ext_header + EXT_HEADER_SIZE +
250 EXT_SIGNATURE_SIZE * i;
251 sum = orig_sum
252 - (mc_header->sig + mc_header->pf + mc_header->cksum)
253 + (ext_sig->sig + ext_sig->pf + ext_sig->cksum);
254 if (sum) {
255 printk(KERN_ERR "microcode: aborting, bad checksum\n");
256 return -EINVAL;
257 }
258 }
259 return 0;
260}
261
262/*
263 * return 0 - no update found
264 * return 1 - found update
265 * return < 0 - error
266 */
267static int get_maching_microcode(void *mc, int cpu)
268{
269 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
270 microcode_header_t *mc_header = mc;
271 struct extended_sigtable *ext_header;
272 unsigned long total_size = get_totalsize(mc_header);
273 int ext_sigcount, i;
274 struct extended_signature *ext_sig;
275 void *new_mc;
276
277 if (microcode_update_match(cpu, mc_header,
278 mc_header->sig, mc_header->pf))
279 goto find;
280
281 if (total_size <= get_datasize(mc_header) + MC_HEADER_SIZE)
282 return 0;
283
284 ext_header = mc + get_datasize(mc_header) + MC_HEADER_SIZE;
285 ext_sigcount = ext_header->count;
286 ext_sig = (void *)ext_header + EXT_HEADER_SIZE;
287 for (i = 0; i < ext_sigcount; i++) {
288 if (microcode_update_match(cpu, mc_header,
289 ext_sig->sig, ext_sig->pf))
290 goto find;
291 ext_sig++;
292 }
293 return 0;
294find:
295 pr_debug("microcode: CPU%d found a matching microcode update with"
296 " version 0x%x (current=0x%x)\n", cpu, mc_header->rev,uci->rev);
297 new_mc = vmalloc(total_size);
298 if (!new_mc) {
299 printk(KERN_ERR "microcode: error! Can not allocate memory\n");
300 return -ENOMEM;
301 }
302
303 /* free previous update file */
304 vfree(uci->mc);
305
306 memcpy(new_mc, mc, total_size);
307 uci->mc = new_mc;
308 return 1;
309}
310
311static void apply_microcode(int cpu)
312{
313 unsigned long flags;
314 unsigned int val[2];
315 int cpu_num = raw_smp_processor_id();
316 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
317
318 /* We should bind the task to the CPU */
319 BUG_ON(cpu_num != cpu);
320
321 if (uci->mc == NULL)
322 return;
323
324 /* serialize access to the physical write to MSR 0x79 */
325 spin_lock_irqsave(&microcode_update_lock, flags);
326
327 /* write microcode via MSR 0x79 */
328 wrmsr(MSR_IA32_UCODE_WRITE,
329 (unsigned long) uci->mc->bits,
330 (unsigned long) uci->mc->bits >> 16 >> 16);
331 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
332
333 /* see notes above for revision 1.07. Apparent chip bug */
334 sync_core();
335
336 /* get the current revision from MSR 0x8B */
337 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
338
339 spin_unlock_irqrestore(&microcode_update_lock, flags);
340 if (val[1] != uci->mc->hdr.rev) {
341 printk(KERN_ERR "microcode: CPU%d update from revision "
342 "0x%x to 0x%x failed\n", cpu_num, uci->rev, val[1]);
343 return;
344 }
345 printk(KERN_INFO "microcode: CPU%d updated from revision "
346 "0x%x to 0x%x, date = %08x \n",
347 cpu_num, uci->rev, val[1], uci->mc->hdr.date);
348 uci->rev = val[1];
349}
350
351#ifdef CONFIG_MICROCODE_OLD_INTERFACE
352static void __user *user_buffer; /* user area microcode data buffer */
353static unsigned int user_buffer_size; /* it's size */
354
355static long get_next_ucode(void **mc, long offset)
356{
357 microcode_header_t mc_header;
358 unsigned long total_size;
359
360 /* No more data */
361 if (offset >= user_buffer_size)
362 return 0;
363 if (copy_from_user(&mc_header, user_buffer + offset, MC_HEADER_SIZE)) {
364 printk(KERN_ERR "microcode: error! Can not read user data\n");
365 return -EFAULT;
366 }
367 total_size = get_totalsize(&mc_header);
368 if (offset + total_size > user_buffer_size) {
369 printk(KERN_ERR "microcode: error! Bad total size in microcode "
370 "data file\n");
371 return -EINVAL;
372 }
373 *mc = vmalloc(total_size);
374 if (!*mc)
375 return -ENOMEM;
376 if (copy_from_user(*mc, user_buffer + offset, total_size)) {
377 printk(KERN_ERR "microcode: error! Can not read user data\n");
378 vfree(*mc);
379 return -EFAULT;
380 }
381 return offset + total_size;
382}
383
384static int do_microcode_update (void)
385{
386 long cursor = 0;
387 int error = 0;
388 void *new_mc = NULL;
389 int cpu;
390 cpumask_t old;
391
392 old = current->cpus_allowed;
393
394 while ((cursor = get_next_ucode(&new_mc, cursor)) > 0) {
395 error = microcode_sanity_check(new_mc);
396 if (error)
397 goto out;
398 /*
399 * It's possible the data file has multiple matching ucode,
400 * lets keep searching till the latest version
401 */
402 for_each_online_cpu(cpu) {
403 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
404
405 if (!uci->valid)
406 continue;
407 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
408 error = get_maching_microcode(new_mc, cpu);
409 if (error < 0)
410 goto out;
411 if (error == 1)
412 apply_microcode(cpu);
413 }
414 vfree(new_mc);
415 }
416out:
417 if (cursor > 0)
418 vfree(new_mc);
419 if (cursor < 0)
420 error = cursor;
421 set_cpus_allowed_ptr(current, &old);
422 return error;
423}
424
425static int microcode_open (struct inode *unused1, struct file *unused2)
426{
427 cycle_kernel_lock();
428 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
429}
430
431static ssize_t microcode_write (struct file *file, const char __user *buf, size_t len, loff_t *ppos)
432{
433 ssize_t ret;
434
435 if ((len >> PAGE_SHIFT) > num_physpages) {
436 printk(KERN_ERR "microcode: too much data (max %ld pages)\n", num_physpages);
437 return -EINVAL;
438 }
439
440 get_online_cpus();
441 mutex_lock(&microcode_mutex);
442
443 user_buffer = (void __user *) buf;
444 user_buffer_size = (int) len;
445
446 ret = do_microcode_update();
447 if (!ret)
448 ret = (ssize_t)len;
449
450 mutex_unlock(&microcode_mutex);
451 put_online_cpus();
452
453 return ret;
454}
455
456static const struct file_operations microcode_fops = {
457 .owner = THIS_MODULE,
458 .write = microcode_write,
459 .open = microcode_open,
460};
461
462static struct miscdevice microcode_dev = {
463 .minor = MICROCODE_MINOR,
464 .name = "microcode",
465 .fops = &microcode_fops,
466};
467
468static int __init microcode_dev_init (void)
469{
470 int error;
471
472 error = misc_register(&microcode_dev);
473 if (error) {
474 printk(KERN_ERR
475 "microcode: can't misc_register on minor=%d\n",
476 MICROCODE_MINOR);
477 return error;
478 }
479
480 return 0;
481}
482
483static void microcode_dev_exit (void)
484{
485 misc_deregister(&microcode_dev);
486}
487
488MODULE_ALIAS_MISCDEV(MICROCODE_MINOR);
489#else
490#define microcode_dev_init() 0
491#define microcode_dev_exit() do { } while(0)
492#endif
493
494static long get_next_ucode_from_buffer(void **mc, const u8 *buf,
495 unsigned long size, long offset)
496{
497 microcode_header_t *mc_header;
498 unsigned long total_size;
499
500 /* No more data */
501 if (offset >= size)
502 return 0;
503 mc_header = (microcode_header_t *)(buf + offset);
504 total_size = get_totalsize(mc_header);
505
506 if (offset + total_size > size) {
507 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
508 return -EINVAL;
509 }
510
511 *mc = vmalloc(total_size);
512 if (!*mc) {
513 printk(KERN_ERR "microcode: error! Can not allocate memory\n");
514 return -ENOMEM;
515 }
516 memcpy(*mc, buf + offset, total_size);
517 return offset + total_size;
518}
519
520/* fake device for request_firmware */
521static struct platform_device *microcode_pdev;
522
523static int cpu_request_microcode(int cpu)
524{
525 char name[30];
526 struct cpuinfo_x86 *c = &cpu_data(cpu);
527 const struct firmware *firmware;
528 const u8 *buf;
529 unsigned long size;
530 long offset = 0;
531 int error;
532 void *mc;
533
534 /* We should bind the task to the CPU */
535 BUG_ON(cpu != raw_smp_processor_id());
536 sprintf(name,"intel-ucode/%02x-%02x-%02x",
537 c->x86, c->x86_model, c->x86_mask);
538 error = request_firmware(&firmware, name, &microcode_pdev->dev);
539 if (error) {
540 pr_debug("microcode: data file %s load failed\n", name);
541 return error;
542 }
543 buf = firmware->data;
544 size = firmware->size;
545 while ((offset = get_next_ucode_from_buffer(&mc, buf, size, offset))
546 > 0) {
547 error = microcode_sanity_check(mc);
548 if (error)
549 break;
550 error = get_maching_microcode(mc, cpu);
551 if (error < 0)
552 break;
553 /*
554 * It's possible the data file has multiple matching ucode,
555 * lets keep searching till the latest version
556 */
557 if (error == 1) {
558 apply_microcode(cpu);
559 error = 0;
560 }
561 vfree(mc);
562 }
563 if (offset > 0)
564 vfree(mc);
565 if (offset < 0)
566 error = offset;
567 release_firmware(firmware);
568
569 return error;
570}
571
572static int apply_microcode_check_cpu(int cpu)
573{
574 struct cpuinfo_x86 *c = &cpu_data(cpu);
575 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
576 cpumask_t old;
577 unsigned int val[2];
578 int err = 0;
579
580 /* Check if the microcode is available */
581 if (!uci->mc)
582 return 0;
583
584 old = current->cpus_allowed;
585 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
586
587 /* Check if the microcode we have in memory matches the CPU */
588 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
589 cpu_has(c, X86_FEATURE_IA64) || uci->sig != cpuid_eax(0x00000001))
590 err = -EINVAL;
591
592 if (!err && ((c->x86_model >= 5) || (c->x86 > 6))) {
593 /* get processor flags from MSR 0x17 */
594 rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
595 if (uci->pf != (1 << ((val[1] >> 18) & 7)))
596 err = -EINVAL;
597 }
598
599 if (!err) {
600 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
601 /* see notes above for revision 1.07. Apparent chip bug */
602 sync_core();
603 /* get the current revision from MSR 0x8B */
604 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
605 if (uci->rev != val[1])
606 err = -EINVAL;
607 }
608
609 if (!err)
610 apply_microcode(cpu);
611 else
612 printk(KERN_ERR "microcode: Could not apply microcode to CPU%d:"
613 " sig=0x%x, pf=0x%x, rev=0x%x\n",
614 cpu, uci->sig, uci->pf, uci->rev);
615
616 set_cpus_allowed_ptr(current, &old);
617 return err;
618}
619
620static void microcode_init_cpu(int cpu, int resume)
621{
622 cpumask_t old;
623 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
624
625 old = current->cpus_allowed;
626
627 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
628 mutex_lock(&microcode_mutex);
629 collect_cpu_info(cpu);
630 if (uci->valid && system_state == SYSTEM_RUNNING && !resume)
631 cpu_request_microcode(cpu);
632 mutex_unlock(&microcode_mutex);
633 set_cpus_allowed_ptr(current, &old);
634}
635
636static void microcode_fini_cpu(int cpu)
637{
638 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
639
640 mutex_lock(&microcode_mutex);
641 uci->valid = 0;
642 vfree(uci->mc);
643 uci->mc = NULL;
644 mutex_unlock(&microcode_mutex);
645}
646
647static ssize_t reload_store(struct sys_device *dev,
648 struct sysdev_attribute *attr,
649 const char *buf, size_t sz)
650{
651 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
652 char *end;
653 unsigned long val = simple_strtoul(buf, &end, 0);
654 int err = 0;
655 int cpu = dev->id;
656
657 if (end == buf)
658 return -EINVAL;
659 if (val == 1) {
660 cpumask_t old = current->cpus_allowed;
661
662 get_online_cpus();
663 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
664
665 mutex_lock(&microcode_mutex);
666 if (uci->valid)
667 err = cpu_request_microcode(cpu);
668 mutex_unlock(&microcode_mutex);
669 put_online_cpus();
670 set_cpus_allowed_ptr(current, &old);
671 }
672 if (err)
673 return err;
674 return sz;
675}
676
677static ssize_t version_show(struct sys_device *dev,
678 struct sysdev_attribute *attr, char *buf)
679{
680 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
681
682 return sprintf(buf, "0x%x\n", uci->rev);
683}
684
685static ssize_t pf_show(struct sys_device *dev,
686 struct sysdev_attribute *attr, char *buf)
687{
688 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
689
690 return sprintf(buf, "0x%x\n", uci->pf);
691}
692
693static SYSDEV_ATTR(reload, 0200, NULL, reload_store);
694static SYSDEV_ATTR(version, 0400, version_show, NULL);
695static SYSDEV_ATTR(processor_flags, 0400, pf_show, NULL);
696
697static struct attribute *mc_default_attrs[] = {
698 &attr_reload.attr,
699 &attr_version.attr,
700 &attr_processor_flags.attr,
701 NULL
702};
703
704static struct attribute_group mc_attr_group = {
705 .attrs = mc_default_attrs,
706 .name = "microcode",
707};
708
709static int __mc_sysdev_add(struct sys_device *sys_dev, int resume)
710{
711 int err, cpu = sys_dev->id;
712 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
713
714 if (!cpu_online(cpu))
715 return 0;
716
717 pr_debug("microcode: CPU%d added\n", cpu);
718 memset(uci, 0, sizeof(*uci));
719
720 err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
721 if (err)
722 return err;
723
724 microcode_init_cpu(cpu, resume);
725
726 return 0;
727}
728
729static int mc_sysdev_add(struct sys_device *sys_dev)
730{
731 return __mc_sysdev_add(sys_dev, 0);
732}
733
734static int mc_sysdev_remove(struct sys_device *sys_dev)
735{
736 int cpu = sys_dev->id;
737
738 if (!cpu_online(cpu))
739 return 0;
740
741 pr_debug("microcode: CPU%d removed\n", cpu);
742 microcode_fini_cpu(cpu);
743 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
744 return 0;
745}
746
747static int mc_sysdev_resume(struct sys_device *dev)
748{
749 int cpu = dev->id;
750
751 if (!cpu_online(cpu))
752 return 0;
753 pr_debug("microcode: CPU%d resumed\n", cpu);
754 /* only CPU 0 will apply ucode here */
755 apply_microcode(0);
756 return 0;
757}
758
759static struct sysdev_driver mc_sysdev_driver = {
760 .add = mc_sysdev_add,
761 .remove = mc_sysdev_remove,
762 .resume = mc_sysdev_resume,
763};
764
765static __cpuinit int
766mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
767{
768 unsigned int cpu = (unsigned long)hcpu;
769 struct sys_device *sys_dev;
770
771 sys_dev = get_cpu_sysdev(cpu);
772 switch (action) {
773 case CPU_UP_CANCELED_FROZEN:
774 /* The CPU refused to come up during a system resume */
775 microcode_fini_cpu(cpu);
776 break;
777 case CPU_ONLINE:
778 case CPU_DOWN_FAILED:
779 mc_sysdev_add(sys_dev);
780 break;
781 case CPU_ONLINE_FROZEN:
782 /* System-wide resume is in progress, try to apply microcode */
783 if (apply_microcode_check_cpu(cpu)) {
784 /* The application of microcode failed */
785 microcode_fini_cpu(cpu);
786 __mc_sysdev_add(sys_dev, 1);
787 break;
788 }
789 case CPU_DOWN_FAILED_FROZEN:
790 if (sysfs_create_group(&sys_dev->kobj, &mc_attr_group))
791 printk(KERN_ERR "microcode: Failed to create the sysfs "
792 "group for CPU%d\n", cpu);
793 break;
794 case CPU_DOWN_PREPARE:
795 mc_sysdev_remove(sys_dev);
796 break;
797 case CPU_DOWN_PREPARE_FROZEN:
798 /* Suspend is in progress, only remove the interface */
799 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
800 break;
801 }
802 return NOTIFY_OK;
803}
804
805static struct notifier_block __refdata mc_cpu_notifier = {
806 .notifier_call = mc_cpu_callback,
807};
808
809static int __init microcode_init (void)
810{
811 int error;
812
813 printk(KERN_INFO
814 "IA-32 Microcode Update Driver: v" MICROCODE_VERSION " <tigran@aivazian.fsnet.co.uk>\n");
815
816 error = microcode_dev_init();
817 if (error)
818 return error;
819 microcode_pdev = platform_device_register_simple("microcode", -1,
820 NULL, 0);
821 if (IS_ERR(microcode_pdev)) {
822 microcode_dev_exit();
823 return PTR_ERR(microcode_pdev);
824 }
825
826 get_online_cpus();
827 error = sysdev_driver_register(&cpu_sysdev_class, &mc_sysdev_driver);
828 put_online_cpus();
829 if (error) {
830 microcode_dev_exit();
831 platform_device_unregister(microcode_pdev);
832 return error;
833 }
834
835 register_hotcpu_notifier(&mc_cpu_notifier);
836 return 0;
837}
838
839static void __exit microcode_exit (void)
840{
841 microcode_dev_exit();
842
843 unregister_hotcpu_notifier(&mc_cpu_notifier);
844
845 get_online_cpus();
846 sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver);
847 put_online_cpus();
848
849 platform_device_unregister(microcode_pdev);
850}
851
852module_init(microcode_init)
853module_exit(microcode_exit)
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
new file mode 100644
index 000000000000..7a1f8eeac2c7
--- /dev/null
+++ b/arch/x86/kernel/microcode_amd.c
@@ -0,0 +1,435 @@
1/*
2 * AMD CPU Microcode Update Driver for Linux
3 * Copyright (C) 2008 Advanced Micro Devices Inc.
4 *
5 * Author: Peter Oruba <peter.oruba@amd.com>
6 *
7 * Based on work by:
8 * Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
9 *
10 * This driver allows to upgrade microcode on AMD
11 * family 0x10 and 0x11 processors.
12 *
13 * Licensed unter the terms of the GNU General Public
14 * License version 2. See file COPYING for details.
15*/
16
17#include <linux/capability.h>
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/sched.h>
21#include <linux/cpumask.h>
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/vmalloc.h>
25#include <linux/miscdevice.h>
26#include <linux/spinlock.h>
27#include <linux/mm.h>
28#include <linux/fs.h>
29#include <linux/mutex.h>
30#include <linux/cpu.h>
31#include <linux/firmware.h>
32#include <linux/platform_device.h>
33#include <linux/pci.h>
34#include <linux/pci_ids.h>
35
36#include <asm/msr.h>
37#include <asm/uaccess.h>
38#include <asm/processor.h>
39#include <asm/microcode.h>
40
41MODULE_DESCRIPTION("AMD Microcode Update Driver");
42MODULE_AUTHOR("Peter Oruba <peter.oruba@amd.com>");
43MODULE_LICENSE("GPL v2");
44
45#define UCODE_MAGIC 0x00414d44
46#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000
47#define UCODE_UCODE_TYPE 0x00000001
48
49struct equiv_cpu_entry {
50 unsigned int installed_cpu;
51 unsigned int fixed_errata_mask;
52 unsigned int fixed_errata_compare;
53 unsigned int equiv_cpu;
54};
55
56struct microcode_header_amd {
57 unsigned int data_code;
58 unsigned int patch_id;
59 unsigned char mc_patch_data_id[2];
60 unsigned char mc_patch_data_len;
61 unsigned char init_flag;
62 unsigned int mc_patch_data_checksum;
63 unsigned int nb_dev_id;
64 unsigned int sb_dev_id;
65 unsigned char processor_rev_id[2];
66 unsigned char nb_rev_id;
67 unsigned char sb_rev_id;
68 unsigned char bios_api_rev;
69 unsigned char reserved1[3];
70 unsigned int match_reg[8];
71};
72
73struct microcode_amd {
74 struct microcode_header_amd hdr;
75 unsigned int mpb[0];
76};
77
78#define UCODE_MAX_SIZE (2048)
79#define DEFAULT_UCODE_DATASIZE (896)
80#define MC_HEADER_SIZE (sizeof(struct microcode_header_amd))
81#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE)
82#define DWSIZE (sizeof(u32))
83/* For now we support a fixed ucode total size only */
84#define get_totalsize(mc) \
85 ((((struct microcode_amd *)mc)->hdr.mc_patch_data_len * 28) \
86 + MC_HEADER_SIZE)
87
88/* serialize access to the physical write */
89static DEFINE_SPINLOCK(microcode_update_lock);
90
91static struct equiv_cpu_entry *equiv_cpu_table;
92
93static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
94{
95 struct cpuinfo_x86 *c = &cpu_data(cpu);
96
97 memset(csig, 0, sizeof(*csig));
98
99 if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
100 printk(KERN_ERR "microcode: CPU%d not a capable AMD processor\n",
101 cpu);
102 return -1;
103 }
104
105 asm volatile("movl %1, %%ecx; rdmsr"
106 : "=a" (csig->rev)
107 : "i" (0x0000008B) : "ecx");
108
109 printk(KERN_INFO "microcode: collect_cpu_info_amd : patch_id=0x%x\n",
110 csig->rev);
111
112 return 0;
113}
114
115static int get_matching_microcode(int cpu, void *mc, int rev)
116{
117 struct microcode_header_amd *mc_header = mc;
118 struct pci_dev *nb_pci_dev, *sb_pci_dev;
119 unsigned int current_cpu_id;
120 unsigned int equiv_cpu_id = 0x00;
121 unsigned int i = 0;
122
123 BUG_ON(equiv_cpu_table == NULL);
124 current_cpu_id = cpuid_eax(0x00000001);
125
126 while (equiv_cpu_table[i].installed_cpu != 0) {
127 if (current_cpu_id == equiv_cpu_table[i].installed_cpu) {
128 equiv_cpu_id = equiv_cpu_table[i].equiv_cpu;
129 break;
130 }
131 i++;
132 }
133
134 if (!equiv_cpu_id) {
135 printk(KERN_ERR "microcode: CPU%d cpu_id "
136 "not found in equivalent cpu table \n", cpu);
137 return 0;
138 }
139
140 if ((mc_header->processor_rev_id[0]) != (equiv_cpu_id & 0xff)) {
141 printk(KERN_ERR
142 "microcode: CPU%d patch does not match "
143 "(patch is %x, cpu extended is %x) \n",
144 cpu, mc_header->processor_rev_id[0],
145 (equiv_cpu_id & 0xff));
146 return 0;
147 }
148
149 if ((mc_header->processor_rev_id[1]) != ((equiv_cpu_id >> 16) & 0xff)) {
150 printk(KERN_ERR "microcode: CPU%d patch does not match "
151 "(patch is %x, cpu base id is %x) \n",
152 cpu, mc_header->processor_rev_id[1],
153 ((equiv_cpu_id >> 16) & 0xff));
154
155 return 0;
156 }
157
158 /* ucode may be northbridge specific */
159 if (mc_header->nb_dev_id) {
160 nb_pci_dev = pci_get_device(PCI_VENDOR_ID_AMD,
161 (mc_header->nb_dev_id & 0xff),
162 NULL);
163 if ((!nb_pci_dev) ||
164 (mc_header->nb_rev_id != nb_pci_dev->revision)) {
165 printk(KERN_ERR "microcode: CPU%d NB mismatch \n", cpu);
166 pci_dev_put(nb_pci_dev);
167 return 0;
168 }
169 pci_dev_put(nb_pci_dev);
170 }
171
172 /* ucode may be southbridge specific */
173 if (mc_header->sb_dev_id) {
174 sb_pci_dev = pci_get_device(PCI_VENDOR_ID_AMD,
175 (mc_header->sb_dev_id & 0xff),
176 NULL);
177 if ((!sb_pci_dev) ||
178 (mc_header->sb_rev_id != sb_pci_dev->revision)) {
179 printk(KERN_ERR "microcode: CPU%d SB mismatch \n", cpu);
180 pci_dev_put(sb_pci_dev);
181 return 0;
182 }
183 pci_dev_put(sb_pci_dev);
184 }
185
186 if (mc_header->patch_id <= rev)
187 return 0;
188
189 return 1;
190}
191
192static void apply_microcode_amd(int cpu)
193{
194 unsigned long flags;
195 unsigned int eax, edx;
196 unsigned int rev;
197 int cpu_num = raw_smp_processor_id();
198 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
199 struct microcode_amd *mc_amd = uci->mc;
200 unsigned long addr;
201
202 /* We should bind the task to the CPU */
203 BUG_ON(cpu_num != cpu);
204
205 if (mc_amd == NULL)
206 return;
207
208 spin_lock_irqsave(&microcode_update_lock, flags);
209
210 addr = (unsigned long)&mc_amd->hdr.data_code;
211 edx = (unsigned int)(((unsigned long)upper_32_bits(addr)));
212 eax = (unsigned int)(((unsigned long)lower_32_bits(addr)));
213
214 asm volatile("movl %0, %%ecx; wrmsr" :
215 : "i" (0xc0010020), "a" (eax), "d" (edx) : "ecx");
216
217 /* get patch id after patching */
218 asm volatile("movl %1, %%ecx; rdmsr"
219 : "=a" (rev)
220 : "i" (0x0000008B) : "ecx");
221
222 spin_unlock_irqrestore(&microcode_update_lock, flags);
223
224 /* check current patch id and patch's id for match */
225 if (rev != mc_amd->hdr.patch_id) {
226 printk(KERN_ERR "microcode: CPU%d update from revision "
227 "0x%x to 0x%x failed\n", cpu_num,
228 mc_amd->hdr.patch_id, rev);
229 return;
230 }
231
232 printk(KERN_INFO "microcode: CPU%d updated from revision "
233 "0x%x to 0x%x \n",
234 cpu_num, uci->cpu_sig.rev, mc_amd->hdr.patch_id);
235
236 uci->cpu_sig.rev = rev;
237}
238
239static void * get_next_ucode(u8 *buf, unsigned int size,
240 int (*get_ucode_data)(void *, const void *, size_t),
241 unsigned int *mc_size)
242{
243 unsigned int total_size;
244#define UCODE_CONTAINER_SECTION_HDR 8
245 u8 section_hdr[UCODE_CONTAINER_SECTION_HDR];
246 void *mc;
247
248 if (get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR))
249 return NULL;
250
251 if (section_hdr[0] != UCODE_UCODE_TYPE) {
252 printk(KERN_ERR "microcode: error! "
253 "Wrong microcode payload type field\n");
254 return NULL;
255 }
256
257 total_size = (unsigned long) (section_hdr[4] + (section_hdr[5] << 8));
258
259 printk(KERN_INFO "microcode: size %u, total_size %u\n",
260 size, total_size);
261
262 if (total_size > size || total_size > UCODE_MAX_SIZE) {
263 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
264 return NULL;
265 }
266
267 mc = vmalloc(UCODE_MAX_SIZE);
268 if (mc) {
269 memset(mc, 0, UCODE_MAX_SIZE);
270 if (get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, total_size)) {
271 vfree(mc);
272 mc = NULL;
273 } else
274 *mc_size = total_size + UCODE_CONTAINER_SECTION_HDR;
275 }
276#undef UCODE_CONTAINER_SECTION_HDR
277 return mc;
278}
279
280
281static int install_equiv_cpu_table(u8 *buf,
282 int (*get_ucode_data)(void *, const void *, size_t))
283{
284#define UCODE_CONTAINER_HEADER_SIZE 12
285 u8 *container_hdr[UCODE_CONTAINER_HEADER_SIZE];
286 unsigned int *buf_pos = (unsigned int *)container_hdr;
287 unsigned long size;
288
289 if (get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE))
290 return 0;
291
292 size = buf_pos[2];
293
294 if (buf_pos[1] != UCODE_EQUIV_CPU_TABLE_TYPE || !size) {
295 printk(KERN_ERR "microcode: error! "
296 "Wrong microcode equivalnet cpu table\n");
297 return 0;
298 }
299
300 equiv_cpu_table = (struct equiv_cpu_entry *) vmalloc(size);
301 if (!equiv_cpu_table) {
302 printk(KERN_ERR "microcode: error, can't allocate memory for equiv CPU table\n");
303 return 0;
304 }
305
306 buf += UCODE_CONTAINER_HEADER_SIZE;
307 if (get_ucode_data(equiv_cpu_table, buf, size)) {
308 vfree(equiv_cpu_table);
309 return 0;
310 }
311
312 return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */
313#undef UCODE_CONTAINER_HEADER_SIZE
314}
315
316static void free_equiv_cpu_table(void)
317{
318 if (equiv_cpu_table) {
319 vfree(equiv_cpu_table);
320 equiv_cpu_table = NULL;
321 }
322}
323
324static int generic_load_microcode(int cpu, void *data, size_t size,
325 int (*get_ucode_data)(void *, const void *, size_t))
326{
327 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
328 u8 *ucode_ptr = data, *new_mc = NULL, *mc;
329 int new_rev = uci->cpu_sig.rev;
330 unsigned int leftover;
331 unsigned long offset;
332
333 offset = install_equiv_cpu_table(ucode_ptr, get_ucode_data);
334 if (!offset) {
335 printk(KERN_ERR "microcode: installing equivalent cpu table failed\n");
336 return -EINVAL;
337 }
338
339 ucode_ptr += offset;
340 leftover = size - offset;
341
342 while (leftover) {
343 unsigned int uninitialized_var(mc_size);
344 struct microcode_header_amd *mc_header;
345
346 mc = get_next_ucode(ucode_ptr, leftover, get_ucode_data, &mc_size);
347 if (!mc)
348 break;
349
350 mc_header = (struct microcode_header_amd *)mc;
351 if (get_matching_microcode(cpu, mc, new_rev)) {
352 if (new_mc)
353 vfree(new_mc);
354 new_rev = mc_header->patch_id;
355 new_mc = mc;
356 } else
357 vfree(mc);
358
359 ucode_ptr += mc_size;
360 leftover -= mc_size;
361 }
362
363 if (new_mc) {
364 if (!leftover) {
365 if (uci->mc)
366 vfree(uci->mc);
367 uci->mc = new_mc;
368 pr_debug("microcode: CPU%d found a matching microcode update with"
369 " version 0x%x (current=0x%x)\n",
370 cpu, new_rev, uci->cpu_sig.rev);
371 } else
372 vfree(new_mc);
373 }
374
375 free_equiv_cpu_table();
376
377 return (int)leftover;
378}
379
380static int get_ucode_fw(void *to, const void *from, size_t n)
381{
382 memcpy(to, from, n);
383 return 0;
384}
385
386static int request_microcode_fw(int cpu, struct device *device)
387{
388 const char *fw_name = "amd-ucode/microcode_amd.bin";
389 const struct firmware *firmware;
390 int ret;
391
392 /* We should bind the task to the CPU */
393 BUG_ON(cpu != raw_smp_processor_id());
394
395 ret = request_firmware(&firmware, fw_name, device);
396 if (ret) {
397 printk(KERN_ERR "microcode: ucode data file %s load failed\n", fw_name);
398 return ret;
399 }
400
401 ret = generic_load_microcode(cpu, (void*)firmware->data, firmware->size,
402 &get_ucode_fw);
403
404 release_firmware(firmware);
405
406 return ret;
407}
408
409static int request_microcode_user(int cpu, const void __user *buf, size_t size)
410{
411 printk(KERN_WARNING "microcode: AMD microcode update via /dev/cpu/microcode"
412 "is not supported\n");
413 return -1;
414}
415
416static void microcode_fini_cpu_amd(int cpu)
417{
418 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
419
420 vfree(uci->mc);
421 uci->mc = NULL;
422}
423
424static struct microcode_ops microcode_amd_ops = {
425 .request_microcode_user = request_microcode_user,
426 .request_microcode_fw = request_microcode_fw,
427 .collect_cpu_info = collect_cpu_info_amd,
428 .apply_microcode = apply_microcode_amd,
429 .microcode_fini_cpu = microcode_fini_cpu_amd,
430};
431
432struct microcode_ops * __init init_amd_microcode(void)
433{
434 return &microcode_amd_ops;
435}
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
new file mode 100644
index 000000000000..936d8d55f230
--- /dev/null
+++ b/arch/x86/kernel/microcode_core.c
@@ -0,0 +1,508 @@
1/*
2 * Intel CPU Microcode Update Driver for Linux
3 *
4 * Copyright (C) 2000-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
5 * 2006 Shaohua Li <shaohua.li@intel.com>
6 *
7 * This driver allows to upgrade microcode on Intel processors
8 * belonging to IA-32 family - PentiumPro, Pentium II,
9 * Pentium III, Xeon, Pentium 4, etc.
10 *
11 * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture
12 * Software Developer's Manual
13 * Order Number 253668 or free download from:
14 *
15 * http://developer.intel.com/design/pentium4/manuals/253668.htm
16 *
17 * For more information, go to http://www.urbanmyth.org/microcode
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version
22 * 2 of the License, or (at your option) any later version.
23 *
24 * 1.0 16 Feb 2000, Tigran Aivazian <tigran@sco.com>
25 * Initial release.
26 * 1.01 18 Feb 2000, Tigran Aivazian <tigran@sco.com>
27 * Added read() support + cleanups.
28 * 1.02 21 Feb 2000, Tigran Aivazian <tigran@sco.com>
29 * Added 'device trimming' support. open(O_WRONLY) zeroes
30 * and frees the saved copy of applied microcode.
31 * 1.03 29 Feb 2000, Tigran Aivazian <tigran@sco.com>
32 * Made to use devfs (/dev/cpu/microcode) + cleanups.
33 * 1.04 06 Jun 2000, Simon Trimmer <simon@veritas.com>
34 * Added misc device support (now uses both devfs and misc).
35 * Added MICROCODE_IOCFREE ioctl to clear memory.
36 * 1.05 09 Jun 2000, Simon Trimmer <simon@veritas.com>
37 * Messages for error cases (non Intel & no suitable microcode).
38 * 1.06 03 Aug 2000, Tigran Aivazian <tigran@veritas.com>
39 * Removed ->release(). Removed exclusive open and status bitmap.
40 * Added microcode_rwsem to serialize read()/write()/ioctl().
41 * Removed global kernel lock usage.
42 * 1.07 07 Sep 2000, Tigran Aivazian <tigran@veritas.com>
43 * Write 0 to 0x8B msr and then cpuid before reading revision,
44 * so that it works even if there were no update done by the
45 * BIOS. Otherwise, reading from 0x8B gives junk (which happened
46 * to be 0 on my machine which is why it worked even when I
47 * disabled update by the BIOS)
48 * Thanks to Eric W. Biederman <ebiederman@lnxi.com> for the fix.
49 * 1.08 11 Dec 2000, Richard Schaal <richard.schaal@intel.com> and
50 * Tigran Aivazian <tigran@veritas.com>
51 * Intel Pentium 4 processor support and bugfixes.
52 * 1.09 30 Oct 2001, Tigran Aivazian <tigran@veritas.com>
53 * Bugfix for HT (Hyper-Threading) enabled processors
54 * whereby processor resources are shared by all logical processors
55 * in a single CPU package.
56 * 1.10 28 Feb 2002 Asit K Mallick <asit.k.mallick@intel.com> and
57 * Tigran Aivazian <tigran@veritas.com>,
58 * Serialize updates as required on HT processors due to
59 * speculative nature of implementation.
60 * 1.11 22 Mar 2002 Tigran Aivazian <tigran@veritas.com>
61 * Fix the panic when writing zero-length microcode chunk.
62 * 1.12 29 Sep 2003 Nitin Kamble <nitin.a.kamble@intel.com>,
63 * Jun Nakajima <jun.nakajima@intel.com>
64 * Support for the microcode updates in the new format.
65 * 1.13 10 Oct 2003 Tigran Aivazian <tigran@veritas.com>
66 * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl
67 * because we no longer hold a copy of applied microcode
68 * in kernel memory.
69 * 1.14 25 Jun 2004 Tigran Aivazian <tigran@veritas.com>
70 * Fix sigmatch() macro to handle old CPUs with pf == 0.
71 * Thanks to Stuart Swales for pointing out this bug.
72 */
73#include <linux/capability.h>
74#include <linux/kernel.h>
75#include <linux/init.h>
76#include <linux/sched.h>
77#include <linux/smp_lock.h>
78#include <linux/cpumask.h>
79#include <linux/module.h>
80#include <linux/slab.h>
81#include <linux/vmalloc.h>
82#include <linux/miscdevice.h>
83#include <linux/spinlock.h>
84#include <linux/mm.h>
85#include <linux/fs.h>
86#include <linux/mutex.h>
87#include <linux/cpu.h>
88#include <linux/firmware.h>
89#include <linux/platform_device.h>
90
91#include <asm/msr.h>
92#include <asm/uaccess.h>
93#include <asm/processor.h>
94#include <asm/microcode.h>
95
96MODULE_DESCRIPTION("Microcode Update Driver");
97MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");
98MODULE_LICENSE("GPL");
99
100#define MICROCODE_VERSION "2.00"
101
102struct microcode_ops *microcode_ops;
103
104/* no concurrent ->write()s are allowed on /dev/cpu/microcode */
105static DEFINE_MUTEX(microcode_mutex);
106
107struct ucode_cpu_info ucode_cpu_info[NR_CPUS];
108EXPORT_SYMBOL_GPL(ucode_cpu_info);
109
110#ifdef CONFIG_MICROCODE_OLD_INTERFACE
111static int do_microcode_update(const void __user *buf, size_t size)
112{
113 cpumask_t old;
114 int error = 0;
115 int cpu;
116
117 old = current->cpus_allowed;
118
119 for_each_online_cpu(cpu) {
120 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
121
122 if (!uci->valid)
123 continue;
124
125 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
126 error = microcode_ops->request_microcode_user(cpu, buf, size);
127 if (error < 0)
128 goto out;
129 if (!error)
130 microcode_ops->apply_microcode(cpu);
131 }
132out:
133 set_cpus_allowed_ptr(current, &old);
134 return error;
135}
136
137static int microcode_open(struct inode *unused1, struct file *unused2)
138{
139 cycle_kernel_lock();
140 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
141}
142
143static ssize_t microcode_write(struct file *file, const char __user *buf,
144 size_t len, loff_t *ppos)
145{
146 ssize_t ret;
147
148 if ((len >> PAGE_SHIFT) > num_physpages) {
149 printk(KERN_ERR "microcode: too much data (max %ld pages)\n",
150 num_physpages);
151 return -EINVAL;
152 }
153
154 get_online_cpus();
155 mutex_lock(&microcode_mutex);
156
157 ret = do_microcode_update(buf, len);
158 if (!ret)
159 ret = (ssize_t)len;
160
161 mutex_unlock(&microcode_mutex);
162 put_online_cpus();
163
164 return ret;
165}
166
167static const struct file_operations microcode_fops = {
168 .owner = THIS_MODULE,
169 .write = microcode_write,
170 .open = microcode_open,
171};
172
173static struct miscdevice microcode_dev = {
174 .minor = MICROCODE_MINOR,
175 .name = "microcode",
176 .fops = &microcode_fops,
177};
178
179static int __init microcode_dev_init(void)
180{
181 int error;
182
183 error = misc_register(&microcode_dev);
184 if (error) {
185 printk(KERN_ERR
186 "microcode: can't misc_register on minor=%d\n",
187 MICROCODE_MINOR);
188 return error;
189 }
190
191 return 0;
192}
193
194static void microcode_dev_exit(void)
195{
196 misc_deregister(&microcode_dev);
197}
198
199MODULE_ALIAS_MISCDEV(MICROCODE_MINOR);
200#else
201#define microcode_dev_init() 0
202#define microcode_dev_exit() do { } while (0)
203#endif
204
205/* fake device for request_firmware */
206struct platform_device *microcode_pdev;
207
208static ssize_t reload_store(struct sys_device *dev,
209 struct sysdev_attribute *attr,
210 const char *buf, size_t sz)
211{
212 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
213 char *end;
214 unsigned long val = simple_strtoul(buf, &end, 0);
215 int err = 0;
216 int cpu = dev->id;
217
218 if (end == buf)
219 return -EINVAL;
220 if (val == 1) {
221 cpumask_t old = current->cpus_allowed;
222
223 get_online_cpus();
224 if (cpu_online(cpu)) {
225 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
226 mutex_lock(&microcode_mutex);
227 if (uci->valid) {
228 err = microcode_ops->request_microcode_fw(cpu,
229 &microcode_pdev->dev);
230 if (!err)
231 microcode_ops->apply_microcode(cpu);
232 }
233 mutex_unlock(&microcode_mutex);
234 set_cpus_allowed_ptr(current, &old);
235 }
236 put_online_cpus();
237 }
238 if (err)
239 return err;
240 return sz;
241}
242
243static ssize_t version_show(struct sys_device *dev,
244 struct sysdev_attribute *attr, char *buf)
245{
246 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
247
248 return sprintf(buf, "0x%x\n", uci->cpu_sig.rev);
249}
250
251static ssize_t pf_show(struct sys_device *dev,
252 struct sysdev_attribute *attr, char *buf)
253{
254 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
255
256 return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
257}
258
259static SYSDEV_ATTR(reload, 0200, NULL, reload_store);
260static SYSDEV_ATTR(version, 0400, version_show, NULL);
261static SYSDEV_ATTR(processor_flags, 0400, pf_show, NULL);
262
263static struct attribute *mc_default_attrs[] = {
264 &attr_reload.attr,
265 &attr_version.attr,
266 &attr_processor_flags.attr,
267 NULL
268};
269
270static struct attribute_group mc_attr_group = {
271 .attrs = mc_default_attrs,
272 .name = "microcode",
273};
274
275static void microcode_fini_cpu(int cpu)
276{
277 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
278
279 mutex_lock(&microcode_mutex);
280 microcode_ops->microcode_fini_cpu(cpu);
281 uci->valid = 0;
282 mutex_unlock(&microcode_mutex);
283}
284
285static void collect_cpu_info(int cpu)
286{
287 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
288
289 memset(uci, 0, sizeof(*uci));
290 if (!microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig))
291 uci->valid = 1;
292}
293
294static int microcode_resume_cpu(int cpu)
295{
296 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
297 struct cpu_signature nsig;
298
299 pr_debug("microcode: CPU%d resumed\n", cpu);
300
301 if (!uci->mc)
302 return 1;
303
304 /*
305 * Let's verify that the 'cached' ucode does belong
306 * to this cpu (a bit of paranoia):
307 */
308 if (microcode_ops->collect_cpu_info(cpu, &nsig)) {
309 microcode_fini_cpu(cpu);
310 return -1;
311 }
312
313 if (memcmp(&nsig, &uci->cpu_sig, sizeof(nsig))) {
314 microcode_fini_cpu(cpu);
315 /* Should we look for a new ucode here? */
316 return 1;
317 }
318
319 return 0;
320}
321
322void microcode_update_cpu(int cpu)
323{
324 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
325 int err = 0;
326
327 /*
328 * Check if the system resume is in progress (uci->valid != NULL),
329 * otherwise just request a firmware:
330 */
331 if (uci->valid) {
332 err = microcode_resume_cpu(cpu);
333 } else {
334 collect_cpu_info(cpu);
335 if (uci->valid && system_state == SYSTEM_RUNNING)
336 err = microcode_ops->request_microcode_fw(cpu,
337 &microcode_pdev->dev);
338 }
339 if (!err)
340 microcode_ops->apply_microcode(cpu);
341}
342
343static void microcode_init_cpu(int cpu)
344{
345 cpumask_t old = current->cpus_allowed;
346
347 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
348 /* We should bind the task to the CPU */
349 BUG_ON(raw_smp_processor_id() != cpu);
350
351 mutex_lock(&microcode_mutex);
352 microcode_update_cpu(cpu);
353 mutex_unlock(&microcode_mutex);
354
355 set_cpus_allowed_ptr(current, &old);
356}
357
358static int mc_sysdev_add(struct sys_device *sys_dev)
359{
360 int err, cpu = sys_dev->id;
361 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
362
363 if (!cpu_online(cpu))
364 return 0;
365
366 pr_debug("microcode: CPU%d added\n", cpu);
367 memset(uci, 0, sizeof(*uci));
368
369 err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
370 if (err)
371 return err;
372
373 microcode_init_cpu(cpu);
374 return 0;
375}
376
377static int mc_sysdev_remove(struct sys_device *sys_dev)
378{
379 int cpu = sys_dev->id;
380
381 if (!cpu_online(cpu))
382 return 0;
383
384 pr_debug("microcode: CPU%d removed\n", cpu);
385 microcode_fini_cpu(cpu);
386 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
387 return 0;
388}
389
390static int mc_sysdev_resume(struct sys_device *dev)
391{
392 int cpu = dev->id;
393
394 if (!cpu_online(cpu))
395 return 0;
396
397 /* only CPU 0 will apply ucode here */
398 microcode_update_cpu(0);
399 return 0;
400}
401
402static struct sysdev_driver mc_sysdev_driver = {
403 .add = mc_sysdev_add,
404 .remove = mc_sysdev_remove,
405 .resume = mc_sysdev_resume,
406};
407
408static __cpuinit int
409mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
410{
411 unsigned int cpu = (unsigned long)hcpu;
412 struct sys_device *sys_dev;
413
414 sys_dev = get_cpu_sysdev(cpu);
415 switch (action) {
416 case CPU_ONLINE:
417 case CPU_ONLINE_FROZEN:
418 microcode_init_cpu(cpu);
419 case CPU_DOWN_FAILED:
420 case CPU_DOWN_FAILED_FROZEN:
421 pr_debug("microcode: CPU%d added\n", cpu);
422 if (sysfs_create_group(&sys_dev->kobj, &mc_attr_group))
423 printk(KERN_ERR "microcode: Failed to create the sysfs "
424 "group for CPU%d\n", cpu);
425 break;
426 case CPU_DOWN_PREPARE:
427 case CPU_DOWN_PREPARE_FROZEN:
428 /* Suspend is in progress, only remove the interface */
429 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
430 pr_debug("microcode: CPU%d removed\n", cpu);
431 break;
432 case CPU_DEAD:
433 case CPU_UP_CANCELED_FROZEN:
434 /* The CPU refused to come up during a system resume */
435 microcode_fini_cpu(cpu);
436 break;
437 }
438 return NOTIFY_OK;
439}
440
441static struct notifier_block __refdata mc_cpu_notifier = {
442 .notifier_call = mc_cpu_callback,
443};
444
445static int __init microcode_init(void)
446{
447 struct cpuinfo_x86 *c = &cpu_data(0);
448 int error;
449
450 if (c->x86_vendor == X86_VENDOR_INTEL)
451 microcode_ops = init_intel_microcode();
452 else if (c->x86_vendor == X86_VENDOR_AMD)
453 microcode_ops = init_amd_microcode();
454
455 if (!microcode_ops) {
456 printk(KERN_ERR "microcode: no support for this CPU vendor\n");
457 return -ENODEV;
458 }
459
460 error = microcode_dev_init();
461 if (error)
462 return error;
463 microcode_pdev = platform_device_register_simple("microcode", -1,
464 NULL, 0);
465 if (IS_ERR(microcode_pdev)) {
466 microcode_dev_exit();
467 return PTR_ERR(microcode_pdev);
468 }
469
470 get_online_cpus();
471 error = sysdev_driver_register(&cpu_sysdev_class, &mc_sysdev_driver);
472 put_online_cpus();
473 if (error) {
474 microcode_dev_exit();
475 platform_device_unregister(microcode_pdev);
476 return error;
477 }
478
479 register_hotcpu_notifier(&mc_cpu_notifier);
480
481 printk(KERN_INFO
482 "Microcode Update Driver: v" MICROCODE_VERSION
483 " <tigran@aivazian.fsnet.co.uk>"
484 " <peter.oruba@amd.com>\n");
485
486 return 0;
487}
488
489static void __exit microcode_exit(void)
490{
491 microcode_dev_exit();
492
493 unregister_hotcpu_notifier(&mc_cpu_notifier);
494
495 get_online_cpus();
496 sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver);
497 put_online_cpus();
498
499 platform_device_unregister(microcode_pdev);
500
501 microcode_ops = NULL;
502
503 printk(KERN_INFO
504 "Microcode Update Driver: v" MICROCODE_VERSION " removed.\n");
505}
506
507module_init(microcode_init);
508module_exit(microcode_exit);
diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
new file mode 100644
index 000000000000..622dc4a21784
--- /dev/null
+++ b/arch/x86/kernel/microcode_intel.c
@@ -0,0 +1,480 @@
1/*
2 * Intel CPU Microcode Update Driver for Linux
3 *
4 * Copyright (C) 2000-2006 Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
5 * 2006 Shaohua Li <shaohua.li@intel.com>
6 *
7 * This driver allows to upgrade microcode on Intel processors
8 * belonging to IA-32 family - PentiumPro, Pentium II,
9 * Pentium III, Xeon, Pentium 4, etc.
10 *
11 * Reference: Section 8.11 of Volume 3a, IA-32 Intel? Architecture
12 * Software Developer's Manual
13 * Order Number 253668 or free download from:
14 *
15 * http://developer.intel.com/design/pentium4/manuals/253668.htm
16 *
17 * For more information, go to http://www.urbanmyth.org/microcode
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version
22 * 2 of the License, or (at your option) any later version.
23 *
24 * 1.0 16 Feb 2000, Tigran Aivazian <tigran@sco.com>
25 * Initial release.
26 * 1.01 18 Feb 2000, Tigran Aivazian <tigran@sco.com>
27 * Added read() support + cleanups.
28 * 1.02 21 Feb 2000, Tigran Aivazian <tigran@sco.com>
29 * Added 'device trimming' support. open(O_WRONLY) zeroes
30 * and frees the saved copy of applied microcode.
31 * 1.03 29 Feb 2000, Tigran Aivazian <tigran@sco.com>
32 * Made to use devfs (/dev/cpu/microcode) + cleanups.
33 * 1.04 06 Jun 2000, Simon Trimmer <simon@veritas.com>
34 * Added misc device support (now uses both devfs and misc).
35 * Added MICROCODE_IOCFREE ioctl to clear memory.
36 * 1.05 09 Jun 2000, Simon Trimmer <simon@veritas.com>
37 * Messages for error cases (non Intel & no suitable microcode).
38 * 1.06 03 Aug 2000, Tigran Aivazian <tigran@veritas.com>
39 * Removed ->release(). Removed exclusive open and status bitmap.
40 * Added microcode_rwsem to serialize read()/write()/ioctl().
41 * Removed global kernel lock usage.
42 * 1.07 07 Sep 2000, Tigran Aivazian <tigran@veritas.com>
43 * Write 0 to 0x8B msr and then cpuid before reading revision,
44 * so that it works even if there were no update done by the
45 * BIOS. Otherwise, reading from 0x8B gives junk (which happened
46 * to be 0 on my machine which is why it worked even when I
47 * disabled update by the BIOS)
48 * Thanks to Eric W. Biederman <ebiederman@lnxi.com> for the fix.
49 * 1.08 11 Dec 2000, Richard Schaal <richard.schaal@intel.com> and
50 * Tigran Aivazian <tigran@veritas.com>
51 * Intel Pentium 4 processor support and bugfixes.
52 * 1.09 30 Oct 2001, Tigran Aivazian <tigran@veritas.com>
53 * Bugfix for HT (Hyper-Threading) enabled processors
54 * whereby processor resources are shared by all logical processors
55 * in a single CPU package.
56 * 1.10 28 Feb 2002 Asit K Mallick <asit.k.mallick@intel.com> and
57 * Tigran Aivazian <tigran@veritas.com>,
58 * Serialize updates as required on HT processors due to
59 * speculative nature of implementation.
60 * 1.11 22 Mar 2002 Tigran Aivazian <tigran@veritas.com>
61 * Fix the panic when writing zero-length microcode chunk.
62 * 1.12 29 Sep 2003 Nitin Kamble <nitin.a.kamble@intel.com>,
63 * Jun Nakajima <jun.nakajima@intel.com>
64 * Support for the microcode updates in the new format.
65 * 1.13 10 Oct 2003 Tigran Aivazian <tigran@veritas.com>
66 * Removed ->read() method and obsoleted MICROCODE_IOCFREE ioctl
67 * because we no longer hold a copy of applied microcode
68 * in kernel memory.
69 * 1.14 25 Jun 2004 Tigran Aivazian <tigran@veritas.com>
70 * Fix sigmatch() macro to handle old CPUs with pf == 0.
71 * Thanks to Stuart Swales for pointing out this bug.
72 */
73#include <linux/capability.h>
74#include <linux/kernel.h>
75#include <linux/init.h>
76#include <linux/sched.h>
77#include <linux/smp_lock.h>
78#include <linux/cpumask.h>
79#include <linux/module.h>
80#include <linux/slab.h>
81#include <linux/vmalloc.h>
82#include <linux/miscdevice.h>
83#include <linux/spinlock.h>
84#include <linux/mm.h>
85#include <linux/fs.h>
86#include <linux/mutex.h>
87#include <linux/cpu.h>
88#include <linux/firmware.h>
89#include <linux/platform_device.h>
90
91#include <asm/msr.h>
92#include <asm/uaccess.h>
93#include <asm/processor.h>
94#include <asm/microcode.h>
95
96MODULE_DESCRIPTION("Microcode Update Driver");
97MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");
98MODULE_LICENSE("GPL");
99
100struct microcode_header_intel {
101 unsigned int hdrver;
102 unsigned int rev;
103 unsigned int date;
104 unsigned int sig;
105 unsigned int cksum;
106 unsigned int ldrver;
107 unsigned int pf;
108 unsigned int datasize;
109 unsigned int totalsize;
110 unsigned int reserved[3];
111};
112
113struct microcode_intel {
114 struct microcode_header_intel hdr;
115 unsigned int bits[0];
116};
117
118/* microcode format is extended from prescott processors */
119struct extended_signature {
120 unsigned int sig;
121 unsigned int pf;
122 unsigned int cksum;
123};
124
125struct extended_sigtable {
126 unsigned int count;
127 unsigned int cksum;
128 unsigned int reserved[3];
129 struct extended_signature sigs[0];
130};
131
132#define DEFAULT_UCODE_DATASIZE (2000)
133#define MC_HEADER_SIZE (sizeof(struct microcode_header_intel))
134#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE)
135#define EXT_HEADER_SIZE (sizeof(struct extended_sigtable))
136#define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature))
137#define DWSIZE (sizeof(u32))
138#define get_totalsize(mc) \
139 (((struct microcode_intel *)mc)->hdr.totalsize ? \
140 ((struct microcode_intel *)mc)->hdr.totalsize : \
141 DEFAULT_UCODE_TOTALSIZE)
142
143#define get_datasize(mc) \
144 (((struct microcode_intel *)mc)->hdr.datasize ? \
145 ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)
146
147#define sigmatch(s1, s2, p1, p2) \
148 (((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0))))
149
150#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE)
151
152/* serialize access to the physical write to MSR 0x79 */
153static DEFINE_SPINLOCK(microcode_update_lock);
154
155static int collect_cpu_info(int cpu_num, struct cpu_signature *csig)
156{
157 struct cpuinfo_x86 *c = &cpu_data(cpu_num);
158 unsigned int val[2];
159
160 memset(csig, 0, sizeof(*csig));
161
162 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
163 cpu_has(c, X86_FEATURE_IA64)) {
164 printk(KERN_ERR "microcode: CPU%d not a capable Intel "
165 "processor\n", cpu_num);
166 return -1;
167 }
168
169 csig->sig = cpuid_eax(0x00000001);
170
171 if ((c->x86_model >= 5) || (c->x86 > 6)) {
172 /* get processor flags from MSR 0x17 */
173 rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
174 csig->pf = 1 << ((val[1] >> 18) & 7);
175 }
176
177 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
178 /* see notes above for revision 1.07. Apparent chip bug */
179 sync_core();
180 /* get the current revision from MSR 0x8B */
181 rdmsr(MSR_IA32_UCODE_REV, val[0], csig->rev);
182 pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
183 csig->sig, csig->pf, csig->rev);
184
185 return 0;
186}
187
188static inline int update_match_cpu(struct cpu_signature *csig, int sig, int pf)
189{
190 return (!sigmatch(sig, csig->sig, pf, csig->pf)) ? 0 : 1;
191}
192
193static inline int
194update_match_revision(struct microcode_header_intel *mc_header, int rev)
195{
196 return (mc_header->rev <= rev) ? 0 : 1;
197}
198
199static int microcode_sanity_check(void *mc)
200{
201 struct microcode_header_intel *mc_header = mc;
202 struct extended_sigtable *ext_header = NULL;
203 struct extended_signature *ext_sig;
204 unsigned long total_size, data_size, ext_table_size;
205 int sum, orig_sum, ext_sigcount = 0, i;
206
207 total_size = get_totalsize(mc_header);
208 data_size = get_datasize(mc_header);
209 if (data_size + MC_HEADER_SIZE > total_size) {
210 printk(KERN_ERR "microcode: error! "
211 "Bad data size in microcode data file\n");
212 return -EINVAL;
213 }
214
215 if (mc_header->ldrver != 1 || mc_header->hdrver != 1) {
216 printk(KERN_ERR "microcode: error! "
217 "Unknown microcode update format\n");
218 return -EINVAL;
219 }
220 ext_table_size = total_size - (MC_HEADER_SIZE + data_size);
221 if (ext_table_size) {
222 if ((ext_table_size < EXT_HEADER_SIZE)
223 || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) {
224 printk(KERN_ERR "microcode: error! "
225 "Small exttable size in microcode data file\n");
226 return -EINVAL;
227 }
228 ext_header = mc + MC_HEADER_SIZE + data_size;
229 if (ext_table_size != exttable_size(ext_header)) {
230 printk(KERN_ERR "microcode: error! "
231 "Bad exttable size in microcode data file\n");
232 return -EFAULT;
233 }
234 ext_sigcount = ext_header->count;
235 }
236
237 /* check extended table checksum */
238 if (ext_table_size) {
239 int ext_table_sum = 0;
240 int *ext_tablep = (int *)ext_header;
241
242 i = ext_table_size / DWSIZE;
243 while (i--)
244 ext_table_sum += ext_tablep[i];
245 if (ext_table_sum) {
246 printk(KERN_WARNING "microcode: aborting, "
247 "bad extended signature table checksum\n");
248 return -EINVAL;
249 }
250 }
251
252 /* calculate the checksum */
253 orig_sum = 0;
254 i = (MC_HEADER_SIZE + data_size) / DWSIZE;
255 while (i--)
256 orig_sum += ((int *)mc)[i];
257 if (orig_sum) {
258 printk(KERN_ERR "microcode: aborting, bad checksum\n");
259 return -EINVAL;
260 }
261 if (!ext_table_size)
262 return 0;
263 /* check extended signature checksum */
264 for (i = 0; i < ext_sigcount; i++) {
265 ext_sig = (void *)ext_header + EXT_HEADER_SIZE +
266 EXT_SIGNATURE_SIZE * i;
267 sum = orig_sum
268 - (mc_header->sig + mc_header->pf + mc_header->cksum)
269 + (ext_sig->sig + ext_sig->pf + ext_sig->cksum);
270 if (sum) {
271 printk(KERN_ERR "microcode: aborting, bad checksum\n");
272 return -EINVAL;
273 }
274 }
275 return 0;
276}
277
278/*
279 * return 0 - no update found
280 * return 1 - found update
281 */
282static int
283get_matching_microcode(struct cpu_signature *cpu_sig, void *mc, int rev)
284{
285 struct microcode_header_intel *mc_header = mc;
286 struct extended_sigtable *ext_header;
287 unsigned long total_size = get_totalsize(mc_header);
288 int ext_sigcount, i;
289 struct extended_signature *ext_sig;
290
291 if (!update_match_revision(mc_header, rev))
292 return 0;
293
294 if (update_match_cpu(cpu_sig, mc_header->sig, mc_header->pf))
295 return 1;
296
297 /* Look for ext. headers: */
298 if (total_size <= get_datasize(mc_header) + MC_HEADER_SIZE)
299 return 0;
300
301 ext_header = mc + get_datasize(mc_header) + MC_HEADER_SIZE;
302 ext_sigcount = ext_header->count;
303 ext_sig = (void *)ext_header + EXT_HEADER_SIZE;
304
305 for (i = 0; i < ext_sigcount; i++) {
306 if (update_match_cpu(cpu_sig, ext_sig->sig, ext_sig->pf))
307 return 1;
308 ext_sig++;
309 }
310 return 0;
311}
312
313static void apply_microcode(int cpu)
314{
315 unsigned long flags;
316 unsigned int val[2];
317 int cpu_num = raw_smp_processor_id();
318 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
319 struct microcode_intel *mc_intel = uci->mc;
320
321 /* We should bind the task to the CPU */
322 BUG_ON(cpu_num != cpu);
323
324 if (mc_intel == NULL)
325 return;
326
327 /* serialize access to the physical write to MSR 0x79 */
328 spin_lock_irqsave(&microcode_update_lock, flags);
329
330 /* write microcode via MSR 0x79 */
331 wrmsr(MSR_IA32_UCODE_WRITE,
332 (unsigned long) mc_intel->bits,
333 (unsigned long) mc_intel->bits >> 16 >> 16);
334 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
335
336 /* see notes above for revision 1.07. Apparent chip bug */
337 sync_core();
338
339 /* get the current revision from MSR 0x8B */
340 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
341
342 spin_unlock_irqrestore(&microcode_update_lock, flags);
343 if (val[1] != mc_intel->hdr.rev) {
344 printk(KERN_ERR "microcode: CPU%d update from revision "
345 "0x%x to 0x%x failed\n", cpu_num, uci->cpu_sig.rev, val[1]);
346 return;
347 }
348 printk(KERN_INFO "microcode: CPU%d updated from revision "
349 "0x%x to 0x%x, date = %04x-%02x-%02x \n",
350 cpu_num, uci->cpu_sig.rev, val[1],
351 mc_intel->hdr.date & 0xffff,
352 mc_intel->hdr.date >> 24,
353 (mc_intel->hdr.date >> 16) & 0xff);
354 uci->cpu_sig.rev = val[1];
355}
356
357static int generic_load_microcode(int cpu, void *data, size_t size,
358 int (*get_ucode_data)(void *, const void *, size_t))
359{
360 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
361 u8 *ucode_ptr = data, *new_mc = NULL, *mc;
362 int new_rev = uci->cpu_sig.rev;
363 unsigned int leftover = size;
364
365 while (leftover) {
366 struct microcode_header_intel mc_header;
367 unsigned int mc_size;
368
369 if (get_ucode_data(&mc_header, ucode_ptr, sizeof(mc_header)))
370 break;
371
372 mc_size = get_totalsize(&mc_header);
373 if (!mc_size || mc_size > leftover) {
374 printk(KERN_ERR "microcode: error!"
375 "Bad data in microcode data file\n");
376 break;
377 }
378
379 mc = vmalloc(mc_size);
380 if (!mc)
381 break;
382
383 if (get_ucode_data(mc, ucode_ptr, mc_size) ||
384 microcode_sanity_check(mc) < 0) {
385 vfree(mc);
386 break;
387 }
388
389 if (get_matching_microcode(&uci->cpu_sig, mc, new_rev)) {
390 if (new_mc)
391 vfree(new_mc);
392 new_rev = mc_header.rev;
393 new_mc = mc;
394 } else
395 vfree(mc);
396
397 ucode_ptr += mc_size;
398 leftover -= mc_size;
399 }
400
401 if (new_mc) {
402 if (!leftover) {
403 if (uci->mc)
404 vfree(uci->mc);
405 uci->mc = (struct microcode_intel *)new_mc;
406 pr_debug("microcode: CPU%d found a matching microcode update with"
407 " version 0x%x (current=0x%x)\n",
408 cpu, new_rev, uci->cpu_sig.rev);
409 } else
410 vfree(new_mc);
411 }
412
413 return (int)leftover;
414}
415
416static int get_ucode_fw(void *to, const void *from, size_t n)
417{
418 memcpy(to, from, n);
419 return 0;
420}
421
422static int request_microcode_fw(int cpu, struct device *device)
423{
424 char name[30];
425 struct cpuinfo_x86 *c = &cpu_data(cpu);
426 const struct firmware *firmware;
427 int ret;
428
429 /* We should bind the task to the CPU */
430 BUG_ON(cpu != raw_smp_processor_id());
431 sprintf(name, "intel-ucode/%02x-%02x-%02x",
432 c->x86, c->x86_model, c->x86_mask);
433 ret = request_firmware(&firmware, name, device);
434 if (ret) {
435 pr_debug("microcode: data file %s load failed\n", name);
436 return ret;
437 }
438
439 ret = generic_load_microcode(cpu, (void*)firmware->data, firmware->size,
440 &get_ucode_fw);
441
442 release_firmware(firmware);
443
444 return ret;
445}
446
447static int get_ucode_user(void *to, const void *from, size_t n)
448{
449 return copy_from_user(to, from, n);
450}
451
452static int request_microcode_user(int cpu, const void __user *buf, size_t size)
453{
454 /* We should bind the task to the CPU */
455 BUG_ON(cpu != raw_smp_processor_id());
456
457 return generic_load_microcode(cpu, (void*)buf, size, &get_ucode_user);
458}
459
460static void microcode_fini_cpu(int cpu)
461{
462 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
463
464 vfree(uci->mc);
465 uci->mc = NULL;
466}
467
468struct microcode_ops microcode_intel_ops = {
469 .request_microcode_user = request_microcode_user,
470 .request_microcode_fw = request_microcode_fw,
471 .collect_cpu_info = collect_cpu_info,
472 .apply_microcode = apply_microcode,
473 .microcode_fini_cpu = microcode_fini_cpu,
474};
475
476struct microcode_ops * __init init_intel_microcode(void)
477{
478 return &microcode_intel_ops;
479}
480
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index b3fb430725cb..f98f4e1dba09 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -397,7 +397,9 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
397 generic_bigsmp_probe(); 397 generic_bigsmp_probe();
398#endif 398#endif
399 399
400#ifdef CONFIG_X86_32
400 setup_apic_routing(); 401 setup_apic_routing();
402#endif
401 if (!num_processors) 403 if (!num_processors)
402 printk(KERN_ERR "MPTABLE: no processors registered!\n"); 404 printk(KERN_ERR "MPTABLE: no processors registered!\n");
403 return num_processors; 405 return num_processors;
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index abb78a2cc4ad..2c97f07f1c2c 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -299,6 +299,15 @@ void acpi_nmi_disable(void)
299 on_each_cpu(__acpi_nmi_disable, NULL, 1); 299 on_each_cpu(__acpi_nmi_disable, NULL, 1);
300} 300}
301 301
302/*
303 * This function is called as soon the LAPIC NMI watchdog driver has everything
304 * in place and it's ready to check if the NMIs belong to the NMI watchdog
305 */
306void cpu_nmi_set_wd_enabled(void)
307{
308 __get_cpu_var(wd_enabled) = 1;
309}
310
302void setup_apic_nmi_watchdog(void *unused) 311void setup_apic_nmi_watchdog(void *unused)
303{ 312{
304 if (__get_cpu_var(wd_enabled)) 313 if (__get_cpu_var(wd_enabled))
@@ -311,8 +320,6 @@ void setup_apic_nmi_watchdog(void *unused)
311 320
312 switch (nmi_watchdog) { 321 switch (nmi_watchdog) {
313 case NMI_LOCAL_APIC: 322 case NMI_LOCAL_APIC:
314 /* enable it before to avoid race with handler */
315 __get_cpu_var(wd_enabled) = 1;
316 if (lapic_watchdog_init(nmi_hz) < 0) { 323 if (lapic_watchdog_init(nmi_hz) < 0) {
317 __get_cpu_var(wd_enabled) = 0; 324 __get_cpu_var(wd_enabled) = 0;
318 return; 325 return;
diff --git a/arch/x86/kernel/numaq_32.c b/arch/x86/kernel/numaq_32.c
index eecc8c18f010..4caff39078e0 100644
--- a/arch/x86/kernel/numaq_32.c
+++ b/arch/x86/kernel/numaq_32.c
@@ -229,6 +229,12 @@ static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable,
229 } 229 }
230} 230}
231 231
232static int __init numaq_setup_ioapic_ids(void)
233{
234 /* so can skip it */
235 return 1;
236}
237
232static struct x86_quirks numaq_x86_quirks __initdata = { 238static struct x86_quirks numaq_x86_quirks __initdata = {
233 .arch_pre_time_init = numaq_pre_time_init, 239 .arch_pre_time_init = numaq_pre_time_init,
234 .arch_time_init = NULL, 240 .arch_time_init = NULL,
@@ -243,6 +249,7 @@ static struct x86_quirks numaq_x86_quirks __initdata = {
243 .mpc_oem_bus_info = mpc_oem_bus_info, 249 .mpc_oem_bus_info = mpc_oem_bus_info,
244 .mpc_oem_pci_bus = mpc_oem_pci_bus, 250 .mpc_oem_pci_bus = mpc_oem_pci_bus,
245 .smp_read_mpc_oem = smp_read_mpc_oem, 251 .smp_read_mpc_oem = smp_read_mpc_oem,
252 .setup_ioapic_ids = numaq_setup_ioapic_ids,
246}; 253};
247 254
248void numaq_mps_oem_check(struct mp_config_table *mpc, char *oem, 255void numaq_mps_oem_check(struct mp_config_table *mpc, char *oem,
diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c
index 3e6672274807..7a13fac63a1f 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/kernel/olpc.c
@@ -190,12 +190,12 @@ EXPORT_SYMBOL_GPL(olpc_ec_cmd);
190static void __init platform_detect(void) 190static void __init platform_detect(void)
191{ 191{
192 size_t propsize; 192 size_t propsize;
193 u32 rev; 193 __be32 rev;
194 194
195 if (ofw("getprop", 4, 1, NULL, "board-revision-int", &rev, 4, 195 if (ofw("getprop", 4, 1, NULL, "board-revision-int", &rev, 4,
196 &propsize) || propsize != 4) { 196 &propsize) || propsize != 4) {
197 printk(KERN_ERR "ofw: getprop call failed!\n"); 197 printk(KERN_ERR "ofw: getprop call failed!\n");
198 rev = 0; 198 rev = cpu_to_be32(0);
199 } 199 }
200 olpc_platform_info.boardrev = be32_to_cpu(rev); 200 olpc_platform_info.boardrev = be32_to_cpu(rev);
201} 201}
@@ -203,7 +203,7 @@ static void __init platform_detect(void)
203static void __init platform_detect(void) 203static void __init platform_detect(void)
204{ 204{
205 /* stopgap until OFW support is added to the kernel */ 205 /* stopgap until OFW support is added to the kernel */
206 olpc_platform_info.boardrev = be32_to_cpu(0xc2); 206 olpc_platform_info.boardrev = 0xc2;
207} 207}
208#endif 208#endif
209 209
diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
new file mode 100644
index 000000000000..0e9f1982b1dd
--- /dev/null
+++ b/arch/x86/kernel/paravirt-spinlocks.c
@@ -0,0 +1,37 @@
1/*
2 * Split spinlock implementation out into its own file, so it can be
3 * compiled in a FTRACE-compatible way.
4 */
5#include <linux/spinlock.h>
6#include <linux/module.h>
7
8#include <asm/paravirt.h>
9
10static void default_spin_lock_flags(struct raw_spinlock *lock, unsigned long flags)
11{
12 __raw_spin_lock(lock);
13}
14
15struct pv_lock_ops pv_lock_ops = {
16#ifdef CONFIG_SMP
17 .spin_is_locked = __ticket_spin_is_locked,
18 .spin_is_contended = __ticket_spin_is_contended,
19
20 .spin_lock = __ticket_spin_lock,
21 .spin_lock_flags = default_spin_lock_flags,
22 .spin_trylock = __ticket_spin_trylock,
23 .spin_unlock = __ticket_spin_unlock,
24#endif
25};
26EXPORT_SYMBOL(pv_lock_ops);
27
28void __init paravirt_use_bytelocks(void)
29{
30#ifdef CONFIG_SMP
31 pv_lock_ops.spin_is_locked = __byte_spin_is_locked;
32 pv_lock_ops.spin_is_contended = __byte_spin_is_contended;
33 pv_lock_ops.spin_lock = __byte_spin_lock;
34 pv_lock_ops.spin_trylock = __byte_spin_trylock;
35 pv_lock_ops.spin_unlock = __byte_spin_unlock;
36#endif
37}
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 300da17e61cb..e4c8fb608873 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -268,17 +268,6 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
268 return __get_cpu_var(paravirt_lazy_mode); 268 return __get_cpu_var(paravirt_lazy_mode);
269} 269}
270 270
271void __init paravirt_use_bytelocks(void)
272{
273#ifdef CONFIG_SMP
274 pv_lock_ops.spin_is_locked = __byte_spin_is_locked;
275 pv_lock_ops.spin_is_contended = __byte_spin_is_contended;
276 pv_lock_ops.spin_lock = __byte_spin_lock;
277 pv_lock_ops.spin_trylock = __byte_spin_trylock;
278 pv_lock_ops.spin_unlock = __byte_spin_unlock;
279#endif
280}
281
282struct pv_info pv_info = { 271struct pv_info pv_info = {
283 .name = "bare hardware", 272 .name = "bare hardware",
284 .paravirt_enabled = 0, 273 .paravirt_enabled = 0,
@@ -330,6 +319,7 @@ struct pv_cpu_ops pv_cpu_ops = {
330#endif 319#endif
331 .wbinvd = native_wbinvd, 320 .wbinvd = native_wbinvd,
332 .read_msr = native_read_msr_safe, 321 .read_msr = native_read_msr_safe,
322 .read_msr_amd = native_read_msr_amd_safe,
333 .write_msr = native_write_msr_safe, 323 .write_msr = native_write_msr_safe,
334 .read_tsc = native_read_tsc, 324 .read_tsc = native_read_tsc,
335 .read_pmc = native_read_pmc, 325 .read_pmc = native_read_pmc,
@@ -348,6 +338,10 @@ struct pv_cpu_ops pv_cpu_ops = {
348 .write_ldt_entry = native_write_ldt_entry, 338 .write_ldt_entry = native_write_ldt_entry,
349 .write_gdt_entry = native_write_gdt_entry, 339 .write_gdt_entry = native_write_gdt_entry,
350 .write_idt_entry = native_write_idt_entry, 340 .write_idt_entry = native_write_idt_entry,
341
342 .alloc_ldt = paravirt_nop,
343 .free_ldt = paravirt_nop,
344
351 .load_sp0 = native_load_sp0, 345 .load_sp0 = native_load_sp0,
352 346
353#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) 347#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
@@ -373,8 +367,6 @@ struct pv_cpu_ops pv_cpu_ops = {
373 367
374struct pv_apic_ops pv_apic_ops = { 368struct pv_apic_ops pv_apic_ops = {
375#ifdef CONFIG_X86_LOCAL_APIC 369#ifdef CONFIG_X86_LOCAL_APIC
376 .apic_write = native_apic_write,
377 .apic_read = native_apic_read,
378 .setup_boot_clock = setup_boot_APIC_clock, 370 .setup_boot_clock = setup_boot_APIC_clock,
379 .setup_secondary_clock = setup_secondary_APIC_clock, 371 .setup_secondary_clock = setup_secondary_APIC_clock,
380 .startup_ipi_hook = paravirt_nop, 372 .startup_ipi_hook = paravirt_nop,
@@ -461,18 +453,6 @@ struct pv_mmu_ops pv_mmu_ops = {
461 .set_fixmap = native_set_fixmap, 453 .set_fixmap = native_set_fixmap,
462}; 454};
463 455
464struct pv_lock_ops pv_lock_ops = {
465#ifdef CONFIG_SMP
466 .spin_is_locked = __ticket_spin_is_locked,
467 .spin_is_contended = __ticket_spin_is_contended,
468
469 .spin_lock = __ticket_spin_lock,
470 .spin_trylock = __ticket_spin_trylock,
471 .spin_unlock = __ticket_spin_unlock,
472#endif
473};
474EXPORT_SYMBOL(pv_lock_ops);
475
476EXPORT_SYMBOL_GPL(pv_time_ops); 456EXPORT_SYMBOL_GPL(pv_time_ops);
477EXPORT_SYMBOL (pv_cpu_ops); 457EXPORT_SYMBOL (pv_cpu_ops);
478EXPORT_SYMBOL (pv_mmu_ops); 458EXPORT_SYMBOL (pv_mmu_ops);
diff --git a/arch/x86/kernel/paravirt_patch_32.c b/arch/x86/kernel/paravirt_patch_32.c
index 58262218781b..9fe644f4861d 100644
--- a/arch/x86/kernel/paravirt_patch_32.c
+++ b/arch/x86/kernel/paravirt_patch_32.c
@@ -23,7 +23,7 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
23 start = start_##ops##_##x; \ 23 start = start_##ops##_##x; \
24 end = end_##ops##_##x; \ 24 end = end_##ops##_##x; \
25 goto patch_site 25 goto patch_site
26 switch(type) { 26 switch (type) {
27 PATCH_SITE(pv_irq_ops, irq_disable); 27 PATCH_SITE(pv_irq_ops, irq_disable);
28 PATCH_SITE(pv_irq_ops, irq_enable); 28 PATCH_SITE(pv_irq_ops, irq_enable);
29 PATCH_SITE(pv_irq_ops, restore_fl); 29 PATCH_SITE(pv_irq_ops, restore_fl);
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index dcdac6c826e9..080d1d27f37a 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -261,7 +261,7 @@ static void iommu_range_reserve(struct iommu_table *tbl,
261 badbit, tbl, start_addr, npages); 261 badbit, tbl, start_addr, npages);
262 } 262 }
263 263
264 set_bit_string(tbl->it_map, index, npages); 264 iommu_area_reserve(tbl->it_map, index, npages);
265 265
266 spin_unlock_irqrestore(&tbl->it_lock, flags); 266 spin_unlock_irqrestore(&tbl->it_lock, flags);
267} 267}
@@ -491,6 +491,8 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size,
491 npages = size >> PAGE_SHIFT; 491 npages = size >> PAGE_SHIFT;
492 order = get_order(size); 492 order = get_order(size);
493 493
494 flag &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
495
494 /* alloc enough pages (and possibly more) */ 496 /* alloc enough pages (and possibly more) */
495 ret = (void *)__get_free_pages(flag, order); 497 ret = (void *)__get_free_pages(flag, order);
496 if (!ret) 498 if (!ret)
@@ -510,8 +512,22 @@ error:
510 return ret; 512 return ret;
511} 513}
512 514
515static void calgary_free_coherent(struct device *dev, size_t size,
516 void *vaddr, dma_addr_t dma_handle)
517{
518 unsigned int npages;
519 struct iommu_table *tbl = find_iommu_table(dev);
520
521 size = PAGE_ALIGN(size);
522 npages = size >> PAGE_SHIFT;
523
524 iommu_free(tbl, dma_handle, npages);
525 free_pages((unsigned long)vaddr, get_order(size));
526}
527
513static struct dma_mapping_ops calgary_dma_ops = { 528static struct dma_mapping_ops calgary_dma_ops = {
514 .alloc_coherent = calgary_alloc_coherent, 529 .alloc_coherent = calgary_alloc_coherent,
530 .free_coherent = calgary_free_coherent,
515 .map_single = calgary_map_single, 531 .map_single = calgary_map_single,
516 .unmap_single = calgary_unmap_single, 532 .unmap_single = calgary_unmap_single,
517 .map_sg = calgary_map_sg, 533 .map_sg = calgary_map_sg,
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 87d4d6964ec2..0a3824e837b4 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -41,11 +41,12 @@ EXPORT_SYMBOL(bad_dma_address);
41/* Dummy device used for NULL arguments (normally ISA). Better would 41/* Dummy device used for NULL arguments (normally ISA). Better would
42 be probably a smaller DMA mask, but this is bug-to-bug compatible 42 be probably a smaller DMA mask, but this is bug-to-bug compatible
43 to older i386. */ 43 to older i386. */
44struct device fallback_dev = { 44struct device x86_dma_fallback_dev = {
45 .bus_id = "fallback device", 45 .bus_id = "fallback device",
46 .coherent_dma_mask = DMA_32BIT_MASK, 46 .coherent_dma_mask = DMA_32BIT_MASK,
47 .dma_mask = &fallback_dev.coherent_dma_mask, 47 .dma_mask = &x86_dma_fallback_dev.coherent_dma_mask,
48}; 48};
49EXPORT_SYMBOL(x86_dma_fallback_dev);
49 50
50int dma_set_mask(struct device *dev, u64 mask) 51int dma_set_mask(struct device *dev, u64 mask)
51{ 52{
@@ -82,7 +83,7 @@ void __init dma32_reserve_bootmem(void)
82 * using 512M as goal 83 * using 512M as goal
83 */ 84 */
84 align = 64ULL<<20; 85 align = 64ULL<<20;
85 size = round_up(dma32_bootmem_size, align); 86 size = roundup(dma32_bootmem_size, align);
86 dma32_bootmem_ptr = __alloc_bootmem_nopanic(size, align, 87 dma32_bootmem_ptr = __alloc_bootmem_nopanic(size, align,
87 512ULL<<20); 88 512ULL<<20);
88 if (dma32_bootmem_ptr) 89 if (dma32_bootmem_ptr)
@@ -133,6 +134,37 @@ unsigned long iommu_num_pages(unsigned long addr, unsigned long len)
133EXPORT_SYMBOL(iommu_num_pages); 134EXPORT_SYMBOL(iommu_num_pages);
134#endif 135#endif
135 136
137void *dma_generic_alloc_coherent(struct device *dev, size_t size,
138 dma_addr_t *dma_addr, gfp_t flag)
139{
140 unsigned long dma_mask;
141 struct page *page;
142 dma_addr_t addr;
143
144 dma_mask = dma_alloc_coherent_mask(dev, flag);
145
146 flag |= __GFP_ZERO;
147again:
148 page = alloc_pages_node(dev_to_node(dev), flag, get_order(size));
149 if (!page)
150 return NULL;
151
152 addr = page_to_phys(page);
153 if (!is_buffer_dma_capable(dma_mask, addr, size)) {
154 __free_pages(page, get_order(size));
155
156 if (dma_mask < DMA_32BIT_MASK && !(flag & GFP_DMA)) {
157 flag = (flag & ~GFP_DMA32) | GFP_DMA;
158 goto again;
159 }
160
161 return NULL;
162 }
163
164 *dma_addr = addr;
165 return page_address(page);
166}
167
136/* 168/*
137 * See <Documentation/x86_64/boot-options.txt> for the iommu kernel parameter 169 * See <Documentation/x86_64/boot-options.txt> for the iommu kernel parameter
138 * documentation. 170 * documentation.
@@ -241,147 +273,6 @@ int dma_supported(struct device *dev, u64 mask)
241} 273}
242EXPORT_SYMBOL(dma_supported); 274EXPORT_SYMBOL(dma_supported);
243 275
244/* Allocate DMA memory on node near device */
245static noinline struct page *
246dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
247{
248 int node;
249
250 node = dev_to_node(dev);
251
252 return alloc_pages_node(node, gfp, order);
253}
254
255/*
256 * Allocate memory for a coherent mapping.
257 */
258void *
259dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
260 gfp_t gfp)
261{
262 struct dma_mapping_ops *ops = get_dma_ops(dev);
263 void *memory = NULL;
264 struct page *page;
265 unsigned long dma_mask = 0;
266 dma_addr_t bus;
267 int noretry = 0;
268
269 /* ignore region specifiers */
270 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
271
272 if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
273 return memory;
274
275 if (!dev) {
276 dev = &fallback_dev;
277 gfp |= GFP_DMA;
278 }
279 dma_mask = dev->coherent_dma_mask;
280 if (dma_mask == 0)
281 dma_mask = (gfp & GFP_DMA) ? DMA_24BIT_MASK : DMA_32BIT_MASK;
282
283 /* Device not DMA able */
284 if (dev->dma_mask == NULL)
285 return NULL;
286
287 /* Don't invoke OOM killer or retry in lower 16MB DMA zone */
288 if (gfp & __GFP_DMA)
289 noretry = 1;
290
291#ifdef CONFIG_X86_64
292 /* Why <=? Even when the mask is smaller than 4GB it is often
293 larger than 16MB and in this case we have a chance of
294 finding fitting memory in the next higher zone first. If
295 not retry with true GFP_DMA. -AK */
296 if (dma_mask <= DMA_32BIT_MASK && !(gfp & GFP_DMA)) {
297 gfp |= GFP_DMA32;
298 if (dma_mask < DMA_32BIT_MASK)
299 noretry = 1;
300 }
301#endif
302
303 again:
304 page = dma_alloc_pages(dev,
305 noretry ? gfp | __GFP_NORETRY : gfp, get_order(size));
306 if (page == NULL)
307 return NULL;
308
309 {
310 int high, mmu;
311 bus = page_to_phys(page);
312 memory = page_address(page);
313 high = (bus + size) >= dma_mask;
314 mmu = high;
315 if (force_iommu && !(gfp & GFP_DMA))
316 mmu = 1;
317 else if (high) {
318 free_pages((unsigned long)memory,
319 get_order(size));
320
321 /* Don't use the 16MB ZONE_DMA unless absolutely
322 needed. It's better to use remapping first. */
323 if (dma_mask < DMA_32BIT_MASK && !(gfp & GFP_DMA)) {
324 gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
325 goto again;
326 }
327
328 /* Let low level make its own zone decisions */
329 gfp &= ~(GFP_DMA32|GFP_DMA);
330
331 if (ops->alloc_coherent)
332 return ops->alloc_coherent(dev, size,
333 dma_handle, gfp);
334 return NULL;
335 }
336
337 memset(memory, 0, size);
338 if (!mmu) {
339 *dma_handle = bus;
340 return memory;
341 }
342 }
343
344 if (ops->alloc_coherent) {
345 free_pages((unsigned long)memory, get_order(size));
346 gfp &= ~(GFP_DMA|GFP_DMA32);
347 return ops->alloc_coherent(dev, size, dma_handle, gfp);
348 }
349
350 if (ops->map_simple) {
351 *dma_handle = ops->map_simple(dev, virt_to_phys(memory),
352 size,
353 PCI_DMA_BIDIRECTIONAL);
354 if (*dma_handle != bad_dma_address)
355 return memory;
356 }
357
358 if (panic_on_overflow)
359 panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",
360 (unsigned long)size);
361 free_pages((unsigned long)memory, get_order(size));
362 return NULL;
363}
364EXPORT_SYMBOL(dma_alloc_coherent);
365
366/*
367 * Unmap coherent memory.
368 * The caller must ensure that the device has finished accessing the mapping.
369 */
370void dma_free_coherent(struct device *dev, size_t size,
371 void *vaddr, dma_addr_t bus)
372{
373 struct dma_mapping_ops *ops = get_dma_ops(dev);
374
375 int order = get_order(size);
376 WARN_ON(irqs_disabled()); /* for portability */
377 if (dma_release_from_coherent(dev, order, vaddr))
378 return;
379 if (ops->unmap_single)
380 ops->unmap_single(dev, bus, size, 0);
381 free_pages((unsigned long)vaddr, order);
382}
383EXPORT_SYMBOL(dma_free_coherent);
384
385static int __init pci_iommu_init(void) 276static int __init pci_iommu_init(void)
386{ 277{
387 calgary_iommu_init(); 278 calgary_iommu_init();
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 49285f8fd4d5..145f1c83369f 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -27,8 +27,8 @@
27#include <linux/scatterlist.h> 27#include <linux/scatterlist.h>
28#include <linux/iommu-helper.h> 28#include <linux/iommu-helper.h>
29#include <linux/sysdev.h> 29#include <linux/sysdev.h>
30#include <linux/io.h>
30#include <asm/atomic.h> 31#include <asm/atomic.h>
31#include <asm/io.h>
32#include <asm/mtrr.h> 32#include <asm/mtrr.h>
33#include <asm/pgtable.h> 33#include <asm/pgtable.h>
34#include <asm/proto.h> 34#include <asm/proto.h>
@@ -80,9 +80,10 @@ AGPEXTERN int agp_memory_reserved;
80AGPEXTERN __u32 *agp_gatt_table; 80AGPEXTERN __u32 *agp_gatt_table;
81 81
82static unsigned long next_bit; /* protected by iommu_bitmap_lock */ 82static unsigned long next_bit; /* protected by iommu_bitmap_lock */
83static int need_flush; /* global flush state. set for each gart wrap */ 83static bool need_flush; /* global flush state. set for each gart wrap */
84 84
85static unsigned long alloc_iommu(struct device *dev, int size) 85static unsigned long alloc_iommu(struct device *dev, int size,
86 unsigned long align_mask)
86{ 87{
87 unsigned long offset, flags; 88 unsigned long offset, flags;
88 unsigned long boundary_size; 89 unsigned long boundary_size;
@@ -90,26 +91,27 @@ static unsigned long alloc_iommu(struct device *dev, int size)
90 91
91 base_index = ALIGN(iommu_bus_base & dma_get_seg_boundary(dev), 92 base_index = ALIGN(iommu_bus_base & dma_get_seg_boundary(dev),
92 PAGE_SIZE) >> PAGE_SHIFT; 93 PAGE_SIZE) >> PAGE_SHIFT;
93 boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1, 94 boundary_size = ALIGN((unsigned long long)dma_get_seg_boundary(dev) + 1,
94 PAGE_SIZE) >> PAGE_SHIFT; 95 PAGE_SIZE) >> PAGE_SHIFT;
95 96
96 spin_lock_irqsave(&iommu_bitmap_lock, flags); 97 spin_lock_irqsave(&iommu_bitmap_lock, flags);
97 offset = iommu_area_alloc(iommu_gart_bitmap, iommu_pages, next_bit, 98 offset = iommu_area_alloc(iommu_gart_bitmap, iommu_pages, next_bit,
98 size, base_index, boundary_size, 0); 99 size, base_index, boundary_size, align_mask);
99 if (offset == -1) { 100 if (offset == -1) {
100 need_flush = 1; 101 need_flush = true;
101 offset = iommu_area_alloc(iommu_gart_bitmap, iommu_pages, 0, 102 offset = iommu_area_alloc(iommu_gart_bitmap, iommu_pages, 0,
102 size, base_index, boundary_size, 0); 103 size, base_index, boundary_size,
104 align_mask);
103 } 105 }
104 if (offset != -1) { 106 if (offset != -1) {
105 next_bit = offset+size; 107 next_bit = offset+size;
106 if (next_bit >= iommu_pages) { 108 if (next_bit >= iommu_pages) {
107 next_bit = 0; 109 next_bit = 0;
108 need_flush = 1; 110 need_flush = true;
109 } 111 }
110 } 112 }
111 if (iommu_fullflush) 113 if (iommu_fullflush)
112 need_flush = 1; 114 need_flush = true;
113 spin_unlock_irqrestore(&iommu_bitmap_lock, flags); 115 spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
114 116
115 return offset; 117 return offset;
@@ -134,7 +136,7 @@ static void flush_gart(void)
134 spin_lock_irqsave(&iommu_bitmap_lock, flags); 136 spin_lock_irqsave(&iommu_bitmap_lock, flags);
135 if (need_flush) { 137 if (need_flush) {
136 k8_flush_garts(); 138 k8_flush_garts();
137 need_flush = 0; 139 need_flush = false;
138 } 140 }
139 spin_unlock_irqrestore(&iommu_bitmap_lock, flags); 141 spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
140} 142}
@@ -173,7 +175,8 @@ static void dump_leak(void)
173 iommu_leak_pages); 175 iommu_leak_pages);
174 for (i = 0; i < iommu_leak_pages; i += 2) { 176 for (i = 0; i < iommu_leak_pages; i += 2) {
175 printk(KERN_DEBUG "%lu: ", iommu_pages-i); 177 printk(KERN_DEBUG "%lu: ", iommu_pages-i);
176 printk_address((unsigned long) iommu_leak_tab[iommu_pages-i], 0); 178 printk_address((unsigned long) iommu_leak_tab[iommu_pages-i],
179 0);
177 printk(KERN_CONT "%c", (i+1)%2 == 0 ? '\n' : ' '); 180 printk(KERN_CONT "%c", (i+1)%2 == 0 ? '\n' : ' ');
178 } 181 }
179 printk(KERN_DEBUG "\n"); 182 printk(KERN_DEBUG "\n");
@@ -212,34 +215,24 @@ static void iommu_full(struct device *dev, size_t size, int dir)
212static inline int 215static inline int
213need_iommu(struct device *dev, unsigned long addr, size_t size) 216need_iommu(struct device *dev, unsigned long addr, size_t size)
214{ 217{
215 u64 mask = *dev->dma_mask; 218 return force_iommu ||
216 int high = addr + size > mask; 219 !is_buffer_dma_capable(*dev->dma_mask, addr, size);
217 int mmu = high;
218
219 if (force_iommu)
220 mmu = 1;
221
222 return mmu;
223} 220}
224 221
225static inline int 222static inline int
226nonforced_iommu(struct device *dev, unsigned long addr, size_t size) 223nonforced_iommu(struct device *dev, unsigned long addr, size_t size)
227{ 224{
228 u64 mask = *dev->dma_mask; 225 return !is_buffer_dma_capable(*dev->dma_mask, addr, size);
229 int high = addr + size > mask;
230 int mmu = high;
231
232 return mmu;
233} 226}
234 227
235/* Map a single continuous physical area into the IOMMU. 228/* Map a single continuous physical area into the IOMMU.
236 * Caller needs to check if the iommu is needed and flush. 229 * Caller needs to check if the iommu is needed and flush.
237 */ 230 */
238static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem, 231static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem,
239 size_t size, int dir) 232 size_t size, int dir, unsigned long align_mask)
240{ 233{
241 unsigned long npages = iommu_num_pages(phys_mem, size); 234 unsigned long npages = iommu_num_pages(phys_mem, size);
242 unsigned long iommu_page = alloc_iommu(dev, npages); 235 unsigned long iommu_page = alloc_iommu(dev, npages, align_mask);
243 int i; 236 int i;
244 237
245 if (iommu_page == -1) { 238 if (iommu_page == -1) {
@@ -259,16 +252,6 @@ static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem,
259 return iommu_bus_base + iommu_page*PAGE_SIZE + (phys_mem & ~PAGE_MASK); 252 return iommu_bus_base + iommu_page*PAGE_SIZE + (phys_mem & ~PAGE_MASK);
260} 253}
261 254
262static dma_addr_t
263gart_map_simple(struct device *dev, phys_addr_t paddr, size_t size, int dir)
264{
265 dma_addr_t map = dma_map_area(dev, paddr, size, dir);
266
267 flush_gart();
268
269 return map;
270}
271
272/* Map a single area into the IOMMU */ 255/* Map a single area into the IOMMU */
273static dma_addr_t 256static dma_addr_t
274gart_map_single(struct device *dev, phys_addr_t paddr, size_t size, int dir) 257gart_map_single(struct device *dev, phys_addr_t paddr, size_t size, int dir)
@@ -276,12 +259,13 @@ gart_map_single(struct device *dev, phys_addr_t paddr, size_t size, int dir)
276 unsigned long bus; 259 unsigned long bus;
277 260
278 if (!dev) 261 if (!dev)
279 dev = &fallback_dev; 262 dev = &x86_dma_fallback_dev;
280 263
281 if (!need_iommu(dev, paddr, size)) 264 if (!need_iommu(dev, paddr, size))
282 return paddr; 265 return paddr;
283 266
284 bus = gart_map_simple(dev, paddr, size, dir); 267 bus = dma_map_area(dev, paddr, size, dir, 0);
268 flush_gart();
285 269
286 return bus; 270 return bus;
287} 271}
@@ -340,7 +324,7 @@ static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg,
340 unsigned long addr = sg_phys(s); 324 unsigned long addr = sg_phys(s);
341 325
342 if (nonforced_iommu(dev, addr, s->length)) { 326 if (nonforced_iommu(dev, addr, s->length)) {
343 addr = dma_map_area(dev, addr, s->length, dir); 327 addr = dma_map_area(dev, addr, s->length, dir, 0);
344 if (addr == bad_dma_address) { 328 if (addr == bad_dma_address) {
345 if (i > 0) 329 if (i > 0)
346 gart_unmap_sg(dev, sg, i, dir); 330 gart_unmap_sg(dev, sg, i, dir);
@@ -362,7 +346,7 @@ static int __dma_map_cont(struct device *dev, struct scatterlist *start,
362 int nelems, struct scatterlist *sout, 346 int nelems, struct scatterlist *sout,
363 unsigned long pages) 347 unsigned long pages)
364{ 348{
365 unsigned long iommu_start = alloc_iommu(dev, pages); 349 unsigned long iommu_start = alloc_iommu(dev, pages, 0);
366 unsigned long iommu_page = iommu_start; 350 unsigned long iommu_page = iommu_start;
367 struct scatterlist *s; 351 struct scatterlist *s;
368 int i; 352 int i;
@@ -427,7 +411,7 @@ gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
427 return 0; 411 return 0;
428 412
429 if (!dev) 413 if (!dev)
430 dev = &fallback_dev; 414 dev = &x86_dma_fallback_dev;
431 415
432 out = 0; 416 out = 0;
433 start = 0; 417 start = 0;
@@ -499,6 +483,46 @@ error:
499 return 0; 483 return 0;
500} 484}
501 485
486/* allocate and map a coherent mapping */
487static void *
488gart_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_addr,
489 gfp_t flag)
490{
491 dma_addr_t paddr;
492 unsigned long align_mask;
493 struct page *page;
494
495 if (force_iommu && !(flag & GFP_DMA)) {
496 flag &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
497 page = alloc_pages(flag | __GFP_ZERO, get_order(size));
498 if (!page)
499 return NULL;
500
501 align_mask = (1UL << get_order(size)) - 1;
502 paddr = dma_map_area(dev, page_to_phys(page), size,
503 DMA_BIDIRECTIONAL, align_mask);
504
505 flush_gart();
506 if (paddr != bad_dma_address) {
507 *dma_addr = paddr;
508 return page_address(page);
509 }
510 __free_pages(page, get_order(size));
511 } else
512 return dma_generic_alloc_coherent(dev, size, dma_addr, flag);
513
514 return NULL;
515}
516
517/* free a coherent mapping */
518static void
519gart_free_coherent(struct device *dev, size_t size, void *vaddr,
520 dma_addr_t dma_addr)
521{
522 gart_unmap_single(dev, dma_addr, size, DMA_BIDIRECTIONAL);
523 free_pages((unsigned long)vaddr, get_order(size));
524}
525
502static int no_agp; 526static int no_agp;
503 527
504static __init unsigned long check_iommu_size(unsigned long aper, u64 aper_size) 528static __init unsigned long check_iommu_size(unsigned long aper, u64 aper_size)
@@ -626,7 +650,6 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
626 struct pci_dev *dev; 650 struct pci_dev *dev;
627 void *gatt; 651 void *gatt;
628 int i, error; 652 int i, error;
629 unsigned long start_pfn, end_pfn;
630 653
631 printk(KERN_INFO "PCI-DMA: Disabling AGP.\n"); 654 printk(KERN_INFO "PCI-DMA: Disabling AGP.\n");
632 aper_size = aper_base = info->aper_size = 0; 655 aper_size = aper_base = info->aper_size = 0;
@@ -650,13 +673,13 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
650 info->aper_size = aper_size >> 20; 673 info->aper_size = aper_size >> 20;
651 674
652 gatt_size = (aper_size >> PAGE_SHIFT) * sizeof(u32); 675 gatt_size = (aper_size >> PAGE_SHIFT) * sizeof(u32);
653 gatt = (void *)__get_free_pages(GFP_KERNEL, get_order(gatt_size)); 676 gatt = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
677 get_order(gatt_size));
654 if (!gatt) 678 if (!gatt)
655 panic("Cannot allocate GATT table"); 679 panic("Cannot allocate GATT table");
656 if (set_memory_uc((unsigned long)gatt, gatt_size >> PAGE_SHIFT)) 680 if (set_memory_uc((unsigned long)gatt, gatt_size >> PAGE_SHIFT))
657 panic("Could not set GART PTEs to uncacheable pages"); 681 panic("Could not set GART PTEs to uncacheable pages");
658 682
659 memset(gatt, 0, gatt_size);
660 agp_gatt_table = gatt; 683 agp_gatt_table = gatt;
661 684
662 enable_gart_translations(); 685 enable_gart_translations();
@@ -665,19 +688,14 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
665 if (!error) 688 if (!error)
666 error = sysdev_register(&device_gart); 689 error = sysdev_register(&device_gart);
667 if (error) 690 if (error)
668 panic("Could not register gart_sysdev -- would corrupt data on next suspend"); 691 panic("Could not register gart_sysdev -- "
692 "would corrupt data on next suspend");
669 693
670 flush_gart(); 694 flush_gart();
671 695
672 printk(KERN_INFO "PCI-DMA: aperture base @ %x size %u KB\n", 696 printk(KERN_INFO "PCI-DMA: aperture base @ %x size %u KB\n",
673 aper_base, aper_size>>10); 697 aper_base, aper_size>>10);
674 698
675 /* need to map that range */
676 end_pfn = (aper_base>>PAGE_SHIFT) + (aper_size>>PAGE_SHIFT);
677 if (end_pfn > max_low_pfn_mapped) {
678 start_pfn = (aper_base>>PAGE_SHIFT);
679 init_memory_mapping(start_pfn<<PAGE_SHIFT, end_pfn<<PAGE_SHIFT);
680 }
681 return 0; 699 return 0;
682 700
683 nommu: 701 nommu:
@@ -687,20 +705,13 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
687 return -1; 705 return -1;
688} 706}
689 707
690extern int agp_amd64_init(void);
691
692static struct dma_mapping_ops gart_dma_ops = { 708static struct dma_mapping_ops gart_dma_ops = {
693 .map_single = gart_map_single, 709 .map_single = gart_map_single,
694 .map_simple = gart_map_simple,
695 .unmap_single = gart_unmap_single, 710 .unmap_single = gart_unmap_single,
696 .sync_single_for_cpu = NULL,
697 .sync_single_for_device = NULL,
698 .sync_single_range_for_cpu = NULL,
699 .sync_single_range_for_device = NULL,
700 .sync_sg_for_cpu = NULL,
701 .sync_sg_for_device = NULL,
702 .map_sg = gart_map_sg, 711 .map_sg = gart_map_sg,
703 .unmap_sg = gart_unmap_sg, 712 .unmap_sg = gart_unmap_sg,
713 .alloc_coherent = gart_alloc_coherent,
714 .free_coherent = gart_free_coherent,
704}; 715};
705 716
706void gart_iommu_shutdown(void) 717void gart_iommu_shutdown(void)
@@ -727,7 +738,8 @@ void __init gart_iommu_init(void)
727{ 738{
728 struct agp_kern_info info; 739 struct agp_kern_info info;
729 unsigned long iommu_start; 740 unsigned long iommu_start;
730 unsigned long aper_size; 741 unsigned long aper_base, aper_size;
742 unsigned long start_pfn, end_pfn;
731 unsigned long scratch; 743 unsigned long scratch;
732 long i; 744 long i;
733 745
@@ -759,30 +771,35 @@ void __init gart_iommu_init(void)
759 (no_agp && init_k8_gatt(&info) < 0)) { 771 (no_agp && init_k8_gatt(&info) < 0)) {
760 if (max_pfn > MAX_DMA32_PFN) { 772 if (max_pfn > MAX_DMA32_PFN) {
761 printk(KERN_WARNING "More than 4GB of memory " 773 printk(KERN_WARNING "More than 4GB of memory "
762 "but GART IOMMU not available.\n" 774 "but GART IOMMU not available.\n");
763 KERN_WARNING "falling back to iommu=soft.\n"); 775 printk(KERN_WARNING "falling back to iommu=soft.\n");
764 } 776 }
765 return; 777 return;
766 } 778 }
767 779
780 /* need to map that range */
781 aper_size = info.aper_size << 20;
782 aper_base = info.aper_base;
783 end_pfn = (aper_base>>PAGE_SHIFT) + (aper_size>>PAGE_SHIFT);
784 if (end_pfn > max_low_pfn_mapped) {
785 start_pfn = (aper_base>>PAGE_SHIFT);
786 init_memory_mapping(start_pfn<<PAGE_SHIFT, end_pfn<<PAGE_SHIFT);
787 }
788
768 printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n"); 789 printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n");
769 aper_size = info.aper_size * 1024 * 1024;
770 iommu_size = check_iommu_size(info.aper_base, aper_size); 790 iommu_size = check_iommu_size(info.aper_base, aper_size);
771 iommu_pages = iommu_size >> PAGE_SHIFT; 791 iommu_pages = iommu_size >> PAGE_SHIFT;
772 792
773 iommu_gart_bitmap = (void *) __get_free_pages(GFP_KERNEL, 793 iommu_gart_bitmap = (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
774 get_order(iommu_pages/8)); 794 get_order(iommu_pages/8));
775 if (!iommu_gart_bitmap) 795 if (!iommu_gart_bitmap)
776 panic("Cannot allocate iommu bitmap\n"); 796 panic("Cannot allocate iommu bitmap\n");
777 memset(iommu_gart_bitmap, 0, iommu_pages/8);
778 797
779#ifdef CONFIG_IOMMU_LEAK 798#ifdef CONFIG_IOMMU_LEAK
780 if (leak_trace) { 799 if (leak_trace) {
781 iommu_leak_tab = (void *)__get_free_pages(GFP_KERNEL, 800 iommu_leak_tab = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
782 get_order(iommu_pages*sizeof(void *))); 801 get_order(iommu_pages*sizeof(void *)));
783 if (iommu_leak_tab) 802 if (!iommu_leak_tab)
784 memset(iommu_leak_tab, 0, iommu_pages * 8);
785 else
786 printk(KERN_DEBUG 803 printk(KERN_DEBUG
787 "PCI-DMA: Cannot allocate leak trace area\n"); 804 "PCI-DMA: Cannot allocate leak trace area\n");
788 } 805 }
@@ -792,7 +809,7 @@ void __init gart_iommu_init(void)
792 * Out of IOMMU space handling. 809 * Out of IOMMU space handling.
793 * Reserve some invalid pages at the beginning of the GART. 810 * Reserve some invalid pages at the beginning of the GART.
794 */ 811 */
795 set_bit_string(iommu_gart_bitmap, 0, EMERGENCY_PAGES); 812 iommu_area_reserve(iommu_gart_bitmap, 0, EMERGENCY_PAGES);
796 813
797 agp_memory_reserved = iommu_size; 814 agp_memory_reserved = iommu_size;
798 printk(KERN_INFO 815 printk(KERN_INFO
@@ -850,7 +867,8 @@ void __init gart_parse_options(char *p)
850 if (!strncmp(p, "leak", 4)) { 867 if (!strncmp(p, "leak", 4)) {
851 leak_trace = 1; 868 leak_trace = 1;
852 p += 4; 869 p += 4;
853 if (*p == '=') ++p; 870 if (*p == '=')
871 ++p;
854 if (isdigit(*p) && get_option(&p, &arg)) 872 if (isdigit(*p) && get_option(&p, &arg))
855 iommu_leak_pages = arg; 873 iommu_leak_pages = arg;
856 } 874 }
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index 3f91f71cdc3e..c70ab5a5d4c8 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -14,7 +14,7 @@
14static int 14static int
15check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size) 15check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size)
16{ 16{
17 if (hwdev && bus + size > *hwdev->dma_mask) { 17 if (hwdev && !is_buffer_dma_capable(*hwdev->dma_mask, bus, size)) {
18 if (*hwdev->dma_mask >= DMA_32BIT_MASK) 18 if (*hwdev->dma_mask >= DMA_32BIT_MASK)
19 printk(KERN_ERR 19 printk(KERN_ERR
20 "nommu_%s: overflow %Lx+%zu of device mask %Lx\n", 20 "nommu_%s: overflow %Lx+%zu of device mask %Lx\n",
@@ -72,7 +72,15 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
72 return nents; 72 return nents;
73} 73}
74 74
75static void nommu_free_coherent(struct device *dev, size_t size, void *vaddr,
76 dma_addr_t dma_addr)
77{
78 free_pages((unsigned long)vaddr, get_order(size));
79}
80
75struct dma_mapping_ops nommu_dma_ops = { 81struct dma_mapping_ops nommu_dma_ops = {
82 .alloc_coherent = dma_generic_alloc_coherent,
83 .free_coherent = nommu_free_coherent,
76 .map_single = nommu_map_single, 84 .map_single = nommu_map_single,
77 .map_sg = nommu_map_sg, 85 .map_sg = nommu_map_sg,
78 .is_phys = 1, 86 .is_phys = 1,
diff --git a/arch/x86/kernel/pcspeaker.c b/arch/x86/kernel/pcspeaker.c
index bc1f2d3ea277..a311ffcaad16 100644
--- a/arch/x86/kernel/pcspeaker.c
+++ b/arch/x86/kernel/pcspeaker.c
@@ -1,20 +1,13 @@
1#include <linux/platform_device.h> 1#include <linux/platform_device.h>
2#include <linux/errno.h> 2#include <linux/err.h>
3#include <linux/init.h> 3#include <linux/init.h>
4 4
5static __init int add_pcspkr(void) 5static __init int add_pcspkr(void)
6{ 6{
7 struct platform_device *pd; 7 struct platform_device *pd;
8 int ret;
9 8
10 pd = platform_device_alloc("pcspkr", -1); 9 pd = platform_device_register_simple("pcspkr", -1, NULL, 0);
11 if (!pd)
12 return -ENOMEM;
13 10
14 ret = platform_device_add(pd); 11 return IS_ERR(pd) ? PTR_ERR(pd) : 0;
15 if (ret)
16 platform_device_put(pd);
17
18 return ret;
19} 12}
20device_initcall(add_pcspkr); 13device_initcall(add_pcspkr);
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 876e91890777..c622772744d8 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -15,7 +15,6 @@ unsigned long idle_nomwait;
15EXPORT_SYMBOL(idle_nomwait); 15EXPORT_SYMBOL(idle_nomwait);
16 16
17struct kmem_cache *task_xstate_cachep; 17struct kmem_cache *task_xstate_cachep;
18static int force_mwait __cpuinitdata;
19 18
20int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) 19int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
21{ 20{
@@ -185,7 +184,8 @@ static void mwait_idle(void)
185static void poll_idle(void) 184static void poll_idle(void)
186{ 185{
187 local_irq_enable(); 186 local_irq_enable();
188 cpu_relax(); 187 while (!need_resched())
188 cpu_relax();
189} 189}
190 190
191/* 191/*
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 31f40b24bf5d..922c14058f97 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -37,6 +37,7 @@
37#include <linux/tick.h> 37#include <linux/tick.h>
38#include <linux/percpu.h> 38#include <linux/percpu.h>
39#include <linux/prctl.h> 39#include <linux/prctl.h>
40#include <linux/dmi.h>
40 41
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
@@ -56,6 +57,8 @@
56#include <asm/cpu.h> 57#include <asm/cpu.h>
57#include <asm/kdebug.h> 58#include <asm/kdebug.h>
58#include <asm/idle.h> 59#include <asm/idle.h>
60#include <asm/syscalls.h>
61#include <asm/smp.h>
59 62
60asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); 63asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
61 64
@@ -73,47 +76,12 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
73 return ((unsigned long *)tsk->thread.sp)[3]; 76 return ((unsigned long *)tsk->thread.sp)[3];
74} 77}
75 78
76#ifdef CONFIG_HOTPLUG_CPU 79#ifndef CONFIG_SMP
77#include <asm/nmi.h>
78
79static void cpu_exit_clear(void)
80{
81 int cpu = raw_smp_processor_id();
82
83 idle_task_exit();
84
85 cpu_uninit();
86 irq_ctx_exit(cpu);
87
88 cpu_clear(cpu, cpu_callout_map);
89 cpu_clear(cpu, cpu_callin_map);
90
91 numa_remove_cpu(cpu);
92 c1e_remove_cpu(cpu);
93}
94
95/* We don't actually take CPU down, just spin without interrupts. */
96static inline void play_dead(void)
97{
98 /* This must be done before dead CPU ack */
99 cpu_exit_clear();
100 mb();
101 /* Ack it */
102 __get_cpu_var(cpu_state) = CPU_DEAD;
103
104 /*
105 * With physical CPU hotplug, we should halt the cpu
106 */
107 local_irq_disable();
108 /* mask all interrupts, flush any and all caches, and halt */
109 wbinvd_halt();
110}
111#else
112static inline void play_dead(void) 80static inline void play_dead(void)
113{ 81{
114 BUG(); 82 BUG();
115} 83}
116#endif /* CONFIG_HOTPLUG_CPU */ 84#endif
117 85
118/* 86/*
119 * The idle thread. There's no useful work to be 87 * The idle thread. There's no useful work to be
@@ -161,6 +129,7 @@ void __show_registers(struct pt_regs *regs, int all)
161 unsigned long d0, d1, d2, d3, d6, d7; 129 unsigned long d0, d1, d2, d3, d6, d7;
162 unsigned long sp; 130 unsigned long sp;
163 unsigned short ss, gs; 131 unsigned short ss, gs;
132 const char *board;
164 133
165 if (user_mode_vm(regs)) { 134 if (user_mode_vm(regs)) {
166 sp = regs->sp; 135 sp = regs->sp;
@@ -173,11 +142,15 @@ void __show_registers(struct pt_regs *regs, int all)
173 } 142 }
174 143
175 printk("\n"); 144 printk("\n");
176 printk("Pid: %d, comm: %s %s (%s %.*s)\n", 145
146 board = dmi_get_system_info(DMI_PRODUCT_NAME);
147 if (!board)
148 board = "";
149 printk("Pid: %d, comm: %s %s (%s %.*s) %s\n",
177 task_pid_nr(current), current->comm, 150 task_pid_nr(current), current->comm,
178 print_tainted(), init_utsname()->release, 151 print_tainted(), init_utsname()->release,
179 (int)strcspn(init_utsname()->version, " "), 152 (int)strcspn(init_utsname()->version, " "),
180 init_utsname()->version); 153 init_utsname()->version, board);
181 154
182 printk("EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n", 155 printk("EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
183 (u16)regs->cs, regs->ip, regs->flags, 156 (u16)regs->cs, regs->ip, regs->flags,
@@ -277,6 +250,14 @@ void exit_thread(void)
277 tss->x86_tss.io_bitmap_base = INVALID_IO_BITMAP_OFFSET; 250 tss->x86_tss.io_bitmap_base = INVALID_IO_BITMAP_OFFSET;
278 put_cpu(); 251 put_cpu();
279 } 252 }
253#ifdef CONFIG_X86_DS
254 /* Free any DS contexts that have not been properly released. */
255 if (unlikely(current->thread.ds_ctx)) {
256 /* we clear debugctl to make sure DS is not used. */
257 update_debugctlmsr(0);
258 ds_free(current->thread.ds_ctx);
259 }
260#endif /* CONFIG_X86_DS */
280} 261}
281 262
282void flush_thread(void) 263void flush_thread(void)
@@ -438,6 +419,35 @@ int set_tsc_mode(unsigned int val)
438 return 0; 419 return 0;
439} 420}
440 421
422#ifdef CONFIG_X86_DS
423static int update_debugctl(struct thread_struct *prev,
424 struct thread_struct *next, unsigned long debugctl)
425{
426 unsigned long ds_prev = 0;
427 unsigned long ds_next = 0;
428
429 if (prev->ds_ctx)
430 ds_prev = (unsigned long)prev->ds_ctx->ds;
431 if (next->ds_ctx)
432 ds_next = (unsigned long)next->ds_ctx->ds;
433
434 if (ds_next != ds_prev) {
435 /* we clear debugctl to make sure DS
436 * is not in use when we change it */
437 debugctl = 0;
438 update_debugctlmsr(0);
439 wrmsr(MSR_IA32_DS_AREA, ds_next, 0);
440 }
441 return debugctl;
442}
443#else
444static int update_debugctl(struct thread_struct *prev,
445 struct thread_struct *next, unsigned long debugctl)
446{
447 return debugctl;
448}
449#endif /* CONFIG_X86_DS */
450
441static noinline void 451static noinline void
442__switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, 452__switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
443 struct tss_struct *tss) 453 struct tss_struct *tss)
@@ -448,14 +458,7 @@ __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
448 prev = &prev_p->thread; 458 prev = &prev_p->thread;
449 next = &next_p->thread; 459 next = &next_p->thread;
450 460
451 debugctl = prev->debugctlmsr; 461 debugctl = update_debugctl(prev, next, prev->debugctlmsr);
452 if (next->ds_area_msr != prev->ds_area_msr) {
453 /* we clear debugctl to make sure DS
454 * is not in use when we change it */
455 debugctl = 0;
456 update_debugctlmsr(0);
457 wrmsr(MSR_IA32_DS_AREA, next->ds_area_msr, 0);
458 }
459 462
460 if (next->debugctlmsr != debugctl) 463 if (next->debugctlmsr != debugctl)
461 update_debugctlmsr(next->debugctlmsr); 464 update_debugctlmsr(next->debugctlmsr);
@@ -479,13 +482,13 @@ __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
479 hard_enable_TSC(); 482 hard_enable_TSC();
480 } 483 }
481 484
482#ifdef X86_BTS 485#ifdef CONFIG_X86_PTRACE_BTS
483 if (test_tsk_thread_flag(prev_p, TIF_BTS_TRACE_TS)) 486 if (test_tsk_thread_flag(prev_p, TIF_BTS_TRACE_TS))
484 ptrace_bts_take_timestamp(prev_p, BTS_TASK_DEPARTS); 487 ptrace_bts_take_timestamp(prev_p, BTS_TASK_DEPARTS);
485 488
486 if (test_tsk_thread_flag(next_p, TIF_BTS_TRACE_TS)) 489 if (test_tsk_thread_flag(next_p, TIF_BTS_TRACE_TS))
487 ptrace_bts_take_timestamp(next_p, BTS_TASK_ARRIVES); 490 ptrace_bts_take_timestamp(next_p, BTS_TASK_ARRIVES);
488#endif 491#endif /* CONFIG_X86_PTRACE_BTS */
489 492
490 493
491 if (!test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) { 494 if (!test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e12e0e4dd256..ca80394ef5b8 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -37,11 +37,11 @@
37#include <linux/kdebug.h> 37#include <linux/kdebug.h>
38#include <linux/tick.h> 38#include <linux/tick.h>
39#include <linux/prctl.h> 39#include <linux/prctl.h>
40#include <linux/uaccess.h>
41#include <linux/io.h>
40 42
41#include <asm/uaccess.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
43#include <asm/system.h> 44#include <asm/system.h>
44#include <asm/io.h>
45#include <asm/processor.h> 45#include <asm/processor.h>
46#include <asm/i387.h> 46#include <asm/i387.h>
47#include <asm/mmu_context.h> 47#include <asm/mmu_context.h>
@@ -51,6 +51,7 @@
51#include <asm/proto.h> 51#include <asm/proto.h>
52#include <asm/ia32.h> 52#include <asm/ia32.h>
53#include <asm/idle.h> 53#include <asm/idle.h>
54#include <asm/syscalls.h>
54 55
55asmlinkage extern void ret_from_fork(void); 56asmlinkage extern void ret_from_fork(void);
56 57
@@ -85,30 +86,12 @@ void exit_idle(void)
85 __exit_idle(); 86 __exit_idle();
86} 87}
87 88
88#ifdef CONFIG_HOTPLUG_CPU 89#ifndef CONFIG_SMP
89DECLARE_PER_CPU(int, cpu_state);
90
91#include <asm/nmi.h>
92/* We halt the CPU with physical CPU hotplug */
93static inline void play_dead(void)
94{
95 idle_task_exit();
96 c1e_remove_cpu(raw_smp_processor_id());
97
98 mb();
99 /* Ack it */
100 __get_cpu_var(cpu_state) = CPU_DEAD;
101
102 local_irq_disable();
103 /* mask all interrupts, flush any and all caches, and halt */
104 wbinvd_halt();
105}
106#else
107static inline void play_dead(void) 90static inline void play_dead(void)
108{ 91{
109 BUG(); 92 BUG();
110} 93}
111#endif /* CONFIG_HOTPLUG_CPU */ 94#endif
112 95
113/* 96/*
114 * The idle thread. There's no useful work to be 97 * The idle thread. There's no useful work to be
@@ -153,7 +136,7 @@ void cpu_idle(void)
153} 136}
154 137
155/* Prints also some state that isn't saved in the pt_regs */ 138/* Prints also some state that isn't saved in the pt_regs */
156void __show_regs(struct pt_regs * regs) 139void __show_regs(struct pt_regs *regs)
157{ 140{
158 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs; 141 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs;
159 unsigned long d0, d1, d2, d3, d6, d7; 142 unsigned long d0, d1, d2, d3, d6, d7;
@@ -162,59 +145,61 @@ void __show_regs(struct pt_regs * regs)
162 145
163 printk("\n"); 146 printk("\n");
164 print_modules(); 147 print_modules();
165 printk("Pid: %d, comm: %.20s %s %s %.*s\n", 148 printk(KERN_INFO "Pid: %d, comm: %.20s %s %s %.*s\n",
166 current->pid, current->comm, print_tainted(), 149 current->pid, current->comm, print_tainted(),
167 init_utsname()->release, 150 init_utsname()->release,
168 (int)strcspn(init_utsname()->version, " "), 151 (int)strcspn(init_utsname()->version, " "),
169 init_utsname()->version); 152 init_utsname()->version);
170 printk("RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->ip); 153 printk(KERN_INFO "RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->ip);
171 printk_address(regs->ip, 1); 154 printk_address(regs->ip, 1);
172 printk("RSP: %04lx:%016lx EFLAGS: %08lx\n", regs->ss, regs->sp, 155 printk(KERN_INFO "RSP: %04lx:%016lx EFLAGS: %08lx\n", regs->ss,
173 regs->flags); 156 regs->sp, regs->flags);
174 printk("RAX: %016lx RBX: %016lx RCX: %016lx\n", 157 printk(KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n",
175 regs->ax, regs->bx, regs->cx); 158 regs->ax, regs->bx, regs->cx);
176 printk("RDX: %016lx RSI: %016lx RDI: %016lx\n", 159 printk(KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n",
177 regs->dx, regs->si, regs->di); 160 regs->dx, regs->si, regs->di);
178 printk("RBP: %016lx R08: %016lx R09: %016lx\n", 161 printk(KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n",
179 regs->bp, regs->r8, regs->r9); 162 regs->bp, regs->r8, regs->r9);
180 printk("R10: %016lx R11: %016lx R12: %016lx\n", 163 printk(KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n",
181 regs->r10, regs->r11, regs->r12); 164 regs->r10, regs->r11, regs->r12);
182 printk("R13: %016lx R14: %016lx R15: %016lx\n", 165 printk(KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n",
183 regs->r13, regs->r14, regs->r15); 166 regs->r13, regs->r14, regs->r15);
184 167
185 asm("movl %%ds,%0" : "=r" (ds)); 168 asm("movl %%ds,%0" : "=r" (ds));
186 asm("movl %%cs,%0" : "=r" (cs)); 169 asm("movl %%cs,%0" : "=r" (cs));
187 asm("movl %%es,%0" : "=r" (es)); 170 asm("movl %%es,%0" : "=r" (es));
188 asm("movl %%fs,%0" : "=r" (fsindex)); 171 asm("movl %%fs,%0" : "=r" (fsindex));
189 asm("movl %%gs,%0" : "=r" (gsindex)); 172 asm("movl %%gs,%0" : "=r" (gsindex));
190 173
191 rdmsrl(MSR_FS_BASE, fs); 174 rdmsrl(MSR_FS_BASE, fs);
192 rdmsrl(MSR_GS_BASE, gs); 175 rdmsrl(MSR_GS_BASE, gs);
193 rdmsrl(MSR_KERNEL_GS_BASE, shadowgs); 176 rdmsrl(MSR_KERNEL_GS_BASE, shadowgs);
194 177
195 cr0 = read_cr0(); 178 cr0 = read_cr0();
196 cr2 = read_cr2(); 179 cr2 = read_cr2();
197 cr3 = read_cr3(); 180 cr3 = read_cr3();
198 cr4 = read_cr4(); 181 cr4 = read_cr4();
199 182
200 printk("FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n", 183 printk(KERN_INFO "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n",
201 fs,fsindex,gs,gsindex,shadowgs); 184 fs, fsindex, gs, gsindex, shadowgs);
202 printk("CS: %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds, es, cr0); 185 printk(KERN_INFO "CS: %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds,
203 printk("CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3, cr4); 186 es, cr0);
187 printk(KERN_INFO "CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3,
188 cr4);
204 189
205 get_debugreg(d0, 0); 190 get_debugreg(d0, 0);
206 get_debugreg(d1, 1); 191 get_debugreg(d1, 1);
207 get_debugreg(d2, 2); 192 get_debugreg(d2, 2);
208 printk("DR0: %016lx DR1: %016lx DR2: %016lx\n", d0, d1, d2); 193 printk(KERN_INFO "DR0: %016lx DR1: %016lx DR2: %016lx\n", d0, d1, d2);
209 get_debugreg(d3, 3); 194 get_debugreg(d3, 3);
210 get_debugreg(d6, 6); 195 get_debugreg(d6, 6);
211 get_debugreg(d7, 7); 196 get_debugreg(d7, 7);
212 printk("DR3: %016lx DR6: %016lx DR7: %016lx\n", d3, d6, d7); 197 printk(KERN_INFO "DR3: %016lx DR6: %016lx DR7: %016lx\n", d3, d6, d7);
213} 198}
214 199
215void show_regs(struct pt_regs *regs) 200void show_regs(struct pt_regs *regs)
216{ 201{
217 printk("CPU %d:", smp_processor_id()); 202 printk(KERN_INFO "CPU %d:", smp_processor_id());
218 __show_regs(regs); 203 __show_regs(regs);
219 show_trace(NULL, regs, (void *)(regs + 1), regs->bp); 204 show_trace(NULL, regs, (void *)(regs + 1), regs->bp);
220} 205}
@@ -240,6 +225,14 @@ void exit_thread(void)
240 t->io_bitmap_max = 0; 225 t->io_bitmap_max = 0;
241 put_cpu(); 226 put_cpu();
242 } 227 }
228#ifdef CONFIG_X86_DS
229 /* Free any DS contexts that have not been properly released. */
230 if (unlikely(t->ds_ctx)) {
231 /* we clear debugctl to make sure DS is not used. */
232 update_debugctlmsr(0);
233 ds_free(t->ds_ctx);
234 }
235#endif /* CONFIG_X86_DS */
243} 236}
244 237
245void flush_thread(void) 238void flush_thread(void)
@@ -315,10 +308,10 @@ void prepare_to_copy(struct task_struct *tsk)
315 308
316int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, 309int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
317 unsigned long unused, 310 unsigned long unused,
318 struct task_struct * p, struct pt_regs * regs) 311 struct task_struct *p, struct pt_regs *regs)
319{ 312{
320 int err; 313 int err;
321 struct pt_regs * childregs; 314 struct pt_regs *childregs;
322 struct task_struct *me = current; 315 struct task_struct *me = current;
323 316
324 childregs = ((struct pt_regs *) 317 childregs = ((struct pt_regs *)
@@ -363,10 +356,10 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
363 if (test_thread_flag(TIF_IA32)) 356 if (test_thread_flag(TIF_IA32))
364 err = do_set_thread_area(p, -1, 357 err = do_set_thread_area(p, -1,
365 (struct user_desc __user *)childregs->si, 0); 358 (struct user_desc __user *)childregs->si, 0);
366 else 359 else
367#endif 360#endif
368 err = do_arch_prctl(p, ARCH_SET_FS, childregs->r8); 361 err = do_arch_prctl(p, ARCH_SET_FS, childregs->r8);
369 if (err) 362 if (err)
370 goto out; 363 goto out;
371 } 364 }
372 err = 0; 365 err = 0;
@@ -473,13 +466,27 @@ static inline void __switch_to_xtra(struct task_struct *prev_p,
473 next = &next_p->thread; 466 next = &next_p->thread;
474 467
475 debugctl = prev->debugctlmsr; 468 debugctl = prev->debugctlmsr;
476 if (next->ds_area_msr != prev->ds_area_msr) { 469
477 /* we clear debugctl to make sure DS 470#ifdef CONFIG_X86_DS
478 * is not in use when we change it */ 471 {
479 debugctl = 0; 472 unsigned long ds_prev = 0, ds_next = 0;
480 update_debugctlmsr(0); 473
481 wrmsrl(MSR_IA32_DS_AREA, next->ds_area_msr); 474 if (prev->ds_ctx)
475 ds_prev = (unsigned long)prev->ds_ctx->ds;
476 if (next->ds_ctx)
477 ds_next = (unsigned long)next->ds_ctx->ds;
478
479 if (ds_next != ds_prev) {
480 /*
481 * We clear debugctl to make sure DS
482 * is not in use when we change it:
483 */
484 debugctl = 0;
485 update_debugctlmsr(0);
486 wrmsrl(MSR_IA32_DS_AREA, ds_next);
487 }
482 } 488 }
489#endif /* CONFIG_X86_DS */
483 490
484 if (next->debugctlmsr != debugctl) 491 if (next->debugctlmsr != debugctl)
485 update_debugctlmsr(next->debugctlmsr); 492 update_debugctlmsr(next->debugctlmsr);
@@ -517,13 +524,13 @@ static inline void __switch_to_xtra(struct task_struct *prev_p,
517 memset(tss->io_bitmap, 0xff, prev->io_bitmap_max); 524 memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
518 } 525 }
519 526
520#ifdef X86_BTS 527#ifdef CONFIG_X86_PTRACE_BTS
521 if (test_tsk_thread_flag(prev_p, TIF_BTS_TRACE_TS)) 528 if (test_tsk_thread_flag(prev_p, TIF_BTS_TRACE_TS))
522 ptrace_bts_take_timestamp(prev_p, BTS_TASK_DEPARTS); 529 ptrace_bts_take_timestamp(prev_p, BTS_TASK_DEPARTS);
523 530
524 if (test_tsk_thread_flag(next_p, TIF_BTS_TRACE_TS)) 531 if (test_tsk_thread_flag(next_p, TIF_BTS_TRACE_TS))
525 ptrace_bts_take_timestamp(next_p, BTS_TASK_ARRIVES); 532 ptrace_bts_take_timestamp(next_p, BTS_TASK_ARRIVES);
526#endif 533#endif /* CONFIG_X86_PTRACE_BTS */
527} 534}
528 535
529/* 536/*
@@ -545,7 +552,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
545 unsigned fsindex, gsindex; 552 unsigned fsindex, gsindex;
546 553
547 /* we're going to use this soon, after a few expensive things */ 554 /* we're going to use this soon, after a few expensive things */
548 if (next_p->fpu_counter>5) 555 if (next_p->fpu_counter > 5)
549 prefetch(next->xstate); 556 prefetch(next->xstate);
550 557
551 /* 558 /*
@@ -553,13 +560,13 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
553 */ 560 */
554 load_sp0(tss, next); 561 load_sp0(tss, next);
555 562
556 /* 563 /*
557 * Switch DS and ES. 564 * Switch DS and ES.
558 * This won't pick up thread selector changes, but I guess that is ok. 565 * This won't pick up thread selector changes, but I guess that is ok.
559 */ 566 */
560 savesegment(es, prev->es); 567 savesegment(es, prev->es);
561 if (unlikely(next->es | prev->es)) 568 if (unlikely(next->es | prev->es))
562 loadsegment(es, next->es); 569 loadsegment(es, next->es);
563 570
564 savesegment(ds, prev->ds); 571 savesegment(ds, prev->ds);
565 if (unlikely(next->ds | prev->ds)) 572 if (unlikely(next->ds | prev->ds))
@@ -585,7 +592,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
585 */ 592 */
586 arch_leave_lazy_cpu_mode(); 593 arch_leave_lazy_cpu_mode();
587 594
588 /* 595 /*
589 * Switch FS and GS. 596 * Switch FS and GS.
590 * 597 *
591 * Segment register != 0 always requires a reload. Also 598 * Segment register != 0 always requires a reload. Also
@@ -594,13 +601,13 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
594 */ 601 */
595 if (unlikely(fsindex | next->fsindex | prev->fs)) { 602 if (unlikely(fsindex | next->fsindex | prev->fs)) {
596 loadsegment(fs, next->fsindex); 603 loadsegment(fs, next->fsindex);
597 /* 604 /*
598 * Check if the user used a selector != 0; if yes 605 * Check if the user used a selector != 0; if yes
599 * clear 64bit base, since overloaded base is always 606 * clear 64bit base, since overloaded base is always
600 * mapped to the Null selector 607 * mapped to the Null selector
601 */ 608 */
602 if (fsindex) 609 if (fsindex)
603 prev->fs = 0; 610 prev->fs = 0;
604 } 611 }
605 /* when next process has a 64bit base use it */ 612 /* when next process has a 64bit base use it */
606 if (next->fs) 613 if (next->fs)
@@ -610,7 +617,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
610 if (unlikely(gsindex | next->gsindex | prev->gs)) { 617 if (unlikely(gsindex | next->gsindex | prev->gs)) {
611 load_gs_index(next->gsindex); 618 load_gs_index(next->gsindex);
612 if (gsindex) 619 if (gsindex)
613 prev->gs = 0; 620 prev->gs = 0;
614 } 621 }
615 if (next->gs) 622 if (next->gs)
616 wrmsrl(MSR_KERNEL_GS_BASE, next->gs); 623 wrmsrl(MSR_KERNEL_GS_BASE, next->gs);
@@ -619,12 +626,12 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
619 /* Must be after DS reload */ 626 /* Must be after DS reload */
620 unlazy_fpu(prev_p); 627 unlazy_fpu(prev_p);
621 628
622 /* 629 /*
623 * Switch the PDA and FPU contexts. 630 * Switch the PDA and FPU contexts.
624 */ 631 */
625 prev->usersp = read_pda(oldrsp); 632 prev->usersp = read_pda(oldrsp);
626 write_pda(oldrsp, next->usersp); 633 write_pda(oldrsp, next->usersp);
627 write_pda(pcurrent, next_p); 634 write_pda(pcurrent, next_p);
628 635
629 write_pda(kernelstack, 636 write_pda(kernelstack,
630 (unsigned long)task_stack_page(next_p) + 637 (unsigned long)task_stack_page(next_p) +
@@ -665,7 +672,7 @@ long sys_execve(char __user *name, char __user * __user *argv,
665 char __user * __user *envp, struct pt_regs *regs) 672 char __user * __user *envp, struct pt_regs *regs)
666{ 673{
667 long error; 674 long error;
668 char * filename; 675 char *filename;
669 676
670 filename = getname(name); 677 filename = getname(name);
671 error = PTR_ERR(filename); 678 error = PTR_ERR(filename);
@@ -723,55 +730,55 @@ asmlinkage long sys_vfork(struct pt_regs *regs)
723unsigned long get_wchan(struct task_struct *p) 730unsigned long get_wchan(struct task_struct *p)
724{ 731{
725 unsigned long stack; 732 unsigned long stack;
726 u64 fp,ip; 733 u64 fp, ip;
727 int count = 0; 734 int count = 0;
728 735
729 if (!p || p == current || p->state==TASK_RUNNING) 736 if (!p || p == current || p->state == TASK_RUNNING)
730 return 0; 737 return 0;
731 stack = (unsigned long)task_stack_page(p); 738 stack = (unsigned long)task_stack_page(p);
732 if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE) 739 if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
733 return 0; 740 return 0;
734 fp = *(u64 *)(p->thread.sp); 741 fp = *(u64 *)(p->thread.sp);
735 do { 742 do {
736 if (fp < (unsigned long)stack || 743 if (fp < (unsigned long)stack ||
737 fp > (unsigned long)stack+THREAD_SIZE) 744 fp >= (unsigned long)stack+THREAD_SIZE)
738 return 0; 745 return 0;
739 ip = *(u64 *)(fp+8); 746 ip = *(u64 *)(fp+8);
740 if (!in_sched_functions(ip)) 747 if (!in_sched_functions(ip))
741 return ip; 748 return ip;
742 fp = *(u64 *)fp; 749 fp = *(u64 *)fp;
743 } while (count++ < 16); 750 } while (count++ < 16);
744 return 0; 751 return 0;
745} 752}
746 753
747long do_arch_prctl(struct task_struct *task, int code, unsigned long addr) 754long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
748{ 755{
749 int ret = 0; 756 int ret = 0;
750 int doit = task == current; 757 int doit = task == current;
751 int cpu; 758 int cpu;
752 759
753 switch (code) { 760 switch (code) {
754 case ARCH_SET_GS: 761 case ARCH_SET_GS:
755 if (addr >= TASK_SIZE_OF(task)) 762 if (addr >= TASK_SIZE_OF(task))
756 return -EPERM; 763 return -EPERM;
757 cpu = get_cpu(); 764 cpu = get_cpu();
758 /* handle small bases via the GDT because that's faster to 765 /* handle small bases via the GDT because that's faster to
759 switch. */ 766 switch. */
760 if (addr <= 0xffffffff) { 767 if (addr <= 0xffffffff) {
761 set_32bit_tls(task, GS_TLS, addr); 768 set_32bit_tls(task, GS_TLS, addr);
762 if (doit) { 769 if (doit) {
763 load_TLS(&task->thread, cpu); 770 load_TLS(&task->thread, cpu);
764 load_gs_index(GS_TLS_SEL); 771 load_gs_index(GS_TLS_SEL);
765 } 772 }
766 task->thread.gsindex = GS_TLS_SEL; 773 task->thread.gsindex = GS_TLS_SEL;
767 task->thread.gs = 0; 774 task->thread.gs = 0;
768 } else { 775 } else {
769 task->thread.gsindex = 0; 776 task->thread.gsindex = 0;
770 task->thread.gs = addr; 777 task->thread.gs = addr;
771 if (doit) { 778 if (doit) {
772 load_gs_index(0); 779 load_gs_index(0);
773 ret = checking_wrmsrl(MSR_KERNEL_GS_BASE, addr); 780 ret = checking_wrmsrl(MSR_KERNEL_GS_BASE, addr);
774 } 781 }
775 } 782 }
776 put_cpu(); 783 put_cpu();
777 break; 784 break;
@@ -825,8 +832,7 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
825 rdmsrl(MSR_KERNEL_GS_BASE, base); 832 rdmsrl(MSR_KERNEL_GS_BASE, base);
826 else 833 else
827 base = task->thread.gs; 834 base = task->thread.gs;
828 } 835 } else
829 else
830 base = task->thread.gs; 836 base = task->thread.gs;
831 ret = put_user(base, (unsigned long __user *)addr); 837 ret = put_user(base, (unsigned long __user *)addr);
832 break; 838 break;
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index e37dccce85db..0a6d8c12e10d 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -14,6 +14,7 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/ptrace.h> 15#include <linux/ptrace.h>
16#include <linux/regset.h> 16#include <linux/regset.h>
17#include <linux/tracehook.h>
17#include <linux/user.h> 18#include <linux/user.h>
18#include <linux/elf.h> 19#include <linux/elf.h>
19#include <linux/security.h> 20#include <linux/security.h>
@@ -39,7 +40,9 @@ enum x86_regset {
39 REGSET_GENERAL, 40 REGSET_GENERAL,
40 REGSET_FP, 41 REGSET_FP,
41 REGSET_XFP, 42 REGSET_XFP,
43 REGSET_IOPERM64 = REGSET_XFP,
42 REGSET_TLS, 44 REGSET_TLS,
45 REGSET_IOPERM32,
43}; 46};
44 47
45/* 48/*
@@ -69,7 +72,7 @@ static inline bool invalid_selector(u16 value)
69 72
70#define FLAG_MASK FLAG_MASK_32 73#define FLAG_MASK FLAG_MASK_32
71 74
72static long *pt_regs_access(struct pt_regs *regs, unsigned long regno) 75static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
73{ 76{
74 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0); 77 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
75 regno >>= 2; 78 regno >>= 2;
@@ -554,45 +557,138 @@ static int ptrace_set_debugreg(struct task_struct *child,
554 return 0; 557 return 0;
555} 558}
556 559
557#ifdef X86_BTS 560/*
561 * These access the current or another (stopped) task's io permission
562 * bitmap for debugging or core dump.
563 */
564static int ioperm_active(struct task_struct *target,
565 const struct user_regset *regset)
566{
567 return target->thread.io_bitmap_max / regset->size;
568}
558 569
559static int ptrace_bts_get_size(struct task_struct *child) 570static int ioperm_get(struct task_struct *target,
571 const struct user_regset *regset,
572 unsigned int pos, unsigned int count,
573 void *kbuf, void __user *ubuf)
560{ 574{
561 if (!child->thread.ds_area_msr) 575 if (!target->thread.io_bitmap_ptr)
562 return -ENXIO; 576 return -ENXIO;
563 577
564 return ds_get_bts_index((void *)child->thread.ds_area_msr); 578 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
579 target->thread.io_bitmap_ptr,
580 0, IO_BITMAP_BYTES);
581}
582
583#ifdef CONFIG_X86_PTRACE_BTS
584/*
585 * The configuration for a particular BTS hardware implementation.
586 */
587struct bts_configuration {
588 /* the size of a BTS record in bytes; at most BTS_MAX_RECORD_SIZE */
589 unsigned char sizeof_bts;
590 /* the size of a field in the BTS record in bytes */
591 unsigned char sizeof_field;
592 /* a bitmask to enable/disable BTS in DEBUGCTL MSR */
593 unsigned long debugctl_mask;
594};
595static struct bts_configuration bts_cfg;
596
597#define BTS_MAX_RECORD_SIZE (8 * 3)
598
599
600/*
601 * Branch Trace Store (BTS) uses the following format. Different
602 * architectures vary in the size of those fields.
603 * - source linear address
604 * - destination linear address
605 * - flags
606 *
607 * Later architectures use 64bit pointers throughout, whereas earlier
608 * architectures use 32bit pointers in 32bit mode.
609 *
610 * We compute the base address for the first 8 fields based on:
611 * - the field size stored in the DS configuration
612 * - the relative field position
613 *
614 * In order to store additional information in the BTS buffer, we use
615 * a special source address to indicate that the record requires
616 * special interpretation.
617 *
618 * Netburst indicated via a bit in the flags field whether the branch
619 * was predicted; this is ignored.
620 */
621
622enum bts_field {
623 bts_from = 0,
624 bts_to,
625 bts_flags,
626
627 bts_escape = (unsigned long)-1,
628 bts_qual = bts_to,
629 bts_jiffies = bts_flags
630};
631
632static inline unsigned long bts_get(const char *base, enum bts_field field)
633{
634 base += (bts_cfg.sizeof_field * field);
635 return *(unsigned long *)base;
636}
637
638static inline void bts_set(char *base, enum bts_field field, unsigned long val)
639{
640 base += (bts_cfg.sizeof_field * field);;
641 (*(unsigned long *)base) = val;
642}
643
644/*
645 * Translate a BTS record from the raw format into the bts_struct format
646 *
647 * out (out): bts_struct interpretation
648 * raw: raw BTS record
649 */
650static void ptrace_bts_translate_record(struct bts_struct *out, const void *raw)
651{
652 memset(out, 0, sizeof(*out));
653 if (bts_get(raw, bts_from) == bts_escape) {
654 out->qualifier = bts_get(raw, bts_qual);
655 out->variant.jiffies = bts_get(raw, bts_jiffies);
656 } else {
657 out->qualifier = BTS_BRANCH;
658 out->variant.lbr.from_ip = bts_get(raw, bts_from);
659 out->variant.lbr.to_ip = bts_get(raw, bts_to);
660 }
565} 661}
566 662
567static int ptrace_bts_read_record(struct task_struct *child, 663static int ptrace_bts_read_record(struct task_struct *child, size_t index,
568 long index,
569 struct bts_struct __user *out) 664 struct bts_struct __user *out)
570{ 665{
571 struct bts_struct ret; 666 struct bts_struct ret;
572 int retval; 667 const void *bts_record;
573 int bts_end; 668 size_t bts_index, bts_end;
574 int bts_index; 669 int error;
575
576 if (!child->thread.ds_area_msr)
577 return -ENXIO;
578 670
579 if (index < 0) 671 error = ds_get_bts_end(child, &bts_end);
580 return -EINVAL; 672 if (error < 0)
673 return error;
581 674
582 bts_end = ds_get_bts_end((void *)child->thread.ds_area_msr);
583 if (bts_end <= index) 675 if (bts_end <= index)
584 return -EINVAL; 676 return -EINVAL;
585 677
678 error = ds_get_bts_index(child, &bts_index);
679 if (error < 0)
680 return error;
681
586 /* translate the ptrace bts index into the ds bts index */ 682 /* translate the ptrace bts index into the ds bts index */
587 bts_index = ds_get_bts_index((void *)child->thread.ds_area_msr); 683 bts_index += bts_end - (index + 1);
588 bts_index -= (index + 1); 684 if (bts_end <= bts_index)
589 if (bts_index < 0) 685 bts_index -= bts_end;
590 bts_index += bts_end; 686
687 error = ds_access_bts(child, bts_index, &bts_record);
688 if (error < 0)
689 return error;
591 690
592 retval = ds_read_bts((void *)child->thread.ds_area_msr, 691 ptrace_bts_translate_record(&ret, bts_record);
593 bts_index, &ret);
594 if (retval < 0)
595 return retval;
596 692
597 if (copy_to_user(out, &ret, sizeof(ret))) 693 if (copy_to_user(out, &ret, sizeof(ret)))
598 return -EFAULT; 694 return -EFAULT;
@@ -600,101 +696,106 @@ static int ptrace_bts_read_record(struct task_struct *child,
600 return sizeof(ret); 696 return sizeof(ret);
601} 697}
602 698
603static int ptrace_bts_clear(struct task_struct *child)
604{
605 if (!child->thread.ds_area_msr)
606 return -ENXIO;
607
608 return ds_clear((void *)child->thread.ds_area_msr);
609}
610
611static int ptrace_bts_drain(struct task_struct *child, 699static int ptrace_bts_drain(struct task_struct *child,
612 long size, 700 long size,
613 struct bts_struct __user *out) 701 struct bts_struct __user *out)
614{ 702{
615 int end, i; 703 struct bts_struct ret;
616 void *ds = (void *)child->thread.ds_area_msr; 704 const unsigned char *raw;
617 705 size_t end, i;
618 if (!ds) 706 int error;
619 return -ENXIO;
620 707
621 end = ds_get_bts_index(ds); 708 error = ds_get_bts_index(child, &end);
622 if (end <= 0) 709 if (error < 0)
623 return end; 710 return error;
624 711
625 if (size < (end * sizeof(struct bts_struct))) 712 if (size < (end * sizeof(struct bts_struct)))
626 return -EIO; 713 return -EIO;
627 714
628 for (i = 0; i < end; i++, out++) { 715 error = ds_access_bts(child, 0, (const void **)&raw);
629 struct bts_struct ret; 716 if (error < 0)
630 int retval; 717 return error;
631 718
632 retval = ds_read_bts(ds, i, &ret); 719 for (i = 0; i < end; i++, out++, raw += bts_cfg.sizeof_bts) {
633 if (retval < 0) 720 ptrace_bts_translate_record(&ret, raw);
634 return retval;
635 721
636 if (copy_to_user(out, &ret, sizeof(ret))) 722 if (copy_to_user(out, &ret, sizeof(ret)))
637 return -EFAULT; 723 return -EFAULT;
638 } 724 }
639 725
640 ds_clear(ds); 726 error = ds_clear_bts(child);
727 if (error < 0)
728 return error;
641 729
642 return end; 730 return end;
643} 731}
644 732
733static void ptrace_bts_ovfl(struct task_struct *child)
734{
735 send_sig(child->thread.bts_ovfl_signal, child, 0);
736}
737
645static int ptrace_bts_config(struct task_struct *child, 738static int ptrace_bts_config(struct task_struct *child,
646 long cfg_size, 739 long cfg_size,
647 const struct ptrace_bts_config __user *ucfg) 740 const struct ptrace_bts_config __user *ucfg)
648{ 741{
649 struct ptrace_bts_config cfg; 742 struct ptrace_bts_config cfg;
650 int bts_size, ret = 0; 743 int error = 0;
651 void *ds;
652 744
745 error = -EOPNOTSUPP;
746 if (!bts_cfg.sizeof_bts)
747 goto errout;
748
749 error = -EIO;
653 if (cfg_size < sizeof(cfg)) 750 if (cfg_size < sizeof(cfg))
654 return -EIO; 751 goto errout;
655 752
753 error = -EFAULT;
656 if (copy_from_user(&cfg, ucfg, sizeof(cfg))) 754 if (copy_from_user(&cfg, ucfg, sizeof(cfg)))
657 return -EFAULT; 755 goto errout;
658 756
659 if ((int)cfg.size < 0) 757 error = -EINVAL;
660 return -EINVAL; 758 if ((cfg.flags & PTRACE_BTS_O_SIGNAL) &&
759 !(cfg.flags & PTRACE_BTS_O_ALLOC))
760 goto errout;
661 761
662 bts_size = 0; 762 if (cfg.flags & PTRACE_BTS_O_ALLOC) {
663 ds = (void *)child->thread.ds_area_msr; 763 ds_ovfl_callback_t ovfl = NULL;
664 if (ds) { 764 unsigned int sig = 0;
665 bts_size = ds_get_bts_size(ds); 765
666 if (bts_size < 0) 766 /* we ignore the error in case we were not tracing child */
667 return bts_size; 767 (void)ds_release_bts(child);
668 } 768
669 cfg.size = PAGE_ALIGN(cfg.size); 769 if (cfg.flags & PTRACE_BTS_O_SIGNAL) {
770 if (!cfg.signal)
771 goto errout;
772
773 sig = cfg.signal;
774 ovfl = ptrace_bts_ovfl;
775 }
670 776
671 if (bts_size != cfg.size) { 777 error = ds_request_bts(child, /* base = */ NULL, cfg.size, ovfl);
672 ret = ptrace_bts_realloc(child, cfg.size, 778 if (error < 0)
673 cfg.flags & PTRACE_BTS_O_CUT_SIZE);
674 if (ret < 0)
675 goto errout; 779 goto errout;
676 780
677 ds = (void *)child->thread.ds_area_msr; 781 child->thread.bts_ovfl_signal = sig;
678 } 782 }
679 783
680 if (cfg.flags & PTRACE_BTS_O_SIGNAL) 784 error = -EINVAL;
681 ret = ds_set_overflow(ds, DS_O_SIGNAL); 785 if (!child->thread.ds_ctx && cfg.flags)
682 else
683 ret = ds_set_overflow(ds, DS_O_WRAP);
684 if (ret < 0)
685 goto errout; 786 goto errout;
686 787
687 if (cfg.flags & PTRACE_BTS_O_TRACE) 788 if (cfg.flags & PTRACE_BTS_O_TRACE)
688 child->thread.debugctlmsr |= ds_debugctl_mask(); 789 child->thread.debugctlmsr |= bts_cfg.debugctl_mask;
689 else 790 else
690 child->thread.debugctlmsr &= ~ds_debugctl_mask(); 791 child->thread.debugctlmsr &= ~bts_cfg.debugctl_mask;
691 792
692 if (cfg.flags & PTRACE_BTS_O_SCHED) 793 if (cfg.flags & PTRACE_BTS_O_SCHED)
693 set_tsk_thread_flag(child, TIF_BTS_TRACE_TS); 794 set_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
694 else 795 else
695 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS); 796 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
696 797
697 ret = sizeof(cfg); 798 error = sizeof(cfg);
698 799
699out: 800out:
700 if (child->thread.debugctlmsr) 801 if (child->thread.debugctlmsr)
@@ -702,10 +803,10 @@ out:
702 else 803 else
703 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR); 804 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
704 805
705 return ret; 806 return error;
706 807
707errout: 808errout:
708 child->thread.debugctlmsr &= ~ds_debugctl_mask(); 809 child->thread.debugctlmsr &= ~bts_cfg.debugctl_mask;
709 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS); 810 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
710 goto out; 811 goto out;
711} 812}
@@ -714,29 +815,40 @@ static int ptrace_bts_status(struct task_struct *child,
714 long cfg_size, 815 long cfg_size,
715 struct ptrace_bts_config __user *ucfg) 816 struct ptrace_bts_config __user *ucfg)
716{ 817{
717 void *ds = (void *)child->thread.ds_area_msr;
718 struct ptrace_bts_config cfg; 818 struct ptrace_bts_config cfg;
819 size_t end;
820 const void *base, *max;
821 int error;
719 822
720 if (cfg_size < sizeof(cfg)) 823 if (cfg_size < sizeof(cfg))
721 return -EIO; 824 return -EIO;
722 825
723 memset(&cfg, 0, sizeof(cfg)); 826 error = ds_get_bts_end(child, &end);
827 if (error < 0)
828 return error;
724 829
725 if (ds) { 830 error = ds_access_bts(child, /* index = */ 0, &base);
726 cfg.size = ds_get_bts_size(ds); 831 if (error < 0)
832 return error;
727 833
728 if (ds_get_overflow(ds) == DS_O_SIGNAL) 834 error = ds_access_bts(child, /* index = */ end, &max);
729 cfg.flags |= PTRACE_BTS_O_SIGNAL; 835 if (error < 0)
836 return error;
730 837
731 if (test_tsk_thread_flag(child, TIF_DEBUGCTLMSR) && 838 memset(&cfg, 0, sizeof(cfg));
732 child->thread.debugctlmsr & ds_debugctl_mask()) 839 cfg.size = (max - base);
733 cfg.flags |= PTRACE_BTS_O_TRACE; 840 cfg.signal = child->thread.bts_ovfl_signal;
841 cfg.bts_size = sizeof(struct bts_struct);
734 842
735 if (test_tsk_thread_flag(child, TIF_BTS_TRACE_TS)) 843 if (cfg.signal)
736 cfg.flags |= PTRACE_BTS_O_SCHED; 844 cfg.flags |= PTRACE_BTS_O_SIGNAL;
737 }
738 845
739 cfg.bts_size = sizeof(struct bts_struct); 846 if (test_tsk_thread_flag(child, TIF_DEBUGCTLMSR) &&
847 child->thread.debugctlmsr & bts_cfg.debugctl_mask)
848 cfg.flags |= PTRACE_BTS_O_TRACE;
849
850 if (test_tsk_thread_flag(child, TIF_BTS_TRACE_TS))
851 cfg.flags |= PTRACE_BTS_O_SCHED;
740 852
741 if (copy_to_user(ucfg, &cfg, sizeof(cfg))) 853 if (copy_to_user(ucfg, &cfg, sizeof(cfg)))
742 return -EFAULT; 854 return -EFAULT;
@@ -744,89 +856,38 @@ static int ptrace_bts_status(struct task_struct *child,
744 return sizeof(cfg); 856 return sizeof(cfg);
745} 857}
746 858
747
748static int ptrace_bts_write_record(struct task_struct *child, 859static int ptrace_bts_write_record(struct task_struct *child,
749 const struct bts_struct *in) 860 const struct bts_struct *in)
750{ 861{
751 int retval; 862 unsigned char bts_record[BTS_MAX_RECORD_SIZE];
752 863
753 if (!child->thread.ds_area_msr) 864 BUG_ON(BTS_MAX_RECORD_SIZE < bts_cfg.sizeof_bts);
754 return -ENXIO;
755 865
756 retval = ds_write_bts((void *)child->thread.ds_area_msr, in); 866 memset(bts_record, 0, bts_cfg.sizeof_bts);
757 if (retval) 867 switch (in->qualifier) {
758 return retval; 868 case BTS_INVALID:
869 break;
759 870
760 return sizeof(*in); 871 case BTS_BRANCH:
761} 872 bts_set(bts_record, bts_from, in->variant.lbr.from_ip);
873 bts_set(bts_record, bts_to, in->variant.lbr.to_ip);
874 break;
762 875
763static int ptrace_bts_realloc(struct task_struct *child, 876 case BTS_TASK_ARRIVES:
764 int size, int reduce_size) 877 case BTS_TASK_DEPARTS:
765{ 878 bts_set(bts_record, bts_from, bts_escape);
766 unsigned long rlim, vm; 879 bts_set(bts_record, bts_qual, in->qualifier);
767 int ret, old_size; 880 bts_set(bts_record, bts_jiffies, in->variant.jiffies);
881 break;
768 882
769 if (size < 0) 883 default:
770 return -EINVAL; 884 return -EINVAL;
771
772 old_size = ds_get_bts_size((void *)child->thread.ds_area_msr);
773 if (old_size < 0)
774 return old_size;
775
776 ret = ds_free((void **)&child->thread.ds_area_msr);
777 if (ret < 0)
778 goto out;
779
780 size >>= PAGE_SHIFT;
781 old_size >>= PAGE_SHIFT;
782
783 current->mm->total_vm -= old_size;
784 current->mm->locked_vm -= old_size;
785
786 if (size == 0)
787 goto out;
788
789 rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
790 vm = current->mm->total_vm + size;
791 if (rlim < vm) {
792 ret = -ENOMEM;
793
794 if (!reduce_size)
795 goto out;
796
797 size = rlim - current->mm->total_vm;
798 if (size <= 0)
799 goto out;
800 }
801
802 rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
803 vm = current->mm->locked_vm + size;
804 if (rlim < vm) {
805 ret = -ENOMEM;
806
807 if (!reduce_size)
808 goto out;
809
810 size = rlim - current->mm->locked_vm;
811 if (size <= 0)
812 goto out;
813 } 885 }
814 886
815 ret = ds_allocate((void **)&child->thread.ds_area_msr, 887 /* The writing task will be the switched-to task on a context
816 size << PAGE_SHIFT); 888 * switch. It needs to write into the switched-from task's BTS
817 if (ret < 0) 889 * buffer. */
818 goto out; 890 return ds_unchecked_write_bts(child, bts_record, bts_cfg.sizeof_bts);
819
820 current->mm->total_vm += size;
821 current->mm->locked_vm += size;
822
823out:
824 if (child->thread.ds_area_msr)
825 set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
826 else
827 clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);
828
829 return ret;
830} 891}
831 892
832void ptrace_bts_take_timestamp(struct task_struct *tsk, 893void ptrace_bts_take_timestamp(struct task_struct *tsk,
@@ -839,7 +900,66 @@ void ptrace_bts_take_timestamp(struct task_struct *tsk,
839 900
840 ptrace_bts_write_record(tsk, &rec); 901 ptrace_bts_write_record(tsk, &rec);
841} 902}
842#endif /* X86_BTS */ 903
904static const struct bts_configuration bts_cfg_netburst = {
905 .sizeof_bts = sizeof(long) * 3,
906 .sizeof_field = sizeof(long),
907 .debugctl_mask = (1<<2)|(1<<3)|(1<<5)
908};
909
910static const struct bts_configuration bts_cfg_pentium_m = {
911 .sizeof_bts = sizeof(long) * 3,
912 .sizeof_field = sizeof(long),
913 .debugctl_mask = (1<<6)|(1<<7)
914};
915
916static const struct bts_configuration bts_cfg_core2 = {
917 .sizeof_bts = 8 * 3,
918 .sizeof_field = 8,
919 .debugctl_mask = (1<<6)|(1<<7)|(1<<9)
920};
921
922static inline void bts_configure(const struct bts_configuration *cfg)
923{
924 bts_cfg = *cfg;
925}
926
927void __cpuinit ptrace_bts_init_intel(struct cpuinfo_x86 *c)
928{
929 switch (c->x86) {
930 case 0x6:
931 switch (c->x86_model) {
932 case 0xD:
933 case 0xE: /* Pentium M */
934 bts_configure(&bts_cfg_pentium_m);
935 break;
936 case 0xF: /* Core2 */
937 case 0x1C: /* Atom */
938 bts_configure(&bts_cfg_core2);
939 break;
940 default:
941 /* sorry, don't know about them */
942 break;
943 }
944 break;
945 case 0xF:
946 switch (c->x86_model) {
947 case 0x0:
948 case 0x1:
949 case 0x2: /* Netburst */
950 bts_configure(&bts_cfg_netburst);
951 break;
952 default:
953 /* sorry, don't know about them */
954 break;
955 }
956 break;
957 default:
958 /* sorry, don't know about them */
959 break;
960 }
961}
962#endif /* CONFIG_X86_PTRACE_BTS */
843 963
844/* 964/*
845 * Called by kernel/ptrace.c when detaching.. 965 * Called by kernel/ptrace.c when detaching..
@@ -852,15 +972,15 @@ void ptrace_disable(struct task_struct *child)
852#ifdef TIF_SYSCALL_EMU 972#ifdef TIF_SYSCALL_EMU
853 clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); 973 clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
854#endif 974#endif
855 if (child->thread.ds_area_msr) { 975#ifdef CONFIG_X86_PTRACE_BTS
856#ifdef X86_BTS 976 (void)ds_release_bts(child);
857 ptrace_bts_realloc(child, 0, 0); 977
858#endif 978 child->thread.debugctlmsr &= ~bts_cfg.debugctl_mask;
859 child->thread.debugctlmsr &= ~ds_debugctl_mask(); 979 if (!child->thread.debugctlmsr)
860 if (!child->thread.debugctlmsr) 980 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
861 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR); 981
862 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS); 982 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
863 } 983#endif /* CONFIG_X86_PTRACE_BTS */
864} 984}
865 985
866#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION 986#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
@@ -980,7 +1100,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
980 /* 1100 /*
981 * These bits need more cooking - not enabled yet: 1101 * These bits need more cooking - not enabled yet:
982 */ 1102 */
983#ifdef X86_BTS 1103#ifdef CONFIG_X86_PTRACE_BTS
984 case PTRACE_BTS_CONFIG: 1104 case PTRACE_BTS_CONFIG:
985 ret = ptrace_bts_config 1105 ret = ptrace_bts_config
986 (child, data, (struct ptrace_bts_config __user *)addr); 1106 (child, data, (struct ptrace_bts_config __user *)addr);
@@ -992,7 +1112,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
992 break; 1112 break;
993 1113
994 case PTRACE_BTS_SIZE: 1114 case PTRACE_BTS_SIZE:
995 ret = ptrace_bts_get_size(child); 1115 ret = ds_get_bts_index(child, /* pos = */ NULL);
996 break; 1116 break;
997 1117
998 case PTRACE_BTS_GET: 1118 case PTRACE_BTS_GET:
@@ -1001,14 +1121,14 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1001 break; 1121 break;
1002 1122
1003 case PTRACE_BTS_CLEAR: 1123 case PTRACE_BTS_CLEAR:
1004 ret = ptrace_bts_clear(child); 1124 ret = ds_clear_bts(child);
1005 break; 1125 break;
1006 1126
1007 case PTRACE_BTS_DRAIN: 1127 case PTRACE_BTS_DRAIN:
1008 ret = ptrace_bts_drain 1128 ret = ptrace_bts_drain
1009 (child, data, (struct bts_struct __user *) addr); 1129 (child, data, (struct bts_struct __user *) addr);
1010 break; 1130 break;
1011#endif 1131#endif /* CONFIG_X86_PTRACE_BTS */
1012 1132
1013 default: 1133 default:
1014 ret = ptrace_request(child, request, addr, data); 1134 ret = ptrace_request(child, request, addr, data);
@@ -1290,6 +1410,12 @@ static const struct user_regset x86_64_regsets[] = {
1290 .size = sizeof(long), .align = sizeof(long), 1410 .size = sizeof(long), .align = sizeof(long),
1291 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set 1411 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
1292 }, 1412 },
1413 [REGSET_IOPERM64] = {
1414 .core_note_type = NT_386_IOPERM,
1415 .n = IO_BITMAP_LONGS,
1416 .size = sizeof(long), .align = sizeof(long),
1417 .active = ioperm_active, .get = ioperm_get
1418 },
1293}; 1419};
1294 1420
1295static const struct user_regset_view user_x86_64_view = { 1421static const struct user_regset_view user_x86_64_view = {
@@ -1336,6 +1462,12 @@ static const struct user_regset x86_32_regsets[] = {
1336 .active = regset_tls_active, 1462 .active = regset_tls_active,
1337 .get = regset_tls_get, .set = regset_tls_set 1463 .get = regset_tls_get, .set = regset_tls_set
1338 }, 1464 },
1465 [REGSET_IOPERM32] = {
1466 .core_note_type = NT_386_IOPERM,
1467 .n = IO_BITMAP_BYTES / sizeof(u32),
1468 .size = sizeof(u32), .align = sizeof(u32),
1469 .active = ioperm_active, .get = ioperm_get
1470 },
1339}; 1471};
1340 1472
1341static const struct user_regset_view user_x86_32_view = { 1473static const struct user_regset_view user_x86_32_view = {
@@ -1357,7 +1489,8 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
1357#endif 1489#endif
1358} 1490}
1359 1491
1360void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code) 1492void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
1493 int error_code, int si_code)
1361{ 1494{
1362 struct siginfo info; 1495 struct siginfo info;
1363 1496
@@ -1366,7 +1499,7 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
1366 1499
1367 memset(&info, 0, sizeof(info)); 1500 memset(&info, 0, sizeof(info));
1368 info.si_signo = SIGTRAP; 1501 info.si_signo = SIGTRAP;
1369 info.si_code = TRAP_BRKPT; 1502 info.si_code = si_code;
1370 1503
1371 /* User-mode ip? */ 1504 /* User-mode ip? */
1372 info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL; 1505 info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL;
@@ -1375,30 +1508,6 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
1375 force_sig_info(SIGTRAP, &info, tsk); 1508 force_sig_info(SIGTRAP, &info, tsk);
1376} 1509}
1377 1510
1378static void syscall_trace(struct pt_regs *regs)
1379{
1380 if (!(current->ptrace & PT_PTRACED))
1381 return;
1382
1383#if 0
1384 printk("trace %s ip %lx sp %lx ax %d origrax %d caller %lx tiflags %x ptrace %x\n",
1385 current->comm,
1386 regs->ip, regs->sp, regs->ax, regs->orig_ax, __builtin_return_address(0),
1387 current_thread_info()->flags, current->ptrace);
1388#endif
1389
1390 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1391 ? 0x80 : 0));
1392 /*
1393 * this isn't the same as continuing with a signal, but it will do
1394 * for normal use. strace only continues with a signal if the
1395 * stopping signal is not SIGTRAP. -brl
1396 */
1397 if (current->exit_code) {
1398 send_sig(current->exit_code, current, 1);
1399 current->exit_code = 0;
1400 }
1401}
1402 1511
1403#ifdef CONFIG_X86_32 1512#ifdef CONFIG_X86_32
1404# define IS_IA32 1 1513# define IS_IA32 1
@@ -1432,8 +1541,9 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
1432 if (unlikely(test_thread_flag(TIF_SYSCALL_EMU))) 1541 if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
1433 ret = -1L; 1542 ret = -1L;
1434 1543
1435 if (ret || test_thread_flag(TIF_SYSCALL_TRACE)) 1544 if ((ret || test_thread_flag(TIF_SYSCALL_TRACE)) &&
1436 syscall_trace(regs); 1545 tracehook_report_syscall_entry(regs))
1546 ret = -1L;
1437 1547
1438 if (unlikely(current->audit_context)) { 1548 if (unlikely(current->audit_context)) {
1439 if (IS_IA32) 1549 if (IS_IA32)
@@ -1459,7 +1569,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
1459 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax); 1569 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
1460 1570
1461 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1571 if (test_thread_flag(TIF_SYSCALL_TRACE))
1462 syscall_trace(regs); 1572 tracehook_report_syscall_exit(regs, 0);
1463 1573
1464 /* 1574 /*
1465 * If TIF_SYSCALL_EMU is set, we only get here because of 1575 * If TIF_SYSCALL_EMU is set, we only get here because of
@@ -1475,6 +1585,6 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
1475 * system call instruction. 1585 * system call instruction.
1476 */ 1586 */
1477 if (test_thread_flag(TIF_SINGLESTEP) && 1587 if (test_thread_flag(TIF_SINGLESTEP) &&
1478 (current->ptrace & PT_PTRACED)) 1588 tracehook_consider_fatal_signal(current, SIGTRAP, SIG_DFL))
1479 send_sigtrap(current, regs, 0); 1589 send_sigtrap(current, regs, 0, TRAP_BRKPT);
1480} 1590}
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 724adfc63cb9..f4c93f1cfc19 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -29,7 +29,11 @@ EXPORT_SYMBOL(pm_power_off);
29 29
30static const struct desc_ptr no_idt = {}; 30static const struct desc_ptr no_idt = {};
31static int reboot_mode; 31static int reboot_mode;
32enum reboot_type reboot_type = BOOT_KBD; 32/*
33 * Keyboard reset and triple fault may result in INIT, not RESET, which
34 * doesn't work when we're in vmx root mode. Try ACPI first.
35 */
36enum reboot_type reboot_type = BOOT_ACPI;
33int reboot_force; 37int reboot_force;
34 38
35#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) 39#if defined(CONFIG_X86_32) && defined(CONFIG_SMP)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 9838f2539dfc..21b8e0a59780 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -223,6 +223,9 @@ unsigned long saved_video_mode;
223#define RAMDISK_LOAD_FLAG 0x4000 223#define RAMDISK_LOAD_FLAG 0x4000
224 224
225static char __initdata command_line[COMMAND_LINE_SIZE]; 225static char __initdata command_line[COMMAND_LINE_SIZE];
226#ifdef CONFIG_CMDLINE_BOOL
227static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
228#endif
226 229
227#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) 230#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
228struct edd edd; 231struct edd edd;
@@ -579,6 +582,190 @@ static struct x86_quirks default_x86_quirks __initdata;
579struct x86_quirks *x86_quirks __initdata = &default_x86_quirks; 582struct x86_quirks *x86_quirks __initdata = &default_x86_quirks;
580 583
581/* 584/*
585 * Some BIOSes seem to corrupt the low 64k of memory during events
586 * like suspend/resume and unplugging an HDMI cable. Reserve all
587 * remaining free memory in that area and fill it with a distinct
588 * pattern.
589 */
590#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
591#define MAX_SCAN_AREAS 8
592
593static int __read_mostly memory_corruption_check = -1;
594
595static unsigned __read_mostly corruption_check_size = 64*1024;
596static unsigned __read_mostly corruption_check_period = 60; /* seconds */
597
598static struct e820entry scan_areas[MAX_SCAN_AREAS];
599static int num_scan_areas;
600
601
602static int set_corruption_check(char *arg)
603{
604 char *end;
605
606 memory_corruption_check = simple_strtol(arg, &end, 10);
607
608 return (*end == 0) ? 0 : -EINVAL;
609}
610early_param("memory_corruption_check", set_corruption_check);
611
612static int set_corruption_check_period(char *arg)
613{
614 char *end;
615
616 corruption_check_period = simple_strtoul(arg, &end, 10);
617
618 return (*end == 0) ? 0 : -EINVAL;
619}
620early_param("memory_corruption_check_period", set_corruption_check_period);
621
622static int set_corruption_check_size(char *arg)
623{
624 char *end;
625 unsigned size;
626
627 size = memparse(arg, &end);
628
629 if (*end == '\0')
630 corruption_check_size = size;
631
632 return (size == corruption_check_size) ? 0 : -EINVAL;
633}
634early_param("memory_corruption_check_size", set_corruption_check_size);
635
636
637static void __init setup_bios_corruption_check(void)
638{
639 u64 addr = PAGE_SIZE; /* assume first page is reserved anyway */
640
641 if (memory_corruption_check == -1) {
642 memory_corruption_check =
643#ifdef CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
644 1
645#else
646 0
647#endif
648 ;
649 }
650
651 if (corruption_check_size == 0)
652 memory_corruption_check = 0;
653
654 if (!memory_corruption_check)
655 return;
656
657 corruption_check_size = round_up(corruption_check_size, PAGE_SIZE);
658
659 while(addr < corruption_check_size && num_scan_areas < MAX_SCAN_AREAS) {
660 u64 size;
661 addr = find_e820_area_size(addr, &size, PAGE_SIZE);
662
663 if (addr == 0)
664 break;
665
666 if ((addr + size) > corruption_check_size)
667 size = corruption_check_size - addr;
668
669 if (size == 0)
670 break;
671
672 e820_update_range(addr, size, E820_RAM, E820_RESERVED);
673 scan_areas[num_scan_areas].addr = addr;
674 scan_areas[num_scan_areas].size = size;
675 num_scan_areas++;
676
677 /* Assume we've already mapped this early memory */
678 memset(__va(addr), 0, size);
679
680 addr += size;
681 }
682
683 printk(KERN_INFO "Scanning %d areas for low memory corruption\n",
684 num_scan_areas);
685 update_e820();
686}
687
688static struct timer_list periodic_check_timer;
689
690void check_for_bios_corruption(void)
691{
692 int i;
693 int corruption = 0;
694
695 if (!memory_corruption_check)
696 return;
697
698 for(i = 0; i < num_scan_areas; i++) {
699 unsigned long *addr = __va(scan_areas[i].addr);
700 unsigned long size = scan_areas[i].size;
701
702 for(; size; addr++, size -= sizeof(unsigned long)) {
703 if (!*addr)
704 continue;
705 printk(KERN_ERR "Corrupted low memory at %p (%lx phys) = %08lx\n",
706 addr, __pa(addr), *addr);
707 corruption = 1;
708 *addr = 0;
709 }
710 }
711
712 WARN(corruption, KERN_ERR "Memory corruption detected in low memory\n");
713}
714
715static void periodic_check_for_corruption(unsigned long data)
716{
717 check_for_bios_corruption();
718 mod_timer(&periodic_check_timer, round_jiffies(jiffies + corruption_check_period*HZ));
719}
720
721void start_periodic_check_for_corruption(void)
722{
723 if (!memory_corruption_check || corruption_check_period == 0)
724 return;
725
726 printk(KERN_INFO "Scanning for low memory corruption every %d seconds\n",
727 corruption_check_period);
728
729 init_timer(&periodic_check_timer);
730 periodic_check_timer.function = &periodic_check_for_corruption;
731 periodic_check_for_corruption(0);
732}
733#endif
734
735static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
736{
737 printk(KERN_NOTICE
738 "%s detected: BIOS may corrupt low RAM, working it around.\n",
739 d->ident);
740
741 e820_update_range(0, 0x10000, E820_RAM, E820_RESERVED);
742 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
743
744 return 0;
745}
746
747/* List of systems that have known low memory corruption BIOS problems */
748static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
749#ifdef CONFIG_X86_RESERVE_LOW_64K
750 {
751 .callback = dmi_low_memory_corruption,
752 .ident = "AMI BIOS",
753 .matches = {
754 DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
755 },
756 },
757 {
758 .callback = dmi_low_memory_corruption,
759 .ident = "Phoenix BIOS",
760 .matches = {
761 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies, LTD"),
762 },
763 },
764#endif
765 {}
766};
767
768/*
582 * Determine if we were loaded by an EFI loader. If so, then we have also been 769 * Determine if we were loaded by an EFI loader. If so, then we have also been
583 * passed the efi memmap, systab, etc., so we should use these data structures 770 * passed the efi memmap, systab, etc., so we should use these data structures
584 * for initialization. Note, the efi init code path is determined by the 771 * for initialization. Note, the efi init code path is determined by the
@@ -665,6 +852,19 @@ void __init setup_arch(char **cmdline_p)
665 bss_resource.start = virt_to_phys(&__bss_start); 852 bss_resource.start = virt_to_phys(&__bss_start);
666 bss_resource.end = virt_to_phys(&__bss_stop)-1; 853 bss_resource.end = virt_to_phys(&__bss_stop)-1;
667 854
855#ifdef CONFIG_CMDLINE_BOOL
856#ifdef CONFIG_CMDLINE_OVERRIDE
857 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
858#else
859 if (builtin_cmdline[0]) {
860 /* append boot loader cmdline to builtin */
861 strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
862 strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
863 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
864 }
865#endif
866#endif
867
668 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); 868 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
669 *cmdline_p = command_line; 869 *cmdline_p = command_line;
670 870
@@ -699,6 +899,10 @@ void __init setup_arch(char **cmdline_p)
699 899
700 finish_e820_parsing(); 900 finish_e820_parsing();
701 901
902 dmi_scan_machine();
903
904 dmi_check_system(bad_bios_dmi_table);
905
702#ifdef CONFIG_X86_32 906#ifdef CONFIG_X86_32
703 probe_roms(); 907 probe_roms();
704#endif 908#endif
@@ -742,6 +946,8 @@ void __init setup_arch(char **cmdline_p)
742#else 946#else
743 num_physpages = max_pfn; 947 num_physpages = max_pfn;
744 948
949 if (cpu_has_x2apic)
950 check_x2apic();
745 951
746 /* How many end-of-memory variables you have, grandma! */ 952 /* How many end-of-memory variables you have, grandma! */
747 /* need this before calling reserve_initrd */ 953 /* need this before calling reserve_initrd */
@@ -753,6 +959,10 @@ void __init setup_arch(char **cmdline_p)
753 high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1; 959 high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
754#endif 960#endif
755 961
962#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
963 setup_bios_corruption_check();
964#endif
965
756 /* max_pfn_mapped is updated here */ 966 /* max_pfn_mapped is updated here */
757 max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT); 967 max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT);
758 max_pfn_mapped = max_low_pfn_mapped; 968 max_pfn_mapped = max_low_pfn_mapped;
@@ -781,8 +991,6 @@ void __init setup_arch(char **cmdline_p)
781 vsmp_init(); 991 vsmp_init();
782#endif 992#endif
783 993
784 dmi_scan_machine();
785
786 io_delay_init(); 994 io_delay_init();
787 995
788 /* 996 /*
@@ -885,3 +1093,5 @@ void __init setup_arch(char **cmdline_p)
885#endif 1093#endif
886#endif 1094#endif
887} 1095}
1096
1097
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 76e305e064f9..0e67f72d9316 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -162,9 +162,16 @@ void __init setup_per_cpu_areas(void)
162 printk(KERN_INFO 162 printk(KERN_INFO
163 "cpu %d has no node %d or node-local memory\n", 163 "cpu %d has no node %d or node-local memory\n",
164 cpu, node); 164 cpu, node);
165 if (ptr)
166 printk(KERN_DEBUG "per cpu data for cpu%d at %016lx\n",
167 cpu, __pa(ptr));
165 } 168 }
166 else 169 else {
167 ptr = alloc_bootmem_pages_node(NODE_DATA(node), size); 170 ptr = alloc_bootmem_pages_node(NODE_DATA(node), size);
171 if (ptr)
172 printk(KERN_DEBUG "per cpu data for cpu%d on node%d at %016lx\n",
173 cpu, node, __pa(ptr));
174 }
168#endif 175#endif
169 per_cpu_offset(cpu) = ptr - __per_cpu_start; 176 per_cpu_offset(cpu) = ptr - __per_cpu_start;
170 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); 177 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
diff --git a/arch/x86/kernel/sigframe.h b/arch/x86/kernel/sigframe.h
index 72bbb519d2dc..cc673aa55ce4 100644
--- a/arch/x86/kernel/sigframe.h
+++ b/arch/x86/kernel/sigframe.h
@@ -3,9 +3,18 @@ struct sigframe {
3 char __user *pretcode; 3 char __user *pretcode;
4 int sig; 4 int sig;
5 struct sigcontext sc; 5 struct sigcontext sc;
6 struct _fpstate fpstate; 6 /*
7 * fpstate is unused. fpstate is moved/allocated after
8 * retcode[] below. This movement allows to have the FP state and the
9 * future state extensions (xsave) stay together.
10 * And at the same time retaining the unused fpstate, prevents changing
11 * the offset of extramask[] in the sigframe and thus prevent any
12 * legacy application accessing/modifying it.
13 */
14 struct _fpstate fpstate_unused;
7 unsigned long extramask[_NSIG_WORDS-1]; 15 unsigned long extramask[_NSIG_WORDS-1];
8 char retcode[8]; 16 char retcode[8];
17 /* fp state follows here */
9}; 18};
10 19
11struct rt_sigframe { 20struct rt_sigframe {
@@ -15,13 +24,19 @@ struct rt_sigframe {
15 void __user *puc; 24 void __user *puc;
16 struct siginfo info; 25 struct siginfo info;
17 struct ucontext uc; 26 struct ucontext uc;
18 struct _fpstate fpstate;
19 char retcode[8]; 27 char retcode[8];
28 /* fp state follows here */
20}; 29};
21#else 30#else
22struct rt_sigframe { 31struct rt_sigframe {
23 char __user *pretcode; 32 char __user *pretcode;
24 struct ucontext uc; 33 struct ucontext uc;
25 struct siginfo info; 34 struct siginfo info;
35 /* fp state follows here */
26}; 36};
37
38int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
39 sigset_t *set, struct pt_regs *regs);
40int ia32_setup_frame(int sig, struct k_sigaction *ka,
41 sigset_t *set, struct pt_regs *regs);
27#endif 42#endif
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 6fb5bcdd8933..d6dd057d0f22 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -17,6 +17,7 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/wait.h> 19#include <linux/wait.h>
20#include <linux/tracehook.h>
20#include <linux/elf.h> 21#include <linux/elf.h>
21#include <linux/smp.h> 22#include <linux/smp.h>
22#include <linux/mm.h> 23#include <linux/mm.h>
@@ -26,6 +27,8 @@
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27#include <asm/i387.h> 28#include <asm/i387.h>
28#include <asm/vdso.h> 29#include <asm/vdso.h>
30#include <asm/syscall.h>
31#include <asm/syscalls.h>
29 32
30#include "sigframe.h" 33#include "sigframe.h"
31 34
@@ -110,6 +113,27 @@ asmlinkage int sys_sigaltstack(unsigned long bx)
110 return do_sigaltstack(uss, uoss, regs->sp); 113 return do_sigaltstack(uss, uoss, regs->sp);
111} 114}
112 115
116#define COPY(x) { \
117 err |= __get_user(regs->x, &sc->x); \
118}
119
120#define COPY_SEG(seg) { \
121 unsigned short tmp; \
122 err |= __get_user(tmp, &sc->seg); \
123 regs->seg = tmp; \
124}
125
126#define COPY_SEG_STRICT(seg) { \
127 unsigned short tmp; \
128 err |= __get_user(tmp, &sc->seg); \
129 regs->seg = tmp | 3; \
130}
131
132#define GET_SEG(seg) { \
133 unsigned short tmp; \
134 err |= __get_user(tmp, &sc->seg); \
135 loadsegment(seg, tmp); \
136}
113 137
114/* 138/*
115 * Do a signal return; undo the signal stack. 139 * Do a signal return; undo the signal stack.
@@ -118,28 +142,13 @@ static int
118restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, 142restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
119 unsigned long *pax) 143 unsigned long *pax)
120{ 144{
145 void __user *buf;
146 unsigned int tmpflags;
121 unsigned int err = 0; 147 unsigned int err = 0;
122 148
123 /* Always make any pending restarted system calls return -EINTR */ 149 /* Always make any pending restarted system calls return -EINTR */
124 current_thread_info()->restart_block.fn = do_no_restart_syscall; 150 current_thread_info()->restart_block.fn = do_no_restart_syscall;
125 151
126#define COPY(x) err |= __get_user(regs->x, &sc->x)
127
128#define COPY_SEG(seg) \
129 { unsigned short tmp; \
130 err |= __get_user(tmp, &sc->seg); \
131 regs->seg = tmp; }
132
133#define COPY_SEG_STRICT(seg) \
134 { unsigned short tmp; \
135 err |= __get_user(tmp, &sc->seg); \
136 regs->seg = tmp|3; }
137
138#define GET_SEG(seg) \
139 { unsigned short tmp; \
140 err |= __get_user(tmp, &sc->seg); \
141 loadsegment(seg, tmp); }
142
143 GET_SEG(gs); 152 GET_SEG(gs);
144 COPY_SEG(fs); 153 COPY_SEG(fs);
145 COPY_SEG(es); 154 COPY_SEG(es);
@@ -149,38 +158,15 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
149 COPY_SEG_STRICT(cs); 158 COPY_SEG_STRICT(cs);
150 COPY_SEG_STRICT(ss); 159 COPY_SEG_STRICT(ss);
151 160
152 { 161 err |= __get_user(tmpflags, &sc->flags);
153 unsigned int tmpflags; 162 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
154 163 regs->orig_ax = -1; /* disable syscall checks */
155 err |= __get_user(tmpflags, &sc->flags);
156 regs->flags = (regs->flags & ~FIX_EFLAGS) |
157 (tmpflags & FIX_EFLAGS);
158 regs->orig_ax = -1; /* disable syscall checks */
159 }
160 164
161 { 165 err |= __get_user(buf, &sc->fpstate);
162 struct _fpstate __user *buf; 166 err |= restore_i387_xstate(buf);
163
164 err |= __get_user(buf, &sc->fpstate);
165 if (buf) {
166 if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
167 goto badframe;
168 err |= restore_i387(buf);
169 } else {
170 struct task_struct *me = current;
171
172 if (used_math()) {
173 clear_fpu(me);
174 clear_used_math();
175 }
176 }
177 }
178 167
179 err |= __get_user(*pax, &sc->ax); 168 err |= __get_user(*pax, &sc->ax);
180 return err; 169 return err;
181
182badframe:
183 return 1;
184} 170}
185 171
186asmlinkage unsigned long sys_sigreturn(unsigned long __unused) 172asmlinkage unsigned long sys_sigreturn(unsigned long __unused)
@@ -226,9 +212,8 @@ badframe:
226 return 0; 212 return 0;
227} 213}
228 214
229asmlinkage int sys_rt_sigreturn(unsigned long __unused) 215static long do_rt_sigreturn(struct pt_regs *regs)
230{ 216{
231 struct pt_regs *regs = (struct pt_regs *)&__unused;
232 struct rt_sigframe __user *frame; 217 struct rt_sigframe __user *frame;
233 unsigned long ax; 218 unsigned long ax;
234 sigset_t set; 219 sigset_t set;
@@ -254,15 +239,22 @@ asmlinkage int sys_rt_sigreturn(unsigned long __unused)
254 return ax; 239 return ax;
255 240
256badframe: 241badframe:
257 force_sig(SIGSEGV, current); 242 signal_fault(regs, frame, "rt_sigreturn");
258 return 0; 243 return 0;
259} 244}
260 245
246asmlinkage int sys_rt_sigreturn(unsigned long __unused)
247{
248 struct pt_regs *regs = (struct pt_regs *)&__unused;
249
250 return do_rt_sigreturn(regs);
251}
252
261/* 253/*
262 * Set up a signal frame. 254 * Set up a signal frame.
263 */ 255 */
264static int 256static int
265setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, 257setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
266 struct pt_regs *regs, unsigned long mask) 258 struct pt_regs *regs, unsigned long mask)
267{ 259{
268 int tmp, err = 0; 260 int tmp, err = 0;
@@ -289,7 +281,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
289 err |= __put_user(regs->sp, &sc->sp_at_signal); 281 err |= __put_user(regs->sp, &sc->sp_at_signal);
290 err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss); 282 err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);
291 283
292 tmp = save_i387(fpstate); 284 tmp = save_i387_xstate(fpstate);
293 if (tmp < 0) 285 if (tmp < 0)
294 err = 1; 286 err = 1;
295 else 287 else
@@ -306,7 +298,8 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
306 * Determine which stack to use.. 298 * Determine which stack to use..
307 */ 299 */
308static inline void __user * 300static inline void __user *
309get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) 301get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
302 void **fpstate)
310{ 303{
311 unsigned long sp; 304 unsigned long sp;
312 305
@@ -332,6 +325,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
332 sp = (unsigned long) ka->sa.sa_restorer; 325 sp = (unsigned long) ka->sa.sa_restorer;
333 } 326 }
334 327
328 if (used_math()) {
329 sp = sp - sig_xstate_size;
330 *fpstate = (struct _fpstate *) sp;
331 }
332
335 sp -= frame_size; 333 sp -= frame_size;
336 /* 334 /*
337 * Align the stack pointer according to the i386 ABI, 335 * Align the stack pointer according to the i386 ABI,
@@ -343,38 +341,29 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
343} 341}
344 342
345static int 343static int
346setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, 344__setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
347 struct pt_regs *regs) 345 struct pt_regs *regs)
348{ 346{
349 struct sigframe __user *frame; 347 struct sigframe __user *frame;
350 void __user *restorer; 348 void __user *restorer;
351 int err = 0; 349 int err = 0;
352 int usig; 350 void __user *fpstate = NULL;
353 351
354 frame = get_sigframe(ka, regs, sizeof(*frame)); 352 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
355 353
356 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 354 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
357 goto give_sigsegv; 355 return -EFAULT;
358 356
359 usig = current_thread_info()->exec_domain 357 if (__put_user(sig, &frame->sig))
360 && current_thread_info()->exec_domain->signal_invmap 358 return -EFAULT;
361 && sig < 32
362 ? current_thread_info()->exec_domain->signal_invmap[sig]
363 : sig;
364 359
365 err = __put_user(usig, &frame->sig); 360 if (setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]))
366 if (err) 361 return -EFAULT;
367 goto give_sigsegv;
368
369 err = setup_sigcontext(&frame->sc, &frame->fpstate, regs, set->sig[0]);
370 if (err)
371 goto give_sigsegv;
372 362
373 if (_NSIG_WORDS > 1) { 363 if (_NSIG_WORDS > 1) {
374 err = __copy_to_user(&frame->extramask, &set->sig[1], 364 if (__copy_to_user(&frame->extramask, &set->sig[1],
375 sizeof(frame->extramask)); 365 sizeof(frame->extramask)))
376 if (err) 366 return -EFAULT;
377 goto give_sigsegv;
378 } 367 }
379 368
380 if (current->mm->context.vdso) 369 if (current->mm->context.vdso)
@@ -399,7 +388,7 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
399 err |= __put_user(0x80cd, (short __user *)(frame->retcode+6)); 388 err |= __put_user(0x80cd, (short __user *)(frame->retcode+6));
400 389
401 if (err) 390 if (err)
402 goto give_sigsegv; 391 return -EFAULT;
403 392
404 /* Set up registers for signal handler */ 393 /* Set up registers for signal handler */
405 regs->sp = (unsigned long)frame; 394 regs->sp = (unsigned long)frame;
@@ -414,50 +403,43 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
414 regs->cs = __USER_CS; 403 regs->cs = __USER_CS;
415 404
416 return 0; 405 return 0;
417
418give_sigsegv:
419 force_sigsegv(sig, current);
420 return -EFAULT;
421} 406}
422 407
423static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 408static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
424 sigset_t *set, struct pt_regs *regs) 409 sigset_t *set, struct pt_regs *regs)
425{ 410{
426 struct rt_sigframe __user *frame; 411 struct rt_sigframe __user *frame;
427 void __user *restorer; 412 void __user *restorer;
428 int err = 0; 413 int err = 0;
429 int usig; 414 void __user *fpstate = NULL;
430 415
431 frame = get_sigframe(ka, regs, sizeof(*frame)); 416 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
432 417
433 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 418 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
434 goto give_sigsegv; 419 return -EFAULT;
435 420
436 usig = current_thread_info()->exec_domain 421 err |= __put_user(sig, &frame->sig);
437 && current_thread_info()->exec_domain->signal_invmap
438 && sig < 32
439 ? current_thread_info()->exec_domain->signal_invmap[sig]
440 : sig;
441
442 err |= __put_user(usig, &frame->sig);
443 err |= __put_user(&frame->info, &frame->pinfo); 422 err |= __put_user(&frame->info, &frame->pinfo);
444 err |= __put_user(&frame->uc, &frame->puc); 423 err |= __put_user(&frame->uc, &frame->puc);
445 err |= copy_siginfo_to_user(&frame->info, info); 424 err |= copy_siginfo_to_user(&frame->info, info);
446 if (err) 425 if (err)
447 goto give_sigsegv; 426 return -EFAULT;
448 427
449 /* Create the ucontext. */ 428 /* Create the ucontext. */
450 err |= __put_user(0, &frame->uc.uc_flags); 429 if (cpu_has_xsave)
430 err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags);
431 else
432 err |= __put_user(0, &frame->uc.uc_flags);
451 err |= __put_user(0, &frame->uc.uc_link); 433 err |= __put_user(0, &frame->uc.uc_link);
452 err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 434 err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
453 err |= __put_user(sas_ss_flags(regs->sp), 435 err |= __put_user(sas_ss_flags(regs->sp),
454 &frame->uc.uc_stack.ss_flags); 436 &frame->uc.uc_stack.ss_flags);
455 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); 437 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
456 err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate, 438 err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
457 regs, set->sig[0]); 439 regs, set->sig[0]);
458 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); 440 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
459 if (err) 441 if (err)
460 goto give_sigsegv; 442 return -EFAULT;
461 443
462 /* Set up to return from userspace. */ 444 /* Set up to return from userspace. */
463 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn); 445 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
@@ -477,12 +459,12 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
477 err |= __put_user(0x80cd, (short __user *)(frame->retcode+5)); 459 err |= __put_user(0x80cd, (short __user *)(frame->retcode+5));
478 460
479 if (err) 461 if (err)
480 goto give_sigsegv; 462 return -EFAULT;
481 463
482 /* Set up registers for signal handler */ 464 /* Set up registers for signal handler */
483 regs->sp = (unsigned long)frame; 465 regs->sp = (unsigned long)frame;
484 regs->ip = (unsigned long)ka->sa.sa_handler; 466 regs->ip = (unsigned long)ka->sa.sa_handler;
485 regs->ax = (unsigned long)usig; 467 regs->ax = (unsigned long)sig;
486 regs->dx = (unsigned long)&frame->info; 468 regs->dx = (unsigned long)&frame->info;
487 regs->cx = (unsigned long)&frame->uc; 469 regs->cx = (unsigned long)&frame->uc;
488 470
@@ -492,15 +474,48 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
492 regs->cs = __USER_CS; 474 regs->cs = __USER_CS;
493 475
494 return 0; 476 return 0;
495
496give_sigsegv:
497 force_sigsegv(sig, current);
498 return -EFAULT;
499} 477}
500 478
501/* 479/*
502 * OK, we're invoking a handler: 480 * OK, we're invoking a handler:
503 */ 481 */
482static int signr_convert(int sig)
483{
484 struct thread_info *info = current_thread_info();
485
486 if (info->exec_domain && info->exec_domain->signal_invmap && sig < 32)
487 return info->exec_domain->signal_invmap[sig];
488 return sig;
489}
490
491#define is_ia32 1
492#define ia32_setup_frame __setup_frame
493#define ia32_setup_rt_frame __setup_rt_frame
494
495static int
496setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
497 sigset_t *set, struct pt_regs *regs)
498{
499 int usig = signr_convert(sig);
500 int ret;
501
502 /* Set up the stack frame */
503 if (is_ia32) {
504 if (ka->sa.sa_flags & SA_SIGINFO)
505 ret = ia32_setup_rt_frame(usig, ka, info, set, regs);
506 else
507 ret = ia32_setup_frame(usig, ka, set, regs);
508 } else
509 ret = __setup_rt_frame(sig, ka, info, set, regs);
510
511 if (ret) {
512 force_sigsegv(sig, current);
513 return -EFAULT;
514 }
515
516 return ret;
517}
518
504static int 519static int
505handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 520handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
506 sigset_t *oldset, struct pt_regs *regs) 521 sigset_t *oldset, struct pt_regs *regs)
@@ -508,9 +523,9 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
508 int ret; 523 int ret;
509 524
510 /* Are we from a system call? */ 525 /* Are we from a system call? */
511 if ((long)regs->orig_ax >= 0) { 526 if (syscall_get_nr(current, regs) >= 0) {
512 /* If so, check system call restarting.. */ 527 /* If so, check system call restarting.. */
513 switch (regs->ax) { 528 switch (syscall_get_error(current, regs)) {
514 case -ERESTART_RESTARTBLOCK: 529 case -ERESTART_RESTARTBLOCK:
515 case -ERESTARTNOHAND: 530 case -ERESTARTNOHAND:
516 regs->ax = -EINTR; 531 regs->ax = -EINTR;
@@ -537,15 +552,20 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
537 likely(test_and_clear_thread_flag(TIF_FORCED_TF))) 552 likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
538 regs->flags &= ~X86_EFLAGS_TF; 553 regs->flags &= ~X86_EFLAGS_TF;
539 554
540 /* Set up the stack frame */ 555 ret = setup_rt_frame(sig, ka, info, oldset, regs);
541 if (ka->sa.sa_flags & SA_SIGINFO)
542 ret = setup_rt_frame(sig, ka, info, oldset, regs);
543 else
544 ret = setup_frame(sig, ka, oldset, regs);
545 556
546 if (ret) 557 if (ret)
547 return ret; 558 return ret;
548 559
560#ifdef CONFIG_X86_64
561 /*
562 * This has nothing to do with segment registers,
563 * despite the name. This magic affects uaccess.h
564 * macros' behavior. Reset it to the normal setting.
565 */
566 set_fs(USER_DS);
567#endif
568
549 /* 569 /*
550 * Clear the direction flag as per the ABI for function entry. 570 * Clear the direction flag as per the ABI for function entry.
551 */ 571 */
@@ -558,8 +578,6 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
558 * handler too. 578 * handler too.
559 */ 579 */
560 regs->flags &= ~X86_EFLAGS_TF; 580 regs->flags &= ~X86_EFLAGS_TF;
561 if (test_thread_flag(TIF_SINGLESTEP))
562 ptrace_notify(SIGTRAP);
563 581
564 spin_lock_irq(&current->sighand->siglock); 582 spin_lock_irq(&current->sighand->siglock);
565 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask); 583 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
@@ -568,9 +586,13 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
568 recalc_sigpending(); 586 recalc_sigpending();
569 spin_unlock_irq(&current->sighand->siglock); 587 spin_unlock_irq(&current->sighand->siglock);
570 588
589 tracehook_signal_handler(sig, info, ka, regs,
590 test_thread_flag(TIF_SINGLESTEP));
591
571 return 0; 592 return 0;
572} 593}
573 594
595#define NR_restart_syscall __NR_restart_syscall
574/* 596/*
575 * Note that 'init' is a special process: it doesn't get signals it doesn't 597 * Note that 'init' is a special process: it doesn't get signals it doesn't
576 * want to handle. Thus you cannot kill init even with a SIGKILL even by 598 * want to handle. Thus you cannot kill init even with a SIGKILL even by
@@ -623,9 +645,9 @@ static void do_signal(struct pt_regs *regs)
623 } 645 }
624 646
625 /* Did we come from a system call? */ 647 /* Did we come from a system call? */
626 if ((long)regs->orig_ax >= 0) { 648 if (syscall_get_nr(current, regs) >= 0) {
627 /* Restart the system call - no handlers present */ 649 /* Restart the system call - no handlers present */
628 switch (regs->ax) { 650 switch (syscall_get_error(current, regs)) {
629 case -ERESTARTNOHAND: 651 case -ERESTARTNOHAND:
630 case -ERESTARTSYS: 652 case -ERESTARTSYS:
631 case -ERESTARTNOINTR: 653 case -ERESTARTNOINTR:
@@ -634,7 +656,7 @@ static void do_signal(struct pt_regs *regs)
634 break; 656 break;
635 657
636 case -ERESTART_RESTARTBLOCK: 658 case -ERESTART_RESTARTBLOCK:
637 regs->ax = __NR_restart_syscall; 659 regs->ax = NR_restart_syscall;
638 regs->ip -= 2; 660 regs->ip -= 2;
639 break; 661 break;
640 } 662 }
@@ -657,9 +679,38 @@ static void do_signal(struct pt_regs *regs)
657void 679void
658do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags) 680do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
659{ 681{
682#if defined(CONFIG_X86_64) && defined(CONFIG_X86_MCE)
683 /* notify userspace of pending MCEs */
684 if (thread_info_flags & _TIF_MCE_NOTIFY)
685 mce_notify_user();
686#endif /* CONFIG_X86_64 && CONFIG_X86_MCE */
687
660 /* deal with pending signal delivery */ 688 /* deal with pending signal delivery */
661 if (thread_info_flags & _TIF_SIGPENDING) 689 if (thread_info_flags & _TIF_SIGPENDING)
662 do_signal(regs); 690 do_signal(regs);
663 691
692 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
693 clear_thread_flag(TIF_NOTIFY_RESUME);
694 tracehook_notify_resume(regs);
695 }
696
697#ifdef CONFIG_X86_32
664 clear_thread_flag(TIF_IRET); 698 clear_thread_flag(TIF_IRET);
699#endif /* CONFIG_X86_32 */
700}
701
702void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
703{
704 struct task_struct *me = current;
705
706 if (show_unhandled_signals && printk_ratelimit()) {
707 printk(KERN_INFO
708 "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
709 me->comm, me->pid, where, frame,
710 regs->ip, regs->sp, regs->orig_ax);
711 print_vma_addr(" in ", regs->ip);
712 printk(KERN_CONT "\n");
713 }
714
715 force_sig(SIGSEGV, me);
665} 716}
diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
index ca316b5b742c..a5c9627f4db9 100644
--- a/arch/x86/kernel/signal_64.c
+++ b/arch/x86/kernel/signal_64.c
@@ -15,17 +15,21 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/wait.h> 16#include <linux/wait.h>
17#include <linux/ptrace.h> 17#include <linux/ptrace.h>
18#include <linux/tracehook.h>
18#include <linux/unistd.h> 19#include <linux/unistd.h>
19#include <linux/stddef.h> 20#include <linux/stddef.h>
20#include <linux/personality.h> 21#include <linux/personality.h>
21#include <linux/compiler.h> 22#include <linux/compiler.h>
23#include <linux/uaccess.h>
24
22#include <asm/processor.h> 25#include <asm/processor.h>
23#include <asm/ucontext.h> 26#include <asm/ucontext.h>
24#include <asm/uaccess.h>
25#include <asm/i387.h> 27#include <asm/i387.h>
26#include <asm/proto.h> 28#include <asm/proto.h>
27#include <asm/ia32_unistd.h> 29#include <asm/ia32_unistd.h>
28#include <asm/mce.h> 30#include <asm/mce.h>
31#include <asm/syscall.h>
32#include <asm/syscalls.h>
29#include "sigframe.h" 33#include "sigframe.h"
30 34
31#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 35#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
@@ -41,11 +45,6 @@
41# define FIX_EFLAGS __FIX_EFLAGS 45# define FIX_EFLAGS __FIX_EFLAGS
42#endif 46#endif
43 47
44int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
45 sigset_t *set, struct pt_regs * regs);
46int ia32_setup_frame(int sig, struct k_sigaction *ka,
47 sigset_t *set, struct pt_regs * regs);
48
49asmlinkage long 48asmlinkage long
50sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, 49sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
51 struct pt_regs *regs) 50 struct pt_regs *regs)
@@ -53,67 +52,14 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
53 return do_sigaltstack(uss, uoss, regs->sp); 52 return do_sigaltstack(uss, uoss, regs->sp);
54} 53}
55 54
56/* 55#define COPY(x) { \
57 * Signal frame handlers. 56 err |= __get_user(regs->x, &sc->x); \
58 */
59
60static inline int save_i387(struct _fpstate __user *buf)
61{
62 struct task_struct *tsk = current;
63 int err = 0;
64
65 BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
66 sizeof(tsk->thread.xstate->fxsave));
67
68 if ((unsigned long)buf % 16)
69 printk("save_i387: bad fpstate %p\n", buf);
70
71 if (!used_math())
72 return 0;
73 clear_used_math(); /* trigger finit */
74 if (task_thread_info(tsk)->status & TS_USEDFPU) {
75 err = save_i387_checking((struct i387_fxsave_struct __user *)
76 buf);
77 if (err)
78 return err;
79 task_thread_info(tsk)->status &= ~TS_USEDFPU;
80 stts();
81 } else {
82 if (__copy_to_user(buf, &tsk->thread.xstate->fxsave,
83 sizeof(struct i387_fxsave_struct)))
84 return -1;
85 }
86 return 1;
87} 57}
88 58
89/* 59#define COPY_SEG_STRICT(seg) { \
90 * This restores directly out of user space. Exceptions are handled. 60 unsigned short tmp; \
91 */ 61 err |= __get_user(tmp, &sc->seg); \
92static inline int restore_i387(struct _fpstate __user *buf) 62 regs->seg = tmp | 3; \
93{
94 struct task_struct *tsk = current;
95 int err;
96
97 if (!used_math()) {
98 err = init_fpu(tsk);
99 if (err)
100 return err;
101 }
102
103 if (!(task_thread_info(current)->status & TS_USEDFPU)) {
104 clts();
105 task_thread_info(current)->status |= TS_USEDFPU;
106 }
107 err = restore_fpu_checking((__force struct i387_fxsave_struct *)buf);
108 if (unlikely(err)) {
109 /*
110 * Encountered an error while doing the restore from the
111 * user buffer, clear the fpu state.
112 */
113 clear_fpu(tsk);
114 clear_used_math();
115 }
116 return err;
117} 63}
118 64
119/* 65/*
@@ -123,13 +69,13 @@ static int
123restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, 69restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
124 unsigned long *pax) 70 unsigned long *pax)
125{ 71{
72 void __user *buf;
73 unsigned int tmpflags;
126 unsigned int err = 0; 74 unsigned int err = 0;
127 75
128 /* Always make any pending restarted system calls return -EINTR */ 76 /* Always make any pending restarted system calls return -EINTR */
129 current_thread_info()->restart_block.fn = do_no_restart_syscall; 77 current_thread_info()->restart_block.fn = do_no_restart_syscall;
130 78
131#define COPY(x) err |= __get_user(regs->x, &sc->x)
132
133 COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx); 79 COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
134 COPY(dx); COPY(cx); COPY(ip); 80 COPY(dx); COPY(cx); COPY(ip);
135 COPY(r8); 81 COPY(r8);
@@ -144,48 +90,24 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
144 /* Kernel saves and restores only the CS segment register on signals, 90 /* Kernel saves and restores only the CS segment register on signals,
145 * which is the bare minimum needed to allow mixed 32/64-bit code. 91 * which is the bare minimum needed to allow mixed 32/64-bit code.
146 * App's signal handler can save/restore other segments if needed. */ 92 * App's signal handler can save/restore other segments if needed. */
147 { 93 COPY_SEG_STRICT(cs);
148 unsigned cs;
149 err |= __get_user(cs, &sc->cs);
150 regs->cs = cs | 3; /* Force into user mode */
151 }
152 94
153 { 95 err |= __get_user(tmpflags, &sc->flags);
154 unsigned int tmpflags; 96 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
155 err |= __get_user(tmpflags, &sc->flags); 97 regs->orig_ax = -1; /* disable syscall checks */
156 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
157 regs->orig_ax = -1; /* disable syscall checks */
158 }
159 98
160 { 99 err |= __get_user(buf, &sc->fpstate);
161 struct _fpstate __user * buf; 100 err |= restore_i387_xstate(buf);
162 err |= __get_user(buf, &sc->fpstate);
163
164 if (buf) {
165 if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
166 goto badframe;
167 err |= restore_i387(buf);
168 } else {
169 struct task_struct *me = current;
170 if (used_math()) {
171 clear_fpu(me);
172 clear_used_math();
173 }
174 }
175 }
176 101
177 err |= __get_user(*pax, &sc->ax); 102 err |= __get_user(*pax, &sc->ax);
178 return err; 103 return err;
179
180badframe:
181 return 1;
182} 104}
183 105
184asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) 106static long do_rt_sigreturn(struct pt_regs *regs)
185{ 107{
186 struct rt_sigframe __user *frame; 108 struct rt_sigframe __user *frame;
187 sigset_t set;
188 unsigned long ax; 109 unsigned long ax;
110 sigset_t set;
189 111
190 frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long)); 112 frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long));
191 if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) 113 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
@@ -198,7 +120,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
198 current->blocked = set; 120 current->blocked = set;
199 recalc_sigpending(); 121 recalc_sigpending();
200 spin_unlock_irq(&current->sighand->siglock); 122 spin_unlock_irq(&current->sighand->siglock);
201 123
202 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax)) 124 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
203 goto badframe; 125 goto badframe;
204 126
@@ -208,16 +130,22 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
208 return ax; 130 return ax;
209 131
210badframe: 132badframe:
211 signal_fault(regs,frame,"sigreturn"); 133 signal_fault(regs, frame, "rt_sigreturn");
212 return 0; 134 return 0;
213} 135}
136
137asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
138{
139 return do_rt_sigreturn(regs);
140}
214 141
215/* 142/*
216 * Set up a signal frame. 143 * Set up a signal frame.
217 */ 144 */
218 145
219static inline int 146static inline int
220setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned long mask, struct task_struct *me) 147setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
148 unsigned long mask, struct task_struct *me)
221{ 149{
222 int err = 0; 150 int err = 0;
223 151
@@ -269,41 +197,40 @@ get_stack(struct k_sigaction *ka, struct pt_regs *regs, unsigned long size)
269 sp = current->sas_ss_sp + current->sas_ss_size; 197 sp = current->sas_ss_sp + current->sas_ss_size;
270 } 198 }
271 199
272 return (void __user *)round_down(sp - size, 16); 200 return (void __user *)round_down(sp - size, 64);
273} 201}
274 202
275static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 203static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
276 sigset_t *set, struct pt_regs * regs) 204 sigset_t *set, struct pt_regs *regs)
277{ 205{
278 struct rt_sigframe __user *frame; 206 struct rt_sigframe __user *frame;
279 struct _fpstate __user *fp = NULL; 207 void __user *fp = NULL;
280 int err = 0; 208 int err = 0;
281 struct task_struct *me = current; 209 struct task_struct *me = current;
282 210
283 if (used_math()) { 211 if (used_math()) {
284 fp = get_stack(ka, regs, sizeof(struct _fpstate)); 212 fp = get_stack(ka, regs, sig_xstate_size);
285 frame = (void __user *)round_down( 213 frame = (void __user *)round_down(
286 (unsigned long)fp - sizeof(struct rt_sigframe), 16) - 8; 214 (unsigned long)fp - sizeof(struct rt_sigframe), 16) - 8;
287 215
288 if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) 216 if (save_i387_xstate(fp) < 0)
289 goto give_sigsegv; 217 return -EFAULT;
290
291 if (save_i387(fp) < 0)
292 err |= -1;
293 } else 218 } else
294 frame = get_stack(ka, regs, sizeof(struct rt_sigframe)) - 8; 219 frame = get_stack(ka, regs, sizeof(struct rt_sigframe)) - 8;
295 220
296 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 221 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
297 goto give_sigsegv; 222 return -EFAULT;
298 223
299 if (ka->sa.sa_flags & SA_SIGINFO) { 224 if (ka->sa.sa_flags & SA_SIGINFO) {
300 err |= copy_siginfo_to_user(&frame->info, info); 225 if (copy_siginfo_to_user(&frame->info, info))
301 if (err) 226 return -EFAULT;
302 goto give_sigsegv;
303 } 227 }
304 228
305 /* Create the ucontext. */ 229 /* Create the ucontext. */
306 err |= __put_user(0, &frame->uc.uc_flags); 230 if (cpu_has_xsave)
231 err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags);
232 else
233 err |= __put_user(0, &frame->uc.uc_flags);
307 err |= __put_user(0, &frame->uc.uc_link); 234 err |= __put_user(0, &frame->uc.uc_link);
308 err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 235 err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
309 err |= __put_user(sas_ss_flags(regs->sp), 236 err |= __put_user(sas_ss_flags(regs->sp),
@@ -311,9 +238,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
311 err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size); 238 err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
312 err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0], me); 239 err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0], me);
313 err |= __put_user(fp, &frame->uc.uc_mcontext.fpstate); 240 err |= __put_user(fp, &frame->uc.uc_mcontext.fpstate);
314 if (sizeof(*set) == 16) { 241 if (sizeof(*set) == 16) {
315 __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]); 242 __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);
316 __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]); 243 __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]);
317 } else 244 } else
318 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); 245 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
319 246
@@ -324,15 +251,15 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
324 err |= __put_user(ka->sa.sa_restorer, &frame->pretcode); 251 err |= __put_user(ka->sa.sa_restorer, &frame->pretcode);
325 } else { 252 } else {
326 /* could use a vstub here */ 253 /* could use a vstub here */
327 goto give_sigsegv; 254 return -EFAULT;
328 } 255 }
329 256
330 if (err) 257 if (err)
331 goto give_sigsegv; 258 return -EFAULT;
332 259
333 /* Set up registers for signal handler */ 260 /* Set up registers for signal handler */
334 regs->di = sig; 261 regs->di = sig;
335 /* In case the signal handler was declared without prototypes */ 262 /* In case the signal handler was declared without prototypes */
336 regs->ax = 0; 263 regs->ax = 0;
337 264
338 /* This also works for non SA_SIGINFO handlers because they expect the 265 /* This also works for non SA_SIGINFO handlers because they expect the
@@ -348,44 +275,45 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
348 regs->cs = __USER_CS; 275 regs->cs = __USER_CS;
349 276
350 return 0; 277 return 0;
351
352give_sigsegv:
353 force_sigsegv(sig, current);
354 return -EFAULT;
355} 278}
356 279
357/* 280/*
358 * Return -1L or the syscall number that @regs is executing. 281 * OK, we're invoking a handler
359 */ 282 */
360static long current_syscall(struct pt_regs *regs) 283static int signr_convert(int sig)
361{ 284{
362 /* 285 return sig;
363 * We always sign-extend a -1 value being set here,
364 * so this is always either -1L or a syscall number.
365 */
366 return regs->orig_ax;
367} 286}
368 287
369/*
370 * Return a value that is -EFOO if the system call in @regs->orig_ax
371 * returned an error. This only works for @regs from @current.
372 */
373static long current_syscall_ret(struct pt_regs *regs)
374{
375#ifdef CONFIG_IA32_EMULATION 288#ifdef CONFIG_IA32_EMULATION
376 if (test_thread_flag(TIF_IA32)) 289#define is_ia32 test_thread_flag(TIF_IA32)
377 /* 290#else
378 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO 291#define is_ia32 0
379 * and will match correctly in comparisons.
380 */
381 return (int) regs->ax;
382#endif 292#endif
383 return regs->ax;
384}
385 293
386/* 294static int
387 * OK, we're invoking a handler 295setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
388 */ 296 sigset_t *set, struct pt_regs *regs)
297{
298 int usig = signr_convert(sig);
299 int ret;
300
301 /* Set up the stack frame */
302 if (is_ia32) {
303 if (ka->sa.sa_flags & SA_SIGINFO)
304 ret = ia32_setup_rt_frame(usig, ka, info, set, regs);
305 else
306 ret = ia32_setup_frame(usig, ka, set, regs);
307 } else
308 ret = __setup_rt_frame(sig, ka, info, set, regs);
309
310 if (ret) {
311 force_sigsegv(sig, current);
312 return -EFAULT;
313 }
314
315 return ret;
316}
389 317
390static int 318static int
391handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 319handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
@@ -394,9 +322,9 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
394 int ret; 322 int ret;
395 323
396 /* Are we from a system call? */ 324 /* Are we from a system call? */
397 if (current_syscall(regs) >= 0) { 325 if (syscall_get_nr(current, regs) >= 0) {
398 /* If so, check system call restarting.. */ 326 /* If so, check system call restarting.. */
399 switch (current_syscall_ret(regs)) { 327 switch (syscall_get_error(current, regs)) {
400 case -ERESTART_RESTARTBLOCK: 328 case -ERESTART_RESTARTBLOCK:
401 case -ERESTARTNOHAND: 329 case -ERESTARTNOHAND:
402 regs->ax = -EINTR; 330 regs->ax = -EINTR;
@@ -423,50 +351,48 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
423 likely(test_and_clear_thread_flag(TIF_FORCED_TF))) 351 likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
424 regs->flags &= ~X86_EFLAGS_TF; 352 regs->flags &= ~X86_EFLAGS_TF;
425 353
426#ifdef CONFIG_IA32_EMULATION
427 if (test_thread_flag(TIF_IA32)) {
428 if (ka->sa.sa_flags & SA_SIGINFO)
429 ret = ia32_setup_rt_frame(sig, ka, info, oldset, regs);
430 else
431 ret = ia32_setup_frame(sig, ka, oldset, regs);
432 } else
433#endif
434 ret = setup_rt_frame(sig, ka, info, oldset, regs); 354 ret = setup_rt_frame(sig, ka, info, oldset, regs);
435 355
436 if (ret == 0) { 356 if (ret)
437 /* 357 return ret;
438 * This has nothing to do with segment registers,
439 * despite the name. This magic affects uaccess.h
440 * macros' behavior. Reset it to the normal setting.
441 */
442 set_fs(USER_DS);
443 358
444 /* 359#ifdef CONFIG_X86_64
445 * Clear the direction flag as per the ABI for function entry. 360 /*
446 */ 361 * This has nothing to do with segment registers,
447 regs->flags &= ~X86_EFLAGS_DF; 362 * despite the name. This magic affects uaccess.h
363 * macros' behavior. Reset it to the normal setting.
364 */
365 set_fs(USER_DS);
366#endif
448 367
449 /* 368 /*
450 * Clear TF when entering the signal handler, but 369 * Clear the direction flag as per the ABI for function entry.
451 * notify any tracer that was single-stepping it. 370 */
452 * The tracer may want to single-step inside the 371 regs->flags &= ~X86_EFLAGS_DF;
453 * handler too.
454 */
455 regs->flags &= ~X86_EFLAGS_TF;
456 if (test_thread_flag(TIF_SINGLESTEP))
457 ptrace_notify(SIGTRAP);
458
459 spin_lock_irq(&current->sighand->siglock);
460 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
461 if (!(ka->sa.sa_flags & SA_NODEFER))
462 sigaddset(&current->blocked,sig);
463 recalc_sigpending();
464 spin_unlock_irq(&current->sighand->siglock);
465 }
466 372
467 return ret; 373 /*
374 * Clear TF when entering the signal handler, but
375 * notify any tracer that was single-stepping it.
376 * The tracer may want to single-step inside the
377 * handler too.
378 */
379 regs->flags &= ~X86_EFLAGS_TF;
380
381 spin_lock_irq(&current->sighand->siglock);
382 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
383 if (!(ka->sa.sa_flags & SA_NODEFER))
384 sigaddset(&current->blocked, sig);
385 recalc_sigpending();
386 spin_unlock_irq(&current->sighand->siglock);
387
388 tracehook_signal_handler(sig, info, ka, regs,
389 test_thread_flag(TIF_SINGLESTEP));
390
391 return 0;
468} 392}
469 393
394#define NR_restart_syscall \
395 test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
470/* 396/*
471 * Note that 'init' is a special process: it doesn't get signals it doesn't 397 * Note that 'init' is a special process: it doesn't get signals it doesn't
472 * want to handle. Thus you cannot kill init even with a SIGKILL even by 398 * want to handle. Thus you cannot kill init even with a SIGKILL even by
@@ -496,7 +422,8 @@ static void do_signal(struct pt_regs *regs)
496 422
497 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 423 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
498 if (signr > 0) { 424 if (signr > 0) {
499 /* Re-enable any watchpoints before delivering the 425 /*
426 * Re-enable any watchpoints before delivering the
500 * signal to user space. The processor register will 427 * signal to user space. The processor register will
501 * have been cleared if the watchpoint triggered 428 * have been cleared if the watchpoint triggered
502 * inside the kernel. 429 * inside the kernel.
@@ -504,7 +431,7 @@ static void do_signal(struct pt_regs *regs)
504 if (current->thread.debugreg7) 431 if (current->thread.debugreg7)
505 set_debugreg(current->thread.debugreg7, 7); 432 set_debugreg(current->thread.debugreg7, 7);
506 433
507 /* Whee! Actually deliver the signal. */ 434 /* Whee! Actually deliver the signal. */
508 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 435 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
509 /* 436 /*
510 * A signal was successfully delivered; the saved 437 * A signal was successfully delivered; the saved
@@ -518,19 +445,18 @@ static void do_signal(struct pt_regs *regs)
518 } 445 }
519 446
520 /* Did we come from a system call? */ 447 /* Did we come from a system call? */
521 if (current_syscall(regs) >= 0) { 448 if (syscall_get_nr(current, regs) >= 0) {
522 /* Restart the system call - no handlers present */ 449 /* Restart the system call - no handlers present */
523 switch (current_syscall_ret(regs)) { 450 switch (syscall_get_error(current, regs)) {
524 case -ERESTARTNOHAND: 451 case -ERESTARTNOHAND:
525 case -ERESTARTSYS: 452 case -ERESTARTSYS:
526 case -ERESTARTNOINTR: 453 case -ERESTARTNOINTR:
527 regs->ax = regs->orig_ax; 454 regs->ax = regs->orig_ax;
528 regs->ip -= 2; 455 regs->ip -= 2;
529 break; 456 break;
457
530 case -ERESTART_RESTARTBLOCK: 458 case -ERESTART_RESTARTBLOCK:
531 regs->ax = test_thread_flag(TIF_IA32) ? 459 regs->ax = NR_restart_syscall;
532 __NR_ia32_restart_syscall :
533 __NR_restart_syscall;
534 regs->ip -= 2; 460 regs->ip -= 2;
535 break; 461 break;
536 } 462 }
@@ -546,29 +472,45 @@ static void do_signal(struct pt_regs *regs)
546 } 472 }
547} 473}
548 474
549void do_notify_resume(struct pt_regs *regs, void *unused, 475/*
550 __u32 thread_info_flags) 476 * notification of userspace execution resumption
477 * - triggered by the TIF_WORK_MASK flags
478 */
479void
480do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
551{ 481{
552#ifdef CONFIG_X86_MCE 482#if defined(CONFIG_X86_64) && defined(CONFIG_X86_MCE)
553 /* notify userspace of pending MCEs */ 483 /* notify userspace of pending MCEs */
554 if (thread_info_flags & _TIF_MCE_NOTIFY) 484 if (thread_info_flags & _TIF_MCE_NOTIFY)
555 mce_notify_user(); 485 mce_notify_user();
556#endif /* CONFIG_X86_MCE */ 486#endif /* CONFIG_X86_64 && CONFIG_X86_MCE */
557 487
558 /* deal with pending signal delivery */ 488 /* deal with pending signal delivery */
559 if (thread_info_flags & _TIF_SIGPENDING) 489 if (thread_info_flags & _TIF_SIGPENDING)
560 do_signal(regs); 490 do_signal(regs);
491
492 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
493 clear_thread_flag(TIF_NOTIFY_RESUME);
494 tracehook_notify_resume(regs);
495 }
496
497#ifdef CONFIG_X86_32
498 clear_thread_flag(TIF_IRET);
499#endif /* CONFIG_X86_32 */
561} 500}
562 501
563void signal_fault(struct pt_regs *regs, void __user *frame, char *where) 502void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
564{ 503{
565 struct task_struct *me = current; 504 struct task_struct *me = current;
505
566 if (show_unhandled_signals && printk_ratelimit()) { 506 if (show_unhandled_signals && printk_ratelimit()) {
567 printk("%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx", 507 printk(KERN_INFO
568 me->comm,me->pid,where,frame,regs->ip,regs->sp,regs->orig_ax); 508 "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
509 me->comm, me->pid, where, frame,
510 regs->ip, regs->sp, regs->orig_ax);
569 print_vma_addr(" in ", regs->ip); 511 print_vma_addr(" in ", regs->ip);
570 printk("\n"); 512 printk(KERN_CONT "\n");
571 } 513 }
572 514
573 force_sig(SIGSEGV, me); 515 force_sig(SIGSEGV, me);
574} 516}
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
index 361b7a4c640c..18f9b19f5f8f 100644
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -214,12 +214,16 @@ void smp_call_function_single_interrupt(struct pt_regs *regs)
214struct smp_ops smp_ops = { 214struct smp_ops smp_ops = {
215 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu, 215 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
216 .smp_prepare_cpus = native_smp_prepare_cpus, 216 .smp_prepare_cpus = native_smp_prepare_cpus,
217 .cpu_up = native_cpu_up,
218 .smp_cpus_done = native_smp_cpus_done, 217 .smp_cpus_done = native_smp_cpus_done,
219 218
220 .smp_send_stop = native_smp_send_stop, 219 .smp_send_stop = native_smp_send_stop,
221 .smp_send_reschedule = native_smp_send_reschedule, 220 .smp_send_reschedule = native_smp_send_reschedule,
222 221
222 .cpu_up = native_cpu_up,
223 .cpu_die = native_cpu_die,
224 .cpu_disable = native_cpu_disable,
225 .play_dead = native_play_dead,
226
223 .send_call_func_ipi = native_send_call_func_ipi, 227 .send_call_func_ipi = native_send_call_func_ipi,
224 .send_call_func_single_ipi = native_send_call_func_single_ipi, 228 .send_call_func_single_ipi = native_send_call_func_single_ipi,
225}; 229};
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 7985c5b3f916..76b6f50978f7 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -52,6 +52,7 @@
52#include <asm/desc.h> 52#include <asm/desc.h>
53#include <asm/nmi.h> 53#include <asm/nmi.h>
54#include <asm/irq.h> 54#include <asm/irq.h>
55#include <asm/idle.h>
55#include <asm/smp.h> 56#include <asm/smp.h>
56#include <asm/trampoline.h> 57#include <asm/trampoline.h>
57#include <asm/cpu.h> 58#include <asm/cpu.h>
@@ -88,7 +89,7 @@ static DEFINE_PER_CPU(struct task_struct *, idle_thread_array);
88#define get_idle_for_cpu(x) (per_cpu(idle_thread_array, x)) 89#define get_idle_for_cpu(x) (per_cpu(idle_thread_array, x))
89#define set_idle_for_cpu(x, p) (per_cpu(idle_thread_array, x) = (p)) 90#define set_idle_for_cpu(x, p) (per_cpu(idle_thread_array, x) = (p))
90#else 91#else
91struct task_struct *idle_thread_array[NR_CPUS] __cpuinitdata ; 92static struct task_struct *idle_thread_array[NR_CPUS] __cpuinitdata ;
92#define get_idle_for_cpu(x) (idle_thread_array[(x)]) 93#define get_idle_for_cpu(x) (idle_thread_array[(x)])
93#define set_idle_for_cpu(x, p) (idle_thread_array[(x)] = (p)) 94#define set_idle_for_cpu(x, p) (idle_thread_array[(x)] = (p))
94#endif 95#endif
@@ -123,13 +124,12 @@ EXPORT_PER_CPU_SYMBOL(cpu_info);
123 124
124static atomic_t init_deasserted; 125static atomic_t init_deasserted;
125 126
126static int boot_cpu_logical_apicid;
127 127
128/* representing cpus for which sibling maps can be computed */ 128/* representing cpus for which sibling maps can be computed */
129static cpumask_t cpu_sibling_setup_map; 129static cpumask_t cpu_sibling_setup_map;
130 130
131/* Set if we find a B stepping CPU */ 131/* Set if we find a B stepping CPU */
132int __cpuinitdata smp_b_stepping; 132static int __cpuinitdata smp_b_stepping;
133 133
134#if defined(CONFIG_NUMA) && defined(CONFIG_X86_32) 134#if defined(CONFIG_NUMA) && defined(CONFIG_X86_32)
135 135
@@ -165,6 +165,8 @@ static void unmap_cpu_to_node(int cpu)
165#endif 165#endif
166 166
167#ifdef CONFIG_X86_32 167#ifdef CONFIG_X86_32
168static int boot_cpu_logical_apicid;
169
168u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = 170u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly =
169 { [0 ... NR_CPUS-1] = BAD_APICID }; 171 { [0 ... NR_CPUS-1] = BAD_APICID };
170 172
@@ -210,7 +212,7 @@ static void __cpuinit smp_callin(void)
210 /* 212 /*
211 * (This works even if the APIC is not enabled.) 213 * (This works even if the APIC is not enabled.)
212 */ 214 */
213 phys_id = GET_APIC_ID(read_apic_id()); 215 phys_id = read_apic_id();
214 cpuid = smp_processor_id(); 216 cpuid = smp_processor_id();
215 if (cpu_isset(cpuid, cpu_callin_map)) { 217 if (cpu_isset(cpuid, cpu_callin_map)) {
216 panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, 218 panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__,
@@ -257,6 +259,7 @@ static void __cpuinit smp_callin(void)
257 end_local_APIC_setup(); 259 end_local_APIC_setup();
258 map_cpu_to_logical_apicid(); 260 map_cpu_to_logical_apicid();
259 261
262 notify_cpu_starting(cpuid);
260 /* 263 /*
261 * Get our bogomips. 264 * Get our bogomips.
262 * 265 *
@@ -550,8 +553,7 @@ static inline void __inquire_remote_apic(int apicid)
550 printk(KERN_CONT 553 printk(KERN_CONT
551 "a previous APIC delivery may have failed\n"); 554 "a previous APIC delivery may have failed\n");
552 555
553 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(apicid)); 556 apic_icr_write(APIC_DM_REMRD | regs[i], apicid);
554 apic_write(APIC_ICR, APIC_DM_REMRD | regs[i]);
555 557
556 timeout = 0; 558 timeout = 0;
557 do { 559 do {
@@ -583,11 +585,9 @@ wakeup_secondary_cpu(int logical_apicid, unsigned long start_eip)
583 int maxlvt; 585 int maxlvt;
584 586
585 /* Target chip */ 587 /* Target chip */
586 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(logical_apicid));
587
588 /* Boot on the stack */ 588 /* Boot on the stack */
589 /* Kick the second */ 589 /* Kick the second */
590 apic_write(APIC_ICR, APIC_DM_NMI | APIC_DEST_LOGICAL); 590 apic_icr_write(APIC_DM_NMI | APIC_DEST_LOGICAL, logical_apicid);
591 591
592 pr_debug("Waiting for send to finish...\n"); 592 pr_debug("Waiting for send to finish...\n");
593 send_status = safe_apic_wait_icr_idle(); 593 send_status = safe_apic_wait_icr_idle();
@@ -640,13 +640,11 @@ wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip)
640 /* 640 /*
641 * Turn INIT on target chip 641 * Turn INIT on target chip
642 */ 642 */
643 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
644
645 /* 643 /*
646 * Send IPI 644 * Send IPI
647 */ 645 */
648 apic_write(APIC_ICR, 646 apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT,
649 APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT); 647 phys_apicid);
650 648
651 pr_debug("Waiting for send to finish...\n"); 649 pr_debug("Waiting for send to finish...\n");
652 send_status = safe_apic_wait_icr_idle(); 650 send_status = safe_apic_wait_icr_idle();
@@ -656,10 +654,8 @@ wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip)
656 pr_debug("Deasserting INIT.\n"); 654 pr_debug("Deasserting INIT.\n");
657 655
658 /* Target chip */ 656 /* Target chip */
659 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
660
661 /* Send IPI */ 657 /* Send IPI */
662 apic_write(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT); 658 apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid);
663 659
664 pr_debug("Waiting for send to finish...\n"); 660 pr_debug("Waiting for send to finish...\n");
665 send_status = safe_apic_wait_icr_idle(); 661 send_status = safe_apic_wait_icr_idle();
@@ -702,11 +698,10 @@ wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip)
702 */ 698 */
703 699
704 /* Target chip */ 700 /* Target chip */
705 apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
706
707 /* Boot on the stack */ 701 /* Boot on the stack */
708 /* Kick the second */ 702 /* Kick the second */
709 apic_write(APIC_ICR, APIC_DM_STARTUP | (start_eip >> 12)); 703 apic_icr_write(APIC_DM_STARTUP | (start_eip >> 12),
704 phys_apicid);
710 705
711 /* 706 /*
712 * Give the other CPU some time to accept the IPI. 707 * Give the other CPU some time to accept the IPI.
@@ -1175,10 +1170,17 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1175 * Setup boot CPU information 1170 * Setup boot CPU information
1176 */ 1171 */
1177 smp_store_cpu_info(0); /* Final full version of the data */ 1172 smp_store_cpu_info(0); /* Final full version of the data */
1173#ifdef CONFIG_X86_32
1178 boot_cpu_logical_apicid = logical_smp_processor_id(); 1174 boot_cpu_logical_apicid = logical_smp_processor_id();
1175#endif
1179 current_thread_info()->cpu = 0; /* needed? */ 1176 current_thread_info()->cpu = 0; /* needed? */
1180 set_cpu_sibling_map(0); 1177 set_cpu_sibling_map(0);
1181 1178
1179#ifdef CONFIG_X86_64
1180 enable_IR_x2apic();
1181 setup_apic_routing();
1182#endif
1183
1182 if (smp_sanity_check(max_cpus) < 0) { 1184 if (smp_sanity_check(max_cpus) < 0) {
1183 printk(KERN_INFO "SMP disabled\n"); 1185 printk(KERN_INFO "SMP disabled\n");
1184 disable_smp(); 1186 disable_smp();
@@ -1186,9 +1188,9 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1186 } 1188 }
1187 1189
1188 preempt_disable(); 1190 preempt_disable();
1189 if (GET_APIC_ID(read_apic_id()) != boot_cpu_physical_apicid) { 1191 if (read_apic_id() != boot_cpu_physical_apicid) {
1190 panic("Boot APIC ID in local APIC unexpected (%d vs %d)", 1192 panic("Boot APIC ID in local APIC unexpected (%d vs %d)",
1191 GET_APIC_ID(read_apic_id()), boot_cpu_physical_apicid); 1193 read_apic_id(), boot_cpu_physical_apicid);
1192 /* Or can we switch back to PIC here? */ 1194 /* Or can we switch back to PIC here? */
1193 } 1195 }
1194 preempt_enable(); 1196 preempt_enable();
@@ -1313,16 +1315,13 @@ __init void prefill_possible_map(void)
1313 if (!num_processors) 1315 if (!num_processors)
1314 num_processors = 1; 1316 num_processors = 1;
1315 1317
1316#ifdef CONFIG_HOTPLUG_CPU
1317 if (additional_cpus == -1) { 1318 if (additional_cpus == -1) {
1318 if (disabled_cpus > 0) 1319 if (disabled_cpus > 0)
1319 additional_cpus = disabled_cpus; 1320 additional_cpus = disabled_cpus;
1320 else 1321 else
1321 additional_cpus = 0; 1322 additional_cpus = 0;
1322 } 1323 }
1323#else 1324
1324 additional_cpus = 0;
1325#endif
1326 possible = num_processors + additional_cpus; 1325 possible = num_processors + additional_cpus;
1327 if (possible > NR_CPUS) 1326 if (possible > NR_CPUS)
1328 possible = NR_CPUS; 1327 possible = NR_CPUS;
@@ -1346,25 +1345,9 @@ static void __ref remove_cpu_from_maps(int cpu)
1346 numa_remove_cpu(cpu); 1345 numa_remove_cpu(cpu);
1347} 1346}
1348 1347
1349int __cpu_disable(void) 1348void cpu_disable_common(void)
1350{ 1349{
1351 int cpu = smp_processor_id(); 1350 int cpu = smp_processor_id();
1352
1353 /*
1354 * Perhaps use cpufreq to drop frequency, but that could go
1355 * into generic code.
1356 *
1357 * We won't take down the boot processor on i386 due to some
1358 * interrupts only being able to be serviced by the BSP.
1359 * Especially so if we're not using an IOAPIC -zwane
1360 */
1361 if (cpu == 0)
1362 return -EBUSY;
1363
1364 if (nmi_watchdog == NMI_LOCAL_APIC)
1365 stop_apic_nmi_watchdog(NULL);
1366 clear_local_APIC();
1367
1368 /* 1351 /*
1369 * HACK: 1352 * HACK:
1370 * Allow any queued timer interrupts to get serviced 1353 * Allow any queued timer interrupts to get serviced
@@ -1382,10 +1365,32 @@ int __cpu_disable(void)
1382 remove_cpu_from_maps(cpu); 1365 remove_cpu_from_maps(cpu);
1383 unlock_vector_lock(); 1366 unlock_vector_lock();
1384 fixup_irqs(cpu_online_map); 1367 fixup_irqs(cpu_online_map);
1368}
1369
1370int native_cpu_disable(void)
1371{
1372 int cpu = smp_processor_id();
1373
1374 /*
1375 * Perhaps use cpufreq to drop frequency, but that could go
1376 * into generic code.
1377 *
1378 * We won't take down the boot processor on i386 due to some
1379 * interrupts only being able to be serviced by the BSP.
1380 * Especially so if we're not using an IOAPIC -zwane
1381 */
1382 if (cpu == 0)
1383 return -EBUSY;
1384
1385 if (nmi_watchdog == NMI_LOCAL_APIC)
1386 stop_apic_nmi_watchdog(NULL);
1387 clear_local_APIC();
1388
1389 cpu_disable_common();
1385 return 0; 1390 return 0;
1386} 1391}
1387 1392
1388void __cpu_die(unsigned int cpu) 1393void native_cpu_die(unsigned int cpu)
1389{ 1394{
1390 /* We don't do anything here: idle task is faking death itself. */ 1395 /* We don't do anything here: idle task is faking death itself. */
1391 unsigned int i; 1396 unsigned int i;
@@ -1402,15 +1407,45 @@ void __cpu_die(unsigned int cpu)
1402 } 1407 }
1403 printk(KERN_ERR "CPU %u didn't die...\n", cpu); 1408 printk(KERN_ERR "CPU %u didn't die...\n", cpu);
1404} 1409}
1410
1411void play_dead_common(void)
1412{
1413 idle_task_exit();
1414 reset_lazy_tlbstate();
1415 irq_ctx_exit(raw_smp_processor_id());
1416 c1e_remove_cpu(raw_smp_processor_id());
1417
1418 mb();
1419 /* Ack it */
1420 __get_cpu_var(cpu_state) = CPU_DEAD;
1421
1422 /*
1423 * With physical CPU hotplug, we should halt the cpu
1424 */
1425 local_irq_disable();
1426}
1427
1428void native_play_dead(void)
1429{
1430 play_dead_common();
1431 wbinvd_halt();
1432}
1433
1405#else /* ... !CONFIG_HOTPLUG_CPU */ 1434#else /* ... !CONFIG_HOTPLUG_CPU */
1406int __cpu_disable(void) 1435int native_cpu_disable(void)
1407{ 1436{
1408 return -ENOSYS; 1437 return -ENOSYS;
1409} 1438}
1410 1439
1411void __cpu_die(unsigned int cpu) 1440void native_cpu_die(unsigned int cpu)
1412{ 1441{
1413 /* We said "no" in __cpu_disable */ 1442 /* We said "no" in __cpu_disable */
1414 BUG(); 1443 BUG();
1415} 1444}
1445
1446void native_play_dead(void)
1447{
1448 BUG();
1449}
1450
1416#endif 1451#endif
diff --git a/arch/x86/kernel/summit_32.c b/arch/x86/kernel/summit_32.c
index d67ce5f044ba..7b987852e876 100644
--- a/arch/x86/kernel/summit_32.c
+++ b/arch/x86/kernel/summit_32.c
@@ -30,7 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/bios_ebda.h> 32#include <asm/bios_ebda.h>
33#include <asm/mach-summit/mach_mpparse.h> 33#include <asm/summit/mpparse.h>
34 34
35static struct rio_table_hdr *rio_table_hdr __initdata; 35static struct rio_table_hdr *rio_table_hdr __initdata;
36static struct scal_detail *scal_devs[MAX_NUMNODES] __initdata; 36static struct scal_detail *scal_devs[MAX_NUMNODES] __initdata;
diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
index 7066cb855a60..1884a8d12bfa 100644
--- a/arch/x86/kernel/sys_i386_32.c
+++ b/arch/x86/kernel/sys_i386_32.c
@@ -22,6 +22,8 @@
22#include <linux/uaccess.h> 22#include <linux/uaccess.h>
23#include <linux/unistd.h> 23#include <linux/unistd.h>
24 24
25#include <asm/syscalls.h>
26
25asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, 27asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
26 unsigned long prot, unsigned long flags, 28 unsigned long prot, unsigned long flags,
27 unsigned long fd, unsigned long pgoff) 29 unsigned long fd, unsigned long pgoff)
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 3b360ef33817..6bc211accf08 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -13,15 +13,17 @@
13#include <linux/utsname.h> 13#include <linux/utsname.h>
14#include <linux/personality.h> 14#include <linux/personality.h>
15#include <linux/random.h> 15#include <linux/random.h>
16#include <linux/uaccess.h>
16 17
17#include <asm/uaccess.h>
18#include <asm/ia32.h> 18#include <asm/ia32.h>
19#include <asm/syscalls.h>
19 20
20asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, 21asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
21 unsigned long fd, unsigned long off) 22 unsigned long prot, unsigned long flags,
23 unsigned long fd, unsigned long off)
22{ 24{
23 long error; 25 long error;
24 struct file * file; 26 struct file *file;
25 27
26 error = -EINVAL; 28 error = -EINVAL;
27 if (off & ~PAGE_MASK) 29 if (off & ~PAGE_MASK)
@@ -56,9 +58,9 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
56 unmapped base down for this case. This can give 58 unmapped base down for this case. This can give
57 conflicts with the heap, but we assume that glibc 59 conflicts with the heap, but we assume that glibc
58 malloc knows how to fall back to mmap. Give it 1GB 60 malloc knows how to fall back to mmap. Give it 1GB
59 of playground for now. -AK */ 61 of playground for now. -AK */
60 *begin = 0x40000000; 62 *begin = 0x40000000;
61 *end = 0x80000000; 63 *end = 0x80000000;
62 if (current->flags & PF_RANDOMIZE) { 64 if (current->flags & PF_RANDOMIZE) {
63 new_begin = randomize_range(*begin, *begin + 0x02000000, 0); 65 new_begin = randomize_range(*begin, *begin + 0x02000000, 0);
64 if (new_begin) 66 if (new_begin)
@@ -66,9 +68,9 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
66 } 68 }
67 } else { 69 } else {
68 *begin = TASK_UNMAPPED_BASE; 70 *begin = TASK_UNMAPPED_BASE;
69 *end = TASK_SIZE; 71 *end = TASK_SIZE;
70 } 72 }
71} 73}
72 74
73unsigned long 75unsigned long
74arch_get_unmapped_area(struct file *filp, unsigned long addr, 76arch_get_unmapped_area(struct file *filp, unsigned long addr,
@@ -78,11 +80,11 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
78 struct vm_area_struct *vma; 80 struct vm_area_struct *vma;
79 unsigned long start_addr; 81 unsigned long start_addr;
80 unsigned long begin, end; 82 unsigned long begin, end;
81 83
82 if (flags & MAP_FIXED) 84 if (flags & MAP_FIXED)
83 return addr; 85 return addr;
84 86
85 find_start_end(flags, &begin, &end); 87 find_start_end(flags, &begin, &end);
86 88
87 if (len > end) 89 if (len > end)
88 return -ENOMEM; 90 return -ENOMEM;
@@ -96,12 +98,12 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
96 } 98 }
97 if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32)) 99 if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32))
98 && len <= mm->cached_hole_size) { 100 && len <= mm->cached_hole_size) {
99 mm->cached_hole_size = 0; 101 mm->cached_hole_size = 0;
100 mm->free_area_cache = begin; 102 mm->free_area_cache = begin;
101 } 103 }
102 addr = mm->free_area_cache; 104 addr = mm->free_area_cache;
103 if (addr < begin) 105 if (addr < begin)
104 addr = begin; 106 addr = begin;
105 start_addr = addr; 107 start_addr = addr;
106 108
107full_search: 109full_search:
@@ -127,7 +129,7 @@ full_search:
127 return addr; 129 return addr;
128 } 130 }
129 if (addr + mm->cached_hole_size < vma->vm_start) 131 if (addr + mm->cached_hole_size < vma->vm_start)
130 mm->cached_hole_size = vma->vm_start - addr; 132 mm->cached_hole_size = vma->vm_start - addr;
131 133
132 addr = vma->vm_end; 134 addr = vma->vm_end;
133 } 135 }
@@ -177,7 +179,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
177 vma = find_vma(mm, addr-len); 179 vma = find_vma(mm, addr-len);
178 if (!vma || addr <= vma->vm_start) 180 if (!vma || addr <= vma->vm_start)
179 /* remember the address as a hint for next time */ 181 /* remember the address as a hint for next time */
180 return (mm->free_area_cache = addr-len); 182 return mm->free_area_cache = addr-len;
181 } 183 }
182 184
183 if (mm->mmap_base < len) 185 if (mm->mmap_base < len)
@@ -194,7 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
194 vma = find_vma(mm, addr); 196 vma = find_vma(mm, addr);
195 if (!vma || addr+len <= vma->vm_start) 197 if (!vma || addr+len <= vma->vm_start)
196 /* remember the address as a hint for next time */ 198 /* remember the address as a hint for next time */
197 return (mm->free_area_cache = addr); 199 return mm->free_area_cache = addr;
198 200
199 /* remember the largest hole we saw so far */ 201 /* remember the largest hole we saw so far */
200 if (addr + mm->cached_hole_size < vma->vm_start) 202 if (addr + mm->cached_hole_size < vma->vm_start)
@@ -224,13 +226,13 @@ bottomup:
224} 226}
225 227
226 228
227asmlinkage long sys_uname(struct new_utsname __user * name) 229asmlinkage long sys_uname(struct new_utsname __user *name)
228{ 230{
229 int err; 231 int err;
230 down_read(&uts_sem); 232 down_read(&uts_sem);
231 err = copy_to_user(name, utsname(), sizeof (*name)); 233 err = copy_to_user(name, utsname(), sizeof(*name));
232 up_read(&uts_sem); 234 up_read(&uts_sem);
233 if (personality(current->personality) == PER_LINUX32) 235 if (personality(current->personality) == PER_LINUX32)
234 err |= copy_to_user(&name->machine, "i686", 5); 236 err |= copy_to_user(&name->machine, "i686", 5);
235 return err ? -EFAULT : 0; 237 return err ? -EFAULT : 0;
236} 238}
diff --git a/arch/x86/kernel/syscall_64.c b/arch/x86/kernel/syscall_64.c
index 170d43c17487..3d1be4f0fac5 100644
--- a/arch/x86/kernel/syscall_64.c
+++ b/arch/x86/kernel/syscall_64.c
@@ -8,12 +8,12 @@
8#define __NO_STUBS 8#define __NO_STUBS
9 9
10#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ; 10#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ;
11#undef _ASM_X86_64_UNISTD_H_ 11#undef ASM_X86__UNISTD_64_H
12#include <asm/unistd_64.h> 12#include <asm/unistd_64.h>
13 13
14#undef __SYSCALL 14#undef __SYSCALL
15#define __SYSCALL(nr, sym) [nr] = sym, 15#define __SYSCALL(nr, sym) [nr] = sym,
16#undef _ASM_X86_64_UNISTD_H_ 16#undef ASM_X86__UNISTD_64_H
17 17
18typedef void (*sys_call_ptr_t)(void); 18typedef void (*sys_call_ptr_t)(void);
19 19
diff --git a/arch/x86/kernel/time_32.c b/arch/x86/kernel/time_32.c
index ffe3c664afc0..bbecf8b6bf96 100644
--- a/arch/x86/kernel/time_32.c
+++ b/arch/x86/kernel/time_32.c
@@ -36,6 +36,7 @@
36#include <asm/arch_hooks.h> 36#include <asm/arch_hooks.h>
37#include <asm/hpet.h> 37#include <asm/hpet.h>
38#include <asm/time.h> 38#include <asm/time.h>
39#include <asm/timer.h>
39 40
40#include "do_timer.h" 41#include "do_timer.h"
41 42
diff --git a/arch/x86/kernel/tlb_32.c b/arch/x86/kernel/tlb_32.c
index fec1ecedc9b7..e00534b33534 100644
--- a/arch/x86/kernel/tlb_32.c
+++ b/arch/x86/kernel/tlb_32.c
@@ -241,3 +241,11 @@ void flush_tlb_all(void)
241 on_each_cpu(do_flush_tlb_all, NULL, 1); 241 on_each_cpu(do_flush_tlb_all, NULL, 1);
242} 242}
243 243
244void reset_lazy_tlbstate(void)
245{
246 int cpu = raw_smp_processor_id();
247
248 per_cpu(cpu_tlbstate, cpu).state = 0;
249 per_cpu(cpu_tlbstate, cpu).active_mm = &init_mm;
250}
251
diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index ab6bf375a307..6bb7b8579e70 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -10,6 +10,7 @@
10#include <asm/ldt.h> 10#include <asm/ldt.h>
11#include <asm/processor.h> 11#include <asm/processor.h>
12#include <asm/proto.h> 12#include <asm/proto.h>
13#include <asm/syscalls.h>
13 14
14#include "tls.h" 15#include "tls.h"
15 16
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 03df8e45e5a1..0429c5de5ea9 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -891,6 +891,7 @@ void __kprobes do_debug(struct pt_regs *regs, long error_code)
891{ 891{
892 struct task_struct *tsk = current; 892 struct task_struct *tsk = current;
893 unsigned int condition; 893 unsigned int condition;
894 int si_code;
894 895
895 trace_hardirqs_fixup(); 896 trace_hardirqs_fixup();
896 897
@@ -935,8 +936,9 @@ void __kprobes do_debug(struct pt_regs *regs, long error_code)
935 goto clear_TF_reenable; 936 goto clear_TF_reenable;
936 } 937 }
937 938
939 si_code = get_si_code((unsigned long)condition);
938 /* Ok, finally something we can handle */ 940 /* Ok, finally something we can handle */
939 send_sigtrap(tsk, regs, error_code); 941 send_sigtrap(tsk, regs, error_code, si_code);
940 942
941 /* 943 /*
942 * Disable additional traps. They'll be re-enabled when 944 * Disable additional traps. They'll be re-enabled when
@@ -1228,7 +1230,6 @@ void __init trap_init(void)
1228 1230
1229 set_bit(SYSCALL_VECTOR, used_vectors); 1231 set_bit(SYSCALL_VECTOR, used_vectors);
1230 1232
1231 init_thread_xstate();
1232 /* 1233 /*
1233 * Should be a barrier for any external CPU state: 1234 * Should be a barrier for any external CPU state:
1234 */ 1235 */
diff --git a/arch/x86/kernel/traps_64.c b/arch/x86/kernel/traps_64.c
index 513caaca7115..9c0ac0cab013 100644
--- a/arch/x86/kernel/traps_64.c
+++ b/arch/x86/kernel/traps_64.c
@@ -32,6 +32,8 @@
32#include <linux/bug.h> 32#include <linux/bug.h>
33#include <linux/nmi.h> 33#include <linux/nmi.h>
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/smp.h>
36#include <linux/io.h>
35 37
36#if defined(CONFIG_EDAC) 38#if defined(CONFIG_EDAC)
37#include <linux/edac.h> 39#include <linux/edac.h>
@@ -45,9 +47,6 @@
45#include <asm/unwind.h> 47#include <asm/unwind.h>
46#include <asm/desc.h> 48#include <asm/desc.h>
47#include <asm/i387.h> 49#include <asm/i387.h>
48#include <asm/nmi.h>
49#include <asm/smp.h>
50#include <asm/io.h>
51#include <asm/pgalloc.h> 50#include <asm/pgalloc.h>
52#include <asm/proto.h> 51#include <asm/proto.h>
53#include <asm/pda.h> 52#include <asm/pda.h>
@@ -85,7 +84,8 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
85 84
86void printk_address(unsigned long address, int reliable) 85void printk_address(unsigned long address, int reliable)
87{ 86{
88 printk(" [<%016lx>] %s%pS\n", address, reliable ? "": "? ", (void *) address); 87 printk(" [<%016lx>] %s%pS\n",
88 address, reliable ? "" : "? ", (void *) address);
89} 89}
90 90
91static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack, 91static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
@@ -98,7 +98,8 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
98 [STACKFAULT_STACK - 1] = "#SS", 98 [STACKFAULT_STACK - 1] = "#SS",
99 [MCE_STACK - 1] = "#MC", 99 [MCE_STACK - 1] = "#MC",
100#if DEBUG_STKSZ > EXCEPTION_STKSZ 100#if DEBUG_STKSZ > EXCEPTION_STKSZ
101 [N_EXCEPTION_STACKS ... N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]" 101 [N_EXCEPTION_STACKS ...
102 N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
102#endif 103#endif
103 }; 104 };
104 unsigned k; 105 unsigned k;
@@ -163,7 +164,7 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
163} 164}
164 165
165/* 166/*
166 * x86-64 can have up to three kernel stacks: 167 * x86-64 can have up to three kernel stacks:
167 * process stack 168 * process stack
168 * interrupt stack 169 * interrupt stack
169 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack 170 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
@@ -219,7 +220,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
219 const struct stacktrace_ops *ops, void *data) 220 const struct stacktrace_ops *ops, void *data)
220{ 221{
221 const unsigned cpu = get_cpu(); 222 const unsigned cpu = get_cpu();
222 unsigned long *irqstack_end = (unsigned long*)cpu_pda(cpu)->irqstackptr; 223 unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
223 unsigned used = 0; 224 unsigned used = 0;
224 struct thread_info *tinfo; 225 struct thread_info *tinfo;
225 226
@@ -237,7 +238,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
237 if (!bp) { 238 if (!bp) {
238 if (task == current) { 239 if (task == current) {
239 /* Grab bp right from our regs */ 240 /* Grab bp right from our regs */
240 asm("movq %%rbp, %0" : "=r" (bp) :); 241 asm("movq %%rbp, %0" : "=r" (bp) : );
241 } else { 242 } else {
242 /* bp is the last reg pushed by switch_to */ 243 /* bp is the last reg pushed by switch_to */
243 bp = *(unsigned long *) task->thread.sp; 244 bp = *(unsigned long *) task->thread.sp;
@@ -339,9 +340,8 @@ static void
339show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, 340show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
340 unsigned long *stack, unsigned long bp, char *log_lvl) 341 unsigned long *stack, unsigned long bp, char *log_lvl)
341{ 342{
342 printk("\nCall Trace:\n"); 343 printk("Call Trace:\n");
343 dump_trace(task, regs, stack, bp, &print_trace_ops, log_lvl); 344 dump_trace(task, regs, stack, bp, &print_trace_ops, log_lvl);
344 printk("\n");
345} 345}
346 346
347void show_trace(struct task_struct *task, struct pt_regs *regs, 347void show_trace(struct task_struct *task, struct pt_regs *regs,
@@ -357,11 +357,15 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
357 unsigned long *stack; 357 unsigned long *stack;
358 int i; 358 int i;
359 const int cpu = smp_processor_id(); 359 const int cpu = smp_processor_id();
360 unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr); 360 unsigned long *irqstack_end =
361 unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE); 361 (unsigned long *) (cpu_pda(cpu)->irqstackptr);
362 unsigned long *irqstack =
363 (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE);
362 364
363 // debugging aid: "show_stack(NULL, NULL);" prints the 365 /*
364 // back trace for this cpu. 366 * debugging aid: "show_stack(NULL, NULL);" prints the
367 * back trace for this cpu.
368 */
365 369
366 if (sp == NULL) { 370 if (sp == NULL) {
367 if (task) 371 if (task)
@@ -386,6 +390,7 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
386 printk(" %016lx", *stack++); 390 printk(" %016lx", *stack++);
387 touch_nmi_watchdog(); 391 touch_nmi_watchdog();
388 } 392 }
393 printk("\n");
389 show_trace_log_lvl(task, regs, sp, bp, log_lvl); 394 show_trace_log_lvl(task, regs, sp, bp, log_lvl);
390} 395}
391 396
@@ -404,7 +409,7 @@ void dump_stack(void)
404 409
405#ifdef CONFIG_FRAME_POINTER 410#ifdef CONFIG_FRAME_POINTER
406 if (!bp) 411 if (!bp)
407 asm("movq %%rbp, %0" : "=r" (bp):); 412 asm("movq %%rbp, %0" : "=r" (bp) : );
408#endif 413#endif
409 414
410 printk("Pid: %d, comm: %.20s %s %s %.*s\n", 415 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
@@ -414,7 +419,6 @@ void dump_stack(void)
414 init_utsname()->version); 419 init_utsname()->version);
415 show_trace(NULL, NULL, &stack, bp); 420 show_trace(NULL, NULL, &stack, bp);
416} 421}
417
418EXPORT_SYMBOL(dump_stack); 422EXPORT_SYMBOL(dump_stack);
419 423
420void show_registers(struct pt_regs *regs) 424void show_registers(struct pt_regs *regs)
@@ -443,7 +447,6 @@ void show_registers(struct pt_regs *regs)
443 printk("Stack: "); 447 printk("Stack: ");
444 show_stack_log_lvl(NULL, regs, (unsigned long *)sp, 448 show_stack_log_lvl(NULL, regs, (unsigned long *)sp,
445 regs->bp, ""); 449 regs->bp, "");
446 printk("\n");
447 450
448 printk(KERN_EMERG "Code: "); 451 printk(KERN_EMERG "Code: ");
449 452
@@ -493,7 +496,7 @@ unsigned __kprobes long oops_begin(void)
493 raw_local_irq_save(flags); 496 raw_local_irq_save(flags);
494 cpu = smp_processor_id(); 497 cpu = smp_processor_id();
495 if (!__raw_spin_trylock(&die_lock)) { 498 if (!__raw_spin_trylock(&die_lock)) {
496 if (cpu == die_owner) 499 if (cpu == die_owner)
497 /* nested oops. should stop eventually */; 500 /* nested oops. should stop eventually */;
498 else 501 else
499 __raw_spin_lock(&die_lock); 502 __raw_spin_lock(&die_lock);
@@ -638,7 +641,7 @@ kernel_trap:
638} 641}
639 642
640#define DO_ERROR(trapnr, signr, str, name) \ 643#define DO_ERROR(trapnr, signr, str, name) \
641asmlinkage void do_##name(struct pt_regs * regs, long error_code) \ 644asmlinkage void do_##name(struct pt_regs *regs, long error_code) \
642{ \ 645{ \
643 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \ 646 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
644 == NOTIFY_STOP) \ 647 == NOTIFY_STOP) \
@@ -648,7 +651,7 @@ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
648} 651}
649 652
650#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \ 653#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
651asmlinkage void do_##name(struct pt_regs * regs, long error_code) \ 654asmlinkage void do_##name(struct pt_regs *regs, long error_code) \
652{ \ 655{ \
653 siginfo_t info; \ 656 siginfo_t info; \
654 info.si_signo = signr; \ 657 info.si_signo = signr; \
@@ -683,7 +686,7 @@ asmlinkage void do_stack_segment(struct pt_regs *regs, long error_code)
683 preempt_conditional_cli(regs); 686 preempt_conditional_cli(regs);
684} 687}
685 688
686asmlinkage void do_double_fault(struct pt_regs * regs, long error_code) 689asmlinkage void do_double_fault(struct pt_regs *regs, long error_code)
687{ 690{
688 static const char str[] = "double fault"; 691 static const char str[] = "double fault";
689 struct task_struct *tsk = current; 692 struct task_struct *tsk = current;
@@ -778,9 +781,10 @@ io_check_error(unsigned char reason, struct pt_regs *regs)
778} 781}
779 782
780static notrace __kprobes void 783static notrace __kprobes void
781unknown_nmi_error(unsigned char reason, struct pt_regs * regs) 784unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
782{ 785{
783 if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP) 786 if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) ==
787 NOTIFY_STOP)
784 return; 788 return;
785 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n", 789 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
786 reason); 790 reason);
@@ -882,7 +886,7 @@ asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
882 else if (user_mode(eregs)) 886 else if (user_mode(eregs))
883 regs = task_pt_regs(current); 887 regs = task_pt_regs(current);
884 /* Exception from kernel and interrupts are enabled. Move to 888 /* Exception from kernel and interrupts are enabled. Move to
885 kernel process stack. */ 889 kernel process stack. */
886 else if (eregs->flags & X86_EFLAGS_IF) 890 else if (eregs->flags & X86_EFLAGS_IF)
887 regs = (struct pt_regs *)(eregs->sp -= sizeof(struct pt_regs)); 891 regs = (struct pt_regs *)(eregs->sp -= sizeof(struct pt_regs));
888 if (eregs != regs) 892 if (eregs != regs)
@@ -891,7 +895,7 @@ asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
891} 895}
892 896
893/* runs on IST stack. */ 897/* runs on IST stack. */
894asmlinkage void __kprobes do_debug(struct pt_regs * regs, 898asmlinkage void __kprobes do_debug(struct pt_regs *regs,
895 unsigned long error_code) 899 unsigned long error_code)
896{ 900{
897 struct task_struct *tsk = current; 901 struct task_struct *tsk = current;
@@ -936,7 +940,7 @@ asmlinkage void __kprobes do_debug(struct pt_regs * regs,
936 tsk->thread.error_code = error_code; 940 tsk->thread.error_code = error_code;
937 info.si_signo = SIGTRAP; 941 info.si_signo = SIGTRAP;
938 info.si_errno = 0; 942 info.si_errno = 0;
939 info.si_code = TRAP_BRKPT; 943 info.si_code = get_si_code(condition);
940 info.si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL; 944 info.si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
941 force_sig_info(SIGTRAP, &info, tsk); 945 force_sig_info(SIGTRAP, &info, tsk);
942 946
@@ -1035,7 +1039,7 @@ asmlinkage void do_coprocessor_error(struct pt_regs *regs)
1035 1039
1036asmlinkage void bad_intr(void) 1040asmlinkage void bad_intr(void)
1037{ 1041{
1038 printk("bad interrupt"); 1042 printk("bad interrupt");
1039} 1043}
1040 1044
1041asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs) 1045asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
@@ -1047,7 +1051,7 @@ asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
1047 1051
1048 conditional_sti(regs); 1052 conditional_sti(regs);
1049 if (!user_mode(regs) && 1053 if (!user_mode(regs) &&
1050 kernel_math_error(regs, "kernel simd math error", 19)) 1054 kernel_math_error(regs, "kernel simd math error", 19))
1051 return; 1055 return;
1052 1056
1053 /* 1057 /*
@@ -1092,7 +1096,7 @@ asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
1092 force_sig_info(SIGFPE, &info, task); 1096 force_sig_info(SIGFPE, &info, task);
1093} 1097}
1094 1098
1095asmlinkage void do_spurious_interrupt_bug(struct pt_regs * regs) 1099asmlinkage void do_spurious_interrupt_bug(struct pt_regs *regs)
1096{ 1100{
1097} 1101}
1098 1102
@@ -1134,7 +1138,7 @@ asmlinkage void math_state_restore(void)
1134 /* 1138 /*
1135 * Paranoid restore. send a SIGSEGV if we fail to restore the state. 1139 * Paranoid restore. send a SIGSEGV if we fail to restore the state.
1136 */ 1140 */
1137 if (unlikely(restore_fpu_checking(&me->thread.xstate->fxsave))) { 1141 if (unlikely(restore_fpu_checking(me))) {
1138 stts(); 1142 stts();
1139 force_sig(SIGSEGV, me); 1143 force_sig(SIGSEGV, me);
1140 return; 1144 return;
@@ -1149,8 +1153,10 @@ void __init trap_init(void)
1149 set_intr_gate(0, &divide_error); 1153 set_intr_gate(0, &divide_error);
1150 set_intr_gate_ist(1, &debug, DEBUG_STACK); 1154 set_intr_gate_ist(1, &debug, DEBUG_STACK);
1151 set_intr_gate_ist(2, &nmi, NMI_STACK); 1155 set_intr_gate_ist(2, &nmi, NMI_STACK);
1152 set_system_gate_ist(3, &int3, DEBUG_STACK); /* int3 can be called from all */ 1156 /* int3 can be called from all */
1153 set_system_gate(4, &overflow); /* int4 can be called from all */ 1157 set_system_gate_ist(3, &int3, DEBUG_STACK);
1158 /* int4 can be called from all */
1159 set_system_gate(4, &overflow);
1154 set_intr_gate(5, &bounds); 1160 set_intr_gate(5, &bounds);
1155 set_intr_gate(6, &invalid_op); 1161 set_intr_gate(6, &invalid_op);
1156 set_intr_gate(7, &device_not_available); 1162 set_intr_gate(7, &device_not_available);
@@ -1173,10 +1179,6 @@ void __init trap_init(void)
1173 set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall); 1179 set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
1174#endif 1180#endif
1175 /* 1181 /*
1176 * initialize the per thread extended state:
1177 */
1178 init_thread_xstate();
1179 /*
1180 * Should be a barrier for any external CPU state: 1182 * Should be a barrier for any external CPU state:
1181 */ 1183 */
1182 cpu_init(); 1184 cpu_init();
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 8f98e9de1b82..161bb850fc47 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -104,7 +104,7 @@ __setup("notsc", notsc_setup);
104/* 104/*
105 * Read TSC and the reference counters. Take care of SMI disturbance 105 * Read TSC and the reference counters. Take care of SMI disturbance
106 */ 106 */
107static u64 tsc_read_refs(u64 *pm, u64 *hpet) 107static u64 tsc_read_refs(u64 *p, int hpet)
108{ 108{
109 u64 t1, t2; 109 u64 t1, t2;
110 int i; 110 int i;
@@ -112,9 +112,9 @@ static u64 tsc_read_refs(u64 *pm, u64 *hpet)
112 for (i = 0; i < MAX_RETRIES; i++) { 112 for (i = 0; i < MAX_RETRIES; i++) {
113 t1 = get_cycles(); 113 t1 = get_cycles();
114 if (hpet) 114 if (hpet)
115 *hpet = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF; 115 *p = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF;
116 else 116 else
117 *pm = acpi_pm_read_early(); 117 *p = acpi_pm_read_early();
118 t2 = get_cycles(); 118 t2 = get_cycles();
119 if ((t2 - t1) < SMI_TRESHOLD) 119 if ((t2 - t1) < SMI_TRESHOLD)
120 return t2; 120 return t2;
@@ -123,13 +123,59 @@ static u64 tsc_read_refs(u64 *pm, u64 *hpet)
123} 123}
124 124
125/* 125/*
126 * Calculate the TSC frequency from HPET reference
127 */
128static unsigned long calc_hpet_ref(u64 deltatsc, u64 hpet1, u64 hpet2)
129{
130 u64 tmp;
131
132 if (hpet2 < hpet1)
133 hpet2 += 0x100000000ULL;
134 hpet2 -= hpet1;
135 tmp = ((u64)hpet2 * hpet_readl(HPET_PERIOD));
136 do_div(tmp, 1000000);
137 do_div(deltatsc, tmp);
138
139 return (unsigned long) deltatsc;
140}
141
142/*
143 * Calculate the TSC frequency from PMTimer reference
144 */
145static unsigned long calc_pmtimer_ref(u64 deltatsc, u64 pm1, u64 pm2)
146{
147 u64 tmp;
148
149 if (!pm1 && !pm2)
150 return ULONG_MAX;
151
152 if (pm2 < pm1)
153 pm2 += (u64)ACPI_PM_OVRRUN;
154 pm2 -= pm1;
155 tmp = pm2 * 1000000000LL;
156 do_div(tmp, PMTMR_TICKS_PER_SEC);
157 do_div(deltatsc, tmp);
158
159 return (unsigned long) deltatsc;
160}
161
162#define CAL_MS 10
163#define CAL_LATCH (CLOCK_TICK_RATE / (1000 / CAL_MS))
164#define CAL_PIT_LOOPS 1000
165
166#define CAL2_MS 50
167#define CAL2_LATCH (CLOCK_TICK_RATE / (1000 / CAL2_MS))
168#define CAL2_PIT_LOOPS 5000
169
170
171/*
126 * Try to calibrate the TSC against the Programmable 172 * Try to calibrate the TSC against the Programmable
127 * Interrupt Timer and return the frequency of the TSC 173 * Interrupt Timer and return the frequency of the TSC
128 * in kHz. 174 * in kHz.
129 * 175 *
130 * Return ULONG_MAX on failure to calibrate. 176 * Return ULONG_MAX on failure to calibrate.
131 */ 177 */
132static unsigned long pit_calibrate_tsc(void) 178static unsigned long pit_calibrate_tsc(u32 latch, unsigned long ms, int loopmin)
133{ 179{
134 u64 tsc, t1, t2, delta; 180 u64 tsc, t1, t2, delta;
135 unsigned long tscmin, tscmax; 181 unsigned long tscmin, tscmax;
@@ -144,8 +190,8 @@ static unsigned long pit_calibrate_tsc(void)
144 * (LSB then MSB) to begin countdown. 190 * (LSB then MSB) to begin countdown.
145 */ 191 */
146 outb(0xb0, 0x43); 192 outb(0xb0, 0x43);
147 outb((CLOCK_TICK_RATE / (1000 / 50)) & 0xff, 0x42); 193 outb(latch & 0xff, 0x42);
148 outb((CLOCK_TICK_RATE / (1000 / 50)) >> 8, 0x42); 194 outb(latch >> 8, 0x42);
149 195
150 tsc = t1 = t2 = get_cycles(); 196 tsc = t1 = t2 = get_cycles();
151 197
@@ -166,31 +212,154 @@ static unsigned long pit_calibrate_tsc(void)
166 /* 212 /*
167 * Sanity checks: 213 * Sanity checks:
168 * 214 *
169 * If we were not able to read the PIT more than 5000 215 * If we were not able to read the PIT more than loopmin
170 * times, then we have been hit by a massive SMI 216 * times, then we have been hit by a massive SMI
171 * 217 *
172 * If the maximum is 10 times larger than the minimum, 218 * If the maximum is 10 times larger than the minimum,
173 * then we got hit by an SMI as well. 219 * then we got hit by an SMI as well.
174 */ 220 */
175 if (pitcnt < 5000 || tscmax > 10 * tscmin) 221 if (pitcnt < loopmin || tscmax > 10 * tscmin)
176 return ULONG_MAX; 222 return ULONG_MAX;
177 223
178 /* Calculate the PIT value */ 224 /* Calculate the PIT value */
179 delta = t2 - t1; 225 delta = t2 - t1;
180 do_div(delta, 50); 226 do_div(delta, ms);
181 return delta; 227 return delta;
182} 228}
183 229
230/*
231 * This reads the current MSB of the PIT counter, and
232 * checks if we are running on sufficiently fast and
233 * non-virtualized hardware.
234 *
235 * Our expectations are:
236 *
237 * - the PIT is running at roughly 1.19MHz
238 *
239 * - each IO is going to take about 1us on real hardware,
240 * but we allow it to be much faster (by a factor of 10) or
241 * _slightly_ slower (ie we allow up to a 2us read+counter
242 * update - anything else implies a unacceptably slow CPU
243 * or PIT for the fast calibration to work.
244 *
245 * - with 256 PIT ticks to read the value, we have 214us to
246 * see the same MSB (and overhead like doing a single TSC
247 * read per MSB value etc).
248 *
249 * - We're doing 2 reads per loop (LSB, MSB), and we expect
250 * them each to take about a microsecond on real hardware.
251 * So we expect a count value of around 100. But we'll be
252 * generous, and accept anything over 50.
253 *
254 * - if the PIT is stuck, and we see *many* more reads, we
255 * return early (and the next caller of pit_expect_msb()
256 * then consider it a failure when they don't see the
257 * next expected value).
258 *
259 * These expectations mean that we know that we have seen the
260 * transition from one expected value to another with a fairly
261 * high accuracy, and we didn't miss any events. We can thus
262 * use the TSC value at the transitions to calculate a pretty
263 * good value for the TSC frequencty.
264 */
265static inline int pit_expect_msb(unsigned char val)
266{
267 int count = 0;
268
269 for (count = 0; count < 50000; count++) {
270 /* Ignore LSB */
271 inb(0x42);
272 if (inb(0x42) != val)
273 break;
274 }
275 return count > 50;
276}
277
278/*
279 * How many MSB values do we want to see? We aim for a
280 * 15ms calibration, which assuming a 2us counter read
281 * error should give us roughly 150 ppm precision for
282 * the calibration.
283 */
284#define QUICK_PIT_MS 15
285#define QUICK_PIT_ITERATIONS (QUICK_PIT_MS * PIT_TICK_RATE / 1000 / 256)
286
287static unsigned long quick_pit_calibrate(void)
288{
289 /* Set the Gate high, disable speaker */
290 outb((inb(0x61) & ~0x02) | 0x01, 0x61);
291
292 /*
293 * Counter 2, mode 0 (one-shot), binary count
294 *
295 * NOTE! Mode 2 decrements by two (and then the
296 * output is flipped each time, giving the same
297 * final output frequency as a decrement-by-one),
298 * so mode 0 is much better when looking at the
299 * individual counts.
300 */
301 outb(0xb0, 0x43);
302
303 /* Start at 0xffff */
304 outb(0xff, 0x42);
305 outb(0xff, 0x42);
306
307 if (pit_expect_msb(0xff)) {
308 int i;
309 u64 t1, t2, delta;
310 unsigned char expect = 0xfe;
311
312 t1 = get_cycles();
313 for (i = 0; i < QUICK_PIT_ITERATIONS; i++, expect--) {
314 if (!pit_expect_msb(expect))
315 goto failed;
316 }
317 t2 = get_cycles();
318
319 /*
320 * Make sure we can rely on the second TSC timestamp:
321 */
322 if (!pit_expect_msb(expect))
323 goto failed;
324
325 /*
326 * Ok, if we get here, then we've seen the
327 * MSB of the PIT decrement QUICK_PIT_ITERATIONS
328 * times, and each MSB had many hits, so we never
329 * had any sudden jumps.
330 *
331 * As a result, we can depend on there not being
332 * any odd delays anywhere, and the TSC reads are
333 * reliable.
334 *
335 * kHz = ticks / time-in-seconds / 1000;
336 * kHz = (t2 - t1) / (QPI * 256 / PIT_TICK_RATE) / 1000
337 * kHz = ((t2 - t1) * PIT_TICK_RATE) / (QPI * 256 * 1000)
338 */
339 delta = (t2 - t1)*PIT_TICK_RATE;
340 do_div(delta, QUICK_PIT_ITERATIONS*256*1000);
341 printk("Fast TSC calibration using PIT\n");
342 return delta;
343 }
344failed:
345 return 0;
346}
184 347
185/** 348/**
186 * native_calibrate_tsc - calibrate the tsc on boot 349 * native_calibrate_tsc - calibrate the tsc on boot
187 */ 350 */
188unsigned long native_calibrate_tsc(void) 351unsigned long native_calibrate_tsc(void)
189{ 352{
190 u64 tsc1, tsc2, delta, pm1, pm2, hpet1, hpet2; 353 u64 tsc1, tsc2, delta, ref1, ref2;
191 unsigned long tsc_pit_min = ULONG_MAX, tsc_ref_min = ULONG_MAX; 354 unsigned long tsc_pit_min = ULONG_MAX, tsc_ref_min = ULONG_MAX;
192 unsigned long flags; 355 unsigned long flags, latch, ms, fast_calibrate;
193 int hpet = is_hpet_enabled(), i; 356 int hpet = is_hpet_enabled(), i, loopmin;
357
358 local_irq_save(flags);
359 fast_calibrate = quick_pit_calibrate();
360 local_irq_restore(flags);
361 if (fast_calibrate)
362 return fast_calibrate;
194 363
195 /* 364 /*
196 * Run 5 calibration loops to get the lowest frequency value 365 * Run 5 calibration loops to get the lowest frequency value
@@ -216,7 +385,13 @@ unsigned long native_calibrate_tsc(void)
216 * calibration delay loop as we have to wait for a certain 385 * calibration delay loop as we have to wait for a certain
217 * amount of time anyway. 386 * amount of time anyway.
218 */ 387 */
219 for (i = 0; i < 5; i++) { 388
389 /* Preset PIT loop values */
390 latch = CAL_LATCH;
391 ms = CAL_MS;
392 loopmin = CAL_PIT_LOOPS;
393
394 for (i = 0; i < 3; i++) {
220 unsigned long tsc_pit_khz; 395 unsigned long tsc_pit_khz;
221 396
222 /* 397 /*
@@ -226,16 +401,16 @@ unsigned long native_calibrate_tsc(void)
226 * read the end value. 401 * read the end value.
227 */ 402 */
228 local_irq_save(flags); 403 local_irq_save(flags);
229 tsc1 = tsc_read_refs(&pm1, hpet ? &hpet1 : NULL); 404 tsc1 = tsc_read_refs(&ref1, hpet);
230 tsc_pit_khz = pit_calibrate_tsc(); 405 tsc_pit_khz = pit_calibrate_tsc(latch, ms, loopmin);
231 tsc2 = tsc_read_refs(&pm2, hpet ? &hpet2 : NULL); 406 tsc2 = tsc_read_refs(&ref2, hpet);
232 local_irq_restore(flags); 407 local_irq_restore(flags);
233 408
234 /* Pick the lowest PIT TSC calibration so far */ 409 /* Pick the lowest PIT TSC calibration so far */
235 tsc_pit_min = min(tsc_pit_min, tsc_pit_khz); 410 tsc_pit_min = min(tsc_pit_min, tsc_pit_khz);
236 411
237 /* hpet or pmtimer available ? */ 412 /* hpet or pmtimer available ? */
238 if (!hpet && !pm1 && !pm2) 413 if (!hpet && !ref1 && !ref2)
239 continue; 414 continue;
240 415
241 /* Check, whether the sampling was disturbed by an SMI */ 416 /* Check, whether the sampling was disturbed by an SMI */
@@ -243,23 +418,41 @@ unsigned long native_calibrate_tsc(void)
243 continue; 418 continue;
244 419
245 tsc2 = (tsc2 - tsc1) * 1000000LL; 420 tsc2 = (tsc2 - tsc1) * 1000000LL;
421 if (hpet)
422 tsc2 = calc_hpet_ref(tsc2, ref1, ref2);
423 else
424 tsc2 = calc_pmtimer_ref(tsc2, ref1, ref2);
246 425
247 if (hpet) { 426 tsc_ref_min = min(tsc_ref_min, (unsigned long) tsc2);
248 if (hpet2 < hpet1) 427
249 hpet2 += 0x100000000ULL; 428 /* Check the reference deviation */
250 hpet2 -= hpet1; 429 delta = ((u64) tsc_pit_min) * 100;
251 tsc1 = ((u64)hpet2 * hpet_readl(HPET_PERIOD)); 430 do_div(delta, tsc_ref_min);
252 do_div(tsc1, 1000000); 431
253 } else { 432 /*
254 if (pm2 < pm1) 433 * If both calibration results are inside a 10% window
255 pm2 += (u64)ACPI_PM_OVRRUN; 434 * then we can be sure, that the calibration
256 pm2 -= pm1; 435 * succeeded. We break out of the loop right away. We
257 tsc1 = pm2 * 1000000000LL; 436 * use the reference value, as it is more precise.
258 do_div(tsc1, PMTMR_TICKS_PER_SEC); 437 */
438 if (delta >= 90 && delta <= 110) {
439 printk(KERN_INFO
440 "TSC: PIT calibration matches %s. %d loops\n",
441 hpet ? "HPET" : "PMTIMER", i + 1);
442 return tsc_ref_min;
259 } 443 }
260 444
261 do_div(tsc2, tsc1); 445 /*
262 tsc_ref_min = min(tsc_ref_min, (unsigned long) tsc2); 446 * Check whether PIT failed more than once. This
447 * happens in virtualized environments. We need to
448 * give the virtual PC a slightly longer timeframe for
449 * the HPET/PMTIMER to make the result precise.
450 */
451 if (i == 1 && tsc_pit_min == ULONG_MAX) {
452 latch = CAL2_LATCH;
453 ms = CAL2_MS;
454 loopmin = CAL2_PIT_LOOPS;
455 }
263 } 456 }
264 457
265 /* 458 /*
@@ -270,7 +463,7 @@ unsigned long native_calibrate_tsc(void)
270 printk(KERN_WARNING "TSC: Unable to calibrate against PIT\n"); 463 printk(KERN_WARNING "TSC: Unable to calibrate against PIT\n");
271 464
272 /* We don't have an alternative source, disable TSC */ 465 /* We don't have an alternative source, disable TSC */
273 if (!hpet && !pm1 && !pm2) { 466 if (!hpet && !ref1 && !ref2) {
274 printk("TSC: No reference (HPET/PMTIMER) available\n"); 467 printk("TSC: No reference (HPET/PMTIMER) available\n");
275 return 0; 468 return 0;
276 } 469 }
@@ -278,7 +471,7 @@ unsigned long native_calibrate_tsc(void)
278 /* The alternative source failed as well, disable TSC */ 471 /* The alternative source failed as well, disable TSC */
279 if (tsc_ref_min == ULONG_MAX) { 472 if (tsc_ref_min == ULONG_MAX) {
280 printk(KERN_WARNING "TSC: HPET/PMTIMER calibration " 473 printk(KERN_WARNING "TSC: HPET/PMTIMER calibration "
281 "failed due to SMI disturbance.\n"); 474 "failed.\n");
282 return 0; 475 return 0;
283 } 476 }
284 477
@@ -290,44 +483,25 @@ unsigned long native_calibrate_tsc(void)
290 } 483 }
291 484
292 /* We don't have an alternative source, use the PIT calibration value */ 485 /* We don't have an alternative source, use the PIT calibration value */
293 if (!hpet && !pm1 && !pm2) { 486 if (!hpet && !ref1 && !ref2) {
294 printk(KERN_INFO "TSC: Using PIT calibration value\n"); 487 printk(KERN_INFO "TSC: Using PIT calibration value\n");
295 return tsc_pit_min; 488 return tsc_pit_min;
296 } 489 }
297 490
298 /* The alternative source failed, use the PIT calibration value */ 491 /* The alternative source failed, use the PIT calibration value */
299 if (tsc_ref_min == ULONG_MAX) { 492 if (tsc_ref_min == ULONG_MAX) {
300 printk(KERN_WARNING "TSC: HPET/PMTIMER calibration failed due " 493 printk(KERN_WARNING "TSC: HPET/PMTIMER calibration failed. "
301 "to SMI disturbance. Using PIT calibration\n"); 494 "Using PIT calibration\n");
302 return tsc_pit_min; 495 return tsc_pit_min;
303 } 496 }
304 497
305 /* Check the reference deviation */
306 delta = ((u64) tsc_pit_min) * 100;
307 do_div(delta, tsc_ref_min);
308
309 /*
310 * If both calibration results are inside a 5% window, the we
311 * use the lower frequency of those as it is probably the
312 * closest estimate.
313 */
314 if (delta >= 95 && delta <= 105) {
315 printk(KERN_INFO "TSC: PIT calibration confirmed by %s.\n",
316 hpet ? "HPET" : "PMTIMER");
317 printk(KERN_INFO "TSC: using %s calibration value\n",
318 tsc_pit_min <= tsc_ref_min ? "PIT" :
319 hpet ? "HPET" : "PMTIMER");
320 return tsc_pit_min <= tsc_ref_min ? tsc_pit_min : tsc_ref_min;
321 }
322
323 printk(KERN_WARNING "TSC: PIT calibration deviates from %s: %lu %lu.\n",
324 hpet ? "HPET" : "PMTIMER", tsc_pit_min, tsc_ref_min);
325
326 /* 498 /*
327 * The calibration values differ too much. In doubt, we use 499 * The calibration values differ too much. In doubt, we use
328 * the PIT value as we know that there are PMTIMERs around 500 * the PIT value as we know that there are PMTIMERs around
329 * running at double speed. 501 * running at double speed. At least we let the user know:
330 */ 502 */
503 printk(KERN_WARNING "TSC: PIT calibration deviates from %s: %lu %lu.\n",
504 hpet ? "HPET" : "PMTIMER", tsc_pit_min, tsc_ref_min);
331 printk(KERN_INFO "TSC: Using PIT calibration value\n"); 505 printk(KERN_INFO "TSC: Using PIT calibration value\n");
332 return tsc_pit_min; 506 return tsc_pit_min;
333} 507}
diff --git a/arch/x86/kernel/visws_quirks.c b/arch/x86/kernel/visws_quirks.c
index 594ef47f0a63..61a97e616f70 100644
--- a/arch/x86/kernel/visws_quirks.c
+++ b/arch/x86/kernel/visws_quirks.c
@@ -25,45 +25,31 @@
25#include <asm/visws/cobalt.h> 25#include <asm/visws/cobalt.h>
26#include <asm/visws/piix4.h> 26#include <asm/visws/piix4.h>
27#include <asm/arch_hooks.h> 27#include <asm/arch_hooks.h>
28#include <asm/io_apic.h>
28#include <asm/fixmap.h> 29#include <asm/fixmap.h>
29#include <asm/reboot.h> 30#include <asm/reboot.h>
30#include <asm/setup.h> 31#include <asm/setup.h>
31#include <asm/e820.h> 32#include <asm/e820.h>
32#include <asm/smp.h>
33#include <asm/io.h> 33#include <asm/io.h>
34 34
35#include <mach_ipi.h> 35#include <mach_ipi.h>
36 36
37#include "mach_apic.h" 37#include "mach_apic.h"
38 38
39#include <linux/init.h>
40#include <linux/smp.h>
41
42#include <linux/kernel_stat.h> 39#include <linux/kernel_stat.h>
43#include <linux/interrupt.h>
44#include <linux/init.h>
45 40
46#include <asm/io.h>
47#include <asm/apic.h>
48#include <asm/i8259.h> 41#include <asm/i8259.h>
49#include <asm/irq_vectors.h> 42#include <asm/irq_vectors.h>
50#include <asm/visws/cobalt.h>
51#include <asm/visws/lithium.h> 43#include <asm/visws/lithium.h>
52#include <asm/visws/piix4.h>
53 44
54#include <linux/sched.h> 45#include <linux/sched.h>
55#include <linux/kernel.h> 46#include <linux/kernel.h>
56#include <linux/init.h>
57#include <linux/pci.h> 47#include <linux/pci.h>
58#include <linux/pci_ids.h> 48#include <linux/pci_ids.h>
59 49
60extern int no_broadcast; 50extern int no_broadcast;
61 51
62#include <asm/io.h>
63#include <asm/apic.h> 52#include <asm/apic.h>
64#include <asm/arch_hooks.h>
65#include <asm/visws/cobalt.h>
66#include <asm/visws/lithium.h>
67 53
68char visws_board_type = -1; 54char visws_board_type = -1;
69char visws_board_rev = -1; 55char visws_board_rev = -1;
diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index 38f566fa27d2..4eeb5cf9720d 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -46,6 +46,7 @@
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/tlbflush.h> 47#include <asm/tlbflush.h>
48#include <asm/irq.h> 48#include <asm/irq.h>
49#include <asm/syscalls.h>
49 50
50/* 51/*
51 * Known problems: 52 * Known problems:
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c
index 6ca515d6db54..8b6c393ab9fd 100644
--- a/arch/x86/kernel/vmi_32.c
+++ b/arch/x86/kernel/vmi_32.c
@@ -235,7 +235,7 @@ static void vmi_write_ldt_entry(struct desc_struct *dt, int entry,
235 const void *desc) 235 const void *desc)
236{ 236{
237 u32 *ldt_entry = (u32 *)desc; 237 u32 *ldt_entry = (u32 *)desc;
238 vmi_ops.write_idt_entry(dt, entry, ldt_entry[0], ldt_entry[1]); 238 vmi_ops.write_ldt_entry(dt, entry, ldt_entry[0], ldt_entry[1]);
239} 239}
240 240
241static void vmi_load_sp0(struct tss_struct *tss, 241static void vmi_load_sp0(struct tss_struct *tss,
@@ -393,13 +393,13 @@ static void *vmi_kmap_atomic_pte(struct page *page, enum km_type type)
393} 393}
394#endif 394#endif
395 395
396static void vmi_allocate_pte(struct mm_struct *mm, u32 pfn) 396static void vmi_allocate_pte(struct mm_struct *mm, unsigned long pfn)
397{ 397{
398 vmi_set_page_type(pfn, VMI_PAGE_L1); 398 vmi_set_page_type(pfn, VMI_PAGE_L1);
399 vmi_ops.allocate_page(pfn, VMI_PAGE_L1, 0, 0, 0); 399 vmi_ops.allocate_page(pfn, VMI_PAGE_L1, 0, 0, 0);
400} 400}
401 401
402static void vmi_allocate_pmd(struct mm_struct *mm, u32 pfn) 402static void vmi_allocate_pmd(struct mm_struct *mm, unsigned long pfn)
403{ 403{
404 /* 404 /*
405 * This call comes in very early, before mem_map is setup. 405 * This call comes in very early, before mem_map is setup.
@@ -410,20 +410,20 @@ static void vmi_allocate_pmd(struct mm_struct *mm, u32 pfn)
410 vmi_ops.allocate_page(pfn, VMI_PAGE_L2, 0, 0, 0); 410 vmi_ops.allocate_page(pfn, VMI_PAGE_L2, 0, 0, 0);
411} 411}
412 412
413static void vmi_allocate_pmd_clone(u32 pfn, u32 clonepfn, u32 start, u32 count) 413static void vmi_allocate_pmd_clone(unsigned long pfn, unsigned long clonepfn, unsigned long start, unsigned long count)
414{ 414{
415 vmi_set_page_type(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE); 415 vmi_set_page_type(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE);
416 vmi_check_page_type(clonepfn, VMI_PAGE_L2); 416 vmi_check_page_type(clonepfn, VMI_PAGE_L2);
417 vmi_ops.allocate_page(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE, clonepfn, start, count); 417 vmi_ops.allocate_page(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE, clonepfn, start, count);
418} 418}
419 419
420static void vmi_release_pte(u32 pfn) 420static void vmi_release_pte(unsigned long pfn)
421{ 421{
422 vmi_ops.release_page(pfn, VMI_PAGE_L1); 422 vmi_ops.release_page(pfn, VMI_PAGE_L1);
423 vmi_set_page_type(pfn, VMI_PAGE_NORMAL); 423 vmi_set_page_type(pfn, VMI_PAGE_NORMAL);
424} 424}
425 425
426static void vmi_release_pmd(u32 pfn) 426static void vmi_release_pmd(unsigned long pfn)
427{ 427{
428 vmi_ops.release_page(pfn, VMI_PAGE_L2); 428 vmi_ops.release_page(pfn, VMI_PAGE_L2);
429 vmi_set_page_type(pfn, VMI_PAGE_NORMAL); 429 vmi_set_page_type(pfn, VMI_PAGE_NORMAL);
@@ -905,8 +905,8 @@ static inline int __init activate_vmi(void)
905#endif 905#endif
906 906
907#ifdef CONFIG_X86_LOCAL_APIC 907#ifdef CONFIG_X86_LOCAL_APIC
908 para_fill(pv_apic_ops.apic_read, APICRead); 908 para_fill(apic_ops->read, APICRead);
909 para_fill(pv_apic_ops.apic_write, APICWrite); 909 para_fill(apic_ops->write, APICWrite);
910#endif 910#endif
911 911
912 /* 912 /*
diff --git a/arch/x86/kernel/vmlinux_32.lds.S b/arch/x86/kernel/vmlinux_32.lds.S
index af5bdad84604..a9b8560adbc2 100644
--- a/arch/x86/kernel/vmlinux_32.lds.S
+++ b/arch/x86/kernel/vmlinux_32.lds.S
@@ -140,10 +140,10 @@ SECTIONS
140 *(.con_initcall.init) 140 *(.con_initcall.init)
141 __con_initcall_end = .; 141 __con_initcall_end = .;
142 } 142 }
143 .x86cpuvendor.init : AT(ADDR(.x86cpuvendor.init) - LOAD_OFFSET) { 143 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
144 __x86cpuvendor_start = .; 144 __x86_cpu_dev_start = .;
145 *(.x86cpuvendor.init) 145 *(.x86_cpu_dev.init)
146 __x86cpuvendor_end = .; 146 __x86_cpu_dev_end = .;
147 } 147 }
148 SECURITY_INIT 148 SECURITY_INIT
149 . = ALIGN(4); 149 . = ALIGN(4);
@@ -180,6 +180,7 @@ SECTIONS
180 . = ALIGN(PAGE_SIZE); 180 . = ALIGN(PAGE_SIZE);
181 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { 181 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
182 __per_cpu_start = .; 182 __per_cpu_start = .;
183 *(.data.percpu.page_aligned)
183 *(.data.percpu) 184 *(.data.percpu)
184 *(.data.percpu.shared_aligned) 185 *(.data.percpu.shared_aligned)
185 __per_cpu_end = .; 186 __per_cpu_end = .;
diff --git a/arch/x86/kernel/vmlinux_64.lds.S b/arch/x86/kernel/vmlinux_64.lds.S
index 63e5c1a22e88..46e05447405b 100644
--- a/arch/x86/kernel/vmlinux_64.lds.S
+++ b/arch/x86/kernel/vmlinux_64.lds.S
@@ -168,12 +168,11 @@ SECTIONS
168 *(.con_initcall.init) 168 *(.con_initcall.init)
169 } 169 }
170 __con_initcall_end = .; 170 __con_initcall_end = .;
171 . = ALIGN(16); 171 __x86_cpu_dev_start = .;
172 __x86cpuvendor_start = .; 172 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
173 .x86cpuvendor.init : AT(ADDR(.x86cpuvendor.init) - LOAD_OFFSET) { 173 *(.x86_cpu_dev.init)
174 *(.x86cpuvendor.init)
175 } 174 }
176 __x86cpuvendor_end = .; 175 __x86_cpu_dev_end = .;
177 SECURITY_INIT 176 SECURITY_INIT
178 177
179 . = ALIGN(8); 178 . = ALIGN(8);
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
new file mode 100644
index 000000000000..9abac8a9d823
--- /dev/null
+++ b/arch/x86/kernel/xsave.c
@@ -0,0 +1,345 @@
1/*
2 * xsave/xrstor support.
3 *
4 * Author: Suresh Siddha <suresh.b.siddha@intel.com>
5 */
6#include <linux/bootmem.h>
7#include <linux/compat.h>
8#include <asm/i387.h>
9#ifdef CONFIG_IA32_EMULATION
10#include <asm/sigcontext32.h>
11#endif
12#include <asm/xcr.h>
13
14/*
15 * Supported feature mask by the CPU and the kernel.
16 */
17u64 pcntxt_mask;
18
19struct _fpx_sw_bytes fx_sw_reserved;
20#ifdef CONFIG_IA32_EMULATION
21struct _fpx_sw_bytes fx_sw_reserved_ia32;
22#endif
23
24/*
25 * Check for the presence of extended state information in the
26 * user fpstate pointer in the sigcontext.
27 */
28int check_for_xstate(struct i387_fxsave_struct __user *buf,
29 void __user *fpstate,
30 struct _fpx_sw_bytes *fx_sw_user)
31{
32 int min_xstate_size = sizeof(struct i387_fxsave_struct) +
33 sizeof(struct xsave_hdr_struct);
34 unsigned int magic2;
35 int err;
36
37 err = __copy_from_user(fx_sw_user, &buf->sw_reserved[0],
38 sizeof(struct _fpx_sw_bytes));
39
40 if (err)
41 return err;
42
43 /*
44 * First Magic check failed.
45 */
46 if (fx_sw_user->magic1 != FP_XSTATE_MAGIC1)
47 return -1;
48
49 /*
50 * Check for error scenarios.
51 */
52 if (fx_sw_user->xstate_size < min_xstate_size ||
53 fx_sw_user->xstate_size > xstate_size ||
54 fx_sw_user->xstate_size > fx_sw_user->extended_size)
55 return -1;
56
57 err = __get_user(magic2, (__u32 *) (((void *)fpstate) +
58 fx_sw_user->extended_size -
59 FP_XSTATE_MAGIC2_SIZE));
60 /*
61 * Check for the presence of second magic word at the end of memory
62 * layout. This detects the case where the user just copied the legacy
63 * fpstate layout with out copying the extended state information
64 * in the memory layout.
65 */
66 if (err || magic2 != FP_XSTATE_MAGIC2)
67 return -1;
68
69 return 0;
70}
71
72#ifdef CONFIG_X86_64
73/*
74 * Signal frame handlers.
75 */
76
77int save_i387_xstate(void __user *buf)
78{
79 struct task_struct *tsk = current;
80 int err = 0;
81
82 if (!access_ok(VERIFY_WRITE, buf, sig_xstate_size))
83 return -EACCES;
84
85 BUG_ON(sig_xstate_size < xstate_size);
86
87 if ((unsigned long)buf % 64)
88 printk("save_i387_xstate: bad fpstate %p\n", buf);
89
90 if (!used_math())
91 return 0;
92 clear_used_math(); /* trigger finit */
93 if (task_thread_info(tsk)->status & TS_USEDFPU) {
94 /*
95 * Start with clearing the user buffer. This will present a
96 * clean context for the bytes not touched by the fxsave/xsave.
97 */
98 err = __clear_user(buf, sig_xstate_size);
99 if (err)
100 return err;
101
102 if (task_thread_info(tsk)->status & TS_XSAVE)
103 err = xsave_user(buf);
104 else
105 err = fxsave_user(buf);
106
107 if (err)
108 return err;
109 task_thread_info(tsk)->status &= ~TS_USEDFPU;
110 stts();
111 } else {
112 if (__copy_to_user(buf, &tsk->thread.xstate->fxsave,
113 xstate_size))
114 return -1;
115 }
116
117 if (task_thread_info(tsk)->status & TS_XSAVE) {
118 struct _fpstate __user *fx = buf;
119 struct _xstate __user *x = buf;
120 u64 xstate_bv;
121
122 err = __copy_to_user(&fx->sw_reserved, &fx_sw_reserved,
123 sizeof(struct _fpx_sw_bytes));
124
125 err |= __put_user(FP_XSTATE_MAGIC2,
126 (__u32 __user *) (buf + sig_xstate_size
127 - FP_XSTATE_MAGIC2_SIZE));
128
129 /*
130 * Read the xstate_bv which we copied (directly from the cpu or
131 * from the state in task struct) to the user buffers and
132 * set the FP/SSE bits.
133 */
134 err |= __get_user(xstate_bv, &x->xstate_hdr.xstate_bv);
135
136 /*
137 * For legacy compatible, we always set FP/SSE bits in the bit
138 * vector while saving the state to the user context. This will
139 * enable us capturing any changes(during sigreturn) to
140 * the FP/SSE bits by the legacy applications which don't touch
141 * xstate_bv in the xsave header.
142 *
143 * xsave aware apps can change the xstate_bv in the xsave
144 * header as well as change any contents in the memory layout.
145 * xrestore as part of sigreturn will capture all the changes.
146 */
147 xstate_bv |= XSTATE_FPSSE;
148
149 err |= __put_user(xstate_bv, &x->xstate_hdr.xstate_bv);
150
151 if (err)
152 return err;
153 }
154
155 return 1;
156}
157
158/*
159 * Restore the extended state if present. Otherwise, restore the FP/SSE
160 * state.
161 */
162int restore_user_xstate(void __user *buf)
163{
164 struct _fpx_sw_bytes fx_sw_user;
165 u64 mask;
166 int err;
167
168 if (((unsigned long)buf % 64) ||
169 check_for_xstate(buf, buf, &fx_sw_user))
170 goto fx_only;
171
172 mask = fx_sw_user.xstate_bv;
173
174 /*
175 * restore the state passed by the user.
176 */
177 err = xrestore_user(buf, mask);
178 if (err)
179 return err;
180
181 /*
182 * init the state skipped by the user.
183 */
184 mask = pcntxt_mask & ~mask;
185
186 xrstor_state(init_xstate_buf, mask);
187
188 return 0;
189
190fx_only:
191 /*
192 * couldn't find the extended state information in the
193 * memory layout. Restore just the FP/SSE and init all
194 * the other extended state.
195 */
196 xrstor_state(init_xstate_buf, pcntxt_mask & ~XSTATE_FPSSE);
197 return fxrstor_checking((__force struct i387_fxsave_struct *)buf);
198}
199
200/*
201 * This restores directly out of user space. Exceptions are handled.
202 */
203int restore_i387_xstate(void __user *buf)
204{
205 struct task_struct *tsk = current;
206 int err = 0;
207
208 if (!buf) {
209 if (used_math())
210 goto clear;
211 return 0;
212 } else
213 if (!access_ok(VERIFY_READ, buf, sig_xstate_size))
214 return -EACCES;
215
216 if (!used_math()) {
217 err = init_fpu(tsk);
218 if (err)
219 return err;
220 }
221
222 if (!(task_thread_info(current)->status & TS_USEDFPU)) {
223 clts();
224 task_thread_info(current)->status |= TS_USEDFPU;
225 }
226 if (task_thread_info(tsk)->status & TS_XSAVE)
227 err = restore_user_xstate(buf);
228 else
229 err = fxrstor_checking((__force struct i387_fxsave_struct *)
230 buf);
231 if (unlikely(err)) {
232 /*
233 * Encountered an error while doing the restore from the
234 * user buffer, clear the fpu state.
235 */
236clear:
237 clear_fpu(tsk);
238 clear_used_math();
239 }
240 return err;
241}
242#endif
243
244/*
245 * Prepare the SW reserved portion of the fxsave memory layout, indicating
246 * the presence of the extended state information in the memory layout
247 * pointed by the fpstate pointer in the sigcontext.
248 * This will be saved when ever the FP and extended state context is
249 * saved on the user stack during the signal handler delivery to the user.
250 */
251void prepare_fx_sw_frame(void)
252{
253 int size_extended = (xstate_size - sizeof(struct i387_fxsave_struct)) +
254 FP_XSTATE_MAGIC2_SIZE;
255
256 sig_xstate_size = sizeof(struct _fpstate) + size_extended;
257
258#ifdef CONFIG_IA32_EMULATION
259 sig_xstate_ia32_size = sizeof(struct _fpstate_ia32) + size_extended;
260#endif
261
262 memset(&fx_sw_reserved, 0, sizeof(fx_sw_reserved));
263
264 fx_sw_reserved.magic1 = FP_XSTATE_MAGIC1;
265 fx_sw_reserved.extended_size = sig_xstate_size;
266 fx_sw_reserved.xstate_bv = pcntxt_mask;
267 fx_sw_reserved.xstate_size = xstate_size;
268#ifdef CONFIG_IA32_EMULATION
269 memcpy(&fx_sw_reserved_ia32, &fx_sw_reserved,
270 sizeof(struct _fpx_sw_bytes));
271 fx_sw_reserved_ia32.extended_size = sig_xstate_ia32_size;
272#endif
273}
274
275/*
276 * Represents init state for the supported extended state.
277 */
278struct xsave_struct *init_xstate_buf;
279
280#ifdef CONFIG_X86_64
281unsigned int sig_xstate_size = sizeof(struct _fpstate);
282#endif
283
284/*
285 * Enable the extended processor state save/restore feature
286 */
287void __cpuinit xsave_init(void)
288{
289 if (!cpu_has_xsave)
290 return;
291
292 set_in_cr4(X86_CR4_OSXSAVE);
293
294 /*
295 * Enable all the features that the HW is capable of
296 * and the Linux kernel is aware of.
297 */
298 xsetbv(XCR_XFEATURE_ENABLED_MASK, pcntxt_mask);
299}
300
301/*
302 * setup the xstate image representing the init state
303 */
304static void __init setup_xstate_init(void)
305{
306 init_xstate_buf = alloc_bootmem(xstate_size);
307 init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;
308}
309
310/*
311 * Enable and initialize the xsave feature.
312 */
313void __init xsave_cntxt_init(void)
314{
315 unsigned int eax, ebx, ecx, edx;
316
317 cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx);
318 pcntxt_mask = eax + ((u64)edx << 32);
319
320 if ((pcntxt_mask & XSTATE_FPSSE) != XSTATE_FPSSE) {
321 printk(KERN_ERR "FP/SSE not shown under xsave features 0x%llx\n",
322 pcntxt_mask);
323 BUG();
324 }
325
326 /*
327 * for now OS knows only about FP/SSE
328 */
329 pcntxt_mask = pcntxt_mask & XCNTXT_MASK;
330 xsave_init();
331
332 /*
333 * Recompute the context size for enabled features
334 */
335 cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx);
336 xstate_size = ebx;
337
338 prepare_fx_sw_frame();
339
340 setup_xstate_init();
341
342 printk(KERN_INFO "xsave/xrstor: enabled xstate_bv 0x%llx, "
343 "cntxt size 0x%x\n",
344 pcntxt_mask, xstate_size);
345}
diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h
index 23e8373507ad..17e25995b65b 100644
--- a/arch/x86/kvm/vmx.h
+++ b/arch/x86/kvm/vmx.h
@@ -331,21 +331,6 @@ enum vmcs_field {
331 331
332#define AR_RESERVD_MASK 0xfffe0f00 332#define AR_RESERVD_MASK 0xfffe0f00
333 333
334#define MSR_IA32_VMX_BASIC 0x480
335#define MSR_IA32_VMX_PINBASED_CTLS 0x481
336#define MSR_IA32_VMX_PROCBASED_CTLS 0x482
337#define MSR_IA32_VMX_EXIT_CTLS 0x483
338#define MSR_IA32_VMX_ENTRY_CTLS 0x484
339#define MSR_IA32_VMX_MISC 0x485
340#define MSR_IA32_VMX_CR0_FIXED0 0x486
341#define MSR_IA32_VMX_CR0_FIXED1 0x487
342#define MSR_IA32_VMX_CR4_FIXED0 0x488
343#define MSR_IA32_VMX_CR4_FIXED1 0x489
344#define MSR_IA32_VMX_VMCS_ENUM 0x48a
345#define MSR_IA32_VMX_PROCBASED_CTLS2 0x48b
346#define MSR_IA32_VMX_EPT_VPID_CAP 0x48c
347
348#define MSR_IA32_FEATURE_CONTROL 0x3a
349#define MSR_IA32_FEATURE_CONTROL_LOCKED 0x1 334#define MSR_IA32_FEATURE_CONTROL_LOCKED 0x1
350#define MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED 0x4 335#define MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED 0x4
351 336
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index d9249a882aa5..65f0b8a47bed 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -55,6 +55,7 @@
55#include <linux/lguest_launcher.h> 55#include <linux/lguest_launcher.h>
56#include <linux/virtio_console.h> 56#include <linux/virtio_console.h>
57#include <linux/pm.h> 57#include <linux/pm.h>
58#include <asm/apic.h>
58#include <asm/lguest.h> 59#include <asm/lguest.h>
59#include <asm/paravirt.h> 60#include <asm/paravirt.h>
60#include <asm/param.h> 61#include <asm/param.h>
@@ -783,14 +784,44 @@ static void lguest_wbinvd(void)
783 * code qualifies for Advanced. It will also never interrupt anything. It 784 * code qualifies for Advanced. It will also never interrupt anything. It
784 * does, however, allow us to get through the Linux boot code. */ 785 * does, however, allow us to get through the Linux boot code. */
785#ifdef CONFIG_X86_LOCAL_APIC 786#ifdef CONFIG_X86_LOCAL_APIC
786static void lguest_apic_write(unsigned long reg, u32 v) 787static void lguest_apic_write(u32 reg, u32 v)
787{ 788{
788} 789}
789 790
790static u32 lguest_apic_read(unsigned long reg) 791static u32 lguest_apic_read(u32 reg)
791{ 792{
792 return 0; 793 return 0;
793} 794}
795
796static u64 lguest_apic_icr_read(void)
797{
798 return 0;
799}
800
801static void lguest_apic_icr_write(u32 low, u32 id)
802{
803 /* Warn to see if there's any stray references */
804 WARN_ON(1);
805}
806
807static void lguest_apic_wait_icr_idle(void)
808{
809 return;
810}
811
812static u32 lguest_apic_safe_wait_icr_idle(void)
813{
814 return 0;
815}
816
817static struct apic_ops lguest_basic_apic_ops = {
818 .read = lguest_apic_read,
819 .write = lguest_apic_write,
820 .icr_read = lguest_apic_icr_read,
821 .icr_write = lguest_apic_icr_write,
822 .wait_icr_idle = lguest_apic_wait_icr_idle,
823 .safe_wait_icr_idle = lguest_apic_safe_wait_icr_idle,
824};
794#endif 825#endif
795 826
796/* STOP! Until an interrupt comes in. */ 827/* STOP! Until an interrupt comes in. */
@@ -990,8 +1021,7 @@ __init void lguest_init(void)
990 1021
991#ifdef CONFIG_X86_LOCAL_APIC 1022#ifdef CONFIG_X86_LOCAL_APIC
992 /* apic read/write intercepts */ 1023 /* apic read/write intercepts */
993 pv_apic_ops.apic_write = lguest_apic_write; 1024 apic_ops = &lguest_basic_apic_ops;
994 pv_apic_ops.apic_read = lguest_apic_read;
995#endif 1025#endif
996 1026
997 /* time operations */ 1027 /* time operations */
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index aa3fa4119424..55e11aa6d66c 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -17,9 +17,6 @@ ifeq ($(CONFIG_X86_32),y)
17 lib-$(CONFIG_X86_USE_3DNOW) += mmx_32.o 17 lib-$(CONFIG_X86_USE_3DNOW) += mmx_32.o
18else 18else
19 obj-y += io_64.o iomap_copy_64.o 19 obj-y += io_64.o iomap_copy_64.o
20
21 CFLAGS_csum-partial_64.o := -funroll-loops
22
23 lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o 20 lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o
24 lib-y += thunk_64.o clear_page_64.o copy_page_64.o 21 lib-y += thunk_64.o clear_page_64.o copy_page_64.o
25 lib-y += memmove_64.o memset_64.o 22 lib-y += memmove_64.o memset_64.o
diff --git a/arch/x86/lib/msr-on-cpu.c b/arch/x86/lib/msr-on-cpu.c
index 01b868ba82f8..321cf720dbb6 100644
--- a/arch/x86/lib/msr-on-cpu.c
+++ b/arch/x86/lib/msr-on-cpu.c
@@ -16,37 +16,46 @@ static void __rdmsr_on_cpu(void *info)
16 rdmsr(rv->msr_no, rv->l, rv->h); 16 rdmsr(rv->msr_no, rv->l, rv->h);
17} 17}
18 18
19static void __rdmsr_safe_on_cpu(void *info) 19static void __wrmsr_on_cpu(void *info)
20{ 20{
21 struct msr_info *rv = info; 21 struct msr_info *rv = info;
22 22
23 rv->err = rdmsr_safe(rv->msr_no, &rv->l, &rv->h); 23 wrmsr(rv->msr_no, rv->l, rv->h);
24} 24}
25 25
26static int _rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h, int safe) 26int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
27{ 27{
28 int err = 0; 28 int err;
29 struct msr_info rv; 29 struct msr_info rv;
30 30
31 rv.msr_no = msr_no; 31 rv.msr_no = msr_no;
32 if (safe) { 32 err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
33 err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu,
34 &rv, 1);
35 err = err ? err : rv.err;
36 } else {
37 err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
38 }
39 *l = rv.l; 33 *l = rv.l;
40 *h = rv.h; 34 *h = rv.h;
41 35
42 return err; 36 return err;
43} 37}
44 38
45static void __wrmsr_on_cpu(void *info) 39int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
40{
41 int err;
42 struct msr_info rv;
43
44 rv.msr_no = msr_no;
45 rv.l = l;
46 rv.h = h;
47 err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
48
49 return err;
50}
51
52/* These "safe" variants are slower and should be used when the target MSR
53 may not actually exist. */
54static void __rdmsr_safe_on_cpu(void *info)
46{ 55{
47 struct msr_info *rv = info; 56 struct msr_info *rv = info;
48 57
49 wrmsr(rv->msr_no, rv->l, rv->h); 58 rv->err = rdmsr_safe(rv->msr_no, &rv->l, &rv->h);
50} 59}
51 60
52static void __wrmsr_safe_on_cpu(void *info) 61static void __wrmsr_safe_on_cpu(void *info)
@@ -56,45 +65,30 @@ static void __wrmsr_safe_on_cpu(void *info)
56 rv->err = wrmsr_safe(rv->msr_no, rv->l, rv->h); 65 rv->err = wrmsr_safe(rv->msr_no, rv->l, rv->h);
57} 66}
58 67
59static int _wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h, int safe) 68int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
60{ 69{
61 int err = 0; 70 int err;
62 struct msr_info rv; 71 struct msr_info rv;
63 72
64 rv.msr_no = msr_no; 73 rv.msr_no = msr_no;
65 rv.l = l; 74 err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
66 rv.h = h; 75 *l = rv.l;
67 if (safe) { 76 *h = rv.h;
68 err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu,
69 &rv, 1);
70 err = err ? err : rv.err;
71 } else {
72 err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
73 }
74
75 return err;
76}
77 77
78int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) 78 return err ? err : rv.err;
79{
80 return _wrmsr_on_cpu(cpu, msr_no, l, h, 0);
81} 79}
82 80
83int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
84{
85 return _rdmsr_on_cpu(cpu, msr_no, l, h, 0);
86}
87
88/* These "safe" variants are slower and should be used when the target MSR
89 may not actually exist. */
90int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) 81int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
91{ 82{
92 return _wrmsr_on_cpu(cpu, msr_no, l, h, 1); 83 int err;
93} 84 struct msr_info rv;
94 85
95int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) 86 rv.msr_no = msr_no;
96{ 87 rv.l = l;
97 return _rdmsr_on_cpu(cpu, msr_no, l, h, 1); 88 rv.h = h;
89 err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1);
90
91 return err ? err : rv.err;
98} 92}
99 93
100EXPORT_SYMBOL(rdmsr_on_cpu); 94EXPORT_SYMBOL(rdmsr_on_cpu);
diff --git a/arch/x86/lib/string_32.c b/arch/x86/lib/string_32.c
index 94972e7c094d..82004d2bf05e 100644
--- a/arch/x86/lib/string_32.c
+++ b/arch/x86/lib/string_32.c
@@ -22,7 +22,7 @@ char *strcpy(char *dest, const char *src)
22 "testb %%al,%%al\n\t" 22 "testb %%al,%%al\n\t"
23 "jne 1b" 23 "jne 1b"
24 : "=&S" (d0), "=&D" (d1), "=&a" (d2) 24 : "=&S" (d0), "=&D" (d1), "=&a" (d2)
25 :"0" (src), "1" (dest) : "memory"); 25 : "0" (src), "1" (dest) : "memory");
26 return dest; 26 return dest;
27} 27}
28EXPORT_SYMBOL(strcpy); 28EXPORT_SYMBOL(strcpy);
@@ -42,7 +42,7 @@ char *strncpy(char *dest, const char *src, size_t count)
42 "stosb\n" 42 "stosb\n"
43 "2:" 43 "2:"
44 : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3) 44 : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3)
45 :"0" (src), "1" (dest), "2" (count) : "memory"); 45 : "0" (src), "1" (dest), "2" (count) : "memory");
46 return dest; 46 return dest;
47} 47}
48EXPORT_SYMBOL(strncpy); 48EXPORT_SYMBOL(strncpy);
@@ -60,7 +60,7 @@ char *strcat(char *dest, const char *src)
60 "testb %%al,%%al\n\t" 60 "testb %%al,%%al\n\t"
61 "jne 1b" 61 "jne 1b"
62 : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) 62 : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
63 : "0" (src), "1" (dest), "2" (0), "3" (0xffffffffu): "memory"); 63 : "0" (src), "1" (dest), "2" (0), "3" (0xffffffffu) : "memory");
64 return dest; 64 return dest;
65} 65}
66EXPORT_SYMBOL(strcat); 66EXPORT_SYMBOL(strcat);
@@ -105,9 +105,9 @@ int strcmp(const char *cs, const char *ct)
105 "2:\tsbbl %%eax,%%eax\n\t" 105 "2:\tsbbl %%eax,%%eax\n\t"
106 "orb $1,%%al\n" 106 "orb $1,%%al\n"
107 "3:" 107 "3:"
108 :"=a" (res), "=&S" (d0), "=&D" (d1) 108 : "=a" (res), "=&S" (d0), "=&D" (d1)
109 :"1" (cs), "2" (ct) 109 : "1" (cs), "2" (ct)
110 :"memory"); 110 : "memory");
111 return res; 111 return res;
112} 112}
113EXPORT_SYMBOL(strcmp); 113EXPORT_SYMBOL(strcmp);
@@ -130,9 +130,9 @@ int strncmp(const char *cs, const char *ct, size_t count)
130 "3:\tsbbl %%eax,%%eax\n\t" 130 "3:\tsbbl %%eax,%%eax\n\t"
131 "orb $1,%%al\n" 131 "orb $1,%%al\n"
132 "4:" 132 "4:"
133 :"=a" (res), "=&S" (d0), "=&D" (d1), "=&c" (d2) 133 : "=a" (res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
134 :"1" (cs), "2" (ct), "3" (count) 134 : "1" (cs), "2" (ct), "3" (count)
135 :"memory"); 135 : "memory");
136 return res; 136 return res;
137} 137}
138EXPORT_SYMBOL(strncmp); 138EXPORT_SYMBOL(strncmp);
@@ -152,9 +152,9 @@ char *strchr(const char *s, int c)
152 "movl $1,%1\n" 152 "movl $1,%1\n"
153 "2:\tmovl %1,%0\n\t" 153 "2:\tmovl %1,%0\n\t"
154 "decl %0" 154 "decl %0"
155 :"=a" (res), "=&S" (d0) 155 : "=a" (res), "=&S" (d0)
156 :"1" (s), "0" (c) 156 : "1" (s), "0" (c)
157 :"memory"); 157 : "memory");
158 return res; 158 return res;
159} 159}
160EXPORT_SYMBOL(strchr); 160EXPORT_SYMBOL(strchr);
@@ -169,9 +169,9 @@ size_t strlen(const char *s)
169 "scasb\n\t" 169 "scasb\n\t"
170 "notl %0\n\t" 170 "notl %0\n\t"
171 "decl %0" 171 "decl %0"
172 :"=c" (res), "=&D" (d0) 172 : "=c" (res), "=&D" (d0)
173 :"1" (s), "a" (0), "0" (0xffffffffu) 173 : "1" (s), "a" (0), "0" (0xffffffffu)
174 :"memory"); 174 : "memory");
175 return res; 175 return res;
176} 176}
177EXPORT_SYMBOL(strlen); 177EXPORT_SYMBOL(strlen);
@@ -189,9 +189,9 @@ void *memchr(const void *cs, int c, size_t count)
189 "je 1f\n\t" 189 "je 1f\n\t"
190 "movl $1,%0\n" 190 "movl $1,%0\n"
191 "1:\tdecl %0" 191 "1:\tdecl %0"
192 :"=D" (res), "=&c" (d0) 192 : "=D" (res), "=&c" (d0)
193 :"a" (c), "0" (cs), "1" (count) 193 : "a" (c), "0" (cs), "1" (count)
194 :"memory"); 194 : "memory");
195 return res; 195 return res;
196} 196}
197EXPORT_SYMBOL(memchr); 197EXPORT_SYMBOL(memchr);
@@ -228,9 +228,9 @@ size_t strnlen(const char *s, size_t count)
228 "cmpl $-1,%1\n\t" 228 "cmpl $-1,%1\n\t"
229 "jne 1b\n" 229 "jne 1b\n"
230 "3:\tsubl %2,%0" 230 "3:\tsubl %2,%0"
231 :"=a" (res), "=&d" (d0) 231 : "=a" (res), "=&d" (d0)
232 :"c" (s), "1" (count) 232 : "c" (s), "1" (count)
233 :"memory"); 233 : "memory");
234 return res; 234 return res;
235} 235}
236EXPORT_SYMBOL(strnlen); 236EXPORT_SYMBOL(strnlen);
diff --git a/arch/x86/lib/strstr_32.c b/arch/x86/lib/strstr_32.c
index 42e8a50303f3..8e2d55f754bf 100644
--- a/arch/x86/lib/strstr_32.c
+++ b/arch/x86/lib/strstr_32.c
@@ -23,9 +23,9 @@ __asm__ __volatile__(
23 "jne 1b\n\t" 23 "jne 1b\n\t"
24 "xorl %%eax,%%eax\n\t" 24 "xorl %%eax,%%eax\n\t"
25 "2:" 25 "2:"
26 :"=a" (__res), "=&c" (d0), "=&S" (d1) 26 : "=a" (__res), "=&c" (d0), "=&S" (d1)
27 :"0" (0), "1" (0xffffffff), "2" (cs), "g" (ct) 27 : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct)
28 :"dx", "di"); 28 : "dx", "di");
29return __res; 29return __res;
30} 30}
31 31
diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
index 24e60944971a..9e68075544f6 100644
--- a/arch/x86/lib/usercopy_32.c
+++ b/arch/x86/lib/usercopy_32.c
@@ -14,6 +14,13 @@
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <asm/mmx.h> 15#include <asm/mmx.h>
16 16
17#ifdef CONFIG_X86_INTEL_USERCOPY
18/*
19 * Alignment at which movsl is preferred for bulk memory copies.
20 */
21struct movsl_mask movsl_mask __read_mostly;
22#endif
23
17static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned long n) 24static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned long n)
18{ 25{
19#ifdef CONFIG_X86_INTEL_USERCOPY 26#ifdef CONFIG_X86_INTEL_USERCOPY
diff --git a/arch/x86/mach-default/setup.c b/arch/x86/mach-default/setup.c
index 3d317836be9e..37b9ae4d44c5 100644
--- a/arch/x86/mach-default/setup.c
+++ b/arch/x86/mach-default/setup.c
@@ -10,13 +10,15 @@
10#include <asm/e820.h> 10#include <asm/e820.h>
11#include <asm/setup.h> 11#include <asm/setup.h>
12 12
13#include <mach_ipi.h>
14
13#ifdef CONFIG_HOTPLUG_CPU 15#ifdef CONFIG_HOTPLUG_CPU
14#define DEFAULT_SEND_IPI (1) 16#define DEFAULT_SEND_IPI (1)
15#else 17#else
16#define DEFAULT_SEND_IPI (0) 18#define DEFAULT_SEND_IPI (0)
17#endif 19#endif
18 20
19int no_broadcast=DEFAULT_SEND_IPI; 21int no_broadcast = DEFAULT_SEND_IPI;
20 22
21/** 23/**
22 * pre_intr_init_hook - initialisation prior to setting up interrupt vectors 24 * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
@@ -36,15 +38,6 @@ void __init pre_intr_init_hook(void)
36 init_ISA_irqs(); 38 init_ISA_irqs();
37} 39}
38 40
39/*
40 * IRQ2 is cascade interrupt to second interrupt controller
41 */
42static struct irqaction irq2 = {
43 .handler = no_action,
44 .mask = CPU_MASK_NONE,
45 .name = "cascade",
46};
47
48/** 41/**
49 * intr_init_hook - post gate setup interrupt initialisation 42 * intr_init_hook - post gate setup interrupt initialisation
50 * 43 *
@@ -60,12 +53,6 @@ void __init intr_init_hook(void)
60 if (x86_quirks->arch_intr_init()) 53 if (x86_quirks->arch_intr_init())
61 return; 54 return;
62 } 55 }
63#ifdef CONFIG_X86_LOCAL_APIC
64 apic_intr_init();
65#endif
66
67 if (!acpi_ioapic)
68 setup_irq(2, &irq2);
69} 56}
70 57
71/** 58/**
diff --git a/arch/x86/mach-es7000/Makefile b/arch/x86/mach-es7000/Makefile
deleted file mode 100644
index 3ef8b43b62fc..000000000000
--- a/arch/x86/mach-es7000/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the linux kernel.
3#
4
5obj-$(CONFIG_X86_ES7000) := es7000plat.o
diff --git a/arch/x86/mach-es7000/es7000.h b/arch/x86/mach-es7000/es7000.h
deleted file mode 100644
index c8d5aa132fa0..000000000000
--- a/arch/x86/mach-es7000/es7000.h
+++ /dev/null
@@ -1,114 +0,0 @@
1/*
2 * Written by: Garry Forsgren, Unisys Corporation
3 * Natalie Protasevich, Unisys Corporation
4 * This file contains the code to configure and interface
5 * with Unisys ES7000 series hardware system manager.
6 *
7 * Copyright (c) 2003 Unisys Corporation. All Rights Reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it would be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write the Free Software Foundation, Inc., 59
19 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 *
21 * Contact information: Unisys Corporation, Township Line & Union Meeting
22 * Roads-A, Unisys Way, Blue Bell, Pennsylvania, 19424, or:
23 *
24 * http://www.unisys.com
25 */
26
27/*
28 * ES7000 chipsets
29 */
30
31#define NON_UNISYS 0
32#define ES7000_CLASSIC 1
33#define ES7000_ZORRO 2
34
35
36#define MIP_REG 1
37#define MIP_PSAI_REG 4
38
39#define MIP_BUSY 1
40#define MIP_SPIN 0xf0000
41#define MIP_VALID 0x0100000000000000ULL
42#define MIP_PORT(VALUE) ((VALUE >> 32) & 0xffff)
43
44#define MIP_RD_LO(VALUE) (VALUE & 0xffffffff)
45
46struct mip_reg_info {
47 unsigned long long mip_info;
48 unsigned long long delivery_info;
49 unsigned long long host_reg;
50 unsigned long long mip_reg;
51};
52
53struct part_info {
54 unsigned char type;
55 unsigned char length;
56 unsigned char part_id;
57 unsigned char apic_mode;
58 unsigned long snum;
59 char ptype[16];
60 char sname[64];
61 char pname[64];
62};
63
64struct psai {
65 unsigned long long entry_type;
66 unsigned long long addr;
67 unsigned long long bep_addr;
68};
69
70struct es7000_mem_info {
71 unsigned char type;
72 unsigned char length;
73 unsigned char resv[6];
74 unsigned long long start;
75 unsigned long long size;
76};
77
78struct es7000_oem_table {
79 unsigned long long hdr;
80 struct mip_reg_info mip;
81 struct part_info pif;
82 struct es7000_mem_info shm;
83 struct psai psai;
84};
85
86#ifdef CONFIG_ACPI
87
88struct oem_table {
89 struct acpi_table_header Header;
90 u32 OEMTableAddr;
91 u32 OEMTableSize;
92};
93
94extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
95#endif
96
97struct mip_reg {
98 unsigned long long off_0;
99 unsigned long long off_8;
100 unsigned long long off_10;
101 unsigned long long off_18;
102 unsigned long long off_20;
103 unsigned long long off_28;
104 unsigned long long off_30;
105 unsigned long long off_38;
106};
107
108#define MIP_SW_APIC 0x1020b
109#define MIP_FUNC(VALUE) (VALUE & 0xff)
110
111extern int parse_unisys_oem (char *oemptr);
112extern void setup_unisys(void);
113extern int es7000_start_cpu(int cpu, unsigned long eip);
114extern void es7000_sw_apic(void);
diff --git a/arch/x86/mach-generic/Makefile b/arch/x86/mach-generic/Makefile
index 0dbd7803a1d5..6730f4e7c744 100644
--- a/arch/x86/mach-generic/Makefile
+++ b/arch/x86/mach-generic/Makefile
@@ -9,4 +9,3 @@ obj-$(CONFIG_X86_NUMAQ) += numaq.o
9obj-$(CONFIG_X86_SUMMIT) += summit.o 9obj-$(CONFIG_X86_SUMMIT) += summit.o
10obj-$(CONFIG_X86_BIGSMP) += bigsmp.o 10obj-$(CONFIG_X86_BIGSMP) += bigsmp.o
11obj-$(CONFIG_X86_ES7000) += es7000.o 11obj-$(CONFIG_X86_ES7000) += es7000.o
12obj-$(CONFIG_X86_ES7000) += ../../x86/mach-es7000/
diff --git a/arch/x86/mach-generic/bigsmp.c b/arch/x86/mach-generic/bigsmp.c
index 59d771714559..df37fc9d6a26 100644
--- a/arch/x86/mach-generic/bigsmp.c
+++ b/arch/x86/mach-generic/bigsmp.c
@@ -5,18 +5,17 @@
5#define APIC_DEFINITION 1 5#define APIC_DEFINITION 1
6#include <linux/threads.h> 6#include <linux/threads.h>
7#include <linux/cpumask.h> 7#include <linux/cpumask.h>
8#include <asm/smp.h>
9#include <asm/mpspec.h> 8#include <asm/mpspec.h>
10#include <asm/genapic.h> 9#include <asm/genapic.h>
11#include <asm/fixmap.h> 10#include <asm/fixmap.h>
12#include <asm/apicdef.h> 11#include <asm/apicdef.h>
13#include <linux/kernel.h> 12#include <linux/kernel.h>
14#include <linux/smp.h>
15#include <linux/init.h> 13#include <linux/init.h>
16#include <linux/dmi.h> 14#include <linux/dmi.h>
17#include <asm/mach-bigsmp/mach_apic.h> 15#include <asm/bigsmp/apicdef.h>
18#include <asm/mach-bigsmp/mach_apicdef.h> 16#include <linux/smp.h>
19#include <asm/mach-bigsmp/mach_ipi.h> 17#include <asm/bigsmp/apic.h>
18#include <asm/bigsmp/ipi.h>
20#include <asm/mach-default/mach_mpparse.h> 19#include <asm/mach-default/mach_mpparse.h>
21 20
22static int dmi_bigsmp; /* can be set by dmi scanners */ 21static int dmi_bigsmp; /* can be set by dmi scanners */
diff --git a/arch/x86/mach-generic/es7000.c b/arch/x86/mach-generic/es7000.c
index 4742626f08c4..520cca0ee04e 100644
--- a/arch/x86/mach-generic/es7000.c
+++ b/arch/x86/mach-generic/es7000.c
@@ -4,20 +4,19 @@
4#define APIC_DEFINITION 1 4#define APIC_DEFINITION 1
5#include <linux/threads.h> 5#include <linux/threads.h>
6#include <linux/cpumask.h> 6#include <linux/cpumask.h>
7#include <asm/smp.h>
8#include <asm/mpspec.h> 7#include <asm/mpspec.h>
9#include <asm/genapic.h> 8#include <asm/genapic.h>
10#include <asm/fixmap.h> 9#include <asm/fixmap.h>
11#include <asm/apicdef.h> 10#include <asm/apicdef.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/string.h> 12#include <linux/string.h>
14#include <linux/smp.h>
15#include <linux/init.h> 13#include <linux/init.h>
16#include <asm/mach-es7000/mach_apicdef.h> 14#include <asm/es7000/apicdef.h>
17#include <asm/mach-es7000/mach_apic.h> 15#include <linux/smp.h>
18#include <asm/mach-es7000/mach_ipi.h> 16#include <asm/es7000/apic.h>
19#include <asm/mach-es7000/mach_mpparse.h> 17#include <asm/es7000/ipi.h>
20#include <asm/mach-es7000/mach_wakecpu.h> 18#include <asm/es7000/mpparse.h>
19#include <asm/es7000/wakecpu.h>
21 20
22static int probe_es7000(void) 21static int probe_es7000(void)
23{ 22{
diff --git a/arch/x86/mach-generic/numaq.c b/arch/x86/mach-generic/numaq.c
index 8091e68764c4..8cf58394975e 100644
--- a/arch/x86/mach-generic/numaq.c
+++ b/arch/x86/mach-generic/numaq.c
@@ -4,7 +4,6 @@
4#define APIC_DEFINITION 1 4#define APIC_DEFINITION 1
5#include <linux/threads.h> 5#include <linux/threads.h>
6#include <linux/cpumask.h> 6#include <linux/cpumask.h>
7#include <linux/smp.h>
8#include <asm/mpspec.h> 7#include <asm/mpspec.h>
9#include <asm/genapic.h> 8#include <asm/genapic.h>
10#include <asm/fixmap.h> 9#include <asm/fixmap.h>
@@ -12,11 +11,12 @@
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/string.h> 12#include <linux/string.h>
14#include <linux/init.h> 13#include <linux/init.h>
15#include <asm/mach-numaq/mach_apic.h> 14#include <asm/numaq/apicdef.h>
16#include <asm/mach-numaq/mach_apicdef.h> 15#include <linux/smp.h>
17#include <asm/mach-numaq/mach_ipi.h> 16#include <asm/numaq/apic.h>
18#include <asm/mach-numaq/mach_mpparse.h> 17#include <asm/numaq/ipi.h>
19#include <asm/mach-numaq/mach_wakecpu.h> 18#include <asm/numaq/mpparse.h>
19#include <asm/numaq/wakecpu.h>
20#include <asm/numaq.h> 20#include <asm/numaq.h>
21 21
22static int mps_oem_check(struct mp_config_table *mpc, char *oem, 22static int mps_oem_check(struct mp_config_table *mpc, char *oem,
diff --git a/arch/x86/mach-generic/summit.c b/arch/x86/mach-generic/summit.c
index a97ea0f35b1e..6ad6b67a723d 100644
--- a/arch/x86/mach-generic/summit.c
+++ b/arch/x86/mach-generic/summit.c
@@ -4,19 +4,18 @@
4#define APIC_DEFINITION 1 4#define APIC_DEFINITION 1
5#include <linux/threads.h> 5#include <linux/threads.h>
6#include <linux/cpumask.h> 6#include <linux/cpumask.h>
7#include <asm/smp.h>
8#include <asm/mpspec.h> 7#include <asm/mpspec.h>
9#include <asm/genapic.h> 8#include <asm/genapic.h>
10#include <asm/fixmap.h> 9#include <asm/fixmap.h>
11#include <asm/apicdef.h> 10#include <asm/apicdef.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/string.h> 12#include <linux/string.h>
14#include <linux/smp.h>
15#include <linux/init.h> 13#include <linux/init.h>
16#include <asm/mach-summit/mach_apic.h> 14#include <asm/summit/apicdef.h>
17#include <asm/mach-summit/mach_apicdef.h> 15#include <linux/smp.h>
18#include <asm/mach-summit/mach_ipi.h> 16#include <asm/summit/apic.h>
19#include <asm/mach-summit/mach_mpparse.h> 17#include <asm/summit/ipi.h>
18#include <asm/summit/mpparse.h>
20 19
21static int probe_summit(void) 20static int probe_summit(void)
22{ 21{
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c
index ee0fba092157..199a5f4a873c 100644
--- a/arch/x86/mach-voyager/voyager_smp.c
+++ b/arch/x86/mach-voyager/voyager_smp.c
@@ -448,6 +448,8 @@ static void __init start_secondary(void *unused)
448 448
449 VDEBUG(("VOYAGER SMP: CPU%d, stack at about %p\n", cpuid, &cpuid)); 449 VDEBUG(("VOYAGER SMP: CPU%d, stack at about %p\n", cpuid, &cpuid));
450 450
451 notify_cpu_starting(cpuid);
452
451 /* enable interrupts */ 453 /* enable interrupts */
452 local_irq_enable(); 454 local_irq_enable();
453 455
diff --git a/arch/x86/mm/discontig_32.c b/arch/x86/mm/discontig_32.c
index 62fa440678d8..847c164725f4 100644
--- a/arch/x86/mm/discontig_32.c
+++ b/arch/x86/mm/discontig_32.c
@@ -328,7 +328,7 @@ void __init initmem_init(unsigned long start_pfn,
328 328
329 get_memcfg_numa(); 329 get_memcfg_numa();
330 330
331 kva_pages = round_up(calculate_numa_remap_pages(), PTRS_PER_PTE); 331 kva_pages = roundup(calculate_numa_remap_pages(), PTRS_PER_PTE);
332 332
333 kva_target_pfn = round_down(max_low_pfn - kva_pages, PTRS_PER_PTE); 333 kva_target_pfn = round_down(max_low_pfn - kva_pages, PTRS_PER_PTE);
334 do { 334 do {
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index a20d1fa64b4e..e7277cbcfb40 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -148,8 +148,8 @@ static void note_page(struct seq_file *m, struct pg_state *st,
148 * we have now. "break" is either changing perms, levels or 148 * we have now. "break" is either changing perms, levels or
149 * address space marker. 149 * address space marker.
150 */ 150 */
151 prot = pgprot_val(new_prot) & ~(PTE_PFN_MASK); 151 prot = pgprot_val(new_prot) & PTE_FLAGS_MASK;
152 cur = pgprot_val(st->current_prot) & ~(PTE_PFN_MASK); 152 cur = pgprot_val(st->current_prot) & PTE_FLAGS_MASK;
153 153
154 if (!st->level) { 154 if (!st->level) {
155 /* First entry */ 155 /* First entry */
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 455f3fe67b42..a742d753d5b0 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -35,6 +35,7 @@
35#include <asm/tlbflush.h> 35#include <asm/tlbflush.h>
36#include <asm/proto.h> 36#include <asm/proto.h>
37#include <asm-generic/sections.h> 37#include <asm-generic/sections.h>
38#include <asm/traps.h>
38 39
39/* 40/*
40 * Page fault error code bits 41 * Page fault error code bits
@@ -357,8 +358,6 @@ static int is_errata100(struct pt_regs *regs, unsigned long address)
357 return 0; 358 return 0;
358} 359}
359 360
360void do_invalid_op(struct pt_regs *, unsigned long);
361
362static int is_f00f_bug(struct pt_regs *regs, unsigned long address) 361static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
363{ 362{
364#ifdef CONFIG_X86_F00F_BUG 363#ifdef CONFIG_X86_F00F_BUG
@@ -915,15 +914,15 @@ LIST_HEAD(pgd_list);
915 914
916void vmalloc_sync_all(void) 915void vmalloc_sync_all(void)
917{ 916{
918#ifdef CONFIG_X86_32
919 unsigned long start = VMALLOC_START & PGDIR_MASK;
920 unsigned long address; 917 unsigned long address;
921 918
919#ifdef CONFIG_X86_32
922 if (SHARED_KERNEL_PMD) 920 if (SHARED_KERNEL_PMD)
923 return; 921 return;
924 922
925 BUILD_BUG_ON(TASK_SIZE & ~PGDIR_MASK); 923 for (address = VMALLOC_START & PMD_MASK;
926 for (address = start; address >= TASK_SIZE; address += PGDIR_SIZE) { 924 address >= TASK_SIZE && address < FIXADDR_TOP;
925 address += PMD_SIZE) {
927 unsigned long flags; 926 unsigned long flags;
928 struct page *page; 927 struct page *page;
929 928
@@ -936,10 +935,8 @@ void vmalloc_sync_all(void)
936 spin_unlock_irqrestore(&pgd_lock, flags); 935 spin_unlock_irqrestore(&pgd_lock, flags);
937 } 936 }
938#else /* CONFIG_X86_64 */ 937#else /* CONFIG_X86_64 */
939 unsigned long start = VMALLOC_START & PGDIR_MASK; 938 for (address = VMALLOC_START & PGDIR_MASK; address <= VMALLOC_END;
940 unsigned long address; 939 address += PGDIR_SIZE) {
941
942 for (address = start; address <= VMALLOC_END; address += PGDIR_SIZE) {
943 const pgd_t *pgd_ref = pgd_offset_k(address); 940 const pgd_t *pgd_ref = pgd_offset_k(address);
944 unsigned long flags; 941 unsigned long flags;
945 struct page *page; 942 struct page *page;
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 60ec1d08ff24..bbe044dbe014 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -31,6 +31,7 @@
31#include <linux/cpumask.h> 31#include <linux/cpumask.h>
32 32
33#include <asm/asm.h> 33#include <asm/asm.h>
34#include <asm/bios_ebda.h>
34#include <asm/processor.h> 35#include <asm/processor.h>
35#include <asm/system.h> 36#include <asm/system.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
@@ -47,6 +48,7 @@
47#include <asm/paravirt.h> 48#include <asm/paravirt.h>
48#include <asm/setup.h> 49#include <asm/setup.h>
49#include <asm/cacheflush.h> 50#include <asm/cacheflush.h>
51#include <asm/smp.h>
50 52
51unsigned int __VMALLOC_RESERVE = 128 << 20; 53unsigned int __VMALLOC_RESERVE = 128 << 20;
52 54
@@ -194,11 +196,30 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base,
194 pgd_t *pgd; 196 pgd_t *pgd;
195 pmd_t *pmd; 197 pmd_t *pmd;
196 pte_t *pte; 198 pte_t *pte;
197 unsigned pages_2m = 0, pages_4k = 0; 199 unsigned pages_2m, pages_4k;
200 int mapping_iter;
201
202 /*
203 * First iteration will setup identity mapping using large/small pages
204 * based on use_pse, with other attributes same as set by
205 * the early code in head_32.S
206 *
207 * Second iteration will setup the appropriate attributes (NX, GLOBAL..)
208 * as desired for the kernel identity mapping.
209 *
210 * This two pass mechanism conforms to the TLB app note which says:
211 *
212 * "Software should not write to a paging-structure entry in a way
213 * that would change, for any linear address, both the page size
214 * and either the page frame or attributes."
215 */
216 mapping_iter = 1;
198 217
199 if (!cpu_has_pse) 218 if (!cpu_has_pse)
200 use_pse = 0; 219 use_pse = 0;
201 220
221repeat:
222 pages_2m = pages_4k = 0;
202 pfn = start_pfn; 223 pfn = start_pfn;
203 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET); 224 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
204 pgd = pgd_base + pgd_idx; 225 pgd = pgd_base + pgd_idx;
@@ -224,6 +245,13 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base,
224 if (use_pse) { 245 if (use_pse) {
225 unsigned int addr2; 246 unsigned int addr2;
226 pgprot_t prot = PAGE_KERNEL_LARGE; 247 pgprot_t prot = PAGE_KERNEL_LARGE;
248 /*
249 * first pass will use the same initial
250 * identity mapping attribute + _PAGE_PSE.
251 */
252 pgprot_t init_prot =
253 __pgprot(PTE_IDENT_ATTR |
254 _PAGE_PSE);
227 255
228 addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE + 256 addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
229 PAGE_OFFSET + PAGE_SIZE-1; 257 PAGE_OFFSET + PAGE_SIZE-1;
@@ -233,7 +261,10 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base,
233 prot = PAGE_KERNEL_LARGE_EXEC; 261 prot = PAGE_KERNEL_LARGE_EXEC;
234 262
235 pages_2m++; 263 pages_2m++;
236 set_pmd(pmd, pfn_pmd(pfn, prot)); 264 if (mapping_iter == 1)
265 set_pmd(pmd, pfn_pmd(pfn, init_prot));
266 else
267 set_pmd(pmd, pfn_pmd(pfn, prot));
237 268
238 pfn += PTRS_PER_PTE; 269 pfn += PTRS_PER_PTE;
239 continue; 270 continue;
@@ -245,17 +276,43 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base,
245 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn; 276 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
246 pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) { 277 pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
247 pgprot_t prot = PAGE_KERNEL; 278 pgprot_t prot = PAGE_KERNEL;
279 /*
280 * first pass will use the same initial
281 * identity mapping attribute.
282 */
283 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
248 284
249 if (is_kernel_text(addr)) 285 if (is_kernel_text(addr))
250 prot = PAGE_KERNEL_EXEC; 286 prot = PAGE_KERNEL_EXEC;
251 287
252 pages_4k++; 288 pages_4k++;
253 set_pte(pte, pfn_pte(pfn, prot)); 289 if (mapping_iter == 1)
290 set_pte(pte, pfn_pte(pfn, init_prot));
291 else
292 set_pte(pte, pfn_pte(pfn, prot));
254 } 293 }
255 } 294 }
256 } 295 }
257 update_page_count(PG_LEVEL_2M, pages_2m); 296 if (mapping_iter == 1) {
258 update_page_count(PG_LEVEL_4K, pages_4k); 297 /*
298 * update direct mapping page count only in the first
299 * iteration.
300 */
301 update_page_count(PG_LEVEL_2M, pages_2m);
302 update_page_count(PG_LEVEL_4K, pages_4k);
303
304 /*
305 * local global flush tlb, which will flush the previous
306 * mappings present in both small and large page TLB's.
307 */
308 __flush_tlb_all();
309
310 /*
311 * Second iteration will set the actual desired PTE attributes.
312 */
313 mapping_iter = 2;
314 goto repeat;
315 }
259} 316}
260 317
261/* 318/*
@@ -718,7 +775,7 @@ void __init setup_bootmem_allocator(void)
718 after_init_bootmem = 1; 775 after_init_bootmem = 1;
719} 776}
720 777
721static void __init find_early_table_space(unsigned long end) 778static void __init find_early_table_space(unsigned long end, int use_pse)
722{ 779{
723 unsigned long puds, pmds, ptes, tables, start; 780 unsigned long puds, pmds, ptes, tables, start;
724 781
@@ -728,7 +785,7 @@ static void __init find_early_table_space(unsigned long end)
728 pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT; 785 pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
729 tables += PAGE_ALIGN(pmds * sizeof(pmd_t)); 786 tables += PAGE_ALIGN(pmds * sizeof(pmd_t));
730 787
731 if (cpu_has_pse) { 788 if (use_pse) {
732 unsigned long extra; 789 unsigned long extra;
733 790
734 extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT); 791 extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT);
@@ -768,12 +825,22 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
768 pgd_t *pgd_base = swapper_pg_dir; 825 pgd_t *pgd_base = swapper_pg_dir;
769 unsigned long start_pfn, end_pfn; 826 unsigned long start_pfn, end_pfn;
770 unsigned long big_page_start; 827 unsigned long big_page_start;
828#ifdef CONFIG_DEBUG_PAGEALLOC
829 /*
830 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
831 * This will simplify cpa(), which otherwise needs to support splitting
832 * large pages into small in interrupt context, etc.
833 */
834 int use_pse = 0;
835#else
836 int use_pse = cpu_has_pse;
837#endif
771 838
772 /* 839 /*
773 * Find space for the kernel direct mapping tables. 840 * Find space for the kernel direct mapping tables.
774 */ 841 */
775 if (!after_init_bootmem) 842 if (!after_init_bootmem)
776 find_early_table_space(end); 843 find_early_table_space(end, use_pse);
777 844
778#ifdef CONFIG_X86_PAE 845#ifdef CONFIG_X86_PAE
779 set_nx(); 846 set_nx();
@@ -819,7 +886,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
819 end_pfn = (end>>PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT); 886 end_pfn = (end>>PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT);
820 if (start_pfn < end_pfn) 887 if (start_pfn < end_pfn)
821 kernel_physical_mapping_init(pgd_base, start_pfn, end_pfn, 888 kernel_physical_mapping_init(pgd_base, start_pfn, end_pfn,
822 cpu_has_pse); 889 use_pse);
823 890
824 /* tail is not big page alignment ? */ 891 /* tail is not big page alignment ? */
825 start_pfn = end_pfn; 892 start_pfn = end_pfn;
@@ -903,6 +970,8 @@ void __init mem_init(void)
903 int codesize, reservedpages, datasize, initsize; 970 int codesize, reservedpages, datasize, initsize;
904 int tmp; 971 int tmp;
905 972
973 start_periodic_check_for_corruption();
974
906#ifdef CONFIG_FLATMEM 975#ifdef CONFIG_FLATMEM
907 BUG_ON(!mem_map); 976 BUG_ON(!mem_map);
908#endif 977#endif
@@ -982,7 +1051,6 @@ void __init mem_init(void)
982 if (boot_cpu_data.wp_works_ok < 0) 1051 if (boot_cpu_data.wp_works_ok < 0)
983 test_wp_bit(); 1052 test_wp_bit();
984 1053
985 cpa_init();
986 save_pg_dir(); 1054 save_pg_dir();
987 zap_low_mappings(); 1055 zap_low_mappings();
988} 1056}
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index d3746efb060d..3e10054c5731 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -31,6 +31,7 @@
31#include <linux/nmi.h> 31#include <linux/nmi.h>
32 32
33#include <asm/processor.h> 33#include <asm/processor.h>
34#include <asm/bios_ebda.h>
34#include <asm/system.h> 35#include <asm/system.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36#include <asm/pgtable.h> 37#include <asm/pgtable.h>
@@ -88,6 +89,62 @@ early_param("gbpages", parse_direct_gbpages_on);
88 89
89int after_bootmem; 90int after_bootmem;
90 91
92unsigned long __supported_pte_mask __read_mostly = ~0UL;
93EXPORT_SYMBOL_GPL(__supported_pte_mask);
94
95static int do_not_nx __cpuinitdata;
96
97/*
98 * noexec=on|off
99 * Control non-executable mappings for 64-bit processes.
100 *
101 * on Enable (default)
102 * off Disable
103 */
104static int __init nonx_setup(char *str)
105{
106 if (!str)
107 return -EINVAL;
108 if (!strncmp(str, "on", 2)) {
109 __supported_pte_mask |= _PAGE_NX;
110 do_not_nx = 0;
111 } else if (!strncmp(str, "off", 3)) {
112 do_not_nx = 1;
113 __supported_pte_mask &= ~_PAGE_NX;
114 }
115 return 0;
116}
117early_param("noexec", nonx_setup);
118
119void __cpuinit check_efer(void)
120{
121 unsigned long efer;
122
123 rdmsrl(MSR_EFER, efer);
124 if (!(efer & EFER_NX) || do_not_nx)
125 __supported_pte_mask &= ~_PAGE_NX;
126}
127
128int force_personality32;
129
130/*
131 * noexec32=on|off
132 * Control non executable heap for 32bit processes.
133 * To control the stack too use noexec=off
134 *
135 * on PROT_READ does not imply PROT_EXEC for 32-bit processes (default)
136 * off PROT_READ implies PROT_EXEC
137 */
138static int __init nonx32_setup(char *str)
139{
140 if (!strcmp(str, "on"))
141 force_personality32 &= ~READ_IMPLIES_EXEC;
142 else if (!strcmp(str, "off"))
143 force_personality32 |= READ_IMPLIES_EXEC;
144 return 1;
145}
146__setup("noexec32=", nonx32_setup);
147
91/* 148/*
92 * NOTE: This function is marked __ref because it calls __init function 149 * NOTE: This function is marked __ref because it calls __init function
93 * (alloc_bootmem_pages). It's safe to do it ONLY when after_bootmem == 0. 150 * (alloc_bootmem_pages). It's safe to do it ONLY when after_bootmem == 0.
@@ -225,7 +282,7 @@ void __init init_extra_mapping_uc(unsigned long phys, unsigned long size)
225void __init cleanup_highmap(void) 282void __init cleanup_highmap(void)
226{ 283{
227 unsigned long vaddr = __START_KERNEL_map; 284 unsigned long vaddr = __START_KERNEL_map;
228 unsigned long end = round_up((unsigned long)_end, PMD_SIZE) - 1; 285 unsigned long end = roundup((unsigned long)_end, PMD_SIZE) - 1;
229 pmd_t *pmd = level2_kernel_pgt; 286 pmd_t *pmd = level2_kernel_pgt;
230 pmd_t *last_pmd = pmd + PTRS_PER_PMD; 287 pmd_t *last_pmd = pmd + PTRS_PER_PMD;
231 288
@@ -271,7 +328,8 @@ static __ref void unmap_low_page(void *adr)
271} 328}
272 329
273static unsigned long __meminit 330static unsigned long __meminit
274phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end) 331phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end,
332 pgprot_t prot)
275{ 333{
276 unsigned pages = 0; 334 unsigned pages = 0;
277 unsigned long last_map_addr = end; 335 unsigned long last_map_addr = end;
@@ -289,36 +347,43 @@ phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end)
289 break; 347 break;
290 } 348 }
291 349
350 /*
351 * We will re-use the existing mapping.
352 * Xen for example has some special requirements, like mapping
353 * pagetable pages as RO. So assume someone who pre-setup
354 * these mappings are more intelligent.
355 */
292 if (pte_val(*pte)) 356 if (pte_val(*pte))
293 continue; 357 continue;
294 358
295 if (0) 359 if (0)
296 printk(" pte=%p addr=%lx pte=%016lx\n", 360 printk(" pte=%p addr=%lx pte=%016lx\n",
297 pte, addr, pfn_pte(addr >> PAGE_SHIFT, PAGE_KERNEL).pte); 361 pte, addr, pfn_pte(addr >> PAGE_SHIFT, PAGE_KERNEL).pte);
298 set_pte(pte, pfn_pte(addr >> PAGE_SHIFT, PAGE_KERNEL));
299 last_map_addr = (addr & PAGE_MASK) + PAGE_SIZE;
300 pages++; 362 pages++;
363 set_pte(pte, pfn_pte(addr >> PAGE_SHIFT, prot));
364 last_map_addr = (addr & PAGE_MASK) + PAGE_SIZE;
301 } 365 }
366
302 update_page_count(PG_LEVEL_4K, pages); 367 update_page_count(PG_LEVEL_4K, pages);
303 368
304 return last_map_addr; 369 return last_map_addr;
305} 370}
306 371
307static unsigned long __meminit 372static unsigned long __meminit
308phys_pte_update(pmd_t *pmd, unsigned long address, unsigned long end) 373phys_pte_update(pmd_t *pmd, unsigned long address, unsigned long end,
374 pgprot_t prot)
309{ 375{
310 pte_t *pte = (pte_t *)pmd_page_vaddr(*pmd); 376 pte_t *pte = (pte_t *)pmd_page_vaddr(*pmd);
311 377
312 return phys_pte_init(pte, address, end); 378 return phys_pte_init(pte, address, end, prot);
313} 379}
314 380
315static unsigned long __meminit 381static unsigned long __meminit
316phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end, 382phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
317 unsigned long page_size_mask) 383 unsigned long page_size_mask, pgprot_t prot)
318{ 384{
319 unsigned long pages = 0; 385 unsigned long pages = 0;
320 unsigned long last_map_addr = end; 386 unsigned long last_map_addr = end;
321 unsigned long start = address;
322 387
323 int i = pmd_index(address); 388 int i = pmd_index(address);
324 389
@@ -326,6 +391,7 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
326 unsigned long pte_phys; 391 unsigned long pte_phys;
327 pmd_t *pmd = pmd_page + pmd_index(address); 392 pmd_t *pmd = pmd_page + pmd_index(address);
328 pte_t *pte; 393 pte_t *pte;
394 pgprot_t new_prot = prot;
329 395
330 if (address >= end) { 396 if (address >= end) {
331 if (!after_bootmem) { 397 if (!after_bootmem) {
@@ -339,27 +405,40 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
339 if (!pmd_large(*pmd)) { 405 if (!pmd_large(*pmd)) {
340 spin_lock(&init_mm.page_table_lock); 406 spin_lock(&init_mm.page_table_lock);
341 last_map_addr = phys_pte_update(pmd, address, 407 last_map_addr = phys_pte_update(pmd, address,
342 end); 408 end, prot);
343 spin_unlock(&init_mm.page_table_lock); 409 spin_unlock(&init_mm.page_table_lock);
410 continue;
344 } 411 }
345 /* Count entries we're using from level2_ident_pgt */ 412 /*
346 if (start == 0) 413 * If we are ok with PG_LEVEL_2M mapping, then we will
347 pages++; 414 * use the existing mapping,
348 continue; 415 *
416 * Otherwise, we will split the large page mapping but
417 * use the same existing protection bits except for
418 * large page, so that we don't violate Intel's TLB
419 * Application note (317080) which says, while changing
420 * the page sizes, new and old translations should
421 * not differ with respect to page frame and
422 * attributes.
423 */
424 if (page_size_mask & (1 << PG_LEVEL_2M))
425 continue;
426 new_prot = pte_pgprot(pte_clrhuge(*(pte_t *)pmd));
349 } 427 }
350 428
351 if (page_size_mask & (1<<PG_LEVEL_2M)) { 429 if (page_size_mask & (1<<PG_LEVEL_2M)) {
352 pages++; 430 pages++;
353 spin_lock(&init_mm.page_table_lock); 431 spin_lock(&init_mm.page_table_lock);
354 set_pte((pte_t *)pmd, 432 set_pte((pte_t *)pmd,
355 pfn_pte(address >> PAGE_SHIFT, PAGE_KERNEL_LARGE)); 433 pfn_pte(address >> PAGE_SHIFT,
434 __pgprot(pgprot_val(prot) | _PAGE_PSE)));
356 spin_unlock(&init_mm.page_table_lock); 435 spin_unlock(&init_mm.page_table_lock);
357 last_map_addr = (address & PMD_MASK) + PMD_SIZE; 436 last_map_addr = (address & PMD_MASK) + PMD_SIZE;
358 continue; 437 continue;
359 } 438 }
360 439
361 pte = alloc_low_page(&pte_phys); 440 pte = alloc_low_page(&pte_phys);
362 last_map_addr = phys_pte_init(pte, address, end); 441 last_map_addr = phys_pte_init(pte, address, end, new_prot);
363 unmap_low_page(pte); 442 unmap_low_page(pte);
364 443
365 spin_lock(&init_mm.page_table_lock); 444 spin_lock(&init_mm.page_table_lock);
@@ -372,12 +451,12 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
372 451
373static unsigned long __meminit 452static unsigned long __meminit
374phys_pmd_update(pud_t *pud, unsigned long address, unsigned long end, 453phys_pmd_update(pud_t *pud, unsigned long address, unsigned long end,
375 unsigned long page_size_mask) 454 unsigned long page_size_mask, pgprot_t prot)
376{ 455{
377 pmd_t *pmd = pmd_offset(pud, 0); 456 pmd_t *pmd = pmd_offset(pud, 0);
378 unsigned long last_map_addr; 457 unsigned long last_map_addr;
379 458
380 last_map_addr = phys_pmd_init(pmd, address, end, page_size_mask); 459 last_map_addr = phys_pmd_init(pmd, address, end, page_size_mask, prot);
381 __flush_tlb_all(); 460 __flush_tlb_all();
382 return last_map_addr; 461 return last_map_addr;
383} 462}
@@ -394,6 +473,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
394 unsigned long pmd_phys; 473 unsigned long pmd_phys;
395 pud_t *pud = pud_page + pud_index(addr); 474 pud_t *pud = pud_page + pud_index(addr);
396 pmd_t *pmd; 475 pmd_t *pmd;
476 pgprot_t prot = PAGE_KERNEL;
397 477
398 if (addr >= end) 478 if (addr >= end)
399 break; 479 break;
@@ -405,10 +485,26 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
405 } 485 }
406 486
407 if (pud_val(*pud)) { 487 if (pud_val(*pud)) {
408 if (!pud_large(*pud)) 488 if (!pud_large(*pud)) {
409 last_map_addr = phys_pmd_update(pud, addr, end, 489 last_map_addr = phys_pmd_update(pud, addr, end,
410 page_size_mask); 490 page_size_mask, prot);
411 continue; 491 continue;
492 }
493 /*
494 * If we are ok with PG_LEVEL_1G mapping, then we will
495 * use the existing mapping.
496 *
497 * Otherwise, we will split the gbpage mapping but use
498 * the same existing protection bits except for large
499 * page, so that we don't violate Intel's TLB
500 * Application note (317080) which says, while changing
501 * the page sizes, new and old translations should
502 * not differ with respect to page frame and
503 * attributes.
504 */
505 if (page_size_mask & (1 << PG_LEVEL_1G))
506 continue;
507 prot = pte_pgprot(pte_clrhuge(*(pte_t *)pud));
412 } 508 }
413 509
414 if (page_size_mask & (1<<PG_LEVEL_1G)) { 510 if (page_size_mask & (1<<PG_LEVEL_1G)) {
@@ -422,7 +518,8 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
422 } 518 }
423 519
424 pmd = alloc_low_page(&pmd_phys); 520 pmd = alloc_low_page(&pmd_phys);
425 last_map_addr = phys_pmd_init(pmd, addr, end, page_size_mask); 521 last_map_addr = phys_pmd_init(pmd, addr, end, page_size_mask,
522 prot);
426 unmap_low_page(pmd); 523 unmap_low_page(pmd);
427 524
428 spin_lock(&init_mm.page_table_lock); 525 spin_lock(&init_mm.page_table_lock);
@@ -430,6 +527,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
430 spin_unlock(&init_mm.page_table_lock); 527 spin_unlock(&init_mm.page_table_lock);
431 } 528 }
432 __flush_tlb_all(); 529 __flush_tlb_all();
530
433 update_page_count(PG_LEVEL_1G, pages); 531 update_page_count(PG_LEVEL_1G, pages);
434 532
435 return last_map_addr; 533 return last_map_addr;
@@ -446,27 +544,28 @@ phys_pud_update(pgd_t *pgd, unsigned long addr, unsigned long end,
446 return phys_pud_init(pud, addr, end, page_size_mask); 544 return phys_pud_init(pud, addr, end, page_size_mask);
447} 545}
448 546
449static void __init find_early_table_space(unsigned long end) 547static void __init find_early_table_space(unsigned long end, int use_pse,
548 int use_gbpages)
450{ 549{
451 unsigned long puds, pmds, ptes, tables, start; 550 unsigned long puds, pmds, ptes, tables, start;
452 551
453 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT; 552 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
454 tables = round_up(puds * sizeof(pud_t), PAGE_SIZE); 553 tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
455 if (direct_gbpages) { 554 if (use_gbpages) {
456 unsigned long extra; 555 unsigned long extra;
457 extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT); 556 extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT);
458 pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT; 557 pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT;
459 } else 558 } else
460 pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT; 559 pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
461 tables += round_up(pmds * sizeof(pmd_t), PAGE_SIZE); 560 tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
462 561
463 if (cpu_has_pse) { 562 if (use_pse) {
464 unsigned long extra; 563 unsigned long extra;
465 extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT); 564 extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT);
466 ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT; 565 ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
467 } else 566 } else
468 ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT; 567 ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
469 tables += round_up(ptes * sizeof(pte_t), PAGE_SIZE); 568 tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
470 569
471 /* 570 /*
472 * RED-PEN putting page tables only on node 0 could 571 * RED-PEN putting page tables only on node 0 could
@@ -528,6 +627,7 @@ static unsigned long __init kernel_physical_mapping_init(unsigned long start,
528 pgd_populate(&init_mm, pgd, __va(pud_phys)); 627 pgd_populate(&init_mm, pgd, __va(pud_phys));
529 spin_unlock(&init_mm.page_table_lock); 628 spin_unlock(&init_mm.page_table_lock);
530 } 629 }
630 __flush_tlb_all();
531 631
532 return last_map_addr; 632 return last_map_addr;
533} 633}
@@ -571,6 +671,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
571 671
572 struct map_range mr[NR_RANGE_MR]; 672 struct map_range mr[NR_RANGE_MR];
573 int nr_range, i; 673 int nr_range, i;
674 int use_pse, use_gbpages;
574 675
575 printk(KERN_INFO "init_memory_mapping\n"); 676 printk(KERN_INFO "init_memory_mapping\n");
576 677
@@ -584,9 +685,21 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
584 if (!after_bootmem) 685 if (!after_bootmem)
585 init_gbpages(); 686 init_gbpages();
586 687
587 if (direct_gbpages) 688#ifdef CONFIG_DEBUG_PAGEALLOC
689 /*
690 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
691 * This will simplify cpa(), which otherwise needs to support splitting
692 * large pages into small in interrupt context, etc.
693 */
694 use_pse = use_gbpages = 0;
695#else
696 use_pse = cpu_has_pse;
697 use_gbpages = direct_gbpages;
698#endif
699
700 if (use_gbpages)
588 page_size_mask |= 1 << PG_LEVEL_1G; 701 page_size_mask |= 1 << PG_LEVEL_1G;
589 if (cpu_has_pse) 702 if (use_pse)
590 page_size_mask |= 1 << PG_LEVEL_2M; 703 page_size_mask |= 1 << PG_LEVEL_2M;
591 704
592 memset(mr, 0, sizeof(mr)); 705 memset(mr, 0, sizeof(mr));
@@ -647,7 +760,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
647 (mr[i].page_size_mask & (1<<PG_LEVEL_2M))?"2M":"4k")); 760 (mr[i].page_size_mask & (1<<PG_LEVEL_2M))?"2M":"4k"));
648 761
649 if (!after_bootmem) 762 if (!after_bootmem)
650 find_early_table_space(end); 763 find_early_table_space(end, use_pse, use_gbpages);
651 764
652 for (i = 0; i < nr_range; i++) 765 for (i = 0; i < nr_range; i++)
653 last_map_addr = kernel_physical_mapping_init( 766 last_map_addr = kernel_physical_mapping_init(
@@ -769,6 +882,8 @@ void __init mem_init(void)
769{ 882{
770 long codesize, reservedpages, datasize, initsize; 883 long codesize, reservedpages, datasize, initsize;
771 884
885 start_periodic_check_for_corruption();
886
772 pci_iommu_alloc(); 887 pci_iommu_alloc();
773 888
774 /* clear_bss() already clear the empty_zero_page */ 889 /* clear_bss() already clear the empty_zero_page */
@@ -806,8 +921,6 @@ void __init mem_init(void)
806 reservedpages << (PAGE_SHIFT-10), 921 reservedpages << (PAGE_SHIFT-10),
807 datasize >> 10, 922 datasize >> 10,
808 initsize >> 10); 923 initsize >> 10);
809
810 cpa_init();
811} 924}
812 925
813void free_init_pages(char *what, unsigned long begin, unsigned long end) 926void free_init_pages(char *what, unsigned long begin, unsigned long end)
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index d4b6e6a29ae3..8cbeda15cd29 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -24,18 +24,26 @@
24 24
25#ifdef CONFIG_X86_64 25#ifdef CONFIG_X86_64
26 26
27unsigned long __phys_addr(unsigned long x) 27static inline int phys_addr_valid(unsigned long addr)
28{ 28{
29 if (x >= __START_KERNEL_map) 29 return addr < (1UL << boot_cpu_data.x86_phys_bits);
30 return x - __START_KERNEL_map + phys_base;
31 return x - PAGE_OFFSET;
32} 30}
33EXPORT_SYMBOL(__phys_addr);
34 31
35static inline int phys_addr_valid(unsigned long addr) 32unsigned long __phys_addr(unsigned long x)
36{ 33{
37 return addr < (1UL << boot_cpu_data.x86_phys_bits); 34 if (x >= __START_KERNEL_map) {
35 x -= __START_KERNEL_map;
36 VIRTUAL_BUG_ON(x >= KERNEL_IMAGE_SIZE);
37 x += phys_base;
38 } else {
39 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
40 x -= PAGE_OFFSET;
41 VIRTUAL_BUG_ON(system_state == SYSTEM_BOOTING ? x > MAXMEM :
42 !phys_addr_valid(x));
43 }
44 return x;
38} 45}
46EXPORT_SYMBOL(__phys_addr);
39 47
40#else 48#else
41 49
@@ -44,6 +52,17 @@ static inline int phys_addr_valid(unsigned long addr)
44 return 1; 52 return 1;
45} 53}
46 54
55#ifdef CONFIG_DEBUG_VIRTUAL
56unsigned long __phys_addr(unsigned long x)
57{
58 /* VMALLOC_* aren't constants; not available at the boot time */
59 VIRTUAL_BUG_ON(x < PAGE_OFFSET || (system_state != SYSTEM_BOOTING &&
60 is_vmalloc_addr((void *)x)));
61 return x - PAGE_OFFSET;
62}
63EXPORT_SYMBOL(__phys_addr);
64#endif
65
47#endif 66#endif
48 67
49int page_is_ram(unsigned long pagenr) 68int page_is_ram(unsigned long pagenr)
@@ -83,6 +102,25 @@ int page_is_ram(unsigned long pagenr)
83 return 0; 102 return 0;
84} 103}
85 104
105int pagerange_is_ram(unsigned long start, unsigned long end)
106{
107 int ram_page = 0, not_rampage = 0;
108 unsigned long page_nr;
109
110 for (page_nr = (start >> PAGE_SHIFT); page_nr < (end >> PAGE_SHIFT);
111 ++page_nr) {
112 if (page_is_ram(page_nr))
113 ram_page = 1;
114 else
115 not_rampage = 1;
116
117 if (ram_page == not_rampage)
118 return -1;
119 }
120
121 return ram_page;
122}
123
86/* 124/*
87 * Fix up the linear direct mapping of the kernel to avoid cache attribute 125 * Fix up the linear direct mapping of the kernel to avoid cache attribute
88 * conflicts. 126 * conflicts.
@@ -421,7 +459,7 @@ void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
421 return; 459 return;
422} 460}
423 461
424int __initdata early_ioremap_debug; 462static int __initdata early_ioremap_debug;
425 463
426static int __init early_ioremap_debug_setup(char *str) 464static int __init early_ioremap_debug_setup(char *str)
427{ 465{
@@ -547,7 +585,7 @@ static inline void __init early_clear_fixmap(enum fixed_addresses idx)
547} 585}
548 586
549 587
550int __initdata early_ioremap_nested; 588static int __initdata early_ioremap_nested;
551 589
552static int __init check_early_ioremap_leak(void) 590static int __init check_early_ioremap_leak(void)
553{ 591{
@@ -595,7 +633,7 @@ void __init *early_ioremap(unsigned long phys_addr, unsigned long size)
595 */ 633 */
596 offset = phys_addr & ~PAGE_MASK; 634 offset = phys_addr & ~PAGE_MASK;
597 phys_addr &= PAGE_MASK; 635 phys_addr &= PAGE_MASK;
598 size = PAGE_ALIGN(last_addr) - phys_addr; 636 size = PAGE_ALIGN(last_addr + 1) - phys_addr;
599 637
600 /* 638 /*
601 * Mappings have to fit in the FIX_BTMAP area. 639 * Mappings have to fit in the FIX_BTMAP area.
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index a4dd793d6003..cebcbf152d46 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -79,7 +79,7 @@ static int __init allocate_cachealigned_memnodemap(void)
79 return 0; 79 return 0;
80 80
81 addr = 0x8000; 81 addr = 0x8000;
82 nodemap_size = round_up(sizeof(s16) * memnodemapsize, L1_CACHE_BYTES); 82 nodemap_size = roundup(sizeof(s16) * memnodemapsize, L1_CACHE_BYTES);
83 nodemap_addr = find_e820_area(addr, max_pfn<<PAGE_SHIFT, 83 nodemap_addr = find_e820_area(addr, max_pfn<<PAGE_SHIFT,
84 nodemap_size, L1_CACHE_BYTES); 84 nodemap_size, L1_CACHE_BYTES);
85 if (nodemap_addr == -1UL) { 85 if (nodemap_addr == -1UL) {
@@ -176,10 +176,10 @@ void __init setup_node_bootmem(int nodeid, unsigned long start,
176 unsigned long start_pfn, last_pfn, bootmap_pages, bootmap_size; 176 unsigned long start_pfn, last_pfn, bootmap_pages, bootmap_size;
177 unsigned long bootmap_start, nodedata_phys; 177 unsigned long bootmap_start, nodedata_phys;
178 void *bootmap; 178 void *bootmap;
179 const int pgdat_size = round_up(sizeof(pg_data_t), PAGE_SIZE); 179 const int pgdat_size = roundup(sizeof(pg_data_t), PAGE_SIZE);
180 int nid; 180 int nid;
181 181
182 start = round_up(start, ZONE_ALIGN); 182 start = roundup(start, ZONE_ALIGN);
183 183
184 printk(KERN_INFO "Bootmem setup node %d %016lx-%016lx\n", nodeid, 184 printk(KERN_INFO "Bootmem setup node %d %016lx-%016lx\n", nodeid,
185 start, end); 185 start, end);
@@ -210,9 +210,9 @@ void __init setup_node_bootmem(int nodeid, unsigned long start,
210 bootmap_pages = bootmem_bootmap_pages(last_pfn - start_pfn); 210 bootmap_pages = bootmem_bootmap_pages(last_pfn - start_pfn);
211 nid = phys_to_nid(nodedata_phys); 211 nid = phys_to_nid(nodedata_phys);
212 if (nid == nodeid) 212 if (nid == nodeid)
213 bootmap_start = round_up(nodedata_phys + pgdat_size, PAGE_SIZE); 213 bootmap_start = roundup(nodedata_phys + pgdat_size, PAGE_SIZE);
214 else 214 else
215 bootmap_start = round_up(start, PAGE_SIZE); 215 bootmap_start = roundup(start, PAGE_SIZE);
216 /* 216 /*
217 * SMP_CACHE_BYTES could be enough, but init_bootmem_node like 217 * SMP_CACHE_BYTES could be enough, but init_bootmem_node like
218 * to use that to align to PAGE_SIZE 218 * to use that to align to PAGE_SIZE
diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
index d4aa503caaa2..e1d106909218 100644
--- a/arch/x86/mm/pageattr-test.c
+++ b/arch/x86/mm/pageattr-test.c
@@ -32,7 +32,7 @@ enum {
32 GPS = (1<<30) 32 GPS = (1<<30)
33}; 33};
34 34
35#define PAGE_TESTBIT __pgprot(_PAGE_UNUSED1) 35#define PAGE_CPA_TEST __pgprot(_PAGE_CPA_TEST)
36 36
37static int pte_testbit(pte_t pte) 37static int pte_testbit(pte_t pte)
38{ 38{
@@ -118,6 +118,7 @@ static int pageattr_test(void)
118 unsigned int level; 118 unsigned int level;
119 int i, k; 119 int i, k;
120 int err; 120 int err;
121 unsigned long test_addr;
121 122
122 if (print) 123 if (print)
123 printk(KERN_INFO "CPA self-test:\n"); 124 printk(KERN_INFO "CPA self-test:\n");
@@ -172,7 +173,8 @@ static int pageattr_test(void)
172 continue; 173 continue;
173 } 174 }
174 175
175 err = change_page_attr_set(addr[i], len[i], PAGE_TESTBIT); 176 test_addr = addr[i];
177 err = change_page_attr_set(&test_addr, len[i], PAGE_CPA_TEST, 0);
176 if (err < 0) { 178 if (err < 0) {
177 printk(KERN_ERR "CPA %d failed %d\n", i, err); 179 printk(KERN_ERR "CPA %d failed %d\n", i, err);
178 failed++; 180 failed++;
@@ -204,7 +206,8 @@ static int pageattr_test(void)
204 failed++; 206 failed++;
205 continue; 207 continue;
206 } 208 }
207 err = change_page_attr_clear(addr[i], len[i], PAGE_TESTBIT); 209 test_addr = addr[i];
210 err = change_page_attr_clear(&test_addr, len[i], PAGE_CPA_TEST, 0);
208 if (err < 0) { 211 if (err < 0) {
209 printk(KERN_ERR "CPA reverting failed: %d\n", err); 212 printk(KERN_ERR "CPA reverting failed: %d\n", err);
210 failed++; 213 failed++;
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 43e2f8483e4f..a9ec89c3fbca 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -25,15 +25,27 @@
25 * The current flushing context - we pass it instead of 5 arguments: 25 * The current flushing context - we pass it instead of 5 arguments:
26 */ 26 */
27struct cpa_data { 27struct cpa_data {
28 unsigned long vaddr; 28 unsigned long *vaddr;
29 pgprot_t mask_set; 29 pgprot_t mask_set;
30 pgprot_t mask_clr; 30 pgprot_t mask_clr;
31 int numpages; 31 int numpages;
32 int flushtlb; 32 int flags;
33 unsigned long pfn; 33 unsigned long pfn;
34 unsigned force_split : 1; 34 unsigned force_split : 1;
35 int curpage;
35}; 36};
36 37
38/*
39 * Serialize cpa() (for !DEBUG_PAGEALLOC which uses large identity mappings)
40 * using cpa_lock. So that we don't allow any other cpu, with stale large tlb
41 * entries change the page attribute in parallel to some other cpu
42 * splitting a large page entry along with changing the attribute.
43 */
44static DEFINE_SPINLOCK(cpa_lock);
45
46#define CPA_FLUSHTLB 1
47#define CPA_ARRAY 2
48
37#ifdef CONFIG_PROC_FS 49#ifdef CONFIG_PROC_FS
38static unsigned long direct_pages_count[PG_LEVEL_NUM]; 50static unsigned long direct_pages_count[PG_LEVEL_NUM];
39 51
@@ -84,7 +96,7 @@ static inline unsigned long highmap_start_pfn(void)
84 96
85static inline unsigned long highmap_end_pfn(void) 97static inline unsigned long highmap_end_pfn(void)
86{ 98{
87 return __pa(round_up((unsigned long)_end, PMD_SIZE)) >> PAGE_SHIFT; 99 return __pa(roundup((unsigned long)_end, PMD_SIZE)) >> PAGE_SHIFT;
88} 100}
89 101
90#endif 102#endif
@@ -190,6 +202,41 @@ static void cpa_flush_range(unsigned long start, int numpages, int cache)
190 } 202 }
191} 203}
192 204
205static void cpa_flush_array(unsigned long *start, int numpages, int cache)
206{
207 unsigned int i, level;
208 unsigned long *addr;
209
210 BUG_ON(irqs_disabled());
211
212 on_each_cpu(__cpa_flush_range, NULL, 1);
213
214 if (!cache)
215 return;
216
217 /* 4M threshold */
218 if (numpages >= 1024) {
219 if (boot_cpu_data.x86_model >= 4)
220 wbinvd();
221 return;
222 }
223 /*
224 * We only need to flush on one CPU,
225 * clflush is a MESI-coherent instruction that
226 * will cause all other CPUs to flush the same
227 * cachelines:
228 */
229 for (i = 0, addr = start; i < numpages; i++, addr++) {
230 pte_t *pte = lookup_address(*addr, &level);
231
232 /*
233 * Only flush present addresses:
234 */
235 if (pte && (pte_val(*pte) & _PAGE_PRESENT))
236 clflush_cache_range((void *) *addr, PAGE_SIZE);
237 }
238}
239
193/* 240/*
194 * Certain areas of memory on x86 require very specific protection flags, 241 * Certain areas of memory on x86 require very specific protection flags,
195 * for example the BIOS area or kernel text. Callers don't always get this 242 * for example the BIOS area or kernel text. Callers don't always get this
@@ -398,7 +445,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
398 */ 445 */
399 new_pte = pfn_pte(pte_pfn(old_pte), canon_pgprot(new_prot)); 446 new_pte = pfn_pte(pte_pfn(old_pte), canon_pgprot(new_prot));
400 __set_pmd_pte(kpte, address, new_pte); 447 __set_pmd_pte(kpte, address, new_pte);
401 cpa->flushtlb = 1; 448 cpa->flags |= CPA_FLUSHTLB;
402 do_split = 0; 449 do_split = 0;
403 } 450 }
404 451
@@ -408,84 +455,6 @@ out_unlock:
408 return do_split; 455 return do_split;
409} 456}
410 457
411static LIST_HEAD(page_pool);
412static unsigned long pool_size, pool_pages, pool_low;
413static unsigned long pool_used, pool_failed;
414
415static void cpa_fill_pool(struct page **ret)
416{
417 gfp_t gfp = GFP_KERNEL;
418 unsigned long flags;
419 struct page *p;
420
421 /*
422 * Avoid recursion (on debug-pagealloc) and also signal
423 * our priority to get to these pagetables:
424 */
425 if (current->flags & PF_MEMALLOC)
426 return;
427 current->flags |= PF_MEMALLOC;
428
429 /*
430 * Allocate atomically from atomic contexts:
431 */
432 if (in_atomic() || irqs_disabled() || debug_pagealloc)
433 gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
434
435 while (pool_pages < pool_size || (ret && !*ret)) {
436 p = alloc_pages(gfp, 0);
437 if (!p) {
438 pool_failed++;
439 break;
440 }
441 /*
442 * If the call site needs a page right now, provide it:
443 */
444 if (ret && !*ret) {
445 *ret = p;
446 continue;
447 }
448 spin_lock_irqsave(&pgd_lock, flags);
449 list_add(&p->lru, &page_pool);
450 pool_pages++;
451 spin_unlock_irqrestore(&pgd_lock, flags);
452 }
453
454 current->flags &= ~PF_MEMALLOC;
455}
456
457#define SHIFT_MB (20 - PAGE_SHIFT)
458#define ROUND_MB_GB ((1 << 10) - 1)
459#define SHIFT_MB_GB 10
460#define POOL_PAGES_PER_GB 16
461
462void __init cpa_init(void)
463{
464 struct sysinfo si;
465 unsigned long gb;
466
467 si_meminfo(&si);
468 /*
469 * Calculate the number of pool pages:
470 *
471 * Convert totalram (nr of pages) to MiB and round to the next
472 * GiB. Shift MiB to Gib and multiply the result by
473 * POOL_PAGES_PER_GB:
474 */
475 if (debug_pagealloc) {
476 gb = ((si.totalram >> SHIFT_MB) + ROUND_MB_GB) >> SHIFT_MB_GB;
477 pool_size = POOL_PAGES_PER_GB * gb;
478 } else {
479 pool_size = 1;
480 }
481 pool_low = pool_size;
482
483 cpa_fill_pool(NULL);
484 printk(KERN_DEBUG
485 "CPA: page pool initialized %lu of %lu pages preallocated\n",
486 pool_pages, pool_size);
487}
488
489static int split_large_page(pte_t *kpte, unsigned long address) 458static int split_large_page(pte_t *kpte, unsigned long address)
490{ 459{
491 unsigned long flags, pfn, pfninc = 1; 460 unsigned long flags, pfn, pfninc = 1;
@@ -494,28 +463,15 @@ static int split_large_page(pte_t *kpte, unsigned long address)
494 pgprot_t ref_prot; 463 pgprot_t ref_prot;
495 struct page *base; 464 struct page *base;
496 465
497 /* 466 if (!debug_pagealloc)
498 * Get a page from the pool. The pool list is protected by the 467 spin_unlock(&cpa_lock);
499 * pgd_lock, which we have to take anyway for the split 468 base = alloc_pages(GFP_KERNEL, 0);
500 * operation: 469 if (!debug_pagealloc)
501 */ 470 spin_lock(&cpa_lock);
502 spin_lock_irqsave(&pgd_lock, flags); 471 if (!base)
503 if (list_empty(&page_pool)) { 472 return -ENOMEM;
504 spin_unlock_irqrestore(&pgd_lock, flags);
505 base = NULL;
506 cpa_fill_pool(&base);
507 if (!base)
508 return -ENOMEM;
509 spin_lock_irqsave(&pgd_lock, flags);
510 } else {
511 base = list_first_entry(&page_pool, struct page, lru);
512 list_del(&base->lru);
513 pool_pages--;
514
515 if (pool_pages < pool_low)
516 pool_low = pool_pages;
517 }
518 473
474 spin_lock_irqsave(&pgd_lock, flags);
519 /* 475 /*
520 * Check for races, another CPU might have split this page 476 * Check for races, another CPU might have split this page
521 * up for us already: 477 * up for us already:
@@ -572,11 +528,8 @@ out_unlock:
572 * If we dropped out via the lookup_address check under 528 * If we dropped out via the lookup_address check under
573 * pgd_lock then stick the page back into the pool: 529 * pgd_lock then stick the page back into the pool:
574 */ 530 */
575 if (base) { 531 if (base)
576 list_add(&base->lru, &page_pool); 532 __free_page(base);
577 pool_pages++;
578 } else
579 pool_used++;
580 spin_unlock_irqrestore(&pgd_lock, flags); 533 spin_unlock_irqrestore(&pgd_lock, flags);
581 534
582 return 0; 535 return 0;
@@ -584,11 +537,16 @@ out_unlock:
584 537
585static int __change_page_attr(struct cpa_data *cpa, int primary) 538static int __change_page_attr(struct cpa_data *cpa, int primary)
586{ 539{
587 unsigned long address = cpa->vaddr; 540 unsigned long address;
588 int do_split, err; 541 int do_split, err;
589 unsigned int level; 542 unsigned int level;
590 pte_t *kpte, old_pte; 543 pte_t *kpte, old_pte;
591 544
545 if (cpa->flags & CPA_ARRAY)
546 address = cpa->vaddr[cpa->curpage];
547 else
548 address = *cpa->vaddr;
549
592repeat: 550repeat:
593 kpte = lookup_address(address, &level); 551 kpte = lookup_address(address, &level);
594 if (!kpte) 552 if (!kpte)
@@ -600,7 +558,7 @@ repeat:
600 return 0; 558 return 0;
601 WARN(1, KERN_WARNING "CPA: called for zero pte. " 559 WARN(1, KERN_WARNING "CPA: called for zero pte. "
602 "vaddr = %lx cpa->vaddr = %lx\n", address, 560 "vaddr = %lx cpa->vaddr = %lx\n", address,
603 cpa->vaddr); 561 *cpa->vaddr);
604 return -EINVAL; 562 return -EINVAL;
605 } 563 }
606 564
@@ -626,7 +584,7 @@ repeat:
626 */ 584 */
627 if (pte_val(old_pte) != pte_val(new_pte)) { 585 if (pte_val(old_pte) != pte_val(new_pte)) {
628 set_pte_atomic(kpte, new_pte); 586 set_pte_atomic(kpte, new_pte);
629 cpa->flushtlb = 1; 587 cpa->flags |= CPA_FLUSHTLB;
630 } 588 }
631 cpa->numpages = 1; 589 cpa->numpages = 1;
632 return 0; 590 return 0;
@@ -650,7 +608,25 @@ repeat:
650 */ 608 */
651 err = split_large_page(kpte, address); 609 err = split_large_page(kpte, address);
652 if (!err) { 610 if (!err) {
653 cpa->flushtlb = 1; 611 /*
612 * Do a global flush tlb after splitting the large page
613 * and before we do the actual change page attribute in the PTE.
614 *
615 * With out this, we violate the TLB application note, that says
616 * "The TLBs may contain both ordinary and large-page
617 * translations for a 4-KByte range of linear addresses. This
618 * may occur if software modifies the paging structures so that
619 * the page size used for the address range changes. If the two
620 * translations differ with respect to page frame or attributes
621 * (e.g., permissions), processor behavior is undefined and may
622 * be implementation-specific."
623 *
624 * We do this global tlb flush inside the cpa_lock, so that we
625 * don't allow any other cpu, with stale tlb entries change the
626 * page attribute in parallel, that also falls into the
627 * just split large page entry.
628 */
629 flush_tlb_all();
654 goto repeat; 630 goto repeat;
655 } 631 }
656 632
@@ -663,6 +639,7 @@ static int cpa_process_alias(struct cpa_data *cpa)
663{ 639{
664 struct cpa_data alias_cpa; 640 struct cpa_data alias_cpa;
665 int ret = 0; 641 int ret = 0;
642 unsigned long temp_cpa_vaddr, vaddr;
666 643
667 if (cpa->pfn >= max_pfn_mapped) 644 if (cpa->pfn >= max_pfn_mapped)
668 return 0; 645 return 0;
@@ -675,16 +652,24 @@ static int cpa_process_alias(struct cpa_data *cpa)
675 * No need to redo, when the primary call touched the direct 652 * No need to redo, when the primary call touched the direct
676 * mapping already: 653 * mapping already:
677 */ 654 */
678 if (!(within(cpa->vaddr, PAGE_OFFSET, 655 if (cpa->flags & CPA_ARRAY)
656 vaddr = cpa->vaddr[cpa->curpage];
657 else
658 vaddr = *cpa->vaddr;
659
660 if (!(within(vaddr, PAGE_OFFSET,
679 PAGE_OFFSET + (max_low_pfn_mapped << PAGE_SHIFT)) 661 PAGE_OFFSET + (max_low_pfn_mapped << PAGE_SHIFT))
680#ifdef CONFIG_X86_64 662#ifdef CONFIG_X86_64
681 || within(cpa->vaddr, PAGE_OFFSET + (1UL<<32), 663 || within(vaddr, PAGE_OFFSET + (1UL<<32),
682 PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT)) 664 PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT))
683#endif 665#endif
684 )) { 666 )) {
685 667
686 alias_cpa = *cpa; 668 alias_cpa = *cpa;
687 alias_cpa.vaddr = (unsigned long) __va(cpa->pfn << PAGE_SHIFT); 669 temp_cpa_vaddr = (unsigned long) __va(cpa->pfn << PAGE_SHIFT);
670 alias_cpa.vaddr = &temp_cpa_vaddr;
671 alias_cpa.flags &= ~CPA_ARRAY;
672
688 673
689 ret = __change_page_attr_set_clr(&alias_cpa, 0); 674 ret = __change_page_attr_set_clr(&alias_cpa, 0);
690 } 675 }
@@ -696,7 +681,7 @@ static int cpa_process_alias(struct cpa_data *cpa)
696 * No need to redo, when the primary call touched the high 681 * No need to redo, when the primary call touched the high
697 * mapping already: 682 * mapping already:
698 */ 683 */
699 if (within(cpa->vaddr, (unsigned long) _text, (unsigned long) _end)) 684 if (within(vaddr, (unsigned long) _text, (unsigned long) _end))
700 return 0; 685 return 0;
701 686
702 /* 687 /*
@@ -707,8 +692,9 @@ static int cpa_process_alias(struct cpa_data *cpa)
707 return 0; 692 return 0;
708 693
709 alias_cpa = *cpa; 694 alias_cpa = *cpa;
710 alias_cpa.vaddr = 695 temp_cpa_vaddr = (cpa->pfn << PAGE_SHIFT) + __START_KERNEL_map - phys_base;
711 (cpa->pfn << PAGE_SHIFT) + __START_KERNEL_map - phys_base; 696 alias_cpa.vaddr = &temp_cpa_vaddr;
697 alias_cpa.flags &= ~CPA_ARRAY;
712 698
713 /* 699 /*
714 * The high mapping range is imprecise, so ignore the return value. 700 * The high mapping range is imprecise, so ignore the return value.
@@ -728,8 +714,15 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
728 * preservation check. 714 * preservation check.
729 */ 715 */
730 cpa->numpages = numpages; 716 cpa->numpages = numpages;
717 /* for array changes, we can't use large page */
718 if (cpa->flags & CPA_ARRAY)
719 cpa->numpages = 1;
731 720
721 if (!debug_pagealloc)
722 spin_lock(&cpa_lock);
732 ret = __change_page_attr(cpa, checkalias); 723 ret = __change_page_attr(cpa, checkalias);
724 if (!debug_pagealloc)
725 spin_unlock(&cpa_lock);
733 if (ret) 726 if (ret)
734 return ret; 727 return ret;
735 728
@@ -746,7 +739,11 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
746 */ 739 */
747 BUG_ON(cpa->numpages > numpages); 740 BUG_ON(cpa->numpages > numpages);
748 numpages -= cpa->numpages; 741 numpages -= cpa->numpages;
749 cpa->vaddr += cpa->numpages * PAGE_SIZE; 742 if (cpa->flags & CPA_ARRAY)
743 cpa->curpage++;
744 else
745 *cpa->vaddr += cpa->numpages * PAGE_SIZE;
746
750 } 747 }
751 return 0; 748 return 0;
752} 749}
@@ -757,9 +754,9 @@ static inline int cache_attr(pgprot_t attr)
757 (_PAGE_PAT | _PAGE_PAT_LARGE | _PAGE_PWT | _PAGE_PCD); 754 (_PAGE_PAT | _PAGE_PAT_LARGE | _PAGE_PWT | _PAGE_PCD);
758} 755}
759 756
760static int change_page_attr_set_clr(unsigned long addr, int numpages, 757static int change_page_attr_set_clr(unsigned long *addr, int numpages,
761 pgprot_t mask_set, pgprot_t mask_clr, 758 pgprot_t mask_set, pgprot_t mask_clr,
762 int force_split) 759 int force_split, int array)
763{ 760{
764 struct cpa_data cpa; 761 struct cpa_data cpa;
765 int ret, cache, checkalias; 762 int ret, cache, checkalias;
@@ -774,21 +771,38 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
774 return 0; 771 return 0;
775 772
776 /* Ensure we are PAGE_SIZE aligned */ 773 /* Ensure we are PAGE_SIZE aligned */
777 if (addr & ~PAGE_MASK) { 774 if (!array) {
778 addr &= PAGE_MASK; 775 if (*addr & ~PAGE_MASK) {
779 /* 776 *addr &= PAGE_MASK;
780 * People should not be passing in unaligned addresses: 777 /*
781 */ 778 * People should not be passing in unaligned addresses:
782 WARN_ON_ONCE(1); 779 */
780 WARN_ON_ONCE(1);
781 }
782 } else {
783 int i;
784 for (i = 0; i < numpages; i++) {
785 if (addr[i] & ~PAGE_MASK) {
786 addr[i] &= PAGE_MASK;
787 WARN_ON_ONCE(1);
788 }
789 }
783 } 790 }
784 791
792 /* Must avoid aliasing mappings in the highmem code */
793 kmap_flush_unused();
794
785 cpa.vaddr = addr; 795 cpa.vaddr = addr;
786 cpa.numpages = numpages; 796 cpa.numpages = numpages;
787 cpa.mask_set = mask_set; 797 cpa.mask_set = mask_set;
788 cpa.mask_clr = mask_clr; 798 cpa.mask_clr = mask_clr;
789 cpa.flushtlb = 0; 799 cpa.flags = 0;
800 cpa.curpage = 0;
790 cpa.force_split = force_split; 801 cpa.force_split = force_split;
791 802
803 if (array)
804 cpa.flags |= CPA_ARRAY;
805
792 /* No alias checking for _NX bit modifications */ 806 /* No alias checking for _NX bit modifications */
793 checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX; 807 checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX;
794 808
@@ -797,7 +811,7 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
797 /* 811 /*
798 * Check whether we really changed something: 812 * Check whether we really changed something:
799 */ 813 */
800 if (!cpa.flushtlb) 814 if (!(cpa.flags & CPA_FLUSHTLB))
801 goto out; 815 goto out;
802 816
803 /* 817 /*
@@ -812,27 +826,30 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
812 * error case we fall back to cpa_flush_all (which uses 826 * error case we fall back to cpa_flush_all (which uses
813 * wbindv): 827 * wbindv):
814 */ 828 */
815 if (!ret && cpu_has_clflush) 829 if (!ret && cpu_has_clflush) {
816 cpa_flush_range(addr, numpages, cache); 830 if (cpa.flags & CPA_ARRAY)
817 else 831 cpa_flush_array(addr, numpages, cache);
832 else
833 cpa_flush_range(*addr, numpages, cache);
834 } else
818 cpa_flush_all(cache); 835 cpa_flush_all(cache);
819 836
820out: 837out:
821 cpa_fill_pool(NULL);
822
823 return ret; 838 return ret;
824} 839}
825 840
826static inline int change_page_attr_set(unsigned long addr, int numpages, 841static inline int change_page_attr_set(unsigned long *addr, int numpages,
827 pgprot_t mask) 842 pgprot_t mask, int array)
828{ 843{
829 return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0), 0); 844 return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0), 0,
845 array);
830} 846}
831 847
832static inline int change_page_attr_clear(unsigned long addr, int numpages, 848static inline int change_page_attr_clear(unsigned long *addr, int numpages,
833 pgprot_t mask) 849 pgprot_t mask, int array)
834{ 850{
835 return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask, 0); 851 return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask, 0,
852 array);
836} 853}
837 854
838int _set_memory_uc(unsigned long addr, int numpages) 855int _set_memory_uc(unsigned long addr, int numpages)
@@ -840,8 +857,8 @@ int _set_memory_uc(unsigned long addr, int numpages)
840 /* 857 /*
841 * for now UC MINUS. see comments in ioremap_nocache() 858 * for now UC MINUS. see comments in ioremap_nocache()
842 */ 859 */
843 return change_page_attr_set(addr, numpages, 860 return change_page_attr_set(&addr, numpages,
844 __pgprot(_PAGE_CACHE_UC_MINUS)); 861 __pgprot(_PAGE_CACHE_UC_MINUS), 0);
845} 862}
846 863
847int set_memory_uc(unsigned long addr, int numpages) 864int set_memory_uc(unsigned long addr, int numpages)
@@ -857,10 +874,48 @@ int set_memory_uc(unsigned long addr, int numpages)
857} 874}
858EXPORT_SYMBOL(set_memory_uc); 875EXPORT_SYMBOL(set_memory_uc);
859 876
877int set_memory_array_uc(unsigned long *addr, int addrinarray)
878{
879 unsigned long start;
880 unsigned long end;
881 int i;
882 /*
883 * for now UC MINUS. see comments in ioremap_nocache()
884 */
885 for (i = 0; i < addrinarray; i++) {
886 start = __pa(addr[i]);
887 for (end = start + PAGE_SIZE; i < addrinarray - 1; end += PAGE_SIZE) {
888 if (end != __pa(addr[i + 1]))
889 break;
890 i++;
891 }
892 if (reserve_memtype(start, end, _PAGE_CACHE_UC_MINUS, NULL))
893 goto out;
894 }
895
896 return change_page_attr_set(addr, addrinarray,
897 __pgprot(_PAGE_CACHE_UC_MINUS), 1);
898out:
899 for (i = 0; i < addrinarray; i++) {
900 unsigned long tmp = __pa(addr[i]);
901
902 if (tmp == start)
903 break;
904 for (end = tmp + PAGE_SIZE; i < addrinarray - 1; end += PAGE_SIZE) {
905 if (end != __pa(addr[i + 1]))
906 break;
907 i++;
908 }
909 free_memtype(tmp, end);
910 }
911 return -EINVAL;
912}
913EXPORT_SYMBOL(set_memory_array_uc);
914
860int _set_memory_wc(unsigned long addr, int numpages) 915int _set_memory_wc(unsigned long addr, int numpages)
861{ 916{
862 return change_page_attr_set(addr, numpages, 917 return change_page_attr_set(&addr, numpages,
863 __pgprot(_PAGE_CACHE_WC)); 918 __pgprot(_PAGE_CACHE_WC), 0);
864} 919}
865 920
866int set_memory_wc(unsigned long addr, int numpages) 921int set_memory_wc(unsigned long addr, int numpages)
@@ -878,8 +933,8 @@ EXPORT_SYMBOL(set_memory_wc);
878 933
879int _set_memory_wb(unsigned long addr, int numpages) 934int _set_memory_wb(unsigned long addr, int numpages)
880{ 935{
881 return change_page_attr_clear(addr, numpages, 936 return change_page_attr_clear(&addr, numpages,
882 __pgprot(_PAGE_CACHE_MASK)); 937 __pgprot(_PAGE_CACHE_MASK), 0);
883} 938}
884 939
885int set_memory_wb(unsigned long addr, int numpages) 940int set_memory_wb(unsigned long addr, int numpages)
@@ -890,37 +945,59 @@ int set_memory_wb(unsigned long addr, int numpages)
890} 945}
891EXPORT_SYMBOL(set_memory_wb); 946EXPORT_SYMBOL(set_memory_wb);
892 947
948int set_memory_array_wb(unsigned long *addr, int addrinarray)
949{
950 int i;
951
952 for (i = 0; i < addrinarray; i++) {
953 unsigned long start = __pa(addr[i]);
954 unsigned long end;
955
956 for (end = start + PAGE_SIZE; i < addrinarray - 1; end += PAGE_SIZE) {
957 if (end != __pa(addr[i + 1]))
958 break;
959 i++;
960 }
961 free_memtype(start, end);
962 }
963 return change_page_attr_clear(addr, addrinarray,
964 __pgprot(_PAGE_CACHE_MASK), 1);
965}
966EXPORT_SYMBOL(set_memory_array_wb);
967
893int set_memory_x(unsigned long addr, int numpages) 968int set_memory_x(unsigned long addr, int numpages)
894{ 969{
895 return change_page_attr_clear(addr, numpages, __pgprot(_PAGE_NX)); 970 return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_NX), 0);
896} 971}
897EXPORT_SYMBOL(set_memory_x); 972EXPORT_SYMBOL(set_memory_x);
898 973
899int set_memory_nx(unsigned long addr, int numpages) 974int set_memory_nx(unsigned long addr, int numpages)
900{ 975{
901 return change_page_attr_set(addr, numpages, __pgprot(_PAGE_NX)); 976 return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_NX), 0);
902} 977}
903EXPORT_SYMBOL(set_memory_nx); 978EXPORT_SYMBOL(set_memory_nx);
904 979
905int set_memory_ro(unsigned long addr, int numpages) 980int set_memory_ro(unsigned long addr, int numpages)
906{ 981{
907 return change_page_attr_clear(addr, numpages, __pgprot(_PAGE_RW)); 982 return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_RW), 0);
908} 983}
984EXPORT_SYMBOL_GPL(set_memory_ro);
909 985
910int set_memory_rw(unsigned long addr, int numpages) 986int set_memory_rw(unsigned long addr, int numpages)
911{ 987{
912 return change_page_attr_set(addr, numpages, __pgprot(_PAGE_RW)); 988 return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_RW), 0);
913} 989}
990EXPORT_SYMBOL_GPL(set_memory_rw);
914 991
915int set_memory_np(unsigned long addr, int numpages) 992int set_memory_np(unsigned long addr, int numpages)
916{ 993{
917 return change_page_attr_clear(addr, numpages, __pgprot(_PAGE_PRESENT)); 994 return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_PRESENT), 0);
918} 995}
919 996
920int set_memory_4k(unsigned long addr, int numpages) 997int set_memory_4k(unsigned long addr, int numpages)
921{ 998{
922 return change_page_attr_set_clr(addr, numpages, __pgprot(0), 999 return change_page_attr_set_clr(&addr, numpages, __pgprot(0),
923 __pgprot(0), 1); 1000 __pgprot(0), 1, 0);
924} 1001}
925 1002
926int set_pages_uc(struct page *page, int numpages) 1003int set_pages_uc(struct page *page, int numpages)
@@ -973,22 +1050,38 @@ int set_pages_rw(struct page *page, int numpages)
973 1050
974static int __set_pages_p(struct page *page, int numpages) 1051static int __set_pages_p(struct page *page, int numpages)
975{ 1052{
976 struct cpa_data cpa = { .vaddr = (unsigned long) page_address(page), 1053 unsigned long tempaddr = (unsigned long) page_address(page);
1054 struct cpa_data cpa = { .vaddr = &tempaddr,
977 .numpages = numpages, 1055 .numpages = numpages,
978 .mask_set = __pgprot(_PAGE_PRESENT | _PAGE_RW), 1056 .mask_set = __pgprot(_PAGE_PRESENT | _PAGE_RW),
979 .mask_clr = __pgprot(0)}; 1057 .mask_clr = __pgprot(0),
1058 .flags = 0};
980 1059
981 return __change_page_attr_set_clr(&cpa, 1); 1060 /*
1061 * No alias checking needed for setting present flag. otherwise,
1062 * we may need to break large pages for 64-bit kernel text
1063 * mappings (this adds to complexity if we want to do this from
1064 * atomic context especially). Let's keep it simple!
1065 */
1066 return __change_page_attr_set_clr(&cpa, 0);
982} 1067}
983 1068
984static int __set_pages_np(struct page *page, int numpages) 1069static int __set_pages_np(struct page *page, int numpages)
985{ 1070{
986 struct cpa_data cpa = { .vaddr = (unsigned long) page_address(page), 1071 unsigned long tempaddr = (unsigned long) page_address(page);
1072 struct cpa_data cpa = { .vaddr = &tempaddr,
987 .numpages = numpages, 1073 .numpages = numpages,
988 .mask_set = __pgprot(0), 1074 .mask_set = __pgprot(0),
989 .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW)}; 1075 .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW),
1076 .flags = 0};
990 1077
991 return __change_page_attr_set_clr(&cpa, 1); 1078 /*
1079 * No alias checking needed for setting not present flag. otherwise,
1080 * we may need to break large pages for 64-bit kernel text
1081 * mappings (this adds to complexity if we want to do this from
1082 * atomic context especially). Let's keep it simple!
1083 */
1084 return __change_page_attr_set_clr(&cpa, 0);
992} 1085}
993 1086
994void kernel_map_pages(struct page *page, int numpages, int enable) 1087void kernel_map_pages(struct page *page, int numpages, int enable)
@@ -1008,11 +1101,8 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
1008 1101
1009 /* 1102 /*
1010 * The return value is ignored as the calls cannot fail. 1103 * The return value is ignored as the calls cannot fail.
1011 * Large pages are kept enabled at boot time, and are 1104 * Large pages for identity mappings are not used at boot time
1012 * split up quickly with DEBUG_PAGEALLOC. If a splitup 1105 * and hence no memory allocations during large page split.
1013 * fails here (due to temporary memory shortage) no damage
1014 * is done because we just keep the largepage intact up
1015 * to the next attempt when it will likely be split up:
1016 */ 1106 */
1017 if (enable) 1107 if (enable)
1018 __set_pages_p(page, numpages); 1108 __set_pages_p(page, numpages);
@@ -1024,53 +1114,8 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
1024 * but that can deadlock->flush only current cpu: 1114 * but that can deadlock->flush only current cpu:
1025 */ 1115 */
1026 __flush_tlb_all(); 1116 __flush_tlb_all();
1027
1028 /*
1029 * Try to refill the page pool here. We can do this only after
1030 * the tlb flush.
1031 */
1032 cpa_fill_pool(NULL);
1033} 1117}
1034 1118
1035#ifdef CONFIG_DEBUG_FS
1036static int dpa_show(struct seq_file *m, void *v)
1037{
1038 seq_puts(m, "DEBUG_PAGEALLOC\n");
1039 seq_printf(m, "pool_size : %lu\n", pool_size);
1040 seq_printf(m, "pool_pages : %lu\n", pool_pages);
1041 seq_printf(m, "pool_low : %lu\n", pool_low);
1042 seq_printf(m, "pool_used : %lu\n", pool_used);
1043 seq_printf(m, "pool_failed : %lu\n", pool_failed);
1044
1045 return 0;
1046}
1047
1048static int dpa_open(struct inode *inode, struct file *filp)
1049{
1050 return single_open(filp, dpa_show, NULL);
1051}
1052
1053static const struct file_operations dpa_fops = {
1054 .open = dpa_open,
1055 .read = seq_read,
1056 .llseek = seq_lseek,
1057 .release = single_release,
1058};
1059
1060static int __init debug_pagealloc_proc_init(void)
1061{
1062 struct dentry *de;
1063
1064 de = debugfs_create_file("debug_pagealloc", 0600, NULL, NULL,
1065 &dpa_fops);
1066 if (!de)
1067 return -ENOMEM;
1068
1069 return 0;
1070}
1071__initcall(debug_pagealloc_proc_init);
1072#endif
1073
1074#ifdef CONFIG_HIBERNATION 1119#ifdef CONFIG_HIBERNATION
1075 1120
1076bool kernel_page_present(struct page *page) 1121bool kernel_page_present(struct page *page)
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 2a50e0fa64a5..738fd0f24958 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -7,24 +7,24 @@
7 * Loosely based on earlier PAT patchset from Eric Biederman and Andi Kleen. 7 * Loosely based on earlier PAT patchset from Eric Biederman and Andi Kleen.
8 */ 8 */
9 9
10#include <linux/mm.h> 10#include <linux/seq_file.h>
11#include <linux/bootmem.h>
12#include <linux/debugfs.h>
11#include <linux/kernel.h> 13#include <linux/kernel.h>
12#include <linux/gfp.h> 14#include <linux/gfp.h>
15#include <linux/mm.h>
13#include <linux/fs.h> 16#include <linux/fs.h>
14#include <linux/bootmem.h>
15#include <linux/debugfs.h>
16#include <linux/seq_file.h>
17 17
18#include <asm/msr.h> 18#include <asm/cacheflush.h>
19#include <asm/tlbflush.h>
20#include <asm/processor.h> 19#include <asm/processor.h>
21#include <asm/page.h> 20#include <asm/tlbflush.h>
22#include <asm/pgtable.h> 21#include <asm/pgtable.h>
23#include <asm/pat.h>
24#include <asm/e820.h>
25#include <asm/cacheflush.h>
26#include <asm/fcntl.h> 22#include <asm/fcntl.h>
23#include <asm/e820.h>
27#include <asm/mtrr.h> 24#include <asm/mtrr.h>
25#include <asm/page.h>
26#include <asm/msr.h>
27#include <asm/pat.h>
28#include <asm/io.h> 28#include <asm/io.h>
29 29
30#ifdef CONFIG_X86_PAT 30#ifdef CONFIG_X86_PAT
@@ -46,6 +46,7 @@ early_param("nopat", nopat);
46 46
47 47
48static int debug_enable; 48static int debug_enable;
49
49static int __init pat_debug_setup(char *str) 50static int __init pat_debug_setup(char *str)
50{ 51{
51 debug_enable = 1; 52 debug_enable = 1;
@@ -145,14 +146,14 @@ static char *cattr_name(unsigned long flags)
145 */ 146 */
146 147
147struct memtype { 148struct memtype {
148 u64 start; 149 u64 start;
149 u64 end; 150 u64 end;
150 unsigned long type; 151 unsigned long type;
151 struct list_head nd; 152 struct list_head nd;
152}; 153};
153 154
154static LIST_HEAD(memtype_list); 155static LIST_HEAD(memtype_list);
155static DEFINE_SPINLOCK(memtype_lock); /* protects memtype list */ 156static DEFINE_SPINLOCK(memtype_lock); /* protects memtype list */
156 157
157/* 158/*
158 * Does intersection of PAT memory type and MTRR memory type and returns 159 * Does intersection of PAT memory type and MTRR memory type and returns
@@ -180,8 +181,8 @@ static unsigned long pat_x_mtrr_type(u64 start, u64 end, unsigned long req_type)
180 return req_type; 181 return req_type;
181} 182}
182 183
183static int chk_conflict(struct memtype *new, struct memtype *entry, 184static int
184 unsigned long *type) 185chk_conflict(struct memtype *new, struct memtype *entry, unsigned long *type)
185{ 186{
186 if (new->type != entry->type) { 187 if (new->type != entry->type) {
187 if (type) { 188 if (type) {
@@ -211,6 +212,66 @@ static struct memtype *cached_entry;
211static u64 cached_start; 212static u64 cached_start;
212 213
213/* 214/*
215 * For RAM pages, mark the pages as non WB memory type using
216 * PageNonWB (PG_arch_1). We allow only one set_memory_uc() or
217 * set_memory_wc() on a RAM page at a time before marking it as WB again.
218 * This is ok, because only one driver will be owning the page and
219 * doing set_memory_*() calls.
220 *
221 * For now, we use PageNonWB to track that the RAM page is being mapped
222 * as non WB. In future, we will have to use one more flag
223 * (or some other mechanism in page_struct) to distinguish between
224 * UC and WC mapping.
225 */
226static int reserve_ram_pages_type(u64 start, u64 end, unsigned long req_type,
227 unsigned long *new_type)
228{
229 struct page *page;
230 u64 pfn, end_pfn;
231
232 for (pfn = (start >> PAGE_SHIFT); pfn < (end >> PAGE_SHIFT); ++pfn) {
233 page = pfn_to_page(pfn);
234 if (page_mapped(page) || PageNonWB(page))
235 goto out;
236
237 SetPageNonWB(page);
238 }
239 return 0;
240
241out:
242 end_pfn = pfn;
243 for (pfn = (start >> PAGE_SHIFT); pfn < end_pfn; ++pfn) {
244 page = pfn_to_page(pfn);
245 ClearPageNonWB(page);
246 }
247
248 return -EINVAL;
249}
250
251static int free_ram_pages_type(u64 start, u64 end)
252{
253 struct page *page;
254 u64 pfn, end_pfn;
255
256 for (pfn = (start >> PAGE_SHIFT); pfn < (end >> PAGE_SHIFT); ++pfn) {
257 page = pfn_to_page(pfn);
258 if (page_mapped(page) || !PageNonWB(page))
259 goto out;
260
261 ClearPageNonWB(page);
262 }
263 return 0;
264
265out:
266 end_pfn = pfn;
267 for (pfn = (start >> PAGE_SHIFT); pfn < end_pfn; ++pfn) {
268 page = pfn_to_page(pfn);
269 SetPageNonWB(page);
270 }
271 return -EINVAL;
272}
273
274/*
214 * req_type typically has one of the: 275 * req_type typically has one of the:
215 * - _PAGE_CACHE_WB 276 * - _PAGE_CACHE_WB
216 * - _PAGE_CACHE_WC 277 * - _PAGE_CACHE_WC
@@ -226,14 +287,15 @@ static u64 cached_start;
226 * it will return a negative return value. 287 * it will return a negative return value.
227 */ 288 */
228int reserve_memtype(u64 start, u64 end, unsigned long req_type, 289int reserve_memtype(u64 start, u64 end, unsigned long req_type,
229 unsigned long *new_type) 290 unsigned long *new_type)
230{ 291{
231 struct memtype *new, *entry; 292 struct memtype *new, *entry;
232 unsigned long actual_type; 293 unsigned long actual_type;
233 struct list_head *where; 294 struct list_head *where;
295 int is_range_ram;
234 int err = 0; 296 int err = 0;
235 297
236 BUG_ON(start >= end); /* end is exclusive */ 298 BUG_ON(start >= end); /* end is exclusive */
237 299
238 if (!pat_enabled) { 300 if (!pat_enabled) {
239 /* This is identical to page table setting without PAT */ 301 /* This is identical to page table setting without PAT */
@@ -266,17 +328,24 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
266 actual_type = _PAGE_CACHE_WB; 328 actual_type = _PAGE_CACHE_WB;
267 else 329 else
268 actual_type = _PAGE_CACHE_UC_MINUS; 330 actual_type = _PAGE_CACHE_UC_MINUS;
269 } else 331 } else {
270 actual_type = pat_x_mtrr_type(start, end, 332 actual_type = pat_x_mtrr_type(start, end,
271 req_type & _PAGE_CACHE_MASK); 333 req_type & _PAGE_CACHE_MASK);
334 }
335
336 is_range_ram = pagerange_is_ram(start, end);
337 if (is_range_ram == 1)
338 return reserve_ram_pages_type(start, end, req_type, new_type);
339 else if (is_range_ram < 0)
340 return -EINVAL;
272 341
273 new = kmalloc(sizeof(struct memtype), GFP_KERNEL); 342 new = kmalloc(sizeof(struct memtype), GFP_KERNEL);
274 if (!new) 343 if (!new)
275 return -ENOMEM; 344 return -ENOMEM;
276 345
277 new->start = start; 346 new->start = start;
278 new->end = end; 347 new->end = end;
279 new->type = actual_type; 348 new->type = actual_type;
280 349
281 if (new_type) 350 if (new_type)
282 *new_type = actual_type; 351 *new_type = actual_type;
@@ -335,6 +404,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
335 start, end, cattr_name(new->type), cattr_name(req_type)); 404 start, end, cattr_name(new->type), cattr_name(req_type));
336 kfree(new); 405 kfree(new);
337 spin_unlock(&memtype_lock); 406 spin_unlock(&memtype_lock);
407
338 return err; 408 return err;
339 } 409 }
340 410
@@ -358,6 +428,7 @@ int free_memtype(u64 start, u64 end)
358{ 428{
359 struct memtype *entry; 429 struct memtype *entry;
360 int err = -EINVAL; 430 int err = -EINVAL;
431 int is_range_ram;
361 432
362 if (!pat_enabled) 433 if (!pat_enabled)
363 return 0; 434 return 0;
@@ -366,6 +437,12 @@ int free_memtype(u64 start, u64 end)
366 if (is_ISA_range(start, end - 1)) 437 if (is_ISA_range(start, end - 1))
367 return 0; 438 return 0;
368 439
440 is_range_ram = pagerange_is_ram(start, end);
441 if (is_range_ram == 1)
442 return free_ram_pages_type(start, end);
443 else if (is_range_ram < 0)
444 return -EINVAL;
445
369 spin_lock(&memtype_lock); 446 spin_lock(&memtype_lock);
370 list_for_each_entry(entry, &memtype_list, nd) { 447 list_for_each_entry(entry, &memtype_list, nd) {
371 if (entry->start == start && entry->end == end) { 448 if (entry->start == start && entry->end == end) {
@@ -386,6 +463,7 @@ int free_memtype(u64 start, u64 end)
386 } 463 }
387 464
388 dprintk("free_memtype request 0x%Lx-0x%Lx\n", start, end); 465 dprintk("free_memtype request 0x%Lx-0x%Lx\n", start, end);
466
389 return err; 467 return err;
390} 468}
391 469
@@ -492,9 +570,9 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
492 570
493void map_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot) 571void map_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot)
494{ 572{
573 unsigned long want_flags = (pgprot_val(vma_prot) & _PAGE_CACHE_MASK);
495 u64 addr = (u64)pfn << PAGE_SHIFT; 574 u64 addr = (u64)pfn << PAGE_SHIFT;
496 unsigned long flags; 575 unsigned long flags;
497 unsigned long want_flags = (pgprot_val(vma_prot) & _PAGE_CACHE_MASK);
498 576
499 reserve_memtype(addr, addr + size, want_flags, &flags); 577 reserve_memtype(addr, addr + size, want_flags, &flags);
500 if (flags != want_flags) { 578 if (flags != want_flags) {
@@ -514,7 +592,7 @@ void unmap_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot)
514 free_memtype(addr, addr + size); 592 free_memtype(addr, addr + size);
515} 593}
516 594
517#if defined(CONFIG_DEBUG_FS) 595#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_X86_PAT)
518 596
519/* get Nth element of the linked list */ 597/* get Nth element of the linked list */
520static struct memtype *memtype_get_idx(loff_t pos) 598static struct memtype *memtype_get_idx(loff_t pos)
@@ -537,6 +615,7 @@ static struct memtype *memtype_get_idx(loff_t pos)
537 } 615 }
538 spin_unlock(&memtype_lock); 616 spin_unlock(&memtype_lock);
539 kfree(print_entry); 617 kfree(print_entry);
618
540 return NULL; 619 return NULL;
541} 620}
542 621
@@ -567,6 +646,7 @@ static int memtype_seq_show(struct seq_file *seq, void *v)
567 seq_printf(seq, "%s @ 0x%Lx-0x%Lx\n", cattr_name(print_entry->type), 646 seq_printf(seq, "%s @ 0x%Lx-0x%Lx\n", cattr_name(print_entry->type),
568 print_entry->start, print_entry->end); 647 print_entry->start, print_entry->end);
569 kfree(print_entry); 648 kfree(print_entry);
649
570 return 0; 650 return 0;
571} 651}
572 652
@@ -598,4 +678,4 @@ static int __init pat_memtype_list_init(void)
598 678
599late_initcall(pat_memtype_list_init); 679late_initcall(pat_memtype_list_init);
600 680
601#endif /* CONFIG_DEBUG_FS */ 681#endif /* CONFIG_DEBUG_FS && CONFIG_X86_PAT */
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index d50302774fe2..86f2ffc43c3d 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -63,10 +63,8 @@ static inline void pgd_list_del(pgd_t *pgd)
63#define UNSHARED_PTRS_PER_PGD \ 63#define UNSHARED_PTRS_PER_PGD \
64 (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD) 64 (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
65 65
66static void pgd_ctor(void *p) 66static void pgd_ctor(pgd_t *pgd)
67{ 67{
68 pgd_t *pgd = p;
69
70 /* If the pgd points to a shared pagetable level (either the 68 /* If the pgd points to a shared pagetable level (either the
71 ptes in non-PAE, or shared PMD in PAE), then just copy the 69 ptes in non-PAE, or shared PMD in PAE), then just copy the
72 references from swapper_pg_dir. */ 70 references from swapper_pg_dir. */
@@ -87,7 +85,7 @@ static void pgd_ctor(void *p)
87 pgd_list_add(pgd); 85 pgd_list_add(pgd);
88} 86}
89 87
90static void pgd_dtor(void *pgd) 88static void pgd_dtor(pgd_t *pgd)
91{ 89{
92 unsigned long flags; /* can be called from interrupt context */ 90 unsigned long flags; /* can be called from interrupt context */
93 91
diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
index cab0abbd1ebe..0951db9ee519 100644
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -123,7 +123,8 @@ static int __init parse_vmalloc(char *arg)
123 if (!arg) 123 if (!arg)
124 return -EINVAL; 124 return -EINVAL;
125 125
126 __VMALLOC_RESERVE = memparse(arg, &arg); 126 /* Add VMALLOC_OFFSET to the parsed value due to vm area guard hole*/
127 __VMALLOC_RESERVE = memparse(arg, &arg) + VMALLOC_OFFSET;
127 return 0; 128 return 0;
128} 129}
129early_param("vmalloc", parse_vmalloc); 130early_param("vmalloc", parse_vmalloc);
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 19af06927fbc..1d88d2b39771 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -250,10 +250,5 @@ int __init pci_acpi_init(void)
250 acpi_pci_irq_enable(dev); 250 acpi_pci_irq_enable(dev);
251 } 251 }
252 252
253#ifdef CONFIG_X86_IO_APIC
254 if (acpi_ioapic)
255 print_IO_APIC();
256#endif
257
258 return 0; 253 return 0;
259} 254}
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index 6a0fca78c362..22e057665e55 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -580,7 +580,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
580 unsigned long action, void *hcpu) 580 unsigned long action, void *hcpu)
581{ 581{
582 int cpu = (long)hcpu; 582 int cpu = (long)hcpu;
583 switch(action) { 583 switch (action) {
584 case CPU_ONLINE: 584 case CPU_ONLINE:
585 case CPU_ONLINE_FROZEN: 585 case CPU_ONLINE_FROZEN:
586 smp_call_function_single(cpu, enable_pci_io_ecs, NULL, 0); 586 smp_call_function_single(cpu, enable_pci_io_ecs, NULL, 0);
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 8791fc55e715..844df0cbbd3e 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -33,6 +33,7 @@
33#include <linux/bootmem.h> 33#include <linux/bootmem.h>
34 34
35#include <asm/pat.h> 35#include <asm/pat.h>
36#include <asm/e820.h>
36 37
37#include "pci.h" 38#include "pci.h"
38 39
@@ -227,6 +228,8 @@ void __init pcibios_resource_survey(void)
227 pcibios_allocate_bus_resources(&pci_root_buses); 228 pcibios_allocate_bus_resources(&pci_root_buses);
228 pcibios_allocate_resources(0); 229 pcibios_allocate_resources(0);
229 pcibios_allocate_resources(1); 230 pcibios_allocate_resources(1);
231
232 e820_reserve_resources_late();
230} 233}
231 234
232/** 235/**
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index 8e077185e185..006599db0dc7 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -1043,35 +1043,44 @@ static void __init pcibios_fixup_irqs(void)
1043 if (io_apic_assign_pci_irqs) { 1043 if (io_apic_assign_pci_irqs) {
1044 int irq; 1044 int irq;
1045 1045
1046 if (pin) { 1046 if (!pin)
1047 /* 1047 continue;
1048 * interrupt pins are numbered starting 1048
1049 * from 1 1049 /*
1050 */ 1050 * interrupt pins are numbered starting from 1
1051 pin--; 1051 */
1052 irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, 1052 pin--;
1053 PCI_SLOT(dev->devfn), pin); 1053 irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
1054 /* 1054 PCI_SLOT(dev->devfn), pin);
1055 * Busses behind bridges are typically not listed in the MP-table. 1055 /*
1056 * In this case we have to look up the IRQ based on the parent bus, 1056 * Busses behind bridges are typically not listed in the
1057 * parent slot, and pin number. The SMP code detects such bridged 1057 * MP-table. In this case we have to look up the IRQ
1058 * busses itself so we should get into this branch reliably. 1058 * based on the parent bus, parent slot, and pin number.
1059 */ 1059 * The SMP code detects such bridged busses itself so we
1060 if (irq < 0 && dev->bus->parent) { /* go back to the bridge */ 1060 * should get into this branch reliably.
1061 struct pci_dev *bridge = dev->bus->self; 1061 */
1062 1062 if (irq < 0 && dev->bus->parent) {
1063 pin = (pin + PCI_SLOT(dev->devfn)) % 4; 1063 /* go back to the bridge */
1064 irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number, 1064 struct pci_dev *bridge = dev->bus->self;
1065 PCI_SLOT(bridge->devfn), pin); 1065 int bus;
1066 if (irq >= 0) 1066
1067 dev_warn(&dev->dev, "using bridge %s INT %c to get IRQ %d\n", 1067 pin = (pin + PCI_SLOT(dev->devfn)) % 4;
1068 pci_name(bridge), 1068 bus = bridge->bus->number;
1069 'A' + pin, irq); 1069 irq = IO_APIC_get_PCI_irq_vector(bus,
1070 } 1070 PCI_SLOT(bridge->devfn), pin);
1071 if (irq >= 0) { 1071 if (irq >= 0)
1072 dev_info(&dev->dev, "PCI->APIC IRQ transform: INT %c -> IRQ %d\n", 'A' + pin, irq); 1072 dev_warn(&dev->dev,
1073 dev->irq = irq; 1073 "using bridge %s INT %c to "
1074 } 1074 "get IRQ %d\n",
1075 pci_name(bridge),
1076 'A' + pin, irq);
1077 }
1078 if (irq >= 0) {
1079 dev_info(&dev->dev,
1080 "PCI->APIC IRQ transform: INT %c "
1081 "-> IRQ %d\n",
1082 'A' + pin, irq);
1083 dev->irq = irq;
1075 } 1084 }
1076 } 1085 }
1077#endif 1086#endif
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index d9635764ce3d..654a2234f8f3 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -209,7 +209,7 @@ static int __init pci_mmcfg_check_hostbridge(void)
209 return name != NULL; 209 return name != NULL;
210} 210}
211 211
212static void __init pci_mmcfg_insert_resources(unsigned long resource_flags) 212static void __init pci_mmcfg_insert_resources(void)
213{ 213{
214#define PCI_MMCFG_RESOURCE_NAME_LEN 19 214#define PCI_MMCFG_RESOURCE_NAME_LEN 19
215 int i; 215 int i;
@@ -233,7 +233,7 @@ static void __init pci_mmcfg_insert_resources(unsigned long resource_flags)
233 cfg->pci_segment); 233 cfg->pci_segment);
234 res->start = cfg->address; 234 res->start = cfg->address;
235 res->end = res->start + (num_buses << 20) - 1; 235 res->end = res->start + (num_buses << 20) - 1;
236 res->flags = IORESOURCE_MEM | resource_flags; 236 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
237 insert_resource(&iomem_resource, res); 237 insert_resource(&iomem_resource, res);
238 names += PCI_MMCFG_RESOURCE_NAME_LEN; 238 names += PCI_MMCFG_RESOURCE_NAME_LEN;
239 } 239 }
@@ -434,11 +434,9 @@ static void __init __pci_mmcfg_init(int early)
434 (pci_mmcfg_config[0].address == 0)) 434 (pci_mmcfg_config[0].address == 0))
435 return; 435 return;
436 436
437 if (pci_mmcfg_arch_init()) { 437 if (pci_mmcfg_arch_init())
438 if (known_bridge)
439 pci_mmcfg_insert_resources(IORESOURCE_BUSY);
440 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 438 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
441 } else { 439 else {
442 /* 440 /*
443 * Signal not to attempt to insert mmcfg resources because 441 * Signal not to attempt to insert mmcfg resources because
444 * the architecture mmcfg setup could not initialize. 442 * the architecture mmcfg setup could not initialize.
@@ -475,7 +473,7 @@ static int __init pci_mmcfg_late_insert_resources(void)
475 * marked so it won't cause request errors when __request_region is 473 * marked so it won't cause request errors when __request_region is
476 * called. 474 * called.
477 */ 475 */
478 pci_mmcfg_insert_resources(0); 476 pci_mmcfg_insert_resources();
479 477
480 return 0; 478 return 0;
481} 479}
diff --git a/arch/x86/power/cpu_32.c b/arch/x86/power/cpu_32.c
index d3e083dea720..274d06082f48 100644
--- a/arch/x86/power/cpu_32.c
+++ b/arch/x86/power/cpu_32.c
@@ -11,6 +11,7 @@
11#include <linux/suspend.h> 11#include <linux/suspend.h>
12#include <asm/mtrr.h> 12#include <asm/mtrr.h>
13#include <asm/mce.h> 13#include <asm/mce.h>
14#include <asm/xcr.h>
14 15
15static struct saved_context saved_context; 16static struct saved_context saved_context;
16 17
@@ -126,6 +127,12 @@ static void __restore_processor_state(struct saved_context *ctxt)
126 if (boot_cpu_has(X86_FEATURE_SEP)) 127 if (boot_cpu_has(X86_FEATURE_SEP))
127 enable_sep_cpu(); 128 enable_sep_cpu();
128 129
130 /*
131 * restore XCR0 for xsave capable cpu's.
132 */
133 if (cpu_has_xsave)
134 xsetbv(XCR_XFEATURE_ENABLED_MASK, pcntxt_mask);
135
129 fix_processor_context(); 136 fix_processor_context();
130 do_fpu_end(); 137 do_fpu_end();
131 mtrr_ap_init(); 138 mtrr_ap_init();
diff --git a/arch/x86/power/cpu_64.c b/arch/x86/power/cpu_64.c
index 66bdfb591fd8..e3b6cf70d62c 100644
--- a/arch/x86/power/cpu_64.c
+++ b/arch/x86/power/cpu_64.c
@@ -14,6 +14,7 @@
14#include <asm/page.h> 14#include <asm/page.h>
15#include <asm/pgtable.h> 15#include <asm/pgtable.h>
16#include <asm/mtrr.h> 16#include <asm/mtrr.h>
17#include <asm/xcr.h>
17 18
18static void fix_processor_context(void); 19static void fix_processor_context(void);
19 20
@@ -122,6 +123,12 @@ static void __restore_processor_state(struct saved_context *ctxt)
122 wrmsrl(MSR_GS_BASE, ctxt->gs_base); 123 wrmsrl(MSR_GS_BASE, ctxt->gs_base);
123 wrmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); 124 wrmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base);
124 125
126 /*
127 * restore XCR0 for xsave capable cpu's.
128 */
129 if (cpu_has_xsave)
130 xsetbv(XCR_XFEATURE_ENABLED_MASK, pcntxt_mask);
131
125 fix_processor_context(); 132 fix_processor_context();
126 133
127 do_fpu_end(); 134 do_fpu_end();
diff --git a/arch/x86/power/hibernate_asm_32.S b/arch/x86/power/hibernate_asm_32.S
index 4fc7e872c85e..d1e9b53f9d33 100644
--- a/arch/x86/power/hibernate_asm_32.S
+++ b/arch/x86/power/hibernate_asm_32.S
@@ -1,5 +1,3 @@
1.text
2
3/* 1/*
4 * This may not use any stack, nor any variable that is not "NoSave": 2 * This may not use any stack, nor any variable that is not "NoSave":
5 * 3 *
@@ -12,17 +10,18 @@
12#include <asm/segment.h> 10#include <asm/segment.h>
13#include <asm/page.h> 11#include <asm/page.h>
14#include <asm/asm-offsets.h> 12#include <asm/asm-offsets.h>
13#include <asm/processor-flags.h>
15 14
16 .text 15.text
17 16
18ENTRY(swsusp_arch_suspend) 17ENTRY(swsusp_arch_suspend)
19
20 movl %esp, saved_context_esp 18 movl %esp, saved_context_esp
21 movl %ebx, saved_context_ebx 19 movl %ebx, saved_context_ebx
22 movl %ebp, saved_context_ebp 20 movl %ebp, saved_context_ebp
23 movl %esi, saved_context_esi 21 movl %esi, saved_context_esi
24 movl %edi, saved_context_edi 22 movl %edi, saved_context_edi
25 pushfl ; popl saved_context_eflags 23 pushfl
24 popl saved_context_eflags
26 25
27 call swsusp_save 26 call swsusp_save
28 ret 27 ret
@@ -59,7 +58,7 @@ done:
59 movl mmu_cr4_features, %ecx 58 movl mmu_cr4_features, %ecx
60 jecxz 1f # cr4 Pentium and higher, skip if zero 59 jecxz 1f # cr4 Pentium and higher, skip if zero
61 movl %ecx, %edx 60 movl %ecx, %edx
62 andl $~(1<<7), %edx; # PGE 61 andl $~(X86_CR4_PGE), %edx
63 movl %edx, %cr4; # turn off PGE 62 movl %edx, %cr4; # turn off PGE
641: 631:
65 movl %cr3, %eax; # flush TLB 64 movl %cr3, %eax; # flush TLB
@@ -74,7 +73,8 @@ done:
74 movl saved_context_esi, %esi 73 movl saved_context_esi, %esi
75 movl saved_context_edi, %edi 74 movl saved_context_edi, %edi
76 75
77 pushl saved_context_eflags ; popfl 76 pushl saved_context_eflags
77 popfl
78 78
79 xorl %eax, %eax 79 xorl %eax, %eax
80 80
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index 3815e425f470..87b9ab166423 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -26,5 +26,13 @@ config XEN_MAX_DOMAIN_MEMORY
26 26
27config XEN_SAVE_RESTORE 27config XEN_SAVE_RESTORE
28 bool 28 bool
29 depends on PM 29 depends on XEN && PM
30 default y \ No newline at end of file 30 default y
31
32config XEN_DEBUG_FS
33 bool "Enable Xen debug and tuning parameters in debugfs"
34 depends on XEN && DEBUG_FS
35 default n
36 help
37 Enable statistics output and various tuning options in debugfs.
38 Enabling this option may incur a significant performance overhead.
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index 59c1e539aed2..313947940a1a 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -1,4 +1,12 @@
1obj-y := enlighten.o setup.o multicalls.o mmu.o \ 1ifdef CONFIG_FTRACE
2# Do not profile debug and lowlevel utilities
3CFLAGS_REMOVE_spinlock.o = -pg
4CFLAGS_REMOVE_time.o = -pg
5CFLAGS_REMOVE_irq.o = -pg
6endif
7
8obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \
2 time.o xen-asm_$(BITS).o grant-table.o suspend.o 9 time.o xen-asm_$(BITS).o grant-table.o suspend.o
3 10
4obj-$(CONFIG_SMP) += smp.o 11obj-$(CONFIG_SMP) += smp.o spinlock.o
12obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o \ No newline at end of file
diff --git a/arch/x86/xen/debugfs.c b/arch/x86/xen/debugfs.c
new file mode 100644
index 000000000000..b53225d2cac3
--- /dev/null
+++ b/arch/x86/xen/debugfs.c
@@ -0,0 +1,123 @@
1#include <linux/init.h>
2#include <linux/debugfs.h>
3#include <linux/module.h>
4
5#include "debugfs.h"
6
7static struct dentry *d_xen_debug;
8
9struct dentry * __init xen_init_debugfs(void)
10{
11 if (!d_xen_debug) {
12 d_xen_debug = debugfs_create_dir("xen", NULL);
13
14 if (!d_xen_debug)
15 pr_warning("Could not create 'xen' debugfs directory\n");
16 }
17
18 return d_xen_debug;
19}
20
21struct array_data
22{
23 void *array;
24 unsigned elements;
25};
26
27static int u32_array_open(struct inode *inode, struct file *file)
28{
29 file->private_data = NULL;
30 return nonseekable_open(inode, file);
31}
32
33static size_t format_array(char *buf, size_t bufsize, const char *fmt,
34 u32 *array, unsigned array_size)
35{
36 size_t ret = 0;
37 unsigned i;
38
39 for(i = 0; i < array_size; i++) {
40 size_t len;
41
42 len = snprintf(buf, bufsize, fmt, array[i]);
43 len++; /* ' ' or '\n' */
44 ret += len;
45
46 if (buf) {
47 buf += len;
48 bufsize -= len;
49 buf[-1] = (i == array_size-1) ? '\n' : ' ';
50 }
51 }
52
53 ret++; /* \0 */
54 if (buf)
55 *buf = '\0';
56
57 return ret;
58}
59
60static char *format_array_alloc(const char *fmt, u32 *array, unsigned array_size)
61{
62 size_t len = format_array(NULL, 0, fmt, array, array_size);
63 char *ret;
64
65 ret = kmalloc(len, GFP_KERNEL);
66 if (ret == NULL)
67 return NULL;
68
69 format_array(ret, len, fmt, array, array_size);
70 return ret;
71}
72
73static ssize_t u32_array_read(struct file *file, char __user *buf, size_t len,
74 loff_t *ppos)
75{
76 struct inode *inode = file->f_path.dentry->d_inode;
77 struct array_data *data = inode->i_private;
78 size_t size;
79
80 if (*ppos == 0) {
81 if (file->private_data) {
82 kfree(file->private_data);
83 file->private_data = NULL;
84 }
85
86 file->private_data = format_array_alloc("%u", data->array, data->elements);
87 }
88
89 size = 0;
90 if (file->private_data)
91 size = strlen(file->private_data);
92
93 return simple_read_from_buffer(buf, len, ppos, file->private_data, size);
94}
95
96static int xen_array_release(struct inode *inode, struct file *file)
97{
98 kfree(file->private_data);
99
100 return 0;
101}
102
103static struct file_operations u32_array_fops = {
104 .owner = THIS_MODULE,
105 .open = u32_array_open,
106 .release= xen_array_release,
107 .read = u32_array_read,
108};
109
110struct dentry *xen_debugfs_create_u32_array(const char *name, mode_t mode,
111 struct dentry *parent,
112 u32 *array, unsigned elements)
113{
114 struct array_data *data = kmalloc(sizeof(*data), GFP_KERNEL);
115
116 if (data == NULL)
117 return NULL;
118
119 data->array = array;
120 data->elements = elements;
121
122 return debugfs_create_file(name, mode, parent, data, &u32_array_fops);
123}
diff --git a/arch/x86/xen/debugfs.h b/arch/x86/xen/debugfs.h
new file mode 100644
index 000000000000..e28132084832
--- /dev/null
+++ b/arch/x86/xen/debugfs.h
@@ -0,0 +1,10 @@
1#ifndef _XEN_DEBUGFS_H
2#define _XEN_DEBUGFS_H
3
4struct dentry * __init xen_init_debugfs(void);
5
6struct dentry *xen_debugfs_create_u32_array(const char *name, mode_t mode,
7 struct dentry *parent,
8 u32 *array, unsigned elements);
9
10#endif /* _XEN_DEBUGFS_H */
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index a4e201b47f64..0013a729b41d 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -30,12 +30,12 @@
30#include <xen/interface/xen.h> 30#include <xen/interface/xen.h>
31#include <xen/interface/physdev.h> 31#include <xen/interface/physdev.h>
32#include <xen/interface/vcpu.h> 32#include <xen/interface/vcpu.h>
33#include <xen/interface/sched.h>
34#include <xen/features.h> 33#include <xen/features.h>
35#include <xen/page.h> 34#include <xen/page.h>
36#include <xen/hvc-console.h> 35#include <xen/hvc-console.h>
37 36
38#include <asm/paravirt.h> 37#include <asm/paravirt.h>
38#include <asm/apic.h>
39#include <asm/page.h> 39#include <asm/page.h>
40#include <asm/xen/hypercall.h> 40#include <asm/xen/hypercall.h>
41#include <asm/xen/hypervisor.h> 41#include <asm/xen/hypervisor.h>
@@ -57,6 +57,9 @@ EXPORT_SYMBOL_GPL(hypercall_page);
57DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); 57DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
58DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info); 58DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
59 59
60enum xen_domain_type xen_domain_type = XEN_NATIVE;
61EXPORT_SYMBOL_GPL(xen_domain_type);
62
60/* 63/*
61 * Identity map, in addition to plain kernel map. This needs to be 64 * Identity map, in addition to plain kernel map. This needs to be
62 * large enough to allocate page table pages to allocate the rest. 65 * large enough to allocate page table pages to allocate the rest.
@@ -110,7 +113,14 @@ struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
110 * 113 *
111 * 0: not available, 1: available 114 * 0: not available, 1: available
112 */ 115 */
113static int have_vcpu_info_placement = 1; 116static int have_vcpu_info_placement =
117#ifdef CONFIG_X86_32
118 1
119#else
120 0
121#endif
122 ;
123
114 124
115static void xen_vcpu_setup(int cpu) 125static void xen_vcpu_setup(int cpu)
116{ 126{
@@ -226,103 +236,68 @@ static unsigned long xen_get_debugreg(int reg)
226 return HYPERVISOR_get_debugreg(reg); 236 return HYPERVISOR_get_debugreg(reg);
227} 237}
228 238
229static unsigned long xen_save_fl(void) 239static void xen_leave_lazy(void)
230{ 240{
231 struct vcpu_info *vcpu; 241 paravirt_leave_lazy(paravirt_get_lazy_mode());
232 unsigned long flags; 242 xen_mc_flush();
233
234 vcpu = x86_read_percpu(xen_vcpu);
235
236 /* flag has opposite sense of mask */
237 flags = !vcpu->evtchn_upcall_mask;
238
239 /* convert to IF type flag
240 -0 -> 0x00000000
241 -1 -> 0xffffffff
242 */
243 return (-flags) & X86_EFLAGS_IF;
244} 243}
245 244
246static void xen_restore_fl(unsigned long flags) 245static unsigned long xen_store_tr(void)
247{ 246{
248 struct vcpu_info *vcpu; 247 return 0;
249
250 /* convert from IF type flag */
251 flags = !(flags & X86_EFLAGS_IF);
252
253 /* There's a one instruction preempt window here. We need to
254 make sure we're don't switch CPUs between getting the vcpu
255 pointer and updating the mask. */
256 preempt_disable();
257 vcpu = x86_read_percpu(xen_vcpu);
258 vcpu->evtchn_upcall_mask = flags;
259 preempt_enable_no_resched();
260
261 /* Doesn't matter if we get preempted here, because any
262 pending event will get dealt with anyway. */
263
264 if (flags == 0) {
265 preempt_check_resched();
266 barrier(); /* unmask then check (avoid races) */
267 if (unlikely(vcpu->evtchn_upcall_pending))
268 force_evtchn_callback();
269 }
270} 248}
271 249
272static void xen_irq_disable(void) 250/*
251 * Set the page permissions for a particular virtual address. If the
252 * address is a vmalloc mapping (or other non-linear mapping), then
253 * find the linear mapping of the page and also set its protections to
254 * match.
255 */
256static void set_aliased_prot(void *v, pgprot_t prot)
273{ 257{
274 /* There's a one instruction preempt window here. We need to 258 int level;
275 make sure we're don't switch CPUs between getting the vcpu 259 pte_t *ptep;
276 pointer and updating the mask. */ 260 pte_t pte;
277 preempt_disable(); 261 unsigned long pfn;
278 x86_read_percpu(xen_vcpu)->evtchn_upcall_mask = 1; 262 struct page *page;
279 preempt_enable_no_resched();
280}
281 263
282static void xen_irq_enable(void) 264 ptep = lookup_address((unsigned long)v, &level);
283{ 265 BUG_ON(ptep == NULL);
284 struct vcpu_info *vcpu;
285 266
286 /* We don't need to worry about being preempted here, since 267 pfn = pte_pfn(*ptep);
287 either a) interrupts are disabled, so no preemption, or b) 268 page = pfn_to_page(pfn);
288 the caller is confused and is trying to re-enable interrupts
289 on an indeterminate processor. */
290 269
291 vcpu = x86_read_percpu(xen_vcpu); 270 pte = pfn_pte(pfn, prot);
292 vcpu->evtchn_upcall_mask = 0;
293 271
294 /* Doesn't matter if we get preempted here, because any 272 if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0))
295 pending event will get dealt with anyway. */ 273 BUG();
296 274
297 barrier(); /* unmask then check (avoid races) */ 275 if (!PageHighMem(page)) {
298 if (unlikely(vcpu->evtchn_upcall_pending)) 276 void *av = __va(PFN_PHYS(pfn));
299 force_evtchn_callback();
300}
301 277
302static void xen_safe_halt(void) 278 if (av != v)
303{ 279 if (HYPERVISOR_update_va_mapping((unsigned long)av, pte, 0))
304 /* Blocking includes an implicit local_irq_enable(). */ 280 BUG();
305 if (HYPERVISOR_sched_op(SCHEDOP_block, NULL) != 0) 281 } else
306 BUG(); 282 kmap_flush_unused();
307} 283}
308 284
309static void xen_halt(void) 285static void xen_alloc_ldt(struct desc_struct *ldt, unsigned entries)
310{ 286{
311 if (irqs_disabled()) 287 const unsigned entries_per_page = PAGE_SIZE / LDT_ENTRY_SIZE;
312 HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL); 288 int i;
313 else
314 xen_safe_halt();
315}
316 289
317static void xen_leave_lazy(void) 290 for(i = 0; i < entries; i += entries_per_page)
318{ 291 set_aliased_prot(ldt + i, PAGE_KERNEL_RO);
319 paravirt_leave_lazy(paravirt_get_lazy_mode());
320 xen_mc_flush();
321} 292}
322 293
323static unsigned long xen_store_tr(void) 294static void xen_free_ldt(struct desc_struct *ldt, unsigned entries)
324{ 295{
325 return 0; 296 const unsigned entries_per_page = PAGE_SIZE / LDT_ENTRY_SIZE;
297 int i;
298
299 for(i = 0; i < entries; i += entries_per_page)
300 set_aliased_prot(ldt + i, PAGE_KERNEL);
326} 301}
327 302
328static void xen_set_ldt(const void *addr, unsigned entries) 303static void xen_set_ldt(const void *addr, unsigned entries)
@@ -425,8 +400,7 @@ static void xen_load_gs_index(unsigned int idx)
425static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum, 400static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum,
426 const void *ptr) 401 const void *ptr)
427{ 402{
428 unsigned long lp = (unsigned long)&dt[entrynum]; 403 xmaddr_t mach_lp = arbitrary_virt_to_machine(&dt[entrynum]);
429 xmaddr_t mach_lp = virt_to_machine(lp);
430 u64 entry = *(u64 *)ptr; 404 u64 entry = *(u64 *)ptr;
431 405
432 preempt_disable(); 406 preempt_disable();
@@ -559,7 +533,7 @@ static void xen_write_gdt_entry(struct desc_struct *dt, int entry,
559} 533}
560 534
561static void xen_load_sp0(struct tss_struct *tss, 535static void xen_load_sp0(struct tss_struct *tss,
562 struct thread_struct *thread) 536 struct thread_struct *thread)
563{ 537{
564 struct multicall_space mcs = xen_mc_entry(0); 538 struct multicall_space mcs = xen_mc_entry(0);
565 MULTI_stack_switch(mcs.mc, __KERNEL_DS, thread->sp0); 539 MULTI_stack_switch(mcs.mc, __KERNEL_DS, thread->sp0);
@@ -580,16 +554,47 @@ static void xen_io_delay(void)
580} 554}
581 555
582#ifdef CONFIG_X86_LOCAL_APIC 556#ifdef CONFIG_X86_LOCAL_APIC
583static u32 xen_apic_read(unsigned long reg) 557static u32 xen_apic_read(u32 reg)
584{ 558{
585 return 0; 559 return 0;
586} 560}
587 561
588static void xen_apic_write(unsigned long reg, u32 val) 562static void xen_apic_write(u32 reg, u32 val)
589{ 563{
590 /* Warn to see if there's any stray references */ 564 /* Warn to see if there's any stray references */
591 WARN_ON(1); 565 WARN_ON(1);
592} 566}
567
568static u64 xen_apic_icr_read(void)
569{
570 return 0;
571}
572
573static void xen_apic_icr_write(u32 low, u32 id)
574{
575 /* Warn to see if there's any stray references */
576 WARN_ON(1);
577}
578
579static void xen_apic_wait_icr_idle(void)
580{
581 return;
582}
583
584static u32 xen_safe_apic_wait_icr_idle(void)
585{
586 return 0;
587}
588
589static struct apic_ops xen_basic_apic_ops = {
590 .read = xen_apic_read,
591 .write = xen_apic_write,
592 .icr_read = xen_apic_icr_read,
593 .icr_write = xen_apic_icr_write,
594 .wait_icr_idle = xen_apic_wait_icr_idle,
595 .safe_wait_icr_idle = xen_safe_apic_wait_icr_idle,
596};
597
593#endif 598#endif
594 599
595static void xen_flush_tlb(void) 600static void xen_flush_tlb(void)
@@ -803,6 +808,19 @@ static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
803 ret = -EFAULT; 808 ret = -EFAULT;
804 break; 809 break;
805#endif 810#endif
811
812 case MSR_STAR:
813 case MSR_CSTAR:
814 case MSR_LSTAR:
815 case MSR_SYSCALL_MASK:
816 case MSR_IA32_SYSENTER_CS:
817 case MSR_IA32_SYSENTER_ESP:
818 case MSR_IA32_SYSENTER_EIP:
819 /* Fast syscall setup is all done in hypercalls, so
820 these are all ignored. Stub them out here to stop
821 Xen console noise. */
822 break;
823
806 default: 824 default:
807 ret = native_write_msr_safe(msr, low, high); 825 ret = native_write_msr_safe(msr, low, high);
808 } 826 }
@@ -812,7 +830,7 @@ static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
812 830
813/* Early in boot, while setting up the initial pagetable, assume 831/* Early in boot, while setting up the initial pagetable, assume
814 everything is pinned. */ 832 everything is pinned. */
815static __init void xen_alloc_pte_init(struct mm_struct *mm, u32 pfn) 833static __init void xen_alloc_pte_init(struct mm_struct *mm, unsigned long pfn)
816{ 834{
817#ifdef CONFIG_FLATMEM 835#ifdef CONFIG_FLATMEM
818 BUG_ON(mem_map); /* should only be used early */ 836 BUG_ON(mem_map); /* should only be used early */
@@ -822,7 +840,7 @@ static __init void xen_alloc_pte_init(struct mm_struct *mm, u32 pfn)
822 840
823/* Early release_pte assumes that all pts are pinned, since there's 841/* Early release_pte assumes that all pts are pinned, since there's
824 only init_mm and anything attached to that is pinned. */ 842 only init_mm and anything attached to that is pinned. */
825static void xen_release_pte_init(u32 pfn) 843static void xen_release_pte_init(unsigned long pfn)
826{ 844{
827 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn))); 845 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
828} 846}
@@ -838,7 +856,7 @@ static void pin_pagetable_pfn(unsigned cmd, unsigned long pfn)
838 856
839/* This needs to make sure the new pte page is pinned iff its being 857/* This needs to make sure the new pte page is pinned iff its being
840 attached to a pinned pagetable. */ 858 attached to a pinned pagetable. */
841static void xen_alloc_ptpage(struct mm_struct *mm, u32 pfn, unsigned level) 859static void xen_alloc_ptpage(struct mm_struct *mm, unsigned long pfn, unsigned level)
842{ 860{
843 struct page *page = pfn_to_page(pfn); 861 struct page *page = pfn_to_page(pfn);
844 862
@@ -846,8 +864,8 @@ static void xen_alloc_ptpage(struct mm_struct *mm, u32 pfn, unsigned level)
846 SetPagePinned(page); 864 SetPagePinned(page);
847 865
848 if (!PageHighMem(page)) { 866 if (!PageHighMem(page)) {
849 make_lowmem_page_readonly(__va(PFN_PHYS(pfn))); 867 make_lowmem_page_readonly(__va(PFN_PHYS((unsigned long)pfn)));
850 if (level == PT_PTE) 868 if (level == PT_PTE && USE_SPLIT_PTLOCKS)
851 pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn); 869 pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn);
852 } else 870 } else
853 /* make sure there are no stray mappings of 871 /* make sure there are no stray mappings of
@@ -856,12 +874,12 @@ static void xen_alloc_ptpage(struct mm_struct *mm, u32 pfn, unsigned level)
856 } 874 }
857} 875}
858 876
859static void xen_alloc_pte(struct mm_struct *mm, u32 pfn) 877static void xen_alloc_pte(struct mm_struct *mm, unsigned long pfn)
860{ 878{
861 xen_alloc_ptpage(mm, pfn, PT_PTE); 879 xen_alloc_ptpage(mm, pfn, PT_PTE);
862} 880}
863 881
864static void xen_alloc_pmd(struct mm_struct *mm, u32 pfn) 882static void xen_alloc_pmd(struct mm_struct *mm, unsigned long pfn)
865{ 883{
866 xen_alloc_ptpage(mm, pfn, PT_PMD); 884 xen_alloc_ptpage(mm, pfn, PT_PMD);
867} 885}
@@ -909,13 +927,13 @@ static void xen_pgd_free(struct mm_struct *mm, pgd_t *pgd)
909} 927}
910 928
911/* This should never happen until we're OK to use struct page */ 929/* This should never happen until we're OK to use struct page */
912static void xen_release_ptpage(u32 pfn, unsigned level) 930static void xen_release_ptpage(unsigned long pfn, unsigned level)
913{ 931{
914 struct page *page = pfn_to_page(pfn); 932 struct page *page = pfn_to_page(pfn);
915 933
916 if (PagePinned(page)) { 934 if (PagePinned(page)) {
917 if (!PageHighMem(page)) { 935 if (!PageHighMem(page)) {
918 if (level == PT_PTE) 936 if (level == PT_PTE && USE_SPLIT_PTLOCKS)
919 pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, pfn); 937 pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, pfn);
920 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn))); 938 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn)));
921 } 939 }
@@ -923,23 +941,23 @@ static void xen_release_ptpage(u32 pfn, unsigned level)
923 } 941 }
924} 942}
925 943
926static void xen_release_pte(u32 pfn) 944static void xen_release_pte(unsigned long pfn)
927{ 945{
928 xen_release_ptpage(pfn, PT_PTE); 946 xen_release_ptpage(pfn, PT_PTE);
929} 947}
930 948
931static void xen_release_pmd(u32 pfn) 949static void xen_release_pmd(unsigned long pfn)
932{ 950{
933 xen_release_ptpage(pfn, PT_PMD); 951 xen_release_ptpage(pfn, PT_PMD);
934} 952}
935 953
936#if PAGETABLE_LEVELS == 4 954#if PAGETABLE_LEVELS == 4
937static void xen_alloc_pud(struct mm_struct *mm, u32 pfn) 955static void xen_alloc_pud(struct mm_struct *mm, unsigned long pfn)
938{ 956{
939 xen_alloc_ptpage(mm, pfn, PT_PUD); 957 xen_alloc_ptpage(mm, pfn, PT_PUD);
940} 958}
941 959
942static void xen_release_pud(u32 pfn) 960static void xen_release_pud(unsigned long pfn)
943{ 961{
944 xen_release_ptpage(pfn, PT_PUD); 962 xen_release_ptpage(pfn, PT_PUD);
945} 963}
@@ -962,6 +980,7 @@ static void *xen_kmap_atomic_pte(struct page *page, enum km_type type)
962} 980}
963#endif 981#endif
964 982
983#ifdef CONFIG_X86_32
965static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte) 984static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
966{ 985{
967 /* If there's an existing pte, then don't allow _PAGE_RW to be set */ 986 /* If there's an existing pte, then don't allow _PAGE_RW to be set */
@@ -980,6 +999,7 @@ static __init void xen_set_pte_init(pte_t *ptep, pte_t pte)
980 999
981 xen_set_pte(ptep, pte); 1000 xen_set_pte(ptep, pte);
982} 1001}
1002#endif
983 1003
984static __init void xen_pagetable_setup_start(pgd_t *base) 1004static __init void xen_pagetable_setup_start(pgd_t *base)
985{ 1005{
@@ -1046,7 +1066,6 @@ void xen_setup_vcpu_info_placement(void)
1046 1066
1047 /* xen_vcpu_setup managed to place the vcpu_info within the 1067 /* xen_vcpu_setup managed to place the vcpu_info within the
1048 percpu area for all cpus, so make use of it */ 1068 percpu area for all cpus, so make use of it */
1049#ifdef CONFIG_X86_32
1050 if (have_vcpu_info_placement) { 1069 if (have_vcpu_info_placement) {
1051 printk(KERN_INFO "Xen: using vcpu_info placement\n"); 1070 printk(KERN_INFO "Xen: using vcpu_info placement\n");
1052 1071
@@ -1056,7 +1075,6 @@ void xen_setup_vcpu_info_placement(void)
1056 pv_irq_ops.irq_enable = xen_irq_enable_direct; 1075 pv_irq_ops.irq_enable = xen_irq_enable_direct;
1057 pv_mmu_ops.read_cr2 = xen_read_cr2_direct; 1076 pv_mmu_ops.read_cr2 = xen_read_cr2_direct;
1058 } 1077 }
1059#endif
1060} 1078}
1061 1079
1062static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf, 1080static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf,
@@ -1077,12 +1095,10 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf,
1077 goto patch_site 1095 goto patch_site
1078 1096
1079 switch (type) { 1097 switch (type) {
1080#ifdef CONFIG_X86_32
1081 SITE(pv_irq_ops, irq_enable); 1098 SITE(pv_irq_ops, irq_enable);
1082 SITE(pv_irq_ops, irq_disable); 1099 SITE(pv_irq_ops, irq_disable);
1083 SITE(pv_irq_ops, save_fl); 1100 SITE(pv_irq_ops, save_fl);
1084 SITE(pv_irq_ops, restore_fl); 1101 SITE(pv_irq_ops, restore_fl);
1085#endif /* CONFIG_X86_32 */
1086#undef SITE 1102#undef SITE
1087 1103
1088 patch_site: 1104 patch_site:
@@ -1220,6 +1236,9 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
1220 .load_gs_index = xen_load_gs_index, 1236 .load_gs_index = xen_load_gs_index,
1221#endif 1237#endif
1222 1238
1239 .alloc_ldt = xen_alloc_ldt,
1240 .free_ldt = xen_free_ldt,
1241
1223 .store_gdt = native_store_gdt, 1242 .store_gdt = native_store_gdt,
1224 .store_idt = native_store_idt, 1243 .store_idt = native_store_idt,
1225 .store_tr = xen_store_tr, 1244 .store_tr = xen_store_tr,
@@ -1241,40 +1260,8 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
1241 }, 1260 },
1242}; 1261};
1243 1262
1244static void __init __xen_init_IRQ(void)
1245{
1246#ifdef CONFIG_X86_64
1247 int i;
1248
1249 /* Create identity vector->irq map */
1250 for(i = 0; i < NR_VECTORS; i++) {
1251 int cpu;
1252
1253 for_each_possible_cpu(cpu)
1254 per_cpu(vector_irq, cpu)[i] = i;
1255 }
1256#endif /* CONFIG_X86_64 */
1257
1258 xen_init_IRQ();
1259}
1260
1261static const struct pv_irq_ops xen_irq_ops __initdata = {
1262 .init_IRQ = __xen_init_IRQ,
1263 .save_fl = xen_save_fl,
1264 .restore_fl = xen_restore_fl,
1265 .irq_disable = xen_irq_disable,
1266 .irq_enable = xen_irq_enable,
1267 .safe_halt = xen_safe_halt,
1268 .halt = xen_halt,
1269#ifdef CONFIG_X86_64
1270 .adjust_exception_frame = xen_adjust_exception_frame,
1271#endif
1272};
1273
1274static const struct pv_apic_ops xen_apic_ops __initdata = { 1263static const struct pv_apic_ops xen_apic_ops __initdata = {
1275#ifdef CONFIG_X86_LOCAL_APIC 1264#ifdef CONFIG_X86_LOCAL_APIC
1276 .apic_write = xen_apic_write,
1277 .apic_read = xen_apic_read,
1278 .setup_boot_clock = paravirt_nop, 1265 .setup_boot_clock = paravirt_nop,
1279 .setup_secondary_clock = paravirt_nop, 1266 .setup_secondary_clock = paravirt_nop,
1280 .startup_ipi_hook = paravirt_nop, 1267 .startup_ipi_hook = paravirt_nop,
@@ -1413,7 +1400,7 @@ static void __init xen_reserve_top(void)
1413 if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0) 1400 if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0)
1414 top = pp.virt_start; 1401 top = pp.virt_start;
1415 1402
1416 reserve_top_address(-top + 2 * PAGE_SIZE); 1403 reserve_top_address(-top);
1417#endif /* CONFIG_X86_32 */ 1404#endif /* CONFIG_X86_32 */
1418} 1405}
1419 1406
@@ -1447,48 +1434,11 @@ static void *m2v(phys_addr_t maddr)
1447 return __ka(m2p(maddr)); 1434 return __ka(m2p(maddr));
1448} 1435}
1449 1436
1450#ifdef CONFIG_X86_64
1451static void walk(pgd_t *pgd, unsigned long addr)
1452{
1453 unsigned l4idx = pgd_index(addr);
1454 unsigned l3idx = pud_index(addr);
1455 unsigned l2idx = pmd_index(addr);
1456 unsigned l1idx = pte_index(addr);
1457 pgd_t l4;
1458 pud_t l3;
1459 pmd_t l2;
1460 pte_t l1;
1461
1462 xen_raw_printk("walk %p, %lx -> %d %d %d %d\n",
1463 pgd, addr, l4idx, l3idx, l2idx, l1idx);
1464
1465 l4 = pgd[l4idx];
1466 xen_raw_printk(" l4: %016lx\n", l4.pgd);
1467 xen_raw_printk(" %016lx\n", pgd_val(l4));
1468
1469 l3 = ((pud_t *)(m2v(l4.pgd)))[l3idx];
1470 xen_raw_printk(" l3: %016lx\n", l3.pud);
1471 xen_raw_printk(" %016lx\n", pud_val(l3));
1472
1473 l2 = ((pmd_t *)(m2v(l3.pud)))[l2idx];
1474 xen_raw_printk(" l2: %016lx\n", l2.pmd);
1475 xen_raw_printk(" %016lx\n", pmd_val(l2));
1476
1477 l1 = ((pte_t *)(m2v(l2.pmd)))[l1idx];
1478 xen_raw_printk(" l1: %016lx\n", l1.pte);
1479 xen_raw_printk(" %016lx\n", pte_val(l1));
1480}
1481#endif
1482
1483static void set_page_prot(void *addr, pgprot_t prot) 1437static void set_page_prot(void *addr, pgprot_t prot)
1484{ 1438{
1485 unsigned long pfn = __pa(addr) >> PAGE_SHIFT; 1439 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
1486 pte_t pte = pfn_pte(pfn, prot); 1440 pte_t pte = pfn_pte(pfn, prot);
1487 1441
1488 xen_raw_printk("addr=%p pfn=%lx mfn=%lx prot=%016llx pte=%016llx\n",
1489 addr, pfn, get_phys_to_machine(pfn),
1490 pgprot_val(prot), pte.pte);
1491
1492 if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0)) 1442 if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
1493 BUG(); 1443 BUG();
1494} 1444}
@@ -1664,6 +1614,8 @@ asmlinkage void __init xen_start_kernel(void)
1664 if (!xen_start_info) 1614 if (!xen_start_info)
1665 return; 1615 return;
1666 1616
1617 xen_domain_type = XEN_PV_DOMAIN;
1618
1667 BUG_ON(memcmp(xen_start_info->magic, "xen-3", 5) != 0); 1619 BUG_ON(memcmp(xen_start_info->magic, "xen-3", 5) != 0);
1668 1620
1669 xen_setup_features(); 1621 xen_setup_features();
@@ -1673,10 +1625,18 @@ asmlinkage void __init xen_start_kernel(void)
1673 pv_init_ops = xen_init_ops; 1625 pv_init_ops = xen_init_ops;
1674 pv_time_ops = xen_time_ops; 1626 pv_time_ops = xen_time_ops;
1675 pv_cpu_ops = xen_cpu_ops; 1627 pv_cpu_ops = xen_cpu_ops;
1676 pv_irq_ops = xen_irq_ops;
1677 pv_apic_ops = xen_apic_ops; 1628 pv_apic_ops = xen_apic_ops;
1678 pv_mmu_ops = xen_mmu_ops; 1629 pv_mmu_ops = xen_mmu_ops;
1679 1630
1631 xen_init_irq_ops();
1632
1633#ifdef CONFIG_X86_LOCAL_APIC
1634 /*
1635 * set up the basic apic ops.
1636 */
1637 apic_ops = &xen_basic_apic_ops;
1638#endif
1639
1680 if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) { 1640 if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) {
1681 pv_mmu_ops.ptep_modify_prot_start = xen_ptep_modify_prot_start; 1641 pv_mmu_ops.ptep_modify_prot_start = xen_ptep_modify_prot_start;
1682 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit; 1642 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit;
@@ -1700,7 +1660,7 @@ asmlinkage void __init xen_start_kernel(void)
1700 1660
1701 /* Prevent unwanted bits from being set in PTEs. */ 1661 /* Prevent unwanted bits from being set in PTEs. */
1702 __supported_pte_mask &= ~_PAGE_GLOBAL; 1662 __supported_pte_mask &= ~_PAGE_GLOBAL;
1703 if (!is_initial_xendomain()) 1663 if (!xen_initial_domain())
1704 __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD); 1664 __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD);
1705 1665
1706 /* Don't do the full vcpu_info placement stuff until we have a 1666 /* Don't do the full vcpu_info placement stuff until we have a
@@ -1735,7 +1695,7 @@ asmlinkage void __init xen_start_kernel(void)
1735 boot_params.hdr.ramdisk_size = xen_start_info->mod_len; 1695 boot_params.hdr.ramdisk_size = xen_start_info->mod_len;
1736 boot_params.hdr.cmd_line_ptr = __pa(xen_start_info->cmd_line); 1696 boot_params.hdr.cmd_line_ptr = __pa(xen_start_info->cmd_line);
1737 1697
1738 if (!is_initial_xendomain()) { 1698 if (!xen_initial_domain()) {
1739 add_preferred_console("xenboot", 0, NULL); 1699 add_preferred_console("xenboot", 0, NULL);
1740 add_preferred_console("tty", 0, NULL); 1700 add_preferred_console("tty", 0, NULL);
1741 add_preferred_console("hvc", 0, NULL); 1701 add_preferred_console("hvc", 0, NULL);
@@ -1743,15 +1703,6 @@ asmlinkage void __init xen_start_kernel(void)
1743 1703
1744 xen_raw_console_write("about to get started...\n"); 1704 xen_raw_console_write("about to get started...\n");
1745 1705
1746#if 0
1747 xen_raw_printk("&boot_params=%p __pa(&boot_params)=%lx __va(__pa(&boot_params))=%lx\n",
1748 &boot_params, __pa_symbol(&boot_params),
1749 __va(__pa_symbol(&boot_params)));
1750
1751 walk(pgd, &boot_params);
1752 walk(pgd, __va(__pa(&boot_params)));
1753#endif
1754
1755 /* Start the world */ 1706 /* Start the world */
1756#ifdef CONFIG_X86_32 1707#ifdef CONFIG_X86_32
1757 i386_start_kernel(); 1708 i386_start_kernel();
diff --git a/arch/x86/xen/irq.c b/arch/x86/xen/irq.c
new file mode 100644
index 000000000000..28b85ab8422e
--- /dev/null
+++ b/arch/x86/xen/irq.c
@@ -0,0 +1,143 @@
1#include <linux/hardirq.h>
2
3#include <xen/interface/xen.h>
4#include <xen/interface/sched.h>
5#include <xen/interface/vcpu.h>
6
7#include <asm/xen/hypercall.h>
8#include <asm/xen/hypervisor.h>
9
10#include "xen-ops.h"
11
12/*
13 * Force a proper event-channel callback from Xen after clearing the
14 * callback mask. We do this in a very simple manner, by making a call
15 * down into Xen. The pending flag will be checked by Xen on return.
16 */
17void xen_force_evtchn_callback(void)
18{
19 (void)HYPERVISOR_xen_version(0, NULL);
20}
21
22static void __init __xen_init_IRQ(void)
23{
24#ifdef CONFIG_X86_64
25 int i;
26
27 /* Create identity vector->irq map */
28 for(i = 0; i < NR_VECTORS; i++) {
29 int cpu;
30
31 for_each_possible_cpu(cpu)
32 per_cpu(vector_irq, cpu)[i] = i;
33 }
34#endif /* CONFIG_X86_64 */
35
36 xen_init_IRQ();
37}
38
39static unsigned long xen_save_fl(void)
40{
41 struct vcpu_info *vcpu;
42 unsigned long flags;
43
44 vcpu = x86_read_percpu(xen_vcpu);
45
46 /* flag has opposite sense of mask */
47 flags = !vcpu->evtchn_upcall_mask;
48
49 /* convert to IF type flag
50 -0 -> 0x00000000
51 -1 -> 0xffffffff
52 */
53 return (-flags) & X86_EFLAGS_IF;
54}
55
56static void xen_restore_fl(unsigned long flags)
57{
58 struct vcpu_info *vcpu;
59
60 /* convert from IF type flag */
61 flags = !(flags & X86_EFLAGS_IF);
62
63 /* There's a one instruction preempt window here. We need to
64 make sure we're don't switch CPUs between getting the vcpu
65 pointer and updating the mask. */
66 preempt_disable();
67 vcpu = x86_read_percpu(xen_vcpu);
68 vcpu->evtchn_upcall_mask = flags;
69 preempt_enable_no_resched();
70
71 /* Doesn't matter if we get preempted here, because any
72 pending event will get dealt with anyway. */
73
74 if (flags == 0) {
75 preempt_check_resched();
76 barrier(); /* unmask then check (avoid races) */
77 if (unlikely(vcpu->evtchn_upcall_pending))
78 xen_force_evtchn_callback();
79 }
80}
81
82static void xen_irq_disable(void)
83{
84 /* There's a one instruction preempt window here. We need to
85 make sure we're don't switch CPUs between getting the vcpu
86 pointer and updating the mask. */
87 preempt_disable();
88 x86_read_percpu(xen_vcpu)->evtchn_upcall_mask = 1;
89 preempt_enable_no_resched();
90}
91
92static void xen_irq_enable(void)
93{
94 struct vcpu_info *vcpu;
95
96 /* We don't need to worry about being preempted here, since
97 either a) interrupts are disabled, so no preemption, or b)
98 the caller is confused and is trying to re-enable interrupts
99 on an indeterminate processor. */
100
101 vcpu = x86_read_percpu(xen_vcpu);
102 vcpu->evtchn_upcall_mask = 0;
103
104 /* Doesn't matter if we get preempted here, because any
105 pending event will get dealt with anyway. */
106
107 barrier(); /* unmask then check (avoid races) */
108 if (unlikely(vcpu->evtchn_upcall_pending))
109 xen_force_evtchn_callback();
110}
111
112static void xen_safe_halt(void)
113{
114 /* Blocking includes an implicit local_irq_enable(). */
115 if (HYPERVISOR_sched_op(SCHEDOP_block, NULL) != 0)
116 BUG();
117}
118
119static void xen_halt(void)
120{
121 if (irqs_disabled())
122 HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
123 else
124 xen_safe_halt();
125}
126
127static const struct pv_irq_ops xen_irq_ops __initdata = {
128 .init_IRQ = __xen_init_IRQ,
129 .save_fl = xen_save_fl,
130 .restore_fl = xen_restore_fl,
131 .irq_disable = xen_irq_disable,
132 .irq_enable = xen_irq_enable,
133 .safe_halt = xen_safe_halt,
134 .halt = xen_halt,
135#ifdef CONFIG_X86_64
136 .adjust_exception_frame = xen_adjust_exception_frame,
137#endif
138};
139
140void __init xen_init_irq_ops()
141{
142 pv_irq_ops = xen_irq_ops;
143}
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index aa37469da696..ae173f6edd8b 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -40,6 +40,7 @@
40 */ 40 */
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/highmem.h> 42#include <linux/highmem.h>
43#include <linux/debugfs.h>
43#include <linux/bug.h> 44#include <linux/bug.h>
44 45
45#include <asm/pgtable.h> 46#include <asm/pgtable.h>
@@ -57,6 +58,61 @@
57 58
58#include "multicalls.h" 59#include "multicalls.h"
59#include "mmu.h" 60#include "mmu.h"
61#include "debugfs.h"
62
63#define MMU_UPDATE_HISTO 30
64
65#ifdef CONFIG_XEN_DEBUG_FS
66
67static struct {
68 u32 pgd_update;
69 u32 pgd_update_pinned;
70 u32 pgd_update_batched;
71
72 u32 pud_update;
73 u32 pud_update_pinned;
74 u32 pud_update_batched;
75
76 u32 pmd_update;
77 u32 pmd_update_pinned;
78 u32 pmd_update_batched;
79
80 u32 pte_update;
81 u32 pte_update_pinned;
82 u32 pte_update_batched;
83
84 u32 mmu_update;
85 u32 mmu_update_extended;
86 u32 mmu_update_histo[MMU_UPDATE_HISTO];
87
88 u32 prot_commit;
89 u32 prot_commit_batched;
90
91 u32 set_pte_at;
92 u32 set_pte_at_batched;
93 u32 set_pte_at_pinned;
94 u32 set_pte_at_current;
95 u32 set_pte_at_kernel;
96} mmu_stats;
97
98static u8 zero_stats;
99
100static inline void check_zero(void)
101{
102 if (unlikely(zero_stats)) {
103 memset(&mmu_stats, 0, sizeof(mmu_stats));
104 zero_stats = 0;
105 }
106}
107
108#define ADD_STATS(elem, val) \
109 do { check_zero(); mmu_stats.elem += (val); } while(0)
110
111#else /* !CONFIG_XEN_DEBUG_FS */
112
113#define ADD_STATS(elem, val) do { (void)(val); } while(0)
114
115#endif /* CONFIG_XEN_DEBUG_FS */
60 116
61/* 117/*
62 * Just beyond the highest usermode address. STACK_TOP_MAX has a 118 * Just beyond the highest usermode address. STACK_TOP_MAX has a
@@ -229,25 +285,35 @@ void make_lowmem_page_readwrite(void *vaddr)
229} 285}
230 286
231 287
232static bool page_pinned(void *ptr) 288static bool xen_page_pinned(void *ptr)
233{ 289{
234 struct page *page = virt_to_page(ptr); 290 struct page *page = virt_to_page(ptr);
235 291
236 return PagePinned(page); 292 return PagePinned(page);
237} 293}
238 294
239static void extend_mmu_update(const struct mmu_update *update) 295static void xen_extend_mmu_update(const struct mmu_update *update)
240{ 296{
241 struct multicall_space mcs; 297 struct multicall_space mcs;
242 struct mmu_update *u; 298 struct mmu_update *u;
243 299
244 mcs = xen_mc_extend_args(__HYPERVISOR_mmu_update, sizeof(*u)); 300 mcs = xen_mc_extend_args(__HYPERVISOR_mmu_update, sizeof(*u));
245 301
246 if (mcs.mc != NULL) 302 if (mcs.mc != NULL) {
303 ADD_STATS(mmu_update_extended, 1);
304 ADD_STATS(mmu_update_histo[mcs.mc->args[1]], -1);
305
247 mcs.mc->args[1]++; 306 mcs.mc->args[1]++;
248 else { 307
308 if (mcs.mc->args[1] < MMU_UPDATE_HISTO)
309 ADD_STATS(mmu_update_histo[mcs.mc->args[1]], 1);
310 else
311 ADD_STATS(mmu_update_histo[0], 1);
312 } else {
313 ADD_STATS(mmu_update, 1);
249 mcs = __xen_mc_entry(sizeof(*u)); 314 mcs = __xen_mc_entry(sizeof(*u));
250 MULTI_mmu_update(mcs.mc, mcs.args, 1, NULL, DOMID_SELF); 315 MULTI_mmu_update(mcs.mc, mcs.args, 1, NULL, DOMID_SELF);
316 ADD_STATS(mmu_update_histo[1], 1);
251 } 317 }
252 318
253 u = mcs.args; 319 u = mcs.args;
@@ -265,7 +331,9 @@ void xen_set_pmd_hyper(pmd_t *ptr, pmd_t val)
265 /* ptr may be ioremapped for 64-bit pagetable setup */ 331 /* ptr may be ioremapped for 64-bit pagetable setup */
266 u.ptr = arbitrary_virt_to_machine(ptr).maddr; 332 u.ptr = arbitrary_virt_to_machine(ptr).maddr;
267 u.val = pmd_val_ma(val); 333 u.val = pmd_val_ma(val);
268 extend_mmu_update(&u); 334 xen_extend_mmu_update(&u);
335
336 ADD_STATS(pmd_update_batched, paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU);
269 337
270 xen_mc_issue(PARAVIRT_LAZY_MMU); 338 xen_mc_issue(PARAVIRT_LAZY_MMU);
271 339
@@ -274,13 +342,17 @@ void xen_set_pmd_hyper(pmd_t *ptr, pmd_t val)
274 342
275void xen_set_pmd(pmd_t *ptr, pmd_t val) 343void xen_set_pmd(pmd_t *ptr, pmd_t val)
276{ 344{
345 ADD_STATS(pmd_update, 1);
346
277 /* If page is not pinned, we can just update the entry 347 /* If page is not pinned, we can just update the entry
278 directly */ 348 directly */
279 if (!page_pinned(ptr)) { 349 if (!xen_page_pinned(ptr)) {
280 *ptr = val; 350 *ptr = val;
281 return; 351 return;
282 } 352 }
283 353
354 ADD_STATS(pmd_update_pinned, 1);
355
284 xen_set_pmd_hyper(ptr, val); 356 xen_set_pmd_hyper(ptr, val);
285} 357}
286 358
@@ -300,12 +372,18 @@ void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
300 if (mm == &init_mm) 372 if (mm == &init_mm)
301 preempt_disable(); 373 preempt_disable();
302 374
375 ADD_STATS(set_pte_at, 1);
376// ADD_STATS(set_pte_at_pinned, xen_page_pinned(ptep));
377 ADD_STATS(set_pte_at_current, mm == current->mm);
378 ADD_STATS(set_pte_at_kernel, mm == &init_mm);
379
303 if (mm == current->mm || mm == &init_mm) { 380 if (mm == current->mm || mm == &init_mm) {
304 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU) { 381 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU) {
305 struct multicall_space mcs; 382 struct multicall_space mcs;
306 mcs = xen_mc_entry(0); 383 mcs = xen_mc_entry(0);
307 384
308 MULTI_update_va_mapping(mcs.mc, addr, pteval, 0); 385 MULTI_update_va_mapping(mcs.mc, addr, pteval, 0);
386 ADD_STATS(set_pte_at_batched, 1);
309 xen_mc_issue(PARAVIRT_LAZY_MMU); 387 xen_mc_issue(PARAVIRT_LAZY_MMU);
310 goto out; 388 goto out;
311 } else 389 } else
@@ -334,7 +412,10 @@ void xen_ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr,
334 412
335 u.ptr = virt_to_machine(ptep).maddr | MMU_PT_UPDATE_PRESERVE_AD; 413 u.ptr = virt_to_machine(ptep).maddr | MMU_PT_UPDATE_PRESERVE_AD;
336 u.val = pte_val_ma(pte); 414 u.val = pte_val_ma(pte);
337 extend_mmu_update(&u); 415 xen_extend_mmu_update(&u);
416
417 ADD_STATS(prot_commit, 1);
418 ADD_STATS(prot_commit_batched, paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU);
338 419
339 xen_mc_issue(PARAVIRT_LAZY_MMU); 420 xen_mc_issue(PARAVIRT_LAZY_MMU);
340} 421}
@@ -400,7 +481,9 @@ void xen_set_pud_hyper(pud_t *ptr, pud_t val)
400 /* ptr may be ioremapped for 64-bit pagetable setup */ 481 /* ptr may be ioremapped for 64-bit pagetable setup */
401 u.ptr = arbitrary_virt_to_machine(ptr).maddr; 482 u.ptr = arbitrary_virt_to_machine(ptr).maddr;
402 u.val = pud_val_ma(val); 483 u.val = pud_val_ma(val);
403 extend_mmu_update(&u); 484 xen_extend_mmu_update(&u);
485
486 ADD_STATS(pud_update_batched, paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU);
404 487
405 xen_mc_issue(PARAVIRT_LAZY_MMU); 488 xen_mc_issue(PARAVIRT_LAZY_MMU);
406 489
@@ -409,18 +492,26 @@ void xen_set_pud_hyper(pud_t *ptr, pud_t val)
409 492
410void xen_set_pud(pud_t *ptr, pud_t val) 493void xen_set_pud(pud_t *ptr, pud_t val)
411{ 494{
495 ADD_STATS(pud_update, 1);
496
412 /* If page is not pinned, we can just update the entry 497 /* If page is not pinned, we can just update the entry
413 directly */ 498 directly */
414 if (!page_pinned(ptr)) { 499 if (!xen_page_pinned(ptr)) {
415 *ptr = val; 500 *ptr = val;
416 return; 501 return;
417 } 502 }
418 503
504 ADD_STATS(pud_update_pinned, 1);
505
419 xen_set_pud_hyper(ptr, val); 506 xen_set_pud_hyper(ptr, val);
420} 507}
421 508
422void xen_set_pte(pte_t *ptep, pte_t pte) 509void xen_set_pte(pte_t *ptep, pte_t pte)
423{ 510{
511 ADD_STATS(pte_update, 1);
512// ADD_STATS(pte_update_pinned, xen_page_pinned(ptep));
513 ADD_STATS(pte_update_batched, paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU);
514
424#ifdef CONFIG_X86_PAE 515#ifdef CONFIG_X86_PAE
425 ptep->pte_high = pte.pte_high; 516 ptep->pte_high = pte.pte_high;
426 smp_wmb(); 517 smp_wmb();
@@ -490,7 +581,7 @@ static void __xen_set_pgd_hyper(pgd_t *ptr, pgd_t val)
490 581
491 u.ptr = virt_to_machine(ptr).maddr; 582 u.ptr = virt_to_machine(ptr).maddr;
492 u.val = pgd_val_ma(val); 583 u.val = pgd_val_ma(val);
493 extend_mmu_update(&u); 584 xen_extend_mmu_update(&u);
494} 585}
495 586
496/* 587/*
@@ -517,17 +608,22 @@ void xen_set_pgd(pgd_t *ptr, pgd_t val)
517{ 608{
518 pgd_t *user_ptr = xen_get_user_pgd(ptr); 609 pgd_t *user_ptr = xen_get_user_pgd(ptr);
519 610
611 ADD_STATS(pgd_update, 1);
612
520 /* If page is not pinned, we can just update the entry 613 /* If page is not pinned, we can just update the entry
521 directly */ 614 directly */
522 if (!page_pinned(ptr)) { 615 if (!xen_page_pinned(ptr)) {
523 *ptr = val; 616 *ptr = val;
524 if (user_ptr) { 617 if (user_ptr) {
525 WARN_ON(page_pinned(user_ptr)); 618 WARN_ON(xen_page_pinned(user_ptr));
526 *user_ptr = val; 619 *user_ptr = val;
527 } 620 }
528 return; 621 return;
529 } 622 }
530 623
624 ADD_STATS(pgd_update_pinned, 1);
625 ADD_STATS(pgd_update_batched, paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU);
626
531 /* If it's pinned, then we can at least batch the kernel and 627 /* If it's pinned, then we can at least batch the kernel and
532 user updates together. */ 628 user updates together. */
533 xen_mc_batch(); 629 xen_mc_batch();
@@ -555,9 +651,12 @@ void xen_set_pgd(pgd_t *ptr, pgd_t val)
555 * For 64-bit, we must skip the Xen hole in the middle of the address 651 * For 64-bit, we must skip the Xen hole in the middle of the address
556 * space, just after the big x86-64 virtual hole. 652 * space, just after the big x86-64 virtual hole.
557 */ 653 */
558static int pgd_walk(pgd_t *pgd, int (*func)(struct page *, enum pt_level), 654static int xen_pgd_walk(struct mm_struct *mm,
559 unsigned long limit) 655 int (*func)(struct mm_struct *mm, struct page *,
656 enum pt_level),
657 unsigned long limit)
560{ 658{
659 pgd_t *pgd = mm->pgd;
561 int flush = 0; 660 int flush = 0;
562 unsigned hole_low, hole_high; 661 unsigned hole_low, hole_high;
563 unsigned pgdidx_limit, pudidx_limit, pmdidx_limit; 662 unsigned pgdidx_limit, pudidx_limit, pmdidx_limit;
@@ -590,8 +689,6 @@ static int pgd_walk(pgd_t *pgd, int (*func)(struct page *, enum pt_level),
590 pmdidx_limit = 0; 689 pmdidx_limit = 0;
591#endif 690#endif
592 691
593 flush |= (*func)(virt_to_page(pgd), PT_PGD);
594
595 for (pgdidx = 0; pgdidx <= pgdidx_limit; pgdidx++) { 692 for (pgdidx = 0; pgdidx <= pgdidx_limit; pgdidx++) {
596 pud_t *pud; 693 pud_t *pud;
597 694
@@ -604,7 +701,7 @@ static int pgd_walk(pgd_t *pgd, int (*func)(struct page *, enum pt_level),
604 pud = pud_offset(&pgd[pgdidx], 0); 701 pud = pud_offset(&pgd[pgdidx], 0);
605 702
606 if (PTRS_PER_PUD > 1) /* not folded */ 703 if (PTRS_PER_PUD > 1) /* not folded */
607 flush |= (*func)(virt_to_page(pud), PT_PUD); 704 flush |= (*func)(mm, virt_to_page(pud), PT_PUD);
608 705
609 for (pudidx = 0; pudidx < PTRS_PER_PUD; pudidx++) { 706 for (pudidx = 0; pudidx < PTRS_PER_PUD; pudidx++) {
610 pmd_t *pmd; 707 pmd_t *pmd;
@@ -619,7 +716,7 @@ static int pgd_walk(pgd_t *pgd, int (*func)(struct page *, enum pt_level),
619 pmd = pmd_offset(&pud[pudidx], 0); 716 pmd = pmd_offset(&pud[pudidx], 0);
620 717
621 if (PTRS_PER_PMD > 1) /* not folded */ 718 if (PTRS_PER_PMD > 1) /* not folded */
622 flush |= (*func)(virt_to_page(pmd), PT_PMD); 719 flush |= (*func)(mm, virt_to_page(pmd), PT_PMD);
623 720
624 for (pmdidx = 0; pmdidx < PTRS_PER_PMD; pmdidx++) { 721 for (pmdidx = 0; pmdidx < PTRS_PER_PMD; pmdidx++) {
625 struct page *pte; 722 struct page *pte;
@@ -633,28 +730,34 @@ static int pgd_walk(pgd_t *pgd, int (*func)(struct page *, enum pt_level),
633 continue; 730 continue;
634 731
635 pte = pmd_page(pmd[pmdidx]); 732 pte = pmd_page(pmd[pmdidx]);
636 flush |= (*func)(pte, PT_PTE); 733 flush |= (*func)(mm, pte, PT_PTE);
637 } 734 }
638 } 735 }
639 } 736 }
737
640out: 738out:
739 /* Do the top level last, so that the callbacks can use it as
740 a cue to do final things like tlb flushes. */
741 flush |= (*func)(mm, virt_to_page(pgd), PT_PGD);
641 742
642 return flush; 743 return flush;
643} 744}
644 745
645static spinlock_t *lock_pte(struct page *page) 746/* If we're using split pte locks, then take the page's lock and
747 return a pointer to it. Otherwise return NULL. */
748static spinlock_t *xen_pte_lock(struct page *page, struct mm_struct *mm)
646{ 749{
647 spinlock_t *ptl = NULL; 750 spinlock_t *ptl = NULL;
648 751
649#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 752#if USE_SPLIT_PTLOCKS
650 ptl = __pte_lockptr(page); 753 ptl = __pte_lockptr(page);
651 spin_lock(ptl); 754 spin_lock_nest_lock(ptl, &mm->page_table_lock);
652#endif 755#endif
653 756
654 return ptl; 757 return ptl;
655} 758}
656 759
657static void do_unlock(void *v) 760static void xen_pte_unlock(void *v)
658{ 761{
659 spinlock_t *ptl = v; 762 spinlock_t *ptl = v;
660 spin_unlock(ptl); 763 spin_unlock(ptl);
@@ -672,7 +775,8 @@ static void xen_do_pin(unsigned level, unsigned long pfn)
672 MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); 775 MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
673} 776}
674 777
675static int pin_page(struct page *page, enum pt_level level) 778static int xen_pin_page(struct mm_struct *mm, struct page *page,
779 enum pt_level level)
676{ 780{
677 unsigned pgfl = TestSetPagePinned(page); 781 unsigned pgfl = TestSetPagePinned(page);
678 int flush; 782 int flush;
@@ -691,21 +795,40 @@ static int pin_page(struct page *page, enum pt_level level)
691 795
692 flush = 0; 796 flush = 0;
693 797
798 /*
799 * We need to hold the pagetable lock between the time
800 * we make the pagetable RO and when we actually pin
801 * it. If we don't, then other users may come in and
802 * attempt to update the pagetable by writing it,
803 * which will fail because the memory is RO but not
804 * pinned, so Xen won't do the trap'n'emulate.
805 *
806 * If we're using split pte locks, we can't hold the
807 * entire pagetable's worth of locks during the
808 * traverse, because we may wrap the preempt count (8
809 * bits). The solution is to mark RO and pin each PTE
810 * page while holding the lock. This means the number
811 * of locks we end up holding is never more than a
812 * batch size (~32 entries, at present).
813 *
814 * If we're not using split pte locks, we needn't pin
815 * the PTE pages independently, because we're
816 * protected by the overall pagetable lock.
817 */
694 ptl = NULL; 818 ptl = NULL;
695 if (level == PT_PTE) 819 if (level == PT_PTE)
696 ptl = lock_pte(page); 820 ptl = xen_pte_lock(page, mm);
697 821
698 MULTI_update_va_mapping(mcs.mc, (unsigned long)pt, 822 MULTI_update_va_mapping(mcs.mc, (unsigned long)pt,
699 pfn_pte(pfn, PAGE_KERNEL_RO), 823 pfn_pte(pfn, PAGE_KERNEL_RO),
700 level == PT_PGD ? UVMF_TLB_FLUSH : 0); 824 level == PT_PGD ? UVMF_TLB_FLUSH : 0);
701 825
702 if (level == PT_PTE) 826 if (ptl) {
703 xen_do_pin(MMUEXT_PIN_L1_TABLE, pfn); 827 xen_do_pin(MMUEXT_PIN_L1_TABLE, pfn);
704 828
705 if (ptl) {
706 /* Queue a deferred unlock for when this batch 829 /* Queue a deferred unlock for when this batch
707 is completed. */ 830 is completed. */
708 xen_mc_callback(do_unlock, ptl); 831 xen_mc_callback(xen_pte_unlock, ptl);
709 } 832 }
710 } 833 }
711 834
@@ -715,11 +838,11 @@ static int pin_page(struct page *page, enum pt_level level)
715/* This is called just after a mm has been created, but it has not 838/* This is called just after a mm has been created, but it has not
716 been used yet. We need to make sure that its pagetable is all 839 been used yet. We need to make sure that its pagetable is all
717 read-only, and can be pinned. */ 840 read-only, and can be pinned. */
718void xen_pgd_pin(pgd_t *pgd) 841static void __xen_pgd_pin(struct mm_struct *mm, pgd_t *pgd)
719{ 842{
720 xen_mc_batch(); 843 xen_mc_batch();
721 844
722 if (pgd_walk(pgd, pin_page, USER_LIMIT)) { 845 if (xen_pgd_walk(mm, xen_pin_page, USER_LIMIT)) {
723 /* re-enable interrupts for kmap_flush_unused */ 846 /* re-enable interrupts for kmap_flush_unused */
724 xen_mc_issue(0); 847 xen_mc_issue(0);
725 kmap_flush_unused(); 848 kmap_flush_unused();
@@ -733,25 +856,35 @@ void xen_pgd_pin(pgd_t *pgd)
733 xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa(pgd))); 856 xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa(pgd)));
734 857
735 if (user_pgd) { 858 if (user_pgd) {
736 pin_page(virt_to_page(user_pgd), PT_PGD); 859 xen_pin_page(mm, virt_to_page(user_pgd), PT_PGD);
737 xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa(user_pgd))); 860 xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa(user_pgd)));
738 } 861 }
739 } 862 }
740#else /* CONFIG_X86_32 */ 863#else /* CONFIG_X86_32 */
741#ifdef CONFIG_X86_PAE 864#ifdef CONFIG_X86_PAE
742 /* Need to make sure unshared kernel PMD is pinnable */ 865 /* Need to make sure unshared kernel PMD is pinnable */
743 pin_page(virt_to_page(pgd_page(pgd[pgd_index(TASK_SIZE)])), PT_PMD); 866 xen_pin_page(mm, virt_to_page(pgd_page(pgd[pgd_index(TASK_SIZE)])),
867 PT_PMD);
744#endif 868#endif
745 xen_do_pin(MMUEXT_PIN_L3_TABLE, PFN_DOWN(__pa(pgd))); 869 xen_do_pin(MMUEXT_PIN_L3_TABLE, PFN_DOWN(__pa(pgd)));
746#endif /* CONFIG_X86_64 */ 870#endif /* CONFIG_X86_64 */
747 xen_mc_issue(0); 871 xen_mc_issue(0);
748} 872}
749 873
874static void xen_pgd_pin(struct mm_struct *mm)
875{
876 __xen_pgd_pin(mm, mm->pgd);
877}
878
750/* 879/*
751 * On save, we need to pin all pagetables to make sure they get their 880 * On save, we need to pin all pagetables to make sure they get their
752 * mfns turned into pfns. Search the list for any unpinned pgds and pin 881 * mfns turned into pfns. Search the list for any unpinned pgds and pin
753 * them (unpinned pgds are not currently in use, probably because the 882 * them (unpinned pgds are not currently in use, probably because the
754 * process is under construction or destruction). 883 * process is under construction or destruction).
884 *
885 * Expected to be called in stop_machine() ("equivalent to taking
886 * every spinlock in the system"), so the locking doesn't really
887 * matter all that much.
755 */ 888 */
756void xen_mm_pin_all(void) 889void xen_mm_pin_all(void)
757{ 890{
@@ -762,7 +895,7 @@ void xen_mm_pin_all(void)
762 895
763 list_for_each_entry(page, &pgd_list, lru) { 896 list_for_each_entry(page, &pgd_list, lru) {
764 if (!PagePinned(page)) { 897 if (!PagePinned(page)) {
765 xen_pgd_pin((pgd_t *)page_address(page)); 898 __xen_pgd_pin(&init_mm, (pgd_t *)page_address(page));
766 SetPageSavePinned(page); 899 SetPageSavePinned(page);
767 } 900 }
768 } 901 }
@@ -775,7 +908,8 @@ void xen_mm_pin_all(void)
775 * that's before we have page structures to store the bits. So do all 908 * that's before we have page structures to store the bits. So do all
776 * the book-keeping now. 909 * the book-keeping now.
777 */ 910 */
778static __init int mark_pinned(struct page *page, enum pt_level level) 911static __init int xen_mark_pinned(struct mm_struct *mm, struct page *page,
912 enum pt_level level)
779{ 913{
780 SetPagePinned(page); 914 SetPagePinned(page);
781 return 0; 915 return 0;
@@ -783,10 +917,11 @@ static __init int mark_pinned(struct page *page, enum pt_level level)
783 917
784void __init xen_mark_init_mm_pinned(void) 918void __init xen_mark_init_mm_pinned(void)
785{ 919{
786 pgd_walk(init_mm.pgd, mark_pinned, FIXADDR_TOP); 920 xen_pgd_walk(&init_mm, xen_mark_pinned, FIXADDR_TOP);
787} 921}
788 922
789static int unpin_page(struct page *page, enum pt_level level) 923static int xen_unpin_page(struct mm_struct *mm, struct page *page,
924 enum pt_level level)
790{ 925{
791 unsigned pgfl = TestClearPagePinned(page); 926 unsigned pgfl = TestClearPagePinned(page);
792 927
@@ -796,10 +931,18 @@ static int unpin_page(struct page *page, enum pt_level level)
796 spinlock_t *ptl = NULL; 931 spinlock_t *ptl = NULL;
797 struct multicall_space mcs; 932 struct multicall_space mcs;
798 933
934 /*
935 * Do the converse to pin_page. If we're using split
936 * pte locks, we must be holding the lock for while
937 * the pte page is unpinned but still RO to prevent
938 * concurrent updates from seeing it in this
939 * partially-pinned state.
940 */
799 if (level == PT_PTE) { 941 if (level == PT_PTE) {
800 ptl = lock_pte(page); 942 ptl = xen_pte_lock(page, mm);
801 943
802 xen_do_pin(MMUEXT_UNPIN_TABLE, pfn); 944 if (ptl)
945 xen_do_pin(MMUEXT_UNPIN_TABLE, pfn);
803 } 946 }
804 947
805 mcs = __xen_mc_entry(0); 948 mcs = __xen_mc_entry(0);
@@ -810,7 +953,7 @@ static int unpin_page(struct page *page, enum pt_level level)
810 953
811 if (ptl) { 954 if (ptl) {
812 /* unlock when batch completed */ 955 /* unlock when batch completed */
813 xen_mc_callback(do_unlock, ptl); 956 xen_mc_callback(xen_pte_unlock, ptl);
814 } 957 }
815 } 958 }
816 959
@@ -818,7 +961,7 @@ static int unpin_page(struct page *page, enum pt_level level)
818} 961}
819 962
820/* Release a pagetables pages back as normal RW */ 963/* Release a pagetables pages back as normal RW */
821static void xen_pgd_unpin(pgd_t *pgd) 964static void __xen_pgd_unpin(struct mm_struct *mm, pgd_t *pgd)
822{ 965{
823 xen_mc_batch(); 966 xen_mc_batch();
824 967
@@ -830,21 +973,27 @@ static void xen_pgd_unpin(pgd_t *pgd)
830 973
831 if (user_pgd) { 974 if (user_pgd) {
832 xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(user_pgd))); 975 xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(user_pgd)));
833 unpin_page(virt_to_page(user_pgd), PT_PGD); 976 xen_unpin_page(mm, virt_to_page(user_pgd), PT_PGD);
834 } 977 }
835 } 978 }
836#endif 979#endif
837 980
838#ifdef CONFIG_X86_PAE 981#ifdef CONFIG_X86_PAE
839 /* Need to make sure unshared kernel PMD is unpinned */ 982 /* Need to make sure unshared kernel PMD is unpinned */
840 pin_page(virt_to_page(pgd_page(pgd[pgd_index(TASK_SIZE)])), PT_PMD); 983 xen_unpin_page(mm, virt_to_page(pgd_page(pgd[pgd_index(TASK_SIZE)])),
984 PT_PMD);
841#endif 985#endif
842 986
843 pgd_walk(pgd, unpin_page, USER_LIMIT); 987 xen_pgd_walk(mm, xen_unpin_page, USER_LIMIT);
844 988
845 xen_mc_issue(0); 989 xen_mc_issue(0);
846} 990}
847 991
992static void xen_pgd_unpin(struct mm_struct *mm)
993{
994 __xen_pgd_unpin(mm, mm->pgd);
995}
996
848/* 997/*
849 * On resume, undo any pinning done at save, so that the rest of the 998 * On resume, undo any pinning done at save, so that the rest of the
850 * kernel doesn't see any unexpected pinned pagetables. 999 * kernel doesn't see any unexpected pinned pagetables.
@@ -859,7 +1008,7 @@ void xen_mm_unpin_all(void)
859 list_for_each_entry(page, &pgd_list, lru) { 1008 list_for_each_entry(page, &pgd_list, lru) {
860 if (PageSavePinned(page)) { 1009 if (PageSavePinned(page)) {
861 BUG_ON(!PagePinned(page)); 1010 BUG_ON(!PagePinned(page));
862 xen_pgd_unpin((pgd_t *)page_address(page)); 1011 __xen_pgd_unpin(&init_mm, (pgd_t *)page_address(page));
863 ClearPageSavePinned(page); 1012 ClearPageSavePinned(page);
864 } 1013 }
865 } 1014 }
@@ -870,14 +1019,14 @@ void xen_mm_unpin_all(void)
870void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next) 1019void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next)
871{ 1020{
872 spin_lock(&next->page_table_lock); 1021 spin_lock(&next->page_table_lock);
873 xen_pgd_pin(next->pgd); 1022 xen_pgd_pin(next);
874 spin_unlock(&next->page_table_lock); 1023 spin_unlock(&next->page_table_lock);
875} 1024}
876 1025
877void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) 1026void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
878{ 1027{
879 spin_lock(&mm->page_table_lock); 1028 spin_lock(&mm->page_table_lock);
880 xen_pgd_pin(mm->pgd); 1029 xen_pgd_pin(mm);
881 spin_unlock(&mm->page_table_lock); 1030 spin_unlock(&mm->page_table_lock);
882} 1031}
883 1032
@@ -907,7 +1056,7 @@ static void drop_other_mm_ref(void *info)
907 } 1056 }
908} 1057}
909 1058
910static void drop_mm_ref(struct mm_struct *mm) 1059static void xen_drop_mm_ref(struct mm_struct *mm)
911{ 1060{
912 cpumask_t mask; 1061 cpumask_t mask;
913 unsigned cpu; 1062 unsigned cpu;
@@ -937,7 +1086,7 @@ static void drop_mm_ref(struct mm_struct *mm)
937 smp_call_function_mask(mask, drop_other_mm_ref, mm, 1); 1086 smp_call_function_mask(mask, drop_other_mm_ref, mm, 1);
938} 1087}
939#else 1088#else
940static void drop_mm_ref(struct mm_struct *mm) 1089static void xen_drop_mm_ref(struct mm_struct *mm)
941{ 1090{
942 if (current->active_mm == mm) 1091 if (current->active_mm == mm)
943 load_cr3(swapper_pg_dir); 1092 load_cr3(swapper_pg_dir);
@@ -961,14 +1110,77 @@ static void drop_mm_ref(struct mm_struct *mm)
961void xen_exit_mmap(struct mm_struct *mm) 1110void xen_exit_mmap(struct mm_struct *mm)
962{ 1111{
963 get_cpu(); /* make sure we don't move around */ 1112 get_cpu(); /* make sure we don't move around */
964 drop_mm_ref(mm); 1113 xen_drop_mm_ref(mm);
965 put_cpu(); 1114 put_cpu();
966 1115
967 spin_lock(&mm->page_table_lock); 1116 spin_lock(&mm->page_table_lock);
968 1117
969 /* pgd may not be pinned in the error exit path of execve */ 1118 /* pgd may not be pinned in the error exit path of execve */
970 if (page_pinned(mm->pgd)) 1119 if (xen_page_pinned(mm->pgd))
971 xen_pgd_unpin(mm->pgd); 1120 xen_pgd_unpin(mm);
972 1121
973 spin_unlock(&mm->page_table_lock); 1122 spin_unlock(&mm->page_table_lock);
974} 1123}
1124
1125#ifdef CONFIG_XEN_DEBUG_FS
1126
1127static struct dentry *d_mmu_debug;
1128
1129static int __init xen_mmu_debugfs(void)
1130{
1131 struct dentry *d_xen = xen_init_debugfs();
1132
1133 if (d_xen == NULL)
1134 return -ENOMEM;
1135
1136 d_mmu_debug = debugfs_create_dir("mmu", d_xen);
1137
1138 debugfs_create_u8("zero_stats", 0644, d_mmu_debug, &zero_stats);
1139
1140 debugfs_create_u32("pgd_update", 0444, d_mmu_debug, &mmu_stats.pgd_update);
1141 debugfs_create_u32("pgd_update_pinned", 0444, d_mmu_debug,
1142 &mmu_stats.pgd_update_pinned);
1143 debugfs_create_u32("pgd_update_batched", 0444, d_mmu_debug,
1144 &mmu_stats.pgd_update_pinned);
1145
1146 debugfs_create_u32("pud_update", 0444, d_mmu_debug, &mmu_stats.pud_update);
1147 debugfs_create_u32("pud_update_pinned", 0444, d_mmu_debug,
1148 &mmu_stats.pud_update_pinned);
1149 debugfs_create_u32("pud_update_batched", 0444, d_mmu_debug,
1150 &mmu_stats.pud_update_pinned);
1151
1152 debugfs_create_u32("pmd_update", 0444, d_mmu_debug, &mmu_stats.pmd_update);
1153 debugfs_create_u32("pmd_update_pinned", 0444, d_mmu_debug,
1154 &mmu_stats.pmd_update_pinned);
1155 debugfs_create_u32("pmd_update_batched", 0444, d_mmu_debug,
1156 &mmu_stats.pmd_update_pinned);
1157
1158 debugfs_create_u32("pte_update", 0444, d_mmu_debug, &mmu_stats.pte_update);
1159// debugfs_create_u32("pte_update_pinned", 0444, d_mmu_debug,
1160// &mmu_stats.pte_update_pinned);
1161 debugfs_create_u32("pte_update_batched", 0444, d_mmu_debug,
1162 &mmu_stats.pte_update_pinned);
1163
1164 debugfs_create_u32("mmu_update", 0444, d_mmu_debug, &mmu_stats.mmu_update);
1165 debugfs_create_u32("mmu_update_extended", 0444, d_mmu_debug,
1166 &mmu_stats.mmu_update_extended);
1167 xen_debugfs_create_u32_array("mmu_update_histo", 0444, d_mmu_debug,
1168 mmu_stats.mmu_update_histo, 20);
1169
1170 debugfs_create_u32("set_pte_at", 0444, d_mmu_debug, &mmu_stats.set_pte_at);
1171 debugfs_create_u32("set_pte_at_batched", 0444, d_mmu_debug,
1172 &mmu_stats.set_pte_at_batched);
1173 debugfs_create_u32("set_pte_at_current", 0444, d_mmu_debug,
1174 &mmu_stats.set_pte_at_current);
1175 debugfs_create_u32("set_pte_at_kernel", 0444, d_mmu_debug,
1176 &mmu_stats.set_pte_at_kernel);
1177
1178 debugfs_create_u32("prot_commit", 0444, d_mmu_debug, &mmu_stats.prot_commit);
1179 debugfs_create_u32("prot_commit_batched", 0444, d_mmu_debug,
1180 &mmu_stats.prot_commit_batched);
1181
1182 return 0;
1183}
1184fs_initcall(xen_mmu_debugfs);
1185
1186#endif /* CONFIG_XEN_DEBUG_FS */
diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
index 0f59bd03f9e3..98d71659da5a 100644
--- a/arch/x86/xen/mmu.h
+++ b/arch/x86/xen/mmu.h
@@ -18,9 +18,6 @@ void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next);
18void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm); 18void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm);
19void xen_exit_mmap(struct mm_struct *mm); 19void xen_exit_mmap(struct mm_struct *mm);
20 20
21void xen_pgd_pin(pgd_t *pgd);
22//void xen_pgd_unpin(pgd_t *pgd);
23
24pteval_t xen_pte_val(pte_t); 21pteval_t xen_pte_val(pte_t);
25pmdval_t xen_pmd_val(pmd_t); 22pmdval_t xen_pmd_val(pmd_t);
26pgdval_t xen_pgd_val(pgd_t); 23pgdval_t xen_pgd_val(pgd_t);
diff --git a/arch/x86/xen/multicalls.c b/arch/x86/xen/multicalls.c
index 9efd1c6c9776..8ea8a0d0b0de 100644
--- a/arch/x86/xen/multicalls.c
+++ b/arch/x86/xen/multicalls.c
@@ -21,16 +21,20 @@
21 */ 21 */
22#include <linux/percpu.h> 22#include <linux/percpu.h>
23#include <linux/hardirq.h> 23#include <linux/hardirq.h>
24#include <linux/debugfs.h>
24 25
25#include <asm/xen/hypercall.h> 26#include <asm/xen/hypercall.h>
26 27
27#include "multicalls.h" 28#include "multicalls.h"
29#include "debugfs.h"
30
31#define MC_BATCH 32
28 32
29#define MC_DEBUG 1 33#define MC_DEBUG 1
30 34
31#define MC_BATCH 32
32#define MC_ARGS (MC_BATCH * 16) 35#define MC_ARGS (MC_BATCH * 16)
33 36
37
34struct mc_buffer { 38struct mc_buffer {
35 struct multicall_entry entries[MC_BATCH]; 39 struct multicall_entry entries[MC_BATCH];
36#if MC_DEBUG 40#if MC_DEBUG
@@ -47,6 +51,76 @@ struct mc_buffer {
47static DEFINE_PER_CPU(struct mc_buffer, mc_buffer); 51static DEFINE_PER_CPU(struct mc_buffer, mc_buffer);
48DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags); 52DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags);
49 53
54/* flush reasons 0- slots, 1- args, 2- callbacks */
55enum flush_reasons
56{
57 FL_SLOTS,
58 FL_ARGS,
59 FL_CALLBACKS,
60
61 FL_N_REASONS
62};
63
64#ifdef CONFIG_XEN_DEBUG_FS
65#define NHYPERCALLS 40 /* not really */
66
67static struct {
68 unsigned histo[MC_BATCH+1];
69
70 unsigned issued;
71 unsigned arg_total;
72 unsigned hypercalls;
73 unsigned histo_hypercalls[NHYPERCALLS];
74
75 unsigned flush[FL_N_REASONS];
76} mc_stats;
77
78static u8 zero_stats;
79
80static inline void check_zero(void)
81{
82 if (unlikely(zero_stats)) {
83 memset(&mc_stats, 0, sizeof(mc_stats));
84 zero_stats = 0;
85 }
86}
87
88static void mc_add_stats(const struct mc_buffer *mc)
89{
90 int i;
91
92 check_zero();
93
94 mc_stats.issued++;
95 mc_stats.hypercalls += mc->mcidx;
96 mc_stats.arg_total += mc->argidx;
97
98 mc_stats.histo[mc->mcidx]++;
99 for(i = 0; i < mc->mcidx; i++) {
100 unsigned op = mc->entries[i].op;
101 if (op < NHYPERCALLS)
102 mc_stats.histo_hypercalls[op]++;
103 }
104}
105
106static void mc_stats_flush(enum flush_reasons idx)
107{
108 check_zero();
109
110 mc_stats.flush[idx]++;
111}
112
113#else /* !CONFIG_XEN_DEBUG_FS */
114
115static inline void mc_add_stats(const struct mc_buffer *mc)
116{
117}
118
119static inline void mc_stats_flush(enum flush_reasons idx)
120{
121}
122#endif /* CONFIG_XEN_DEBUG_FS */
123
50void xen_mc_flush(void) 124void xen_mc_flush(void)
51{ 125{
52 struct mc_buffer *b = &__get_cpu_var(mc_buffer); 126 struct mc_buffer *b = &__get_cpu_var(mc_buffer);
@@ -60,6 +134,8 @@ void xen_mc_flush(void)
60 something in the middle */ 134 something in the middle */
61 local_irq_save(flags); 135 local_irq_save(flags);
62 136
137 mc_add_stats(b);
138
63 if (b->mcidx) { 139 if (b->mcidx) {
64#if MC_DEBUG 140#if MC_DEBUG
65 memcpy(b->debug, b->entries, 141 memcpy(b->debug, b->entries,
@@ -115,6 +191,7 @@ struct multicall_space __xen_mc_entry(size_t args)
115 191
116 if (b->mcidx == MC_BATCH || 192 if (b->mcidx == MC_BATCH ||
117 (argidx + args) > MC_ARGS) { 193 (argidx + args) > MC_ARGS) {
194 mc_stats_flush(b->mcidx == MC_BATCH ? FL_SLOTS : FL_ARGS);
118 xen_mc_flush(); 195 xen_mc_flush();
119 argidx = roundup(b->argidx, sizeof(u64)); 196 argidx = roundup(b->argidx, sizeof(u64));
120 } 197 }
@@ -158,10 +235,44 @@ void xen_mc_callback(void (*fn)(void *), void *data)
158 struct mc_buffer *b = &__get_cpu_var(mc_buffer); 235 struct mc_buffer *b = &__get_cpu_var(mc_buffer);
159 struct callback *cb; 236 struct callback *cb;
160 237
161 if (b->cbidx == MC_BATCH) 238 if (b->cbidx == MC_BATCH) {
239 mc_stats_flush(FL_CALLBACKS);
162 xen_mc_flush(); 240 xen_mc_flush();
241 }
163 242
164 cb = &b->callbacks[b->cbidx++]; 243 cb = &b->callbacks[b->cbidx++];
165 cb->fn = fn; 244 cb->fn = fn;
166 cb->data = data; 245 cb->data = data;
167} 246}
247
248#ifdef CONFIG_XEN_DEBUG_FS
249
250static struct dentry *d_mc_debug;
251
252static int __init xen_mc_debugfs(void)
253{
254 struct dentry *d_xen = xen_init_debugfs();
255
256 if (d_xen == NULL)
257 return -ENOMEM;
258
259 d_mc_debug = debugfs_create_dir("multicalls", d_xen);
260
261 debugfs_create_u8("zero_stats", 0644, d_mc_debug, &zero_stats);
262
263 debugfs_create_u32("batches", 0444, d_mc_debug, &mc_stats.issued);
264 debugfs_create_u32("hypercalls", 0444, d_mc_debug, &mc_stats.hypercalls);
265 debugfs_create_u32("arg_total", 0444, d_mc_debug, &mc_stats.arg_total);
266
267 xen_debugfs_create_u32_array("batch_histo", 0444, d_mc_debug,
268 mc_stats.histo, MC_BATCH);
269 xen_debugfs_create_u32_array("hypercall_histo", 0444, d_mc_debug,
270 mc_stats.histo_hypercalls, NHYPERCALLS);
271 xen_debugfs_create_u32_array("flush_reasons", 0444, d_mc_debug,
272 mc_stats.flush, FL_N_REASONS);
273
274 return 0;
275}
276fs_initcall(xen_mc_debugfs);
277
278#endif /* CONFIG_XEN_DEBUG_FS */
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index d8faf79a0a1d..d77da613b1d2 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -11,11 +11,8 @@
11 * useful topology information for the kernel to make use of. As a 11 * useful topology information for the kernel to make use of. As a
12 * result, all CPUs are treated as if they're single-core and 12 * result, all CPUs are treated as if they're single-core and
13 * single-threaded. 13 * single-threaded.
14 *
15 * This does not handle HOTPLUG_CPU yet.
16 */ 14 */
17#include <linux/sched.h> 15#include <linux/sched.h>
18#include <linux/kernel_stat.h>
19#include <linux/err.h> 16#include <linux/err.h>
20#include <linux/smp.h> 17#include <linux/smp.h>
21 18
@@ -36,8 +33,6 @@
36#include "xen-ops.h" 33#include "xen-ops.h"
37#include "mmu.h" 34#include "mmu.h"
38 35
39static void __cpuinit xen_init_lock_cpu(int cpu);
40
41cpumask_t xen_cpu_initialized_map; 36cpumask_t xen_cpu_initialized_map;
42 37
43static DEFINE_PER_CPU(int, resched_irq); 38static DEFINE_PER_CPU(int, resched_irq);
@@ -64,11 +59,12 @@ static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id)
64 return IRQ_HANDLED; 59 return IRQ_HANDLED;
65} 60}
66 61
67static __cpuinit void cpu_bringup_and_idle(void) 62static __cpuinit void cpu_bringup(void)
68{ 63{
69 int cpu = smp_processor_id(); 64 int cpu = smp_processor_id();
70 65
71 cpu_init(); 66 cpu_init();
67 touch_softlockup_watchdog();
72 preempt_disable(); 68 preempt_disable();
73 69
74 xen_enable_sysenter(); 70 xen_enable_sysenter();
@@ -89,6 +85,11 @@ static __cpuinit void cpu_bringup_and_idle(void)
89 local_irq_enable(); 85 local_irq_enable();
90 86
91 wmb(); /* make sure everything is out */ 87 wmb(); /* make sure everything is out */
88}
89
90static __cpuinit void cpu_bringup_and_idle(void)
91{
92 cpu_bringup();
92 cpu_idle(); 93 cpu_idle();
93} 94}
94 95
@@ -212,8 +213,6 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
212 213
213 cpu_set(cpu, cpu_present_map); 214 cpu_set(cpu, cpu_present_map);
214 } 215 }
215
216 //init_xenbus_allowed_cpumask();
217} 216}
218 217
219static __cpuinit int 218static __cpuinit int
@@ -281,12 +280,6 @@ static int __cpuinit xen_cpu_up(unsigned int cpu)
281 struct task_struct *idle = idle_task(cpu); 280 struct task_struct *idle = idle_task(cpu);
282 int rc; 281 int rc;
283 282
284#if 0
285 rc = cpu_up_check(cpu);
286 if (rc)
287 return rc;
288#endif
289
290#ifdef CONFIG_X86_64 283#ifdef CONFIG_X86_64
291 /* Allocate node local memory for AP pdas */ 284 /* Allocate node local memory for AP pdas */
292 WARN_ON(cpu == 0); 285 WARN_ON(cpu == 0);
@@ -339,6 +332,60 @@ static void xen_smp_cpus_done(unsigned int max_cpus)
339{ 332{
340} 333}
341 334
335#ifdef CONFIG_HOTPLUG_CPU
336static int xen_cpu_disable(void)
337{
338 unsigned int cpu = smp_processor_id();
339 if (cpu == 0)
340 return -EBUSY;
341
342 cpu_disable_common();
343
344 load_cr3(swapper_pg_dir);
345 return 0;
346}
347
348static void xen_cpu_die(unsigned int cpu)
349{
350 while (HYPERVISOR_vcpu_op(VCPUOP_is_up, cpu, NULL)) {
351 current->state = TASK_UNINTERRUPTIBLE;
352 schedule_timeout(HZ/10);
353 }
354 unbind_from_irqhandler(per_cpu(resched_irq, cpu), NULL);
355 unbind_from_irqhandler(per_cpu(callfunc_irq, cpu), NULL);
356 unbind_from_irqhandler(per_cpu(debug_irq, cpu), NULL);
357 unbind_from_irqhandler(per_cpu(callfuncsingle_irq, cpu), NULL);
358 xen_uninit_lock_cpu(cpu);
359 xen_teardown_timer(cpu);
360
361 if (num_online_cpus() == 1)
362 alternatives_smp_switch(0);
363}
364
365static void xen_play_dead(void)
366{
367 play_dead_common();
368 HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
369 cpu_bringup();
370}
371
372#else /* !CONFIG_HOTPLUG_CPU */
373static int xen_cpu_disable(void)
374{
375 return -ENOSYS;
376}
377
378static void xen_cpu_die(unsigned int cpu)
379{
380 BUG();
381}
382
383static void xen_play_dead(void)
384{
385 BUG();
386}
387
388#endif
342static void stop_self(void *v) 389static void stop_self(void *v)
343{ 390{
344 int cpu = smp_processor_id(); 391 int cpu = smp_processor_id();
@@ -419,176 +466,16 @@ static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id)
419 return IRQ_HANDLED; 466 return IRQ_HANDLED;
420} 467}
421 468
422struct xen_spinlock {
423 unsigned char lock; /* 0 -> free; 1 -> locked */
424 unsigned short spinners; /* count of waiting cpus */
425};
426
427static int xen_spin_is_locked(struct raw_spinlock *lock)
428{
429 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
430
431 return xl->lock != 0;
432}
433
434static int xen_spin_is_contended(struct raw_spinlock *lock)
435{
436 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
437
438 /* Not strictly true; this is only the count of contended
439 lock-takers entering the slow path. */
440 return xl->spinners != 0;
441}
442
443static int xen_spin_trylock(struct raw_spinlock *lock)
444{
445 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
446 u8 old = 1;
447
448 asm("xchgb %b0,%1"
449 : "+q" (old), "+m" (xl->lock) : : "memory");
450
451 return old == 0;
452}
453
454static DEFINE_PER_CPU(int, lock_kicker_irq) = -1;
455static DEFINE_PER_CPU(struct xen_spinlock *, lock_spinners);
456
457static inline void spinning_lock(struct xen_spinlock *xl)
458{
459 __get_cpu_var(lock_spinners) = xl;
460 wmb(); /* set lock of interest before count */
461 asm(LOCK_PREFIX " incw %0"
462 : "+m" (xl->spinners) : : "memory");
463}
464
465static inline void unspinning_lock(struct xen_spinlock *xl)
466{
467 asm(LOCK_PREFIX " decw %0"
468 : "+m" (xl->spinners) : : "memory");
469 wmb(); /* decrement count before clearing lock */
470 __get_cpu_var(lock_spinners) = NULL;
471}
472
473static noinline int xen_spin_lock_slow(struct raw_spinlock *lock)
474{
475 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
476 int irq = __get_cpu_var(lock_kicker_irq);
477 int ret;
478
479 /* If kicker interrupts not initialized yet, just spin */
480 if (irq == -1)
481 return 0;
482
483 /* announce we're spinning */
484 spinning_lock(xl);
485
486 /* clear pending */
487 xen_clear_irq_pending(irq);
488
489 /* check again make sure it didn't become free while
490 we weren't looking */
491 ret = xen_spin_trylock(lock);
492 if (ret)
493 goto out;
494
495 /* block until irq becomes pending */
496 xen_poll_irq(irq);
497 kstat_this_cpu.irqs[irq]++;
498
499out:
500 unspinning_lock(xl);
501 return ret;
502}
503
504static void xen_spin_lock(struct raw_spinlock *lock)
505{
506 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
507 int timeout;
508 u8 oldval;
509
510 do {
511 timeout = 1 << 10;
512
513 asm("1: xchgb %1,%0\n"
514 " testb %1,%1\n"
515 " jz 3f\n"
516 "2: rep;nop\n"
517 " cmpb $0,%0\n"
518 " je 1b\n"
519 " dec %2\n"
520 " jnz 2b\n"
521 "3:\n"
522 : "+m" (xl->lock), "=q" (oldval), "+r" (timeout)
523 : "1" (1)
524 : "memory");
525
526 } while (unlikely(oldval != 0 && !xen_spin_lock_slow(lock)));
527}
528
529static noinline void xen_spin_unlock_slow(struct xen_spinlock *xl)
530{
531 int cpu;
532
533 for_each_online_cpu(cpu) {
534 /* XXX should mix up next cpu selection */
535 if (per_cpu(lock_spinners, cpu) == xl) {
536 xen_send_IPI_one(cpu, XEN_SPIN_UNLOCK_VECTOR);
537 break;
538 }
539 }
540}
541
542static void xen_spin_unlock(struct raw_spinlock *lock)
543{
544 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
545
546 smp_wmb(); /* make sure no writes get moved after unlock */
547 xl->lock = 0; /* release lock */
548
549 /* make sure unlock happens before kick */
550 barrier();
551
552 if (unlikely(xl->spinners))
553 xen_spin_unlock_slow(xl);
554}
555
556static __cpuinit void xen_init_lock_cpu(int cpu)
557{
558 int irq;
559 const char *name;
560
561 name = kasprintf(GFP_KERNEL, "spinlock%d", cpu);
562 irq = bind_ipi_to_irqhandler(XEN_SPIN_UNLOCK_VECTOR,
563 cpu,
564 xen_reschedule_interrupt,
565 IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
566 name,
567 NULL);
568
569 if (irq >= 0) {
570 disable_irq(irq); /* make sure it's never delivered */
571 per_cpu(lock_kicker_irq, cpu) = irq;
572 }
573
574 printk("cpu %d spinlock event irq %d\n", cpu, irq);
575}
576
577static void __init xen_init_spinlocks(void)
578{
579 pv_lock_ops.spin_is_locked = xen_spin_is_locked;
580 pv_lock_ops.spin_is_contended = xen_spin_is_contended;
581 pv_lock_ops.spin_lock = xen_spin_lock;
582 pv_lock_ops.spin_trylock = xen_spin_trylock;
583 pv_lock_ops.spin_unlock = xen_spin_unlock;
584}
585
586static const struct smp_ops xen_smp_ops __initdata = { 469static const struct smp_ops xen_smp_ops __initdata = {
587 .smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu, 470 .smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu,
588 .smp_prepare_cpus = xen_smp_prepare_cpus, 471 .smp_prepare_cpus = xen_smp_prepare_cpus,
589 .cpu_up = xen_cpu_up,
590 .smp_cpus_done = xen_smp_cpus_done, 472 .smp_cpus_done = xen_smp_cpus_done,
591 473
474 .cpu_up = xen_cpu_up,
475 .cpu_die = xen_cpu_die,
476 .cpu_disable = xen_cpu_disable,
477 .play_dead = xen_play_dead,
478
592 .smp_send_stop = xen_smp_send_stop, 479 .smp_send_stop = xen_smp_send_stop,
593 .smp_send_reschedule = xen_smp_send_reschedule, 480 .smp_send_reschedule = xen_smp_send_reschedule,
594 481
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
new file mode 100644
index 000000000000..dd71e3a021cd
--- /dev/null
+++ b/arch/x86/xen/spinlock.c
@@ -0,0 +1,428 @@
1/*
2 * Split spinlock implementation out into its own file, so it can be
3 * compiled in a FTRACE-compatible way.
4 */
5#include <linux/kernel_stat.h>
6#include <linux/spinlock.h>
7#include <linux/debugfs.h>
8#include <linux/log2.h>
9
10#include <asm/paravirt.h>
11
12#include <xen/interface/xen.h>
13#include <xen/events.h>
14
15#include "xen-ops.h"
16#include "debugfs.h"
17
18#ifdef CONFIG_XEN_DEBUG_FS
19static struct xen_spinlock_stats
20{
21 u64 taken;
22 u32 taken_slow;
23 u32 taken_slow_nested;
24 u32 taken_slow_pickup;
25 u32 taken_slow_spurious;
26 u32 taken_slow_irqenable;
27
28 u64 released;
29 u32 released_slow;
30 u32 released_slow_kicked;
31
32#define HISTO_BUCKETS 30
33 u32 histo_spin_total[HISTO_BUCKETS+1];
34 u32 histo_spin_spinning[HISTO_BUCKETS+1];
35 u32 histo_spin_blocked[HISTO_BUCKETS+1];
36
37 u64 time_total;
38 u64 time_spinning;
39 u64 time_blocked;
40} spinlock_stats;
41
42static u8 zero_stats;
43
44static unsigned lock_timeout = 1 << 10;
45#define TIMEOUT lock_timeout
46
47static inline void check_zero(void)
48{
49 if (unlikely(zero_stats)) {
50 memset(&spinlock_stats, 0, sizeof(spinlock_stats));
51 zero_stats = 0;
52 }
53}
54
55#define ADD_STATS(elem, val) \
56 do { check_zero(); spinlock_stats.elem += (val); } while(0)
57
58static inline u64 spin_time_start(void)
59{
60 return xen_clocksource_read();
61}
62
63static void __spin_time_accum(u64 delta, u32 *array)
64{
65 unsigned index = ilog2(delta);
66
67 check_zero();
68
69 if (index < HISTO_BUCKETS)
70 array[index]++;
71 else
72 array[HISTO_BUCKETS]++;
73}
74
75static inline void spin_time_accum_spinning(u64 start)
76{
77 u32 delta = xen_clocksource_read() - start;
78
79 __spin_time_accum(delta, spinlock_stats.histo_spin_spinning);
80 spinlock_stats.time_spinning += delta;
81}
82
83static inline void spin_time_accum_total(u64 start)
84{
85 u32 delta = xen_clocksource_read() - start;
86
87 __spin_time_accum(delta, spinlock_stats.histo_spin_total);
88 spinlock_stats.time_total += delta;
89}
90
91static inline void spin_time_accum_blocked(u64 start)
92{
93 u32 delta = xen_clocksource_read() - start;
94
95 __spin_time_accum(delta, spinlock_stats.histo_spin_blocked);
96 spinlock_stats.time_blocked += delta;
97}
98#else /* !CONFIG_XEN_DEBUG_FS */
99#define TIMEOUT (1 << 10)
100#define ADD_STATS(elem, val) do { (void)(val); } while(0)
101
102static inline u64 spin_time_start(void)
103{
104 return 0;
105}
106
107static inline void spin_time_accum_total(u64 start)
108{
109}
110static inline void spin_time_accum_spinning(u64 start)
111{
112}
113static inline void spin_time_accum_blocked(u64 start)
114{
115}
116#endif /* CONFIG_XEN_DEBUG_FS */
117
118struct xen_spinlock {
119 unsigned char lock; /* 0 -> free; 1 -> locked */
120 unsigned short spinners; /* count of waiting cpus */
121};
122
123static int xen_spin_is_locked(struct raw_spinlock *lock)
124{
125 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
126
127 return xl->lock != 0;
128}
129
130static int xen_spin_is_contended(struct raw_spinlock *lock)
131{
132 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
133
134 /* Not strictly true; this is only the count of contended
135 lock-takers entering the slow path. */
136 return xl->spinners != 0;
137}
138
139static int xen_spin_trylock(struct raw_spinlock *lock)
140{
141 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
142 u8 old = 1;
143
144 asm("xchgb %b0,%1"
145 : "+q" (old), "+m" (xl->lock) : : "memory");
146
147 return old == 0;
148}
149
150static DEFINE_PER_CPU(int, lock_kicker_irq) = -1;
151static DEFINE_PER_CPU(struct xen_spinlock *, lock_spinners);
152
153/*
154 * Mark a cpu as interested in a lock. Returns the CPU's previous
155 * lock of interest, in case we got preempted by an interrupt.
156 */
157static inline struct xen_spinlock *spinning_lock(struct xen_spinlock *xl)
158{
159 struct xen_spinlock *prev;
160
161 prev = __get_cpu_var(lock_spinners);
162 __get_cpu_var(lock_spinners) = xl;
163
164 wmb(); /* set lock of interest before count */
165
166 asm(LOCK_PREFIX " incw %0"
167 : "+m" (xl->spinners) : : "memory");
168
169 return prev;
170}
171
172/*
173 * Mark a cpu as no longer interested in a lock. Restores previous
174 * lock of interest (NULL for none).
175 */
176static inline void unspinning_lock(struct xen_spinlock *xl, struct xen_spinlock *prev)
177{
178 asm(LOCK_PREFIX " decw %0"
179 : "+m" (xl->spinners) : : "memory");
180 wmb(); /* decrement count before restoring lock */
181 __get_cpu_var(lock_spinners) = prev;
182}
183
184static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enable)
185{
186 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
187 struct xen_spinlock *prev;
188 int irq = __get_cpu_var(lock_kicker_irq);
189 int ret;
190 unsigned long flags;
191 u64 start;
192
193 /* If kicker interrupts not initialized yet, just spin */
194 if (irq == -1)
195 return 0;
196
197 start = spin_time_start();
198
199 /* announce we're spinning */
200 prev = spinning_lock(xl);
201
202 flags = __raw_local_save_flags();
203 if (irq_enable) {
204 ADD_STATS(taken_slow_irqenable, 1);
205 raw_local_irq_enable();
206 }
207
208 ADD_STATS(taken_slow, 1);
209 ADD_STATS(taken_slow_nested, prev != NULL);
210
211 do {
212 /* clear pending */
213 xen_clear_irq_pending(irq);
214
215 /* check again make sure it didn't become free while
216 we weren't looking */
217 ret = xen_spin_trylock(lock);
218 if (ret) {
219 ADD_STATS(taken_slow_pickup, 1);
220
221 /*
222 * If we interrupted another spinlock while it
223 * was blocking, make sure it doesn't block
224 * without rechecking the lock.
225 */
226 if (prev != NULL)
227 xen_set_irq_pending(irq);
228 goto out;
229 }
230
231 /*
232 * Block until irq becomes pending. If we're
233 * interrupted at this point (after the trylock but
234 * before entering the block), then the nested lock
235 * handler guarantees that the irq will be left
236 * pending if there's any chance the lock became free;
237 * xen_poll_irq() returns immediately if the irq is
238 * pending.
239 */
240 xen_poll_irq(irq);
241 ADD_STATS(taken_slow_spurious, !xen_test_irq_pending(irq));
242 } while (!xen_test_irq_pending(irq)); /* check for spurious wakeups */
243
244 kstat_this_cpu.irqs[irq]++;
245
246out:
247 raw_local_irq_restore(flags);
248 unspinning_lock(xl, prev);
249 spin_time_accum_blocked(start);
250
251 return ret;
252}
253
254static inline void __xen_spin_lock(struct raw_spinlock *lock, bool irq_enable)
255{
256 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
257 unsigned timeout;
258 u8 oldval;
259 u64 start_spin;
260
261 ADD_STATS(taken, 1);
262
263 start_spin = spin_time_start();
264
265 do {
266 u64 start_spin_fast = spin_time_start();
267
268 timeout = TIMEOUT;
269
270 asm("1: xchgb %1,%0\n"
271 " testb %1,%1\n"
272 " jz 3f\n"
273 "2: rep;nop\n"
274 " cmpb $0,%0\n"
275 " je 1b\n"
276 " dec %2\n"
277 " jnz 2b\n"
278 "3:\n"
279 : "+m" (xl->lock), "=q" (oldval), "+r" (timeout)
280 : "1" (1)
281 : "memory");
282
283 spin_time_accum_spinning(start_spin_fast);
284
285 } while (unlikely(oldval != 0 &&
286 (TIMEOUT == ~0 || !xen_spin_lock_slow(lock, irq_enable))));
287
288 spin_time_accum_total(start_spin);
289}
290
291static void xen_spin_lock(struct raw_spinlock *lock)
292{
293 __xen_spin_lock(lock, false);
294}
295
296static void xen_spin_lock_flags(struct raw_spinlock *lock, unsigned long flags)
297{
298 __xen_spin_lock(lock, !raw_irqs_disabled_flags(flags));
299}
300
301static noinline void xen_spin_unlock_slow(struct xen_spinlock *xl)
302{
303 int cpu;
304
305 ADD_STATS(released_slow, 1);
306
307 for_each_online_cpu(cpu) {
308 /* XXX should mix up next cpu selection */
309 if (per_cpu(lock_spinners, cpu) == xl) {
310 ADD_STATS(released_slow_kicked, 1);
311 xen_send_IPI_one(cpu, XEN_SPIN_UNLOCK_VECTOR);
312 break;
313 }
314 }
315}
316
317static void xen_spin_unlock(struct raw_spinlock *lock)
318{
319 struct xen_spinlock *xl = (struct xen_spinlock *)lock;
320
321 ADD_STATS(released, 1);
322
323 smp_wmb(); /* make sure no writes get moved after unlock */
324 xl->lock = 0; /* release lock */
325
326 /* make sure unlock happens before kick */
327 barrier();
328
329 if (unlikely(xl->spinners))
330 xen_spin_unlock_slow(xl);
331}
332
333static irqreturn_t dummy_handler(int irq, void *dev_id)
334{
335 BUG();
336 return IRQ_HANDLED;
337}
338
339void __cpuinit xen_init_lock_cpu(int cpu)
340{
341 int irq;
342 const char *name;
343
344 name = kasprintf(GFP_KERNEL, "spinlock%d", cpu);
345 irq = bind_ipi_to_irqhandler(XEN_SPIN_UNLOCK_VECTOR,
346 cpu,
347 dummy_handler,
348 IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
349 name,
350 NULL);
351
352 if (irq >= 0) {
353 disable_irq(irq); /* make sure it's never delivered */
354 per_cpu(lock_kicker_irq, cpu) = irq;
355 }
356
357 printk("cpu %d spinlock event irq %d\n", cpu, irq);
358}
359
360void xen_uninit_lock_cpu(int cpu)
361{
362 unbind_from_irqhandler(per_cpu(lock_kicker_irq, cpu), NULL);
363}
364
365void __init xen_init_spinlocks(void)
366{
367 pv_lock_ops.spin_is_locked = xen_spin_is_locked;
368 pv_lock_ops.spin_is_contended = xen_spin_is_contended;
369 pv_lock_ops.spin_lock = xen_spin_lock;
370 pv_lock_ops.spin_lock_flags = xen_spin_lock_flags;
371 pv_lock_ops.spin_trylock = xen_spin_trylock;
372 pv_lock_ops.spin_unlock = xen_spin_unlock;
373}
374
375#ifdef CONFIG_XEN_DEBUG_FS
376
377static struct dentry *d_spin_debug;
378
379static int __init xen_spinlock_debugfs(void)
380{
381 struct dentry *d_xen = xen_init_debugfs();
382
383 if (d_xen == NULL)
384 return -ENOMEM;
385
386 d_spin_debug = debugfs_create_dir("spinlocks", d_xen);
387
388 debugfs_create_u8("zero_stats", 0644, d_spin_debug, &zero_stats);
389
390 debugfs_create_u32("timeout", 0644, d_spin_debug, &lock_timeout);
391
392 debugfs_create_u64("taken", 0444, d_spin_debug, &spinlock_stats.taken);
393 debugfs_create_u32("taken_slow", 0444, d_spin_debug,
394 &spinlock_stats.taken_slow);
395 debugfs_create_u32("taken_slow_nested", 0444, d_spin_debug,
396 &spinlock_stats.taken_slow_nested);
397 debugfs_create_u32("taken_slow_pickup", 0444, d_spin_debug,
398 &spinlock_stats.taken_slow_pickup);
399 debugfs_create_u32("taken_slow_spurious", 0444, d_spin_debug,
400 &spinlock_stats.taken_slow_spurious);
401 debugfs_create_u32("taken_slow_irqenable", 0444, d_spin_debug,
402 &spinlock_stats.taken_slow_irqenable);
403
404 debugfs_create_u64("released", 0444, d_spin_debug, &spinlock_stats.released);
405 debugfs_create_u32("released_slow", 0444, d_spin_debug,
406 &spinlock_stats.released_slow);
407 debugfs_create_u32("released_slow_kicked", 0444, d_spin_debug,
408 &spinlock_stats.released_slow_kicked);
409
410 debugfs_create_u64("time_spinning", 0444, d_spin_debug,
411 &spinlock_stats.time_spinning);
412 debugfs_create_u64("time_blocked", 0444, d_spin_debug,
413 &spinlock_stats.time_blocked);
414 debugfs_create_u64("time_total", 0444, d_spin_debug,
415 &spinlock_stats.time_total);
416
417 xen_debugfs_create_u32_array("histo_total", 0444, d_spin_debug,
418 spinlock_stats.histo_spin_total, HISTO_BUCKETS + 1);
419 xen_debugfs_create_u32_array("histo_spinning", 0444, d_spin_debug,
420 spinlock_stats.histo_spin_spinning, HISTO_BUCKETS + 1);
421 xen_debugfs_create_u32_array("histo_blocked", 0444, d_spin_debug,
422 spinlock_stats.histo_spin_blocked, HISTO_BUCKETS + 1);
423
424 return 0;
425}
426fs_initcall(xen_spinlock_debugfs);
427
428#endif /* CONFIG_XEN_DEBUG_FS */
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 685b77470fc3..004ba86326ae 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -30,8 +30,6 @@
30#define TIMER_SLOP 100000 30#define TIMER_SLOP 100000
31#define NS_PER_TICK (1000000000LL / HZ) 31#define NS_PER_TICK (1000000000LL / HZ)
32 32
33static cycle_t xen_clocksource_read(void);
34
35/* runstate info updated by Xen */ 33/* runstate info updated by Xen */
36static DEFINE_PER_CPU(struct vcpu_runstate_info, runstate); 34static DEFINE_PER_CPU(struct vcpu_runstate_info, runstate);
37 35
@@ -213,7 +211,7 @@ unsigned long xen_tsc_khz(void)
213 return xen_khz; 211 return xen_khz;
214} 212}
215 213
216static cycle_t xen_clocksource_read(void) 214cycle_t xen_clocksource_read(void)
217{ 215{
218 struct pvclock_vcpu_time_info *src; 216 struct pvclock_vcpu_time_info *src;
219 cycle_t ret; 217 cycle_t ret;
@@ -452,6 +450,14 @@ void xen_setup_timer(int cpu)
452 setup_runstate_info(cpu); 450 setup_runstate_info(cpu);
453} 451}
454 452
453void xen_teardown_timer(int cpu)
454{
455 struct clock_event_device *evt;
456 BUG_ON(cpu == 0);
457 evt = &per_cpu(xen_clock_events, cpu);
458 unbind_from_irqhandler(evt->irq, NULL);
459}
460
455void xen_setup_cpu_clockevents(void) 461void xen_setup_cpu_clockevents(void)
456{ 462{
457 BUG_ON(preemptible()); 463 BUG_ON(preemptible());
diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
index 2497a30f41de..42786f59d9c0 100644
--- a/arch/x86/xen/xen-asm_32.S
+++ b/arch/x86/xen/xen-asm_32.S
@@ -298,7 +298,7 @@ check_events:
298 push %eax 298 push %eax
299 push %ecx 299 push %ecx
300 push %edx 300 push %edx
301 call force_evtchn_callback 301 call xen_force_evtchn_callback
302 pop %edx 302 pop %edx
303 pop %ecx 303 pop %ecx
304 pop %eax 304 pop %eax
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index 7f58304fafb3..05794c566e87 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -26,8 +26,15 @@
26/* Pseudo-flag used for virtual NMI, which we don't implement yet */ 26/* Pseudo-flag used for virtual NMI, which we don't implement yet */
27#define XEN_EFLAGS_NMI 0x80000000 27#define XEN_EFLAGS_NMI 0x80000000
28 28
29#if 0 29#if 1
30#include <asm/percpu.h> 30/*
31 x86-64 does not yet support direct access to percpu variables
32 via a segment override, so we just need to make sure this code
33 never gets used
34 */
35#define BUG ud2a
36#define PER_CPU_VAR(var, off) 0xdeadbeef
37#endif
31 38
32/* 39/*
33 Enable events. This clears the event mask and tests the pending 40 Enable events. This clears the event mask and tests the pending
@@ -35,6 +42,8 @@
35 events, then enter the hypervisor to get them handled. 42 events, then enter the hypervisor to get them handled.
36 */ 43 */
37ENTRY(xen_irq_enable_direct) 44ENTRY(xen_irq_enable_direct)
45 BUG
46
38 /* Unmask events */ 47 /* Unmask events */
39 movb $0, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask) 48 movb $0, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask)
40 49
@@ -58,6 +67,8 @@ ENDPATCH(xen_irq_enable_direct)
58 non-zero. 67 non-zero.
59 */ 68 */
60ENTRY(xen_irq_disable_direct) 69ENTRY(xen_irq_disable_direct)
70 BUG
71
61 movb $1, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask) 72 movb $1, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask)
62ENDPATCH(xen_irq_disable_direct) 73ENDPATCH(xen_irq_disable_direct)
63 ret 74 ret
@@ -74,6 +85,8 @@ ENDPATCH(xen_irq_disable_direct)
74 Xen and x86 use opposite senses (mask vs enable). 85 Xen and x86 use opposite senses (mask vs enable).
75 */ 86 */
76ENTRY(xen_save_fl_direct) 87ENTRY(xen_save_fl_direct)
88 BUG
89
77 testb $0xff, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask) 90 testb $0xff, PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask)
78 setz %ah 91 setz %ah
79 addb %ah,%ah 92 addb %ah,%ah
@@ -91,6 +104,8 @@ ENDPATCH(xen_save_fl_direct)
91 if so. 104 if so.
92 */ 105 */
93ENTRY(xen_restore_fl_direct) 106ENTRY(xen_restore_fl_direct)
107 BUG
108
94 testb $X86_EFLAGS_IF>>8, %ah 109 testb $X86_EFLAGS_IF>>8, %ah
95 setz PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask) 110 setz PER_CPU_VAR(xen_vcpu_info, XEN_vcpu_info_mask)
96 /* Preempt here doesn't matter because that will deal with 111 /* Preempt here doesn't matter because that will deal with
@@ -122,7 +137,7 @@ check_events:
122 push %r9 137 push %r9
123 push %r10 138 push %r10
124 push %r11 139 push %r11
125 call force_evtchn_callback 140 call xen_force_evtchn_callback
126 pop %r11 141 pop %r11
127 pop %r10 142 pop %r10
128 pop %r9 143 pop %r9
@@ -133,7 +148,6 @@ check_events:
133 pop %rcx 148 pop %rcx
134 pop %rax 149 pop %rax
135 ret 150 ret
136#endif
137 151
138ENTRY(xen_adjust_exception_frame) 152ENTRY(xen_adjust_exception_frame)
139 mov 8+0(%rsp),%rcx 153 mov 8+0(%rsp),%rcx
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index dd3c23152a2e..d7422dc2a55c 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -2,6 +2,7 @@
2#define XEN_OPS_H 2#define XEN_OPS_H
3 3
4#include <linux/init.h> 4#include <linux/init.h>
5#include <linux/clocksource.h>
5#include <linux/irqreturn.h> 6#include <linux/irqreturn.h>
6#include <xen/xen-ops.h> 7#include <xen/xen-ops.h>
7 8
@@ -31,7 +32,10 @@ void xen_vcpu_restore(void);
31 32
32void __init xen_build_dynamic_phys_to_machine(void); 33void __init xen_build_dynamic_phys_to_machine(void);
33 34
35void xen_init_irq_ops(void);
34void xen_setup_timer(int cpu); 36void xen_setup_timer(int cpu);
37void xen_teardown_timer(int cpu);
38cycle_t xen_clocksource_read(void);
35void xen_setup_cpu_clockevents(void); 39void xen_setup_cpu_clockevents(void);
36unsigned long xen_tsc_khz(void); 40unsigned long xen_tsc_khz(void);
37void __init xen_time_init(void); 41void __init xen_time_init(void);
@@ -50,6 +54,10 @@ void __init xen_setup_vcpu_info_placement(void);
50#ifdef CONFIG_SMP 54#ifdef CONFIG_SMP
51void xen_smp_init(void); 55void xen_smp_init(void);
52 56
57void __init xen_init_spinlocks(void);
58__cpuinit void xen_init_lock_cpu(int cpu);
59void xen_uninit_lock_cpu(int cpu);
60
53extern cpumask_t xen_cpu_initialized_map; 61extern cpumask_t xen_cpu_initialized_map;
54#else 62#else
55static inline void xen_smp_init(void) {} 63static inline void xen_smp_init(void) {}